summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-02-26 11:58:42 +1100
committerDamien George <damien.p.george@gmail.com>2020-02-28 10:31:07 +1100
commit3f39d18c2b884d32f0443e2e8114ff9d7a14d718 (patch)
tree9c0ef34c65df237b1f41ff32f36ff400e1730af8 /py
parentb86075ef1fc8df19844b18b315ade3c084accd54 (diff)
all: Add *FORMAT-OFF* in various places.
This string is recognised by uncrustify, to disable formatting in the region marked by these comments. This is necessary in the qstrdef*.h files to prevent modification of the strings within the Q(...). In other places it is used to prevent excessive reformatting that would make the code less readable.
Diffstat (limited to 'py')
-rw-r--r--py/gc.c2
-rw-r--r--py/grammar.h2
-rw-r--r--py/nlr.h4
-rw-r--r--py/objexcept.c4
-rw-r--r--py/objint_mpz.c2
-rw-r--r--py/parse.c4
-rw-r--r--py/qstrdefs.h2
-rw-r--r--py/vm.c2
-rw-r--r--py/vmentrytable.h2
9 files changed, 24 insertions, 0 deletions
diff --git a/py/gc.c b/py/gc.c
index c18cd429f..092dbc750 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -473,10 +473,12 @@ void *gc_alloc(size_t n_bytes, unsigned int alloc_flags) {
n_free = 0;
for (i = MP_STATE_MEM(gc_last_free_atb_index); i < MP_STATE_MEM(gc_alloc_table_byte_len); i++) {
byte a = MP_STATE_MEM(gc_alloc_table_start)[i];
+ // *FORMAT-OFF*
if (ATB_0_IS_FREE(a)) { if (++n_free >= n_blocks) { i = i * BLOCKS_PER_ATB + 0; goto found; } } else { n_free = 0; }
if (ATB_1_IS_FREE(a)) { if (++n_free >= n_blocks) { i = i * BLOCKS_PER_ATB + 1; goto found; } } else { n_free = 0; }
if (ATB_2_IS_FREE(a)) { if (++n_free >= n_blocks) { i = i * BLOCKS_PER_ATB + 2; goto found; } } else { n_free = 0; }
if (ATB_3_IS_FREE(a)) { if (++n_free >= n_blocks) { i = i * BLOCKS_PER_ATB + 3; goto found; } } else { n_free = 0; }
+ // *FORMAT-ON*
}
GC_EXIT();
diff --git a/py/grammar.h b/py/grammar.h
index ca9b5b379..c3d30cdf7 100644
--- a/py/grammar.h
+++ b/py/grammar.h
@@ -24,6 +24,8 @@
* THE SOFTWARE.
*/
+// *FORMAT-OFF*
+
// rules for writing rules:
// - zero_or_more is implemented using opt_rule around a one_or_more rule
// - don't put opt_rule in arguments of or rule; instead, wrap the call to this or rule in opt_rule
diff --git a/py/nlr.h b/py/nlr.h
index 3be3eb58c..f9fbf56e5 100644
--- a/py/nlr.h
+++ b/py/nlr.h
@@ -42,6 +42,8 @@
#define MICROPY_NLR_NUM_REGS_XTENSA (10)
#define MICROPY_NLR_NUM_REGS_XTENSAWIN (17)
+// *FORMAT-OFF*
+
// If MICROPY_NLR_SETJMP is not enabled then auto-detect the machine arch
#if !MICROPY_NLR_SETJMP
// A lot of nlr-related things need different treatment on Windows
@@ -83,6 +85,8 @@
#endif
#endif
+// *FORMAT-ON*
+
#if MICROPY_NLR_SETJMP
#include <setjmp.h>
#endif
diff --git a/py/objexcept.c b/py/objexcept.c
index de3b0abe1..b5c169327 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -224,6 +224,8 @@ const mp_obj_type_t mp_type_BaseException = {
.attr = mp_obj_exception_attr,
};
+// *FORMAT-OFF*
+
// List of all exceptions, arranged as in the table at:
// http://docs.python.org/3/library/exceptions.html
MP_DEFINE_EXCEPTION(SystemExit, BaseException)
@@ -303,6 +305,8 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
MP_DEFINE_EXCEPTION(ResourceWarning, Warning)
*/
+// *FORMAT-ON*
+
mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) {
assert(exc_type->make_new == mp_obj_exception_make_new);
return mp_obj_exception_make_new(exc_type, 0, 0, NULL);
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 5c014ac23..7b2bcc9c9 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -41,6 +41,7 @@
#if MICROPY_PY_SYS_MAXSIZE
// Export value for sys.maxsize
+// *FORMAT-OFF*
#define DIG_MASK ((MPZ_LONG_1 << MPZ_DIG_SIZE) - 1)
STATIC const mpz_dig_t maxsize_dig[] = {
#define NUM_DIG 1
@@ -64,6 +65,7 @@ STATIC const mpz_dig_t maxsize_dig[] = {
#endif
#endif
};
+// *FORMAT-ON*
const mp_obj_int_t mp_maxsize_obj = {
{&mp_type_int},
{.fixed_dig = 1, .len = NUM_DIG, .alloc = NUM_DIG, .dig = (mpz_dig_t*)maxsize_dig}
diff --git a/py/parse.c b/py/parse.c
index 42a947997..1174f5d83 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -58,6 +58,8 @@
// (un)comment to use rule names; for debugging
//#define USE_RULE_NAME (1)
+// *FORMAT-OFF*
+
enum {
// define rules with a compile function
#define DEF_RULE(rule, comp, kind, ...) RULE_##rule,
@@ -207,6 +209,8 @@ STATIC const char *const rule_name_table[] = {
};
#endif
+// *FORMAT-ON*
+
typedef struct _rule_stack_t {
size_t src_line : (8 * sizeof(size_t) - 8); // maximum bits storing source line number
size_t rule_id : 8; // this must be large enough to fit largest rule number
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index 5c8b13b47..5b4e0dc48 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -24,6 +24,8 @@
* THE SOFTWARE.
*/
+// *FORMAT-OFF*
+
#include "py/mpconfig.h"
// All the qstr definitions in this file are available as constants.
diff --git a/py/vm.c b/py/vm.c
index 11dbffaff..8c835bb9b 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -36,6 +36,8 @@
#include "py/bc.h"
#include "py/profile.h"
+// *FORMAT-OFF*
+
#if 0
#define TRACE(ip) printf("sp=%d ", (int)(sp - &code_state->state[0] + 1)); mp_bytecode_print2(ip, 1, code_state->fun_bc->const_table);
#else
diff --git a/py/vmentrytable.h b/py/vmentrytable.h
index 7f55a4806..068214bf9 100644
--- a/py/vmentrytable.h
+++ b/py/vmentrytable.h
@@ -24,6 +24,8 @@
* THE SOFTWARE.
*/
+// *FORMAT-OFF*
+
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winitializer-overrides"