[C++-sig] Pyste bug: implicit constructors

Niall Douglas s_sourceforge at nedprod.com
Sat Feb 5 00:24:47 CET 2005


Referring to v1.32. If you have a struct like this:

struct FXProcess
{
  struct Foo
  {
    int foo;
  };
};

... and you feed it to pyste, pyste gives:

class_< FXProcess::Foo, boost::noncopyable >("Foo", no_init)

And that's not correct obviously. Looking at the GCC-XML output:

<Constructor id="_844" name="Foo" artificial="1" context="_451" 
mangled="_ZN2FX9FXProcess14FooC1ERKS1_ *INTERNAL*" location="f0:154" 
file="f0" line="154">
  <Argument name="_ctor_arg" type="_987" /> 
  </Constructor>

Now the problem becomes in pyste, GCCXMLParser.py:

        artificial = element.get('artificial', False)
        if not artificial:
            ctor = Constructor(name, classname, params, visib)
        else:
            # we don't want artificial constructors
            ctor = Unknown('__Unknown_Element_%s' % id)

Since the artificial flag is 1, Constructor() never gets called and 
thus pyste generating the boost::noncopyable.

I suggest:

        artificial = element.get('artificial', False)
        ctor = Constructor(name, classname, params, visib)
        if artificial and not ctor.IsCopy():
            # we don't want artificial constructors except copy ones
            ctor = Unknown('__Unknown_Element_%s' % id)

... but this may not be the right thing either.

Cheers,
Niall






More information about the Cplusplus-sig mailing list