Commits

Keigo Imai  committed dda3917

new ojacare main

  • Participants
  • Parent commits 0d71035

Comments (0)

Files changed (1)

File ojacare/src/main/ojacare.ml

 (*	$Id: ojacare.ml,v 1.2 2004/03/27 16:37:53 henry Exp $	*)
+let classify (ls : ('a * 'b) list) : ('a * 'b list) list =
+  let ls = List.sort (fun (k,_) (k',_) -> compare k k') ls in
+  let rec clas result ((now_key,now_values) as now : ('a * 'b list)) = function 
+    | [] -> now::result
+    | (k,v)::ls -> 
+      if now_key=k then clas result (now_key, (v::now_values)) ls
+      else clas (now::result) (k,[v]) ls in
+  let (k,v) = List.hd ls in
+  let result = clas [] (k,[v]) (List.tl ls) in
+  List.rev (List.map (fun (k,vs) -> k, List.rev vs) result)
+;;
 
 let main () =
   Pcaml.input_file := "-";
     
   let p_file  = Idl_parser.from_file file in
   let c_file = Idl_check.main file p_file in
-  Idl_javagen.create_stub_files c_file;
+
+  let packed = classify (List.map (fun c -> (Ident.get_class_ml_module_name c.Cidl.cc_ident, c)) c_file) in
+
   let out = Unix.openfile ((Filename.chop_suffix file ".idl") ^ ".ml") [Unix.O_WRONLY;Unix.O_CREAT;Unix.O_TRUNC] 0o644 in
   Unix.dup2 out Unix.stdout;
-  Idl_camlgen.output c_file;
+  Idl_camlgen.output packed;
   Unix.close out;
   ()