{"action":"created","issue":{"url":"https://api.github.com/repos/kripken/emscripten/issues/3804","labels_url":"https://api.github.com/repos/kripken/emscripten/issues/3804/labels{/name}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/3804/comments","events_url":"https://api.github.com/repos/kripken/emscripten/issues/3804/events","html_url":"https://github.com/kripken/emscripten/issues/3804","id":107666964,"number":3804,"title":"Passing a parameter pack to EM_ASM_INT","user":{"login":"jjrv","id":778781,"avatar_url":"https://avatars.githubusercontent.com/u/778781?v=3","gravatar_id":"","url":"https://api.github.com/users/jjrv","html_url":"https://github.com/jjrv","followers_url":"https://api.github.com/users/jjrv/followers","following_url":"https://api.github.com/users/jjrv/following{/other_user}","gists_url":"https://api.github.com/users/jjrv/gists{/gist_id}","starred_url":"https://api.github.com/users/jjrv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjrv/subscriptions","organizations_url":"https://api.github.com/users/jjrv/orgs","repos_url":"https://api.github.com/users/jjrv/repos","events_url":"https://api.github.com/users/jjrv/events{/privacy}","received_events_url":"https://api.github.com/users/jjrv/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-22T08:32:13Z","updated_at":"2015-09-22T21:44:55Z","closed_at":null,"body":"If I call `EM_ASM_INT` like:\r\n\r\n```c++\r\ntemplate <typename... Args>\r\nint call(Args... args) {\r\n    return(EM_ASM_INT(\r\n        {\r\n            return(foobar.apply(this, arguments));\r\n        },\r\n        args...\r\n    ));\r\n}\r\n```\r\n\r\nThe generated asm.js code seems to correctly call `_emscripten_asm_const_1` or `_emscripten_asm_const_2` etc. However, some of those functions don't exist. Would it be possible to automatically generate every `_emscripten_asm_const_n` that gets called in the generated code?\r\n\r\nBackground: I need this for Embind-style handling of callbacks. `args...` will be replaced by something like `BindingType<Args>::toWireType(args)...` so that for example an std::string is readable by `foobar`. Then any JavaScript function can be passed to C++ and turned into a functor with a `call` method somewhat like the example above. C++ can then call an arbitrary number of JavaScript functions without any constant `RESERVED_FUNCTION_POINTERS` limit (foobar on JavaScript side will convert the arguments to JavaScript types and call the correct function). Every single C++ -> JavaScript call would pass through that same EM_ASM block."},"comment":{"url":"https://api.github.com/repos/kripken/emscripten/issues/comments/142431468","html_url":"https://github.com/kripken/emscripten/issues/3804#issuecomment-142431468","issue_url":"https://api.github.com/repos/kripken/emscripten/issues/3804","id":142431468,"user":{"login":"kripken","id":173661,"avatar_url":"https://avatars.githubusercontent.com/u/173661?v=3","gravatar_id":"","url":"https://api.github.com/users/kripken","html_url":"https://github.com/kripken","followers_url":"https://api.github.com/users/kripken/followers","following_url":"https://api.github.com/users/kripken/following{/other_user}","gists_url":"https://api.github.com/users/kripken/gists{/gist_id}","starred_url":"https://api.github.com/users/kripken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kripken/subscriptions","organizations_url":"https://api.github.com/users/kripken/orgs","repos_url":"https://api.github.com/users/kripken/repos","events_url":"https://api.github.com/users/kripken/events{/privacy}","received_events_url":"https://api.github.com/users/kripken/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T21:44:55Z","updated_at":"2015-09-22T21:44:55Z","body":"I'm not sure what is going wrong here - is that code sample a testcase that shows the problem? What does\r\n\r\n> However, some of those functions don't exist. \r\n\r\nrefer to - are \"those functions\" functions needed, causing the testcase to fail? Or are they needed for the advanced embind use case?"}}