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
58051117
Commit
58051117
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Add hex builtin function.
A one-liner, added especially for @pfalcon :)
parent
256b319d
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
py/builtin.c
+6
-0
6 additions, 0 deletions
py/builtin.c
py/builtin.h
+1
-0
1 addition, 0 deletions
py/builtin.h
py/builtintables.c
+1
-0
1 addition, 0 deletions
py/builtintables.c
py/makeqstrdata.py
+1
-0
1 addition, 0 deletions
py/makeqstrdata.py
py/qstrdefs.h
+2
-0
2 additions, 0 deletions
py/qstrdefs.h
with
11 additions
and
0 deletions
py/builtin.c
+
6
−
0
View file @
58051117
...
...
@@ -207,6 +207,12 @@ STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
MP_DEFINE_CONST_FUN_OBJ_1
(
mp_builtin_hash_obj
,
mp_builtin_hash
);
STATIC
mp_obj_t
mp_builtin_hex
(
mp_obj_t
o_in
)
{
return
mp_binary_op
(
MP_BINARY_OP_MODULO
,
MP_OBJ_NEW_QSTR
(
MP_QSTR__percent_x
),
o_in
);
}
MP_DEFINE_CONST_FUN_OBJ_1
(
mp_builtin_hex_obj
,
mp_builtin_hex
);
STATIC
mp_obj_t
mp_builtin_iter
(
mp_obj_t
o_in
)
{
return
mp_getiter
(
o_in
);
}
...
...
This diff is collapsed.
Click to expand it.
py/builtin.h
+
1
−
0
View file @
58051117
...
...
@@ -15,6 +15,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_builtin_exec_obj);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_getattr_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_globals_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_hash_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_hex_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_id_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_isinstance_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_issubclass_obj
);
...
...
This diff is collapsed.
Click to expand it.
py/builtintables.c
+
1
−
0
View file @
58051117
...
...
@@ -60,6 +60,7 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = {
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_getattr
),
(
mp_obj_t
)
&
mp_builtin_getattr_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_globals
),
(
mp_obj_t
)
&
mp_builtin_globals_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_hash
),
(
mp_obj_t
)
&
mp_builtin_hash_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_hex
),
(
mp_obj_t
)
&
mp_builtin_hex_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_id
),
(
mp_obj_t
)
&
mp_builtin_id_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_isinstance
),
(
mp_obj_t
)
&
mp_builtin_isinstance_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_issubclass
),
(
mp_obj_t
)
&
mp_builtin_issubclass_obj
},
...
...
This diff is collapsed.
Click to expand it.
py/makeqstrdata.py
+
1
−
0
View file @
58051117
...
...
@@ -16,6 +16,7 @@ codepoint2name[ord('-')] = 'hyphen';
codepoint2name
[
ord
(
'
.
'
)]
=
'
dot
'
codepoint2name
[
ord
(
'
:
'
)]
=
'
colon
'
codepoint2name
[
ord
(
'
/
'
)]
=
'
slash
'
codepoint2name
[
ord
(
'
%
'
)]
=
'
percent
'
# this must match the equivalent function in qstr.c
def
compute_hash
(
qstr
):
...
...
This diff is collapsed.
Click to expand it.
py/qstrdefs.h
+
2
−
0
View file @
58051117
...
...
@@ -106,6 +106,8 @@ Q(from_bytes)
Q
(
getattr
)
Q
(
globals
)
Q
(
hash
)
Q
(
hex
)
Q
(
%
x
)
Q
(
id
)
Q
(
io
)
Q
(
int
)
...
...
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