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
4abaa1b1
Commit
4abaa1b1
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
unix modffi: Convert to static module structures.
parent
de7c4251
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
unix/main.c
+0
-4
0 additions, 4 deletions
unix/main.c
unix/modffi.c
+22
-7
22 additions, 7 deletions
unix/modffi.c
unix/mpconfigport.h
+2
-0
2 additions, 0 deletions
unix/mpconfigport.h
unix/qstrdefsport.h
+4
-0
4 additions, 0 deletions
unix/qstrdefsport.h
with
28 additions
and
11 deletions
unix/main.c
+
0
−
4
View file @
4abaa1b1
...
@@ -357,10 +357,6 @@ int main(int argc, char **argv) {
...
@@ -357,10 +357,6 @@ int main(int argc, char **argv) {
mp_store_name
(
qstr_from_str
(
"gc"
),
(
mp_obj_t
)
&
pyb_gc_obj
);
mp_store_name
(
qstr_from_str
(
"gc"
),
(
mp_obj_t
)
&
pyb_gc_obj
);
#endif
#endif
#if MICROPY_MOD_FFI
ffi_init
();
#endif
// Here is some example code to create a class and instance of that class.
// Here is some example code to create a class and instance of that class.
// First is the Python, then the C code.
// First is the Python, then the C code.
//
//
...
...
This diff is collapsed.
Click to expand it.
unix/modffi.c
+
22
−
7
View file @
4abaa1b1
...
@@ -365,11 +365,26 @@ mp_obj_t mod_ffi_as_bytearray(mp_obj_t ptr, mp_obj_t size) {
...
@@ -365,11 +365,26 @@ mp_obj_t mod_ffi_as_bytearray(mp_obj_t ptr, mp_obj_t size) {
}
}
MP_DEFINE_CONST_FUN_OBJ_2
(
mod_ffi_as_bytearray_obj
,
mod_ffi_as_bytearray
);
MP_DEFINE_CONST_FUN_OBJ_2
(
mod_ffi_as_bytearray_obj
,
mod_ffi_as_bytearray
);
STATIC
const
mp_map_elem_t
mp_module_ffi_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR_ffi
)
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_open
),
(
mp_obj_t
)
&
mod_ffi_open_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_callback
),
(
mp_obj_t
)
&
mod_ffi_callback_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_as_bytearray
),
(
mp_obj_t
)
&
mod_ffi_as_bytearray_obj
},
};
void
ffi_init
()
{
STATIC
const
mp_obj_dict_t
mp_module_ffi_globals
=
{
mp_obj_t
m
=
mp_obj_new_module
(
QSTR_FROM_STR_STATIC
(
"ffi"
));
.
base
=
{
&
mp_type_dict
},
mp_store_attr
(
m
,
MP_QSTR_open
,
(
mp_obj_t
)
&
mod_ffi_open_obj
);
.
map
=
{
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"callback"
),
(
mp_obj_t
)
&
mod_ffi_callback_obj
);
.
all_keys_are_qstrs
=
1
,
// there would be as_bytes, but bytes currently is value, not reference type!
.
table_is_fixed_array
=
1
,
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"as_bytearray"
),
(
mp_obj_t
)
&
mod_ffi_as_bytearray_obj
);
.
used
=
sizeof
(
mp_module_ffi_globals_table
)
/
sizeof
(
mp_map_elem_t
),
}
.
alloc
=
sizeof
(
mp_module_ffi_globals_table
)
/
sizeof
(
mp_map_elem_t
),
.
table
=
(
mp_map_elem_t
*
)
mp_module_ffi_globals_table
,
},
};
const
mp_obj_module_t
mp_module_ffi
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_ffi
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_ffi_globals
,
};
This diff is collapsed.
Click to expand it.
unix/mpconfigport.h
+
2
−
0
View file @
4abaa1b1
...
@@ -19,7 +19,9 @@
...
@@ -19,7 +19,9 @@
extern
const
struct
_mp_obj_module_t
mp_module_time
;
extern
const
struct
_mp_obj_module_t
mp_module_time
;
extern
const
struct
_mp_obj_module_t
mp_module_socket
;
extern
const
struct
_mp_obj_module_t
mp_module_socket
;
extern
const
struct
_mp_obj_module_t
mp_module_ffi
;
#define MICROPY_EXTRA_BUILTIN_MODULES \
#define MICROPY_EXTRA_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR_ffi), (mp_obj_t)&mp_module_ffi }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mp_module_time }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mp_module_time }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_microsocket), (mp_obj_t)&mp_module_socket }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_microsocket), (mp_obj_t)&mp_module_socket }, \
...
...
This diff is collapsed.
Click to expand it.
unix/qstrdefsport.h
+
4
−
0
View file @
4abaa1b1
...
@@ -10,10 +10,14 @@ Q(write)
...
@@ -10,10 +10,14 @@ Q(write)
Q
(
makefile
)
Q
(
makefile
)
Q
(
FileIO
)
Q
(
FileIO
)
Q
(
ffi
)
Q
(
ffimod
)
Q
(
ffimod
)
Q
(
ffifunc
)
Q
(
ffifunc
)
Q
(
fficallback
)
Q
(
fficallback
)
Q
(
ffivar
)
Q
(
ffivar
)
Q
(
as_bytearray
)
Q
(
callback
)
Q
(
func
)
Q
(
func
)
Q
(
var
)
Q
(
var
)
...
...
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