[C++-sig] two question from boost.python

2012-09-02 Thread simon zhang
The first question: The class_ class has four parameters,class template class_. I don't understand the parameters of Bases and HeldType.How to use the parameters. this doc: http://www.boost.org/doc/libs/1_51_0/libs/python/doc/v2/class.html The second question: I have to make a python function as

[C++-sig] How to make a python function as callback of a c++ function

2012-09-02 Thread simon zhang
I have to make a python function as callback of a c++ function.How to do?Where can I find some examples?? I want to use boost.python. I want my code look something like this: In C++ : typedef void (*MyCallback_t) (CallbackInfo); > class MyClass > {... > void setcallback(MyCallback_t cb); >

[C++-sig] How to compile static library with -fPIC from boost.python

2012-09-07 Thread simon zhang
Hi all Default,libboostpython.a has be compiled without -fPIC.But I have to make a python extending and it is a dynamic library with -fPIC that link to static library. How to compile static library (libboostpython.a) with -fPIC from boost.python simon _

[C++-sig] a boost.python question about parameter that is a pointer of instance.

2012-11-17 Thread simon zhang
This is a complex problem. I provide some code. c++ === #include #include #include class Rectangle { public: Rectangle(); virtual ~Rectangle(); void set(int lg,int wd) { long=lg; width=wd; }; int area() { return long*width; } ; int long;

Re: [C++-sig] a boost.python question about parameter that is a pointer of instance.

2012-11-17 Thread simon zhang
> func( &rt ); How to make a parameter of c++ instance's pointer to a python function. > def pfunc( ret ) > print ret.long > print ret.area() How to use c++ instance in python code. parameter 2012/11/17 Sybren A. Stüvel > On 17 November 2012 16:25, simon zhan

Re: [C++-sig] a boost.python question about parameter that is a pointer of instance.

2012-11-17 Thread simon zhang
yes..I try it.. Error:undefined symbol:_ZRI9Rectangle 2012/11/17 Sybren A. Stüvel > > On 17 November 2012 16:46, simon zhang wrote: > >> > func( &rt ); >> How to make a parameter of c++ instance's pointer to a python function. >> >> > def pfu

Re: [C++-sig] a boost.python question about parameter that is a pointer of instance.

2012-11-17 Thread simon zhang
) ; def("runtest",runtest); } 2012/11/18 simon zhang > yes..I try it.. > Error:undefined symbol:_ZRI9Rectangle > > 2012/11/17 Sybren A. Stüvel > >> >> On 17 November 2012 16:46, simon zhang wrote: >> >>> > func( &rt ); >>>

Re: [C++-sig] a boost.python question about parameter that is a pointer of instance.

2012-11-17 Thread simon zhang
18 Holger Brandsmeier > Have a look at > http://stackoverflow.com/questions/4331599/calling-python-functions-from-c > > On Sat, Nov 17, 2012 at 4:25 PM, simon zhang wrote: > > This is a complex problem. I provide some code. > > > > c++ > > =

Re: [C++-sig] a boost.python question about parameter that is a pointer of instance.

2012-11-17 Thread simon zhang
he object file generated from the definiton of Rectangle, > usually you would have a Rectangle.cpp and generate a Rectangle.o. > Your python module needs to link against Rectangle.o. > > On Sat, Nov 17, 2012 at 6:02 PM, simon zhang wrote: > > yes..I try it.. > > Erro

[C++-sig] Do the boost.python support member data pointer??

2012-11-30 Thread simon zhang
Do the boost.python support member data pointer?? ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

[C++-sig] How to find an object from tuple

2012-12-18 Thread simon zhang
I wanted to know a way to find an object from tuple.The tuple maybe set in python.The flowing is sample. ### #include using namespace boost::python; class A { public: A() { M=make_tule("ab","cd","1234"); }

[C++-sig] How to converter std::string* in boost.python?

2012-12-21 Thread simon zhang
How to converter std::string* in boost.python?I have to handle some data of c++ in python.The data may be big.So I return a pointer to python. But there are some errors. c++ #include #include class A {public: A() { data="342342fgsf"; ss=&data; } std::string *ss; s

