OSDN Git Service

Change CmdOpt module's return type
authormzp <mzpppp@gmail.com>
Sun, 11 Oct 2009 01:04:15 +0000 (10:04 +0900)
committermzp <mzpppp@gmail.com>
Sun, 11 Oct 2009 01:04:15 +0000 (10:04 +0900)
Change record type to object type. Because, I want to use it over some modules.

link/cmdOpt.ml
link/cmdOpt.mli
link/cmdOptTest.ml
link/main.ml

index a23c544..8f4763a 100644 (file)
@@ -1,11 +1,7 @@
 open Base
 open OptParse
 
-type t = {
-  size       : int * int;
-  color      : int * int * int;
-  main_class : string
-}
+type t = <color:int*int*int; size:int*int; main_class:string>
 
 let opt_parser =
   OptParser.make
@@ -77,11 +73,11 @@ let blue =
 let parse argv =
   let inputs =
     OptParser.parse opt_parser argv in
-    inputs,{
+    inputs,{|
       color      = (Opt.get red, Opt.get green, Opt.get blue);
       main_class = Opt.get main_class;
       size       = (Opt.get width, Opt.get height)
-    }
+    |}
 
 let parse_argv () =
   parse Sys.argv
index c9675f7..9849521 100644 (file)
@@ -1,7 +1,4 @@
-type t = {
-  size       : int * int;
-  color      : int * int * int;
-  main_class : string
-}
+type t = <color:int*int*int; size:int*int; main_class:string>
+
 val parse : string array -> string list * t
 val parse_argv : unit -> string list * t
index ff05b71..2322903 100644 (file)
@@ -12,14 +12,14 @@ let _ = begin "cmdOpt.ml" >::: [
     assert_equal ["foo"; "bar"] @@ fst @@ parse [| "foo"; "bar" |]
   end;
   "size" >:: begin fun () ->
-    ok (100,200) (fun {size} -> size) "-W 100 -H 200";
-    ok (100,200) (fun {size} -> size) "--width=100 --height=200";
+    ok (100,200) (fun t -> t#size) "-W 100 -H 200";
+    ok (100,200) (fun t -> t#size) "--width=100 --height=200";
   end;
   "color" >:: begin fun () ->
-    ok (1,2,3) (fun {color}-> color) "--red=1 --green=2 --blue=3"
+    ok (1,2,3) (fun t -> t#color) "--red=1 --green=2 --blue=3"
   end;
   "main class" >:: begin fun () ->
-    ok "foo" (fun {main_class}->main_class) "-m foo";
-    ok "foo" (fun {main_class}->main_class) "--main=foo"
+    ok "foo" (fun t -> t#main_class) "-m foo";
+    ok "foo" (fun t -> t#main_class) "--main=foo"
   end
 ] end +> run_test_tt_main
index b2fa0cb..3f7db0e 100644 (file)
@@ -1,4 +1,36 @@
 open Base
+open Swflib.SwfType
 
+(*<swf version="9" compressed="1">
+  <Header framerate="24" frames="1">
+    <size>
+      <Rectangle left="0" right="__WIDTH__" top="0" bottom="__HEIGHT__"/>
+    </size>
+    <tags>
+      <FileAttributes hasMetaData="1" allowABC="1" suppressCrossDomainCaching="0" swfRelativeURLs="0" useNetwork="1"/>
+      <SetBackgroundColor>
+        <color>
+          <Color red="__BG_RED__" green="__BG_GREEN__" blue="__BG_BLUE__"/>
+        </color>
+      </SetBackgroundColor>
+      <FrameLabel label="__MAIN_CLASS__">
+        <flags/>
+      </FrameLabel>
+      <DoABCDefine flags="1" name="frame1">
+        <actions>
+include(__ABCX__)
+</actions>
+      </DoABCDefine>
+      <SymbolClass>
+        <symbols>
+          <Symbol objectID="0" name="__MAIN_CLASS__"/>
+        </symbols>
+      </SymbolClass>
+      <ShowFrame/>
+      <End/>
+    </tags>
+  </Header>
+</swf>
+*)
 let _ =
   print_endline "hello"