dart-lang / dart-lang/native

[vm/ffi] ObjC: Make it possible to subclass/implement ObjC classes/protocols

Open
#1,196 2 comments 3 reactions 0 assignees View on GitHub
lang-objective_c package:ffigen
Dominant language
Dart
Stars
275
Forks
144
Avg merge
2d 10h
Merged PRs (30d)
47

Description

There's use cases where it would be very convenient to make subclasses of ObjC classes (e.g. see [sub-classing NSOperationQueue](https://dart-review.googlesource.com/c/sdk/+/242062/1/runtime/lib/ffi_queue.mm)) and doing so in Dart.

Having this ability would avoid the need to write native code (and thereby not require changes to `dart:ffi` or adding flutter-specific plugins) - it could be done purely in Dart .

The most convenient way would be have Dart syntax for making subclasses of ObjC, possibly with some language restrictions and kernel lowering - similar to how the pure C-based FFI support is done.

Though a simpler way to get started would be providing utilities to procedurally lookup classes, create classes, add methods, ... (see [objc_allocateClassPair](https://developer.apple.com/documentation/objectivec/1418559-objc_allocateclasspair), [objc_addmethod](https://developer.apple.com/documentation/objectivec/1418901-class_addmethod))

/cc @brianquinlan @mraleph @dcharkes

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.