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



Author: walters
Date: Tue Sep  9 19:13:33 2008
New Revision: 48
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=48&view=rev

Log:
Extend GList/GSList APIs to allow some access


Modified:
   trunk/src/org/gnome/gir/gobject/GList.java
   trunk/src/org/gnome/gir/gobject/GSList.java
   trunk/src/org/gnome/gir/gobject/GlibAPI.java

Modified: trunk/src/org/gnome/gir/gobject/GList.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/GList.java	(original)
+++ trunk/src/org/gnome/gir/gobject/GList.java	Tue Sep  9 19:13:33 2008
@@ -1,7 +1,29 @@
 package org.gnome.gir.gobject;
 
-import com.sun.jna.PointerType;
+import java.util.ArrayList;
+import java.util.List;
 
-public class GList extends PointerType {
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+
+public abstract class GList extends Structure {
+	public static class ByReference extends GList implements Structure.ByReference {};
+	
+	public Pointer data;
+	public GList.ByReference next;
+	public GList.ByReference prev;	
+	
+	public List<Pointer> copy() {
+		List<Pointer> ret = new ArrayList<Pointer>();
+		GList list = this;
+		while (list.next != null) {
+			ret.add(list.data);
+			list = list.next;
+		}
+		return ret;
+	}
 	
+	public void free() {
+		GlibAPI.glib.g_list_free(this);
+	}
 }

Modified: trunk/src/org/gnome/gir/gobject/GSList.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/GSList.java	(original)
+++ trunk/src/org/gnome/gir/gobject/GSList.java	Tue Sep  9 19:13:33 2008
@@ -1,7 +1,28 @@
 package org.gnome.gir.gobject;
 
-import com.sun.jna.PointerType;
+import java.util.ArrayList;
+import java.util.List;
 
-public class GSList extends PointerType {
+import com.sun.jna.Pointer;
+import com.sun.jna.Structure;
+
+public class GSList extends Structure {
+	public static class ByReference extends GSList implements Structure.ByReference {};
+	
+	public Pointer data;
+	public GSList.ByReference next;
+	
+	public List<Pointer> copy() {
+		List<Pointer> ret = new ArrayList<Pointer>();
+		GSList list = this;
+		while (list.next != null) {
+			ret.add(list.data);
+			list = list.next;
+		}
+		return ret;
+	}
 	
+	public void free() {
+		GlibAPI.glib.g_slist_free(this);
+	}	
 }

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	Tue Sep  9 19:13:33 2008
@@ -159,28 +159,7 @@
     int g_log_set_handler(String log_domain, int levels, GLogFunc handler, Pointer user_data);
     void g_log_default_handler (String log_domain, int log_level, String message, Pointer unused_data);    
     Pointer g_log_set_default_handler(GLogFunc log_func, Pointer user_data);    
-    
-    public final static class GList extends com.sun.jna.Structure {
-        public volatile Pointer data;
-        public volatile Pointer _next;
-        public volatile Pointer _prev;
-        public GList() {            
-        }
-        private GList(Pointer pointer) {
-            useMemory(pointer);
-            read();
-        }
-        private static GList valueOf(Pointer ptr) {
-            return ptr != null ? new GList(ptr) : null;
-        }
-        public GList next() {
-            return valueOf(_next);
-        }
-        public GList prev() {
-            return valueOf(_prev);
-        }
-    }
-    
+
     public static final class GMutex extends Structure {
     	
     }
@@ -212,5 +191,8 @@
       public GStaticMutex mutex;
       public int depth;
       public GSystemThread owner;
-    };
+    }
+    
+	void g_list_free(GList list);
+	void g_slist_free(GSList list);	
 }



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