aboutsummaryrefslogtreecommitdiff
path: root/py/objstrunicode.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-11-27 17:01:44 +0000
committerDamien George <damien.p.george@gmail.com>2015-11-29 14:25:35 +0000
commit999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 (patch)
tree897eb07b82f1893cfd413b9ef7f625cd996f859d /py/objstrunicode.c
parentcbf7674025814797f5c537d6d1c195efe58ccaaf (diff)
py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.
This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
Diffstat (limited to 'py/objstrunicode.c')
-rw-r--r--py/objstrunicode.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index 50916c34b..fb3d52007 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -114,7 +114,7 @@ STATIC mp_obj_t uni_unary_op(mp_uint_t op, mp_obj_t self_in) {
// Convert an index into a pointer to its lead byte. Out of bounds indexing will raise IndexError or
// be capped to the first/last character of the string, depending on is_slice.
-const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, mp_uint_t self_len,
+const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len,
mp_obj_t index, bool is_slice) {
(void)type;
mp_int_t i;
@@ -259,7 +259,7 @@ const mp_obj_type_t mp_type_str = {
.subscr = str_subscr,
.getiter = mp_obj_new_str_iterator,
.buffer_p = { .get_buffer = mp_obj_str_get_buffer },
- .locals_dict = (mp_obj_t)&struni_locals_dict,
+ .locals_dict = (mp_obj_dict_t*)&struni_locals_dict,
};
/******************************************************************************/
@@ -272,7 +272,7 @@ typedef struct _mp_obj_str_it_t {
} mp_obj_str_it_t;
STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
- mp_obj_str_it_t *self = self_in;
+ mp_obj_str_it_t *self = MP_OBJ_TO_PTR(self_in);
GET_STR_DATA_LEN(self->str, str, len);
if (self->cur < len) {
const byte *cur = str + self->cur;
@@ -297,7 +297,7 @@ STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str) {
o->base.type = &mp_type_str_it;
o->str = str;
o->cur = 0;
- return o;
+ return MP_OBJ_FROM_PTR(o);
}
#endif // MICROPY_PY_BUILTINS_STR_UNICODE