[C++-sig] Trouble destructor, call python's object with pointer in boost.python

2012-12-22 Thread simon zhang
when I call python's function with pointer as an argument in boost.python, there are some troubles in destructor. The following is a sample code #include #include #include #include #include using namespace boost::python; class A {public: A() { std::cout<< "A start"< ("A",init<>())

Re: [C++-sig] Trouble destructor, call python's object with pointer in boost.python

2012-12-22 Thread simon zhang
ject _obj; > > > Note that both "aa" objects are wrapped by a call to "ptr()" > > Just be careful with the python when doing this, as it can cause a crash > if python tries to access that object after its C++ lifetime has ended. So > always make sure t

[C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-22 Thread simon zhang
I have make a boost.python module with an endless loop.But I can't kill the process by ctrl-c.The following is an example. C++ #include #include #include #include usring namespace boost::python; void foo() { int it=0; while (true) { //endless loop ++it; st

Re: [C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-22 Thread simon zhang
handlers (including SIGINT) to send python exceptions instead of killing > the process. This may be what's hitting you. > > > On 12/23/2012 1:44 AM, simon zhang wrote: > > I have make a boost.python module with an endless loop.But I can't kill > the process by ctrl-c.T

Re: [C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-23 Thread simon zhang
I do embedded and extended.Anyway, thank you for your reply. :) This boost.python document is so complex. :( 2012/12/23 Jaedyn K. Draper > Oh, my mistake. Not sure then, I've only embedded, never extended. Maybe > someone else can help. :( > > > On 12/23/2012 1:59 A

Re: [C++-sig] How to converter std::string* in boost.python?

2012-12-23 Thread simon zhang
..so,It seems I can only convert std::string and make a deep copy.I can only avoid it as much as possible.Thank you. 2012/12/22 Jim Bosch > On 12/21/2012 03:52 AM, simon zhang wrote: > >> How to converter std::string* in boost.python?I have to handle some data >> of c++ in p

Re: [C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-23 Thread simon zhang
This is the answer from the stackoverflow. while (true) { //endless loop ++it; std::cout<< it < > Oh, my mistake. Not sure then, I've only embedded, never extended. Maybe > someone else can help. :( > > > On 12/23/2012 1:59 AM, simon zhang

Re: [C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-23 Thread simon zhang
); >} >} > > > 2012/12/23 Jaedyn K. Draper > >> Oh, my mistake. Not sure then, I've only embedded, never extended. Maybe >> someone else can help. :( >> >> >> On 12/23/2012 1:59 AM, simon zhang wrote: >> >> But I don&#x

Re: [C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

2012-12-23 Thread simon zhang
g the desired string as a reference > parameter, rather than trying to return it. Again, I'm not sure if this > will work or not, as I've never tried it. > > If neither of those work, I'd have to play around with it some to see if I > could come up with anything else

Re: [C++-sig] How to converter std::string* in boost.python?

2012-12-24 Thread simon zhang
stem is always limited. > > Niall > > On 23 Dec 2012 at 16:16, simon zhang wrote: > > > ..so,It seems I can only convert std::string and make a deep copy.I can > > only avoid it as much as possible.Thank you. > > > > > > 2012/12/22 Jim Bosch > > > &

[C++-sig] compile some code with boost.python by mingw in win7-64bit

2012-12-30 Thread simon zhang
I decided to make my program compatible with windows environment.But I have very little programming experience on windows.There are some errors need help. Environment: - os: win7-64bit, - ide: codeblocks12.11, - python: Python 2.7.3 Windows X86-64 Installer (Windows AMD64 / Intel 64 /

Re: [C++-sig] compile some code with boost.python by mingw in win7-64bit

2013-01-04 Thread simon zhang
here are references to this problem already from > other people. > > On Mon, Dec 31, 2012 at 1:27 AM, simon zhang wrote: > > > > I decided to make my program compatible with windows environment.But I > > have very little programming experience on windows.There are some e