Skip to content
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

DNG Adobe Presets #1539

Closed
masterav10 opened this issue Sep 7, 2024 · 3 comments
Closed

DNG Adobe Presets #1539

masterav10 opened this issue Sep 7, 2024 · 3 comments
Labels

Comments

@masterav10
Copy link

Working on some presets for the Adobe DNG SDK, and I'm down to the final error.

I'm running into a compilation problem with setter func in the jni file from this definition (only showing relevant line):

// dng_idf.h
class dng_ifd
	{
	
	public:
	
		std::shared_ptr<const dng_memory_block> fSemanticXMP;

		...		
	};

Javacpp is generating the following output:

// dng_idf.java	
public native @Const @SharedPtr dng_memory_block fSemanticXMP(); 
public native dng_ifd fSemanticXMP(dng_memory_block setter);
// jnidng.cpp setter function definition
JNIEXPORT jobject JNICALL Java_org_bytedeco_dng_dng_1ifd_fSemanticXMP__(JNIEnv* env, jobject obj) {
dng_ifd* ptr = (dng_ifd*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
if (ptr == NULL) {
	env->ThrowNew(JavaCPP_getClass(env, 7), "This pointer address is NULL.");
	return 0;
}
jlong position = env->GetLongField(obj, JavaCPP_positionFID);
ptr += position;
jobject rarg = NULL;
const dng_memory_block* rptr;
SharedPtrAdapter< const dng_memory_block > radapter(ptr->fSemanticXMP);
rptr = radapter;
jlong rcapacity = (jlong)radapter.size;
void* rowner = radapter.owner;
void (*deallocator)(void*) = rowner != NULL ? &SharedPtrAdapter< const dng_memory_block >::deallocate : 0;
if (rptr != NULL) {
	rarg = JavaCPP_createPointer(env, 30);
	if (rarg != NULL) {
		JavaCPP_initPointer(env, rarg, rptr, rcapacity, rowner, deallocator);
	}
}
return rarg;
}

Here is the error I receive:

jnidng.cpp(27414): error C2664: 'SharedPtrAdapter<dng_memory_block>::SharedPtrAdapter(const std::shared_ptr<dng_memory_block> &)': cannot convert argument 1 from 'std::shared_ptr<const dng_memory_block>' to 'const std::shared_ptr<dng_memory_block> &'
jnidng.cpp(27414): note: Reason: cannot convert from 'std::shared_ptr<const dng_memory_block>' to 'const std::shared_ptr<dng_memory_block>'
jnidng.cpp(27414): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

This line seems to be the problem child SharedPtrAdapter< const dng_memory_block > radapter(ptr->fSemanticXMP);

It makes sense, since the generic types don't match. Is there an easy way to overcome this using InfoMap (such as javaText(...) ) or is this just one of them issues where I gotta do something jank to overcome? I poked around in some of the other bindings but couldn't find an analogous case.

FYI I'm using 1.5.9 right now because I can't upgrade my CUDA yet. So if this is a bug that has already been fixed by the generator then I'll wait till we upgrade.

@saudet
Copy link
Member

saudet commented Oct 4, 2024

Sorry for the late reply! It's something we can work around with a cast like this:

.put(new Info("std::shared_ptr<const dng_memory_block>").annotations("@SharedPtr")
    .valueTypes("@Cast({\"const dng_memory_block*\", \"std::shared_ptr<const dng_memory_block>\"}) dng_memory_block")

@masterav10
Copy link
Author

Worked like a charm partner. Probably worth adding this behavior to https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes no?

Either way, this particular issue is fixed for me.

@saudet
Copy link
Member

saudet commented Oct 13, 2024

We could, please feel free to edit the page!

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

No branches or pull requests

2 participants