Function xsHostZone

Used to set up and clean up a stack frame, so that you can use all the macros of XS in C in between, provided in lieu of xsBeginHost and xsEndHost.

ReturnType!Func xsHostZone(alias Func) (
  scope xsMachine* the
)
if (isCallableAsHostZone!Func);

Uncaught exceptions that occur within Func do not propagate beyond the execution of xsHostZone.

Returns

The result of Func, or void if Func has no return type.

Throws

JSException when the JS VM is aborted with the xsUnhandledExceptionExit status while executing Func.

See Also

From the XS in C Moddable SDK Documentation:

Examples

long xsWndProc(HWND hwnd, uint m, uint w, long l)
{
long result = 0;
xsMachine* aMachine = GetWindowLongPtr(hwnd, GWL_USERDATA);
auto zone = (xsMachine* the) => {
result = the.xsToInteger(the.xsCall(
the.xsGlobal, xsID_dispatch,
the.xsInteger(m), the.xsInteger(w), the.xsInteger(l)
));
}();
aMachine.xsHostZone!zone;
return result;
}