Skip to content

Commit 5dfdcc0

Browse files
author
Bernhard Boser
committed
rename read, write to read_bytes, write_bytes
1 parent 4c308cb commit 5dfdcc0

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

locale/circuitpython.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-11-17 12:15-0800\n"
11+
"POT-Creation-Date: 2020-11-10 15:30+0530\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"

ports/cxd56/boards/spresense/mpconfigboard.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ USB_PRODUCT = "Spresense"
44
USB_MANUFACTURER = "Sony"
55

66
INTERNAL_FLASH_FILESYSTEM = 1
7-
8-
CIRCUITPY_MSGPACK = 0

shared-module/msgpack/__init__.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#include <stddef.h>
2827
#include <stdio.h>
2928
#include <inttypes.h>
3029

@@ -57,7 +56,7 @@ STATIC msgpack_stream_t get_stream(mp_obj_t stream_obj, int flags) {
5756
////////////////////////////////////////////////////////////////
5857
// readers
5958

60-
STATIC void read(msgpack_stream_t *s, void *buf, mp_uint_t size) {
59+
STATIC void read_bytes(msgpack_stream_t *s, void *buf, mp_uint_t size) {
6160
if (size == 0) return;
6261
mp_uint_t ret = s->read(s->stream_obj, buf, size, &s->errcode);
6362
if (s->errcode != 0) {
@@ -70,21 +69,21 @@ STATIC void read(msgpack_stream_t *s, void *buf, mp_uint_t size) {
7069

7170
STATIC uint8_t read1(msgpack_stream_t *s) {
7271
uint8_t res = 0;
73-
read(s, &res, 1);
72+
read_bytes(s, &res, 1);
7473
return res;
7574
}
7675

7776
STATIC uint16_t read2(msgpack_stream_t *s) {
7877
uint16_t res = 0;
79-
read(s, &res, 2);
78+
read_bytes(s, &res, 2);
8079
int n = 1;
8180
if (*(char *)&n == 1) res = __builtin_bswap16(res);
8281
return res;
8382
}
8483

8584
STATIC uint32_t read4(msgpack_stream_t *s) {
8685
uint32_t res = 0;
87-
read(s, &res, 4);
86+
read_bytes(s, &res, 4);
8887
int n = 1;
8988
if (*(char *)&n == 1) res = __builtin_bswap32(res);
9089
return res;
@@ -104,7 +103,7 @@ STATIC size_t read_size(msgpack_stream_t *s, uint8_t len_index) {
104103
////////////////////////////////////////////////////////////////
105104
// writers
106105

107-
STATIC void write(msgpack_stream_t *s, const void *buf, mp_uint_t size) {
106+
STATIC void write_bytes(msgpack_stream_t *s, const void *buf, mp_uint_t size) {
108107
mp_uint_t ret = s->write(s->stream_obj, buf, size, &s->errcode);
109108
if (s->errcode != 0) {
110109
mp_raise_OSError(s->errcode);
@@ -115,19 +114,19 @@ STATIC void write(msgpack_stream_t *s, const void *buf, mp_uint_t size) {
115114
}
116115

117116
STATIC void write1(msgpack_stream_t *s, uint8_t obj) {
118-
write(s, &obj, 1);
117+
write_bytes(s, &obj, 1);
119118
}
120119

121120
STATIC void write2(msgpack_stream_t *s, uint16_t obj) {
122121
int n = 1;
123122
if (*(char *)&n == 1) obj = __builtin_bswap16(obj);
124-
write(s, &obj, 2);
123+
write_bytes(s, &obj, 2);
125124
}
126125

127126
STATIC void write4(msgpack_stream_t *s, uint32_t obj) {
128127
int n = 1;
129128
if (*(char *)&n == 1) obj = __builtin_bswap32(obj);
130-
write(s, &obj, 4);
129+
write_bytes(s, &obj, 4);
131130
}
132131

133132
// compute and write msgpack size code (array structures)
@@ -294,7 +293,7 @@ mp_obj_t unpack(msgpack_stream_t *s) {
294293
size_t len = code & 0b11111;
295294
// allocate on stack; len < 32
296295
char str[len];
297-
read(s, &str, len);
296+
read_bytes(s, &str, len);
298297
return mp_obj_new_str(str, len);
299298
}
300299
if ((code & 0b11110000) == 0b10010000) {
@@ -327,7 +326,7 @@ mp_obj_t unpack(msgpack_stream_t *s) {
327326
vstr_t vstr;
328327
vstr_init_len(&vstr, size);
329328
byte *p = (byte*)vstr.buf;
330-
read(s, p, size);
329+
read_bytes(s, p, size);
331330
return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
332331
}
333332
case 0xcc:
@@ -356,7 +355,7 @@ mp_obj_t unpack(msgpack_stream_t *s) {
356355
vstr_t vstr;
357356
vstr_init_len(&vstr, size);
358357
byte *p = (byte*)vstr.buf;
359-
read(s, p, size);
358+
read_bytes(s, p, size);
360359
return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
361360
}
362361
case 0xde:

0 commit comments

Comments
 (0)