OSDN Git Service

add doabc
authormzp <mzpppp@gmail.com>
Tue, 6 Oct 2009 23:23:22 +0000 (08:23 +0900)
committermzp <mzpppp@gmail.com>
Tue, 6 Oct 2009 23:23:22 +0000 (08:23 +0900)
swflib/gen_inst.ml
swflib/swfBaseOut.ml
swflib/swfBaseOut.mli
swflib/swfBaseOutTest.ml
swflib/tag.txt
swflib/tagOut.mlp

index 7a88eb1..896714d 100644 (file)
@@ -154,7 +154,7 @@ let cmds = [
      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
index c094231..f0936d7 100644 (file)
@@ -1,5 +1,6 @@
 open Base
 open StdLabels
+open ExtString
 
 type bit =
     SB of int * int
@@ -27,6 +28,7 @@ type compose = [
 | `Rect    of int * int * int * int
 | `RGB     of int * int * int
 | `RGBA    of int * int * int * int
+| `Str     of string
 ]
 
 type s = [ byte | compose ]
@@ -97,6 +99,9 @@ let to_int : byte -> int list = function
       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 =
@@ -128,6 +133,8 @@ let to_byte : compose -> byte list = function
       [`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
index 4b2c280..4b116e3 100644 (file)
@@ -21,6 +21,7 @@ type s = [
 | `Rect    of int*int*int*int
 | `RGB     of int * int * int
 | `RGBA    of int * int * int * int
+| `Str     of string
 ]
 
 type backpatch = [
index 6987953..4878b3c 100644 (file)
@@ -2,6 +2,9 @@ open Base
 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 ]
 
@@ -109,6 +112,10 @@ let _ = begin "swfBaseOut.ml" >::: [
     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;];
index 9dec481..63b8429 100644 (file)
@@ -2,4 +2,6 @@ End(0x00)
 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)
index 7d0d0a4..d975503 100644 (file)
@@ -2,10 +2,21 @@ open Base
 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);
@@ -13,7 +24,11 @@ let byte_file_attrs {is_metadat; is_as3; use_network} =
     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"