This repository has been archived by the owner on Jan 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Creating a hosting context
fholm edited this page Apr 6, 2011
·
2 revisions
Creating a hosting context for IronJS is very simple, first you open the namespaces and modules you'll need:
open IronJS
module IronJS = IronJS.Hosting.FSharp
Then call createContext
on the IronJS.Hosting.FSharp
(aliased as IronJS
):
let ctx = IronJS.createContext()
To execute JavaScript source code you have access to the following methods on the Hosting.FSharp
module
execute : string -> IronJS.Hosting.FSharp.T -> obj
executeAs<'a> : string -> IronJS.Hosting.FSharp.T -> 'a
executeFile : string -> IronJS.Hosting.FSharp.T -> obj
executeFileAs<'a> : string -> IronJS.Hosting.FSharp.T -> 'a
For working with global values you have access to the following fucntions:
setGlobal: string -> obj -> IronJS.Hosting.FSharp.T -> unit
getGlobal: string -> IronJS.Hosting.FSharp.T -> IronJS.BoxedValue
getGlobalAs<'a>: string -> IronJS.Hosting.FSharp.T -> 'a
You can also access the IronJS environment object and the globals object with the following functions
env: -> IronJS.Hosting.FSharp.T -> IronJS.Environment
globals: -> IronJS.Hosting.FSharp.T -> IronJS.CommonObject