Skip to content
oliverbock edited this page Dec 5, 2018 · 2 revisions

Type conversion

When converting C# objects into JavaScript, simple types and arrays will be copied in. Complex types (classes) will be wrapped, and calls to their methods/properties will be forwarded to C#.

Fatal errors

Stack overflows and other badness will terminate the entire process. This is a v8 thing, and not something we can do much about.

API

JavascriptContext();

Constructs a single, isolate v8 context. Code in one context runs independently of code in other contexts, and they cannot interact.

void SetParameter(System::String^ iName, System::Object^ iObject);

Give a C# object for use by JavaScript code. This goes into the global object (like window in a browser).

System::Object^ GetParameter(System::String^ iName);

Copies a value form the global object back into C#.

System::Object^ Run(System::String^ iSourceCode);

System::Object^ Run(System::String^ iScript, System::String^ iScriptResourceName);

Runs a fragment of JavaScript source code. iScriptResourceName is the name that will be shown for this code in stack traces.

static System::String^ V8Version { System::String^ get(); }

Returns the version of v8 compiled into this copy of JavaScript.Net.

System::Collections::Generic::List<JavascriptStackFrame^>^ GetCurrentStack(int maxDepth);

Not sure what this is for, or how it would be useful.

void TerminateExecution();

void TerminateExecution(bool terminate_subsequent_runs);

Terminates the code running in this context (if any). Typically called from another thread.
terminate_subsequent_runs allows you to avoid the race condition that occurs if you haven't yet called Run(), and you know your context is being constructed for a single execution.

bool IsExecutionTerminating();

Tells you that you have called TerminateExecution(). Not sure why we support this.