Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PrimBool #321

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hs-bindgen/examples/bool.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ struct bools2 {
bool x;
bool y;
};

#define BOOL _Bool

struct bools3 {
BOOL x;
BOOL y;
};
11 changes: 7 additions & 4 deletions hs-bindgen/fixtures/bool.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
DeclData (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = ("cBools1_x",HsPrimType HsPrimVoid) ::: ("cBools1_y",HsPrimType HsPrimVoid) ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = ("cBools1_x",HsPrimType HsPrimVoid) ::: ("cBools1_y",HsPrimType HsPrimVoid) ::: VNil}) (StorableInstance {storableSizeOf = 2, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = ("cBools1_x",HsPrimType HsPrimVoid) ::: ("cBools1_y",HsPrimType HsPrimVoid) ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 1]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = ("cBools1_x",HsPrimType HsPrimVoid) ::: ("cBools1_y",HsPrimType HsPrimVoid) ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 1 1])))}))
DeclData (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = ("cBools2_x",HsTypRef "CBool'") ::: ("cBools2_y",HsTypRef "CBool'") ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = ("cBools2_x",HsTypRef "CBool'") ::: ("cBools2_y",HsTypRef "CBool'") ::: VNil}) (StorableInstance {storableSizeOf = 2, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = ("cBools2_x",HsTypRef "CBool'") ::: ("cBools2_y",HsTypRef "CBool'") ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 1]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = ("cBools2_x",HsTypRef "CBool'") ::: ("cBools2_y",HsTypRef "CBool'") ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 1 1])))}))
DeclNewtype (Newtype {newtypeName = "CBOOL", newtypeConstr = "MkCBOOL", newtypeField = "unCBOOL", newtypeType = HsPrimType HsPrimCBool})
DeclData (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = ("cBools1_x",HsPrimType HsPrimCBool) ::: ("cBools1_y",HsPrimType HsPrimCBool) ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = ("cBools1_x",HsPrimType HsPrimCBool) ::: ("cBools1_y",HsPrimType HsPrimCBool) ::: VNil}) (StorableInstance {storableSizeOf = 2, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = ("cBools1_x",HsPrimType HsPrimCBool) ::: ("cBools1_y",HsPrimType HsPrimCBool) ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 1]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = ("cBools1_x",HsPrimType HsPrimCBool) ::: ("cBools1_y",HsPrimType HsPrimCBool) ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 1 1])))}))
DeclData (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = ("cBools2_x",HsPrimType HsPrimCBool) ::: ("cBools2_y",HsPrimType HsPrimCBool) ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = ("cBools2_x",HsPrimType HsPrimCBool) ::: ("cBools2_y",HsPrimType HsPrimCBool) ::: VNil}) (StorableInstance {storableSizeOf = 2, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = ("cBools2_x",HsPrimType HsPrimCBool) ::: ("cBools2_y",HsPrimType HsPrimCBool) ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 1]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = ("cBools2_x",HsPrimType HsPrimCBool) ::: ("cBools2_y",HsPrimType HsPrimCBool) ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 1 1])))}))
DeclData (Struct {structName = "CBools3", structConstr = "MkCBools3", structFields = ("cBools3_x",HsTypRef "CBOOL") ::: ("cBools3_y",HsTypRef "CBOOL") ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CBools3", structConstr = "MkCBools3", structFields = ("cBools3_x",HsTypRef "CBOOL") ::: ("cBools3_y",HsTypRef "CBOOL") ::: VNil}) (StorableInstance {storableSizeOf = 2, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CBools3", structConstr = "MkCBools3", structFields = ("cBools3_x",HsTypRef "CBOOL") ::: ("cBools3_y",HsTypRef "CBOOL") ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 1]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CBools3", structConstr = "MkCBools3", structFields = ("cBools3_x",HsTypRef "CBOOL") ::: ("cBools3_y",HsTypRef "CBOOL") ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 1 1])))}))
39 changes: 34 additions & 5 deletions hs-bindgen/fixtures/bool.pp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

module Example where

import Data.Void (Void)
import qualified Foreign as F
import qualified Foreign.C as FC
import Prelude ((<*>), (>>), pure)

newtype CBOOL = MkCBOOL
{ unCBOOL :: FC.CBool
}

data CBools1 = MkCBools1
{ cBools1_x :: Void
, cBools1_y :: Void
{ cBools1_x :: FC.CBool
, cBools1_y :: FC.CBool
}

instance F.Storable CBools1 where
Expand All @@ -32,8 +36,8 @@ instance F.Storable CBools1 where
>> F.pokeByteOff ptr0 1 cBools1_y3

data CBools2 = MkCBools2
{ cBools2_x :: CBool'
, cBools2_y :: CBool'
{ cBools2_x :: FC.CBool
, cBools2_y :: FC.CBool
}

instance F.Storable CBools2 where
Expand All @@ -55,3 +59,28 @@ instance F.Storable CBools2 where
MkCBools2 cBools2_x2 cBools2_y3 ->
F.pokeByteOff ptr0 0 cBools2_x2
>> F.pokeByteOff ptr0 1 cBools2_y3

data CBools3 = MkCBools3
{ cBools3_x :: CBOOL
, cBools3_y :: CBOOL
}

instance F.Storable CBools3 where

sizeOf = \_ -> 2

alignment = \_ -> 1

peek =
\ptr0 ->
pure MkCBools3
<*> F.peekByteOff ptr0 0
<*> F.peekByteOff ptr0 1

poke =
\ptr0 ->
\s1 ->
case s1 of
MkCBools3 cBools3_x2 cBools3_y3 ->
F.pokeByteOff ptr0 0 cBools3_x2
>> F.pokeByteOff ptr0 1 cBools3_y3
13 changes: 13 additions & 0 deletions hs-bindgen/fixtures/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,16 @@ const _: () = {
["Offset of field: bools2::x"][::std::mem::offset_of!(bools2, x) - 0usize];
["Offset of field: bools2::y"][::std::mem::offset_of!(bools2, y) - 1usize];
};
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct bools3 {
pub x: bool,
pub y: bool,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of bools3"][::std::mem::size_of::<bools3>() - 2usize];
["Alignment of bools3"][::std::mem::align_of::<bools3>() - 1usize];
["Offset of field: bools3::x"][::std::mem::offset_of!(bools3, x) - 0usize];
["Offset of field: bools3::y"][::std::mem::offset_of!(bools3, y) - 1usize];
};
13 changes: 11 additions & 2 deletions hs-bindgen/fixtures/bool.th.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
data CBools1 = MkCBools1 {cBools1_x :: Void, cBools1_y :: Void}
newtype CBOOL = MkCBOOL {unCBOOL :: CBool}
data CBools1 = MkCBools1 {cBools1_x :: CBool, cBools1_y :: CBool}
instance Storable CBools1
where {sizeOf = \_ -> 2;
alignment = \_ -> 1;
peek = \ptr_0 -> (pure MkCBools1 <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 1;
poke = \ptr_1 -> \s_2 -> case s_2 of
{MkCBools1 cBools1_x_3
cBools1_y_4 -> pokeByteOff ptr_1 0 cBools1_x_3 >> pokeByteOff ptr_1 1 cBools1_y_4}}
data CBools2 = MkCBools2 {cBools2_x :: CBool', cBools2_y :: CBool'}
data CBools2 = MkCBools2 {cBools2_x :: CBool, cBools2_y :: CBool}
instance Storable CBools2
where {sizeOf = \_ -> 2;
alignment = \_ -> 1;
peek = \ptr_0 -> (pure MkCBools2 <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 1;
poke = \ptr_1 -> \s_2 -> case s_2 of
{MkCBools2 cBools2_x_3
cBools2_y_4 -> pokeByteOff ptr_1 0 cBools2_x_3 >> pokeByteOff ptr_1 1 cBools2_y_4}}
data CBools3 = MkCBools3 {cBools3_x :: CBOOL, cBools3_y :: CBOOL}
instance Storable CBools3
where {sizeOf = \_ -> 2;
alignment = \_ -> 1;
peek = \ptr_0 -> (pure MkCBools3 <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 1;
poke = \ptr_1 -> \s_2 -> case s_2 of
{MkCBools3 cBools3_x_3
cBools3_y_4 -> pokeByteOff ptr_1 0 cBools3_x_3 >> pokeByteOff ptr_1 1 cBools3_y_4}}
42 changes: 38 additions & 4 deletions hs-bindgen/fixtures/bool.tree-diff.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
WrapCHeader
(Header
[
DeclMacro
MacroDecl {
macroDeclMacro = Macro {
macroLoc = MultiLoc {
multiLocExpansion = SingleLoc {
singleLocPath = [
"examples",
"bool.h"],
singleLocLine = 13,
singleLocColumn = 9},
multiLocPresumed = Nothing,
multiLocSpelling = Nothing,
multiLocFile = Nothing},
macroName = CName "BOOL",
macroArgs = [],
macroBody = MTerm
(MType PrimBool)},
macroDeclMacroTy = "PrimTy"},
DeclStruct
Struct {
structTag = DefnName
Expand All @@ -11,26 +29,42 @@ WrapCHeader
StructField {
fieldName = CName "x",
fieldOffset = 0,
fieldType = TypePrim PrimVoid},
fieldType = TypePrim PrimBool},
StructField {
fieldName = CName "y",
fieldOffset = 8,
fieldType = TypePrim
PrimVoid}]},
PrimBool}]},
DeclStruct
Struct {
structTag = DefnName
(CName "bools2"),
structSizeof = 2,
structAlignment = 1,
structFields = [
StructField {
fieldName = CName "x",
fieldOffset = 0,
fieldType = TypePrim PrimBool},
StructField {
fieldName = CName "y",
fieldOffset = 8,
fieldType = TypePrim
PrimBool}]},
DeclStruct
Struct {
structTag = DefnName
(CName "bools3"),
structSizeof = 2,
structAlignment = 1,
structFields = [
StructField {
fieldName = CName "x",
fieldOffset = 0,
fieldType = TypeTypedef
(CName "bool")},
(CName "BOOL")},
StructField {
fieldName = CName "y",
fieldOffset = 8,
fieldType = TypeTypedef
(CName "bool")}]}])
(CName "BOOL")}]}])
4 changes: 2 additions & 2 deletions hs-bindgen/fixtures/distilled_lib_1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ DeclNewtype (Newtype {newtypeName = "CUint16T", newtypeConstr = "MkCUint16T", ne
DeclNewtypeInstance Storable "CUint16T"
DeclNewtype (Newtype {newtypeName = "CUint32T", newtypeConstr = "MkCUint32T", newtypeField = "unCUint32T", newtypeType = HsPrimType HsPrimCUInt})
DeclNewtypeInstance Storable "CUint32T"
DeclData (Struct {structName = "CATypedefStruct", structConstr = "MkCATypedefStruct", structFields = ("cATypedefStruct_field_0",HsTypRef "CBool'") ::: ("cATypedefStruct_field_1",HsTypRef "CUint8T") ::: ("cATypedefStruct_field_2",HsTypRef "CUint16T") ::: ("cATypedefStruct_field_3",HsTypRef "CUint32T") ::: ("cATypedefStruct_field_4",HsTypRef "CAnotherTypedefStructT") ::: ("cATypedefStruct_field_5",HsPtr (HsTypRef "CAnotherTypedefStructT")) ::: ("cATypedefStruct_field_6",HsPtr (HsPrimType HsPrimVoid)) ::: ("cATypedefStruct_field_7",HsConstArray 7 (HsTypRef "CUint32T")) ::: ("cATypedefStruct_field_8",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_9",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_10",HsTypRef "CAnotherTypedefEnumE") ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CATypedefStruct", structConstr = "MkCATypedefStruct", structFields = ("cATypedefStruct_field_0",HsTypRef "CBool'") ::: ("cATypedefStruct_field_1",HsTypRef "CUint8T") ::: ("cATypedefStruct_field_2",HsTypRef "CUint16T") ::: ("cATypedefStruct_field_3",HsTypRef "CUint32T") ::: ("cATypedefStruct_field_4",HsTypRef "CAnotherTypedefStructT") ::: ("cATypedefStruct_field_5",HsPtr (HsTypRef "CAnotherTypedefStructT")) ::: ("cATypedefStruct_field_6",HsPtr (HsPrimType HsPrimVoid)) ::: ("cATypedefStruct_field_7",HsConstArray 7 (HsTypRef "CUint32T")) ::: ("cATypedefStruct_field_8",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_9",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_10",HsTypRef "CAnotherTypedefEnumE") ::: VNil}) (StorableInstance {storableSizeOf = 140, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CATypedefStruct", structConstr = "MkCATypedefStruct", structFields = ("cATypedefStruct_field_0",HsTypRef "CBool'") ::: ("cATypedefStruct_field_1",HsTypRef "CUint8T") ::: ("cATypedefStruct_field_2",HsTypRef "CUint16T") ::: ("cATypedefStruct_field_3",HsTypRef "CUint32T") ::: ("cATypedefStruct_field_4",HsTypRef "CAnotherTypedefStructT") ::: ("cATypedefStruct_field_5",HsPtr (HsTypRef "CAnotherTypedefStructT")) ::: ("cATypedefStruct_field_6",HsPtr (HsPrimType HsPrimVoid)) ::: ("cATypedefStruct_field_7",HsConstArray 7 (HsTypRef "CUint32T")) ::: ("cATypedefStruct_field_8",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_9",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_10",HsTypRef "CAnotherTypedefEnumE") ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 1,PeekByteOff 0 2,PeekByteOff 0 4,PeekByteOff 0 8,PeekByteOff 0 16,PeekByteOff 0 24,PeekByteOff 0 32,PeekByteOff 0 60,PeekByteOff 0 64,PeekByteOff 0 80]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CATypedefStruct", structConstr = "MkCATypedefStruct", structFields = ("cATypedefStruct_field_0",HsTypRef "CBool'") ::: ("cATypedefStruct_field_1",HsTypRef "CUint8T") ::: ("cATypedefStruct_field_2",HsTypRef "CUint16T") ::: ("cATypedefStruct_field_3",HsTypRef "CUint32T") ::: ("cATypedefStruct_field_4",HsTypRef "CAnotherTypedefStructT") ::: ("cATypedefStruct_field_5",HsPtr (HsTypRef "CAnotherTypedefStructT")) ::: ("cATypedefStruct_field_6",HsPtr (HsPrimType HsPrimVoid)) ::: ("cATypedefStruct_field_7",HsConstArray 7 (HsTypRef "CUint32T")) ::: ("cATypedefStruct_field_8",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_9",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_10",HsTypRef "CAnotherTypedefEnumE") ::: VNil}) 11 (Seq [PokeByteOff 12 0 0,PokeByteOff 12 1 1,PokeByteOff 12 2 2,PokeByteOff 12 4 3,PokeByteOff 12 8 4,PokeByteOff 12 16 5,PokeByteOff 12 24 6,PokeByteOff 12 32 7,PokeByteOff 12 60 8,PokeByteOff 12 64 9,PokeByteOff 12 80 10])))}))
DeclData (Struct {structName = "CATypedefStruct", structConstr = "MkCATypedefStruct", structFields = ("cATypedefStruct_field_0",HsPrimType HsPrimCBool) ::: ("cATypedefStruct_field_1",HsTypRef "CUint8T") ::: ("cATypedefStruct_field_2",HsTypRef "CUint16T") ::: ("cATypedefStruct_field_3",HsTypRef "CUint32T") ::: ("cATypedefStruct_field_4",HsTypRef "CAnotherTypedefStructT") ::: ("cATypedefStruct_field_5",HsPtr (HsTypRef "CAnotherTypedefStructT")) ::: ("cATypedefStruct_field_6",HsPtr (HsPrimType HsPrimVoid)) ::: ("cATypedefStruct_field_7",HsConstArray 7 (HsTypRef "CUint32T")) ::: ("cATypedefStruct_field_8",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_9",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_10",HsTypRef "CAnotherTypedefEnumE") ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CATypedefStruct", structConstr = "MkCATypedefStruct", structFields = ("cATypedefStruct_field_0",HsPrimType HsPrimCBool) ::: ("cATypedefStruct_field_1",HsTypRef "CUint8T") ::: ("cATypedefStruct_field_2",HsTypRef "CUint16T") ::: ("cATypedefStruct_field_3",HsTypRef "CUint32T") ::: ("cATypedefStruct_field_4",HsTypRef "CAnotherTypedefStructT") ::: ("cATypedefStruct_field_5",HsPtr (HsTypRef "CAnotherTypedefStructT")) ::: ("cATypedefStruct_field_6",HsPtr (HsPrimType HsPrimVoid)) ::: ("cATypedefStruct_field_7",HsConstArray 7 (HsTypRef "CUint32T")) ::: ("cATypedefStruct_field_8",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_9",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_10",HsTypRef "CAnotherTypedefEnumE") ::: VNil}) (StorableInstance {storableSizeOf = 140, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CATypedefStruct", structConstr = "MkCATypedefStruct", structFields = ("cATypedefStruct_field_0",HsPrimType HsPrimCBool) ::: ("cATypedefStruct_field_1",HsTypRef "CUint8T") ::: ("cATypedefStruct_field_2",HsTypRef "CUint16T") ::: ("cATypedefStruct_field_3",HsTypRef "CUint32T") ::: ("cATypedefStruct_field_4",HsTypRef "CAnotherTypedefStructT") ::: ("cATypedefStruct_field_5",HsPtr (HsTypRef "CAnotherTypedefStructT")) ::: ("cATypedefStruct_field_6",HsPtr (HsPrimType HsPrimVoid)) ::: ("cATypedefStruct_field_7",HsConstArray 7 (HsTypRef "CUint32T")) ::: ("cATypedefStruct_field_8",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_9",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_10",HsTypRef "CAnotherTypedefEnumE") ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 1,PeekByteOff 0 2,PeekByteOff 0 4,PeekByteOff 0 8,PeekByteOff 0 16,PeekByteOff 0 24,PeekByteOff 0 32,PeekByteOff 0 60,PeekByteOff 0 64,PeekByteOff 0 80]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CATypedefStruct", structConstr = "MkCATypedefStruct", structFields = ("cATypedefStruct_field_0",HsPrimType HsPrimCBool) ::: ("cATypedefStruct_field_1",HsTypRef "CUint8T") ::: ("cATypedefStruct_field_2",HsTypRef "CUint16T") ::: ("cATypedefStruct_field_3",HsTypRef "CUint32T") ::: ("cATypedefStruct_field_4",HsTypRef "CAnotherTypedefStructT") ::: ("cATypedefStruct_field_5",HsPtr (HsTypRef "CAnotherTypedefStructT")) ::: ("cATypedefStruct_field_6",HsPtr (HsPrimType HsPrimVoid)) ::: ("cATypedefStruct_field_7",HsConstArray 7 (HsTypRef "CUint32T")) ::: ("cATypedefStruct_field_8",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_9",HsTypRef "CAnotherTypedefEnumE") ::: ("cATypedefStruct_field_10",HsTypRef "CAnotherTypedefEnumE") ::: VNil}) 11 (Seq [PokeByteOff 12 0 0,PokeByteOff 12 1 1,PokeByteOff 12 2 2,PokeByteOff 12 4 3,PokeByteOff 12 8 4,PokeByteOff 12 16 5,PokeByteOff 12 24 6,PokeByteOff 12 32 7,PokeByteOff 12 60 8,PokeByteOff 12 64 9,PokeByteOff 12 80 10])))}))
DeclNewtype (Newtype {newtypeName = "CATypedefStructT", newtypeConstr = "MkCATypedefStructT", newtypeField = "unCATypedefStructT", newtypeType = HsTypRef "CATypedefStruct"})
DeclNewtypeInstance Storable "CATypedefStructT"
DeclNewtype (Newtype {newtypeName = "CATypedefEnumE", newtypeConstr = "MkCATypedefEnumE", newtypeField = "unCATypedefEnumE", newtypeType = HsPrimType HsPrimCSChar})
Expand Down
2 changes: 1 addition & 1 deletion hs-bindgen/fixtures/distilled_lib_1.pp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ newtype CUint32T = MkCUint32T
deriving newtype instance F.Storable CUint32T

