summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-01-23 02:15:56 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-01-23 02:15:56 +0200
commit344e15b1ae641528b0f37447604ba66be9184a10 (patch)
tree4eda273a0714f9c63cc99a86c19fd242048b058b
parent6113eb2f3342223d3e5ca36d6ff12199e0d05164 (diff)
downloadmicropython-344e15b1ae641528b0f37447604ba66be9184a10.tar.gz
micropython-344e15b1ae641528b0f37447604ba66be9184a10.zip
objstr: Remove code duplication and unbreak Windows build.
There was really weird warning (promoted to error) when building Windows port. Exact cause is still unknown, but it uncovered another issue: 8-bit and unicode str_make_new implementations should be mutually exclusive, and not built at the same time. What we had is that bytes_decode() pulled 8-bit str_make_new() even for unicode build.
-rw-r--r--py/objstr.c8
-rw-r--r--py/objstr.h1
-rw-r--r--py/objstrunicode.c4
3 files changed, 7 insertions, 6 deletions
diff --git a/py/objstr.c b/py/objstr.c
index de46ca6880..f5a577552c 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -130,8 +130,8 @@ STATIC void str_print(void (*print)(void *env, const char *fmt, ...), void *env,
}
}
-#if !MICROPY_PY_BUILTINS_STR_UNICODE || MICROPY_CPYTHON_COMPAT
-STATIC mp_obj_t str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
+#if !MICROPY_PY_BUILTINS_STR_UNICODE
+mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
#if MICROPY_CPYTHON_COMPAT
if (n_kw != 0) {
mp_arg_error_unimpl_kw();
@@ -1725,7 +1725,7 @@ STATIC mp_obj_t bytes_decode(mp_uint_t n_args, const mp_obj_t *args) {
args = new_args;
n_args++;
}
- return str_make_new((mp_obj_t)&mp_type_str, n_args, 0, args);
+ return mp_obj_str_make_new((mp_obj_t)&mp_type_str, n_args, 0, args);
}
// TODO: should accept kwargs too
@@ -1831,7 +1831,7 @@ const mp_obj_type_t mp_type_str = {
{ &mp_type_type },
.name = MP_QSTR_str,
.print = str_print,
- .make_new = str_make_new,
+ .make_new = mp_obj_str_make_new,
.binary_op = mp_obj_str_binary_op,
.subscr = bytes_subscr,
.getiter = mp_obj_new_str_iterator,
diff --git a/py/objstr.h b/py/objstr.h
index 5128a005f3..bae352ad43 100644
--- a/py/objstr.h
+++ b/py/objstr.h
@@ -54,6 +54,7 @@ typedef struct _mp_obj_str_t {
{ str_data = qstr_data(MP_OBJ_QSTR_VALUE(str_obj_in), &str_len); } \
else { str_len = ((mp_obj_str_t*)str_obj_in)->len; str_data = ((mp_obj_str_t*)str_obj_in)->data; }
+mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
void mp_str_print_json(void (*print)(void *env, const char *fmt, ...), void *env, const byte *str_data, mp_uint_t str_len);
mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, mp_uint_t len);
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index 06bf64f1bb..ce950b6bc8 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -113,7 +113,7 @@ STATIC mp_obj_t uni_unary_op(mp_uint_t op, mp_obj_t self_in) {
}
}
-STATIC mp_obj_t str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
+mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
#if MICROPY_CPYTHON_COMPAT
if (n_kw != 0) {
mp_arg_error_unimpl_kw();
@@ -312,7 +312,7 @@ const mp_obj_type_t mp_type_str = {
{ &mp_type_type },
.name = MP_QSTR_str,
.print = uni_print,
- .make_new = str_make_new,
+ .make_new = mp_obj_str_make_new,
.unary_op = uni_unary_op,
.binary_op = mp_obj_str_binary_op,
.subscr = str_subscr,