Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualBlackMoons

Posted 17 September 2013 - 05:25 PM

Hi, I am having a small problem.

I have 'ObjectRef' registered as a reference type

It has the standard ref counting/addref/release functionality.

I also have a copy constructor registered as:

r = scriptEngine->RegisterObjectMethod("ObjectRef", "ObjectRef@ opAssign(const ObjectRef &in other)", asMETHOD(ObjectRef,operator=), asCALL_THISCALL); assert( r >= 0 );

 

And right now I am encountering two problems...

I have an angelscript class like this:

class FireSource
{
    ObjectRef @ mOwner;
    Light mLight;
    FireSource()
    {
        gConsole.AddItem("Constructed!");
    }

    void Initilize(ObjectRef @ ref)
    {
        gConsole.AddItem("Testing!");
        mOwner = ref;
        gConsole.AddItem("Testing!1.01");
        mLight.mOwner = ref;
        gConsole.AddItem("Testing!1.1");
    }
};

I construct the class on my C++ side and call Initilize:


        asIScriptFunction * init = objDetails->mUserDataType->GetMethodByDecl("void Initilize(ObjectRef @)");

        Engine::mScript->mContext->Prepare(init);
        ObjectRef * ref = new ObjectRef();
        ref->SetObject(this);
        Engine::mScript->mContext->SetArgObject(0, ref);
        Engine::mScript->mContext->SetObject(mObjectData);
        // Execute the call
        Engine::mScript->mContext->Execute();
        ref->Release();

I can confirm the object is constructed, and the first 'gConsole.AddItem("Testing!");' is executed.

After that, it returns from "Engine::mScript->mContext->Execute();" without calling the ObjectRef copy assignment or any further instructions, No error is logged or reported?

 

If I comment out '//mOwner = ref;', it continues on to call the ObjectRef copy constructor for the line "mLight.mOwner = ref;"

 

And then it crashes. (MSVC2010)

"File crt\src\dbgdel.cpp line 52

Expression _BLOCK_TYPE_IS_VALID(pHead->nBlockUSE)"

 

 

For reference, the C++ side of Light is (its also registered as ref type)

class Light : public ScriptRef
{
public:
    ObjectRef mOwner;
};
...
r = scriptEngine->RegisterObjectProperty("Light", "ObjectRef mOwner", asOFFSET(Light,mOwner)); assert( r >= 0 );

So yea, two problems, I am not exactly sure what I did wrong.


#1BlackMoons

Posted 17 September 2013 - 05:07 PM

Hi, I am having a small problem.

I have 'ObjectRef' registered as a reference type

It has the standard ref counting/addref/release functionality.

I also have a copy constructor registered as:

r = scriptEngine->RegisterObjectMethod("ObjectRef", "ObjectRef@ opAssign(const ObjectRef &in other)", asMETHOD(ObjectRef,operator=), asCALL_THISCALL); assert( r >= 0 );

 

And right now I am encountering two problems...

I have an angelscript class like this:

class FireSource
{
    ObjectRef @ mOwner;
    Light mLight;
    FireSource()
    {
        gConsole.AddItem("Constructed!");
    }

    void Initilize(ObjectRef @ ref)
    {
        gConsole.AddItem("Testing!");
        mOwner = ref;
        gConsole.AddItem("Testing!1.01");
        mLight.mOwner = ref;
        gConsole.AddItem("Testing!1.1");
    }
};

I construct the class on my C++ side and call Initilize:


        asIScriptFunction * init = objDetails->mUserDataType->GetMethodByDecl("void Initilize(ObjectRef @)");

        Engine::mScript->mContext->Prepare(init);
        ObjectRef * ref = new ObjectRef();
        ref->SetObject(this);
        Engine::mScript->mContext->SetArgObject(0, ref);
        Engine::mScript->mContext->SetObject(mObjectData);
        // Execute the call
        Engine::mScript->mContext->Execute();
        ref->Release();

I can confirm the object is constructed, and the first 'gConsole.AddItem("Testing!");' is executed.

After that, it returns from execute without calling the ObjectRef copy assignment or any further instructions, No error is loged or reported?

 

If I comment out '//mOwner = ref;', it continues on to call the ObjectRef copy constructor for the line "mLight.mOwner = ref;"

 

And then it crashes. (MSVC2010)

"File crt\src\dbgdel.cpp line 52

Expression _BLOCK_TYPE_IS_VALID(pHead->nBlockUSE)"

 

 

For reference, the C++ side of Light is (its also registered as ref type)

class Light : public ScriptRef
{
public:
    ObjectRef mOwner;
};
...
r = scriptEngine->RegisterObjectProperty("Light", "ObjectRef mOwner", asOFFSET(Light,mOwner)); assert( r >= 0 );

So yea, two problems, I am not exactly sure what I did wrong.


PARTNERS