typeDefinition (TLStruct{ struct_name = sname, struct_fields = fields })
 = do sayln' $ "struct " ++ sname ++ " {"
      mapM_ fieldDefinition fields
      sayln' $ "};"
 where fieldDefinition (StructField{ field_name = fname, field_array = farray, field_type = ftype })
         = case farray of
            Scalar   -> sayln' $ "  " ++ fieldType ftype ++ " " ++ fname ++ ";"
            Fixed _  -> sayln' $ "  " ++ fieldType ftype ++ " " ++ fname ++ "[" ++ arrayLenFixed sname fname ++ "];"
            Max _ -> do sayln' $ "  " ++ intType IKUnsigned IS32 ++ " " ++ arrayLen fname ++ ";"
                        sayln' $ "  " ++ fieldType ftype ++ "* " ++ fname ++ ";"
typeDefinition (TLStruct{ struct_name = sname, struct_fields = fields })
 = do sayln' $ "struct " ++ sname ++ " {"
      mapM_ fieldDefinition fields
      sayln' $ "};"
 where fieldDefinition (StructField{ field_name = fname, field_array = farray, field_type = ftype })
         = case farray of
            Scalar   -> sayln' $ "  " ++ fieldType ftype ++ " " ++ fname ++ ";"
            Fixed _  -> sayln' $ "  " ++ fieldType ftype ++ " " ++ fname ++ "[" ++ arrayLenFixed sname fname ++ "];"
            Max _ -> do sayln' $ "  " ++ intType IKUnsigned IS32 ++ " " ++ arrayLen fname ++ ";"
                        sayln' $ "  " ++ fieldType ftype ++ "* " ++ fname ++ ";"
typeDefinition (TLStruct{ struct_name = sname, struct_fields = fields })
 = do sayln' $ "struct " ++ sname ++ " {"
      mapM_ fieldDefinition fields
      sayln' $ "};"
 where fieldDefinition (StructField{ field_name = fname, field_array = farray, field_type = ftype })
         = case farray of
            Scalar   -> sayln' $ "  " ++ fieldType ftype ++ " " ++ fname ++ ";"
            Fixed _  -> sayln' $ "  " ++ fieldType ftype ++ " " ++ fname ++ "[" ++ arrayLenFixed sname fname ++ "];"
            Max _ -> do sayln' $ "  " ++ intType IKUnsigned IS32 ++ " " ++ arrayLen fname ++ ";"
                        sayln' $ "  " ++ fieldType ftype ++ "* " ++ fname ++ ";"