diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2018-08-29 08:36:30 +0200 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2018-09-07 11:40:03 +0200 |
commit | 98afa68d935215e8ab2c7de7fb45972a03e3da26 (patch) | |
tree | ded48d64b8a9e943a5ea82de6675952d7050aa45 /src/pl | |
parent | 75f7855369ec56d4a8e7d6eae98aff1182b85cac (diff) | |
download | postgresql-98afa68d935215e8ab2c7de7fb45972a03e3da26.tar.gz postgresql-98afa68d935215e8ab2c7de7fb45972a03e3da26.zip |
Use C99 designated initializers for some structs
These are just a few particularly egregious cases that were hard to read
and write, and error prone because of many similar adjacent types.
Discussion: https://www.postgresql.org/message-id/flat/4c9f01be-9245-2148-b569-61a8562ef190%402ndquadrant.com
Diffstat (limited to 'src/pl')
-rw-r--r-- | src/pl/plpython/plpy_cursorobject.c | 39 | ||||
-rw-r--r-- | src/pl/plpython/plpy_planobject.c | 37 | ||||
-rw-r--r-- | src/pl/plpython/plpy_plpymodule.c | 22 | ||||
-rw-r--r-- | src/pl/plpython/plpy_resultobject.c | 55 | ||||
-rw-r--r-- | src/pl/plpython/plpy_subxactobject.c | 37 |
5 files changed, 42 insertions, 148 deletions
diff --git a/src/pl/plpython/plpy_cursorobject.c b/src/pl/plpython/plpy_cursorobject.c index e32bc568bc2..45ac25b2ae0 100644 --- a/src/pl/plpython/plpy_cursorobject.c +++ b/src/pl/plpython/plpy_cursorobject.c @@ -43,37 +43,14 @@ static PyMethodDef PLy_cursor_methods[] = { static PyTypeObject PLy_CursorType = { PyVarObject_HEAD_INIT(NULL, 0) - "PLyCursor", /* tp_name */ - sizeof(PLyCursorObject), /* tp_size */ - 0, /* tp_itemsize */ - - /* - * methods - */ - PLy_cursor_dealloc, /* 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 | Py_TPFLAGS_HAVE_ITER, /* tp_flags */ - PLy_cursor_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - PyObject_SelfIter, /* tp_iter */ - PLy_cursor_iternext, /* tp_iternext */ - PLy_cursor_methods, /* tp_tpmethods */ + .tp_name = "PLyCursor", + .tp_basicsize = sizeof(PLyCursorObject), + .tp_dealloc = PLy_cursor_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_ITER, + .tp_doc = PLy_cursor_doc, + .tp_iter = PyObject_SelfIter, + .tp_iternext = PLy_cursor_iternext, + .tp_methods = PLy_cursor_methods, }; void diff --git a/src/pl/plpython/plpy_planobject.c b/src/pl/plpython/plpy_planobject.c index 390b4e90d45..96ea24cbcf5 100644 --- a/src/pl/plpython/plpy_planobject.c +++ b/src/pl/plpython/plpy_planobject.c @@ -34,37 +34,12 @@ static PyMethodDef PLy_plan_methods[] = { static PyTypeObject PLy_PlanType = { PyVarObject_HEAD_INIT(NULL, 0) - "PLyPlan", /* tp_name */ - sizeof(PLyPlanObject), /* tp_size */ - 0, /* tp_itemsize */ - - /* - * methods - */ - PLy_plan_dealloc, /* 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 */ - PLy_plan_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PLy_plan_methods, /* tp_tpmethods */ + .tp_name = "PLyPlan", + .tp_basicsize = sizeof(PLyPlanObject), + .tp_dealloc = PLy_plan_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .tp_doc = PLy_plan_doc, + .tp_methods = PLy_plan_methods, }; void diff --git a/src/pl/plpython/plpy_plpymodule.c b/src/pl/plpython/plpy_plpymodule.c index c55cd959c29..23e49e4b754 100644 --- a/src/pl/plpython/plpy_plpymodule.c +++ b/src/pl/plpython/plpy_plpymodule.c @@ -115,23 +115,17 @@ static PyMethodDef PLy_exc_methods[] = { #if PY_MAJOR_VERSION >= 3 static PyModuleDef PLy_module = { - PyModuleDef_HEAD_INIT, /* m_base */ - "plpy", /* m_name */ - NULL, /* m_doc */ - -1, /* m_size */ - PLy_methods, /* m_methods */ + PyModuleDef_HEAD_INIT, + .m_name = "plpy", + .m_size = -1, + .m_methods = PLy_methods, }; static PyModuleDef PLy_exc_module = { - PyModuleDef_HEAD_INIT, /* m_base */ - "spiexceptions", /* m_name */ - NULL, /* m_doc */ - -1, /* m_size */ - PLy_exc_methods, /* m_methods */ - NULL, /* m_reload */ - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ + PyModuleDef_HEAD_INIT, + .m_name = "spiexceptions", + .m_size = -1, + .m_methods = PLy_exc_methods, }; /* diff --git a/src/pl/plpython/plpy_resultobject.c b/src/pl/plpython/plpy_resultobject.c index 4064f6a7a26..20cf3edea87 100644 --- a/src/pl/plpython/plpy_resultobject.c +++ b/src/pl/plpython/plpy_resultobject.c @@ -29,19 +29,14 @@ static char PLy_result_doc[] = { }; static PySequenceMethods PLy_result_as_sequence = { - PLy_result_length, /* sq_length */ - NULL, /* sq_concat */ - NULL, /* sq_repeat */ - PLy_result_item, /* sq_item */ - NULL, /* sq_slice */ - NULL, /* sq_ass_item */ - NULL, /* sq_ass_slice */ + .sq_length = PLy_result_length, + .sq_item = PLy_result_item, }; static PyMappingMethods PLy_result_as_mapping = { - PLy_result_length, /* mp_length */ - PLy_result_subscript, /* mp_subscript */ - PLy_result_ass_subscript, /* mp_ass_subscript */ + .mp_length = PLy_result_length, + .mp_subscript = PLy_result_subscript, + .mp_ass_subscript = PLy_result_ass_subscript, }; static PyMethodDef PLy_result_methods[] = { @@ -55,37 +50,15 @@ static PyMethodDef PLy_result_methods[] = { static PyTypeObject PLy_ResultType = { PyVarObject_HEAD_INIT(NULL, 0) - "PLyResult", /* tp_name */ - sizeof(PLyResultObject), /* tp_size */ - 0, /* tp_itemsize */ - - /* - * methods - */ - PLy_result_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - &PLy_result_as_sequence, /* tp_as_sequence */ - &PLy_result_as_mapping, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - &PLy_result_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - PLy_result_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PLy_result_methods, /* tp_tpmethods */ + .tp_name = "PLyResult", + .tp_basicsize = sizeof(PLyResultObject), + .tp_dealloc = PLy_result_dealloc, + .tp_as_sequence = &PLy_result_as_sequence, + .tp_as_mapping = &PLy_result_as_mapping, + .tp_str = &PLy_result_str, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .tp_doc = PLy_result_doc, + .tp_methods = PLy_result_methods, }; void diff --git a/src/pl/plpython/plpy_subxactobject.c b/src/pl/plpython/plpy_subxactobject.c index 331d2b859c0..53fd36edba1 100644 --- a/src/pl/plpython/plpy_subxactobject.c +++ b/src/pl/plpython/plpy_subxactobject.c @@ -38,37 +38,12 @@ static PyMethodDef PLy_subtransaction_methods[] = { static PyTypeObject PLy_SubtransactionType = { PyVarObject_HEAD_INIT(NULL, 0) - "PLySubtransaction", /* tp_name */ - sizeof(PLySubtransactionObject), /* tp_size */ - 0, /* tp_itemsize */ - - /* - * methods - */ - PLy_subtransaction_dealloc, /* 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 */ - PLy_subtransaction_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PLy_subtransaction_methods, /* tp_tpmethods */ + .tp_name = "PLySubtransaction", + .tp_basicsize = sizeof(PLySubtransactionObject), + .tp_dealloc = PLy_subtransaction_dealloc, + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .tp_doc = PLy_subtransaction_doc, + .tp_methods = PLy_subtransaction_methods, }; |