Skip to content

Commit

Permalink
use PY_ prefix, add Py_UNREACHABLE() to switches
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Mar 6, 2023
1 parent 33dda2a commit 239981c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Include/cpython/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);

PyAPI_FUNC(int) PyCode_Addr2Location(PyCodeObject *, int, int *, int *, int *, int *);

#define FOREACH_CODE_EVENT(V) \
#define PY_FOREACH_CODE_EVENT(V) \
V(CREATE) \
V(DESTROY)

typedef enum {
#define DEF_EVENT(op) PY_CODE_EVENT_##op,
FOREACH_CODE_EVENT(DEF_EVENT)
PY_FOREACH_CODE_EVENT(DEF_EVENT)
#undef DEF_EVENT
} PyCodeEvent;

Expand Down
14 changes: 7 additions & 7 deletions Include/cpython/dictobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);

/* Dictionary watchers */

#define FOREACH_DICT_EVENT(V) \
V(ADDED) \
V(MODIFIED) \
V(DELETED) \
V(CLONED) \
V(CLEARED) \
#define PY_FOREACH_DICT_EVENT(V) \
V(ADDED) \
V(MODIFIED) \
V(DELETED) \
V(CLONED) \
V(CLEARED) \
V(DEALLOCATED)

typedef enum {
#define DEF_EVENT(EVENT) PyDict_EVENT_##EVENT,
FOREACH_DICT_EVENT(DEF_EVENT)
PY_FOREACH_DICT_EVENT(DEF_EVENT)
#undef DEF_EVENT
} PyDict_WatchEvent;

Expand Down
12 changes: 6 additions & 6 deletions Include/cpython/funcobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);

#define FOREACH_FUNC_EVENT(V) \
V(CREATE) \
V(DESTROY) \
V(MODIFY_CODE) \
V(MODIFY_DEFAULTS) \
#define PY_FOREACH_FUNC_EVENT(V) \
V(CREATE) \
V(DESTROY) \
V(MODIFY_CODE) \
V(MODIFY_DEFAULTS) \
V(MODIFY_KWDEFAULTS)

typedef enum {
#define DEF_EVENT(EVENT) PyFunction_EVENT_##EVENT,
FOREACH_FUNC_EVENT(DEF_EVENT)
PY_FOREACH_FUNC_EVENT(DEF_EVENT)
#undef DEF_EVENT
} PyFunction_WatchEvent;

Expand Down
2 changes: 1 addition & 1 deletion Modules/_testcapi/watchers.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ _PyTestCapi_Init_Watchers(PyObject *mod)
PyFunction_EVENT_##event)) { \
return -1; \
}
FOREACH_FUNC_EVENT(ADD_EVENT);
PY_FOREACH_FUNC_EVENT(ADD_EVENT);
#undef ADD_EVENT

return 0;
Expand Down
3 changes: 2 additions & 1 deletion Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ code_event_name(PyCodeEvent event) {
#define CASE(op) \
case PY_CODE_EVENT_##op: \
return "PY_CODE_EVENT_" #op;
FOREACH_CODE_EVENT(CASE)
PY_FOREACH_CODE_EVENT(CASE)
#undef CASE
}
Py_UNREACHABLE();
}

static void
Expand Down
3 changes: 2 additions & 1 deletion Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5745,9 +5745,10 @@ dict_event_name(PyDict_WatchEvent event) {
#define CASE(op) \
case PyDict_EVENT_##op: \
return "PyDict_EVENT_" #op;
FOREACH_DICT_EVENT(CASE)
PY_FOREACH_DICT_EVENT(CASE)
#undef CASE
}
Py_UNREACHABLE();
}

void
Expand Down
3 changes: 2 additions & 1 deletion Objects/funcobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ func_event_name(PyFunction_WatchEvent event) {
#define CASE(op) \
case PyFunction_EVENT_##op: \
return "PyFunction_EVENT_" #op;
FOREACH_FUNC_EVENT(CASE)
PY_FOREACH_FUNC_EVENT(CASE)
#undef CASE
}
Py_UNREACHABLE();
}

static void
Expand Down

0 comments on commit 239981c

Please sign in to comment.