summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/ConnectionInfo.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2009-10-23 10:00:17 -0230
committerDwayne Boone <dwayne@zeroc.com>2009-10-23 10:00:17 -0230
commit278f7856b4b906aea4199eda8294b46064ec4ce8 (patch)
tree6ac95560911cad6acb3253b5d5d258dbea993edc /py/modules/IcePy/ConnectionInfo.cpp
parentPHP fixes for 5.3 (diff)
downloadice-278f7856b4b906aea4199eda8294b46064ec4ce8.tar.bz2
ice-278f7856b4b906aea4199eda8294b46064ec4ce8.tar.xz
ice-278f7856b4b906aea4199eda8294b46064ec4ce8.zip
Port latest Endpoint/ConnectionInfo changes to python/ruby
Added Ice/info test to python/ruby Modified allTest to not run info test for compress or ipv6 Added Endpoint comparison methods to python/ruby
Diffstat (limited to 'py/modules/IcePy/ConnectionInfo.cpp')
-rw-r--r--py/modules/IcePy/ConnectionInfo.cpp169
1 files changed, 109 insertions, 60 deletions
diff --git a/py/modules/IcePy/ConnectionInfo.cpp b/py/modules/IcePy/ConnectionInfo.cpp
index e9820ee87b0..d84cd00431b 100644
--- a/py/modules/IcePy/ConnectionInfo.cpp
+++ b/py/modules/IcePy/ConnectionInfo.cpp
@@ -31,21 +31,22 @@ struct ConnectionInfoObject
//
// ConnectionInfo members
//
-#define MEMBER_ENDPOINT 0
+#define MEMBER_INCOMING 0
+#define MEMBER_ADAPTER_NAME 1
//
-// Shared TCP/UDP members
+// IPConnectionInfo members
//
-#define MEMBER_LOCAL_ADDRESS 1
-#define MEMBER_LOCAL_PORT 2
-#define MEMBER_REMOTE_ADDRESS 3
-#define MEMBER_REMOTE_PORT 4
+#define MEMBER_LOCAL_ADDRESS 2
+#define MEMBER_LOCAL_PORT 3
+#define MEMBER_REMOTE_ADDRESS 4
+#define MEMBER_REMOTE_PORT 5
//
-// UdpConnectionInfo members
+// UDPConnectionInfo members
//
-#define MEMBER_MCAST_ADDRESS 5
-#define MEMBER_MCAST_PORT 6
+#define MEMBER_MCAST_ADDRESS 6
+#define MEMBER_MCAST_PORT 7
#ifdef WIN32
extern "C"
@@ -78,8 +79,11 @@ connectionInfoGetter(ConnectionInfoObject* self, void* closure)
switch(member)
{
- case MEMBER_ENDPOINT:
- result = createEndpointInfo((*self->connectionInfo)->endpoint);
+ case MEMBER_INCOMING:
+ result = (*self->connectionInfo)->incoming ? getTrue() : getFalse();
+ break;
+ case MEMBER_ADAPTER_NAME:
+ result = createString((*self->connectionInfo)->adapterName);
break;
default:
assert(false);
@@ -92,11 +96,11 @@ connectionInfoGetter(ConnectionInfoObject* self, void* closure)
extern "C"
#endif
static PyObject*
-tcpConnectionInfoGetter(ConnectionInfoObject* self, void* closure)
+ipConnectionInfoGetter(ConnectionInfoObject* self, void* closure)
{
int member = reinterpret_cast<int>(closure);
PyObject* result = 0;
- Ice::TcpConnectionInfoPtr info = Ice::TcpConnectionInfoPtr::dynamicCast(*self->connectionInfo);
+ Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
assert(info);
switch(member)
@@ -128,23 +132,11 @@ udpConnectionInfoGetter(ConnectionInfoObject* self, void* closure)
{
int member = reinterpret_cast<int>(closure);
PyObject* result = 0;
- Ice::UdpConnectionInfoPtr info = Ice::UdpConnectionInfoPtr::dynamicCast(*self->connectionInfo);
+ Ice::UDPConnectionInfoPtr info = Ice::UDPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
assert(info);
switch(member)
{
- case MEMBER_LOCAL_ADDRESS:
- result = createString(info->localAddress);
- break;
- case MEMBER_LOCAL_PORT:
- result = PyInt_FromLong(info->localPort);
- break;
- case MEMBER_REMOTE_ADDRESS:
- result = createString(info->remoteAddress);
- break;
- case MEMBER_REMOTE_PORT:
- result = PyInt_FromLong(info->remotePort);
- break;
case MEMBER_MCAST_ADDRESS:
result = createString(info->mcastAddress);
break;
@@ -160,34 +152,28 @@ udpConnectionInfoGetter(ConnectionInfoObject* self, void* closure)
static PyGetSetDef ConnectionInfoGetters[] =
{
- { STRCAST("endpoint"), reinterpret_cast<getter>(connectionInfoGetter), 0,
- PyDoc_STR(STRCAST("endpoint used to establish the connection")), reinterpret_cast<void*>(MEMBER_ENDPOINT) },
+ { STRCAST("incoming"), reinterpret_cast<getter>(connectionInfoGetter), 0,
+ PyDoc_STR(STRCAST("whether connection is incoming")), reinterpret_cast<void*>(MEMBER_INCOMING) },
+ { STRCAST("adapterName"), reinterpret_cast<getter>(connectionInfoGetter), 0,
+ PyDoc_STR(STRCAST("adapter associated the connection")), reinterpret_cast<void*>(MEMBER_ADAPTER_NAME) },
{ 0, 0 } /* sentinel */
};
-static PyGetSetDef TcpConnectionInfoGetters[] =
+static PyGetSetDef IPConnectionInfoGetters[] =
{
- { STRCAST("localAddress"), reinterpret_cast<getter>(tcpConnectionInfoGetter), 0,
+ { STRCAST("localAddress"), reinterpret_cast<getter>(ipConnectionInfoGetter), 0,
PyDoc_STR(STRCAST("local address")), reinterpret_cast<void*>(MEMBER_LOCAL_ADDRESS) },
- { STRCAST("localPort"), reinterpret_cast<getter>(tcpConnectionInfoGetter), 0,
+ { STRCAST("localPort"), reinterpret_cast<getter>(ipConnectionInfoGetter), 0,
PyDoc_STR(STRCAST("local port")), reinterpret_cast<void*>(MEMBER_LOCAL_PORT) },
- { STRCAST("remoteAddress"), reinterpret_cast<getter>(tcpConnectionInfoGetter), 0,
+ { STRCAST("remoteAddress"), reinterpret_cast<getter>(ipConnectionInfoGetter), 0,
PyDoc_STR(STRCAST("remote address")), reinterpret_cast<void*>(MEMBER_REMOTE_ADDRESS) },
- { STRCAST("remotePort"), reinterpret_cast<getter>(tcpConnectionInfoGetter), 0,
+ { STRCAST("remotePort"), reinterpret_cast<getter>(ipConnectionInfoGetter), 0,
PyDoc_STR(STRCAST("remote port")), reinterpret_cast<void*>(MEMBER_REMOTE_PORT) },
{ 0, 0 } /* sentinel */
};
-static PyGetSetDef UdpConnectionInfoGetters[] =
+static PyGetSetDef UDPConnectionInfoGetters[] =
{
- { STRCAST("localAddress"), reinterpret_cast<getter>(udpConnectionInfoGetter), 0,
- PyDoc_STR(STRCAST("local address")), reinterpret_cast<void*>(MEMBER_LOCAL_ADDRESS) },
- { STRCAST("localPort"), reinterpret_cast<getter>(udpConnectionInfoGetter), 0,
- PyDoc_STR(STRCAST("local port")), reinterpret_cast<void*>(MEMBER_LOCAL_PORT) },
- { STRCAST("remoteAddress"), reinterpret_cast<getter>(udpConnectionInfoGetter), 0,
- PyDoc_STR(STRCAST("remote address")), reinterpret_cast<void*>(MEMBER_REMOTE_ADDRESS) },
- { STRCAST("remotePort"), reinterpret_cast<getter>(udpConnectionInfoGetter), 0,
- PyDoc_STR(STRCAST("remote port")), reinterpret_cast<void*>(MEMBER_REMOTE_PORT) },
{ STRCAST("mcastAddress"), reinterpret_cast<getter>(udpConnectionInfoGetter), 0,
PyDoc_STR(STRCAST("multicast address")), reinterpret_cast<void*>(MEMBER_MCAST_ADDRESS) },
{ STRCAST("mcastPort"), reinterpret_cast<getter>(udpConnectionInfoGetter), 0,
@@ -246,13 +232,13 @@ PyTypeObject ConnectionInfoType =
0, /* tp_is_gc */
};
-PyTypeObject TcpConnectionInfoType =
+PyTypeObject IPConnectionInfoType =
{
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
PyObject_HEAD_INIT(0)
0, /* ob_size */
- STRCAST("IcePy.TcpConnectionInfo"),/* tp_name */
+ STRCAST("IcePy.IPConnectionInfo"), /* tp_name */
sizeof(ConnectionInfoObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
@@ -281,7 +267,7 @@ PyTypeObject TcpConnectionInfoType =
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
- TcpConnectionInfoGetters, /* tp_getset */
+ IPConnectionInfoGetters, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
@@ -294,13 +280,13 @@ PyTypeObject TcpConnectionInfoType =
0, /* tp_is_gc */
};
-PyTypeObject UdpConnectionInfoType =
+PyTypeObject TCPConnectionInfoType =
{
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
PyObject_HEAD_INIT(0)
0, /* ob_size */
- STRCAST("IcePy.UdpConnectionInfo"),/* tp_name */
+ STRCAST("IcePy.TCPConnectionInfo"),/* tp_name */
sizeof(ConnectionInfoObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
@@ -329,7 +315,55 @@ PyTypeObject UdpConnectionInfoType =
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
- UdpConnectionInfoGetters, /* tp_getset */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ (newfunc)connectionInfoNew, /* tp_new */
+ 0, /* tp_free */
+ 0, /* tp_is_gc */
+};
+
+PyTypeObject UDPConnectionInfoType =
+{
+ /* The ob_type field must be initialized in the module init function
+ * to be portable to Windows without using C++. */
+ PyObject_HEAD_INIT(0)
+ 0, /* ob_size */
+ STRCAST("IcePy.UDPConnectionInfo"),/* tp_name */
+ sizeof(ConnectionInfoObject), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)connectionInfoDealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ UDPConnectionInfoGetters, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
@@ -357,24 +391,35 @@ IcePy::initConnectionInfo(PyObject* module)
return false;
}
- TcpConnectionInfoType.tp_base = &ConnectionInfoType; // Force inheritance from ConnectionInfoType.
- if(PyType_Ready(&TcpConnectionInfoType) < 0)
+ IPConnectionInfoType.tp_base = &ConnectionInfoType; // Force inheritance from ConnectionInfoType.
+ if(PyType_Ready(&IPConnectionInfoType) < 0)
{
return false;
}
- type = &TcpConnectionInfoType; // Necessary to prevent GCC's strict-alias warnings.
- if(PyModule_AddObject(module, STRCAST("TcpConnectionInfo"), reinterpret_cast<PyObject*>(type)) < 0)
+ type = &IPConnectionInfoType; // Necessary to prevent GCC's strict-alias warnings.
+ if(PyModule_AddObject(module, STRCAST("IPConnectionInfo"), reinterpret_cast<PyObject*>(type)) < 0)
{
return false;
}
- UdpConnectionInfoType.tp_base = &ConnectionInfoType; // Force inheritance from ConnectionType.
- if(PyType_Ready(&UdpConnectionInfoType) < 0)
+ TCPConnectionInfoType.tp_base = &IPConnectionInfoType; // Force inheritance from IPConnectionInfoType.
+ if(PyType_Ready(&TCPConnectionInfoType) < 0)
{
return false;
}
- type = &UdpConnectionInfoType; // Necessary to prevent GCC's strict-alias warnings.
- if(PyModule_AddObject(module, STRCAST("UdpConnectionInfo"), reinterpret_cast<PyObject*>(type)) < 0)
+ type = &TCPConnectionInfoType; // Necessary to prevent GCC's strict-alias warnings.
+ if(PyModule_AddObject(module, STRCAST("TCPConnectionInfo"), reinterpret_cast<PyObject*>(type)) < 0)
+ {
+ return false;
+ }
+
+ UDPConnectionInfoType.tp_base = &IPConnectionInfoType; // Force inheritance from IPConnectionType.
+ if(PyType_Ready(&UDPConnectionInfoType) < 0)
+ {
+ return false;
+ }
+ type = &UDPConnectionInfoType; // Necessary to prevent GCC's strict-alias warnings.
+ if(PyModule_AddObject(module, STRCAST("UDPConnectionInfo"), reinterpret_cast<PyObject*>(type)) < 0)
{
return false;
}
@@ -394,13 +439,17 @@ PyObject*
IcePy::createConnectionInfo(const Ice::ConnectionInfoPtr& connectionInfo)
{
PyTypeObject* type;
- if(Ice::TcpConnectionInfoPtr::dynamicCast(connectionInfo))
+ if(Ice::TCPConnectionInfoPtr::dynamicCast(connectionInfo))
+ {
+ type = &TCPConnectionInfoType;
+ }
+ else if(Ice::UDPConnectionInfoPtr::dynamicCast(connectionInfo))
{
- type = &TcpConnectionInfoType;
+ type = &UDPConnectionInfoType;
}
- else if(Ice::UdpConnectionInfoPtr::dynamicCast(connectionInfo))
+ else if(Ice::IPConnectionInfoPtr::dynamicCast(connectionInfo))
{
- type = &UdpConnectionInfoType;
+ type = &IPConnectionInfoType;
}
else
{