{"action":"created","issue":{"url":"https://api.github.com/repos/Maratyszcza/PeachPy/issues/55","repository_url":"https://api.github.com/repos/Maratyszcza/PeachPy","labels_url":"https://api.github.com/repos/Maratyszcza/PeachPy/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/Maratyszcza/PeachPy/issues/55/comments","events_url":"https://api.github.com/repos/Maratyszcza/PeachPy/issues/55/events","html_url":"https://github.com/Maratyszcza/PeachPy/issues/55","id":187517651,"number":55,"title":"Go: `uintptr` support?","user":{"login":"dgryski","id":970862,"avatar_url":"https://avatars.githubusercontent.com/u/970862?v=3","gravatar_id":"","url":"https://api.github.com/users/dgryski","html_url":"https://github.com/dgryski","followers_url":"https://api.github.com/users/dgryski/followers","following_url":"https://api.github.com/users/dgryski/following{/other_user}","gists_url":"https://api.github.com/users/dgryski/gists{/gist_id}","starred_url":"https://api.github.com/users/dgryski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgryski/subscriptions","organizations_url":"https://api.github.com/users/dgryski/orgs","repos_url":"https://api.github.com/users/dgryski/repos","events_url":"https://api.github.com/users/dgryski/events{/privacy}","received_events_url":"https://api.github.com/users/dgryski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-05T19:23:24Z","updated_at":"2016-11-06T18:56:03Z","closed_at":null,"body":"https://golang.org/pkg/builtin/#uintptr\r\n\r\nIt seems to be this can map directly to `uintptr_t` ?\r\n\r\n```\r\ndiff --git a/peachpy/x86_64/function.py b/peachpy/x86_64/function.py\r\nindex f4614d6..00c81b9 100644\r\n--- a/peachpy/x86_64/function.py\r\n+++ b/peachpy/x86_64/function.py\r\n@@ -130,6 +130,8 @@ class Function:\r\n                 return \"boolean\"\r\n             elif c_type.is_size_integer:\r\n                 return \"int\" if c_type.is_signed_integer else \"uint\"\r\n+            elif c_type.is_pointer_integer:\r\n+                return \"uintptr\"\r\n             elif c_type.is_signed_integer:\r\n                 return {\r\n                     1: \"int8\",\r\n```\r\n\r\nMy rationale for wanting this is to make it easier to have slices and structs as arguments.\r\n\r\nA slice header ( https://golang.org/pkg/reflect/#SliceHeader ) can be simulated by having three arguments,\r\n\r\n```\r\ns = Argument(ptr(uintptr_t))\r\ns_len = Argument(int64_t)\r\ns_cap = Argument(int64_t)\r\n```\r\n(I know the documentation says to use `ptrdiff_t` to get Go's `int`, but that *really* makes the code confusing... In my code I'm using int64 explicitly because I know I'm on 64-bit platform.)\r\n\r\nHowever, due to the lack of mapping for uintptr, this fails when trying to generate the commented function header -- I have to put an explicit integer type for `s`.\r\n\r\nSimilarly if I want to pass a pointer to a struct, using `uintptr_t` seems the only sane option."},"comment":{"url":"https://api.github.com/repos/Maratyszcza/PeachPy/issues/comments/258701828","html_url":"https://github.com/Maratyszcza/PeachPy/issues/55#issuecomment-258701828","issue_url":"https://api.github.com/repos/Maratyszcza/PeachPy/issues/55","id":258701828,"user":{"login":"dgryski","id":970862,"avatar_url":"https://avatars.githubusercontent.com/u/970862?v=3","gravatar_id":"","url":"https://api.github.com/users/dgryski","html_url":"https://github.com/dgryski","followers_url":"https://api.github.com/users/dgryski/followers","following_url":"https://api.github.com/users/dgryski/following{/other_user}","gists_url":"https://api.github.com/users/dgryski/gists{/gist_id}","starred_url":"https://api.github.com/users/dgryski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgryski/subscriptions","organizations_url":"https://api.github.com/users/dgryski/orgs","repos_url":"https://api.github.com/users/dgryski/repos","events_url":"https://api.github.com/users/dgryski/events{/privacy}","received_events_url":"https://api.github.com/users/dgryski/received_events","type":"User","site_admin":false},"created_at":"2016-11-06T18:56:03Z","updated_at":"2016-11-06T18:56:03Z","body":"I think my goal is to find an integer type that would make *semantic* sense rather than just one which generates the correct assembly instructions.  Reading the peachpy code and seeing `size_t` for a pointer and a `ptrdiff_t` for the length and capacity is confusing.  There *is* already a `uintptr_t` type both in Go and C -- it just needs to be mapped."}}
{"actor":{"display_login":"dgryski"}}