Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revised API and implementation #37

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

Conversation

hhas
Copy link

@hhas hhas commented Mar 10, 2022

  • significantly improves performance by caching parse method types and wrapper functions on first use
  • JS<->ObjC type bridging is fully integrated with ref-napi's JS<->C type descriptors and uses ObjC-style type encoding strings throughout
  • redesigned APIs for creating blocks, structs, subclasses, and inout arguments
  • ns, js functions support custom handling of unconverted values
  • updated example scripts and documentation

TO DO:

  • inout arguments in blocks and subclass methods
  • array, union, bitwise types
  • update test.js
  • optionally replace ffi-napi with C++ extension to improve performance
  • clean up code comments

… also now caches method wrappers (ObjC's method introspection APIs are heinously slow, so this caching provides ~1000× speedup on repeated method calls!); caution: this is all *very* Work In Progress (lots of stuff is incomplete/inconsistent/broken/mis-commented/to be redone; including JS↔︎NS type conversions, inout args, unit tests, docs, etc, etc)
…speed is much improved without breaking behavior)
… we finish codecs redesign)

* renamed `selectorForMethodName` to `Selector.fromjs` (this allows users to create Selector objects from both "foo:bar:" and "foo_bar_" strings)

* various rejigging of internal API designs
* added `Selector.tojs()`

* `callObjCMethod` now includes object and method name in error messages

* added extra debug logging/error handling to `introspectMethod`
* temporary fixes for `void*` inout arguments (pass a Buffer for now), argument encodings containing inout/out/etc modifiers
…sses a third argument to handler’s `get` which is the proxy object itself, so use that—*not* `this`, which is the handler object only—to call additional ObjC methods on the object)
….inspect(objc)` result

* sorting out (touch-wood) `util.inspect.custom` support
* revised `ns`, `js` functions take function/value as optional 2nd argument, allowing handling of unconverted values to be customized

* updated examples
…[util.inspect.custom]` and `Proxy` behave sensibly together
…ons, streamlining packing and unpacking of method arguments and results
… dog-slow overall; which might be ffi overhead)

* moved `swizzle` back to its own module, updating implementation (not yet tested)

* redesigned block API, dividing it into `BlockType` and `Block` (not yet tested, and `BlockType` is not yet fully ref-napi compatible)
…from `ref-struct-di`, with `objc.structs.define` function for defining new struct types, and already-created struct types being cached and exported as `objc.structs.NAME` (note: `ref*` types may eventually go away, or at least be relegated to 'slow fallback' as there is are severe performance bottlenecks in `ref-napi` and `ffi-napi`; thus users should use ObjC encoding strings rather than `objc.types...` when defining new struct types)
…se are currently publicly exported as `objc.blocks` and `objc.structs` but should eventually merge into top-level `objc` namespace)

* various renamings of public classes for consistency (TBD: should they all have `ObjC` prefix or not; on one hand it may make troubleshooting easier as their names are otherwise very generic; on the other, name prefixing is verbose and clumsy)

* reworked CommonJS `require` and `module.exports` usage to allow for circular dependencies (i.e. 1. attach to `module.exports` instead of replacing it; and 2. bind the whole module returned by `require`, not parts of it)
…ion, example script, and docs to use current APIs (its own API is still TBD)

* struct and block types should now be accessible via `objc`, although this is currently kludgy and doesn’t detect/prevent ObjC namespace collisions (which is a problem in current `objc.blocks` and `objc.structs` API design)
…`objc` object)

* simplified subclassing API (encodings object is now passed as argument before methods object)

* tidying code, comments, docs
…red parser object isn't thread safe)

* added `objc.auto()` convenience function, equivalent to `@autoreleasepool {...}`

* tidied comments
# Conflicts:
#	src/instance.js
#	src/objctypes.js
#	test/test-inout.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant