On 9/24/06, Matthias Baas <ba...@ir...> wrote:
> Roman Yakovenko wrote:
> > On 9/23/06, Matthias Baas <ba...@ir...> wrote:
> >> Roman Yakovenko wrote:
> >> > They should. Can you give me few good reasons to not create wrappers?
> >>
> >> I've just stumbled over another problem as I compiled the bindings on
> >> Linux. Compilation fails because of a class that has a private
> >> destructor. This class only provides static members and a few enums, it
> >> isn't meant to be instantiated (let alone sub-classed).
> >
> > Sometimes static members need wrapper, for example arrays.
> > Can you post small code that reproduce the problem?
>
> class Foo
> {
> public:
> static void get_value(int& n) { n = 12; }
>
> private:
> ~Foo() {}
> };
>
> In your generation script you have to assign the output transformer to
> get_value:
>
> Foo.member_function("get_value").function_transformers.append(output_t(1))
>
> Compilation will then produce the following error:
>
> testlib.h: In constructor `Foo_wrapper::Foo_wrapper()':
> testlib.h:14: error: `Foo::~Foo()' is private
> testlib/Foo.pypp.cpp:13: error: within this context
> error: command 'gcc' failed with exit status 1
>
>
> Tested on Linux with gcc 3.3.4 (whereas MSVC 7.1 obviously ignores that
> the destructor is private and compiles the above code without problems,
> so you have to test with gcc as well).
I test generated code on two compilers: MSVC 7.1 and gcc 4.0.3.
The generated code does not work. Also I don't see other choice but not to
generate wrapper in this specific case. I will try to fix it in next few days.
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
|