-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to deal with template taking std::function as arguments? #1051
Comments
There isn't a way to map that as a "basic container", yet, but if it's just for an argument, we can map it using a |
infoMap.put(new Info("std::function<bool(uint64_t)>").pointerTypes("FilterFunction"));
public static class FilterFunction extends FunctionPointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public FilterFunction(Pointer p) { super(p); }
protected FilterFunction() { allocate(); }
private native void allocate();
public native boolean call(@Cast("uint64_t") long key);
} Hi @saudet, I added void set_filter2 (std::function<bool(uint64_t)> &&func) {
filter_ = std::move(func);
} However, the original function is a template function. I still cannot get it work. I have tried adding the following mapping info. // infoMap.put(new Info("SomeClass::set_filter<std::function<bool(uint64_t)> >&&").javaNames("set_filter"));
// infoMap.put(new Info("SomeClass::set_filter<std::function<bool(uint64_t)> >&&")
// .javaText("public native void set_filter(@ByVal FilterFunction func);")); |
Try without the |
Remove infoMap.put(new Info("SomeClass::set_filter<std::function<bool(uint64_t)> >").javaNames("set_filter")); |
BTW, I've added support for |
Got stuck with the following mvn error. Help needed.
|
In any case, it's easy to build from source, so just do that if you're not able to fix whatever networking issue you're having. |
got mvn problem solved. Am I supposed to add the following mapping info? infoMap.put(new Info("std::function<bool(uint64_t)>").pointerTypes("FunctionPointer")); Parsing phase succeeds with the following warning
And building fails with the following message
|
You'll need to use another name than "FunctionPointer".
|
Still not work. infoMap.put(new Info("std::function<bool(uint64_t)>").pointerTypes("MyFilterFunction")); cannot find symbol [ERROR] symbol: class MyFilterFunction
|
Info.define needs to be set:
https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes#defining-wrappers-for-basic-c-containers
|
It works. |
This has now been released with JavaCPP 1.5.8. Enjoy! |
T's receiver is
std::function<bool(uint64_t)>
.We tried to add the following mapping info
mvn install
works but the function is omitted from generated java file.The text was updated successfully, but these errors were encountered: