Avoid typedefs
This makes the header simpler, and silences `hs-bindgen` notices about "squashed" typedefs.
This commit is contained in:
parent
9ca4f615d8
commit
e977181252
@ -30,6 +30,7 @@ cbindgen \
|
||||
--lang c \
|
||||
--crate garnet-rs \
|
||||
--output "$HEADER" \
|
||||
--style tag \
|
||||
"$RUST_DIR"
|
||||
|
||||
echo " Raw header written to $HEADER"
|
||||
|
||||
@ -40,7 +40,7 @@ import Prelude ((<*>), (>>), Eq, Int, Ord, Read, Show, pure, showsPrec)
|
||||
|
||||
{-| __C declaration:__ @struct T@
|
||||
|
||||
__defined at:__ @garnet_rs.h 6:16@
|
||||
__defined at:__ @garnet_rs.h 6:8@
|
||||
|
||||
__exported by:__ @garnet_rs.h@
|
||||
-}
|
||||
@ -115,7 +115,7 @@ instance ( TyEq ty ((HsBindgen.Runtime.HasCField.CFieldType T) "b")
|
||||
|
||||
{-| __C declaration:__ @enum Shape_Tag@
|
||||
|
||||
__defined at:__ @garnet_rs.h 11:14@
|
||||
__defined at:__ @garnet_rs.h 11:6@
|
||||
|
||||
__exported by:__ @garnet_rs.h@
|
||||
-}
|
||||
@ -226,7 +226,7 @@ pattern Rectangle = Shape_Tag 1
|
||||
|
||||
{-| __C declaration:__ @struct Circle_Body@
|
||||
|
||||
__defined at:__ @garnet_rs.h 16:16@
|
||||
__defined at:__ @garnet_rs.h 16:8@
|
||||
|
||||
__exported by:__ @garnet_rs.h@
|
||||
-}
|
||||
@ -280,7 +280,7 @@ instance ( TyEq ty ((HsBindgen.Runtime.HasCField.CFieldType Circle_Body) "radius
|
||||
|
||||
{-| __C declaration:__ @struct Rectangle_Body@
|
||||
|
||||
__defined at:__ @garnet_rs.h 20:16@
|
||||
__defined at:__ @garnet_rs.h 20:8@
|
||||
|
||||
__exported by:__ @garnet_rs.h@
|
||||
-}
|
||||
@ -378,7 +378,7 @@ deriving via HsBindgen.Runtime.Marshal.EquivStorable Shape_body instance F.Stora
|
||||
|
||||
__C declaration:__ @circle@
|
||||
|
||||
__defined at:__ @garnet_rs.h 28:17@
|
||||
__defined at:__ @garnet_rs.h 28:24@
|
||||
|
||||
__exported by:__ @garnet_rs.h@
|
||||
-}
|
||||
@ -405,7 +405,7 @@ set_shape_body_circle =
|
||||
|
||||
__C declaration:__ @rectangle@
|
||||
|
||||
__defined at:__ @garnet_rs.h 29:20@
|
||||
__defined at:__ @garnet_rs.h 29:27@
|
||||
|
||||
__exported by:__ @garnet_rs.h@
|
||||
-}
|
||||
@ -453,7 +453,7 @@ instance ( TyEq ty ((HsBindgen.Runtime.HasCField.CFieldType Shape_body) "rectang
|
||||
|
||||
{-| __C declaration:__ @struct Shape@
|
||||
|
||||
__defined at:__ @garnet_rs.h 25:16@
|
||||
__defined at:__ @garnet_rs.h 25:8@
|
||||
|
||||
__exported by:__ @garnet_rs.h@
|
||||
-}
|
||||
@ -461,7 +461,7 @@ data Shape = Shape
|
||||
{ tag :: Shape_Tag
|
||||
{- ^ __C declaration:__ @tag@
|
||||
|
||||
__defined at:__ @garnet_rs.h 26:13@
|
||||
__defined at:__ @garnet_rs.h 26:18@
|
||||
|
||||
__exported by:__ @garnet_rs.h@
|
||||
-}
|
||||
|
||||
@ -3,32 +3,32 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct T {
|
||||
struct T {
|
||||
bool a;
|
||||
uint8_t b;
|
||||
} T;
|
||||
};
|
||||
|
||||
typedef enum Shape_Tag {
|
||||
enum Shape_Tag {
|
||||
Circle,
|
||||
Rectangle,
|
||||
} Shape_Tag;
|
||||
};
|
||||
|
||||
typedef struct Circle_Body {
|
||||
struct Circle_Body {
|
||||
double radius;
|
||||
} Circle_Body;
|
||||
};
|
||||
|
||||
typedef struct Rectangle_Body {
|
||||
struct Rectangle_Body {
|
||||
double width;
|
||||
double height;
|
||||
} Rectangle_Body;
|
||||
};
|
||||
|
||||
typedef struct Shape {
|
||||
Shape_Tag tag;
|
||||
struct Shape {
|
||||
enum Shape_Tag tag;
|
||||
union {
|
||||
Circle_Body circle;
|
||||
Rectangle_Body rectangle;
|
||||
struct Circle_Body circle;
|
||||
struct Rectangle_Body rectangle;
|
||||
} body;
|
||||
} Shape;
|
||||
};
|
||||
|
||||
void hello(const char *c);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user