From 98cbbbf8ba90550d5d2b67155c352f8c73e33c88 Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Fri, 19 Jul 2019 19:56:45 +0200 Subject: [PATCH] fix(pycardium): Make sure clang-format won't break upy macros Closes #45 Signed-off-by: Rahix <rahix@rahix.de> --- Documentation/pycardium-guide.rst | 7 +++++++ pycardium/modules/leds.c | 1 + pycardium/modules/utime.c | 1 + pycardium/modules/vibra.c | 3 ++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/pycardium-guide.rst b/Documentation/pycardium-guide.rst index 707a86ed..3a8fcaba 100644 --- a/Documentation/pycardium-guide.rst +++ b/Documentation/pycardium-guide.rst @@ -82,8 +82,15 @@ looks like this: }; /* This is a special macro that will make MicroPython aware of this module */ + /* clang-format off */ MP_REGISTER_MODULE(MP_QSTR_example, example_module, MODULE_EXAMPLE_ENABLED); +.. note:: + + Please keep the ``/* clang-format off */``. It ensures that *clang-format* + won't touch the following line. This is necessary because MicroPython's + codegen scripts can'd deal with newlines in the ``MP_REGISTER_MODULE`` macro. + Build Integration ~~~~~~~~~~~~~~~~~ Next, you need to add your module to ``pycardium/meson.build``. There is a list diff --git a/pycardium/modules/leds.c b/pycardium/modules/leds.c index efce3e08..a1dc47e8 100644 --- a/pycardium/modules/leds.c +++ b/pycardium/modules/leds.c @@ -44,4 +44,5 @@ const mp_obj_module_t leds_module = { }; /* Register the module to make it available in Python */ +/* clang-format off */ MP_REGISTER_MODULE(MP_QSTR_leds, leds_module, MODULE_LEDS_ENABLED); diff --git a/pycardium/modules/utime.c b/pycardium/modules/utime.c index 107202dc..39972df4 100644 --- a/pycardium/modules/utime.c +++ b/pycardium/modules/utime.c @@ -25,4 +25,5 @@ const mp_obj_module_t mp_module_utime = { }; /* Register the module to make it available in Python */ +/* clang-format off */ MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_utime, MODULE_UTIME_ENABLED); diff --git a/pycardium/modules/vibra.c b/pycardium/modules/vibra.c index 50bd0721..96249846 100644 --- a/pycardium/modules/vibra.c +++ b/pycardium/modules/vibra.c @@ -37,5 +37,6 @@ const mp_obj_module_t vibra_module = { .globals = (mp_obj_dict_t *)&vibra_module_globals, }; -// Register the module to make it available in Python +/* Register the module to make it available in Python */ +/* clang-format off */ MP_REGISTER_MODULE(MP_QSTR_vibra, vibra_module, MODULE_VIBRA_ENABLED); -- GitLab