smallworld.extern.ctypes

class smallworld.extern.ctypes.TypedPointer(*args, **kwargs)

Typed pointer class

This class fills a gap in ctypes ability to represent data.

The existing typed pointer classes are designed as direct references to Python objects; it’s not possible to set a specific address.

c_void_p represents the correct kind of value, but has no associated data type.

Warning

Do not instantiate this class directly! The referenced type needs to be bound to a class, since ctypes uses instances to represent specific variables or fields. Use create_typed_pointer() to create a subclass for your type.

property type

The type referenced by this pointer.

classmethod from_param()

Convert a Python object into a function call parameter.

value

current value

smallworld.extern.ctypes.create_typed_pointer(reference)

Create a typed pointer class.

The referenced type should be any ctypes type definition, or None to represent ‘void’.

Referenced types that already have a ctypes pointer value type will return that type, not a TypedPointer:

create_typed_pointer(c_char)  # returns c_char_p
create_typed_pointer(c_wchar)  # returns c_wchar_p
create_typed_pointer(None)  # returns c_void_p
Parameters:

reference – The ctypes object defining the referenced type.

Returns:

A subclass of TypedPointer representing your referenced type.