summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-02-21 11:09:44 -0500
committerDan Halbert <halbert@halwitz.org>2019-02-21 11:09:44 -0500
commit10d3a20f8a639ad8ef5555e2142052190e8a7e13 (patch)
treead72afa87cadb0e3749d60109cffdd768280cc00 /py
parentc5dbdbe88c099494cd14790b8c645020538eed27 (diff)
Add CIRCUITPY macro; rename u* only when CIRCUITPY=1
Diffstat (limited to 'py')
-rw-r--r--py/circuitpy_mpconfig.h3
-rw-r--r--py/moduerrno.c4
-rwxr-xr-xpy/mpconfig.h5
-rw-r--r--py/objmodule.c19
4 files changed, 28 insertions, 3 deletions
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index c70d52a7b..bb43201d8 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -33,6 +33,9 @@
#ifndef __INCLUDED_MPCONFIG_CIRCUITPY_H
#define __INCLUDED_MPCONFIG_CIRCUITPY_H
+// This is CircuitPython.
+#define CIRCUITPY 1
+
// REPR_C encodes qstrs, 31-bit ints, and 30-bit floats in a single 32-bit word.
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C)
diff --git a/py/moduerrno.c b/py/moduerrno.c
index c5daae468..7915603e4 100644
--- a/py/moduerrno.c
+++ b/py/moduerrno.c
@@ -84,7 +84,11 @@ STATIC const mp_obj_dict_t errorcode_dict = {
#endif
STATIC const mp_rom_map_elem_t mp_module_uerrno_globals_table[] = {
+#if CIRCUITPY
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_errno) },
+#else
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uerrno) },
+#endif
#if MICROPY_PY_UERRNO_ERRORCODE
{ MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) },
#endif
diff --git a/py/mpconfig.h b/py/mpconfig.h
index bb7952a8b..3ec383817 100755
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -45,6 +45,11 @@
#include <mpconfigport.h>
#endif
+// Is this a CircuitPython build?
+#ifndef CIRCUITPY
+#define CIRCUITPY 0
+#endif
+
// Any options not explicitly set in mpconfigport.h will get default
// values below.
diff --git a/py/objmodule.c b/py/objmodule.c
index 9a56f4851..469a95976 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -148,7 +148,11 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
{ MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mp_module_array) },
#endif
#if MICROPY_PY_IO
+#if CIRCUITPY
{ MP_ROM_QSTR(MP_QSTR_io), MP_ROM_PTR(&mp_module_io) },
+#else
+ { MP_ROM_QSTR(MP_QSTR_uio), MP_ROM_PTR(&mp_module_io) },
+#endif
#endif
#if MICROPY_PY_COLLECTIONS
{ MP_ROM_QSTR(MP_QSTR_collections), MP_ROM_PTR(&mp_module_collections) },
@@ -179,9 +183,12 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
// extmod modules
#if MICROPY_PY_UERRNO
+#if CIRCUITPY
// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here.
// TODO: move to shared-bindings/
-// { MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) },
+#else
+ { MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) },
+#endif
#endif
#if MICROPY_PY_UCTYPES
{ MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) },
@@ -190,14 +197,20 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = {
{ MP_ROM_QSTR(MP_QSTR_uzlib), MP_ROM_PTR(&mp_module_uzlib) },
#endif
#if MICROPY_PY_UJSON
+#if CIRCUITPY
// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here.
// TODO: move to shared-bindings/
-// { MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) },
+#else
+ { MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) },
+#endif
#endif
#if MICROPY_PY_URE
+#if CIRCUITPY
// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here.
// TODO: move to shared-bindings/
-// { MP_ROM_QSTR(MP_QSTR_ure), MP_ROM_PTR(&mp_module_ure) },
+#else
+ { MP_ROM_QSTR(MP_QSTR_ure), MP_ROM_PTR(&mp_module_ure) },
+#endif
#endif
#if MICROPY_PY_UHEAPQ
{ MP_ROM_QSTR(MP_QSTR_uheapq), MP_ROM_PTR(&mp_module_uheapq) },