data CATypedefStruct = MkCATypedefStruct
{ cATypedefStruct_field_0 :: CBool'
{ cATypedefStruct_field_0 :: FC.CBool
, cATypedefStruct_field_1 :: CUint8T
, cATypedefStruct_field_2 :: CUint16T
, cATypedefStruct_field_3 :: CUint32T
Expand Down
2 changes: 1 addition & 1 deletion hs-bindgen/fixtures/distilled_lib_1.th.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ deriving newtype instance Storable CUint16T
newtype CUint32T = MkCUint32T {unCUint32T :: CUInt}
deriving newtype instance Storable CUint32T
data CATypedefStruct
= MkCATypedefStruct {cATypedefStruct_field_0 :: CBool',
= MkCATypedefStruct {cATypedefStruct_field_0 :: CBool,
cATypedefStruct_field_1 :: CUint8T,
cATypedefStruct_field_2 :: CUint16T,
cATypedefStruct_field_3 :: CUint32T,
Expand Down
3 changes: 1 addition & 2 deletions hs-bindgen/fixtures/distilled_lib_1.tree-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,7 @@ WrapCHeader
StructField {
fieldName = CName "field_0",
fieldOffset = 0,
fieldType = TypeTypedef
(CName "bool")},
fieldType = TypePrim PrimBool},
StructField {
fieldName = CName "field_1",
fieldOffset = 8,
Expand Down
3 changes: 3 additions & 0 deletions hs-bindgen/src/HsBindgen/C/AST/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ data PrimType =

-- | @void@
| PrimVoid

-- | @_Bool@
| PrimBool
deriving stock (Show, Eq, Ord, Generic)
deriving anyclass (PrettyVal)

Expand Down
Loading
Loading