{"action":"created","comment":{"url":"https://api.github.com/repos/livecode/livecode/pulls/comments/102667411","pull_request_review_id":23427438,"id":102667411,"diff_hunk":"@@ -0,0 +1,168 @@\n+/*                                                                     -*-c++-*-\n+ Copyright (C) 2017 LiveCode Ltd.\n+ \n+ This file is part of LiveCode.\n+ \n+ LiveCode is free software; you can redistribute it and/or modify it under\n+ the terms of the GNU General Public License v3 as published by the Free\n+ Software Foundation.\n+ \n+ LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY\n+ WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\n+ for more details.\n+ \n+ You should have received a copy of the GNU General Public License\n+ along with LiveCode.  If not see <http://www.gnu.org/licenses/>.  */\n+\n+#include \"system-private.h\"\n+\n+#include <foundation-auto.h>\n+\n+/* ================================================================\n+ * Android Handle Class\n+ * ================================================================ */\n+\n+#include \"system-library-posix.hpp\"\n+\n+#include <dlfcn.h>\n+#include <link.h>\n+\n+#if __ANDROID_API__ < 21\n+extern \"C\" __attribute__((weak)) int\n+dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),\n+                void *);\n+#endif\n+\n+extern MCStringRef gMCSAndroidNativeLibPath;\n+\n+class __MCSLibraryHandleAndroid: public __MCSLibraryHandlePosix\n+{\n+public:\n+    bool\n+    CopyNativePath(MCStringRef& r_native_path) const\n+    {\n+        const char *t_sys_filename = nullptr;\n+        if (dl_iterate_phdr == nullptr)\n+        {\n+            t_sys_filename = CopyNativePathLegacy();\n+        }\n+        else\n+        {\n+            t_sys_filename = CopyNativePathModern(m_handle).Run();\n+        }\n+\n+        if (t_sys_filename != nullptr)\n+        {\n+            \n+            MCAutoStringRef t_filename;\n+            if (!MCStringCreateWithSysString(t_sys_filename,\n+                                             &t_filename))\n+            {\n+                return false;\n+            }\n+        \n+            return MCStringFormat(r_native_path,\n+                                  \"%@/%@\",\n+                                  gMCSAndroidNativeLibPath,\n+                                  *t_filename);\n+        }\n+\n+        return __MCSLibraryThrowResolvePathFailed();\n+    }\n+    \n+private:\n+    class CopyNativePathModern\n+    {\n+    public:\n+        CopyNativePathModern(void *p_handle)\n+            : m_handle(p_handle),\n+              m_filename(nullptr)\n+        {\n+        }\n+        \n+        const char *Run(void)\n+        {\n+            dl_iterate_phdr(Thunk,\n+                            this);\n+            return m_filename;\n+        }\n+        \n+    private:\n+        int operator () (struct dl_phdr_info* p_info,\n+                         size_t p_size)\n+        {\n+            if (m_filename != nullptr)\n+            {\n+                return 0;\n+            }\n+            \n+            Dl_info t_addr_info;\n+            if (dladdr(reinterpret_cast<void *>(p_info->dlpi_addr),","path":"libfoundation/src/system-library-android.hpp","position":161,"original_position":101,"commit_id":"ad659e0667ea64bb4a6f3aab2095f5a7094f9ac8","original_commit_id":"86cd24ad587e3d1d5bdf2dd4ccf2c9a1f2dec9bd","user":{"login":"runrevmark","id":3985298,"avatar_url":"https://avatars.githubusercontent.com/u/3985298?v=3","gravatar_id":"","url":"https://api.github.com/users/runrevmark","html_url":"https://github.com/runrevmark","followers_url":"https://api.github.com/users/runrevmark/followers","following_url":"https://api.github.com/users/runrevmark/following{/other_user}","gists_url":"https://api.github.com/users/runrevmark/gists{/gist_id}","starred_url":"https://api.github.com/users/runrevmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runrevmark/subscriptions","organizations_url":"https://api.github.com/users/runrevmark/orgs","repos_url":"https://api.github.com/users/runrevmark/repos","events_url":"https://api.github.com/users/runrevmark/events{/privacy}","received_events_url":"https://api.github.com/users/runrevmark/received_events","type":"User","site_admin":false},"body":"I tried that, but it didn't work - dlpi_addr is a uintptr_t so it needs reinterpret.","created_at":"2017-02-23T09:10:10Z","updated_at":"2017-02-23T09:10:11Z","html_url":"https://github.com/livecode/livecode/pull/5161#discussion_r102667411","pull_request_url":"https://api.github.com/repos/livecode/livecode/pulls/5161","_links":{"self":{"href":"https://api.github.com/repos/livecode/livecode/pulls/comments/102667411"},"html":{"href":"https://github.com/livecode/livecode/pull/5161#discussion_r102667411"},"pull_request":{"href":"https://api.github.com/repos/livecode/livecode/pulls/5161"}}},"pull_request":{"url":"https://api.github.com/repos/livecode/livecode/pulls/5161","id":105057656,"html_url":"https://github.com/livecode/livecode/pull/5161","diff_url":"https://github.com/livecode/livecode/pull/5161.diff","patch_url":"https://github.com/livecode/livecode/pull/5161.patch","issue_url":"https://api.github.com/repos/livecode/livecode/issues/5161","number":5161,"state":"open","locked":false,"title":"[[ SysLibrary ]] Add a loadable library management API to system","user":{"login":"runrevmark","id":3985298,"avatar_url":"https://avatars.githubusercontent.com/u/3985298?v=3","gravatar_id":"","url":"https://api.github.com/users/runrevmark","html_url":"https://github.com/runrevmark","followers_url":"https://api.github.com/users/runrevmark/followers","following_url":"https://api.github.com/users/runrevmark/following{/other_user}","gists_url":"https://api.github.com/users/runrevmark/gists{/gist_id}","starred_url":"https://api.github.com/users/runrevmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runrevmark/subscriptions","organizations_url":"https://api.github.com/users/runrevmark/orgs","repos_url":"https://api.github.com/users/runrevmark/repos","events_url":"https://api.github.com/users/runrevmark/events{/privacy}","received_events_url":"https://api.github.com/users/runrevmark/received_events","type":"User","site_admin":false},"body":"This patch adds a new MCSLibrary API to foundation-system. The API\r\nwraps the implementation details of the type of underlying shared\r\nlibrary (whether it be dlfcn, HMODULE, CFBundleRef or static) from\r\nthe caller.\r\n\r\nBased on the idea original proposed by @livecodeali here #5148 ","created_at":"2017-02-07T17:45:49Z","updated_at":"2017-02-23T09:10:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f47b9163fa7d59c1692227f047a83c61fb2852ec","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/livecode/livecode/pulls/5161/commits","review_comments_url":"https://api.github.com/repos/livecode/livecode/pulls/5161/comments","review_comment_url":"https://api.github.com/repos/livecode/livecode/pulls/comments{/number}","comments_url":"https://api.github.com/repos/livecode/livecode/issues/5161/comments","statuses_url":"https://api.github.com/repos/livecode/livecode/statuses/ad659e0667ea64bb4a6f3aab2095f5a7094f9ac8","head":{"label":"runrevmark:bugfix-19213","ref":"bugfix-19213","sha":"ad659e0667ea64bb4a6f3aab2095f5a7094f9ac8","user":{"login":"runrevmark","id":3985298,"avatar_url":"https://avatars.githubusercontent.com/u/3985298?v=3","gravatar_id":"","url":"https://api.github.com/users/runrevmark","html_url":"https://github.com/runrevmark","followers_url":"https://api.github.com/users/runrevmark/followers","following_url":"https://api.github.com/users/runrevmark/following{/other_user}","gists_url":"https://api.github.com/users/runrevmark/gists{/gist_id}","starred_url":"https://api.github.com/users/runrevmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runrevmark/subscriptions","organizations_url":"https://api.github.com/users/runrevmark/orgs","repos_url":"https://api.github.com/users/runrevmark/repos","events_url":"https://api.github.com/users/runrevmark/events{/privacy}","received_events_url":"https://api.github.com/users/runrevmark/received_events","type":"User","site_admin":false},"repo":{"id":9373954,"name":"livecode","full_name":"runrevmark/livecode","owner":{"login":"runrevmark","id":3985298,"avatar_url":"https://avatars.githubusercontent.com/u/3985298?v=3","gravatar_id":"","url":"https://api.github.com/users/runrevmark","html_url":"https://github.com/runrevmark","followers_url":"https://api.github.com/users/runrevmark/followers","following_url":"https://api.github.com/users/runrevmark/following{/other_user}","gists_url":"https://api.github.com/users/runrevmark/gists{/gist_id}","starred_url":"https://api.github.com/users/runrevmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runrevmark/subscriptions","organizations_url":"https://api.github.com/users/runrevmark/orgs","repos_url":"https://api.github.com/users/runrevmark/repos","events_url":"https://api.github.com/users/runrevmark/events{/privacy}","received_events_url":"https://api.github.com/users/runrevmark/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/runrevmark/livecode","description":null,"fork":true,"url":"https://api.github.com/repos/runrevmark/livecode","forks_url":"https://api.github.com/repos/runrevmark/livecode/forks","keys_url":"https://api.github.com/repos/runrevmark/livecode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/runrevmark/livecode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/runrevmark/livecode/teams","hooks_url":"https://api.github.com/repos/runrevmark/livecode/hooks","issue_events_url":"https://api.github.com/repos/runrevmark/livecode/issues/events{/number}","events_url":"https://api.github.com/repos/runrevmark/livecode/events","assignees_url":"https://api.github.com/repos/runrevmark/livecode/assignees{/user}","branches_url":"https://api.github.com/repos/runrevmark/livecode/branches{/branch}","tags_url":"https://api.github.com/repos/runrevmark/livecode/tags","blobs_url":"https://api.github.com/repos/runrevmark/livecode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/runrevmark/livecode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/runrevmark/livecode/git/refs{/sha}","trees_url":"https://api.github.com/repos/runrevmark/livecode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/runrevmark/livecode/statuses/{sha}","languages_url":"https://api.github.com/repos/runrevmark/livecode/languages","stargazers_url":"https://api.github.com/repos/runrevmark/livecode/stargazers","contributors_url":"https://api.github.com/repos/runrevmark/livecode/contributors","subscribers_url":"https://api.github.com/repos/runrevmark/livecode/subscribers","subscription_url":"https://api.github.com/repos/runrevmark/livecode/subscription","commits_url":"https://api.github.com/repos/runrevmark/livecode/commits{/sha}","git_commits_url":"https://api.github.com/repos/runrevmark/livecode/git/commits{/sha}","comments_url":"https://api.github.com/repos/runrevmark/livecode/comments{/number}","issue_comment_url":"https://api.github.com/repos/runrevmark/livecode/issues/comments{/number}","contents_url":"https://api.github.com/repos/runrevmark/livecode/contents/{+path}","compare_url":"https://api.github.com/repos/runrevmark/livecode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/runrevmark/livecode/merges","archive_url":"https://api.github.com/repos/runrevmark/livecode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/runrevmark/livecode/downloads","issues_url":"https://api.github.com/repos/runrevmark/livecode/issues{/number}","pulls_url":"https://api.github.com/repos/runrevmark/livecode/pulls{/number}","milestones_url":"https://api.github.com/repos/runrevmark/livecode/milestones{/number}","notifications_url":"https://api.github.com/repos/runrevmark/livecode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/runrevmark/livecode/labels{/name}","releases_url":"https://api.github.com/repos/runrevmark/livecode/releases{/id}","deployments_url":"https://api.github.com/repos/runrevmark/livecode/deployments","created_at":"2013-04-11T15:43:35Z","updated_at":"2016-07-06T11:56:01Z","pushed_at":"2017-02-23T09:08:53Z","git_url":"git://github.com/runrevmark/livecode.git","ssh_url":"git@github.com:runrevmark/livecode.git","clone_url":"https://github.com/runrevmark/livecode.git","svn_url":"https://github.com/runrevmark/livecode","homepage":null,"size":127826,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"livecode:develop","ref":"develop","sha":"6f7d6b0b1fb6337a786775f4ff43692e7312c894","user":{"login":"livecode","id":3985749,"avatar_url":"https://avatars.githubusercontent.com/u/3985749?v=3","gravatar_id":"","url":"https://api.github.com/users/livecode","html_url":"https://github.com/livecode","followers_url":"https://api.github.com/users/livecode/followers","following_url":"https://api.github.com/users/livecode/following{/other_user}","gists_url":"https://api.github.com/users/livecode/gists{/gist_id}","starred_url":"https://api.github.com/users/livecode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/livecode/subscriptions","organizations_url":"https://api.github.com/users/livecode/orgs","repos_url":"https://api.github.com/users/livecode/repos","events_url":"https://api.github.com/users/livecode/events{/privacy}","received_events_url":"https://api.github.com/users/livecode/received_events","type":"Organization","site_admin":false},"repo":{"id":9334445,"name":"livecode","full_name":"livecode/livecode","owner":{"login":"livecode","id":3985749,"avatar_url":"https://avatars.githubusercontent.com/u/3985749?v=3","gravatar_id":"","url":"https://api.github.com/users/livecode","html_url":"https://github.com/livecode","followers_url":"https://api.github.com/users/livecode/followers","following_url":"https://api.github.com/users/livecode/following{/other_user}","gists_url":"https://api.github.com/users/livecode/gists{/gist_id}","starred_url":"https://api.github.com/users/livecode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/livecode/subscriptions","organizations_url":"https://api.github.com/users/livecode/orgs","repos_url":"https://api.github.com/users/livecode/repos","events_url":"https://api.github.com/users/livecode/events{/privacy}","received_events_url":"https://api.github.com/users/livecode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/livecode/livecode","description":"LiveCode cross-platform development environment (engine)","fork":false,"url":"https://api.github.com/repos/livecode/livecode","forks_url":"https://api.github.com/repos/livecode/livecode/forks","keys_url":"https://api.github.com/repos/livecode/livecode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/livecode/livecode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/livecode/livecode/teams","hooks_url":"https://api.github.com/repos/livecode/livecode/hooks","issue_events_url":"https://api.github.com/repos/livecode/livecode/issues/events{/number}","events_url":"https://api.github.com/repos/livecode/livecode/events","assignees_url":"https://api.github.com/repos/livecode/livecode/assignees{/user}","branches_url":"https://api.github.com/repos/livecode/livecode/branches{/branch}","tags_url":"https://api.github.com/repos/livecode/livecode/tags","blobs_url":"https://api.github.com/repos/livecode/livecode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/livecode/livecode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/livecode/livecode/git/refs{/sha}","trees_url":"https://api.github.com/repos/livecode/livecode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/livecode/livecode/statuses/{sha}","languages_url":"https://api.github.com/repos/livecode/livecode/languages","stargazers_url":"https://api.github.com/repos/livecode/livecode/stargazers","contributors_url":"https://api.github.com/repos/livecode/livecode/contributors","subscribers_url":"https://api.github.com/repos/livecode/livecode/subscribers","subscription_url":"https://api.github.com/repos/livecode/livecode/subscription","commits_url":"https://api.github.com/repos/livecode/livecode/commits{/sha}","git_commits_url":"https://api.github.com/repos/livecode/livecode/git/commits{/sha}","comments_url":"https://api.github.com/repos/livecode/livecode/comments{/number}","issue_comment_url":"https://api.github.com/repos/livecode/livecode/issues/comments{/number}","contents_url":"https://api.github.com/repos/livecode/livecode/contents/{+path}","compare_url":"https://api.github.com/repos/livecode/livecode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/livecode/livecode/merges","archive_url":"https://api.github.com/repos/livecode/livecode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/livecode/livecode/downloads","issues_url":"https://api.github.com/repos/livecode/livecode/issues{/number}","pulls_url":"https://api.github.com/repos/livecode/livecode/pulls{/number}","milestones_url":"https://api.github.com/repos/livecode/livecode/milestones{/number}","notifications_url":"https://api.github.com/repos/livecode/livecode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/livecode/livecode/labels{/name}","releases_url":"https://api.github.com/repos/livecode/livecode/releases{/id}","deployments_url":"https://api.github.com/repos/livecode/livecode/deployments","created_at":"2013-04-10T00:15:57Z","updated_at":"2017-02-01T06:08:07Z","pushed_at":"2017-02-23T09:08:55Z","git_url":"git://github.com/livecode/livecode.git","ssh_url":"git@github.com:livecode/livecode.git","clone_url":"https://github.com/livecode/livecode.git","svn_url":"https://github.com/livecode/livecode","homepage":"https://livecode.com/","size":135452,"stargazers_count":163,"watchers_count":163,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":119,"mirror_url":null,"open_issues_count":95,"forks":119,"open_issues":95,"watchers":163,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/livecode/livecode/pulls/5161"},"html":{"href":"https://github.com/livecode/livecode/pull/5161"},"issue":{"href":"https://api.github.com/repos/livecode/livecode/issues/5161"},"comments":{"href":"https://api.github.com/repos/livecode/livecode/issues/5161/comments"},"review_comments":{"href":"https://api.github.com/repos/livecode/livecode/pulls/5161/comments"},"review_comment":{"href":"https://api.github.com/repos/livecode/livecode/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/livecode/livecode/pulls/5161/commits"},"statuses":{"href":"https://api.github.com/repos/livecode/livecode/statuses/ad659e0667ea64bb4a6f3aab2095f5a7094f9ac8"}}}}
{"actor":{"display_login":"runrevmark"}}