Giter Club home page Giter Club logo

jnaerator's Introduction

BEWARE: This project hasn't been maintained since 2015. An effort to refresh it (and BridJ) is ongoing (Nov 2022), with no guarantees.

Maven Central Build Status Join the chat at https://gitter.im/nativelibs4java/JNAerator

JNAerator generates complete native bindings for C, C++ and Objective-C libraries, targetting BridJ, JNA or node.js runtimes.

A comprehensive documentation is available on its Wiki.

It was previously hosted on ochafik/nativelibs4java.

Quick links

Building

git clone http://github.com/nativelibs4java/JNAerator.git
cd JNAerator
mvn clean install

Support

Please use the mailing-list and file bugs.

jnaerator's People

Contributors

cwalther avatar enzymepower avatar finson avatar gitter-badger avatar ixkael avatar ochafik avatar topikachu avatar twitwi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jnaerator's Issues

Typedef feature request for JNAerate

From @rit001 on June 5, 2013 19:57

From working with JNAerate its seems that all typedefs are decompose back to their more basic definitions, so

typedef int strongint;
int functionCall (strongint in);

ends up with java coding as follows

native public static int functionCall(int in);

would it not be helpful for JNAerate to list all the typedefs and what has been used as their direct replacement? They would be helpful for projects where the original C code seems to have gone out of it's way to build upon layers of typedefs.

Thanks

RIT

Copied from original issue: nativelibs4java/nativelibs4java#412

Better documentation of capability to store and extract native libraries

From @ochafik on September 1, 2011 18:48

Aside from the brief mention of self-extraction of DLL files in the FAQ,
the capabilty of JNAerator to automatically store and extract DLL files is
not well documented. Perhaps you could address the following in your
documentation:

  1. JNAerator bundles its own runtime library in the output jar file,
    including LibraryExtrator, which automatically extracts required native
    libraries.
  2. The location where native library files are extracted to. (And what if
    I want to change this location)?
  3. How to store and extract files that don't end in your default
    extensions (so|dll|dylib|jnilib), such as auxiliary files that my DLLs
    depend on.

This store-and-extract capability is not included in JNA, but I imagine
many people find it useful. So perhaps you should more strongly promote
this capability in JNAerator!

Google Code Info:
Issue #: 53
Author: [email protected]
Created On: 2010-01-24T02:31:30.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#178

vector<unsigned char > error

From @miho on November 11, 2012 20:55

Hi,

when trying to create wrappers for rtmidi library I get the following error:

1. ERROR in file:///rtmidi/RtMidiLibrary.java (at line 45)
public static interface vector<unsigned char > {
                                        ^^^^

I used the following command:

java -jar jnaerator-0.11-SNAPSHOT-20121008.jar -I. -library RtMidi RtMidi.h librtmidi.dylib -mode StandaloneJar

My system: Mac OS X 10.8, Java 1.7.0_07

Regards,

Michael Hoffer

Copied from original issue: nativelibs4java/nativelibs4java#344

Java code not generated if ifdef condition into enum exists

From @dzavodnikov on June 4, 2013 2:1

For example, I have 2 header files: header2_1.h and header2_2.h.

File header2_1.h contains:

#define VERSION  1

#ifndef PARAM
#define PARAM (VERSION < 2)
#endif

int f1();

enum DAY {
    sunday,
    monday,
    tuesday,
    wednesday,
    thursday,
#if PARAM
#include "header2_2.h"
#endif
};

int f2();

File header2_2.h contains:

friday,
saturday

And I use this code to generate wrapper:

$ java -jar jnaerator-0.12-SNAPSHOT-20130323-2.jar  -dontCastConstants \
-f -limitComments -mode 'Directory' -preferJavac -runtime JNA \
-skipLibraryInstance -I include -library test header2_1.h

Result is:

...
public interface TestLibrary extends Library {
    public static final boolean PARAM = (1 < 2);
    public static final int VERSION = 1;
    /// Original signature : <code>int f1()</code>
    int f1();
}

No enumeration definition and no function definitions AFTER enumeration!

If I comment #include "header2_2.h" everything works fine.

Copied from original issue: nativelibs4java/nativelibs4java#410

Failed to #define TRUE !FALSE

From @rslemos on April 10, 2012 13:43

Given as input:

#define FALSE 0
#define TRUE !FALSE

Jnaerator display some parsing errors:

line 1:0 Failed to match any alternative with token [@0,0:0='<EOF>',<-1>,1:0]
     File: null:1
    Input: <EOF>
     Rule: 
    Stack: []

line 1:0 Failed to match any alternative with token [@0,0:0='<EOF>',<-1>,1:0]
     File: null:1
    Input: <EOF>
     Rule: 
    Stack: []

line 1:0 Failed to match any alternative with token [@0,0:0='<EOF>',<-1>,1:0]
     File: null:1
    Input: <EOF>
     Rule: 
    Stack: []

And outputs library wrapper skipping the troublesome #definition:

        /// <i>native declaration : src/main/c/test.h</i>
        public static final int FALSE = (int)0;
        /**
         * define<br>
         * Conversion Error : !0<br>
         * SKIPPED:<br>
         * <i>native declaration : src/main/c/test.h:0</i><br>
         * !0
         */

I'm not sure about which output would be correct in this case (since !0 in C can be used as boolean and is only expanded when needed).

Copied from original issue: nativelibs4java/nativelibs4java#298

problems with jnaerator parsing the fuse library on linux

From @ochafik on September 1, 2011 18:46

Here's what I've tried:

java -jar jnaerator-0.9.3.jar -library fuse -o . -package my.jnafuse
-D__s32=int -DFUSE_USE_VERSION=26 -D_FILE_OFFSET_BITS=64 -direct -jar
./jnafuse.jar -preferJavac -scanSymbols /usr/include/fuse.h /usr/lib/libfuse.so

Here's what I get:
javacTask: no source files
Usage: javacTask
use -help for a list of possible options
JNAeration completed !

jnaerator does create the jar file but doesn't generate any java classes in
it.

Without the -preferJavac I get a complaint from the eclipse compiler.

OS is ubuntu 9.04 fuse is version 26
java -version
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Server VM (build 10.0-b19, mixed mode)

Google Code Info:
Issue #: 54
Author: [email protected]
Created On: 2010-02-03T02:08:50.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#138

Can not generate C plus plus method

From @dudi123456 on September 18, 2013 9:28

Hello:
I am a newbie for jnaerator. Below is my scirpt:
@echo off
set dst=ctp_api-4.0.jar
set dll= thosttraderapi.dll
set inc= ThostFtdcTraderApi.h ThostFtdcUserApiDataType.h ThostFtdcUserApiStruct.h
set sdk=ctp
set rt=JNA
C:\Java\jdk1.6.0_34\bin\java -jar jnaerator-0.11-shaded.jar -jar %dst% -library %sdk% -root com.dxf -runtime %rt% %dll% %inc% -mode Jar -noComments -v -f

the ThostFtdcTraderApi.h

if !defined(_FTDCTRADERAPI_H)

define _FTDCTRADERAPI_H

if _MSC_VER > 1000

pragma once

endif // _MSC_VER > 1000

include "ThostFtdcUserApiStruct.h"

if defined(ISLIB) && defined(WIN32)

ifdef LIB_TRADER_API_EXPORT

define TRADER_API_EXPORT __declspec(dllexport)

else

define TRADER_API_EXPORT __declspec(dllimport)

endif

else

define TRADER_API_EXPORT

endif

class CThostFtdcTraderSpi
{
public:
virtual void OnFrontConnected(){};
.....

I can gen files successsfully. but there are no methods in the library.

Copied from original issue: nativelibs4java/nativelibs4java#441

Create BridJ Mapping for method with IplImage* parameter

From @apiening on September 16, 2012 22:11

Hi nativelibs4java team,

I have a library written in C++ using OpenCV 2.4.2 doing image analys and manipulation. I want to leave the chained processing in the C++ unit as much as possible (for performance and decoupling).

Basically I want to call the library from Java (Mac OS X 10.8.1) with the image-data and display the manipulated image on a swing JScrollPane canvas.

=> I have JavaCV running and I can create IplImage Objects and use them. Now I would like to pass a IplImage to my C++ library.
=> I have added a method signature in my header file with a IplImage* parameter
=> I use JNAerator to create the mapping code, but it fails:

java -Xmx1g -jar jnaerator-0.10-shaded.jar -I/opt/local/include/ BridJTest_so_Cpp/dist/Debug/GNU-MacOSX/libBridJTest_so_Cpp.dylib BridJTest_so_Cpp/Test.h -mode Jar

Warning: no -library option for file 'Test.h', using "Test".
Auto-configuring parser...
Parsing native headers...
/usr/include/sys/cdefs.h:74:25: warning: #warning "Unsupported compiler detected"
/opt/local/include/opencv2/core/operations.hpp:55:0: error: File not found: bits/atomicity.h in /opt/local/include /opt . /usr/include /usr/include/c++/4.2.1 /usr/include/c++/4.2.1/tr1

Looking into /opt/local/include/opencv2/core/operations.hpp it looks like bits/atomicity.h should not be included for my plattorm if i red the preprocessor directives correctly. But JNAerator tries it anyway and fails (wrong defines?).
I had success creating working mappings if I removed the OpenCV header includes and the IplImage parameter.

Please can you give me a hint how I get in the right direction? Is there a chance to use the JavaCP BridJ mapping and "extend" in that way that I can call my method with the IplImage* parameter?

Any help on this topic would be greatly appreciated!

Thank you!

Andreas Piening

Copied from original issue: nativelibs4java/nativelibs4java#337

Possible endless recursion

From @ochafik on September 1, 2011 18:48

What steps will reproduce the problem?

