MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / FindFunction

Method FindFunction

neo/d3xp/script/Script_Program.cpp:1508–1550  ·  view source on GitHub ↗

================ idProgram::FindFunction Searches for the specified function in the currently loaded script. A full namespace should be specified if not in the global namespace. Returns 0 if function not found. Returns >0 if function found. ================ */

Source from the content-addressed store, hash-verified

1506================
1507*/
1508function_t *idProgram::FindFunction( const char *name ) const {
1509 int start;
1510 int pos;
1511 idVarDef *namespaceDef;
1512 idVarDef *def;
1513
1514 assert( name );
1515
1516 idStr fullname = name;
1517 start = 0;
1518 namespaceDef = &def_namespace;
1519 do {
1520 pos = fullname.Find( "::", true, start );
1521 if ( pos < 0 ) {
1522 break;
1523 }
1524
1525 idStr namespaceName = fullname.Mid( start, pos - start );
1526 def = GetDef( NULL, namespaceName, namespaceDef );
1527 if ( !def ) {
1528 // couldn't find namespace
1529 return NULL;
1530 }
1531 namespaceDef = def;
1532
1533 // skip past the ::
1534 start = pos + 2;
1535 } while( def->Type() == ev_namespace );
1536
1537 idStr funcName = fullname.Right( fullname.Length() - start );
1538 def = GetDef( NULL, funcName, namespaceDef );
1539 if ( !def ) {
1540 // couldn't find function
1541 return NULL;
1542 }
1543
1544 if ( ( def->Type() == ev_function ) && ( def->value.functionPtr->eventdef == NULL ) ) {
1545 return def->value.functionPtr;
1546 }
1547
1548 // is not a function, or is an eventdef
1549 return NULL;
1550}
1551
1552/*
1553================

Callers 15

NextMapMethod · 0.45
InitScriptForMapMethod · 0.45
SpawnEntityDefMethod · 0.45
LoadScriptMethod · 0.45
RestoreMethod · 0.45
HandleGuiCommandsMethod · 0.45
SpawnMethod · 0.45
ThinkMethod · 0.45
RestoreMethod · 0.45
SpawnMethod · 0.45
SpawnMethod · 0.45
Event_OnSignalMethod · 0.45

Calls 7

MidMethod · 0.80
FindMethod · 0.45
TypeMethod · 0.45
RightMethod · 0.45
LengthMethod · 0.45
SuperClassMethod · 0.45
TypeDefMethod · 0.45

Tested by

no test coverage detected