Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Extern type defined with generic parameters incorrectly generated in C++ #149

Open
Goos opened this issue Oct 4, 2015 · 2 comments · May be fixed by #313
Open

Extern type defined with generic parameters incorrectly generated in C++ #149

Goos opened this issue Oct 4, 2015 · 2 comments · May be fixed by #313

Comments

@Goos
Copy link

Goos commented Oct 4, 2015

When defining an external type in yaml like so:

name: generic_interface
typedef: 'interface'
params: [parameter]
prefix: ''
cpp:
  typename: 'test::GenericInterface'
  header: '"../generic_interface.hpp"'
  byValue: false

# Followed by the java + obj-c definitions

And an interface using the type:

do_things(): generic_interface<another_type>;

The signature for a method using this type is generated thusly:

virtual std::shared_ptr<test::GenericInterface><AnotherType> doThings() = 0;

So the type parameter is tacked on at the end of the pointer definition, rather than after the type definition, as one would expect:

virtual std::shared_ptr<test::GenericInterface<AnotherType>> doThings() = 0;
@artwyman
Copy link
Contributor

I'm pretty sure the generic type / type parameters code in Djinni is vestigial, left over from an early experimental version and never really finished or tested for a real use case. I welcome PRs if you can make it work for you, but I feel like the code should probably just be deleted if it's not going to be finished for all languages.

@sdelaysam
Copy link

@artwyman I guess Djinni allows user-defined generic types but using hand-written translator

https://github.com/dropbox/djinni#modularization-and-library-support

If your type is generic the translator takes the same number of template parameters. 
At usage each is instantiated with the translators of the respective type argument.
...

Further readers (and myself) would highly appreciate some simple complete example how to accomplish this. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants