Skip to content

Commit

Permalink
Implement minimal default name mangling (#331)
Browse files Browse the repository at this point in the history
This commit changes name mangling so that there are minimal changes by
default, not attempting to create Haskell-style names.  One significant
difference with the previous implementation is that it can now add a
prefix if/when the first character is not valid, used to handle leading
underscores when creating type constructors.

`MkHsName` is removed, replaced by `mkHsNamePrefixInvalid` and
`mkHsNameDropInvalid` functions that are now passed to `translateName`
like other options.

`ctxFieldVarSingleConstr` is removed since constructors now have the
same name as types by default, and we do not generate sum types anyway.
If we do so in the future, we need to decide how to do name mangling for
constructors as well as accessors.

`HsBindgen.C.Fold.Type.mkDefnName` is changed to follow the conventions
of the new defaults.
  • Loading branch information
TravisCardwell committed Dec 10, 2024
1 parent fa2ce3d commit 69519d3
Show file tree
Hide file tree
Showing 54 changed files with 1,218 additions and 1,189 deletions.
20 changes: 10 additions & 10 deletions hs-bindgen/fixtures/anonymous.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
DeclData (Struct {structName = "CS1c", structConstr = "MkCS1c", structFields = Field {fieldName = "cS1c_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "cS1c_b", fieldType = HsPrimType HsPrimCInt} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CS1c", structConstr = "MkCS1c", structFields = Field {fieldName = "cS1c_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "cS1c_b", fieldType = HsPrimType HsPrimCInt} ::: VNil}) (StorableInstance {storableSizeOf = 8, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CS1c", structConstr = "MkCS1c", structFields = Field {fieldName = "cS1c_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "cS1c_b", fieldType = HsPrimType HsPrimCInt} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 4]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CS1c", structConstr = "MkCS1c", structFields = Field {fieldName = "cS1c_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "cS1c_b", fieldType = HsPrimType HsPrimCInt} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 4 1])))}))
DeclData (Struct {structName = "CS1", structConstr = "MkCS1", structFields = Field {fieldName = "cS1_c", fieldType = HsTypRef "CS1c"} ::: Field {fieldName = "cS1_d", fieldType = HsPrimType HsPrimCInt} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CS1", structConstr = "MkCS1", structFields = Field {fieldName = "cS1_c", fieldType = HsTypRef "CS1c"} ::: Field {fieldName = "cS1_d", fieldType = HsPrimType HsPrimCInt} ::: VNil}) (StorableInstance {storableSizeOf = 12, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CS1", structConstr = "MkCS1", structFields = Field {fieldName = "cS1_c", fieldType = HsTypRef "CS1c"} ::: Field {fieldName = "cS1_d", fieldType = HsPrimType HsPrimCInt} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 8]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CS1", structConstr = "MkCS1", structFields = Field {fieldName = "cS1_c", fieldType = HsTypRef "CS1c"} ::: Field {fieldName = "cS1_d", fieldType = HsPrimType HsPrimCInt} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 8 1])))}))
DeclData (Struct {structName = "CS2innerdeep", structConstr = "MkCS2innerdeep", structFields = Field {fieldName = "cS2innerdeep_b", fieldType = HsPrimType HsPrimCInt} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CS2innerdeep", structConstr = "MkCS2innerdeep", structFields = Field {fieldName = "cS2innerdeep_b", fieldType = HsPrimType HsPrimCInt} ::: VNil}) (StorableInstance {storableSizeOf = 4, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CS2innerdeep", structConstr = "MkCS2innerdeep", structFields = Field {fieldName = "cS2innerdeep_b", fieldType = HsPrimType HsPrimCInt} ::: VNil})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CS2innerdeep", structConstr = "MkCS2innerdeep", structFields = Field {fieldName = "cS2innerdeep_b", fieldType = HsPrimType HsPrimCInt} ::: VNil}) 1 (Seq [PokeByteOff 2 0 0])))}))
DeclData (Struct {structName = "CS2inner", structConstr = "MkCS2inner", structFields = Field {fieldName = "cS2inner_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "cS2inner_deep", fieldType = HsTypRef "CS2innerdeep"} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CS2inner", structConstr = "MkCS2inner", structFields = Field {fieldName = "cS2inner_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "cS2inner_deep", fieldType = HsTypRef "CS2innerdeep"} ::: VNil}) (StorableInstance {storableSizeOf = 8, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CS2inner", structConstr = "MkCS2inner", structFields = Field {fieldName = "cS2inner_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "cS2inner_deep", fieldType = HsTypRef "CS2innerdeep"} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 4]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CS2inner", structConstr = "MkCS2inner", structFields = Field {fieldName = "cS2inner_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "cS2inner_deep", fieldType = HsTypRef "CS2innerdeep"} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 4 1])))}))
DeclData (Struct {structName = "CS2", structConstr = "MkCS2", structFields = Field {fieldName = "cS2_inner", fieldType = HsTypRef "CS2inner"} ::: Field {fieldName = "cS2_d", fieldType = HsPrimType HsPrimCInt} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "CS2", structConstr = "MkCS2", structFields = Field {fieldName = "cS2_inner", fieldType = HsTypRef "CS2inner"} ::: Field {fieldName = "cS2_d", fieldType = HsPrimType HsPrimCInt} ::: VNil}) (StorableInstance {storableSizeOf = 12, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CS2", structConstr = "MkCS2", structFields = Field {fieldName = "cS2_inner", fieldType = HsTypRef "CS2inner"} ::: Field {fieldName = "cS2_d", fieldType = HsPrimType HsPrimCInt} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 8]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CS2", structConstr = "MkCS2", structFields = Field {fieldName = "cS2_inner", fieldType = HsTypRef "CS2inner"} ::: Field {fieldName = "cS2_d", fieldType = HsPrimType HsPrimCInt} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 8 1])))}))
DeclData (Struct {structName = "S1_c", structConstr = "S1_c", structFields = Field {fieldName = "s1_c_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "s1_c_b", fieldType = HsPrimType HsPrimCInt} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "S1_c", structConstr = "S1_c", structFields = Field {fieldName = "s1_c_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "s1_c_b", fieldType = HsPrimType HsPrimCInt} ::: VNil}) (StorableInstance {storableSizeOf = 8, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "S1_c", structConstr = "S1_c", structFields = Field {fieldName = "s1_c_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "s1_c_b", fieldType = HsPrimType HsPrimCInt} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 4]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "S1_c", structConstr = "S1_c", structFields = Field {fieldName = "s1_c_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "s1_c_b", fieldType = HsPrimType HsPrimCInt} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 4 1])))}))
DeclData (Struct {structName = "S1", structConstr = "S1", structFields = Field {fieldName = "s1_c", fieldType = HsTypRef "S1_c"} ::: Field {fieldName = "s1_d", fieldType = HsPrimType HsPrimCInt} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "S1", structConstr = "S1", structFields = Field {fieldName = "s1_c", fieldType = HsTypRef "S1_c"} ::: Field {fieldName = "s1_d", fieldType = HsPrimType HsPrimCInt} ::: VNil}) (StorableInstance {storableSizeOf = 12, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "S1", structConstr = "S1", structFields = Field {fieldName = "s1_c", fieldType = HsTypRef "S1_c"} ::: Field {fieldName = "s1_d", fieldType = HsPrimType HsPrimCInt} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 8]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "S1", structConstr = "S1", structFields = Field {fieldName = "s1_c", fieldType = HsTypRef "S1_c"} ::: Field {fieldName = "s1_d", fieldType = HsPrimType HsPrimCInt} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 8 1])))}))
DeclData (Struct {structName = "S2_inner_deep", structConstr = "S2_inner_deep", structFields = Field {fieldName = "s2_inner_deep_b", fieldType = HsPrimType HsPrimCInt} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "S2_inner_deep", structConstr = "S2_inner_deep", structFields = Field {fieldName = "s2_inner_deep_b", fieldType = HsPrimType HsPrimCInt} ::: VNil}) (StorableInstance {storableSizeOf = 4, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "S2_inner_deep", structConstr = "S2_inner_deep", structFields = Field {fieldName = "s2_inner_deep_b", fieldType = HsPrimType HsPrimCInt} ::: VNil})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "S2_inner_deep", structConstr = "S2_inner_deep", structFields = Field {fieldName = "s2_inner_deep_b", fieldType = HsPrimType HsPrimCInt} ::: VNil}) 1 (Seq [PokeByteOff 2 0 0])))}))
DeclData (Struct {structName = "S2_inner", structConstr = "S2_inner", structFields = Field {fieldName = "s2_inner_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "s2_inner_deep", fieldType = HsTypRef "S2_inner_deep"} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "S2_inner", structConstr = "S2_inner", structFields = Field {fieldName = "s2_inner_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "s2_inner_deep", fieldType = HsTypRef "S2_inner_deep"} ::: VNil}) (StorableInstance {storableSizeOf = 8, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "S2_inner", structConstr = "S2_inner", structFields = Field {fieldName = "s2_inner_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "s2_inner_deep", fieldType = HsTypRef "S2_inner_deep"} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 4]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "S2_inner", structConstr = "S2_inner", structFields = Field {fieldName = "s2_inner_a", fieldType = HsPrimType HsPrimCInt} ::: Field {fieldName = "s2_inner_deep", fieldType = HsTypRef "S2_inner_deep"} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 4 1])))}))
DeclData (Struct {structName = "S2", structConstr = "S2", structFields = Field {fieldName = "s2_inner", fieldType = HsTypRef "S2_inner"} ::: Field {fieldName = "s2_d", fieldType = HsPrimType HsPrimCInt} ::: VNil})
DeclInstance (InstanceStorable (Struct {structName = "S2", structConstr = "S2", structFields = Field {fieldName = "s2_inner", fieldType = HsTypRef "S2_inner"} ::: Field {fieldName = "s2_d", fieldType = HsPrimType HsPrimCInt} ::: VNil}) (StorableInstance {storableSizeOf = 12, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "S2", structConstr = "S2", structFields = Field {fieldName = "s2_inner", fieldType = HsTypRef "S2_inner"} ::: Field {fieldName = "s2_d", fieldType = HsPrimType HsPrimCInt} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 8]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "S2", structConstr = "S2", structFields = Field {fieldName = "s2_inner", fieldType = HsTypRef "S2_inner"} ::: Field {fieldName = "s2_d", fieldType = HsPrimType HsPrimCInt} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 8 1])))}))
74 changes: 37 additions & 37 deletions hs-bindgen/fixtures/anonymous.pp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,123 +6,123 @@ import qualified Foreign as F
import qualified Foreign.C as FC
import Prelude ((<*>), (>>), pure)

