| 549 | } |
| 550 | |
| 551 | int CScriptBuilder::Build() |
| 552 | { |
| 553 | int r = module->Build(); |
| 554 | if( r < 0 ) |
| 555 | return r; |
| 556 | |
| 557 | #if AS_PROCESS_METADATA == 1 |
| 558 | // After the script has been built, the metadata strings should be |
| 559 | // stored for later lookup by function id, type id, and variable index |
| 560 | for( int n = 0; n < (int)foundDeclarations.size(); n++ ) |
| 561 | { |
| 562 | SMetadataDecl *decl = &foundDeclarations[n]; |
| 563 | module->SetDefaultNamespace(decl->nameSpace.c_str()); |
| 564 | if( decl->type == MDT_TYPE ) |
| 565 | { |
| 566 | // Find the type id |
| 567 | int typeId = module->GetTypeIdByDecl(decl->declaration.c_str()); |
| 568 | assert( typeId >= 0 ); |
| 569 | if( typeId >= 0 ) |
| 570 | typeMetadataMap.insert(map<int, vector<string>>::value_type(typeId, decl->metadata)); |
| 571 | } |
| 572 | else if( decl->type == MDT_FUNC ) |
| 573 | { |
| 574 | if( decl->parentClass == "" ) |
| 575 | { |
| 576 | // Find the function id |
| 577 | asIScriptFunction *func = module->GetFunctionByDecl(decl->declaration.c_str()); |
| 578 | assert( func ); |
| 579 | if( func ) |
| 580 | funcMetadataMap.insert(map<int, vector<string>>::value_type(func->GetId(), decl->metadata)); |
| 581 | } |
| 582 | else |
| 583 | { |
| 584 | // Find the method id |
| 585 | int typeId = module->GetTypeIdByDecl(decl->parentClass.c_str()); |
| 586 | assert( typeId > 0 ); |
| 587 | map<int, SClassMetadata>::iterator it = classMetadataMap.find(typeId); |
| 588 | if( it == classMetadataMap.end() ) |
| 589 | { |
| 590 | classMetadataMap.insert(map<int, SClassMetadata>::value_type(typeId, SClassMetadata(decl->parentClass))); |
| 591 | it = classMetadataMap.find(typeId); |
| 592 | } |
| 593 | |
| 594 | asITypeInfo *type = engine->GetTypeInfoById(typeId); |
| 595 | asIScriptFunction *func = type->GetMethodByDecl(decl->declaration.c_str()); |
| 596 | assert( func ); |
| 597 | if( func ) |
| 598 | it->second.funcMetadataMap.insert(map<int, vector<string>>::value_type(func->GetId(), decl->metadata)); |
| 599 | } |
| 600 | } |
| 601 | else if( decl->type == MDT_VIRTPROP ) |
| 602 | { |
| 603 | if( decl->parentClass == "" ) |
| 604 | { |
| 605 | // Find the global virtual property accessors |
| 606 | asIScriptFunction *func = module->GetFunctionByName(("get_" + decl->declaration).c_str()); |
| 607 | if( func ) |
| 608 | funcMetadataMap.insert(map<int, vector<string>>::value_type(func->GetId(), decl->metadata)); |
nothing calls this directly
no test coverage detected