summaryrefslogtreecommitdiffstats
path: root/doc/manual/example2
diff options
context:
space:
mode:
Diffstat (limited to 'doc/manual/example2')
-rw-r--r--doc/manual/example2/function.c17
-rw-r--r--doc/manual/example2/function.cfg9
-rw-r--r--doc/manual/example2/function.h3
-rw-r--r--doc/manual/example2/gen.sh17
4 files changed, 46 insertions, 0 deletions
diff --git a/doc/manual/example2/function.c b/doc/manual/example2/function.c
new file mode 100644
index 0000000..159ddb7
--- /dev/null
+++ b/doc/manual/example2/function.c
@@ -0,0 +1,17 @@
+float process_data(float* data, int n) {
+ int i;
+ float sum;
+ for (i = 0; i < n; i++) {
+ sum += data[i];
+ }
+ return sum;
+}
+
+float* global_data;
+void set_global_data(float* data) {
+ global_data = data;
+}
+
+float process_global_data(int n) {
+ return process_data(global_data, n);
+}
diff --git a/doc/manual/example2/function.cfg b/doc/manual/example2/function.cfg
new file mode 100644
index 0000000..91d379b
--- /dev/null
+++ b/doc/manual/example2/function.cfg
@@ -0,0 +1,9 @@
+Package testfunction
+Style AllStatic
+JavaClass TestFunction
+JavaOutputDir gensrc/java
+NativeOutputDir gensrc/native
+
+# The semantics of set_global_data imply that
+# only direct Buffers are legal
+NioDirectOnly set_global_data
diff --git a/doc/manual/example2/function.h b/doc/manual/example2/function.h
new file mode 100644
index 0000000..af14bd2
--- /dev/null
+++ b/doc/manual/example2/function.h
@@ -0,0 +1,3 @@
+float process_data(float* data, int n);
+void set_global_data(float* data);
+float process_global_data(int n);
diff --git a/doc/manual/example2/gen.sh b/doc/manual/example2/gen.sh
new file mode 100644
index 0000000..3310b06
--- /dev/null
+++ b/doc/manual/example2/gen.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+JAVA=java
+GLUEGEN_JAR=../../../build/gluegen.jar
+ANTLR_JAR=../../../../../ANTLR/antlr-2.7.4/antlr.jar
+
+NAME=`uname`
+
+if [ $NAME="Windows*" ] ; then
+ SEP=\;
+elif [ $NAME="CYGWIN*" ] ; then
+ SEP=\;
+else
+ SEP=:
+fi
+
+java -cp $GLUEGEN_JAR$SEP$ANTLR_JAR com.sun.gluegen.GlueGen -I. -Ecom.sun.gluegen.JavaEmitter -Cfunction.cfg function.h