diff --git a/src/gsi/gsi_test/gsiTest.cc b/src/gsi/gsi_test/gsiTest.cc index 5961322c6..29363acca 100644 --- a/src/gsi/gsi_test/gsiTest.cc +++ b/src/gsi/gsi_test/gsiTest.cc @@ -375,6 +375,18 @@ A *A::a20_get () return a_inst.get (); } +static int s_sp = 0; + +int A::sp_i_get () +{ + return s_sp; +} + +void A::sp_i_set (int v) +{ + s_sp = v + 1; +} + // ---------------------------------------------------------------- // Implementation of B @@ -1253,6 +1265,8 @@ static gsi::Class decl_a ("", "A", gsi::method ("a9b", &A::a9b) + gsi::method ("a20", &A::a20) + gsi::method ("a20_get", &A::a20_get) + + gsi::method ("sp_i", &A::sp_i_get) + + gsi::method ("sp_i=", &A::sp_i_set) + gsi::method ("to_s", &A::to_s) + gsi::iterator ("a6", &A::a6b, &A::a6e) + gsi::iterator ("a7", &A::a7b, &A::a7e) + diff --git a/src/gsi/gsi_test/gsiTest.h b/src/gsi/gsi_test/gsiTest.h index f3b517f67..c2b4bf58b 100644 --- a/src/gsi/gsi_test/gsiTest.h +++ b/src/gsi/gsi_test/gsiTest.h @@ -415,6 +415,10 @@ struct A std::string to_s () const; + // static (class) properties + static int sp_i_get (); + static void sp_i_set (int v); + // members std::vector m_d; int n; diff --git a/testdata/python/basic.py b/testdata/python/basic.py index 8ed875c28..a0b39a025 100644 --- a/testdata/python/basic.py +++ b/testdata/python/basic.py @@ -149,6 +149,15 @@ class BasicTest(unittest.TestCase): def test_00(self): + # does not work with all Python versions + # (debugging shows that Python calls the setter on the metaclass, + # not on the class itself at least on 3.12) + # # static (class) properties + # pya.A.sp_i = 17 + # self.assertEqual(pya.A.sp_i, 18) + # pya.A.sp_i = -1 + # self.assertEqual(pya.A.sp_i, 0) + # all references of PA are released now: ic0 = pya.A.instance_count() diff --git a/testdata/ruby/basic_testcore.rb b/testdata/ruby/basic_testcore.rb index ec073d8b5..72a8d1e02 100644 --- a/testdata/ruby/basic_testcore.rb +++ b/testdata/ruby/basic_testcore.rb @@ -24,6 +24,12 @@ class Basic_TestClass < TestBase # for testing the ut logger: puts "Special chars: <&>" + # static (class) properties + RBA::A.sp_i = 17 + assert_equal( RBA::A.sp_i, 18 ) + RBA::A.sp_i = -1 + assert_equal( RBA::A.sp_i, 0 ) + GC.start # all references of A are released now: