[C++-sig] pyplusplus registration order - solution

Roman Yakovenko roman.yakovenko at gmail.com
Wed Feb 15 07:30:47 CET 2006


On 2/14/06, Matthias Baas <baas at ira.uka.de> wrote:
> But there's still more to do. I still get an error during import. Now
> it's the registering order within one file that should be modified. I
> have a class that contains some enums. In the constructor of this class,
> the enum is already used. But in the pyplusplus file, the enum is
> created after the class constructor. I'm not sure if this can be
> resolved at all....

Here is simple test case:

struct container{
    enum fruits{ apple, orange };

    explicit container( fruits x = apple )
    {}
};

1. I think you are right. IMO this issue could not be elegantly
resolved without
   modification of boost.python.

    Consider next case:

    enum fruits{ other_apple, other_orange };

    struct container{
        enum fruits{ apple, orange };

        explicit container( fruits x = apple )
        {}
    };

2. If you can make your class default constructable then pyplusplus can handle
    this situation. I attached relevant file. Please put it in
pyplusplus\module_creator
    directory.

3. You can remove default arguments from generated code. Also you can
create class
    in Python that will add default arguments.

> - Matthias -

Thanks

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: creator.py
Type: application/x-python
Size: 25879 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060215/3c27b5f4/attachment.bin>


More information about the Cplusplus-sig mailing list