Skip to content

Split of type and method declaration for parametric types #138

@grasph

Description

@grasph

Hello Bart,

In the code generated by Wrapit and for non-parametric types, we proceed first with the wrap declaration (add_type()) of all types and proceed in the second step to the method declarations (method()). This ensures that all types needed for a method are in place when declaring it.

It does not work for non-parametric parametric types because type declaration is finalized by the apply() call that declares also the methods. The method apply() cannot be called multiple times. Otherwise, we could call it with a functor that does nothing to proceed with the type declaration finalization. The call will also define the default methods, but that should not be a problem.

Beyond convenience of a two-step approach, separation of type and method declaration is mandatory in case of cyclic dependency like in the example below.

template<typename> class B;

template<typename T>
struct A{
  void f(const B<T>&){}
};


template<typename T>
struct B{
  void f(const A<T>&){}
};

template struct A<int>;

Would it be possible to add support for multiple call to apply() or another way to allow a two-step declaration?

Let me know in case there is already a way to achieve this with the current CxxWrap version.

Regards,

Philippe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions