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
GitLab 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
ee4aaf7c
Commit
ee4aaf7c
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
Implement tuple addition.
parent
e827e98a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
py/obj.h
+2
-1
2 additions, 1 deletion
py/obj.h
py/objlist.c
+1
-2
1 addition, 2 deletions
py/objlist.c
py/objtuple.c
+10
-0
10 additions, 0 deletions
py/objtuple.c
tests/basics/tuple1.py
+2
-0
2 additions, 0 deletions
tests/basics/tuple1.py
with
15 additions
and
3 deletions
py/obj.h
+
2
−
1
View file @
ee4aaf7c
...
...
@@ -398,6 +398,7 @@ typedef struct _mp_obj_static_class_method_t {
// sequence helpers
void
mp_seq_multiply
(
const
void
*
items
,
uint
item_sz
,
uint
len
,
uint
times
,
void
*
dest
);
bool
m_seq_get_fast_slice_indexes
(
machine_uint_t
len
,
mp_obj_t
slice
,
machine_uint_t
*
begin
,
machine_uint_t
*
end
);
#define m_seq_copy(dest, src, len, item_sz) memcpy(dest, src, len * sizeof(item_sz))
#define m_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * sizeof(item_t))
#define m_seq_cat(dest, src1, len1, src2, len2, item_t) { memcpy(dest, src1, len1 * sizeof(item_t)); memcpy(dest + len1, src2, len2 * sizeof(item_t)); }
bool
mp_seq_cmp_bytes
(
int
op
,
const
byte
*
data1
,
uint
len1
,
const
byte
*
data2
,
uint
len2
);
bool
mp_seq_cmp_objs
(
int
op
,
const
mp_obj_t
*
items1
,
uint
len1
,
const
mp_obj_t
*
items2
,
uint
len2
);
This diff is collapsed.
Click to expand it.
py/objlist.c
+
1
−
2
View file @
ee4aaf7c
...
...
@@ -114,8 +114,7 @@ static mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
}
mp_obj_list_t
*
p
=
rhs
;
mp_obj_list_t
*
s
=
list_new
(
o
->
len
+
p
->
len
);
memcpy
(
s
->
items
,
o
->
items
,
sizeof
(
mp_obj_t
)
*
o
->
len
);
memcpy
(
s
->
items
+
o
->
len
,
p
->
items
,
sizeof
(
mp_obj_t
)
*
p
->
len
);
m_seq_cat
(
s
->
items
,
o
->
items
,
o
->
len
,
p
->
items
,
p
->
len
,
mp_obj_t
);
return
s
;
}
case
RT_BINARY_OP_INPLACE_ADD
:
...
...
This diff is collapsed.
Click to expand it.
py/objtuple.c
+
10
−
0
View file @
ee4aaf7c
...
...
@@ -114,6 +114,16 @@ static mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
uint
index
=
mp_get_index
(
o
->
base
.
type
,
o
->
len
,
rhs
);
return
o
->
items
[
index
];
}
case
RT_BINARY_OP_ADD
:
{
if
(
!
MP_OBJ_IS_TYPE
(
rhs
,
&
tuple_type
))
{
return
NULL
;
}
mp_obj_tuple_t
*
p
=
rhs
;
mp_obj_tuple_t
*
s
=
mp_obj_new_tuple
(
o
->
len
+
p
->
len
,
NULL
);
m_seq_cat
(
s
->
items
,
o
->
items
,
o
->
len
,
p
->
items
,
p
->
len
,
mp_obj_t
);
return
s
;
}
case
RT_BINARY_OP_EQUAL
:
case
RT_BINARY_OP_LESS
:
case
RT_BINARY_OP_LESS_EQUAL
:
...
...
This diff is collapsed.
Click to expand it.
tests/basics/tuple1.py
+
2
−
0
View file @
ee4aaf7c
...
...
@@ -14,3 +14,5 @@ except AttributeError:
print
(
x
[
1
:])
print
(
x
[:
-
1
])
print
(
x
[
2
:
3
])
print
(
x
+
(
10
,
100
,
10000
))
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