Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

714 Good

About saejox

  • Rank
  1. saejox

    Global Variable Initialization Context

    What i mean is you can't add variables to context and make them available to function. SetUserData is just to associate it some of your own c++ object, just a convenience method.   If you have one module per script file than you should use globals. They are belong to module they are created. If not use script classes, your c++ class owns a asIScriptObject then you can operate on that.
  2. saejox


    edit:   Ok i am sorry, i just did the math for real this time. You are right. I should have rushed to answer without checking my facts :)   A script object handle has mask of asTYPEID_MASK_OBJECT | asTYPEID_OBJHANDLE An c++ object handle has mask of asTYPEID_APPOBJECT | asTYPEID_OBJHANDLE   I don't think there is anything wrong with if( subTypeId & asTYPEID_MASK_OBJECT ). It doesn't care about handles because all handles are asTYPEID_APPOBJECT or asTYPEID_MASK_OBJECT or asTYPEID_TEMPLATE . There aren't any handle types that doesn't fit those 3. No such thing as pure asTYPEID_OBJHANDLE
  3. saejox

    Global Variable Initialization Context

    Contexts do not have special storage for executing function to access. You should use classes. Associate your C++ objects with script classes then you have what you need.   Get module of the current function.  (wrote this from memory might be a syntax error) asIScriptModule *mod =  asGetActiveContext()->GetEngine()->GetModule(asGetActiveContext()->GetCurrentFunction()->GetModuleName());
  4. saejox

    Object Handle vs Object reference

    They are very different. You cant assign a reference for example. Handle is a safe refcounted/garbage collected pointer, ( like shared_ptr in c++ but safer ) Reference is same as reference in c++ but not assignable.   void Func( Object &obj ) {    Object &o = obj; // not possible in angelscript }
  5. saejox


    It's a binary mask. You can check its value in angelscript.h. If a type is asTYPEID_OBJHANDLE then it's a asTYPEID_MASK_OBJECT.   asTYPEID_MASK_OBJECT = asTYPEID_OBJHANDLE | asTYPEID_SCRIPTOBJECT | asTYPEID_APPOBJECT
  6. saejox

    passing class/function to asMETHOD

    You are just storing void* and expecting C++ to call correct function. C++ can not call the correct function just with a void*.   There was a project called AngelBinder, google it. What you want is doable, but require advanced c++ templates knowledge.
  7. saejox

    Delegates are fully working now

    Okay, i understand. Not a big issue. I knew it was far stretch anyways.   I think i will name them using their signatures. an example: AddEvent(FrameEnded, FrameEndedDelegate(func)); but this also has a variant that gives takes a float. so i need to find another meaningful name. Like AddEvent(FrameEnded, FrameEndedDelegateWithTimePassed(func)); This gets too complex for my taste. if i were to name it based on signature then i don't need to remember just formulate its name from the signature of the bound function. That function the one she wrote, she can figure delegate name easily. Another thing when the delegate name is typed wrong since there are too many overloads of the AddEvent resulting error message is not helpful. One more is that i can generate funcdef declarations using a simple for loop, fn_void_void, fn_void_int, fn_void_float etc... Saves me typing and figuring out clever names for each delegate. Like a poor man's template :P   Since, i have no real experience with named delegates. Maybe i will be doing wrong. Time will tell :)
  8. saejox

    Delegates are fully working now

    Hi, its me again :)   Will delegates support implicit conversion from functions and methods? At the moment I'm very conflicted if i should add funcdefs like this: fn_void_int_float . Because its very hard to remember all those delegate names. I have less than 10 and still forget the correct one. I do suck at memorizing stuff :D Autocomplete ruined me i guess.
  9. saejox

    Parsing expression with functions -- AS vs boost

    ExecuteString function in ScriptHelper addon seems to be what you are look for.
  10. saejox

    Delegates are fully working now

    That works. Thank you. First multiple subtypes, now delegates. AngelScript started 2013 very strongly. I need to rewrite significant portion of my game now. :)
  11. saejox

    Delegates are fully working now

    Ok, i forgot not all script objects needs to be GC'd.     I have crash during compilation caused by  overloaded methods:   class Object {   void Method(Object @obj){obj.a++;}   void Method(){}   int a = 1; } int main() {   Object @obj = Object();   GetFunctionPtr(@Callback(obj.Method));   obj.a++;   return 1; }   Registration: void GetFunctionPtr(asIScriptFunction *func) {...} r = engine->RegisterFuncdef("void Callback()"); assert(r>=0); r = engine->RegisterGlobalFunction("void GetFunctionPtr(Callback@)", asFUNCTION(GetFunctionPtr), asCALL_CDECL); assert(r>=0); Crashing in module compilation. at line 8122 as_compiler.cpp. bestMethod is null.
  12. saejox

    Delegates are fully working now

    Calling the delegate works. :)   Other questions: asIScriptFunction has objForDelegate but no public method to get it. In some cases i would prefer to hold method pointer and object pointer separately.     objForDelegate has refCount of 2. Wouldn't it need to be 3? ( gc, script scope, delegate) class Object { void Method(){}   int a = 1; } int main() {   Object @obj = Object();   GetFunctionPtr(@Callback(obj.Method));   obj.a++;   return 1; }        
  13. saejox

    Delegates are fully working now

    Nice.   Question:   How do i register functions accepting delegates as parameters. funcdef void CALLBACK(); class Foo {   void Bar() { counter++; }   void counter = 0; } events.Add(CALLBACK(f.Bar)); How does RegisterObjectMethod look? Does it accept asIScriptFunction*? Do i have to increase refcount myself?
  14. saejox

    AngelScript 2.26.1

      I think i can write a 8 bytes any for both 64bits and 32bits. That wouldn't be slow to copy. I'll write a value type any and benchmark it :)
  15. saejox

    General purpose void* addon

    I had the same urge. But in time it became apparent that people are pretty bad at following simple guidelines.   I have added unsafe iterators for my containers to allow faster find-delete. Put up real nice documentation about how it would crash if it's invalidated. Almost immediately someone invalidated iterators. And i got the blame of writing bad code :(
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!