Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
586bfce1
Commit
586bfce1
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
objfun: Add equality support.
parent
38d34303
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/objfun.c
+13
-0
13 additions, 0 deletions
py/objfun.c
with
13 additions
and
0 deletions
py/objfun.c
+
13
−
0
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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment