Sign in to follow this  

registering a pointer

This topic is 4301 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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);

// AngelScript
STAR.GetGraphics().Bar(20, 20, 100, 100);


Share this post


Link to post
Share on other sites
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



Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4301 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this