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

BridJ: Can't call char* class_name::method_name(char* a, char* b) #38

Closed
ochafik opened this issue Sep 1, 2011 · 8 comments
Closed
Assignees
Labels

Comments

@ochafik
Copy link
Member

ochafik commented Sep 1, 2011

I have a library compiled in VS2010.
The code looks like this:
class __declspec(dllexport) class_name {
public:
class_name ();
char* method_name(char* filename, char* filename1);
}

And I get the following exception while trying to use it:
org.bridj.Demangler$DemanglingException: Parsing error at position 51: Invalid back reference
?method_name@class_name@@QAEPAPADPAD0@Z

Google Code Info:
Issue #: 36
Author: [email protected]
Created On: 2010-11-25T18:51:11.000Z
Closed On: 2010-11-27T22:19:58.000Z

@ghost ghost assigned ochafik Sep 1, 2011
@ochafik ochafik closed this as completed Sep 1, 2011
@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Hello oleglbch,

Thanks for your report !

VS2010 hasn't been tested yet, so there might be changes in the name mangling scheme that need to be worked out.
In the meanwhile as a workaround, you can try to hardcode the offending symbol by adding the following annotation to your BridJed method :
{{{
@symbol("?method_name@class_name@@QAEPAPADPAD0@Z")
public native Pointer<java.lang.Byte > method_name(Pointer<java.lang.Byte > filename, Pointer<java.lang.Byte > filename1);
}}}

Also, you should make sure to use the latest snapshot version of JNAerator (0.9.6-SNAPSHOT), bugs are regularly fixed in the wrappers generation code.

Cheers

Olivier

Google Code Info:
Author: olivier.chafik
Created On: 2010-11-25T19:11:19.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

(NB: full class name of the annotation is org.bridj.ann.Symbol)

Google Code Info:
Author: olivier.chafik
Created On: 2010-11-25T19:12:24.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

That was quick :) Thanks a lot!
I'm planning to also use the same code on linux, will it be possible to support both vs2010 and gcc4?

I guess adding webstart for the latest version of JNAErator might be a good idea, because currently main page leads me to 0.9.5-SNAPSHOT.

Thanks,
Oleg.

Google Code Info:
Author: [email protected]
Created On: 2010-11-25T23:04:30.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

You're welcome :-)
Please let me know if you face further issues, even if they're of the same kind : having the new mangled names + their corresponding signature will help me reverse engineer the mangling scheme, if needed.

I believe the webstart link is correctly pointing to version 0.9.6-SNAPSHOT (if you downloaded it multiple times, beware of the " (1)" suffix syndrom when redownloading).
The download link, however, is for 0.9.5 (but it's the latest stable version, while the snapshot is supposed to be the "unstable" version).

If I missed the link you're referring to, would you mind telling me which it is exactly ?
Thanks,

Cheers

Olivier

Google Code Info:
Author: olivier.chafik
Created On: 2010-11-26T00:24:08.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Yeah, you are right, 0.9.5 was there a couple of days ago and now it's 0.9.6.

Thanks,
Oleg.

Google Code Info:
Author: [email protected]
Created On: 2010-11-26T00:31:15.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Hehe indeed, I did a silent update to support a feature requested on jna's mailing list :-)

Regarding your question on running the same code with both VS2010 and GCC4, it should be all right : the logic is to first try and find the symbol(s) defined in the @symbol annotation (Which, btw, should contain an array, my bad : @symbol({ "..." })), then to look at the symbols exported by the library and try and parse the ones that look vaguely okay, then match the result of this parsing against the method signature.

Happy binding !

Cheers

Olivier

Google Code Info:
Author: olivier.chafik
Created On: 2010-11-26T00:42:52.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Here are the functions i've tried so far:
//works fine
char* c::m(char* filename);
//works fine
int c::m();
//?m1@c@@QAEPADPAD0@Z
char* c::m1(char* a1,char* a2);
//?m2@c@@QAEPAPADPAD0@Z
char** c::m2(char* a1,char* a2);

Thanks,
Oleg.

Google Code Info:
Author: [email protected]
Created On: 2010-11-26T00:44:37.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Hi Oleg,

Thanks for the added details :-)
I've fixed the demangling for the cases you've submitted (back-references of types already used in the same signature), in revision 1396 (will upload a new snapshot in a few minutes).

Please feel free to open (many) new bugs as you find more issues :-)

Cheers

Olivier

Google Code Info:
Author: olivier.chafik
Created On: 2010-11-27T22:19:58.000Z

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

1 participant