/tryocaml/js_of_ocaml-patched/lib/js.mli

http://github.com/cago/tryocaml · OCaml · 531 lines · 242 code · 47 blank · 242 comment · 0 complexity · 54d809ef205c8779fa41007bf6d5a613 MD5 · raw file

  1. (* Js_of_ocaml library
  2. * http://www.ocsigen.org/js_of_ocaml/
  3. * Copyright (C) 2010 Jérôme Vouillon
  4. * Laboratoire PPS - CNRS Université Paris Diderot
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, with linking exception;
  9. * either version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. *)
  20. (** Javascript binding
  21. This module provides types and functions to interoperate with
  22. Javascript values, and gives access to Javascript standard
  23. objects.
  24. *)
  25. (** {2 Dealing with [null] and [undefined] values.} *)
  26. type +'a opt
  27. (** Type of possibly null values. *)
  28. type +'a optdef
  29. (** Type of possibly undefined values. *)
  30. val null : 'a opt
  31. (** The [null] value. *)
  32. val some : 'a -> 'a opt
  33. (** Consider a value into a possibly null value. *)
  34. val undefined : 'a optdef
  35. (** The [undefined] value *)
  36. val def : 'a -> 'a optdef
  37. (** Consider a value into a possibly undefined value. *)
  38. (** Signatures of a set of standard functions for manipulating
  39. optional values. *)
  40. module type OPT = sig
  41. type 'a t
  42. val empty : 'a t
  43. (** No value. *)
  44. val return : 'a -> 'a t
  45. (** Consider a value as an optional value. *)
  46. val map : 'a t -> ('a -> 'b) -> 'b t
  47. (** Apply a function to an optional value if it is available.
  48. Returns the result of the application. *)
  49. val bind : 'a t -> ('a -> 'b t) -> 'b t
  50. (** Apply a function returning an optional value to an optional value *)
  51. val test : 'a t -> bool
  52. (** Returns [true] if a value is available, [false] otherwise. *)
  53. val iter : 'a t -> ('a -> unit) -> unit
  54. (** Apply a function to an optional value if it is available. *)
  55. val case : 'a t -> (unit -> 'b) -> ('a -> 'b) -> 'b
  56. (** Pattern matching on optional values. *)
  57. val get : 'a t -> (unit -> 'a) -> 'a
  58. (** Get the value. If no value available, an alternative function
  59. is called to get a default value. *)
  60. val option : 'a option -> 'a t
  61. (** Convert option type. *)
  62. val to_option : 'a t -> 'a option
  63. (** Convert to option type. *)
  64. end
  65. module Opt : OPT with type 'a t = 'a opt
  66. (** Standard functions for manipulating possibly null values. *)
  67. module Optdef : OPT with type 'a t = 'a optdef
  68. (** Standard functions for manipulating possibly undefined values. *)
  69. (** {2 Types for specifying method and properties of Javascript objects} *)
  70. type +'a t
  71. (** Type of Javascript objects. The type parameter is used to
  72. specify more precisely an object. *)
  73. type +'a meth
  74. (** Type used to specify method types:
  75. a Javascript object
  76. [<m : t1 -> t2 -> ... -> tn -> t Js.meth> Js.t]
  77. has a Javascript method [m] expecting {i n} arguments
  78. of types [t1] to [tn] and returns a value of type [t]. *)
  79. type +'a gen_prop
  80. (** Type used to specify the properties of Javascript
  81. objects. In practice you should rarely need this type directly,
  82. but should rather use the type abbreviations below instead. *)
  83. type 'a readonly_prop = <get : 'a> gen_prop
  84. (** Type of read-only properties:
  85. a Javascript object
  86. [<p : t Js.readonly_prop> Js.t]
  87. has a read-only property [p] of type [t]. *)
  88. type 'a writeonly_prop = <set : 'a -> unit> gen_prop
  89. (** Type of write-only properties:
  90. a Javascript object
  91. [<p : t Js.writeonly_prop> Js.t]
  92. has a write-only property [p] of type [t]. *)
  93. type 'a prop = <get : 'a; set : 'a -> unit> gen_prop
  94. (** Type of read/write properties:
  95. a Javascript object
  96. [<p : t Js.writeonly_prop> Js.t]
  97. has a read/write property [p] of type [t]. *)
  98. type 'a optdef_prop = <get : 'a optdef; set : 'a -> unit> gen_prop
  99. (** Type of read/write properties that may be undefined:
  100. you can set them to a value of some type [t], but if you read
  101. them, you will get a value of type [t optdef] (that may be
  102. [undefined]). *)
  103. type float_prop = <get : float t; set : float -> unit> gen_prop
  104. (** Type of float properties:
  105. you can set them to an OCaml [float], but you will get back a
  106. native Javascript number of type [float t]. *)
  107. (** {2 Object constructors} *)
  108. type +'a constr
  109. (** A value of type [(t1 -> ... -> tn -> t Js.t) Js.constr] is a
  110. Javascript constructor expecting {i n} arguments of types [t1]
  111. to [tn] and returning a Javascript object of type [t Js.t]. Use
  112. the syntax extension [jsnew c (e1, ..., en)] to build an object
  113. using constructor [c] and arguments [e1] to [en]. *)
  114. (** {2 Callbacks to OCaml} *)
  115. type (-'a, +'b) meth_callback
  116. (** Type of callback functions. A function of type
  117. [(u, t1 -> ... -> tn -> t) meth_callback] can be called
  118. from Javascript with [this] bound to a value of type [u]
  119. and up to {i n} arguments of types [t1] to [tn]. The system
  120. takes care of currification, so less than {i n} arguments can
  121. be provided. As a special case, a callback of type
  122. [(t, unit -> t) meth_callback] can be called from Javascript
  123. with no argument. It will behave as if it was called with a
  124. single argument of type [unit]. *)
  125. type 'a callback = (unit, 'a) meth_callback
  126. (** Type of callback functions intended to be called without a
  127. meaningful [this] implicit parameter. *)
  128. external wrap_callback : ('a -> 'b) -> ('c, 'a -> 'b) meth_callback =
  129. "caml_js_wrap_callback"
  130. (** Wrap an OCaml function so that it can be invoked from
  131. Javascript. *)
  132. external wrap_meth_callback :
  133. ('c -> 'a -> 'b) -> ('c, 'a -> 'b) meth_callback =
  134. "caml_js_wrap_meth_callback"
  135. (** Wrap an OCaml function so that it can be invoked from
  136. Javascript. The first parameter of the function will be bound
  137. to the value of the [this] implicit parameter. *)
  138. (** {2 Javascript standard objects} *)
  139. val _true : bool t
  140. (** Javascript [true] boolean. *)
  141. val _false : bool t
  142. (** Javascript [false] boolean. *)
  143. type match_result_handle
  144. (** A handle to a match result. Use function [Js.match_result]
  145. to get the corresponding [MatchResult] object.
  146. (This type is used to resolved the mutual dependency between
  147. string and array type definitions.) *)
  148. type string_array
  149. (** Opaque type for string arrays. You can get the actual [Array]
  150. object using function [Js.str_array].
  151. (This type is used to resolved the mutual dependency between
  152. string and array type definitions.) *)
  153. (** Specification of Javascript string objects. *)
  154. class type js_string = object
  155. method toString : js_string t meth
  156. method valueOf : js_string t meth
  157. method charAt : int -> js_string t meth
  158. method charCodeAt : int -> float t meth (* This may return NaN... *)
  159. method concat : js_string t -> js_string t meth
  160. method concat_2 : js_string t -> js_string t -> js_string t meth
  161. method concat_3 :
  162. js_string t -> js_string t -> js_string t -> js_string t meth
  163. method concat_4 :
  164. js_string t -> js_string t -> js_string t -> js_string t ->
  165. js_string t meth
  166. method indexOf : js_string t -> int meth
  167. method indexOf_from : js_string t -> int -> int meth
  168. method lastIndexOf : js_string t -> int meth
  169. method lastIndexOf_from : js_string t -> int -> int meth
  170. method localeCompare : js_string t -> float t meth
  171. method _match : regExp t -> match_result_handle t opt meth
  172. method replace : regExp t -> js_string t -> js_string t meth
  173. (* FIX: version of replace taking a function... *)
  174. method replace_string : js_string t -> js_string t -> js_string t meth
  175. method search : regExp t -> int meth
  176. method slice : int -> int -> js_string t meth
  177. method slice_end : int -> js_string t meth
  178. method split : js_string t -> string_array t meth
  179. method split_limited : js_string t -> int -> string_array t meth
  180. method split_regExp : regExp t -> string_array t meth
  181. method split_regExpLimited : regExp t -> int -> string_array t meth
  182. method substring : int -> int -> js_string t meth
  183. method substring_toEnd : int -> js_string t meth
  184. method toLowerCase : js_string t meth
  185. method toLocaleLowerCase : js_string t meth
  186. method toUpperCase : js_string t meth
  187. method toLocaleUpperCase : js_string t meth
  188. method length : int readonly_prop
  189. end
  190. (** Specification of Javascript regular expression objects. *)
  191. and regExp = object
  192. method exec : js_string t -> match_result_handle t opt meth
  193. method test : js_string t -> bool t meth
  194. method toString : js_string t meth
  195. method source : js_string t readonly_prop
  196. method global : bool t readonly_prop
  197. method ignoreCase : bool t readonly_prop
  198. method multiline : bool t readonly_prop
  199. method lastIndex : int prop
  200. end
  201. val regExp : (js_string t -> regExp t) constr
  202. (** Constructor of [RegExp] objects. The expression [jsnew regExp (s)]
  203. builds the regular expression specified by string [s]. *)
  204. val regExp_withFlags : (js_string t -> js_string t -> regExp t) constr
  205. (** Constructor of [RegExp] objects. The expression
  206. [jsnew regExp (s, f)] builds the regular expression specified by
  207. string [s] using flags [f]. *)
  208. val regExp_copy : (regExp t -> regExp t) constr
  209. (** Constructor of [RegExp] objects. The expression
  210. [jsnew regExp (r)] builds a copy of regular expression [r]. *)
  211. (** Specification of Javascript regular arrays. *)
  212. class type ['a] js_array = object
  213. method toString : js_string t meth
  214. method toLocaleString : js_string t meth
  215. method concat : 'a js_array t -> 'a js_array t meth
  216. method join : js_string t -> js_string t meth
  217. method pop : 'a optdef meth
  218. method push : 'a -> int meth
  219. method push_2 : 'a -> 'a -> int meth
  220. method push_3 : 'a -> 'a -> 'a -> int meth
  221. method push_4 : 'a -> 'a -> 'a -> 'a -> int meth
  222. method reverse : 'a js_array t meth
  223. method shift : 'a optdef meth
  224. method slice : int -> int -> 'a js_array t meth
  225. method slice_end : int -> 'a js_array t meth
  226. method sort : ('a -> 'a -> float) callback -> 'a js_array t meth
  227. method sort_asStrings : 'a js_array t meth
  228. method splice : int -> int -> 'a js_array t meth
  229. method splice_1 : int -> int -> 'a -> 'a js_array t meth
  230. method splice_2 : int -> int -> 'a -> 'a -> 'a js_array t meth
  231. method splice_3 : int -> int -> 'a -> 'a -> 'a -> 'a js_array t meth
  232. method splice_4 : int -> int -> 'a -> 'a -> 'a -> 'a -> 'a js_array t meth
  233. method unshift : 'a -> int meth
  234. method unshift_2 : 'a -> 'a -> int meth
  235. method unshift_3 : 'a -> 'a -> 'a -> int meth
  236. method unshift_4 : 'a -> 'a -> 'a -> 'a -> int meth
  237. method length : int prop
  238. end
  239. val array_empty : 'a js_array t constr
  240. (** Constructor of [Array] objects. The expression
  241. [jsnew array_empty ()] returns an empty array. *)
  242. val array_length : (int -> 'a js_array t) constr
  243. (** Constructor of [Array] objects. The expression
  244. [jsnew array_empty (l)] returns an array of length [l]. *)
  245. val array_get : 'a #js_array t -> int -> 'a optdef
  246. (** Array access: [array_get a i] returns the element at index [i]
  247. of array [a]. Returns [undefined] if there is no element at
  248. this index. *)
  249. val array_set : 'a #js_array t -> int -> 'a -> unit
  250. (** Array update: [array_set a i v] puts [v] at index [i] in
  251. array [a]. *)
  252. (** Specification of match result objects *)
  253. class type match_result = object
  254. inherit [js_string t] js_array
  255. method index : int readonly_prop
  256. method input : js_string t readonly_prop
  257. end
  258. val str_array : string_array t -> js_string t js_array t
  259. (** Convert an opaque [string_array t] object into an array of
  260. string. (Used to resolved the mutual dependency between string
  261. and array type definitions.) *)
  262. val match_result : match_result_handle t -> match_result t
  263. (** Convert a match result handle into a [MatchResult] object.
  264. (Used to resolved the mutual dependency between string
  265. and array type definitions.) *)
  266. (** Specification of Javascript number objects. *)
  267. class type number = object
  268. method toString : js_string t meth
  269. method toString_radix : int -> js_string t meth
  270. method toLocaleString : js_string t meth
  271. method toFixed : int -> js_string t meth
  272. method toExponential : js_string t meth
  273. method toExponential_digits : int -> js_string t meth
  274. method toPrecision : int -> js_string meth t
  275. end
  276. external number_of_float : float -> number t = "caml_js_from_float"
  277. (** Conversion of OCaml floats to Javascript number objects. *)
  278. external float_of_number : number t -> float = "caml_js_to_float"
  279. (** Conversion of Javascript number objects to OCaml floats. *)
  280. (** Specification of Javascript date objects. *)
  281. class type date = object
  282. method toString : js_string t meth
  283. method toDateString : js_string t meth
  284. method toTimeString : js_string t meth
  285. method toLocaleString : js_string t meth
  286. method toLocaleDateString : js_string t meth
  287. method toLocaleTimeString : js_string t meth
  288. method valueOf : float t meth
  289. method getTime : float t meth
  290. method getFullYear : int meth
  291. method getUTCFullYear : int meth
  292. method getMonth : int meth
  293. method getUTCMonth : int meth
  294. method getDate : int meth
  295. method getUTCDate : int meth
  296. method getDay : int meth
  297. method getUTCDay : int meth
  298. method getHours : int meth
  299. method getUTCHours : int meth
  300. method getMinutes : int meth
  301. method getUTCMinutes : int meth
  302. method getSeconds : int meth
  303. method getUTCSeconds : int meth
  304. method getMilliseconds : int meth
  305. method getUTCMilliseconds : int meth
  306. method getTimezoneOffset : int meth
  307. method setTime : float -> float t meth
  308. method setFullYear : int -> float t meth
  309. method setUTCFullYear : int -> float t meth
  310. method setMonth : int -> float t meth
  311. method setUTCMonth : int -> float t meth
  312. method setDate : int -> float t meth
  313. method setUTCDate : int -> float t meth
  314. method setDay : int -> float t meth
  315. method setUTCDay : int -> float t meth
  316. method setHours : int -> float t meth
  317. method setUTCHours : int -> float t meth
  318. method setMinutes : int -> float t meth
  319. method setUTCMinutes : int -> float t meth
  320. method setSeconds : int -> float t meth
  321. method setUTCSeconds : int -> float t meth
  322. method setMilliseconds : int -> float t meth
  323. method setUTCMilliseconds : int -> float t meth
  324. method toUTCString : js_string t meth
  325. method toISOString : js_string t meth
  326. method toJSON : 'a -> js_string t meth
  327. end
  328. val date_now : date t constr
  329. (** Constructor of [Date] objects: [new date_now ()] returns a
  330. [Date] object initialized with the current date. *)
  331. val date_fromTimeValue : (float -> date t) constr
  332. (** Constructor of [Date] objects: [new date_fromTimeValue (t)] returns a
  333. [Date] object initialized with the time value [t]. *)
  334. val date_month : (int -> int -> date t) constr
  335. (** Constructor of [Date] objects: [new date_fromTimeValue (y, m)]
  336. returns a [Date] object corresponding to year [y] and month [m]. *)
  337. val date_day : (int -> int -> int -> date t) constr
  338. (** Constructor of [Date] objects: [new date_fromTimeValue (y, m, d)]
  339. returns a [Date] object corresponding to year [y], month [m] and
  340. day [d]. *)
  341. val date_hour : (int -> int -> int -> int -> date t) constr
  342. (** Constructor of [Date] objects: [new date_fromTimeValue (y, m, d, h)]
  343. returns a [Date] object corresponding to year [y] to hour [h]. *)
  344. val date_min : (int -> int -> int -> int -> int -> date t) constr
  345. (** Constructor of [Date] objects: [new date_fromTimeValue (y, m, d, h, m')]
  346. returns a [Date] object corresponding to year [y] to minute [m']. *)
  347. val date_sec : (int -> int -> int -> int -> int -> int -> date t) constr
  348. (** Constructor of [Date] objects:
  349. [new date_fromTimeValue (y, m, d, h, m', s)]
  350. returns a [Date] object corresponding to year [y] to second [s]. *)
  351. val date_ms : (int -> int -> int -> int -> int -> int -> int -> date t) constr
  352. (** Constructor of [Date] objects:
  353. [new date_fromTimeValue (y, m, d, h, m', s, ms)]
  354. returns a [Date] object corresponding to year [y]
  355. to millisecond [ms]. *)
  356. (** Specification of the date constructor, considered as an object. *)
  357. class type date_constr = object
  358. method parse : js_string t -> float t meth
  359. method _UTC_month : int -> int -> float t meth
  360. method _UTC_day : int -> int -> float t meth
  361. method _UTC_hour : int -> int -> int -> int -> float t meth
  362. method _UTC_min : int -> int -> int -> int -> int -> float t meth
  363. method _UTC_sec : int -> int -> int -> int -> int -> int -> float t meth
  364. method _UTC_ms :
  365. int -> int -> int -> int -> int -> int -> int -> float t meth
  366. (* This method is not available on Internet Explorer...
  367. method now : float t meth
  368. *)
  369. end
  370. val date : date_constr t
  371. (** The date constructor, as an object. *)
  372. (** Specification of Javascript math object. *)
  373. class type math = object
  374. method random : float t meth
  375. end
  376. val math : math t
  377. (** The Math object *)
  378. (** {2 Standard Javascript functions} *)
  379. val decodeURI : js_string t -> js_string t
  380. (** Decode a URI: replace by the corresponding byte all escape
  381. sequences but the ones corresponding to a URI reserved character
  382. and convert the string from UTF-8 to UTF-16. *)
  383. val decodeURIComponent : js_string t -> js_string t
  384. (** Decode a URIComponent: replace all escape sequences by the
  385. corresponding byte and convert the string from UTF-8 to
  386. UTF-16. *)
  387. val encodeURI : js_string t -> js_string t
  388. (** Encode a URI: convert the string to UTF-8 and replace all unsafe
  389. bytes by the corresponding escape sequence. *)
  390. val encodeURIComponent : js_string t -> js_string t
  391. (** Same as [encodeURI], but also encode URI reserved characters. *)
  392. val escape : js_string t -> js_string t
  393. (** Escape a string: unsafe UTF-16 code points are replaced by
  394. 2-digit and 4-digit escape sequences. *)
  395. val unescape : js_string t -> js_string t
  396. (** Unescape a string: 2-digit and 4-digit escape sequences are
  397. replaced by the corresponding UTF-16 code point. *)
  398. (** {2 Conversion functions between Javascript and OCaml types} *)
  399. external bool : bool -> bool t = "caml_js_from_bool"
  400. (** Conversion of booleans from OCaml to Javascript. *)
  401. external to_bool : bool t -> bool = "caml_js_to_bool"
  402. (** Conversion of booleans from Javascript to OCaml. *)
  403. external string : string -> js_string t = "caml_js_from_string"
  404. (** Conversion of strings from OCaml to Javascript. (The OCaml
  405. string is considered to be encoded in UTF-8 and is converted to
  406. UTF-16.) *)
  407. external to_string : js_string t -> string = "caml_js_to_string"
  408. (** Conversion of strings from Javascript to OCaml. *)
  409. external float : float -> float t = "caml_js_from_float"
  410. (** Conversion of OCaml floats to Javascript numbers. *)
  411. external to_float : float t -> float = "caml_js_to_float"
  412. (** Conversion of Javascript numbers to OCaml floats. *)
  413. external array : 'a array -> 'a js_array t = "caml_js_from_array"
  414. (** Conversion of arrays from OCaml to Javascript. *)
  415. external to_array : 'a js_array t -> 'a array = "caml_js_to_array"
  416. (** Conversion of arrays from Javascript to OCaml. *)
  417. external bytestring : string -> js_string t = "caml_js_from_byte_string"
  418. (** Conversion of strings of bytes from OCaml to Javascript.
  419. (Each byte will be converted in an UTF-16 code point.) *)
  420. external to_bytestring : js_string t -> string = "caml_js_to_byte_string"
  421. (** Conversion of strings of bytes from Javascript to OCaml. (The
  422. Javascript string should only contain UTF-16 code points below
  423. 255.) *)
  424. (** {2 Convenience coercion functions} *)
  425. val coerce : 'a -> ('a -> 'b Opt.t) -> ('a -> 'b) -> 'b
  426. (** Apply a possibly failing coercion function.
  427. [coerce v c f] attempts to apply coercion [c] to value [v].
  428. If the coercion returns [null], function [f] is called. *)
  429. val coerce_opt : 'a Opt.t -> ('a -> 'b Opt.t) -> ('a -> 'b) -> 'b
  430. (** Apply a possibly failing coercion function.
  431. [coerce_opt v c f] attempts to apply coercion [c] to value [v].
  432. If [v] is [null] or the coercion returns [null], function [f] is
  433. called.
  434. Typical usage is the following:
  435. {[Js.coerce_opt (Dom_html.getElementById id)
  436. Dom_html.CoerceTo.div (fun _ -> assert false)]} *)
  437. (** {2 Type checking operators.} *)
  438. external typeof : < .. > t -> js_string t = "caml_js_typeof"
  439. (** Returns the type of a Javascript object. *)
  440. external instanceof : < .. > t -> _ constr -> bool = "caml_js_instanceof"
  441. (** Tests whether a Javascript object is an instance of a given class. *)
  442. (** {2 Unsafe operations.} *)
  443. (** Unsafe Javascript operations *)
  444. module Unsafe : sig
  445. external variable : string -> 'a = "caml_js_var"
  446. (** Access a Javascript variable. [variable "foo"] will
  447. return the current value of variable [foo]. *)
  448. type any
  449. (** Top type. Used for putting values of different types
  450. in a same array. *)
  451. external inject : 'a -> any = "%identity"
  452. (** Coercion to top type. *)
  453. external coerce : < .. > t -> < ..> t = "%identity"
  454. (** Unsafe coercion between to Javascript objects. *)
  455. external get : 'a -> 'b -> 'c = "caml_js_get"
  456. (** Get the value of an object property. The expression [get o s]
  457. returns the value of property [s] of object [o]. *)
  458. external set : 'a -> 'b -> 'c -> unit = "caml_js_set"
  459. (** Set an object property. The expression [set o s v]
  460. set the property [s] of object [o] to value [v]. *)
  461. external call : 'a -> 'b -> any array -> 'c = "caml_js_call"
  462. (** Performs a Javascript function call. The expression
  463. [call f o a] calls the Javascript function [f] with the
  464. arguments given by the array [o], and binding [this] to [o]. *)
  465. external fun_call : 'a -> any array -> 'b = "caml_js_fun_call"
  466. (** Performs a Javascript function call. The expression
  467. [fun_call f a] calls the Javascript function [f] with the
  468. arguments given by the array [o]. *)
  469. external meth_call : 'a -> string -> any array -> 'b = "caml_js_meth_call"
  470. (** Performs a Javascript method call. The expression
  471. [meth_call o m a] calls the Javascript method [m] of object [o]
  472. with the arguments given by the array [a]. *)
  473. external new_obj : 'a -> any array -> 'b = "caml_js_new"
  474. (** Create a Javascript object. The expression [new_obj c a]
  475. creates a Javascript object with constructor [c] using the
  476. arguments given by the array [a]. *)
  477. external pure_expr : (unit -> 'a) -> 'a = "caml_js_pure_expr"
  478. (** Asserts that an expression is pure, and can therefore be
  479. optimized away by the compiler if unused. *)
  480. external eval_string : string -> 'a = "caml_js_eval_string"
  481. (** Evaluate Javascript code *)
  482. (*FIX also, object/array literals *)
  483. end