Generated types for C types¶
Structure types¶
Structure are generated by objc.createStructType()
and represent
a C structure, such as NSPoint or CGRect.
Structure types are all separate types, directly inheriting from object
,
and behave like a mutable variant of collections.namedtuple()
.
The rest of this section describes StructureType
, which defines the
API of the structure types but does not exist as a real type.
- class objc.StructureType(\**kwds)¶
A structure type.
- _fields¶
- A tuple with the field names for this structure. Every name
- in *_fields* is present as an attribute of instances of the type.
- __typestr__¶
- The type encoding for this structure type
- __getitem__(idx)¶
- Return the *idx*-th element of the object. This also supports
- slices.
- __setitem__(idx, value)¶
- Set the *idx*-th element of the object. This also supports
- slice, but the assignment is not allowed to change the number
- of elements.
- copy()¶
- Returns a deep copy of the structure, that is all field values
- that are instances of a structure types are copied as well.
- __pyobjc_copy__()¶
- An alias for :meth:`copy`, for use by PyObjC.
- _replace(\**kwds)¶
- First create a copy of the object, then use the keyword arguments
- to replace the values of some attributes.
- _asdict()¶
- Returns a dictionary where the keys are the values in :data:`_fields`
- and the values are the corresponding attribute values.
Opaque pointer types¶
Opaque pointer are created by objc.createOpaquePointerType()
and represent
opaque pointers or handles, such as values of type ‘NSZone*’. Opaque pointers do
not have further structure or behavior, they just exist as blobs of data that are
returned from and passed to Objective-C functions or methods.
The rest of this section describes OpaquePointerType
, which defines the
API of the opaque pointer types but does not exist as a real type.
- class objc.OpaquePointerType(cobject=None, c_void_p=None)¶
An opaque pointer type. Values are usually created by the PyObjC bridge, but can be created manually using one of the keyword arguments:
cobject: A PyCapsule object with name “objc.__opaque__” that represents an opaque pointer value.
c_void_p: An instance of
ctypes.c_void_p
orint
that represents an opaque pointer value.
- __typestr__¶
- The type encoding for the opaque pointer type
- __pointer__¶
- An integer with the raw pointer value
- __c_void_p__()¶
- Returns a :class:`ctypes.c_void_p` instance with the raw pointer value
- __cobject__()¶
- Returns a PyCapsule object with name "objc.__opaque__" representing
- the raw pointer value.