  1. Generate bindings for xlib (/usr/include/X11)

What is the expected output? What do you see instead?
Should generate bindings, instead fails with out of heap space excpetion in maven (upping the max heap space is no solution). Running directly from the jnaerator jar points to possible endless recursion.

What version of the product are you using? On what operating system?
0.97

Is the problem still present in the latest SVN version ? (you can easily
build from sources with these instructions : not tested

Please provide any additional information below.

Build using ubuntu linux 32-bit

Google Code Info:
Issue #: 90
Author: DeRijcke.Erik
Created On: 2011-07-27T21:43:42.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#164

Null pointer exception when using a visual studio solution

From @ochafik on September 1, 2011 18:47

What steps will reproduce the problem?

  1. I try to generate interfaces for a whole solution
  2. I run "java -jar jnaerator-0.9.5.jar sundials.sln"
  3. And it results in an exception

What is the expected output? What do you see instead?
They output is:
Dec 29, 2010 6:21:11 PM com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] ProgramFiles(x86)=C:\Program Files (x86)
Dec 29, 2010 6:21:11 PM com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] VISUAL_STUDIO_HOME=C:\Program Files (x86)\Microsoft Visual Studio 9.0
Dec 29, 2010 6:21:11 PM com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] ProgramFiles(x86)=C:\Program Files (x86)
Dec 29, 2010 6:21:11 PM com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] WINDOWS_SDK_HOME=C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A
Dec 29, 2010 6:21:11 PM com.ochafik.admin.visualstudio.VisualStudioUtils getProp
INFO: [environment] VISUAL_STUDIO_INCLUDES=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include;C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Include
Error parsing arguments :
sundials.sln
Finished with errors.
java.lang.NullPointerException
at com.ochafik.lang.jnaerator.JNAeratorConfigUtils.readProjectConfig(JNAeratorConfigUtils.java:390)
at com.ochafik.lang.jnaerator.JNAerator$1.parsedFile(JNAerator.java:565)
at com.ochafik.lang.jnaerator.JNAerator$1.parsed(JNAerator.java:400)
at com.ochafik.lang.jnaerator.JNAeratorCommandLineArgs$ArgsParser.parse(JNAeratorCommandLineArgs.java:89)
at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:290)
at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:171)

What version of the product are you using? On what operating system?

Is the problem still present in the latest SVN version ? (you can easily
build from sources with these instructions :
http://code.google.com/p/javacl/wiki/Build)

Please provide any additional information below.
I tried to generate a java interface for the Sundials (https://computation.llnl.gov/casc/sundials/main.html) library which is written in C. Following their installation instructions and using CMake, I created a visual studio solution. Then I compiled it for Windows with Visual Studio 2010. I then tried to use the aforementioned command to generate the java interface but it failed with the given exception. I can also provide the complete solution with the code and built dlls if needed (somewhere around 100mb I guess).

Google Code Info:
Issue #: 77
Author: [email protected]
Created On: 2010-12-29T17:35:16.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#154

Please add -scanSymbols support for .tlb and .exe files

From @bernard01 on December 31, 2012 22:57

Hi,

Hopefully some java source code can be generated from type libraries. These can be extracted from .tlb files, .dll files, .exe files and possibly others.

I used jacoZoom to generate from SketchUp.exe. http://www.sketchup.com has a free version. This was only partially successful because jacoZoom and others do not support UDT arrays in parameters. But there may be other .exe files that are easier to generate from.

DesignCad 3dMax http://www.imsidesign.com/Products/DesignCADSeries/DesignCAD3DMAXV22/tabid/1832/Default.aspx has a trial download. It contains Dcad22.tlb in its root program directory. jacoZoom generates good java files from it.

It would be really nice if jnaerator could be the reference starting point for interfacing with ANY native library because it seems that support for other java native open source projects and even some commercial products is no longer available.

Thanks.

Copied from original issue: nativelibs4java/nativelibs4java#353

JNAerator issue - not generating proper .java code

From @tedgress on March 14, 2013 23:42

I am having difficulty with JNAerator creating proper .java files from my headers.

Header:

#include <LEDA/core/p_queue.h>
#include <list>

using namespace leda;

struct bin_tree_node
{
  ~bin_tree_node(){delete L; delete R;}
  bin_tree_node *L, *R, *P;
  double h;
  int id;
};

struct search_struct
{
  int prev, cur;
  double accum;
};



struct mst_edge
{
  int u, v;
  double w;
};

struct construct_ret
{
  int i;
  double f, *p;
};

 int test_bit(unsigned char*bits, int i);

 void clear_bit(unsigned char*bits, int i);

 void set_bit(unsigned char*bits, int i);

void MST_Prim(double**Dists, int size, int root, int*Pa);

bool rcmp_mst_edge(mst_edge a, mst_edge b);

bin_tree_node*  FitTreeToGraph(double ** Dists, int a, int size);

bin_tree_node* GetUFromMST(std::list<int> * adj_list,
                           mst_edge * tree_edges, int size,
                           int* verticies, unsigned char*bits,
                           double ** Dists);


construct_ret ConstructTree(bin_tree_node* btn, int node, double ** Dists);


void PostfixTraversial(FILE*fout, bin_tree_node* btn);


int main(int argc, char*argv[]);

JNAerator creates the following java file:

package test;
import org.bridj.BridJ;
import org.bridj.CRuntime;
import org.bridj.ann.Library;
import org.bridj.ann.Runtime;
/**
 * Wrapper for library <b>test</b><br>
 * This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
 * a tool written by <a href="http://ochafik.com/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
 * For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> or <a href="http://bridj.googlecode.com/">BridJ</a> .
 */
@Library("test") 
@Runtime(CRuntime.class) 
public class TestLibrary {
    static {
        BridJ.register();
    }
    /// Undefined type
    /// Undefined type
    public static interface _Tp {

    };
    /// Undefined type
    /// Undefined type
    public static interface _Iffalse {

    };
}

Copied from original issue: nativelibs4java/nativelibs4java#388

NullPointerException in JNAeratorParser

From @blair0011 on February 25, 2013 22:13

I am trying to generate wrapper classes via JNAerator but I either do not get anything generated or this error happens (I added -parseChunks after reading another issue entry). Oh I am running on CentOS 6.3 with Oracle JDK 1.7.0_10b18.

java -jar jnaerator-0.11-shaded.jar config.jnaerator libA.h
Auto-configuring parser...
Feb 25, 2013 1:48:30 PM com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_INCLUDE_PATH=.:/usr/include:/usr/local/include:/usr/include/c++/4.4.6:/usr/include/c++/4.4.6/tr1
Feb 25, 2013 1:48:30 PM com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_FRAMEWORKS_PATH=/System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks:/Library/Frameworks:/Local/Library/Frameworks/:/home/blair/Library/Frameworks
os.arch = amd64
Feb 25, 2013 1:48:30 PM com.ochafik.lang.jnaerator.JNAerator jnaerate
INFO: Include path :
/usr/include/c++/4.4.6/x86_64-redhat-linux
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/include
.
/usr/include
/usr/local/include
/usr/include/c++/4.4.6
/usr/include/c++/4.4.6/tr1
Parsing native headers...
Writing preprocessor output to '_jnaerator.preprocessed.c'
Writing preprocessor macros to '_jnaerator.macros.cpp'
Now trying to parse sources slice by slice.
Now parsing 418 slices
java.util.concurrent.ExecutionException: com.ochafik.lang.jnaerator.JNAeratorParser$ParseError: Failed to parse because of java.lang.NullPointerException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:262)
at java.util.concurrent.FutureTask.get(FutureTask.java:119)
at com.ochafik.lang.jnaerator.JNAeratorParser.parse(JNAeratorParser.java:267)
at com.ochafik.lang.jnaerator.JNAerator.parseSources(JNAerator.java:1224)
at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:923)
at com.ochafik.lang.jnaerator.JNAerator$1.finished(JNAerator.java:734)
at com.ochafik.lang.jnaerator.JNAeratorCommandLineArgs$ArgsParser.parse(JNAeratorCommandLineArgs.java:135)
at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:239)
at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:212)
Caused by: com.ochafik.lang.jnaerator.JNAeratorParser$ParseError: Failed to parse because of java.lang.NullPointerException
at com.ochafik.lang.jnaerator.JNAeratorParser$1.call(JNAeratorParser.java:160)
at com.ochafik.lang.jnaerator.JNAeratorParser$1.call(JNAeratorParser.java:126)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
at com.ochafik.lang.jnaerator.parser.ObjCppParser.qualifiedCppFunctionName(ObjCppParser.java:9697)
at com.ochafik.lang.jnaerator.parser.ObjCppParser.functionDeclaration(ObjCppParser.java:4417)
at com.ochafik.lang.jnaerator.parser.ObjCppParser.declaration(ObjCppParser.java:1153)
at com.ochafik.lang.jnaerator.parser.ObjCppParser.namespaceDecl(ObjCppParser.java:1421)
at com.ochafik.lang.jnaerator.parser.ObjCppParser.declaration(ObjCppParser.java:1274)
at com.ochafik.lang.jnaerator.parser.ObjCppParser.sourceFile(ObjCppParser.java:763)
at com.ochafik.lang.jnaerator.JNAeratorParser$1.call(JNAeratorParser.java:140)
... 6 more
Parsing failed : java.util.concurrent.ExecutionException: com.ochafik.lang.jnaerator.JNAeratorParser$ParseError: Failed to parse because of java.lang.NullPointerException
Parsing failed : java.util.concurrent.TimeoutException
Parsing failed : java.util.concurrent.TimeoutException

My config file is this:
-library my_bridj
-I /usr/include/c++/4.4.6/x86_64-redhat-linux
-I /usr/lib/gcc/x86_64-redhat-linux/4.4.6/include/
-mode StandaloneJar
-reification
-package libACE
-v
-f
-parseChunks

Copied from original issue: nativelibs4java/nativelibs4java#380

Put #defines found in structs inside the JNAerated classes of these structs

From @ochafik on September 1, 2011 18:48

This enhancement request was taken from Comment 2 of issue #36 by [email protected], Oct
01, 2009 :
An additional requirement would be to define the static constants inside the
generated classes when the #define is found inside a struct (ffmpeg makes a lot of
use of this pattern).

It would require a change of the parser to identify the end of each element, and a change of the
generator to match start/end offsets with #defines.

Google Code Info:
Issue #: 45
Author: olivier.chafik
Created On: 2009-10-28T00:21:22.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#175

BridJ (via JNAerator studio) fails to process simple code with includes throwing 'OutOfMemory'

From @lazyval on November 27, 2011 13:27

Here is the snippet of header file:

#include <iostream>

void printSome(int argc, int xs[]);

int intTest(int arg);

Pretty simple, yeah, but looks like BridJ has to parse out so after a while it fails. Here is the output of log:

/usr/include/c++/4.4.5/iostream:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/iosfwd:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/stringfwd.h:14:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cwchar:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cstddef:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cstddef:19:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/exception:11:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/stl_algobase.h:38:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/functexcept.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/cpp_type_traits.h:14:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/type_traits.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/move.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/concept_check.h:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/stl_iterator_base_types.h:42:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cstdio:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/stdio.h:28:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/_G_config.h:8:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/wchar.h:31:0: error: File not found: stddef.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/libio.h:35:0: error: File not found: stdarg.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/localefwd.h:14:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/localefwd.h:15:0: error: File not found: bits/c++locale.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cctype:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/atomicity.h:12:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/atomicity.h:13:0: error: File not found: bits/gthr.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/ext/atomicity.h:14:0: error: File not found: bits/atomic_word.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/string:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/allocator.h:25:0: error: File not found: bits/c++allocator.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/streambuf:13:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/cwctype:18:0: error: File not found: bits/c++config.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/locale_facets.h:15:0: error: File not found: bits/ctype_base.h in . /usr/include /usr/include/c++/4.4.5
/usr/include/c++/4.4.5/bits/locale_facets.h:1256:0: error: File not found: bits/ctype_inline.h in . /usr/include /usr/include/c++/4.4.5
Exception for /usr/include/c++/4.4.5/ios at line 1128:java.util.concurrent.ExecutionException: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
java.util.concurrent.ExecutionException: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:262)
    at java.util.concurrent.FutureTask.get(FutureTask.java:119)
    at com.ochafik.lang.jnaerator.JNAeratorParser.parseSlices(JNAeratorParser.java:177)
    at com.ochafik.lang.jnaerator.JNAeratorParser.parse(JNAeratorParser.java:213)
    at com.ochafik.lang.jnaerator.JNAerator.parseSources(JNAerator.java:1119)
    at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:837)
    at com.ochafik.lang.jnaerator.studio.JNAeratorStudio$14.run(JNAeratorStudio.java:607)
Caused by: java.lang.Exception: java.lang.OutOfMemoryError: Java heap space
    at com.ochafik.lang.jnaerator.JNAeratorParser$1.call(JNAeratorParser.java:147)
    at com.ochafik.lang.jnaerator.JNAeratorParser$1.call(JNAeratorParser.java:136)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.OutOfMemoryError: Java heap space
----------
1. WARNING in file:///test/_IO_marker.java (at line 17)
    public _IO_marker(Pointer pointer) {
                      ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
2. WARNING in file:///test/_IO_marker.java (at line 18)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
3. WARNING in file:///test/_G_fpos64_t.java (at line 17)
    public _G_fpos64_t(Pointer pointer) {
                       ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
4. WARNING in file:///test/_G_fpos64_t.java (at line 18)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
5. WARNING in file:///test/_G_fpos_t.java (at line 17)
    public _G_fpos_t(Pointer pointer) {
                     ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
6. WARNING in file:///test/_G_fpos_t.java (at line 18)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
7. WARNING in file:///test/mbstate_t.java (at line 18)
    public mbstate_t(Pointer pointer) {
                     ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
8. WARNING in file:///test/mbstate_t.java (at line 19)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
9. WARNING in file:///test/TestLibrary.java (at line 619)
    return (Pointer<_IO_FILE >)BridJ.getNativeLibrary("test").getSymbolPointer("stdin").as(DefaultParameterizedType.paramType(Pointer.class, _IO_FILE.class)).get();
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<_IO_FILE>
----------
10. WARNING in file:///test/TestLibrary.java (at line 650)
    return (Pointer<_IO_FILE >)BridJ.getNativeLibrary("test").getSymbolPointer("stdout").as(DefaultParameterizedType.paramType(Pointer.class, _IO_FILE.class)).get();
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<_IO_FILE>
----------
11. WARNING in file:///test/TestLibrary.java (at line 680)
    return (Pointer<_IO_FILE >)BridJ.getNativeLibrary("test").getSymbolPointer("stderr").as(DefaultParameterizedType.paramType(Pointer.class, _IO_FILE.class)).get();
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<_IO_FILE>
----------
12. WARNING in file:///test/TestLibrary.java (at line 728)
    return (Pointer<Pointer<Byte > >)BridJ.getNativeLibrary("test").getSymbolPointer("sys_errlist").as(DefaultParameterizedType.paramType(Pointer.class, DefaultParameterizedType.paramType(Pointer.class, Byte.class))).get();
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: Unchecked cast from Object to Pointer<Pointer<Byte>>
----------
----------
13. WARNING in file:///test/__mbstate_t.java (at line 19)
    public __mbstate_t(Pointer pointer) {
                       ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
14. WARNING in file:///test/__mbstate_t.java (at line 20)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
15. WARNING in file:///test/__mbstate_t.java (at line 57)
    public __value_union(Pointer pointer) {
                         ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
16. WARNING in file:///test/__mbstate_t.java (at line 58)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
17. WARNING in file:///test/_IO_FILE.java (at line 19)
    public _IO_FILE(Pointer pointer) {
                    ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
18. WARNING in file:///test/_IO_FILE.java (at line 20)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
19. ERROR in file:///test/_IO_FILE.java (at line 525)
    @Array({15 * 4 - 4 * org.bridj.Pointer.SIZE - com.ochafik.lang.jnaerator.runtime.NativeSize.SIZE}) 
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The value for annotation attribute Array.value must be a constant expression
----------
----------
20. WARNING in file:///test/__locale_struct.java (at line 19)
    public __locale_struct(Pointer pointer) {
                           ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
21. WARNING in file:///test/__locale_struct.java (at line 20)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
----------
22. WARNING in file:///test/__fsid_t.java (at line 18)
    public __fsid_t(Pointer pointer) {
                    ^^^^^^^
Pointer is a raw type. References to generic type Pointer<T> should be parameterized
----------
23. WARNING in file:///test/__fsid_t.java (at line 19)
    super(pointer);
          ^^^^^^^
Type safety: The expression of type Pointer needs unchecked conversion to conform to Pointer<? extends StructObject>
----------
23 problems (1 error, 22 warnings)

I don't care about warnings, but this one error is confusing.
I've tried to specify more memory to JNAerator appending -Xmx2g but even with 2g of ram result is the same. Is there some workaround?

My environment is
Ubuntu 10.10 x86 / JNAerator 0.9.9-SNAPSHOT
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.10) (6b20-1.9.10-0ubuntu1~10.10.2)

Copied from original issue: nativelibs4java/nativelibs4java#205

Classes not generated

Hi Olivier Chafik,

The System

  1. Windows XP
  2. Microsoft Visual Studio 2010 Express

The Command

$env:VISUAL_STUDIO_HOME="D:\Program Files\Microsoft Visual Studio 10.0"
$env:WINDOWS_SDK_HOME="D:\Program Files\Microsoft SDKs\Windows\v7.0A"
java -jar jnaerator-0.13-20150311.101753-1-shaded.jar D:\Wind\WAPI.PE\WAPIWrapperCPP\lib\Win32\WAPIWrapperCpp.dll D:\Wind\WAPI.PE\WAPIWrapperCPP\API\WAPIWrapperCpp.h -mode StandaloneJar

Expected Output

There should be Java enum for ErrMsgLang, and Java classes for WindData and CWAPIWrapperCpp

Actual Output

There is only Java enum for ErrMsgLang

## The CPP File

#ifndef _WAPIWRAPPERCPP_H
#define _WAPIWRAPPERCPP_H

#include <windows.h>
#include <comutil.h>

#ifdef WAPIWRAPPERCPP_EXPORTS
#define WAPIWRAPPERCPP_EXP __declspec(dllexport)
#else
#define WAPIWRAPPERCPP_EXP __declspec(dllimport)
#endif

//ๆŽงไปถๆœชๆณจๅ†Œ้”™่ฏฏ
const LONG noRegErr = -1;

enum ErrMsgLang //้”™่ฏฏไฟกๆฏ่ฏญ่จ€
{
    eENG = 0,   ///< ่‹ฑ่ฏญ
    eCHN,       ///< ไธญๆ–‡
};

class WAPIWRAPPERCPP_EXP WindData
{
public:
    VARIANT data;   ///< ๆ•ฐๆฎ
    VARIANT codes;  ///< Codeๅˆ—่กจ
    VARIANT fields; ///< ๆŒ‡ๆ ‡ๅˆ—่กจ
    VARIANT times;  ///< ๆ—ถ้—ดๅˆ—่กจ
    LONG errorCode; ///< ้”™่ฏฏ็ 
public:

    WindData();
    ~WindData();

    VOID InitWindData();
    VOID ClearWindData();

    //่Žทๅ–้”™่ฏฏไฟกๆฏ
    LPCWSTR GetErrorMsg() const;

    //ๆ—ฅๆœŸ่ฝฌๅŒ–ๅ‡ฝๆ•ฐ(้œ€่ฆdelete)
    static WCHAR* DateToString(DATE date, LPCWSTR strFormat = L"%Y-%m-%d");
    static VOID FreeString(WCHAR*& pStr);

    //////////////////////////////////////////////////////////////////////////
    //ๆ•ฐๆฎไฝฟ็”จ

    INT GetCodesLength() const;
    INT GetFieldsLength() const;
    INT GetTimesLength() const;

    LPCWSTR GetCodeByIndex(int index) const;
    LPCWSTR GetFieldsByIndex(int index) const;
    BOOL GetTimeByIndex(int index, WCHAR timeBuffer[], int& length) const;
    DATE GetTimeByIndex(int index) const;

    //่Žทๅ–ๆ•ฐๆฎๆŸฅ่ฏขๆŽฅๅฃOneData
    BOOL GetDataItem(int timeIndex, int codesIndex, int fieldsIndex, VARIANT& outItem) const;

    //่Žทๅ–ๆ—ฅๆœŸๅˆ—่กจ
    const DATE* GetTDaysInfo(LONG& lDateCount) const;

    //////////////////////////////////////////////////////////////////////////
    //ไบคๆ˜“ไฝฟ็”จ

    INT GetRecordCount() const;

    //่Žทๅ–ไบคๆ˜“ๆŽฅๅฃOneData
    BOOL GetTradeItem(int recordIndex, int fieldsIndex, VARIANT& outItem) const;

    //่Žทๅ–็™ปๅฝ•ID
    LONG GetLogonID() const;

    //่Žทๅ–Order่ฏทๆฑ‚Id
    LONG GetOrderRequestID() const;

    //่Žทๅ–OrderNumber
    LPCWSTR GetOrderNumber(int recordIndex = 0) const;
};

// ๅ›ž่ฐƒๅ‡ฝๆ•ฐๅฎšไน‰
typedef LONG (WINAPI *WsqCallBack)(const WindData &windData);

// ๆญค็ฑปๆ˜ฏไปŽ WAPIWrapperCpp.dll ๅฏผๅ‡บ็š„
class WAPIWRAPPERCPP_EXP CWAPIWrapperCpp {
public:

    //ๅŸบๆœฌๅ‡ฝๆ•ฐ
    //////////////////////////////////////////////////////////////////////////
    //WindๆŽฅๅฃๅฏๅŠจๅ‡ฝๆ•ฐ
    static LONG start(LPCWSTR options = NULL, LPCWSTR options2 = NULL, LONG timeout = 5000);

    //WindๆŽฅๅฃ็ปˆๆญขๅ‡ฝๆ•ฐ
    static LONG stop();

    //ๅˆคๆ–ญ่ฟžๆŽฅ็Šถๆ€
    static LONG isconnected();

    //่‹ฅ requestId ไธบ0 ๅ–ๆถˆๆ‰€ๆœ‰่ฏทๆฑ‚๏ผ›ๅฆๅˆ™ๅชๅ–ๆถˆ็ป™ๅฎšIDๅท็š„่ฏทๆฑ‚
    static VOID cancelRequest(ULONGLONG requestId);

    //ๅ–ๆถˆๆ‰€ๆœ‰่ฏทๆฑ‚
    static VOID cancelAllRequest();

    //่Žทๅ–้”™่ฏฏ็ ็›ธๅบ”็š„้”™่ฏฏไฟกๆฏ
    static BOOL getErrorMsg(LONG errCode, ErrMsgLang lang, WCHAR msg[], int& /*inout*/msgLength);

    //////////////////////////////////////////////////////////////////////////

    //ๆ•ฐๆฎๅ‡ฝๆ•ฐ
    //////////////////////////////////////////////////////////////////////////
    //ๅคšๅ€ผๅ‡ฝๆ•ฐwsd๏ผŒ่Žทๅพ—ๆ—ฅๆœŸๅบๅˆ—
    static LONG wsd(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR startTime = NULL, LPCWSTR endTime = NULL, LPCWSTR options = NULL);

    //ๅคšๅ€ผๅ‡ฝๆ•ฐwss๏ผŒ่Žทๅพ—ๅŽ†ๅฒๅฟซ็…ง
    static LONG wss(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR options = NULL);

    //ๅคšๅ€ผๅ‡ฝๆ•ฐwsi๏ผŒ่Žทๅพ—ๅˆ†้’Ÿๅบๅˆ—
    static LONG wsi(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR startTime, LPCWSTR endTime, LPCWSTR options = NULL);

    //ๅคšๅ€ผๅ‡ฝๆ•ฐwst๏ผŒ่Žทๅพ—ๆ—ฅๅ†…่ทณไปท
    static LONG wst(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR startTime, LPCWSTR endTime, LPCWSTR options = NULL);

    //ๅคšๅ€ผๅ‡ฝๆ•ฐwsq๏ผŒ่Žทๅพ—ๅฎžๆ—ถ่กŒๆƒ…
    //้ž่ฎข้˜…ๆจกๅผ๏ผŒๅ–ไธ€ๆฌกๆ€งๅฟซ็…งๆ•ฐๆฎ
    static LONG wsq(WindData& outWindData, LPCWSTR windCodes, LPCWSTR fields, LPCWSTR options = NULL);

    //่ฎข้˜…ๆจกๅผ๏ผŒ่ฎข้˜…ๅฎžๆ—ถๆ•ฐๆฎ๏ผŒๆ•ฐๆฎ้€š่ฟ‡ๅ›ž่ฐƒๅ‡ฝๆ•ฐ่ฟ”ๅ›ž
    static LONG wsq(ULONGLONG &reqId, LPCWSTR windCodes, LPCWSTR fields, WsqCallBack callBack, LPCWSTR options = NULL, BOOL updateAllFields = FALSE);

    //ๅคšๅ€ผๅ‡ฝๆ•ฐwset๏ผŒ่Žทๅพ—ๆŒ‡ๅฎšๆ•ฐๆฎ้›†
    static LONG wset(WindData& outWindData, LPCWSTR reportName, LPCWSTR options = NULL);

    //ๅคšๅ€ผๅ‡ฝๆ•ฐedb๏ผŒ่Žทๅพ—็ปๆตŽๆ•ฐๆฎ
    static LONG edb(WindData& outWindData, LPCWSTR windCodes, LPCWSTR startTime = NULL, LPCWSTR endTime = NULL, LPCWSTR options = NULL);

    //็ป„ๅˆๆŠฅ่กจๅ‡ฝๆ•ฐ
    static LONG wpf(WindData& outWindData, LPCWSTR portfolioName, LPCWSTR viewName, LPCWSTR options = NULL);

    //็ป„ๅˆไธŠไผ ๅ‡ฝๆ•ฐ
    static LONG wupf(WindData& outWindData, LPCWSTR portfolioName, LPCWSTR tradeDate, LPCWSTR windCodes, LPCWSTR quantity, LPCWSTR costPrice, LPCWSTR options = NULL);

    //่ฏๅŠต็ญ›้€‰ๅ‡ฝๆ•ฐ
    static LONG weqs(WindData& outWindData, LPCWSTR planName, LPCWSTR options = NULL);

    //ๆ—ฅๅŽ†ๆ—ฅใ€ๅทฅไฝœๆ—ฅใ€ไบคๆ˜“ๆ—ฅ็š„ๆ—ฅๆœŸๅบๅˆ—ๅ‡ฝๆ•ฐ
    static LONG tdays(WindData& outWindData, LPCWSTR startTime, LPCWSTR endTime, LPCWSTR options = NULL);

    //ๆ—ฅๅŽ†ๆ—ฅใ€ๅทฅไฝœๆ—ฅใ€ไบคๆ˜“ๆ—ฅ็š„ๆ—ฅๆœŸๅ็งป่ฎก็ฎ—
    static LONG tdaysoffset(DATE& outDate, LPCWSTR startTime, LONG offset, LPCWSTR options = NULL);

    //ๆ—ฅๅŽ†ๆ—ฅใ€ๅทฅไฝœๆ—ฅใ€ไบคๆ˜“ๆ—ฅ็š„ๆ—ฅๆœŸๅคฉๆ•ฐ่ฎก็ฎ—
    static LONG tdayscount(LONG& outCount, LPCWSTR startTime, LPCWSTR endTime, LPCWSTR options = NULL);
    //////////////////////////////////////////////////////////////////////////

    //ไบคๆ˜“ๅ‡ฝๆ•ฐ
    //////////////////////////////////////////////////////////////////////////
    //ไบคๆ˜“่ดฆๅท็™ป้™†
    static LONG tlogon(WindData& outWindData, LPCWSTR brokerID, LPCWSTR departmentID, LPCWSTR accountID, LPCWSTR password, LPCWSTR accountType, LPCWSTR options = NULL);

    //ไบคๆ˜“่ดฆๅท็™ปๅ‡บ, 0:็™ปๅ‡บๅ…จ้ƒจๅทฒ็™ปๅฝ•็š„่ดฆๅท
    static LONG tlogout(INT longId=0);

    //ไธ‹ๅ•
    static LONG torder(WindData& outWindData, LPCWSTR windCodes, LPCWSTR tradeSide, LPCWSTR orderPrice, LPCWSTR orderVolume, LPCWSTR options = NULL);
    static LONG torder(LONG& reqId, LPCWSTR windCodes, LPCWSTR tradeSide, DOUBLE orderPrice, LONG orderVolume, LPCWSTR options = NULL, WCHAR** pErrosMsg = NULL);

    //ๅค‡ๅ…‘
    static LONG tcovered(WindData& outWindData, LPCWSTR windCodes, LPCWSTR tradeSide, LPCWSTR orderVolume, LPCWSTR options = NULL);
    static LONG tcovered(LONG& reqId, LPCWSTR windCodes, LPCWSTR tradeSide, LONG orderVolume, LPCWSTR options = NULL, WCHAR** pErrosMsg = NULL);

    //ไบคๆ˜“ๆƒ…ๅ†ตๆŸฅ่ฏข
    static LONG tquery(WindData& outWindData, LPCWSTR qryCode, LPCWSTR options = NULL);

    //ๆ’คๅ•
    static LONG tcancel(LPCWSTR orderNumber, LPCWSTR options = NULL);
    //////////////////////////////////////////////////////////////////////////

    //ๅ›žๆต‹ๅ‡ฝๆ•ฐ
    //////////////////////////////////////////////////////////////////////////
    //ๅ›žๆต‹ๅผ€ๅง‹
    static LONG bktstart(WindData& outWindData, LPCWSTR strategyName, LPCWSTR startDate, LPCWSTR endDate, LPCWSTR options = NULL);

    //ๅ›žๆต‹ๆŸฅ่ฏข
    static LONG bktquery(WindData& outWindData, LPCWSTR qrycode, LPCWSTR qrytime, LPCWSTR options = NULL);

    //ๅ›žๆต‹ไธ‹ๅ•
    static LONG bktorder(WindData& outWindData, LPCWSTR tradeTime, LPCWSTR securityCode, LPCWSTR tradeSide, LPCWSTR tradeVol, LPCWSTR options = NULL);

    //ๅ›žๆต‹็ป“ๆŸ
    static LONG bktend(WindData& outWindData, LPCWSTR options);

    //ๆŸฅ็œ‹ๅ›žๆต‹็Šถๆ€
    static LONG bktstatus(WindData& outWindData, LPCWSTR options);

    //ๅ›žๆต‹ๆฆ‚่ฆ
    static LONG bktsummary(WindData& outWindData, LPCWSTR bktID, LPCWSTR view, LPCWSTR options);

    //ๅ›žๆต‹ๅˆ ้™ค
    static LONG bktdelete(WindData& outWindData, LPCWSTR bktID, LPCWSTR options);

    //่ฟ”ๅ›ž็ญ–็•ฅๅˆ—่กจ
    static LONG bktstrategy(WindData& outWindData, LPCWSTR options);

    //////////////////////////////////////////////////////////////////////////
};

#endif

Regards,
sinall

Partial specialization file name

From @ochafik on September 1, 2011 18:47

What steps will reproduce the problem?

  1. Create a new file test.h containing

template
struct my_template {
// A partial specialization
};

  1. Run jnaerator
    java -jar jnaerator-0.9.7-SNAPSHOT-shaded.jar -library Test test.h -o . -v -noJar -noComp

What is the expected output? What do you see instead?

It fails to create the correct java file for the structure, because it tries to put angle brackets with the type in the filename.

Now parsing 1 text blocks
Normalizing parsed code...
Writing raw parsed sources to '_jnaerator.rawParsed.cpp'
Writing normalized parsed sources to '_jnaerator.normalizedParsed.cpp'
Generating libraries...
Struct with no field : my_template
Generating my_template.java
JNAeration failed !
java.io.FileNotFoundException: .\test\my_template.java (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(Unknown Source)
at java.io.FileOutputStream.(Unknown Source)
at java.io.PrintWriter.(Unknown Source)
at com.ochafik.lang.jnaerator.JNAerator$3$1.(JNAerator.java:795)
at com.ochafik.lang.jnaerator.JNAerator$3.getClassSourceWriter(JNAerator.java:795)
at com.ochafik.lang.jnaerator.JNAerator.getClassSourceWriter(JNAerator.java:745)
at com.ochafik.lang.jnaerator.JNAerator$4.getClassSourceWriter(JNAerator.java:809)
at com.ochafik.lang.jnaerator.DeclarationsConverter.outputConvertedStruct(DeclarationsConverter.java:1484)
at com.ochafik.lang.jnaerator.DeclarationsConverter.convertStructs(DeclarationsConverter.java:1576)
at com.ochafik.lang.jnaerator.JNAerator.fillLibraryMapping(JNAerator.java:1336)
at com.ochafik.lang.jnaerator.JNAerator.generateJNALibraryFiles(JNAerator.java:1322)
at com.ochafik.lang.jnaerator.JNAerator.generateLibraryFiles(JNAerator.java:1141)
at com.ochafik.lang.jnaerator.JNAerator.jnaerationCore(JNAerator.java:1723)
at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:831)
at com.ochafik.lang.jnaerator.JNAerator$1.finished(JNAerator.java:721)
at com.ochafik.lang.jnaerator.JNAeratorCommandLineArgs$ArgsParser.parse(JNAeratorCommandLineArgs.java:98)
at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:292)
at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:173)
Finished with errors.

What version of the product are you using? On what operating system?
Maven snapsot of 25/02/2011 (20110225010542)

Is the problem still present in the latest SVN version ? (you can easily
build from sources with these instructions :
http://code.google.com/p/javacl/wiki/Build)
Not tried yet, but tried with the last maven snapshot where the problem persists.

Please provide any additional information below.

Google Code Info:
Issue #: 83
Author: [email protected]
Created On: 2011-02-25T13:58:32.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#158

Problems parsing 'boost' libraries

From @eoh667 on January 3, 2012 2:20

Hi,

I am trying to generate a wrapper for a somewhat complex C++ library / interface that mostly relies on the c++ boost library. While many parts appear to convert quite well, there are two errors I get over and over again:

1. /opt/local/include/boost/config.hpp:7:23: error: Expected string or header, not <
2. /opt/local/include/boost/type_traits/type_with_alignment.hpp:24:46: error: macro BOOST_PP_CHECK_2 has 2 parameters but given 1 args

The actual files / position vary, but the "Expected string" / "parameters but given" come up regularly. Looking into the boost files lines which cause it are, for example:

1: #  define BOOST_USER_CONFIG <boost/config/user.hpp>
2: #define BOOST_TT_ALIGNMENT_BASE_TYPES BOOST_PP_TUPLE_TO_LIST( \
        12, ( \
        char, short, int, long,  ::boost::long_long_type, float, double, long double \
        , void*, function_ptr, member_ptr, member_function_ptr))

Please let me know if you need anything else.

Copied from original issue: nativelibs4java/nativelibs4java#224

[question] cannot run jnaerator

This is almost surely a problem on my side, but I can't manage to run JNAerator correctly. All the FAQ simply run jnaerator.jar, but I just cloned & built the repository and the only JAR files that come close are jnaerator-0.13-SNAPSHOT.jar and jnaerator-parser-0.13-SNAPSHOT.jar.

However, when I use those to run it, I get a "java.lang.NoClassDefFoundError: com/ochafik/lang/jnaerator/parser/Visitor" and "no main manifest attribute, in jnaerator-parser-0.13-SNAPSHOT.jar" respectively.

What am I doing wrong? For completeness, the command I ran was

java -jar $WHATEVER.jar -library xcb xcb.h libxcb.so -mode StandaloneJar

Running Oracle JDK 1.8.0_40.

JNAerator self-extraction does not work

From @leahxschmidt on December 27, 2012 7:40

To reproduce, do the following (instructions assume you are using Linux, but I've also gotten the same result on win32 with the appropriate changes):
git clone https://github.com/leahxschmidt/testjnaerator.git
cd testjnaerator
make
cd java
javac -cp test_linux.jar:. JavaTest.java
java -cp test_linux.jar:. -Djna.nosys=true JavaTest

I would expect this to run correctly, but it does not.

If I first extract the jar and manually configure the library path, it does run:
jar xf test_linux.jar
java -cp test_linux.jar:. -Djna.nosys=true -Djna.library.path=lib/linux_x64/ JavaTest

Naturally, I don't want to have to do that. I don't have this problem if I use 0.9.7, but I do with 0.10.0.

Copied from original issue: nativelibs4java/nativelibs4java#351

Many unknown types

From @Xabster on August 8, 2012 2:47

First I'd like to say that I'm not sure this is a bug.

I'm using this bat file: http://pastebin.com/XS9DF1qV

To generate some stuff from this header file: http://pastebin.com/8YtRPfJ4

And I'm getting unknown types for the following types: UCHAR, COLORREF, time_t, HWND, LPCSTR, LPVOID, LPSTR, REFIID

They're created as empty public static interfaces like this: public static interface LPSTR { };

Copied from original issue: nativelibs4java/nativelibs4java#331

ObjectiveC generation not working

From @Arcnor on October 20, 2011 9:47

I've tried the example from the ObjectiveC wiki page to generate bindings for AppKit, Foundation and CoreFoundation (leaving out CoreFoundation gives the same error message). A .jar is generated, but lots of errors are thrown. don't know if it's because I need to configure anything at all, or a bug in jnaerator (cloned git repo today and uses precompiled bin/jnaerator.jar)

I'm using Java Mac OSX 10.6.6

Error log is here: https://gist.github.com/1300774

Hope this helps!

Copied from original issue: nativelibs4java/nativelibs4java#191

Nested enum definitions not translated properly to method signatures

From @ilganeli on September 24, 2013 18:30

If I have a structure:
typedef struct _PttPriority
{
enum Enum
{
Low, Normal, High
};
} PttPriority;

This definition is useful since it enables the following syntax: PttPriority::Low and this enum can be used like "PttPriority::Enum enumType;"

The Jnaerator succesfully translates this definition into:

public class PttPriority extends StructObject {
/**
* enum values

* native declaration : PttStructs.h:41
*/
public enum Enum implements IntValuedEnum {
Low(0),
Normal(1),
High(2);
}
}

However, if I have -
class Foo{
public:
Foo(PttPriority::Enum enum);
}

The Jnaerator fails to translate that into an appropriately parameterized Java constructor. The class ends up being defined as an abstract class that looks like:
public abstract class Foo extends CPPObject {
public Foo(Enum enum){
}
}

and it reports a Conversion Error:
/** Conversion Error : PttPriority::Enum (failed to convert type to Java (undefined type)) */

Copied from original issue: nativelibs4java/nativelibs4java#447

jnaerator-0.10-shaded java.lang.StackOverflowError

From @rit001 on April 16, 2012 19:28

Hi, I've just started to look at the jnaerator-0.10-shaded release with the same library set that has thrown up a number of issues due to their quirky layout.

The final result is always

Parsing native headers...
Writing preprocessor output to '_jnaerator.preprocessed.c'
Writing preprocessor macros to '_jnaerator.macros.cpp'
Normalizing parsed code...
Writing raw parsed sources to '_jnaerator.rawParsed.cpp'
Writing normalized parsed sources to '_jnaerator.normalizedParsed.cpp'
Generating libraries...
java.lang.StackOverflowError
at com.ochafik.lang.jnaerator.JNAerator$1$2.setFinished(JNAerator.java:692)
at com.ochafik.lang.jnaerator.JNAerator.jnaerate(JNAerator.java:973)
at com.ochafik.lang.jnaerator.JNAerator$1.finished(JNAerator.java:727)
at com.ochafik.lang.jnaerator.JNAeratorCommandLineArgs$ArgsParser.parse(JNAeratorCommandLineArgs.java:135)
at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:238)
at com.ochafik.lang.jnaerator.JNAerator.main(JNAerator.java:211)

 ERROR: JNAeration failed !

  java.lang.StackOverflowError

It looks like there is a recursive error as I've pushed the stack out to 180Mbyte and the only difference is that the CPU is loaded at 100% for longer.

What can I post to allow you to debug the issue?

By the way thanks for the work you carried out for the last issue I posted.

Copied from original issue: nativelibs4java/nativelibs4java#303

jnaerator does not create methods/subclasses (0.10 and 0.11)

From @timk on July 2, 2012 12:2

Hi.

I am trying to jnearate libav-0.8.3 but compared to the library FFMpeg built here there is a lot of classes and methods missing. And using that library or build script it fails from missing classes.

When building with 'jnaerator-0.10-shaded.jar' or 'jnaerator-0.11-SNAPSHOT-shaded.jar' the only files created is the library files as 'AVCodecLibrary.java'.

See this for reference for what should be:
https://github.com/ochafik/nativelibs4java/tree/master/libraries/FFMpeg/src/main/java/com/nativelibs4java/ffmpeg/avcodec

I also found the issue nativelibs4java/nativelibs4java#288 where some of this is discussed but it isn't really a bug for this particular problem so I thought I'd open this to help pin the problem down.

My output

$ java -jar jnaerator-0.11-SNAPSHOT-shaded.jar config.jnaerator
Auto-configuring parser...
2012-jul-02 13:35:41 com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_INCLUDE_PATH=.:/usr/include:/usr/include/c++/4.6.3:/usr/include/c++/4.6.3/tr1
2012-jul-02 13:35:41 com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_FRAMEWORKS_PATH=/System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks:/Library/Frameworks:/Local/Library/Frameworks/:/home/timk/Library/Frameworks
os.arch = amd64
2012-jul-02 13:35:41 com.ochafik.lang.jnaerator.JNAerator jnaerate
INFO: Include path : 
    /home/timk/sources/libav-0.8.3
    /usr/include/x86_64-linux-gnu
    /usr/include/linux
    /usr/include/c++/4.6/x86_64-linux-gnu
    /usr/include/dirac
    /usr/include/schroedinger-1.0
    /usr/x86_64-w64-mingw32/include
    .
    /usr/include
    /usr/include/c++/4.6.3
    /usr/include/c++/4.6.3/tr1
Parsing native headers...
/home/timk/sources/libav-0.8.3/libavcodec/vda.h:28:0: error: File not found: VideoDecodeAcceleration/VDADecoder.h in /home/timk/sources/libav-0.8.3 /usr/include/x86_64-linux-gnu /usr/include/linux /usr/include/c++/4.6/x86_64-linux-gnu /usr/include/dirac /usr/include/schroedinger-1.0 /usr/x86_64-w64-mingw32/include . /usr/include /usr/include/c++/4.6.3 /usr/include/c++/4.6.3/tr1
/usr/x86_64-w64-mingw32/include/winnt.h:219:4: error: #error Must define a target architecture.
Writing preprocessor output to '_jnaerator.preprocessed.c'
Writing preprocessor macros to '_jnaerator.macros.cpp'
line 1:1 no viable alternative at character '\'
line 1:4 no viable alternative at character '\'
line 1:14 mismatched character '<EOF>' expecting '"'
Normalizing parsed code...
Writing raw parsed sources to '_jnaerator.rawParsed.cpp'
Writing normalized parsed sources to '_jnaerator.normalizedParsed.cpp'
Generating libraries...
Overwriting file '_jnaerator.choices'
Compiling JNAerated files...
Generating out.jar
#
# SUCCESS: JNAeration completed !
# Output mode is 'Jar(JAR with bindings only)
#
# => '/home/timk/workspace/Transcoder/lib/out.jar'
#

config.jnaerator

-I /home/timk/sources/libav-0.8.3
-I /usr/include/x86_64-linux-gnu/
-I /usr/include/linux/
-I /usr/include/c++/4.6/x86_64-linux-gnu/
-I /usr/include/dirac
-I /usr/include/schroedinger-1.0
-I /usr/x86_64-w64-mingw32/include

"/usr/lib/x86_64-linux-gnu/libavcodec.so" 
"/usr/lib/x86_64-linux-gnu/libavdevice.so" 
"/usr/lib/x86_64-linux-gnu/libavfilter.so" 
"/usr/lib/x86_64-linux-gnu/libavformat.so" 
"/usr/lib/x86_64-linux-gnu/libavutil.so" 
"/usr/lib/x86_64-linux-gnu/libpostproc.so"  
"/usr/lib/x86_64-linux-gnu/libswscale.so"  

-library avcodec    /home/timk/sources/libav-0.8.3/libavcodec/internal.h 
-library avcodec    /home/timk/sources/libav-0.8.3/libavcodec/*.h 
-library avcodec    /home/timk/sources/libav-0.8.3/libavcodec/avcodec.h 
-library avdevice   /home/timk/sources/libav-0.8.3/libavdevice/*.h
-library avdevice   /home/timk/sources/libav-0.8.3/libavdevice/avdevice.h
-library avfilter   /home/timk/sources/libav-0.8.3/libavfilter/*.h
-library avfilter   /home/timk/sources/libav-0.8.3/libavfilter/avfilter.h
-library avformat   /home/timk/sources/libav-0.8.3/libavformat/*.h
-library avformat   /home/timk/sources/libav-0.8.3/libavformat/avformat.h
-library avutil     /home/timk/sources/libav-0.8.3/libavutil/opt.h
-library avutil     /home/timk/sources/libav-0.8.3/libavutil/*.h
-library avutil     /home/timk/sources/libav-0.8.3/libavutil/avutil.h
-library postproc   /home/timk/sources/libav-0.8.3/libpostproc/*.h
-library postproc   /home/timk/sources/libav-0.8.3/libpostproc/postprocess.h
-library swscale    /home/timk/sources/libav-0.8.3/libswscale/*.h
-library swscale    /home/timk/sources/libav-0.8.3/libswscale/swscale.h

-runtime Bridj
-reification
-scalaStructSetters

-root com.nativelibs4java.ffmpeg

-mode Jar
//-noJar -noComp
-arch linux_x64
//-o src/main/java
-o /home/timk/workspace/Transcoder/lib
-v
-f

Example from AVCodecLibrary.java:
http://pastebin.com/CZu3jgD5

Copied from original issue: nativelibs4java/nativelibs4java#324

NullPointerException processing C++ code

From @ochafik on September 1, 2011 18:47

What steps will reproduce the problem?

  1. Download Vamp SDK from http://vamp-plugins.org/develop.html
    Header files: http://downloads.sourceforge.net/vamp/vamp-plugin-sdk-2.2.zip
    Compiled DLL: http://downloads.sourceforge.net/vamp/vamp-plugin-sdk-2.1-binaries-win32-mingw.zip
  2. Call jnaerator on the Host-DLL and one of the header files, e.g.
    java -jar jnaerator-0.9.6-shaded.jar
    -o generated -v -noJar -noComp
    vamp-hostsdk/vamp-hostsdk.h libvamp-hostsdk.dll

What is the expected output?
I expect generated Java interfaces.

What do you see instead?
Messages 'File not found: string', 'File not found: vector', ...
Messages 'Failed to match any alternative with token'
A NullPointerException
See attached file for detailed error output.

What version of the product are you using? On what operating system?
Tried with jnaerator 0.95 and 0.96, Sun JDK 1.5 and 1.6, 32-bit and 64-bit on Windows XP 64bit

Is the problem still present in the latest SVN version ? (you can easily
build from sources with these instructions :
http://code.google.com/p/javacl/wiki/Build)
I didn't get the build from SVN sources to work.

Please provide any additional information below.
I posted an entry to the jnaerator users forum under http://java.net/projects/jna/lists/users/archive/2011-02/message/17

Google Code Info:
Issue #: 78
Author: [email protected]
Created On: 2011-02-10T06:45:25.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#155

Support of @property in Objective-C

From @ochafik on September 1, 2011 18:45

What steps will reproduce the problem?
Take example code from [http://theocacao.com/document.page/510] :
{{{
@interface Movie : NSObject {

NSString* title;
NSString* studio;
NSInteger yearReleased;
}

  • (id)movie;

@Property (copy) NSString* title;
@Property (copy) NSString* studio;
@Property (assign) NSInteger yearReleased;
@Property (readonly) NSString* summary;

@EnD
}}}

What is the expected output? What do you see instead?
We need to generate getters and/or setters for properties (readonly => no
setter).

Google Code Info:
Issue #: 14
Author: olivier.chafik
Created On: 2009-06-04T08:42:37.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#112

Unable to parse GLib

From @ochafik on September 1, 2011 18:46

What steps will reproduce the problem?

  1. Try to janearate glib.h on Linux Ubuntu 9.04
  2. Set up Maven project with the following config values:
    -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/linux
    -I/usr/lib/gcc/i486-linux-gnu/4.3/include -library Gtk
    /usr/include/glib-2.0/glib.h
  3. Run the Maven JNAerator plugin

What is the expected output? What do you see instead?

Expected to get a JAR with GLib bindings.
Instead get:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building gtk
[INFO] task-segment: [com.jnaerator:maven-jnaerator-plugin:jnaerate]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing jnaerator:jnaerate
[INFO] No goals needed for project - skipping
[INFO] [jnaerator:jnaerate {execution: default-cli}]
os.arch = i386
/usr/include/glib-2.0/glib/gmessages.h:128:12: error: error in macro
parameters: ...
/usr/include/glib-2.0/glib/gmessages.h:133:37: error: error in macro
parameters: ...
/usr/include/glib-2.0/glib/gmessages.h:136:15: error: error in macro
parameters: ...
/usr/include/glib-2.0/glib/gmessages.h:139:14: error: error in macro
parameters: ...
/usr/include/glib-2.0/glib/gmessages.h:142:12: error: error in macro
parameters: ...
JNAeration completed !
/media/My Passport/Jacek/Dev/Scala/gtk4j/target/generated-sources/java

What version of the product are you using? On what operating system?

0.9.1, Ubuntu 9.04
Please provide any additional information below.

Google Code Info:
Issue #: 46
Author: [email protected]
Created On: 2009-10-29T19:38:43.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#132

maven plugin: allow specifying in-pom cmd-line arguments

From @ochafik on September 1, 2011 18:48

what:
in addition to the ${project.basedir}/src/main/jnaerator/config.jnaerator file, allow specifying arguemtns like this:

...



com.jnaerator
maven-jnaerator-plugin


-noCpp
${project.basedir}/src/main/native/myHeader.h





why:
when specifying my header file, i found no solution to reliably, specify a relative path to the myHeader.h file. when the plugin executes JNAerator, we can not rely on PWD == ${project.basedir}.

alternatives:

  • if possible, switch the PWD to ${project.basedir} during the execution of JNAErator.
  • allow usage of external vars in config.jnaerator
    bot not so nice (and also harder to implement) in my eyes.

useful reference:
http://www.sonatype.com/books/maven-book/reference/writing-plugins-sect-multival-params.html

misc:
Thanks a lot for that plugin. It is really very nice to wrapp a library with this!
Also for JNAerator itsself of course :-)

Google Code Info:
Issue #: 72
Author: robin.vobruba
Created On: 2010-09-13T10:03:17.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#177

JNAerator doesn't generate enums from C "flag" enums using #define and casting

From @jolson88 on November 24, 2012 8:32

JNAerator doesn't currently generate a ValuedEnum for Bridj bindings when the originating C code uses an "enum pattern" via typedef unsigned long and matching #defines with typecasts. I didn't find an existing issue when searching for "enum".

Here's a sample snippet from PortAudio:

typedef unsigned long PaStreamFlags;

/** @see PaStreamFlags */
#define   paNoFlag          ((PaStreamFlags) 0)

/** Disable default clipping of out of range samples.
 @see PaStreamFlags
*/
#define   paClipOff         ((PaStreamFlags) 0x00000001)

/** Disable default dithering.
 @see PaStreamFlags
*/
#define   paDitherOff       ((PaStreamFlags) 0x00000002)

This currently generates the following code which fails at runtime (because there is no matching ValueType):

    /// Undefined type
    /// Undefined type
    public static interface PaStreamFlags {

    };

What is expected is a normal enum (that can then be OR'd together if necessary):

    /// enum values
    public enum PaStreamFlags implements IntValuedEnum<PaStreamFlags > {
        paNoFlag(0),
        paClipOff(0x00000001),
        paDitherOff(0x00000002);

        PaStreamFlags(long value) {
            this.value = value;
        }
        public final long value;
        public long value() {
            return this.value;
        }
        public Iterator<PaStreamFlags > iterator() {
            return Collections.singleton(this).iterator();
        }
        public static IntValuedEnum<PaStreamFlags > fromValue(int value) {
            return FlagSet.fromValue(value, values());
        }
    };

If I can get some time soon, I'll try to work up a patch to submit as a fix. But I figured I would submit this issue in the meantime.

Copied from original issue: nativelibs4java/nativelibs4java#345

problems with jnaerator parsing the fuse library on linux

From @ochafik on September 1, 2011 18:46

Here's what I've tried:

java -jar jnaerator-0.9.3.jar -library fuse -o . -package my.jnafuse
-D__s32=int -DFUSE_USE_VERSION=26 -D_FILE_OFFSET_BITS=64 -direct -jar
./jnafuse.jar -preferJavac -scanSymbols /usr/include/fuse.h /usr/lib/libfuse.so

Here's what I get:
javacTask: no source files
Usage: javacTask
use -help for a list of possible options
JNAeration completed !

jnaerator does create the jar file but doesn't generate any java classes in
it.

Without the -preferJavac I get a complaint from the eclipse compiler.

OS is ubuntu 9.04 fuse is version 26
java -version
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Server VM (build 10.0-b19, mixed mode)

Google Code Info:
Issue #: 54
Author: [email protected]
Created On: 2010-02-03T02:08:50.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#138

JNAerated libraries crash or hang in printf on win32

From @leahxschmidt on December 27, 2012 16:37

To reproduce, do the following, on a 32-bit Windows XP system (I am using a 32-bit VM on a 64-bit host, if that matters).

Install cygwin, including gcc, and make.

git clone https://github.com/leahxschmidt/testjnaerator.git
cd testjnaerator
make
cd java
javac -cp test_linux.jar:. JavaTest.java
java -cp test_linux.jar:. -Djna.nosys=true JavaTest

now, manually extract the jar -- see #351

jar xf test_win32.jar
java -cp . -Djna.library.path=lib/win32/ JavaTest

For me, this hangs. But I have tried a bunch of variants on the C code and some also make the JVM crash in cygwin's aclcheck function (I think inet_addr typically does this). On 64-bit Windows XP, this code runs correctly (well, the printf stuff gets printed after the Java println but I assume this is due to buffering; that doesn't bother me).

Copied from original issue: nativelibs4java/nativelibs4java#352

Parsing error in MinGW limits.h

From @ochafik on September 1, 2011 18:46

Hi,

I am using MSYS/MINGW to compile FFMPEG.

The limits.h file that comes with MinGW as the following preprocessor #if
(the comment is from limits.h too...)

/* TODO: Is this safe? I think it might just be testing the preprocessor,

  •   not the compiler itself... */
    
    #if ('\x80' < 0)

JNAerator does like the #if:
D:\test\msys\mingw\include\limits.h:41:2: error: Bad token in expression:
'\x80'
D:\test\msys\mingw\include\limits.h:41:2: error: missing ) in expression
D:\test\msys\mingw\include\limits.h:41:8: warning: Unexpected nonwhite token
D:\test\msys\mingw\include\limits.h:41:8: warning: Unexpected nonwhite token
D:\test\msys\mingw\include\limits.h:41:7: warning: Unexpected nonwhite token

This issue seems minor and is not causing further issues down the line.

Google Code Info:
Issue #: 37
Author: [email protected]
Created On: 2009-10-02T10:35:34.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#127

Null Pointer Exception using C++ sln

From @ochafik on September 1, 2011 18:47

What steps will reproduce the problem?

  1. java -jar jnaerator.jar LibCommon.sln

What is the expected output? What do you see instead?

Expecting to get LibCommon.jar, instead there is a null pointer
exception and jar is not generated.

What version of the product are you using? On what operating system?
jnaerator-0.9.5 on Windows XP (Win32)

Is the problem still present in the latest SVN version ? (you can easily
build from sources with these instructions :
http://code.google.com/p/javacl/wiki/Build)

Please provide any additional information below.

Google Code Info:
Issue #: 81
Author: [email protected]
Created On: 2011-02-22T15:00:48.000Z
Closed On:

Copied from original issue: nativelibs4java/nativelibs4java#156

Process of edge case struct usage

From @rit001 on June 9, 2013 23:11

The following does not correctly define VixDiskLibConnectParam

struct VixDiskLibConnectParam;
typedef struct VixDiskLibConnectParam *VixDiskLibConnection;
VixDiskLib_Disconnect(VixDiskLibConnection connection);

This does seem to create the correct code

struct VixDiskLibConnectParam {};
typedef struct VixDiskLibConnectParam *VixDiskLibConnection;
VixDiskLib_Disconnect(VixDiskLibConnection connection);

As I understand C something like 'struct VixDiskLibConnectParam' allows the compiler to create a place holder so that the struct's name can be used in a header without having to completly define it or #include it from elsewhere.

Copied from original issue: nativelibs4java/nativelibs4java#415

cannot generate java bindings to windows libraries

I have windows-8.1 and visual studio 2013, and I was trying to generate java wrapper for vds.h (partition management COM objects).
However it seems it is impossible to do. Even if I add -Iwindows.h to the parameter list, the generated output does not compile. Many errors results from things like PDWORD64 (a typedef from basetsd.h) missing, for example. When PDWORD64 is referenced in java, the typedef is not recognized, instead jnaerator tries to import it from a non-existant package... What is actually happening?

ObjCppParser resolves CPP Methods as VariablesDeclaration

From @zillazilla on January 13, 2012 14:34

ObjCppParser resolves the following methods incorrectly as VariablesDeclaration Objects:

public short AClass::getX(void);
public long AClass::getX(void);
public AClass::AClass(void);

In contrast, these methods are correctly resolved as Function Objects:

public int AClass::getX(void);
public xxx AClass::getX(void);
public AClass::~AClass(void);

Moreover, these methods are not resolved at all (parser error):
public short AClass::getX(void)const;
public long AClass::getX(void)const;

Failed to match any alternative with token [@4,13:18='AClass',<13>,1:13]
File: null:1
Input: public short AClass :: getX ( void )
Rule: 539:4: ({...}? => pragmaContent |{...}? => templateDef | functionDeclaration |{...}? => externDeclarations | varDecl ';' | objCClassDef | typeDef | forwardClassDecl | namespaceDecl )
Stack: []

Copied from original issue: nativelibs4java/nativelibs4java#235

Parsing D3DX10math.h ends in an Out Of Memory error after a long wait

From @cessationoftime on January 11, 2012 3:36

Using JNAerator-0.9.8-shaded.jar

config.jnaerator looks like this:

-DWIN32_LEAN_AND_MEAN= 
-DNOCOMM= 
-DNOSOUND= 
-DNOKANJI= 
-DNOSYSMETRICS= 
-DNOICONS= 
-DNOSERVICE= 
-DNOSOUND= 
-DNOTEXTMETRIC= 
-DNOKANJI= 
-DNOHELP= 
-DNOPROFILER= 
-DNOMCX= 
-DWINVER=0x0502 
-D_WIN32_WINNT=0x0502 
-D_WIN32_IE=0x0603 
-root com.redsoft.keyhole.windows.api 
-scalaStructSetters 
-D_MSC_VER=1600 
-DMIDL_PASS=1 
-DHRESULT=int 
-DDWORD=int 
-DBYTE=char 
-DSIZE_T=size_t 
-D__stdcall= 
-D__cplusplus=1 
-DVOID=void 
-DBOOL=int 
-DPVOID=void* 
"-DMIDL_INTERFACE(x)=struct __declspec(uuid(x)) __declspec(novtable)" 
"-IC:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include" 
"-IC:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" 
"-IC:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include" 
-library d3dx10 
"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\d3d10.h" 
"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\d3dx10.h" 
//running out of memory GC overhead on this header
"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\d3dx10math.h" 
"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\d3dx10core.h" 
"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\d3dx10tex.h" 
"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\d3dx10mesh.h" 
"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\d3dx10async.h" 
-noJar -noComp 
-o src/main/jnaerated 
-v 
-runtime BridJ 

JNAerator is unable to give any serious output unless one comments out the #include for the math header in d3dx10.h, then it is able to parse the other files and can ignore d3dx10math.h

JNAerator appears to be failing at approx line 90 of d3dx10math.h when it reaches the following struct:

typedef struct D3DXFLOAT16 
{ 
#ifdef __cplusplus 
public: 
    D3DXFLOAT16() {}; 
    D3DXFLOAT16( FLOAT ); 
    D3DXFLOAT16( CONST D3DXFLOAT16& ); 
    // casting 
    operator FLOAT (); 
    // binary operators 
    BOOL operator == ( CONST D3DXFLOAT16& ) const; 
    BOOL operator != ( CONST D3DXFLOAT16& ) const; 
protected: 
#endif //__cplusplus 
    WORD value; 
} D3DXFLOAT16, *LPD3DXFLOAT16; 

One can get pretty good output from d3dx10math.h by using "#undef __cplusplus" to ignore the faulty sections of the file and then redefining it at the end of d3dx10math.h

see: http://groups.google.com/group/nativelibs4java/browse_thread/thread/2bbe5a69e681ca51

Copied from original issue: nativelibs4java/nativelibs4java#230

Failed to #define TRUE !FALSE

From @rslemos on April 10, 2012 13:43

Given as input:

#define FALSE 0
#define TRUE !FALSE

Jnaerator display some parsing errors:

line 1:0 Failed to match any alternative with token [@0,0:0='<EOF>',<-1>,1:0]
     File: null:1
    Input: <EOF>
     Rule: 
    Stack: []

line 1:0 Failed to match any alternative with token [@0,0:0='<EOF>',<-1>,1:0]
     File: null:1
    Input: <EOF>
     Rule: 
    Stack: []

line 1:0 Failed to match any alternative with token [@0,0:0='<EOF>',<-1>,1:0]
     File: null:1
    Input: <EOF>
     Rule: 
    Stack: []

And outputs library wrapper skipping the troublesome #definition:

        /// <i>native declaration : src/main/c/test.h</i>
        public static final int FALSE = (int)0;
        /**
         * define<br>
         * Conversion Error : !0<br>
         * SKIPPED:<br>
         * <i>native declaration : src/main/c/test.h:0</i><br>
         * !0
         */

I'm not sure about which output would be correct in this case (since !0 in C can be used as boolean and is only expanded when needed).

Copied from original issue: nativelibs4java/nativelibs4java#298

Unable to process Python 2.6: "Failed to match any alternative with token"

From @yang on December 9, 2011 20:13

I'm simply trying to process the standard Python 2.6 headers on Ubuntu 10.04. Transcript:

$ java -jar jnaerator-0.9.8-shaded.jar -library python26 /usr/include/python2.6/Python.h -o dst -v -noJar -noComp 2>&1 -I /usr/lib/gcc/x86_64-linux-gnu/4.4/include/
Auto-configuring parser...
Dec 9, 2011 12:04:45 PM com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_INCLUDE_PATH=.:/usr/include:/usr/include/c++/4.4.3
Dec 9, 2011 12:04:45 PM com.ochafik.lang.jnaerator.JNAeratorConfigUtils getProp
INFO: [environment] JNAERATOR_FRAMEWORKS_PATH=/System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/Frameworks:/System/Library/Frameworks:/Library/Frameworks:/Local/Library/Frameworks/:/home/yang/Library/Frameworks
os.arch = amd64
Dec 9, 2011 12:04:45 PM com.ochafik.lang.jnaerator.JNAerator jnaerate
INFO: Include path : 
        /usr/lib/gcc/x86_64-linux-gnu/4.4/include
        .
        /usr/include
        /usr/include/c++/4.4.3
Parsing native headers...
/usr/include/bits/wchar.h:30:7: warning: Unexpected nonwhite token
/usr/include/bits/wchar.h:30:7: warning: Unexpected nonwhite token
/usr/include/bits/wchar.h:30:7: warning: Unexpected nonwhite token
/usr/include/bits/wchar.h:30:7: warning: Unexpected nonwhite token
Writing preprocessor output to '_jnaerator.preprocessed.c'
Writing preprocessor macros to '_jnaerator.macros.cpp'
line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );



...



         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 1:0 Failed to match any alternative with token [@0,0:5='return',<55>,1:0]
         File: null:1
        Input: return   Py_INCREF ( Py_True )
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 1:18 extraneous input [@5,18:18='2',<4>,1:18] expecting ')'
line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 0:-1 Failed to match any alternative with token [@-1,0:0='<no text>',<-1>,0:-1]
         File: null:0
        Input: 
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

line 1:0 Failed to match any alternative with token [@0,0:5='return',<55>,1:0]
         File: null:1
        Input: return   Py_INCREF ( Py_None )
         Rule: 1656:1: castExpr returns [Expression expr] : ( '(' tr= mutableTypeRef ')' (inner= castExpr | '(' expression ( ',' expression )+ ')' ) | e= unaryExpr );
        Stack: []

Now parsing 439 text blocks
Normalizing parsed code...
Writing raw parsed sources to '_jnaerator.rawParsed.cpp'
Writing normalized parsed sources to '_jnaerator.normalizedParsed.cpp'
Generating libraries...
Generating Python26Library.java
JNAeration completed !
/home/yang/tmp/dst

$ cat dst/python26/Python26Library.java
package python26;
import com.ochafik.lang.jnaerator.runtime.LibraryExtractor;
import com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper;
import com.ochafik.lang.jnaerator.runtime.Mangling;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;
import com.sun.jna.Pointer;
/**
 * JNA Wrapper for library <b>python26</b><br>
 * This file was autogenerated by <a href="http://jnaerator.googlecode.com/">JNAerator</a>,<br>
 * a tool written by <a href="http://ochafik.free.fr/">Olivier Chafik</a> that <a href="http://code.google.com/p/jnaerator/wiki/CreditsAndLicense">uses a few opensource projects.</a>.<br>
 * For help, please visit <a href="http://nativelibs4java.googlecode.com/">NativeLibs4Java</a> , <a href="http://rococoa.dev.java.net/">Rococoa</a>, or <a href="http://jna.dev.java.net/">JNA</a>.
 */
public interface Python26Library extends Library {
        public static final String JNA_LIBRARY_NAME = LibraryExtractor.getLibraryPath("python26", true, python26.Python26Library.class);
        public static final NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(python26.Python26Library.JNA_LIBRARY_NAME, com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper.DEFAULT_OPTIONS);
        public static final Python26Library INSTANCE = (Python26Library)Native.loadLibrary(python26.Python26Library.JNA_LIBRARY_NAME, python26.Python26Library.class, com.ochafik.lang.jnaerator.runtime.MangledFunctionMapper.DEFAULT_OPTIONS);
        /// <i>native declaration : /usr/include/python2.6/Python.h</i>
        public static final int WITH_CYCLE_GC = (int)1;
        /// <i>native declaration : /usr/include/python2.6/Python.h</i>
        public static final int Py_file_input = (int)257;
        /// <i>native declaration : /usr/include/python2.6/Python.h</i>
        public static final int Py_single_input = (int)256;
        /// <i>native declaration : /usr/include/python2.6/Python.h</i>
        public static final int Py_eval_input = (int)258;
        /**
         * _Py_Mangle is defined in compile.c<br>
         * Original signature : <code>PyObject* _Py_Mangle(PyObject*, PyObject*)</code><br>
         * <i>native declaration : /usr/include/python2.6/Python.h:4</i>
         */
        @Mangling({"_Z10_Py_MangleP8PyObjectP8PyObject", "?_Py_Mangle@@YAPA8PyObjectPA8PyObjectPA8PyObject@Z"}) 
        Pointer _Py_Mangle(Pointer p, Pointer name);
        /// Undefined type
        public static interface PyObject {

        };
}

Copied from original issue: nativelibs4java/nativelibs4java#207

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.