Re: [C++-sig] [py++] Problem: empty xml file created

2008-12-02 Thread Marcus Lindblom

Roman Yakovenko wrote:

2008/12/2 Marcus Lindblom <[EMAIL PROTECTED]>:

Hi all,

I'm trying to get OpenSG's python-bindings to work on Windows (and
contruibuting that back to the project), and trying to track down an
exception that get's thrown when running it's gen_bindings.py. (see attached
log.txt for output)


[snip]


The PyOpenSG-devs have only used linux, and have maybe seen this before,
earlier, but can't recall what and when. They also have used a earlier
py++-version, but I'm using 1.0. I might be shooting myself in the foot with
that, but I hope not.


There were few changes here and there, but it should not be too
dificcult to upgrade,


That's what I'm hoping for. :)


The output contains the following command:

""C:\program files\bin\gccxml.exe"
/IJ:\3rd\OpenSG\opensg2_trunk\build.win32.cl.9.0\instlinks\include
/IC:\Program Files oost oost_1_36_0 -DBOOST_PYTHON_MAX_ARITY=21
-I"." -I"osg_module"
-I"J:\3rd\OpenSG\opensg2_trunk\build.win32.cl.9.0\instlinks\include"
-I"J:\3rd\OpenSG\opensg2_trunk\build.win32.cl.9.0\instlinks\include\OpenSG"
-I"j:\3rd\boost\boost_1_36_0" -I"c:\dev\python26\include"
"osg_module\osgmodule_mainheader.h"
-fxml="c:\users\marcusl\appdata\local\temp\tmp1e92ik.xml""

Can you run the command, from cmd and check that file was created and
contains data.


Ok. It came right back at me:

pyopensg/src> ** the above **
Could not determine compiler setting.
Could not determine GCCXML_FLAGS setting.
pyopensg/src>

