Module JSOO


module JSOO: sig .. end
This operator tries to simulate the dot (.) of JavaScript. Its left operand being the subject object and its right one the message to send.

val (>>>) : 'a -> ('a -> 'b) -> 'b
type obj 
The abstract type obj represents a JS object

type value =
| Obj of obj (*identity*)
| Num of float (*javascript number / OCaml float*)
| String of string (*strings*)
| Block of Obj.t (*identity, but checks if OCaml value*)
| Nil (*JS null*)
The value type is used as an intermediate container to pass values between OCaml and JS
val new_obj : obj -> obj
creates An empty object
val eval : string -> obj
Evaluates a JS code
val inject : value -> obj
Transforms an OCaml value into a JS object
val extract : obj -> value
Extracts an OCaml value from a JS object
val null : obj
null JS value
val string : string -> obj
Obtain a JS string from a string. The result is a copy so any modification to the original string does not affect the JS string.
val float : float -> obj
Obtain a JS number from a float value
val int : int -> obj
Obtain a JS number from an int value
val js_false : obj
Obtain a JS bool from a bool
val js_true : obj
val bool : bool -> obj
val undefined : obj
special values
val null : obj
val as_string : obj -> string
extracts a string from a JS object, raises (Failure "as_string") in case of error
val as_obj : obj -> obj
extracts an object from a JS object, raises (Failure "as_obj") in case of error
val as_int : obj -> int
extracts a int from a JS object, raises (Failure "as_int") in case of error
val as_float : obj -> float
extracts a floatfrom a JS object, raises (Failure "as_float") in case of error
val as_block : obj -> Obj.t
extracts a block from a JS object, raises (Failure "as_block") in case of error
val as_bool : obj -> bool
Extracts a bool from a JS object
val get : string -> obj -> obj
Access a property of a JS object, as a JS object. Parameters are reversed to be used with the (>>>) combinator defined above. For instance (o >>> get "f") is equivalent to o.f (or o"f") in JS
val set : string -> obj -> obj -> unit
Modify a property : (o >>> set "f" v) is equivalent to o.f = v in JS
val unset : string -> obj -> unit
removes a property from an object
val call : obj -> obj array -> obj -> obj
Generic call mechanism, takes the function object, the subject (bound to 'this' in the body and an array of JS objects to use as arguments
val call_method : string -> obj array -> obj -> obj
Calls a method from an object
val call_function : obj array -> obj -> obj
Calls a function object with a null subject
val wrap_event : (unit -> unit) -> obj
internal function
val get_event_arg : unit -> obj
internal function
val wrap_event : (obj -> 'a) -> obj
Wraps an OCaml functional value into a JS object useable as an event handler
val current_vm : unit -> obj