• Advertisement


  • Content count

  • Joined

  • Last visited

Everything posted by saejox

  1. asPEEK, HTML remote debugger

    Hi, I made a remote debugger using websockets, with a silly name [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Console debugger wasn't cutting it anymore. integration is quite painless. runs in its own thread, my game had no fps drops. this a about 2 weeks work. there are probably many unforeseen bugs. everyone utilizes angelscript uniquely. There is a windows binary demo in Downloads section. Hope you like it. Thanks. [url="https://bitbucket.org/saejox/aspeek"]https://bitbucket.org/saejox/aspeek[/url] [attachment=11904:asPEEK.png]
  2. 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.
  3. CScriptArray::Destruct

    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
  4. 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());
  5. 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 }
  6. CScriptArray::Destruct

    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
  7. 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.
  8. 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 :)
  9. 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.
  10. Parsing expression with functions -- AS vs boost

    ExecuteString function in ScriptHelper addon seems to be what you are look for.   http://www.angelcode.com/angelscript/sdk/docs/manual/doc_addon_helpers.html#doc_addon_helpers_1
  11. 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. :)
  12. 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.
  13. 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; }        
  14. 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?
  15. 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 :)
  16. 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 :(
  17. AngelScript 2.26.1

    Thanks, i understand. I thought that's a bug. opAssign would do nicely.     I have another small question,   Why is scriptany addon implemented as GC collected ? Wouldn't a value type be enough. I'm not a pro at garbage collection sorry for my noobiness :) .
  18. AngelScript 2.26.1

    Sorry, it seems i deleted the question while tagging the code. Let me rewrite a better one       Does this mean if i have constructor for a type like this "any(int val)" then i can call this? any foo = 42;   I looked in tests folder but could not find new tests for this feature. It's committed in rev1568 but there are no new tests. Implementing it like this did not give any fruit.   int r = engine->RegisterObjectType("any", sizeof(Any), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);assert(r >= 0);    r = engine->RegisterObjectBehaviour("any", asBEHAVE_CONSTRUCT, "void f(uint)", asFUNCTIONPR(Any::CreateAny, (unsigned int, Any*),void), asCALL_CDECL_OBJLAST); assert(r >= 0); compile error: There is not copy operator for the type any available Adding an opAssign method works tho.   Thanks!
  19. AngelScript 2.26.1

    any foo = 42;
  20. The dictionary class

    No. Lua tables are the result of Lua being a prototypical language. It's not possible to have dictionaries that hold varying types.   You can sort of emulate it with dictionary addon and any addon. Not pretty tho.
  21. Passing reference as parameter

    SetArgObject works just fine. Please post some code.
  22. AngelScript 2.26.0 is out

    Thank you Frictional Games and Thank you Andreas Jonsson.
  23. auto as C++0x

    I think i can live without built-in containers. Still, i just feel addon's are not the same. VM could do much better job. Compiler time optimization, better memory layout, avoid unnecessary ref counting, weak iterators etc.. Anyway, that's what i think. I can't even write a simple parser. My suggestions are probably worthless :)   Delegates and multiple subtypes are going to be revolutionizing. I will rewrite half my AngelScript code. Can wait :D
  24. auto as C++0x

    That's an interesting use of mixins :) I didn't go beyond code reuse and separating same class in multiple files.   I have just read your ideas page. I thought i should make a list myself. :)   1. Function pointers and function objects 2. Template objects with multiple subtypes 3. Inheritance from registered classes. Without this your whole program design changes, it sucks. 4. Closures/Anonymous functions/Lambdas. Functional programming is the best. 5. Builtin array, set and maps. Everyone needs them, why are they addons. They can still be optional, but builtin is a must. If they are builtin i can finally write some AngelScript only programs. I can write a 1000 word essay how important built-in containers are for a language. 6. Static functions. Great for organization. 7. Generic handle. like ref addon but supports all types and can implicitly convert. 8. Varidic functions. Or functions with argument array. void MyFunction(args). Would be easy with #7 9. Type comparison. if( typeof(my_int) == int ). This may even be a switch/select statement. Useless without #8 10. Unsafe keyword. Mark functions and objects to be free of garbage collection. Also warn user of the dangers. Maybe go crazy with pointers. 11. new and delete. Unmanaged memory for all types. ( would be double awesome with unsafe keyword) 12. Stateful functions. With a keyword like 'yield' . Pause execution, resume when called by other later. Script languages are great for stuff like this. 13. Reflection. No not as powerful as js or lua. At least functions like createClass .addMethod("func()") .invoke("func")   These are just stuff i like, no need for a feedback. You are likely very busy.
  25. auto as C++0x

    I used to think type inference would be a great addition to AngelScript. As i used it more and more in C++, i have turned around. I see two problems with it.   1. AngelScript does not have templates or generics. It doesn't have nested classes neither. It's not possible to create conventional iterators. Auto is practically useless without long type names to infer.   2. Auto is not magic. You still need to determine if it's an handle, reference or value. This is a great source of confusion, unwanted constructor/destructor calls and bunch of other nasty bugs.
  • Advertisement