aboutsummaryrefslogtreecommitdiffstats
path: root/doc/manual/example4
diff options
context:
space:
mode:
Diffstat (limited to 'doc/manual/example4')
-rw-r--r--doc/manual/example4/function.c10
-rw-r--r--doc/manual/example4/function.cfg12
-rw-r--r--doc/manual/example4/function.h2
-rw-r--r--doc/manual/example4/gen.sh17
4 files changed, 41 insertions, 0 deletions
diff --git a/doc/manual/example4/function.c b/doc/manual/example4/function.c
new file mode 100644
index 0000000..8666666
--- /dev/null
+++ b/doc/manual/example4/function.c
@@ -0,0 +1,10 @@
+#include <stdlib.h>
+#include <malloc.h>
+
+void* custom_allocate(int num_bytes) {
+ return malloc(num_bytes);
+}
+
+void custom_free(void* data) {
+ free(data);
+}
diff --git a/doc/manual/example4/function.cfg b/doc/manual/example4/function.cfg
new file mode 100644
index 0000000..feee635
--- /dev/null
+++ b/doc/manual/example4/function.cfg
@@ -0,0 +1,12 @@
+Package testfunction
+Style AllStatic
+JavaClass TestFunction
+JavaOutputDir gensrc/java
+NativeOutputDir gensrc/native
+
+# The length of the returned ByteBuffer from custom_allocate is
+# specified as the argument
+ReturnValueCapacity custom_allocate {0}
+
+# custom_free will only ever receive a direct Buffer
+NioDirectOnly custom_free
diff --git a/doc/manual/example4/function.h b/doc/manual/example4/function.h
new file mode 100644
index 0000000..8db77a1
--- /dev/null
+++ b/doc/manual/example4/function.h
@@ -0,0 +1,2 @@
+void* custom_allocate(int num_bytes);
+void custom_free(void* data);
diff --git a/doc/manual/example4/gen.sh b/doc/manual/example4/gen.sh
new file mode 100644
index 0000000..6fb971e
--- /dev/null
+++ b/doc/manual/example4/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