mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Add console function to link namespaces
This commit is contained in:
parent
561e26ea07
commit
a22254ad0a
1 changed files with 41 additions and 0 deletions
|
|
@ -834,3 +834,44 @@ DefineEngineFunction( sizeof, S32, ( const char *objectOrClass ),,
|
||||||
Con::warnf("could not find a class rep for that object or class name.");
|
Con::warnf("could not find a class rep for that object or class name.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DefineEngineFunction(linkNamespaces, bool, ( String childNSName, String parentNSName ),,
|
||||||
|
"@brief Links childNS to parentNS.\n\n"
|
||||||
|
"Links childNS to parentNS, or nothing if parentNS is NULL.\n"
|
||||||
|
"Will unlink the namespace from previous namespace if a parent already exists.\n"
|
||||||
|
"@internal\n")
|
||||||
|
{
|
||||||
|
StringTableEntry childNSSTE = StringTable->insert(childNSName.c_str());
|
||||||
|
StringTableEntry parentNSSTE = StringTable->insert(parentNSName.c_str());
|
||||||
|
|
||||||
|
Namespace *childNS = Namespace::find(childNSSTE);
|
||||||
|
Namespace *parentNS = Namespace::find(parentNSSTE);
|
||||||
|
Namespace *currentParent = childNS->getParent();
|
||||||
|
|
||||||
|
if (!childNS)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Link to new NS if applicable
|
||||||
|
|
||||||
|
if (currentParent != parentNS)
|
||||||
|
{
|
||||||
|
if (currentParent != NULL)
|
||||||
|
{
|
||||||
|
if (!childNS->unlinkClass(currentParent))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parentNS != NULL)
|
||||||
|
{
|
||||||
|
return childNS->classLinkTo(parentNS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue