core

class core.ccore[source]

Generic class dedicated to a collected object, used as parent class for all C/C++ items collected by ccrawl:

  • typedef

  • struct

  • union

  • enum

  • macro

  • func

  • class

  • template

  • namespace

formatter

a function used to print the object in various formats.

Type:

function

_cache_

a global (parent class level) dict of all types that have been fetched from the database so far.

Type:

dict

show(db=None, r=None, form=None)[source]

Generic method that possibly defines and ultimately calls the internal formatter function.

db[opt]

database used in recursive mode

Type:

Proxy

unfold(db, limit=None)[source]

Generic method that fetches recursively from the given database all other types on which this type depends. The method is recursive in the sense that all subtypes are unfolded as well until they only depend on primitive types (int, short, float, etc.)

build(db)[source]

Generic method for building a ctypes instance for this type. Basically just a wrapper for the ctypes_.build function.

Parameters:

db (Proxy) – database used to get any other type on which this type depends.

add_subtype(db, elt, limit=None)[source]

Generic method that fetches item ‘elt’ from the database and adds it to the subtypes of this type before unfolding it.

graph(db, V=None, g=None)[source]

Generic method that returns the types-dependency graph associated with this type. Basically just a wrapper for the graphs.build function.

Parameters:

db (Proxy) – database used to get any other type on which this type depends.

classmethod set_formatter(form)[source]

Selects the formatter to be used for the entire class from the available formatters.

Parameters:

form (str) – name of a module in the formatters sub-package. If the module is not found, ‘raw’ is used.

to_db(identifier, tag, src)[source]

Generic method that returns a list of database-insertable “documents” for the current item.

static from_db(data)[source]

Generic method that returns a specialized ccore instance from a given document data usually obtained from the database.

Parameters:

data (dict) – must have “id”, “cls” and “val” keys where cls is one of the below ccore specialized class name.

class core.cTypedef[source]

Specialized ccore class that is also a ‘str’ representing a C/C++ typedef.

identifier

the new typename associated to this typedef.

unfold(db, limit=None, ctx=None)[source]

Unfolding a typedef simply adds its underlying type definition to subtypes.

class core.cStruct(iterable=(), /)[source]

Specialized ccore class that is also a ‘list’ representing a C struct.

identifier

the typename associated to this C struct.

Items of the list represent fields of the structure and are formatted as triplet of the form (t,n,c) where

  • t is a string that represents the type the field

  • n is a string that represents the name of the field

  • c is a string that represents a comment for the field

unfold(db, limit=None)[source]

Unfolding a struct adds all its fields’ types to subtypes.

class core.cClass(iterable=(), /)[source]

Specialized ccore class that is also a ‘list’ representing a C++ class.

identifier

the name associated to this C++ class.

Items of the list represent attributes of the class and are formatted as triplet of the form (x,y,z) where

  • x is a tuple (q,t) where q is a “parent”, “using” or “virtual” keyword and t is “virtual” or a type name,

  • y is a tuple (mn,n) where mn is the mangled name and n is the full name of the class attribute,

  • z is a tuple (p,c) where p is a “public”/”protected”/”private”/”friend” indicator and c is a string that represents a comment.

unfold(db, limit=None)[source]

Generic method that fetches recursively from the given database all other types on which this type depends. The method is recursive in the sense that all subtypes are unfolded as well until they only depend on primitive types (int, short, float, etc.)

build(db)[source]

Generic method for building a ctypes instance for this type. Basically just a wrapper for the ctypes_.build function.

Parameters:

db (Proxy) – database used to get any other type on which this type depends.

cStruct_build_info(db)[source]

Defines the structure layout for this class, according to the gcc cxx ABI for virtual classes.

The returned value is a triplet, (vptr, M, V) where

  • vptr is a virtual indicator,

  • M is the list of non-virtual fields,

  • V is the ordered dict of virtual fields.

This triplet is used to create a cStruct instance that correspond to an instance of this C++ class in memory.

as_cStruct(db)[source]

Creates a cStruct instance that correspond to this C++ class, according the gcc cxx ABI for virtual classes.

has_virtual_members()[source]

Returns True if the C++ class has virtual members.

base_specifier_list()[source]

Returns the list of C++ parent (possibly virtual) classes.

class core.cUnion(iterable=(), /)[source]

Specialized ccore class that is also a ‘list’ representing a C union.

unfold(db, limit=None)[source]

Generic method that fetches recursively from the given database all other types on which this type depends. The method is recursive in the sense that all subtypes are unfolded as well until they only depend on primitive types (int, short, float, etc.)

class core.cEnum[source]

Specialized ccore class that is also a ‘dict’ representing a C enum.

class core.cMacro[source]

Specialized ccore class that is also a ‘str’ representing a C macro.

class core.cFunc[source]

Specialized ccore class that is also a ‘dict’ representing a C/C++ function.

unfold(db, limit=None)[source]

Generic method that fetches recursively from the given database all other types on which this type depends. The method is recursive in the sense that all subtypes are unfolded as well until they only depend on primitive types (int, short, float, etc.)

class core.cTemplate[source]

Specialized ccore class that is also a ‘dict’ representing a C++ template.

class core.cNamespace(iterable=(), /)[source]

Specialized ccore class that is also a ‘list’ representing a C++ namespace.

unfold(db, limit=None)[source]

Generic method that fetches recursively from the given database all other types on which this type depends. The method is recursive in the sense that all subtypes are unfolded as well until they only depend on primitive types (int, short, float, etc.)