So, I changed it to run my compiled gccxml (pretty recent cvs head) and 
added "--gccxml-compiler cl" (I use VS9 and python 2.6) and fixed the 
include paths (pyopensg retrieves includepaths from the osg2-config 
python script, which used /I instead of /I and also had some non-escaped 
backslashes (turing 'c:\program files\boost' into 'c:\program files 
oost' as can be seen above :)


Running the modified cmd-line made gccxml run and print a whole lot, 
starting with:


j:/3rd/OpenSG/opensg2_trunk/build.win32.cl.9.0/instlinks/include/OpenSG/OSGConfig.h:135:2: 
error: #error Endian determination : could not guess your plattform


and ending up with an ICE.

It seems as I have to add a few defines and such to get the 
opensg-sources to identify the compiler correctly.


I can handle the osg2-config script myself, and probably figure out what 
defines are necessary, but where do I set compiler-arg + defines that 
are used when doing the cache-step that calls the above command?


Is this cache stuff in PyOpenSG or Py++? (because I can't seem to find 
any such call in gen_bindings.main() nor nearby related modules, unless 
I've missed something).


Cheers,
/Marcus
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Mihail Konstantinov
Hello,
I am still in the early process of learning boost.python.
I have reduced my problem to the following code:

#include 
using namespace boost::python;
class A{
private:
  A(const A&){}; //no public copy constructor
};
class B: public A{
public:
  B(){};
};
BOOST_PYTHON_MODULE(boost_ext)
{
class_("A",init<>());
class_ >("B",init<>());
}

When running bjam on this example, I get
"boost.cpp:6: error: ‘A::A(const A&)’ is private"
as the first error among a long list of hints from the compiler.

How can I expose the classes with their constructors to python?

Thank you
Mihail



  

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] [py++] Problem: empty xml file created

2008-12-02 Thread Roman Yakovenko
On Tue, Dec 2, 2008 at 3:15 PM, Marcus Lindblom <[EMAIL PROTECTED]> wrote:
> Ok. It came right back at me:
>
> pyopensg/src> ** the above **
> Could not determine compiler setting.
> Could not determine GCCXML_FLAGS setting.
> pyopensg/src>
>
> So, I changed it to run my compiled gccxml (pretty recent cvs head) and
> added "--gccxml-compiler cl" (I use VS9 and python 2.6) and fixed the
> include paths (pyopensg retrieves includepaths from the osg2-config python
> script, which used /I instead of /I and also had some non-escaped
> backslashes (turing 'c:\program files\boost' into 'c:\program files oost' as
> can be seen above :)
>
> Running the modified cmd-line made gccxml run and print a whole lot,
> starting with:
>
> j:/3rd/OpenSG/opensg2_trunk/build.win32.cl.9.0/instlinks/include/OpenSG/OSGConfig.h:135:2:
> error: #error Endian determination : could not guess your plattform
>
> and ending up with an ICE.
>
> It seems as I have to add a few defines and such to get the opensg-sources
> to identify the compiler correctly.
>
> I can handle the osg2-config script myself, and probably figure out what
> defines are necessary, but where do I set compiler-arg + defines that are
> used when doing the cache-step that calls the above command?

gen_bindings.py file contains the following lines:

813mb = ModuleBuilder([main_header_filename],
814   working_directory = ".",
815   include_paths=inc_path,
816   cache=cache_file+".module",
817   define_symbols=defines,
818   ignore_gccxml_output=True,
819   optimize_queries=use_query_opt,
820   #start_with_declarations=["OSG",],
821   cflags=opensg_cflags + " " + boost_cflags)

opensg_cflags, boost_cflags variables contains the configuration flags

> Is this cache stuff in PyOpenSG or Py++? (because I can't seem to find any
> such call in gen_bindings.main() nor nearby related modules, unless I've
> missed something).

I don't understand the question, sorry :-(



-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Mihail Konstantinov
Sorry, the public A::A() constructor was missing. The corrected class A, which 
caused the described problem, is:

class A{
private:
  A(const A&){}; //no public copy constructor
public:
  A(){};
};



  

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Stefan Seefeld

Mihail Konstantinov wrote:

Hello,
I am still in the early process of learning boost.python.
I have reduced my problem to the following code:

#include 
using namespace boost::python;
class A{
private:
  A(const A&){}; //no public copy constructor
};
class B: public A{
public:
  B(){};
};
BOOST_PYTHON_MODULE(boost_ext)
{
class_("A",init<>());
class_ >("B",init<>());
}

When running bjam on this example, I get
"boost.cpp:6: error: ‘A::A(const A&)’ is private"
as the first error among a long list of hints from the compiler.
  



In this case you want to tell Python that your object is non-copyable:

class_ a("A", init<>);
...

See 
http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/class.html#class_-spec 
for details.


HTH,
  Stefan

--

 ...ich hab' noch einen Koffer in Berlin...

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] [py++] Problem: empty xml file created

2008-12-02 Thread Marcus Lindblom

Roman Yakovenko wrote:

On Tue, Dec 2, 2008 at 3:15 PM, Marcus Lindblom <[EMAIL PROTECTED]> wrote:

Ok. It came right back at me:

pyopensg/src> ** the above **
Could not determine compiler setting.
Could not determine GCCXML_FLAGS setting.
pyopensg/src>

So, I changed it to run my compiled gccxml (pretty recent cvs head) and
added "--gccxml-compiler cl" (I use VS9 and python 2.6) and fixed the
include paths (pyopensg retrieves includepaths from the osg2-config python
script, which used /I instead of /I and also had some non-escaped
backslashes (turing 'c:\program files\boost' into 'c:\program files oost' as
can be seen above :)

Running the modified cmd-line made gccxml run and print a whole lot,
starting with:

j:/3rd/OpenSG/opensg2_trunk/build.win32.cl.9.0/instlinks/include/OpenSG/OSGConfig.h:135:2:
error: #error Endian determination : could not guess your plattform

and ending up with an ICE.

It seems as I have to add a few defines and such to get the opensg-sources
to identify the compiler correctly.

I can handle the osg2-config script myself, and probably figure out what
defines are necessary, but where do I set compiler-arg + defines that are
used when doing the cache-step that calls the above command?


gen_bindings.py file contains the following lines:

813mb = ModuleBuilder([main_header_filename],
814   working_directory = ".",
815   include_paths=inc_path,
816   cache=cache_file+".module",
817   define_symbols=defines,
818   ignore_gccxml_output=True,
819   optimize_queries=use_query_opt,
820   #start_with_declarations=["OSG",],
821   cflags=opensg_cflags + " " + boost_cflags)

opensg_cflags, boost_cflags variables contains the configuration flags


Yes, but IIUC, this is way after the call to gccxml that I ran above, 
since the follwing is printed after the 'INFO gccxml cmd: ...' in the 
log-file in my first post:


566 print "Auto-building list of node cores using .fcd files... "


Is this cache stuff in PyOpenSG or Py++? (because I can't seem to find any
such call in gen_bindings.main() nor nearby related modules, unless I've
missed something).


I don't understand the question, sorry :-(


No worries. :)

The call to gccxml that you asked me to run does not produce a valid 
ouput file, because it's needs fixing.


So, I'm guessing a bit here, but since the log contains stuff about 
cache file load failure and cache creation, which does the gccxml-call 
that I need to augment with defines and --gccxml-compiler option, I 
assumed I need to fix the gccxml call in the cache-creation thingy, not 
the call to ModuleBuilder way below. (which tries to use the empty file 
that gccxml failed to create earlier.)


So, my question is, where does that gccxml call come from, and how do I 
change it's parameters? (Is even a py++ thing, or does it come from a 
pyopensg somewhere I've missed?)


(I don't think the gccxml-call happens because of the call to the 
ModuleBuilder at line 813, although I might be wrong?)


Does that make sense?

I'll tinker with the ModuleBuilder a bit anyway.. to see if it helps, 
but the order of output makes me think the problem is somewhere else.


Cheers,
/Marcus

P.S. Thanks for helping out! I'm ping-pong:ing a bit between the 
opensg-list and this one, so if I need to address my questions the other 
way, let me know.

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Mihail Konstantinov
> Stefan Seefeld wrote:

> 
> In this case you want to tell Python that your object is non-copyable:

I followed your suggestion and still get the same error message:
boost.cpp:6: error: ‘A::A(const A&)’ is private
(full bjam output is appended to this email)

Could you check this modified code? boost_ext.cpp:
#include 
using namespace boost::python;

class A{
private:
  A(const A&){}; //no public copy constructor
public:
  A(){};
};

class B: public A{
public:
  B(){};
};

BOOST_PYTHON_MODULE(boost_ext)
{
class_ a("A",init<>());
class_ >("B",init<>());
}

Thank you
Mihail

Compilation output:

$bjam boost_ext
...patience...
...found 1202 targets...
...updating 2 targets...
gcc.compile.c++ bin/gcc-4.1.2/debug/boost.o
boost.cpp: In copy constructor ‘B::B(const B&)’:
boost.cpp:11:   instantiated from 
‘boost::python::objects::value_holder::value_holder(PyObject*, A0) [with 
A0 = boost::reference_wrapper, Value = B]’
/home/mihail/temporary/boost_1_37_0/boost/python/object/make_instance.hpp:68:   
instantiated from ‘static Holder* boost::python::objects::make_instance::construct(void*, PyObject*, boost::reference_wrapper) [with T 
= B, Holder = boost::python::objects::value_holder]’
/home/mihail/temporary/boost_1_37_0/boost/python/object/make_instance.hpp:42:   
instantiated from ‘static PyObject* 
boost::python::objects::make_instance_impl::execute(Arg&) 
[with Arg = const boost::reference_wrapper, T = B, Holder = 
boost::python::objects::value_holder, Derived = 
boost::python::objects::make_instance >]’
/home/mihail/temporary/boost_1_37_0/boost/python/object/class_wrapper.hpp:29:   
instantiated from ‘static PyObject* 
boost::python::objects::class_cref_wrapper::convert(const 
Src&) [with Src = B, MakeInstance = boost::python::objects::make_instance >]’
/home/mihail/temporary/boost_1_37_0/boost/python/converter/as_to_python_function.hpp:27:
   instantiated from ‘static PyObject* 
boost::python::converter::as_to_python_function::convert(const 
void*) [with T = B, ToPython = boost::python::objects::class_cref_wrapper > >]’
/home/mihail/temporary/boost_1_37_0/boost/python/to_python_converter.hpp:87:   
instantiated from ‘boost::python::to_python_converter::to_python_converter() [with T = B, Conversion = 
boost::python::objects::class_cref_wrapper > >, bool has_get_pytype = true]’
/home/mihail/temporary/boost_1_37_0/boost/python/object/class_wrapper.hpp:26:   
instantiated from ‘static void boost::python::objects::class_metadata::maybe_register_class_to_python(T2*, mpl_::false_) [with T2 = B, T = B, 
X1 = boost::python::bases, 
X2 = boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/home/mihail/temporary/boost_1_37_0/boost/python/object/class_metadata.hpp:229: 
  instantiated from ‘static void boost::python::objects::class_metadata::register_aux2(T2*, Callback) [with T2 = B, Callback = 
boost::integral_constant, T = B, X1 = boost::python::bases, X2 = 
boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/home/mihail/temporary/boost_1_37_0/boost/python/object/class_metadata.hpp:219: 
  instantiated from ‘static void boost::python::objects::class_metadata::register_aux(void*) [with T = B, X1 = boost::python::bases, X2 = 
boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/home/mihail/temporary/boost_1_37_0/boost/python/object/class_metadata.hpp:205: 
  instantiated from ‘static void boost::python::objects::class_metadata::register_() [with T = B, X1 = boost::python::bases, X2 = boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/home/mihail/temporary/boost_1_37_0/boost/python/class.hpp:496:   instantiated 
from ‘void boost::python::class_::initialize(const DefVisitor&) 
[with DefVisitor = boost::python::init_base >, W = B, X1 = boost::python::bases, X2 = boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/home/mihail/temporary/boost_1_37_0/boost/python/class.hpp:208:   instantiated 
from ‘boost::python::class_::class_(const char*, const 
boost::python::init_base&) [with DerivedT = 
boost::python::init, W = B, X1 = 
boost::python::bases, X2 = 
boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
boost.cpp:19:   instantiated from here
boost.cpp:6: error: ‘A::A(const A&)’ is private
boost.cpp:11: error: within this context
/home/mihail/temporary/boost_1_37_0/boost/python/object/value_holder.hpp: In 
constructor 
‘boost::python::objects::value_holder::value_holder(PyObject*, A0) [with 
A0 = boost::reference_wrapper, Value = B]’:
/home/mihail/temporary/boost_1_37_0/boost/python/object/value_holder.hpp:134: 
note: synthesized method ‘B::B(const B&)’ first required here 

"g++"  -ftemplate-depth-128 -O0 -fno-inline -Wall -g -fPIC
-I"/home/mihail/temporary/boost_1_37_0" -I"/usr/include/python2.5" -c -o 
"bin/gcc-4.1.2/debug/boost.o" "boost.cpp"

...failed gcc.compile.c++ bin/gcc-4.1.2/debug/boost.o
...skipped boost_e

Re: [C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Renato Araujo
try use boost::noncopyable to B or implemente a copy constructor in B
without call A copy contructor.

BR



On Tue, Dec 2, 2008 at 11:03 AM, Mihail Konstantinov
<[EMAIL PROTECTED]> wrote:
>> Stefan Seefeld wrote:
>
>>
>> In this case you want to tell Python that your object is non-copyable:
>
> I followed your suggestion and still get the same error message:
> boost.cpp:6: error: 'A::A(const A&)' is private
> (full bjam output is appended to this email)
>
> Could you check this modified code? boost_ext.cpp:
> #include 
> using namespace boost::python;
>
> class A{
> private:
>  A(const A&){}; //no public copy constructor
> public:
>  A(){};
> };
>
> class B: public A{
> public:
>  B(){};
> };
>
> BOOST_PYTHON_MODULE(boost_ext)
> {
>class_ a("A",init<>());
>class_ >("B",init<>());
> }
>
> Thank you
> Mihail
>
> Compilation output:
>
> $bjam boost_ext
> ...patience...
> ...found 1202 targets...
> ...updating 2 targets...
> gcc.compile.c++ bin/gcc-4.1.2/debug/boost.o
> boost.cpp: In copy constructor 'B::B(const B&)':
> boost.cpp:11:   instantiated from 
> 'boost::python::objects::value_holder::value_holder(PyObject*, A0) 
> [with A0 = boost::reference_wrapper, Value = B]'
> /home/mihail/temporary/boost_1_37_0/boost/python/object/make_instance.hpp:68: 
>   instantiated from 'static Holder* boost::python::objects::make_instance Holder>::construct(void*, PyObject*, boost::reference_wrapper) [with 
> T = B, Holder = boost::python::objects::value_holder]'
> /home/mihail/temporary/boost_1_37_0/boost/python/object/make_instance.hpp:42: 
>   instantiated from 'static PyObject* 
> boost::python::objects::make_instance_impl::execute(Arg&) 
> [with Arg = const boost::reference_wrapper, T = B, Holder = 
> boost::python::objects::value_holder, Derived = 
> boost::python::objects::make_instance boost::python::objects::value_holder >]'
> /home/mihail/temporary/boost_1_37_0/boost/python/object/class_wrapper.hpp:29: 
>   instantiated from 'static PyObject* 
> boost::python::objects::class_cref_wrapper::convert(const 
> Src&) [with Src = B, MakeInstance = boost::python::objects::make_instance boost::python::objects::value_holder >]'
> /home/mihail/temporary/boost_1_37_0/boost/python/converter/as_to_python_function.hpp:27:
>instantiated from 'static PyObject* 
> boost::python::converter::as_to_python_function::convert(const 
> void*) [with T = B, ToPython = boost::python::objects::class_cref_wrapper boost::python::objects::make_instance boost::python::objects::value_holder > >]'
> /home/mihail/temporary/boost_1_37_0/boost/python/to_python_converter.hpp:87:  
>  instantiated from 'boost::python::to_python_converter has_get_pytype>::to_python_converter() [with T = B, Conversion = 
> boost::python::objects::class_cref_wrapper boost::python::objects::make_instance boost::python::objects::value_holder > >, bool has_get_pytype = true]'
> /home/mihail/temporary/boost_1_37_0/boost/python/object/class_wrapper.hpp:26: 
>   instantiated from 'static void boost::python::objects::class_metadata X1, X2, X3>::maybe_register_class_to_python(T2*, mpl_::false_) [with T2 = B, 
> T = B, X1 = boost::python::bases mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, 
> mpl_::void_>, X2 = boost::python::detail::not_specified, X3 = 
> boost::python::detail::not_specified]'
> /home/mihail/temporary/boost_1_37_0/boost/python/object/class_metadata.hpp:229:
>instantiated from 'static void boost::python::objects::class_metadata X1, X2, X3>::register_aux2(T2*, Callback) [with T2 = B, Callback = 
> boost::integral_constant, T = B, X1 = boost::python::bases mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, 
> mpl_::void_, mpl_::void_, mpl_::void_>, X2 = 
> boost::python::detail::not_specified, X3 = 
> boost::python::detail::not_specified]'
> /home/mihail/temporary/boost_1_37_0/boost/python/object/class_metadata.hpp:219:
>instantiated from 'static void boost::python::objects::class_metadata X1, X2, X3>::register_aux(void*) [with T = B, X1 = boost::python::bases mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, 
> mpl_::void_, mpl_::void_, mpl_::void_>, X2 = 
> boost::python::detail::not_specified, X3 = 
> boost::python::detail::not_specified]'
> /home/mihail/temporary/boost_1_37_0/boost/python/object/class_metadata.hpp:205:
>instantiated from 'static void boost::python::objects::class_metadata X1, X2, X3>::register_() [with T = B, X1 = boost::python::bases mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, 
> mpl_::void_, mpl_::void_, mpl_::void_>, X2 = 
> boost::python::detail::not_specified, X3 = 
> boost::python::detail::not_specified]'
> /home/mihail/temporary/boost_1_37_0/boost/python/class.hpp:496:   
> instantiated from 'void boost::python::class_ X3>::initialize(const DefVisitor&) [with DefVisitor = 
> boost::python::init_base mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, 
> mpl_::void_, mpl_::void_, mp

Re: [C++-sig] [py++] Problem: empty xml file created

2008-12-02 Thread Marcus Lindblom

Marcus Lindblom wrote:

(I don't think the gccxml-call happens because of the call to the 
ModuleBuilder at line 813, although I might be wrong?)


Waitaminute. When I'm rerunning it now, the order makes more sense, and 
the cache-calls come up after the calls to ModuleBuilder. Probably the 
log-file merging of stdout and stderr was playing tricks on me.


I'll look augmenting the ModuleBuilder call, just as you said. Sorry for 
the confusion. :-/


cheers
/Marcus
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Marcus Lindblom

Mihail Konstantinov wrote:

Stefan Seefeld wrote:



In this case you want to tell Python that your object is non-copyable:


I followed your suggestion and still get the same error message:


[snip]


/home/mihail/temporary/boost_1_37_0/boost/python/object/value_holder.hpp: In constructor 
‘boost::python::objects::value_holder::value_holder(PyObject*, A0) [with A0 = 
boost::reference_wrapper, Value = B]’:
/home/mihail/temporary/boost_1_37_0/boost/python/object/value_holder.hpp:134: note: synthesized method ‘B::B(const B&)’ first required here 


Seems like B needs to be noncopyable too?

/Marcus
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Roman Yakovenko
On Tue, Dec 2, 2008 at 4:11 PM, Renato Araujo <[EMAIL PROTECTED]> wrote:
> try use boost::noncopyable to B or implemente a copy constructor in B
> without call A copy contructor.

He is right. The following code was generated by Py++:

#include "boost/python.hpp"

namespace bp = boost::python;

BOOST_PYTHON_MODULE(pyplusplus){
bp::class_< A, boost::noncopyable >( "A", bp::init< >() );

bp::class_< B, bp::bases< A >, boost::noncopyable >( "B", bp::init< >() );
}

Py++ has some GUI too (
http://language-binding.net/pyplusplus/documentation/tutorials/pyplusplus_gui.html
) - no need to learn API
-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Stefan Seefeld

Mihail Konstantinov wrote:


gcc.compile.c++ bin/gcc-4.1.2/debug/boost.o
boost.cpp: In copy constructor ‘B::B(const B&)’:
  


As this error message suggests: as B derives from A, it is (by default) 
non-copyable, too. That you have to tell python, too, thus:


class_ a("A", init<>);
class_, noncopyable> b("B", init<>);
...

HTH,
  Stefan


--

 ...ich hab' noch einen Koffer in Berlin...

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Mihail Konstantinov
> try use boost::noncopyable to B or implemente a copy constructor in B

> without call A copy contructor.

Thank you. This works:
BOOST_PYTHON_MODULE(boost_ext)
{
class_ a("A",init<>());
class_, boost::noncopyable >("B",init<>());
}

One more question about the syntax. You cited 
http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/class.html#class_-spec 
which specifies the syntax as "class_" so that I 
thought I have to include all 4 template arguments. But when I used instead of 
the above (working!) solution:
class_, A, boost::noncopyable> a("A",init<>());
class_, B, boost::noncopyable >("B",init<>());
I get the error:
>/home/mihail/temporary/boost_1_37_0/boost/python/object/value_holder.hpp:159: 
>error: no matching function for call to
>‘B::B(PyObject*&)’
>boost.cpp:13: note: candidates are: B::B()
>boost.cpp:11: note: B::B(const B&)

Why does the abbreviated template argument list work, and why not the complete 
argument list?

Thank you
Mihail



  

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] boost.python: private copy constructor problem

2008-12-02 Thread Stefan Seefeld

Mihail Konstantinov wrote:
One more question about the syntax. You cited 
http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/class.html#class_-spec 
which specifies the syntax as "class_" 
so that I thought I have to include all 4 template arguments. But when 
I used instead of the above (working!) solution:

class_, A, boost::noncopyable> a("A",init<>());
class_, B, boost::noncopyable >("B",init<>());
I get the error:
  

/home/mihail/temporary/boost_1_37_0/boost/python/object/value_holder.hpp:159: 
error: no matching function for call to
‘B::B(PyObject*&)’
boost.cpp:13: note: candidates are: B::B()
boost.cpp:11: note: B::B(const B&)



Why does the abbreviated template argument list work, and why not the complete 
argument list?
  


As the docs say, all but the first template argument are optional. And, 
thanks to some meta-programming magic, their order doesn't matter.
The above link also discusses requirements on the HeldType, such as "its 
exposed constructor(s) must accept an initial |PyObject*| argument..."


Again, may not actually need to care about the HeldType if the defaults 
work fine for you.


HTH,
  Stefan

--

 ...ich hab' noch einen Koffer in Berlin...

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

[C++-sig] [py++] Problem: empty xml file created

2008-12-02 Thread Marcus Lindblom

Hi all,

I'm trying to get OpenSG's python-bindings to work on Windows (and 
contruibuting that back to the project), and trying to track down an 
exception that get's thrown when running it's gen_bindings.py. (see 
attached log.txt for output)


The source for gen_bindings.py is here, for reference:

https://realityforge.vrsource.org/trac/pyopensg/browser/branches/trunk_update/src/gen_bindings.py


From what I can see, the exception is thrown, as can be seen, in 
read_gccxml_file in pygccxml/parser/source_reader.py. The generation of 
the temp xml file (self.create_xml_file( ffname )) creates an empty 
file, which then gets a syntax error when read back.


As I'm rather new to py++ (being old on c++ and average on python) I 
don't really know where to look when hunting for this bug.


The PyOpenSG-devs have only used linux, and have maybe seen this before, 
earlier, but can't recall what and when. They also have used a earlier 
py++-version, but I'm using 1.0. I might be shooting myself in the foot 
with that, but I hope not.


All help gratefully recieved. :)

Cheers,
/Marcus

J:\3rd\OpenSG\pyopensg_trunk_update\src>c:\dev\python26\python 
.\gen_bindings.py -s J:\3rd\OpenSG\opensg2_trunk\source\ -b 
j:\3rd\boost\boost_1_36_0 -c 
J:\3rd\OpenSG\opensg2_trunk\source\\..\build.win32.cl.9.0\instlinks\bin\ 
c:\dev\python26\lib\site-packages\pygccxml\parser\declarations_cache.py:8: 
DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
INFO Loading cache file "pypp.pyopensg.cache.module".
ERROR Error occured while reading cache file: 
Traceback (most recent call last):
  File 
"c:\dev\Python26\lib\site-packages\pygccxml\parser\declarations_cache.py", line 
156, in __load
cache = cPickle.load( cache_file_obj )
EOFError
INFO Invalid cache file: [pypp.pyopensg.cache.module]  Regenerating.
INFO Parsing source file "osg_module\osgmodule_mainheader.h" ... 
INFO gccxml cmd: ""C:\program files\bin\gccxml.exe"  
/IJ:\3rd\OpenSG\opensg2_trunk\build.win32.cl.9.0\instlinks\include /IC:\Program 
Filesoostoost_1_36_0 -DBOOST_PYTHON_MAX_ARITY=21   -I"." -I"osg_module" 
-I"J:\3rd\OpenSG\opensg2_trunk\build.win32.cl.9.0\instlinks\include" 
-I"J:\3rd\OpenSG\opensg2_trunk\build.win32.cl.9.0\instlinks\include\OpenSG" 
-I"j:\3rd\boost\boost_1_36_0" -I"c:\dev\python26\include"   
"osg_module\osgmodule_mainheader.h" 
-fxml="c:\users\marcusl\appdata\local\temp\tmp1e92ik.xml""
Auto-building list of node cores using .fcd files... 
Node cores found:  195
Building PyOpenSG module
setting up templates...
  creating header file: osg_module\osgmodule_mainheader.h
creating builder and parsing.
{'optimize_queries': True, 'cache': 'pypp.pyopensg.cache.module', 
'include_paths': ['osg_module', 
'J:\\3rd\\OpenSG\\opensg2_trunk\\build.win32.cl.9.0\\instlinks\\include', 
'J:\\3rd\\OpenSG\\opensg2_trunk\\build.win32.cl.9.0\\instlinks\\include\\OpenSG',
 'j:\\3rd\\boost\\boost_1_36_0', 'c:\\dev\\python26\\include'], 
'define_symbols': [], 'cflags': 
'/IJ:\\3rd\\OpenSG\\opensg2_trunk\\build.win32.cl.9.0\\instlinks\\include 
/IC:\\Program Files\x08oost\x08oost_1_36_0 -DBOOST_PYTHON_MAX_ARITY=21', 
'ignore_gccxml_output': True, 'working_directory': '.'}
No handlers could be found for logger "pygccxml"
Traceback (most recent call last):
  File ".\gen_bindings.py", line 1918, in 
main()
  File ".\gen_bindings.py", line 843, in main
mb = ModuleBuilder([main_header_filename], **kwargs)
  File 
"C:\dev\python26\lib\site-packages\pyplusplus\module_builder\builder.py", line 
92, in __init__
, indexing_suite_version)
  File 
