File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1401,4 +1401,26 @@ KAGUYA_TEST_FUNCTION_DEF(self_refcounted_object)(kaguya::State& )
14011401
14021402}
14031403
1404+ int Base_a_getter (const Base* self)
1405+ {
1406+ return self->a ;
1407+ }
1408+ void Base_a_setter (Base* self,int v)
1409+ {
1410+ self->a = v;
1411+ }
1412+ KAGUYA_TEST_FUNCTION_DEF (add_property_external)(kaguya::State& state)
1413+ {
1414+
1415+ state[" Base" ].setClass (kaguya::UserdataMetatable<Base>()
1416+ .setConstructors <Base ()>()
1417+ .addProperty (" a" , &Base_a_getter,&Base_a_setter)
1418+ );
1419+ Base base;
1420+ state[" base" ] = &base;
1421+ TEST_CHECK (state (" base.a=1" ));
1422+ TEST_CHECK (state (" assert(1 == base.a)" ));
1423+ TEST_EQUAL (base.a , 1 );
1424+ }
1425+
14041426KAGUYA_TEST_GROUP_END (test_02_classreg)
You can’t perform that action at this time.
0 commit comments