| 67 | //----------------------------------------------------------------------------- |
| 68 | |
| 69 | SimObject* TamlXmlReader::parseElement( TiXmlElement* pXmlElement ) |
| 70 | { |
| 71 | // Debug Profiling. |
| 72 | PROFILE_SCOPE(TamlXmlReader_ParseElement); |
| 73 | |
| 74 | SimObject* pSimObject = NULL; |
| 75 | |
| 76 | // Fetch element name. |
| 77 | StringTableEntry typeName = StringTable->insert( pXmlElement->Value() ); |
| 78 | |
| 79 | // Fetch reference to Id. |
| 80 | const U32 tamlRefToId = getTamlRefToId( pXmlElement ); |
| 81 | |
| 82 | // Do we have a reference to Id? |
| 83 | if ( tamlRefToId != 0 ) |
| 84 | { |
| 85 | // Yes, so fetch reference. |
| 86 | typeObjectReferenceHash::Iterator referenceItr = mObjectReferenceMap.find( tamlRefToId ); |
| 87 | |
| 88 | // Did we find the reference? |
| 89 | if ( referenceItr == mObjectReferenceMap.end() ) |
| 90 | { |
| 91 | // No, so warn. |
| 92 | Con::warnf( "Taml: Could not find a reference Id of '%d'", tamlRefToId ); |
| 93 | return NULL; |
| 94 | } |
| 95 | |
| 96 | // Return object. |
| 97 | return referenceItr->value; |
| 98 | } |
| 99 | |
| 100 | // No, so fetch reference Id. |
| 101 | const U32 tamlRefId = getTamlRefId( pXmlElement ); |
| 102 | |
| 103 | #ifdef TORQUE_DEBUG |
| 104 | // Format the type location. |
| 105 | char typeLocationBuffer[64]; |
| 106 | dSprintf( typeLocationBuffer, sizeof(typeLocationBuffer), "Taml [format='xml' row=%d column=%d]", pXmlElement->Row(), pXmlElement->Column() ); |
| 107 | |
| 108 | // Create type. |
| 109 | pSimObject = Taml::createType( typeName, mpTaml, typeLocationBuffer ); |
| 110 | #else |
| 111 | // Create type. |
| 112 | pSimObject = Taml::createType( typeName, mpTaml ); |
| 113 | #endif |
| 114 | |
| 115 | |
| 116 | // Finish if we couldn't create the type. |
| 117 | if ( pSimObject == NULL ) |
| 118 | return NULL; |
| 119 | |
| 120 | // Find Taml callbacks. |
| 121 | TamlCallbacks* pCallbacks = dynamic_cast<TamlCallbacks*>( pSimObject ); |
| 122 | |
| 123 | // Are there any Taml callbacks? |
| 124 | if ( pCallbacks != NULL ) |
| 125 | { |
| 126 | // Yes, so call it. |
nothing calls this directly
no test coverage detected