Commits

Keigo Imai committed 988d4b3

changed make_dyn to accept expression rather than varname (is this safe?)

Comments (0)

Files changed (2)

ojacare/src/camlgen/mlMethod.ml

           (* construction du corps de la méthode *)
 	  let body = 
 	    if not callback then
-	      <:expr< $lid:call_method$ $lid:java_obj$ $lid:id$ [| $list:jargs$ |] >> 
+	      <:expr< $lid:call_method$ $java_obj$ $lid:id$ [| $list:jargs$ |] >> 
 	    else
-	      <:expr< $lid:call_method$ $lid:java_obj$ $lid:clazz$ $lid:id$ [| $list:jargs$ |] >> in
+	      <:expr< $lid:call_method$ $java_obj$ $lid:clazz$ $lid:id$ [| $list:jargs$ |] >> in
 	  let body = MlType.convert_from_java rtyp body in
 	  let body = MlGen.make_local_decl (MlType.get_args_convertion MlType.convert_to_java args) body in
 	  let body = MlGen.make_fun args body in
 	let id = fid_prefix^java_name
 	and call_method_name = "Jni.set_"^(MlType.string_of_type typ)^"_field"  
 	and narg = "_p" in
-	let call = <:expr< $lid:call_method_name$ $lid:java_obj$ $lid:id$ $lid:narg$ >> in
+	let call = <:expr< $lid:call_method_name$ $java_obj$ $lid:id$ $lid:narg$ >> in
 	
 	let body = MlGen.make_local_decl [narg,MlType.convert_to_java typ <:expr< $lid:narg$ >>] call in
 	let body = MlGen.make_fun [narg,typ] body in
 	let id = fid_prefix^java_name
 	and sign = MlType.java_signature_of_type typ 
 	and call_method_name = "Jni.get_"^(MlType.string_of_type typ)^"_field"  in
-	let call = <:expr< $lid:call_method_name$ $lid:java_obj$ $lid:id$ >> in
+	let call = <:expr< $lid:call_method_name$ $java_obj$ $lid:id$ >> in
 	
 	let body = MlType.convert_from_java typ call in
 	let body = MlGen.make_fun [] body in
 	let args = List.combine nargs targs in
 	
 	(* construction du corps de la méthode 'stub' appelé par java *)   
-	let stub_body = MlGen.make_call <:expr< self # $lid:ml_name$ >> nargs in
+	let stub_body = MlGen.make_call <:expr< self # $lid:ml_name$ >> (List.map (fun s -> <:expr< $lid:s$ >>) nargs) in
 	let stub_body = MlType.convert_to_java rtyp stub_body in
 	let stub_body = MlGen.make_local_decl (MlType.get_args_convertion MlType.convert_from_java args) stub_body in 
 	let stub_body = 
 
 (** Génčre les fonctions correspondantes au méthodes 'static' *)
 let make_static cl_list =
-  let clazz = "clazz" in
   let id = "id" in
   let make_cl cl =
     let class_name = Ident.get_class_java_signature cl.cc_ident in
-    let class_expr =  <:expr< Jni.find_class $str:class_name$ >> in
+    let clazz = Ident.get_class_ml_ref cl.cc_ident in
     let make m = 
       let ml_name = Ident.get_method_ml_name m.cm_ident 
       and java_name =  Ident.get_method_java_name m.cm_ident in
 	  let body = MlGen.make_local_decl [narg,MlType.convert_to_java typ <:expr< $lid:narg$ >>] call in
 	  let body = MlGen.make_fun [narg,typ] body in
 	  let body = MlGen.make_local_decl [id,id_expr] body in
-	  let body = MlGen.make_local_decl [clazz,class_expr] body in
 	   <:str_item< value $lid:ml_name$ = $body$ >>
 
       | Cget typ -> 
 	  let body = MlType.convert_from_java typ call in
 	  let body = MlGen.make_fun [] body in
 	  let body = MlGen.make_local_decl [id,safe_id_expr] body in
-	  let body = MlGen.make_local_decl [clazz,class_expr] body in
 
 	  <:str_item< value $lid:ml_name$ = $body$ >>
 	  
 	  let body = MlGen.make_local_decl (MlType.get_args_convertion MlType.convert_to_java args) body in
 	  let body = MlGen.make_fun args body in
 	  let body = MlGen.make_local_decl [id,safe_id_expr] body in
-	  let body = MlGen.make_local_decl [clazz,class_expr] body in
 	  
 	  <:str_item< value $lid:ml_name$ = $body$ >>
     in

ojacare/src/camlgen/mlMethod.mli

 val make_class_type: callback:bool -> Cidl.mmethod list -> MLast.class_sig_item list
 (** génčre la liste des signatures (pour inclure dans le 'class type' *)
 
-val make_dyn: string -> string -> callback:bool -> Cidl.mmethod list -> (string * MLast.expr) list * MLast.class_str_item list
+val make_dyn: string -> MLast.expr -> callback:bool -> Cidl.mmethod list -> (string * MLast.expr) list * MLast.class_str_item list
 (** génčre le code d'implantation des méthodes, avec des appels virtuel ou non.
    Les deux premier arguments correspondent on nom des variables globales ŕ la classe clazz et java_obj *)