__stdcall not recognized

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

__stdcall not recognized

Dino Puller
Hi there,
  i'm playing with gluegen to see if it fits my needs. Actually it can't finish to parse my header because of __stdcall (callbacks routines). Any ideas?

tnx,
   Dino Puller
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: __stdcall not recognized

Wade Walker
Administrator
Hi Dino,

It looks like you might have to modify gluegen's C grammar slightly to make this work. If you check out the source and look in gluegen/src/java/com/jogamp/gluegen/cgram, you can see the ANTLR grammar files there (the *.g files). Inside HeaderParser.g and StdCParser.g, you can see the definitions for the functionDef and functionDeclSpecifiers grammar rules don't include any mention of __stdcall (since this is a Microsoft-specific extension).

To fix it quick and dirty, you should be able to simply add __stdcall something like this:

functionDef {
    TypeBox tb = null;
}
        :   #( NFunctionDef
                ( functionDeclSpecifiers)? 
                declarator[tb]
                ("__stdcall")?
                (declaration | VARARGS)*
                compoundStatement
            )
        ;

I'm not quite sure where it goes in the grammar rule -- you might have to poke around a bit and make sure. And it may also need to go in other occurrences of functionDef in other *.g files.

Once you've fixed the grammar, recompile gluegen (making sure the ANTLR parser generation step doesn't throw any errors) and test it out on your input file.

To fix this "for real", you'd probably need to do what they've done for GNU C -- create a new .g file for MS C and just override the parts of the grammar that are different. See the GnuC*.g files for an example.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: __stdcall not recognized

Sven Gothel
Administrator
On Saturday, June 18, 2011 11:04:23 PM Wade Walker [via jogamp] wrote:

>
> Hi Dino,
>
> It looks like you might have to modify gluegen's C grammar slightly to make
> this work. If you check out the source and look in
> gluegen/src/java/com/jogamp/gluegen/cgram, you can see the ANTLR grammar
> files there (the *.g files). Inside HeaderParser.g and StdCParser.g, you can
> see the definitions for the functionDef and functionDeclSpecifiers grammar
> rules don't include any mention of __stdcall (since this is a
> Microsoft-specific extension).
>

well, actually we .. and khronos headers, and usually all others,
use macro definitions to get around this non std qualifier.

However .. sure, you may patch gluegen as Wade suggest as well.
If so, pls offer me a git pull .. w/ unit tests, thx.

~Sven

> To fix it quick and dirty, you should be able to simply add __stdcall
> something like this:
>
>
> functionDef {
>     TypeBox tb = null;
> }
>         :   #( NFunctionDef
>                 ( functionDeclSpecifiers)?
>                 declarator[tb]
>                 ("__stdcall")?
>                 (declaration | VARARGS)*
>                 compoundStatement
>             )
>         ;
>
>
> I'm not quite sure where it goes in the grammar rule -- you might have to
> poke around a bit and make sure. And it may also need to go in other
> occurrences of functionDef in other *.g files.
>
> Once you've fixed the grammar, recompile gluegen (making sure the ANTLR
> parser generation step doesn't throw any errors) and test it out on your
> input file.
>
> To fix this "for real", you'd probably need to do what they've done for GNU
> C -- create a new .g file for MS C and just override the parts of the
> grammar that are different. See the GnuC*.g files for an example.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: __stdcall not recognized

Dino Puller
>well, actually we .. and khronos headers, and usually all others,
>use macro definitions to get around this non std qualifier.
It's seems easier to do but i didn't understand how. I can create a stub header file in which gluegen can see the macro definition, but that keyword is needed into the generated native code. How can i instruct gluegen to use that keyword?

tnx,
   Dino
Loading...