Skip to content

Commit

Permalink
Merge pull request #1 from tannewt/vectorio
Browse files Browse the repository at this point in the history
Merge in master
  • Loading branch information
Kenny authored May 12, 2020
2 parents 90bd931 + d274074 commit 8a9579c
Show file tree
Hide file tree
Showing 85 changed files with 2,767 additions and 203 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,13 @@ jobs:
- "pewpew10"
- "pewpew_m4"
- "pirkey_m0"
- "pitaya_go"
- "pyb_nano_v2"
- "pybadge"
- "pybadge_airlift"
- "pyboard_v11"
- "pycubed"
- "pycubed_mram"
- "pygamer"
- "pygamer_advance"
- "pyportal"
Expand Down Expand Up @@ -249,6 +251,7 @@ jobs:
- "stm32f746g_discovery"
- "stringcar_m0_express"
- "teensy40"
- "teensy41"
- "teknikio_bluebird"
- "thunderpack"
- "trellis_m4_express"
Expand Down
33 changes: 24 additions & 9 deletions extmod/modujson.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps);

#define JSON_DEBUG(...) (void)0
// #define JSON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__)


// The function below implements a simple non-recursive JSON parser.
//
// The JSON specification is at http://www.ietf.org/rfc/rfc4627.txt
Expand Down Expand Up @@ -80,6 +84,7 @@ typedef struct _ujson_stream_t {

STATIC byte ujson_stream_next(ujson_stream_t *s) {
mp_uint_t ret = s->read(s->stream_obj, &s->cur, 1, &s->errcode);
JSON_DEBUG(" usjon_stream_next err:%2d cur: %c \n", s->errcode, s->cur);
if (s->errcode != 0) {
mp_raise_OSError(s->errcode);
}
Expand All @@ -89,9 +94,10 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) {
return s->cur;
}

STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
STATIC mp_obj_t _mod_ujson_load(mp_obj_t stream_obj, bool return_first_json) {
const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ);
ujson_stream_t s = {stream_obj, stream_p->read, 0, 0};
JSON_DEBUG("got JSON stream\n");
vstr_t vstr;
vstr_init(&vstr, 8);
mp_obj_list_t stack; // we use a list as a simple stack for nested JSON
Expand Down Expand Up @@ -262,13 +268,18 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
}
}
success:
// eat trailing whitespace
while (unichar_isspace(S_CUR(s))) {
S_NEXT(s);
}
if (!S_END(s)) {
// unexpected chars
goto fail;
// It is legal for a stream to have contents after JSON.
// E.g., A UART is not closed after receiving an object; in load() we will
// return the first complete JSON object, while in loads() we will retain
// strict adherence to the buffer's complete semantic.
if (!return_first_json) {
while (unichar_isspace(S_CUR(s))) {
S_NEXT(s);
}
if (!S_END(s)) {
// unexpected chars
goto fail;
}
}
if (stack_top == MP_OBJ_NULL || stack.len != 0) {
// not exactly 1 object
Expand All @@ -280,14 +291,18 @@ STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
fail:
mp_raise_ValueError(translate("syntax error in JSON"));
}

STATIC mp_obj_t mod_ujson_load(mp_obj_t stream_obj) {
return _mod_ujson_load(stream_obj, true);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_load_obj, mod_ujson_load);

STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
size_t len;
const char *buf = mp_obj_str_get_data(obj, &len);
vstr_t vstr = {len, len, (char*)buf, true};
mp_obj_stringio_t sio = {{&mp_type_stringio}, &vstr, 0, MP_OBJ_NULL};
return mod_ujson_load(MP_OBJ_FROM_PTR(&sio));
return _mod_ujson_load(MP_OBJ_FROM_PTR(&sio), false);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_loads_obj, mod_ujson_loads);

Expand Down
45 changes: 36 additions & 9 deletions locale/ID.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-06 17:47+0800\n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -70,13 +70,22 @@ msgstr ""
msgid "%q indices must be integers, not %s"
msgstr ""

#: shared-bindings/vectorio/Polygon.c
msgid "%q list must be a list"
msgstr ""

#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
#: shared-bindings/displayio/Shape.c
#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
#: shared-bindings/vectorio/Rectangle.c
#, fuzzy
msgid "%q must be >= 1"
msgstr "buffers harus mempunyai panjang yang sama"

#: shared-bindings/vectorio/Polygon.c
msgid "%q must be a tuple of length 2"
msgstr ""

#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr ""
Expand Down Expand Up @@ -797,7 +806,8 @@ msgstr ""
msgid "Group full"
msgstr ""

#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c
#: ports/stm/common-hal/busio/SPI.c
msgid "Hardware busy, try alternative pins"
msgstr ""

Expand Down Expand Up @@ -1050,15 +1060,15 @@ msgstr ""
msgid "Microphone startup delay must be in range 0.0 to 1.0"
msgstr ""

#: ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "Missing MISO or MOSI Pin"
msgstr ""

#: shared-bindings/displayio/Group.c
msgid "Must be a %q subclass."
msgstr ""

#: ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "Must provide MISO or MOSI pin"
msgstr ""

