Closed pmp-p closed 3 years ago
and no i still don't have finished reading documentation yet, but i will try to
thanks for the suggestion, this was my earliest thinking as well, and as far as I can tell several others have tried that ( see \tools\gendoc.py which is part of micropython) but that also will require to (re)build or integrate a multiplatform C pre-processor to deal with all the C prepocessor conditioonals in order to select the correct lines from the sourcefiles. and while that would bee very cool , that is also is a lot of work.
perhaps there is a way to 1) run the precompiler with the correct options ( likely needs a make file as well ) 2) filter for the ^STATIC MP_DEFINE_CONST_FUN_OBJ ' 3) deal with the duplicates 4) attribute that to a specific firmware build
i think the qstr process do all the preprocessing stuff you need but then you do not have access to sources but to a build. if you can have access to a local build then there are more interesting files to get under each port folder the precompiler for qstr is usually the first to be run for all ports Makefile ( and also for mpy-cross the Micropython cross compiler which is native to host )
qstr
files always contains the functions names defined in a port and there are strong reference to where they are extracted from. it's also very consistent beetween all Micropython flavors as it's a key component.
given the number of processors and OSs , there is no such thing as native to all hosts ... and i would not want to take a dependency on all toolchains for all ports ... on all platforms either , lets get started with as simple a solution as can be. can you create a concept script that extracts the relevant information assuming a git clone has been done ? lets pick the network module or any other that you prefer and lets see how far we can get.
i would not want to take a dependency on all toolchains for all ports ... on all platforms either
you only need python2/3 + clang -E that should not be hard to get, no need to full build.
you can have both node and clang packed with emscripten portable SDK which was considered here https://github.com/microsoft/vscode-python/issues/2375 ( could even run with the stubs module in there with some visual display if using micropython wasm )
can you create a concept script that extracts the relevant information assuming a git clone has been done
not at the time, i'm actually more interested in the other way around : parsing python annotations to create C modules headers for people with python abilities who can't write C ( that's why type checking ready-made files were of interest for me )
so what is your suggested approach, emscripten ? I see no benefit to microstubber for any/all micropython sourcecode code to be be transpiled using emscripten ?
What is the expected success ratio for that ? I see quite a few red flags mentionedin https://emscripten.org/docs/porting/guidelines/portability_guidelines.html#code-portability-guidelines
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
From: Paul m. p. P. notifications@github.com Sent: Wednesday, July 10, 2019 10:48:25 PM To: Josverl/micropython-stubber Cc: Jos Verlinde; State change Subject: Re: [Josverl/micropython-stubber] get the number of positionnal arguments or variable (#5)
i would not want to take a dependency on all toolchains for all ports ... on all platforms either
you only need clang -E that should not be hard to get,
you can have both node and clang packed with emscripten portable SDK which was considered here microsoft/vscode-python#2375https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fvscode-python%2Fissues%2F2375&data=02%7C01%7C%7C77e1951d381f4c51c17a08d70577f4bd%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636983885065834136&sdata=WGleaSOW6e2%2B8bgl9ZXMnXcMhPZR1qtUj7fM%2Bw6jlsM%3D&reserved=0 ( could even run mock module in there with some visual display if using micropython wasm )
can you create a concept script that extracts the relevant information assuming a git clone has been done
not i'm actually more interested in the other way around : parsing python annotations to create C modules headers for people with python abilities who can't write C.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FJosverl%2Fmicropython-stubber%2Fissues%2F5%3Femail_source%3Dnotifications%26email_token%3DAAHPVFUP6OXZRF47FBPGTJTP6ZDJTA5CNFSM4H7RY7I2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZUWGHI%23issuecomment-510223133&data=02%7C01%7C%7C77e1951d381f4c51c17a08d70577f4bd%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636983885065844147&sdata=admt0zB1AXdzpKTVi0neGiPlSZUSILstJ0rqZWygHpQ%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAHPVFRUT23F6Y55LWQUIHDP6ZDJTANCNFSM4H7RY7IQ&data=02%7C01%7C%7C77e1951d381f4c51c17a08d70577f4bd%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636983885065854146&sdata=oEGByo2mKMXcmaIYKUwnr8XhC7mumToBdNUnrs64HpY%3D&reserved=0.
no i meant using the emscripten sdk tools for getting hand on a valid preprocessor for all platforms a major platform edit/ after consideration it seems all platforms have either gcc -E or clang -E available.
you can preprocess all ports from the same git source with the included tools and they are easy to install for any platform.
you don't need to build anything at all you just need the intermediate build files which are unrelated to toolchains.
edit/ i spoke too fast, for some ports you need some of the toolchains headers to make $(CPP) happy, but still it's simpler to bundle some files than downloading toolchains for each.
ive tried the c-route, but after considerable work it only got me a very very limited number of module primitives/stubs that were useful by using regex pattern matching.
specifically the matches depend very much on the coding styles and naming conventions used. due to the OSS nature with many authors , and very different tools, i do not think this is worth the effort. partial work in this branch https://github.com/Josverl/micropython-stubber/commits/feat/stub_from_source getfromsource.ps1 script to parse source
these are
following https://github.com/microsoft/pylance-release/issues/3783 i had an idea (won't work on closed source, but who would like to work with a closed source micropython anyway ) ?
Maybe try that way: rgrep ^STATIC MP_DEFINE_CONST_FUN_OBJ on all the source tree
per line you'll have 1) will be name of module * generally py/mod**.c
2) you will get either MP_DEFINE_CONST_FUN_OBJ_x where x is the number of fixed args or MP_DEFINE_CONST_FUN_OBJ_VAR for variable arguments list.
3) you'll get a () couple where the 2nd item is the function name
I guess you are extracting from a live board and according to the example i gave you in the wrong place (sorry for that) you've closed to my nose when i was about to apologize.
you would get :
py/modmicropython.c:STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule);
that means micropython.schedule(arg0, arg1) which is probably better than micropython.schedule()
also that gives name of relevant C source, maybe more can be extracted there eg
rgrep mp_micropython_schedule|grep { |grep -v MP_ROM
could inform that :
micropython.schedule(function, arg)