Comments (10)
There are 2 unrelated bugs involved here:
- 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
forstd::vector
(but also forstd::shared_ptr
). This is due to these lines that substitute the type with the template argument and setindirection
to 1.std::vector<U>
ends up being replaced byU*
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 ?
- 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.
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.
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.
- 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.
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.
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.
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.
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.
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.
Remains the fact (bug 1) that
std::vector<U>
orstd::shared_ptr<U>
is replaced byU*
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.
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)
- JavaCPP can't link dll file HOT 1
- Open CV 4.8.0 integration HOT 2
- Parser mapping HOT 12
- 'jni.h' file not found HOT 6
- windows Cannot run program "cl" HOT 1
- std::unique_ptr fields HOT 4
- Optional pair HOT 2
- ParserException for valid c++ code HOT 1
- Function pointer returning shared_ptr HOT 10
- LNK2001: Unresolved external, issue with namespace? HOT 7
- infinite recursion when calling virtualized inherited function HOT 4
- Mapping Template Constraints, Parser Error HOT 5
- Parser cannot compile because of QT HOT 4
- Template class with template functions HOT 15
- Inadequate Error Handling HOT 1
- Crash when passing a unique_ptr by value HOT 12
- Potential class loading deadlock when call static methods of Loader or Pointer HOT 13
- Multiple pointer types and automatic generation of function overloads HOT 1
- Parser doesn't add @Virtual annotations HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javacpp.