Closed zaki699 closed 1 month ago
/Users/zak/Repo/javacpp-presets/shaka-packager/target/native/org/bytedeco/shakapackager/macosx-arm64/jnipackager.cpp:2423:35: error: incompatible pointer types assigning to 'char ()(const shaka::EncryptionParams::EncryptedStreamAttributes &)' from 'std::function<std::string (const EncryptedStreamAttributes &)> ' (aka 'function<basic_string (const shaka::EncryptionParams::EncryptedStreamAttributes &)> ') if (rptr != NULL) rptr->ptr = &ptr->stream_label_func;
You'll need to create an actual instance of std::function like this with Info.define: https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes#defining-wrappers-for-basic-c-containers
.put( new Info("shaka::RawKeyParams::KeyInfo").valueTypes("RawKeyParams.KeyInfo"))
You'll need to set Info.pointerTypes, not Info.valueTypes, like this: https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes#specifying-names-to-use-in-java
Hi @saudet ,
I'm not sure to understand the created instance part. Did you mean like this ?:
.put(new Info("std::function<std::string(const shaka::EncryptionParams::EncryptedStreamAttributes&)>").pointerTypes("StringEncryptedStreamAttributes").define())
It seems to work fine. Annoyingly, it leads to another issue related to the class Packager.h
static std::string DefaultStreamLabelFunction(
int max_sd_pixels,
int max_hd_pixels,
int max_uhd1_pixels,
const EncryptionParams::EncryptedStreamAttributes& stream_attributes);
Generated Java:
public static native @StdString BytePointer DefaultStreamLabelFunction(
int max_sd_pixels,
int max_hd_pixels,
int max_uhd1_pixels,
EncryptionParams.EncryptedStreamAttributes stream_attributes);
Error
/Users/zak/Repo/javacpp-presets/shaka-packager/target/native/org/bytedeco/shakapackager/macosx-arm64/jnipackager.cpp:5744:102: error: reference to type 'const EncryptionParams::EncryptedStreamAttributes' could not bind to an lvalue of type 'shaka::EncryptionParams::EncryptedStreamAttributes *'
StringAdapter< char > radapter(shaka::Packager::DefaultStreamLabelFunction(arg0, arg1, arg2, ptr3));
^~~~
/Users/zak/Repo/javacpp-presets/shaka-packager/cppbuild/macosx-arm64/include/packager/packager.h:213:58: note: passing argument to parameter 'stream_attributes' here
const EncryptionParams::EncryptedStreamAttributes& stream_attributes);
Thx
Looks like something is failing somewhere with EncryptionParams.EncryptedStreamAttributes...
I was currently updating this issue.
I manage to solve most of the errors (Thx to you). I have only 3 left :)
1) /Users/zak/Repo/javacpp-presets/shaka-packager/target/native/org/bytedeco/shakapackager/macosx-arm64/jnipackager.cpp:8104:16: error: assigning to 'signed char *' from incompatible type 'std::string'
rptr = ptr->operator ()(*(const shaka::EncryptionParams::EncryptedStreamAttributes*)ptr0);
2) /Users/zak/Repo/javacpp-presets/shaka-packager/target/native/org/bytedeco/shakapackager/macosx-arm64/jnipackager.cpp:5333:24: error: no viable overloaded '='
rptr = &((*ptr)=(*ptr0));
3) /Users/zak/Repo/javacpp-presets/shaka-packager/target/native/org/bytedeco/shakapackager/macosx-arm64/jnipackager.cpp:5013:24: error: no viable overloaded '='
rptr = &((*ptr)=(*ptr0));
For Number 1:
JNIEXPORT jobject JNICALL Java_org_bytedeco_shakapackager_StringEncryptedStreamAttributes_call(JNIEnv* env, jobject obj, jobject arg0) {
std::function<std::string(const shaka::EncryptionParams::EncryptedStreamAttributes&)>* ptr = (std::function<std::string(const shaka::EncryptionParams::EncryptedStreamAttributes&)>*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 9), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
shaka::EncryptionParams::EncryptedStreamAttributes* ptr0 = arg0 == NULL ? NULL : (shaka::EncryptionParams::EncryptedStreamAttributes*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
if (ptr0 == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 9), "Pointer address of argument 0 is NULL.");
return 0;
}
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
jobject rarg = NULL;
signed char* rptr;
jthrowable exc = NULL;
try {
rptr = ptr->operator ()(*(const shaka::EncryptionParams::EncryptedStreamAttributes*)ptr0);
if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 27);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
} catch (...) {
exc = JavaCPP_handleException(env, 8);
}
if (exc != NULL) {
env->Throw(exc);
}
return rarg;
}
@Properties(inherit = org.bytedeco.shakapackager.presets.packager.class)
public class StringEncryptedStreamAttributes_EncryptionParams_EncryptedStreamAttributes extends FunctionPointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public StringEncryptedStreamAttributes_EncryptionParams_EncryptedStreamAttributes(Pointer p) { super(p); }
protected StringEncryptedStreamAttributes_EncryptionParams_EncryptedStreamAttributes() { allocate(); }
private native void allocate();
public native @StdString BytePointer call(@Const @ByRef EncryptionParams.EncryptedStreamAttributes arg0);
}
@NoOffset @Name("std::function<std::string(const shaka::EncryptionParams::EncryptedStreamAttributes&)>") @Properties(inherit = org.bytedeco.shakapackager.presets.packager.class)
public class StringEncryptedStreamAttributes extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public StringEncryptedStreamAttributes(Pointer p) { super(p); }
public StringEncryptedStreamAttributes(StringEncryptedStreamAttributes_EncryptionParams_EncryptedStreamAttributes value) { this(); put(value); }
public StringEncryptedStreamAttributes() { allocate(); }
private native void allocate();
public native @Name("operator =") @ByRef StringEncryptedStreamAttributes put(@ByRef StringEncryptedStreamAttributes x);
public native @Name("operator =") @ByRef StringEncryptedStreamAttributes put(@ByRef StringEncryptedStreamAttributes_EncryptionParams_EncryptedStreamAttributes value);
public native @Name("operator ()") BytePointer call(@Const @ByRef EncryptionParams.EncryptedStreamAttributes arg0);
}
It should return @StdString BytePointer instead of BytePointer only. I replaced it and the compiler does not produce an error. The problem is how to tell the parser to add it ? or I should just add it manually as a FunctionPointer.
public native @Name("operator ()") BytePointer call(@Const @ByRef EncryptionParams.EncryptedStreamAttributes arg0);
public native @Name("operator ()") @StdString BytePointer call(@Const @ByRef EncryptionParams.EncryptedStreamAttributes arg0);
There's probably something that needs to be fixed somewhere around here: https://github.com/bytedeco/javacpp/blob/1.5.10/src/main/java/org/bytedeco/javacpp/tools/Parser.java#L1778
I have one more issue that I am trying to fix but wow I'm lacking expertise on that one.
The compilation error:
/Users/zak/Repo/javacpp-presets/shaka-packager/target/native/org/bytedeco/shakapackager/macosx-arm64/jnipackager.cpp:5333:24: error: no viable overloaded '='
rptr = &((*ptr)=(*ptr0));
InfoMap
.put(new Info("std::function<int64_t(const std::string&,const void*,uint64_t)>").pointerTypes("Node2Fn").define())
JNI CPP
JNIEXPORT jobject JNICALL Java_org_bytedeco_shakapackager_NodeFn_put__Lorg_bytedeco_shakapackager_NodeFn_1BytePointer_1Pointer_1long_2(JNIEnv* env, jobject obj, jobject arg0) {
std::function<int64_t(const std::string&,void*,uint64_t)>* ptr = (std::function<int64_t(const std::string&,void*,uint64_t)>*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 9), "This pointer address is NULL.");
return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
JavaCPP_org_bytedeco_shakapackager_NodeFn_1BytePointer_1Pointer_1long* ptr0 = arg0 == NULL ? NULL : (JavaCPP_org_bytedeco_shakapackager_NodeFn_1BytePointer_1Pointer_1long*)jlong_to_ptr(env->GetLongField(arg0, JavaCPP_addressFID));
if (ptr0 == NULL) {
env->ThrowNew(JavaCPP_getClass(env, 9), "Pointer address of argument 0 is NULL.");
return 0;
}
jlong position0 = arg0 == NULL ? 0 : env->GetLongField(arg0, JavaCPP_positionFID);
ptr0 += position0;
jobject rarg = NULL;
std::function<int64_t(const std::string&,void*,uint64_t)>* rptr;
jthrowable exc = NULL;
try {
rptr = &((*ptr)=(*ptr0));
if (rptr == ptr) {
rarg = obj;
} else if (rptr != NULL) {
rarg = JavaCPP_createPointer(env, 12);
if (rarg != NULL) {
env->SetLongField(rarg, JavaCPP_addressFID, ptr_to_jlong(rptr));
}
}
} catch (...) {
exc = JavaCPP_handleException(env, 8);
}
if (exc != NULL) {
env->Throw(exc);
}
return rarg;
}
@Properties(inherit = org.bytedeco.shakapackager.presets.packager.class)
public class Node2Fn_BytePointer_Pointer_long extends FunctionPointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public Node2Fn_BytePointer_Pointer_long(Pointer p) { super(p); }
protected Node2Fn_BytePointer_Pointer_long() { allocate(); }
private native void allocate();
public native @Cast("int64_t") long call(@StdString BytePointer arg0,@Const Pointer arg1,@Cast("uint64_t") long arg2);
}
@NoOffset @Name("std::function<int64_t(const std::string&,const void*,uint64_t)>") @Properties(inherit = org.bytedeco.shakapackager.presets.packager.class)
public class Node2Fn extends Pointer {
static { Loader.load(); }
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
public Node2Fn(Pointer p) { super(p); }
public Node2Fn(Node2Fn_BytePointer_Pointer_long value) { this(); put(value); }
public Node2Fn() { allocate(); }
private native void allocate();
public native @Name("operator =") @ByRef Node2Fn put(@ByRef Node2Fn x);
public native @Name("operator =") @ByRef Node2Fn put(@ByRef Node2Fn_BytePointer_Pointer_long value);
public native @Name("operator ()") long call(@StdString BytePointer arg0,@Const Pointer arg1,@Cast("uint64_t") long arg2);
}
I can't find where does the issue come from.
OK I found the issue. It was because of the missing @Const on the first function argument
The problem was here
public native @Cast("int64_t") long call(@StdString BytePointer arg0,@Const Pointer arg1,@Cast("uint64_t") long arg2);
and solved with
public native @Cast("int64_t") long call(@Const @StdString BytePointer arg0,@Const Pointer arg1,@Cast("uint64_t") long arg2);
Hi Everyone,
I am facing some issues that I can't solve on my own. I tried to look at the code of Torch and TensorFlow but I could not find an answer to my issues.
Do you mind looking at it and tell me if you find a fix that will solve my problems?
but then I've got the error
/Users/zak/Repo/javacpp-presets/shaka-packager/target/native/org/bytedeco/shakapackager/macosx-arm64/jnipackager.cpp:2423:35: error: incompatible pointer types assigning to 'char ()(const shaka::EncryptionParams::EncryptedStreamAttributes &)' from 'std::function<std::string (const EncryptedStreamAttributes &)> ' (aka 'function<basic_string (const shaka::EncryptionParams::EncryptedStreamAttributes &)> ')
if (rptr != NULL) rptr->ptr = &ptr->stream_label_func;
My second issue is related to std::map
Then In InfoMap
And the JAVA generated
But unfortunately I've got this compilation error
And finally I've get some errors like this related to 'std::basic_string' to 'std::string :
Thanks for your help and your time.