Advertisement

Few more problems

Started by January 20, 2009 02:17 PM
14 comments, last by WitchLord 15 years, 10 months ago
I still don't see anything wrong.

I wrote a small test based on your information and it works without crashing.

class CEngine{public:	CEngine() {}	~CEngine() {}	void BuildButton(std::string& caption, int x, int y, int width, int height, std::string& function) 	{		assert( caption == "Test" );		assert( x == 0 );		assert( y == 0 );		assert( width == 100 );		assert( height == 100 );		assert( function == "test" );	}};static void Constructor(void *memory){	new(memory) CEngine();}static void Destructor(CEngine *p){	p->~CEngine();}bool Test2(){	int r;	bool fail = false;	asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);	RegisterScriptString(engine);	r = engine->RegisterObjectType("CEngine", sizeof(CEngine), asOBJ_VALUE | asOBJ_APP_CLASS_CDA); assert( r >= 0 );	r = engine->RegisterObjectBehaviour("CEngine", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(Constructor), asCALL_CDECL_OBJLAST); assert(r >= 0);		r = engine->RegisterObjectBehaviour("CEngine", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(Destructor), asCALL_CDECL_OBJLAST); assert(r >= 0);	r = engine->RegisterObjectMethod("CEngine", "void BuildButton(string &in, int, int, int, int, string &in)", asMETHOD(CEngine, BuildButton), asCALL_THISCALL); assert( r >= 0 );	r = engine->ExecuteString(0, "CEngine blah; blah.BuildButton('Test', 0, 0, 100, 100, 'test');");	if( r != asEXECUTION_FINISHED )	{		fail = true;	}	engine->Release();	return fail;}


Are you sure the problem is with this method, and not something else?

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

Quote: Original post by WitchLord
I still don't see anything wrong.

I wrote a small test based on your information and it works without crashing.

*** Source Snippet Removed ***

Are you sure the problem is with this method, and not something else?


Well, I'm not sure. If I remove the call to that function in the script, it doesn't fail.

Advertisement
Can you test the code I wrote to see if it also crashes? If it doesn't crashes, can you try to find the difference between it and your application?

It may be a difference in compilers. What compiler are you using?

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

What is the callstack when you crash? What if you put a breakpoint at the top of your BuildButton function (in C++) - does it get hit?
Weird.

I did a recompile a few times without changing anything and now it doesn't crash.

That's really strange.
That has happened to me a few times as well. It may be that a previous compilation didn't identify earlier changes that you had made, thus getting a corrupt binary.

I'm glad the problem is solved.

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