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
58051117
Commit
58051117
authored
Apr 15, 2014
by
Damien George
Browse files
py: Add hex builtin function.
A one-liner, added especially for @pfalcon :)
parent
256b319d
Changes
5
Hide whitespace changes
Inline
Side-by-side
py/builtin.c
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
);
}
...
...
py/builtin.h
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
);
...
...
py/builtintables.c
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
},
...
...
py/makeqstrdata.py
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
):
...
...
py/qstrdefs.h
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
)
...
...
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