[C++-sig] C++ Operators and Constructers

Stefan Wolf wolfs at in.tum.de
Mon May 10 20:39:16 CEST 2004


I've got the following problem:

I'm trying to create a python interface to GiNaC (www.ginac.de).
Mainly I'm interested in the ex class. 

In GiNaC there exists the operators:
const ex operator* (ex& lh,ex& rh);
(same with +,- and /).

Porting this to python isn't too difficult when dealing only with ex-objects. But if you want, for example, multiply to symbols
(symbol is another class dervived from basic, and ex has a constructor ex(const basic& other) ) I get the error: 

TypeError: unsupported operand type(s) for * or mul(): 'symbol' and 'symbol'

Another thing is, if I call for example the subs-method from an ex-instance 
GiNaC::ex ex_subs(GiNaC::ex &express, GiNaC::symbol & x, GiNaC::ex & y)
(a wrapper programmed by myself), I get:

Boost.Python.ArgumentError: Python argument types in
    ex.subs(ex, symbol, symbol)
did not match C++ signature:
    subs(GiNaC::ex {lvalue}, GiNaC::symbol {lvalue}, GiNaC::ex {lvalue})

Which is correct. But I used a 
in my .cpp file, so it should convert it automagically, should't it?

Now, I could write wrapper-functions for all possible combination of types, but there should be a shorter way, should't it?

  Stefan Wolf 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040510/61e157cc/attachment.pgp>

More information about the Cplusplus-sig mailing list