Giter Club home page Giter Club logo

Comments (2)

dgelessus avatar dgelessus commented on June 11, 2024

@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 IMPs 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 structs and unions 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 cdefs 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.

dimaqq avatar dimaqq commented on June 11, 2024

Okay that explains it!

from rubicon-objc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.