[JNAerator] issue with parsing defines #255

Closed
vbolshutkin opened this Issue Feb 6, 2012 · 2 comments

Projects

None yet

2 participants

@vbolshutkin

Hello,

I'm trying to use JNAerator to generate BridJ code for my open-source project Octclipse and I've run to some issues with generation. For some of them I've found workarounds, but two of them, as I see are JNAerator's bugs:

1.

When parsing line:

define FOOBAR ""

the output is the following
Failed to convert define 'FOOBAR => "":
java.lang.IllegalArgumentException: Expecting string, got ""

2.

I could not use defines with spaces in my config.jnaerator. For instance, line

-DFOO=unsigned char

is appended directly to command line and JNAerator says, that file "char" was not found.
Workaround was to put all such defines to a separate file and include it first.

P.S. Even after all my workarounds and spikes(and resolving all defines in _jnaerator.preprocessed.c), JNAeration hangs with 100% CPU load. I am not sure that is really JNAerator bug, so it is not a good idea to post all the details here. But where can I ask for help regarding JNAeration?

@vbolshutkin

Here is the simpliest patch for 1st issue:

diff --git a/libraries/jnaerator/jnaerator-parser/src/main/java/com/ochafik/lang/jnaerator/parser/Expression.java b/libraries/jnaerator/jnaerator-parser/src/main/java/com/ochafik/lang/jnaerator/parser/Expression.java
index 83fe250..6007b04 100644
--- a/libraries/jnaerator/jnaerator-parser/src/main/java/com/ochafik/lang/jnaerator/parser/Expression.java
+++ b/libraries/jnaerator/jnaerator-parser/src/main/java/com/ochafik/lang/jnaerator/parser/Expression.java

@@ -1350,7 +1350,7 @@ public abstract class Expression extends Element {
        public static Constant parseString(final String orig) {
             String string = orig;
            int len = string.length();
-           if (len <= 2 || string.charAt(0) != '"' || string.charAt(len - 1) != '"')
+           if (len < 2 || string.charAt(0) != '"' || string.charAt(len - 1) != '"')
                throw new IllegalArgumentException("Expecting string, got " + string);
 
            string = string.substring(1, len - 1);
@ochafik
Member
ochafik commented Feb 12, 2012

Hi @ENargit,

Thanks a lot for your report, much appreciated !

I've fixed the empty string issue (thx for the patch).
About the -D switch : you can use double quotes around the whole argument : "-DFOO=unsigned char".

And regarding the 100% CPU hang you've faced, I would encourage you make sure you've read the FAQ and trouble-shooting pages (http://code.google.com/p/jnaerator/wiki/TroubleShootingJNAeration), and then to open an issue for the parser (if possible with the source code that reproduces the issue).
Please note that there are currently some known regressions in JNAerator 0.9.10-SNAPSHOT, though, and that I'm currently doing my best to iron them out :-S

Cheers

@ochafik ochafik closed this Feb 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment