diff options
-rw-r--r-- | .classpath | 2 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | doc/HowToBuild.html | 269 | ||||
m--------- | jcpp | 0 | ||||
-rw-r--r-- | make/build-test.xml | 10 | ||||
-rw-r--r-- | make/build.xml | 13 | ||||
-rwxr-xr-x | make/scripts/runtest.sh | 27 | ||||
-rw-r--r-- | make/stub_includes/gluegen/stdio.h | 7 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/IOUtil.java | 10 | ||||
-rw-r--r-- | src/java/com/jogamp/gluegen/GenericCPP.java | 5 | ||||
-rw-r--r-- | src/java/com/jogamp/gluegen/GlueGen.java | 5 | ||||
-rw-r--r-- | src/java/com/jogamp/gluegen/pcpp/PCPP.java | 2 | ||||
-rw-r--r-- | src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java | 27 | ||||
-rw-r--r-- | src/junit/com/jogamp/gluegen/test/junit/generation/test1.h | 7 |
14 files changed, 369 insertions, 18 deletions
@@ -21,6 +21,8 @@ </attributes> </classpathentry> <classpathentry kind="src" path="test/junit"/> + <classpathentry kind="src" path="jcpp/src/main/java"/> + <classpathentry kind="src" path="jcpp/src/test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Ant"/> <classpathentry kind="lib" path="make/lib/antlr.jar"/> diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c3f990a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "jcpp"] + path = jcpp + url = ../jcpp diff --git a/doc/HowToBuild.html b/doc/HowToBuild.html new file mode 100644 index 0000000..dcfe3ba --- /dev/null +++ b/doc/HowToBuild.html @@ -0,0 +1,269 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <link href="../../style.css" rel="stylesheet" type="text/css"/> + <title>How to build JOGL</title> + </head> + <body> + <div id="container"> + <div id="header"> + <div id="slogan">How to build GlueGen</div> + <div id="logo"><a href="http://jogamp.org/">How to build GlueGen</a></div> + </div> + <div id="menu"> + <ul> + <li><a href="http://jogamp.org/">Home</a></li> + <li><a href="../../gluegen/www/">Gluegen</a></li> + <li><a href="../../joal/www/">JOAL</a></li> + <li><a href="../../jocl/www/">JOCL</a></li> + <li><a href="../../jogl/www/">JOGL</a></li> + <li><a href="../../demos/www/">Demos</a></li> + <li><a href="../../wiki/">Wiki</a></li> + <li><a href="../../deployment/jogl-next/javadoc_public/">JavaDoc</a></li> + <li><a href="../../blog/">Blogs</a></li> + <li><a href="../../forum.html">Forums</a></li> + </ul> + </div> + <div id="main"> + <div id="text" class="fill"> + + <h2>Platform and Component Requirements</h2> + <hr/> + Here is a list of platforms and components, we were able to build GlueGen on,<br/> + if not stated otherwise.<br/> + + <ul> + <li> <b>Java</b><br/> + A Java 1.6 compliant SDK. + </li> + <li> <b><a href="http://ant.apache.org/">Ant</a></b> 1.9.0 or later</li> + <li> <b><a href="http://www.kernel.org/pub/software/scm/git/docs/">Git</a></b> 1.6.0 or later<br/> + <ul> + <li> Use your Unix distribution's version, if available, or</li> + <li> <a href="http://www.kernel.org/pub/software/scm/git/">Source Code for GNU/Linux, MacOSX, ..</a>, or</li> + <li> Git on Windows + <ul> + <li> <a href="https://cygwin.com">cygwin</a></li> + <li> <a href="http://code.google.com/p/msysgit/">msysgit</a></li> + </ul> + </li> + <li> <a href="http://code.google.com/p/git-osx-installer/">git-osx-installer</a> </li> + </ul> + </li> + + <li> <b>GNU Linux</b> x86, 32- and 64-bit<br/> + You may have to install a few developer packages ... + <ul> + <li> <b>Debian</b> 5.00 or later + <ul> + <li>openjdk-7-jre</li> + <li>openjdk-7-jdk</li> + <li>ant</li> + <li>git</li> + <li>p7zip-full</li> + <li>gcc</li> + </ul> + One liner install command: + <pre> +apt-get install openjdk-7-jre openjdk-7-jdk ant git-all p7zip-full gcc + </pre> + Optional: Add <i>kernel</i> build utilities: + <pre> +apt-get install kernel-package build-essential + </pre> + Optional: Add <i>multiarch</i> i386 next to amd64 + <ul> + <li><b>Debian</b> 7.00 + <pre> +dpkg --add-architecture i386 +apt-get update +apt-get install ia32-libs ia32-libs-gtk gcc-multilib lib32gcc1 lib32gomp1 lib32itm1 lib32quadmath0 libc6-i386 ibc6-dev-i386 g++-multilib lib32stdc++6 openjdk-7-jre:i386 openjdk-7-jdk:i386 + </pre></li> + + <li><b>Debian</b> 8.00 + <pre> +dpkg --add-architecture i386 +apt-get update +apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 gcc-multilib lib32gcc1 lib32gomp1 lib32itm1 lib32quadmath0 libc6-i386 libc6-dev-i386 g++-multilib lib32stdc++6 openjdk-7-jre:i386 openjdk-7-jdk:i386 + </pre></li> + </ul> + </li> + <li> <b>OpenSuSE</b> 10.2 or later + <ul> + <li>openjdk-7-jre</li> + <li>openjdk-7-jdk</li> + <li>ant</li> + <li>git</li> + <li>p7zip-full</li> + <li>gcc</li> + </ul> + </li> + <li> <b>CentOS / Red Hat Enterprise Linux</b> 5.4 or later<br/> + <ul> + <li>openjdk-7-jre</li> + <li>openjdk-7-jdk</li> + <li>ant</li> + <li>git</li> + <li>p7zip-full</li> + <li>gcc</li> + </ul> + </li> + </ul> + </li> + <li> <b>OpenSolaris</b> SPARC and x86, 32- and 64-bit + <ul> + <li> <a href="http://opensolaris.org/">OpenSolaris 2009.06 or later</a></li> + </ul> + </li> + <li> <b>MacOSX</b> Intel + <ul> + <li> git, see above </li> + <li> <a href="http://www.apple.com/macosx/">Mac OS X</a> 10.3 (note: will not work with earlier releases) </li> + <li> <a href="http://developer.apple.com/technologies/xcode.html">Xcode</a> for gcc, etc (included in OSX)</li> + </ul> + </li> + <li> <b>Windows</b>/x86 (32 bit) + <ul> + <li>Windows XP or later </li> + <li>git, see above</li> + <li> <a href="http://mingw-w64.sourceforge.net/">MinGW64</a> + <ul> + <li> <a href="http://sourceforge.net/projects/mingwbuilds/files/mingw-builds-install/mingw-builds-install.exe/download">Installer</a> + <ul> + <li>mingw-build-install</li> + <li>version: 4.8.1</li> + <li>host: x32</li> + <li>threading: win32</li> + <li>exceptions: SJLJ</li> + <li>revision: 5</li> + </ul></li> + <li> or <a href="http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/">manual</a> + via <a href="http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-win32/sjlj/">7z archive file</a></li> + </ul></li> + </ul> + </li> + <li> <b>Windows</b>/x86_64 (64-bit) + <ul> + <li>Windows XP or later </li> + <li>git, see above</li> + <li> <a href="http://mingw-w64.sourceforge.net/">MinGW64</a> + <ul> + <li> <a href="http://sourceforge.net/projects/mingwbuilds/files/mingw-builds-install/mingw-builds-install.exe/download">Installer</a> + <ul> + <li>mingw-build-install</li> + <li>version: 4.8.1</li> + <li>host: x64</li> + <li>threading: win32</li> + <li>exceptions: SJLJ</li> + <li>revision: 5</li> + </ul></li> + <li> or <a href="http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/">manual</a> + via <a href="http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/threads-win32/sjlj/">7z archive file</a></li> + </ul></li> + </ul> + </li> + </ul> + + <p> + Additional platforms such as FreeBSD and HP/UX are handled by the + build system, but are not officially supported. + </p> + + <h2>Build Steps</h2> + <hr/> + <p> + Here are the steps that are required in order to build JOGL. + </p> + + <ol> + <li><b>Optain the source code</b> using git: + <ul> + <li><a href="http://jogamp.org/git/?p=gluegen.git">Gluegen Dev GIT Repo</a></li> + </ul><br/> + It is crucial that you checkout the source code under a common root directory: + <pre> + /home/dude/projects/jogamp> git clone --recurse-submodules git://jogamp.org/srv/scm/gluegen.git gluegen + </pre> + Now you should have following directory structure: + <pre> + /home/dude/projects/jogamp + /home/dude/projects/jogamp/gluegen + </pre> + <p> + Note-1: The GlueGen source must be fetched using <i>-recurse-submodules</i>, + which imports <i>JCPP</i>, now used as the default C preprocessor. + </p> + </li> + + <li> <b>Unset your CLASSPATH environment variable:</b> <br/> + The Ant build requires that the JOGL jars not be visible on the classpath. On Unix, type + <code> unsetenv CLASSPATH </code> into a csh or tcsh shell, or <code> unset CLASSPATH </code> + into a Bourne shell. On Windows, type <code> set CLASSPATH= </code> into a command prompt. + </li> + + <li> <b>Optional</b> <i>Copy and edit <b>gluegen.properties</b>:</i> <br/> + To specify different basic options for components and compilers,<br/> + copy <b>gluegen/make/gluegen.properties</b> into your home directory (pointed to by the Java system property <b>user.home</b>). <br/></li> + + <li> <b>Build the source tree:</b> <br/> + Open a command shell in the "gluegen/make" directory of the source tree and type <code>"ant"</code>. + </li> + + <li> <b>Test your build:</b> <br/> Stay in your command shell in the "gluegen/make" directory of the source tree and type <code>"ant junit.run"</code>.</li> + + <li> <b>Build Javadoc:</b> <br/> Stay in your command shell in the "gluegen/make" directory of the source tree and type "<code>ant javadoc"</code>. + This will produce the end-user documentation for JOGL along with some auxiliary utility packages. + </li> + </ol> + + Note that there might be a few warnings produced by ANTLR about the + C grammar and our modifications to some of the signatures of the + productions; the C grammar warnings have been documented by the + author of the grammar as having been investigated completely and + harmless, and the warnings about our modifications are also + harmless. + + <h2> Common build problems </h2> + + <ol> + + <li> + <b>Your CLASSPATH environment variable appears to be set (some GlueGen classes are currently visible to the build.)</b>, and $CLASSPATH isn't set. + An older version of GlueGen was installed into the extension directory of the JDK you're using to build the + current GlueGen. On Windows and Linux, delete any ANTLR jars from jre/lib/ext, and on Mac OS X, delete them from + /Library/Java/Extensions. It is generally not a good idea to drop GlueGen directly into the extensions directory, + as this can interfere with upgrades via Java Web Start. + </li> + + <li> + <b>CharScanner; panic: ClassNotFoundException: com.sun.gluegen.cgram.CToken</b> + + This occurs because ANTLR was dropped into the Extensions + directory of the JRE/JDK. On Windows and Linux, delete any ANTLR jars from jre/lib/ext, + and on Mac OS X, delete them from /Library/Java/Extensions. Use the antlr.jar property in the build.xml + to point to a JRE-external location of this jar file. + </li> + + </ol> + + <br/> + <p> + <i>- Christopher Kline and Kenneth Russell, June 2003 (revised November 2006)</i><br/> + <i>- Sven Gothel and Michael Bien, May 2010</i><br/> + <i>- Sven Gothel, March 2010 (Extracted version from JOGL)</i><br/> + </p> + + </div> + </div> + <div id="footer"> + <div id="footer_left"> + <span>JogAmp.org</span> + by <a href="http://jogamp.org">http://jogamp.org</a> + is licensed under a <br/> + <a href="http://creativecommons.org/licenses/by/3.0/us/">Creative Commons Attribution 3.0 License</a>. + </div> + </div> + </div> + </body> +</html> diff --git a/jcpp b/jcpp new file mode 160000 +Subproject b68145fe23170089f797f697163d75eedb3bb31 diff --git a/make/build-test.xml b/make/build-test.xml index fe1aaec..68f674f 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -36,6 +36,8 @@ <property name="test.junit.generation.rel" value="${test.junit.rel}/gluegen/test/junit/generation" /> <property name="test.junit.generation.dir" value="${test.base.dir}/${test.junit.generation.rel}" /> + <property name="test.jcpp.base.dir" value="${project.root}/jcpp/src/test/java" /> + <property name="tempdir" value="${project.root}/build-temp" /> <property name="build" location="${project.root}/${rootrel.build}" /> <property name="test.dir" value="${gluegen.root}/${rootrel.build}/test"/> @@ -169,6 +171,7 @@ <classpath refid="junit.compile.classpath"/> <compilerarg value="-proc:none"/> <src path="${test.base.dir}"/> + <src path="${test.jcpp.base.dir}"/> <src path="${build_t.gen}" /> </javac> @@ -266,9 +269,10 @@ <target name="junit.compile.check" depends="init"> <uptodate property="junit.compile.skip"> - <srcfiles dir= "." includes="*.xml"/> - <srcfiles dir= "${test.base.dir}" includes="**"/> - <srcfiles file="${gluegen.jar}" /> + <srcfiles dir= "." includes="*.xml"/> + <srcfiles dir= "${test.base.dir}" includes="**"/> + <srcfiles dir= "${test.jcpp.base.dir}" includes="**"/> + <srcfiles file="${gluegen.jar}" /> <mapper type="merge" to="${gluegen-test.jar}"/> </uptodate> </target> diff --git a/make/build.xml b/make/build.xml index aa3282b..e92da5b 100644 --- a/make/build.xml +++ b/make/build.xml @@ -31,6 +31,7 @@ This requires the user-defined "antlr.jar" property. --> <path id="cc_gluegen.classpath"> <pathelement location="${antlr.jar}" /> + <pathelement location="${semver.jar}" /> </path> </target> @@ -59,6 +60,7 @@ <property name="project.root" value=".." /> <property name="src.java" value="${project.root}/src/java" /> <property name="src.antlr" value="${project.root}/src/antlr" /> + <property name="src.jcpp" value="${project.root}/jcpp/src/main/java" /> <property name="build" location="${project.root}/${rootrel.build}" /> <property name="javadoc.root.path" location="${build}/javadoc" /> @@ -142,6 +144,7 @@ <property name="java.part.nonjava" value="com/jogamp/common/util/bin/*" /> <property name="gluegen-rt.classes" value="com/jogamp/gluegen/runtime/**"/> <property name="jogamp.common.classes" value="com/jogamp/common/** jogamp/common/**"/> + <property name="java.part.jcpp" value="com/jogamp/gluegen/jcpp/**"/> <property name="gluegen.excludes.all" value="${gluegen.excludes.nsig} ${jogamp-android-launcher.classes}" /> </target> @@ -604,6 +607,7 @@ <uptodate property="gluegen.build.skip.java1"> <srcfiles dir= "." includes="*.xml"/> <srcfiles dir= "${src.java}" includes="**"/> + <srcfiles dir= "${src.jcpp}" includes="**"/> <srcfiles dir= "${c.grammar}" includes="*.g"/> <srcfiles dir= "${j.grammar}" includes="*.g"/> <mapper type="merge" to="${build}/gluegen.jar"/> @@ -611,6 +615,7 @@ <uptodate property="gluegen.build.skip.java2"> <srcfiles dir= "." includes="*.xml"/> <srcfiles dir= "${src.java}" includes="**"/> + <srcfiles dir= "${src.jcpp}" includes="**"/> <srcfiles dir= "${c.grammar}" includes="*.g"/> <srcfiles dir= "${j.grammar}" includes="*.g"/> <mapper type="merge" to="${build}/gluegen-rt.jar"/> @@ -739,10 +744,11 @@ excludes="${gluegen.excludes.all} ${gluegen-rt.classes} ${java.part.android}" memoryMaximumSize="${javac.memorymax}" encoding="UTF-8" - source="${target.sourcelevel}" + source="${target.sourcelevel}" target="${target.targetlevel}" bootclasspath="${host.rt.jar}" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> + <src path="${src.jcpp}" /> <src path="${src.java}" /> <src path="${src.generated.java}" /> <classpath refid="cc_gluegen.classpath" /> @@ -822,6 +828,7 @@ <include name="jogamp/common/**" /> <exclude name="${jogamp-android-launcher.classes}" /> <exclude name="${java.part.android}" /> + <exclude name="${java.part.jcpp}" /> </fileset> <fileset dir="resources/assets"> <include name="**" /> @@ -836,6 +843,7 @@ <include name="jogamp/common/**" /> <exclude name="${jogamp-android-launcher.classes}" /> <exclude name="${java.part.android}" /> + <exclude name="${java.part.jcpp}" /> </fileset> <fileset dir="resources/assets"> <include name="**" /> @@ -1033,7 +1041,7 @@ <delete dir="${javadoc.gluegen.path}" includeEmptyDirs="true" quiet="true" failonerror="false" /> <mkdir dir="${javadoc.gluegen.path}" /> <javadoc packagenames="com.jogamp.*" - sourcepath="${src.java};${src.generated.java}" + sourcepath="${src.java};${src.jcpp};${src.generated.java}" destdir="${javadoc.gluegen.path}" windowtitle="GlueGen Runtime Documentation" overview="../src/java/com/jogamp/gluegen/package.html" encoding="UTF-8" @@ -1065,6 +1073,7 @@ <zip destfile="${build}/gluegen-java-src.zip" level="0"> <fileset dir="${src.java}"/> <fileset dir="${build}/gensrc/java"/> + <fileset dir="${src.jcpp}"/> </zip> </target> diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh index 5d19e7f..0837c42 100755 --- a/make/scripts/runtest.sh +++ b/make/scripts/runtest.sh @@ -39,6 +39,10 @@ ANT_JARS=$ANT_PATH/lib/ant.jar:$ANT_PATH/lib/ant-junit.jar:$ANT_PATH/lib/ant-lau LOG=runtest.log rm -f $LOG +GLUEGEN_ROOT=`dirname $builddir` +ROOTREL_BUILD=`basename $builddir` + +X_ARGS="-Drootrel.build=$ROOTREL_BUILD -Dgluegen.root=$GLUEGEN_ROOT" #D_ARGS="-Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup" #D_ARGS="-Djogamp.debug.TraceLock" #D_ARGS="-Djogamp.debug.Platform -Djogamp.debug.NativeLibrary" @@ -58,7 +62,8 @@ rm -f $LOG #D_ARGS="-Djogamp.debug.IOUtil" #D_ARGS="-Djogamp.debug.ByteBufferInputStream" #D_ARGS="-Djogamp.debug.Bitstream" -D_ARGS="-Djogamp.debug=all" +#D_ARGS="-Djogamp.debug=all" +#D_ARGS="-Djogamp.debug.Logging" function onetest() { #USE_CLASSPATH=lib/junit.jar:$ANT_JARS:lib/semantic-versioning/semver.jar:"$builddir"/../make/lib/TestJarsInJar.jar:"$builddir"/gluegen-rt.jar:"$builddir"/gluegen.jar:"$builddir"/gluegen-test-util.jar:"$builddir"/test/build/gluegen-test.jar @@ -73,11 +78,11 @@ function onetest() { echo LD_LIBRARY_PATH $LD_LIBRARY_PATH echo USE_CLASSPATH $USE_CLASSPATH which java - #echo java -cp $USE_CLASSPATH $D_ARGS -Djava.library.path=$libspath $* - #java -cp $USE_CLASSPATH $D_ARGS -Djava.library.path="$libspath" $* - echo java -cp "$USE_CLASSPATH" $D_ARGS $* - java -cp "$USE_CLASSPATH" $D_ARGS $* - #j3 -cp "$USE_CLASSPATH" $D_ARGS $* + #echo java -cp $USE_CLASSPATH $X_ARGS $D_ARGS -Djava.library.path=$libspath $* + #java -cp $USE_CLASSPATH $X_ARGS $D_ARGS -Djava.library.path="$libspath" $* + echo java -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS $* + java -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS $* + #j3 -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS $* echo } # @@ -128,9 +133,15 @@ function onetest() { #onetest com.jogamp.common.nio.TestByteBufferCopyStream 2>&1 | tee -a $LOG #onetest com.jogamp.common.os.TestElfReader01 $* 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.internals.TestType 2>&1 | tee -a $LOG -#onetest com.jogamp.gluegen.PCPPTest 2>&1 | tee -a $LOG + +#onetest com.jogamp.gluegen.test.junit.generation.PCPPTest 2>&1 | tee -a $LOG +#onetest com.jogamp.gluegen.jcpp.IncludeAbsoluteTest 2>&1 | tee -a $LOG +#onetest com.jogamp.gluegen.jcpp.CppReaderTest 2>&1 | tee -a $LOG +#onetest com.jogamp.gluegen.jcpp.TokenPastingWhitespaceTest 2>&1 | tee -a $LOG +onetest com.jogamp.gluegen.jcpp.PreprocessorTest 2>&1 | tee -a $LOG + #onetest com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter 2>&1 | tee -a $LOG -onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG +#onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.generation.Test1p2LoadJNIAndImplLib 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.structgen.TestStructGen01 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.structgen.TestStructGen02 2>&1 | tee -a $LOG diff --git a/make/stub_includes/gluegen/stdio.h b/make/stub_includes/gluegen/stdio.h new file mode 100644 index 0000000..13d941e --- /dev/null +++ b/make/stub_includes/gluegen/stdio.h @@ -0,0 +1,7 @@ +#ifndef __stdio_h +#define __stdio_h + +#include <gluegen_types.h> + +#endif /* __stdio_h */ + diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index c773b21..88542c4 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -39,6 +39,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; +import java.io.Reader; import java.lang.ref.WeakReference; import java.lang.reflect.Constructor; import java.net.URISyntaxException; @@ -188,6 +189,15 @@ public class IOUtil { return numBytes; } + public static StringBuilder appendCharStream(final StringBuilder sb, final Reader r) throws IOException { + final char[] cbuf = new char[1024]; + int count; + while( 0 < ( count = r.read(cbuf) ) ) { + sb.append(cbuf, 0, count); + } + return sb; + } + /** * Copy the specified input stream to a byte array, which is being returned. */ diff --git a/src/java/com/jogamp/gluegen/GenericCPP.java b/src/java/com/jogamp/gluegen/GenericCPP.java index 85c8e65..db414d9 100644 --- a/src/java/com/jogamp/gluegen/GenericCPP.java +++ b/src/java/com/jogamp/gluegen/GenericCPP.java @@ -31,7 +31,7 @@ import java.io.OutputStream; import java.io.Reader; import java.util.List; -import org.anarres.cpp.LexerException; +import com.jogamp.gluegen.jcpp.LexerException; /** * Generic C preprocessor interface for GlueGen @@ -55,8 +55,9 @@ public interface GenericCPP { * May return an empty list, in case this preprocessor does not * store {@link ConstantDefinition}s. * </p> + * @throws GlueGenException */ - public List<ConstantDefinition> getConstantDefinitions(); + public List<ConstantDefinition> getConstantDefinitions() throws GlueGenException; }
\ No newline at end of file diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java index 20e1efa..4153518 100644 --- a/src/java/com/jogamp/gluegen/GlueGen.java +++ b/src/java/com/jogamp/gluegen/GlueGen.java @@ -49,7 +49,7 @@ import antlr.*; import com.jogamp.gluegen.cgram.*; import com.jogamp.gluegen.cgram.types.*; -import com.jogamp.gluegen.pcpp.*; +import com.jogamp.gluegen.jcpp.JCPP; import static java.lang.System.*; @@ -136,7 +136,8 @@ public class GlueGen implements GlueEmitterControls { out.deleteOnExit(); } - preprocessor = new PCPP(includePaths, debug, copyPCPPOutput2Stderr); + // preprocessor = new PCPP(includePaths, debug, copyPCPPOutput2Stderr); + preprocessor = new JCPP(includePaths, debug, copyPCPPOutput2Stderr); preprocessor.addDefine(__GLUEGEN__, "2"); preprocessor.setOut(outStream); diff --git a/src/java/com/jogamp/gluegen/pcpp/PCPP.java b/src/java/com/jogamp/gluegen/pcpp/PCPP.java index a06b8ee..c766634 100644 --- a/src/java/com/jogamp/gluegen/pcpp/PCPP.java +++ b/src/java/com/jogamp/gluegen/pcpp/PCPP.java @@ -137,7 +137,7 @@ public class PCPP implements GenericCPP { } @Override - public List<ConstantDefinition> getConstantDefinitions() { + public List<ConstantDefinition> getConstantDefinitions() throws GlueGenException { return new ArrayList<ConstantDefinition>(); // NOP } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java index 6e56a49..32ec496 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseClass.java @@ -96,6 +96,33 @@ public class BaseClass extends SingletonJunitCase { AnonBlob ab = null; PointerBuffer pb=null; + // Test constants values: binding and value! + { + // Plain vanilla CPP constants + Assert.assertEquals( 1, Bindingtest1.CONSTANT_ONE); + Assert.assertEquals( 8, Bindingtest1.ARRAY_SIZE); + Assert.assertEquals(1234, Bindingtest1.DEFINE_01); + + // Enums + Assert.assertEquals( 1, Bindingtest1.LI); + Assert.assertEquals( 3, Bindingtest1.LO); + Assert.assertEquals( 2, Bindingtest1.LU); + Assert.assertEquals( 1, Bindingtest1.MI); + Assert.assertEquals( 3, Bindingtest1.MO); + Assert.assertEquals( 2, Bindingtest1.MU); + Assert.assertEquals( 0, Bindingtest1.ZERO); + Assert.assertEquals( 1, Bindingtest1.ONE); + Assert.assertEquals( 2, Bindingtest1.TWO); + Assert.assertEquals( 3, Bindingtest1.THREE); + + // CPP Macro Expansion! + Assert.assertEquals( 1, Bindingtest1.NUMBER_ONE); + Assert.assertEquals( 2, Bindingtest1.NUMBER_TWO); + Assert.assertEquals( 4, Bindingtest1.NUMBER_FOUR); + Assert.assertEquals( 8, Bindingtest1.NUMBER_EIGHT); + Assert.assertEquals( 9, Bindingtest1.NUMBER_NINE); + Assert.assertEquals( 10, Bindingtest1.NUMBER_TEN); + } { l = binding.testXID(l); l = binding.testXID_2(l); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h index 6e826c5..fa876c6 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h @@ -50,6 +50,13 @@ typedef void * AnonBuffer; // Non Opaque // #define DEFINE_02 ( (int ) 3 ) // Duplicate w/ same value ERROR (PCPP redefine) // #define DEFINE_02 ( (int) 3 ) // Duplicate w/ diff value ERROR (PCPP redefine, then GlueGen) +#define NUMBER_ONE CONSTANT_ONE +#define NUMBER_TWO ( NUMBER_ONE + NUMBER_ONE ) +#define NUMBER_FOUR ( NUMBER_ONE << NUMBER_TWO ) +#define NUMBER_EIGHT ( NUMBER_TWO * NUMBER_TWO + ( NUMBER_ONE << NUMBER_TWO ) ) +#define NUMBER_NINE ( 2 * 2 + ( 1 << 2 ) + 1 ) +#define NUMBER_TEN ( NUMBER_EIGHT | NUMBER_TWO ) + enum Lala { LI=1, LU, LO }; // enum Lala { LI=1, LU, LO }; // Duplicate w/ same value (ignored, ERROR in native compilation) // enum Lala { LI=1, LU=3, LO }; // Duplicate w/ diff value ERROR |