summaryrefslogtreecommitdiffstatshomepage
path: root/py/obj.h
diff options
context:
space:
mode:
authorJohn R. Lenton <jlenton@gmail.com>2014-01-07 18:01:08 +0000
committerJohn R. Lenton <jlenton@gmail.com>2014-01-07 18:01:08 +0000
commit270112f7312f724e46ae34649dfce3ec43b697e0 (patch)
treed7438ae877350aede062d8ac7e62e52ab35cb018 /py/obj.h
parentc06763a0207dde7f2060f7b1670a0b99298a01f8 (diff)
parentfd04bb3bacf5dbc4d79c04a49520e3e81abb7352 (diff)
downloadmicropython-270112f7312f724e46ae34649dfce3ec43b697e0.tar.gz
micropython-270112f7312f724e46ae34649dfce3ec43b697e0.zip
Merge remote-tracking branch 'upstream/master' into listsort. Lots of conflict fun.
Conflicts: py/obj.h py/objbool.c py/objboundmeth.c py/objcell.c py/objclass.c py/objclosure.c py/objcomplex.c py/objdict.c py/objexcept.c py/objfun.c py/objgenerator.c py/objinstance.c py/objmodule.c py/objrange.c py/objset.c py/objslice.c
Diffstat (limited to 'py/obj.h')
-rw-r--r--py/obj.h31
1 files changed, 17 insertions, 14 deletions
diff --git a/py/obj.h b/py/obj.h
index e4e64fca71..332867a194 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -15,15 +15,14 @@ typedef machine_int_t mp_small_int_t;
typedef machine_float_t mp_float_t;
#endif
-// Anything that wants to be a Micro Python object must
-// have 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;
+// Anything that wants to be a Micro Python object must have
+// mp_obj_base_t as its first member (except NULL and small ints)
+struct _mp_obj_type_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
// It *cannot* be used when an mp_obj_t is expected, except where explicitly allowed
@@ -43,13 +42,14 @@ struct _mp_obj_base_t {
#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}, false, 0, 0, fun_name}
-#define MP_DEFINE_CONST_FUN_OBJ_1(obj_name, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, false, 1, 1, fun_name}
-#define MP_DEFINE_CONST_FUN_OBJ_2(obj_name, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, false, 2, 2, fun_name}
-#define MP_DEFINE_CONST_FUN_OBJ_3(obj_name, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, false, 3, 3, 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}, false, n_args_min, (~((machine_uint_t)0)), 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}, false, n_args_min, n_args_max, fun_name}
-#define MP_DEFINE_CONST_FUN_OBJ_KW(obj_name, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, true, 0, (~((machine_uint_t)0)), fun_name}
+#define MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, is_kw, n_args_min, n_args_max, fun_name) const mp_obj_fun_native_t obj_name = {{&fun_native_type}, is_kw, n_args_min, n_args_max, (void *)fun_name}
+#define MP_DEFINE_CONST_FUN_OBJ_0(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, 0, 0, (mp_fun_0_t)fun_name)
+#define MP_DEFINE_CONST_FUN_OBJ_1(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, 1, 1, (mp_fun_1_t)fun_name)
+#define MP_DEFINE_CONST_FUN_OBJ_2(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, 2, 2, (mp_fun_2_t)fun_name)
+#define MP_DEFINE_CONST_FUN_OBJ_3(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, false, 3, 3, (mp_fun_3_t)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, false, 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, false, n_args_min, n_args_max, (mp_fun_var_t)fun_name)
+#define MP_DEFINE_CONST_FUN_OBJ_KW(obj_name, fun_name) MP_DEFINE_CONST_FUN_OBJ_VOID_PTR(obj_name, true, 0, (~((machine_uint_t)0)), (mp_fun_var_t)fun_name)
// Need to declare this here so we are not dependent on map.h
struct _mp_map_t;
@@ -90,7 +90,7 @@ struct _mp_obj_type_t {
mp_fun_1_t getiter;
mp_fun_1_t iternext;
- const mp_method_t methods[];
+ const mp_method_t *methods;
/*
What we might need to add here:
@@ -115,6 +115,8 @@ struct _mp_obj_type_t {
*/
};
+typedef struct _mp_obj_type_t mp_obj_type_t;
+
// Constant objects, globally accessible
extern const mp_obj_type_t mp_const_type;
@@ -245,6 +247,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
// such functions won't be able to access the global scope, but that's probably okay
} mp_obj_fun_native_t;
+
extern const mp_obj_type_t fun_native_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);