{"action":"created","issue":{"url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/109","labels_url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/109/labels{/name}","comments_url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/109/comments","events_url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/109/events","html_url":"https://github.com/crabtw/rust-bindgen/issues/109","id":45572345,"number":109,"title":"Generate proper enums","user":{"login":"fread2281","id":985195,"avatar_url":"https://avatars.githubusercontent.com/u/985195?v=3","gravatar_id":"","url":"https://api.github.com/users/fread2281","html_url":"https://github.com/fread2281","followers_url":"https://api.github.com/users/fread2281/followers","following_url":"https://api.github.com/users/fread2281/following{/other_user}","gists_url":"https://api.github.com/users/fread2281/gists{/gist_id}","starred_url":"https://api.github.com/users/fread2281/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fread2281/subscriptions","organizations_url":"https://api.github.com/users/fread2281/orgs","repos_url":"https://api.github.com/users/fread2281/repos","events_url":"https://api.github.com/users/fread2281/events{/privacy}","received_events_url":"https://api.github.com/users/fread2281/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-10-12T07:31:52Z","updated_at":"2015-01-22T22:49:18Z","closed_at":null,"body":"It would be really nice if rust-bindgen would generate proper enums (for enums in C) instead of a type alias and constants."},"comment":{"url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/comments/71115437","html_url":"https://github.com/crabtw/rust-bindgen/issues/109#issuecomment-71115437","issue_url":"https://api.github.com/repos/crabtw/rust-bindgen/issues/109","id":71115437,"user":{"login":"davekong","id":87889,"avatar_url":"https://avatars.githubusercontent.com/u/87889?v=3","gravatar_id":"","url":"https://api.github.com/users/davekong","html_url":"https://github.com/davekong","followers_url":"https://api.github.com/users/davekong/followers","following_url":"https://api.github.com/users/davekong/following{/other_user}","gists_url":"https://api.github.com/users/davekong/gists{/gist_id}","starred_url":"https://api.github.com/users/davekong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davekong/subscriptions","organizations_url":"https://api.github.com/users/davekong/orgs","repos_url":"https://api.github.com/users/davekong/repos","events_url":"https://api.github.com/users/davekong/events{/privacy}","received_events_url":"https://api.github.com/users/davekong/received_events","type":"User","site_admin":false},"created_at":"2015-01-22T22:49:18Z","updated_at":"2015-01-22T22:49:18Z","body":"What if this\r\n```c\r\n/**\r\n *  \\brief The blend mode used in SDL_RenderCopy() and drawing operations.\r\n */\r\ntypedef enum\r\n{\r\n    SDL_BLENDMODE_NONE = 0x00000000,     /**< no blending\r\n                                              dstRGBA = srcRGBA */\r\n    SDL_BLENDMODE_BLEND = 0x00000001,    /**< alpha blending\r\n                                              dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))\r\n                                              dstA = srcA + (dstA * (1-srcA)) */\r\n    SDL_BLENDMODE_ADD = 0x00000002,      /**< additive blending\r\n                                              dstRGB = (srcRGB * srcA) + dstRGB\r\n                                              dstA = dstA */\r\n    SDL_BLENDMODE_MOD = 0x00000004       /**< color modulate\r\n                                              dstRGB = srcRGB * dstRGB\r\n                                              dstA = dstA */\r\n} SDL_BlendMode;\r\n```\r\n\r\ncould be turned into something like this\r\n\r\n```\r\n#[repr(C)]\r\nenum SDL_BlendMode {\r\n    NONE = 0x00_00_00_00,\r\n    BLEND = 0x00_00_00_01,\r\n    ADD = 0x00_00_00_02,\r\n    MOD = 0x00_00_00_04,\r\n}\r\n\r\nimpl CEnum for SDL_BlendMode {\r\n    fn to_c_int(&self) -> c_int {\r\n        *self as c_int\r\n    }\r\n\r\n    fn from_c_int(v: c_int) -> SDL_BlendMode {\r\n        unsafe { mem::transmute(v) }\r\n    }\r\n}\r\n```\r\nThen the C functions can be wrapped using these to and from methods."}}