[omniORB] [Fwd: Omniifr backend for omniidl -- a bug fix (hopefully)]

Leandro Fanzone leandro@hasar.com
Tue, 26 Feb 2002 12:48:05 -0300


--------------091EAFEE352DEF9B0CE2763B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello, Duncan. I'm sorry that you had to take the duty of omniifr too. I
send you the last mail I sent them with (probably) the things to be done
to fix what I found. I hope this will  help someone else also working
with omniifr.

Leandro Fanzone.

-------- Original Message --------
Subject: Omniifr backend for omniidl -- a bug fix (hopefully)
   Date: Mon, 03 Dec 2001 15:05:20 -0300
   From: Leandro Fanzone <leandro@hasar.com>
     To: dreyes@factoriaX.com, marc@factoriaX.com

I did not receive any feedback of the last mails I sent you with
problems; I fixed them myself but I'm not sure it will work for
everything else. It works actually for a huge amount of IDLs I have
here. Here's the description of what I did.
The original ifr.py backend for omniifr has a bug when looking for
exceptions raised by operations, it only looks for the simple name of
the exception (scopedName()[-1]) without paying attention to the rest.

Thus this IDL loads incorrectly:

exception jj {};

module m1
{
    exception MyError {};
    interface p
    {
        enum e {a, b, c};
        void ff() raises(MyError);
    };
};

module m2
{
    interface q
    {
        enum e {d1, e1, f1};
        exception MyError{};
        void f(in e ii) raises(MyError, jj);
    };
};

If you feed this IDL into omniifr, m2::q::f() is declared to raise
m1::Myerror, which is incorrect (it really raises m2::q::MyError).

Looking at ifr.py, I realized that getException() had a patch at the
beginning that was obviously responsible for this behaviour. I commented
the patch and the code that followed seemed to work properly, except
that it failed if the IDL had a "#pragma prefix" in it, since that code
was only looking for a fixed prefix of "IDL:".

I changed ifr.py by passing repoId() instead of scopedName() to
getException(), and matching the whole qualified string. The resulting
code is simpler and seems to work with and without prefix (I tested it
with the above sample IDL adding a "#pragma prefix" at the beginning,
and with some complex IDLs line CosNaming.idl which have a prefix of
"omg.org").

The previous code in ifr.py was as follows:

[line 636]

       if len(node.raises()) > 0:
            for ra in node.raises():
                ex = iraccess.getException( ra.scopedName() )

[line 829]

    def getException( self, name ):
        for ex in self.listExceptionsDef:
            if name[-1] == ex._get_name():
                return ex
        return None

        localname = "IDL:"
        for n in name:
            localname = localname + n + "/"
        print localname
        for ex in self.listExceptionsDef:
            temp = ex._get_id()
            if len(temp) - 1 < len( localname ):
                continue
            equal = 1
            for i in range( len( localname ) - 1 ):
                if localname[ i ] <> temp[ i ]:
                    equal = 0
                    break
            if equal == 1:
                return ex
        return None

The new code in ifr.py is as follows:

[line 636]

        if len(node.raises()) > 0:
            for ra in node.raises():
                ex = iraccess.getException( ra.repoId() )

[line 829]

    def getException( self, name ):
        for ex in self.listExceptionsDef:
            if ex._get_id() == name:
                return ex
        return None

I would appreciate your confirmation of whether this fix is OK or
perhaps it creates some other problems.

Thank you, and best regards.

Leandro Fanzone

--------------091EAFEE352DEF9B0CE2763B
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hello, Duncan. I'm sorry that you had to take the duty of omniifr too.
I send you the last mail I sent them with (probably) the things to be done
to fix what I found. I hope this will&nbsp; help someone else also working
with omniifr.
<p>Leandro Fanzone.
<p>-------- Original Message --------
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 >
<tr>
<th ALIGN=RIGHT VALIGN=BASELINE NOWRAP>Subject:&nbsp;</th>

<td>Omniifr backend for omniidl -- a bug fix (hopefully)</td>
</tr>

<tr>
<th ALIGN=RIGHT VALIGN=BASELINE NOWRAP>Date:&nbsp;</th>

