java-gobject-introspection r129 - in trunk/src/org/gnome/gir: gobject repository
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection r129 - in trunk/src/org/gnome/gir: gobject repository
- Date: Mon, 17 Nov 2008 04:54:36 +0000 (UTC)
Author: walters
Date: Mon Nov 17 04:54:35 2008
New Revision: 129
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=129&view=rev
Log:
Fix up unref for GObject, add missing BaseInfo conversions
Modified:
trunk/src/org/gnome/gir/gobject/NativeObject.java
trunk/src/org/gnome/gir/repository/BaseInfo.java
Modified: trunk/src/org/gnome/gir/gobject/NativeObject.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/NativeObject.java (original)
+++ trunk/src/org/gnome/gir/gobject/NativeObject.java Mon Nov 17 04:54:35 2008
@@ -51,9 +51,7 @@
import java.lang.reflect.Modifier;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.gnome.gir.gobject.GObjectAPI.GObjectStruct;
import org.gnome.gir.repository.BaseInfo;
import com.sun.jna.Pointer;
@@ -166,18 +164,21 @@
return null;
}
NativeObject obj = null;
- if (BaseInfo.class.isAssignableFrom(cls))
+ if (BaseInfo.class.isAssignableFrom(cls)) {
obj = BaseInfo.newInstanceFor(ptr);
- else if (GObject.class.isAssignableFrom(cls) || GObject.GObjectProxy.class.isAssignableFrom(cls))
+ if (obj != null && ownsRef)
+ ((RefCountedObject) obj).unref();
+ } else if (GObject.class.isAssignableFrom(cls) || GObject.GObjectProxy.class.isAssignableFrom(cls)) {
obj = Internals.instanceFor(ptr);
- if (obj != null && cls.isInstance(obj)) {
- if (ownsRef) {
- ((RefCountedObject) obj).unref(); // Lose the extra ref that we expect functions to add by default
- }
+ if (obj != null && ownsRef)
+ GObjectAPI.gobj.g_object_unref((GObject)obj);
+ }
+ if (obj != null) {
+ if (!cls.isInstance(obj))
+ throw new RuntimeException(String.format("returned obj %s (%s) not instanceof %s", obj, obj.getClass(), cls));
return cls.cast(obj);
}
-
/* Special-case GObject.GObjectProxy here - these are interface values
* for which we don't know of a current concrete class.
*/
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 Mon Nov 17 04:54:35 2008
@@ -27,6 +27,12 @@
return new FieldInfo(init);
if (itype == InfoType.OBJECT.ordinal())
return new ObjectInfo(init);
+ if (itype == InfoType.ARG.ordinal())
+ return new ArgInfo(init);
+ if (itype == InfoType.VALUE.ordinal())
+ return new ValueInfo(init);
+ if (itype == InfoType.SIGNAL.ordinal())
+ return new SignalInfo(init);
if (itype == InfoType.FUNCTION.ordinal())
return new FunctionInfo(init);
if (itype == InfoType.STRUCT.ordinal())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]