diff options
35 files changed, 277 insertions, 1232 deletions
@@ -14,7 +14,18 @@ This project has has been used to successfully preprocess much of the source code of the GNU C library. As of version 1.2.5, it can also preprocess the Apple Objective C library. +# JogAmp Branch + +This branch is modified for JogAmp +to supply [GlueGen](http://jogamp.org/gluegen/www/) with JCPP. + +This branch is only intended as a submodule for GlueGen +and hence must be [build from within GlueGen](http://jogamp.org/gluegen/doc/HowToBuild.html). + +# Original JCPP Version +* [Homepage](http://www.anarres.org/projects/jcpp/) +* [GitHub](https://github.com/shevek/jcpp.git) + # Documentation -* [JavaDoc API](http://shevek.github.io/jcpp/docs/javadoc/) -* [Coverage Report](http://shevek.github.io/jcpp/docs/cobertura/) +* [JavaDoc API](http://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/) diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 0f0d31e..0000000 --- a/build.gradle +++ /dev/null @@ -1,38 +0,0 @@ -// Establish version and status -ext.githubProjectName = rootProject.name // Change if github project name is not the same as the root project's name -group = "org.anarres" - -buildscript { - apply from: file('gradle/buildscript.gradle'), to: buildscript -} - -apply from: file('gradle/convention.gradle') -apply from: file('gradle/github.gradle') -apply from: file('gradle/nexus.gradle') -apply from: file('gradle/check.gradle') -apply from: file('gradle/license.gradle') - -dependencies { - // compile 'gnu.getopt:java-getopt:1.0.13' - compile 'net.sf.jopt-simple:jopt-simple:4.7' - compile 'org.apache.ant:ant:1.7.0' - compile 'com.github.zafarkhaja:java-semver:0.8.0' - - runtime 'org.slf4j:slf4j-simple:1.7.7' - - testCompile 'com.google.guava:guava:18.0' -} - -// This ensures that the info-plugin's properties file is in the -// same location for the test suite as in the JAR. -task('processTestVersionResources', type: Copy, dependsOn: processTestResources) { - into project.sourceSets.test.output.resourcesDir - from(writeManifestProperties) { - into "META-INF" - } -} -testClasses.dependsOn(processTestVersionResources) - -apply plugin: 'application' - -mainClassName = "org.anarres.cpp.Main" diff --git a/codequality/HEADER b/codequality/HEADER deleted file mode 100644 index 169c3d1..0000000 --- a/codequality/HEADER +++ /dev/null @@ -1,13 +0,0 @@ -Copyright ${year} Shevek. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/codequality/checkstyle.xml b/codequality/checkstyle.xml deleted file mode 100644 index 47c01a2..0000000 --- a/codequality/checkstyle.xml +++ /dev/null @@ -1,188 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE module PUBLIC - "-//Puppy Crawl//DTD Check Configuration 1.2//EN" - "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> - -<module name="Checker"> - - <!-- Checks that a package-info.java file exists for each package. --> - <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage --> - <!-- - <module name="JavadocPackage"> - <property name="allowLegacy" value="true"/> - </module> - --> - - <!-- Checks whether files end with a new line. --> - <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> - <module name="NewlineAtEndOfFile"/> - - <!-- Checks that property files contain the same keys. --> - <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> - <module name="Translation"/> - - <!-- Checks for Size Violations. --> - <!-- See http://checkstyle.sf.net/config_sizes.html --> - <module name="FileLength"/> - - <!-- Checks for whitespace --> - <!-- See http://checkstyle.sf.net/config_whitespace.html --> - <module name="FileTabCharacter"/> - - <!-- Miscellaneous other checks. --> - <!-- See http://checkstyle.sf.net/config_misc.html --> - <module name="RegexpSingleline"> - <property name="format" value="\s+$"/> - <property name="minimum" value="0"/> - <property name="maximum" value="0"/> - <property name="message" value="Line has trailing spaces."/> - <property name="severity" value="info"/> - </module> - - <module name="TreeWalker"> - - <!-- Checks for Javadoc comments. --> - <!-- See http://checkstyle.sf.net/config_javadoc.html --> - <module name="JavadocMethod"> - <property name="scope" value="package"/> - <property name="allowMissingParamTags" value="true"/> - <property name="allowMissingThrowsTags" value="true"/> - <property name="allowMissingReturnTag" value="true"/> - <property name="allowThrowsTagsForSubclasses" value="true"/> - <property name="allowUndeclaredRTE" value="true"/> - <property name="allowMissingPropertyJavadoc" value="true"/> - </module> - <module name="JavadocType"> - <property name="scope" value="package"/> - </module> - <module name="JavadocVariable"> - <property name="scope" value="package"/> - </module> - <module name="JavadocStyle"> - <property name="checkEmptyJavadoc" value="true"/> - </module> - - <!-- Checks for Naming Conventions. --> - <!-- See http://checkstyle.sf.net/config_naming.html --> - <module name="ConstantName"/> - <module name="LocalFinalVariableName"/> - <module name="LocalVariableName"/> - <module name="MemberName"/> - <module name="MethodName"/> - <module name="PackageName"/> - <module name="ParameterName"/> - <module name="StaticVariableName"/> - <module name="TypeName"/> - - <!-- Checks for imports --> - <!-- See http://checkstyle.sf.net/config_import.html --> - <module name="AvoidStarImport"/> - <module name="IllegalImport"/> <!-- defaults to sun.* packages --> - <module name="RedundantImport"/> - <module name="UnusedImports"/> - - - <!-- Checks for Size Violations. --> - <!-- See http://checkstyle.sf.net/config_sizes.html --> - <module name="LineLength"> - <!-- what is a good max value? --> - <property name="max" value="120"/> - <!-- ignore lines like "$File: //depot/... $" --> - <property name="ignorePattern" value="\$File.*\$"/> - <property name="severity" value="info"/> - </module> - <module name="MethodLength"/> - <module name="ParameterNumber"/> - - - <!-- Checks for whitespace --> - <!-- See http://checkstyle.sf.net/config_whitespace.html --> - <module name="EmptyForIteratorPad"/> - <module name="GenericWhitespace"/> - <module name="MethodParamPad"/> - <module name="NoWhitespaceAfter"/> - <module name="NoWhitespaceBefore"/> - <module name="OperatorWrap"/> - <module name="ParenPad"/> - <module name="TypecastParenPad"/> - <module name="WhitespaceAfter"/> - <module name="WhitespaceAround"/> - - <!-- Modifier Checks --> - <!-- See http://checkstyle.sf.net/config_modifiers.html --> - <module name="ModifierOrder"/> - <module name="RedundantModifier"/> - - - <!-- Checks for blocks. You know, those {}'s --> - <!-- See http://checkstyle.sf.net/config_blocks.html --> - <module name="AvoidNestedBlocks"/> - <module name="EmptyBlock"> - <property name="option" value="text"/> - </module> - <module name="LeftCurly"/> - <module name="NeedBraces"/> - <module name="RightCurly"/> - - - <!-- Checks for common coding problems --> - <!-- See http://checkstyle.sf.net/config_coding.html --> - <!-- <module name="AvoidInlineConditionals"/> --> - <module name="EmptyStatement"/> - <module name="EqualsHashCode"/> - <module name="HiddenField"> - <property name="ignoreConstructorParameter" value="true"/> - <property name="ignoreSetter" value="true"/> - <property name="severity" value="warning"/> - </module> - <module name="IllegalInstantiation"/> - <module name="InnerAssignment"/> - <module name="MagicNumber"> - <property name="severity" value="warning"/> - </module> - <module name="MissingSwitchDefault"/> - <!-- Problem with finding exception types... --> - <module name="RedundantThrows"> - <property name="allowUnchecked" value="true"/> - <property name="suppressLoadErrors" value="true"/> - <property name="severity" value="info"/> - </module> - <module name="SimplifyBooleanExpression"/> - <module name="SimplifyBooleanReturn"/> - - <!-- Checks for class design --> - <!-- See http://checkstyle.sf.net/config_design.html --> - <!-- <module name="DesignForExtension"/> --> - <module name="FinalClass"/> - <module name="HideUtilityClassConstructor"/> - <module name="InterfaceIsType"/> - <module name="VisibilityModifier"/> - - - <!-- Miscellaneous other checks. --> - <!-- See http://checkstyle.sf.net/config_misc.html --> - <module name="ArrayTypeStyle"/> - <!-- <module name="FinalParameters"/> --> - <module name="TodoComment"> - <property name="format" value="TODO"/> - <property name="severity" value="info"/> - </module> - <module name="UpperEll"/> - - <module name="FileContentsHolder"/> <!-- Required by comment suppression filters --> - - </module> - - <!-- Enable suppression comments --> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE IGNORE\s+(\S+)"/> - <property name="onCommentFormat" value="CHECKSTYLE END IGNORE\s+(\S+)"/> - <property name="checkFormat" value="$1"/> - </module> - <module name="SuppressWithNearbyCommentFilter"> - <!-- Syntax is "SUPPRESS CHECKSTYLE name" --> - <property name="commentFormat" value="SUPPRESS CHECKSTYLE (\w+)"/> - <property name="checkFormat" value="$1"/> - <property name="influenceFormat" value="1"/> - </module> -</module> diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 3c7f13f..0000000 --- a/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -version=1.4.8-SNAPSHOT diff --git a/gradle/buildscript.gradle b/gradle/buildscript.gradle deleted file mode 100644 index 50a1d9c..0000000 --- a/gradle/buildscript.gradle +++ /dev/null @@ -1,19 +0,0 @@ -// Executed in context of buildscript -repositories { - // mavenLocal() - mavenCentral() - // jcenter() -} - -dependencies { - classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0' - // classpath 'com.mapvine:gradle-cobertura-plugin:0.1' - classpath "net.saliman:gradle-cobertura-plugin:2.2.5" - // classpath 'gradle-release:gradle-release:1.1.5' - classpath 'org.ajoberstar:gradle-git:0.12.0' - classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.5' - classpath('com.netflix.nebula:gradle-info-plugin:1.12.5') { - exclude group: 'com.perforce' - } - classpath 'com.bmuschko:gradle-nexus-plugin:2.2' -} diff --git a/gradle/check.gradle b/gradle/check.gradle deleted file mode 100644 index ad1f9fc..0000000 --- a/gradle/check.gradle +++ /dev/null @@ -1,29 +0,0 @@ - // Checkstyle - // apply plugin: 'checkstyle' - // checkstyle { - // ignoreFailures = true - // configFile = rootProject.file('codequality/checkstyle.xml') - // } - - // FindBugs - apply plugin: 'findbugs' - findbugs { - ignoreFailures = true - } - findbugsTest.enabled = false - - // PMD - // apply plugin: 'pmd' - // tasks.withType(Pmd) { reports.html.enabled true } - - apply plugin: 'cobertura' - cobertura { - coverageFormats = [ 'html', 'xml' ] - } - githubPages { - pages { - from(cobertura.coverageReportDir) { - into "docs/cobertura" - } - } - } diff --git a/gradle/convention.gradle b/gradle/convention.gradle deleted file mode 100644 index d0ed864..0000000 --- a/gradle/convention.gradle +++ /dev/null @@ -1,67 +0,0 @@ - apply plugin: 'java' // Plugin as major conventions - apply plugin: 'errorprone' - apply plugin: 'info' - - sourceCompatibility = 1.5 - - // GRADLE-2087 workaround, perform after java plugin - status = project.hasProperty('preferredStatus')?project.preferredStatus:(version.contains('SNAPSHOT')?'snapshot':'release') - - repositories { - // mavenLocal() - mavenCentral() - // jcenter() - } - - dependencies { - compile 'com.google.code.findbugs:jsr305:2.0.2' - compile 'org.slf4j:slf4j-api:1.7.7' - - testCompile 'junit:junit:4.11' - - testRuntime 'org.slf4j:slf4j-simple:1.7.7' - } - - tasks.withType(JavaCompile) { - // options.incremental = true - } - - javadoc { - options.links "http://docs.oracle.com/javase/7/docs/api/", - "http://docs.oracle.com/javaee/7/api/", - "http://docs.guava-libraries.googlecode.com/git/javadoc/" - } - - test { - systemProperty 'org.apache.commons.logging.Log', 'org.apache.commons.logging.impl.SimpleLog' - systemProperty 'org.apache.commons.logging.simplelog.defaultlog', 'debug' - systemProperty 'org.apache.commons.logging.diagnostics.dest', 'STDERR' - systemProperty 'org.slf4j.simpleLogger.logFile', 'System.out' - systemProperty 'org.slf4j.simpleLogger.defaultLogLevel', 'debug' - systemProperty 'jna.nosys', 'true' - - testLogging { - if (System.properties['test.single']) { - // events "passed", "skipped", "failed" - events "started", "passed", "skipped", "failed" - showExceptions true - exceptionFormat "full" - showStandardStreams true - } else { - events "started", "skipped", "failed" - } - - debug { - events "started", "passed", "skipped", "failed", "standard_out", "standard_error" - exceptionFormat "full" - } - } - } - -apply plugin: 'build-announcements' -apply plugin: 'build-dashboard' - -// Generate wrapper, which is distributed as part of source to alleviate the need of installing gradle -wrapper { - gradleVersion = '2.2.1' -} diff --git a/gradle/github.gradle b/gradle/github.gradle deleted file mode 100644 index 64a8fee..0000000 --- a/gradle/github.gradle +++ /dev/null @@ -1,33 +0,0 @@ -apply plugin: 'org.ajoberstar.github-pages' - -def docTasks = [:] -[Javadoc,ScalaDoc,Groovydoc].each{ Class docClass -> - def allSources = allprojects.tasks*.withType(docClass).flatten()*.source - if (allSources) { - def shortName = docClass.simpleName.toLowerCase() - def docTask = task "aggregate${shortName.capitalize()}"(type: docClass, description: "Aggregate subproject ${shortName}s") { - source = allSources - destinationDir = file("${project.buildDir}/docs/${shortName}") - options.links "http://docs.oracle.com/javase/7/docs/api/", - "http://docs.oracle.com/javaee/7/api/", - "http://docs.guava-libraries.googlecode.com/git/javadoc/" - doFirst { - def classpaths = allprojects.findAll { it.plugins.hasPlugin(JavaPlugin) }.collect { it.sourceSets.main.compileClasspath } - classpath = files(classpaths) - } - } - docTasks[shortName] = docTask - publishGhPages.dependsOn(docTask) - } -} - -githubPages { - repoUri = "[email protected]:shevek/${rootProject.githubProjectName}.git" - pages { - docTasks.each { shortName, docTask -> - from(docTask.outputs.files) { - into "docs/${shortName}" - } - } - } -} diff --git a/gradle/license.gradle b/gradle/license.gradle deleted file mode 100644 index 662bde1..0000000 --- a/gradle/license.gradle +++ /dev/null @@ -1,9 +0,0 @@ -allprojects { - apply plugin: 'license' //nl.javadude.gradle.plugins.license.LicensePlugin - license { - header rootProject.file('codequality/HEADER') - ext.year = Calendar.getInstance().get(Calendar.YEAR) - skipExistingHeaders true - ignoreFailures true - } -} diff --git a/gradle/nexus.gradle b/gradle/nexus.gradle deleted file mode 100644 index a51ec4b..0000000 --- a/gradle/nexus.gradle +++ /dev/null @@ -1,43 +0,0 @@ - apply plugin: 'com.bmuschko.nexus' - - project.afterEvaluate { - uploadArchives { - repositories { - mavenDeployer { - uniqueVersion = false - } - } - } - } - - modifyPom { - // Closure to configure all the POM with extra info, common to all projects - project { - name "${project.name}" - description "Java C Preprocessor" - developers { - developer { - id 'shevek' - name 'Shevek' - email '[email protected]' - } - } - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - url "https://github.com/shevek/${rootProject.githubProjectName}" - scm { - connection "scm:git:[email protected]:shevek/${rootProject.githubProjectName}.git" - url "scm:git:[email protected]:shevek/${rootProject.githubProjectName}.git" - developerConnection "scm:git:[email protected]:shevek/${rootProject.githubProjectName}.git" - } - issueManagement { - system 'github' - url "https://github.com/shevek/${rootProject.githubProjectName}/issues" - } - } - } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differdeleted file mode 100644 index c97a8bd..0000000 --- a/gradle/wrapper/gradle-wrapper.jar +++ /dev/null diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 58b3586..0000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Tue Dec 02 23:57:35 PST 2014 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip diff --git a/gradlew b/gradlew deleted file mode 100755 index 91a7e26..0000000 --- a/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index aec9973..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/install b/install deleted file mode 120000 index a40f9f7..0000000 --- a/install +++ /dev/null @@ -1 +0,0 @@ -build/install/jcpp/
\ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index f22856c..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name='jcpp' diff --git a/src/main/ghpages/index.html b/src/main/ghpages/index.html deleted file mode 100644 index 32292c3..0000000 --- a/src/main/ghpages/index.html +++ /dev/null @@ -1,6 +0,0 @@ -<html> -<body> -<a href="docs/javadoc/">Javadoc</a> -<a href="docs/cobertura/">Coverage</a> -</body> -</html> diff --git a/src/main/java/com/jogamp/gluegen/jcpp/BuildMetadata.java b/src/main/java/com/jogamp/gluegen/jcpp/BuildMetadata.java deleted file mode 100644 index f22d853..0000000 --- a/src/main/java/com/jogamp/gluegen/jcpp/BuildMetadata.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.jogamp.gluegen.jcpp; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import javax.annotation.Nonnull; - -/** - * Returns information about the build. - * - * @author shevek - */ -public class BuildMetadata { - - public static final String RESOURCE = "/META-INF/jcpp.properties"; - private static BuildMetadata INSTANCE; - - /** @throws RuntimeException if the properties file cannot be found on the classpath. */ - @Nonnull - public static synchronized BuildMetadata getInstance() { - try { - if (INSTANCE == null) - INSTANCE = new BuildMetadata(); - return INSTANCE; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private final Properties properties = new Properties(); - - private BuildMetadata() throws IOException { - URL url = BuildMetadata.class.getResource(RESOURCE); - InputStream in = url.openStream(); - try { - properties.load(in); - } finally { - in.close(); - } - } - - @Nonnull - public Map<? extends String, ? extends String> asMap() { - Map<String, String> out = new HashMap<String, String>(); - for (Map.Entry<Object, Object> e : properties.entrySet()) - out.put(String.valueOf(e.getKey()), String.valueOf(e.getValue())); - return out; - } - - @Nonnull - public com.github.zafarkhaja.semver.Version getVersion() { - return com.github.zafarkhaja.semver.Version.valueOf(properties.getProperty("Implementation-Version")); - } - - @Nonnull - public Date getBuildDate() throws ParseException { - // Build-Date=2015-01-01_10:09:09 - String text = properties.getProperty("Build-Date"); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); - return format.parse(text); - } - - public String getChangeId() { - return properties.getProperty("Change"); - } -} diff --git a/src/main/java/com/jogamp/gluegen/jcpp/Main.java b/src/main/java/com/jogamp/gluegen/jcpp/Main.java deleted file mode 100644 index 9f06fb0..0000000 --- a/src/main/java/com/jogamp/gluegen/jcpp/Main.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Anarres C Preprocessor - * Copyright (c) 2007-2008, Shevek - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ -package com.jogamp.gluegen.jcpp; - -import java.io.File; -import java.io.PrintStream; -import java.util.Arrays; -import java.util.EnumSet; -import java.util.List; -import javax.annotation.Nonnull; -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import joptsimple.OptionSpec; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * (Currently a simple test class). - */ -public class Main { - - private static final Logger LOG = LoggerFactory.getLogger(Main.class); - - @Nonnull - private static CharSequence getWarnings() { - StringBuilder buf = new StringBuilder(); - for (Warning w : Warning.values()) { - if (buf.length() > 0) - buf.append(", "); - String name = w.name().toLowerCase(); - buf.append(name.replace('_', '-')); - } - return buf; - } - - public static void main(String[] args) throws Exception { - (new Main()).run(args); - } - - public void run(String[] args) throws Exception { - - OptionParser parser = new OptionParser(); - OptionSpec<?> helpOption = parser.accepts("help", - "Displays command-line help.") - .forHelp(); - OptionSpec<?> versionOption = parser.acceptsAll(Arrays.asList("version"), - "Displays the product version (" + BuildMetadata.getInstance().getVersion() + ") and exits.") - .forHelp(); - - OptionSpec<?> debugOption = parser.acceptsAll(Arrays.asList("debug"), - "Enables debug output."); - - OptionSpec<String> defineOption = parser.acceptsAll(Arrays.asList("define", "D"), - "Defines the given macro.") - .withRequiredArg().ofType(String.class).describedAs("name[=definition]"); - OptionSpec<String> undefineOption = parser.acceptsAll(Arrays.asList("undefine", "U"), - "Undefines the given macro, previously either builtin or defined using -D.") - .withRequiredArg().describedAs("name"); - OptionSpec<File> includeOption = parser.accepts("include", - "Process file as if \"#" + "include \"file\"\" appeared as the first line of the primary source file.") - .withRequiredArg().ofType(File.class).describedAs("file"); - OptionSpec<File> incdirOption = parser.acceptsAll(Arrays.asList("incdir", "I"), - "Adds the directory dir to the list of directories to be searched for header files.") - .withRequiredArg().ofType(File.class).describedAs("dir"); - OptionSpec<File> iquoteOption = parser.acceptsAll(Arrays.asList("iquote"), - "Adds the directory dir to the list of directories to be searched for header files included using \"\".") - .withRequiredArg().ofType(File.class).describedAs("dir"); - OptionSpec<String> warningOption = parser.acceptsAll(Arrays.asList("warning", "W"), - "Enables the named warning class (" + getWarnings() + ").") - .withRequiredArg().ofType(String.class).describedAs("warning"); - OptionSpec<Void> noWarningOption = parser.acceptsAll(Arrays.asList("no-warnings", "w"), - "Disables ALL warnings."); - OptionSpec<File> inputsOption = parser.nonOptions() - .ofType(File.class).describedAs("Files to process."); - - OptionSet options = parser.parse(args); - - if (options.has(helpOption)) { - parser.printHelpOn(System.out); - return; - } - - if (options.has(versionOption)) { - version(System.out); - return; - } - - Preprocessor pp = new Preprocessor(); - pp.addFeature(Feature.DIGRAPHS); - pp.addFeature(Feature.TRIGRAPHS); - pp.addFeature(Feature.LINEMARKERS); - pp.addWarning(Warning.IMPORT); - pp.setListener(new DefaultPreprocessorListener()); - pp.addMacro("__JCPP__"); - pp.getSystemIncludePath().add("/usr/local/include"); - pp.getSystemIncludePath().add("/usr/include"); - pp.getFrameworksPath().add("/System/Library/Frameworks"); - pp.getFrameworksPath().add("/Library/Frameworks"); - pp.getFrameworksPath().add("/Local/Library/Frameworks"); - - if (options.has(debugOption)) - pp.addFeature(Feature.DEBUG); - - if (options.has(noWarningOption)) - pp.getWarnings().clear(); - - for (String warning : options.valuesOf(warningOption)) { - warning = warning.toUpperCase(); - warning = warning.replace('-', '_'); - if (warning.equals("ALL")) - pp.addWarnings(EnumSet.allOf(Warning.class)); - else - pp.addWarning(Enum.valueOf(Warning.class, warning)); - } - - for (String arg : options.valuesOf(defineOption)) { - int idx = arg.indexOf('='); - if (idx == -1) - pp.addMacro(arg); - else - pp.addMacro(arg.substring(0, idx), arg.substring(idx + 1)); - } - for (String arg : options.valuesOf(undefineOption)) { - pp.getMacros().remove(arg); - } - - for (File dir : options.valuesOf(incdirOption)) - pp.getSystemIncludePath().add(dir.getAbsolutePath()); - for (File dir : options.valuesOf(iquoteOption)) - pp.getQuoteIncludePath().add(dir.getAbsolutePath()); - for (File file : options.valuesOf(includeOption)) - // Comply exactly with spec. - pp.addInput(new StringLexerSource("#" + "include \"" + file + "\"\n")); - - List<File> inputs = options.valuesOf(inputsOption); - if (inputs.isEmpty()) { - pp.addInput(new InputLexerSource(System.in)); - } else { - for (File input : inputs) - pp.addInput(new FileLexerSource(input)); - } - - if (pp.getFeature(Feature.DEBUG)) { - LOG.info("#" + "include \"...\" search starts here:"); - for (String dir : pp.getQuoteIncludePath()) - LOG.info(" " + dir); - LOG.info("#" + "include <...> search starts here:"); - for (String dir : pp.getSystemIncludePath()) - LOG.info(" " + dir); - LOG.info("End of search list."); - } - - try { - for (;;) { - Token tok = pp.token(); - if (tok == null) - break; - if (tok.getType() == Token.EOF) - break; - System.out.print(tok.getText()); - } - } catch (Exception e) { - StringBuilder buf = new StringBuilder("Preprocessor failed:\n"); - Source s = pp.getSource(); - while (s != null) { - buf.append(" -> ").append(s).append("\n"); - s = s.getParent(); - } - LOG.error(buf.toString(), e); - } - - } - - private static void version(@Nonnull PrintStream out) { - BuildMetadata metadata = BuildMetadata.getInstance(); - out.println("Anarres Java C Preprocessor version " + metadata.getVersion() + " change-id " + metadata.getChangeId()); - out.println("Copyright (C) 2008-2014 Shevek (http://www.anarres.org/)."); - out.println("This is free software; see the source for copying conditions. There is NO"); - out.println("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); - } -} diff --git a/src/main/velocity/org/anarres/cpp/Version.java b/src/main/velocity/org/anarres/cpp/Version.java deleted file mode 100644 index cedd6bb..0000000 --- a/src/main/velocity/org/anarres/cpp/Version.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Anarres C Preprocessor - * Copyright (c) 2007-2008, Shevek - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ - -package org.anarres.cpp; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * System version metadata for Anarres Java C Preprocessor ${version}. - * - * This class contains a main() and may be run to print the version. - */ -public class Version { - - /* Don't instantiate me */ - private Version() { - } - - private static final String VERSION = "${version}"; - - private static final int major; - private static final int minor; - private static final int patch; - private static final String modifier; - - static { - String[] tmp = VERSION.split("[\\.-]"); - major = Integer.parseInt(tmp[0]); - minor = Integer.parseInt(tmp[1]); - patch = Integer.parseInt(tmp[2]); - modifier = (tmp.length > 3) ? tmp[3] : null; - } - - @Nonnull - public static String getVersion() { - return VERSION; - } - - public static int getMajor() { - return major; - } - - public static int getMinor() { - return minor; - } - - public static int getPatch() { - return patch; - } - - @CheckForNull - public static String getModifier() { - return modifier; - } - - public static boolean isSnapshot() { - return "SNAPSHOT".equalsIgnoreCase(getModifier()); - } - - public static void main(String[] args) { - System.out.println("Version " + VERSION); - System.out.println("getVersion() returns " + getVersion()); - System.out.println("getMajor() returns " + getMajor()); - System.out.println("getMinor() returns " + getMinor()); - System.out.println("getPatch() returns " + getPatch()); - } - -} diff --git a/src/scripts/jcpp b/src/scripts/jcpp deleted file mode 100755 index ed167c5..0000000 --- a/src/scripts/jcpp +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -CPP_JAR=anarres-cpp.jar - -if [ -n "$CPP_ROOT" ] ; then - CPP_ROOT="$CPP_ROOT" -elif [ -f lib/$CPP_JAR ] ; then - CPP_ROOT="." -elif [ -f ../lib/$CPP_JAR ] ; then - CPP_ROOT=".." -elif [ -f $(dirname $0)/lib/$CPP_JAR ] ; then - CPP_ROOT=$(dirname $0) -else - echo "Could not find $CPP_JAR. Please set CPP_ROOT." - exit 1 -fi - -if [ -z "$CPP_LIB" ] ; then - CPP_LIB=$CPP_ROOT/lib -fi - -if [ -z "$CPP_CLASSPATH" ] ; then - CPP_CLASSPATH="$(ls $CPP_LIB/*.jar | tr '\n' ':')" -fi - -if [ -z "$CPP_MAINCLASS" ] ; then - CPP_MAINCLASS=org.anarres.cpp.Main -fi - -CPP_JFLAGS="-Xmx128M" - -exec java $CPP_JFLAGS -cp "$CPP_CLASSPATH" $CPP_MAINCLASS "$@" diff --git a/src/scripts/release.sh b/src/scripts/release.sh deleted file mode 100644 index cd88d95..0000000 --- a/src/scripts/release.sh +++ /dev/null @@ -1,5 +0,0 @@ -rsync -avP build/dist/anarres-cpp-*.tar.gz [email protected]:public_html/projects/jcpp/ -rsync -avP --exclude=.svn --exclude=autohandler build/javadoc [email protected]:public_html/projects/jcpp/ -cp build/tar/lib/anarres-cpp.jar /home/shevek/java/iengine/trunk/lib/runtime/jcpp/ -cp build/tar/lib/anarres-cpp.jar /home/shevek/java/karma/trunk/lib/dp/ -cp build/tar/lib/anarres-cpp.jar /home/shevek/java/dp/trunk/lib/runtime/cpp/ diff --git a/src/test/java/org/anarres/cpp/CppReaderTest.java b/src/test/java/com/jogamp/gluegen/jcpp/CppReaderTest.java index c901722..e4ef1c5 100644 --- a/src/test/java/org/anarres/cpp/CppReaderTest.java +++ b/src/test/java/com/jogamp/gluegen/jcpp/CppReaderTest.java @@ -1,26 +1,33 @@ -package org.anarres.cpp; +package com.jogamp.gluegen.jcpp; import java.io.BufferedReader; +import java.io.IOException; import java.io.StringReader; import java.util.Collections; + import javax.annotation.Nonnull; + import org.junit.Test; + +import com.jogamp.gluegen.test.junit.generation.BuildEnvironment; + import static org.junit.Assert.assertEquals; public class CppReaderTest { - public static String testCppReader(@Nonnull String in, Feature... f) - throws Exception { + public static String testCppReader(@Nonnull final String in, final Feature... f) throws Exception { + final String inclpath = BuildEnvironment.gluegenRoot + "/jcpp/src/test/resources" ; + System.out.println("Testing " + in); - StringReader r = new StringReader(in); - CppReader p = new CppReader(r); + final StringReader r = new StringReader(in); + final CppReader p = new CppReader(r); p.getPreprocessor().setSystemIncludePath( - Collections.singletonList("src/test/resources") + Collections.singletonList(inclpath) ); p.getPreprocessor().addFeatures(f); - BufferedReader b = new BufferedReader(p); + final BufferedReader b = new BufferedReader(p); - StringBuilder out = new StringBuilder(); + final StringBuilder out = new StringBuilder(); String line; while ((line = b.readLine()) != null) { System.out.println(" >> " + line); @@ -47,7 +54,7 @@ public class CppReaderTest { public void testPragmaOnce() throws Exception { // The newlines are irrelevant, We want exactly one "foo" - String out = testCppReader("#include <once.c>\n", Feature.PRAGMA_ONCE); + final String out = testCppReader("#include <once.c>\n", Feature.PRAGMA_ONCE); assertEquals("foo", out.trim()); } @@ -58,4 +65,9 @@ public class CppReaderTest { testCppReader("#include <once.c>\n", Feature.PRAGMA_ONCE, Feature.LINEMARKERS); } + public static void main(final String args[]) throws IOException { + final String tstname = CppReaderTest.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + } diff --git a/src/test/java/org/anarres/cpp/ErrorTest.java b/src/test/java/com/jogamp/gluegen/jcpp/ErrorTest.java index 42240d4..12a5160 100644 --- a/src/test/java/org/anarres/cpp/ErrorTest.java +++ b/src/test/java/com/jogamp/gluegen/jcpp/ErrorTest.java @@ -1,8 +1,8 @@ -package org.anarres.cpp; +package com.jogamp.gluegen.jcpp; import java.io.IOException; import org.junit.Test; -import static org.anarres.cpp.Token.*; +import static com.jogamp.gluegen.jcpp.Token.*; import static org.junit.Assert.*; public class ErrorTest { diff --git a/src/test/java/com/jogamp/gluegen/jcpp/IncludeAbsoluteTest.java b/src/test/java/com/jogamp/gluegen/jcpp/IncludeAbsoluteTest.java new file mode 100644 index 0000000..b44b900 --- /dev/null +++ b/src/test/java/com/jogamp/gluegen/jcpp/IncludeAbsoluteTest.java @@ -0,0 +1,46 @@ +package com.jogamp.gluegen.jcpp; + +import java.io.File; +import java.io.IOException; +import java.io.Reader; + +import org.junit.Test; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.gluegen.Logging; +import com.jogamp.gluegen.Logging.LoggerIf; +import com.jogamp.gluegen.test.junit.generation.BuildEnvironment; + +import static org.junit.Assert.*; + +/** + * + * @author shevek + */ +public class IncludeAbsoluteTest { + + private static final LoggerIf LOG = Logging.getLogger(IncludeAbsoluteTest.class); + + @Test + public void testAbsoluteInclude() throws Exception { + final String filepath = BuildEnvironment.gluegenRoot + "/jcpp/src/test/resources/absolute.h" ; + LOG.info("filepath: " + filepath); + + final File file = new File(filepath); + assertTrue(file.exists()); + + final String input = "#include <" + file.getAbsolutePath() + ">\n"; + LOG.info("Input: " + input); + final Preprocessor pp = new Preprocessor(); + pp.addInput(new StringLexerSource(input, true)); + final Reader r = new CppReader(pp); + final String output = IOUtil.appendCharStream(new StringBuilder(), r).toString(); + r.close(); + LOG.info("Output: " + output); + assertTrue(output.contains("absolute-result")); + } + public static void main(final String args[]) throws IOException { + final String tstname = IncludeAbsoluteTest.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/test/java/org/anarres/cpp/JavaFileSystemTest.java b/src/test/java/com/jogamp/gluegen/jcpp/JavaFileSystemTest.java index 6e6f834..d867fb8 100644 --- a/src/test/java/org/anarres/cpp/JavaFileSystemTest.java +++ b/src/test/java/com/jogamp/gluegen/jcpp/JavaFileSystemTest.java @@ -1,4 +1,4 @@ -package org.anarres.cpp; +package com.jogamp.gluegen.jcpp; import java.io.FileNotFoundException; import org.junit.Test; diff --git a/src/test/java/org/anarres/cpp/JoinReaderTest.java b/src/test/java/com/jogamp/gluegen/jcpp/JoinReaderTest.java index bb9cc2d..628a7ec 100644 --- a/src/test/java/org/anarres/cpp/JoinReaderTest.java +++ b/src/test/java/com/jogamp/gluegen/jcpp/JoinReaderTest.java @@ -1,4 +1,4 @@ -package org.anarres.cpp; +package com.jogamp.gluegen.jcpp; import java.io.StringReader; import org.junit.Test; diff --git a/src/test/java/org/anarres/cpp/LexerSourceTest.java b/src/test/java/com/jogamp/gluegen/jcpp/LexerSourceTest.java index 96ec4a3..43ccbe6 100644 --- a/src/test/java/org/anarres/cpp/LexerSourceTest.java +++ b/src/test/java/com/jogamp/gluegen/jcpp/LexerSourceTest.java @@ -1,33 +1,36 @@ -package org.anarres.cpp; +package com.jogamp.gluegen.jcpp; import java.util.Arrays; + import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import static org.anarres.cpp.PreprocessorTest.assertType; -import static org.anarres.cpp.Token.*; + +import com.jogamp.gluegen.Logging; +import com.jogamp.gluegen.Logging.LoggerIf; + +import static com.jogamp.gluegen.jcpp.PreprocessorTest.assertType; +import static com.jogamp.gluegen.jcpp.Token.*; import static org.junit.Assert.*; public class LexerSourceTest { - private static final Logger LOG = LoggerFactory.getLogger(LexerSourceTest.class); + private static final LoggerIf LOG = Logging.getLogger(LexerSourceTest.class); - public static void testLexerSource(String in, boolean textmatch, int... out) + public static void testLexerSource(final String in, final boolean textmatch, final int... out) throws Exception { LOG.info("Testing '" + in + "' => " + Arrays.toString(out)); - StringLexerSource s = new StringLexerSource(in); + final StringLexerSource s = new StringLexerSource(in); - StringBuilder buf = new StringBuilder(); + final StringBuilder buf = new StringBuilder(); for (int i = 0; i < out.length; i++) { - Token tok = s.token(); + final Token tok = s.token(); LOG.info("Token is " + tok); assertType(out[i], tok); // assertEquals(col, tok.getColumn()); buf.append(tok.getText()); } - Token tok = s.token(); + final Token tok = s.token(); LOG.info("Token is " + tok); assertType(EOF, tok); diff --git a/src/test/java/org/anarres/cpp/NumericValueTest.java b/src/test/java/com/jogamp/gluegen/jcpp/NumericValueTest.java index d4ea432..2d612ce 100644 --- a/src/test/java/org/anarres/cpp/NumericValueTest.java +++ b/src/test/java/com/jogamp/gluegen/jcpp/NumericValueTest.java @@ -1,8 +1,8 @@ -package org.anarres.cpp; +package com.jogamp.gluegen.jcpp; import java.io.IOException; import org.junit.Test; -import static org.anarres.cpp.Token.*; +import static com.jogamp.gluegen.jcpp.Token.*; import static org.junit.Assert.*; /** diff --git a/src/test/java/org/anarres/cpp/PreprocessorTest.java b/src/test/java/com/jogamp/gluegen/jcpp/PreprocessorTest.java index 13bd944..651af98 100644 --- a/src/test/java/org/anarres/cpp/PreprocessorTest.java +++ b/src/test/java/com/jogamp/gluegen/jcpp/PreprocessorTest.java @@ -1,29 +1,38 @@ -package org.anarres.cpp; +package com.jogamp.gluegen.jcpp; +import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PipedInputStream; import java.io.PipedOutputStream; +import java.util.List; +import java.util.logging.Level; + +import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import static org.anarres.cpp.Token.*; + +import com.jogamp.gluegen.Logging; +import com.jogamp.gluegen.Logging.LoggerIf; + +import static com.jogamp.gluegen.jcpp.Token.*; import static org.junit.Assert.*; public class PreprocessorTest { - private static final Logger LOG = LoggerFactory.getLogger(PreprocessorTest.class); + private static final LoggerIf LOG = Logging.getLogger(PreprocessorTest.class); private OutputStreamWriter writer; private Preprocessor p; @Before public void setUp() throws Exception { + LOG.setLevel(Level.INFO); final PipedOutputStream po = new PipedOutputStream(); writer = new OutputStreamWriter(po); p = new Preprocessor(); + // p.addFeature(Feature.DEBUG); p.addInput( new LexerSource( new InputStreamReader( @@ -35,10 +44,9 @@ public class PreprocessorTest { } private static class I { - private final String t; - public I(String t) { + public I(final String t) { this.t = t; } @@ -51,10 +59,28 @@ public class PreprocessorTest { return getText(); } } - - private static I I(String t) { + private static I I(final String t) { return new I(t); } + private static class N { + private final String t; + + public N(final String t) { + this.t = t; + } + + public String getText() { + return t; + } + + @Override + public String toString() { + return getText(); + } + } + private static N N(final String t) { + return new N(t); + } /* * When writing tests in this file, remember the preprocessor @@ -63,7 +89,7 @@ public class PreprocessorTest { * the following input line. */ @Test - public void testPreprocessor() throws Exception { + public void test01Preprocessor() throws Exception { /* Magic macros */ testInput("line = __LINE__\n", I("line"), WHITESPACE, '=', WHITESPACE, NUMBER @@ -75,7 +101,11 @@ public class PreprocessorTest { /* Simple definitions */ testInput("#define A a /* a defined */\n", NL); + testInput("A /* a */\n", NL, I("a"), WHITESPACE, CCOMMENT); + testConstMacro("A", true, I("a")); testInput("#define B b /* b defined */\n", NL); + testInput("B /* b */\n", NL, I("b"), WHITESPACE, CCOMMENT); + testConstMacro("B", false, I("b")); testInput("#define C c /* c defined */\n", NL); /* Expansion of arguments */ @@ -107,20 +137,54 @@ public class PreprocessorTest { /* Redefinitions, undefinitions. */ testInput("#define two three\n", NL); + testInput("two /* three */\n", NL, I("three"), WHITESPACE, CCOMMENT); testInput("one /* one */\n", NL, I("one"), WHITESPACE, CCOMMENT); + testConstMacro("two", false, I("three")); + testConstMacro("two", true, I("three")); + testInput("#define one two\n", NL); testInput("one /* three */\n", NL, I("three"), WHITESPACE, CCOMMENT); + testConstMacro("one", false, I("two")); + testConstMacro("one", true, I("three")); + testInput("#undef two\n", NL); + testInput("one /* two */\n", NL, I("two"), WHITESPACE, CCOMMENT); + testConstMacro("one", false, I("two")); + testConstMacro("one", true, I("two")); + testInput("#define two five\n", NL); testInput("one /* five */\n", NL, I("five"), WHITESPACE, CCOMMENT); + testConstMacro("one", false, I("two")); + testConstMacro("one", true, I("five")); + testInput("#undef two\n", NL); testInput("one /* two */\n", NL, I("two"), WHITESPACE, CCOMMENT); + testConstMacro("one", false, I("two")); + testConstMacro("one", true, I("two")); + testInput("#undef one\n", NL); testInput("#define one four\n", NL); testInput("one /* four */\n", NL, I("four"), WHITESPACE, CCOMMENT); + testConstMacro("one", false, I("four")); + testConstMacro("one", true, I("four")); + testInput("#undef one\n", NL); testInput("#define one one\n", NL); testInput("one /* one */\n", NL, I("one"), WHITESPACE, CCOMMENT); + testConstMacro("one", false, I("one")); + testConstMacro("one", true, I("one")); + + testInput("#define NUM1 1\n", NL); + testInput("#define NUM4 ( 1 << ( NUM1 + NUM1 ) )\n", NL); + testInput("NUM4 /* ( 1 << ( 1 + 1 ) ) */\n", NL, + '(', WHITESPACE, N("1"), WHITESPACE, LSH, WHITESPACE, + '(', WHITESPACE, N("1"), WHITESPACE, '+', WHITESPACE, N("1"), WHITESPACE, ')', WHITESPACE, ')', + WHITESPACE, CCOMMENT); + testConstMacro("NUM4", false, '(', WHITESPACE, N("1"), WHITESPACE, LSH, WHITESPACE, + '(', WHITESPACE, I("NUM1"), WHITESPACE, '+', WHITESPACE, I("NUM1"), WHITESPACE, ')', + WHITESPACE, ')'); + testConstMacro("NUM4", true, '(', WHITESPACE, N("1"), WHITESPACE, LSH, WHITESPACE, + '(', WHITESPACE, N("1"), WHITESPACE, '+', WHITESPACE, N("1"), WHITESPACE, ')', WHITESPACE, ')'); /* Variadic macros. */ testInput("#define var(x...) a x __VA_ARGS__ b\n", NL); @@ -186,12 +250,12 @@ public class PreprocessorTest { Token t; do { t = p.token(); - LOG.warn("Remaining token " + t); + LOG.warning("Remaining token " + t); } while (t.getType() != EOF); } @Test - public void testPreprocessorUnterminated() throws Exception { + public void test02PreprocessorUnterminated() throws Exception { testInput("#ifndef X\na\n#else\nb\n"); // Bug #16 writer.close(); @@ -199,32 +263,38 @@ public class PreprocessorTest { Token t; do { t = p.token(); - LOG.warn("Remaining token " + t); + LOG.warning("Remaining token " + t); } while (t.getType() != EOF); } - public static void assertType(int type, Token t) { - String typeExpect = TokenType.getTokenName(type); - String typeActual = TokenType.getTokenName(t.getType()); + public static void assertType(final int type, final Token t) { + final String typeExpect = TokenType.getTokenName(type); + final String typeActual = TokenType.getTokenName(t.getType()); assertEquals("Expected " + typeExpect + " but got " + typeActual, type, t.getType()); } - private void testInput(String in, Object... out) + private void testInput(final String in, final Object... out) throws Exception { LOG.info("Input: " + in); writer.write(in); writer.flush(); - for (Object v : out) { - Token t = p.token(); - LOG.info(String.valueOf(t)); + for (final Object v : out) { + final Token t = p.token(); + LOG.info("READ: "+String.valueOf(t)); if (v instanceof String) { if (t.getType() != STRING) fail("Expected STRING, but got " + t); assertEquals(v, t.getValue()); } else if (v instanceof I) { - if (t.getType() != IDENTIFIER) + if (t.getType() != IDENTIFIER) { fail("Expected IDENTIFIER " + v + ", but got " + t); + } assertEquals(((I) v).getText(), t.getText()); + } else if (v instanceof N) { + if (t.getType() != NUMBER) { + fail("Expected NUMBER " + v + ", but got " + t); + } + assertEquals(((N) v).getText(), t.getText()); } else if (v instanceof Character) { assertType(((Character) v).charValue(), t); } else if (v instanceof Integer) { @@ -234,4 +304,69 @@ public class PreprocessorTest { } } } + // slow .. + private Macro findMacro(final List<Macro> macros, final String macroName) { + final int count = macros.size(); + for(int i=0; i<count; i++) { + final Macro m = macros.get(i); + if( m.getName().equals(macroName) ) { + return m; + } + } + return null; + } + private void dumpMacros(final List<Macro> macros) { + final int count = macros.size(); + System.err.println("Macro count: "+count); + for(int i=0; i<count; i++) { + final Macro m = macros.get(i); + System.err.println(" ["+i+"]: "+m); + } + } + private void testConstMacro(final String macroName, final boolean expandMacro, final Object... out) + throws Exception { + final List<Macro> macros = p.getMacros(expandMacro); + final Macro m = findMacro(macros, macroName); + if( null == m ) { + dumpMacros(macros); + } + Assert.assertNotNull("Macro <"+macroName+"> is missing!", m); + Assert.assertFalse(m.isFunctionLike()); + + final Source s = new MacroTokenSource(m, null); + try { + for (final Object v : out) { + final Token t = s.token(); + LOG.info("READ: "+String.valueOf(t)); + if (v instanceof String) { + if (t.getType() != STRING) { + fail("Expected STRING, but got " + t); + } + assertEquals(v, t.getValue()); + } else if (v instanceof I) { + if (t.getType() != IDENTIFIER) { + fail("Expected IDENTIFIER " + v + ", but got " + t); + } + assertEquals(((I) v).getText(), t.getText()); + } else if (v instanceof N) { + if (t.getType() != NUMBER) { + fail("Expected NUMBER " + v + ", but got " + t); + } + assertEquals(((N) v).getText(), t.getText()); + } else if (v instanceof Character) { + assertType(((Character) v).charValue(), t); + } else if (v instanceof Integer) { + assertType(((Number) v).intValue(), t); + } else { + fail("Bad object " + v.getClass()); + } + } + } finally { + s.close(); + } + } + public static void main(final String args[]) throws IOException { + final String tstname = PreprocessorTest.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } } diff --git a/src/test/java/org/anarres/cpp/TokenPastingWhitespaceTest.java b/src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java index 2e6a2b5..756425b 100644 --- a/src/test/java/org/anarres/cpp/TokenPastingWhitespaceTest.java +++ b/src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java @@ -1,11 +1,15 @@ -package org.anarres.cpp; +package com.jogamp.gluegen.jcpp; + +import com.jogamp.common.util.IOUtil; -import com.google.common.io.CharStreams; import java.io.IOException; import java.io.Reader; + import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import com.jogamp.gluegen.Logging; +import com.jogamp.gluegen.Logging.LoggerIf; + import static org.junit.Assert.*; /** @@ -15,11 +19,14 @@ import static org.junit.Assert.*; */ public class TokenPastingWhitespaceTest { - private static final Logger LOG = LoggerFactory.getLogger(TokenPastingWhitespaceTest.class); + private static final LoggerIf LOG = Logging.getLogger(TokenPastingWhitespaceTest.class); @Test - public void testWhitespacePasting() throws IOException { - Preprocessor pp = new Preprocessor(); + public void test01WhitespacePasting() throws IOException { + final Preprocessor pp = new Preprocessor(); + testWhitespacePastingImpl(pp); + } + void testWhitespacePastingImpl(final Preprocessor pp) throws IOException { pp.addInput(new StringLexerSource( "#define ONE(arg) one_##arg\n" + "#define TWO(arg) ONE(two_##arg)\n" @@ -31,8 +38,8 @@ public class TokenPastingWhitespaceTest { + "ONE(good)\n" + "ONE( /* evil newline */\n" + " bad)\n", true)); - Reader r = new CppReader(pp); - String text = CharStreams.toString(r).trim(); + final Reader r = new CppReader(pp); + final String text = IOUtil.appendCharStream(new StringBuilder(), r).toString().trim(); LOG.info("Output is:\n" + text); assertEquals("one_two_good\n" + "one_two_bad\n" @@ -40,4 +47,9 @@ public class TokenPastingWhitespaceTest { + "one_good\n" + "one_bad", text); } + + public static void main(final String args[]) throws IOException { + final String tstname = TokenPastingWhitespaceTest.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } } diff --git a/src/test/java/org/anarres/cpp/BuildMetadataTest.java b/src/test/java/org/anarres/cpp/BuildMetadataTest.java deleted file mode 100644 index 42dc071..0000000 --- a/src/test/java/org/anarres/cpp/BuildMetadataTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.anarres.cpp; - -import com.google.common.base.Charsets; -import com.google.common.io.Resources; -import java.net.URL; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author shevek - */ -public class BuildMetadataTest { - - private static final Logger LOG = LoggerFactory.getLogger(BuildMetadataTest.class); - - @Test - public void testProperties() throws Exception { - URL url = Resources.getResource("META-INF/jcpp.properties"); - String text = Resources.asCharSource(url, Charsets.ISO_8859_1).read(); - LOG.info("Metadata is " + text); - } - - @Test - public void testMetadata() throws Exception { - BuildMetadata metadata = BuildMetadata.getInstance(); - LOG.info("Version is " + metadata.getVersion()); - LOG.info("BuildDate is " + metadata.getBuildDate()); - LOG.info("ChangeId is " + metadata.getChangeId()); - } - -} diff --git a/src/test/java/org/anarres/cpp/IncludeAbsoluteTest.java b/src/test/java/org/anarres/cpp/IncludeAbsoluteTest.java deleted file mode 100644 index df7ffb7..0000000 --- a/src/test/java/org/anarres/cpp/IncludeAbsoluteTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.anarres.cpp; - -import com.google.common.io.CharStreams; -import java.io.BufferedReader; -import java.io.File; -import java.io.Reader; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import static org.junit.Assert.*; - -/** - * - * @author shevek - */ -public class IncludeAbsoluteTest { - - private static final Logger LOG = LoggerFactory.getLogger(IncludeAbsoluteTest.class); - - @Test - public void testAbsoluteInclude() throws Exception { - File file = new File("build/resources/test/absolute.h"); - assertTrue(file.exists()); - - String input = "#include <" + file.getAbsolutePath() + ">\n"; - LOG.info("Input: " + input); - Preprocessor pp = new Preprocessor(); - pp.addInput(new StringLexerSource(input, true)); - Reader r = new CppReader(pp); - String output = CharStreams.toString(r); - r.close(); - LOG.info("Output: " + output); - assertTrue(output.contains("absolute-result")); - } -} diff --git a/src/test/java/org/anarres/cpp/MainTest.java b/src/test/java/org/anarres/cpp/MainTest.java deleted file mode 100644 index 5ff7350..0000000 --- a/src/test/java/org/anarres/cpp/MainTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.anarres.cpp; - -import org.junit.Test; - -public class MainTest { - - @Test - public void testMain() throws Exception { - Main.main(new String[]{"--version"}); - } -} |