Skip to content

Commit

Permalink
20544: Fixes issues where setting labels could yield erroneous result…
Browse files Browse the repository at this point in the history
…s, primarily when called directly via API (#151)
  • Loading branch information
howsohazard authored Jun 13, 2024
1 parent 3efc0c3 commit f9ca283
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
2 changes: 2 additions & 0 deletions src/Amalgam/entity/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ bool Entity::SetValueAtLabel(StringInternPool::StringID label_sid, EvaluableNode
//copy over the existing node, but don't update labels, etc.
destination->CopyValueFrom(new_value);
}
//the value is being used in the entity, so no longer unique if it was before
new_value.unique = false;
}
else //direct set
{
Expand Down
44 changes: 0 additions & 44 deletions src/Amalgam/entity/EntityExternalInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,50 +169,6 @@ std::vector<std::string> EntityExternalInterface::GetEntities()
return entities;
}

EvaluableNode *NodifyNumberList(Entity *entity, double *arr, size_t len)
{
EvaluableNodeManager *enm = &entity->evaluableNodeManager;
EvaluableNode *list_node = enm->AllocNode(ENT_LIST);
auto &children = list_node->GetOrderedChildNodes();
children.resize(len);
for(size_t i = 0; i < len; i++)
children[i] = enm->AllocNode(arr[i]);

return list_node;
}

EvaluableNode *NodifyNumberMatrix(Entity *entity, double *arr, size_t w, size_t h)
{
EvaluableNodeManager *enm = &entity->evaluableNodeManager;
EvaluableNode *matrix_node = enm->AllocNode(ENT_LIST);

auto &children = matrix_node->GetOrderedChildNodes();
children.resize(w);
for(size_t x = 0; x < w; x++)
{
double *column = new double[h];
for(size_t y = 0; y < h; y++)
column[y] = arr[x*h + y];

children[x] = NodifyNumberList(entity, column, h);
delete [] column;
}

return matrix_node;
}

EvaluableNode *NodifyStringList(Entity *entity, char **arr, size_t len)
{
EvaluableNodeManager *enm = &entity->evaluableNodeManager;
EvaluableNode *list_node = enm->AllocNode(ENT_LIST);
auto &children = list_node->GetOrderedChildNodes();
children.resize(len);
for(size_t i = 0; i < len; i++)
children[i] = enm->AllocNode(ENT_STRING, arr[i]);

return list_node;
}

bool EntityExternalInterface::SetJSONToLabel(std::string &handle, std::string &label, std::string_view json)
{
auto bundle = FindEntityBundle(handle);
Expand Down

0 comments on commit f9ca283

Please sign in to comment.