JSCFunctionListEntry.defCFunc constructor

JSCFunctionListEntry.defCFunc(
  1. JSContext _ctx,
  2. String name, {
  3. JSCFunction? func,
  4. int argc = 0,
  5. bool autoDispose = true,
})

Implementation

JSCFunctionListEntry.defCFunc(
  this._ctx,
  String name, {
  JSCFunction? func,
  int argc = 0,
  bool autoDispose = true,
}) {
  name = name;
  propFlags = JSProp.WRITABLE | JSProp.CONFIGURABLE;
  defType = JSDef.CFUNC;
  magic = 0;
  union = JSCFuntionListEntryUnion(
    func: JSCFunctionListEntryFunc(
      argc,
      JSCFunctionEnum.JS_CFUNC_generic,
      JSCFunctionType.defGeneric(_ctx, generic: func),
    ),
  );
  _ref =
      calloc.call(sizeOf<JSCFunctionListEntry_>())
        ..ref.name = name.toNativeUtf8()
        ..ref.prop_flags = propFlags.value
        ..ref.def_type = defType.value
        ..ref.magic = magic
        ..ref.u = union!.ref.ref;
  attach(calloc.nativeFree, _ref.cast(), autoDispose: autoDispose);
}