{"action":"opened","number":512,"pull_request":{"url":"https://api.github.com/repos/Hammerspoon/hammerspoon/pulls/512","id":42988113,"html_url":"https://github.com/Hammerspoon/hammerspoon/pull/512","diff_url":"https://github.com/Hammerspoon/hammerspoon/pull/512.diff","patch_url":"https://github.com/Hammerspoon/hammerspoon/pull/512.patch","issue_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/512","number":512,"state":"open","locked":false,"title":"WIP NSObject->Lua conversion in LuaSkin","user":{"login":"asmagill","id":8139480,"avatar_url":"https://avatars.githubusercontent.com/u/8139480?v=3","gravatar_id":"","url":"https://api.github.com/users/asmagill","html_url":"https://github.com/asmagill","followers_url":"https://api.github.com/users/asmagill/followers","following_url":"https://api.github.com/users/asmagill/following{/other_user}","gists_url":"https://api.github.com/users/asmagill/gists{/gist_id}","starred_url":"https://api.github.com/users/asmagill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmagill/subscriptions","organizations_url":"https://api.github.com/users/asmagill/orgs","repos_url":"https://api.github.com/users/asmagill/repos","events_url":"https://api.github.com/users/asmagill/events{/privacy}","received_events_url":"https://api.github.com/users/asmagill/received_events","type":"User","site_admin":false},"body":"This is a work in progress and should not be considered for inclusion in core at this time.  I am creating this pull for comments and questions for the brave who want to check it out  😛\r\n\r\n@cmsj - is there a reference guide for the commenting style you're using in LuaSkin?  I'd like to make mine match, but haven't really looked that closely at it yet.\r\n\r\nContains:\r\n* NSObject to Lua Conversion (actual converters return an int - it should always be 1, but this allows these to be used as `return [skin push...]` in your own module functions.)\r\n\r\n  * [x] `(int) [skin pushNSObject:obj]`\r\n    Takes an arbitrary NSObject and checks registered helpers, then the defaults for a class match and uses the appropriate method to convert the object into its Lua representation.\r\n    \r\n  * [ ] `(int) [skin pushNSObject:obj withLocalHelpers:fnList ]`\r\n    Takes an arbitrary NSObject and checks a run-time supplied list of conversion functions, then the registered helpers, then the defaults for a class match and uses the appropriate method to convert the object into its Lua representation.  This method allows a module which knows its data might match another converter to override it for this specific call only if special needs apply.\r\n    \r\n  * [x] `(void) [skin registerPushNSHelper:helperFN forClass:className]`\r\n    registers a c-function to handle conversion for NSObject types which are used within a module.  See the example in hs.application which allows NSRunningApplication objects to be converted to a hs.application userdata for use within Hammerspoon.\r\n    \r\n  * [x] `(void) [skin unregisterPushNSHelperForClass:className]`\r\n    un-registers a c-function and removes it from the list of registered converters.\r\n\r\n    * Default Converters (in order)   \r\n      * [x] `(int) [skin pushNSNull:obj]`\r\n    Converts [NSNull null] to lua's nil\r\n    \r\n      * [x] `(int) [skin pushNSNumber:obj]`\r\n    Converts [NSNumber] to lua number or integer as appropriate.\r\n    \r\n      * [x] `(int) [skin pushNSString:obj]`\r\n    Converts [NSString] to a UTF8 representation in a lua string.\r\n    \r\n      * [x] `(int) [skin pushNSData:obj]`\r\n    Converts [NSData] to a byte-by-byte copy as a lua string (note that this probably won't print to the console properly, but can be manipulated as binary data)\r\n    \r\n      * [x] `(int) [skin pushNSDate:obj]`\r\n    Converts [NSDate] to an integer useable with os.date() in lua.\r\n    \r\n      * [x] `(int) [skin pushNSArray:obj]`\r\n    Converts [NSArray] into a lua table.  Recursively calls pushNSObject: on its contents.\r\n    \r\n      * [x] `(int) [skin pushNSSet:obj]`\r\n    Converts [NSSet] into a lua table.  Recursively calls pushNSObject: on its contents.\r\n\r\n      * [x] `(int) [skin pushNSDictionary:obj]`\r\n    Converts [NSDictionary] into a lua table.  Recursively calls pushNSObject: on its keys and contents.\r\n\r\n      * [x] `(int) [skin pushNSUnknown:obj]`\r\n    Final check -- catches [NSObject] (which should be any NS type) and returns its string representation as %@ would in NSLog.\r\n\r\n* Lua to NSObject Conversion\r\n\r\n    *not in LuaSkin yet*\r\n\r\n* Known Limitations and Issues\r\n\r\n  * in registerPushNSHelper:forClass:, if a class converter exists, it is overwritten.  Should this raise an error?\r\n  \r\n  * in registerPushNSHelper:forClass:, converters are stored in a NSDictionary, so order is not guaranteed.  This means that an object that might match more than one class will be handled by whichever one is found first, and that might change from invocation to invocation.  If changed to an array, then order would be based upon which order modules are loaded into Lua, and even this can be non-deterministic.  Suggestions?  Wait and see if it bites us and deal with it then?\r\n  \r\n  * Does not handle loops (e.g. a NSDictionary in which one of its objects is itself)... nor is there currently a maximum depth for recursion. Looking into options here because this does need to be addressed before including in core.\r\n\r\n\r\nAny other thoughts or suggestions or questions, go ahead and put in here as well.","created_at":"2015-08-20T22:58:15Z","updated_at":"2015-08-20T22:58:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/pulls/512/commits","review_comments_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/pulls/512/comments","review_comment_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/512/comments","statuses_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/statuses/8ed7527a9c031e6f528783cdd8bd5ed6048d733b","head":{"label":"asmagill:NS2lua","ref":"NS2lua","sha":"8ed7527a9c031e6f528783cdd8bd5ed6048d733b","user":{"login":"asmagill","id":8139480,"avatar_url":"https://avatars.githubusercontent.com/u/8139480?v=3","gravatar_id":"","url":"https://api.github.com/users/asmagill","html_url":"https://github.com/asmagill","followers_url":"https://api.github.com/users/asmagill/followers","following_url":"https://api.github.com/users/asmagill/following{/other_user}","gists_url":"https://api.github.com/users/asmagill/gists{/gist_id}","starred_url":"https://api.github.com/users/asmagill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmagill/subscriptions","organizations_url":"https://api.github.com/users/asmagill/orgs","repos_url":"https://api.github.com/users/asmagill/repos","events_url":"https://api.github.com/users/asmagill/events{/privacy}","received_events_url":"https://api.github.com/users/asmagill/received_events","type":"User","site_admin":false},"repo":{"id":34886150,"name":"hammerspoon","full_name":"asmagill/hammerspoon","owner":{"login":"asmagill","id":8139480,"avatar_url":"https://avatars.githubusercontent.com/u/8139480?v=3","gravatar_id":"","url":"https://api.github.com/users/asmagill","html_url":"https://github.com/asmagill","followers_url":"https://api.github.com/users/asmagill/followers","following_url":"https://api.github.com/users/asmagill/following{/other_user}","gists_url":"https://api.github.com/users/asmagill/gists{/gist_id}","starred_url":"https://api.github.com/users/asmagill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmagill/subscriptions","organizations_url":"https://api.github.com/users/asmagill/orgs","repos_url":"https://api.github.com/users/asmagill/repos","events_url":"https://api.github.com/users/asmagill/events{/privacy}","received_events_url":"https://api.github.com/users/asmagill/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/asmagill/hammerspoon","description":"Staggeringly powerful OS X desktop automation with Lua","fork":true,"url":"https://api.github.com/repos/asmagill/hammerspoon","forks_url":"https://api.github.com/repos/asmagill/hammerspoon/forks","keys_url":"https://api.github.com/repos/asmagill/hammerspoon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asmagill/hammerspoon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asmagill/hammerspoon/teams","hooks_url":"https://api.github.com/repos/asmagill/hammerspoon/hooks","issue_events_url":"https://api.github.com/repos/asmagill/hammerspoon/issues/events{/number}","events_url":"https://api.github.com/repos/asmagill/hammerspoon/events","assignees_url":"https://api.github.com/repos/asmagill/hammerspoon/assignees{/user}","branches_url":"https://api.github.com/repos/asmagill/hammerspoon/branches{/branch}","tags_url":"https://api.github.com/repos/asmagill/hammerspoon/tags","blobs_url":"https://api.github.com/repos/asmagill/hammerspoon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asmagill/hammerspoon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asmagill/hammerspoon/git/refs{/sha}","trees_url":"https://api.github.com/repos/asmagill/hammerspoon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asmagill/hammerspoon/statuses/{sha}","languages_url":"https://api.github.com/repos/asmagill/hammerspoon/languages","stargazers_url":"https://api.github.com/repos/asmagill/hammerspoon/stargazers","contributors_url":"https://api.github.com/repos/asmagill/hammerspoon/contributors","subscribers_url":"https://api.github.com/repos/asmagill/hammerspoon/subscribers","subscription_url":"https://api.github.com/repos/asmagill/hammerspoon/subscription","commits_url":"https://api.github.com/repos/asmagill/hammerspoon/commits{/sha}","git_commits_url":"https://api.github.com/repos/asmagill/hammerspoon/git/commits{/sha}","comments_url":"https://api.github.com/repos/asmagill/hammerspoon/comments{/number}","issue_comment_url":"https://api.github.com/repos/asmagill/hammerspoon/issues/comments{/number}","contents_url":"https://api.github.com/repos/asmagill/hammerspoon/contents/{+path}","compare_url":"https://api.github.com/repos/asmagill/hammerspoon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asmagill/hammerspoon/merges","archive_url":"https://api.github.com/repos/asmagill/hammerspoon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asmagill/hammerspoon/downloads","issues_url":"https://api.github.com/repos/asmagill/hammerspoon/issues{/number}","pulls_url":"https://api.github.com/repos/asmagill/hammerspoon/pulls{/number}","milestones_url":"https://api.github.com/repos/asmagill/hammerspoon/milestones{/number}","notifications_url":"https://api.github.com/repos/asmagill/hammerspoon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asmagill/hammerspoon/labels{/name}","releases_url":"https://api.github.com/repos/asmagill/hammerspoon/releases{/id}","created_at":"2015-05-01T02:10:10Z","updated_at":"2015-07-30T08:35:00Z","pushed_at":"2015-08-20T22:15:14Z","git_url":"git://github.com/asmagill/hammerspoon.git","ssh_url":"git@github.com:asmagill/hammerspoon.git","clone_url":"https://github.com/asmagill/hammerspoon.git","svn_url":"https://github.com/asmagill/hammerspoon","homepage":"http://www.hammerspoon.org","size":16389,"stargazers_count":0,"watchers_count":0,"language":"Objective-C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Hammerspoon:master","ref":"master","sha":"26dd1e769e6560379ba1fcec8600b13f3a461d9e","user":{"login":"Hammerspoon","id":9214848,"avatar_url":"https://avatars.githubusercontent.com/u/9214848?v=3","gravatar_id":"","url":"https://api.github.com/users/Hammerspoon","html_url":"https://github.com/Hammerspoon","followers_url":"https://api.github.com/users/Hammerspoon/followers","following_url":"https://api.github.com/users/Hammerspoon/following{/other_user}","gists_url":"https://api.github.com/users/Hammerspoon/gists{/gist_id}","starred_url":"https://api.github.com/users/Hammerspoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hammerspoon/subscriptions","organizations_url":"https://api.github.com/users/Hammerspoon/orgs","repos_url":"https://api.github.com/users/Hammerspoon/repos","events_url":"https://api.github.com/users/Hammerspoon/events{/privacy}","received_events_url":"https://api.github.com/users/Hammerspoon/received_events","type":"Organization","site_admin":false},"repo":{"id":24956772,"name":"hammerspoon","full_name":"Hammerspoon/hammerspoon","owner":{"login":"Hammerspoon","id":9214848,"avatar_url":"https://avatars.githubusercontent.com/u/9214848?v=3","gravatar_id":"","url":"https://api.github.com/users/Hammerspoon","html_url":"https://github.com/Hammerspoon","followers_url":"https://api.github.com/users/Hammerspoon/followers","following_url":"https://api.github.com/users/Hammerspoon/following{/other_user}","gists_url":"https://api.github.com/users/Hammerspoon/gists{/gist_id}","starred_url":"https://api.github.com/users/Hammerspoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hammerspoon/subscriptions","organizations_url":"https://api.github.com/users/Hammerspoon/orgs","repos_url":"https://api.github.com/users/Hammerspoon/repos","events_url":"https://api.github.com/users/Hammerspoon/events{/privacy}","received_events_url":"https://api.github.com/users/Hammerspoon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Hammerspoon/hammerspoon","description":"Staggeringly powerful OS X desktop automation with Lua","fork":false,"url":"https://api.github.com/repos/Hammerspoon/hammerspoon","forks_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/forks","keys_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/teams","hooks_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/hooks","issue_events_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/events{/number}","events_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/events","assignees_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/assignees{/user}","branches_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/branches{/branch}","tags_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/tags","blobs_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/git/refs{/sha}","trees_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/statuses/{sha}","languages_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/languages","stargazers_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/stargazers","contributors_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/contributors","subscribers_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/subscribers","subscription_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/subscription","commits_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/commits{/sha}","git_commits_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/git/commits{/sha}","comments_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/comments{/number}","issue_comment_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/comments{/number}","contents_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/contents/{+path}","compare_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/merges","archive_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/downloads","issues_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues{/number}","pulls_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/pulls{/number}","milestones_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/milestones{/number}","notifications_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/labels{/name}","releases_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/releases{/id}","created_at":"2014-10-08T19:24:44Z","updated_at":"2015-08-20T19:53:43Z","pushed_at":"2015-08-20T22:58:15Z","git_url":"git://github.com/Hammerspoon/hammerspoon.git","ssh_url":"git@github.com:Hammerspoon/hammerspoon.git","clone_url":"https://github.com/Hammerspoon/hammerspoon.git","svn_url":"https://github.com/Hammerspoon/hammerspoon","homepage":"http://www.hammerspoon.org","size":19445,"stargazers_count":455,"watchers_count":455,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":47,"mirror_url":null,"open_issues_count":88,"forks":47,"open_issues":88,"watchers":455,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Hammerspoon/hammerspoon/pulls/512"},"html":{"href":"https://github.com/Hammerspoon/hammerspoon/pull/512"},"issue":{"href":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/512"},"comments":{"href":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/512/comments"},"review_comments":{"href":"https://api.github.com/repos/Hammerspoon/hammerspoon/pulls/512/comments"},"review_comment":{"href":"https://api.github.com/repos/Hammerspoon/hammerspoon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Hammerspoon/hammerspoon/pulls/512/commits"},"statuses":{"href":"https://api.github.com/repos/Hammerspoon/hammerspoon/statuses/8ed7527a9c031e6f528783cdd8bd5ed6048d733b"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":250,"deletions":11,"changed_files":3}}