"C:\dev\python26\lib\site-packages\pyplusplus\module_builder\builder.py", line 
146, in __parse_declarations
decls = reader.read_files( files, compilation_mode )
  File "c:\dev\Python26\lib\site-packages\pygccxml\parser\project_reader.py", 
line 225, in read_files
return self.__parse_file_by_file(files)
  File "c:\dev\Python26\lib\site-packages\pygccxml\parser\project_reader.py", 
line 250, in __parse_file_by_file
decls = reader.read_file( header )
  File "c:\dev\Python26\lib\site-packages\pygccxml\parser\source_reader.py", 
line 197, in read_file
return self.read_gccxml_file( source_file )
  File "c:\dev\Python26\lib\site-packages\pygccxml\parser\source_reader.py", 
line 224, in read_gccxml_file
raise error
SyntaxError: no element found: line 1, column 0
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] gccxml

2008-12-02 Thread Alan Baljeu
This is getting out of hand :-(

All I wanted to do was parse some simple C++ function declarations to generate 
a corresponding py-callable wrapper.  To do this I need to get pygccxml.  Then 
I need gccxml to use pygccxml.  To get that I need WinCVS or some equivalent 
(which version, and learn how CVS works) or Cygwin.  Then I need to choose the 
preferred version of gccxml.  And then I need to obtain CMake to install it?

I think I'd rather just do my own thing, except that C++ is so warty it's 
difficult to come up with anything reasonable that will serve the purpose.

Alan Baljeu



- Original Message 
From: Roman Yakovenko <[EMAIL PROTECTED]>
To: Development of Python/C++ integration 
Sent: Tuesday, December 2, 2008 2:37:46 AM
Subject: Re: [C++-sig] gccxml

On Mon, Dec 1, 2008 at 11:29 PM, Alan Baljeu <[EMAIL PROTECTED]> wrote:
> I'm lost getting the right gccxml for use with pygccxml.  And of course that 
> would be used in Pybindgen and/or py++.
>
> The links point to a gccxml page which advertises version 0.6, but docs talk 
> about versions 0.7 and 0.9.  Anyhow, I downloaded 0.6 and didn't have much 
> success.  But then I'm not sure what I'm supposed to do to get a proper scan. 
>  I also don't get where I would find 0.7 or 0.9 versions.  Ideally I'd just 
> like a documented package that gives me everything together that I can test 
> out.

Unfortunately there is no GUI to install gccxml.
http://gccxml.org/HTML/Install.html contains set of simple
instructions to install latest GCCXML. It takes only few minutes to
install it.
If you use Ubuntu Linux, that you can install it using Synaptic.

HTH

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig



  __
Instant Messaging, free SMS, sharing photos and more... Try the new Yahoo! 
Canada Messenger at http://ca.beta.messenger.yahoo.com/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] gccxml

2008-12-02 Thread Stefan Seefeld

Alan Baljeu wrote:

This is getting out of hand :-(
  



I think I'd rather just do my own thing, except that C++ is so warty it's 
difficult to come up with anything reasonable that will serve the purpose.
  


How many functions and objects do you want to export, anyway ? I have so 
far always preferred to write my boost.python code manually. Not only 
because installing the prerequisites for the alternate tools is so 
cumbersome, but mainly because I want the python API to look a little 
more pythonic than the equivalent C++ code I'm wrapping.


You can always move 'back' to auto-generated wrapper code later if you 
find it is worth it.


Regards,
  Stefan

--

 ...ich hab' noch einen Koffer in Berlin...

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] [py++] Problem: empty xml file created

2008-12-02 Thread Roman Yakovenko
2008/12/2 Marcus Lindblom <[EMAIL PROTECTED]>:
> Hi all,
>
> I'm trying to get OpenSG's python-bindings to work on Windows (and
> contruibuting that back to the project), and trying to track down an
> exception that get's thrown when running it's gen_bindings.py. (see attached
> log.txt for output)
>
> The source for gen_bindings.py is here, for reference:
>
> https://realityforge.vrsource.org/trac/pyopensg/browser/branches/trunk_update/src/gen_bindings.py
>
>
> From what I can see, the exception is thrown, as can be seen, in
> read_gccxml_file in pygccxml/parser/source_reader.py. The generation of the
> temp xml file (self.create_xml_file( ffname )) creates an empty file, which
> then gets a syntax error when read back.
>
> As I'm rather new to py++ (being old on c++ and average on python) I don't
> really know where to look when hunting for this bug.
>
> The PyOpenSG-devs have only used linux, and have maybe seen this before,
> earlier, but can't recall what and when. They also have used a earlier
> py++-version, but I'm using 1.0. I might be shooting myself in the foot with
> that, but I hope not.

There were few changes here and there, but it should not be too
dificcult to upgrade,

The output contains the following command:

""C:\program files\bin\gccxml.exe"
/IJ:\3rd\OpenSG\opensg2_trunk\build.win32.cl.9.0\instlinks\include
/IC:\Program Files oost oost_1_36_0 -DBOOST_PYTHON_MAX_ARITY=21
-I"." -I"osg_module"
-I"J:\3rd\OpenSG\opensg2_trunk\build.win32.cl.9.0\instlinks\include"
-I"J:\3rd\OpenSG\opensg2_trunk\build.win32.cl.9.0\instlinks\include\OpenSG"
-I"j:\3rd\boost\boost_1_36_0" -I"c:\dev\python26\include"
"osg_module\osgmodule_mainheader.h"
-fxml="c:\users\marcusl\appdata\local\temp\tmp1e92ik.xml""

Can you run the command, from cmd and check that file was created and
contains data.

If I remember right, PyOpenSG project uses some tricky configuration
to suppress GCCXML warnings and\or errors.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] gccxml

