Re: BonoboGenericFactory: multi/single factories
- From: ERDI Gergo <cactus cactus rulez org>
- To: Michael Meeks <michael ximian com>
- Cc: gnome-components-list gnome org
- Subject: Re: BonoboGenericFactory: multi/single factories
- Date: Sat, 28 Jul 2001 01:28:26 +0200 (CEST)
On Fri, 27 Jul 2001, Michael Meeks wrote:
> Yes, we don't want single factories - they are a tedious
> anachronism, I'd be very interested in a patch ASAP to clean out single
> factories entirely - can you help ?
sure, this is why I asked...
here it is (yes, I know, no changelog entry, trust me I will include one
when I actually check it in)
it has some changes that seem meaningless (like changing the order of
some arguments), but if we are about the clean this mess up, let's do it
all at once.
Index: bonobo-generic-factory.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-generic-factory.c,v
retrieving revision 1.31
diff -u -u -r1.31 bonobo-generic-factory.c
--- bonobo-generic-factory.c 2001/07/12 19:31:50 1.31
+++ bonobo-generic-factory.c 2001/07/27 23:26:14
@@ -129,12 +129,11 @@
/**
* bonobo_generic_factory_construct:
- * @oaf_iid: The GOAD id that the new factory will implement.
- * @c_factory: The object to be initialized.
+ * @factory: The object to be initialized.
* @corba_factory: The CORBA object which supports the
+ * @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: A callback which is used to create new GnomeGeneric object instances.
* @factory_cb: A Multi object factory callback.
* @user_data: The closure data to be passed to the @factory callback routine.
*
@@ -144,82 +143,39 @@
* Returns: The initialized BonoboGenericFactory object.
*/
BonoboGenericFactory *
-bonobo_generic_factory_construct (const char *oaf_iid,
- BonoboGenericFactory *c_factory,
+bonobo_generic_factory_construct (BonoboGenericFactory *factory,
GNOME_ObjectFactory corba_factory,
- BonoboGenericFactoryFn factory,
- GnomeFactoryCallback factory_cb,
+ const char *oaf_iid,
+ BonoboFactoryCallback factory_cb,
gpointer user_data)
{
CORBA_Environment ev;
int ret;
- g_return_val_if_fail (c_factory != NULL, NULL);
- g_return_val_if_fail (BONOBO_IS_GENERIC_FACTORY (c_factory), NULL);
+ 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);
- c_factory->factory = factory;
- c_factory->factory_cb = factory_cb;
- c_factory->factory_closure = user_data;
- c_factory->oaf_iid = g_strdup (oaf_iid);
+ factory->factory_cb = factory_cb;
+ factory->factory_closure = user_data;
+ factory->oaf_iid = g_strdup (oaf_iid);
CORBA_exception_init (&ev);
- c_factory->corba_objref = CORBA_Object_duplicate (corba_factory, &ev);
+ factory->corba_objref = CORBA_Object_duplicate (corba_factory, &ev);
CORBA_exception_free (&ev);
-
- ret = oaf_active_server_register (c_factory->oaf_iid, corba_factory);
+
+ ret = oaf_active_server_register (factory->oaf_iid, corba_factory);
if (ret == OAF_REG_ERROR) {
CORBA_Environment ev;
CORBA_exception_init (&ev);
- g_object_unref (G_OBJECT (c_factory));
+ g_object_unref (G_OBJECT (factory));
CORBA_Object_release (corba_factory, &ev);
CORBA_exception_free (&ev);
return NULL;
}
-
- return c_factory;
-}
-
-/**
- * bonobo_generic_factory_new:
- * @oaf_iid: The GOAD id that this factory implements
- * @factory: A callback which is used to create new BonoboObject instances.
- * @user_data: The closure data to be passed to the @factory callback routine.
- *
- * This is a helper routine that simplifies the creation of factory
- * objects for GNOME objects. The @factory function 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
- * the creation function with some state information.
- *
- * Returns: A BonoboGenericFactory object that has an activated
- * Bonobo::GenericFactory object that has registered with the GNOME
- * name server.
- */
-BonoboGenericFactory *
-bonobo_generic_factory_new (const char *oaf_iid,
- BonoboGenericFactoryFn factory,
- gpointer user_data)
-{
- BonoboGenericFactory *c_factory;
- GNOME_ObjectFactory corba_factory;
-
- g_return_val_if_fail (factory != NULL, NULL);
-
- c_factory = g_object_new (bonobo_generic_factory_get_type (), NULL);
-
- corba_factory = bonobo_generic_factory_corba_object_create (
- c_factory, factory);
- if (corba_factory == CORBA_OBJECT_NIL) {
- g_object_unref (G_OBJECT (c_factory));
- return NULL;
- }
-
- return bonobo_generic_factory_construct (
- oaf_iid, c_factory, corba_factory, factory, NULL, user_data);
+ return factory;
}
/**
@@ -239,42 +195,41 @@
* Bonobo::GenericFactory object that has registered with the GNOME
* name server.
*/
-BonoboGenericFactory *bonobo_generic_factory_new_multi (
- const char *oaf_iid,
- GnomeFactoryCallback factory_cb,
- gpointer data)
+BonoboGenericFactory *
+bonobo_generic_factory_new (const char *oaf_iid,
+ BonoboFactoryCallback factory_cb,
+ gpointer data)
{
- BonoboGenericFactory *c_factory;
+ BonoboGenericFactory *factory;
GNOME_ObjectFactory corba_factory;
g_return_val_if_fail (factory_cb != NULL, NULL);
g_return_val_if_fail (oaf_iid != NULL, NULL);
- c_factory = g_object_new (bonobo_generic_factory_get_type (), NULL);
-
- corba_factory = bonobo_generic_factory_corba_object_create (
- c_factory, factory_cb);
+ factory = g_object_new (bonobo_generic_factory_get_type (), NULL);
+
+ corba_factory = bonobo_generic_factory_corba_object_create (factory, factory_cb);
if (corba_factory == CORBA_OBJECT_NIL) {
- g_object_unref (G_OBJECT (c_factory));
+ g_object_unref (G_OBJECT (factory));
return NULL;
}
- return bonobo_generic_factory_construct (
- oaf_iid, c_factory, corba_factory, NULL, factory_cb, data);
+ return bonobo_generic_factory_construct (factory, corba_factory,
+ oaf_iid, factory_cb, data);
}
static void
bonobo_generic_factory_finalize (GObject *object)
{
- BonoboGenericFactory *c_factory G_GNUC_UNUSED = BONOBO_GENERIC_FACTORY (object);
+ BonoboGenericFactory *factory G_GNUC_UNUSED = BONOBO_GENERIC_FACTORY (object);
CORBA_Environment ev;
CORBA_exception_init (&ev);
- oaf_active_server_unregister (c_factory->oaf_iid, c_factory->corba_objref);
- CORBA_Object_release (c_factory->corba_objref, &ev);
+ oaf_active_server_unregister (factory->oaf_iid, factory->corba_objref);
+ CORBA_Object_release (factory->corba_objref, &ev);
CORBA_exception_free (&ev);
- g_free (c_factory->oaf_iid);
+ g_free (factory->oaf_iid);
G_OBJECT_CLASS (bonobo_generic_factory_parent_class)->finalize (object);
}
@@ -286,11 +241,8 @@
g_return_val_if_fail (factory != NULL, NULL);
g_return_val_if_fail (BONOBO_IS_GENERIC_FACTORY (factory), NULL);
- if (factory->factory_cb)
- return factory->factory_cb (factory, oaf_iid,
- factory->factory_closure);
- else
- return factory->factory (factory, factory->factory_closure);
+ return factory->factory_cb (factory, oaf_iid,
+ factory->factory_closure);
}
static void
@@ -338,6 +290,7 @@
return type;
}
+#if 0
/**
* bonobo_generic_factory_set:
* @c_factory: The BonoboGenericFactory object whose callback will be set.
@@ -359,7 +312,7 @@
c_factory->factory = factory;
c_factory->factory_closure = data;
}
-
+#endif
/**
* bonobo_generic_factory_get_epv:
Index: bonobo-generic-factory.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-generic-factory.h,v
retrieving revision 1.27
diff -u -u -r1.27 bonobo-generic-factory.h
--- bonobo-generic-factory.h 2001/05/19 17:04:19 1.27
+++ bonobo-generic-factory.h 2001/07/27 23:26:14
@@ -28,15 +28,13 @@
typedef struct _BonoboGenericFactoryPrivate BonoboGenericFactoryPrivate;
typedef struct _BonoboGenericFactory BonoboGenericFactory;
-typedef BonoboObject * (*BonoboGenericFactoryFn)(BonoboGenericFactory *Factory, void *closure);
-typedef BonoboObject * (*GnomeFactoryCallback)(BonoboGenericFactory *factory, const char *component_id, gpointer closure);
+typedef BonoboObject * (*BonoboFactoryCallback) (BonoboGenericFactory *factory, const char *component_id, gpointer closure);
struct _BonoboGenericFactory {
GObject base;
/* The function factory */
- BonoboGenericFactoryFn factory; /* compat reasons only */
- GnomeFactoryCallback factory_cb;
+ BonoboFactoryCallback factory_cb;
gpointer factory_closure;
/* The CORBA Object */
@@ -50,42 +48,27 @@
GObjectClass parent_class;
/* Virtual methods */
- BonoboObject *(*new_generic) (BonoboGenericFactory *c_factory,
+ BonoboObject *(*new_generic) (BonoboGenericFactory *factory,
const char *component_id);
} BonoboGenericFactoryClass;
GType bonobo_generic_factory_get_type (void);
-GNOME_ObjectFactory bonobo_generic_factory_corba_objref (
- BonoboGenericFactory *object);
+GNOME_ObjectFactory bonobo_generic_factory_corba_objref (BonoboGenericFactory *object);
-GNOME_ObjectFactory bonobo_generic_factory_corba_object_create (
- BonoboGenericFactory *object,
- gpointer shlib_id);
-
-BonoboGenericFactory *bonobo_generic_factory_new (
- const char *oaf_iid,
- BonoboGenericFactoryFn factory,
- gpointer user_data);
-
-BonoboGenericFactory *bonobo_generic_factory_new_multi (
- const char *oaf_iid,
- GnomeFactoryCallback factory_cb,
- gpointer data);
-
-BonoboGenericFactory *bonobo_generic_factory_construct (
- const char *oaf_iid,
- BonoboGenericFactory *c_factory,
- GNOME_ObjectFactory corba_factory,
- BonoboGenericFactoryFn factory,
- GnomeFactoryCallback factory_cb,
- gpointer user_data);
-
-void bonobo_generic_factory_set (
- BonoboGenericFactory *c_factory,
- BonoboGenericFactoryFn factory,
- void *data);
+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_construct (BonoboGenericFactory *factory,
+ GNOME_ObjectFactory corba_factory,
+ const char *oaf_iid,
+ BonoboFactoryCallback factory_cb,
+ gpointer user_data);
+
POA_GNOME_ObjectFactory__epv *bonobo_generic_factory_get_epv (void);
#ifdef __BONOBO_UI_MAIN_H__
@@ -97,25 +80,14 @@
if (!bonobo_init (argcp, argv)) \
g_error (_("Could not initialize Bonobo"));
#endif
-
-#define BONOBO_OAF_FACTORY(oafiid, descr, version, fn, data) \
-int main (int argc, char *argv []) \
-{ \
- BonoboGenericFactory *factory; \
- \
- BONOBO_FACTORY_INIT (descr, version, &argc, argv); \
- factory = bonobo_generic_factory_new (oafiid, fn, data); \
- bonobo_main (); \
- return 0; \
-}
-#define BONOBO_OAF_FACTORY_MULTI(oafiid, descr, version, fn, data) \
+#define BONOBO_OAF_FACTORY(oafiid, descr, version, callback, data) \
int main (int argc, char *argv []) \
{ \
BonoboGenericFactory *factory; \
\
BONOBO_FACTORY_INIT (descr, version, &argc, argv); \
- factory = bonobo_generic_factory_new_multi (oafiid, fn, data); \
+ factory = bonobo_generic_factory_new (oafiid, callback, data); \
bonobo_main (); \
return 0; \
}
Index: bonobo-shlib-factory.c
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-shlib-factory.c,v
retrieving revision 1.9
diff -u -u -r1.9 bonobo-shlib-factory.c
--- bonobo-shlib-factory.c 2001/07/02 12:50:30 1.9
+++ bonobo-shlib-factory.c 2001/07/27 23:26:14
@@ -29,13 +29,13 @@
/**
* bonobo_shlib_factory_construct:
- * @c_factory: The object to be initialized.
+ * @factory: The object to be initialized.
+ * @corba_factory: The CORBA object which supports the
* @oaf_iid: The GOAD id that the new factory will implement.
* @oaf_impl_ptr: Oaf shlib handle
- * @corba_factory: The CORBA object which supports the
* Bonobo::ShlibFactory interface and which will be used to
* construct this BonoboShlibFactory Gtk object.
- * @factory: A callback which is used to create new GnomeShlib object instances.
+ * @factory_cb: A callback which is used to create new GnomeShlib object instances.
* @data: The closure data to be passed to the @factory callback routine.
*
* Initializes @c_factory with the command-line arguments and registers
@@ -44,28 +44,28 @@
* Returns: The initialized BonoboShlibFactory object.
*/
BonoboShlibFactory *
-bonobo_shlib_factory_construct (BonoboShlibFactory *c_factory,
+bonobo_shlib_factory_construct (BonoboShlibFactory *factory,
+ CORBA_Object corba_factory,
const char *oaf_iid,
PortableServer_POA poa,
gpointer oaf_impl_ptr,
- CORBA_Object corba_factory,
- BonoboGenericFactoryFn factory,
- GnomeFactoryCallback factory_cb,
+ BonoboFactoryCallback factory_cb,
gpointer user_data)
{
- g_return_val_if_fail (c_factory != NULL, NULL);
- g_return_val_if_fail (BONOBO_IS_SHLIB_FACTORY (c_factory), NULL);
+ g_return_val_if_fail (factory != NULL, NULL);
+ g_return_val_if_fail (BONOBO_IS_SHLIB_FACTORY (factory), NULL);
g_return_val_if_fail (corba_factory != CORBA_OBJECT_NIL, NULL);
- c_factory->live_objects = 0;
- c_factory->oaf_impl_ptr = oaf_impl_ptr;
+ factory->live_objects = 0;
+ factory->oaf_impl_ptr = oaf_impl_ptr;
oaf_plugin_use (poa, oaf_impl_ptr);
return BONOBO_SHLIB_FACTORY (
- bonobo_generic_factory_construct (
- oaf_iid, BONOBO_GENERIC_FACTORY (c_factory),
- corba_factory, factory, factory_cb, user_data));
+ bonobo_generic_factory_construct (BONOBO_GENERIC_FACTORY (factory),
+ corba_factory,
+ oaf_iid,
+ factory_cb, user_data));
}
/**
@@ -73,52 +73,6 @@
* @oaf_iid: The GOAD id that this factory implements
* @poa: the poa.
* @oaf_impl_ptr: Oaf shlib handle
- * @factory: A callback which is used to create new BonoboObject instances.
- * @user_data: The closure data to be passed to the @factory callback routine.
- *
- * This is a helper routine that simplifies the creation of factory
- * objects for GNOME objects. The @factory function 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
- * the creation function with some state information.
- *
- * Returns: A BonoboShlibFactory object that has an activated
- * Bonobo::ShlibFactory object that has registered with the GNOME
- * name server.
- */
-BonoboShlibFactory *
-bonobo_shlib_factory_new (const char *oaf_iid,
- PortableServer_POA poa,
- gpointer oaf_impl_ptr,
- BonoboGenericFactoryFn factory,
- gpointer user_data)
-{
- BonoboShlibFactory *c_factory;
- GNOME_ObjectFactory corba_factory;
-
- g_return_val_if_fail (factory != NULL, NULL);
-
- c_factory = g_object_new (bonobo_shlib_factory_get_type (), NULL);
-
- corba_factory = bonobo_generic_factory_corba_object_create (
- BONOBO_GENERIC_FACTORY (c_factory), factory);
-
- if (corba_factory == CORBA_OBJECT_NIL) {
- g_object_unref (G_OBJECT (c_factory));
- return NULL;
- }
-
- return bonobo_shlib_factory_construct (
- c_factory, oaf_iid, poa, oaf_impl_ptr,
- corba_factory, factory, NULL, user_data);
-}
-
-/**
- * bonobo_shlib_factory_new_multi:
- * @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.
*
@@ -133,32 +87,31 @@
* Bonobo::ShlibFactory object that has registered with the GNOME
* name server.
*/
-BonoboShlibFactory *bonobo_shlib_factory_new_multi (
- const char *oaf_iid,
- PortableServer_POA poa,
- gpointer oaf_impl_ptr,
- GnomeFactoryCallback factory_cb,
- gpointer user_data)
+BonoboShlibFactory *bonobo_shlib_factory_new (const char *oaf_iid,
+ PortableServer_POA poa,
+ gpointer oaf_impl_ptr,
+ BonoboFactoryCallback factory_cb,
+ gpointer user_data)
{
- BonoboShlibFactory *c_factory;
+ BonoboShlibFactory *factory;
GNOME_ObjectFactory corba_factory;
g_return_val_if_fail (factory_cb != NULL, NULL);
g_return_val_if_fail (oaf_iid != NULL, NULL);
- c_factory = g_object_new (bonobo_shlib_factory_get_type (), NULL);
+ factory = g_object_new (bonobo_shlib_factory_get_type (), NULL);
corba_factory = bonobo_generic_factory_corba_object_create (
- BONOBO_GENERIC_FACTORY (c_factory), factory_cb);
+ BONOBO_GENERIC_FACTORY (factory), factory_cb);
if (corba_factory == CORBA_OBJECT_NIL) {
- g_object_unref (G_OBJECT (c_factory));
+ g_object_unref (G_OBJECT (factory));
return NULL;
}
- return bonobo_shlib_factory_construct (
- c_factory, oaf_iid, poa, oaf_impl_ptr,
- corba_factory, NULL, factory_cb, user_data);
+ return bonobo_shlib_factory_construct (factory, corba_factory,
+ oaf_iid, poa, oaf_impl_ptr,
+ factory_cb, user_data);
}
static void
Index: bonobo-shlib-factory.h
===================================================================
RCS file: /cvs/gnome/libbonobo/bonobo/bonobo-shlib-factory.h,v
retrieving revision 1.7
diff -u -u -r1.7 bonobo-shlib-factory.h
--- bonobo-shlib-factory.h 2001/04/23 14:48:34 1.7
+++ bonobo-shlib-factory.h 2001/07/27 23:26:16
@@ -26,25 +26,6 @@
#define BONOBO_IS_SHLIB_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), BONOBO_SHLIB_FACTORY_TYPE))
#define BONOBO_IS_SHLIB_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), BONOBO_SHLIB_FACTORY_TYPE))
-#define BONOBO_OAF_SHLIB_FACTORY_MULTI(oafiid, descr, fn, data) \
-static CORBA_Object \
-make_factory (PortableServer_POA poa, const char *iid, gpointer impl_ptr, \
- CORBA_Environment *ev) \
-{ \
- BonoboShlibFactory *f; \
- CORBA_Object object_ref; \
- f = bonobo_shlib_factory_new_multi (oafiid, poa, impl_ptr, fn, data); \
- object_ref = bonobo_generic_factory_corba_objref (BONOBO_GENERIC_FACTORY (f)); \
- if (BONOBO_EX (ev) || !object_ref) { \
- g_warning ("cannot get objref: '%s'", \
- bonobo_exception_get_text (ev)); \
- return CORBA_OBJECT_NIL; \
- } \
- return CORBA_Object_duplicate (object_ref, ev); \
-} \
-static OAFPluginObject plugin_list[] = {{oafiid, make_factory}, { NULL } }; \
-const OAFPlugin OAF_Plugin_info = { plugin_list, descr };
-
#define BONOBO_OAF_SHLIB_FACTORY(oafiid, descr, fn, data) \
static CORBA_Object \
make_factory (PortableServer_POA poa, const char *iid, gpointer impl_ptr, \
@@ -80,40 +61,27 @@
} BonoboShlibFactoryClass;
GType bonobo_shlib_factory_get_type (void);
+
+BonoboShlibFactory *bonobo_shlib_factory_construct (BonoboShlibFactory *factory,
+ CORBA_Object corba_factory,
+ const char *component_id,
+ PortableServer_POA poa,
+ gpointer oaf_impl_ptr,
+ BonoboFactoryCallback factory_cb,
+ gpointer user_data);
+
+BonoboShlibFactory *bonobo_shlib_factory_new (const char *component_id,
+ PortableServer_POA poa,
+ gpointer oaf_impl_ptr,
+ BonoboFactoryCallback factory_cb,
+ gpointer user_data);
-BonoboShlibFactory *bonobo_shlib_factory_construct (
- BonoboShlibFactory *c_factory,
- const char *component_id,
- PortableServer_POA poa,
- gpointer oaf_impl_ptr,
- CORBA_Object corba_factory,
- BonoboGenericFactoryFn factory,
- GnomeFactoryCallback factory_cb,
- void *data);
-
-BonoboShlibFactory *bonobo_shlib_factory_new (
- const char *component_id,
- PortableServer_POA poa,
- gpointer oaf_impl_ptr,
- BonoboGenericFactoryFn factory,
- gpointer user_data);
-
-BonoboShlibFactory *bonobo_shlib_factory_new_multi (
- const char *component_id,
- PortableServer_POA poa,
- gpointer oaf_impl_ptr,
- GnomeFactoryCallback factory_cb,
- gpointer user_data);
-
-void bonobo_shlib_factory_track_object (
- BonoboShlibFactory *factory,
- BonoboObject *object);
+void bonobo_shlib_factory_track_object (BonoboShlibFactory *factory,
+ BonoboObject *object);
-void bonobo_shlib_factory_inc_live (
- BonoboShlibFactory *factory);
+void bonobo_shlib_factory_inc_live (BonoboShlibFactory *factory);
-void bonobo_shlib_factory_dec_live (
- BonoboShlibFactory *factory);
+void bonobo_shlib_factory_dec_live (BonoboShlibFactory *factory);
G_END_DECLS
--
.--= ULLA! =---------------------. `We are not here to give users what
\ http://cactus.rulez.org \ they want' -- RMS, at GUADEC 2001
`---= cactus cactus rulez org =---'
A ferfi jutalma a no, a no jutalma, hogy o a jutalom.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]