internal
| 1482 | |
| 1483 | // internal |
| 1484 | int asCScriptEngine::GetFactoryIdByDecl(const asCObjectType *ot, const char *decl) |
| 1485 | { |
| 1486 | asCModule *mod = 0; |
| 1487 | |
| 1488 | // Is this a script class? |
| 1489 | if( (ot->flags & asOBJ_SCRIPT_OBJECT) && ot->size > 0 ) |
| 1490 | mod = scriptFunctions[ot->beh.factories[0]]->module; |
| 1491 | |
| 1492 | asCBuilder bld(this, mod); |
| 1493 | |
| 1494 | // Don't write parser errors to the message callback |
| 1495 | bld.silent = true; |
| 1496 | |
| 1497 | asCScriptFunction func(this, mod, asFUNC_DUMMY); |
| 1498 | int r = bld.ParseFunctionDeclaration(0, decl, &func, false, 0, 0, defaultNamespace); |
| 1499 | if( r < 0 ) |
| 1500 | return asINVALID_DECLARATION; |
| 1501 | |
| 1502 | // Search for matching factory function |
| 1503 | int id = -1; |
| 1504 | for( asUINT n = 0; n < ot->beh.factories.GetLength(); n++ ) |
| 1505 | { |
| 1506 | asCScriptFunction *f = scriptFunctions[ot->beh.factories[n]]; |
| 1507 | |
| 1508 | // We don't really care if the name of the function is correct |
| 1509 | if( f->IsSignatureExceptNameEqual(&func) ) |
| 1510 | { |
| 1511 | id = ot->beh.factories[n]; |
| 1512 | break; |
| 1513 | } |
| 1514 | } |
| 1515 | |
| 1516 | if( id == -1 ) return asNO_FUNCTION; |
| 1517 | |
| 1518 | return id; |
| 1519 | } |
| 1520 | |
| 1521 | |
| 1522 | // internal |
no test coverage detected