default function parameters
Is there a way to bind a function that contains defaults to some of its parameters without creating overloaded wrappers? IE class.function(const obj ∈, float a = 5, float b = 2, float c = 4);
Another question:
I have a class with a vector, and wish to make some properties always reference to the first index of the vector. Is this possible without getter functions? All my constructors ensure that the vector is always large enough to index to 0 but binding it as
engine->RegisterObjectProperty("class", "obj d", offsetof(class, v[0].d));
where v is the vector causes memory access violation during this registration call. I thought perhaps it was creating an instance of the object to determine the memory offsets for the properties, but then wouldn't my default constructor be called? What exactly is going on here?
Lastly, suppose I have a suspended script, and would like to save the state of the context to a file to be loaded and resumed at a later time. How viable is this? What all would this involve to save the state of the context's global variables, the current line that was executing when it was suspended and the contents of the stack? Assuming references to C++ objects have all been released and only holding references to angelscript created objects.
[Edited by - IndependentHat on May 7, 2009 4:23:02 AM]
It's not yet possible to use default function arguments. It is on my to-do list though as it is something that will simplify the use of the engine quite a bit.
The offsetof() macro is a default macro in C/C++. It doesn't instanciate an object to determine the offset, instead it cast a null pointer to the wanted type and then determine the offset from that. You're probably getting the memory access violation because the macro is producing some illegal access on that null pointer. You may be able to do it in two steps, e.g.
Of course, this is assuming the vector is not a dynamic vector. If it isn't then the element can't be accessed through a simple offset.
I have plans to support serialization of the context call stack, but at this moment it is not possible. The contexts are designed so that when they are suspended there are no loose references on the call stack, so in theory it should just be a matter of traversing the call stack and serializing each variable. The type of each object variable is already stored for the sake of exception handling so all the information is there.
The global variables belong to the module, so they should be serialized separately from the context.
Regards,
Andreas
The offsetof() macro is a default macro in C/C++. It doesn't instanciate an object to determine the offset, instead it cast a null pointer to the wanted type and then determine the offset from that. You're probably getting the memory access violation because the macro is producing some illegal access on that null pointer. You may be able to do it in two steps, e.g.
engine->RegisterObjectProperty("class", "obj d", offsetof(class, v) + offsetof(vector, d));
Of course, this is assuming the vector is not a dynamic vector. If it isn't then the element can't be accessed through a simple offset.
I have plans to support serialization of the context call stack, but at this moment it is not possible. The contexts are designed so that when they are suspended there are no loose references on the call stack, so in theory it should just be a matter of traversing the call stack and serializing each variable. The type of each object variable is already stored for the sake of exception handling so all the information is there.
The global variables belong to the module, so they should be serialized separately from the context.
Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement