Passing script objects as base pointers?

Started by
20 comments, last by Wavesonics 15 years, 2 months ago
What compiler are you using?

In the test framework I have a test for multiple inheritance already (testmultipleinheritance.cpp). It should have covered this scenario, but I'll try recreate your problem to see if there is a difference.

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
MinGW GCC 4.3.x (.5 i think? i'm not at home right now so I can't check for sure)

Also, that proxy function is declared virtual, if that makes any difference.

Maybe it has something to do with multiple-inheritance with an implicit cast? idk.
==============================
A Developers Blog | Dark Rock Studios - My Site
I've written the following test based on the info you gave me. On MSVC it doesn't have any problems, but perhaps on MinGW it reproduces the problem you're having. Would you mind giving it a try?

bool addOverlayCalled = false;class Drawable {private:    int somestuff;protected:	int somethingElse;public:    Drawable(  ) {}    virtual ~Drawable() {}    virtual void addOverlay(  ) { addOverlayCalled = true; }};class Creep {private:	int somestuffOfMine;protected:	int duh;public:	Creep() {}	virtual ~Creep() {}};class CreepClient : public Creep, public Drawable {private:protected:public:    CreepClient( ) {}    virtual ~CreepClient() {}};void Dummy() {}bool Exec(asIScriptEngine *engine, Creep &c){	bool fail = false;	CreepClient &cc = dynamic_cast<CreepClient&>(c);	asIScriptModule *mod = engine->GetModule("mod");	int funcId = mod->GetFunctionIdByIndex(0);	asIScriptContext *ctx = engine->CreateContext();	ctx->Prepare(funcId);	ctx->SetArgObject(0, &cc);	int r = ctx->Execute();	if( r != asEXECUTION_FINISHED ) 	{		fail = true;	}	ctx->Release();	return fail;}bool TestMultipleInheritance2(){	bool fail = false;	int r;	asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);    r = engine->RegisterObjectType("CreepClient", sizeof(CreepClient), asOBJ_REF ); assert( r >= 0 );    r = engine->RegisterObjectBehaviour("CreepClient", asBEHAVE_ADDREF, "void f()", asFUNCTION(Dummy), asCALL_CDECL_OBJFIRST); assert( r >= 0 );    r = engine->RegisterObjectBehaviour("CreepClient", asBEHAVE_RELEASE, "void f()", asFUNCTION(Dummy), asCALL_CDECL_OBJFIRST); assert( r >= 0 );    r = engine->RegisterObjectMethod("CreepClient", "void addOverlay(  )", asMETHOD(CreepClient, addOverlay), asCALL_THISCALL); assert( r >= 0 );	const char *script = 		"void fireEffects( CreepClient@ c ) { \n"		"		c.addOverlay(  ); // This one doesn't ever fire off  \n"		"} \n";	asIScriptModule *mod = engine->GetModule("mod", asGM_ALWAYS_CREATE);	mod->AddScriptSection("script", script);	r = mod->Build();	if( r < 0 )	{		fail = true;	}    CreepClient cc;	fail = Exec(engine, cc) || fail;	if( addOverlayCalled == false )		fail = true;	engine->Release();	return fail;}

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

Ok I compiled and tested the code as such:

#include <iostream>#include <assert.h>#include "angelscript.h"using namespace std;{  // Your code here}int main() {    if( TestMultipleInheritance2() )        cout << "Success!" << endl;    else        cout << "FAIL" << endl;}


and it fails. I tested it with MinGW on both GCC 4.x and 3.x.
==============================
A Developers Blog | Dark Rock Studios - My Site
Any ideas?
==============================
A Developers Blog | Dark Rock Studios - My Site
I've haven't had the time to look into this yet. But if I can reproduce it once I install MinGW it ought to quite simple to fix.

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

Cool, If you download Code::Blocks, the MinGW GCC 3.x it ships with should produce it for you:

http://prdownload.berlios.de/codeblocks/codeblocks-8.02mingw-setup.exe
==============================
A Developers Blog | Dark Rock Studios - My Site
Thanks for the tip. The visual debugger in Code::Blocks ought to help a great deal when fixing the bug as well.

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

I downloaded Code::Blocks as you recommended, but unfortunately the problem you're having isn't reproducable. The test I wrote above works without a problem.

I just noticed that you were running the test slightly wrong. The function TestMultipleInheritance2() returns 'true' if it fails, but in your test you interpret 'true' as success. So I guess this means that my test didn't reproduce the problem on your setup either.

However, downloading Code::Blocks with MinGW wasn't fruitless. There were plenty of other bugs that showed up for MinGW/Win32. I've fixed them now, so you may want to download the new version from the SVN. Perhaps some of the bugs I fixed was also the cause for the problem you were having.



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

aahh crap, sorry for the false positive, I wounder what is going on in my app then.

I updated to the SVN version and recompiled everything, but still no go.

Any tips on how to begin debugging the script?
==============================
A Developers Blog | Dark Rock Studios - My Site

This topic is closed to new replies.

Advertisement