data CS1c = MkCS1c
{ cS1c_a :: FC.CInt
, cS1c_b :: FC.CInt
data S1_c = S1_c
{ s1_c_a :: FC.CInt
, s1_c_b :: FC.CInt
}

instance F.Storable CS1c where
instance F.Storable S1_c where

sizeOf = \_ -> 8

alignment = \_ -> 4

peek =
\ptr0 ->
pure MkCS1c
pure S1_c
<*> F.peekByteOff ptr0 0
<*> F.peekByteOff ptr0 4

poke =
\ptr0 ->
\s1 ->
case s1 of
MkCS1c cS1c_a2 cS1c_b3 ->
F.pokeByteOff ptr0 0 cS1c_a2
>> F.pokeByteOff ptr0 4 cS1c_b3
S1_c s1_c_a2 s1_c_b3 ->
F.pokeByteOff ptr0 0 s1_c_a2
>> F.pokeByteOff ptr0 4 s1_c_b3

data CS1 = MkCS1
{ cS1_c :: CS1c
, cS1_d :: FC.CInt
data S1 = S1
{ s1_c :: S1_c
, s1_d :: FC.CInt
}

instance F.Storable CS1 where
instance F.Storable S1 where

sizeOf = \_ -> 12

alignment = \_ -> 4

peek =
\ptr0 ->
pure MkCS1
pure S1
<*> F.peekByteOff ptr0 0
<*> F.peekByteOff ptr0 8

poke =
\ptr0 ->
\s1 ->
case s1 of
MkCS1 cS1_c2 cS1_d3 ->
F.pokeByteOff ptr0 0 cS1_c2
>> F.pokeByteOff ptr0 8 cS1_d3
S1 s1_c2 s1_d3 ->
F.pokeByteOff ptr0 0 s1_c2
>> F.pokeByteOff ptr0 8 s1_d3

data CS2innerdeep = MkCS2innerdeep
{ cS2innerdeep_b :: FC.CInt
data S2_inner_deep = S2_inner_deep
{ s2_inner_deep_b :: FC.CInt
}

instance F.Storable CS2innerdeep where
instance F.Storable S2_inner_deep where

sizeOf = \_ -> 4

alignment = \_ -> 4

peek =
\ptr0 ->
pure MkCS2innerdeep
pure S2_inner_deep
<*> F.peekByteOff ptr0 0

poke =
\ptr0 ->
\s1 ->
case s1 of
MkCS2innerdeep cS2innerdeep_b2 -> F.pokeByteOff ptr0 0 cS2innerdeep_b2
S2_inner_deep s2_inner_deep_b2 -> F.pokeByteOff ptr0 0 s2_inner_deep_b2

data CS2inner = MkCS2inner
{ cS2inner_a :: FC.CInt
, cS2inner_deep :: CS2innerdeep
data S2_inner = S2_inner
{ s2_inner_a :: FC.CInt
, s2_inner_deep :: S2_inner_deep
}

instance F.Storable CS2inner where
instance F.Storable S2_inner where

sizeOf = \_ -> 8

alignment = \_ -> 4

peek =
\ptr0 ->
pure MkCS2inner
pure S2_inner
<*> F.peekByteOff ptr0 0
<*> F.peekByteOff ptr0 4

poke =
\ptr0 ->
\s1 ->
case s1 of
MkCS2inner cS2inner_a2 cS2inner_deep3 ->
F.pokeByteOff ptr0 0 cS2inner_a2
>> F.pokeByteOff ptr0 4 cS2inner_deep3
S2_inner s2_inner_a2 s2_inner_deep3 ->
F.pokeByteOff ptr0 0 s2_inner_a2
>> F.pokeByteOff ptr0 4 s2_inner_deep3

data CS2 = MkCS2
{ cS2_inner :: CS2inner
, cS2_d :: FC.CInt
data S2 = S2
{ s2_inner :: S2_inner
, s2_d :: FC.CInt
}

instance F.Storable CS2 where
instance F.Storable S2 where

sizeOf = \_ -> 12

alignment = \_ -> 4

peek =
\ptr0 ->
pure MkCS2
pure S2
<*> F.peekByteOff ptr0 0
<*> F.peekByteOff ptr0 8

poke =
\ptr0 ->
\s1 ->
case s1 of
MkCS2 cS2_inner2 cS2_d3 ->
F.pokeByteOff ptr0 0 cS2_inner2
>> F.pokeByteOff ptr0 8 cS2_d3
S2 s2_inner2 s2_d3 ->
F.pokeByteOff ptr0 0 s2_inner2
>> F.pokeByteOff ptr0 8 s2_d3
50 changes: 25 additions & 25 deletions hs-bindgen/fixtures/anonymous.th.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
data CS1c = MkCS1c {cS1c_a :: CInt, cS1c_b :: CInt}
instance Storable CS1c
data S1_c = S1_c {s1_c_a :: CInt, s1_c_b :: CInt}
instance Storable S1_c
where {sizeOf = \_ -> 8;
alignment = \_ -> 4;
peek = \ptr_0 -> (pure MkCS1c <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 4;
peek = \ptr_0 -> (pure S1_c <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 4;
poke = \ptr_1 -> \s_2 -> case s_2 of
{MkCS1c cS1c_a_3
cS1c_b_4 -> pokeByteOff ptr_1 0 cS1c_a_3 >> pokeByteOff ptr_1 4 cS1c_b_4}}
data CS1 = MkCS1 {cS1_c :: CS1c, cS1_d :: CInt}
instance Storable CS1
{S1_c s1_c_a_3
s1_c_b_4 -> pokeByteOff ptr_1 0 s1_c_a_3 >> pokeByteOff ptr_1 4 s1_c_b_4}}
data S1 = S1 {s1_c :: S1_c, s1_d :: CInt}
instance Storable S1
where {sizeOf = \_ -> 12;
alignment = \_ -> 4;
peek = \ptr_0 -> (pure MkCS1 <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 8;
peek = \ptr_0 -> (pure S1 <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 8;
poke = \ptr_1 -> \s_2 -> case s_2 of
{MkCS1 cS1_c_3
cS1_d_4 -> pokeByteOff ptr_1 0 cS1_c_3 >> pokeByteOff ptr_1 8 cS1_d_4}}
data CS2innerdeep = MkCS2innerdeep {cS2innerdeep_b :: CInt}
instance Storable CS2innerdeep
{S1 s1_c_3
s1_d_4 -> pokeByteOff ptr_1 0 s1_c_3 >> pokeByteOff ptr_1 8 s1_d_4}}
data S2_inner_deep = S2_inner_deep {s2_inner_deep_b :: CInt}
instance Storable S2_inner_deep
where {sizeOf = \_ -> 4;
alignment = \_ -> 4;
peek = \ptr_0 -> pure MkCS2innerdeep <*> peekByteOff ptr_0 0;
peek = \ptr_0 -> pure S2_inner_deep <*> peekByteOff ptr_0 0;
poke = \ptr_1 -> \s_2 -> case s_2 of
{MkCS2innerdeep cS2innerdeep_b_3 -> pokeByteOff ptr_1 0 cS2innerdeep_b_3}}
data CS2inner
= MkCS2inner {cS2inner_a :: CInt, cS2inner_deep :: CS2innerdeep}
instance Storable CS2inner
{S2_inner_deep s2_inner_deep_b_3 -> pokeByteOff ptr_1 0 s2_inner_deep_b_3}}
data S2_inner
= S2_inner {s2_inner_a :: CInt, s2_inner_deep :: S2_inner_deep}
instance Storable S2_inner
where {sizeOf = \_ -> 8;
alignment = \_ -> 4;
peek = \ptr_0 -> (pure MkCS2inner <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 4;
peek = \ptr_0 -> (pure S2_inner <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 4;
poke = \ptr_1 -> \s_2 -> case s_2 of
{MkCS2inner cS2inner_a_3
cS2inner_deep_4 -> pokeByteOff ptr_1 0 cS2inner_a_3 >> pokeByteOff ptr_1 4 cS2inner_deep_4}}
data CS2 = MkCS2 {cS2_inner :: CS2inner, cS2_d :: CInt}
instance Storable CS2
{S2_inner s2_inner_a_3
s2_inner_deep_4 -> pokeByteOff ptr_1 0 s2_inner_a_3 >> pokeByteOff ptr_1 4 s2_inner_deep_4}}
data S2 = S2 {s2_inner :: S2_inner, s2_d :: CInt}
instance Storable S2
where {sizeOf = \_ -> 12;
alignment = \_ -> 4;
peek = \ptr_0 -> (pure MkCS2 <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 8;
peek = \ptr_0 -> (pure S2 <*> peekByteOff ptr_0 0) <*> peekByteOff ptr_0 8;
poke = \ptr_1 -> \s_2 -> case s_2 of
{MkCS2 cS2_inner_3
cS2_d_4 -> pokeByteOff ptr_1 0 cS2_inner_3 >> pokeByteOff ptr_1 8 cS2_d_4}}
{S2 s2_inner_3
s2_d_4 -> pokeByteOff ptr_1 0 s2_inner_3 >> pokeByteOff ptr_1 8 s2_d_4}}
12 changes: 6 additions & 6 deletions hs-bindgen/fixtures/anonymous.tree-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WrapCHeader
DeclStruct
Struct {
structTag = DefnName
(CName "S1c"),
(CName "S1_c"),
structSizeof = 8,
structAlignment = 4,
structFields = [
Expand Down Expand Up @@ -47,7 +47,7 @@ WrapCHeader
fieldName = CName "c",
fieldOffset = 0,
fieldType = TypeStruct
(DefnName (CName "S1c")),
(DefnName (CName "S1_c")),
fieldSourceLoc = SingleLoc {
singleLocPath = [
"examples",
Expand All @@ -74,7 +74,7 @@ WrapCHeader
DeclStruct
Struct {
structTag = DefnName
(CName "S2innerdeep"),
(CName "S2_inner_deep"),
structSizeof = 4,
structAlignment = 4,
structFields = [
Expand All @@ -98,7 +98,7 @@ WrapCHeader
DeclStruct
Struct {
structTag = DefnName
(CName "S2inner"),
(CName "S2_inner"),
structSizeof = 8,
structAlignment = 4,
structFields = [
Expand All @@ -118,7 +118,7 @@ WrapCHeader
fieldOffset = 32,
fieldType = TypeStruct
(DefnName
(CName "S2innerdeep")),
(CName "S2_inner_deep")),
fieldSourceLoc = SingleLoc {
singleLocPath = [
"examples",
Expand All @@ -142,7 +142,7 @@ WrapCHeader
fieldName = CName "inner",
fieldOffset = 0,
fieldType = TypeStruct
(DefnName (CName "S2inner")),
(DefnName (CName "S2_inner")),
fieldSourceLoc = SingleLoc {
singleLocPath = [
"examples",
Expand Down
Loading

0 comments on commit 69519d3

Please sign in to comment.