From 527255e3a18e5f5cd6be218ca1cc431c512e69a2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 12 Mar 2018 10:38:12 +0530 Subject: [PATCH] Fix compilation with gcc 8 Apparently some nitwit Linux distros have made an unreleased compiler their default compiler. Fixes #376 Fixes various new warnings that GCC 8 issues --- kittens/unicode_input/unicode_names.c | 2 +- kitty/child-monitor.c | 11 ++++++----- kitty/colors.c | 4 ++-- kitty/cursor.c | 6 +++--- kitty/data-types.c | 2 +- kitty/data-types.h | 6 ++++-- kitty/fonts.c | 2 +- kitty/freetype.c | 7 ++++--- kitty/glfw.c | 22 +++++++++++----------- kitty/graphics.c | 2 +- kitty/history.c | 2 +- kitty/keys.h | 10 ++++++++++ kitty/keys.py | 6 ++++-- kitty/line-buf.c | 4 ++-- kitty/line.c | 4 ++-- kitty/screen.c | 22 +++++++++++----------- kitty/shaders.c | 3 +-- kitty/state.c | 3 +-- 18 files changed, 66 insertions(+), 52 deletions(-) diff --git a/kittens/unicode_input/unicode_names.c b/kittens/unicode_input/unicode_names.c index 4debf073f..f01f9bad0 100644 --- a/kittens/unicode_input/unicode_names.c +++ b/kittens/unicode_input/unicode_names.c @@ -8,7 +8,7 @@ #include "names.h" static PyObject* -all_words(PyObject *self UNUSED) { +all_words(PYNOARG) { PyObject *ans = PyTuple_New(arraysz(idx_to_word)); if (!ans) return NULL; for (size_t i = 0; i < arraysz(idx_to_word); i++) { diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index 1509a60ec..2bad710f7 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -199,8 +199,9 @@ static void wakeup_talk_loop(bool); static bool talk_thread_started = false; static PyObject * -start(ChildMonitor *self) { +start(PyObject *s, PyObject *a UNUSED) { #define start_doc "start() -> Start the I/O thread" + ChildMonitor *self = (ChildMonitor*)s; if (self->talk_fd > -1 || self->listen_fd > -1) { if (pthread_create(&self->talk_thread, NULL, talk_loop, self) != 0) return PyErr_SetFromErrno(PyExc_OSError); talk_thread_started = true; @@ -213,7 +214,7 @@ start(ChildMonitor *self) { static PyObject * -wakeup(ChildMonitor UNUSED *self) { +wakeup(PYNOARG) { #define wakeup_doc "wakeup() -> wakeup the ChildMonitor I/O thread, forcing it to exit from poll() if it is waiting there." wakeup_io_loop(false); Py_RETURN_NONE; @@ -286,7 +287,7 @@ needs_write(ChildMonitor UNUSED *self, PyObject *args) { } static PyObject * -shutdown_monitor(ChildMonitor *self) { +shutdown_monitor(ChildMonitor *self, PyObject *a UNUSED) { #define shutdown_monitor_doc "shutdown_monitor() -> Shutdown the monitor loop." signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); @@ -734,7 +735,7 @@ process_pending_resizes(double now) { } static PyObject* -main_loop(ChildMonitor *self) { +main_loop(ChildMonitor *self, PyObject *a UNUSED) { #define main_loop_doc "The main thread loop" bool has_open_windows = true; @@ -1256,7 +1257,7 @@ PyTypeObject ChildMonitor_Type = { }; static PyObject* -safe_pipe(PyObject *self UNUSED) { +safe_pipe(PYNOARG) { int fds[2] = {0}; if (!self_pipe(fds)) return PyErr_SetFromErrno(PyExc_OSError); return Py_BuildValue("ii", fds[0], fds[1]); diff --git a/kitty/colors.c b/kitty/colors.c index 9f4e1cb40..507049dea 100644 --- a/kitty/colors.c +++ b/kitty/colors.c @@ -133,7 +133,7 @@ as_color(ColorProfile *self, PyObject *val) { } static PyObject* -reset_color_table(ColorProfile *self) { +reset_color_table(ColorProfile *self, PyObject *a UNUSED) { #define reset_color_table_doc "Reset all customized colors back to defaults" memcpy(self->color_table, self->orig_color_table, sizeof(FG_BG_256)); self->dirty = true; @@ -179,7 +179,7 @@ copy_color_table_to_buffer(ColorProfile *self, color_type *buf, int offset, size } static PyObject* -color_table_address(ColorProfile *self) { +color_table_address(ColorProfile *self, PyObject *a UNUSED) { #define color_table_address_doc "Pointer address to start of color table" return PyLong_FromVoidPtr((void*)self->color_table); } diff --git a/kitty/cursor.c b/kitty/cursor.c index df6c2c8fa..630d2ee33 100644 --- a/kitty/cursor.c +++ b/kitty/cursor.c @@ -253,7 +253,7 @@ cursor_as_sgr(Cursor *self, Cursor *prev) { } static PyObject * -reset_display_attrs(Cursor *self) { +reset_display_attrs(Cursor *self, PyObject *a UNUSED) { #define reset_display_attrs_doc "Reset all display attributes to unset" cursor_reset_display_attrs(self); Py_RETURN_NONE; @@ -272,7 +272,7 @@ void cursor_copy_to(Cursor *src, Cursor *dest) { } static PyObject* -copy(Cursor *self); +copy(Cursor *self, PyObject*); #define copy_doc "Create a clone of this cursor" // Boilerplate {{{ @@ -342,7 +342,7 @@ cursor_copy(Cursor *self) { } static PyObject* -copy(Cursor *self) { +copy(Cursor *self, PyObject *a UNUSED) { return (PyObject*)cursor_copy(self); } diff --git a/kitty/data-types.c b/kitty/data-types.c index bb3f2dbe2..b992db40d 100644 --- a/kitty/data-types.c +++ b/kitty/data-types.c @@ -104,7 +104,7 @@ handle_sigchld(int UNUSED signum, siginfo_t *sinfo, void UNUSED *unused) { } static PyObject* -install_sigchld_handler(PyObject UNUSED *self) { +install_sigchld_handler(PYNOARG) { struct sigaction sa; sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = handle_sigchld; diff --git a/kitty/data-types.h b/kitty/data-types.h index 52df8d4e1..6e4a5df21 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -18,6 +18,7 @@ #define OPENGL_REQUIRED_VERSION_MAJOR 3 #define OPENGL_REQUIRED_VERSION_MINOR 3 #define UNUSED __attribute__ ((unused)) +#define PYNOARG PyObject *__a1 UNUSED, PyObject *__a2 UNUSED #define EXPORTED __attribute__ ((visibility ("default"))) #define LIKELY(x) __builtin_expect (!!(x), 1) #define UNLIKELY(x) __builtin_expect (!!(x), 0) @@ -208,7 +209,7 @@ typedef struct { #define clear_sprite_position(cell) (cell).sprite_x = 0; (cell).sprite_y = 0; (cell).sprite_z = 0; -#define left_shift_line(line, at, num) \ +#define left_shift_line(line, at, num) { \ for(index_type __i__ = (at); __i__ < (line)->xnum - (num); __i__++) { \ COPY_CELL(line, __i__ + (num), line, __i__) \ } \ @@ -216,7 +217,8 @@ typedef struct { (line)->cells[(at)].ch = BLANK_CHAR; \ (line)->cells[(at)].attrs = BLANK_CHAR ? 1 : 0; \ clear_sprite_position((line)->cells[(at)]); \ - } + }\ +} #define ensure_space_for(base, array, type, num, capacity, initial_cap, zero_mem) \ if ((base)->capacity < num) { \ diff --git a/kitty/fonts.c b/kitty/fonts.c index fb93f29ca..33bbcb543 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -1066,7 +1066,7 @@ concat_cells(PyObject UNUSED *self, PyObject *args) { } static PyObject* -current_fonts(PyObject UNUSED *self) { +current_fonts(PYNOARG) { PyObject *ans = PyDict_New(); if (!ans) return NULL; #define SET(key, val) {if (PyDict_SetItemString(ans, #key, fonts.fonts[val].face) != 0) { goto error; }} diff --git a/kitty/freetype.c b/kitty/freetype.c index 70e8d0011..45f2ce9ba 100644 --- a/kitty/freetype.c +++ b/kitty/freetype.c @@ -532,7 +532,8 @@ render_glyphs_in_cells(PyObject *f, bool bold, bool italic, hb_glyph_info_t *inf } static PyObject* -display_name(Face *self) { +display_name(PyObject *s, PyObject *a UNUSED) { + Face *self = (Face*)s; const char *psname = FT_Get_Postscript_Name(self->face); if (psname) return Py_BuildValue("s", psname); Py_INCREF(self->path); @@ -540,8 +541,8 @@ display_name(Face *self) { } static PyObject* -extra_data(Face *self) { - return PyLong_FromVoidPtr(self->extra_data); +extra_data(PyObject *self, PyObject *a UNUSED) { + return PyLong_FromVoidPtr(((Face*)self)->extra_data); } // Boilerplate {{{ diff --git a/kitty/glfw.c b/kitty/glfw.c index 0e9dd037b..67eed4528 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -481,7 +481,7 @@ glfw_init(PyObject UNUSED *self, PyObject *args) { } PyObject* -glfw_terminate(PyObject UNUSED *self) { +glfw_terminate(PYNOARG) { glfwTerminate(); Py_RETURN_NONE; } @@ -499,13 +499,13 @@ glfw_wait_events(PyObject UNUSED *self, PyObject *args) { } PyObject* -glfw_post_empty_event(PyObject UNUSED *self) { +glfw_post_empty_event(PYNOARG) { glfwPostEmptyEvent(); Py_RETURN_NONE; } PyObject* -glfw_poll_events(PyObject UNUSED *self) { +glfw_poll_events(PYNOARG) { glfwPollEvents(); Py_RETURN_NONE; } @@ -523,7 +523,7 @@ get_physical_dpi(GLFWmonitor *m) { } PyObject* -glfw_get_physical_dpi(PyObject UNUSED *self) { +glfw_get_physical_dpi(PYNOARG) { GLFWmonitor *m = glfwGetPrimaryMonitor(); if (m == NULL) { PyErr_SetString(PyExc_ValueError, "Failed to get primary monitor"); return NULL; } return get_physical_dpi(m); @@ -548,14 +548,14 @@ glfw_window_hint(PyObject UNUSED *self, PyObject *args) { // }}} static PyObject* -get_clipboard_string(PyObject UNUSED *self) { +get_clipboard_string(PYNOARG) { OSWindow *w = current_os_window(); if (w) return Py_BuildValue("s", glfwGetClipboardString(w->handle)); return Py_BuildValue("s", ""); } static PyObject* -get_content_scale_for_window(PyObject UNUSED *self) { +get_content_scale_for_window(PYNOARG) { OSWindow *w = global_state.callback_os_window ? global_state.callback_os_window : global_state.os_windows; float xscale, yscale; glfwGetWindowContentScale(w->handle, &xscale, &yscale); @@ -572,7 +572,7 @@ set_clipboard_string(PyObject UNUSED *self, PyObject *args) { } static PyObject* -toggle_fullscreen(PyObject UNUSED *self) { +toggle_fullscreen(PYNOARG) { GLFWmonitor *monitor; OSWindow *w = current_os_window(); if (!w) Py_RETURN_NONE; @@ -662,14 +662,14 @@ should_os_window_close(OSWindow* w) { } static PyObject* -primary_monitor_size(PyObject UNUSED *self) { +primary_monitor_size(PYNOARG) { GLFWmonitor* monitor = glfwGetPrimaryMonitor(); const GLFWvidmode* mode = glfwGetVideoMode(monitor); return Py_BuildValue("ii", mode->width, mode->height); } static PyObject* -primary_monitor_content_scale(PyObject UNUSED *self) { +primary_monitor_content_scale(PYNOARG) { GLFWmonitor* monitor = glfwGetPrimaryMonitor(); float xscale, yscale; glfwGetMonitorContentScale(monitor, &xscale, &yscale); @@ -677,7 +677,7 @@ primary_monitor_content_scale(PyObject UNUSED *self) { } static PyObject* -x11_display(PyObject UNUSED *self) { +x11_display(PYNOARG) { if (glfwGetX11Display) { return PyLong_FromVoidPtr(glfwGetX11Display()); } else log_error("Failed to load glfwGetX11Display"); @@ -699,7 +699,7 @@ x11_window_id(PyObject UNUSED *self, PyObject *os_wid) { } static PyObject* -get_primary_selection(PyObject UNUSED *self) { +get_primary_selection(PYNOARG) { if (glfwGetX11SelectionString) { return Py_BuildValue("y", glfwGetX11SelectionString()); } else log_error("Failed to load glfwGetX11SelectionString"); diff --git a/kitty/graphics.c b/kitty/graphics.c index 2581fe995..56f020499 100644 --- a/kitty/graphics.c +++ b/kitty/graphics.c @@ -509,7 +509,7 @@ handle_add_command(GraphicsManager *self, const GraphicsCommand *g, const uint8_ static inline const char* create_add_response(GraphicsManager UNUSED *self, bool data_loaded, uint32_t iid) { - static char rbuf[sizeof(add_response)/sizeof(add_response[0])]; + static char rbuf[sizeof(add_response)/sizeof(add_response[0]) + 64]; if (iid) { if (!has_add_respose) { if (!data_loaded) return NULL; diff --git a/kitty/history.c b/kitty/history.c index a6129e6a7..fa6feb412 100644 --- a/kitty/history.c +++ b/kitty/history.c @@ -215,7 +215,7 @@ as_text(HistoryBuf *self, PyObject *args) { static PyObject* -dirty_lines(HistoryBuf *self) { +dirty_lines(HistoryBuf *self, PyObject *a UNUSED) { #define dirty_lines_doc "dirty_lines() -> Line numbers of all lines that have dirty text." PyObject *ans = PyList_New(0); for (index_type i = 0; i < self->ynum; i++) { diff --git a/kitty/keys.h b/kitty/keys.h index c6e045585..65ec65839 100644 --- a/kitty/keys.h +++ b/kitty/keys.h @@ -1747,6 +1747,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { return "\x01\x0d"; } // end switch(key) } // end switch(mods) + break; case 2: // REPEAT switch (mods & 0xf) { @@ -3005,8 +3006,10 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { return "\x01\x0d"; } // end switch(key) } // end switch(mods) + break; } // end switch(action) in mode NORMAL + break; case APPLICATION: @@ -4271,6 +4274,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { return "\x01\x0d"; } // end switch(key) } // end switch(mods) + break; case 2: // REPEAT switch (mods & 0xf) { @@ -5529,8 +5533,10 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { return "\x01\x0d"; } // end switch(key) } // end switch(mods) + break; } // end switch(action) in mode APPLICATION + break; case EXTENDED: @@ -9134,6 +9140,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { return "\x05\x4b\x72\x50\x42\x68"; } // end switch(key) } // end switch(mods) + break; case 1: // PRESS switch (mods & 0xf) { @@ -12738,6 +12745,7 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { return "\x05\x4b\x70\x50\x42\x68"; } // end switch(key) } // end switch(mods) + break; case 2: // REPEAT switch (mods & 0xf) { @@ -16342,8 +16350,10 @@ key_lookup(uint8_t key, KeyboardMode mode, uint8_t mods, uint8_t action) { return "\x05\x4b\x74\x50\x42\x68"; } // end switch(key) } // end switch(mods) + break; } // end switch(action) in mode EXTENDED + break; } diff --git a/kitty/keys.py b/kitty/keys.py index 46c75dfa1..b99ae3a84 100644 --- a/kitty/keys.py +++ b/kitty/keys.py @@ -336,13 +336,15 @@ def generate_key_table(): ind('return NULL;') i -= 2 i -= 1 - ind('} // end switch(mods)\n') + ind('} // end switch(mods)') + ind('break;\n') i -= 1 else: ind('return NULL;\n') i -= 1 i -= 1 - ind('}} // end switch(action) in mode {}\n\n'.format(mode)) + ind('}} // end switch(action) in mode {}'.format(mode)) + ind('break;\n\n') i -= 1 i -= 1 ind('}') diff --git a/kitty/line-buf.c b/kitty/line-buf.c index e5dee70e4..51092bf0e 100644 --- a/kitty/line-buf.c +++ b/kitty/line-buf.c @@ -46,7 +46,7 @@ linebuf_mark_line_clean(LineBuf *self, index_type y) { } static PyObject* -clear(LineBuf *self) { +clear(LineBuf *self, PyObject *a UNUSED) { #define clear_doc "Clear all lines in this LineBuf" linebuf_clear(self, BLANK_CHAR); Py_RETURN_NONE; @@ -167,7 +167,7 @@ set_continued(LineBuf *self, PyObject *args) { } static PyObject* -dirty_lines(LineBuf *self) { +dirty_lines(LineBuf *self, PyObject *a UNUSED) { #define dirty_lines_doc "dirty_lines() -> Line numbers of all lines that have dirty text." PyObject *ans = PyList_New(0); for (index_type i = 0; i < self->ynum; i++) { diff --git a/kitty/line.c b/kitty/line.c index 8a9dc2641..be87886e8 100644 --- a/kitty/line.c +++ b/kitty/line.c @@ -263,7 +263,7 @@ line_as_ansi(Line *self, Py_UCS4 *buf, index_type buflen) { } static PyObject* -as_ansi(Line* self) { +as_ansi(Line* self, PyObject *a UNUSED) { #define as_ansi_doc "Return the line's contents with ANSI (SGR) escape codes for formatting" static Py_UCS4 t[5120] = {0}; index_type num = line_as_ansi(self, t, 5120); @@ -272,7 +272,7 @@ as_ansi(Line* self) { } static PyObject* -is_continued(Line* self) { +is_continued(Line* self, PyObject *a UNUSED) { #define is_continued_doc "Return the line's continued flag" PyObject *ans = self->continued ? Py_True : Py_False; Py_INCREF(ans); diff --git a/kitty/screen.c b/kitty/screen.c index 1498faba7..f9fcec1a9 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -219,7 +219,7 @@ screen_change_scrollback_size(Screen *self, unsigned int size) { } static PyObject* -reset_callbacks(Screen *self) { +reset_callbacks(Screen *self, PyObject *a UNUSED) { Py_CLEAR(self->callbacks); self->callbacks = Py_None; Py_INCREF(self->callbacks); @@ -1444,8 +1444,8 @@ screen_open_url(Screen *self) { // }}} // Python interface {{{ -#define WRAP0(name) static PyObject* name(Screen *self) { screen_##name(self); Py_RETURN_NONE; } -#define WRAP0x(name) static PyObject* xxx_##name(Screen *self) { screen_##name(self); Py_RETURN_NONE; } +#define WRAP0(name) static PyObject* name(Screen *self, PyObject *a UNUSED) { screen_##name(self); Py_RETURN_NONE; } +#define WRAP0x(name) static PyObject* xxx_##name(Screen *self, PyObject *a UNUSED) { screen_##name(self); Py_RETURN_NONE; } #define WRAP1(name, defval) static PyObject* name(Screen *self, PyObject *args) { unsigned int v=defval; if(!PyArg_ParseTuple(args, "|I", &v)) return NULL; screen_##name(self, v); Py_RETURN_NONE; } #define WRAP1B(name, defval) static PyObject* name(Screen *self, PyObject *args) { unsigned int v=defval; int b=false; if(!PyArg_ParseTuple(args, "|Ip", &v, &b)) return NULL; screen_##name(self, v, b); Py_RETURN_NONE; } #define WRAP1E(name, defval, ...) static PyObject* name(Screen *self, PyObject *args) { unsigned int v=defval; if(!PyArg_ParseTuple(args, "|I", &v)) return NULL; screen_##name(self, v, __VA_ARGS__); Py_RETURN_NONE; } @@ -1458,7 +1458,7 @@ as_text(Screen *self, PyObject *args) { } static PyObject* -refresh_sprite_positions(Screen *self) { +refresh_sprite_positions(Screen *self, PyObject *a UNUSED) { self->is_dirty = true; for (index_type i = 0; i < self->lines; i++) { linebuf_mark_line_dirty(self->main_linebuf, i); @@ -1572,13 +1572,13 @@ set_mode(Screen *self, PyObject *args) { } static PyObject* -reset_dirty(Screen *self) { +reset_dirty(Screen *self, PyObject *a UNUSED) { screen_reset_dirty(self); Py_RETURN_NONE; } static PyObject* -is_using_alternate_linebuf(Screen *self) { +is_using_alternate_linebuf(Screen *self, PyObject *a UNUSED) { if (self->linebuf == self->alt_linebuf) Py_RETURN_TRUE; Py_RETURN_FALSE; } @@ -1631,7 +1631,7 @@ change_scrollback_size(Screen *self, PyObject *args) { } static PyObject* -text_for_selection(Screen *self) { +text_for_selection(Screen *self, PyObject *a UNUSED) { FullSelectionBoundary start, end; full_selection_limits_(selection, &start, &end); PyObject *ans = NULL; @@ -1747,26 +1747,26 @@ screen_update_selection(Screen *self, index_type x, index_type y, bool ended) { } static PyObject* -mark_as_dirty(Screen *self) { +mark_as_dirty(Screen *self, PyObject *a UNUSED) { self->is_dirty = true; Py_RETURN_NONE; } static PyObject* -current_char_width(Screen *self) { +current_char_width(Screen *self, PyObject *a UNUSED) { #define current_char_width_doc "The width of the character under the cursor" return PyLong_FromUnsignedLong(screen_current_char_width(self)); } static PyObject* -is_main_linebuf(Screen *self) { +is_main_linebuf(Screen *self, PyObject *a UNUSED) { PyObject *ans = (self->linebuf == self->main_linebuf) ? Py_True : Py_False; Py_INCREF(ans); return ans; } static PyObject* -toggle_alt_screen(Screen *self) { +toggle_alt_screen(Screen *self, PyObject *a UNUSED) { screen_toggle_screen_buffer(self); Py_RETURN_NONE; } diff --git a/kitty/shaders.c b/kitty/shaders.c index 80a19d73f..dcae8356c 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -587,9 +587,8 @@ end: Py_RETURN_NONE; } -#define PYWRAP0(name) static PyObject* py##name(PyObject UNUSED *self) +#define PYWRAP0(name) static PyObject* py##name(PYNOARG) #define PYWRAP1(name) static PyObject* py##name(PyObject UNUSED *self, PyObject *args) -#define PYWRAP2(name) static PyObject* py##name(PyObject UNUSED *self, PyObject *args, PyObject *kw) #define PA(fmt, ...) if(!PyArg_ParseTuple(args, fmt, __VA_ARGS__)) return NULL; #define ONE_INT(name) PYWRAP1(name) { name(PyLong_AsSsize_t(args)); Py_RETURN_NONE; } #define TWO_INT(name) PYWRAP1(name) { int a, b; PA("ii", &a, &b); name(a, b); Py_RETURN_NONE; } diff --git a/kitty/state.c b/kitty/state.c index 4b97a55d4..458089c3c 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -268,9 +268,8 @@ os_window_regions(OSWindow *os_window, Region *central, Region *tab_bar) { // Python API {{{ -#define PYWRAP0(name) static PyObject* py##name(PyObject UNUSED *self) +#define PYWRAP0(name) static PyObject* py##name(PYNOARG) #define PYWRAP1(name) static PyObject* py##name(PyObject UNUSED *self, PyObject *args) -#define PYWRAP2(name) static PyObject* py##name(PyObject UNUSED *self, PyObject *args, PyObject *kw) #define PA(fmt, ...) if(!PyArg_ParseTuple(args, fmt, __VA_ARGS__)) return NULL; #define ONE_UINT(name) PYWRAP1(name) { name((unsigned int)PyLong_AsUnsignedLong(args)); Py_RETURN_NONE; } #define TWO_UINT(name) PYWRAP1(name) { unsigned int a, b; PA("II", &a, &b); name(a, b); Py_RETURN_NONE; }