[C++-sig] Pybindgen/pygccxml integration

Ben Fitzpatrick bfitzpatrick at vtiinstruments.com
Wed Aug 19 19:28:24 CEST 2009


Hi everyone,

The messages below are from quite a bit ago. I didn’t respond then because the unit tests weren’t passing for me, and I wanted to try and make them pass…. But then I got pulled off on another project. I’ve recently had some time to work on this again, and I got all the tests involving annotations to work (there’s still a couple tests that don’t pass, involving get_simple_map, but they don’t look super-vital).

I finally got my pure virtual class wrapped and compiled, and it is instantiatable and seems to work, but one of my functions is missing. Here’s the code:

class pure_virtual_class
{
  public:
  // -#- @foobaz(transfer_ownership=true, direction=out) -#-
  virtual int get_value(int* foobaz) = 0;
  virtual int set_value(int foobaz);

  // -#- @return(caller_owns_return=true) -#-
  static pure_virtual_class* Create();
  virtual ~pure_virtual_class() {};
}

class non_virtual_class : public pure_virtual_class
{
  public:
  non_virtual_class();
  ~non_virtual_class();
  // -#- @foobaz(transfer_ownership=true, direction=out) -#-
  int get_value(int* foobaz);
  int set_value(int foobaz);

  private:
  int internal_state;
  int utility_function(int foobaz);
}

And the Create method does this:
pure_virtual_class* pure_virtual_class::Create()
{
  return static_cast<pure_virtual_class*>(new non_virtual_class());
}

So, I got rid of all the gccxml warnings on the code (except for the one indicating that the class pure_virtual_class was pure virtual…), and it compiles just fine, and the Create function even works… but the get_value function doesn’t appear when I dir the class. Set_value appears and seems to work, so why not get? Any ideas?

I’m on a clean Debian Etch install (virtual machine), using GCC 4.3.2, Python 2.5.2, gccxml 0.9.

Thanks,
Ben Fitzpatrick



From: cplusplus-sig-bounces+bfitzpatrick=vtiinstruments.com at python.org [mailto:cplusplus-sig-bounces+bfitzpatrick=vtiinstruments.com at python.org] On Behalf Of Gustavo Carneiro
Sent: Tuesday, June 23, 2009 6:52 PM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] Pybindgen/pygccxml integration


2009/6/23 Ben Fitzpatrick <bfitzpatrick at vtiinstruments.com<mailto:bfitzpatrick at vtiinstruments.com>>
Gustavo Carneiro wrote:


2009/6/23 Ben Fitzpatrick <bfitzpatrick at vtiinstruments.com<mailto:bfitzpatrick at vtiinstruments.com> <mailto:bfitzpatrick at vtiinstruments.com<mailto:bfitzpatrick at vtiinstruments.com>>>
   Thanks for the suggestions!

   I tried the first one, just as a test. I'd like to do the second
   programatically if I can, but I just wanted to make sure
   annotations were going to fix this. It still seems to be giving me
   the same error:
   (...)/pure_virtual.h:5: WrapperWarning: Parameter 'int * value'
   error (used in int pure_virtual_class::get_value(int * value)
   [member function]):
   <pybindgen.typehandlers.base.TypeConfigurationError instance at
   0xb780326c>

    virtual int get_value(int* value) = 0;

   Here is what I changed my code to:

     // -#- @value(transfer_ownership=true) -#-

    virtual int get_value(int* value)=0;


Apart from the blank line, seems OK.  Do you get a "unused annotation" warning?

That's odd, there wasn't a blank line in my original email. There certainly isn't one in the file.
I do not get an unused annotation warning, or anything to suggest it noticed my annotation in the slightest. I am using Python2.4 on Debian Etch, with Pygccxml 0.9.5. The Python's a bit old, but everything else has been compiled or installed manually.

Well, with Python 2.5 it prints TypeConfigurationError('some message'), which is rather more helpful.  You are not seeing the full error message, just the (vague) exception type.

And did you run the unit tests (./waf check) ?  If the unit tests pass, annotations supposedly are working...




_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig at python.org<mailto:Cplusplus-sig at python.org>
http://mail.python.org/mailman/listinfo/cplusplus-sig



--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20090819/ae7e5cc1/attachment-0001.htm>


More information about the Cplusplus-sig mailing list