java-gobject-introspection r40 - in trunk/src/org/gnome/gir: compiler gobject
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection r40 - in trunk/src/org/gnome/gir: compiler gobject
- Date: Mon, 8 Sep 2008 16:41:02 +0000 (UTC)
Author: walters
Date: Mon Sep 8 16:41:02 2008
New Revision: 40
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=40&view=rev
Log:
Bind some more things for Soup; write out functions even for no-field structures
Added:
trunk/src/org/gnome/gir/gobject/GHashTable.java
trunk/src/org/gnome/gir/gobject/GIOFunc.java
trunk/src/org/gnome/gir/gobject/GThreadAPI.java
Modified:
trunk/src/org/gnome/gir/compiler/CodeFactory.java
trunk/src/org/gnome/gir/gobject/BoxedStructure.java
trunk/src/org/gnome/gir/gobject/BoxedUnion.java
trunk/src/org/gnome/gir/gobject/GObjectGlobals.java
trunk/src/org/gnome/gir/gobject/GType.java
trunk/src/org/gnome/gir/gobject/GlibAPI.java
Modified: trunk/src/org/gnome/gir/compiler/CodeFactory.java
==============================================================================
--- trunk/src/org/gnome/gir/compiler/CodeFactory.java (original)
+++ trunk/src/org/gnome/gir/compiler/CodeFactory.java Mon Sep 8 16:41:02 2008
@@ -1280,56 +1280,71 @@
(isRegistered ? "org/gnome/gir/gobject/Boxed" : "com/sun/jna/") + type, null);
} else {
compilation.writer.visit(V1_6, ACC_PUBLIC + ACC_SUPER, internalName, null,
- "com/sun/jna/Pointer", null);
- return;
+ "com/sun/jna/PointerType", null);
+ /* Write out a no-args ctor, though people shouldn't use this */
+ MethodVisitor mv = compilation.writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "com/sun/jna/PointerType", "<init>", "()V");
+ mv.visitInsn(RETURN);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLocalVariable("this", "L" + compilation.internalName + ";", null, l0, l1, 0);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
}
- if (isRegistered)
+ if (hasFields && isRegistered)
writeGetGType(info, compilation);
- InnerClassCompilation byRef = compilation.newInner("ByReference");
- compilation.writer.visitInnerClass(compilation.internalName + "$ByReference",
- compilation.internalName, "ByReference", ACC_PUBLIC + ACC_STATIC);
- byRef.writer.visit(V1_6, ACC_PUBLIC + ACC_STATIC,
- byRef.internalName, null, compilation.internalName, new String[] { "com/sun/jna/Structure$ByReference"});
- writeStructUnionInnerCtor(byRef, internalName);
-
- InnerClassCompilation byValue = compilation.newInner("ByValue");
- compilation.writer.visitInnerClass(compilation.internalName + "$ByValue",
- compilation.internalName, "ByValue", ACC_PUBLIC + ACC_STATIC);
- byValue.writer.visit(V1_6, ACC_PUBLIC + ACC_STATIC,
- byValue.internalName, null, compilation.internalName, new String[] { "com/sun/jna/Structure$ByValue"});
- writeStructUnionInnerCtor(byValue, internalName);
-
- /* constructor; public no-args and protected TypeMapper */
- MethodVisitor mv = compilation.writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
- mv.visitCode();
- Label l0 = new Label();
- mv.visitLabel(l0);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitMethodInsn(INVOKESTATIC, "org/gnome/gir/gobject/GTypeMapper", "getInstance", "()Lorg/gnome/gir/gobject/GTypeMapper;");
- mv.visitMethodInsn(INVOKESPECIAL, "com/sun/jna/" + type, "<init>", "(Lcom/sun/jna/TypeMapper;)V");
- mv.visitInsn(RETURN);
- Label l1 = new Label();
- mv.visitLabel(l1);
- mv.visitLocalVariable("this", "L" + compilation.internalName + ";", null, l0, l1, 0);
- mv.visitMaxs(2, 1);
- mv.visitEnd();
-
- mv = compilation.writer.visitMethod(ACC_PROTECTED, "<init>", "(Lcom/sun/jna/TypeMapper;)V", null, null);
- mv.visitCode();
- l0 = new Label();
- mv.visitLabel(l0);
- mv.visitVarInsn(ALOAD, 0);
- mv.visitVarInsn(ALOAD, 1);
- mv.visitMethodInsn(INVOKESPECIAL, "com/sun/jna/" + type, "<init>", "(Lcom/sun/jna/TypeMapper;)V");
- mv.visitInsn(RETURN);
- l1 = new Label();
- mv.visitLabel(l1);
- mv.visitLocalVariable("this", "L" + compilation.internalName + ";", null, l0, l1, 0);
- mv.visitLocalVariable("mapper", "Lcom/sun/jna/TypeMapper;", null, l0, l1, 0);
- mv.visitMaxs(2, 2);
- mv.visitEnd();
+ if (hasFields) {
+ InnerClassCompilation byRef = compilation.newInner("ByReference");
+ compilation.writer.visitInnerClass(compilation.internalName + "$ByReference", compilation.internalName,
+ "ByReference", ACC_PUBLIC + ACC_STATIC);
+ byRef.writer.visit(V1_6, ACC_PUBLIC + ACC_STATIC, byRef.internalName, null, compilation.internalName,
+ new String[] { "com/sun/jna/Structure$ByReference" });
+ writeStructUnionInnerCtor(byRef, internalName);
+
+ InnerClassCompilation byValue = compilation.newInner("ByValue");
+ compilation.writer.visitInnerClass(compilation.internalName + "$ByValue", compilation.internalName,
+ "ByValue", ACC_PUBLIC + ACC_STATIC);
+ byValue.writer.visit(V1_6, ACC_PUBLIC + ACC_STATIC, byValue.internalName, null, compilation.internalName,
+ new String[] { "com/sun/jna/Structure$ByValue" });
+ writeStructUnionInnerCtor(byValue, internalName);
+
+ /* constructor; public no-args and protected TypeMapper */
+ MethodVisitor mv = compilation.writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+ mv.visitCode();
+ Label l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESTATIC, "org/gnome/gir/gobject/GTypeMapper", "getInstance",
+ "()Lorg/gnome/gir/gobject/GTypeMapper;");
+ mv.visitMethodInsn(INVOKESPECIAL, "com/sun/jna/" + type, "<init>", "(Lcom/sun/jna/TypeMapper;)V");
+ mv.visitInsn(RETURN);
+ Label l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLocalVariable("this", "L" + compilation.internalName + ";", null, l0, l1, 0);
+ mv.visitMaxs(2, 1);
+ mv.visitEnd();
+
+ mv = compilation.writer.visitMethod(ACC_PROTECTED, "<init>", "(Lcom/sun/jna/TypeMapper;)V", null, null);
+ mv.visitCode();
+ l0 = new Label();
+ mv.visitLabel(l0);
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitVarInsn(ALOAD, 1);
+ mv.visitMethodInsn(INVOKESPECIAL, "com/sun/jna/" + type, "<init>", "(Lcom/sun/jna/TypeMapper;)V");
+ mv.visitInsn(RETURN);
+ l1 = new Label();
+ mv.visitLabel(l1);
+ mv.visitLocalVariable("this", "L" + compilation.internalName + ";", null, l0, l1, 0);
+ mv.visitLocalVariable("mapper", "Lcom/sun/jna/TypeMapper;", null, l0, l1, 0);
+ mv.visitMaxs(2, 2);
+ mv.visitEnd();
+ }
Set<String> sigs = new HashSet<String>();
for (FunctionInfo fi : methods) {
Modified: trunk/src/org/gnome/gir/gobject/BoxedStructure.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/BoxedStructure.java (original)
+++ trunk/src/org/gnome/gir/gobject/BoxedStructure.java Mon Sep 8 16:41:02 2008
@@ -29,4 +29,9 @@
free();
super.finalize();
}
+
+ @Override
+ public String toString() {
+ return GObjectAPI.gobj.g_type_name(GType.of(this.getClass())) + "(" + super.toString() + ")";
+ }
}
Modified: trunk/src/org/gnome/gir/gobject/BoxedUnion.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/BoxedUnion.java (original)
+++ trunk/src/org/gnome/gir/gobject/BoxedUnion.java Mon Sep 8 16:41:02 2008
@@ -29,4 +29,9 @@
free();
super.finalize();
}
+
+ @Override
+ public String toString() {
+ return GObjectAPI.gobj.g_type_name(GType.of(this.getClass())) + "(" + super.toString() + ")";
+ }
}
Added: trunk/src/org/gnome/gir/gobject/GHashTable.java
==============================================================================
--- (empty file)
+++ trunk/src/org/gnome/gir/gobject/GHashTable.java Mon Sep 8 16:41:02 2008
@@ -0,0 +1,6 @@
+package org.gnome.gir.gobject;
+
+
+public class GHashTable extends GBoxed {
+
+}
Added: trunk/src/org/gnome/gir/gobject/GIOFunc.java
==============================================================================
--- (empty file)
+++ trunk/src/org/gnome/gir/gobject/GIOFunc.java Mon Sep 8 16:41:02 2008
@@ -0,0 +1,9 @@
+package org.gnome.gir.gobject;
+
+import com.sun.jna.Callback;
+import com.sun.jna.Pointer;
+
+
+public interface GIOFunc extends Callback {
+ public void callback(Pointer source, int condition, Pointer data);
+}
Modified: trunk/src/org/gnome/gir/gobject/GObjectGlobals.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/GObjectGlobals.java (original)
+++ trunk/src/org/gnome/gir/gobject/GObjectGlobals.java Mon Sep 8 16:41:02 2008
@@ -48,6 +48,7 @@
}
GlibAPI.glib.g_log_set_default_handler(handler, null);
+ GThreadAPI.gthread.g_thread_init(null);
GObjectAPI.gobj.g_type_init();
initialized = true;
}
Added: trunk/src/org/gnome/gir/gobject/GThreadAPI.java
==============================================================================
--- (empty file)
+++ trunk/src/org/gnome/gir/gobject/GThreadAPI.java Mon Sep 8 16:41:02 2008
@@ -0,0 +1,18 @@
+package org.gnome.gir.gobject;
+import java.util.HashMap;
+
+import com.sun.jna.Library;
+import com.sun.jna.Pointer;
+
+/**
+ *
+ */
+public interface GThreadAPI extends Library {
+ static GThreadAPI gthread = GNative.loadLibrary("gthread-2.0", GThreadAPI.class, new HashMap<String, Object>() {
+ private static final long serialVersionUID = 1L;
+ {
+ put(Library.OPTION_TYPE_MAPPER, new GTypeMapper());
+ }
+ });
+ void g_thread_init(Pointer funcs);
+}
Modified: trunk/src/org/gnome/gir/gobject/GType.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/GType.java (original)
+++ trunk/src/org/gnome/gir/gobject/GType.java Mon Sep 8 16:41:02 2008
@@ -73,6 +73,7 @@
put("GLib.List", "org/gnome/gir/gobject/GList");
put("GLib.SList", "org/gnome/gir/gobject/GSList");
+ put("GLib.MainContext", "org/gnome/gir/gobject/GMainContext");
put("GLib.Closure", "org/gnome/gir/gobject/GClosure");
put("GLib.Quark", "org/gnome/gir/gobject/GQuark");
put("GLib.TimeVal", "org/gnome/gir/gobject/GTimeVal");
@@ -83,11 +84,12 @@
put("GLib.String", "org/gnome/gir/gobject/GString");
put("GLib.Callback", "com/sun/jna/Callback");
put("GLib.Mutex", "org/gnome/gir/gobject/GLibAPI$GMutex");
- put("GLib.StaticRecMutex", "org/gnome/gir/gobject/GLibAPI$GStaticRecMutex");
+ put("GLib.StaticRecMutex", "org/gnome/gir/gobject/GLibAPI$GStaticRecMutex");
+ put("GLib.IOFunc", "org/gnome/gir/gobject/GIOFunc");
String[] glibPointerUnmapped = new String[] { "Mutex", "Cond", "FreeFunc", "DestroyNotify", "MarkupParser",
"SpawnChildSetupFunc", "SourceFunc", "Node", "CompareFunc", "KeyFile", "PtrArray", "Func",
- "ThreadPool", "Source", "CompareDataFunc", "Array" };
+ "ThreadPool", "Source", "CompareDataFunc", "Array", "Data", "DataSet" };
for (String unmapped : glibPointerUnmapped)
put("GLib." + unmapped, "com/sun/jna/Pointer");
String[] glibIntegerUnmapped = new String[] { "SpawnFlags", "SeekType", };
@@ -113,6 +115,7 @@
put("GObject.TypeInstance", "org/gnome/gir/gobject/GObjectAPI$GTypeInstance");
put("GObject.TypeInterface", "org/gnome/gir/gobject/GObjectAPI$GTypeInterface");
put("GObject.String", "org/gnome/gir/gobject/GString");
+ put("GObject.HashTable", "org/gnome/gir/gobject/GHashTable");
put("GObject.Closure", "org/gnome/gir/gobject/GClosure");
put("GObject.SignalInvocationHint", "org/gnome/gir/gobject/GSignalAPI$GSignalInvocationHint");
put("GObject.EnumValue", "org/gnome/gir/gobject/GObjectAPI$GEnumValue");
@@ -122,7 +125,7 @@
String[] gobjectUnmapped = new String[] { "Callback", "BaseInitFunc", "InstanceInitFunc",
"SignalAccumulator", "ClosureMarshal", "ClassInitFunc", "SignalEmissionHook",
- "IOChannel", "Date", "BaseFinalizeFunc", "ClassFinalizeFunc" };
+ "IOChannel", "Date", "BaseFinalizeFunc", "ClassFinalizeFunc", "ValueArray" };
for (String unmapped : gobjectUnmapped)
put("GObject." + unmapped, "com/sun/jna/Pointer");
String[] gobjectIntegerUnmapped = new String[] { "SignalFlags", "ConnectFlags", "SignalMatchType",
Modified: trunk/src/org/gnome/gir/gobject/GlibAPI.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/GlibAPI.java (original)
+++ trunk/src/org/gnome/gir/gobject/GlibAPI.java Mon Sep 8 16:41:02 2008
@@ -106,6 +106,7 @@
interface GThreadFunc extends Callback {
Pointer callback(Pointer data);
}
+ void g_thread_init(Pointer funcs);
Pointer g_thread_create(GThreadFunc func, Pointer data, boolean joinable, PointerByReference error);
Pointer g_thread_self();
Pointer g_thread_join(Pointer thread);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]