From aa87c041a7cc569b63c989231cc5105b9a7c7e46 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Tue, 20 Sep 2022 11:25:19 +1000 Subject: [PATCH] Updated Build Troubleshooting (markdown) --- Build-Troubleshooting.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Build-Troubleshooting.md b/Build-Troubleshooting.md index 53d859a..9ba05b3 100644 --- a/Build-Troubleshooting.md +++ b/Build-Troubleshooting.md @@ -51,7 +51,7 @@ MP_DEFINE_CONST_OBJ_TYPE( ... ``` -In most cases this change should be mechanical, pass the type, name, and flags as the first three arguments, then just replace all remaining `.a = b,` with `a, b,`. The one exception is `getiter` & `iternext`, see the next section. +In most cases this change should be mechanical, pass the type, name, and flags as the first three arguments, then just replace all remaining `.a = b,` with `a, b,`. The two exceptions are `buffer` and `getiter` / `iternext`, see the next two sections. If your code need to access properties on a give type, e.g. `mp_type_foo.make_new` then it needs to be updated to use the accessor macros. @@ -61,6 +61,30 @@ MP_OBJ_TYPE_GET_SLOT(type, slot) # equivalent to type->slot (but you must know t MP_OBJ_TYPE_GET_SLOT_OR_NULL(type, slot) # marginally less efficient but will return NULL if the slot is not set ``` +## buffer + +The definition for a type with a buffer slot has been simplified and no longer requires a nested struct. + +As part of updating to use `MP_DEFINE_CONST_OBJ_TYPE`, change + +```c +const mp_obj_type_t mp_type_foo = { +... + .buffer_p = { .get_buffer = mp_obj_str_get_buffer }, +... +} +``` + +to + +```c +MP_DEFINE_CONST_OBJ_TYPE( +... + buffer, mp_obj_str_get_buffer, +... +); +``` + ## getiter/iternext If you see errors about `getiter` and/or `iternext` then also see #8813.