Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
ecc88e94
Commit
ecc88e94
authored
Aug 30, 2014
by
Damien George
Browse files
Change some parts of the core API to use mp_uint_t instead of uint/int.
Addressing issue #50, still some way to go yet.
parent
4d3fc463
Changes
57
Show whitespace changes
Inline
Side-by-side
py/objnamedtuple.c
View file @
ecc88e94
...
...
@@ -134,7 +134,7 @@ STATIC bool namedtuple_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_AttributeError
,
"can't set attribute"
));
}
STATIC
mp_obj_t
namedtuple_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
namedtuple_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_obj_namedtuple_type_t
*
type
=
type_in
;
uint
num_fields
=
namedtuple_count_fields
(
type
->
fields
);
if
(
n_args
!=
num_fields
)
{
...
...
py/objnone.c
View file @
ecc88e94
...
...
@@ -41,7 +41,7 @@ STATIC void none_print(void (*print)(void *env, const char *fmt, ...), void *env
print
(
env
,
"None"
);
}
STATIC
mp_obj_t
none_unary_op
(
in
t
op
,
mp_obj_t
o_in
)
{
STATIC
mp_obj_t
none_unary_op
(
mp_uint_
t
op
,
mp_obj_t
o_in
)
{
switch
(
op
)
{
case
MP_UNARY_OP_BOOL
:
return
mp_const_false
;
default:
return
MP_OBJ_NULL
;
// op not supported
...
...
py/objobject.c
View file @
ecc88e94
...
...
@@ -33,13 +33,13 @@
#include
"obj.h"
#include
"runtime0.h"
mp_obj_t
instance_make_new
(
mp_obj_t
self_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
);
mp_obj_t
instance_make_new
(
mp_obj_t
self_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
);
typedef
struct
_mp_obj_object_t
{
mp_obj_base_t
base
;
}
mp_obj_object_t
;
STATIC
mp_obj_t
object_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
object_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
if
(
n_args
!=
0
||
n_kw
!=
0
)
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_TypeError
,
"object takes no arguments"
));
}
...
...
py/objproperty.c
View file @
ecc88e94
...
...
@@ -41,7 +41,7 @@ typedef struct _mp_obj_property_t {
mp_obj_t
proxy
[
3
];
// getter, setter, deleter
}
mp_obj_property_t
;
STATIC
mp_obj_t
property_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
property_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_arg_check_num
(
n_args
,
n_kw
,
0
,
4
,
false
);
mp_obj_property_t
*
o
=
m_new_obj
(
mp_obj_property_t
);
...
...
py/objrange.c
View file @
ecc88e94
...
...
@@ -93,7 +93,7 @@ STATIC void range_print(void (*print)(void *env, const char *fmt, ...), void *en
}
}
STATIC
mp_obj_t
range_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
range_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_arg_check_num
(
n_args
,
n_kw
,
1
,
3
,
false
);
mp_obj_range_t
*
o
=
m_new_obj
(
mp_obj_range_t
);
...
...
@@ -130,7 +130,7 @@ STATIC mp_int_t range_len(mp_obj_range_t *self) {
return
len
;
}
STATIC
mp_obj_t
range_unary_op
(
in
t
op
,
mp_obj_t
self_in
)
{
STATIC
mp_obj_t
range_unary_op
(
mp_uint_
t
op
,
mp_obj_t
self_in
)
{
mp_obj_range_t
*
self
=
self_in
;
mp_int_t
len
=
range_len
(
self
);
switch
(
op
)
{
...
...
py/objreversed.c
View file @
ecc88e94
...
...
@@ -40,7 +40,7 @@ typedef struct _mp_obj_reversed_t {
mp_uint_t
cur_index
;
// current index, plus 1; 0=no more, 1=last one (index 0)
}
mp_obj_reversed_t
;
STATIC
mp_obj_t
reversed_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
reversed_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_arg_check_num
(
n_args
,
n_kw
,
1
,
1
,
false
);
mp_obj_reversed_t
*
o
=
m_new_obj
(
mp_obj_reversed_t
);
...
...
py/objset.c
View file @
ecc88e94
...
...
@@ -122,7 +122,7 @@ STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env,
}
STATIC
mp_obj_t
set_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
set_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_arg_check_num
(
n_args
,
n_kw
,
0
,
1
,
false
);
switch
(
n_args
)
{
...
...
@@ -234,7 +234,7 @@ STATIC mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
set_discard_obj
,
set_discard
);
STATIC
mp_obj_t
set_diff_int
(
in
t
n_args
,
const
mp_obj_t
*
args
,
bool
update
)
{
STATIC
mp_obj_t
set_diff_int
(
mp_uint_
t
n_args
,
const
mp_obj_t
*
args
,
bool
update
)
{
assert
(
n_args
>
0
);
mp_obj_set_t
*
self
;
...
...
@@ -264,12 +264,12 @@ STATIC mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) {
return
self
;
}
STATIC
mp_obj_t
set_diff
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
set_diff
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
set_diff_int
(
n_args
,
args
,
false
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR
(
set_diff_obj
,
1
,
set_diff
);
STATIC
mp_obj_t
set_diff_update
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
set_diff_update
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
set_diff_int
(
n_args
,
args
,
true
);
return
mp_const_none
;
}
...
...
@@ -453,7 +453,7 @@ STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
}
}
STATIC
mp_obj_t
set_update
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
set_update
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
assert
(
n_args
>
0
);
for
(
int
i
=
1
;
i
<
n_args
;
i
++
)
{
...
...
@@ -472,7 +472,7 @@ STATIC mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
set_union_obj
,
set_union
);
STATIC
mp_obj_t
set_unary_op
(
in
t
op
,
mp_obj_t
self_in
)
{
STATIC
mp_obj_t
set_unary_op
(
mp_uint_
t
op
,
mp_obj_t
self_in
)
{
mp_obj_set_t
*
self
=
self_in
;
switch
(
op
)
{
case
MP_UNARY_OP_BOOL
:
return
MP_BOOL
(
self
->
set
.
used
!=
0
);
...
...
@@ -481,7 +481,7 @@ STATIC mp_obj_t set_unary_op(int op, mp_obj_t self_in) {
}
}
STATIC
mp_obj_t
set_binary_op
(
in
t
op
,
mp_obj_t
lhs
,
mp_obj_t
rhs
)
{
STATIC
mp_obj_t
set_binary_op
(
mp_uint_
t
op
,
mp_obj_t
lhs
,
mp_obj_t
rhs
)
{
mp_obj_t
args
[]
=
{
lhs
,
rhs
};
switch
(
op
)
{
case
MP_BINARY_OP_OR
:
...
...
py/objstr.c
View file @
ecc88e94
...
...
@@ -41,7 +41,7 @@
#include
"objstr.h"
#include
"objlist.h"
STATIC
mp_obj_t
str_modulo_format
(
mp_obj_t
pattern
,
uint
n_args
,
const
mp_obj_t
*
args
,
mp_obj_t
dict
);
STATIC
mp_obj_t
str_modulo_format
(
mp_obj_t
pattern
,
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
,
mp_obj_t
dict
);
const
mp_obj_t
mp_const_empty_bytes
;
mp_obj_t
mp_obj_new_str_iterator
(
mp_obj_t
str
);
...
...
@@ -105,7 +105,7 @@ STATIC void str_print(void (*print)(void *env, const char *fmt, ...), void *env,
}
}
STATIC
mp_obj_t
str_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
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_CPYTHON_COMPAT
if
(
n_kw
!=
0
)
{
mp_arg_error_unimpl_kw
();
...
...
@@ -145,7 +145,7 @@ STATIC mp_obj_t str_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
}
}
STATIC
mp_obj_t
bytes_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
bytes_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
if
(
n_args
==
0
)
{
return
mp_const_empty_bytes
;
}
...
...
@@ -250,7 +250,7 @@ STATIC const byte *find_subbytes(const byte *haystack, mp_uint_t hlen, const byt
// Note: this function is used to check if an object is a str or bytes, which
// works because both those types use it as their binary_op method. Revisit
// MP_OBJ_IS_STR_OR_BYTES if this fact changes.
mp_obj_t
mp_obj_str_binary_op
(
in
t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
mp_obj_t
mp_obj_str_binary_op
(
mp_uint_
t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
GET_STR_DATA_LEN
(
lhs_in
,
lhs_data
,
lhs_len
);
mp_obj_type_t
*
lhs_type
=
mp_obj_get_type
(
lhs_in
);
mp_obj_type_t
*
rhs_type
=
mp_obj_get_type
(
rhs_in
);
...
...
@@ -440,7 +440,7 @@ STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
#define is_ws(c) ((c) == ' ' || (c) == '\t')
STATIC
mp_obj_t
str_split
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_split
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
const
mp_obj_type_t
*
self_type
=
mp_obj_get_type
(
args
[
0
]);
mp_int_t
splits
=
-
1
;
mp_obj_t
sep
=
mp_const_none
;
...
...
@@ -515,7 +515,7 @@ STATIC mp_obj_t str_split(uint n_args, const mp_obj_t *args) {
return
res
;
}
STATIC
mp_obj_t
str_rsplit
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_rsplit
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
if
(
n_args
<
3
)
{
// If we don't have split limit, it doesn't matter from which side
// we split.
...
...
@@ -576,7 +576,7 @@ STATIC mp_obj_t str_rsplit(uint n_args, const mp_obj_t *args) {
return
res
;
}
STATIC
mp_obj_t
str_finder
(
uint
n_args
,
const
mp_obj_t
*
args
,
mp_int_t
direction
,
bool
is_index
)
{
STATIC
mp_obj_t
str_finder
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
,
mp_int_t
direction
,
bool
is_index
)
{
const
mp_obj_type_t
*
self_type
=
mp_obj_get_type
(
args
[
0
]);
assert
(
2
<=
n_args
&&
n_args
<=
4
);
assert
(
MP_OBJ_IS_STR
(
args
[
0
]));
...
...
@@ -613,24 +613,24 @@ STATIC mp_obj_t str_finder(uint n_args, const mp_obj_t *args, mp_int_t direction
}
}
STATIC
mp_obj_t
str_find
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_find
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
str_finder
(
n_args
,
args
,
1
,
false
);
}
STATIC
mp_obj_t
str_rfind
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_rfind
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
str_finder
(
n_args
,
args
,
-
1
,
false
);
}
STATIC
mp_obj_t
str_index
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_index
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
str_finder
(
n_args
,
args
,
1
,
true
);
}
STATIC
mp_obj_t
str_rindex
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_rindex
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
str_finder
(
n_args
,
args
,
-
1
,
true
);
}
// TODO: (Much) more variety in args
STATIC
mp_obj_t
str_startswith
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_startswith
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
const
mp_obj_type_t
*
self_type
=
mp_obj_get_type
(
args
[
0
]);
GET_STR_DATA_LEN
(
args
[
0
],
str
,
str_len
);
GET_STR_DATA_LEN
(
args
[
1
],
prefix
,
prefix_len
);
...
...
@@ -644,7 +644,7 @@ STATIC mp_obj_t str_startswith(uint n_args, const mp_obj_t *args) {
return
MP_BOOL
(
memcmp
(
start
,
prefix
,
prefix_len
)
==
0
);
}
STATIC
mp_obj_t
str_endswith
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_endswith
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
GET_STR_DATA_LEN
(
args
[
0
],
str
,
str_len
);
GET_STR_DATA_LEN
(
args
[
1
],
suffix
,
suffix_len
);
assert
(
n_args
==
2
);
...
...
@@ -657,7 +657,7 @@ STATIC mp_obj_t str_endswith(uint n_args, const mp_obj_t *args) {
enum
{
LSTRIP
,
RSTRIP
,
STRIP
};
STATIC
mp_obj_t
str_uni_strip
(
int
type
,
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_uni_strip
(
int
type
,
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
assert
(
1
<=
n_args
&&
n_args
<=
2
);
assert
(
MP_OBJ_IS_STR_OR_BYTES
(
args
[
0
]));
const
mp_obj_type_t
*
self_type
=
mp_obj_get_type
(
args
[
0
]);
...
...
@@ -725,15 +725,15 @@ STATIC mp_obj_t str_uni_strip(int type, uint n_args, const mp_obj_t *args) {
return
mp_obj_new_str_of_type
(
self_type
,
orig_str
+
first_good_char_pos
,
stripped_len
);
}
STATIC
mp_obj_t
str_strip
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_strip
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
str_uni_strip
(
STRIP
,
n_args
,
args
);
}
STATIC
mp_obj_t
str_lstrip
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_lstrip
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
str_uni_strip
(
LSTRIP
,
n_args
,
args
);
}
STATIC
mp_obj_t
str_rstrip
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_rstrip
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
str_uni_strip
(
RSTRIP
,
n_args
,
args
);
}
...
...
@@ -785,7 +785,7 @@ static mp_obj_t arg_as_int(mp_obj_t arg) {
return
arg
;
}
mp_obj_t
mp_obj_str_format
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
mp_obj_t
mp_obj_str_format
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
assert
(
MP_OBJ_IS_STR
(
args
[
0
]));
GET_STR_DATA_LEN
(
args
[
0
],
str
,
len
);
...
...
@@ -1148,7 +1148,7 @@ mp_obj_t mp_obj_str_format(uint n_args, const mp_obj_t *args) {
return
s
;
}
STATIC
mp_obj_t
str_modulo_format
(
mp_obj_t
pattern
,
uint
n_args
,
const
mp_obj_t
*
args
,
mp_obj_t
dict
)
{
STATIC
mp_obj_t
str_modulo_format
(
mp_obj_t
pattern
,
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
,
mp_obj_t
dict
)
{
assert
(
MP_OBJ_IS_STR
(
pattern
));
GET_STR_DATA_LEN
(
pattern
,
str
,
len
);
...
...
@@ -1336,7 +1336,7 @@ not_enough_args:
return
s
;
}
STATIC
mp_obj_t
str_replace
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_replace
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
assert
(
MP_OBJ_IS_STR
(
args
[
0
]));
mp_int_t
max_rep
=
-
1
;
...
...
@@ -1438,7 +1438,7 @@ STATIC mp_obj_t str_replace(uint n_args, const mp_obj_t *args) {
return
mp_obj_str_builder_end
(
replaced_str
);
}
STATIC
mp_obj_t
str_count
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_count
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
const
mp_obj_type_t
*
self_type
=
mp_obj_get_type
(
args
[
0
]);
assert
(
2
<=
n_args
&&
n_args
<=
4
);
assert
(
MP_OBJ_IS_STR
(
args
[
0
]));
...
...
@@ -1595,7 +1595,7 @@ STATIC mp_obj_t str_islower(mp_obj_t self_in) {
// These methods are superfluous in the presense of str() and bytes()
// constructors.
// TODO: should accept kwargs too
STATIC
mp_obj_t
bytes_decode
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
bytes_decode
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
mp_obj_t
new_args
[
2
];
if
(
n_args
==
1
)
{
new_args
[
0
]
=
args
[
0
];
...
...
@@ -1607,7 +1607,7 @@ STATIC mp_obj_t bytes_decode(uint n_args, const mp_obj_t *args) {
}
// TODO: should accept kwargs too
STATIC
mp_obj_t
str_encode
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
str_encode
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
mp_obj_t
new_args
[
2
];
if
(
n_args
==
1
)
{
new_args
[
0
]
=
args
[
0
];
...
...
py/objstr.h
View file @
ecc88e94
...
...
@@ -50,10 +50,10 @@ 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_format
(
uint
n_args
,
const
mp_obj_t
*
args
);
mp_obj_t
mp_obj_str_format
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
);
mp_obj_t
mp_obj_new_str_of_type
(
const
mp_obj_type_t
*
type
,
const
byte
*
data
,
uint
len
);
mp_obj_t
mp_obj_str_binary_op
(
in
t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
);
mp_obj_t
mp_obj_str_binary_op
(
mp_uint_
t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
);
mp_int_t
mp_obj_str_get_buffer
(
mp_obj_t
self_in
,
mp_buffer_info_t
*
bufinfo
,
int
flags
);
const
byte
*
str_index_to_ptr
(
const
mp_obj_type_t
*
type
,
const
byte
*
self_data
,
uint
self_len
,
...
...
py/objstringio.c
View file @
ecc88e94
...
...
@@ -95,7 +95,7 @@ STATIC mp_obj_t stringio_close(mp_obj_t self_in) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
stringio_close_obj
,
stringio_close
);
mp_obj_t
stringio___exit__
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
mp_obj_t
stringio___exit__
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
stringio_close
(
args
[
0
]);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
stringio___exit___obj
,
4
,
4
,
stringio___exit__
);
...
...
@@ -108,7 +108,7 @@ STATIC mp_obj_stringio_t *stringio_new(mp_obj_t type_in) {
return
o
;
}
STATIC
mp_obj_t
stringio_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
stringio_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_obj_stringio_t
*
o
=
stringio_new
(
type_in
);
if
(
n_args
>
0
)
{
...
...
py/objstrunicode.c
View file @
ecc88e94
...
...
@@ -100,7 +100,7 @@ STATIC void uni_print(void (*print)(void *env, const char *fmt, ...), void *env,
}
}
STATIC
mp_obj_t
uni_unary_op
(
in
t
op
,
mp_obj_t
self_in
)
{
STATIC
mp_obj_t
uni_unary_op
(
mp_uint_
t
op
,
mp_obj_t
self_in
)
{
GET_STR_DATA_LEN
(
self_in
,
str_data
,
str_len
);
switch
(
op
)
{
case
MP_UNARY_OP_BOOL
:
...
...
@@ -112,7 +112,7 @@ STATIC mp_obj_t uni_unary_op(int op, mp_obj_t self_in) {
}
}
STATIC
mp_obj_t
str_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
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_CPYTHON_COMPAT
if
(
n_kw
!=
0
)
{
mp_arg_error_unimpl_kw
();
...
...
py/objtuple.c
View file @
ecc88e94
...
...
@@ -56,7 +56,7 @@ void mp_obj_tuple_print(void (*print)(void *env, const char *fmt, ...), void *en
print
(
env
,
")"
);
}
STATIC
mp_obj_t
mp_obj_tuple_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
mp_obj_tuple_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_arg_check_num
(
n_args
,
n_kw
,
0
,
1
,
false
);
switch
(
n_args
)
{
...
...
@@ -96,7 +96,7 @@ STATIC mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw,
}
// Don't pass MP_BINARY_OP_NOT_EQUAL here
STATIC
bool
tuple_cmp_helper
(
in
t
op
,
mp_obj_t
self_in
,
mp_obj_t
another_in
)
{
STATIC
bool
tuple_cmp_helper
(
mp_uint_
t
op
,
mp_obj_t
self_in
,
mp_obj_t
another_in
)
{
mp_obj_type_t
*
self_type
=
mp_obj_get_type
(
self_in
);
if
(
self_type
->
getiter
!=
mp_obj_tuple_getiter
)
{
assert
(
0
);
...
...
@@ -115,7 +115,7 @@ STATIC bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
return
mp_seq_cmp_objs
(
op
,
self
->
items
,
self
->
len
,
another
->
items
,
another
->
len
);
}
mp_obj_t
mp_obj_tuple_unary_op
(
in
t
op
,
mp_obj_t
self_in
)
{
mp_obj_t
mp_obj_tuple_unary_op
(
mp_uint_
t
op
,
mp_obj_t
self_in
)
{
mp_obj_tuple_t
*
self
=
self_in
;
switch
(
op
)
{
case
MP_UNARY_OP_BOOL
:
return
MP_BOOL
(
self
->
len
!=
0
);
...
...
@@ -124,7 +124,7 @@ mp_obj_t mp_obj_tuple_unary_op(int op, mp_obj_t self_in) {
}
}
mp_obj_t
mp_obj_tuple_binary_op
(
in
t
op
,
mp_obj_t
lhs
,
mp_obj_t
rhs
)
{
mp_obj_t
mp_obj_tuple_binary_op
(
mp_uint_
t
op
,
mp_obj_t
lhs
,
mp_obj_t
rhs
)
{
mp_obj_tuple_t
*
o
=
lhs
;
switch
(
op
)
{
case
MP_BINARY_OP_ADD
:
{
...
...
@@ -194,7 +194,7 @@ STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
tuple_count_obj
,
tuple_count
);
STATIC
mp_obj_t
tuple_index
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
tuple_index
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
assert
(
MP_OBJ_IS_TYPE
(
args
[
0
],
&
mp_type_tuple
));
mp_obj_tuple_t
*
self
=
args
[
0
];
return
mp_seq_index_obj
(
self
->
items
,
self
->
len
,
n_args
,
args
);
...
...
py/objtuple.h
View file @
ecc88e94
...
...
@@ -31,7 +31,7 @@ typedef struct _mp_obj_tuple_t {
}
mp_obj_tuple_t
;
void
mp_obj_tuple_print
(
void
(
*
print
)(
void
*
env
,
const
char
*
fmt
,
...),
void
*
env
,
mp_obj_t
o_in
,
mp_print_kind_t
kind
);
mp_obj_t
mp_obj_tuple_unary_op
(
in
t
op
,
mp_obj_t
self_in
);
mp_obj_t
mp_obj_tuple_binary_op
(
in
t
op
,
mp_obj_t
lhs
,
mp_obj_t
rhs
);
mp_obj_t
mp_obj_tuple_unary_op
(
mp_uint_
t
op
,
mp_obj_t
self_in
);
mp_obj_t
mp_obj_tuple_binary_op
(
mp_uint_
t
op
,
mp_obj_t
lhs
,
mp_obj_t
rhs
);
mp_obj_t
mp_obj_tuple_subscr
(
mp_obj_t
base
,
mp_obj_t
index
,
mp_obj_t
value
);
mp_obj_t
mp_obj_tuple_getiter
(
mp_obj_t
o_in
);
py/objtype.c
View file @
ecc88e94
...
...
@@ -46,14 +46,14 @@
#define DEBUG_printf(...) (void)0
#endif
STATIC
mp_obj_t
static_class_method_make_new
(
mp_obj_t
self_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
);
STATIC
mp_obj_t
static_class_method_make_new
(
mp_obj_t
self_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
);
/******************************************************************************/
// instance object
#define is_instance_type(type) ((type)->make_new == instance_make_new)
#define is_native_type(type) ((type)->make_new != instance_make_new)
mp_obj_t
instance_make_new
(
mp_obj_t
self_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
);
mp_obj_t
instance_make_new
(
mp_obj_t
self_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
);
STATIC
void
instance_convert_return_attr
(
mp_obj_t
self
,
const
mp_obj_type_t
*
type
,
mp_obj_t
member
,
mp_obj_t
*
dest
);
STATIC
mp_obj_t
mp_obj_new_instance
(
mp_obj_t
class
,
uint
subobjs
)
{
...
...
@@ -236,7 +236,7 @@ STATIC void instance_print(void (*print)(void *env, const char *fmt, ...), void
print
(
env
,
"<%s object at %p>"
,
mp_obj_get_type_str
(
self_in
),
self_in
);
}
mp_obj_t
instance_make_new
(
mp_obj_t
self_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
mp_obj_t
instance_make_new
(
mp_obj_t
self_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
assert
(
MP_OBJ_IS_TYPE
(
self_in
,
&
mp_type_type
));
mp_obj_type_t
*
self
=
self_in
;
...
...
@@ -327,7 +327,7 @@ STATIC const qstr unary_op_method_name[] = {
[
MP_UNARY_OP_NOT
]
=
MP_QSTR_
,
// don't need to implement this, used to make sure array has full size
};
STATIC
mp_obj_t
instance_unary_op
(
in
t
op
,
mp_obj_t
self_in
)
{
STATIC
mp_obj_t
instance_unary_op
(
mp_uint_
t
op
,
mp_obj_t
self_in
)
{
mp_obj_instance_t
*
self
=
self_in
;
qstr
op_name
=
unary_op_method_name
[
op
];
/* Still try to lookup native slot
...
...
@@ -421,7 +421,7 @@ STATIC void instance_convert_return_attr(mp_obj_t self, const mp_obj_type_t *typ
}
}
STATIC
mp_obj_t
instance_binary_op
(
in
t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
STATIC
mp_obj_t
instance_binary_op
(
mp_uint_
t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
// Note: For ducktyping, CPython does not look in the instance members or use
// __getattr__ or __getattribute__. It only looks in the class dictionary.
mp_obj_instance_t
*
lhs
=
lhs_in
;
...
...
@@ -583,7 +583,7 @@ STATIC mp_obj_t instance_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value
}
}
STATIC
mp_obj_t
instance_call
(
mp_obj_t
self_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
instance_call
(
mp_obj_t
self_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_obj_instance_t
*
self
=
self_in
;
mp_obj_t
member
[
2
]
=
{
MP_OBJ_NULL
};
struct
class_lookup_data
lookup
=
{
...
...
@@ -643,7 +643,7 @@ STATIC void type_print(void (*print)(void *env, const char *fmt, ...), void *env
print
(
env
,
"<class '%s'>"
,
qstr_str
(
self
->
name
));
}
STATIC
mp_obj_t
type_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
type_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_arg_check_num
(
n_args
,
n_kw
,
1
,
3
,
false
);
switch
(
n_args
)
{
...
...
@@ -661,7 +661,7 @@ STATIC mp_obj_t type_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
}
}
STATIC
mp_obj_t
type_call
(
mp_obj_t
self_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
type_call
(
mp_obj_t
self_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
// instantiate an instance of a class
mp_obj_type_t
*
self
=
self_in
;
...
...
@@ -725,7 +725,7 @@ STATIC bool type_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
return
false
;
}
STATIC
mp_obj_t
type_binary_op
(
in
t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
STATIC
mp_obj_t
type_binary_op
(
mp_uint_
t
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
switch
(
op
)
{
case
MP_BINARY_OP_EQUAL
:
// Types can be equal only if it's the same type structure,
...
...
@@ -819,7 +819,7 @@ STATIC void super_print(void (*print)(void *env, const char *fmt, ...), void *en
print
(
env
,
">"
);
}
STATIC
mp_obj_t
super_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
super_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
if
(
n_args
!=
2
||
n_kw
!=
0
)
{
// 0 arguments are turned into 2 in the compiler
// 1 argument is not yet implemented
...
...
@@ -968,7 +968,7 @@ mp_obj_t mp_instance_cast_to_native_base(mp_const_obj_t self_in, mp_const_obj_t
/******************************************************************************/
// staticmethod and classmethod types (probably should go in a different file)
STATIC
mp_obj_t
static_class_method_make_new
(
mp_obj_t
self_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
static_class_method_make_new
(
mp_obj_t
self_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
assert
(
self_in
==
&
mp_type_staticmethod
||
self_in
==
&
mp_type_classmethod
);
if
(
n_args
!=
1
||
n_kw
!=
0
)
{
...
...
py/objzip.c
View file @
ecc88e94
...
...
@@ -39,7 +39,7 @@ typedef struct _mp_obj_zip_t {
mp_obj_t
iters
[];
}
mp_obj_zip_t
;
STATIC
mp_obj_t
zip_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
zip_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_arg_check_num
(
n_args
,
n_kw
,
0
,
MP_OBJ_FUN_ARGS_MAX
,
false
);
mp_obj_zip_t
*
o
=
m_new_obj_var
(
mp_obj_zip_t
,
mp_obj_t
,
n_args
);
...
...
stmhal/accel.c
View file @
ecc88e94
...
...
@@ -132,7 +132,7 @@ STATIC pyb_accel_obj_t pyb_accel_obj;
/// accel = pyb.Accel()
/// pyb.delay(20)
/// print(accel.x())
STATIC
mp_obj_t
pyb_accel_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
pyb_accel_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
// check arguments
mp_arg_check_num
(
n_args
,
n_kw
,
0
,
0
,
false
);
...
...
stmhal/adc.c
View file @
ecc88e94
...
...
@@ -152,7 +152,7 @@ STATIC void adc_print(void (*print)(void *env, const char *fmt, ...), void *env,
/// \classmethod \constructor(pin)
/// Create an ADC object associated with the given pin.
/// This allows you to then read analog values on that pin.
STATIC
mp_obj_t
adc_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
adc_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
// check number of arguments
mp_arg_check_num
(
n_args
,
n_kw
,
1
,
1
,
false
);
...
...
@@ -372,7 +372,7 @@ float adc_read_core_vref(ADC_HandleTypeDef *adcHandle) {
/******************************************************************************/
/* Micro Python bindings : adc_all object */
STATIC
mp_obj_t
adc_all_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
adc_all_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
// check number of arguments
mp_arg_check_num
(
n_args
,
n_kw
,
1
,
1
,
false
);
...
...
stmhal/dac.c
View file @
ecc88e94
...
...
@@ -111,7 +111,7 @@ typedef struct _pyb_dac_obj_t {
/// Construct a new DAC object.
///
/// `id` can be 1 or 2: DAC 1 is on pin X5 and DAC 2 is on pin X6.
STATIC
mp_obj_t
pyb_dac_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
pyb_dac_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
// check arguments
mp_arg_check_num
(
n_args
,
n_kw
,
1
,
1
,
false
);
...
...
@@ -246,7 +246,7 @@ STATIC const mp_arg_t pyb_dac_write_timed_args[] = {
};
#define PYB_DAC_WRITE_TIMED_NUM_ARGS MP_ARRAY_SIZE(pyb_dac_write_timed_args)
mp_obj_t
pyb_dac_write_timed
(
uint
n_args
,
const
mp_obj_t
*
args
,
mp_map_t
*
kw_args
)
{
mp_obj_t
pyb_dac_write_timed
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
,
mp_map_t
*
kw_args
)
{
pyb_dac_obj_t
*
self
=
args
[
0
];
// parse args
...
...
stmhal/extint.c
View file @
ecc88e94
...
...
@@ -298,7 +298,7 @@ STATIC const mp_arg_t pyb_extint_make_new_args[] = {
};
#define PYB_EXTINT_MAKE_NEW_NUM_ARGS MP_ARRAY_SIZE(pyb_extint_make_new_args)
STATIC
mp_obj_t
extint_make_new
(
mp_obj_t
type_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
extint_make_new
(
mp_obj_t
type_in
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
// type_in == extint_obj_type
// parse args
...
...
stmhal/file.c
View file @
ecc88e94
...
...
@@ -109,12 +109,12 @@ mp_obj_t file_obj_close(mp_obj_t self_in) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
file_obj_close_obj
,
file_obj_close
);
mp_obj_t
file_obj___exit__
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
mp_obj_t
file_obj___exit__
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
return
file_obj_close
(
args
[
0
]);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
file_obj___exit___obj
,
4
,
4
,
file_obj___exit__
);
mp_obj_t
file_obj_seek
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
mp_obj_t
file_obj_seek
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
pyb_file_obj_t
*
self
=
args
[
0
];
mp_int_t
offset
=
mp_obj_get_int
(
args
[
1
]);
mp_int_t
whence
=
0
;
...
...
@@ -160,7 +160,7 @@ mp_obj_t file_obj_tell(mp_obj_t self_in) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
file_obj_tell_obj
,
file_obj_tell
);
STATIC
mp_obj_t
file_obj_make_new
(
mp_obj_t
type
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
file_obj_make_new
(
mp_obj_t
type
,
mp_
uint
_t
n_args
,
mp_
uint
_t
n_kw
,
const
mp_obj_t
*
args
)
{
mp_arg_check_num
(
n_args
,
n_kw
,
1
,
2
,
false
);
const
char
*
fname
=
mp_obj_str_get_str
(
args
[
0
]);
...
...
@@ -272,7 +272,7 @@ const mp_obj_type_t mp_type_textio = {
};
// Factory function for I/O stream classes
STATIC
mp_obj_t
pyb_io_open
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
STATIC
mp_obj_t
pyb_io_open
(
mp_
uint
_t
n_args
,
const
mp_obj_t
*
args
)
{
// TODO: analyze mode and buffering args and instantiate appropriate type
return
file_obj_make_new
((
mp_obj_t
)
&
mp_type_textio
,
n_args
,
0
,
args
);