<td>Mon, 03 Dec 2001 15:05:20 -0300</td>
</tr>

<tr>
<th ALIGN=RIGHT VALIGN=BASELINE NOWRAP>From:&nbsp;</th>

<td>Leandro Fanzone &lt;leandro@hasar.com></td>
</tr>

<tr>
<th ALIGN=RIGHT VALIGN=BASELINE NOWRAP>To:&nbsp;</th>

<td>dreyes@factoriaX.com, marc@factoriaX.com</td>
</tr>
</table>

<p><tt>I did not receive any feedback of the last mails I sent you with
problems; I fixed them myself but I'm not sure it will work for everything
else. It works actually for a huge amount of IDLs I have here. Here's the
description of what I did.</tt>
<br><tt>The original ifr.py backend for omniifr has a bug when looking
for exceptions raised by operations, it only looks for the simple name
of the exception (scopedName()[-1]) without paying attention to the rest.</tt>
<p><tt>Thus this IDL loads incorrectly:</tt>
<p><tt>exception jj {};</tt>
<p><tt>module m1</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp; exception MyError {};</tt>
<br><tt>&nbsp;&nbsp;&nbsp; interface p</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum e {a, b, c};</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void ff() raises(MyError);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; };</tt>
<br><tt>};</tt>
<p><tt>module m2</tt>
<br><tt>{</tt>
<br><tt>&nbsp;&nbsp;&nbsp; interface q</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enum e {d1, e1, f1};</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exception MyError{};</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void f(in e ii) raises(MyError,
jj);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; };</tt>
<br><tt>};</tt>
<p><tt>If you feed this IDL into omniifr, m2::q::f() is declared to raise
m1::Myerror, which is incorrect (it really raises m2::q::MyError).</tt>
<p><tt>Looking at ifr.py, I realized that getException() had a patch at
the beginning that was obviously responsible for this behaviour. I commented
the patch and the code that followed seemed to work properly, except that
it failed if the IDL had a "#pragma prefix" in it, since that code was
only looking for a fixed prefix of "IDL:".</tt>
<p><tt>I changed ifr.py by passing repoId() instead of scopedName() to
getException(), and matching the whole qualified string. The resulting
code is simpler and seems to work with and without prefix (I tested it
with the above sample IDL adding a "#pragma prefix" at the beginning, and
with some complex IDLs line CosNaming.idl which have a prefix of "omg.org").</tt>
<p><tt>The previous code in ifr.py was as follows:</tt>
<p><tt>[line 636]</tt>
<p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if len(node.raises()) > 0:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
for ra in node.raises():</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ex = iraccess.getException( ra.scopedName() )</tt>
<p><tt>[line 829]</tt>
<p><tt>&nbsp;&nbsp;&nbsp; def getException( self, name ):</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ex in self.listExceptionsDef:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if name[-1] == ex._get_name():</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return ex</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return None</tt>
<p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; localname = "IDL:"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for n in name:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
localname = localname + n + "/"</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print localname</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ex in self.listExceptionsDef:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
temp = ex._get_id()</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if len(temp) - 1 &lt; len( localname ):</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
continue</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
equal = 1</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
for i in range( len( localname ) - 1 ):</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if localname[ i ] &lt;> temp[ i ]:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
equal = 0</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
break</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if equal == 1:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return ex</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return None</tt>
<p><tt>The new code in ifr.py is as follows:</tt>
<p><tt>[line 636]</tt>
<p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if len(node.raises())
> 0:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
for ra in node.raises():</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ex = iraccess.getException( ra.repoId() )</tt>
<p><tt>[line 829]</tt>
<p><tt>&nbsp;&nbsp;&nbsp; def getException( self, name ):</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ex in self.listExceptionsDef:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if ex._get_id() == name:</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
return ex</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return None</tt>
<p><tt>I would appreciate your confirmation of whether this fix is OK or
perhaps it creates some other problems.</tt>
<p><tt>Thank you, and best regards.</tt>
<p><tt>Leandro Fanzone</tt></html>

--------------091EAFEE352DEF9B0CE2763B--