2008-12-02 Thread Roman Yakovenko
On Tue, Dec 2, 2008 at 5:26 PM, Alan Baljeu <[EMAIL PROTECTED]> wrote:
> This is getting out of hand :-(
>
> All I wanted to do was parse some simple C++ function declarations to 
> generate a corresponding py-callable wrapper.  To do this I need to get 
> pygccxml.  Then I need gccxml to use pygccxml.  To get that I need WinCVS or 
> some equivalent (which version, and learn how CVS works) or Cygwin.  Then I 
> need to choose the preferred version of gccxml.  And then I need to obtain 
> CMake to install it?
>
> I think I'd rather just do my own thing, except that C++ is so warty it's 
> difficult to come up with anything reasonable that will serve the purpose.

How much effort did you put to improve the situation? Did you
contribute to GCCXML project in someway or another?

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] gccxml

2008-12-02 Thread Alan Baljeu
I would make a contribution to some projects.  GCC-XML is not one of them, 
seeing how it's not even worth my effort to try to install and configure this 
stuff.  If I were involved with these packages, I would make it easy for others 
to get involved.  As it isn't easy I'm going to look elsewhere.

 Alan Baljeu




- Original Message 
From: Roman Yakovenko <[EMAIL PROTECTED]>
To: Development of Python/C++ integration 
Sent: Tuesday, December 2, 2008 10:58:33 AM
Subject: Re: [C++-sig] gccxml

