MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / linkNamespaces

Method linkNamespaces

Engine/source/console/simObject.cpp:1708–1852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1706//-----------------------------------------------------------------------------
1707
1708void SimObject::linkNamespaces()
1709{
1710 // Don't link if we already have a namespace linkage in place.
1711 // If you want to change namespace linking, first call unlinkNamespaces()
1712 // while still having the class namespace fields matching the current
1713 // setup.
1714
1715 if (mNameSpace)
1716 {
1717 Con::warnf("SimObject::linkNamespaces -- Namespace linkage already in place %s", mNameSpace->getName());
1718 return;
1719 }
1720 // Get the namespace for the C++ class.
1721
1722 Namespace* cppNamespace = getClassRep()->getNameSpace();
1723
1724 // Parent namespace defaults to namespace of C++ class.
1725
1726 Namespace* parentNamespace = cppNamespace;
1727
1728 // Perform superclass linking, if requested.
1729
1730 if( mSuperClassName && mSuperClassName[ 0 ] )
1731 {
1732 // Look up the superclass namespace.
1733
1734 Namespace* superClassNamespace = Con::lookupNamespace( mSuperClassName );
1735
1736 // If packages are active and adding to the superclass namespace, then we will
1737 // have multiple packages in a parent chain that all have the same name.
1738 // Con::lookupNamespace returns the bottom-most package in the chain to us so
1739 // in order to properly link namespace here without conflicting with the package
1740 // mechanism, we need to properly link child namespaces to the bottom-most namespace
1741 // while linking parent namespaces to the topmost namespace. To find the latter
1742 // one, we walk up the hierarchy here.
1743
1744 Namespace* superClassNamespacePackageRoot = superClassNamespace->getPackageRoot();
1745
1746 // Link the superclass namespace to the C++ class namespace.
1747
1748 if( superClassNamespacePackageRoot->getParent() == NULL )
1749 {
1750 // The superclass namespace isn't linked yet so we just
1751 // link it to the C++ class namespace and make that our parent.
1752 // No increasing parent reference counts is needed in this case.
1753
1754 bool ok = superClassNamespacePackageRoot->classLinkTo( cppNamespace );
1755 AssertFatal( ok, "SimObject::linkNamespaces - failed to link new namespace to c++ class name" );
1756 parentNamespace = superClassNamespace;
1757 }
1758 else
1759 {
1760 // In debug builds, make sure the namespace hierarchy that's been
1761 // put into place actually makes sense and leads back to the C++
1762 // class namespace.
1763
1764#ifdef TORQUE_DEBUG
1765

Callers

nothing calls this directly

Calls 11

warnfFunction · 0.85
lookupNamespaceFunction · 0.85
errorfFunction · 0.85
getNameSpaceMethod · 0.80
getPackageRootMethod · 0.80
classLinkToMethod · 0.80
getPackageMethod · 0.80
incRefCountToParentMethod · 0.80
getNameFunction · 0.50
getNameMethod · 0.45
getParentMethod · 0.45

Tested by

no test coverage detected