File: publiccapi.rst

package info (click to toggle)
micropython 1.25.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 48,944 kB
  • sloc: ansic: 317,850; python: 59,539; xml: 4,241; makefile: 3,530; sh: 1,421; javascript: 744; asm: 681; cpp: 45; exp: 11; pascal: 6
file content (25 lines) | stat: -rw-r--r-- 936 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
.. _publiccapi:

The public C API
================

The public C-API comprises functions defined in all C header files in the ``py/``
directory. Most of the important core runtime C APIs are exposed in ``runtime.h`` and
``obj.h``.

The following is an example of public API functions from ``obj.h``:

.. code-block:: c

   mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items);
   mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg);
   mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value);
   void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items);

At its core, any functions and macros in header files make up the public
API and can be used to access very low-level details of MicroPython. Static
inline functions in header files are fine too, such functions will be
inlined in the code when used.

Header files in the ``ports`` directory are only exposed to the functionality
specific to a given port.