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
68e7c514
Commit
68e7c514
authored
Apr 13, 2014
by
Paul Sokolovsky
Browse files
py: Factor out impl of special methods for builtin types into opmethods.c
parent
036ad766
Changes
5
Hide whitespace changes
Inline
Side-by-side
py/builtin.h
View file @
68e7c514
...
...
@@ -35,6 +35,9 @@ MP_DECLARE_CONST_FUN_OBJ(mp_builtin_sum_obj);
MP_DECLARE_CONST_FUN_OBJ
(
mp_namedtuple_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_op_contains_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_op_getitem_obj
);
extern
const
mp_obj_module_t
mp_module___main__
;
extern
const
mp_obj_module_t
mp_module_array
;
extern
const
mp_obj_module_t
mp_module_collections
;
...
...
py/objdict.c
View file @
68e7c514
...
...
@@ -10,6 +10,7 @@
#include
"objtuple.h"
#include
"runtime0.h"
#include
"runtime.h"
#include
"builtin.h"
STATIC
mp_obj_t
mp_obj_new_dict_iterator
(
mp_obj_dict_t
*
dict
,
int
cur
);
STATIC
mp_map_elem_t
*
dict_it_iternext_elem
(
mp_obj_t
self_in
);
...
...
@@ -137,12 +138,6 @@ STATIC bool dict_store_item(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
return
true
;
}
STATIC
mp_obj_t
dict_getitem
(
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
return
dict_binary_op
(
MP_BINARY_OP_SUBSCR
,
lhs_in
,
rhs_in
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
dict_getitem_obj
,
dict_getitem
);
/******************************************************************************/
/* dict iterator */
...
...
@@ -501,7 +496,7 @@ STATIC const mp_map_elem_t dict_locals_dict_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_setdefault
),
(
mp_obj_t
)
&
dict_setdefault_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_update
),
(
mp_obj_t
)
&
dict_update_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_values
),
(
mp_obj_t
)
&
dict_values_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___getitem__
),
(
mp_obj_t
)
&
dict
_getitem_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___getitem__
),
(
mp_obj_t
)
&
mp_op
_getitem_obj
},
};
STATIC
MP_DEFINE_CONST_DICT
(
dict_locals_dict
,
dict_locals_dict_table
);
...
...
py/objset.c
View file @
68e7c514
...
...
@@ -9,6 +9,7 @@
#include
"obj.h"
#include
"runtime.h"
#include
"runtime0.h"
#include
"builtin.h"
typedef
struct
_mp_obj_set_t
{
mp_obj_base_t
base
;
...
...
@@ -423,13 +424,6 @@ STATIC mp_obj_t set_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
}
}
// TODO: Move to common file
STATIC
mp_obj_t
set_contains
(
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
return
set_binary_op
(
MP_BINARY_OP_IN
,
lhs_in
,
rhs_in
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_2
(
set_contains_obj
,
set_contains
);
/******************************************************************************/
/* set constructors & public C API */
...
...
@@ -452,7 +446,7 @@ STATIC const mp_map_elem_t set_locals_dict_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_symmetric_difference_update
),
(
mp_obj_t
)
&
set_symmetric_difference_update_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_union
),
(
mp_obj_t
)
&
set_union_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_update
),
(
mp_obj_t
)
&
set_update_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___contains__
),
(
mp_obj_t
)
&
set
_contains_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___contains__
),
(
mp_obj_t
)
&
mp_op
_contains_obj
},
};
STATIC
MP_DEFINE_CONST_DICT
(
set_locals_dict
,
set_locals_dict_table
);
...
...
py/opmethods.c
0 → 100644
View file @
68e7c514
#include
"nlr.h"
#include
"misc.h"
#include
"mpconfig.h"
#include
"qstr.h"
#include
"obj.h"
#include
"runtime.h"
#include
"runtime0.h"
#include
"builtin.h"
STATIC
mp_obj_t
op_getitem
(
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
mp_obj_type_t
*
type
=
mp_obj_get_type
(
lhs_in
);
return
type
->
binary_op
(
MP_BINARY_OP_SUBSCR
,
lhs_in
,
rhs_in
);
}
MP_DEFINE_CONST_FUN_OBJ_2
(
mp_op_getitem_obj
,
op_getitem
);
STATIC
mp_obj_t
op_contains
(
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
mp_obj_type_t
*
type
=
mp_obj_get_type
(
lhs_in
);
return
type
->
binary_op
(
MP_BINARY_OP_IN
,
lhs_in
,
rhs_in
);
}
MP_DEFINE_CONST_FUN_OBJ_2
(
mp_op_contains_obj
,
op_contains
);
py/py.mk
View file @
68e7c514
...
...
@@ -69,6 +69,7 @@ PY_O_BASENAME = \
objtuple.o
\
objtype.o
\
objzip.o
\
opmethods.o
\
sequence.o
\
stream.o
\
binary.o
\
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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