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



Author: walters
Date: Sun Oct 19 20:58:21 2008
New Revision: 90
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=90&view=rev

Log:
Add fromJava method to GValue


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

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	Sun Oct 19 20:58:21 2008
@@ -271,6 +271,9 @@
             return DOUBLE;
         } else if (String.class == javaType) {
             return STRING;
+        } else if (GObject.class.isAssignableFrom(javaType) 
+        		|| GObject.GObjectProxy.class.isAssignableFrom(javaType)) {
+        	return OBJECT;
         } else {
             throw new IllegalArgumentException("No GType for " + javaType);
         }

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	Sun Oct 19 20:58:21 2008
@@ -65,6 +65,13 @@
         GValueAPI.gvalue.g_value_init(this, type);
 	}
 	
+	public static GValue fromJava(Object obj) {
+		GType type = GType.valueOf(obj.getClass());
+		GValue val = new GValue(type);
+		val.set(obj);
+		return val;
+	}
+	
 	/* public for GTypeValueTable methods */
 	public static class GValueData extends com.sun.jna.Union {
 		public volatile int v_int;



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