MCPcopy Create free account
hub / github.com/anjo76/angelscript / Build

Method Build

sdk/add_on/scriptbuilder/scriptbuilder.cpp:615–805  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615int 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));

Callers

nothing calls this directly

Calls 15

SClassMetadataClass · 0.85
GetFunctionByDeclMethod · 0.80
GetIdMethod · 0.80
findMethod · 0.80
endMethod · 0.80
GetTypeInfoByIdMethod · 0.80
GetFunctionByNameMethod · 0.80
sizeMethod · 0.45
SetDefaultNamespaceMethod · 0.45
GetTypeIdByDeclMethod · 0.45
GetMethodByDeclMethod · 0.45

Tested by

no test coverage detected