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.