? autom4te.cache
? stamp-h1
? activation-server/test-performance
? bonobo-activation/bonobo-activation-2.0.pc
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libbonobo/ChangeLog,v
retrieving revision 1.387
diff -u -p -r1.387 ChangeLog
--- ChangeLog	14 Apr 2003 09:27:32 -0000	1.387
+++ ChangeLog	15 Apr 2003 22:35:51 -0000
@@ -1,3 +1,20 @@
+2003-04-15  Gustavo J. A. M. Carneiro  <gustavo@users.sourceforge.net>
+
+	* tests/test-object.c (main): A very lame excuse of a test of
+	BonoboForeignObject.
+
+	* bonobo/bonobo-foreign-object.h, bonobo/bonobo-foreign-object.c:
+	Implement BonoboForeignObject, which GObject-derives from
+	BonoboObject, and allows one to wrap an existing plain
+	CORBA_Object as a BonoboObject, as long as that object implements
+	the interface Bonobo::Unknown.
+
+	* bonobo/bonobo-object.c (bonobo_object_finalize_internal): Don't
+	call bonobo_object_corba_deactivate for BonoboForeignObject
+	instances.
+	(bonobo_object_instance_init): Don't call do_corba_setup for
+	BonoboForeignObject instances.
+
 2003-04-14  Michael Meeks  <michael@ximian.com>
 
 	* idl/Makefile.am (idl_flags): fix.
Index: bonobo/Makefile.am
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/Makefile.am,v
retrieving revision 1.70
diff -u -p -r1.70 Makefile.am
--- bonobo/Makefile.am	14 Apr 2003 09:27:33 -0000	1.70
+++ bonobo/Makefile.am	15 Apr 2003 22:35:51 -0000
@@ -71,6 +71,7 @@ libbonoboinclude_HEADERS =		\
 	bonobo-moniker-util.h		\
 	bonobo-moniker.h		\
 	bonobo-object.h			\
+	bonobo-foreign-object.h		\
 	bonobo-persist-file.h		\
 	bonobo-persist-stream.h		\
 	bonobo-persist.h		\
@@ -109,6 +110,7 @@ libbonobo_src =				\
 	bonobo-moniker-simple.c		\
 	bonobo-moniker-util.c		\
 	bonobo-object.c			\
+	bonobo-foreign-object.c		\
 	bonobo-persist-file.c		\
 	bonobo-persist-stream.c		\
 	bonobo-persist.c		\
Index: bonobo/bonobo-foreign-object.c
===================================================================
RCS file: bonobo/bonobo-foreign-object.c
diff -N bonobo/bonobo-foreign-object.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ bonobo/bonobo-foreign-object.c	15 Apr 2003 22:35:52 -0000
@@ -0,0 +1,79 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+#include <bonobo/bonobo-foreign-object.h>
+#include <bonobo/bonobo-exception.h>
+
+
+
+static void
+bonobo_foreign_object_class_init (BonoboForeignObjectClass *klass)
+{
+
+}
+
+
+static void
+bonobo_foreign_object_instance_init (GObject    *g_object,
+				     GTypeClass *klass)
+{
+
+}
+
+
+GType
+bonobo_foreign_object_get_type (void)
+{
+	static GType type = 0;
+
+	if (!type) {
+		GTypeInfo info = {
+			sizeof (BonoboForeignObjectClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) bonobo_foreign_object_class_init,
+			NULL, /* class_finalize */
+			NULL, /* class_data */
+			sizeof (BonoboForeignObject),
+			0, /* n_preallocs */
+			(GInstanceInitFunc) bonobo_foreign_object_instance_init
+		};
+		
+		type = g_type_register_static (BONOBO_TYPE_OBJECT, "BonoboForeignObject",
+					       &info, 0);
+	}
+
+	return type;
+}
+
+
+BonoboObject* bonobo_foreign_object_new (CORBA_Object corba_objref)
+{
+	BonoboObject *object;
+	CORBA_Environment ev;
+
+	g_return_val_if_fail (corba_objref != CORBA_OBJECT_NIL, NULL);
+
+	  /* The following type check is deactivated because
+	   * CORBA_Object_is_a doesn't seem to work correctly,
+	   * considering that it returns TRUE only if the object is
+	   * exactly of type Bonobo::Unknown, and FALSE if it is of a
+	   * derived type, while the CORBA spec says it should return
+	   * TRUE in both cases.  Perhaps there is a bug in ORBit?.. */
+#if 0
+	CORBA_exception_init (&ev);
+	if (!CORBA_Object_is_a (corba_objref, "IDL:Bonobo/Unknown:1.0", &ev)) {
+		if (ev._major != CORBA_NO_EXCEPTION)
+			g_warning ("CORBA_Object_is_a: %s",
+				   bonobo_exception_get_text (&ev));
+		else
+			g_warning ("bonobo_foreign_object_new: corba_objref"
+				   " doesn't have interface Bonobo::Unknown");
+		CORBA_exception_free (&ev);
+		return NULL;
+	}
+	CORBA_exception_free (&ev);
+#endif
+	object = BONOBO_OBJECT (g_type_create_instance (BONOBO_TYPE_FOREIGN_OBJECT));
+	object->corba_objref = CORBA_Object_duplicate (corba_objref, NULL);
+	return object;
+}
+
Index: bonobo/bonobo-foreign-object.h
===================================================================
RCS file: bonobo/bonobo-foreign-object.h
diff -N bonobo/bonobo-foreign-object.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ bonobo/bonobo-foreign-object.h	15 Apr 2003 22:35:52 -0000
@@ -0,0 +1,46 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+#ifndef _BONOBO_FOREIGN_OBJECT_H_
+#define _BONOBO_FOREIGN_OBJECT_H_
+
+#include <bonobo/bonobo-object.h>
+
+G_BEGIN_DECLS
+
+#define BONOBO_TYPE_FOREIGN_OBJECT         (bonobo_foreign_object_get_type ())
+
+#define BONOBO_FOREIGN_OBJECT(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o),\
+                                            BONOBO_TYPE_FOREIGN_OBJECT,\
+                                            BonoboForeignObject))
+
+#define BONOBO_FOREIGN_OBJECT_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k),\
+                                            BONOBO_TYPE_FOREIGN_OBJECT,\
+                                            BonoboForeignObjectClass))
+
+#define BONOBO_IS_FOREIGN_OBJECT(o)    	   (G_TYPE_CHECK_INSTANCE_TYPE ((o),\
+                                            BONOBO_TYPE_FOREIGN_OBJECT))
+
+#define BONOBO_IS_FOREIGN_OBJECT_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k),\
+                                            BONOBO_TYPE_FOREIGN_OBJECT))
+
+#define BONOBO_FOREIGN_OBJECT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),\
+					    BONOBO_TYPE_FOREIGN_OBJECT,\
+                                            BonoboForeignObjectClass))
+
+
+typedef struct _BonoboForeignObject BonoboForeignObject;
+
+
+struct _BonoboForeignObject {
+	BonoboObject base;
+};
+
+typedef struct {
+	BonoboObjectClass parent_class;
+} BonoboForeignObjectClass;
+
+GType         bonobo_foreign_object_get_type (void) G_GNUC_CONST;
+BonoboObject* bonobo_foreign_object_new      (CORBA_Object corba_objref);
+
+G_END_DECLS
+
+#endif
Index: bonobo/bonobo-object.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-object.c,v
retrieving revision 1.146
diff -u -p -r1.146 bonobo-object.c
--- bonobo/bonobo-object.c	28 Oct 2002 14:37:53 -0000	1.146
+++ bonobo/bonobo-object.c	15 Apr 2003 22:35:54 -0000
@@ -19,6 +19,7 @@
 #include <bonobo/bonobo-exception.h>
 #include <bonobo/bonobo-main.h>
 #include <bonobo/bonobo-object.h>
