{"action":"created","issue":{"url":"https://api.github.com/repos/swig/swig/issues/248","repository_url":"https://api.github.com/repos/swig/swig","labels_url":"https://api.github.com/repos/swig/swig/issues/248/labels{/name}","comments_url":"https://api.github.com/repos/swig/swig/issues/248/comments","events_url":"https://api.github.com/repos/swig/swig/issues/248/events","html_url":"https://github.com/swig/swig/issues/248","id":46492487,"number":248,"title":"%typemap(in)      (char *STRING, int LENGTH) with types other than char*","user":{"login":"stevenhdb","id":9349562,"avatar_url":"https://avatars.githubusercontent.com/u/9349562?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenhdb","html_url":"https://github.com/stevenhdb","followers_url":"https://api.github.com/users/stevenhdb/followers","following_url":"https://api.github.com/users/stevenhdb/following{/other_user}","gists_url":"https://api.github.com/users/stevenhdb/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenhdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenhdb/subscriptions","organizations_url":"https://api.github.com/users/stevenhdb/orgs","repos_url":"https://api.github.com/users/stevenhdb/repos","events_url":"https://api.github.com/users/stevenhdb/events{/privacy}","received_events_url":"https://api.github.com/users/stevenhdb/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/swig/swig/labels/Java","name":"Java","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2014-10-22T10:01:36Z","updated_at":"2016-09-09T06:20:15Z","closed_at":null,"body":"Hi,\r\n\r\nI'm using SWIG 3.0.2 and came across an issue where I needed to use the above typemap on a BYTE*.\r\n\r\nI added `%apply (char *STRING, int LENGTH) { (BYTE* data, int len) }` to my code but got a compile error in the generated wrapper cxx code on the line `arg2 = (char *) jenv->GetByteArrayElements(jarg2, 0);`\r\n\r\nThe fix for this seems to be to change the typemap in java.swg to use `$1_type` instead of char * as follows:\r\n```\r\n@@ -1327,7 +1327,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)\r\n %typemap(freearg) (char *STRING, size_t LENGTH) \"\"\r\n %typemap(in)      (char *STRING, size_t LENGTH) {\r\n   if ($input) {\r\n-    $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);\r\n+    $1 = ($1_type) JCALL2(GetByteArrayElements, jenv, $input, 0);\r\n     $2 = (size_t) JCALL1(GetArrayLength, jenv, $input);\r\n   } else {\r\n     $1 = 0;\r\n```\r\nIs this a valid change?\r\n\r\nThanks,\r\nSteven"},"comment":{"url":"https://api.github.com/repos/swig/swig/issues/comments/245829157","html_url":"https://github.com/swig/swig/issues/248#issuecomment-245829157","issue_url":"https://api.github.com/repos/swig/swig/issues/248","id":245829157,"user":{"login":"wsfulton","id":2878511,"avatar_url":"https://avatars.githubusercontent.com/u/2878511?v=3","gravatar_id":"","url":"https://api.github.com/users/wsfulton","html_url":"https://github.com/wsfulton","followers_url":"https://api.github.com/users/wsfulton/followers","following_url":"https://api.github.com/users/wsfulton/following{/other_user}","gists_url":"https://api.github.com/users/wsfulton/gists{/gist_id}","starred_url":"https://api.github.com/users/wsfulton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wsfulton/subscriptions","organizations_url":"https://api.github.com/users/wsfulton/orgs","repos_url":"https://api.github.com/users/wsfulton/repos","events_url":"https://api.github.com/users/wsfulton/events{/privacy}","received_events_url":"https://api.github.com/users/wsfulton/received_events","type":"User","site_admin":false},"created_at":"2016-09-09T06:20:15Z","updated_at":"2016-09-09T06:20:15Z","body":"Yes. Just needs applying with a testcase which will probably flush out similar problems in other languages."}}
{"actor":{"display_login":"wsfulton"}}