gcrand_func *func;
} gccrand_info;
-#define RNGF_INT 1u
-#define RNGF_NONCE 2u
-#define RNGF_LATIN 4u
+#define RNGF_MASK 255u
+
+enum {
+ RNG_PLAIN = 0,
+ RNG_SEAL,
+ RNG_LATIN,
+ RNG_SHAKE,
+ RNG_KMAC
+};
typedef struct gccrand_pyobj {
PyHeapTypeObject ty;
gccrand_pyobj *g = newtype(gccrand_pytype, 0, info->name);
g->info = info;
g->ty.ht_type.tp_basicsize = sizeof(grand_pyobj);
- g->ty.ht_type.tp_base =
- (info->f & RNGF_LATIN) ? gclatinrand_pytype : gcrand_pytype;
+ switch (info->f&RNGF_MASK) {
+ case RNG_LATIN: g->ty.ht_type.tp_base = gclatinrand_pytype; break;
+ default: g->ty.ht_type.tp_base = gcrand_pytype; break;
+ }
Py_INCREF(g->ty.ht_type.tp_base);
g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
Py_TPFLAGS_BASETYPE |
Py_TPFLAGS_HEAPTYPE);
g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
g->ty.ht_type.tp_free = 0;
- if (info->f & RNGF_INT) g->ty.ht_type.tp_new = gcirand_pynew;
- else if (info->f & RNGF_NONCE) g->ty.ht_type.tp_new = gcnrand_pynew;
- else g->ty.ht_type.tp_new = gcrand_pynew;
+ switch (info->f&RNGF_MASK) {
+ case RNG_LATIN: g->ty.ht_type.tp_new = gcnrand_pynew; break;
+ case RNG_SEAL: g->ty.ht_type.tp_new = gcirand_pynew; break;
+ default: g->ty.ht_type.tp_new = gcrand_pynew; break;
+ }
typeready(&g->ty.ht_type);
return ((PyObject *)g);
}