Advertisement

Returning a Pointer

Started by June 11, 2009 03:14 PM
1 comment, last by Cloudef 15 years, 5 months ago
Hello, I'm new to AngelScript and I'm quite lost with it to speak the truth. Anyways my proplem is that in my script this works:

int x		= 0;
int y		= 0;
void onClick()
{
			//if(handle is null)
				IWindow@ handle = addWindow("Equip.backgrnd",x,y,x,y,"");
			//else
			//	handle.close();
}

But this does not:

int x		= 0;
int y		= 0;
IWindow@        handle;
void onClick()
{
			if(handle is null)
				handle = addWindow("Equip.backgrnd",x,y,x,y,"");
			//else
			//	handle.close();
}

It opens the window correctly in second code, but i get error about NULL pointer expection. I register my methods and objects like this:

        r = engine->RegisterObjectType("IWindow", sizeof(iWindow*), asOBJ_REF); assert( r >= 0 );
        r = engine->RegisterObjectBehaviour("IWindow", asBEHAVE_ADDREF, "void f()", asMETHOD(iWindow, add),asCALL_THISCALL); assert( r >= 0 );
        r = engine->RegisterObjectBehaviour("IWindow", asBEHAVE_RELEASE, "void f()", asMETHOD(iWindow, release),asCALL_THISCALL); assert( r >= 0 );
        r = engine->RegisterObjectBehaviour("IWindow", asBEHAVE_ASSIGNMENT, "IWindow &f(IWindow &in)", asMETHODPR(iWindow, operator=, (const iWindow&), iWindow&), asCALL_THISCALL); assert( r >= 0 );
        r = engine->RegisterGlobalFunction("IWindow@ addWindow(const string &in, uint32, uint32, uint32, uint32, const string &in)", asFUNCTION(addWindow), asCALL_CDECL); assert( r >= 0 );

Hope you understood. I would really like to use AngelScript in my Client, because of the syntax. But it lacks lots of examples about different things so it's quite hard to get started with it IMO.
Manual: Object handles

To perform a handle assignment, rather than a value assignment you must use the @ symbol, i.e:

if(handle is null)  @handle = addWindow("Equip.backgrnd",x,y,x,y,"");



AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Ah, this is me not reading propebly =) Thanks a bunch!

This topic is closed to new replies.

Advertisement