{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/ClangSharp/issues/27","repository_url":"https://api.github.com/repos/Microsoft/ClangSharp","labels_url":"https://api.github.com/repos/Microsoft/ClangSharp/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/ClangSharp/issues/27/comments","events_url":"https://api.github.com/repos/Microsoft/ClangSharp/issues/27/events","html_url":"https://github.com/Microsoft/ClangSharp/issues/27","id":367572094,"node_id":"MDU6SXNzdWUzNjc1NzIwOTQ=","number":27,"title":"Multiple issues with ClangSharp","user":{"login":"kaby76","id":11389451,"node_id":"MDQ6VXNlcjExMzg5NDUx","avatar_url":"https://avatars3.githubusercontent.com/u/11389451?v=4","gravatar_id":"","url":"https://api.github.com/users/kaby76","html_url":"https://github.com/kaby76","followers_url":"https://api.github.com/users/kaby76/followers","following_url":"https://api.github.com/users/kaby76/following{/other_user}","gists_url":"https://api.github.com/users/kaby76/gists{/gist_id}","starred_url":"https://api.github.com/users/kaby76/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaby76/subscriptions","organizations_url":"https://api.github.com/users/kaby76/orgs","repos_url":"https://api.github.com/users/kaby76/repos","events_url":"https://api.github.com/users/kaby76/events{/privacy}","received_events_url":"https://api.github.com/users/kaby76/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-07T16:50:20Z","updated_at":"2018-10-29T16:29:50Z","closed_at":"2018-10-29T16:29:49Z","author_association":"NONE","body":"I'm looking to replace my SWIG generated and ManagedCuda wrappers for CUDA with a ClangSharp-generated wrapper (SWIG rules are just to arcane). ClangSharpPInvokeGenerator looks promising, but there are several issues:\r\n\r\n1) ClangSharp seems to be in two locations: https://github.com/Microsoft/ClangSharp and as a sub project in LLVM https://github.com/Microsoft/LLVMSharp/tree/master/tools/ClangSharpPInvokeGenerator\r\nWhich is it? I assume https://github.com/Microsoft/ClangSharp is the correct source as it was more recently updated.\r\n\r\n2) In cuda.h, there are many typedef declarations, for example:\r\n\r\n`typedef enum CUaddress_mode_enum {\r\n    CU_TR_ADDRESS_MODE_WRAP   = 0, /**< Wrapping address mode */\r\n    CU_TR_ADDRESS_MODE_CLAMP  = 1, /**< Clamp to edge address mode */\r\n    CU_TR_ADDRESS_MODE_MIRROR = 2, /**< Mirror address mode */\r\n    CU_TR_ADDRESS_MODE_BORDER = 3  /**< Border address mode */\r\n} CUaddress_mode;`\r\n\r\nThe generator handles the enum, but not the typedef. A \"using ... = ...\" might be appropriate.\r\n\r\n3) The generator does not handle C unions, nor anonymous types well. In cuda.h, there is the following decl:\r\n\r\n`    union {\r\n        struct {\r\n            CUarray hArray;                   /**< CUDA array */\r\n        } array;\r\n        struct {\r\n            CUmipmappedArray hMipmappedArray; /**< CUDA mipmapped array */\r\n        } mipmap;\r\n        struct {\r\n            CUdeviceptr devPtr;               /**< Device pointer */\r\n            CUarray_format format;            /**< Array format */\r\n            unsigned int numChannels;         /**< Channels per array element */\r\n            size_t sizeInBytes;               /**< Size in bytes */\r\n        } linear;\r\n        struct {\r\n            CUdeviceptr devPtr;               /**< Device pointer */\r\n            CUarray_format format;            /**< Array format */\r\n            unsigned int numChannels;         /**< Channels per array element */\r\n            size_t width;                     /**< Width of the array in elements */\r\n            size_t height;                    /**< Height of the array in elements */\r\n            size_t pitchInBytes;              /**< Pitch between two rows in bytes */\r\n        } pitch2D;\r\n        struct {\r\n            int reserved[32];\r\n        } reserved;\r\n    } res;\r\n`\r\n\r\nThe generator bypasses unions completely. For anonymous structs (e.g., contained in the above union), the generator assigns the name \"_\" as the anonymous type name, but it should make it unique, eg \"_\" + int_id++, because after creating the type, it tests to see if the type was declared previously, and thinks that it was already declared.\r\n\r\nI'm planning on a patch for ClangSharp to fix these problems in the next couple days as I'd like to get the tool to work with CUDA asap so I can get back to work on my C#/CIL compiler for GPUs.\r\n\r\nKen Domino"},"comment":{"url":"https://api.github.com/repos/Microsoft/ClangSharp/issues/comments/433979433","html_url":"https://github.com/Microsoft/ClangSharp/issues/27#issuecomment-433979433","issue_url":"https://api.github.com/repos/Microsoft/ClangSharp/issues/27","id":433979433,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzk3OTQzMw==","user":{"login":"kaby76","id":11389451,"node_id":"MDQ6VXNlcjExMzg5NDUx","avatar_url":"https://avatars3.githubusercontent.com/u/11389451?v=4","gravatar_id":"","url":"https://api.github.com/users/kaby76","html_url":"https://github.com/kaby76","followers_url":"https://api.github.com/users/kaby76/followers","following_url":"https://api.github.com/users/kaby76/following{/other_user}","gists_url":"https://api.github.com/users/kaby76/gists{/gist_id}","starred_url":"https://api.github.com/users/kaby76/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaby76/subscriptions","organizations_url":"https://api.github.com/users/kaby76/orgs","repos_url":"https://api.github.com/users/kaby76/repos","events_url":"https://api.github.com/users/kaby76/events{/privacy}","received_events_url":"https://api.github.com/users/kaby76/received_events","type":"User","site_admin":false},"created_at":"2018-10-29T16:29:49Z","updated_at":"2018-10-29T16:29:49Z","author_association":"NONE","body":"I've decided to write an entirely new P/Invoke generator based on Clang AST matchers and code templates. Therefore, I am closing this issue."}}
{"actor":{"display_login":"kaby76"}}