Giter VIP home page Giter VIP logo

Comments (10)

HGuillemet avatar HGuillemet commented on June 12, 2024 1

There are 2 unrelated bugs involved here:

  1. These lines do not reconstruct the parameter list correctly when a parameter is a template instance with no info for the explicit instance but with a generic info like the ones you found in InfoMap for std::vector (but also for std::shared_ptr). This is due to these lines that substitute the type with the template argument and set indirection to 1. std::vector<U> ends up being replaced by U* in the parameter list. So you can work around by writing:
new Info("TemplatedClass<double>::TemplatedClass<int>(U*)

instead of:

new Info("TemplatedClass<double>::TemplatedClass<int>(std::vector<U>)

I'm not sure how to fix this, and if it is worth. @saudet any idea ?

  1. Using an info key without parameters should be enough in this case, just like you did for the function;
infoMap.put(new Info("TemplatedClass<double>::TemplatedClass<int>").define());

but that doesn't work because your class is in the top level namespace and in this case for constructors (and probably operators), an extra qualification by TemplateClass:: prevents the info query to match. I guess this one could be fixed.

from javacpp.

HGuillemet avatar HGuillemet commented on June 12, 2024 1

I'm not sure what you mean by "that". But what I meant by "bug 2" (from post #735 (comment)) should be fixed by PR #739 you are about to merge.

Remains the fact (bug 1) that std::vector<U> or std::shared_ptr<U> is replaced by U* in the function fullnames if there is no user info with this cpp name. I guess that we could fix that by avoiding to substitute the type here and maybe instead create a dynamic info. If you think it's worth I can try.

from javacpp.

benshiffman avatar benshiffman commented on June 12, 2024

you can work around by writing:

new Info("TemplatedClass<double>::TemplatedClass<int>(U*)

instead of:

new Info("TemplatedClass<double>::TemplatedClass<int>(std::vector<U>)

Confirmed that this does work.

  1. Using an info key without parameters should be enough in this case, just like you did for the function;
infoMap.put(new Info("TemplatedClass<double>::TemplatedClass<int>").define());

but that doesn't work because your class is in the top level namespace and in this case for constructors (and probably operators), an extra qualification by TemplateClass:: prevents the info query to match. I guess this one could be fixed.

Would the same change apply to operators? Currently, only normal templated functions can be mapped without specifying parameters.

from javacpp.

HGuillemet avatar HGuillemet commented on June 12, 2024

Would the same change apply to operators? Currently, only normal templated functions can be mapped without specifying parameters.

Hmm. Are you sure ? I just tested with an operator without specifying the parameter list and it does work, even in the top level namespace.
For constructors it works only if your class is not in the top level namespace.

from javacpp.

benshiffman avatar benshiffman commented on June 12, 2024

Strangely I get this

public native @Name("operator =<int>") void operator =(@StdVector @ByVal IntVec vec);

from this mapping:

infoMap.put(new Info("TemplatedClass<double>::operator =<int>").define());

from javacpp.

saudet avatar saudet commented on June 12, 2024

BTW, if you don't need @StdVector at all, you should be able to override that with something like InfoMap.putFirst(new Info("std::vector")) in your presets.

from javacpp.

HGuillemet avatar HGuillemet commented on June 12, 2024

Strangely I get this

public native @Name("operator =<int>") void operator =(@StdVector @ByVal IntVec vec);

from this mapping:

infoMap.put(new Info("TemplatedClass<double>::operator =<int>").define());

Right. So if you replace the define by a .javaNames("put"), you should be alright.

I'll try to find a fix for bug 2.

from javacpp.

saudet avatar saudet commented on June 12, 2024

Strangely I get this

public native @Name("operator =<int>") void operator =(@StdVector @ByVal IntVec vec);

from this mapping:

infoMap.put(new Info("TemplatedClass<double>::operator =<int>").define());

Right. So if you replace the define by a .javaNames("put"), you should be alright.

I'll try to find a fix for bug 2.

I don't think we need a fix for that, that's how it's intended to work.

from javacpp.

saudet avatar saudet commented on June 12, 2024

Remains the fact (bug 1) that std::vector<U> or std::shared_ptr<U> is replaced by U* in the function fullnames if there is no user info with this cpp name. I guess that we could fix that by avoiding to substitute the type here and maybe instead create a dynamic info. If you think it's worth I can try.

If the workaround is good enough for now, probably not worth it, no

from javacpp.

HGuillemet avatar HGuillemet commented on June 12, 2024

I think so. This is only hit when we have a templated function with overloads and that we need to add a user info with function parameters to instantiate a specific overload.
Workarounds are either to use U* in the info, or to add a dummy info:

infoMap.add(new Info("std::vector<U>"));

from javacpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.