java-gobject-introspection r101 - trunk/src/org/gnome/gir/gobject



Author: walters
Date: Tue Oct 21 05:20:32 2008
New Revision: 101
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=101&view=rev

Log:
Ensure we write/read boxed structures across GValue transitions


Modified:
   trunk/src/org/gnome/gir/gobject/GBoxed.java
   trunk/src/org/gnome/gir/gobject/GValue.java

Modified: trunk/src/org/gnome/gir/gobject/GBoxed.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/GBoxed.java	(original)
+++ trunk/src/org/gnome/gir/gobject/GBoxed.java	Tue Oct 21 05:20:32 2008
@@ -2,18 +2,31 @@
 
 import com.sun.jna.Pointer;
 import com.sun.jna.PointerType;
+import com.sun.jna.Structure;
 
 public abstract class GBoxed extends PointerType implements RegisteredType {
 	public static Pointer getPointerFor(Object data) {
 		Pointer ptr;
-		if (data instanceof BoxedStructure)
+		/* Since we're denaturing it here, we need to ensure that the structure
+		 * is written to native memory.
+		 */
+		if (data instanceof BoxedStructure) {
 			ptr = ((BoxedStructure) data).getPointer();
-		else if (data instanceof BoxedUnion)
-			ptr = ((BoxedUnion) data).getPointer();
-		else if (data instanceof GBoxed)
+		} else if (data instanceof BoxedUnion) {
+			ptr = ((BoxedUnion) data).getPointer();	
+		} else if (data instanceof GBoxed) {
 			ptr = ((GBoxed) data).getPointer();
-		else	
+		} else {	
 			throw new RuntimeException("Invalid unboxed object " + data);
+		}
+		if (data instanceof Structure)
+			((Structure) data).write();		
 		return ptr;
 	}
+	
+	public static void postInvokeRead(Object data) {
+		if (!(data instanceof Structure))
+			return;
+		((Structure) data).read();
+	}
 }

Modified: trunk/src/org/gnome/gir/gobject/GValue.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/GValue.java	(original)
+++ trunk/src/org/gnome/gir/gobject/GValue.java	Tue Oct 21 05:20:32 2008
@@ -211,6 +211,7 @@
 			return GValueAPI.gvalue.g_value_get_string(this);
 		} else if (fundamental.equals(GType.OBJECT)) {
 			return GValueAPI.gvalue.g_value_dup_object(this);
+			/* FIXME implement boxed mapping */
 		} else if (GValueAPI.gvalue.g_value_type_transformable(g_type, GType.OBJECT)) {
 			return GValueAPI.gvalue.g_value_dup_object(transform(this, GType.OBJECT));
 		} else if (GValueAPI.gvalue.g_value_type_transformable(g_type, GType.INT)) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]