| 613 | } |
| 614 | |
| 615 | int CScriptBuilder::Build() |
| 616 | { |
| 617 | int r = module->Build(); |
| 618 | if( r < 0 ) |
| 619 | return r; |
| 620 | |
| 621 | #if AS_PROCESS_METADATA == 1 |
| 622 | // After the script has been built, the metadata strings should be |
| 623 | // stored for later lookup by function id, type id, and variable index |
| 624 | for( int n = 0; n < (int)foundDeclarations.size(); n++ ) |
| 625 | { |
| 626 | SMetadataDecl *decl = &foundDeclarations[n]; |
| 627 | module->SetDefaultNamespace(decl->nameSpace.c_str()); |
| 628 | if( decl->type == MDT_TYPE ) |
| 629 | { |
| 630 | // Find the type id |
| 631 | int typeId = module->GetTypeIdByDecl(decl->declaration.c_str()); |
| 632 | assert( typeId >= 0 ); |
| 633 | if( typeId >= 0 ) |
| 634 | typeMetadataMap.insert(map<int, vector<string> >::value_type(typeId, decl->metadata)); |
| 635 | } |
| 636 | else if( decl->type == MDT_FUNC ) |
| 637 | { |
| 638 | if( decl->parentClass == "" ) |
| 639 | { |
| 640 | // Find the function id |
| 641 | asIScriptFunction *func = module->GetFunctionByDecl(decl->declaration.c_str()); |
| 642 | assert( func ); |
| 643 | if( func ) |
| 644 | funcMetadataMap.insert(map<int, vector<string> >::value_type(func->GetId(), decl->metadata)); |
| 645 | } |
| 646 | else |
| 647 | { |
| 648 | // Find the method id |
| 649 | int typeId = module->GetTypeIdByDecl(decl->parentClass.c_str()); |
| 650 | assert( typeId > 0 ); |
| 651 | map<int, SClassMetadata>::iterator it = classMetadataMap.find(typeId); |
| 652 | if( it == classMetadataMap.end() ) |
| 653 | { |
| 654 | classMetadataMap.insert(map<int, SClassMetadata>::value_type(typeId, SClassMetadata(decl->parentClass))); |
| 655 | it = classMetadataMap.find(typeId); |
| 656 | } |
| 657 | |
| 658 | asITypeInfo *type = engine->GetTypeInfoById(typeId); |
| 659 | asIScriptFunction *func = type->GetMethodByDecl(decl->declaration.c_str()); |
| 660 | assert( func ); |
| 661 | if( func ) |
| 662 | it->second.funcMetadataMap.insert(map<int, vector<string> >::value_type(func->GetId(), decl->metadata)); |
| 663 | } |
| 664 | } |
| 665 | else if( decl->type == MDT_VIRTPROP ) |
| 666 | { |
| 667 | if( decl->parentClass == "" ) |
| 668 | { |
| 669 | // Find the global virtual property accessors |
| 670 | asIScriptFunction *func = module->GetFunctionByName(("get_" + decl->declaration).c_str()); |
| 671 | if( func ) |
| 672 | funcMetadataMap.insert(map<int, vector<string> >::value_type(func->GetId(), decl->metadata)); |
nothing calls this directly
no test coverage detected