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
e5dbe1e2
Commit
e5dbe1e2
authored
Nov 26, 2014
by
Paul Sokolovsky
Committed by
Damien George
Nov 27, 2014
Browse files
map: Add empty fixed map.
Useful when need to call kw-receiving functions without any keywords from C, etc.
parent
317cf184
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/map.c
View file @
e5dbe1e2
...
...
@@ -34,6 +34,16 @@
#include
"obj.h"
#include
"runtime0.h"
// Fixed empty map. Useful when need to call kw-receiving functions
// without any keywords from C, etc.
const
mp_map_t
mp_const_empty_map
=
{
.
all_keys_are_qstrs
=
0
,
.
table_is_fixed_array
=
1
,
.
used
=
0
,
.
alloc
=
0
,
.
table
=
NULL
,
};
// approximatelly doubling primes; made with Mathematica command: Table[Prime[Floor[(1.7)^n]], {n, 3, 24}]
// prefixed with zero for the empty case.
STATIC
uint32_t
doubling_primes
[]
=
{
0
,
7
,
19
,
43
,
89
,
179
,
347
,
647
,
1229
,
2297
,
4243
,
7829
,
14347
,
26017
,
47149
,
84947
,
152443
,
273253
,
488399
,
869927
,
1547173
,
2745121
,
4861607
};
...
...
py/obj.h
View file @
e5dbe1e2
...
...
@@ -148,6 +148,8 @@ typedef enum _mp_map_lookup_kind_t {
MP_MAP_LOOKUP_REMOVE_IF_FOUND
,
// 2
}
mp_map_lookup_kind_t
;
extern
const
mp_map_t
mp_const_empty_map
;
static
inline
bool
MP_MAP_SLOT_IS_FILLED
(
const
mp_map_t
*
map
,
mp_uint_t
pos
)
{
return
((
map
)
->
table
[
pos
].
key
!=
MP_OBJ_NULL
&&
(
map
)
->
table
[
pos
].
key
!=
MP_OBJ_SENTINEL
);
}
void
mp_map_init
(
mp_map_t
*
map
,
mp_uint_t
n
);
...
...
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