blob: 409484c3f0c575db30ebe902841e4c6af193e0d8 [file]
// AUTO GENERATED FILE, DO NOT EDIT.
//
// Generated by `package:ffigen`.
// ignore_for_file: type=lint, unused_import, unused_element, deprecated_member_use_from_same_package
@ffi.DefaultAsset('package:ffigen/swift_class_test')
library;
import 'dart:ffi' as ffi;
import 'package:objective_c/objective_c.dart' as objc;
import 'package:ffi/ffi.dart' as pkg_ffi;
const _$objcVersionCheck = objc.ObjCVersionCheck(9, 4);
@ffi.Native<
ffi.Long Function(ffi.Pointer<objc.ObjCObjectImpl>, ffi.Pointer<ffi.Void>)
>()
external int _pyqkbm_protocolTrampoline_fai2e9(
ffi.Pointer<objc.ObjCObjectImpl> target,
ffi.Pointer<ffi.Void> arg0,
);
/// MySwiftClass
extension type MySwiftClass._(objc.ObjCObject object$)
implements objc.ObjCObject, objc.NSObject, MySwiftProtocol {
/// Constructs a [MySwiftClass] that points to the same underlying object as [other].
MySwiftClass.as(objc.ObjCObject other) : object$ = other {
assert(isA(object$));
}
/// Constructs a [MySwiftClass] that wraps the given raw object pointer.
MySwiftClass.fromPointer(
ffi.Pointer<objc.ObjCObjectImpl> other, {
bool retain = false,
bool release = false,
}) : object$ = objc.ObjCObject(other, retain: retain, release: release) {
assert(isA(object$));
}
/// Returns whether [obj] is an instance of [MySwiftClass].
static bool isA(objc.ObjCObject? obj) => obj == null
? false
: _objc_msgSend_19nvye5(
obj.ref.pointer,
_sel_isKindOfClass_,
_class_MySwiftClass,
);
/// alloc
static MySwiftClass alloc() {
final $ret = _objc_msgSend_151sglz(_class_MySwiftClass, _sel_alloc);
return MySwiftClass.fromPointer($ret, retain: false, release: true);
}
/// allocWithZone:
static MySwiftClass allocWithZone(ffi.Pointer<objc.NSZone> zone) {
final $ret = _objc_msgSend_1cwp428(
_class_MySwiftClass,
_sel_allocWithZone_,
zone,
);
return MySwiftClass.fromPointer($ret, retain: false, release: true);
}
/// new
static MySwiftClass new$() {
final $ret = _objc_msgSend_151sglz(_class_MySwiftClass, _sel_new);
return MySwiftClass.fromPointer($ret, retain: false, release: true);
}
/// Returns a new instance of MySwiftClass constructed with the default `new` method.
MySwiftClass() : this.as(new$().object$);
}
extension MySwiftClass$Methods on MySwiftClass {
/// getValue
int getValue() {
final _$$ref = object$.ref;
return _objc_msgSend_1hz7y9r(_$$ref.pointer, _sel_getValue);
}
/// init
MySwiftClass init() {
final _$$ref = object$.ref;
objc.checkOsVersionInternal(
'MySwiftClass.init',
iOS: (false, (2, 0, 0)),
macOS: (false, (10, 0, 0)),
);
final $ret = _objc_msgSend_151sglz(
_$$ref.retainAndReturnPointer(),
_sel_init,
);
return MySwiftClass.fromPointer($ret, retain: false, release: true);
}
/// setValueWithX:
void setValueWithX(int x) {
final _$$ref = object$.ref;
_objc_msgSend_4sp4xj(_$$ref.pointer, _sel_setValueWithX_, x);
}
}
/// MySwiftProtocol
extension type MySwiftProtocol._(objc.ObjCProtocol object$)
implements objc.ObjCProtocol, objc.NSObjectProtocol {
/// Constructs a [MySwiftProtocol] that points to the same underlying object as [other].
MySwiftProtocol.as(objc.ObjCObject other) : object$ = other;
/// Constructs a [MySwiftProtocol] that wraps the given raw object pointer.
MySwiftProtocol.fromPointer(
ffi.Pointer<objc.ObjCObjectImpl> other, {
bool retain = false,
bool release = false,
}) : object$ = objc.ObjCProtocol(other, retain: retain, release: release);
/// Returns whether [obj] is an instance of [MySwiftProtocol].
static bool conformsTo(objc.ObjCObject obj) {
return _objc_msgSend_e3qsqz(
obj.ref.pointer,
_sel_conformsToProtocol_,
_protocol_MySwiftProtocol,
);
}
}
extension MySwiftProtocol$Methods on MySwiftProtocol {
/// getValue
int getValue() {
final _$$ref$1 = object$.ref;
return _objc_msgSend_1hz7y9r(_$$ref$1.pointer, _sel_getValue);
}
}
interface class MySwiftProtocol$Builder {
/// Returns the [objc.Protocol] object for this protocol.
static objc.Protocol get $protocol =>
objc.Protocol.fromPointer(_protocol_MySwiftProtocol.cast());
/// Builds an object that implements the MySwiftProtocol protocol. To implement
/// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly.
///
/// If `$keepIsolateAlive` is true, this protocol will keep this isolate
/// alive until it is garbage collected by both Dart and ObjC.
static MySwiftProtocol implement({
required int Function() getValue,
bool $keepIsolateAlive = true,
}) {
final builder = objc.ObjCProtocolBuilder(debugName: 'MySwiftProtocol');
MySwiftProtocol$Builder.getValue.implement(builder, getValue);
builder.addProtocol($protocol);
return MySwiftProtocol.as(
builder.build(keepIsolateAlive: $keepIsolateAlive),
);
}
/// Adds the implementation of the MySwiftProtocol protocol to an existing
/// [objc.ObjCProtocolBuilder].
///
/// Note: You cannot call this method after you have called `builder.build`.
static void addToBuilder(
objc.ObjCProtocolBuilder builder, {
required int Function() getValue,
bool $keepIsolateAlive = true,
}) {
MySwiftProtocol$Builder.getValue.implement(builder, getValue);
builder.addProtocol($protocol);
}
/// getValue
static final getValue = objc.ObjCProtocolMethod<int Function()>(
_protocol_MySwiftProtocol,
_sel_getValue,
ffi.Native.addressOf<
ffi.NativeFunction<
ffi.Long Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<ffi.Void>,
)
>
>(_pyqkbm_protocolTrampoline_fai2e9)
.cast(),
objc.getProtocolMethodSignature(
_protocol_MySwiftProtocol,
_sel_getValue,
isRequired: true,
isInstanceMethod: true,
),
(int Function() func) => ObjCBlock_NSInteger_ffiVoid.fromFunction(
(ffi.Pointer<ffi.Void> _) => func(),
),
);
}
/// Construction methods for `objc.ObjCBlock<ffi.Long Function(ffi.Pointer<ffi.Void>)>`.
abstract final class ObjCBlock_NSInteger_ffiVoid {
/// Returns a block that wraps the given raw block pointer.
static objc.ObjCBlock<ffi.Long Function(ffi.Pointer<ffi.Void>)> fromPointer(
ffi.Pointer<objc.ObjCBlockImpl> pointer, {
bool retain = false,
bool release = false,
}) => objc.ObjCBlock<ffi.Long Function(ffi.Pointer<ffi.Void>)>(
pointer,
retain: retain,
release: release,
);
/// Creates a block from a C function pointer.
///
/// This block must be invoked by native code running on the same thread as
/// the isolate that registered it. Invoking the block on the wrong thread
/// will result in a crash.
static objc.ObjCBlock<ffi.Long Function(ffi.Pointer<ffi.Void>)>
fromFunctionPointer(
ffi.Pointer<
ffi.NativeFunction<ffi.Long Function(ffi.Pointer<ffi.Void> arg0)>
>
ptr,
) => objc.ObjCBlock<ffi.Long Function(ffi.Pointer<ffi.Void>)>(
objc.newPointerBlock(_fnPtrCallable, ptr.cast()),
retain: false,
release: true,
);
/// Creates a block from a Dart function.
///
/// This block must be invoked by native code running on the same thread as
/// the isolate that registered it. Invoking the block on the wrong thread
/// will result in a crash.
///
/// If `keepIsolateAlive` is true, this block will keep this isolate alive
/// until it is garbage collected by both Dart and ObjC.
static objc.ObjCBlock<ffi.Long Function(ffi.Pointer<ffi.Void>)> fromFunction(
int Function(ffi.Pointer<ffi.Void>) fn, {
bool keepIsolateAlive = true,
}) => objc.ObjCBlock<ffi.Long Function(ffi.Pointer<ffi.Void>)>(
objc.newClosureBlock(_closureCallable, (ffi.Pointer<ffi.Void> arg0) {
return fn(arg0);
}, keepIsolateAlive),
retain: false,
release: true,
);
static int _fnPtrTrampoline(
ffi.Pointer<objc.ObjCBlockImpl> block,
ffi.Pointer<ffi.Void> arg0,
) => block.ref.target
.cast<ffi.NativeFunction<ffi.Long Function(ffi.Pointer<ffi.Void> arg0)>>()
.asFunction<int Function(ffi.Pointer<ffi.Void>)>()(arg0);
static ffi.Pointer<ffi.Void> _fnPtrCallable =
ffi.Pointer.fromFunction<
ffi.Long Function(
ffi.Pointer<objc.ObjCBlockImpl>,
ffi.Pointer<ffi.Void>,
)
>(_fnPtrTrampoline, 0)
.cast();
static int _closureTrampoline(
ffi.Pointer<objc.ObjCBlockImpl> block,
ffi.Pointer<ffi.Void> arg0,
) => (objc.getBlockClosure(block) as int Function(ffi.Pointer<ffi.Void>))(
arg0,
);
static ffi.Pointer<ffi.Void> _closureCallable =
ffi.Pointer.fromFunction<
ffi.Long Function(
ffi.Pointer<objc.ObjCBlockImpl>,
ffi.Pointer<ffi.Void>,
)
>(_closureTrampoline, 0)
.cast();
}
/// Call operator for `objc.ObjCBlock<ffi.Long Function(ffi.Pointer<ffi.Void>)>`.
extension ObjCBlock_NSInteger_ffiVoid$CallExtension
on objc.ObjCBlock<ffi.Long Function(ffi.Pointer<ffi.Void>)> {
int call(ffi.Pointer<ffi.Void> arg0) {
return ref.pointer.ref.invoke
.cast<
ffi.NativeFunction<
ffi.Long Function(
ffi.Pointer<objc.ObjCBlockImpl> block,
ffi.Pointer<ffi.Void> arg0,
)
>
>()
.asFunction<
int Function(ffi.Pointer<objc.ObjCBlockImpl>, ffi.Pointer<ffi.Void>)
>()(ref.pointer, arg0);
}
}
@ffi.Native<ffi.Pointer<objc.ObjCObjectImpl>>(
symbol: 'OBJC_CLASS_\$__TtC16swift_class_test12MySwiftClass',
)
external ffi.Pointer<objc.ObjCObjectImpl> _class_MySwiftClass_raw;
final _class_MySwiftClass = objc.getClass(
"swift_class_test.MySwiftClass",
() => ffi.Native.addressOf<ffi.Pointer<objc.ObjCObjectImpl>>(
_class_MySwiftClass_raw,
).cast(),
);
final _objc_msgSend_151sglz = objc.msgSendPointer
.cast<
ffi.NativeFunction<
ffi.Pointer<objc.ObjCObjectImpl> Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
)
>
>()
.asFunction<
ffi.Pointer<objc.ObjCObjectImpl> Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
)
>();
final _objc_msgSend_19nvye5 = objc.msgSendPointer
.cast<
ffi.NativeFunction<
ffi.Bool Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
ffi.Pointer<objc.ObjCObjectImpl>,
)
>
>()
.asFunction<
bool Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
ffi.Pointer<objc.ObjCObjectImpl>,
)
>();
final _objc_msgSend_1cwp428 = objc.msgSendPointer
.cast<
ffi.NativeFunction<
ffi.Pointer<objc.ObjCObjectImpl> Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
ffi.Pointer<objc.NSZone>,
)
>
>()
.asFunction<
ffi.Pointer<objc.ObjCObjectImpl> Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
ffi.Pointer<objc.NSZone>,
)
>();
final _objc_msgSend_1hz7y9r = objc.msgSendPointer
.cast<
ffi.NativeFunction<
ffi.Long Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
)
>
>()
.asFunction<
int Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
)
>();
final _objc_msgSend_4sp4xj = objc.msgSendPointer
.cast<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
ffi.Long,
)
>
>()
.asFunction<
void Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
int,
)
>();
final _objc_msgSend_e3qsqz = objc.msgSendPointer
.cast<
ffi.NativeFunction<
ffi.Bool Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
ffi.Pointer<objc.ObjCProtocolImpl>,
)
>
>()
.asFunction<
bool Function(
ffi.Pointer<objc.ObjCObjectImpl>,
ffi.Pointer<objc.ObjCSelector>,
ffi.Pointer<objc.ObjCProtocolImpl>,
)
>();
@ffi.Native<ffi.Pointer<objc.ObjCProtocolImpl> Function()>(
symbol: '_pyqkbm_MySwiftProtocol',
)
external ffi.Pointer<objc.ObjCProtocolImpl> _protocol_MySwiftProtocol_raw();
final _protocol_MySwiftProtocol = objc.getProtocol(
"swift_class_test.MySwiftProtocol",
_protocol_MySwiftProtocol_raw,
);
late final _sel_alloc = objc.registerName("alloc");
late final _sel_allocWithZone_ = objc.registerName("allocWithZone:");
late final _sel_conformsToProtocol_ = objc.registerName("conformsToProtocol:");
late final _sel_getValue = objc.registerName("getValue");
late final _sel_init = objc.registerName("init");
late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:");
late final _sel_new = objc.registerName("new");
late final _sel_setValueWithX_ = objc.registerName("setValueWithX:");
typedef instancetype = ffi.Pointer<objc.ObjCObjectImpl>;
typedef Dartinstancetype = objc.ObjCObject;