Source

opycaml / js_of_ocaml / testoox.ml

Full commit
open Opycaml.OOApi
open Opy_of_ocaml
  
class type module_string = object
  method lowercase : o_String Js.readonly_prop
  method capitalize : #o_String -> o_String Js.meth
end

let module_string_wrap = object
  method lowercase = OPy.String.coerce
  method capitalize = OPy.String.coerce
end

let _ =
  let module_string : module_string Js.t = import_module "string" in
  (* from string import * *)
  let lowercase =
    let module_string_1 : (< .. > as 'x1) Js.t = module_string in
    let _ (arg1 : 'x1) =
      (arg1#lowercase : < get : 'x2; .. > Js.gen_prop)
    in 
    (* (Js.Unsafe.get module_string_1 "lowercase" : 'x2)  *)
    module_string_wrap#lowercase
    ((Obj.magic module_string_1 : o_Dict)#getItemString "lowercase")
  in

  let res =
    let module_string_2 : (< .. > as 'x3) Js.t = module_string in
    let _ (arg2 : 'x3) =
      (arg2#capitalize : 'x4 -> 'x5 Js.meth)
    in
    module_string_wrap#capitalize
      (Js.Unsafe.meth_call module_string_2 "capitalize" [| Js.Unsafe.inject ((Obj.magic lowercase) : 'x4) |] : 'x5)
  in prerr_endline res#asString