| 1852 | //----------------------------------------------------------------------------- |
| 1853 | |
| 1854 | void SimObject::linkNamespaces() |
| 1855 | { |
| 1856 | // Don't link if we already have a namespace linkage in place. |
| 1857 | // If you want to change namespace linking, first call unlinkNamespaces() |
| 1858 | // while still having the class namespace fields matching the current |
| 1859 | // setup. |
| 1860 | |
| 1861 | if (mNameSpace) |
| 1862 | { |
| 1863 | Con::warnf("SimObject::linkNamespaces -- Namespace linkage already in place %s", mNameSpace->getName()); |
| 1864 | return; |
| 1865 | } |
| 1866 | // Get the namespace for the C++ class. |
| 1867 | |
| 1868 | Namespace* cppNamespace = getClassRep()->getNameSpace(); |
| 1869 | |
| 1870 | // Parent namespace defaults to namespace of C++ class. |
| 1871 | |
| 1872 | Namespace* parentNamespace = cppNamespace; |
| 1873 | |
| 1874 | // Perform superclass linking, if requested. |
| 1875 | |
| 1876 | if( mSuperClassName && mSuperClassName[ 0 ] ) |
| 1877 | { |
| 1878 | // Look up the superclass namespace. |
| 1879 | |
| 1880 | Namespace* superClassNamespace = Con::lookupNamespace( mSuperClassName ); |
| 1881 | |
| 1882 | // If packages are active and adding to the superclass namespace, then we will |
| 1883 | // have multiple packages in a parent chain that all have the same name. |
| 1884 | // Con::lookupNamespace returns the bottom-most package in the chain to us so |
| 1885 | // in order to properly link namespace here without conflicting with the package |
| 1886 | // mechanism, we need to properly link child namespaces to the bottom-most namespace |
| 1887 | // while linking parent namespaces to the topmost namespace. To find the latter |
| 1888 | // one, we walk up the hierarchy here. |
| 1889 | |
| 1890 | Namespace* superClassNamespacePackageRoot = superClassNamespace->getPackageRoot(); |
| 1891 | |
| 1892 | // Link the superclass namespace to the C++ class namespace. |
| 1893 | |
| 1894 | if( superClassNamespacePackageRoot->getParent() == NULL ) |
| 1895 | { |
| 1896 | // The superclass namespace isn't linked yet so we just |
| 1897 | // link it to the C++ class namespace and make that our parent. |
| 1898 | // No increasing parent reference counts is needed in this case. |
| 1899 | |
| 1900 | bool ok = superClassNamespacePackageRoot->classLinkTo( cppNamespace ); |
| 1901 | AssertFatal( ok, "SimObject::linkNamespaces - failed to link new namespace to c++ class name" ); |
| 1902 | parentNamespace = superClassNamespace; |
| 1903 | } |
| 1904 | else |
| 1905 | { |
| 1906 | // In debug builds, make sure the namespace hierarchy that's been |
| 1907 | // put into place actually makes sense and leads back to the C++ |
| 1908 | // class namespace. |
| 1909 | |
| 1910 | #ifdef TORQUE_DEBUG |
| 1911 |
nothing calls this directly
no test coverage detected