Commits

camlspotter committed 141afca

added some useful functions

Comments (0)

Files changed (2)

 	(** Object method call *)
       val obj : [> _Object ] t -> _Object t
 	(** Forget the type of the object *)
+      val ocamlRepr : [> _Object ] t -> string
+      (** obtain OCaml string of repr *)
+      val ocamlStr : [> _Object ] t -> string
+	(** obtain OCaml string of str *)
     end = struct
       let call callable ?kwd list =
 	_internal_call callable (Tuple.from_list list) kwd
 	| list -> _internal_callObject callable (Some (Tuple.from_list list))
 
       let obj t : _Object t = unsafe_coerce t
+
+      let ocamlRepr t = String.asString (repr t)
+      let ocamlStr t = String.asString (str t)
     end
 
     include X
     let py_ocaml_1 = Base.unsafe_embed 1 in
     Base.debug "py_ocaml_1" py_ocaml_1;
 
-    prerr_endline "*** OCaml closure wrapping";
+    prerr_endline "*** inserting a closure into module opycaml";
     let f (args : _Tuple t) : _Object t =
-      Format.eprintf "#Args!!@.";
+      let i = ref 0 in
+      List.iter (fun t -> 
+	Format.eprintf "Arg %d : %s@." !i (Object.ocamlRepr t);
+	incr i;
+      ) (Tuple.to_list args);
       Object.obj (Base.none ())
     in
     
-    let fo = Base.embed_closure f in
-    Base.debug "fo" fo;
-
-    prerr_endline "*** inserting a closure into module opycaml";
     let m = Import.importModule "opycaml" in
-    Module.setItemString m "f" fo;
+    Module.setClosureString m "f" f;
     prerr_endline "* check / import opycaml / opycaml.__dict__ / opycaml.f(1)";
 
     prerr_endline "*** Entering the toploop";
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.