IOJsScript constructor

IOJsScript({
  1. int maxArguments = MAX_ARGUMENTS,
  2. void onUncaughtError(
    1. String
    )?,
  3. dynamic fileSystems = const [],
})

Implementation

IOJsScript({
  this.maxArguments = MAX_ARGUMENTS,
  this.onUncaughtError,
  fileSystems = const []
}) : _rawArguments = malloc.allocate(maxArguments * sizeOf<JsArgument>()),
      _rawResults = malloc.allocate(maxArguments * sizeOf<JsArgument>()),
      super.init(fileSystems: fileSystems) {
  for (int i = 0; i < maxArguments; ++i) {
    _arguments.add(_rawArguments[i]);
  }
  for (int i = 0; i < maxArguments; ++i) {
    _results.add(_rawResults[i]);
  }

  Pointer<JsHandlers> handlers = malloc.allocate(sizeOf<JsHandlers>());
  handlers.ref.maxArguments = maxArguments;
  handlers.ref.print = _printHandlerPtr;
  handlers.ref.toDartAction = _toDartHandlerPtr;
  _context = binder.setupJsContext(_rawArguments, _rawResults, handlers);
  _index[_context] = this;
  malloc.free(handlers);
  addClass(ClassInfo<Object>(
    name: "DartObject",
    newInstance: (_, argv) => Object(),
  ));
  addClass(mapClass);
  addClass(listClass);
}