From 88dd01eb22d1c0f37ef69c5b082dbc5dd7b82cf6 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Wed, 21 Sep 2022 10:03:16 +1000 Subject: [PATCH] Updated Build Troubleshooting (markdown) --- Build-Troubleshooting.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Build-Troubleshooting.md b/Build-Troubleshooting.md index 02ce469..a1cefab 100644 --- a/Build-Troubleshooting.md +++ b/Build-Troubleshooting.md @@ -61,6 +61,24 @@ 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 ``` +If your code needs to access fields on `mp_obj_type_t` (this should be relatively rare), then you will now need to do so via the helper macros. Code that previously did: + +```c +if (type->call) {} // See if field is set. +mp_call_fun_t f = type->call; // Access field. +type->call = f; // Set field. +``` + +will need to be changed to: + +```c +if (MP_OBJ_TYPE_HAS_SLOT(type, call)) {} +mp_call_fun_t f = MP_OBJ_TYPE_GET_SLOT(type, call); // Or MP_OBJ_TYPE_GET_SLOT_OR_NULL(type, call) if you do not know whether the slot is set. +MP_OBJ_TYPE_SET_SLOT(type, call, f, index); +``` + +In the last case, you need to know the index (likely this is being used in a situation where you're initialising a new mp_obj_type_t instance so you can generate the slots sequentially). + ## buffer The definition for a type with a buffer slot has been simplified and no longer requires a nested struct.