Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
97209d38
Commit
97209d38
authored
Jan 07, 2014
by
Damien George
Browse files
Merge branch 'cplusplus' of
https://github.com/ian-v/micropython
into ian-v-cplusplus
Conflicts: py/objcomplex.c
parents
d49420e7
a5a01df8
Changes
30
Hide whitespace changes
Inline
Side-by-side
py/misc.h
View file @
97209d38
...
@@ -5,11 +5,7 @@
...
@@ -5,11 +5,7 @@
/** types *******************************************************/
/** types *******************************************************/
typedef
int
bool
;
#include <stdbool.h>
enum
{
false
=
0
,
true
=
1
};
typedef
unsigned
char
byte
;
typedef
unsigned
char
byte
;
typedef
unsigned
int
uint
;
typedef
unsigned
int
uint
;
...
...
py/obj.h
View file @
97209d38
...
@@ -15,15 +15,14 @@ typedef machine_int_t mp_small_int_t;
...
@@ -15,15 +15,14 @@ typedef machine_int_t mp_small_int_t;
typedef
machine_float_t
mp_float_t
;
typedef
machine_float_t
mp_float_t
;
#endif
#endif
// Anything that wants to be a Micro Python object must
// Anything that wants to be a Micro Python object must have
// have mp_obj_base_t as its first member (except NULL and small ints)
// mp_obj_base_t as its first member (except NULL and small ints)
typedef
struct
_mp_obj_base_t
mp_obj_base_t
;
typedef
struct
_mp_obj_type_t
mp_obj_type_t
;
struct
_mp_obj_type_t
;
struct
_mp_obj_base_t
{
struct
_mp_obj_base_t
{
const
mp_obj_type_t
*
type
;
const
struct
_
mp_obj_type_t
*
type
;
};
};
typedef
struct
_mp_obj_base_t
mp_obj_base_t
;
// The NULL object is used to indicate the absence of an object
// The NULL object is used to indicate the absence of an object
// It *cannot* be used when an mp_obj_t is expected, except where explicitly allowed
// It *cannot* be used when an mp_obj_t is expected, except where explicitly allowed
...
@@ -43,12 +42,13 @@ struct _mp_obj_base_t {
...
@@ -43,12 +42,13 @@ struct _mp_obj_base_t {
#define MP_DECLARE_CONST_FUN_OBJ(obj_name) extern const mp_obj_fun_native_t obj_name
#define MP_DECLARE_CONST_FUN_OBJ(obj_name) extern const mp_obj_fun_native_t obj_name
#define MP_DEFINE_CONST_FUN_OBJ_0(obj_name, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, 0, 0, fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, n_args_min, n_args_max, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, n_args_min, n_args_max, (void *)fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_1(obj_name, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, 1, 1, fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_0(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, 0, 0, (mp_fun_0_t)fun_name)
#define MP_DEFINE_CONST_FUN_OBJ_2(obj_name, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, 2, 2, fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_1(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, 1, 1, (mp_fun_1_t)fun_name)
#define MP_DEFINE_CONST_FUN_OBJ_3(obj_name, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, 3, 3, fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_2(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, 2, 2, (mp_fun_2_t)fun_name)
#define MP_DEFINE_CONST_FUN_OBJ_VAR(obj_name, n_args_min, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, n_args_min, (~((machine_uint_t)0)), fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_3(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, 3, 3, (mp_fun_3_t)fun_name)
#define MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name, n_args_min, n_args_max, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, n_args_min, n_args_max, fun_name}
#define MP_DEFINE_CONST_FUN_OBJ_VAR(obj_name, n_args_min, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, n_args_min, (~((machine_uint_t)0)), (mp_fun_var_t)fun_name)
#define MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name, n_args_min, n_args_max, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, n_args_min, n_args_max, (mp_fun_var_t)fun_name)
// Type definitions for methods
// Type definitions for methods
...
@@ -83,7 +83,7 @@ struct _mp_obj_type_t {
...
@@ -83,7 +83,7 @@ struct _mp_obj_type_t {
mp_fun_1_t
getiter
;
mp_fun_1_t
getiter
;
mp_fun_1_t
iternext
;
mp_fun_1_t
iternext
;
const
mp_method_t
methods
[]
;
const
mp_method_t
*
methods
;
/*
/*
What we might need to add here:
What we might need to add here:
...
@@ -108,6 +108,8 @@ struct _mp_obj_type_t {
...
@@ -108,6 +108,8 @@ struct _mp_obj_type_t {
*/
*/
};
};
typedef
struct
_mp_obj_type_t
mp_obj_type_t
;
// Constant objects, globally accessible
// Constant objects, globally accessible
extern
const
mp_obj_type_t
mp_const_type
;
extern
const
mp_obj_type_t
mp_const_type
;
...
@@ -241,6 +243,7 @@ typedef struct _mp_obj_fun_native_t { // need this so we can define const object
...
@@ -241,6 +243,7 @@ typedef struct _mp_obj_fun_native_t { // need this so we can define const object
// for const function objects, make an empty, const map
// for const function objects, make an empty, const map
// such functions won't be able to access the global scope, but that's probably okay
// such functions won't be able to access the global scope, but that's probably okay
}
mp_obj_fun_native_t
;
}
mp_obj_fun_native_t
;
extern
const
mp_obj_type_t
fun_native_type
;
extern
const
mp_obj_type_t
fun_native_type
;
extern
const
mp_obj_type_t
fun_bc_type
;
extern
const
mp_obj_type_t
fun_bc_type
;
void
mp_obj_fun_bc_get
(
mp_obj_t
self_in
,
int
*
n_args
,
uint
*
n_state
,
const
byte
**
code
);
void
mp_obj_fun_bc_get
(
mp_obj_t
self_in
,
int
*
n_args
,
uint
*
n_state
,
const
byte
**
code
);
...
...
py/objbool.c
View file @
97209d38
...
@@ -34,14 +34,8 @@ static mp_obj_t bool_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args
...
@@ -34,14 +34,8 @@ static mp_obj_t bool_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args
const
mp_obj_type_t
bool_type
=
{
const
mp_obj_type_t
bool_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"bool"
,
"bool"
,
bool_print
,
// print
.
print
=
bool_print
,
bool_make_new
,
// make_new
.
make_new
=
bool_make_new
,
NULL
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
static
const
mp_obj_bool_t
false_obj
=
{{
&
bool_type
},
false
};
static
const
mp_obj_bool_t
false_obj
=
{{
&
bool_type
},
false
};
...
...
py/objboundmeth.c
View file @
97209d38
...
@@ -36,14 +36,7 @@ mp_obj_t bound_meth_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
...
@@ -36,14 +36,7 @@ mp_obj_t bound_meth_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
const
mp_obj_type_t
bound_meth_type
=
{
const
mp_obj_type_t
bound_meth_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"bound_method"
,
"bound_method"
,
NULL
,
// print
.
call_n
=
bound_meth_call_n
,
NULL
,
// make_new
bound_meth_call_n
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_bound_meth
(
mp_obj_t
self
,
mp_obj_t
meth
)
{
mp_obj_t
mp_obj_new_bound_meth
(
mp_obj_t
self
,
mp_obj_t
meth
)
{
...
...
py/objcell.c
View file @
97209d38
...
@@ -26,14 +26,6 @@ void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) {
...
@@ -26,14 +26,6 @@ void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) {
const
mp_obj_type_t
cell_type
=
{
const
mp_obj_type_t
cell_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"cell"
,
"cell"
,
NULL
,
// print
NULL
,
// make_new
NULL
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_cell
(
mp_obj_t
obj
)
{
mp_obj_t
mp_obj_new_cell
(
mp_obj_t
obj
)
{
...
...
py/objclass.c
View file @
97209d38
...
@@ -63,14 +63,7 @@ mp_map_t *mp_obj_class_get_locals(mp_obj_t self_in) {
...
@@ -63,14 +63,7 @@ mp_map_t *mp_obj_class_get_locals(mp_obj_t self_in) {
const
mp_obj_type_t
class_type
=
{
const
mp_obj_type_t
class_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"class"
,
"class"
,
NULL
,
// print
.
call_n
=
class_call_n
,
NULL
,
// make_new
class_call_n
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_class
(
mp_map_t
*
class_locals
)
{
mp_obj_t
mp_obj_new_class
(
mp_map_t
*
class_locals
)
{
...
...
py/objclosure.c
View file @
97209d38
...
@@ -35,14 +35,7 @@ mp_obj_t closure_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
...
@@ -35,14 +35,7 @@ mp_obj_t closure_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
const
mp_obj_type_t
closure_type
=
{
const
mp_obj_type_t
closure_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"closure"
,
"closure"
,
NULL
,
// print
.
call_n
=
closure_call_n
,
NULL
,
// make_new
closure_call_n
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_closure
(
mp_obj_t
fun
,
mp_obj_t
closure_tuple
)
{
mp_obj_t
mp_obj_new_closure
(
mp_obj_t
fun
,
mp_obj_t
closure_tuple
)
{
...
...
py/objcomplex.c
View file @
97209d38
...
@@ -87,14 +87,10 @@ static mp_obj_t complex_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
...
@@ -87,14 +87,10 @@ static mp_obj_t complex_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
const
mp_obj_type_t
complex_type
=
{
const
mp_obj_type_t
complex_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"complex"
,
"complex"
,
complex_print
,
// print
.
print
=
complex_print
,
complex_make_new
,
// make_new
.
make_new
=
complex_make_new
,
NULL
,
// call_n
.
unary_op
=
complex_unary_op
,
complex_unary_op
,
// unary_op
.
binary_op
=
complex_binary_op
,
complex_binary_op
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{
{
NULL
,
NULL
},
},
};
};
mp_obj_t
mp_obj_new_complex
(
mp_float_t
real
,
mp_float_t
imag
)
{
mp_obj_t
mp_obj_new_complex
(
mp_float_t
real
,
mp_float_t
imag
)
{
...
...
py/objdict.c
View file @
97209d38
...
@@ -66,8 +66,6 @@ const mp_obj_type_t dict_type = {
...
@@ -66,8 +66,6 @@ const mp_obj_type_t dict_type = {
.
print
=
dict_print
,
.
print
=
dict_print
,
.
make_new
=
dict_make_new
,
.
make_new
=
dict_make_new
,
.
binary_op
=
dict_binary_op
,
.
binary_op
=
dict_binary_op
,
.
getiter
=
NULL
,
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_dict
(
int
n_args
)
{
mp_obj_t
mp_obj_new_dict
(
int
n_args
)
{
...
...
py/objexcept.c
View file @
97209d38
...
@@ -38,14 +38,7 @@ void exception_print(void (*print)(void *env, const char *fmt, ...), void *env,
...
@@ -38,14 +38,7 @@ void exception_print(void (*print)(void *env, const char *fmt, ...), void *env,
const
mp_obj_type_t
exception_type
=
{
const
mp_obj_type_t
exception_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"exception"
,
"exception"
,
exception_print
,
// print
.
print
=
exception_print
,
NULL
,
// make_new
NULL
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_exception
(
qstr
id
)
{
mp_obj_t
mp_obj_new_exception
(
qstr
id
)
{
...
...
py/objfloat.c
View file @
97209d38
...
@@ -68,7 +68,6 @@ const mp_obj_type_t float_type = {
...
@@ -68,7 +68,6 @@ const mp_obj_type_t float_type = {
.
make_new
=
float_make_new
,
.
make_new
=
float_make_new
,
.
unary_op
=
float_unary_op
,
.
unary_op
=
float_unary_op
,
.
binary_op
=
float_binary_op
,
.
binary_op
=
float_binary_op
,
.
methods
=
{
{
NULL
,
NULL
},
},
};
};
mp_obj_t
mp_obj_new_float
(
mp_float_t
value
)
{
mp_obj_t
mp_obj_new_float
(
mp_float_t
value
)
{
...
...
py/objfun.c
View file @
97209d38
...
@@ -72,16 +72,7 @@ mp_obj_t fun_native_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
...
@@ -72,16 +72,7 @@ mp_obj_t fun_native_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
const
mp_obj_type_t
fun_native_type
=
{
const
mp_obj_type_t
fun_native_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"function"
,
"function"
,
NULL
,
// print
.
call_n
=
fun_native_call_n
,
NULL
,
// make_new
fun_native_call_n
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{
{
NULL
,
NULL
},
// end-of-list sentinel
},
};
};
mp_obj_t
rt_make_function_0
(
mp_fun_0_t
fun
)
{
mp_obj_t
rt_make_function_0
(
mp_fun_0_t
fun
)
{
...
@@ -174,16 +165,7 @@ mp_obj_t fun_bc_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
...
@@ -174,16 +165,7 @@ mp_obj_t fun_bc_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
const
mp_obj_type_t
fun_bc_type
=
{
const
mp_obj_type_t
fun_bc_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"function"
,
"function"
,
NULL
,
// print
.
call_n
=
fun_bc_call_n
,
NULL
,
// make_new
fun_bc_call_n
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{
{
NULL
,
NULL
},
// end-of-list sentinel
},
};
};
mp_obj_t
mp_obj_new_fun_bc
(
int
n_args
,
uint
n_state
,
const
byte
*
code
)
{
mp_obj_t
mp_obj_new_fun_bc
(
int
n_args
,
uint
n_state
,
const
byte
*
code
)
{
...
@@ -288,16 +270,7 @@ mp_obj_t fun_asm_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
...
@@ -288,16 +270,7 @@ mp_obj_t fun_asm_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
static
const
mp_obj_type_t
fun_asm_type
=
{
static
const
mp_obj_type_t
fun_asm_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"function"
,
"function"
,
NULL
,
// print
.
call_n
=
fun_asm_call_n
,
NULL
,
// make_new
fun_asm_call_n
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{
{
NULL
,
NULL
},
// end-of-list sentinel
},
};
};
mp_obj_t
mp_obj_new_fun_asm
(
uint
n_args
,
void
*
fun
)
{
mp_obj_t
mp_obj_new_fun_asm
(
uint
n_args
,
void
*
fun
)
{
...
...
py/objgenerator.c
View file @
97209d38
...
@@ -39,14 +39,7 @@ mp_obj_t gen_wrap_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
...
@@ -39,14 +39,7 @@ mp_obj_t gen_wrap_call_n(mp_obj_t self_in, int n_args, const mp_obj_t *args) {
const
mp_obj_type_t
gen_wrap_type
=
{
const
mp_obj_type_t
gen_wrap_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"generator"
,
"generator"
,
NULL
,
// print
.
call_n
=
gen_wrap_call_n
,
NULL
,
// make_new
gen_wrap_call_n
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_gen_wrap
(
uint
n_locals
,
uint
n_stack
,
mp_obj_t
fun
)
{
mp_obj_t
mp_obj_new_gen_wrap
(
uint
n_locals
,
uint
n_stack
,
mp_obj_t
fun
)
{
...
@@ -94,14 +87,9 @@ mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
...
@@ -94,14 +87,9 @@ mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
const
mp_obj_type_t
gen_instance_type
=
{
const
mp_obj_type_t
gen_instance_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"generator"
,
"generator"
,
gen_instance_print
,
// print
.
print
=
gen_instance_print
,
NULL
,
// make_new
.
getiter
=
gen_instance_getiter
,
NULL
,
// call_n
.
iternext
=
gen_instance_iternext
,
NULL
,
// unary_op
NULL
,
// binary_op
gen_instance_getiter
,
// getiter
gen_instance_iternext
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
// args are in reverse order in the array
// args are in reverse order in the array
...
...
py/objinstance.c
View file @
97209d38
...
@@ -92,14 +92,6 @@ void mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
...
@@ -92,14 +92,6 @@ void mp_obj_instance_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
const
mp_obj_type_t
instance_type
=
{
const
mp_obj_type_t
instance_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"instance"
,
"instance"
,
NULL
,
// print
NULL
,
// make_new
NULL
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_instance
(
mp_obj_t
class
)
{
mp_obj_t
mp_obj_new_instance
(
mp_obj_t
class
)
{
...
...
py/objint.c
View file @
97209d38
...
@@ -34,7 +34,6 @@ const mp_obj_type_t int_type = {
...
@@ -34,7 +34,6 @@ const mp_obj_type_t int_type = {
{
&
mp_const_type
},
{
&
mp_const_type
},
"int"
,
"int"
,
.
make_new
=
int_make_new
,
.
make_new
=
int_make_new
,
.
methods
=
{
{
NULL
,
NULL
},
},
};
};
mp_obj_t
mp_obj_new_int
(
machine_int_t
value
)
{
mp_obj_t
mp_obj_new_int
(
machine_int_t
value
)
{
...
...
py/objlist.c
View file @
97209d38
...
@@ -57,6 +57,7 @@ static mp_obj_t list_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args
...
@@ -57,6 +57,7 @@ static mp_obj_t list_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args
default:
default:
nlr_jump
(
mp_obj_new_exception_msg_1_arg
(
MP_QSTR_TypeError
,
"list takes at most 1 argument, %d given"
,
(
void
*
)(
machine_int_t
)
n_args
));
nlr_jump
(
mp_obj_new_exception_msg_1_arg
(
MP_QSTR_TypeError
,
"list takes at most 1 argument, %d given"
,
(
void
*
)(
machine_int_t
)
n_args
));
}
}
return
NULL
;
}
}
static
mp_obj_t
list_binary_op
(
int
op
,
mp_obj_t
lhs
,
mp_obj_t
rhs
)
{
static
mp_obj_t
list_binary_op
(
int
op
,
mp_obj_t
lhs
,
mp_obj_t
rhs
)
{
...
@@ -260,27 +261,28 @@ static MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, list_remove);
...
@@ -260,27 +261,28 @@ static MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, list_remove);
static
MP_DEFINE_CONST_FUN_OBJ_1
(
list_reverse_obj
,
list_reverse
);
static
MP_DEFINE_CONST_FUN_OBJ_1
(
list_reverse_obj
,
list_reverse
);
static
MP_DEFINE_CONST_FUN_OBJ_2
(
list_sort_obj
,
list_sort
);
static
MP_DEFINE_CONST_FUN_OBJ_2
(
list_sort_obj
,
list_sort
);
static
const
mp_method_t
list_type_methods
[]
=
{
{
"append"
,
&
list_append_obj
},
{
"clear"
,
&
list_clear_obj
},
{
"copy"
,
&
list_copy_obj
},
{
"count"
,
&
list_count_obj
},
{
"index"
,
&
list_index_obj
},
{
"insert"
,
&
list_insert_obj
},
{
"pop"
,
&
list_pop_obj
},
{
"remove"
,
&
list_remove_obj
},
{
"reverse"
,
&
list_reverse_obj
},
{
"sort"
,
&
list_sort_obj
},
{
NULL
,
NULL
},
// end-of-list sentinel
};
const
mp_obj_type_t
list_type
=
{
const
mp_obj_type_t
list_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"list"
,
"list"
,
.
print
=
list_print
,
.
print
=
list_print
,
.
make_new
=
list_make_new
,
.
make_new
=
list_make_new
,
.
unary_op
=
NULL
,
.
binary_op
=
list_binary_op
,
.
binary_op
=
list_binary_op
,
.
getiter
=
list_getiter
,
.
getiter
=
list_getiter
,
.
methods
=
{
.
methods
=
list_type_methods
,
{
"append"
,
&
list_append_obj
},
{
"clear"
,
&
list_clear_obj
},
{
"copy"
,
&
list_copy_obj
},
{
"count"
,
&
list_count_obj
},
{
"index"
,
&
list_index_obj
},
{
"insert"
,
&
list_insert_obj
},
{
"pop"
,
&
list_pop_obj
},
{
"remove"
,
&
list_remove_obj
},
{
"reverse"
,
&
list_reverse_obj
},
{
"sort"
,
&
list_sort_obj
},
{
NULL
,
NULL
},
// end-of-list sentinel
},
};
};
static
mp_obj_list_t
*
list_new
(
uint
n
)
{
static
mp_obj_list_t
*
list_new
(
uint
n
)
{
...
@@ -344,7 +346,6 @@ static const mp_obj_type_t list_it_type = {
...
@@ -344,7 +346,6 @@ static const mp_obj_type_t list_it_type = {
{
&
mp_const_type
},
{
&
mp_const_type
},
"list_iterator"
,
"list_iterator"
,
.
iternext
=
list_it_iternext
,
.
iternext
=
list_it_iternext
,
.
methods
=
{
{
NULL
,
NULL
},
},
};
};
mp_obj_t
mp_obj_new_list_iterator
(
mp_obj_list_t
*
list
,
int
cur
)
{
mp_obj_t
mp_obj_new_list_iterator
(
mp_obj_list_t
*
list
,
int
cur
)
{
...
...
py/objmodule.c
View file @
97209d38
...
@@ -24,14 +24,7 @@ void module_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_
...
@@ -24,14 +24,7 @@ void module_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_
const
mp_obj_type_t
module_type
=
{
const
mp_obj_type_t
module_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"module"
,
"module"
,
module_print
,
// print
.
print
=
module_print
,
NULL
,
// make_new
NULL
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_module
(
qstr
module_name
)
{
mp_obj_t
mp_obj_new_module
(
qstr
module_name
)
{
...
...
py/objnone.c
View file @
97209d38
...
@@ -18,7 +18,6 @@ const mp_obj_type_t none_type = {
...
@@ -18,7 +18,6 @@ const mp_obj_type_t none_type = {
{
&
mp_const_type
},
{
&
mp_const_type
},
"NoneType"
,
"NoneType"
,
.
print
=
none_print
,
.
print
=
none_print
,
.
methods
=
{{
NULL
,
NULL
},},
};
};
static
const
mp_obj_none_t
none_obj
=
{{
&
none_type
}};
static
const
mp_obj_none_t
none_obj
=
{{
&
none_type
}};
...
...
py/objrange.c
View file @
97209d38
...
@@ -25,14 +25,7 @@ mp_obj_t range_getiter(mp_obj_t o_in) {
...
@@ -25,14 +25,7 @@ mp_obj_t range_getiter(mp_obj_t o_in) {
static
const
mp_obj_type_t
range_type
=
{
static
const
mp_obj_type_t
range_type
=
{
{
&
mp_const_type
}
,
{
&
mp_const_type
}
,
"range"
,
"range"
,
NULL
,
// print
.
getiter
=
range_getiter
,
NULL
,
// make_new
NULL
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
range_getiter
,
NULL
,
// iternext
.
methods
=
{{
NULL
,
NULL
},},
};
};
// range is a class and instances are immutable sequence objects
// range is a class and instances are immutable sequence objects
...
@@ -70,14 +63,7 @@ mp_obj_t range_it_iternext(mp_obj_t o_in) {
...
@@ -70,14 +63,7 @@ mp_obj_t range_it_iternext(mp_obj_t o_in) {
static
const
mp_obj_type_t
range_it_type
=
{
static
const
mp_obj_type_t
range_it_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"range_iterator"
,
"range_iterator"
,
NULL
,
// print
.
iternext
=
range_it_iternext
,
NULL
,
// make_new
NULL
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
range_it_iternext
,
.
methods
=
{{
NULL
,
NULL
},},
};
};
mp_obj_t
mp_obj_new_range_iterator
(
int
cur
,
int
stop
,
int
step
)
{
mp_obj_t
mp_obj_new_range_iterator
(
int
cur
,
int
stop
,
int
step
)
{
...
...
py/objset.c
View file @
97209d38
...
@@ -57,14 +57,8 @@ static mp_obj_t set_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args)
...
@@ -57,14 +57,8 @@ static mp_obj_t set_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args)
const
mp_obj_type_t
set_type
=
{
const
mp_obj_type_t
set_type
=
{
{
&
mp_const_type
},
{
&
mp_const_type
},
"set"
,
"set"
,
set_print
,
// print
.
print
=
set_print
,
set_make_new
,
// make_new
.
make_new
=
set_make_new
,
NULL
,
// call_n
NULL
,
// unary_op
NULL
,
// binary_op
NULL
,
// getiter
NULL
,
// iternext
.
methods
=
{
{
NULL
,
NULL
},
},
};
};
mp_obj_t
mp_obj_new_set
(
int
n_args
,
mp_obj_t
*
items
)
{
mp_obj_t
mp_obj_new_set
(
int
n_args
,
mp_obj_t
*
items
)
{
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment