|
|
@ -395,7 +395,12 @@ PyObject *NewScalarMapContainer( |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
|
|
|
|
|
|
ScopedPyObjectPtr obj(PyType_GenericAlloc( |
|
|
|
|
|
|
|
reinterpret_cast<PyTypeObject *>(ScalarMapContainer_Type), 0)); |
|
|
|
|
|
|
|
#else |
|
|
|
ScopedPyObjectPtr obj(PyType_GenericAlloc(&ScalarMapContainer_Type, 0)); |
|
|
|
ScopedPyObjectPtr obj(PyType_GenericAlloc(&ScalarMapContainer_Type, 0)); |
|
|
|
|
|
|
|
#endif |
|
|
|
if (obj.get() == NULL) { |
|
|
|
if (obj.get() == NULL) { |
|
|
|
return PyErr_Format(PyExc_RuntimeError, |
|
|
|
return PyErr_Format(PyExc_RuntimeError, |
|
|
|
"Could not allocate new container."); |
|
|
|
"Could not allocate new container."); |
|
|
@ -510,12 +515,6 @@ static void ScalarMapDealloc(PyObject* _self) { |
|
|
|
Py_TYPE(_self)->tp_free(_self); |
|
|
|
Py_TYPE(_self)->tp_free(_self); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static PyMappingMethods ScalarMapMappingMethods = { |
|
|
|
|
|
|
|
MapReflectionFriend::Length, // mp_length
|
|
|
|
|
|
|
|
MapReflectionFriend::ScalarMapGetItem, // mp_subscript
|
|
|
|
|
|
|
|
MapReflectionFriend::ScalarMapSetItem, // mp_ass_subscript
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static PyMethodDef ScalarMapMethods[] = { |
|
|
|
static PyMethodDef ScalarMapMethods[] = { |
|
|
|
{ "__contains__", MapReflectionFriend::Contains, METH_O, |
|
|
|
{ "__contains__", MapReflectionFriend::Contains, METH_O, |
|
|
|
"Tests whether a key is a member of the map." }, |
|
|
|
"Tests whether a key is a member of the map." }, |
|
|
@ -532,7 +531,33 @@ static PyMethodDef ScalarMapMethods[] = { |
|
|
|
{NULL, NULL}, |
|
|
|
{NULL, NULL}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
PyTypeObject ScalarMapContainer_Type = { |
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
|
|
|
|
|
|
static PyType_Slot ScalarMapContainer_Type_slots[] = { |
|
|
|
|
|
|
|
{Py_tp_dealloc, (void *)ScalarMapDealloc}, |
|
|
|
|
|
|
|
{Py_mp_length, (void *)MapReflectionFriend::Length}, |
|
|
|
|
|
|
|
{Py_mp_subscript, (void *)MapReflectionFriend::ScalarMapGetItem}, |
|
|
|
|
|
|
|
{Py_mp_ass_subscript, (void *)MapReflectionFriend::ScalarMapSetItem}, |
|
|
|
|
|
|
|
{Py_tp_methods, (void *)ScalarMapMethods}, |
|
|
|
|
|
|
|
{Py_tp_iter, (void *)MapReflectionFriend::GetIterator}, |
|
|
|
|
|
|
|
{0, 0}, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyType_Spec ScalarMapContainer_Type_spec = { |
|
|
|
|
|
|
|
FULL_MODULE_NAME ".ScalarMapContainer", |
|
|
|
|
|
|
|
sizeof(MapContainer), |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
Py_TPFLAGS_DEFAULT, |
|
|
|
|
|
|
|
ScalarMapContainer_Type_slots |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
PyObject *ScalarMapContainer_Type; |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
static PyMappingMethods ScalarMapMappingMethods = { |
|
|
|
|
|
|
|
MapReflectionFriend::Length, // mp_length
|
|
|
|
|
|
|
|
MapReflectionFriend::ScalarMapGetItem, // mp_subscript
|
|
|
|
|
|
|
|
MapReflectionFriend::ScalarMapSetItem, // mp_ass_subscript
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyTypeObject ScalarMapContainer_Type = { |
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
|
|
FULL_MODULE_NAME ".ScalarMapContainer", // tp_name
|
|
|
|
FULL_MODULE_NAME ".ScalarMapContainer", // tp_name
|
|
|
|
sizeof(MapContainer), // tp_basicsize
|
|
|
|
sizeof(MapContainer), // tp_basicsize
|
|
|
@ -569,7 +594,8 @@ PyTypeObject ScalarMapContainer_Type = { |
|
|
|
0, // tp_descr_set
|
|
|
|
0, // tp_descr_set
|
|
|
|
0, // tp_dictoffset
|
|
|
|
0, // tp_dictoffset
|
|
|
|
0, // tp_init
|
|
|
|
0, // tp_init
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MessageMap //////////////////////////////////////////////////////////////////
|
|
|
|
// MessageMap //////////////////////////////////////////////////////////////////
|
|
|
@ -613,7 +639,12 @@ PyObject* NewMessageMapContainer( |
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
|
|
|
|
|
|
PyObject* obj = PyType_GenericAlloc( |
|
|
|
|
|
|
|
reinterpret_cast<PyTypeObject *>(MessageMapContainer_Type), 0); |
|
|
|
|
|
|
|
#else |
|
|
|
PyObject* obj = PyType_GenericAlloc(&MessageMapContainer_Type, 0); |
|
|
|
PyObject* obj = PyType_GenericAlloc(&MessageMapContainer_Type, 0); |
|
|
|
|
|
|
|
#endif |
|
|
|
if (obj == NULL) { |
|
|
|
if (obj == NULL) { |
|
|
|
return PyErr_Format(PyExc_RuntimeError, |
|
|
|
return PyErr_Format(PyExc_RuntimeError, |
|
|
|
"Could not allocate new container."); |
|
|
|
"Could not allocate new container."); |
|
|
@ -735,12 +766,6 @@ static void MessageMapDealloc(PyObject* _self) { |
|
|
|
Py_TYPE(_self)->tp_free(_self); |
|
|
|
Py_TYPE(_self)->tp_free(_self); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static PyMappingMethods MessageMapMappingMethods = { |
|
|
|
|
|
|
|
MapReflectionFriend::Length, // mp_length
|
|
|
|
|
|
|
|
MapReflectionFriend::MessageMapGetItem, // mp_subscript
|
|
|
|
|
|
|
|
MapReflectionFriend::MessageMapSetItem, // mp_ass_subscript
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static PyMethodDef MessageMapMethods[] = { |
|
|
|
static PyMethodDef MessageMapMethods[] = { |
|
|
|
{ "__contains__", (PyCFunction)MapReflectionFriend::Contains, METH_O, |
|
|
|
{ "__contains__", (PyCFunction)MapReflectionFriend::Contains, METH_O, |
|
|
|
"Tests whether the map contains this element."}, |
|
|
|
"Tests whether the map contains this element."}, |
|
|
@ -759,7 +784,34 @@ static PyMethodDef MessageMapMethods[] = { |
|
|
|
{NULL, NULL}, |
|
|
|
{NULL, NULL}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
PyTypeObject MessageMapContainer_Type = { |
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
|
|
|
|
|
|
static PyType_Slot MessageMapContainer_Type_slots[] = { |
|
|
|
|
|
|
|
{Py_tp_dealloc, (void *)MessageMapDealloc}, |
|
|
|
|
|
|
|
{Py_mp_length, (void *)MapReflectionFriend::Length}, |
|
|
|
|
|
|
|
{Py_mp_subscript, (void *)MapReflectionFriend::MessageMapGetItem}, |
|
|
|
|
|
|
|
{Py_mp_ass_subscript, (void *)MapReflectionFriend::MessageMapSetItem}, |
|
|
|
|
|
|
|
{Py_tp_methods, (void *)MessageMapMethods}, |
|
|
|
|
|
|
|
{Py_tp_iter, (void *)MapReflectionFriend::GetIterator}, |
|
|
|
|
|
|
|
{0, 0} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyType_Spec MessageMapContainer_Type_spec = { |
|
|
|
|
|
|
|
FULL_MODULE_NAME ".MessageMapContainer", |
|
|
|
|
|
|
|
sizeof(MapContainer), |
|
|
|
|
|
|
|
0, |
|
|
|
|
|
|
|
Py_TPFLAGS_DEFAULT, |
|
|
|
|
|
|
|
MessageMapContainer_Type_slots |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyObject *MessageMapContainer_Type; |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
static PyMappingMethods MessageMapMappingMethods = { |
|
|
|
|
|
|
|
MapReflectionFriend::Length, // mp_length
|
|
|
|
|
|
|
|
MapReflectionFriend::MessageMapGetItem, // mp_subscript
|
|
|
|
|
|
|
|
MapReflectionFriend::MessageMapSetItem, // mp_ass_subscript
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyTypeObject MessageMapContainer_Type = { |
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
|
|
FULL_MODULE_NAME ".MessageMapContainer", // tp_name
|
|
|
|
FULL_MODULE_NAME ".MessageMapContainer", // tp_name
|
|
|
|
sizeof(MessageMapContainer), // tp_basicsize
|
|
|
|
sizeof(MessageMapContainer), // tp_basicsize
|
|
|
@ -796,7 +848,8 @@ PyTypeObject MessageMapContainer_Type = { |
|
|
|
0, // tp_descr_set
|
|
|
|
0, // tp_descr_set
|
|
|
|
0, // tp_dictoffset
|
|
|
|
0, // tp_dictoffset
|
|
|
|
0, // tp_init
|
|
|
|
0, // tp_init
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// MapIterator /////////////////////////////////////////////////////////////////
|
|
|
|
// MapIterator /////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|