Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 12 additions & 176 deletions pkgs/ffigen/example/objective_c/avf_audio_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ import 'dart:ffi' as ffi;
import 'package:objective_c/objective_c.dart' as objc;
import 'package:ffi/ffi.dart' as pkg_ffi;

@ffi.Native<
ffi.Pointer<objc.ObjCObject> Function(
ffi.Pointer<objc.ObjCObject>,
ffi.Pointer<ffi.Void>,
)
>()
external ffi.Pointer<objc.ObjCObject> _AVFAudio_protocolTrampoline_1mbt9g9(
ffi.Pointer<objc.ObjCObject> target,
ffi.Pointer<ffi.Void> arg0,
);

final class AudioStreamBasicDescription extends ffi.Struct {
@ffi.Double()
external double mSampleRate;
Expand Down Expand Up @@ -641,141 +630,6 @@ final _objc_msgSend_1cwp428 = objc.msgSendPointer
)
>();
late final _sel_alloc = objc.registerName("alloc");
late final _sel_self = objc.registerName("self");

/// Construction methods for `objc.ObjCBlock<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void>)>`.
abstract final class ObjCBlock_objcObjCObject_ffiVoid {
/// Returns a block that wraps the given raw block pointer.
static objc.ObjCBlock<
ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void>)
>
castFromPointer(
ffi.Pointer<objc.ObjCBlockImpl> pointer, {
bool retain = false,
bool release = false,
}) =>
objc.ObjCBlock<
ffi.Pointer<objc.ObjCObject> 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.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void>)
>
fromFunctionPointer(
ffi.Pointer<
ffi.NativeFunction<
ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void> arg0)
>
>
ptr,
) =>
objc.ObjCBlock<
ffi.Pointer<objc.ObjCObject> 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.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void>)
>
fromFunction(
objc.ObjCObjectBase Function(ffi.Pointer<ffi.Void>) fn, {
bool keepIsolateAlive = true,
}) =>
objc.ObjCBlock<
ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void>)
>(
objc.newClosureBlock(
_closureCallable,
(ffi.Pointer<ffi.Void> arg0) => fn(arg0).ref.retainAndAutorelease(),
keepIsolateAlive,
),
retain: false,
release: true,
);

static ffi.Pointer<objc.ObjCObject> _fnPtrTrampoline(
ffi.Pointer<objc.ObjCBlockImpl> block,
ffi.Pointer<ffi.Void> arg0,
) => block.ref.target
.cast<
ffi.NativeFunction<
ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void> arg0)
>
>()
.asFunction<
ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void>)
>()(arg0);
static ffi.Pointer<ffi.Void> _fnPtrCallable =
ffi.Pointer.fromFunction<
ffi.Pointer<objc.ObjCObject> Function(
ffi.Pointer<objc.ObjCBlockImpl>,
ffi.Pointer<ffi.Void>,
)
>(_fnPtrTrampoline)
.cast();
static ffi.Pointer<objc.ObjCObject> _closureTrampoline(
ffi.Pointer<objc.ObjCBlockImpl> block,
ffi.Pointer<ffi.Void> arg0,
) =>
(objc.getBlockClosure(block)
as ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void>))(
arg0,
);
static ffi.Pointer<ffi.Void> _closureCallable =
ffi.Pointer.fromFunction<
ffi.Pointer<objc.ObjCObject> Function(
ffi.Pointer<objc.ObjCBlockImpl>,
ffi.Pointer<ffi.Void>,
)
>(_closureTrampoline)
.cast();
}

/// Call operator for `objc.ObjCBlock<ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void>)>`.
extension ObjCBlock_objcObjCObject_ffiVoid$CallExtension
on
objc.ObjCBlock<
ffi.Pointer<objc.ObjCObject> Function(ffi.Pointer<ffi.Void>)
> {
objc.ObjCObjectBase call(ffi.Pointer<ffi.Void> arg0) => objc.ObjCObjectBase(
ref.pointer.ref.invoke
.cast<
ffi.NativeFunction<
ffi.Pointer<objc.ObjCObject> Function(
ffi.Pointer<objc.ObjCBlockImpl> block,
ffi.Pointer<ffi.Void> arg0,
)
>
>()
.asFunction<
ffi.Pointer<objc.ObjCObject> Function(
ffi.Pointer<objc.ObjCBlockImpl>,
ffi.Pointer<ffi.Void>,
)
>()(ref.pointer, arg0),
retain: true,
release: true,
);
}

late final _sel_retain = objc.registerName("retain");
late final _sel_autorelease = objc.registerName("autorelease");

