PyObjC Architecture

Author: Ronald Oussoren

Introduction

XXX: This documented is outdated and incomplete.

This document gives a (brief) description of how the PyObjc package is structured.

Objective-C classes and objects

Objective-C classes are represented directly as python classes. This allows us to implement subclassing of Objective-C classes with the full power that new-style classes provide.

There is one problem with this though, PyTypeObject does not have space to store additional information, and is a variable-sized object. This means that subclasses of PyType_Type cannot add instance variables. We solve this by storing the additional information in a dictionary indexed by the PyTypeObjects that represent Objective-C classes.

Objective-C objects are represented by proxy objects that are instances of the classes descriped above.

TODO: work out how we'll implement subclasses objects and describe here.

Methods and instance variables

Methods and instance variables are represented as 'descriptor' objects that are attributes of the PyTypeObject describing a class. This way it is possible to use the normal python introspection mechanisms to explore an objective-C object/class.

There is also a mechanism to call methods that are not part of the advertised interface of a class. This is needed to support classes like NSProxy that forward method invocations to other objects.