PyC API: utility to parse a string as an RNA like enum

More convenient than comparing strings,
with the advantage that errors don't need to repeat expected values.
This commit is contained in:
2019-10-01 04:09:33 +10:00
parent ddb157999e
commit 07feb6e814
2 changed files with 42 additions and 0 deletions

View File

@@ -126,6 +126,17 @@ bool PyC_RunString_AsString(const char **imports,
int PyC_ParseBool(PyObject *o, void *p);
struct PyC_StringEnumItems {
int value;
const char *id;
};
struct PyC_StringEnum {
const struct PyC_StringEnumItems *items;
int value_found;
};
int PyC_ParseStringEnum(PyObject *o, void *p);
int PyC_CheckArgs_DeepCopy(PyObject *args);
/* Integer parsing (with overflow checks), -1 on error. */