bottlenoselabs / c2cs

Generate C# bindings from a C header.
MIT License
245 stars 18 forks source link

Introducing attributes and `CNodeAttribute` #116

Closed lithiumtoast closed 1 year ago

lithiumtoast commented 1 year ago

Instead of using comments for the C platform / C file location, use attributes.

E.g.

Before

        // Function @ my_c_library.h:21:28
        //  aarch64-apple-darwin
        //  x86_64-apple-darwin
        [DllImport(LibraryName, CallingConvention = CallingConvention.Cdecl)]
        public static extern void hw_hello_world();

After

        [CNode(Kind = "Function", Platform = "aarch64-apple-darwin", Location = "my_c_library.h:21:28")]
        [CNode(Kind = "Function", Platform = "x86_64-apple-darwin", Location = "my_c_library.h:21:28")]
        [DllImport(LibraryName, CallingConvention = CallingConvention.Cdecl)]
        public static extern void hw_hello_world();