Jump to content
  • Advertisement
Sign in to follow this  

Bug with registered properties and property accessors

This topic is 1132 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

It is possible to register a property, and a property accessor that both have the same name:

struct foo
	int bar = 0;

	static foo* create()
		return new foo;

	static int get_bar( foo* pThis ) { return pThis->bar; }

m_pScriptEngine->RegisterObjectType( "foo", 0, asOBJ_REF | asOBJ_NOCOUNT );

m_pScriptEngine->RegisterObjectBehaviour( "foo", asBEHAVE_FACTORY, "foo@ foo()", asFUNCTION( foo::create ), asCALL_CDECL );

m_pScriptEngine->RegisterObjectProperty( "foo", "int bar", asOFFSET( foo, bar ) );

m_pScriptEngine->RegisterObjectMethod( "foo", "int get_bar() const", asFUNCTION( foo::get_bar ), asCALL_CDECL_OBJLAST );

Where m_pScriptEngine is asIScriptEngine*.


It seems that the accessor is always used; when you try to assign a value to it, it will report an error saying no set accessor exist.

Share this post

Link to post
Share on other sites

The property accessors hides a real property of the same name. This is not really a bug, but I can see that it would be better to validate and give an error in case the application tries to register the interface like this.


I'll add an item on my to-do list to implement this validation.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!