java-gobject-introspection r86 - trunk/src/org/gnome/gir/repository



Author: walters
Date: Sat Oct 18 21:45:59 2008
New Revision: 86
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=86&view=rev

Log:
Clean up some APIs, implement equals()/hashCode for BaseInfo, add name caching


Modified:
   trunk/src/org/gnome/gir/repository/BaseInfo.java
   trunk/src/org/gnome/gir/repository/GIntrospectionAPI.java
   trunk/src/org/gnome/gir/repository/InterfaceInfo.java
   trunk/src/org/gnome/gir/repository/ObjectInfo.java

Modified: trunk/src/org/gnome/gir/repository/BaseInfo.java
==============================================================================
--- trunk/src/org/gnome/gir/repository/BaseInfo.java	(original)
+++ trunk/src/org/gnome/gir/repository/BaseInfo.java	Sat Oct 18 21:45:59 2008
@@ -5,6 +5,8 @@
 import com.sun.jna.Pointer;
 
 public class BaseInfo extends RefCountedObject {
+	private String cachedNamespace = null;
+	private String cachedName = null;
 	protected BaseInfo(Initializer init) {
 		super(init);
 	}
@@ -53,7 +55,9 @@
 	}
 	
 	public String getName() {
-		return Repository.getNativeLibrary().g_base_info_get_name(this.handle());		
+		if (cachedName == null)
+			cachedName = Repository.getNativeLibrary().g_base_info_get_name(this.handle());
+		return cachedName;
 	}
 
 	@Override
@@ -62,7 +66,9 @@
 	}
 
 	public String getNamespace() {
-		return GIntrospectionAPI.gi.g_base_info_get_namespace(this.handle());
+		if (cachedNamespace == null)
+			cachedNamespace = GIntrospectionAPI.gi.g_base_info_get_namespace(this.handle());
+		return cachedNamespace;
 	}
 	
 	public String toString() {
@@ -72,4 +78,21 @@
 	public boolean isDeprecated() {
 		return GIntrospectionAPI.gi.g_base_info_is_deprecated(this);
 	}
+
+	@Override
+	public boolean equals(Object o) {
+		if (!(o instanceof BaseInfo))
+			return super.equals(o);
+		BaseInfo bo = (BaseInfo) o;
+		return getNamespace().equals(bo.getNamespace())
+			&& getName().equals(bo.getName());
+	}
+
+	@Override
+	public int hashCode() {
+		int hash = 1;
+		hash += 31 * getNamespace().hashCode();
+		hash += 31 * getName().hashCode();
+		return hash;
+	}
 }

Modified: trunk/src/org/gnome/gir/repository/GIntrospectionAPI.java
==============================================================================
--- trunk/src/org/gnome/gir/repository/GIntrospectionAPI.java	(original)
+++ trunk/src/org/gnome/gir/repository/GIntrospectionAPI.java	Sat Oct 18 21:45:59 2008
@@ -146,7 +146,7 @@
 	
 	String          g_object_info_get_type_name 	    (ObjectInfo    info);
 	String          g_object_info_get_type_init 	    (ObjectInfo    info);
-	BaseInfo        g_object_info_get_parent             (ObjectInfo    info);
+	ObjectInfo      g_object_info_get_parent             (ObjectInfo    info);
 	int                   g_object_info_get_n_interfaces      (ObjectInfo    info);
 	InterfaceInfo       g_object_info_get_interface          (ObjectInfo    info,
 								     int            n);
@@ -172,7 +172,7 @@
 								     int            n);
 	
 	int                   g_interface_info_get_n_prerequisites (InterfaceInfo info);
-	BaseInfo           g_interface_info_get_prerequisite    (InterfaceInfo info,
+	InterfaceInfo           g_interface_info_get_prerequisite    (InterfaceInfo info,
 								     int        n);
 	int                   g_interface_info_get_n_properties    (InterfaceInfo info);
 	PropertyInfo       g_interface_info_get_property        (InterfaceInfo info,

Modified: trunk/src/org/gnome/gir/repository/InterfaceInfo.java
==============================================================================
--- trunk/src/org/gnome/gir/repository/InterfaceInfo.java	(original)
+++ trunk/src/org/gnome/gir/repository/InterfaceInfo.java	Sat Oct 18 21:45:59 2008
@@ -6,9 +6,9 @@
 		super(init);
 	}
 	
-	public BaseInfo[] getPrerequisites() {
+	public InterfaceInfo[] getPrerequisites() {
 		int n = GIntrospectionAPI.gi.g_interface_info_get_n_prerequisites(this);
-		BaseInfo[] ret= new BaseInfo[n];
+		InterfaceInfo[] ret= new InterfaceInfo[n];
 		for (int i = 0; i < n; i++)
 			ret[i] = GIntrospectionAPI.gi.g_interface_info_get_prerequisite(this, i);
 		return ret;

Modified: trunk/src/org/gnome/gir/repository/ObjectInfo.java
==============================================================================
--- trunk/src/org/gnome/gir/repository/ObjectInfo.java	(original)
+++ trunk/src/org/gnome/gir/repository/ObjectInfo.java	Sat Oct 18 21:45:59 2008
@@ -10,7 +10,7 @@
 		return GIntrospectionAPI.gi.g_object_info_get_type_name(this);
 	}
 	
-	public BaseInfo getParent() {
+	public ObjectInfo getParent() {
 		return GIntrospectionAPI.gi.g_object_info_get_parent(this);
 	}
 	



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