{"action":"created","issue":{"url":"https://api.github.com/repos/keyboardio/Kaleidoscope/issues/323","repository_url":"https://api.github.com/repos/keyboardio/Kaleidoscope","labels_url":"https://api.github.com/repos/keyboardio/Kaleidoscope/issues/323/labels{/name}","comments_url":"https://api.github.com/repos/keyboardio/Kaleidoscope/issues/323/comments","events_url":"https://api.github.com/repos/keyboardio/Kaleidoscope/issues/323/events","html_url":"https://github.com/keyboardio/Kaleidoscope/issues/323","id":323494046,"number":323,"title":"Adding a new hook from a plugin","user":{"login":"algernon","id":17243,"avatar_url":"https://avatars3.githubusercontent.com/u/17243?v=4","gravatar_id":"","url":"https://api.github.com/users/algernon","html_url":"https://github.com/algernon","followers_url":"https://api.github.com/users/algernon/followers","following_url":"https://api.github.com/users/algernon/following{/other_user}","gists_url":"https://api.github.com/users/algernon/gists{/gist_id}","starred_url":"https://api.github.com/users/algernon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algernon/subscriptions","organizations_url":"https://api.github.com/users/algernon/orgs","repos_url":"https://api.github.com/users/algernon/repos","events_url":"https://api.github.com/users/algernon/events{/privacy}","received_events_url":"https://api.github.com/users/algernon/received_events","type":"User","site_admin":false},"labels":[{"id":63830151,"url":"https://api.github.com/repos/keyboardio/Kaleidoscope/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":{"login":"algernon","id":17243,"avatar_url":"https://avatars3.githubusercontent.com/u/17243?v=4","gravatar_id":"","url":"https://api.github.com/users/algernon","html_url":"https://github.com/algernon","followers_url":"https://api.github.com/users/algernon/followers","following_url":"https://api.github.com/users/algernon/following{/other_user}","gists_url":"https://api.github.com/users/algernon/gists{/gist_id}","starred_url":"https://api.github.com/users/algernon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algernon/subscriptions","organizations_url":"https://api.github.com/users/algernon/orgs","repos_url":"https://api.github.com/users/algernon/repos","events_url":"https://api.github.com/users/algernon/events{/privacy}","received_events_url":"https://api.github.com/users/algernon/received_events","type":"User","site_admin":false},"assignees":[{"login":"algernon","id":17243,"avatar_url":"https://avatars3.githubusercontent.com/u/17243?v=4","gravatar_id":"","url":"https://api.github.com/users/algernon","html_url":"https://github.com/algernon","followers_url":"https://api.github.com/users/algernon/followers","following_url":"https://api.github.com/users/algernon/following{/other_user}","gists_url":"https://api.github.com/users/algernon/gists{/gist_id}","starred_url":"https://api.github.com/users/algernon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algernon/subscriptions","organizations_url":"https://api.github.com/users/algernon/orgs","repos_url":"https://api.github.com/users/algernon/repos","events_url":"https://api.github.com/users/algernon/events{/privacy}","received_events_url":"https://api.github.com/users/algernon/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2018-05-16T07:10:13Z","updated_at":"2018-05-17T15:55:02Z","closed_at":null,"author_association":"MEMBER","body":"At the moment, it is not easily possible to add a new hook entirely from a plugin: all the helpers will try to put symbols under `kaleidoscope::Hooks`, and use methods from `kaleidoscope_internal::EventDispatcher`. These are not extensible from outside, so if a plugin wants to add a hook, it has to duplicate all the magic macros.\r\n\r\nIt would be nice if they had an extra argument, letting the caller control where the symbols end up at."},"comment":{"url":"https://api.github.com/repos/keyboardio/Kaleidoscope/issues/comments/389916821","html_url":"https://github.com/keyboardio/Kaleidoscope/issues/323#issuecomment-389916821","issue_url":"https://api.github.com/repos/keyboardio/Kaleidoscope/issues/323","id":389916821,"user":{"login":"noseglasses","id":29701465,"avatar_url":"https://avatars3.githubusercontent.com/u/29701465?v=4","gravatar_id":"","url":"https://api.github.com/users/noseglasses","html_url":"https://github.com/noseglasses","followers_url":"https://api.github.com/users/noseglasses/followers","following_url":"https://api.github.com/users/noseglasses/following{/other_user}","gists_url":"https://api.github.com/users/noseglasses/gists{/gist_id}","starred_url":"https://api.github.com/users/noseglasses/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noseglasses/subscriptions","organizations_url":"https://api.github.com/users/noseglasses/orgs","repos_url":"https://api.github.com/users/noseglasses/repos","events_url":"https://api.github.com/users/noseglasses/events{/privacy}","received_events_url":"https://api.github.com/users/noseglasses/received_events","type":"User","site_admin":false},"created_at":"2018-05-17T15:55:02Z","updated_at":"2018-05-17T15:55:02Z","author_association":"CONTRIBUTOR","body":"It just occured to me that there is at least one issue that needs to be solved, which is the friendship of the `Hook` class. If we would provide a macro that would define siblings of the `Hook` class in user space (I'll call it that way to distinguish from core-space - hello Linux kernel!), we would need to pass this macro the name(s) of those classes and functions that are meant to be allowed to call a specific set of user space hooks.\r\n\r\nExample:\r\n```cpp\r\n#define _FRIEND_DECLARATION(CLASS_OR_FUNCTION) \\\r\n   friend CLASS_OR_FUNCTION;\r\n\r\n#define UNWRAP(...) __VA_ARGS__\r\n\r\n#define KALEIDOSCOPE_DEFINE_HOOK_SYSTEM(HOOK_SYSTEM, EVENT_HANDLER_DEFINITION, FRIENDS)  \\\r\n   namespace kaleidoscope { \\\r\n      class HOOK_SYSTEM {  \\\r\n         public:  \\\r\n            MAP(_FRIEND_DECLARATION, UNWRAP FRIENDS)  \\\r\n         private:\r\n            EVENT_HANDLER_DEFINITION(DEFINE_WEAK_HOOK_FUNCTION)\r\n      };\r\n   }\r\n\r\n...\r\nKALEIDOSCOPE_DEFINE_HOOK_SYSTEM(\r\n   FancyPluginsHooks, // The user-space hook system's name\r\n   FANCY_PLUGINS_FOR_EACH_EVENT_HANDLER, // The plugin's version of _FOR_EACH_EVENT_HANDLER (defined somewhere)\r\n   ( // classes and functions (fully qualified names!) that are supposed to allowed to call hooks of \r\n     // hooking system PluginsFancyHooks\r\n      class Plugin, \r\n      void anyArbitraryFuntion()\r\n   )\r\n)\r\n```\r\n\r\nA modified version of `INSTANTIATE_WEAK_HOOK_FUNCTION`, called with `FANCY_PLUGINS_FOR_EACH_EVENT_HANDLER` would take care of the instantiation of the hook system.\r\n\r\n"}}
{"actor":{"display_login":"noseglasses"}}