Package pycocoa :: Module octypes
[frames] | no frames]

Module octypes

ObjC ..._t type definitions and some additional ctypes.

Names starting with c_ are ctypes, names ending with _t are ObjC types defined in terms of a ctypes c_ type.


Version: 25.04.07

Classes
  c_ptrdiff_t
  unichar_t
Unicode wchar ctype.
  UniChar_t
Unicode unsigned short ctype.
  c_struct_t
Base type to pretty-print ctypes Structures.
  ObjC_t
Base type to pretty-print ctypes c_void_p.
  TypeCodeError
Error in ObjC type encoding.
  CGFloat_t
ObjC CGFloat ctype.
  NSInteger_t
ObjC NSInteger ctype.
  NSUInteger_t
ObjC NSUInteger ctype.
  CFIndex_t
ObjC CFIndex ctype.
  Allocator_t
ObjC CFAllocatorRef type.
  Array_t
ObjC NSArray ctype.
  Block_t
ObjC block type.
  BOOL_t
ObjC boolean type.
  Data_t
ObjC CFDataRef ctype.
  Dictionary_t
ObjC NSDictionary ctype.
  Id_t
ObjC Id/self type, encoding b'@'.
  Class_t
ObjC Class type, encoding b'#'.
  IMP_t
ObjC IMPlementation type.
  Ivar_t
ObjC instance variable type.
  Method_t
ObjC method type.
  Number_t
ObjC NSNumber ctype.
  NumberType_t
ObjC NSNumberType ctype.
  OptionFlags_t
ObjC CFOptionFlags ctype.
  Protocol_t
ObjC protocol type.
  RunLoop_t
ObjC CFRunLoopRef type.
  SEL_t
ObjC SELector/cmd type, encoding b':'.
  Set_t
ObjC NSSet ctype.
  String_t
ObjC CFStringRef ctype.
  Struct_t
ObjC struct type.
  TimeInterval_t
ObjC CFTimeInterval ctype.
  TypeID_t
ObjC CFTypeID ctype.
  TypeRef_t
ObjC opaque type.
  Union_t
ObjC union type.
  Unknown_t
Unknown type.
  UnknownPtr_t
Unknown pointer.
  URL_t
ObjC URL type.
  VoidPtr_t
Same as c_void_p, but distinguishable from c_void_p.
  objc_method_description_t
ObjC struct with fields name and types (SEL_t, c_char_p).
  objc_property_t
ObjC property Class.
  objc_property_attribute_t
ObjC struct with fields name and value (both c_char_p).
  objc_super_t
ObjC struct with fields receiver and class (Id_t, Class_t).
  NSDouble_t
  NSFloat_t
ObjC NSFloat ctype.
  NSRange_t
ObjC struct with fields loc[ation] and len[gth] (both NSUInteger_t).
  CFRange_t
ObjC struct with fields loc[ation] and len[gth] (both CFIndex_t).
  NSPoint_t
ObjC struct with fields x and y (both CGFloat_t).
  NSSize_t
ObjC struct with fields width and height (both CGFloat_t).
  NSRect_t
ObjC struct with fields origin and size (NSPoint_t, NSSize_t).
  NSRect4_t
ObjC struct, like NSRect_t with different signature and properties.
  CGBitmapInfo_t
ObjC CGBitmapInfo ctype.
  CGDirectDisplayID_t
ObjC CGDirectDisplayID ctype.
  CGError_t
ObjC CGError ctype.
  CGGlyph_t
ObjC CGGlyph ctype.
  CGPoint_t
ObjC struct with fields x and y (both CGFloat_t).
  CGRect_t
ObjC struct with fields origin and size (NSPoint_t, NSSize_t).
  CGSize_t
ObjC struct with fields width and height (both CGFloat_t).
  CTFontOrientation_t
Objc CTFontOrientation ctype.
  CTFontSymbolicTraits_t
Objc CTFontSymbolicTraits ctype.
  NSMakePoint
ObjC struct with fields x and y (both CGFloat_t).
  NSMakeRange
ObjC struct with fields loc[ation] and len[gth] (both NSUInteger_t).
  NSMakeRect
ObjC struct, like NSRect_t with different signature and properties.
  NSMakeSize
