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

Module octypes


Version: 17.11.19

Classes
  unichar
  UniChar
  c_ptrdiff_t
  NSInteger
  NSUInteger
  CGFloat
  CFArray
  CFIndex
  CGGlyph
  CFNumberType
  CFTypeID
  NSPoint
ObjC struct with x and y.
  NSSize
ObjC struct with width and height.
  NSRect
ObjC struc with origin and size.
  CFRange
ObjC struct with location and length (CFIndex-s).
  NSRange
ObjC struct with location and length (NSInteger-s).
  CGPoint
ObjC struct with x and y.
  CGRect
ObjC struc with origin and size.
  CGSize
ObjC struct with width and height.
  NSTimeInterval
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
  NSPointEncoding = '{CGPoint=dd}'
  NSRangeEncoding = '{_NSRange=QQ}'
  NSRectEncoding = '{CGRect={CGPoint=dd}{CGSize=dd}}'
  NSSizeEncoding = '{CGSize=dd}'
  CGImageEncoding = '{CGImage=}'
  NSZoneEncoding = '{_NSZone=}'
  PyObjectEncoding = '{PyObject=@}'
  CGFloatEncoding = 'd'
  NSIntegerEncoding = 'q'
  NSUIntegerEncoding = 'Q'
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.

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

In the returned 2-tuple (codes, encoding), codes is the list of individual type encodings from item start=0 and encoding the combined type encoding in bytes and both extended if needed.

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.

Examples:

>>> 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)
  • 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, statically typed, typed id, etc.)
  • @"name" = instance of class "name"
  • ^type = pointer to type
  • ? = unknown type (among other things, used for function pointers)

Unsupported Type Encodings:

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

For Objective-C internal use only:

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

Type encodings may be preceeded by a "name", for example a bit field "name"b1, structure fields {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.