On Tue, Dec 2, 2008 at 5:26 PM, Alan Baljeu <[EMAIL PROTECTED]> wrote:
> This is getting out of hand :-(
>
> All I wanted to do was parse some simple C++ function declarations to 
> generate a corresponding py-callable wrapper.  To do this I need to get 
> pygccxml.  Then I need gccxml to use pygccxml.  To get that I need WinCVS or 
> some equivalent (which version, and learn how CVS works) or Cygwin.  Then I 
> need to choose the preferred version of gccxml.  And then I need to obtain 
> CMake to install it?
>
> I think I'd rather just do my own thing, except that C++ is so warty it's 
> difficult to come up with anything reasonable that will serve the purpose.

How much effort did you put to improve the situation? Did you
contribute to GCCXML project in someway or another?

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig



  __
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now at
http://ca.toolbar.yahoo.com.
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] gccxml

2008-12-02 Thread Gustavo Carneiro
2008/12/2 Alan Baljeu <[EMAIL PROTECTED]>

> I would make a contribution to some projects.  GCC-XML is not one of them,
> seeing how it's not even worth my effort to try to install and configure
> this stuff.  If I were involved with these packages, I would make it easy
> for others to get involved.  As it isn't easy I'm going to look elsewhere.


Unfortunately you will soon find out there is no real alternative to GCC-XML
if you have to do serious parsing of C++ headers.  The time invested in
getting GCC-XML to work for you will pay off in the end in case your project
has multi-year scope and large API set to wrap.  If on the other hand your
project is small, you can get by if you just manually write your wrappers
(both boost.python and pybindgen support this manual wrapping method).