ObjC struct with fields width and height (both CGFloat_t).
  NSTimeInterval_t
ObjC NSTimeInterval ctype.
Functions
 
split_emcoding2(encoding, start=0)
Split the type encoding of a method signature into separate, single encodings and the combined encoding.
 
split_encoding(encoding)
Split a type encoding into separate type encodings.
Variables
  c_void = None
hash(x)
  __all__ = _ALL_LAZY.octypes
  NSIntegerMax = 9223372036854775807
  NSPointEncoding = '{CGPoint=dd}'
  NSRangeEncoding = '{_NSRange=QQ}'
  NSRectEncoding = '{CGRect={CGPoint=dd}{CGSize=dd}}'
  NSSizeEncoding = '{CGSize=dd}'
  CGPointEncoding = '{CGPoint=dd}'
  CGRectEncoding = '{CGRect={CGPoint=dd}{CGSize=dd}}'
  CGSizeEncoding = '{CGSize=dd}'
  CGImageEncoding = '{CGImage=}'
  NSZoneEncoding = '{_NSZone=}'
  PyObjectEncoding = '{PyObject=@}'
  NSNotFound = 9223372036854775807
  NSPointZero = NSPoint_t(0, 0)
  NSFloatEncoding = 'f'
  NSIntegerEncoding = 'l'
  NSUIntegerEncoding = 'L'
  e = _encoding2ctype.copy()
  i = 0
  CFStringEncoding_t
ObjC CFStringEncoding ctype.
  NSDoubl_t
ObjC CFDataRef ctype.
Function Details

split_emcoding2(encoding, start=0)

 

Split the type encoding of a method signature into separate, single encodings and the combined encoding.

If necessary, the encoding is extended with the type encoding for the hidden method arguments Id/self and SEL/cmd.

Returns:
2-Tuple (codes, encoding), where codes is the list of individual type encodings from item start=0 and encoding is the combined type encoding in bytes, both extended with Id/self and SEL/cmd iff needed.
Raises:

Note: Does not handle bitfields, arrays, structs, unions, etc. and strips any offset, size or width specifiers from the encoding.

Example:

>>> split_emcoding2('v*')
>>> (['v', '@', ':', '*'], 'v@:*')

split_encoding(encoding)

 

Split a type encoding into separate type encodings.

Does not handle bitfields, arrays, structs, unions, etc. and strips any offset, size or width specifiers from the encoding.

Returns:
The individual type encodings (list).
Raises:

Example:

>>> split_encoding('^v16@0:8')
>>> ['^v', '@', ':']
>>> split_encoding('{CGSize=dd}40@0:8{PyObject=@}Q32')
>>> ['{CGSize=dd}', '@', ':', '{PyObject=@}', 'Q']

Supported Type Encodings:

  • B = bool (C++ bool, C99 _Bool)
  • c, C = char, unsigned char
  • f, d = float, double
  • i, I = int, unsigned int
  • l, L = long, unsigned long (32-bit in 64-bit Apps)
  • q, Q = long long, unsigned long long
  • s, S = short, unsigned short
  • t, T = 128-bit int, unsigned int
  • v = void
  • * = string (char *)
  • : = method selector SEL/cmd
  • # = class
  • #"name" = class "name"
  • @ = object instance Id/self or statically typed
  • @"name" = instance Id/self of class "name"
  • ^type = pointer to type
  • ? = unknown type (among other things, used for function pointers)

PyCocoa specific:

  • P = Python object, shorthand for PyObjectEncoding

Unsupported Type Encodings:

  • bW = bitfield of width W
  • [Ltype] = array of L items of type
  • {name=type...} = structure
  • (name=type...) = union
  • <...> = block
  • ?<...> = block with signature

Unknown or for ObjC internal use:

  • A = ?
  • j = ?
  • n, N = in, inout
  • o, O = out, bycopy
  • r, R = const, byref
  • V = oneway

Note: Type encodings may be preceeded by "name", for example a bitfield "name"b1, struct items {CGsize="width"d"heigth"d}, union items, etc. and all such "name" prefixes are ignored.

See Also: Type Encodings, NSHipster Type Encodings and Digits in type encoding.