MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / addVariable

Method addVariable

Engine/source/console/consoleInternal.cpp:615–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615Dictionary::Entry* Dictionary::addVariable(const char *name,
616 S32 type,
617 void *dataPtr,
618 const char* usage)
619{
620 AssertFatal(type >= 0, "Dictionary::addVariable - Got bad type!");
621
622 if (name[0] != '$')
623 {
624 scratchBuffer[0] = '$';
625 dStrcpy(scratchBuffer + 1, name, 1023);
626 name = scratchBuffer;
627 }
628
629 Entry *ent = add(StringTable->insert(name));
630
631 if (ent->type <= Entry::TypeInternalString && ent->sval != NULL)
632 dFree(ent->sval);
633
634 ent->mUsage = usage;
635 ent->type = type;
636 ent->dataPtr = dataPtr;
637
638 // Fetch enum table, if any.
639 ConsoleBaseType* conType = ConsoleBaseType::getType(type);
640 AssertFatal(conType, "Dictionary::addVariable - invalid console type");
641 ent->enumTable = conType->getEnumTable();
642
643 return ent;
644}
645
646bool Dictionary::removeVariable(StringTableEntry name)
647{

Callers 2

addVariableFunction · 0.45
addConstantFunction · 0.45

Calls 6

dStrcpyFunction · 0.85
getTypeFunction · 0.85
addFunction · 0.50
dFreeFunction · 0.50
insertMethod · 0.45
getEnumTableMethod · 0.45

Tested by

no test coverage detected