zexee

Members
  • Content count

    14
  • Joined

  • Last visited

Community Reputation

118 Neutral

About zexee

  • Rank
    Member
  1. That's great! Then I found a bug that GetVarDecl and GetTypeDeclaration does not work on template specializations. 
  2. Hi, I want to get the full declaration (something like: const namespace::array<object> a;) of a local variable in context.   I tried function->GetVarDecl(), but it does not full (no namespace, no <object>). I know namespace can be found in engine->GetObjectTypeById()->GetNamespace(), and const can be found in function->GetVarDecl() but how to get the template subtype?   Since the template subtype can also be a template and have const and reference/handle, it seems to be a iterative process to get the full declaration. Is there a simple way to do that?   Thanks in advance!
  3. Assign object handle to array element

    I see, thank you very much!
  4. I am a bit confused about how to use object handle. Here is the code example I was trying to compile with the add-on array: class Obj {   int x; }; void main() {   array<Obj@> a(3);   Obj o;   o.x = 10;   a[0] = @o; } The compile error is "Can't implicitly convert from 'Obj@const&' to 'const Obj&'." for the assign line. What is the correct way of doing that?  
  5. Progressive compiling

    Hi, here is the problem I want to find a solution. I want to dynamically edit a script file A, so I need to compile it again and again and see the running result. A requires some common functions and global variables that are stable and no need to change, more importantly, it always needs some data that need some time to calculate. Say these dependent function and variables are stored in script B. So it's better to load B first and let it do the calculation to prepare data and then load A to run it. In this way A can be changed and run without recalculate data in B. However I found that if there is some errors in A which makes the module fail to build, the modules will be "damaged" and those function/variables in B will also be destroyed and that will be contradicted to my initial purpose of doing so. Since all script entities are in modules, I cannot make them global. And right now importing global variable from another module is not supported. So is there any good solution to this? Thank you very much!
  6. Internal value of bool?

    Sorry, it was my mistake. I was actually calling opCmp so equal is 0. Thank you for your answering!
  7. Internal value of bool?

    I am just met trouble of use c++ to access bool value in angelscript. There is no SetArgBool or GetReturnBool, and it said bool is 8bit in the document. So I used *(bool*)GetAddressOfReturnValue() but it turned out wrong.   I looked at the memory, it seemed that true is 0 and false is 255 in byte. If so, that is different from c++ tradition (as far as I can remember, in c++ 0 is false and all others are true), and it should be documented or provide set and get function.
  8. Error: Type is still used by function?

    I found my bug! I tried to use inherited reference_count class and put AddRef and Release in the base class. Therefore the function address is for the base class and when call them with the address of the derived class as object using this_call, the function will consider it as the address of the base class and it cannot find the correct reference counter variable.   So I cannot register any function of the base class if the inheritance is not trivial.
  9. Error: Type is still used by function?

    It is not easy to create a simple example, so I am trying to debug myself. I found it only happens on template object and the reason is that the template object is never released. No one calls ->Release() for the local variable so it is never deleted. I am not sure where it should be called, after function release or after context release? I am guessing that every function call is related to a context and when context releases all its local variable releases. According to the function name I think CleanStack is doing that but it is never called for successfully executed function. I am lost. Would you point me out the way where to look at?   Plus, I didn't use funcdefs, I just compile a script into a module and run one function of it. I only explicitly create one context for running function and get one function from the module. I am sure this two things are correctly released.
  10. When engine is destructed, I got a error message saying "type string is still used by function erase". It seems that a the function is holding a reference to a type. It's true that the input parameter of function erase is string, but it never addref it.   What could be the problem?
  11. Why need to copy when using const T &in

    For example, I want to have a template<int N> class Vector; I want some specific method for specific Vector<N>, for example CrossProduct are only for Vector<3>. But also, all Vector can have some common method like operator+(). So here is what I implemented template<int N> class VectorBase{ /* common methods */} template<int N> class Vector : public VectorBase; template<> class Vector<3> : public VectorBase<3> { /* specific methods */ } The operator+ can only return a VectorBase, so many functions only need to accept VectorBase& as arguments. So I want Vector& be implicit cast to VectorBase&.
  12. Why need to copy when using const T &in

    Thank you very much for the detailed answer! It prevents the passed in arguments being destroyed inside the current function. If it is a reference object, the argument always holds a reference, so &inout is allowed.    I tried asEP_ALLOW_UNSAFE_REFERENCES, and it works very well, except for it still disallow register a reference cast behavior to a value type. Since it is already unsafe, this cast should be no more unsafe than passing value type by ref right?
  13. HI,   First of all, I am looking for such (c++ style) script for a long time and very happy that angelscript exists.   I am working on design even simpler interface to register c++ objects / functions so that I can easily register many good c++ libraries and make it a general purpose language.   I met some problem when dealing with arguments passing to functions. The const T&in type will always cause a copy constructing for the object passed in and the object will be destroyed after the function ends, and const T&out will create a new object to pass into the function and copy it back to the original object after the function ends. These two behaviors happen no matter for value object type or reference object type. These behaviors are different from c++ and will cause some problem.   Since for reference object type, neither const T &inout or T &inout do the copy and I think const T&in should be the same as const T &inout, so that is not a implementation problem.   I am wondering what's the original thought of &in and &out? Since the caller will always hold a reference or the value so the object will not be destroyed during the call, and const will control whether the function can modify it or not, so why do we need &in and &out?