Advertisement

Disabling global handles

Started by September 20, 2010 05:53 AM
1 comment, last by cvet 14 years, 2 months ago
Can be possible add feature for disabling storing some classes in global scope?
Example:
C++// asOBJ_NO_GLOBAL - new modifierengine->RegisterObjectType("MyClass",0,asOBJ_REF|asOBJ_NO_GLOBAL);AngelScriptMyClass@ global; // Errorvoid func(MyClass& local){} // Okvoid main(){MyClass@ local=GetMyObject();} // Ok

This need for multithreading synchronization, because object locks before script function call and unlocks after. But if user store it in global scope than this object can not be locked in next time.
You can easily enumerate the global variables and check if the script tries to store something there that it shouldn't be allowed to.

int errorOnTypeId = engine->GetTypeIdByDecl("MyClass");asIScriptModule *mod = engine->GetModule("my module");for( int n = 0; n < mod->GetGlobalVarCount(); n++ ){  int typeId = mod->GetGlobalVarTypeId(n);  if( typeId == errorOnTypeId )  {    string msg;    msg = "The global variable '" + string(mod->GetGlobalVarName(n)) + "' uses a type that cannot be stored globally";    engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, msg.c_str());  }}


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
I think do enumerating in runtime, but now see what i can do it in compile time.
Thanks for help.

This topic is closed to new replies.

Advertisement