{"action":"created","issue":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5850","repository_url":"https://api.github.com/repos/HaxeFoundation/haxe","labels_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5850/labels{/name}","comments_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5850/comments","events_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5850/events","html_url":"https://github.com/HaxeFoundation/haxe/issues/5850","id":192730540,"number":5850,"title":"3.4-rc.1 cpp code/type issue","user":{"login":"underscorediscovery","id":236374,"avatar_url":"https://avatars.githubusercontent.com/u/236374?v=3","gravatar_id":"","url":"https://api.github.com/users/underscorediscovery","html_url":"https://github.com/underscorediscovery","followers_url":"https://api.github.com/users/underscorediscovery/followers","following_url":"https://api.github.com/users/underscorediscovery/following{/other_user}","gists_url":"https://api.github.com/users/underscorediscovery/gists{/gist_id}","starred_url":"https://api.github.com/users/underscorediscovery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/underscorediscovery/subscriptions","organizations_url":"https://api.github.com/users/underscorediscovery/orgs","repos_url":"https://api.github.com/users/underscorediscovery/repos","events_url":"https://api.github.com/users/underscorediscovery/events{/privacy}","received_events_url":"https://api.github.com/users/underscorediscovery/received_events","type":"User","site_admin":false},"labels":[{"id":41271761,"url":"https://api.github.com/repos/HaxeFoundation/haxe/labels/platform-cpp","name":"platform-cpp","color":"006b75","default":false},{"id":166727714,"url":"https://api.github.com/repos/HaxeFoundation/haxe/labels/regression","name":"regression","color":"e11d21","default":false}],"state":"open","locked":false,"assignee":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"assignees":[{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},{"login":"hughsando","id":1665494,"avatar_url":"https://avatars.githubusercontent.com/u/1665494?v=3","gravatar_id":"","url":"https://api.github.com/users/hughsando","html_url":"https://github.com/hughsando","followers_url":"https://api.github.com/users/hughsando/followers","following_url":"https://api.github.com/users/hughsando/following{/other_user}","gists_url":"https://api.github.com/users/hughsando/gists{/gist_id}","starred_url":"https://api.github.com/users/hughsando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hughsando/subscriptions","organizations_url":"https://api.github.com/users/hughsando/orgs","repos_url":"https://api.github.com/users/hughsando/repos","events_url":"https://api.github.com/users/hughsando/events{/privacy}","received_events_url":"https://api.github.com/users/hughsando/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/milestones/11","html_url":"https://github.com/HaxeFoundation/haxe/milestones/3.3.0","labels_url":"https://api.github.com/repos/HaxeFoundation/haxe/milestones/11/labels","id":1599225,"number":11,"title":"3.3.0","description":"","creator":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":81,"state":"open","created_at":"2016-02-23T09:11:44Z","updated_at":"2016-12-01T10:00:26Z","due_on":"2016-06-18T22:00:00Z","closed_at":null},"comments":4,"created_at":"2016-12-01T01:27:15Z","updated_at":"2016-12-01T12:50:39Z","closed_at":null,"body":"Trying the new RC to no avail (yet!).\r\nNot sure if this is for hxcpp repo or here.\r\nhxcpp `3.4.2`\r\nhaxe `3.4-rc.1` \r\n\r\nI have the following code:\r\n```haxe\r\nvar _joystick : sdl.Joystick = joysticks.get(e.jdevice.which);\r\nSDL.joystickClose(_joystick);\r\n```\r\n\r\nThe call itself is an extern to a native library:\r\n```haxe\r\n@:native('SDL_JoystickClose')\r\nstatic function joystickClose(joystick:Joystick):Void;\r\n```\r\n\r\nThe joystick type is an opaque extern class to `SDL_Joystick*`\r\n```haxe\r\n@:native(\"SDL_Joystick\")\r\n@:include('linc_sdl.h')\r\nextern private class SDL_Joystick {}\r\ntypedef Joystick = cpp.Pointer<SDL_Joystick>;\r\n```\r\n\r\nAnd the map, is just a map:\r\n```haxe\r\nvar joysticks : Map<Int, sdl.Joystick>;\r\n```\r\n\r\n[The code is here](https://github.com/snowkit/snow/blob/master/snow/modules/sdl/Runtime.hx#L675-L677). I added an explicit type to see if type inference was playing a role.\r\n\r\n### The problem\r\n\r\nThe problem lies in the generated code.\r\n```c++\r\nHXLINE( 677) SDL_JoystickClose(::haxe::IMap_obj::get(this->joysticks,e->jdevice.which));\r\n```\r\n\r\nWhich due to the way it's generated, creates a c++ error:\r\n```\r\nerror: no matching function for call to 'SDL_JoystickClose'\r\nno known conversion from '::Dynamic' to 'SDL_Joystick *'\r\n```\r\n\r\nI have no ideas to try work around it, I can't see any way to force it not to make the change or to interpret the type any differently. Ideas appreciated. \r\n\r\ncc @hughsando \r\n\r\n---\r\n\r\nThe AST:\r\n```\r\n[Then:Void] [Block:Void]\r\n    [Call:Void]\r\n        [Field:joystick : sdl.Joystick -> Void]\r\n            [TypeExpr sdl.SDL:Class<sdl.SDL>]\r\n            [FStatic:joystick : sdl.Joystick -> Void]\r\n                sdl.SDL\r\n                SDL_JoystickClose\r\n        [Call:Null<sdl.Joystick>]\r\n            [Field:k : Int -> Null<sdl.Joystick>]\r\n                [Cast:IMap<Int, sdl.Joystick>]\r\n                    [Cast:IMap<Int, sdl.Joystick>]\r\n                        [Field:Map<Int, sdl.Joystick>]\r\n                            [Const:snow.modules.sdl.Runtime] this\r\n                            [FInstance:Map<Int, sdl.Joystick>]\r\n                                snow.modules.sdl.Runtime\r\n                                joysticks\r\n                [FInstance:k : Int -> Null<sdl.Joystick>]\r\n                    haxe.IMap<Int, sdl.Joystick>\r\n                    get\r\n```\r\n\r\n### 3.2.1 code\r\n\r\n3.2.1 worked as intended, code generated (without hxcpp debug):\r\n\r\n```cpp\r\n::haxe::ds::IntMap tmp4 = this->joysticks;      \r\nint tmp5 = e->jdevice.which;        \r\n::cpp::Pointer< SDL_Joystick > tmp6 = tmp4->get(tmp5);\r\n::cpp::Pointer< SDL_Joystick > _joystick = tmp6;        \r\n::cpp::Pointer< SDL_Joystick > tmp7 = _joystick;\r\nSDL_JoystickClose(tmp7);\r\n```\r\n\r\n3.2.1 AST\r\n```\r\n[Then:Void] [Block:Void]\r\n    [Var tmp4(60816):haxe.ds.IntMap<sdl.Joystick>]\r\n        [Field:haxe.ds.IntMap<sdl.Joystick>]\r\n            [Const this:snow.modules.sdl.Runtime]\r\n            [FInstance:haxe.ds.IntMap<sdl.Joystick>]\r\n                snow.modules.sdl.Runtime\r\n                joysticks\r\n    [Var tmp5(60817):Int]\r\n        [Field:Int]\r\n            [Field:::cpp::Struct<SDL_JoyDeviceEvent>]\r\n                [Local e(14587):::cpp::Struct<SDL_Event>]\r\n                [FInstance:::cpp::Struct<SDL_JoyDeviceEvent>]\r\n                    SDL_Event\r\n                    jdevice\r\n            [FInstance:Int]\r\n                ::cpp::Struct<SDL_JoyDeviceEvent>\r\n                which\r\n    [Var tmp6(60818):Null<sdl.Joystick>]\r\n        [Call:Null<sdl.Joystick>]\r\n            [Field:key : Int -> Null<sdl.Joystick>]\r\n                [Local tmp4(60816):haxe.ds.IntMap<sdl.Joystick>]\r\n                [FInstance:key : Int -> Null<sdl.Joystick>]\r\n                    haxe.ds.IntMap<sdl.Joystick>\r\n                    get\r\n            [Local tmp5(60817):Int]\r\n    [Var _joystick(14688):sdl.Joystick] [Cast:Null<sdl.Joystick>] [Local tmp6(60818):Null<sdl.Joystick>]\r\n    [Var tmp7(60819):sdl.Joystick] [Local _joystick(14688):sdl.Joystick]\r\n    [Call:Void]\r\n        [Field:joystick : sdl.Joystick -> Void]\r\n            [TypeExpr sdl.SDL:Class<sdl.SDL>]\r\n            [FStatic:joystick : sdl.Joystick -> Void]\r\n                sdl.SDL\r\n                SDL_JoystickClose\r\n        [Local tmp7(60819):sdl.Joystick]\r\n```"},"comment":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/comments/264165863","html_url":"https://github.com/HaxeFoundation/haxe/issues/5850#issuecomment-264165863","issue_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5850","id":264165863,"user":{"login":"hughsando","id":1665494,"avatar_url":"https://avatars.githubusercontent.com/u/1665494?v=3","gravatar_id":"","url":"https://api.github.com/users/hughsando","html_url":"https://github.com/hughsando","followers_url":"https://api.github.com/users/hughsando/followers","following_url":"https://api.github.com/users/hughsando/following{/other_user}","gists_url":"https://api.github.com/users/hughsando/gists{/gist_id}","starred_url":"https://api.github.com/users/hughsando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hughsando/subscriptions","organizations_url":"https://api.github.com/users/hughsando/orgs","repos_url":"https://api.github.com/users/hughsando/repos","events_url":"https://api.github.com/users/hughsando/events{/privacy}","received_events_url":"https://api.github.com/users/hughsando/received_events","type":"User","site_admin":false},"created_at":"2016-12-01T12:50:39Z","updated_at":"2016-12-01T12:50:39Z","body":"I have some \"auto cast\" code in gencpp, and it should be able to detect that I'm actually passing a Dynamic to cpp.Pointer function call.  So think it should probably be fixed here - or at least I should have a look and see where it falls down - there might be other cases.\r\nI have a spot in the hxcpp tests for this kind of thing."}}
{"actor":{"display_login":"hughsando"}}