/// AVAudioPlayer
class AVAudioPlayer extends objc.NSObject {
Expand Down Expand Up @@ -818,11 +672,11 @@ class AVAudioPlayer extends objc.NSObject {
}

/// allocWithZone:
static AVAudioPlayer allocWithZone(ffi.Pointer<objc.NSZone> zone) {
static AVAudioPlayer allocWithZone(ffi.Pointer<objc.NSZone> zone$1) {
final $ret = _objc_msgSend_1cwp428(
_class_AVAudioPlayer,
_sel_allocWithZone_,
zone,
zone$1,
);
return AVAudioPlayer.castFromPointer($ret, retain: false, release: true);
}
Expand All @@ -838,12 +692,6 @@ class AVAudioPlayer extends objc.NSObject {
}

extension AVAudioPlayer$Methods on AVAudioPlayer {
/// autorelease
AVAudioPlayer autorelease() {
final $ret = _objc_msgSend_151sglz(this.ref.pointer, _sel_autorelease);
return AVAudioPlayer.castFromPointer($ret, retain: true, release: true);
}

/// averagePowerForChannel:
double averagePowerForChannel(int channelNumber) {
objc.checkOsVersionInternal(
Expand Down Expand Up @@ -996,7 +844,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {

/// initWithContentsOfURL:error:
AVAudioPlayer? initWithContentsOfURL(
objc.NSURL url, {
objc.NSURL url$1, {
required ffi.Pointer<ffi.Pointer<objc.ObjCObject>> error,
}) {
objc.checkOsVersionInternal(
Expand All @@ -1007,7 +855,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {
final $ret = _objc_msgSend_1lhpu4m(
this.ref.retainAndReturnPointer(),
_sel_initWithContentsOfURL_error_,
url.ref.pointer,
url$1.ref.pointer,
error,
);
return $ret.address == 0
Expand All @@ -1017,7 +865,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {

/// initWithContentsOfURL:fileTypeHint:error:
AVAudioPlayer? initWithContentsOfURL$1(
objc.NSURL url, {
objc.NSURL url$1, {
objc.NSString? fileTypeHint,
required ffi.Pointer<ffi.Pointer<objc.ObjCObject>> error,
}) {
Expand All @@ -1029,7 +877,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {
final $ret = _objc_msgSend_1pnyuds(
this.ref.retainAndReturnPointer(),
_sel_initWithContentsOfURL_fileTypeHint_error_,
url.ref.pointer,
url$1.ref.pointer,
fileTypeHint?.ref.pointer ?? ffi.nullptr,
error,
);
Expand All @@ -1040,7 +888,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {

/// initWithData:error:
AVAudioPlayer? initWithData(
objc.NSData data, {
objc.NSData data$1, {
required ffi.Pointer<ffi.Pointer<objc.ObjCObject>> error,
}) {
objc.checkOsVersionInternal(
Expand All @@ -1051,7 +899,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {
final $ret = _objc_msgSend_1lhpu4m(
this.ref.retainAndReturnPointer(),
_sel_initWithData_error_,
data.ref.pointer,
data$1.ref.pointer,
error,
);
return $ret.address == 0
Expand All @@ -1061,7 +909,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {

/// initWithData:fileTypeHint:error:
AVAudioPlayer? initWithData$1(
objc.NSData data, {
objc.NSData data$1, {
objc.NSString? fileTypeHint,
required ffi.Pointer<ffi.Pointer<objc.ObjCObject>> error,
}) {
Expand All @@ -1073,7 +921,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {
final $ret = _objc_msgSend_1pnyuds(
this.ref.retainAndReturnPointer(),
_sel_initWithData_fileTypeHint_error_,
data.ref.pointer,
data$1.ref.pointer,
fileTypeHint?.ref.pointer ?? ffi.nullptr,
error,
);
Expand Down Expand Up @@ -1224,18 +1072,6 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {
: _objc_msgSend_2cgrxl(this.ref.pointer, _sel_rate);
}

/// retain
AVAudioPlayer retain() {
final $ret = _objc_msgSend_151sglz(this.ref.pointer, _sel_retain);
return AVAudioPlayer.castFromPointer($ret, retain: true, release: true);
}

/// self
AVAudioPlayer self() {
final $ret = _objc_msgSend_151sglz(this.ref.pointer, _sel_self);
return AVAudioPlayer.castFromPointer($ret, retain: true, release: true);
}

/// setChannelAssignments:
set channelAssignments(objc.NSArray? value) {
objc.checkOsVersionInternal(
Expand Down Expand Up @@ -1363,7 +1199,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {
}

/// setVolume:fadeDuration:
void setVolume(double volume, {required double fadeDuration}) {
void setVolume(double volume$1, {required double fadeDuration}) {
objc.checkOsVersionInternal(
'AVAudioPlayer.setVolume:fadeDuration:',
iOS: (false, (10, 0, 0)),
Expand All @@ -1372,7 +1208,7 @@ extension AVAudioPlayer$Methods on AVAudioPlayer {
_objc_msgSend_1p4uk9e(
this.ref.pointer,
_sel_setVolume_fadeDuration_,
volume,
volume$1,
fadeDuration,
);
}
Expand Down
6 changes: 0 additions & 6 deletions pkgs/ffigen/example/objective_c/avf_audio_bindings.dart.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@


Protocol* _AVFAudio_AVAudioPlayerDelegate(void) { return @protocol(AVAudioPlayerDelegate); }

typedef id (^_ProtocolTrampoline)(void * sel);
__attribute__((visibility("default"))) __attribute__((used))
id _AVFAudio_protocolTrampoline_1mbt9g9(id target, void * sel) {
return ((_ProtocolTrampoline)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel);
}
#undef BLOCKING_BLOCK_IMPL

#pragma clang diagnostic pop
Loading
Loading