Expand Down Expand Up @@ -1089,11 +1099,11 @@ msgstr "Tidak ada DAC (Digital Analog Converter) di dalam chip"
msgid "No DMA channel found"
msgstr "tidak ada channel DMA ditemukan"

#: ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "No MISO Pin"
msgstr ""

#: ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "No MOSI Pin"
msgstr ""

Expand Down Expand Up @@ -1142,6 +1152,10 @@ msgstr "Tidak ada dukungan hardware untuk pin"
msgid "No key was specified"
msgstr ""

#: shared-bindings/time/__init__.c
msgid "No long integer support"
msgstr ""

#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "No more timers available on this pin."
msgstr ""
Expand Down Expand Up @@ -2012,6 +2026,10 @@ msgstr ""
msgid "chr() arg not in range(256)"
msgstr ""

#: shared-module/vectorio/Circle.c
msgid "circle can only be registered in one parent"
msgstr ""

#: shared-bindings/displayio/Palette.c
msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)"
msgstr ""
Expand Down Expand Up @@ -2114,6 +2132,10 @@ msgstr ""
msgid "empty"
msgstr ""

#: shared-bindings/vectorio/Polygon.c
msgid "empty %q list"
msgstr ""

#: extmod/moduheapq.c extmod/modutimeq.c
msgid "empty heap"
msgstr "heap kosong"
Expand Down Expand Up @@ -2804,10 +2826,14 @@ msgstr ""
msgid "pixel value requires too many bits"
msgstr ""

#: shared-bindings/displayio/TileGrid.c
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter"
msgstr ""

#: shared-module/vectorio/Polygon.c
msgid "polygon can only be registered in one parent"
msgstr ""

#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
Expand Down Expand Up @@ -3127,7 +3153,8 @@ msgstr ""
msgid "unreadable attribute"
msgstr ""

#: shared-bindings/displayio/TileGrid.c
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c
#: shared-bindings/vectorio/VectorShape.c
msgid "unsupported %q type"
msgstr ""

Expand Down
45 changes: 36 additions & 9 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-05-06 17:47+0800\n"
"POT-Creation-Date: 2020-05-12 12:24-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -70,12 +70,21 @@ msgstr ""
msgid "%q indices must be integers, not %s"
msgstr ""

#: shared-bindings/vectorio/Polygon.c
msgid "%q list must be a list"
msgstr ""

#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
#: shared-bindings/displayio/Shape.c
#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
#: shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr ""

#: shared-bindings/vectorio/Polygon.c
msgid "%q must be a tuple of length 2"
msgstr ""

#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr ""
Expand Down Expand Up @@ -786,7 +795,8 @@ msgstr ""
msgid "Group full"
msgstr ""

#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c
#: ports/stm/common-hal/busio/SPI.c
msgid "Hardware busy, try alternative pins"
msgstr ""

Expand Down Expand Up @@ -1039,15 +1049,15 @@ msgstr ""
msgid "Microphone startup delay must be in range 0.0 to 1.0"
msgstr ""

#: ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "Missing MISO or MOSI Pin"
msgstr ""

#: shared-bindings/displayio/Group.c
msgid "Must be a %q subclass."
msgstr ""

#: ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "Must provide MISO or MOSI pin"
msgstr ""

Expand Down Expand Up @@ -1078,11 +1088,11 @@ msgstr ""
msgid "No DMA channel found"
msgstr ""

#: ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "No MISO Pin"
msgstr ""

#: ports/stm/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "No MOSI Pin"
msgstr ""

Expand Down Expand Up @@ -1131,6 +1141,10 @@ msgstr ""
msgid "No key was specified"
msgstr ""

#: shared-bindings/time/__init__.c
msgid "No long integer support"
msgstr ""

#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "No more timers available on this pin."
msgstr ""
Expand Down Expand Up @@ -1988,6 +2002,10 @@ msgstr ""
msgid "chr() arg not in range(256)"
msgstr ""

#: shared-module/vectorio/Circle.c
msgid "circle can only be registered in one parent"
msgstr ""

#: shared-bindings/displayio/Palette.c
msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)"
msgstr ""
Expand Down Expand Up @@ -2090,6 +2108,10 @@ msgstr ""
msgid "empty"
msgstr ""

#: shared-bindings/vectorio/Polygon.c
msgid "empty %q list"
msgstr ""

#: extmod/moduheapq.c extmod/modutimeq.c
msgid "empty heap"
msgstr ""
Expand Down Expand Up @@ -2779,10 +2801,14 @@ msgstr ""
msgid "pixel value requires too many bits"
msgstr ""

#: shared-bindings/displayio/TileGrid.c
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter"
msgstr ""

#: shared-module/vectorio/Polygon.c
msgid "polygon can only be registered in one parent"
msgstr ""

#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
Expand Down Expand Up @@ -3101,7 +3127,8 @@ msgstr ""
msgid "unreadable attribute"
msgstr ""

#: shared-bindings/displayio/TileGrid.c
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/Polygon.c
#: shared-bindings/vectorio/VectorShape.c
msgid "unsupported %q type"
msgstr ""

Expand Down
Loading

0 comments on commit 8a9579c

Please sign in to comment.