Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Christopher Schramm
Thomas Berg wrote: > bp::scope sc(main); > bp::def("function", myfunction, "function helpstring"); Now that looks interesting. I'll implement that and let you know if it leads to any further problems. But it sounds like the perfect solution. > Found this out by reading the source

Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Thomas Berg
On Wed, Jun 24, 2009 at 10:26 PM, Christopher Schramm wrote: > > > Thomas Berg wrote: > >>     bp::object function = bp::object(myfunction); > > > > Great! And it was that simple... > > But wait... Giving that a second thought I don't think that's going to > exhaust bpy's full potential. At least

Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Christopher Schramm
> Thomas Berg wrote: >> bp::object function = bp::object(myfunction); > > Great! And it was that simple... But wait... Giving that a second thought I don't think that's going to exhaust bpy's full potential. At least I don't see a way to use it's docstring handling or call policies. I'll tes

Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Christopher Schramm
Thomas Berg wrote: > bp::object function = bp::object(myfunction); Great! And it was that simple... Thanks! ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Function handling with Boost

2009-06-24 Thread Thomas Berg
Hi, On Wed, Jun 24, 2009 at 7:52 AM, Christopher Schramm wrote: > > Stefan Seefeld wrote: > > An alternative is not to use BOOST_PYTHON_MODULE at all, but set up > > converters in ordinary C++ code. In the following I set up a Python > > interpreter in my main application, inject a (C++) base cla

Re: [C++-sig] Function handling with Boost

2009-06-23 Thread Christopher Schramm
Stefan Seefeld wrote: > An alternative is not to use BOOST_PYTHON_MODULE at all, but set up > converters in ordinary C++ code. In the following I set up a Python > interpreter in my main application, inject a (C++) base class, run a > Python script that adds a derived class, then instantiate and ru

Re: [C++-sig] Function handling with Boost

2009-06-23 Thread Stefan Seefeld
On 06/23/2009 04:43 PM, Christopher Schramm wrote: Stefan Seefeld wrote: You need a module into which to inject the symbols you export. That is true no matter the (meta)type of what you export, i.e. classes, functions, etc. Once you have that module set up (via BOOST_PYTHON_MODULE), you can

Re: [C++-sig] Function handling with Boost

2009-06-23 Thread Christopher Schramm
Stefan Seefeld wrote: > You need a module into which to inject the symbols you export. That is > true no matter the (meta)type of what you export, i.e. classes, > functions, etc. > Once you have that module set up (via BOOST_PYTHON_MODULE), you can > instantiate the newly created Python objects (ty

Re: [C++-sig] Function handling with Boost

2009-06-23 Thread Stefan Seefeld
On 06/23/2009 04:03 PM, Christopher Schramm wrote: Stefan Seefeld wrote: I read your original mail, but I didn't understand what you are trying to achieve. You certainly can export functions to python: void foo(...); ... bpl::def("foo", foo); works just fine. There shouldn't be any need

Re: [C++-sig] Function handling with Boost

2009-06-23 Thread Christopher Schramm
Stefan Seefeld wrote: > I read your original mail, but I didn't understand what you are trying > to achieve. You certainly can export functions to python: > > void foo(...); > > ... > > bpl::def("foo", foo); > > > works just fine. There shouldn't be any need to wrap the function in a > class (

Re: [C++-sig] Function handling with Boost

2009-06-23 Thread Stefan Seefeld
On 06/23/2009 02:32 PM, Christopher Schramm wrote: Mmmkay, looks like I found a dirty little workaround: I read your original mail, but I didn't understand what you are trying to achieve. You certainly can export functions to python: void foo(...); ... bpl::def("foo", foo); works jus

Re: [C++-sig] Function handling with Boost

2009-06-23 Thread Christopher Schramm
Mmmkay, looks like I found a dirty little workaround: I put the C++ functions, I want to expose into a dummy class: class Dummy { int f1(str arg1, ... void f2(tuple arg1, ... } And then create a bpy object from it: object tmp = class_("dummy") .def("f1", &Dummy::f1)

[C++-sig] Function handling with Boost

2009-06-21 Thread Christopher Schramm
Hi, I'm new to Python's C API and developing my very first project using Boost::Python (bpy). My goal is executing user defined scripts within an embedded python environment using custom stdout and stderr and providing a special built in module. Beside a bunch of classes (which can be defined usi