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
586bfce1
Commit
586bfce1
authored
Apr 05, 2014
by
Paul Sokolovsky
Browse files
objfun: Add equality support.
parent
38d34303
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/objfun.c
View file @
586bfce1
...
...
@@ -53,6 +53,16 @@ void mp_check_nargs(int n_args, machine_uint_t n_args_min, machine_uint_t n_args
}
}
STATIC
mp_obj_t
fun_binary_op
(
int
op
,
mp_obj_t
lhs_in
,
mp_obj_t
rhs_in
)
{
switch
(
op
)
{
case
MP_BINARY_OP_EQUAL
:
// These objects can be equal only if it's the same underlying structure,
// we don't even need to check for 2nd arg type.
return
MP_BOOL
(
lhs_in
==
rhs_in
);
}
return
NULL
;
}
STATIC
mp_obj_t
fun_native_call
(
mp_obj_t
self_in
,
uint
n_args
,
uint
n_kw
,
const
mp_obj_t
*
args
)
{
assert
(
MP_OBJ_IS_TYPE
(
self_in
,
&
mp_type_fun_native
));
mp_obj_fun_native_t
*
self
=
self_in
;
...
...
@@ -102,6 +112,7 @@ const mp_obj_type_t mp_type_fun_native = {
{
&
mp_type_type
},
.
name
=
MP_QSTR_function
,
.
call
=
fun_native_call
,
.
binary_op
=
fun_binary_op
,
};
// fun must have the correct signature for n_args fixed arguments
...
...
@@ -338,6 +349,7 @@ const mp_obj_type_t mp_type_fun_bc = {
{
&
mp_type_type
},
.
name
=
MP_QSTR_function
,
.
call
=
fun_bc_call
,
.
binary_op
=
fun_binary_op
,
};
mp_obj_t
mp_obj_new_fun_bc
(
uint
scope_flags
,
qstr
*
args
,
uint
n_args
,
mp_obj_t
def_args_in
,
const
byte
*
code
)
{
...
...
@@ -464,6 +476,7 @@ STATIC const mp_obj_type_t mp_type_fun_asm = {
{
&
mp_type_type
},
.
name
=
MP_QSTR_function
,
.
call
=
fun_asm_call
,
.
binary_op
=
fun_binary_op
,
};
mp_obj_t
mp_obj_new_fun_asm
(
uint
n_args
,
void
*
fun
)
{
...
...
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