Discussion:
[omniORB] [PATCH] add support for setraises and getraises
Wei Jiang
2009-07-23 15:06:13 UTC
Permalink
Hi,
Since most ORBs already support setraises and getraises, so I made a
patch for omniORB and omniORBpy.

And full tested.

y.tab.* and lex.yy.cc are excluded from the patch, please recompile
idl.ll and idl.yy.


********************** IDL Compiler Test ************************

[***@lt ~]$ cat test.idl

typedef string X,Y,Z;

interface TestAttr {
exception WrongTime { };
exception WrongPlace { };

struct Point { float x,y,z; };

readonly attribute double value raises(WrongTime, WrongPlace);
attribute Point xyz getraises(WrongTime) setraises(WrongPlace);
};

[***@lt ~]$ omniidl -bdump test.idl
typedef string X, Y, Z;
interface TestAttr {
exception WrongTime {
};
exception WrongPlace {
};
struct Point {
float x, y, z;
};
readonly attribute double value raises (TestAttr::WrongTime,
TestAttr::WrongPlace);
attribute ::TestAttr::Point xyz getraises (TestAttr::WrongTime)
setraises (TestAttr::WrongPlace);
};

[***@lt ~]$ omniidl -d test.idl

typedef string X, Y, Z;

interface TestAttr { // RepoId = IDL:TestAttr:1.0
exception WrongTime {
};
exception WrongPlace {
};
struct Point { // RepoId = IDL:TestAttr/Point:1.0
float x, y, z;
};
readonly attribute double value raises (TestAttr::WrongTime,
TestAttr::WrongPlace);
attribute TestAttr::Point xyz getraises (TestAttr::WrongTime)
setraises (TestAttr::WrongPlace);
};

[***@lt ~]$ omniidl -bpython -Wbstdout test.idl
... ...
# TestAttr operations and attributes
TestAttr._d__get_value =
((),(omniORB.tcInternal.tv_double,),{_0__GlobalIDL.TestAttr.WrongTime._NP_RepositoryId:
_0__GlobalIDL.TestAttr._d_WrongTime,
_0__GlobalIDL.TestAttr.WrongPlace._NP_RepositoryId:
_0__GlobalIDL.TestAttr._d_WrongPlace})
TestAttr._d__get_xyz =
((),(omniORB.typeMapping["IDL:TestAttr/Point:1.0"],),{_0__GlobalIDL.TestAttr.WrongTime._NP_RepositoryId:
_0__GlobalIDL.TestAttr._d_WrongTime})
TestAttr._d__set_xyz =
((omniORB.typeMapping["IDL:TestAttr/Point:1.0"],),(),{_0__GlobalIDL.TestAttr.WrongPlace._NP_RepositoryId:
_0__GlobalIDL.TestAttr._d_WrongPlace})

... ...

[***@lt ~]$ omniidl -bcxx test.idl && cat testSK.cc

... ...
const char* const _0RL_cd_c3e75e47f9aa5034_00000000::_user_exns[] = {
TestAttr::WrongPlace::_PD_repoId,
TestAttr::WrongTime::_PD_repoId
};

void _0RL_cd_c3e75e47f9aa5034_00000000::userException(cdrStream& s,
_OMNI_NS(IOP_C)* iop_client, const char* repoId)
{
if ( omni::strMatch(repoId, TestAttr::WrongPlace::_PD_repoId) ) {
TestAttr::WrongPlace _ex;
_ex <<= s;
if (iop_client) iop_client->RequestCompleted();
throw _ex;
}

if ( omni::strMatch(repoId, TestAttr::WrongTime::_PD_repoId) ) {
TestAttr::WrongTime _ex;
_ex <<= s;
if (iop_client) iop_client->RequestCompleted();
throw _ex;
}

... ...


****************************Python Server & Client
Test*****************************************
*Python Server*

class TestAttr_i (_GlobalIDL__POA.TestAttr):

def __init__(self):
pass

# readonly attribute double value
def _get_value(self):
raise _GlobalIDL.TestAttr.WrongTime()

# attribute TestAttr::Point xyz
def _set_xyz(self, value):
raise _GlobalIDL.TestAttr.WrongPlace()

# attribute TestAttr::Point xyz
def _get_xyz(self):
raise _GlobalIDL.TestAttr.WrongTime()

*Python Client*

try:
o._get_value()
except Exception,e:
print e

try:
o._set_xyz(TestAttr.Point(1,2,3))
except Exception,e:
print e

try:
o._get_xyz()
except Exception,e:
print e

* run *
[***@lt t]$ python test_idl_example.py
IOR:010000001100000049444c3a5465...
[***@lt t]$ python client.py IOR:010000001100000049444...
_GlobalIDL.TestAttr.WrongTime()
_GlobalIDL.TestAttr.WrongPlace()
_GlobalIDL.TestAttr.WrongTime()


****************************C++ Server & Client
Test*****************************************
* C++ Server Code*
... ...
::CORBA::Double TestAttr_i::value(){
throw TestAttr::WrongTime();
}

void TestAttr_i::xyz(const TestAttr::Point&){
throw TestAttr::WrongPlace();
}

TestAttr::Point TestAttr_i::xyz(){
throw TestAttr::WrongTime();
}
... ...

* C++ Client Code*
... ...
try {
t->value();
} catch (TestAttr::WrongTime &) {
std::cout << "TestAttr::WrongTime" << std::endl;
} catch (TestAttr::WrongPlace &) {
std::cout << "TestAttr::WrongPlace" << std::endl;
}
try {
t->xyz(TestAttr::Point());
} catch (TestAttr::WrongTime &) {
std::cout << "TestAttr::WrongTime" << std::endl;
} catch (TestAttr::WrongPlace &) {
std::cout << "TestAttr::WrongPlace" << std::endl;
}
try {
t->xyz();
} catch (TestAttr::WrongTime &) {
std::cout << "TestAttr::WrongTime" << std::endl;
} catch (TestAttr::WrongPlace &) {
std::cout << "TestAttr::WrongPlace" << std::endl;
}

... ...

*run*
[***@lt ~]$ ./server
IDL object TestAttr IOR = 'IOR:010000001100000049444c3a5465737441747...'

[***@lt ~]$ ./client
IOR:010000001100000049444c3a54657374417474723a312e300000000...
TestAttr::WrongTime
TestAttr::WrongPlace
TestAttr::WrongTime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attr_raises.patch
Type: application/octet-stream
Size: 17552 bytes
Desc: not available
Url : http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20090723/e5db5e2d/attr_raises-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attr_raises_py.patch
Type: application/octet-stream
Size: 3267 bytes
Desc: not available
Url : http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20090723/e5db5e2d/attr_raises_py-0001.obj
Loading...