Browse Source

Merge pull request #8 from larsks/fix/qstr

Fix spelling of MP_QSTR
master
Zoltán Vörös 2 years ago
committed by GitHub
parent
commit
237b717236
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      docs/micropython-usermod.ipynb
  2. 6
      docs/source/usermods_05.rst

2
docs/micropython-usermod.ipynb

@ -851,7 +851,7 @@
"source": [
"At this point, we are more or less done with the C implementation of our function, but we still have to expose it. This we do by adding a table, an array of key/value pairs to the globals of our module, and bind the table to the `_module_globals` variable by applying the `MP_DEFINE_CONST_DICT` macro. This table should have at least one entry, the name of the module, which is going to be stored in the string `MP_QSTR___name__`. \n",
"\n",
"These `MP_QSRT_` items are the C representation of the python strings that come at the end of them. So, `MP_QSRT_foo_bar` in C will be turned into a name, `foo_bar`, in python. `foo_bar` can be a constant, a function, a class, a type, etc., and depending on what is associated with it, different things will happen on the console, when `foo_bar` is invoked. But the crucial point is that, if you want `foo_bar` to have any meaning in python, then somewhere in your C code, you have to define `MP_QSRT_foo_bar`. \n",
"These `MP_QSTR_` items are the C representation of the python strings that come at the end of them. So, `MP_QSTR_foo_bar` in C will be turned into a name, `foo_bar`, in python. `foo_bar` can be a constant, a function, a class, a type, etc., and depending on what is associated with it, different things will happen on the console, when `foo_bar` is invoked. But the crucial point is that, if you want `foo_bar` to have any meaning in python, then somewhere in your C code, you have to define `MP_QSTR_foo_bar`. \n",
"\n",
"The second key-value pair of the table is the pointer to the function that we have just implemented, and the name that we want to call the functions in python itself. So, in the example below, our `simplefunction_add_ints` function will be invoked, when we call `add_ints` in the console.\n",
"\n",

6
docs/source/usermods_05.rst

@ -119,14 +119,14 @@ table to the ``_module_globals`` variable by applying the
entry, the name of the module, which is going to be stored in the string
``MP_QSTR___name__``.
These ``MP_QSRT_`` items are the C representation of the python strings
that come at the end of them. So, ``MP_QSRT_foo_bar`` in C will be
These ``MP_QSTR_`` items are the C representation of the python strings
that come at the end of them. So, ``MP_QSTR_foo_bar`` in C will be
turned into a name, ``foo_bar``, in python. ``foo_bar`` can be a
constant, a function, a class, a type, etc., and depending on what is
associated with it, different things will happen on the console, when
``foo_bar`` is invoked. But the crucial point is that, if you want
``foo_bar`` to have any meaning in python, then somewhere in your C
code, you have to define ``MP_QSRT_foo_bar``.
code, you have to define ``MP_QSTR_foo_bar``.
The second key-value pair of the table is the pointer to the function
that we have just implemented, and the name that we want to call the

Loading…
Cancel
Save