{"action":"created","comment":{"url":"https://api.github.com/repos/micropython/micropython/pulls/comments/230691208","pull_request_review_id":171482383,"id":230691208,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMDY5MTIwOA==","diff_hunk":"@@ -0,0 +1,106 @@\n+#!/usr/bin/env python\n+\n+# This pre-processor parses provided objects' c files for \n+# `MP_REGISTER_MODULE(module_name, obj_module, enabled_define)`\n+# These are used to generate a header with the required entries for \n+# `mp_rom_map_elem_t mp_builtin_module_table[]` in py/objmodule.c\n+\n+from __future__ import print_function\n+\n+import re\n+import os\n+import argparse\n+\n+\n+def find_c_file(vpath, obj_file):\n+    \"\"\"\n+    Search the provided vpaths for the c file that matches the provided object_file","path":"py/makemoduledefs.py","position":17,"original_position":17,"commit_id":"5e87dcadb7bf51295e03d2a9465d0afc52482f34","original_commit_id":"5e87dcadb7bf51295e03d2a9465d0afc52482f34","user":{"login":"stinos","id":1902997,"node_id":"MDQ6VXNlcjE5MDI5OTc=","avatar_url":"https://avatars3.githubusercontent.com/u/1902997?v=4","gravatar_id":"","url":"https://api.github.com/users/stinos","html_url":"https://github.com/stinos","followers_url":"https://api.github.com/users/stinos/followers","following_url":"https://api.github.com/users/stinos/following{/other_user}","gists_url":"https://api.github.com/users/stinos/gists{/gist_id}","starred_url":"https://api.github.com/users/stinos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stinos/subscriptions","organizations_url":"https://api.github.com/users/stinos/orgs","repos_url":"https://api.github.com/users/stinos/repos","events_url":"https://api.github.com/users/stinos/events{/privacy}","received_events_url":"https://api.github.com/users/stinos/received_events","type":"User","site_admin":false},"body":"Shouldn't docstring style be something more standard like\r\n```\r\n\"\"\" Short description which ends with period.\r\n\r\nRest of description\r\n\"\"\"\r\n\r\nor\r\n\r\n```\r\n\"\"\"  Short description which ends with period. \"\"\"\r\n```\r\n\r\nJust checking, don't know if this is set in stone somewhere for uPy.","created_at":"2018-11-05T10:02:07Z","updated_at":"2018-11-05T10:02:08Z","html_url":"https://github.com/micropython/micropython/pull/4289#discussion_r230691208","pull_request_url":"https://api.github.com/repos/micropython/micropython/pulls/4289","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/micropython/micropython/pulls/comments/230691208"},"html":{"href":"https://github.com/micropython/micropython/pull/4289#discussion_r230691208"},"pull_request":{"href":"https://api.github.com/repos/micropython/micropython/pulls/4289"}}},"pull_request":{"url":"https://api.github.com/repos/micropython/micropython/pulls/4289","id":228104082,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI4MTA0MDgy","html_url":"https://github.com/micropython/micropython/pull/4289","diff_url":"https://github.com/micropython/micropython/pull/4289.diff","patch_url":"https://github.com/micropython/micropython/pull/4289.patch","issue_url":"https://api.github.com/repos/micropython/micropython/issues/4289","number":4289,"state":"open","locked":false,"title":"RFC: Allow registration of modules at their definition.","user":{"login":"andrewleech","id":3318786,"node_id":"MDQ6VXNlcjMzMTg3ODY=","avatar_url":"https://avatars0.githubusercontent.com/u/3318786?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewleech","html_url":"https://github.com/andrewleech","followers_url":"https://api.github.com/users/andrewleech/followers","following_url":"https://api.github.com/users/andrewleech/following{/other_user}","gists_url":"https://api.github.com/users/andrewleech/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewleech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewleech/subscriptions","organizations_url":"https://api.github.com/users/andrewleech/orgs","repos_url":"https://api.github.com/users/andrewleech/repos","events_url":"https://api.github.com/users/andrewleech/events{/privacy}","received_events_url":"https://api.github.com/users/andrewleech/received_events","type":"User","site_admin":false},"body":"The current method of adding a new builtin/global modules is to have the module object defined in the c file for said module, but the python module name and matching `#define` enable guard defined in the central `objmodule.c` file.\r\n\r\nThis PR provides a mechanism for moving this name and guard definition to the actual module file, removing the need to edit the `objmodule.c` file whenever you want to add a new module.\r\n\r\nThere is sort of fake macro provided `MP_REGISTER_MODULE(name, obj, enabled)` for use where modules are being defined.\r\n\r\nThese are parsed by the included python script during make (not the c the preprocessor) to generate the header of required entries in the builtins modules list in `objmodule.c`\r\n\r\nThis was originally written to replace my json based method of declaring modules in #4195 but I think it could have wider appeal across the micropython codebase.\r\n\r\nIf you're interested in this system, I'm happy to replace the other existing module definitions with the \"macro\", similar to the array one I've used as reference. I'll also update my cmodule branch to suit.\r\n\r\nI'd also like to see a similar system used for module init (early and late) and de-init functions, so that modules can themselves declare the functions needed for their set up or tear down in `main.c` rather than having to maintain such a list of functions manually in all the separate ports main files. There could be some added complexity there with regard to dependencies and ordering, but that's a separate issue to this PR.","created_at":"2018-11-03T07:05:44Z","updated_at":"2018-11-05T10:02:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e6662de6d3d10585fdc3cc6bdf3326926111c1e7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/micropython/micropython/pulls/4289/commits","review_comments_url":"https://api.github.com/repos/micropython/micropython/pulls/4289/comments","review_comment_url":"https://api.github.com/repos/micropython/micropython/pulls/comments{/number}","comments_url":"https://api.github.com/repos/micropython/micropython/issues/4289/comments","statuses_url":"https://api.github.com/repos/micropython/micropython/statuses/5e87dcadb7bf51295e03d2a9465d0afc52482f34","head":{"label":"andrewleech:module_registration","ref":"module_registration","sha":"5e87dcadb7bf51295e03d2a9465d0afc52482f34","user":{"login":"andrewleech","id":3318786,"node_id":"MDQ6VXNlcjMzMTg3ODY=","avatar_url":"https://avatars0.githubusercontent.com/u/3318786?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewleech","html_url":"https://github.com/andrewleech","followers_url":"https://api.github.com/users/andrewleech/followers","following_url":"https://api.github.com/users/andrewleech/following{/other_user}","gists_url":"https://api.github.com/users/andrewleech/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewleech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewleech/subscriptions","organizations_url":"https://api.github.com/users/andrewleech/orgs","repos_url":"https://api.github.com/users/andrewleech/repos","events_url":"https://api.github.com/users/andrewleech/events{/privacy}","received_events_url":"https://api.github.com/users/andrewleech/received_events","type":"User","site_admin":false},"repo":{"id":134820485,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQ4MjA0ODU=","name":"micropython","full_name":"andrewleech/micropython","private":false,"owner":{"login":"andrewleech","id":3318786,"node_id":"MDQ6VXNlcjMzMTg3ODY=","avatar_url":"https://avatars0.githubusercontent.com/u/3318786?v=4","gravatar_id":"","url":"https://api.github.com/users/andrewleech","html_url":"https://github.com/andrewleech","followers_url":"https://api.github.com/users/andrewleech/followers","following_url":"https://api.github.com/users/andrewleech/following{/other_user}","gists_url":"https://api.github.com/users/andrewleech/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewleech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewleech/subscriptions","organizations_url":"https://api.github.com/users/andrewleech/orgs","repos_url":"https://api.github.com/users/andrewleech/repos","events_url":"https://api.github.com/users/andrewleech/events{/privacy}","received_events_url":"https://api.github.com/users/andrewleech/received_events","type":"User","site_admin":false},"html_url":"https://github.com/andrewleech/micropython","description":"MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems","fork":true,"url":"https://api.github.com/repos/andrewleech/micropython","forks_url":"https://api.github.com/repos/andrewleech/micropython/forks","keys_url":"https://api.github.com/repos/andrewleech/micropython/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andrewleech/micropython/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andrewleech/micropython/teams","hooks_url":"https://api.github.com/repos/andrewleech/micropython/hooks","issue_events_url":"https://api.github.com/repos/andrewleech/micropython/issues/events{/number}","events_url":"https://api.github.com/repos/andrewleech/micropython/events","assignees_url":"https://api.github.com/repos/andrewleech/micropython/assignees{/user}","branches_url":"https://api.github.com/repos/andrewleech/micropython/branches{/branch}","tags_url":"https://api.github.com/repos/andrewleech/micropython/tags","blobs_url":"https://api.github.com/repos/andrewleech/micropython/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andrewleech/micropython/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andrewleech/micropython/git/refs{/sha}","trees_url":"https://api.github.com/repos/andrewleech/micropython/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andrewleech/micropython/statuses/{sha}","languages_url":"https://api.github.com/repos/andrewleech/micropython/languages","stargazers_url":"https://api.github.com/repos/andrewleech/micropython/stargazers","contributors_url":"https://api.github.com/repos/andrewleech/micropython/contributors","subscribers_url":"https://api.github.com/repos/andrewleech/micropython/subscribers","subscription_url":"https://api.github.com/repos/andrewleech/micropython/subscription","commits_url":"https://api.github.com/repos/andrewleech/micropython/commits{/sha}","git_commits_url":"https://api.github.com/repos/andrewleech/micropython/git/commits{/sha}","comments_url":"https://api.github.com/repos/andrewleech/micropython/comments{/number}","issue_comment_url":"https://api.github.com/repos/andrewleech/micropython/issues/comments{/number}","contents_url":"https://api.github.com/repos/andrewleech/micropython/contents/{+path}","compare_url":"https://api.github.com/repos/andrewleech/micropython/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andrewleech/micropython/merges","archive_url":"https://api.github.com/repos/andrewleech/micropython/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andrewleech/micropython/downloads","issues_url":"https://api.github.com/repos/andrewleech/micropython/issues{/number}","pulls_url":"https://api.github.com/repos/andrewleech/micropython/pulls{/number}","milestones_url":"https://api.github.com/repos/andrewleech/micropython/milestones{/number}","notifications_url":"https://api.github.com/repos/andrewleech/micropython/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andrewleech/micropython/labels{/name}","releases_url":"https://api.github.com/repos/andrewleech/micropython/releases{/id}","deployments_url":"https://api.github.com/repos/andrewleech/micropython/deployments","created_at":"2018-05-25T07:34:03Z","updated_at":"2018-09-25T20:25:22Z","pushed_at":"2018-11-04T03:33:33Z","git_url":"git://github.com/andrewleech/micropython.git","ssh_url":"git@github.com:andrewleech/micropython.git","clone_url":"https://github.com/andrewleech/micropython.git","svn_url":"https://github.com/andrewleech/micropython","homepage":"https://micropython.org","size":37352,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"micropython:master","ref":"master","sha":"d94aa577a65c10e7fe2e7ce5021b79fb30a03274","user":{"login":"micropython","id":6298560,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYyOTg1NjA=","avatar_url":"https://avatars1.githubusercontent.com/u/6298560?v=4","gravatar_id":"","url":"https://api.github.com/users/micropython","html_url":"https://github.com/micropython","followers_url":"https://api.github.com/users/micropython/followers","following_url":"https://api.github.com/users/micropython/following{/other_user}","gists_url":"https://api.github.com/users/micropython/gists{/gist_id}","starred_url":"https://api.github.com/users/micropython/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micropython/subscriptions","organizations_url":"https://api.github.com/users/micropython/orgs","repos_url":"https://api.github.com/users/micropython/repos","events_url":"https://api.github.com/users/micropython/events{/privacy}","received_events_url":"https://api.github.com/users/micropython/received_events","type":"Organization","site_admin":false},"repo":{"id":15337142,"node_id":"MDEwOlJlcG9zaXRvcnkxNTMzNzE0Mg==","name":"micropython","full_name":"micropython/micropython","private":false,"owner":{"login":"micropython","id":6298560,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYyOTg1NjA=","avatar_url":"https://avatars1.githubusercontent.com/u/6298560?v=4","gravatar_id":"","url":"https://api.github.com/users/micropython","html_url":"https://github.com/micropython","followers_url":"https://api.github.com/users/micropython/followers","following_url":"https://api.github.com/users/micropython/following{/other_user}","gists_url":"https://api.github.com/users/micropython/gists{/gist_id}","starred_url":"https://api.github.com/users/micropython/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micropython/subscriptions","organizations_url":"https://api.github.com/users/micropython/orgs","repos_url":"https://api.github.com/users/micropython/repos","events_url":"https://api.github.com/users/micropython/events{/privacy}","received_events_url":"https://api.github.com/users/micropython/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/micropython/micropython","description":"MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems","fork":false,"url":"https://api.github.com/repos/micropython/micropython","forks_url":"https://api.github.com/repos/micropython/micropython/forks","keys_url":"https://api.github.com/repos/micropython/micropython/keys{/key_id}","collaborators_url":"https://api.github.com/repos/micropython/micropython/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/micropython/micropython/teams","hooks_url":"https://api.github.com/repos/micropython/micropython/hooks","issue_events_url":"https://api.github.com/repos/micropython/micropython/issues/events{/number}","events_url":"https://api.github.com/repos/micropython/micropython/events","assignees_url":"https://api.github.com/repos/micropython/micropython/assignees{/user}","branches_url":"https://api.github.com/repos/micropython/micropython/branches{/branch}","tags_url":"https://api.github.com/repos/micropython/micropython/tags","blobs_url":"https://api.github.com/repos/micropython/micropython/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/micropython/micropython/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/micropython/micropython/git/refs{/sha}","trees_url":"https://api.github.com/repos/micropython/micropython/git/trees{/sha}","statuses_url":"https://api.github.com/repos/micropython/micropython/statuses/{sha}","languages_url":"https://api.github.com/repos/micropython/micropython/languages","stargazers_url":"https://api.github.com/repos/micropython/micropython/stargazers","contributors_url":"https://api.github.com/repos/micropython/micropython/contributors","subscribers_url":"https://api.github.com/repos/micropython/micropython/subscribers","subscription_url":"https://api.github.com/repos/micropython/micropython/subscription","commits_url":"https://api.github.com/repos/micropython/micropython/commits{/sha}","git_commits_url":"https://api.github.com/repos/micropython/micropython/git/commits{/sha}","comments_url":"https://api.github.com/repos/micropython/micropython/comments{/number}","issue_comment_url":"https://api.github.com/repos/micropython/micropython/issues/comments{/number}","contents_url":"https://api.github.com/repos/micropython/micropython/contents/{+path}","compare_url":"https://api.github.com/repos/micropython/micropython/compare/{base}...{head}","merges_url":"https://api.github.com/repos/micropython/micropython/merges","archive_url":"https://api.github.com/repos/micropython/micropython/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/micropython/micropython/downloads","issues_url":"https://api.github.com/repos/micropython/micropython/issues{/number}","pulls_url":"https://api.github.com/repos/micropython/micropython/pulls{/number}","milestones_url":"https://api.github.com/repos/micropython/micropython/milestones{/number}","notifications_url":"https://api.github.com/repos/micropython/micropython/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/micropython/micropython/labels{/name}","releases_url":"https://api.github.com/repos/micropython/micropython/releases{/id}","deployments_url":"https://api.github.com/repos/micropython/micropython/deployments","created_at":"2013-12-20T11:47:07Z","updated_at":"2018-11-05T05:17:47Z","pushed_at":"2018-11-05T08:47:03Z","git_url":"git://github.com/micropython/micropython.git","ssh_url":"git@github.com:micropython/micropython.git","clone_url":"https://github.com/micropython/micropython.git","svn_url":"https://github.com/micropython/micropython","homepage":"https://micropython.org","size":37258,"stargazers_count":7348,"watchers_count":7348,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2061,"mirror_url":null,"archived":false,"open_issues_count":684,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":2061,"open_issues":684,"watchers":7348,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/micropython/micropython/pulls/4289"},"html":{"href":"https://github.com/micropython/micropython/pull/4289"},"issue":{"href":"https://api.github.com/repos/micropython/micropython/issues/4289"},"comments":{"href":"https://api.github.com/repos/micropython/micropython/issues/4289/comments"},"review_comments":{"href":"https://api.github.com/repos/micropython/micropython/pulls/4289/comments"},"review_comment":{"href":"https://api.github.com/repos/micropython/micropython/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/micropython/micropython/pulls/4289/commits"},"statuses":{"href":"https://api.github.com/repos/micropython/micropython/statuses/5e87dcadb7bf51295e03d2a9465d0afc52482f34"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"stinos"}}