From 4a2779365185c063a86825beb3d5e01b7fa0c0d4 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 9 Sep 2017 12:08:14 +0530 Subject: [PATCH] DRYer CoreText --- kitty/core_text.h | 15 --------------- kitty/core_text.m | 5 +++++ kitty/data-types.c | 11 ++++------- 3 files changed, 9 insertions(+), 22 deletions(-) delete mode 100644 kitty/core_text.h diff --git a/kitty/core_text.h b/kitty/core_text.h deleted file mode 100644 index 83fd1bf11..000000000 --- a/kitty/core_text.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (C) 2017 Kovid Goyal - * - * Distributed under terms of the GPL3 license. - */ - -#pragma once - -#define UNUSED __attribute__ ((unused)) - -int init_CoreText(PyObject *); -PyObject* coretext_all_fonts(PyObject UNUSED *self); - -#define CORE_TEXT_FUNC_WRAPPERS \ - {"coretext_all_fonts", (PyCFunction)coretext_all_fonts, METH_NOARGS, ""}, diff --git a/kitty/core_text.m b/kitty/core_text.m index 00f8e4e9e..11fc24a6d 100644 --- a/kitty/core_text.m +++ b/kitty/core_text.m @@ -320,11 +320,16 @@ PyTypeObject Face_Type = { .tp_repr = (reprfunc)repr, }; +static PyMethodDef module_methods[] = { + {"coretext_all_fonts", (PyCFunction)coretext_all_fonts, METH_NOARGS, ""}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; int init_CoreText(PyObject *module) { if (PyType_Ready(&Face_Type) < 0) return 0; if (PyModule_AddObject(module, "CTFace", (PyObject *)&Face_Type) != 0) return 0; + if (PyModule_AddFunctions(module, module_methods) != 0) return 0; return 1; } diff --git a/kitty/data-types.c b/kitty/data-types.c index 9370591c4..dd9afec7e 100644 --- a/kitty/data-types.c +++ b/kitty/data-types.c @@ -60,10 +60,6 @@ stop_profiler(PyObject UNUSED *self) { } #endif -#ifdef __APPLE__ -#include "core_text.h" -#endif - static PyMethodDef module_methods[] = { {"set_iutf8", (PyCFunction)pyset_iutf8, METH_VARARGS, ""}, {"thread_write", (PyCFunction)cm_thread_write, METH_VARARGS, ""}, @@ -72,9 +68,6 @@ static PyMethodDef module_methods[] = { {"redirect_std_streams", (PyCFunction)redirect_std_streams, METH_VARARGS, ""}, {"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""}, {"change_wcwidth", (PyCFunction)change_wcwidth_wrap, METH_O, ""}, -#ifdef __APPLE__ - CORE_TEXT_FUNC_WRAPPERS -#endif GLFW_FUNC_WRAPPERS SPRITE_FUNC_WRAPPERS #ifdef WITH_PROFILER @@ -108,6 +101,10 @@ extern int init_Face(PyObject *); extern int init_Window(PyObject *); extern bool init_freetype_library(PyObject*); extern bool init_fontconfig_library(PyObject*); +#ifdef __APPLE__ +extern int init_CoreText(PyObject *); +#endif + EXPORTED PyMODINIT_FUNC PyInit_fast_data_types(void) {