|
|
@ -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,44 +531,71 @@ static PyMethodDef ScalarMapMethods[] = { |
|
|
|
{NULL, NULL}, |
|
|
|
{NULL, NULL}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
PyTypeObject ScalarMapContainer_Type = { |
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
|
|
static PyType_Slot ScalarMapContainer_Type_slots[] = { |
|
|
|
FULL_MODULE_NAME ".ScalarMapContainer", // tp_name
|
|
|
|
{Py_tp_dealloc, (void *)ScalarMapDealloc}, |
|
|
|
sizeof(MapContainer), // tp_basicsize
|
|
|
|
{Py_mp_length, (void *)MapReflectionFriend::Length}, |
|
|
|
0, // tp_itemsize
|
|
|
|
{Py_mp_subscript, (void *)MapReflectionFriend::ScalarMapGetItem}, |
|
|
|
ScalarMapDealloc, // tp_dealloc
|
|
|
|
{Py_mp_ass_subscript, (void *)MapReflectionFriend::ScalarMapSetItem}, |
|
|
|
0, // tp_print
|
|
|
|
{Py_tp_methods, (void *)ScalarMapMethods}, |
|
|
|
0, // tp_getattr
|
|
|
|
{Py_tp_iter, (void *)MapReflectionFriend::GetIterator}, |
|
|
|
0, // tp_setattr
|
|
|
|
{0, 0}, |
|
|
|
0, // tp_compare
|
|
|
|
}; |
|
|
|
0, // tp_repr
|
|
|
|
|
|
|
|
0, // tp_as_number
|
|
|
|
PyType_Spec ScalarMapContainer_Type_spec = { |
|
|
|
0, // tp_as_sequence
|
|
|
|
FULL_MODULE_NAME ".ScalarMapContainer", |
|
|
|
&ScalarMapMappingMethods, // tp_as_mapping
|
|
|
|
sizeof(MapContainer), |
|
|
|
0, // tp_hash
|
|
|
|
0, |
|
|
|
0, // tp_call
|
|
|
|
Py_TPFLAGS_DEFAULT, |
|
|
|
0, // tp_str
|
|
|
|
ScalarMapContainer_Type_slots |
|
|
|
0, // tp_getattro
|
|
|
|
}; |
|
|
|
0, // tp_setattro
|
|
|
|
PyObject *ScalarMapContainer_Type; |
|
|
|
0, // tp_as_buffer
|
|
|
|
#else |
|
|
|
Py_TPFLAGS_DEFAULT, // tp_flags
|
|
|
|
static PyMappingMethods ScalarMapMappingMethods = { |
|
|
|
"A scalar map container", // tp_doc
|
|
|
|
MapReflectionFriend::Length, // mp_length
|
|
|
|
0, // tp_traverse
|
|
|
|
MapReflectionFriend::ScalarMapGetItem, // mp_subscript
|
|
|
|
0, // tp_clear
|
|
|
|
MapReflectionFriend::ScalarMapSetItem, // mp_ass_subscript
|
|
|
|
0, // tp_richcompare
|
|
|
|
}; |
|
|
|
0, // tp_weaklistoffset
|
|
|
|
|
|
|
|
MapReflectionFriend::GetIterator, // tp_iter
|
|
|
|
PyTypeObject ScalarMapContainer_Type = { |
|
|
|
0, // tp_iternext
|
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
|
|
ScalarMapMethods, // tp_methods
|
|
|
|
FULL_MODULE_NAME ".ScalarMapContainer", // tp_name
|
|
|
|
0, // tp_members
|
|
|
|
sizeof(MapContainer), // tp_basicsize
|
|
|
|
0, // tp_getset
|
|
|
|
0, // tp_itemsize
|
|
|
|
0, // tp_base
|
|
|
|
ScalarMapDealloc, // tp_dealloc
|
|
|
|
0, // tp_dict
|
|
|
|
0, // tp_print
|
|
|
|
0, // tp_descr_get
|
|
|
|
0, // tp_getattr
|
|
|
|
0, // tp_descr_set
|
|
|
|
0, // tp_setattr
|
|
|
|
0, // tp_dictoffset
|
|
|
|
0, // tp_compare
|
|
|
|
0, // tp_init
|
|
|
|
0, // tp_repr
|
|
|
|
}; |
|
|
|
0, // tp_as_number
|
|
|
|
|
|
|
|
0, // tp_as_sequence
|
|
|
|
|
|
|
|
&ScalarMapMappingMethods, // 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, // tp_flags
|
|
|
|
|
|
|
|
"A scalar map container", // tp_doc
|
|
|
|
|
|
|
|
0, // tp_traverse
|
|
|
|
|
|
|
|
0, // tp_clear
|
|
|
|
|
|
|
|
0, // tp_richcompare
|
|
|
|
|
|
|
|
0, // tp_weaklistoffset
|
|
|
|
|
|
|
|
MapReflectionFriend::GetIterator, // tp_iter
|
|
|
|
|
|
|
|
0, // tp_iternext
|
|
|
|
|
|
|
|
ScalarMapMethods, // tp_methods
|
|
|
|
|
|
|
|
0, // tp_members
|
|
|
|
|
|
|
|
0, // tp_getset
|
|
|
|
|
|
|
|
0, // tp_base
|
|
|
|
|
|
|
|
0, // tp_dict
|
|
|
|
|
|
|
|
0, // tp_descr_get
|
|
|
|
|
|
|
|
0, // tp_descr_set
|
|
|
|
|
|
|
|
0, // tp_dictoffset
|
|
|
|
|
|
|
|
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,44 +784,72 @@ static PyMethodDef MessageMapMethods[] = { |
|
|
|
{NULL, NULL}, |
|
|
|
{NULL, NULL}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
PyTypeObject MessageMapContainer_Type = { |
|
|
|
#if PY_MAJOR_VERSION >= 3 |
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
|
|
static PyType_Slot MessageMapContainer_Type_slots[] = { |
|
|
|
FULL_MODULE_NAME ".MessageMapContainer", // tp_name
|
|
|
|
{Py_tp_dealloc, (void *)MessageMapDealloc}, |
|
|
|
sizeof(MessageMapContainer), // tp_basicsize
|
|
|
|
{Py_mp_length, (void *)MapReflectionFriend::Length}, |
|
|
|
0, // tp_itemsize
|
|
|
|
{Py_mp_subscript, (void *)MapReflectionFriend::MessageMapGetItem}, |
|
|
|
MessageMapDealloc, // tp_dealloc
|
|
|
|
{Py_mp_ass_subscript, (void *)MapReflectionFriend::MessageMapSetItem}, |
|
|
|
0, // tp_print
|
|
|
|
{Py_tp_methods, (void *)MessageMapMethods}, |
|
|
|
0, // tp_getattr
|
|
|
|
{Py_tp_iter, (void *)MapReflectionFriend::GetIterator}, |
|
|
|
0, // tp_setattr
|
|
|
|
{0, 0} |
|
|
|
0, // tp_compare
|
|
|
|
}; |
|
|
|
0, // tp_repr
|
|
|
|
|
|
|
|
0, // tp_as_number
|
|
|
|
PyType_Spec MessageMapContainer_Type_spec = { |
|
|
|
0, // tp_as_sequence
|
|
|
|
FULL_MODULE_NAME ".MessageMapContainer", |
|
|
|
&MessageMapMappingMethods, // tp_as_mapping
|
|
|
|
sizeof(MapContainer), |
|
|
|
0, // tp_hash
|
|
|
|
0, |
|
|
|
0, // tp_call
|
|
|
|
Py_TPFLAGS_DEFAULT, |
|
|
|
0, // tp_str
|
|
|
|
MessageMapContainer_Type_slots |
|
|
|
0, // tp_getattro
|
|
|
|
}; |
|
|
|
0, // tp_setattro
|
|
|
|
|
|
|
|
0, // tp_as_buffer
|
|
|
|
PyObject *MessageMapContainer_Type; |
|
|
|
Py_TPFLAGS_DEFAULT, // tp_flags
|
|
|
|
#else |
|
|
|
"A map container for message", // tp_doc
|
|
|
|
static PyMappingMethods MessageMapMappingMethods = { |
|
|
|
0, // tp_traverse
|
|
|
|
MapReflectionFriend::Length, // mp_length
|
|
|
|
0, // tp_clear
|
|
|
|
MapReflectionFriend::MessageMapGetItem, // mp_subscript
|
|
|
|
0, // tp_richcompare
|
|
|
|
MapReflectionFriend::MessageMapSetItem, // mp_ass_subscript
|
|
|
|
0, // tp_weaklistoffset
|
|
|
|
}; |
|
|
|
MapReflectionFriend::GetIterator, // tp_iter
|
|
|
|
|
|
|
|
0, // tp_iternext
|
|
|
|
PyTypeObject MessageMapContainer_Type = { |
|
|
|
MessageMapMethods, // tp_methods
|
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0) |
|
|
|
0, // tp_members
|
|
|
|
FULL_MODULE_NAME ".MessageMapContainer", // tp_name
|
|
|
|
0, // tp_getset
|
|
|
|
sizeof(MessageMapContainer), // tp_basicsize
|
|
|
|
0, // tp_base
|
|
|
|
0, // tp_itemsize
|
|
|
|
0, // tp_dict
|
|
|
|
MessageMapDealloc, // tp_dealloc
|
|
|
|
0, // tp_descr_get
|
|
|
|
0, // tp_print
|
|
|
|
0, // tp_descr_set
|
|
|
|
0, // tp_getattr
|
|
|
|
0, // tp_dictoffset
|
|
|
|
0, // tp_setattr
|
|
|
|
0, // tp_init
|
|
|
|
0, // tp_compare
|
|
|
|
}; |
|
|
|
0, // tp_repr
|
|
|
|
|
|
|
|
0, // tp_as_number
|
|
|
|
|
|
|
|
0, // tp_as_sequence
|
|
|
|
|
|
|
|
&MessageMapMappingMethods, // 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, // tp_flags
|
|
|
|
|
|
|
|
"A map container for message", // tp_doc
|
|
|
|
|
|
|
|
0, // tp_traverse
|
|
|
|
|
|
|
|
0, // tp_clear
|
|
|
|
|
|
|
|
0, // tp_richcompare
|
|
|
|
|
|
|
|
0, // tp_weaklistoffset
|
|
|
|
|
|
|
|
MapReflectionFriend::GetIterator, // tp_iter
|
|
|
|
|
|
|
|
0, // tp_iternext
|
|
|
|
|
|
|
|
MessageMapMethods, // tp_methods
|
|
|
|
|
|
|
|
0, // tp_members
|
|
|
|
|
|
|
|
0, // tp_getset
|
|
|
|
|
|
|
|
0, // tp_base
|
|
|
|
|
|
|
|
0, // tp_dict
|
|
|
|
|
|
|
|
0, // tp_descr_get
|
|
|
|
|
|
|
|
0, // tp_descr_set
|
|
|
|
|
|
|
|
0, // tp_dictoffset
|
|
|
|
|
|
|
|
0, // tp_init
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// MapIterator /////////////////////////////////////////////////////////////////
|
|
|
|
// MapIterator /////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|