mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/code] Clean ScriptNode
This commit is contained in:
@@ -12,25 +12,21 @@ public:
|
||||
Function,
|
||||
Variable
|
||||
};
|
||||
ScriptNode() :
|
||||
m_type(Type::Function), m_name(nullptr), m_scriptIndex(0), m_nameLength(0) {}
|
||||
static ScriptNode FunctionNode(const char * name, int nameLength, uint16_t scriptIndex) {
|
||||
return ScriptNode(Type::Function, name, scriptIndex, nameLength);
|
||||
}
|
||||
static ScriptNode VariableNode(const char * name, int nameLength, uint16_t scriptIndex) {
|
||||
return ScriptNode(Type::Variable, name, scriptIndex, nameLength);
|
||||
}
|
||||
ScriptNode(Type type = Type::Variable, const char * name = nullptr, int nameLength = 0, uint16_t scriptIndex = 0) :
|
||||
m_type(type),
|
||||
m_name(name),
|
||||
m_scriptIndex(scriptIndex),
|
||||
m_nameLength(nameLength)
|
||||
{}
|
||||
Type type() const { return m_type; }
|
||||
const char * name() const { return m_name; }
|
||||
int nameLength() const { return m_nameLength; }
|
||||
uint16_t scriptIndex() const { return m_scriptIndex; }
|
||||
private:
|
||||
ScriptNode(Type type, const char * name, uint16_t scriptIndex, int nameLength) :
|
||||
m_type(type), m_name(name), m_scriptIndex(scriptIndex), m_nameLength(nameLength) {}
|
||||
Type m_type;
|
||||
const char * m_name;
|
||||
uint16_t m_scriptIndex;
|
||||
int m_nameLength;
|
||||
uint16_t m_scriptIndex; // TODO LEA smaller type ?
|
||||
int m_nameLength; // TODO LEA smaller type ?
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -198,8 +198,7 @@ void VariableBoxController::loadFunctionsAndVariables(int scriptIndex, const cha
|
||||
};
|
||||
assert(sizeof(builtinNames) / sizeof(builtinNames[0]) == k_totalBuiltinNodesCount);
|
||||
for (int i = 0; i < k_totalBuiltinNodesCount; i++) {
|
||||
// TODO remove those two constructors
|
||||
ScriptNode node = builtinNames[i].type == ScriptNode::Type::Function ? ScriptNode::FunctionNode( builtinNames[i].name, -1, 0) : ScriptNode::VariableNode(builtinNames[i].name, -1, 0);
|
||||
ScriptNode node = ScriptNode(builtinNames[i].type, builtinNames[i].name, -1, 0);
|
||||
int startsWith = textToAutocomplete == nullptr ? 0 : NodeNameStartsWith(&node, textToAutocomplete, textToAutocompleteLength);
|
||||
if (startsWith == 0) {
|
||||
m_builtinNodes[m_builtinNodesCount++] = node;
|
||||
@@ -454,9 +453,7 @@ void VariableBoxController::addNode(ScriptNode::Type type, NodeOrigin origin, co
|
||||
nodes[i+1] = nodes[i];
|
||||
}
|
||||
// Add the node
|
||||
nodes[insertionIndex] = type == ScriptNode::Type::Variable ?
|
||||
ScriptNode::VariableNode(name, nameLength, scriptIndex) :
|
||||
ScriptNode::FunctionNode(name, nameLength, scriptIndex);
|
||||
nodes[insertionIndex] = ScriptNode(type, name, nameLength, scriptIndex);
|
||||
// Increase the node count
|
||||
*currentNodeCount = *currentNodeCount + 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user