summaryrefslogtreecommitdiff
path: root/py/modules/IcePy/Current.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2012-04-30 11:57:21 +0200
committerBenoit Foucher <benoit@zeroc.com>2012-04-30 11:57:21 +0200
commit06024a6fc1ceb70d70e41f93ba0016edefe36289 (patch)
tree40f4bdf32862e466d059bbf0dd1a7293aa522604 /py/modules/IcePy/Current.cpp
parentWin32 fixes, C# port (diff)
downloadice-06024a6fc1ceb70d70e41f93ba0016edefe36289.tar.bz2
ice-06024a6fc1ceb70d70e41f93ba0016edefe36289.tar.xz
ice-06024a6fc1ceb70d70e41f93ba0016edefe36289.zip
Python port, added tests to Ice/info
Diffstat (limited to 'py/modules/IcePy/Current.cpp')
-rw-r--r--py/modules/IcePy/Current.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/py/modules/IcePy/Current.cpp b/py/modules/IcePy/Current.cpp
index 865e9f8ab02..7082d2ed0f2 100644
--- a/py/modules/IcePy/Current.cpp
+++ b/py/modules/IcePy/Current.cpp
@@ -35,6 +35,7 @@ struct CurrentObject
PyObject* mode;
PyObject* ctx;
PyObject* requestId;
+ PyObject* encoding;
};
//
@@ -48,6 +49,7 @@ const Py_ssize_t CURRENT_OPERATION = 4;
const Py_ssize_t CURRENT_MODE = 5;
const Py_ssize_t CURRENT_CTX = 6;
const Py_ssize_t CURRENT_REQUEST_ID = 7;
+const Py_ssize_t CURRENT_ENCODING = 8;
}
@@ -72,6 +74,7 @@ currentNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/)
self->mode = 0;
self->ctx = 0;
self->requestId = 0;
+ self->encoding = 0;
return self;
}
@@ -90,6 +93,7 @@ currentDealloc(CurrentObject* self)
Py_XDECREF(self->mode);
Py_XDECREF(self->ctx);
Py_XDECREF(self->requestId);
+ Py_XDECREF(self->encoding);
delete self->current;
Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self));
}
@@ -223,6 +227,17 @@ currentGetter(CurrentObject* self, void* closure)
result = self->requestId;
break;
}
+ case CURRENT_ENCODING:
+ {
+ if(!self->encoding)
+ {
+ self->encoding = IcePy::createEncodingVersion(self->current->encoding);
+ assert(self->encoding);
+ }
+ Py_INCREF(self->encoding);
+ result = self->encoding;
+ break;
+ }
}
return result;
@@ -246,6 +261,8 @@ static PyGetSetDef CurrentGetSetters[] =
reinterpret_cast<void*>(CURRENT_CTX) },
{ STRCAST("requestId"), reinterpret_cast<getter>(currentGetter), 0, STRCAST("requestId"),
reinterpret_cast<void*>(CURRENT_REQUEST_ID) },
+ { STRCAST("encoding"), reinterpret_cast<getter>(currentGetter), 0, STRCAST("encoding"),
+ reinterpret_cast<void*>(CURRENT_ENCODING) },
{ 0 } /* Sentinel */
};