aboutsummaryrefslogtreecommitdiffstats
path: root/doc/manual/example5
diff options
context:
space:
mode:
Diffstat (limited to 'doc/manual/example5')
-rw-r--r--doc/manual/example5/function.c16
-rw-r--r--doc/manual/example5/function.cfg9
-rw-r--r--doc/manual/example5/function.h8
-rw-r--r--doc/manual/example5/gen.sh17
4 files changed, 50 insertions, 0 deletions
diff --git a/doc/manual/example5/function.c b/doc/manual/example5/function.c
new file mode 100644
index 0000000..457b4a4
--- /dev/null
+++ b/doc/manual/example5/function.c
@@ -0,0 +1,16 @@
+static ScreenInfo default;
+static int initialized = 0;
+
+ScreenInfo* default_screen_depth() {
+ if (!initialized) {
+ default.redBits = 8;
+ default.greenBits = 8;
+ default.blueBits = 8;
+ initialized = 1;
+ }
+ return &default;
+}
+
+void set_screen_depth(ScreenInfo* info) {
+ /* Do something ... */
+}
diff --git a/doc/manual/example5/function.cfg b/doc/manual/example5/function.cfg
new file mode 100644
index 0000000..cb158ca
--- /dev/null
+++ b/doc/manual/example5/function.cfg
@@ -0,0 +1,9 @@
+Package testfunction
+Style AllStatic
+JavaClass TestFunction
+JavaOutputDir gensrc/java
+NativeOutputDir gensrc/native
+
+# Tell GlueGen that default_screen_depth() returns a pointer to a
+# single ScreenInfo
+ReturnValueCapacity default_screen_depth sizeof(ScreenInfo)
diff --git a/doc/manual/example5/function.h b/doc/manual/example5/function.h
new file mode 100644
index 0000000..d845887
--- /dev/null
+++ b/doc/manual/example5/function.h
@@ -0,0 +1,8 @@
+typedef struct {
+ int redBits;
+ int greenBits;
+ int blueBits;
+} ScreenInfo;
+
+ScreenInfo* default_screen_depth();
+void set_screen_depth(ScreenInfo* info);
diff --git a/doc/manual/example5/gen.sh b/doc/manual/example5/gen.sh
new file mode 100644
index 0000000..6fb971e
--- /dev/null
+++ b/doc/manual/example5/gen.sh
@@ -0,0 +1,17 @@
+#!/bin/ksh
+
+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