{"action":"created","issue":{"url":"https://api.github.com/repos/svaarala/duktape/issues/732","repository_url":"https://api.github.com/repos/svaarala/duktape","labels_url":"https://api.github.com/repos/svaarala/duktape/issues/732/labels{/name}","comments_url":"https://api.github.com/repos/svaarala/duktape/issues/732/comments","events_url":"https://api.github.com/repos/svaarala/duktape/issues/732/events","html_url":"https://github.com/svaarala/duktape/issues/732","id":152942522,"number":732,"title":"Option to create prototype for Duktape/C function","user":{"login":"fatcerberus","id":4097841,"avatar_url":"https://avatars.githubusercontent.com/u/4097841?v=3","gravatar_id":"","url":"https://api.github.com/users/fatcerberus","html_url":"https://github.com/fatcerberus","followers_url":"https://api.github.com/users/fatcerberus/followers","following_url":"https://api.github.com/users/fatcerberus/following{/other_user}","gists_url":"https://api.github.com/users/fatcerberus/gists{/gist_id}","starred_url":"https://api.github.com/users/fatcerberus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatcerberus/subscriptions","organizations_url":"https://api.github.com/users/fatcerberus/orgs","repos_url":"https://api.github.com/users/fatcerberus/repos","events_url":"https://api.github.com/users/fatcerberus/events{/privacy}","received_events_url":"https://api.github.com/users/fatcerberus/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/svaarala/duktape/labels/api","name":"api","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/svaarala/duktape/milestones/5","html_url":"https://github.com/svaarala/duktape/milestones/v2.0.0","labels_url":"https://api.github.com/repos/svaarala/duktape/milestones/5/labels","id":840957,"number":5,"title":"v2.0.0","description":"","creator":{"login":"svaarala","id":6377415,"avatar_url":"https://avatars.githubusercontent.com/u/6377415?v=3","gravatar_id":"","url":"https://api.github.com/users/svaarala","html_url":"https://github.com/svaarala","followers_url":"https://api.github.com/users/svaarala/followers","following_url":"https://api.github.com/users/svaarala/following{/other_user}","gists_url":"https://api.github.com/users/svaarala/gists{/gist_id}","starred_url":"https://api.github.com/users/svaarala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svaarala/subscriptions","organizations_url":"https://api.github.com/users/svaarala/orgs","repos_url":"https://api.github.com/users/svaarala/repos","events_url":"https://api.github.com/users/svaarala/events{/privacy}","received_events_url":"https://api.github.com/users/svaarala/received_events","type":"User","site_admin":false},"open_issues":21,"closed_issues":2,"state":"open","created_at":"2014-10-26T15:05:37Z","updated_at":"2016-05-04T09:33:29Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-05-04T07:01:57Z","updated_at":"2016-05-04T09:45:36Z","closed_at":null,"body":"Currently `duk_push_c_function()` doesn't create a prototype for the pushed function.  This is usually fine, however it's inconvenient when creating constructors.  Even when no methods are in the prototype, having an empty prototype is still useful for inheritance.  Even just an empty prototype is two additional lines of code for every constructor:\r\n\r\n```c\r\nduk_push_object(ctx);\r\nduk_put_prop_string(ctx, -2, \"prototype\");\r\n```\r\n\r\nI propose a flag for `duk_push_c_function()` to request automatic prototype creation.\r\n\r\nIf this is implemented, another flag that might be nice to have is one to take an object already on the value stack and use it as the prototype.  That'd probably just be bloat though since if you already have an object on the stack it's not that hard just to call `duk_put_prop_string()` at that point."},"comment":{"url":"https://api.github.com/repos/svaarala/duktape/issues/comments/216813925","html_url":"https://github.com/svaarala/duktape/issues/732#issuecomment-216813925","issue_url":"https://api.github.com/repos/svaarala/duktape/issues/732","id":216813925,"user":{"login":"svaarala","id":6377415,"avatar_url":"https://avatars.githubusercontent.com/u/6377415?v=3","gravatar_id":"","url":"https://api.github.com/users/svaarala","html_url":"https://github.com/svaarala","followers_url":"https://api.github.com/users/svaarala/followers","following_url":"https://api.github.com/users/svaarala/following{/other_user}","gists_url":"https://api.github.com/users/svaarala/gists{/gist_id}","starred_url":"https://api.github.com/users/svaarala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svaarala/subscriptions","organizations_url":"https://api.github.com/users/svaarala/orgs","repos_url":"https://api.github.com/users/svaarala/repos","events_url":"https://api.github.com/users/svaarala/events{/privacy}","received_events_url":"https://api.github.com/users/svaarala/received_events","type":"User","site_admin":false},"created_at":"2016-05-04T09:45:36Z","updated_at":"2016-05-04T09:45:36Z","body":"Another need for a flag is to control whether a function can be called as a constructor or not. There's a \"constructable\" internal flag already and it's used for built-in functions, but user functions cannot be declared as being non-constructable. This would be useful to add too, otherwise an explicit constructor call check is needed in a Duktape/C function to reject a constructor call if it's not desirable."}}