Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 Dec 2012
Offline Last Active Jun 18 2014 09:10 PM

Topics I've Started

Initializing array in function call

16 January 2014 - 12:01 PM

Any chance of allowing a initialization list to be used in a function call?

void test(array<string> &in); // Function definition

test({"string1", "string2"});

Or something like:

test(array<string>{"string1", "string2"});

- dave


05 January 2013 - 10:50 PM

Could you add a method to get the current default namespace?


const char *asCScriptEngine::GetDefaultNamespace() const
    return defaultNamespace->name.AddressOf();



Dave Krusu


01 January 2013 - 11:26 PM

I'm getting a segfault when registering a object with a method that returns a handle to it's self. The following code reproduces the crash:


#include <angelscript.h>
#include <stdio.h>

class IManaged {
        virtual void addRef() = 0;
        virtual void Release() = 0;

class Test : public IManaged {
        void addRef() {


        void Release() {


        Test &Foo() {
            return *this;

Test *pTest;

int main() {
    asIScriptEngine *pEngine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
    asIScriptModule *Mod     = pEngine->GetModule(0, asGM_ALWAYS_CREATE);

    pTest = new Test();

    pEngine->RegisterObjectType("Test", 0, asOBJ_REF);
    pEngine->RegisterObjectBehaviour("Test", asBEHAVE_ADDREF, "void f()", asMETHOD(Test, addRef), asCALL_THISCALL);
    pEngine->RegisterObjectBehaviour("Test", asBEHAVE_RELEASE, "void f()", asMETHOD(Test, Release), asCALL_THISCALL);
    pEngine->RegisterObjectMethod("Test", "Test &Foo()", asMETHOD(Test, Foo), asCALL_THISCALL);
    pEngine->RegisterGlobalProperty("Test @pTest", pTest);

    const char *Script = "void main() { pTest.Foo(); }";

    Mod->AddScriptSection("script", Script);

    asIScriptContext *Ctx = pEngine->CreateContext();
    asIScriptFunction *Func = Mod->GetFunctionByDecl("void main()");


    return 0;


here is the backtrace:


#0  0x0000000000412682 in asCScriptEngine::CallObjectMethod (this=0x737010,
    obj=0x4c5e30 <vtable for Test+16>, i=0x7400f0, s=0x740150)
    at ../../source/as_scriptengine.cpp:3382
#1  0x0000000000412574 in asCScriptEngine::CallObjectMethod (this=0x737010,
    obj=0x4c5e30 <vtable for Test+16>, func=31)
    at ../../source/as_scriptengine.cpp:3354
#2  0x0000000000490b73 in asCContext::ExecuteNext (this=0x740ae0)
    at ../../source/as_context.cpp:3739
#3  0x00000000004896af in asCContext::Execute (this=0x740ae0)
    at ../../source/as_context.cpp:1155
#4  0x00000000004026c7 in main () at test.cpp:48



This happends on both 32 and 64-bit builds with GCC 4.7.2 (Linux)





No type id for enum values?

26 December 2012 - 10:56 AM

I'm writing a function that takes a var arg type and then identifies the type to print either the value or information about the object. Everything seems to have an Id except enum values, however they always seem to get an id of 14. Can enum values be given a typeId like the rest? Or am I missing something that allows me to identify enum values?



Dave Krusu

Possible namespace bug?

22 December 2012 - 11:27 PM

I'm not sure if this is intentional or a bug. When writing in the script language namespaces seem to inherit everything from the global, but when registering it it doesn't:


Script code:

namespace test {

    void blah() {

        string s;





That works, but if I register a global function inside of a namespace like this

pEngine->RegisterGlobalFunction("bool foo(const string &in)", asFUNCTION(Foo), asCALL_CDECL);


I get the following error:

System function (1, 18) : ERR  : Identifier 'string' is not a data type
 (0, 0) : ERR  : Failed in call to function 'RegisterGlobalFunction' with 'bool isDir(const string &in)' (Code: -10)
VelScript: /home/droz/Projects/Velox/VelScript/Include/Script.h:235: void Vel::Script::FunctionGroup::Register(asIScriptEngine*): Assertion `Ret >= 0' failed.

If I register it with:

pEngine->RegisterGlobalFunction("bool foo(const ::string &in)", asFUNCTION(Foo), asCALL_CDECL);


it works.