Either way, know that wrapping C/C++ for Python is usually hard for
beginners, but don't give up, it gets easier with practice :-)

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

[C++-sig] boost.python: implicit type conversion

2008-12-02 Thread Mihail Konstantinov
Dear all,
thanks a lot for your immediate responses that lead to a fast solution for my 
previous problem.

Here comes the next one.

In the example below both classes A and B are derived from std::string. Class B 
can be implicitly converted to A by means of 'B::operator const A()'. So the 
function printme(const A&) can also be called with an argument of class B (see 
main function).

My aim is to be able to call in python:
>>>import boost_ext
>>>b=boost_ext.B("hello world")
>>>boost_ext.printme(b)
but it produces the error:
> : Python argument types in  
> boost_ext.printme(B)
> did not match C++ signature:
>printme(A)

Can I modify the declaration inside BOOST_PYTHON_MODULE so that the implicit 
conversion is recognized and the above call boost_ext.printme(b) succeeds?

Thank you
Mihail

BTW, in the code below I'm using a preprocessor definition __BJAM__ which I had 
to define explicitly in the Jamroot. Is there some variable defined by default 
which I can use to distinguish between bjam builds and other (testing) calls to 
g++?

boost.cpp:
#ifdef __BJAM__ // I define __BJAM__ in the Jamroot file..
  #include 
#endif
#include 
#include 

class A: public std::string{
public:
  A(const std::string&s,int i):std::string(s){}
};

