Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uint32_t count = module->GetObjectTypeCount();
- for(uint32_t i = 0; i < count; i++)
- {
- // Get the type for the class
- auto type = module->GetObjectTypeByIndex(i);
- // Get metadata for the class
- std::vector<std::string> metadata = builder.GetMetadataForType(type->GetTypeId());
- for(auto meta : metadata)
- {
- // The metadata equals IServer so its our main server class
- if(meta != "IServer") continue;
- // Create an instance
- auto factory = type->GetFactoryByIndex(0);
- context->Prepare(factory);
- context->Execute();
- asIScriptObject* obj = *(asIScriptObject**)context->GetAddressOfReturnValue();
- obj->AddRef();
- // Store our instance on the resource
- mainScriptClass = obj;
- // Get all methods and check their metadata
- for(uint32_t n = 0; n < type->GetMethodCount(); n++)
- {
- auto method = type->GetMethodByIndex(n, false);
- // Get metadata for the method
- std::vector<std::string> methodMetas = builder.GetMetadataForTypeMethod(type->GetTypeId(), method);
- Log::Info << methodMetas.size() << Log::Endl;
- for(auto methodMeta : methodMetas)
- {
- Log::Info << methodMeta << Log::Endl;
- // Get the event associated with the metadata
- Event* event = Event::GetByMetadata(methodMeta);
- if(event == nullptr) continue;
- // Store the event on the method
- method->SetUserData(event);
- }
- }
- // We are done so we break out of all the loops and return
- goto done;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement