summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Bustle/VariantFormatter.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/Bustle/VariantFormatter.hs b/Bustle/VariantFormatter.hs
index 060a30b..d4aa489 100644
--- a/Bustle/VariantFormatter.hs
+++ b/Bustle/VariantFormatter.hs
@@ -25,6 +25,7 @@ where
import Data.Word
import Data.Int
import Data.List (intercalate)
+import Data.Char (chr, isPrint)
-- :'(
import Data.Maybe (fromJust)
import qualified Data.Text.Lazy as Text
@@ -37,6 +38,15 @@ format_Bool = show
format_Word8 :: Word8 -> String
format_Word8 = show
+format_ByteArray :: Array -> String
+format_ByteArray ay =
+ if all (\y -> isPrint (chr (fromIntegral y))) bytes
+ then show (map (chr . fromIntegral) bytes :: String)
+ else format_Array ay
+ where
+ bytes = map (fromJust . fromVariant) (arrayItems ay) :: [Word8]
+
+
format_Int16 :: Int16 -> String
format_Int16 = show
format_Int32 :: Int32 -> String
@@ -129,6 +139,7 @@ format_Variant style v =
TypeSignature -> format_Signature . fromJust . fromVariant
TypeObjectPath -> format_ObjectPath . fromJust . fromVariant
TypeVariant -> format_Variant VariantStyleAngleBrackets . fromJust . fromVariant
+ TypeArray TypeWord8 -> format_ByteArray . fromJust . fromVariant
TypeArray _ -> format_Array . fromJust . fromVariant
TypeDictionary _ _ -> format_Dictionary . fromJust . fromVariant
TypeStructure _ -> format_Structure . fromJust . fromVariant