Re: libbonobo closureization
- From: ERDI Gergo <cactus cactus rulez org>
- To: Michael Meeks <michael ximian com>
- Cc: gnome-components-list gnome org
- Subject: Re: libbonobo closureization
- Date: Mon, 30 Jul 2001 19:43:24 +0200 (CEST)
Without further ado, here's what I've just checked in
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libbonobo/ChangeLog,v
retrieving revision 1.108
diff -u -u -r1.108 ChangeLog
--- ChangeLog 2001/07/30 16:59:36 1.108
+++ ChangeLog 2001/07/30 17:41:15
@@ -1,3 +1,21 @@
+2001-07-30 ERDI Gergo <cactus cactus rulez org>
+
+ * bonobo/bonobo-moniker-simple.h: cleanup, privatization
+ Maybe next time someone creates a new Bonobo object they can make
+ it privatized form the beginning... grr...
+
+ * bonobo/bonobo-shlib-factory.h: cleanup
+
+ * bonobo/bonobo-generic-factory.h: cleanup
+
+ * bonobo/bonobo-property-bag.c: Completely privatized BonoboPoperty
+ plus GClosure-ization
+
+ * bonobo/bonobo-marshal.list: Added new signature for PropertyBag,
+ MonikerSimple and ItemHandler callbacks
+
+ * bonobo/bonobo-item-handler.c: Privatization, GClosure-ization
+
2001-07-30 Michael Meeks <michael ximian com>
* bonobo/bonobo-exception.c (bonobo_exception_get_text):
@@ -92,6 +110,7 @@
* bonobo/bonobo-shlib-factory.c (bonobo_shlib_factory_new): impl.
(bonobo_shlib_factory_new_gc): impl.
2001-07-30 ERDI Gergo <cactus cactus rulez org>
Checked in Bonobo_Clipboard (now for real:)
Index: bonobo/bonobo-generic-factory.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-generic-factory.c,v
retrieving revision 1.34
diff -u -u -r1.34 bonobo-generic-factory.c
--- bonobo/bonobo-generic-factory.c 2001/07/30 13:21:41 1.34
+++ bonobo/bonobo-generic-factory.c 2001/07/30 17:41:15
@@ -26,6 +26,8 @@
#include <bonobo/bonobo-running-context.h>
#include <liboaf/liboaf.h>
+#include <bonobo/bonobo-types.h>
+
/* FIXME: cut and paste nastiness from old bonobo */
typedef struct {
@@ -37,7 +39,7 @@
struct _BonoboGenericFactoryPrivate
{
/* The function factory */
- GClosure *factory_cb;
+ GClosure *factory_closure;
/* The CORBA Object */
GNOME_ObjectFactory corba_objref;
@@ -148,8 +150,7 @@
* @oaf_iid: The GOAD id that the new factory will implement.
* Bonobo::GenericFactory interface and which will be used to
* construct this BonoboGenericFactory Gtk object.
- * @factory_cb: A Multi object factory callback.
- * @user_data: The closure data to be passed to the @factory callback routine.
+ * @factory_closure: A Multi object factory closure.
*
* Initializes @c_factory with the command-line arguments and registers
* the new factory in the name server.
@@ -160,7 +161,7 @@
bonobo_generic_factory_construct (BonoboGenericFactory *factory,
GNOME_ObjectFactory corba_factory,
const char *oaf_iid,
- GClosure *factory_cb)
+ GClosure *factory_closure)
{
CORBA_Environment ev;
int ret;
@@ -168,13 +169,9 @@
g_return_val_if_fail (factory != NULL, NULL);
g_return_val_if_fail (BONOBO_IS_GENERIC_FACTORY (factory), NULL);
g_return_val_if_fail (corba_factory != CORBA_OBJECT_NIL, NULL);
-
- g_closure_ref (factory_cb);
- g_closure_sink (factory_cb);
- if (G_CLOSURE_NEEDS_MARSHAL (factory_cb))
- g_closure_set_marshal (factory_cb, g_cclosure_marshal_VOID__STRING);
- factory->priv->factory_cb = factory_cb;
+ factory->priv->factory_closure =
+ bonobo_closure_store (factory_closure, g_cclosure_marshal_VOID__STRING);
factory->priv->oaf_iid = g_strdup (oaf_iid);
CORBA_exception_init (&ev);
@@ -196,13 +193,12 @@
}
/**
- * bonobo_generic_factory_new_gc:
+ * bonobo_generic_factory_new_closure:
* @oaf_iid: The GOAD id that this factory implements
- * @factory_cb: A callback which is used to create new BonoboObject instances.
- * @data: The closure data to be passed to the @factory callback routine.
+ * @factory_closure: A closure which is used to create new BonoboObject instances.
*
* This is a helper routine that simplifies the creation of factory
- * objects for GNOME objects. The @factory function will be
+ * objects for GNOME objects. The @factory_closure closure will be
* invoked by the CORBA server when a request arrives to create a new
* instance of an object supporting the Bonobo::Generic interface.
* The factory callback routine is passed the @data pointer to provide
@@ -213,25 +209,25 @@
* name server.
*/
BonoboGenericFactory *
-bonobo_generic_factory_new_gc (const char *oaf_iid,
- GClosure *factory_cb)
+bonobo_generic_factory_new_closure (const char *oaf_iid,
+ GClosure *factory_closure)
{
BonoboGenericFactory *factory;
GNOME_ObjectFactory corba_factory;
- g_return_val_if_fail (factory_cb != NULL, NULL);
+ g_return_val_if_fail (factory_closure != NULL, NULL);
g_return_val_if_fail (oaf_iid != NULL, NULL);
factory = g_object_new (bonobo_generic_factory_get_type (), NULL);
- corba_factory = bonobo_generic_factory_corba_object_create (factory, factory_cb);
+ corba_factory = bonobo_generic_factory_corba_object_create (factory, factory_closure);
if (corba_factory == CORBA_OBJECT_NIL) {
g_object_unref (G_OBJECT (factory));
return NULL;
}
return bonobo_generic_factory_construct (factory, corba_factory,
- oaf_iid, factory_cb);
+ oaf_iid, factory_closure);
}
@@ -257,7 +253,7 @@
BonoboFactoryCallback factory_cb,
gpointer user_data)
{
- return bonobo_generic_factory_new_gc (
+ return bonobo_generic_factory_new_closure (
oaf_iid, g_cclosure_new (G_CALLBACK (factory_cb), user_data, NULL));
}
@@ -275,7 +271,7 @@
CORBA_exception_free (&ev);
g_free (factory->priv->oaf_iid);
- g_closure_unref (factory->priv->factory_cb);
+ g_closure_unref (factory->priv->factory_closure);
g_free (factory->priv);
factory->priv = 0;
@@ -296,7 +292,7 @@
g_value_init (&ret_val, BONOBO_OBJECT_TYPE);
- bonobo_closure_invoke (factory->priv->factory_cb,
+ bonobo_closure_invoke (factory->priv->factory_closure,
&ret_val,
BONOBO_GENERIC_FACTORY_TYPE, factory,
G_TYPE_STRING, oaf_iid, 0);
Index: bonobo/bonobo-generic-factory.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-generic-factory.h,v
retrieving revision 1.29
diff -u -u -r1.29 bonobo-generic-factory.h
--- bonobo/bonobo-generic-factory.h 2001/07/30 13:21:41 1.29
+++ bonobo/bonobo-generic-factory.h 2001/07/30 17:41:15
@@ -55,17 +55,17 @@
GNOME_ObjectFactory bonobo_generic_factory_corba_object_create (BonoboGenericFactory *object,
gpointer shlib_id);
-BonoboGenericFactory *bonobo_generic_factory_new (const char *oaf_iid,
- BonoboFactoryCallback factory_cb,
- gpointer user_data);
+BonoboGenericFactory *bonobo_generic_factory_new (const char *oaf_iid,
+ BonoboFactoryCallback factory_cb,
+ gpointer user_data);
-BonoboGenericFactory *bonobo_generic_factory_new_gc (const char *oaf_iid,
- GClosure *factory_cb);
+BonoboGenericFactory *bonobo_generic_factory_new_closure (const char *oaf_iid,
+ GClosure *factory_closure);
-BonoboGenericFactory *bonobo_generic_factory_construct (BonoboGenericFactory *factory,
- GNOME_ObjectFactory corba_factory,
- const char *oaf_iid,
- GClosure *factory_cb);
+BonoboGenericFactory *bonobo_generic_factory_construct (BonoboGenericFactory *factory,
+ GNOME_ObjectFactory corba_factory,
+ const char *oaf_iid,
+ GClosure *factory_cb);
POA_GNOME_ObjectFactory__epv *bonobo_generic_factory_get_epv (void);
Index: bonobo/bonobo-item-handler.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-item-handler.c,v
retrieving revision 1.12
diff -u -u -r1.12 bonobo-item-handler.c
--- bonobo/bonobo-item-handler.c 2001/04/18 22:09:06 1.12
+++ bonobo/bonobo-item-handler.c 2001/07/30 17:41:20
@@ -13,10 +13,21 @@
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-exception.h>
+
+#include <bonobo/bonobo-types.h>
+#include <bonobo/bonobo-marshal.h>
+
#include "bonobo-item-handler.h"
#define PARENT_TYPE BONOBO_OBJECT_TYPE
+static GObjectClass *bonobo_item_handler_parent_class;
+struct _BonoboItemHandlerPrivate
+{
+ GClosure *enum_objects;
+ GClosure *get_object;
+};
+
/*
* Returns a list of the objects in this container
*/
@@ -25,10 +36,24 @@
{
BonoboObject *object = bonobo_object_from_servant (servant);
BonoboItemHandler *handler = BONOBO_ITEM_HANDLER (object);
+
+ if (handler->priv->enum_objects)
+ {
+ Bonobo_ItemContainer_ObjectNames *ret;
+ GValue ret_val = {0, };
+
+ g_value_init (&ret_val, G_TYPE_POINTER);
+
+ bonobo_closure_invoke (handler->priv->enum_objects,
+ &ret_val,
+ BONOBO_ITEM_HANDLER_TYPE, handler,
+ G_TYPE_POINTER, ev);
- if (handler->enum_objects)
- return handler->enum_objects (handler, handler->user_data, ev);
- else
+ ret = g_value_get_pointer (&ret_val);
+ g_value_unset (&ret_val);
+
+ return ret;
+ } else
return Bonobo_ItemContainer_ObjectNames__alloc ();
}
@@ -40,30 +65,64 @@
{
BonoboObject *object = bonobo_object_from_servant (servant);
BonoboItemHandler *handler = BONOBO_ITEM_HANDLER (object);
+
+ if (handler->priv->get_object)
+ {
+ Bonobo_Unknown ret;
+ GValue ret_val = {0, };
+
+ g_value_init (&ret_val, G_TYPE_BOXED);
+
+ bonobo_closure_invoke (handler->priv->enum_objects,
+ &ret_val,
+ BONOBO_ITEM_HANDLER_TYPE, handler,
+ G_TYPE_STRING, item_name,
+ G_TYPE_BOOLEAN, only_if_exists,
+ G_TYPE_POINTER, ev);
+
+
+ ret = g_value_get_boxed (&ret_val);
+ g_value_unset (&ret_val);
- if (handler->get_object)
- return handler->get_object (handler, item_name,
- only_if_exists,
- handler->user_data, ev);
- else
+ return ret;
+ } else
return CORBA_OBJECT_NIL;
}
static void
-bonobo_item_handler_class_init (BonoboItemHandlerClass *klass)
+bonobo_item_handler_finalize (GObject *object)
{
- POA_Bonobo_ItemContainer__epv *epv = &klass->epv;
+ BonoboItemHandler *handler = BONOBO_ITEM_HANDLER (object);
- epv->enumObjects = impl_enum_objects;
- epv->getObjectByName = impl_get_object;
+ g_free (handler->priv);
+
+ bonobo_item_handler_parent_class->finalize (object);
+
}
static void
bonobo_item_handler_init (GObject *object)
{
- /* nothing to do */
+ BonoboItemHandler *handler = BONOBO_ITEM_HANDLER (object);
+
+ handler->priv = g_new0 (BonoboItemHandlerPrivate, 1);
}
+
+static void
+bonobo_item_handler_class_init (BonoboItemHandlerClass *klass)
+{
+ POA_Bonobo_ItemContainer__epv *epv = &klass->epv;
+
+ bonobo_item_handler_parent_class = g_type_class_peek_parent (klass);
+
+ G_OBJECT_CLASS (klass)->finalize = bonobo_item_handler_finalize;
+
+ epv->enumObjects = impl_enum_objects;
+ epv->getObjectByName = impl_get_object;
+
+}
+
BONOBO_TYPE_FUNC_FULL (BonoboItemHandler,
Bonobo_ItemContainer,
PARENT_TYPE,
@@ -72,25 +131,26 @@
/**
* bonobo_item_handler_construct:
* @container: The handler object to construct
- * @corba_container: The CORBA object that implements Bonobo::ItemContainer
+ * @enum_objects: The closure implementing enumObjects
+ * @get_object: The closure implementing getObject
*
- * Constructs the @container Gtk object using the provided CORBA
- * object.
+ * Constructs the @container BonoboObject using the provided closures
+ * for the actual implementation.
*
* Returns: The constructed BonoboItemContainer object.
*/
BonoboItemHandler *
-bonobo_item_handler_construct (BonoboItemHandler *handler,
- BonoboItemHandlerEnumObjectsFn enum_objects,
- BonoboItemHandlerGetObjectFn get_object,
- gpointer user_data)
+bonobo_item_handler_construct (BonoboItemHandler *handler,
+ GClosure *enum_objects,
+ GClosure *get_object)
{
g_return_val_if_fail (handler != NULL, NULL);
g_return_val_if_fail (BONOBO_IS_ITEM_HANDLER (handler), NULL);
- handler->get_object = get_object;
- handler->enum_objects = enum_objects;
- handler->user_data = user_data;
+ handler->priv->enum_objects = bonobo_closure_store
+ (enum_objects, bonobo_marshal_POINTER__POINTER_POINTER);
+ handler->priv->get_object = bonobo_closure_store
+ (get_object, bonobo_marshal_BOXED__STRING_BOOLEAN_POINTER_POINTER);
return handler;
}
@@ -107,14 +167,29 @@
bonobo_item_handler_new (BonoboItemHandlerEnumObjectsFn enum_objects,
BonoboItemHandlerGetObjectFn get_object,
gpointer user_data)
+{
+ return bonobo_item_handler_new_closure (
+ g_cclosure_new (G_CALLBACK (enum_objects), user_data, NULL),
+ g_cclosure_new (G_CALLBACK (get_object), user_data, NULL));
+}
+/**
+ * bonobo_item_handler_new_closure:
+ *
+ * Creates a new BonoboItemHandler object. These are used to hold
+ * client sites.
+ *
+ * Returns: The newly created BonoboItemHandler object
+ */
+BonoboItemHandler *
+bonobo_item_handler_new_closure (GClosure *enum_objects,
+ GClosure *get_object)
{
BonoboItemHandler *handler;
handler = g_object_new (bonobo_item_handler_get_type (), NULL);
- return bonobo_item_handler_construct (
- handler, enum_objects, get_object, user_data);
+ return bonobo_item_handler_construct (handler, enum_objects, get_object);
}
/**
Index: bonobo/bonobo-item-handler.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-item-handler.h,v
retrieving revision 1.9
diff -u -u -r1.9 bonobo-item-handler.h
--- bonobo/bonobo-item-handler.h 2001/04/18 22:09:06 1.9
+++ bonobo/bonobo-item-handler.h 2001/07/30 17:41:20
@@ -13,7 +13,7 @@
#define _BONOBO_ITEM_HANDLER_H_
-#include <gobject/gobject.h>
+#include <gobject/gclosure.h>
#include <bonobo/bonobo-object.h>
G_BEGIN_DECLS
@@ -39,10 +39,6 @@
POA_Bonobo_ItemContainer__epv epv;
- BonoboItemHandlerEnumObjectsFn enum_objects;
- BonoboItemHandlerGetObjectFn get_object;
- gpointer user_data;
-
BonoboItemHandlerPrivate *priv;
};
@@ -57,11 +53,13 @@
BonoboItemHandlerGetObjectFn get_object,
gpointer user_data);
-BonoboItemHandler *bonobo_item_handler_construct (BonoboItemHandler *handler,
- BonoboItemHandlerEnumObjectsFn enum_objects,
- BonoboItemHandlerGetObjectFn get_object,
- gpointer user_data);
+BonoboItemHandler *bonobo_item_handler_new_closure (GClosure *enum_objects,
+ GClosure *get_object);
+BonoboItemHandler *bonobo_item_handler_construct (BonoboItemHandler *handler,
+ GClosure *enum_objects,
+ GClosure *get_object);
+
/* Utility functions that can be used by getObject routines */
typedef struct {
char *key;
@@ -74,4 +72,3 @@
G_END_DECLS
#endif
-
Index: bonobo/bonobo-listener.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-listener.c,v
retrieving revision 1.23
diff -u -u -r1.23 bonobo-listener.c
--- bonobo/bonobo-listener.c 2001/07/30 13:21:41 1.23
+++ bonobo/bonobo-listener.c 2001/07/30 17:41:21
@@ -114,12 +114,11 @@
bonobo_listener);
/**
- * bonobo_listener_new:
- * @event_callback: function to be invoked when an event is emitted by the EventSource.
- * @user_data: data passed to the functioned pointed by @event_call.
+ * bonobo_listener_new_closure:
+ * @event_closure: closure to be invoked when an event is emitted by the EventSource.
*
- * Creates a generic event listener. The listener calls the @event_callback
- * function and emits an "event_notify" signal when notified of an event.
+ * Creates a generic event listener. The listener invokes the @event_closure
+ * closure and emits an "event_notify" signal when notified of an event.
* The signal callback should be of the form:
*
* <informalexample>
@@ -138,19 +137,14 @@
* Returns: A BonoboListener object.
*/
BonoboListener*
-bonobo_listener_new_gc (GClosure *event_cb)
+bonobo_listener_new_closure (GClosure *event_closure)
{
BonoboListener *listener;
listener = g_object_new (BONOBO_LISTENER_TYPE, NULL);
-
- g_closure_ref (event_cb);
- g_closure_sink (event_cb);
- if (G_CLOSURE_NEEDS_MARSHAL (event_cb))
- g_closure_set_marshal (event_cb,
- bonobo_marshal_VOID__STRING_BOXED_POINTER);
- listener->priv->event_callback = event_cb;
+ listener->priv->event_callback = bonobo_closure_store (
+ event_closure, bonobo_marshal_VOID__STRING_BOXED_POINTER);
return listener;
}
@@ -180,11 +174,11 @@
* Returns: A BonoboListener object.
*/
BonoboListener *
-bonobo_listener_new (BonoboListenerCallbackFn event_callback,
+bonobo_listener_new (BonoboListenerCallbackFn event_cb,
gpointer user_data)
{
- return bonobo_listener_new_gc (
- g_cclosure_new (G_CALLBACK (event_callback), user_data, NULL));
+ return bonobo_listener_new_closure (
+ g_cclosure_new (G_CALLBACK (event_cb), user_data, NULL));
}
/**
Index: bonobo/bonobo-listener.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-listener.h,v
retrieving revision 1.12
diff -u -u -r1.12 bonobo-listener.h
--- bonobo/bonobo-listener.h 2001/07/30 13:21:41 1.12
+++ bonobo/bonobo-listener.h 2001/07/30 17:41:21
@@ -45,26 +45,27 @@
} BonoboListenerClass;
-typedef void (*BonoboListenerCallbackFn) (BonoboListener *listener,
- char *event_name,
- CORBA_any *any,
- CORBA_Environment *ev,
- gpointer user_data);
+typedef void (*BonoboListenerCallbackFn) (BonoboListener *listener,
+ char *event_name,
+ CORBA_any *any,
+ CORBA_Environment *ev,
+ gpointer user_data);
-GType bonobo_listener_get_type (void);
+GType bonobo_listener_get_type (void);
-BonoboListener *bonobo_listener_new (BonoboListenerCallbackFn event_callback,
- gpointer user_data);
-BonoboListener *bonobo_listener_new_gc (GClosure *event_callback);
+BonoboListener *bonobo_listener_new (BonoboListenerCallbackFn event_cb,
+ gpointer user_data);
-char *bonobo_event_make_name (const char *idl_path,
- const char *kind,
- const char *subtype);
+BonoboListener *bonobo_listener_new_closure (GClosure *event_closure);
-char *bonobo_event_type (const char *event_name);
-char *bonobo_event_subtype (const char *event_name);
-char *bonobo_event_kind (const char *event_name);
-char *bonobo_event_idl_path (const char *event_name);
+char *bonobo_event_make_name (const char *idl_path,
+ const char *kind,
+ const char *subtype);
+
+char *bonobo_event_type (const char *event_name);
+char *bonobo_event_subtype (const char *event_name);
+char *bonobo_event_kind (const char *event_name);
+char *bonobo_event_idl_path (const char *event_name);
G_END_DECLS
Index: bonobo/bonobo-marshal.list
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-marshal.list,v
retrieving revision 1.6
diff -u -u -r1.6 bonobo-marshal.list
--- bonobo/bonobo-marshal.list 2001/07/30 14:25:39 1.6
+++ bonobo/bonobo-marshal.list 2001/07/30 17:41:21
@@ -8,3 +8,7 @@
POINTER:POINTER,BOOLEAN,POINTER
BOOLEAN:POINTER
VOID:STRING,BOXED,POINTER
+VOID:BOXED,UINT,POINTER
+BOXED:STRING,BOOLEAN,POINTER,POINTER
+POINTER:POINTER,POINTER
+BOXED:POINTER,STRING,POINTER
Index: bonobo/bonobo-moniker-simple.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-moniker-simple.c,v
retrieving revision 1.10
diff -u -u -r1.10 bonobo-moniker-simple.c
--- bonobo/bonobo-moniker-simple.c 2001/07/30 15:54:55 1.10
+++ bonobo/bonobo-moniker-simple.c 2001/07/30 17:41:22
@@ -12,6 +12,13 @@
#include <bonobo/bonobo-moniker.h>
#include <bonobo/bonobo-moniker-simple.h>
+#include <bonobo/bonobo-types.h>
+#include <bonobo/bonobo-marshal.h>
+
+struct _BonoboMonikerSimplePrivate {
+ GClosure *resolve_closure;
+};
+
static Bonobo_Unknown
simple_resolve (BonoboMoniker *moniker,
const Bonobo_ResolveOptions *options,
@@ -29,7 +36,8 @@
g_value_init (&value, BONOBO_TYPE_CORBA_OBJECT);
- bonobo_closure_invoke (simple->resolve_fn, &value,
+ bonobo_closure_invoke (simple->priv->resolve_closure,
+ &value,
BONOBO_MONIKER_TYPE, moniker,
G_TYPE_POINTER, options,
G_TYPE_STRING, requested_interface,
@@ -46,9 +54,14 @@
{
BonoboMonikerSimple *simple = (BonoboMonikerSimple *) object;
- if (simple->resolve_fn)
- g_closure_unref (simple->resolve_fn);
- simple->resolve_fn = NULL;
+ if (simple->priv)
+ {
+ if (simple->priv->resolve_closure)
+ g_closure_unref (simple->priv->resolve_closure);
+
+ g_free (simple->priv);
+ simple->priv = NULL;
+ }
}
static void
@@ -64,7 +77,9 @@
static void
bonobo_moniker_simple_init (GObject *object)
{
- /* nothing to do */
+ BonoboMonikerSimple *simple = BONOBO_MONIKER_SIMPLE (object);
+
+ simple->priv = g_new0 (BonoboMonikerSimplePrivate, 1);
}
BONOBO_TYPE_FUNC (BonoboMonikerSimple,
@@ -75,7 +90,7 @@
* bonobo_moniker_simple_construct:
* @moniker: the moniker to construct
* @name: the name of the moniker eg. 'file:'
- * @resolve_fn: the function used to resolve the moniker
+ * @resolve_closure: the closure used to resolve the moniker
*
* Constructs a simple moniker
*
@@ -84,28 +99,29 @@
BonoboMoniker *
bonobo_moniker_simple_construct (BonoboMonikerSimple *moniker,
const char *name,
- GClosure *resolve_fn)
+ GClosure *resolve_closure)
{
- g_return_val_if_fail (resolve_fn != NULL, NULL);
+ g_return_val_if_fail (resolve_closure != NULL, NULL);
- moniker->resolve_fn = resolve_fn;
-
+ moniker->priv->resolve_closure =
+ bonobo_closure_store (resolve_closure, bonobo_marshal_BOXED__POINTER_STRING_POINTER);
+
return bonobo_moniker_construct (
BONOBO_MONIKER (moniker), name);
}
/**
- * bonobo_moniker_simple_new_gc:
+ * bonobo_moniker_simple_new_closure:
* @name: the display name for the moniker
- * @resolve_fn: a closure for the resolve process.
+ * @resolve_closure: a closure for the resolve process.
*
* Create a new instance of a simplified moniker.
*
* Return value: the moniker object
**/
BonoboMoniker *
-bonobo_moniker_simple_new_gc (const char *name,
- GClosure *resolve_fn)
+bonobo_moniker_simple_new_closure (const char *name,
+ GClosure *resolve_closure)
{
BonoboMoniker *moniker;
@@ -113,7 +129,7 @@
return bonobo_moniker_simple_construct (
BONOBO_MONIKER_SIMPLE (moniker),
- name, resolve_fn);
+ name, resolve_closure);
}
/**
@@ -129,7 +145,7 @@
bonobo_moniker_simple_new (const char *name,
BonoboMonikerSimpleResolveFn resolve_fn)
{
- return bonobo_moniker_simple_new_gc (
+ return bonobo_moniker_simple_new_closure (
name, g_cclosure_new (G_CALLBACK (resolve_fn), NULL, NULL));
}
Index: bonobo/bonobo-moniker-simple.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-moniker-simple.h,v
retrieving revision 1.7
diff -u -u -r1.7 bonobo-moniker-simple.h
--- bonobo/bonobo-moniker-simple.h 2001/07/30 15:54:55 1.7
+++ bonobo/bonobo-moniker-simple.h 2001/07/30 17:41:22
@@ -31,7 +31,7 @@
struct _BonoboMonikerSimple {
BonoboMoniker moniker;
- GClosure *resolve_fn;
+
BonoboMonikerSimplePrivate *priv;
};
@@ -39,17 +39,17 @@
BonoboMonikerClass parent_class;
} BonoboMonikerSimpleClass;
-GType bonobo_moniker_simple_get_type (void);
+GType bonobo_moniker_simple_get_type (void);
-BonoboMoniker *bonobo_moniker_simple_construct (BonoboMonikerSimple *moniker,
- const char *name,
- GClosure *resolve_fn);
+BonoboMoniker *bonobo_moniker_simple_construct (BonoboMonikerSimple *moniker,
+ const char *name,
+ GClosure *resolve_closure);
-BonoboMoniker *bonobo_moniker_simple_new (const char *name,
- BonoboMonikerSimpleResolveFn resolve_fn);
+BonoboMoniker *bonobo_moniker_simple_new (const char *name,
+ BonoboMonikerSimpleResolveFn resolve_fn);
-BonoboMoniker *bonobo_moniker_simple_new_gc (const char *name,
- GClosure *resolve_fn);
+BonoboMoniker *bonobo_moniker_simple_new_closure (const char *name,
+ GClosure *resolve_closure);
G_END_DECLS
Index: bonobo/bonobo-property-bag.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-property-bag.c,v
retrieving revision 1.62
diff -u -u -r1.62 bonobo-property-bag.c
--- bonobo/bonobo-property-bag.c 2001/07/22 22:58:03 1.62
+++ bonobo/bonobo-property-bag.c 2001/07/30 17:41:26
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* bonobo-property-bag.c: property bag object implementation.
*
@@ -13,6 +14,9 @@
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-property-bag.h>
+#include <bonobo/bonobo-marshal.h>
+#include <bonobo/bonobo-types.h>
+
#define PARENT_TYPE BONOBO_OBJECT_TYPE
#define CLASS(o) BONOBO_PROPERTY_BAG_CLASS (G_OBJECT_GET_CLASS (o))
@@ -26,11 +30,23 @@
* Internal data structures.
*/
struct _BonoboPropertyBagPrivate {
- GHashTable *prop_hash;
+ GHashTable *prop_hash;
+
+ GClosure *get_prop;
+ GClosure *set_prop;
+};
+
+struct _BonoboProperty {
+ char *name;
+ int idx;
+ BonoboArgType type;
+ BonoboArg *default_value;
+ char *doctitle;
+ char *docstring;
+ Bonobo_PropertyFlags flags;
- BonoboPropertySetFn set_prop;
- BonoboPropertyGetFn get_prop;
- gpointer user_data;
+ GClosure *get_prop;
+ GClosure *set_prop;
};
static void
@@ -157,8 +173,12 @@
arg = bonobo_arg_new (prop->type);
- prop->get_prop (pb, arg, prop->idx, ev, prop->user_data);
-
+ bonobo_closure_invoke (prop->get_prop,
+ NULL,
+ BONOBO_PROPERTY_BAG_TYPE, pb,
+ BONOBO_TYPE_CORBA_ANY, arg,
+ G_TYPE_UINT, prop->idx,
+ G_TYPE_POINTER, ev);
return arg;
}
@@ -193,10 +213,14 @@
CORBA_string_dup (prop->name);
arg = bonobo_arg_new (prop->type);
-
- prop->get_prop (pb, arg, prop->idx, ev,
- prop->user_data);
+ bonobo_closure_invoke (prop->get_prop,
+ NULL,
+ BONOBO_PROPERTY_BAG_TYPE, pb,
+ BONOBO_TYPE_CORBA_ANY, arg,
+ G_TYPE_UINT, prop->idx,
+ G_TYPE_POINTER, ev);
+
set->_buffer [set->_length].value = *arg;
set->_length++;
@@ -227,8 +251,13 @@
bonobo_exception_set (ev, ex_Bonobo_PropertyBag_InvalidType);
return;
}
-
- prop->set_prop (pb, value, prop->idx, ev, prop->user_data);
+
+ bonobo_closure_invoke (prop->set_prop,
+ NULL,
+ BONOBO_PROPERTY_BAG_TYPE, pb,
+ BONOBO_TYPE_CORBA_ANY, value,
+ G_TYPE_UINT, prop->idx,
+ G_TYPE_POINTER, ev);
if (!BONOBO_EX (ev))
notify_listeners (pb, prop, value, NULL);
@@ -265,9 +294,14 @@
for (i = 0; i < set->_length; i++) {
prop = g_hash_table_lookup (pb->priv->prop_hash,
set->_buffer [i].name);
+
+ bonobo_closure_invoke (prop->set_prop,
+ NULL,
+ BONOBO_PROPERTY_BAG_TYPE, pb,
+ BONOBO_TYPE_CORBA_ANY, &set->_buffer [i].value,
+ G_TYPE_UINT, prop->idx,
+ G_TYPE_POINTER, ev);
- prop->set_prop (pb, &set->_buffer [i].value, prop->idx, ev,
- prop->user_data);
if (BONOBO_EX (ev))
return;
@@ -355,10 +389,9 @@
/**
* bonobo_property_bag_construct:
* @pb: #BonoboPropertyBag to construct
- * @get_prop: the property get callback
- * @set_prop: the property set callback
+ * @get_prop: the property get closure
+ * @set_prop: the property set closure
* @es: an event source to aggregate
- * @user_data: user data for the callbacks
*
* Constructor, only for use in wrappers and object derivation, please
* refer to the #bonobo_property_bag_new for normal use.
@@ -369,16 +402,14 @@
* Returns: #BonoboPropertyBag pointer or %NULL.
*/
BonoboPropertyBag *
-bonobo_property_bag_construct (BonoboPropertyBag *pb,
- BonoboPropertyGetFn get_prop,
- BonoboPropertySetFn set_prop,
- BonoboEventSource *es,
- gpointer user_data)
-{
- pb->es = es;
- pb->priv->set_prop = set_prop;
- pb->priv->get_prop = get_prop;
- pb->priv->user_data = user_data;
+bonobo_property_bag_construct (BonoboPropertyBag *pb,
+ GClosure *get_prop,
+ GClosure *set_prop,
+ BonoboEventSource *es)
+{
+ pb->es = es;
+ pb->priv->get_prop = bonobo_closure_store (get_prop, bonobo_marshal_VOID__BOXED_UINT_POINTER);
+ pb->priv->set_prop = bonobo_closure_store (set_prop, bonobo_marshal_VOID__BOXED_UINT_POINTER);
bonobo_object_add_interface (BONOBO_OBJECT (pb), BONOBO_OBJECT (es));
@@ -387,20 +418,18 @@
/**
* bonobo_property_bag_new_full:
- * @get_prop: the property get callback
- * @set_prop: the property set callback
+ * @get_prop: the property get closure
+ * @set_prop: the property set closure
* @es: an event source to aggregate
- * @user_data: user data for the callbacks
*
* Creates a new property bag with the specified callbacks.
*
* Returns: A new #BonoboPropertyBag object.
*/
BonoboPropertyBag *
-bonobo_property_bag_new_full (BonoboPropertyGetFn get_prop,
- BonoboPropertySetFn set_prop,
- BonoboEventSource *es,
- gpointer user_data)
+bonobo_property_bag_new_full (GClosure *get_prop,
+ GClosure *set_prop,
+ BonoboEventSource *es)
{
BonoboPropertyBag *pb;
@@ -408,8 +437,7 @@
pb = g_object_new (BONOBO_PROPERTY_BAG_TYPE, NULL);
- return bonobo_property_bag_construct (pb, get_prop, set_prop, es,
- user_data);
+ return bonobo_property_bag_construct (pb, get_prop, set_prop, es);
}
/**
@@ -422,17 +450,34 @@
*
* Returns: A new #BonoboPropertyBag object.
*/
+BonoboPropertyBag *
+bonobo_property_bag_new (BonoboPropertyGetFn get_prop_cb,
+ BonoboPropertySetFn set_prop_cb,
+ gpointer user_data)
+{
+ return bonobo_property_bag_new_closure (
+ g_cclosure_new (G_CALLBACK (get_prop_cb), user_data, NULL),
+ g_cclosure_new (G_CALLBACK (set_prop_cb), user_data, NULL));
+}
+
+/**
+ * bonobo_property_bag_new_closure:
+ * @get_prop: the property get closure
+ * @set_prop: the property set closure
+ *
+ * Creates a new property bag with the specified callbacks.
+ *
+ * Returns: A new #BonoboPropertyBag object.
+ */
BonoboPropertyBag *
-bonobo_property_bag_new (BonoboPropertyGetFn get_prop,
- BonoboPropertySetFn set_prop,
- gpointer user_data)
+bonobo_property_bag_new_closure (GClosure *get_prop,
+ GClosure *set_prop)
{
BonoboEventSource *es;
es = bonobo_event_source_new ();
- return bonobo_property_bag_new_full (get_prop, set_prop, es,
- user_data);
+ return bonobo_property_bag_new_full (get_prop, set_prop, es);
}
static gboolean
@@ -453,6 +498,9 @@
if (prop->doctitle)
g_free (prop->doctitle);
+ g_closure_unref (prop->get_prop);
+ g_closure_unref (prop->set_prop);
+
g_free (prop);
return TRUE;
@@ -470,6 +518,9 @@
g_hash_table_destroy (pb->priv->prop_hash);
+ g_closure_unref (pb->priv->get_prop);
+ g_closure_unref (pb->priv->set_prop);
+
g_free (pb->priv);
parent_class->finalize (object);
@@ -496,17 +547,16 @@
* This adds a property to @pb at the full tilt of complexity.
**/
void
-bonobo_property_bag_add_full (BonoboPropertyBag *pb,
- const char *name,
- int idx,
- BonoboArgType type,
- BonoboArg *default_value,
- const char *doctitle,
- const char *docstring,
- Bonobo_PropertyFlags flags,
- BonoboPropertyGetFn get_prop,
- BonoboPropertySetFn set_prop,
- gpointer user_data)
+bonobo_property_bag_add_full (BonoboPropertyBag *pb,
+ const char *name,
+ int idx,
+ BonoboArgType type,
+ BonoboArg *default_value,
+ const char *doctitle,
+ const char *docstring,
+ Bonobo_PropertyFlags flags,
+ GClosure *get_prop,
+ GClosure *set_prop)
{
BonoboProperty *prop;
@@ -531,16 +581,15 @@
if (!(flags & Bonobo_PROPERTY_READABLE) && default_value)
g_warning ("Assigning a default value to a non readable "
"property '%s'", name);
-
+
prop = g_new0 (BonoboProperty, 1);
prop->name = g_strdup (name);
prop->idx = idx;
prop->type = type;
prop->flags = flags;
- prop->get_prop = get_prop;
- prop->set_prop = set_prop;
- prop->user_data = user_data;
+ prop->get_prop = bonobo_closure_store (get_prop, bonobo_marshal_VOID__BOXED_UINT_POINTER);
+ prop->set_prop = bonobo_closure_store (set_prop, bonobo_marshal_VOID__BOXED_UINT_POINTER);
prop->docstring = g_strdup (docstring);
prop->doctitle = g_strdup (doctitle);
@@ -683,9 +732,11 @@
g_type_name (value_type), NULL);
g_warning ("Mapping '%s'", desc);
- bonobo_property_bag_add_full (pb, pspec->name, i, type,
- NULL, desc, NULL, flags,
- get_prop, set_prop, pspec);
+ bonobo_property_bag_add_full
+ (pb, pspec->name, i, type,
+ NULL, desc, NULL, flags,
+ g_cclosure_new (G_CALLBACK (get_prop), pspec, NULL),
+ g_cclosure_new (G_CALLBACK (set_prop), pspec, NULL));
g_free (desc);
}
@@ -721,8 +772,7 @@
default_value, doctitle,
NULL, flags,
pb->priv->get_prop,
- pb->priv->set_prop,
- pb->priv->user_data);
+ pb->priv->set_prop);
}
Index: bonobo/bonobo-property-bag.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-property-bag.h,v
retrieving revision 1.30
diff -u -u -r1.30 bonobo-property-bag.h
--- bonobo/bonobo-property-bag.h 2001/05/04 13:00:19 1.30
+++ bonobo/bonobo-property-bag.h 2001/07/30 17:41:26
@@ -15,6 +15,8 @@
#include <bonobo/bonobo-arg.h>
#include <bonobo/bonobo-event-source.h>
+#include <gobject/gclosure.h>
+
G_BEGIN_DECLS
#define BONOBO_PROPERTY_READABLE Bonobo_PROPERTY_READABLE
@@ -24,6 +26,8 @@
typedef struct _BonoboPropertyBagPrivate BonoboPropertyBagPrivate;
typedef struct _BonoboPropertyBag BonoboPropertyBag;
+typedef struct _BonoboProperty BonoboProperty;
+
typedef void (*BonoboPropertyGetFn) (BonoboPropertyBag *bag,
BonoboArg *arg,
guint arg_id,
@@ -35,21 +39,6 @@
CORBA_Environment *ev,
gpointer user_data);
-typedef struct {
- char *name;
- int idx;
- BonoboArgType type;
- BonoboArg *default_value;
- char *doctitle;
- char *docstring;
- Bonobo_PropertyFlags flags;
-
- BonoboPropertyGetFn get_prop;
- BonoboPropertySetFn set_prop;
- gpointer user_data;
-} BonoboProperty;
-
-
struct _BonoboPropertyBag {
BonoboObject parent;
BonoboPropertyBagPrivate *priv;
@@ -71,23 +60,25 @@
GType
bonobo_property_bag_get_type (void);
+BonoboPropertyBag *
+bonobo_property_bag_new (BonoboPropertyGetFn get_prop_cb,
+ BonoboPropertySetFn set_prop_cb,
+ gpointer user_data);
+
BonoboPropertyBag *
-bonobo_property_bag_new (BonoboPropertyGetFn get_prop,
- BonoboPropertySetFn set_prop,
- gpointer user_data);
+bonobo_property_bag_new_closure (GClosure *get_prop,
+ GClosure *set_prop);
BonoboPropertyBag *
-bonobo_property_bag_new_full (BonoboPropertyGetFn get_prop,
- BonoboPropertySetFn set_prop,
- BonoboEventSource *event_source,
- gpointer user_data);
+bonobo_property_bag_new_full (GClosure *get_prop,
+ GClosure *set_prop,
+ BonoboEventSource *event_source);
BonoboPropertyBag *
-bonobo_property_bag_construct (BonoboPropertyBag *pb,
- BonoboPropertyGetFn get_prop,
- BonoboPropertySetFn set_prop,
- BonoboEventSource *event_source,
- gpointer user_data);
+bonobo_property_bag_construct (BonoboPropertyBag *pb,
+ GClosure *get_prop,
+ GClosure *set_prop,
+ BonoboEventSource *event_source);
void
bonobo_property_bag_add (BonoboPropertyBag *pb,
@@ -99,17 +90,16 @@
Bonobo_PropertyFlags flags);
void
-bonobo_property_bag_add_full (BonoboPropertyBag *pb,
- const char *name,
- int idx,
- BonoboArgType type,
- BonoboArg *default_value,
- const char *doctitle,
- const char *docstring,
- Bonobo_PropertyFlags flags,
- BonoboPropertyGetFn get_prop,
- BonoboPropertySetFn set_prop,
- gpointer user_data);
+bonobo_property_bag_add_full (BonoboPropertyBag *pb,
+ const char *name,
+ int idx,
+ BonoboArgType type,
+ BonoboArg *default_value,
+ const char *doctitle,
+ const char *docstring,
+ Bonobo_PropertyFlags flags,
+ GClosure *get_prop,
+ GClosure *set_prop);
void
bonobo_property_bag_add_gtk_args (BonoboPropertyBag *pb,
Index: bonobo/bonobo-shlib-factory.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-shlib-factory.c,v
retrieving revision 1.11
diff -u -u -r1.11 bonobo-shlib-factory.c
--- bonobo/bonobo-shlib-factory.c 2001/07/30 13:21:41 1.11
+++ bonobo/bonobo-shlib-factory.c 2001/07/30 17:41:27
@@ -74,15 +74,14 @@
}
/**
- * bonobo_shlib_factory_new_gc:
+ * bonobo_shlib_factory_new_closure:
* @oaf_iid: The GOAD id that this factory implements
* @poa: the poa.
* @oaf_impl_ptr: Oaf shlib handle
- * @factory_cb: A callback which is used to create new BonoboObject instances.
- * @user_data: The closure data to be passed to the @factory callback routine.
+ * @factory_closure: A closure which is used to create new BonoboObject instances.
*
* This is a helper routine that simplifies the creation of factory
- * objects for GNOME objects. The @factory function will be
+ * objects for GNOME objects. The @factory_closure closure will be
* invoked by the CORBA server when a request arrives to create a new
* instance of an object supporting the Bonobo::Shlib interface.
* The factory callback routine is passed the @data pointer to provide
@@ -93,21 +92,21 @@
* name server.
*/
BonoboShlibFactory *
-bonobo_shlib_factory_new_gc (const char *oaf_iid,
- PortableServer_POA poa,
- gpointer oaf_impl_ptr,
- GClosure *closure)
+bonobo_shlib_factory_new_closure (const char *oaf_iid,
+ PortableServer_POA poa,
+ gpointer oaf_impl_ptr,
+ GClosure *factory_closure)
{
BonoboShlibFactory *factory;
GNOME_ObjectFactory corba_factory;
- g_return_val_if_fail (closure != NULL, NULL);
+ g_return_val_if_fail (factory_closure != NULL, NULL);
g_return_val_if_fail (oaf_iid != NULL, NULL);
factory = g_object_new (bonobo_shlib_factory_get_type (), NULL);
corba_factory = bonobo_generic_factory_corba_object_create (
- BONOBO_GENERIC_FACTORY (factory), closure);
+ BONOBO_GENERIC_FACTORY (factory), factory_closure);
if (corba_factory == CORBA_OBJECT_NIL) {
g_object_unref (G_OBJECT (factory));
@@ -116,7 +115,7 @@
return bonobo_shlib_factory_construct (factory, corba_factory,
oaf_iid, poa, oaf_impl_ptr,
- closure);
+ factory_closure);
}
/**
@@ -145,9 +144,9 @@
BonoboFactoryCallback factory_cb,
gpointer user_data)
{
- return bonobo_shlib_factory_new_gc (
+ return bonobo_shlib_factory_new_closure (
component_id, poa, oaf_impl_ptr,
- g_cclosure_new (factory_cb, user_data, NULL));
+ g_cclosure_new (G_CALLBACK (factory_cb), user_data, NULL));
}
static void
Index: bonobo/bonobo-shlib-factory.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-shlib-factory.h,v
retrieving revision 1.9
diff -u -u -r1.9 bonobo-shlib-factory.h
--- bonobo/bonobo-shlib-factory.h 2001/07/30 13:21:41 1.9
+++ bonobo/bonobo-shlib-factory.h 2001/07/30 17:41:28
@@ -53,10 +53,10 @@
BonoboFactoryCallback factory_cb,
gpointer user_data);
-BonoboShlibFactory *bonobo_shlib_factory_new_gc (const char *component_id,
+BonoboShlibFactory *bonobo_shlib_factory_new_closure (const char *component_id,
PortableServer_POA poa,
gpointer oaf_impl_ptr,
- GClosure *closure);
+ GClosure *factory_closure);
void bonobo_shlib_factory_track_object (BonoboShlibFactory *factory,
BonoboObject *object);
Index: bonobo/bonobo-types.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-types.c,v
retrieving revision 1.7
diff -u -u -r1.7 bonobo-types.c
--- bonobo/bonobo-types.c 2001/07/30 15:54:55 1.7
+++ bonobo/bonobo-types.c 2001/07/30 17:41:31
@@ -350,3 +350,22 @@
va_end (var_args);
}
+/**
+ * bonobo_closure_store:
+ * @closure: a standard GClosure
+ * @default_marshal: the default marshaller to use
+ *
+ * Does the necessary refcounting magic and returns a directly
+ * storable closure
+ **/
+GClosure *
+bonobo_closure_store (GClosure *closure,
+ GClosureMarshal default_marshal)
+{
+ g_closure_ref (closure);
+ g_closure_sink (closure);
+ if (G_CLOSURE_NEEDS_MARSHAL (closure))
+ g_closure_set_marshal (closure, default_marshal);
+
+ return closure;
+}
Index: bonobo/bonobo-types.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-types.h,v
retrieving revision 1.3
diff -u -u -r1.3 bonobo-types.h
--- bonobo/bonobo-types.h 2001/07/30 15:54:55 1.3
+++ bonobo/bonobo-types.h 2001/07/30 17:41:37
@@ -42,16 +42,19 @@
CORBA_Object bonobo_value_get_corba_object (GValue *value);
CORBA_Environment *bonobo_value_get_corba_exception (GValue *value);
-void bonobo_closure_invoke_va_list (GClosure *closure,
+void bonobo_closure_invoke_va_list (GClosure *closure,
GValue *retval,
GType first_type,
va_list var_args);
-void bonobo_closure_invoke (GClosure *closure,
+void bonobo_closure_invoke (GClosure *closure,
GValue *retval,
GType first_type,
...);
+GClosure * bonobo_closure_store (GClosure *closure,
+ GClosureMarshal default_marshal);
+
G_END_DECLS
#endif
--
.--= ULLA! =---------------------. `We are not here to give users what
\ http://cactus.rulez.org \ they want' -- RMS, at GUADEC 2001
`---= cactus cactus rulez org =---'
Don't anthropomorphize computers. They hate that.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]