+#include <bonobo/bonobo-foreign-object.h>
 #include <bonobo/bonobo-shlib-factory.h>
 #include <bonobo/bonobo-running-context.h>
 #include <bonobo/bonobo-marshal.h>
@@ -169,8 +170,8 @@ bonobo_object_finalize_internal (BonoboA
 			 */
 
 			BONOBO_OBJECT (o)->priv->ao = NULL;
-
-			bonobo_object_corba_deactivate (BONOBO_OBJECT (o));
+			if (!g_type_is_a (G_OBJECT_TYPE(o), BONOBO_TYPE_OBJECT))
+				bonobo_object_corba_deactivate (BONOBO_OBJECT (o));
 
 			g_object_unref (o);
 #ifdef G_ENABLE_DEBUG
@@ -834,8 +835,8 @@ bonobo_object_instance_init (GObject    
 		g_hash_table_insert (living_ao_ht, ao, ao);
 	}
 #endif /* G_ENABLE_DEBUG */
-
-	do_corba_setup (object, BONOBO_OBJECT_CLASS (klass));
+	if (!g_type_is_a (G_TYPE_FROM_CLASS(klass), BONOBO_TYPE_FOREIGN_OBJECT))
+		do_corba_setup (object, BONOBO_OBJECT_CLASS (klass));
 }
 
 /**
Index: tests/test-object.c
===================================================================
RCS file: /cvs/gnome/libbonobo/tests/test-object.c,v
retrieving revision 1.16
diff -u -p -r1.16 test-object.c
--- tests/test-object.c	31 Oct 2001 04:34:29 -0000	1.16
+++ tests/test-object.c	15 Apr 2003 22:35:56 -0000
@@ -1,9 +1,11 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <libbonobo.h>
 #include <orbit/poa/poa.h>
+#include <bonobo/bonobo-foreign-object.h>
 
 #define GENERAL_ERROR_MESSAGE "Hello World"
 
@@ -55,6 +57,20 @@ main (int argc, char *argv [])
 
 	ev = &real_ev;
 	CORBA_exception_init (ev);
+
+	fprintf (stderr, "Foreign object\n");
+	{		       /* This is a very lame test, I know. */
+		BonoboObject *foreign;
+		object = BONOBO_OBJECT (g_object_new (
+			bonobo_moniker_get_type (), NULL));
+		
+		g_assert (bonobo_object_ref (object) == object);
+		g_assert (bonobo_object_unref (BONOBO_OBJECT (object)) == NULL);
+
+		foreign = bonobo_foreign_object_new (bonobo_object_corba_objref (object));
+		bonobo_object_unref (BONOBO_OBJECT (foreign));
+		bonobo_object_unref (BONOBO_OBJECT (object));
+	}
 
 	fprintf (stderr, "Local lifecycle\n");
 	{
