| 1311 | } |
| 1312 | |
| 1313 | int 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 |
no test coverage detected