summaryrefslogtreecommitdiffstats
path: root/doc/manual/example6
diff options
context:
space:
mode:
Diffstat (limited to 'doc/manual/example6')
-rw-r--r--doc/manual/example6/function.cfg25
-rw-r--r--doc/manual/example6/function.h23
-rw-r--r--doc/manual/example6/gen.sh17
3 files changed, 65 insertions, 0 deletions
diff --git a/doc/manual/example6/function.cfg b/doc/manual/example6/function.cfg
new file mode 100644
index 0000000..c94e856
--- /dev/null
+++ b/doc/manual/example6/function.cfg
@@ -0,0 +1,25 @@
+Package testfunction
+Style AllStatic
+JavaClass TestFunction
+JavaOutputDir gensrc/java
+NativeOutputDir gensrc/native
+
+# Get returned array's capacity from XGetVisualInfo to be correct
+TemporaryCVariableDeclaration XGetVisualInfo int count;
+TemporaryCVariableAssignment XGetVisualInfo count = _ptr3[0];
+ReturnValueCapacity XGetVisualInfo count * sizeof(XVisualInfo)
+
+# Helper routine to make the ReturnedArrayLength expression below work correctly
+CustomJavaCode TestFunction private static int getFirstElement(IntBuffer buf) { return buf.get(buf.position()); }
+CustomJavaCode TestFunction private static int getFirstElement(int[] arr, int offset) { return arr[offset]; }
+ReturnedArrayLength XGetVisualInfo getFirstElement({3})
+
+# We don't need the Display and Visual data structures to be
+# explicitly exposed
+Opaque long Display *
+Opaque long Visual *
+# Ignore the empty Display and Visual data structures (though made
+# opaque, the references from XVisualInfo and elsewhere are still
+# traversed)
+Ignore Display
+Ignore Visual
diff --git a/doc/manual/example6/function.h b/doc/manual/example6/function.h
new file mode 100644
index 0000000..0517471
--- /dev/null
+++ b/doc/manual/example6/function.h
@@ -0,0 +1,23 @@
+typedef struct {} Display;
+typedef struct {} Visual;
+typedef unsigned long VisualID;
+
+typedef struct {
+ Visual *visual;
+ VisualID visualid;
+ int screen;
+ int depth;
+ int c_class; /* C++ */
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ int colormap_size;
+ int bits_per_rgb;
+} XVisualInfo;
+
+XVisualInfo *XGetVisualInfo(
+ Display* /* display */,
+ long /* vinfo_mask */,
+ XVisualInfo* /* vinfo_template */,
+ int* /* nitems_return */
+);
diff --git a/doc/manual/example6/gen.sh b/doc/manual/example6/gen.sh
new file mode 100644
index 0000000..6fb971e
--- /dev/null
+++ b/doc/manual/example6/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