-- Copyright 2020 United States Government as represented by the
-- Administrator of the National Aeronautics and Space Administration. All
-- Rights Reserved.
--
-- Disclaimers
--
-- Licensed under the Apache License, Version 2.0 (the "License"); you may
-- not use this file except in compliance with the License. You may obtain a
-- copy of the License at
--
--      https://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-- WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-- License for the specific language governing permissions and limitations
-- under the License.
--
-- | Copilot's representation and conversion of C Structs from C's AST.
module Language.Copilot.CStruct
    (
      -- * CStruct
      CStruct(..)
    , CField(..)

    )
  where

-- | A C struct is a name and fields with different types.
data CStruct = CStruct
    { CStruct -> String
cStructName   :: String
    , CStruct -> [CField]
cStructFields :: [CField]
    }
  deriving (CStruct -> CStruct -> Bool
(CStruct -> CStruct -> Bool)
-> (CStruct -> CStruct -> Bool) -> Eq CStruct
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CStruct -> CStruct -> Bool
== :: CStruct -> CStruct -> Bool
$c/= :: CStruct -> CStruct -> Bool
/= :: CStruct -> CStruct -> Bool
Eq, Int -> CStruct -> ShowS
[CStruct] -> ShowS
CStruct -> String
(Int -> CStruct -> ShowS)
-> (CStruct -> String) -> ([CStruct] -> ShowS) -> Show CStruct
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CStruct -> ShowS
showsPrec :: Int -> CStruct -> ShowS
$cshow :: CStruct -> String
show :: CStruct -> String
$cshowList :: [CStruct] -> ShowS
showList :: [CStruct] -> ShowS
Show)

-- | A field may have a name and a type, or be an array with a name, type and
-- length. Pointers are not currently supported.
data CField = CPlain String String
            | CArray String String Integer
  deriving (CField -> CField -> Bool
(CField -> CField -> Bool)
-> (CField -> CField -> Bool) -> Eq CField
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CField -> CField -> Bool
== :: CField -> CField -> Bool
$c/= :: CField -> CField -> Bool
/= :: CField -> CField -> Bool
Eq, Int -> CField -> ShowS
[CField] -> ShowS
CField -> String
(Int -> CField -> ShowS)
-> (CField -> String) -> ([CField] -> ShowS) -> Show CField
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CField -> ShowS
showsPrec :: Int -> CField -> ShowS
$cshow :: CField -> String
show :: CField -> String
$cshowList :: [CField] -> ShowS
showList :: [CField] -> ShowS
Show)