internal
| 1334 | |
| 1335 | // internal |
| 1336 | int asCModule::AddImportedFunction(int id, const asCString &funcName, const asCDataType &returnType, const asCArray<asCDataType> ¶ms, const asCArray<asETypeModifiers> &inOutFlags, const asCArray<asCString *> &defaultArgs, asSFunctionTraits funcTraits, asSNameSpace *ns, const asCString &moduleName) |
| 1337 | { |
| 1338 | asASSERT(id >= 0); |
| 1339 | |
| 1340 | // Store the function information |
| 1341 | asCScriptFunction *func = asNEW(asCScriptFunction)(m_engine, this, asFUNC_IMPORTED); |
| 1342 | if( func == 0 ) |
| 1343 | { |
| 1344 | // Free the default args |
| 1345 | for( asUINT n = 0; n < defaultArgs.GetLength(); n++ ) |
| 1346 | if( defaultArgs[n] ) |
| 1347 | asDELETE(defaultArgs[n], asCString); |
| 1348 | |
| 1349 | return asOUT_OF_MEMORY; |
| 1350 | } |
| 1351 | |
| 1352 | func->name = funcName; |
| 1353 | func->id = id; |
| 1354 | func->returnType = returnType; |
| 1355 | func->nameSpace = ns; |
| 1356 | func->parameterTypes = params; |
| 1357 | func->inOutFlags = inOutFlags; |
| 1358 | func->defaultArgs = defaultArgs; |
| 1359 | func->objectType = 0; |
| 1360 | func->traits = funcTraits; |
| 1361 | |
| 1362 | sBindInfo *info = asNEW(sBindInfo); |
| 1363 | if( info == 0 ) |
| 1364 | { |
| 1365 | asDELETE(func, asCScriptFunction); |
| 1366 | return asOUT_OF_MEMORY; |
| 1367 | } |
| 1368 | |
| 1369 | info->importedFunctionSignature = func; |
| 1370 | info->boundFunctionId = -1; |
| 1371 | info->importFromModule = moduleName; |
| 1372 | m_bindInformations.PushLast(info); |
| 1373 | |
| 1374 | // Add the info to the array in the engine |
| 1375 | if( m_engine->freeImportedFunctionIdxs.GetLength() ) |
| 1376 | m_engine->importedFunctions[m_engine->freeImportedFunctionIdxs.PopLast()] = info; |
| 1377 | else |
| 1378 | m_engine->importedFunctions.PushLast(info); |
| 1379 | |
| 1380 | return 0; |
| 1381 | } |
| 1382 | #endif |
| 1383 | |
| 1384 | // internal |
no test coverage detected