ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/doc/doc2haskell.xsl
(Generate patch)

Comparing kgsueme/doc/doc2haskell.xsl (file contents):
Revision 1.10 by elmex, Sat Jul 26 13:02:15 2003 UTC vs.
Revision 1.11 by pcg, Sun Jul 27 00:20:48 2003 UTC

53dec_U64 = 53dec_U64 =
54 do a1 <- getU16 54 do a1 <- getU16
55 a2 <- getU16 55 a2 <- getU16
56 a3 <- getU16 56 a3 <- getU16
57 a4 <- getU16 57 a4 <- getU16
58 return $ (fI a1) `shiftL` 48 -- please check endians 58 return $ (fI a4) `shiftL` 48
59 + (fI a2) `shiftL` 32 59 + (fI a3) `shiftL` 32
60 + (fI a3) `shiftL` 16 60 + (fI a2) `shiftL` 16
61 + (fI a4) 61 + (fI a1)
62 where fI a = fromIntegral a :: Word64 62 where fI a = fromIntegral a :: Word64
63 63
64 64
65dec_I8 :: DecS Int8 65dec_I8 :: DecS Int8
66dec_I8 = 66dec_I8 =
74 74
75dec_I32 :: DecS Int32 75dec_I32 :: DecS Int32
76dec_I32 = 76dec_I32 =
77 do w16_1 <- getU16 77 do w16_1 <- getU16
78 w16_2 <- getU16 78 w16_2 <- getU16
79 return $ (fI w16_1) `shiftL` 16 -- please cgecj endians 79 return $ (fI w16_2) `shiftL` 16
80 + (fI w16_2) 80 + (fI w16_1)
81 where fI a = fromIntegral a :: Int32 81 where fI a = fromIntegral a :: Int32
82 82
83dec_DATA :: DecS [Word8] 83dec_DATA :: DecS [Word8]
84dec_DATA = 84dec_DATA =
85 do da <- get 85 do da <- get
94 mkstr str [] = 94 mkstr str [] =
95 (reverse str,[]) 95 (reverse str,[])
96 mkstr str (0:rest) = 96 mkstr str (0:rest) =
97 (reverse str, rest) 97 (reverse str, rest)
98 mkstr str (c:rest) = 98 mkstr str (c:rest) =
99 mkstr ((toEnum (fromIntegra c :: Int)):str) rest 99 mkstr ((toEnum (fromIntegral c :: Int)):str) rest
100 100
101{- 101{-
102sub dec_STRING { 102sub dec_STRING {
103 $data =~ s/^((?:..)*?)(?:\x00\x00|\Z)//s; 103 $data =~ s/^((?:..)*?)(?:\x00\x00|\Z)//s;
104 # use Encode... 104 # use Encode...
134putU16 :: Word16 -> DecS () 134putU16 :: Word16 -> DecS ()
135putU16 a = 135putU16 a =
136 do x <- get 136 do x <- get
137 let b1 = fromIntegral (a `shiftR` 8) :: Word8 137 let b1 = fromIntegral (a `shiftR` 8) :: Word8
138 b2 = fromIntegral a :: Word8 138 b2 = fromIntegral a :: Word8
139 put (b2:b1:x) -- check endians 139 put (b1:b2:x)
140 140
141enc_U8 :: Word8 -> DecS () 141enc_U8 :: Word8 -> DecS ()
142enc_U8 = 142enc_U8 =
143 putU8 143 putU8
144 144
148 148
149enc_U32 :: Word32 -> DecS () 149enc_U32 :: Word32 -> DecS ()
150enc_U32 a = 150enc_U32 a =
151 let b1 = fromIntegral (a `shiftR` 16) :: Word16 151 let b1 = fromIntegral (a `shiftR` 16) :: Word16
152 b2 = fromIntegral a :: Word16 152 b2 = fromIntegral a :: Word16
153 putU16 b1 -- check the goddamn endians marc :)
154 putU16 b2 153 putU16 b2
154 putU16 b1
155 155
156enc_U64 :: Word64 -> DecS () 156enc_U64 :: Word64 -> DecS ()
157enc_U64 a = 157enc_U64 a =
158 let b1 = fromIntegral (a `shiftR` 48) :: Word16 158 let b1 = fromIntegral (a `shiftR` 48) :: Word16
159 b2 = fromIntegral (a `shiftR` 32) :: Word16 159 b2 = fromIntegral (a `shiftR` 32) :: Word16
160 b3 = fromIntegral (a `shiftR` 16) :: Word16 160 b3 = fromIntegral (a `shiftR` 16) :: Word16
161 b4 = fromIntegral a :: Word16 161 b4 = fromIntegral a :: Word16
162 putU16 b1 -- check the goddamn endians marc :) 162 putU16 b4
163 putU16 b3
163 putU16 b2 164 putU16 b2
164 putU16 b3 165 putU16 b1
165 putU16 b4
166 166
167enc_I8 :: Int8 -> DecS () 167enc_I8 :: Int8 -> DecS ()
168enc_I8 a = 168enc_I8 a =
169 putU8 (fromIntegral a :: Word8) 169 putU8 (fromIntegral a :: Word8)
170 170
171enc_I16 :: Int16 -> DecS () 171enc_I16 :: Int16 -> DecS ()
172enc_I16 a = 172enc_I16 a =
173 let b1 = fromIntegral (a `shiftR` 8) :: Word8 173 let b1 = fromIntegral (a `shiftR` 8) :: Word8
174 b2 = fromIntegral a :: Word8 174 b2 = fromIntegral a :: Word8
175 putU8 b2
175 putU8 b1 176 putU8 b1
176 putU8 b2
177 177
178enc_I32 :: Int32 -> DecS () 178enc_I32 :: Int32 -> DecS ()
179enc_I32 a = 179enc_I32 a =
180 let 180 let
181 b1 = fromIntegral (a `shiftR` 16) :: Word16 181 b1 = fromIntegral (a `shiftR` 16) :: Word16
182 b2 = fromIntegral a :: Word16 182 b2 = fromIntegral a :: Word16
183 putU16 b2
183 putU16 b1 184 putU16 b1
184 putU16 b2
185 185
186enc_DATA :: [Word8] -> DecS () 186enc_DATA :: [Word8] -> DecS ()
187enc_DATA d = 187enc_DATA d =
188 do x <- get 188 do x <- get
189 put $ (reverse d) ++ x 189 put $ (reverse d) ++ x

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines