Comments (2)
@dimaqq FYI, that isn't Pythonista's "official" Objective-C interface. The built-in one is called objc_util
, it's included only with the app, so you probably can't find it online. The one you linked is my attempt at making an Objective-C interface based on CFFI.
The advantage of CFFI is that you can specify types and declare functions using normal C syntax and let CFFI do all the magic. However an issue with CFFI is that it doesn't support dynamic definition of types very well - the only way to define types is from C source with cdef
. Objective-C requires a lot of dynamic type creation, because the objc_msgSend
function and method IMP
s need to be cast to the correct signature, based on the method type encoding. This leads to some relatively lengthy code just to create a type, for example here for struct
s and union
s and here for function pointers. It's also quite slow, because of all the string building and parsing.
Another issue is that all type definitions land in a single namespace. My library automatically cdef
s any named structures and unions that it sees in type encodings, which can result in name conflicts. (I'm not sure, but CFFI might even complain if you define the same structure twice with exactly the same fields, which is even more problematic.) The obvious solution would be to use unnamed/anonymous structures and unions instead, but I think if you use an anonymous structure as a function parameter type, anything you try to pass as that parameter will be of the wrong type.
Long story short, I didn't really work on my CFFI-based version much anymore and decided to contribute to rubicon-objc instead.
from rubicon-objc.
Okay that explains it!
from rubicon-objc.
Related Issues (20)
- Enforce `restype` and `argtypes` for `send_super` HOT 2
- I am passing the correct number of arguments, however stilling hitting "takes 7 arguments, but got 5 arguments" HOT 5
- Improve repr() calls for NSPoint/NSRect types
- Calling performSelector for a @objc_method created by rubicon from Objective C crashes in Python 3.9 HOT 3
- Blocks not fully working on M1 hardware HOT 5
- "ObjC Class 'b'WrappedPyObject'' couldn't be found." when running on iOS device HOT 7
- iOS event loop blocks when thread waits on socket.
- x86_64 machine architecture not identified correctly on iOS simulator
- Attribute intermittently returns the wrong object HOT 5
- Segmentation fault when exiting multi-threaded program
- Race condition when instantiating ObjCInstance objects
- Race condition when populating the ObjCClass method/attribute cache
- Update CI configuration to test release artefacts
- Improve correspondence between ObjectiveC objects and Python wrappers HOT 17
- New caching logic may inadvertently release objects that are still needed HOT 5
- ctypes.ArgumentError message is split into individual characters
- Warning about deprecated `pkg_resources` API
- Incompatibility with `from __future__ import annotations` HOT 1
- Incompatibility with Python 3.12.0b1 HOT 4
- Scroll blocks eventloop for ios HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rubicon-objc.