stinos / micropython Goto Github PK
View Code? Open in Web Editor NEWThis project forked from micropython/micropython
The Micro Python project
License: Other
This project forked from micropython/micropython
The Micro Python project
License: Other
Hi,
i have added support in windows port for modffi.
As main mantainer of windows port i want ask you if my implementation is correct/acceptable.
i have added "libffi_msvc" from cffi (https://bitbucket.org/cffi/cffi/src/78ceec56f4dc71de69d175d8b2dee782a2da74b2/c/libffi_msvc/?at=default) and "dlfcn" from (https://github.com/dlfcn-win32/dlfcn-win32) for reuse unix/modffi.c
for do this i have modified:
unix/modffi.c:
MSVC strikes again with C99 non-compliance with varlen arrays, switching to use alloca().
232: mp_obj_t pyargs[cif->nargs]; -> mp_obj_t *pyargs = alloca(sizeof(mp_obj_t)*cif->nargs);
236: mp_obj_t res = mp_call_function_n_kw(MP_OBJ_FROM_PTR(func), cif->nargs, 0, pyargs); -> mp_obj_t res = mp_call_function_n_kw(MP_OBJ_FROM_PTR(func), cif->nargs, 0, *pyargs);
355: ffi_arg values[n_args]; -> ffi_arg *values = alloca(sizeof(ffi_arg)*n_args);
356: void *valueptrs[n_args]; -> void **valueptrs = alloca(sizeof(void *)*n_args);
windows/micropython.vcxproj:
to support "dlfcn"
80: ->
psapi.lib;%(AdditionalDependencies)
84: ->
psapi.lib;%(AdditionalDependencies)
windows/mpconfigport.h:
added:
171: extern const struct _mp_obj_module_t mp_module_ffi;
175: { MP_ROM_QSTR(MP_QSTR_ffi), MP_ROM_PTR(&mp_module_ffi) }, \
windows/paths.props:
31:
windows/sources.props:
added:
8:
14:
38:
Any hint on this?
Regards,
D.
Hi,
I was trying to use your code to load some .so modules on Linux and it works. But I had to make some changes.
You required the .so to expose a function names "init_<module_name>()", which works in the scenario of "import module_name". But in a lot of places people do "from pkg_name import module_name", in this scenario, the mod_name passed in to mp_load_dynlib is actually <pkg_name>.<module_name> which makes init_<mod_name> an invalid C function name.
My workaround was to search for the last "." in mod_name and only used the rest of the string to be the init function name.
I unziped packages. In terminal did:
$cd /unix
$make
After this steps I saw:
$API MP_DECLARE_CONST_FUN_OBJ(mp_identity_obj);
$ ^
$make: *** [build/py/gc.o] Error 1
PS: Sorry for my bad English. I am russian beginer programmist
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.