Jump to content
  • Advertisement

Marcus L

Member
  • Content Count

    14
  • Joined

  • Last visited

Community Reputation

235 Neutral

About Marcus L

  • Rank
    Member
  1. Marcus L

    Question regarding 'private' keyword

    Yes, in my opinion that would be a great addition to an already excellent scripting engine! And having it as an option allows for those who don't need it to disable the feature (or vise-versa) (and yes, I saw that thread and immediately felt a little guilty for opening a new one, sorry!)
  2. Hi there,   I stumbled upon an issue with using the 'private' keyword in my application. It seems AngelScript doesn't mind when I access private members from derived classes, however accessing private functions from derived classes yields an error of type: "ERR : Illegal call to private method". I see that this is mentioned in the manual and is expected behavior. However my question is why the engine won't allow private methods to get called, as it would be more consistent, and in tune with C++/Java's 'protected' keyword. As it stands it acts like a mix of 'private' and 'protected', and can cause confusion. The real reason I'm in need of this myself is because want to have private 'init' functions (for my serializer), which also act polymorphically. As it stands this turned out to be difficult without modifying the engine (although I did manage to hack together a solution which has yet to crash). My solution for those interested: I changed: if( descr->isPrivate && descr->GetObjectType() != outFunc->GetObjectType() ) to if( descr->isPrivate && descr->GetObjectType() != outFunc->GetObjectType() && !outFunc->GetObjectType()->DerivesFrom(descr->GetObjectType()) ) in as_compiler.cpp: void asCCompiler::PerformFunctionCall Whats your thought on the matter?   Thanks in advance! EDIT: Pressing tab apparenty posted my unfinished post
  3. Marcus L

    A quite specific bug

    Hi again So continuing down the road that is circular references, I've now stumbled upon what I suspect is a awfully specific bug. I've created this simple example to illustrate: (I'm here using your any-addon, array-addon and grid-addon)   // Dummy class. class B {} class A { any a; grid<B> t(10, 10); // Using a dummy class here, because apparently using primitives doesn't crash the application. A() { a.store(@this); } } // Global array of A-handles array<A@> arr; void main() { arr.insertLast(@A()); } (This time I haven't modified the add-on files, I promise !)   This code will cause a crash when I try to release the script engine. If you're curious what the specific crash I get is; it's at line 708 in CScriptGrid::EnumReferences (because buffer = 0).   Adding a if(buffer == 0) return; at the begining fixes it, but that seems more like a hack to me Thanks in advance!
  4. Marcus L

    Problem with Circular References

    No problem . Sorry if I caused you any headaches!
  5. Marcus L

    Problem with Circular References

    Never mind. Seems it was a mistake on my part (had modified the EnumReferences callback ). Mods may delete this thread if they wish (the manual answered all my remaining questions).
  6. Marcus L

    Problem with Circular References

    Hi again So, I've stumbled across a strange issue with circular references. It seems AngelScript doesn't like it when I feed a member variable a reference to its owner (not too surprising, all things considered). Here is an example of what I mean: (I'm using the "any object"-addon in this example) class A { any test; A() { test.store(@this); } } void main() { A a(); } After running this code, I get the following error messages as I exit my application: ERR: (0, 0) : ERR : Object {4}. GC cannot destroy an object of type 'A' as it doesn't know how many references to there are. ERR: (0, 0) : ERR : Object {5}. GC cannot destroy an object of type 'any' as it can't see all references. Current ref count is 1. ERR: (0, 0) : ERR : Object {76}. GC cannot destroy an object of type '_builtin_objecttype_' as it can't see all references. Current ref count is 2. INFO: (0, 0) : INFO : The builtin type in previous message is named 'A' While this doesn't actually cause any memory leaks as far as I can tell, I still suspect this might lead to problems. I have tried to call scriptEngine->GarbageCollect(asGC_FULL_CYCLE) before scirptEngine->Release(), same result. So now I'm wondering what might be causing this. Is this expected behavior perhaps? (I'm using AngelScript 2.29.0 btw)
  7. Marcus L

    Android - virtual function call issue

    Hah, nice . Tested the revision, and it worked in the emulator! Thanks for your help Andreas!
  8. Marcus L

    Android - virtual function call issue

    Oh sorry, Fixed it, I didn't have this in my original code though. (the wrath of the copy-paste ...)
  9. Marcus L

    Android - virtual function call issue

    As far as my investigation goes, it appears it only happens to functions which are registered using asCALL_THISCALL_ASGLOBAL. I tested asCALL_THISCALL with a simple reference type class, and it worked just fine. I even tested what would happen if I registered a global property of type Derived, then called a virtual function of Base registered with asCALL_THISCALL, and it still worked. So the issue seems to be specifically regarding asCALL_THISCALL_ASGLOBAL, when calling a method at an object which inherits another (EDIT: also tested now; the derived object doesn't even have to implement any virtual function for it to crash). Here is an updated and corrected sample which will produce the crash:   class Base { public: virtual void printA() { LOGI("Base: PrintA called"); } virtual void printB() { LOGI("Base: PrintB called"); } }; class Derived : public Base { public: void printA() { LOGI("Derived: PrintA called"); } }; // ... registering part Derived *derived = new Derived(); Base *base = static_cast<Base*>(derived); scriptEngine->RegisterGlobalFunction("void printA()", asMETHOD(Base, printA), asCALL_THISCALL_ASGLOBAL, base); scriptEngine->RegisterGlobalFunction("void printB()", asMETHOD(Base, printB), asCALL_THISCALL_ASGLOBAL, base); Both printA and printB will crash. Thanks again for your help!
  10. Marcus L

    Android - virtual function call issue

    Okay, so I changed my register calls to the following:   scriptEngine->RegisterGlobalFunction("void printA()", asMETHOD(Derived, printA), asCALL_THISCALL_ASGLOBAL, derivedObj); scriptEngine->RegisterGlobalFunction("void printB()", asMETHOD(Derived, printB), asCALL_THISCALL_ASGLOBAL, derivedObj); However, I still get the crash. Also, on windows, registering my functions using a pointer to the Base class method, and the base class object, actually works just fine. When I call the script functions in AngelScript on windows the Derived's implementation is called, if any. The reason I want to do it this way is because my main application acts like a framework, or a AS wrapper, where platform-specific functionality is implemented thought abstract classes (well, kinda-abstract classes). Is it just coincidental that it works for my windows build, maybe? I wish I could provide some debug information, but retrieving debug info from Android seems near impossible . Especially since the crash resides in a Android library (libc.so). Anyways, thanks for responding!
  11. Hi again! I've encountered a weird problem when calling virtual functions on Android (ARM version). It seems like I'm getting a crash whenever I call a inherited function, whether or not it is overwritten by a derived class. For example if I have these two classes:   class Base { public:     virtual void printA()     {         LOGI("Base: PrintA called");     }          virtual void printB()     {         LOGI("Base: PrintB called");     } }; class Derived : public Base { public:     void printA()     {         LOGI("Derived: PrintA called");     } }; And I register printA and printB at some point using the following:   scriptEngine->RegisterGlobalFunction("void printA()", asMETHOD(Base, printA), asCALL_THISCALL_ASGLOBAL, derivedObj); scriptEngine->RegisterGlobalFunction("void printB()", asMETHOD(Base, printB), asCALL_THISCALL_ASGLOBAL, derivedObj); If I now call either printA or printB in AngleScript, my Android application will crash. Now, as a disclaimer, I might have messed up my configuration at some point, however I don't know how to track down the problem if it in fact is a configuration problem. I've made sure __GNUC__ and ANDROID is defined. I figure it might have something with the VIRTUAL_BASE_OFFSET macro, but, then again, my lack of the technical know-how makes it difficult for me to track the exact problem down. Has anyone else got something like this to work? As a side note; I have managed to register and call simple global functions and different value type objects (strings and math objects), so the problem seems to be quite specific. Also, I cannot explain this, but in my main application, I'm actually able to call some function which are registered in this way (but mostly not), but I'm not able to find any obvious pattern among them Anyways, looking forward to some feedback!
  12. Marcus L

    Problem with array of handles

    Oh, i guess that does make sense   Wait. So does this mean that something like @objectA == @objectB will perform a value comparison? Or is when you omit the '@'s that a value comparison will be done? I have a suggestion on how the original problem can be solved, but as i don't know the inner workings of AngelScript, i don't know if this is too difficult to pull off. However, what i thought could work, is when the script writer wrote something like "list.find(@a)", then AS would interpret this as look for the handle of 'a' in the list, while if the script writer wrote "list.find(a)", then it would be interpreted as look for the value of 'a' in the list (using opCmp). Anyways, thanks for clearing that up !
  13. Marcus L

    Problem with array of handles

    Hi again! It seems I've encountered a bug in the newest version of the scriptarray add-on (tested rev1771 also). AngelScript yields the following error:   ... When i run something like this:   class A {} array<A@> list; void main() { A a; list.insertLast(@a); int idx = list.find(@a); // ERROR } I'm sure there is an easy fix for this, but knowing me I'll probably take ages to figure it out, so for the time being I think I'll just revert back to an older version of the add-on .  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!