-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a type spelling field to the following ASTs: * `C` phase: `Struct`, `Enu`, `Typedef` * Type: `Text` * `Hs` phase: `Struct`, `Newtype` * Type: `Maybe Text` * `SHs` phase: `Record`, `Newtype` * Type: `Maybe Text` As suggested in #316, the string is not parsed. This commit simply uses `Text`, but we could implement a `newtype` wrapper if desired. The goal is to make it easier to generate tests for structures, enumerations, and `typedef`s of structures/enumerations. Note that this is also required for unions, but those are not implemented yet. This is the minimal change required to do this; the `Maybe` is needed because it does *not* track the type spelling for macros. (Cherry-picked from `source-info` for experimentation)
- Loading branch information
1 parent
3e53b8e
commit 3e76979
Showing
36 changed files
with
248 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
DeclData (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = Field {fieldName = "cBools1_x", fieldType = HsPrimType HsPrimVoid} ::: Field {fieldName = "cBools1_y", fieldType = HsPrimType HsPrimVoid} ::: VNil}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = Field {fieldName = "cBools1_x", fieldType = HsPrimType HsPrimVoid} ::: Field {fieldName = "cBools1_y", fieldType = HsPrimType HsPrimVoid} ::: VNil}) (StorableInstance {storableSizeOf = 2, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = Field {fieldName = "cBools1_x", fieldType = HsPrimType HsPrimVoid} ::: Field {fieldName = "cBools1_y", fieldType = HsPrimType HsPrimVoid} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 1]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = Field {fieldName = "cBools1_x", fieldType = HsPrimType HsPrimVoid} ::: Field {fieldName = "cBools1_y", fieldType = HsPrimType HsPrimVoid} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 1 1])))})) | ||
DeclData (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = Field {fieldName = "cBools2_x", fieldType = HsTypRef "CBool'"} ::: Field {fieldName = "cBools2_y", fieldType = HsTypRef "CBool'"} ::: VNil}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = Field {fieldName = "cBools2_x", fieldType = HsTypRef "CBool'"} ::: Field {fieldName = "cBools2_y", fieldType = HsTypRef "CBool'"} ::: VNil}) (StorableInstance {storableSizeOf = 2, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = Field {fieldName = "cBools2_x", fieldType = HsTypRef "CBool'"} ::: Field {fieldName = "cBools2_y", fieldType = HsTypRef "CBool'"} ::: VNil})) [PeekByteOff 0 0,PeekByteOff 0 1]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = Field {fieldName = "cBools2_x", fieldType = HsTypRef "CBool'"} ::: Field {fieldName = "cBools2_y", fieldType = HsTypRef "CBool'"} ::: VNil}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 1 1])))})) | ||
DeclData (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = Field {fieldName = "cBools1_x", fieldType = HsPrimType HsPrimVoid} ::: Field {fieldName = "cBools1_y", fieldType = HsPrimType HsPrimVoid} ::: VNil, structTypeSpelling = Just "struct bools1"}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = Field {fieldName = "cBools1_x", fieldType = HsPrimType HsPrimVoid} ::: Field {fieldName = "cBools1_y", fieldType = HsPrimType HsPrimVoid} ::: VNil, structTypeSpelling = Just "struct bools1"}) (StorableInstance {storableSizeOf = 2, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = Field {fieldName = "cBools1_x", fieldType = HsPrimType HsPrimVoid} ::: Field {fieldName = "cBools1_y", fieldType = HsPrimType HsPrimVoid} ::: VNil, structTypeSpelling = Just "struct bools1"})) [PeekByteOff 0 0,PeekByteOff 0 1]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CBools1", structConstr = "MkCBools1", structFields = Field {fieldName = "cBools1_x", fieldType = HsPrimType HsPrimVoid} ::: Field {fieldName = "cBools1_y", fieldType = HsPrimType HsPrimVoid} ::: VNil, structTypeSpelling = Just "struct bools1"}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 1 1])))})) | ||
DeclData (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = Field {fieldName = "cBools2_x", fieldType = HsTypRef "CBool'"} ::: Field {fieldName = "cBools2_y", fieldType = HsTypRef "CBool'"} ::: VNil, structTypeSpelling = Just "struct bools2"}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = Field {fieldName = "cBools2_x", fieldType = HsTypRef "CBool'"} ::: Field {fieldName = "cBools2_y", fieldType = HsTypRef "CBool'"} ::: VNil, structTypeSpelling = Just "struct bools2"}) (StorableInstance {storableSizeOf = 2, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = Field {fieldName = "cBools2_x", fieldType = HsTypRef "CBool'"} ::: Field {fieldName = "cBools2_y", fieldType = HsTypRef "CBool'"} ::: VNil, structTypeSpelling = Just "struct bools2"})) [PeekByteOff 0 0,PeekByteOff 0 1]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CBools2", structConstr = "MkCBools2", structFields = Field {fieldName = "cBools2_x", fieldType = HsTypRef "CBool'"} ::: Field {fieldName = "cBools2_y", fieldType = HsTypRef "CBool'"} ::: VNil, structTypeSpelling = Just "struct bools2"}) 2 (Seq [PokeByteOff 3 0 0,PokeByteOff 3 1 1])))})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
DeclNewtype (Newtype {newtypeName = "CFirst", newtypeConstr = "MkCFirst", newtypeField = Field {fieldName = "unCFirst", fieldType = HsPrimType HsPrimCUInt}}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CFirst", structConstr = "MkCFirst", structFields = Field {fieldName = "unCFirst", fieldType = HsPrimType HsPrimCUInt} ::: VNil}) (StorableInstance {storableSizeOf = 4, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CFirst", structConstr = "MkCFirst", structFields = Field {fieldName = "unCFirst", fieldType = HsPrimType HsPrimCUInt} ::: VNil})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CFirst", structConstr = "MkCFirst", structFields = Field {fieldName = "unCFirst", fieldType = HsPrimType HsPrimCUInt} ::: VNil}) 1 (Seq [PokeByteOff 2 0 0])))})) | ||
DeclNewtype (Newtype {newtypeName = "CSecond", newtypeConstr = "MkCSecond", newtypeField = Field {fieldName = "unCSecond", fieldType = HsPrimType HsPrimCInt}}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CSecond", structConstr = "MkCSecond", structFields = Field {fieldName = "unCSecond", fieldType = HsPrimType HsPrimCInt} ::: VNil}) (StorableInstance {storableSizeOf = 4, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CSecond", structConstr = "MkCSecond", structFields = Field {fieldName = "unCSecond", fieldType = HsPrimType HsPrimCInt} ::: VNil})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CSecond", structConstr = "MkCSecond", structFields = Field {fieldName = "unCSecond", fieldType = HsPrimType HsPrimCInt} ::: VNil}) 1 (Seq [PokeByteOff 2 0 0])))})) | ||
DeclNewtype (Newtype {newtypeName = "CSame", newtypeConstr = "MkCSame", newtypeField = Field {fieldName = "unCSame", fieldType = HsPrimType HsPrimCUInt}}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CSame", structConstr = "MkCSame", structFields = Field {fieldName = "unCSame", fieldType = HsPrimType HsPrimCUInt} ::: VNil}) (StorableInstance {storableSizeOf = 4, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CSame", structConstr = "MkCSame", structFields = Field {fieldName = "unCSame", fieldType = HsPrimType HsPrimCUInt} ::: VNil})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CSame", structConstr = "MkCSame", structFields = Field {fieldName = "unCSame", fieldType = HsPrimType HsPrimCUInt} ::: VNil}) 1 (Seq [PokeByteOff 2 0 0])))})) | ||
DeclNewtype (Newtype {newtypeName = "CPackad", newtypeConstr = "MkCPackad", newtypeField = Field {fieldName = "unCPackad", fieldType = HsPrimType HsPrimCSChar}}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CPackad", structConstr = "MkCPackad", structFields = Field {fieldName = "unCPackad", fieldType = HsPrimType HsPrimCSChar} ::: VNil}) (StorableInstance {storableSizeOf = 1, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CPackad", structConstr = "MkCPackad", structFields = Field {fieldName = "unCPackad", fieldType = HsPrimType HsPrimCSChar} ::: VNil})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CPackad", structConstr = "MkCPackad", structFields = Field {fieldName = "unCPackad", fieldType = HsPrimType HsPrimCSChar} ::: VNil}) 1 (Seq [PokeByteOff 2 0 0])))})) | ||
DeclNewtype (Newtype {newtypeName = "CFirst", newtypeConstr = "MkCFirst", newtypeField = Field {fieldName = "unCFirst", fieldType = HsPrimType HsPrimCUInt}, newtypeTypeSpelling = Just "enum first"}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CFirst", structConstr = "MkCFirst", structFields = Field {fieldName = "unCFirst", fieldType = HsPrimType HsPrimCUInt} ::: VNil, structTypeSpelling = Just "enum first"}) (StorableInstance {storableSizeOf = 4, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CFirst", structConstr = "MkCFirst", structFields = Field {fieldName = "unCFirst", fieldType = HsPrimType HsPrimCUInt} ::: VNil, structTypeSpelling = Just "enum first"})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CFirst", structConstr = "MkCFirst", structFields = Field {fieldName = "unCFirst", fieldType = HsPrimType HsPrimCUInt} ::: VNil, structTypeSpelling = Just "enum first"}) 1 (Seq [PokeByteOff 2 0 0])))})) | ||
DeclNewtype (Newtype {newtypeName = "CSecond", newtypeConstr = "MkCSecond", newtypeField = Field {fieldName = "unCSecond", fieldType = HsPrimType HsPrimCInt}, newtypeTypeSpelling = Just "enum second"}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CSecond", structConstr = "MkCSecond", structFields = Field {fieldName = "unCSecond", fieldType = HsPrimType HsPrimCInt} ::: VNil, structTypeSpelling = Just "enum second"}) (StorableInstance {storableSizeOf = 4, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CSecond", structConstr = "MkCSecond", structFields = Field {fieldName = "unCSecond", fieldType = HsPrimType HsPrimCInt} ::: VNil, structTypeSpelling = Just "enum second"})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CSecond", structConstr = "MkCSecond", structFields = Field {fieldName = "unCSecond", fieldType = HsPrimType HsPrimCInt} ::: VNil, structTypeSpelling = Just "enum second"}) 1 (Seq [PokeByteOff 2 0 0])))})) | ||
DeclNewtype (Newtype {newtypeName = "CSame", newtypeConstr = "MkCSame", newtypeField = Field {fieldName = "unCSame", fieldType = HsPrimType HsPrimCUInt}, newtypeTypeSpelling = Just "enum same"}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CSame", structConstr = "MkCSame", structFields = Field {fieldName = "unCSame", fieldType = HsPrimType HsPrimCUInt} ::: VNil, structTypeSpelling = Just "enum same"}) (StorableInstance {storableSizeOf = 4, storableAlignment = 4, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CSame", structConstr = "MkCSame", structFields = Field {fieldName = "unCSame", fieldType = HsPrimType HsPrimCUInt} ::: VNil, structTypeSpelling = Just "enum same"})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CSame", structConstr = "MkCSame", structFields = Field {fieldName = "unCSame", fieldType = HsPrimType HsPrimCUInt} ::: VNil, structTypeSpelling = Just "enum same"}) 1 (Seq [PokeByteOff 2 0 0])))})) | ||
DeclNewtype (Newtype {newtypeName = "CPackad", newtypeConstr = "MkCPackad", newtypeField = Field {fieldName = "unCPackad", fieldType = HsPrimType HsPrimCSChar}, newtypeTypeSpelling = Just "enum packad"}) | ||
DeclInstance (InstanceStorable (Struct {structName = "CPackad", structConstr = "MkCPackad", structFields = Field {fieldName = "unCPackad", fieldType = HsPrimType HsPrimCSChar} ::: VNil, structTypeSpelling = Just "enum packad"}) (StorableInstance {storableSizeOf = 1, storableAlignment = 1, storablePeek = Lambda "ptr" (Ap (StructCon (Struct {structName = "CPackad", structConstr = "MkCPackad", structFields = Field {fieldName = "unCPackad", fieldType = HsPrimType HsPrimCSChar} ::: VNil, structTypeSpelling = Just "enum packad"})) [PeekByteOff 0 0]), storablePoke = Lambda "ptr" (Lambda "s" (ElimStruct 0 (Struct {structName = "CPackad", structConstr = "MkCPackad", structFields = Field {fieldName = "unCPackad", fieldType = HsPrimType HsPrimCSChar} ::: VNil, structTypeSpelling = Just "enum packad"}) 1 (Seq [PokeByteOff 2 0 0])))})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
DeclNewtype (Newtype {newtypeName = "CTriple", newtypeConstr = "MkCTriple", newtypeField = Field {fieldName = "unCTriple", fieldType = HsConstArray 3 (HsPrimType HsPrimCInt)}}) | ||
DeclNewtype (Newtype {newtypeName = "CTriple", newtypeConstr = "MkCTriple", newtypeField = Field {fieldName = "unCTriple", fieldType = HsConstArray 3 (HsPrimType HsPrimCInt)}, newtypeTypeSpelling = Just "triple"}) | ||
DeclNewtypeInstance Storable "CTriple" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,6 @@ WrapCHeader | |
3 | ||
(TypePrim | ||
(PrimIntegral | ||
(PrimInt Signed)))}]) | ||
(PrimInt Signed))), | ||
typedefTypeSpelling = | ||
"triple"}]) |
Oops, something went wrong.