{"action":"created","comment":{"url":"https://api.github.com/repos/danhedron/openrw/pulls/comments/65820986","id":65820986,"diff_hunk":"@@ -0,0 +1,75 @@\n+import sys\n+import re\n+\n+opcode_names = {};\n+unimplemented_names = {};\n+module_files = sys.argv[1:]\n+scmfile = \"SCM.ini\"\n+methods = []\n+\n+header_template = \"\"\"/*\n+\\tTo implement an opcode, add a function to the correct module file and update\n+\\tthe bindUnimplemented to bindFunction().\n+*/\n+#define bindUnimplemented(opcode, args, func) \\\\\n+\\tbind(opcode, [](const ScriptArguments&) { return false; }, args, #func)\n+\"\"\"\n+\n+\n+\n+# import each existing module file\n+for module in module_files:\n+    with open(module) as f:\n+        for line in f:\n+            m = re.search(\"bindFunction\\(\\s?0x([0-9A-Fa-f]+), ([^0-9][^,]+),\", line)\n+            if m is not None:\n+                opcode = int(m.group(1), 16)\n+                name = m.group(2)\n+                opcode_names[opcode] = name\n+            m = re.search(\"bindUnimplemented\\(\\s?0x([0-9A-Fa-f]+), ([^0-9][^,]+),\", line)\n+            if m is not None:\n+                opcode = int(m.group(1), 16)\n+                name = m.group(2)\n+                unimplemented_names[opcode] = name\n+            m = re.search(\"bindFunction\\(\\s?0x([0-9A-Fa-f]+), (-?\\d+), ([0-9A-Za-z_<>]+)\", line)\n+            if m is not None:\n+                opcode = int(m.group(1), 16)\n+                name = m.group(3)\n+                opcode_names[opcode] = name\n+            m = re.search(\"bindUnimplemented\\(\\s?0x([0-9A-Fa-f]+), (-?\\d+), ([0-9A-Za-z_<>]+)\", line)\n+            if m is not None:\n+                opcode = int(m.group(1), 16)\n+                name = m.group(3)\n+                unimplemented_names[opcode] = name","path":"scripts/generate_script_functions.py","position":43,"original_position":43,"commit_id":"ecc6eca934ca268605621e034aa072c70d1a3fa8","original_commit_id":"ecc6eca934ca268605621e034aa072c70d1a3fa8","user":{"login":"JayFoxRox","id":360330,"avatar_url":"https://avatars.githubusercontent.com/u/360330?v=3","gravatar_id":"","url":"https://api.github.com/users/JayFoxRox","html_url":"https://github.com/JayFoxRox","followers_url":"https://api.github.com/users/JayFoxRox/followers","following_url":"https://api.github.com/users/JayFoxRox/following{/other_user}","gists_url":"https://api.github.com/users/JayFoxRox/gists{/gist_id}","starred_url":"https://api.github.com/users/JayFoxRox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JayFoxRox/subscriptions","organizations_url":"https://api.github.com/users/JayFoxRox/orgs","repos_url":"https://api.github.com/users/JayFoxRox/repos","events_url":"https://api.github.com/users/JayFoxRox/events{/privacy}","received_events_url":"https://api.github.com/users/JayFoxRox/received_events","type":"User","site_admin":false},"body":"Your current solution works for now but I think in the long term searching for implemented opcodes should be done differently or.. not at all.\r\n\r\nGiven that larger SCM.ini changes are highly unlikely in the future we could generate all function names from that.\r\nWe'd then generate all binds (there wouldn't be anything unimplemented) and stubs for all functions (with type from SCM.ini).\r\nIf we want to bind functions to templates we'd do it near the implementation instead of in the bind.\r\n\r\nWe can then simply turn stubs into functions as we see fit.\r\nIn the *highly* unlikely event that there is a major rename / refactoring in the SCM.ini we'd just generate a short-script to search for the stubs which need a rename.\r\n\r\nHaving all stubs ready for implementation also reduces the burden to actually implement a feature. In the long run this will save time. (0x300 opcodes * optimistic 10 seconds to change from bindUnimplemented to a bindFunction and adding a stub with argument parsing:  7680 seconds ~> 2 hours)\r\n\r\nThis means, that as a one-time-solution we need a tool to rename our existing script functions into what SCM.ini would expect AND we need a handful of rules to rename opcodes (such as \"/=\" becoming something like: \"divide_by\" etc.)\r\nWe should also have pseudo data-types such as LocalInteger and GlobalInteger we can use as arguments to the stub.\r\nInformation which is not yet present in SCM.ini should be added by us, possibly in the form as an overlay SCM.ini, patch or seperate file. That could contain information that a certain argument is a local/global/garage/crane/certain type of pickup/.. .\r\nWe could, however, also just cast in the actual implementation functions.","created_at":"2016-06-05T17:31:44Z","updated_at":"2016-06-05T17:31:44Z","html_url":"https://github.com/danhedron/openrw/pull/1#discussion_r65820986","pull_request_url":"https://api.github.com/repos/danhedron/openrw/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/danhedron/openrw/pulls/comments/65820986"},"html":{"href":"https://github.com/danhedron/openrw/pull/1#discussion_r65820986"},"pull_request":{"href":"https://api.github.com/repos/danhedron/openrw/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/danhedron/openrw/pulls/1","id":72634040,"html_url":"https://github.com/danhedron/openrw/pull/1","diff_url":"https://github.com/danhedron/openrw/pull/1.diff","patch_url":"https://github.com/danhedron/openrw/pull/1.patch","issue_url":"https://api.github.com/repos/danhedron/openrw/issues/1","number":1,"state":"open","locked":false,"title":"Feature/generate script functions","user":{"login":"danhedron","id":418211,"avatar_url":"https://avatars.githubusercontent.com/u/418211?v=3","gravatar_id":"","url":"https://api.github.com/users/danhedron","html_url":"https://github.com/danhedron","followers_url":"https://api.github.com/users/danhedron/followers","following_url":"https://api.github.com/users/danhedron/following{/other_user}","gists_url":"https://api.github.com/users/danhedron/gists{/gist_id}","starred_url":"https://api.github.com/users/danhedron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhedron/subscriptions","organizations_url":"https://api.github.com/users/danhedron/orgs","repos_url":"https://api.github.com/users/danhedron/repos","events_url":"https://api.github.com/users/danhedron/events{/privacy}","received_events_url":"https://api.github.com/users/danhedron/received_events","type":"User","site_admin":false},"body":"This moves all of the bind() calls into a single GTA3 Module, so that the implementation file only contains the actual functions themselves. The old calls are currently disabled by pre-processor, they need to be removed entirely before merging.\r\n\r\nThe included script can re-generate the file from a list of opcodes and the names in the existing bindFunction/bindUnimplemented calls.","created_at":"2016-06-05T16:43:35Z","updated_at":"2016-06-05T17:31:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fd763f1b2aa75231caeeb0d8e6aea595e1c57e3b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/danhedron/openrw/pulls/1/commits","review_comments_url":"https://api.github.com/repos/danhedron/openrw/pulls/1/comments","review_comment_url":"https://api.github.com/repos/danhedron/openrw/pulls/comments{/number}","comments_url":"https://api.github.com/repos/danhedron/openrw/issues/1/comments","statuses_url":"https://api.github.com/repos/danhedron/openrw/statuses/ecc6eca934ca268605621e034aa072c70d1a3fa8","head":{"label":"danhedron:feature/generate-script-functions","ref":"feature/generate-script-functions","sha":"ecc6eca934ca268605621e034aa072c70d1a3fa8","user":{"login":"danhedron","id":418211,"avatar_url":"https://avatars.githubusercontent.com/u/418211?v=3","gravatar_id":"","url":"https://api.github.com/users/danhedron","html_url":"https://github.com/danhedron","followers_url":"https://api.github.com/users/danhedron/followers","following_url":"https://api.github.com/users/danhedron/following{/other_user}","gists_url":"https://api.github.com/users/danhedron/gists{/gist_id}","starred_url":"https://api.github.com/users/danhedron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhedron/subscriptions","organizations_url":"https://api.github.com/users/danhedron/orgs","repos_url":"https://api.github.com/users/danhedron/repos","events_url":"https://api.github.com/users/danhedron/events{/privacy}","received_events_url":"https://api.github.com/users/danhedron/received_events","type":"User","site_admin":false},"repo":{"id":60128563,"name":"openrw","full_name":"danhedron/openrw","owner":{"login":"danhedron","id":418211,"avatar_url":"https://avatars.githubusercontent.com/u/418211?v=3","gravatar_id":"","url":"https://api.github.com/users/danhedron","html_url":"https://github.com/danhedron","followers_url":"https://api.github.com/users/danhedron/followers","following_url":"https://api.github.com/users/danhedron/following{/other_user}","gists_url":"https://api.github.com/users/danhedron/gists{/gist_id}","starred_url":"https://api.github.com/users/danhedron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhedron/subscriptions","organizations_url":"https://api.github.com/users/danhedron/orgs","repos_url":"https://api.github.com/users/danhedron/repos","events_url":"https://api.github.com/users/danhedron/events{/privacy}","received_events_url":"https://api.github.com/users/danhedron/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danhedron/openrw","description":"OpenRW \"Open ReWrite\" is an un-official open source recreation of the classic Grand Theft Auto III game executable","fork":true,"url":"https://api.github.com/repos/danhedron/openrw","forks_url":"https://api.github.com/repos/danhedron/openrw/forks","keys_url":"https://api.github.com/repos/danhedron/openrw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danhedron/openrw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danhedron/openrw/teams","hooks_url":"https://api.github.com/repos/danhedron/openrw/hooks","issue_events_url":"https://api.github.com/repos/danhedron/openrw/issues/events{/number}","events_url":"https://api.github.com/repos/danhedron/openrw/events","assignees_url":"https://api.github.com/repos/danhedron/openrw/assignees{/user}","branches_url":"https://api.github.com/repos/danhedron/openrw/branches{/branch}","tags_url":"https://api.github.com/repos/danhedron/openrw/tags","blobs_url":"https://api.github.com/repos/danhedron/openrw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danhedron/openrw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danhedron/openrw/git/refs{/sha}","trees_url":"https://api.github.com/repos/danhedron/openrw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danhedron/openrw/statuses/{sha}","languages_url":"https://api.github.com/repos/danhedron/openrw/languages","stargazers_url":"https://api.github.com/repos/danhedron/openrw/stargazers","contributors_url":"https://api.github.com/repos/danhedron/openrw/contributors","subscribers_url":"https://api.github.com/repos/danhedron/openrw/subscribers","subscription_url":"https://api.github.com/repos/danhedron/openrw/subscription","commits_url":"https://api.github.com/repos/danhedron/openrw/commits{/sha}","git_commits_url":"https://api.github.com/repos/danhedron/openrw/git/commits{/sha}","comments_url":"https://api.github.com/repos/danhedron/openrw/comments{/number}","issue_comment_url":"https://api.github.com/repos/danhedron/openrw/issues/comments{/number}","contents_url":"https://api.github.com/repos/danhedron/openrw/contents/{+path}","compare_url":"https://api.github.com/repos/danhedron/openrw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danhedron/openrw/merges","archive_url":"https://api.github.com/repos/danhedron/openrw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danhedron/openrw/downloads","issues_url":"https://api.github.com/repos/danhedron/openrw/issues{/number}","pulls_url":"https://api.github.com/repos/danhedron/openrw/pulls{/number}","milestones_url":"https://api.github.com/repos/danhedron/openrw/milestones{/number}","notifications_url":"https://api.github.com/repos/danhedron/openrw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danhedron/openrw/labels{/name}","releases_url":"https://api.github.com/repos/danhedron/openrw/releases{/id}","deployments_url":"https://api.github.com/repos/danhedron/openrw/deployments","created_at":"2016-05-31T22:42:25Z","updated_at":"2016-06-02T16:37:13Z","pushed_at":"2016-06-05T17:22:52Z","git_url":"git://github.com/danhedron/openrw.git","ssh_url":"git@github.com:danhedron/openrw.git","clone_url":"https://github.com/danhedron/openrw.git","svn_url":"https://github.com/danhedron/openrw","homepage":"https://github.com/rwengine/openrw","size":1669,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"base":{"label":"danhedron:master","ref":"master","sha":"d4599f4931453c8624abd01eeba9a98ff8462353","user":{"login":"danhedron","id":418211,"avatar_url":"https://avatars.githubusercontent.com/u/418211?v=3","gravatar_id":"","url":"https://api.github.com/users/danhedron","html_url":"https://github.com/danhedron","followers_url":"https://api.github.com/users/danhedron/followers","following_url":"https://api.github.com/users/danhedron/following{/other_user}","gists_url":"https://api.github.com/users/danhedron/gists{/gist_id}","starred_url":"https://api.github.com/users/danhedron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhedron/subscriptions","organizations_url":"https://api.github.com/users/danhedron/orgs","repos_url":"https://api.github.com/users/danhedron/repos","events_url":"https://api.github.com/users/danhedron/events{/privacy}","received_events_url":"https://api.github.com/users/danhedron/received_events","type":"User","site_admin":false},"repo":{"id":60128563,"name":"openrw","full_name":"danhedron/openrw","owner":{"login":"danhedron","id":418211,"avatar_url":"https://avatars.githubusercontent.com/u/418211?v=3","gravatar_id":"","url":"https://api.github.com/users/danhedron","html_url":"https://github.com/danhedron","followers_url":"https://api.github.com/users/danhedron/followers","following_url":"https://api.github.com/users/danhedron/following{/other_user}","gists_url":"https://api.github.com/users/danhedron/gists{/gist_id}","starred_url":"https://api.github.com/users/danhedron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhedron/subscriptions","organizations_url":"https://api.github.com/users/danhedron/orgs","repos_url":"https://api.github.com/users/danhedron/repos","events_url":"https://api.github.com/users/danhedron/events{/privacy}","received_events_url":"https://api.github.com/users/danhedron/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danhedron/openrw","description":"OpenRW \"Open ReWrite\" is an un-official open source recreation of the classic Grand Theft Auto III game executable","fork":true,"url":"https://api.github.com/repos/danhedron/openrw","forks_url":"https://api.github.com/repos/danhedron/openrw/forks","keys_url":"https://api.github.com/repos/danhedron/openrw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danhedron/openrw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danhedron/openrw/teams","hooks_url":"https://api.github.com/repos/danhedron/openrw/hooks","issue_events_url":"https://api.github.com/repos/danhedron/openrw/issues/events{/number}","events_url":"https://api.github.com/repos/danhedron/openrw/events","assignees_url":"https://api.github.com/repos/danhedron/openrw/assignees{/user}","branches_url":"https://api.github.com/repos/danhedron/openrw/branches{/branch}","tags_url":"https://api.github.com/repos/danhedron/openrw/tags","blobs_url":"https://api.github.com/repos/danhedron/openrw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danhedron/openrw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danhedron/openrw/git/refs{/sha}","trees_url":"https://api.github.com/repos/danhedron/openrw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danhedron/openrw/statuses/{sha}","languages_url":"https://api.github.com/repos/danhedron/openrw/languages","stargazers_url":"https://api.github.com/repos/danhedron/openrw/stargazers","contributors_url":"https://api.github.com/repos/danhedron/openrw/contributors","subscribers_url":"https://api.github.com/repos/danhedron/openrw/subscribers","subscription_url":"https://api.github.com/repos/danhedron/openrw/subscription","commits_url":"https://api.github.com/repos/danhedron/openrw/commits{/sha}","git_commits_url":"https://api.github.com/repos/danhedron/openrw/git/commits{/sha}","comments_url":"https://api.github.com/repos/danhedron/openrw/comments{/number}","issue_comment_url":"https://api.github.com/repos/danhedron/openrw/issues/comments{/number}","contents_url":"https://api.github.com/repos/danhedron/openrw/contents/{+path}","compare_url":"https://api.github.com/repos/danhedron/openrw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danhedron/openrw/merges","archive_url":"https://api.github.com/repos/danhedron/openrw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danhedron/openrw/downloads","issues_url":"https://api.github.com/repos/danhedron/openrw/issues{/number}","pulls_url":"https://api.github.com/repos/danhedron/openrw/pulls{/number}","milestones_url":"https://api.github.com/repos/danhedron/openrw/milestones{/number}","notifications_url":"https://api.github.com/repos/danhedron/openrw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danhedron/openrw/labels{/name}","releases_url":"https://api.github.com/repos/danhedron/openrw/releases{/id}","deployments_url":"https://api.github.com/repos/danhedron/openrw/deployments","created_at":"2016-05-31T22:42:25Z","updated_at":"2016-06-02T16:37:13Z","pushed_at":"2016-06-05T17:22:52Z","git_url":"git://github.com/danhedron/openrw.git","ssh_url":"git@github.com:danhedron/openrw.git","clone_url":"https://github.com/danhedron/openrw.git","svn_url":"https://github.com/danhedron/openrw","homepage":"https://github.com/rwengine/openrw","size":1669,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/danhedron/openrw/pulls/1"},"html":{"href":"https://github.com/danhedron/openrw/pull/1"},"issue":{"href":"https://api.github.com/repos/danhedron/openrw/issues/1"},"comments":{"href":"https://api.github.com/repos/danhedron/openrw/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/danhedron/openrw/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/danhedron/openrw/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/danhedron/openrw/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/danhedron/openrw/statuses/ecc6eca934ca268605621e034aa072c70d1a3fa8"}}}}
{"actor":{"display_login":"JayFoxRox"}}