utils

class utils.c_type(decl)[source]

The c_type object parses a C type string and decomposes it into several parts.

The parser is implemented with below ‘nested_c’ pyparsing object. It captures nested parenthesis expressions that allows to define complex C types that represent pointer-to array-of … function prototypes returning a C type.

lbase

base typename

Type:

str

lbfw

type has a bitfield length (0 means type is not a bitfield)

Type:

int

lconst

type has a ‘const’ keyword

Type:

bool

unsigned

type has an ‘unsigned’ keyword

Type:

bool

volatile

type has a ‘volatile’ keyword

Type:

bool

pstack

list of “pointers stack” (see pstack function)

Type:

list

is_ptr

True if the pstack contains a ptr object.

Type:

bool

dim

dimension if the type is an array (or 0.)

Type:

int

show_base(kw=False, ns=False)[source]

returns the string that represents the base type with possibly additional ‘const’ and ‘unsigned’ keywords (if kw is True) and namespace(s) indicators (if ns is True).

show_ptr(name)[source]

returns the string that represents the pointers stack, with optional name parameter used as the name of the function (in case of a prototype).

show(name='')[source]

returns the string that represents full type with optional name parameter for a function’s prototype.

class utils.cxx_type(decl)[source]

cxx_type extends c_type with extracting the namespace parts of the fully qualified name of the C++ type.

show_base(kw=False, ns=False)[source]

returns the string that represents the base type with possibly additional ‘const’ and ‘unsigned’ keywords (if kw is True) and namespace(s) indicators (if ns is True).

show_ptr(name)[source]

returns the string that represents the pointers stack, with optional name parameter used as the name of the function (in case of a prototype).

show(name='', kw=True, ns=True)[source]

returns the string that represents full type with optional name parameter for a function’s prototype.

class utils.ptr(p, c)[source]

Object that represents a series of pointer (aka stars) possibly with additional ‘const’ keyword.

p

list of ‘*’ chars that represent the C pointers

Type:

str

const

‘const’ keyword or None.

Type:

str

class utils.arr(a)[source]

Object that represents an array indicator.

a

dimension of the array

Type:

int

class utils.fargs(f)[source]

Object that represents the arguments list of a function prototype.

f

the arguments part of a function prototype

Type:

str

args

the list of arguments

Type:

list

utils.pstack(plist, cls=<class 'utils.c_type'>)[source]

returns the ‘stack’ of pointers-to array-N-of pointer-to function() returning pointer to function() returning …