class B: public std::string{
public:
  B(const std::string&s):std::string(s){}
  operator const A(){return A(*this,-1);}
};

void printme(const A &a){std::cout<("string");
class_ > ("A",init());
class_ > ("B",init());
def("printme",&printme);
}
#endif



  

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] gccxml

2008-12-02 Thread Mathieu Malaterre
2008/12/2 Gustavo Carneiro <[EMAIL PROTECTED]>:
> 2008/12/2 Alan Baljeu <[EMAIL PROTECTED]>
>>
>> I would make a contribution to some projects.  GCC-XML is not one of them,
>> seeing how it's not even worth my effort to try to install and configure
>> this stuff.  If I were involved with these packages, I would make it easy
>> for others to get involved.  As it isn't easy I'm going to look elsewhere.
>
> Unfortunately you will soon find out there is no real alternative to GCC-XML
> if you have to do serious parsing of C++ headers.  The time invested in
> getting GCC-XML to work for you will pay off in the end in case your project
> has multi-year scope and large API set to wrap.

Switch to a debian based system:

 $ sudo apt-get install gccxml

Approx ~1min of time invested (+ time to write this email).

-- 
Mathieu
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] gccxml

2008-12-02 Thread Gustavo Carneiro
2008/12/2 Mathieu Malaterre <[EMAIL PROTECTED]>

> 2008/12/2 Gustavo Carneiro <[EMAIL PROTECTED]>:
> > 2008/12/2 Alan Baljeu <[EMAIL PROTECTED]>
> >>
> >> I would make a contribution to some projects.  GCC-XML is not one of
> them,
> >> seeing how it's not even worth my effort to try to install and configure
> >> this stuff.  If I were involved with these packages, I would make it
> easy
> >> for others to get involved.  As it isn't easy I'm going to look
> elsewhere.
> >
> > Unfortunately you will soon find out there is no real alternative to
> GCC-XML
> > if you have to do serious parsing of C++ headers.  The time invested in
> > getting GCC-XML to work for you will pay off in the end in case your
> project
> > has multi-year scope and large API set to wrap.
>
> Switch to a debian based system:
>
>  $ sudo apt-get install gccxml
>
> Approx ~1min of time invested (+ time to write this email).


Sure, but how current is this debian gccxml?  Is it a CVS snapshot, or the
years old official release that does not work well with pygccxml?

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] gccxml

2008-12-02 Thread Mathieu Malaterre
2008/12/2 Gustavo Carneiro <[EMAIL PROTECTED]>:
>
>
> 2008/12/2 Mathieu Malaterre <[EMAIL PROTECTED]>
>>
>> 2008/12/2 Gustavo Carneiro <[EMAIL PROTECTED]>:
>> > 2008/12/2 Alan Baljeu <[EMAIL PROTECTED]>
>> >>
>> >> I would make a contribution to some projects.  GCC-XML is not one of
>> >> them,
>> >> seeing how it's not even worth my effort to try to install and
>> >> configure
>> >> this stuff.  If I were involved with these packages, I would make it
>> >> easy
>> >> for others to get involved.  As it isn't easy I'm going to look
>> >> elsewhere.
>> >
>> > Unfortunately you will soon find out there is no real alternative to
>> > GCC-XML
>> > if you have to do serious parsing of C++ headers.  The time invested in
>> > getting GCC-XML to work for you will pay off in the end in case your
>> > project
>> > has multi-year scope and large API set to wrap.
>>
>> Switch to a debian based system:
>>
>>  $ sudo apt-get install gccxml
>>
>> Approx ~1min of time invested (+ time to write this email).
>
> Sure, but how current is this debian gccxml?  Is it a CVS snapshot, or the
> years old official release that does not work well with pygccxml?
>

From:
http://packages.debian.org/lenny/gccxml

...
Package: gccxml (0.9.0+cvs20080525-1)
...

I do not know if you call that /recent/ or not...

-- 
Mathieu
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] gccxml

2008-12-02 Thread Gustavo Carneiro
2008/12/2 Mathieu Malaterre <[EMAIL PROTECTED]>

> 2008/12/2 Gustavo Carneiro <[EMAIL PROTECTED]>:
> >
> >
> > 2008/12/2 Mathieu Malaterre <[EMAIL PROTECTED]>
> >>
> >> 2008/12/2 Gustavo Carneiro <[EMAIL PROTECTED]>:
> >> > 2008/12/2 Alan Baljeu <[EMAIL PROTECTED]>
> >> >>
> >> >> I would make a contribution to some projects.  GCC-XML is not one of
> >> >> them,
> >> >> seeing how it's not even worth my effort to try to install and
> >> >> configure
> >> >> this stuff.  If I were involved with these packages, I would make it
> >> >> easy
> >> >> for others to get involved.  As it isn't easy I'm going to look
> >> >> elsewhere.
> >> >
> >> > Unfortunately you will soon find out there is no real alternative to
> >> > GCC-XML
> >> > if you have to do serious parsing of C++ headers.  The time invested
> in
> >> > getting GCC-XML to work for you will pay off in the end in case your
> >> > project
> >> > has multi-year scope and large API set to wrap.
> >>
> >> Switch to a debian based system:
> >>
> >>  $ sudo apt-get install gccxml
> >>
> >> Approx ~1min of time invested (+ time to write this email).
> >
> > Sure, but how current is this debian gccxml?  Is it a CVS snapshot, or
> the
> > years old official release that does not work well with pygccxml?
> >
>
> From:
> http://packages.debian.org/lenny/gccxml
>
> ...
> Package: gccxml (0.9.0+cvs20080525-1)
> ...
>
> I do not know if you call that /recent/ or not...


Goodie!  That should work with pygccxml 0.9.5, in theory.  And to my
surprise Ubuntu 8.04 now has that same snapshot as well.

Kids these days have it too easy... :P

Unfortunately Debian/Ubuntu have no pygccxml package, what a shame! :-(

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] boost.python: implicit type conversion

2008-12-02 Thread Roman Yakovenko
On Tue, Dec 2, 2008 at 7:04 PM, Mihail Konstantinov
<[EMAIL PROTECTED]> wrote:
> Dear all,
> thanks a lot for your immediate responses that lead to a fast solution for my 
> previous problem.
>
> Here comes the next one.
>
> In the example below both classes A and B are derived from std::string.

It is not a good idea. Python string is immutable. May be you should
consider custom converter.
http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/faq.html#custom_string

