let pat =
make_pat name args in
let body =
- sprintf "(0x%x,[%s])"
+ sprintf "(0x%x,List.concat [%s])"
opcode
(call_args "byte" args) in
sprintf "| %s -> %s" pat body
open Base
open StdLabels
+open ExtString
type bit =
SB of int * int
| `Rect of int * int * int * int
| `RGB of int * int * int
| `RGBA of int * int * int * int
+| `Str of string
]
type s = [ byte | compose ]
List.fold_left ~f:bits ~init:BitsOut.empty xs
+> BitsOut.to_list
+let char c =
+ `Ui8 (Char.code c)
+
let to_byte : compose -> byte list = function
`Fixed x ->
let int =
[`Ui8 r; `Ui8 g; `Ui8 b]
| `RGBA(r,g,b,a) ->
[`Ui8 r; `Ui8 g; `Ui8 b; `Ui8 a]
+ | `Str s ->
+ List.map ~f:char (String.explode s) @ [`Ui8 0]
let int_of_compose x =
match x with
| `Rect of int*int*int*int
| `RGB of int * int * int
| `RGBA of int * int * int * int
+| `Str of string
]
type backpatch = [
open OUnit
open SwfBaseOut
+let char c =
+ `Ui8 (Char.code c)
+
let ok_i x y =
assert_equal ~printer:Std.dump x @@ to_list [ y ]
ok_b [ `Bits [UB(5,2); SB(2,0); SB(2,0); SB(2,1); SB(2,1)]] @@ [`Rect (0,0,1,1)];
ok_b [ `Bits [UB(5,11); SB(11,127); SB(11,260); SB(11,15); SB(11,514)]] @@ [`Rect (127,260,15,514)]
end;
+ "String" >:: begin fun () ->
+ ok_b [ char 'f'; char 'o'; char 'o'; `Ui8 0] @@ [`Str "foo"];
+ ok_b [ `Ui8 0] @@ [`Str ""]
+ end;
"whole size" >:: begin fun () ->
ok_b [`Ui32 4l] [`Ui32Size];
ok_b [`Ui32 6l; `EUi32 0xFFl] [`Ui32Size; `EUi32 0xFFl;];
ShowFrame(0x01)
SetBackgroundColor of color(0x09)
FileAttributes of file_attrs(0x45)
-
+FrameLabel of string(0x2b)
+SymbolClass of symbol_class(0x4c)
+DoABC of u32 * string * abc(0x52)
open SwfBaseOut
type color = {r:int; g:int; b:int}
-let byte_color {r;g;b} = `RGB(r,g,b)
+let byte_color {r;g;b} =
+ [ `RGB(r,g,b) ]
+
+let byte_string s =
+ [ `Str s ]
+
+type u32 = int32
+let byte_u32 n =
+ [ `Ui32 n]
+type abc = int list
+let byte_abc abc =
+ List.map (fun n -> `Ui8 n) abc
type file_attrs = {is_metadat:bool; is_as3:bool; use_network:bool}
-let byte_file_attrs {is_metadat; is_as3; use_network} =
+let byte_file_attrs {is_metadat; is_as3; use_network} = [
`Bits [
UB(3 , 0);
UB(1 , if is_metadat then 1 else 0);
UB(2 , 0);
UB(1 , if use_network then 1 else 0);
UB(24, 0)
- ]
+ ]]
+
+type symbol_class = (int*string) list
+let byte_symbol_class xs =
+ `Ui16 (List.length xs)::HList.concat_map (fun(id,name)-> [`Ui16 id; `Str name]) xs
type t = [
#include "type.tag.h"