Skip to content

Instantly share code, notes, and snippets.

@SanderSpies
Created December 17, 2015 16:17
Show Gist options
  • Save SanderSpies/ed6b934dc8fdb6feb217 to your computer and use it in GitHub Desktop.
Save SanderSpies/ed6b934dc8fdb6feb217 to your computer and use it in GitHub Desktop.
JSC in OCaml
let context = createGlobalContext null in
let script = createStringWithUTF8CString "(function(){return 'Hi OCaml, this is your friend JavaScriptCore.';})();" in
let valueref = evaluateScript context script null null 0 null in
let result = valueToString context valueref null in
let ocaml_str = toOCamlString result in (
print_string ocaml_str;
releaseString script;
releaseGlobalContext context;
releaseOCamlString ocaml_str);;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment