*.c: Rearrange and reformat the class methods.
[catacomb-python] / buffer.c
index 45888ec..49ed9d2 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -245,40 +245,40 @@ end:
   return (-1);
 }
 
-static PyGetSetDef rbuf_pygetset[] = {
+static const PyGetSetDef rbuf_pygetset[] = {
 #define GETSETNAME(op, name) rb##op##_##name
-  GET  (size,                  "RBUF.size -> SIZE")
-  GET  (left,                  "RBUF.left -> REMAINDER")
-  GET  (endp,                  "RBUF.endp -> BOOL")
-  GETSET(offset,               "RBUF.offset -> OFFSET")
+  GET  (size,          "RBUF.size -> SIZE")
+  GET  (left,          "RBUF.left -> REMAINDER")
+  GET  (endp,          "RBUF.endp -> BOOL")
+  GETSET(offset,       "RBUF.offset -> OFFSET")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef rbuf_pymethods[] = {
+static const PyMethodDef rbuf_pymethods[] = {
 #define METHNAME(func) rbmeth_##func
-  METH (skip,                  "RBUF.skip(N)")
-  METH (get,                   "RBUF.get(N) -> BYTES")
+  METH (skip,          "RBUF.skip(N)")
+  METH (get,           "RBUF.get(N) -> BYTES")
 #define RBMETH_DECL_GETU_(n, W, w)                                     \
-    METH(getu##w, "RBUF.getu" #w "() -> INT")
+    METH(getu##w,      "RBUF.getu" #w "() -> INT")
   DOUINTCONV(RBMETH_DECL_GETU_)
 #define RBMETH_DECL_GETBLK_(n, W, w)                                   \
-    METH(getblk##w, "RBUF.getblk" #w "() -> BYTES")
+    METH(getblk##w,    "RBUF.getblk" #w "() -> BYTES")
   BUF_DOSUFFIXES(RBMETH_DECL_GETBLK_)
 #define RBMETH_DECL_GETBUF_(n, W, w)                                   \
-    METH(getbuf##w, "RBUF.getbuf" #w "() -> RBUF'")
+    METH(getbuf##w,    "RBUF.getbuf" #w "() -> RBUF'")
   BUF_DOSUFFIXES(RBMETH_DECL_GETBUF_)
-  METH (getmp,                 "RBUF.getmp() -> X")
-  METH (getgf,                 "RBUF.getgf() -> X")
-  KWMETH(getecpt,              "RBUF.getecpt([curve = None]) -> P")
-  METH (getecptraw,            "RBUF.getecptraw(CURVE) -> P")
-  METH (getge,                 "RBUF.getge(GROUP) -> X")
-  METH (getgeraw,              "RBUF.getgeraw(GROUP) -> X")
+  METH (getmp,         "RBUF.getmp() -> X")
+  METH (getgf,         "RBUF.getgf() -> X")
+  KWMETH(getecpt,      "RBUF.getecpt([curve = None]) -> P")
+  METH (getecptraw,    "RBUF.getecptraw(CURVE) -> P")
+  METH (getge,         "RBUF.getge(GROUP) -> X")
+  METH (getgeraw,      "RBUF.getgeraw(GROUP) -> X")
 #undef METHNAME
   { 0 }
 };
 
-static PyBufferProcs rbuf_pybuffer = {
+static const PyBufferProcs rbuf_pybuffer = {
   rbuf_pyreadbuf,                      /* @bf_getreadbuffer@ */
   0,                                   /* @bf_getwritebuffer@ */
   rbuf_pysegcount,                     /* @bf_getsegcount@ */
@@ -305,12 +305,12 @@ static PyTypeObject rbuf_pytype_skel = {
   0,                                   /* @tp_str@ */
   0,                                   /* @tp_getattro@ */
   0,                                   /* @tp_setattro@ */
-  &rbuf_pybuffer,                      /* @tp_as_buffer@ */
+  PYBUFFER(rbuf),                      /* @tp_as_buffer@ */
   Py_TPFLAGS_DEFAULT |                 /* @tp_flags@ */
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"ReadBuffer(STR): a read buffer.",
+  "ReadBuffer(STR): a read buffer.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -318,9 +318,9 @@ static PyTypeObject rbuf_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  rbuf_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(rbuf),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  rbuf_pygetset,                       /* @tp_getset@ */
+  PYGETSET(rbuf),                      /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -490,35 +490,35 @@ static PyObject *wbget_size(PyObject *me, void *hunoz)
 static PyObject *wbget_contents(PyObject *me, void *hunoz)
   { return (bytestring_pywrap(BBASE(BUF_B(me)), BLEN(BUF_B(me)))); }
 
-static PyGetSetDef wbuf_pygetset[] = {
+static const PyGetSetDef wbuf_pygetset[] = {
 #define GETSETNAME(op, name) wb##op##_##name
-  GET  (size,                  "WBUF.size -> SIZE")
-  GET  (contents,              "WBUF.contents -> STR")
+  GET  (size,          "WBUF.size -> SIZE")
+  GET  (contents,      "WBUF.contents -> STR")
 #undef GETSETNAME
   { 0 }
 };
 
-static PyMethodDef wbuf_pymethods[] = {
+static const PyMethodDef wbuf_pymethods[] = {
 #define METHNAME(func) wbmeth_##func
-  METH (zero,                  "WBUF.zero(N)")
-  METH (put,                   "WBUF.put(BYTES)")
+  METH (zero,          "WBUF.zero(N)")
+  METH (put,           "WBUF.put(BYTES)")
 #define WBMETH_DECL_PUTU_(n, W, w)                                     \
-    METH(putu##w, "WBUF.putu" #w "(INT)")
+    METH(putu##w,      "WBUF.putu" #w "(INT)")
   DOUINTCONV(WBMETH_DECL_PUTU_)
 #define WBMETH_DECL_PUTBLK_(n, W, w)                                   \
-    METH(putblk##w, "WBUF.putblk" #w "(BYTES)")
+    METH(putblk##w,    "WBUF.putblk" #w "(BYTES)")
   BUF_DOSUFFIXES(WBMETH_DECL_PUTBLK_)
-  METH (putmp,                 "WBUF.putmp(X)")
-  METH (putgf,                 "WBUF.putgf(X)")
-  METH (putecpt,               "WBUF.putecpt(P)")
-  METH (putecptraw,            "WBUF.putecptraw(P)")
-  METH (putge,                 "WBUF.putge(X)")
-  METH (putgeraw,              "WBUF.putgeraw(X)")
+  METH (putmp,         "WBUF.putmp(X)")
+  METH (putgf,         "WBUF.putgf(X)")
+  METH (putecpt,       "WBUF.putecpt(P)")
+  METH (putecptraw,    "WBUF.putecptraw(P)")
+  METH (putge,         "WBUF.putge(X)")
+  METH (putgeraw,      "WBUF.putgeraw(X)")
 #undef METHNAME
   { 0 }
 };
 
-static PyBufferProcs wbuf_pybuffer = {
+static const PyBufferProcs wbuf_pybuffer = {
   wbuf_pyreadbuf,                      /* @bf_getreadbuffer@ */
   0,                                   /* @bf_getwritebuffer@ */
   wbuf_pysegcount,                     /* @bf_getsegcount@ */
@@ -545,12 +545,12 @@ static PyTypeObject wbuf_pytype_skel = {
   0,                                   /* @tp_str@ */
   0,                                   /* @tp_getattro@ */
   0,                                   /* @tp_setattro@ */
-  &wbuf_pybuffer,                      /* @tp_as_buffer@ */
+  PYBUFFER(wbuf),                      /* @tp_as_buffer@ */
   Py_TPFLAGS_DEFAULT |                 /* @tp_flags@ */
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"WriteBuffer([size = ?]): a write buffer.",
+  "WriteBuffer([size = ?]): a write buffer.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
@@ -558,9 +558,9 @@ static PyTypeObject wbuf_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  wbuf_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(wbuf),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  wbuf_pygetset,                       /* @tp_getset@ */
+  PYGETSET(wbuf),                      /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */