🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

registering a pointer

Started by
6 comments, last by WitchLord 18 years, 3 months ago
i registered a pointer to a class in order to use it in the script. somehow i kept getting error during execution of the script: test (27, 16) : Error : No matching signatures to 'Bar(const uint, const uint, const uint, const uint)' //-------- in C++ --------- class C3D { public: Graphics *m_pGraphics; } r = e->RegisterObjectType("Graphics", 0, 0); r = e->RegisterObjectMethod("Graphics", "void Bar (int x0, int y0, int x1, int y1)", asMETHOD(Graphics, Bar), asCALL_THISCALL); C3D *p3D = new C3D; r = e->RegisterObjectType ("GfxPtr", sizeof(Graphics*), asOBJ_PRIMITIVE); r = e->RegisterObjectType("sr3D", sizeof(C3D), asOBJ_CLASS); r = e->RegisterObjectProperty("sr3D", "GfxPtr Graphics", offsetof(C3D, m_pGraphics)); r = e->RegisterGlobalProperty ("sr3D STAR", &p3D); //-------- in script --------- STAR.Graphics.Bar (20, 20, 100, 100);
Advertisement
The Graphics property of sr3D is of the type GfxPtr. AngelScript doesn't know the relationship between the types GfxPtr and Graphics.

Two suggestions; Either:

register the method Bar() on the GfxPtr type. You'll need to write a wrapper function for this, as the method will receive a pointer to a pointer to the Graphics object.

Or:

register the property as "Graphics &Graphics". Not sure if this works though. If it doesn't let me know so that I can do something about it.

Regards,
Andreas

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


nope, registering as "Graphics &Graphics" does not work.
got a "Invalid configuration", i guess it is because AddRef and DecRef not present. but i do not have control on that class.

writing wrapper for each methods is going to kill me too, since i have a lot of other classes and methods in the same way.

i am using a 3rd party library where Angelscript is under it too. so plenty of constraints.

guess i need to look into other ways.
I'll see if I can adjust Angelscript to allow you to register the Graphics property as a reference.

In the meantime I remembered another solution that you might be able to use:

// C++Graphics *C3D::GetGraphics(){  return m_pGraphics;}e->RegisterObjectMethod("sr3D", "Graphics &GetGraphics()", asMETHOD(C3D,GetGraphics), asCALL_THISCALL);// AngelScriptSTAR.GetGraphics().Bar(20, 20, 100, 100);


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


do i need Graphics class to have AddRef and DecRef before it can be exposed with an & ?

No, you don't need that.

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

got it, it works!

but does it means any classes can be exposed this way? via a method ?

i guess it is not possible to expose these classes as variables

i.e. Graphics &test //will not work in script



Exactly.

Variables and properties cannot be declared as references. Not yet anyway.

I'll investigate this further, because I think it must be possible to register class properties both with and without reference. At least to give the necessary flexibility to application developers.

The scripts themselves will not be able to declare variables, nor class members, as references.

Regards,
Andreas

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