Re: [C++-sig] Conversion of python files to C++ ostreams

2010-04-06 Thread Christopher Bruns
On Sun, Apr 4, 2010 at 1:07 PM, Christopher Bruns wrote: [...] >>> // C++ API >>> struct Foo { >>>     Foo(ostream& os); >>> }; >>> >>> # desired python usage >>> foo = Foo(streambuf(sys.stdout)) Solved. Thanks everyone

Re: [C++-sig] Conversion of python files to C++ ostreams

2010-04-04 Thread Christopher Bruns
On Sat, Apr 3, 2010 at 8:54 PM, Ralf W. Grosse-Kunstleve wrote: >> // C++ API >> struct Foo { >>     Foo(ostream& os); >> }; >> >> # desired python usage >> foo = Foo(streambuf(sys.stdout)) > > Did you already try the usual > >  def(init((arg("os" Yes. Well pretty close. Py++ code generator

Re: [C++-sig] Conversion of python files to C++ ostreams

2010-04-04 Thread Christopher Bruns
On Sat, Apr 3, 2010 at 11:53 AM, troy d. straszheim wrote: > BOOST_PYTHON_MODULE(mod) > { >  def("sayhello", as( &sayhello )); >  //  arg converter       ^ > }; > > The as<> might need some clarification Thanks Troy for the helpful tip. I'm still confused by the "as<>" symbol. I

Re: [C++-sig] Conversion of python files to C++ ostreams

2010-04-03 Thread Christopher Bruns
On Thu, Apr 1, 2010 at 1:32 PM, Michele De Stefano wrote: > So, as shown into the doxygen example, you have to program a wrapper > like this one: > > foo_wrap(boost::python::object pyfile) { > >     mds_utils::python::oFileObj      fobj(py_file); > >     foo(fobj); > } That's clever. I wonder ho

Re: [C++-sig] Conversion of python files to C++ ostreams

2010-04-03 Thread Christopher Bruns
On Thu, Apr 1, 2010 at 7:11 PM, Ralf W. Grosse-Kunstleve wrote: >> Is it necessary to explicitly invoke the streambuf object from python? > > Yes. I could be different and in fact was different in the initial > implementation (if you look back in the svn history). But there were > a few subtle pro

Re: [C++-sig] Conversion of python files to C++ ostreams

2010-04-01 Thread Christopher Bruns
On Tue, Mar 30, 2010 at 11:33 AM, Ralf W. Grosse-Kunstleve wrote: > http://cctbx.svn.sourceforge.net/viewvc/cctbx/trunk/boost_adaptbx/python_streambuf.h?view=markup I have not seen this cctbx product before. It especially interesting to me, since I am performing molecular computations, and also

Re: [C++-sig] Conversion of python files to C++ ostreams

2010-04-01 Thread Christopher Bruns
On Tue, Mar 30, 2010 at 12:02 AM, Michele De Stefano wrote: > there is a much easier way to treat a FILE* as a C++ stream. The easy > way is to use my open source library (mds-utils, > http://code.google.com/p/mds-utils/). If I have a C++ api like: void foo(ostream& os); using mds-utils, would

[C++-sig] Conversion of python files to C++ ostreams

2010-03-29 Thread Christopher Bruns
I am trying to coax boost.python to automatically convert python files to C++ std::ostreams, for methods that take arguments of type "std::ostream&". I have made some progress, and I could use some advice on how to go further. I created a derived class of std::ostream, called FilestarOstream, whi

Re: [C++-sig] [Py++] Registration order corner case

2010-03-25 Thread Christopher Bruns
On Thu, Mar 25, 2010 at 2:20 PM, Roman Yakovenko wrote: >... > Is this an option to "drop" base classes: >... > If not, then there is one more option, but you definitely not going to > like it - to manipulate code creators tree. >... Thanks for the in depth explanation. I am glad to learn that t

Re: [C++-sig] [Py++] Registration order corner case

2010-03-25 Thread Christopher Bruns
010 at 8:34 PM, Christopher Bruns > wrote: >> ... >> //## foo.h ### >> struct Foo1 { struct Foo2; }; >> struct Foo3 : public Foo1 {}; >> struct Foo1::Foo2 : public Foo3 {}; >> ... > > I am pretty sure Py++ doesn't export such hierar

[C++-sig] [Py++] Registration order corner case

2010-03-25 Thread Christopher Bruns
Py++ has produced for me over 97,000 lines of beautiful boost.python wrapping code on my project, using less than 2500 lines of python. But I am still experiencing some minor troubles that prevent me from completing my project. Suppose I wish to wrap the following: //## foo.h ### stru

[C++-sig] [Py++] How to wrap default arg as enum with complicated scope?

2009-10-12 Thread Christopher Bruns
Below is a simplified example of a tricky wrapping problem I have encountered. The example remains somewhat complicated, but further simplification results in a file that causes no trouble. I get a compile error when I try to build the boost python code generated by the following case: test_

Re: [C++-sig] [Py++] Does pyplusplus respect explicit constructors?

2009-10-01 Thread Christopher Bruns
Roman Yakovenko wrote: > On Wed, Sep 30, 2009 at 6:18 PM, Christopher Bruns > wrote: > > I suspect I can manually adjust the implicitly_convertible tag > > generation using the "allow_implicit_conversion" flag in pyplusplus. > > Is there a way to tell

[C++-sig] [Py++] Does pyplusplus respect explicit constructors?

2009-09-30 Thread Christopher Bruns
Single-argument C++ constructors in pyplusplus seem to generate a boost::python::implicitly_convertible tag, even when the constructor is declared "explicit" in C++. That doesn't sound right to me. Shouldn't a pair of types that are not implicitly convertible in C++, also not be implicitly convert

[C++-sig] [Py++] Help with wrapping setter methods

2009-09-28 Thread Christopher Bruns
Please help. I am just a beginner with pyplusplus and am not smart enough to see how to create certain complex rules. How would I create a pyplusplus rule for setting the return policy to "return internal reference" for all member functions that meet the following criteria: * method name begins