>Class B can be implicitly converted to A by means of 'B::operator const A()'. 
>So the function printme(const A&) can also be called with an argument of class 
>B (see main function).
>
> My aim is to be able to call in python:
import boost_ext
b=boost_ext.B("hello world")
boost_ext.printme(b)
> but it produces the error:
>> : Python argument types in  
>> boost_ext.printme(B)
>> did not match C++ signature:
>>printme(A)
>
> Can I modify the declaration inside BOOST_PYTHON_MODULE so that the implicit 
> conversion is recognized and the above call boost_ext.printme(b) succeeds?

Yes: http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/implicit.html

> Thank you
> Mihail
>
> BTW, in the code below I'm using a preprocessor definition __BJAM__ which I 
> had to define explicitly in the Jamroot. Is there some variable defined by 
> default which I can use to distinguish between bjam builds and other 
> (testing) calls to g++?

You can separate your source code to different files.


-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost.python: implicit type conversion

2008-12-02 Thread Mihail Konstantinov
> Roman Yakovenko wrote:

> 
> It is not a good idea. Python string is immutable. May be you should
> consider custom converter.
> http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/faq.html#custom_string

I don't see why it is not a good idea. I am nowhere accessing any string 
derived classes in a mutable fashion, am I?
Also I have no option to change the class hierarchy. The code fragments I am 
posting are simplified from a large project that I try to pythonify, reduced to 
what I think is the cause of the problems. I want to avoid modifying the 
underlying project under all circumstances.

> > Can I modify the declaration inside BOOST_PYTHON_MODULE so that the 
> > implicit 
> conversion is recognized and the above call boost_ext.printme(b) succeeds?
> 
> Yes: http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/implicit.html

This looks very helpful. But I don't understand the C++ module definition 
example on that page. It ends with

>implicitly_convertible();
>implicitly_convertible();
>}
I see that an int can be implicitly converted to X. But how can an X be 
converted to an int? I can't believe that boost.python searches all implemented 
functions to find that make_x is capable of converting an int to X?

Thank you
Mihail


  

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost.python: implicit type conversion

2008-12-02 Thread Mihail Konstantinov
> >implicitly_convertible();

> >implicitly_convertible();
> >}
> I see that an int can be implicitly converted to X. But how can an X be 
> converted to an int? I can't believe that boost.python searches all 
> implemented 
> functions to find that make_x is capable of converting an int to X?

Found it. X::operator int() const. Apparently I need some sleep.

Thank you
Mihail



  

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost.python: implicit type conversion

2008-12-02 Thread Roman Yakovenko
On Tue, Dec 2, 2008 at 9:20 PM, Mihail Konstantinov
<[EMAIL PROTECTED]> wrote:
>> Roman Yakovenko wrote:
>> It is not a good idea. Python string is immutable. May be you should
>> consider custom converter.
>> http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/faq.html#custom_string
>
> I don't see why it is not a good idea. I am nowhere accessing any string 
> derived classes in a mutable fashion, am I?

May in the code you posted you don't. May be you don't change it in
the whole project. But if you do, it breaks too many Python
assumptions.

> Also I have no option to change the class hierarchy. The code fragments I am 
> posting are simplified from a large project that I try to pythonify, reduced 
> to what I think is the cause of the problems. I want to avoid modifying the 
> underlying project under all circumstances.

I understand. I suggest you to reconsider registration of std::string
as a base class of your classes.

Also, Boost.Python has built-in functionality to convert Python string
and std::basic_string. I don't know what effect class_< std::string >
registration will have.

-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


Re: [C++-sig] boost.python: implicit type conversion

2008-12-02 Thread Stefan Seefeld

Mihail Konstantinov wrote:

Roman Yakovenko wrote:



  

It is not a good idea. Python string is immutable. May be you should
consider custom converter.
http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/faq.html#custom_string



I don't see why it is not a good idea. I am nowhere accessing any string 
derived classes in a mutable fashion, am I?
Also I have no option to change the class hierarchy. The code fragments I am 
posting are simplified from a large project that I try to pythonify, reduced to 
what I think is the cause of the problems. I want to avoid modifying the 
underlying project under all circumstances.
  


You are attempting to make Python aware of the inheritance relationship 
between std::string and your own class. That is what doesn't work, not 
your own deriving from std::string.
In order to make 'bases' work, you would have to export the 
std::string class to Python first. But as that isn't what you actually 
want, you may as well remove the 'bases' from your code, 
and instead rely on (implicit) conversion.



  
Can I modify the declaration inside BOOST_PYTHON_MODULE so that the implicit 
  

conversion is recognized and the above call boost_ext.printme(b) succeeds?

Yes: http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/implicit.html



This looks very helpful. But I don't understand the C++ module definition 
example on that page. It ends with

  

   implicitly_convertible();
   implicitly_convertible();
}


I see that an int can be implicitly converted to X. But how can an X be 
converted to an int? I can't believe that boost.python searches all implemented 
functions to find that make_x is capable of converting an int to X?
  


I believe it simply expects an 'operator int ()' to be available in that 
case.


Regards,
  Stefan

--

 ...ich hab' noch einen Koffer in Berlin...

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig


[C++-sig] Pickle an enum from c++

2008-12-02 Thread Matthew Scouten (TT)
I have an enum in my c++ library. In fact I have a crap load of them.
169 to be exact. 

 

I need them to be pickle-able.  The enum_ object does not have a
.def_pickle function, so I cannot use the pickle suite. I tried to just
up and pickle it but that does not work either.

 

 enum box {cardboard, cereal, toy};

 

BOOST_PYTHON_MODULE(busybox)

{

 

enum_("box")

.value("cardboard",cardboard )

.value("cereal",cereal )

.value("toy", toy);

 

}

 

C:\Documents and Settings\mscouten>cd C:\tt-dev\manticore\

 

C:\tt-dev\manticore>call setpath.bat

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> import pickle, busybox

>>> 

>>> b = busybox.box.toy

>>> 

>>> bs = pickle.dumps(b)

Traceback (most recent call last):

  File "", line 1, in 

  File "C:\Python25\lib\pickle.py", line 1366, in dumps

Pickler(file, protocol).dump(obj)

  File "C:\Python25\lib\pickle.py", line 224, in dump

self.save(obj)

  File "C:\Python25\lib\pickle.py", line 331, in save

self.save_reduce(obj=obj, *rv)

  File "C:\Python25\lib\pickle.py", line 401, in save_reduce

save(args)

  File "C:\Python25\lib\pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

  File "C:\Python25\lib\pickle.py", line 562, in save_tuple

save(element)

  File "C:\Python25\lib\pickle.py", line 286, in save

f(self, obj) # Call unbound method with explicit self

  File "C:\Python25\lib\pickle.py", line 748, in save_global

(obj, module, name))

pickle.PicklingError: Can't pickle : it's
not found as __main__.busybox.box

>>> 

 

 

___
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig