callFunction property

JsFunction callFunction

Implementation

js.JsFunction get callFunction {
  if (_callFunction == null) {
    _callFunction = js.JsFunction.withThis((js.JsObject self, ClassInfo classInfo, int method, List args) {
      var member = classInfo.members[method];
      List arr = [];
      var iter = args.iterator;
      while (true) {
        try {
          if (iter.moveNext()) {
            arr.add(wrap(iter.current, this));
          } else {
            break;
          }
        } catch (e) {
          arr.add(null);
          break;
        }
      }
      var ret;
      if (method == 0) {
        ret = member.call(this, arr);
      } else if (member.type & MEMBER_STATIC != 0) {
        ret = member.call(null, arr);
      } else {
        ret = member.call(self[privateKey], arr);
      }
      return jsValue(ret, this);
    });
  }
  return _callFunction!;
}