MCPcopy Create free account
hub / github.com/anjo76/angelscript / ParseFunctionDeclaration

Method ParseFunctionDeclaration

sdk/angelscript/source/as_builder.cpp:1313–1526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1311}
1312
1313int asCBuilder::ParseFunctionDeclaration(asCObjectType *objType, const char *decl, asCScriptFunction *func, bool isSystemFunction, asCArray<bool> *paramAutoHandles, bool *returnAutoHandle, asSNameSpace *ns, asCScriptNode **listPattern, asCObjectType **outParentClass)
1314{
1315 asASSERT( objType || ns );
1316
1317 if (listPattern)
1318 *listPattern = 0;
1319 if (outParentClass)
1320 *outParentClass = 0;
1321
1322 // TODO: Can't we use GetParsedFunctionDetails to do most of what is done in this function?
1323
1324 Reset();
1325
1326 asCScriptCode source;
1327 source.SetCode(TXT_SYSTEM_FUNCTION, decl, true);
1328
1329 asCParser parser(this);
1330 int r = parser.ParseFunctionDefinition(&source, listPattern != 0);
1331 if( r < 0 )
1332 return asINVALID_DECLARATION;
1333
1334 asCScriptNode *node = parser.GetScriptNode();
1335
1336 // Determine scope
1337 asCScriptNode *n = node->firstChild->next->next;
1338 asCObjectType *parentClass = 0;
1339 func->nameSpace = GetNameSpaceFromNode(n, &source, ns, &n, &parentClass);
1340 if( func->nameSpace == 0 && parentClass == 0 )
1341 return asINVALID_DECLARATION;
1342 if (parentClass && func->funcType != asFUNC_FUNCDEF)
1343 return asINVALID_DECLARATION;
1344
1345 if (outParentClass)
1346 *outParentClass = parentClass;
1347
1348 // Find name
1349 func->name.Assign(&source.code[n->tokenPos], n->tokenLength);
1350
1351 // Handle templates
1352 asCScriptNode* tmp = n;
1353 bool isTemplate = false;
1354 while(tmp->next->nodeType != snParameterList)
1355 {
1356 asCString name(decl + tmp->next->tokenPos, tmp->next->tokenLength);
1357 asCTypeInfo* templSubType = engine->GetTemplateSubTypeByName(name);
1358 if (templSubType == 0)
1359 return asOUT_OF_MEMORY;
1360
1361 func->templateSubTypes.PushLast(asCDataType::CreateType(templSubType,false));
1362 templSubType->AddRefInternal();
1363 isTemplate = true;
1364 tmp = tmp->next;
1365 }
1366
1367 // Initialize a script function object for registration
1368 bool autoHandle;
1369
1370 // Scoped reference types are allowed to use handle when returned from application functions

Callers 10

GetFactoryIdByDeclMethod · 0.80
GetMethodIdByDeclMethod · 0.80
RegisterFuncdefMethod · 0.80
GetFunctionByDeclMethod · 0.80

Calls 15

asCStringClass · 0.85
SetCodeMethod · 0.80
GetScriptNodeMethod · 0.80
AssignMethod · 0.80
PushLastMethod · 0.80
IsObjectHandleMethod · 0.80
GetTypeInfoMethod · 0.80
GetTokenTypeMethod · 0.80
SetVariadicMethod · 0.80
SetReadOnlyMethod · 0.80

Tested by

no test coverage detected