perl binding namespace issues

Lately I have been working on a Perl binding for Bonobo.
I use a modified version of CORBA::ORBit for this that installs
the typemap and the header files so that other perl extensions can 
use them. Anyway the problem I had is related to how CORBA::ORBit
and modules that use the Gtk object system present the Gtk objects
and CORBA objects to the Perl programmer.

The Gtk related modules create hash references and bless them in a
package whose name is determined at compile time from the name
of the Gtk class: a GtkWindow object, for example, is blessed
in the Gtk::Window package. The same happens for objects provided
by the gnome and bonobo libraries respectively int the Gnome:: and
Bonobo:: namspace.

CORBA::ORBit uses the repo_id to bless a perl ref in a perl package.
Basically, when you write a CORBA object implemetation, you create
a package 'deriving' from POA_Repo::Id (if the repo id is IDL::Repo/Id:1.0).
On the other hand, when you hand a CORBA_OBject to CORBA::ORBit, it
creates the methods in a package named Repo::Id and blesses the
reference in that package.

Now it happens that there are both objects derived from Gtk::Object and
IDL interfaces that have conflicting namespaces. Note that this
happened in the Bonobo binding, but it's sure the problem will be bigger
as the use of CORBA and CORBA::ORBit increases.
So the problme is: do we use a different namespace for CORBA or for
the Gtk related modules (or any other module that may conflict with
a CORBA repo id)?

There is also another issue regarding the namespace used by 
CORBA::ORBit: right now it's not possible to support different
versions of the same IDL interface and while this may not look like
a problem now, it will increase as the interfaces are changed and adjusted 
with new releases.

My initial solution to the issue (namespacing all the CORBA stuff under
CORBA::) is a little ugly and doesn't solve the version problem, so I'm
proposing a different one: the perl package name embeds not only the
absolute name of the repository id, but also the version, so
objects that implement IDL::Repo/ID:1.0 get blessed in the
Repo::Id_1_0 package. This solution should solve the namespace and
version issues. Some code will need to be changed, but I'd like to
propose some guidelines to lessen the hurdle on that. Note that programmers
shouldn't care about the package a CORBA_Object is blessed into
(probably CORBA_Object_isa() should be exported as CORBA::Object::CORBA_isa,
since the isa method is already taken by Perl). So the problem is
mainly when you need to develop your own server. CORBA::ORBit already
provides CORBA::ORBit::find_interface(repoid), so, what used to be

@MyAccount::ISA = qw(POA_Account::Account);

should become:

@MyAccount::ISA = CORBA::ORBit::find_interface("IDL:Account/Acount:1.0");

And it will remain compatibile even (if) the proposed change is accepted,
or they may be changed to just this later:

@MyAccount::ISA = qw(POA_Account::Account_1_0);

The proposed patch to the C source follows the signature.
Comments welcome.


lupus debian org                                     debian/rules
lupus ximian com                             Monkeys do it better

Index: interfaces.c
RCS file: /cvs/corba-orbit-perl/interfaces.c,v
retrieving revision 1.2
diff -u -r1.2 interfaces.c
--- interfaces.c	2000/12/04 13:36:09	1.2
+++ interfaces.c	2001/01/08 19:35:49
@@ -36,11 +36,23 @@
     SV *pkg_sv;
     char *varname;
+    char *version;
     HV *hv = perl_get_hv("CORBA::ORBit::_interfaces", TRUE);
     PORBitIfaceInfo *info = g_new (PORBitIfaceInfo, 1);
-    info->pkg = g_strdup (package_name);
+    version = rindex(desc->id, ':');
+    if (version) {
+	int i;
+	version = g_strdup(version);
+	for (i=0; version[i]; ++i) {
+	    if (version[i] == ':' || version[i] == '.')
+		version[i] = '_';
+	}
+    }
+    info->pkg = g_strconcat (package_name, version, NULL);
+    g_free(version);
     info->desc = desc;
     info->class_id = 0;

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