*.c: Make all of the type-definition tables read-only.
[catacomb-python] / ec.c
diff --git a/ec.c b/ec.c
index edf6ed6..d55cd3f 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -555,7 +555,7 @@ end:
   return (0);
 }
 
-static PyGetSetDef ecptnc_pygetset[] = {
+static const PyGetSetDef ecptnc_pygetset[] = {
 #define GETSETNAME(op, name) epnc##op##_##name
   GET  (ix,            "P.ix -> integer x coordinate of P")
   GET  (iy,            "P.iy -> integer y coordinate of P")
@@ -564,14 +564,14 @@ static PyGetSetDef ecptnc_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef ecptnc_pymethods[] = {
+static const PyMethodDef ecptnc_pymethods[] = {
 #define METHNAME(func) epmeth_##func
   METH (tobuf,         "X.tobuf() -> BIN")
 #undef METHNAME
   { 0 }
 };
 
-static PyNumberMethods ecpt_pynumber = {
+static const PyNumberMethods ecpt_pynumber = {
   0,                                   /* @nb_add@ */
   0,                                   /* @nb_subtract@ */
   0,                                   /* @nb_multiply@ */
@@ -626,7 +626,7 @@ static PyTypeObject ecpt_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
-  &ecpt_pynumber,                      /* @tp_as_number@ */
+  PYNUMBER(ecpt),                      /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
   0,                                   /* @tp_as_mapping@ */
   ecpt_pyhash,                         /* @tp_hash@ */
@@ -650,9 +650,9 @@ static PyTypeObject ecpt_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  ecptnc_pymethods,                    /* @tp_methods@ */
+  PYMETHODS(ecptnc),                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  ecptnc_pygetset,                     /* @tp_getset@ */
+  PYGETSET(ecptnc),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -665,7 +665,7 @@ static PyTypeObject ecpt_pytype_skel = {
   0                                    /* @tp_is_gc@ */
 };
 
-static PyGetSetDef ecpt_pygetset[] = {
+static const PyGetSetDef ecpt_pygetset[] = {
 #define GETSETNAME(op, name) ep##op##_##name
   GET  (curve,         "P.curve -> elliptic curve containing P")
   GET  (point,         "P.point -> standalone curve point")
@@ -678,7 +678,7 @@ static PyGetSetDef ecpt_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef ecpt_pymethods[] = {
+static const PyMethodDef ecpt_pymethods[] = {
 #define METHNAME(func) epmeth_##func
   METH (toraw,         "X.toraw() -> BIN")
   KWMETH(ec2osp,       "X.ec2osp([flags = EC_EXPLY]) -> BIN")
@@ -688,7 +688,7 @@ static PyMethodDef ecpt_pymethods[] = {
   { 0 }
 };
 
-static PyNumberMethods ecptcurve_pynumber = {
+static const PyNumberMethods ecptcurve_pynumber = {
   ecpt_pyadd,                          /* @nb_add@ */
   ecpt_pysub,                          /* @nb_subtract@ */
   ecpt_pymul,                          /* @nb_multiply@ */
@@ -743,7 +743,7 @@ static PyTypeObject ecptcurve_pytype_skel = {
   0,                                   /* @tp_setattr@ */
   0,                                   /* @tp_compare@ */
   0,                                   /* @tp_repr@ */
-  &ecptcurve_pynumber,                 /* @tp_as_number@ */
+  PYNUMBER(ecptcurve),                 /* @tp_as_number@ */
   0,                                   /* @tp_as_sequence@ */
   0,                                   /* @tp_as_mapping@ */
   0,                                   /* @tp_hash@ */
@@ -765,9 +765,9 @@ static PyTypeObject ecptcurve_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  ecpt_pymethods,                      /* @tp_methods@ */
+  PYMETHODS(ecpt),                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  ecpt_pygetset,                       /* @tp_getset@ */
+  PYGETSET(ecpt),                      /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1050,7 +1050,7 @@ static PyObject *ecget_field(PyObject *me, void *hunoz)
 static PyObject *ecget_inf(PyObject *me, void *hunoz)
   { ec inf = EC_INIT; return (ecpt_pywrap(me, &inf)); }
 
-static PyGetSetDef eccurve_pygetset[] = {
+static const PyGetSetDef eccurve_pygetset[] = {
 #define GETSETNAME(op, name) ec##op##_##name
   GET  (name,          "E.name -> name of this kind of curve")
   GET  (a,             "E.a -> first parameter of curve")
@@ -1061,7 +1061,7 @@ static PyGetSetDef eccurve_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef eccurve_pymethods[] = {
+static const PyMethodDef eccurve_pymethods[] = {
 #define METHNAME(name) ecmeth_##name
   METH (mmul,     "E.mmul([(P0, N0), (P1, N1), ...]) = N0 P0 + N1 P1 + ...")
   METH (find,          "E.find(X) -> P")
@@ -1103,9 +1103,9 @@ static PyTypeObject eccurve_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  eccurve_pymethods,                   /* @tp_methods@ */
+  PYMETHODS(eccurve),                  /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  eccurve_pygetset,                    /* @tp_getset@ */
+  PYGETSET(eccurve),                   /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1478,7 +1478,7 @@ static PyObject *eiget_r(PyObject *me, void *hunoz)
 static PyObject *eiget_h(PyObject *me, void *hunoz)
   { return (mp_pywrap(MP_COPY(ECINFO_EI(me)->h))); }
 
-static PyGetSetDef ecinfo_pygetset[] = {
+static const PyGetSetDef ecinfo_pygetset[] = {
 #define GETSETNAME(op, name) ei##op##_##name
   GET  (curve,         "I.curve -> the elliptic curve")
   GET  (G,             "I.G -> generator point for the group")
@@ -1488,7 +1488,7 @@ static PyGetSetDef ecinfo_pygetset[] = {
   { 0 }
 };
 
-static PyMethodDef ecinfo_pymethods[] = {
+static const PyMethodDef ecinfo_pymethods[] = {
 #define METHNAME(name) eimeth_##name
   KWMETH(check,                "I.check([rng = rand]) -> None")
 #undef METHNAME
@@ -1528,9 +1528,9 @@ static PyTypeObject ecinfo_pytype_skel = {
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
   0,                                   /* @tp_iternext@ */
-  ecinfo_pymethods,                    /* @tp_methods@ */
+  PYMETHODS(ecinfo),                   /* @tp_methods@ */
   0,                                   /* @tp_members@ */
-  ecinfo_pygetset,                     /* @tp_getset@ */
+  PYGETSET(ecinfo),                    /* @tp_getset@ */
   0,                                   /* @tp_base@ */
   0,                                   /* @tp_dict@ */
   0,                                   /* @tp_descr_get@ */
@@ -1545,7 +1545,7 @@ static PyTypeObject ecinfo_pytype_skel = {
 
 /*----- Setup -------------------------------------------------------------*/
 
-static PyMethodDef methods[] = {
+static const PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
   METH (_ECPt_frombuf, "frombuf(E, STR) -> (P, REST)")
   METH (_ECPtCurve_fromraw, "fromraw(E, STR) -> (P, REST)")