=================== idDeclManagerLocal::FindTypeWithoutParsing This finds or creats the decl, but does not cause a parse. This is only used internally. =================== */
| 1704 | =================== |
| 1705 | */ |
| 1706 | idDeclLocal *idDeclManagerLocal::FindTypeWithoutParsing( declType_t type, const char *name, bool makeDefault ) { |
| 1707 | int typeIndex = (int)type; |
| 1708 | int i, hash; |
| 1709 | |
| 1710 | if ( typeIndex < 0 || typeIndex >= declTypes.Num() || declTypes[typeIndex] == NULL ) { |
| 1711 | common->FatalError( "idDeclManager::FindTypeWithoutParsing: bad type: %i", typeIndex ); |
| 1712 | } |
| 1713 | |
| 1714 | char canonicalName[MAX_STRING_CHARS]; |
| 1715 | |
| 1716 | MakeNameCanonical( name, canonicalName, sizeof( canonicalName ) ); |
| 1717 | |
| 1718 | // see if it already exists |
| 1719 | hash = hashTables[typeIndex].GenerateKey( canonicalName, false ); |
| 1720 | for ( i = hashTables[typeIndex].First( hash ); i >= 0; i = hashTables[typeIndex].Next( i ) ) { |
| 1721 | if ( linearLists[typeIndex][i]->name.Icmp( canonicalName ) == 0 ) { |
| 1722 | // only print these when decl_show is set to 2, because it can be a lot of clutter |
| 1723 | if ( decl_show.GetInteger() > 1 ) { |
| 1724 | MediaPrint( "referencing %s %s\n", declTypes[ type ]->typeName.c_str(), name ); |
| 1725 | } |
| 1726 | return linearLists[typeIndex][i]; |
| 1727 | } |
| 1728 | } |
| 1729 | |
| 1730 | if ( !makeDefault ) { |
| 1731 | return NULL; |
| 1732 | } |
| 1733 | |
| 1734 | idDeclLocal *decl = new idDeclLocal; |
| 1735 | decl->self = NULL; |
| 1736 | decl->name = canonicalName; |
| 1737 | decl->type = type; |
| 1738 | decl->declState = DS_UNPARSED; |
| 1739 | decl->textSource = NULL; |
| 1740 | decl->textLength = 0; |
| 1741 | decl->sourceFile = &implicitDecls; |
| 1742 | decl->referencedThisLevel = false; |
| 1743 | decl->everReferenced = false; |
| 1744 | decl->parsedOutsideLevelLoad = !insideLevelLoad; |
| 1745 | |
| 1746 | // add it to the linear list and hash table |
| 1747 | decl->index = linearLists[typeIndex].Num(); |
| 1748 | hashTables[typeIndex].Add( hash, linearLists[typeIndex].Append( decl ) ); |
| 1749 | |
| 1750 | return decl; |
| 1751 | } |
| 1752 | |
| 1753 | |
| 1754 | /* |
no test coverage detected