how to access live c++ object?
This is my class class CT { public: CT() {}; ~CT() {}; int GetNum( void ) { return num; } void SetNum( int n ) { num = n; } private: int num; }; static CT ct; CT & getCT( void ) { return ct; } I want to access ct object from boost.python, thanks for your advice.
... def("getCT",&getCT,return_value_policy<reference_existing_object>()); ... Ñî±ù[Ô´´úÂëÖ®¹â] wrote:
This is my class class CT { public: CT() {}; ~CT() {}; int GetNum( void ) { return num; } void SetNum( int n ) { num = n; }
private: int num; };
static CT ct;
CT & getCT( void ) { return ct; }
I want to access ct object from boost.python, thanks for your advice.
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
this is python code def run(): myFoo = HoHo_PI.getCT() a = myFoo.SetNum( 50 ) b=str(a) But b is none? why? thx "Leonard "paniq" Ritter" <paniq@paniq.org> wrote in message news:42354F3F.5070406@paniq.org... ... def("getCT",&getCT,return_value_policy<reference_existing_object>()); ... Ñî±ù[ÔŽŽúÂëÖ®¹â] wrote:
This is my class class CT { public: CT() {}; ~CT() {}; int GetNum( void ) { return num; } void SetNum( int n ) { num = n; }
private: int num; };
static CT ct;
CT & getCT( void ) { return ct; }
I want to access ct object from boost.python, thanks for your advice.
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
if getCT had really failed, you would have get an exception when calling SetNum. try repr(a), and if the return type is None, SetNum is most probably of return type void. ??[?????] wrote:
this is python code def run(): myFoo = HoHo_PI.getCT() a = myFoo.SetNum( 50 ) b=str(a)
But b is none? why? thx
"Leonard "paniq" Ritter" <paniq@paniq.org> wrote in message news:42354F3F.5070406@paniq.org... ...
def("getCT",&getCT,return_value_policy<reference_existing_object>());
...
Ñî±ù[Ô´´úÂëÖ®¹â] wrote:
This is my class class CT { public: CT() {}; ~CT() {}; int GetNum( void ) { return num; } void SetNum( int n ) { num = n; }
private: int num; };
static CT ct;
CT & getCT( void ) { return ct; }
I want to access ct object from boost.python, thanks for your advice.
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
If the c++ object is pointer, How do I write def function? def("getCT",getCT,return_value_policy<reference_existing_object>()); I think reference_existing_object may be changed, is right? "Leonard "paniq" Ritter" <paniq@paniq.org> wrote in message news:4238302A.5040205@paniq.org... if getCT had really failed, you would have get an exception when calling SetNum. try repr(a), and if the return type is None, SetNum is most probably of return type void. ??[?????] wrote:
this is python code def run(): myFoo = HoHo_PI.getCT() a = myFoo.SetNum( 50 ) b=str(a)
But b is none? why? thx
"Leonard "paniq" Ritter" <paniq@paniq.org> wrote in message news:42354F3F.5070406@paniq.org... ...
def("getCT",&getCT,return_value_policy<reference_existing_object>());
...
Ñî±ù[ÔŽŽúÂëÖ®¹â] wrote:
This is my class class CT { public: CT() {}; ~CT() {}; int GetNum( void ) { return num; } void SetNum( int n ) { num = n; }
private: int num; };
static CT ct;
CT & getCT( void ) { return ct; }
I want to access ct object from boost.python, thanks for your advice.
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
i dont understand you at all. have you read http://www.boost.org/libs/python/doc/tutorial/doc/html/index.html and especially http://www.boost.org/libs/python/doc/tutorial/doc/html/python/functions.html... Ñî±ù[Ô´´úÂëÖ®¹â] wrote:
If the c++ object is pointer, How do I write def function? def("getCT",getCT,return_value_policy<reference_existing_object>());
I think reference_existing_object may be changed, is right?
"Leonard "paniq" Ritter" <paniq@paniq.org> wrote in message news:4238302A.5040205@paniq.org... if getCT had really failed, you would have get an exception when calling SetNum. try repr(a), and if the return type is None, SetNum is most probably of return type void.
??[?????] wrote:
this is python code def run(): myFoo = HoHo_PI.getCT() a = myFoo.SetNum( 50 ) b=str(a)
But b is none? why? thx
"Leonard "paniq" Ritter" <paniq@paniq.org> wrote in message news:42354F3F.5070406@paniq.org... ...
def("getCT",&getCT,return_value_policy<reference_existing_object>());
...
Ñî±ù[Ô´´úÂëÖ®¹â] wrote:
This is my class class CT { public: CT() {}; ~CT() {}; int GetNum( void ) { return num; } void SetNum( int n ) { num = n; }
private: int num; };
static CT ct;
CT & getCT( void ) { return ct; }
I want to access ct object from boost.python, thanks for your advice.
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
The problem has been solved , thanks.... "Leonard "paniq" Ritter" <paniq@paniq.org> wrote in message news:42395C58.1050202@paniq.org... i dont understand you at all. have you read http://www.boost.org/libs/python/doc/tutorial/doc/html/index.html and especially http://www.boost.org/libs/python/doc/tutorial/doc/html/python/functions.html... Ñî±ù[ÔŽŽúÂëÖ®¹â] wrote:
If the c++ object is pointer, How do I write def function? def("getCT",getCT,return_value_policy<reference_existing_object>());
I think reference_existing_object may be changed, is right?
"Leonard "paniq" Ritter" <paniq@paniq.org> wrote in message news:4238302A.5040205@paniq.org... if getCT had really failed, you would have get an exception when calling SetNum. try repr(a), and if the return type is None, SetNum is most probably of return type void.
??[?????] wrote:
this is python code def run(): myFoo = HoHo_PI.getCT() a = myFoo.SetNum( 50 ) b=str(a)
But b is none? why? thx
"Leonard "paniq" Ritter" <paniq@paniq.org> wrote in message news:42354F3F.5070406@paniq.org... ...
def("getCT",&getCT,return_value_policy<reference_existing_object>());
...
Ñî±ù[ÔŽŽúÂëÖ®¹â] wrote:
This is my class class CT { public: CT() {}; ~CT() {}; int GetNum( void ) { return num; } void SetNum( int n ) { num = n; }
private: int num; };
static CT ct;
CT & getCT( void ) { return ct; }
I want to access ct object from boost.python, thanks for your advice.
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
_______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
participants (3)
-
??[?????] -
Leonard "paniq" Ritter -
���[Դ����֮��]