CYCLUS
Loading...
Searching...
No Matches
hdf5_back_gen Namespace Reference

Classes

class  Assign
 
class  BinOp
 
class  Block
 
class  Case
 
class  CppGen
 
class  Decl
 
class  DeclAssign
 
class  Expr
 
class  ExprStmt
 
class  For
 
class  FuncCall
 
class  FuncDef
 
class  If
 
class  LeftUnaryOp
 
class  Line
 
class  Node
 
class  Nothing
 
class  PrettyFormatter
 
class  Raw
 
class  RightUnaryOp
 
class  Type
 
class  Var
 
class  Visitor
 

Functions

 a_cast (t, depth=0, prefix="")
 
 camel_case (db)
 
 case_template (t, read_x)
 
 convert_canonical (raw_list)
 
 flatten (canon)
 
 get_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 get_decl (t, depth=0, prefix="")
 
 get_dim_shape (canon, start=0, depth=0)
 
 get_item_size (t, shape_array=None, vl_flag=False, depth=0)
 
 get_item_type (t, shape_array=None, vl_flag=False, prefix="", depth=0)
 
 get_prefix (base_prefix, parent_type, child_index)
 
 get_setup (t, depth=0, prefix="", HDF5_type="tb_type", child_index='j')
 
 get_teardown (t)
 
 get_variable (name, depth=0, prefix="")
 
 get_variation_body (t)
 
 get_variation_cond (t)
 
 get_write_body (t, shape_array, depth=0, prefix="", variable="a", offset="buf", pointer=False)
 
 get_write_setup (t, shape_array, depth=0, prefix="")
 
 hdf5_array_create (item_variable, rank=1, dims="&shape0")
 
 hdf5_create_compound (sizes)
 
 hdf5_insert (container_type, compound_var, types_sizes_dict)
 
 indent (text, prefix, predicate=None)
 
 is_all_vl (t)
 
 list_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 list_dependencies (canon)
 
 list_primitive_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 main ()
 
 main_buf_to_val ()
 
 main_create ()
 
 main_fill_buf ()
 
 main_query ()
 
 main_val_to_buf ()
 
 main_val_to_buf_h ()
 
 main_vl_dataset ()
 
 main_write ()
 
 map_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 memcpy (dest, src, size)
 
 memset (dest, src, size)
 
 no_vl (t)
 
 normal_close (t)
 
 pad_children (t, variable, fixed_var=None, depth=0, prefix="", called_depth=0)
 
 pair_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 primitive_setup (t, depth=0, prefix="")
 
 print_statement (t, identifier)
 
 reinterpret_cast (t, offset, deref=False)
 
 reinterpret_cast_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 resolve_unicode (item)
 
 set_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 set_primitive_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 set_string_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 setup ()
 
 string (s)
 
 string_body (t, depth=0, prefix="", base_offset="buf+offset", variable=None)
 
 string_setup (depth=0, prefix="")
 
 to_buf_body (t, vl_list, depth=0, prefix="", variable=None, offset="reinterpret_cast<char*>(buf.p)")
 
 to_from_buf_setup (t, depth=0, prefix="", spec=None)
 
 to_val_body (t, vl_list, depth=0, prefix='', variable='x0', offset=None)
 
 typeid (t)
 
 uuid_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 vec_string_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 vector_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 vector_primitive_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 VL_ADD_BLOCK (t, item_var)
 
 vl_body (t, depth=0, prefix="", base_offset="buf+offset")
 
 vl_read (t, offset)
 
 vl_string_body (t, depth=0, prefix="", base_offset="buf+offset", variable=None)
 
 vl_string_setup (depth=0, prefix="")
 
 vl_write (t, variable, depth=0, prefix="", pointer=False)
 
 write_body_primitive (t, depth=0, prefix="", variable=None, offset="buf", pointer=False)
 
 write_body_string (t, depth=0, prefix="", variable=None, offset="buf", pointer=False)
 
 write_body_uuid (t, depth=0, prefix="", variable=None, offset="buf", pointer=False)
 

Variables

cls _lowername = lambda cls.__name__.lower()
 
dict BODIES
 
dict CANON_TO_DB = {}
 
dict CANON_TO_NODE = {}
 
list CANON_TYPES = []
 
dict CONTAINER_INSERT_STRINGS
 
dict DB_TO_CPP = {}
 
dict DB_TO_VL = {}
 
list DEBUG_TYPES = ["VECTOR_STRING"]
 
dict HDF5_PRIMITIVES
 
str INDENT = ' '
 
 io_error
 
isinstance is_primitive = lambda t(t.canon, str)
 
dict MAIN_DISPATCH = {}
 
list NOT_VL = []
 
 ORIGIN_DICT = OrderedDict()
 
dict ORIGIN_TO_VL = {}
 
dict PRIMITIVE_SIZES
 
 raw_blob
 
 raw_string
 
dict RAW_TYPES
 
list TEARDOWN_STACK = []
 
dict template_args
 
list variable_length_types = ["MAP", "LIST", "SET", "VECTOR"]
 
 VARIATION_DICT = OrderedDict()
 
list VARS = []
 
dict VL_SPECIAL_TYPES
 
dict VL_TO_FL_CONTAINERS
 
str vl_write_blob
 
str vl_write_vl_string
 
dict WRITE_BODY_PRIMITIVES
 

Detailed Description

This module generates HDF5 backend code found in src/hdf5_back.cc

There are 8 distinct code generation options, one of which must be passed
as an argument to this module. They are CREATE, QUERY, VL_DATASET,
FILL_BUF, WRITE, VAL_TO_BUF_H, VAL_TO_BUF, and BUF_TO_VAL. Each of these
generates a different section of Hdf5 backend code. All are invoked by
src/CMakeLists.txt prior to C++ compilation. However, for debugging purposes,
each section can be printed individually by passing that section's identifier
as a command line argument. The entry point for each of these generation
routines is the function main_XXXX, where XXXX is a generation option.

Example
-------
To generate the code found in src/hdf5_back.cc::Query, use

    $ python3 hdf5_back_gen.py QUERY

Function Documentation

◆ a_cast()

hdf5_back_gen.a_cast ( t,
depth = 0,
prefix = "" )
HDF5 Write: Node representation of boost hold_any casting.

Definition at line 1812 of file hdf5_back_gen.py.

◆ camel_case()

hdf5_back_gen.camel_case ( db)

Definition at line 1699 of file hdf5_back_gen.py.

◆ case_template()

hdf5_back_gen.case_template ( t,
read_x )
Represents C++ case statement.

Parameters
----------
t : Type
    Depth 0 type.
read_x : Node
    Nodes of case statement body.

Returns
-------
Node
    Complete case statement block.

Definition at line 447 of file hdf5_back_gen.py.

◆ convert_canonical()

hdf5_back_gen.convert_canonical ( raw_list)
Converts JSON list of lists to tuple of tuples.

Parameters
----------
raw_list : list or str
    List to be converted, or str

Returns
-------
str or tuple
    Converted list, or str

Definition at line 368 of file hdf5_back_gen.py.

◆ flatten()

hdf5_back_gen.flatten ( canon)

Definition at line 1141 of file hdf5_back_gen.py.

◆ get_body()

hdf5_back_gen.get_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Get body nodes for a C++ type.

Parameters
----------
t : Type
    C++ type, canonical form.
depth : int, optional
    Depth relative to initial, depth 0 type.
prefix : str, optional
    Current prefix, determined by parent type.

Returns
-------
Node
    Body nodes required for the type.

Definition at line 1022 of file hdf5_back_gen.py.

◆ get_decl()

hdf5_back_gen.get_decl ( t,
depth = 0,
prefix = "" )
HDF5 Query: Get node representing C++ type declaration.

Declarations occur directly before bodies, created without recursion.

Parameters
----------
t : Type
    C++ type, canonical form.
depth : int, optional
    Depth relative to initial, depth 0 type.
prefix : str, optional
    Prefix determined by parent type.

Returns
-------
Node
    Declaration statement as a node.

Definition at line 628 of file hdf5_back_gen.py.

◆ get_dim_shape()

hdf5_back_gen.get_dim_shape ( canon,
start = 0,
depth = 0 )

Definition at line 1124 of file hdf5_back_gen.py.

◆ get_item_size()

hdf5_back_gen.get_item_size ( t,
shape_array = None,
vl_flag = False,
depth = 0 )
Resolves item size recursively.

We can dig down into a type until we reach eventual primitives, and then
multiply the known sizes of those primitives by the lengths of their
containers. Container length is defined in the C++ shape array.

Parameters
----------
t : Type
    The type whose size is in question
shape_array : list, optional
    Dimensioned list of shape array indicies, same shape as t.canon
depth : int, optional
    Recursive depth counter

Returns
-------
size : str
    String of C++ expression representing t's size.

Definition at line 1488 of file hdf5_back_gen.py.

◆ get_item_type()

hdf5_back_gen.get_item_type ( t,
shape_array = None,
vl_flag = False,
prefix = "",
depth = 0 )
HDF5 Create: Build specified HDF5 type, recursively if necessary.

HDF5 types are Primitive, Compound, or Array. We handle each of these cases
here differently. Primitives are immediately returned by querying the
HDF5_PRIMITIVES dictionary. Compound types are made up of multiple
Primitive or Compound types, so each of these child types must be declared
and created before the parent type can be created. This is accomplished via
recursion over every child type in the type's canon. It should be noted that
Compound types depend heavily on the size of those types they contain,
and this function relies on get_item_size for that information. Finally,
Arrays can contain one Primitive or Compound type, and are created by
specifying this child type, Array dimensions, and the Array length.

Parameters
----------
t : Type
    Type node representing C++ type
shape_array : list, optional
    Dimensioned list of current type shape
prefix : str, optional
    Used to name C++ variables throughout multiple levels of recursion
depth : int, optional
    Recursive depth counter

Returns
-------
node : Block
    Cumulative collection of nodes necessary for specified item type
opened_stack : list
    Cumulative collection of opened HDF5 types which must eventually be
    closed

Definition at line 1312 of file hdf5_back_gen.py.

◆ get_prefix()

hdf5_back_gen.get_prefix ( base_prefix,
parent_type,
child_index )
Return the prefix of a C++ variable, appropriately formatted for depth.

Parameters
----------
base_prefix : str
    Prefix of direct parent type.
parent_type : Type
    Node of parent type.
child_index : int
    Index relative to direct parent.

Returns
-------
str
    New prefix.

Definition at line 428 of file hdf5_back_gen.py.

◆ get_setup()

hdf5_back_gen.get_setup ( t,
depth = 0,
prefix = "",
HDF5_type = "tb_type",
child_index = 'j' )
HDF5 Query: Get nodes representing C++ setup.

Primitive setups are called directly, while template types are handled
recursively.

Parameters
----------
t : Type
    C++ type, canonical form.
depth : int, optional
    Depth relative to initial, depth 0 type.
prefix : str, optional
    Current prefix, determined by parent type.
HDF5_type : str
    hid_t type used to access HDF5 methods
child_index : str or int
    Index into parent type, None if only child

Returns
-------
Block
    Nodes required for type t setup.

Definition at line 498 of file hdf5_back_gen.py.

◆ get_teardown()

hdf5_back_gen.get_teardown ( t)

Definition at line 1087 of file hdf5_back_gen.py.

◆ get_variable()

hdf5_back_gen.get_variable ( name,
depth = 0,
prefix = "" )
Return a C++ variable, appropriately formatted for depth.

Parameters
----------
name : str
    Base variable name.
depth : int, optional
    Depth of variable in relation to depth 0 type.
prefix : str, optional
    New prefix to add, based on direct parent type.

Returns
-------
str
    Variable name.

Definition at line 408 of file hdf5_back_gen.py.

◆ get_variation_body()

hdf5_back_gen.get_variation_body ( t)
HDF5 Create: Generate C++ if-statement body for a given type.

Called in coordination with get_variation_cond. For a given C++ type, this
function returns the necessary C++ statements to create the HDF5 version
of that type.

Parameters
----------
t : Type
    C++ type for which to create an if-statement body.

Returns
-------
body : Block
    Node containing necessary C++ statements for HDF5 creation.

Definition at line 1236 of file hdf5_back_gen.py.

◆ get_variation_cond()

hdf5_back_gen.get_variation_cond ( t)
HDF5 Create: Generate C++ if-statement condition for a given type.

These if-statements are always a string of boolean expressions of the form
'shape[n]<1' or 'shape[n]>=1', where n is an index into the C++ shape array.
A shape index less than one (<1) denotes a variable length type, whereas an
index greater than one (>=1) denotes fixed length type. These boolean
expressions are joined by '&&' operators. For instance, a type of
VL_MAP_VL_STRING_VL_STRING would receive the condition
'shape[0]<1 && shape[1]<1 && shape[2]<1'.

Parameters
----------
t : Type
    C++ type for the boolean condition.

Returns
-------
current_bool : BinOp
    Node representing the boolean condition.

Definition at line 1157 of file hdf5_back_gen.py.

◆ get_write_body()

hdf5_back_gen.get_write_body ( t,
shape_array,
depth = 0,
prefix = "",
variable = "a",
offset = "buf",
pointer = False )
HDF5 Write: Generates the body of the WriteToBuf function definition.

Parameters
----------
t : Type
    Node representing the desired C++ type
shape_array : list
    Dimensioned list of shape array indicies corresponding to types in
    t.canon
depth : int, optional
    Recursive depth
prefix : str, optional
    Used for recursive variable naming convention
variable : str, optional
    Name of the type's C++ variable
offset : str, optional
    Location of current memory offset
pointer : bool, optional
    Denotes if current variable is a pointer, and whether member access
    should be performed via arrow or dot notation

Returns
-------
result : Block
    Nodes required for body of the function definition

Definition at line 2158 of file hdf5_back_gen.py.

◆ get_write_setup()

hdf5_back_gen.get_write_setup ( t,
shape_array,
depth = 0,
prefix = "" )
HDF5 Write: Creates setup variables (lengths, sizes) for function body.

This function recursively declares the sizes, lengths and other necessary
variables for the parent and children types. Called by get_write_body.

Parameters
----------
t : Type
shape_array : list
depth : int
prefix : str

Returns
-------
setup : Block

Definition at line 1831 of file hdf5_back_gen.py.

◆ hdf5_array_create()

hdf5_back_gen.hdf5_array_create ( item_variable,
rank = 1,
dims = "&shape0" )
Node representation of the C++ H5Tarray_create2 method.

Parameters
----------
item_variable : str
    Variable name of HDF5 array item.
rank : int, optional
    Number of HDF5 array dimensions.
dims : str, optional
    Variable (by reference) of shape array belonging to HDF5 array

Returns
-------
node : FuncCall
    Node of H5Tarray_create2 function call.

Definition at line 1549 of file hdf5_back_gen.py.

◆ hdf5_create_compound()

hdf5_back_gen.hdf5_create_compound ( sizes)
Node representation of the C++ HDF5 compound type creation function.

Parameters
----------
sizes : list
    List of type sizes, all must be str type.

Returns
-------
node : FuncCall
    H5Tcreate function call node.

Definition at line 1571 of file hdf5_back_gen.py.

◆ hdf5_insert()

hdf5_back_gen.hdf5_insert ( container_type,
compound_var,
types_sizes_dict )
Node representation of the C++ H5Tinsert function.

This function is used to identify partitions within an already established
HDF5 Compound type. That is, we specify which inner types are located at
what memory location within the Compound type.

Parameters
----------
container_type : str
    Should be a key in the template_args dict
compound_var : str
    C++ variable to which the function should refer
types_sizes_dict : dict
    Dictionary of C++ type variables mapped to their size in memory

Returns
-------
node : Block
    Cumulative nodes for H5Tinsert function

Definition at line 1588 of file hdf5_back_gen.py.

◆ indent()

hdf5_back_gen.indent ( text,
prefix,
predicate = None )
This function copied from textwrap library version 3.3.

Adds 'prefix' to the beginning of selected lines in 'text'.
If 'predicate' is provided, 'prefix' will only be added to the lines
where 'predicate(line)' is True. If 'predicate' is not provided,
it will default to adding 'prefix' to all non-empty lines that do not
consist solely of whitespace characters.

Definition at line 1090 of file hdf5_back_gen.py.

◆ is_all_vl()

hdf5_back_gen.is_all_vl ( t)
HDF5 Write: Determines if type is entirely VL.

A type is entirely VL if the top level type is VL, as well as all children
that have the potential to be VL. This means that VL_VECTOR_INT will return
True here, but VL_VECTOR_STRING will return False.

Parameters
----------
t : Type

Returns
-------
result : bool
    True if type is entirely VL, else False

Definition at line 1977 of file hdf5_back_gen.py.

◆ list_body()

hdf5_back_gen.list_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents body of C++ list<non-primitive> types.

Definition at line 975 of file hdf5_back_gen.py.

◆ list_dependencies()

hdf5_back_gen.list_dependencies ( canon)
Return a list of a type's dependencies, each in canonical form.

Parameters
----------
canon : tuple or str
    the canonical form of the type

Returns
-------
list or str
    list of dependencies or str if base type is primitive

Examples:
>>> list_dep("('PAIR', 'INT', 'VL_STRING')")
[('PAIR', 'INT', 'VL_STRING'), 'INT', 'VL_STRING']

Definition at line 385 of file hdf5_back_gen.py.

◆ list_primitive_body()

hdf5_back_gen.list_primitive_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents body of C++ list<primitive> types.

Definition at line 950 of file hdf5_back_gen.py.

◆ main()

hdf5_back_gen.main ( )

Definition at line 2845 of file hdf5_back_gen.py.

◆ main_buf_to_val()

hdf5_back_gen.main_buf_to_val ( )
HDF5 BUF_TO_VAL: Generates the VLBufToVal function code.

Definition at line 2740 of file hdf5_back_gen.py.

◆ main_create()

hdf5_back_gen.main_create ( )
HDF5 Create: Generate CreateTable if-statements.

Definition at line 1659 of file hdf5_back_gen.py.

◆ main_fill_buf()

hdf5_back_gen.main_fill_buf ( )
HDF5 FILL_BUF: Generates the FillBuf function code.

Definition at line 1732 of file hdf5_back_gen.py.

◆ main_query()

hdf5_back_gen.main_query ( )
HDF5 Query: Generate Query case statement code.

Definition at line 1625 of file hdf5_back_gen.py.

◆ main_val_to_buf()

hdf5_back_gen.main_val_to_buf ( )
HDF5 VAL_TO_BUF: Generates VLValToBuf function.

Definition at line 2553 of file hdf5_back_gen.py.

◆ main_val_to_buf_h()

hdf5_back_gen.main_val_to_buf_h ( )
HDF5 VAL_TO_BUF_H: Generates header declarations for VLValToBuf function.

Definition at line 2572 of file hdf5_back_gen.py.

◆ main_vl_dataset()

hdf5_back_gen.main_vl_dataset ( )
HDF5 VL_DATASET: Generate the VLDataset function code.

Definition at line 1708 of file hdf5_back_gen.py.

◆ main_write()

hdf5_back_gen.main_write ( )
HDF5 Write: Generate the WriteToBuf templated function definitions.

Definition at line 2323 of file hdf5_back_gen.py.

◆ map_body()

hdf5_back_gen.map_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents the body for C++ map type.

Definition at line 728 of file hdf5_back_gen.py.

◆ memcpy()

hdf5_back_gen.memcpy ( dest,
src,
size )
HDF5 Write: Node representation of memcpy function.

Definition at line 1800 of file hdf5_back_gen.py.

◆ memset()

hdf5_back_gen.memset ( dest,
src,
size )
HDF5 Write: Node representation of memset function.

Definition at line 1806 of file hdf5_back_gen.py.

◆ no_vl()

hdf5_back_gen.no_vl ( t)

Definition at line 1112 of file hdf5_back_gen.py.

◆ normal_close()

hdf5_back_gen.normal_close ( t)
Represents the generic close to an hdf5 type code block.

Definition at line 1066 of file hdf5_back_gen.py.

◆ pad_children()

hdf5_back_gen.pad_children ( t,
variable,
fixed_var = None,
depth = 0,
prefix = "",
called_depth = 0 )
HDF5 Write: Pads FL children of VL parent types.

This function is used on top-level VL container types which contain 1 or
more FL child types (i.e. VL_VECTOR_STRING). These children should be
padded to their max length if they do not already meet it. This is done
recursively.

Parameters
----------
t : Type
variable : str
fixed_var : None or str, optional
depth : int, optional
prefix : str, optional
called_depth : int, optional
    Records the origin depth to determine when we're at relative depth=0

Returns
-------
result : Block
    Nodes required for padding

Definition at line 2014 of file hdf5_back_gen.py.

◆ pair_body()

hdf5_back_gen.pair_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents body for C++ pair type.

Definition at line 765 of file hdf5_back_gen.py.

◆ primitive_setup()

hdf5_back_gen.primitive_setup ( t,
depth = 0,
prefix = "" )
HDF5 Query: Represents necessary setup steps for C++ primitives.

Definition at line 470 of file hdf5_back_gen.py.

◆ print_statement()

hdf5_back_gen.print_statement ( t,
identifier )
Generate C++ print statement for debugging generated code.

Definition at line 1230 of file hdf5_back_gen.py.

◆ reinterpret_cast()

hdf5_back_gen.reinterpret_cast ( t,
offset,
deref = False )
Representation of C++ reinterpret_cast function.

Parameters
----------
t : Type
    C++ type to cast as.
offset : str
    Memory location of the data to cast.
deref : bool, optional
    Should the function be dereferenced? (This returns the newly casted
    data, rather than a pointer)

Returns
-------
node : FuncCall
    The final function call.

Definition at line 2615 of file hdf5_back_gen.py.

◆ reinterpret_cast_body()

hdf5_back_gen.reinterpret_cast_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents a body using the reinterpret_cast method.

This includes int, double, float, etc.

Definition at line 651 of file hdf5_back_gen.py.

◆ resolve_unicode()

hdf5_back_gen.resolve_unicode ( item)
Translate unicode types into string types, if necessary.

This function exists to support Python 2.7.

Parameters
----------
item : int or str or list
    The list of items, or item to potentially encode.

Returns
-------
int or str or list
    The same type as was passed to the function, encoded if necessary

Definition at line 340 of file hdf5_back_gen.py.

◆ set_body()

hdf5_back_gen.set_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents body of C++ set<non-primitive> types.

Definition at line 896 of file hdf5_back_gen.py.

◆ set_primitive_body()

hdf5_back_gen.set_primitive_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents body of C++ set<primitive> types.

Definition at line 870 of file hdf5_back_gen.py.

◆ set_string_body()

hdf5_back_gen.set_string_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents body of C++ set<std::string> types.

Definition at line 923 of file hdf5_back_gen.py.

◆ setup()

hdf5_back_gen.setup ( )

Definition at line 2761 of file hdf5_back_gen.py.

◆ string()

hdf5_back_gen.string ( s)

Definition at line 1705 of file hdf5_back_gen.py.

◆ string_body()

hdf5_back_gen.string_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset",
variable = None )
HDF5 Query: Represents body for the C++ String primitive.

Definition at line 665 of file hdf5_back_gen.py.

◆ string_setup()

hdf5_back_gen.string_setup ( depth = 0,
prefix = "" )
HDF5 Query: Represents necessary setup steps for C++ String.

Definition at line 475 of file hdf5_back_gen.py.

◆ to_buf_body()

hdf5_back_gen.to_buf_body ( t,
vl_list,
depth = 0,
prefix = "",
variable = None,
offset = "reinterpret_cast<char*>(buf.p)" )
HDF5 VAL_TO_BUF: Generates the body of the VLValToBuf function.

The VLValToBuf function creates a new VL buffer from an original C++ data
type. All potentially variable length types are passed to VLWrite and a
SHA1 hash is added to the buffer in place of the actual type data.
Primitives and remaining container types are written as-is to the buffer.

Parameters
----------
t : Type
    Node representing current C++ type
vl_list : list
    Potentially dimensioned list of 1's and 0's, corresponding to each
    child type and whether it is variable length or not, respectively.
depth : int, optional
    Current recursive depth, used for naming variables.
prefix : str, optional
    Current variable prefix, used to ensure unique variable names.
variable : str, optional
    Current container variable name.
offset : str or None, optional
    Current offset into data.

Returns
-------
block : Block
    Nodes representing the body.

Definition at line 2448 of file hdf5_back_gen.py.

◆ to_from_buf_setup()

hdf5_back_gen.to_from_buf_setup ( t,
depth = 0,
prefix = "",
spec = None )
HDF5 VAL_TO_BUF and BUF_TO_VAL: Generate setup for both functions.

This setup is to be called one time for each type. It returns nodes for
initial buffer/type declaration, item sizes, and a potentially dimensioned
list describing which child types within the initial container t are VL.
These are denoted by a 1, where fixed-length primitive types are denoted by
a 0. Fixed-length containers (i.e. pairs) are denoted by a nested list of
1's and 0's.

Parameters
----------
t : Type
    C++ type node.
depth : int, optional
    Recursive depth counter, used for variable names.
prefix : str, optional
    Current prefix, used for variable name uniqueness.
spec : str or None, optional
    Determines whether extra nodes are added for VAL_TO_BUF or BUF_TO_VAL

Returns
-------
node : Block
    All setup nodes.
vl_list : list
    Potentially dimensioned list cooresponding to child types, with values
    of 0 and 1 representing FL and VL types, respectively.

Definition at line 2347 of file hdf5_back_gen.py.

◆ to_val_body()

hdf5_back_gen.to_val_body ( t,
vl_list,
depth = 0,
prefix = '',
variable = 'x0',
offset = None )
Generates the body of the VLBufToVal function.

The VLBufToVal function is responsible for reading the bytes of a VL buffer
back into a C++ value. Importantly, we assume that all types which have the
capability of being VL *are* VL. When we encounter one of these types, we
call VLRead, passing in the respective SHA1 hash value. Otherwise, we read
in the fixed length number of bytes associated with the type.

Parameters
----------
t : Type
    Node representing current C++ type
vl_list : list
    Potentially dimensioned list of 1's and 0's, corresponding to each
    child type and whether it is variable length or not, respectively.
depth : int, optional
    Current recursive depth, used for naming variables.
prefix : str, optional
    Current variable prefix, used to ensure unique variable names.
variable : str, optional
    Current container variable name.
offset : str or None, optional
    Current offset into buffer.

Returns
-------
block : Block
    Nodes representing the body.

Definition at line 2641 of file hdf5_back_gen.py.

◆ typeid()

hdf5_back_gen.typeid ( t)

Definition at line 1108 of file hdf5_back_gen.py.

◆ uuid_body()

hdf5_back_gen.uuid_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents the body for the boost::uuid primitive.

Definition at line 706 of file hdf5_back_gen.py.

◆ vec_string_body()

hdf5_back_gen.vec_string_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents body of C++ Vector<std::string> types.

Definition at line 843 of file hdf5_back_gen.py.

◆ vector_body()

hdf5_back_gen.vector_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents body of C++ Vector<non-primitive> types.

Definition at line 812 of file hdf5_back_gen.py.

◆ vector_primitive_body()

hdf5_back_gen.vector_primitive_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents body of C++ Vector<primitive> types.

Definition at line 793 of file hdf5_back_gen.py.

◆ VL_ADD_BLOCK()

hdf5_back_gen.VL_ADD_BLOCK ( t,
item_var )

Definition at line 1216 of file hdf5_back_gen.py.

◆ vl_body()

hdf5_back_gen.vl_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset" )
HDF5 Query: Represents the body for all C++ VL types.

Definition at line 718 of file hdf5_back_gen.py.

◆ vl_read()

hdf5_back_gen.vl_read ( t,
offset )
Representation of C++ VLRead function.

Parameters
----------
t : Type
    C++ type node.
offset : str
    Memory location of SHA1 hash.

Returns
-------
node : FuncCall
    The final function call.

Definition at line 2594 of file hdf5_back_gen.py.

◆ vl_string_body()

hdf5_back_gen.vl_string_body ( t,
depth = 0,
prefix = "",
base_offset = "buf+offset",
variable = None )
HDF5 Query: Represents the body for the VL_String primitive.

Definition at line 692 of file hdf5_back_gen.py.

◆ vl_string_setup()

hdf5_back_gen.vl_string_setup ( depth = 0,
prefix = "" )
HDF5 Query: Represents necessary setup steps for C++ VL_String.

Definition at line 483 of file hdf5_back_gen.py.

◆ vl_write()

hdf5_back_gen.vl_write ( t,
variable,
depth = 0,
prefix = "",
pointer = False )
HDF5 Write: Return code previously found in VLWrite.

Definition at line 1771 of file hdf5_back_gen.py.

◆ write_body_primitive()

hdf5_back_gen.write_body_primitive ( t,
depth = 0,
prefix = "",
variable = None,
offset = "buf",
pointer = False )
HDF5 Write: Specialization of the write_body function for primitives

Definition at line 1952 of file hdf5_back_gen.py.

◆ write_body_string()

hdf5_back_gen.write_body_string ( t,
depth = 0,
prefix = "",
variable = None,
offset = "buf",
pointer = False )
HDF5 Write: Specialization of the write_body function for STRING type

Definition at line 1919 of file hdf5_back_gen.py.

◆ write_body_uuid()

hdf5_back_gen.write_body_uuid ( t,
depth = 0,
prefix = "",
variable = None,
offset = "buf",
pointer = False )
HDF5 Write: Specialization of the write_body function for UUID type

Definition at line 1939 of file hdf5_back_gen.py.

Variable Documentation

◆ _lowername

cls hdf5_back_gen._lowername = lambda cls.__name__.lower()
protected

Definition at line 121 of file hdf5_back_gen.py.

◆ BODIES

dict hdf5_back_gen.BODIES
Initial value:
1= {"INT": reinterpret_cast_body,
2 "DOUBLE": reinterpret_cast_body,
3 "FLOAT": reinterpret_cast_body,
4 "BOOL": reinterpret_cast_body,
5 "UUID": uuid_body,
6 "STRING": string_body,
7 "VL_STRING": vl_body,
8 "BLOB": vl_body,
9 "VECTOR_STRING": vec_string_body,
10 "MAP": map_body,
11 "PAIR": pair_body,
12 "LIST_INT": list_primitive_body,
13 "LIST_DOUBLE": list_primitive_body,
14 "LIST_FLOAT": list_primitive_body,
15 "LIST": list_body,
16 "SET_INT": set_primitive_body,
17 "SET_DOUBLE": set_primitive_body,
18 "SET_FLOAT": set_primitive_body,
19 "SET": set_body,
20 "VECTOR_INT": vector_primitive_body,
21 "VECTOR_DOUBLE": vector_primitive_body,
22 "VECTOR_FLOAT": vector_primitive_body,
23 "VECTOR": vector_body}

Definition at line 998 of file hdf5_back_gen.py.

◆ CANON_TO_DB

dict hdf5_back_gen.CANON_TO_DB = {}

Definition at line 32 of file hdf5_back_gen.py.

◆ CANON_TO_NODE

dict hdf5_back_gen.CANON_TO_NODE = {}

Definition at line 29 of file hdf5_back_gen.py.

◆ CANON_TYPES

list hdf5_back_gen.CANON_TYPES = []

Definition at line 30 of file hdf5_back_gen.py.

◆ CONTAINER_INSERT_STRINGS

dict hdf5_back_gen.CONTAINER_INSERT_STRINGS
Initial value:
1= {"MAP": "{var}[{child0}] = {child1}",
2 "LIST": "{var}.push_back({child0})",
3 "SET": "{var}.insert({child0})",
4 "VECTOR": "{var}.push_back({child0})",
5 "PAIR": "{var} = std::make_pair({child0},{child1})"}

Definition at line 1971 of file hdf5_back_gen.py.

◆ DB_TO_CPP

dict hdf5_back_gen.DB_TO_CPP = {}

Definition at line 31 of file hdf5_back_gen.py.

◆ DB_TO_VL

dict hdf5_back_gen.DB_TO_VL = {}

Definition at line 33 of file hdf5_back_gen.py.

◆ DEBUG_TYPES

list hdf5_back_gen.DEBUG_TYPES = ["VECTOR_STRING"]

Definition at line 1657 of file hdf5_back_gen.py.

◆ HDF5_PRIMITIVES

dict hdf5_back_gen.HDF5_PRIMITIVES
Initial value:
1= {"INT": "H5T_NATIVE_INT",
2 "DOUBLE": "H5T_NATIVE_DOUBLE",
3 "FLOAT": "H5T_NATIVE_FLOAT",
4 "BOOL": "H5T_NATIVE_CHAR",
5 "STRING": "CreateFLStrType({size})",
6 "BLOB": "sha1_type_",
7 "UUID": "uuid_type_"}

Definition at line 1291 of file hdf5_back_gen.py.

◆ INDENT

str hdf5_back_gen.INDENT = ' '

Definition at line 34 of file hdf5_back_gen.py.

◆ io_error

hdf5_back_gen.io_error
Initial value:
1= Raw(code=("throw IOError(\"the type for column \'\"+"
2 "std::string(field_names[i])+\"\' is not yet supported "
3 "in HDF5.\");"))

Definition at line 1639 of file hdf5_back_gen.py.

◆ is_primitive

isinstance hdf5_back_gen.is_primitive = lambda t(t.canon, str)

Definition at line 41 of file hdf5_back_gen.py.

◆ MAIN_DISPATCH

dict hdf5_back_gen.MAIN_DISPATCH = {}

Definition at line 27 of file hdf5_back_gen.py.

◆ NOT_VL

list hdf5_back_gen.NOT_VL = []

Definition at line 36 of file hdf5_back_gen.py.

◆ ORIGIN_DICT

hdf5_back_gen.ORIGIN_DICT = OrderedDict()

Definition at line 38 of file hdf5_back_gen.py.

◆ ORIGIN_TO_VL

dict hdf5_back_gen.ORIGIN_TO_VL = {}

Definition at line 39 of file hdf5_back_gen.py.

◆ PRIMITIVE_SIZES

dict hdf5_back_gen.PRIMITIVE_SIZES
Initial value:
1= {"INT": "sizeof(int)",
2 "DOUBLE": "sizeof(double)",
3 "FLOAT": "sizeof(float)",
4 "BOOL": "sizeof(char)",
5 "VL_STRING": "CYCLUS_SHA1_SIZE",
6 "BLOB": "CYCLUS_SHA1_SIZE",
7 "UUID": "CYCLUS_UUID_SIZE"}

Definition at line 1299 of file hdf5_back_gen.py.

◆ raw_blob

hdf5_back_gen.raw_blob
Initial value:
1= Raw(code=("dbtypes[i]=BLOB;\n"
2 "field_types[i]=sha1_type_;\n"
3 "dst_sizes[i]=CYCLUS_SHA1_SIZE;\n"))

Definition at line 1650 of file hdf5_back_gen.py.

◆ raw_string

hdf5_back_gen.raw_string
Initial value:
1= Raw(code=("dbtypes[i]=STRING;\n"
2 "field_types[i]=H5Tcopy(H5T_C_S1);\n"
3 "H5Tset_size(field_types[i], shape[0]);\n"
4 "H5Tset_strpad(field_types[i], H5T_STR_NULLPAD);\n"
5 "opened_types_.insert(field_types[i]);\n"
6 "dst_sizes[i]=sizeof(char)*shape[0];\n"))

Definition at line 1643 of file hdf5_back_gen.py.

◆ RAW_TYPES

dict hdf5_back_gen.RAW_TYPES
Initial value:
1= {"STRING": raw_string,
2 "BLOB": raw_blob}

Definition at line 1654 of file hdf5_back_gen.py.

◆ TEARDOWN_STACK

list hdf5_back_gen.TEARDOWN_STACK = []

Definition at line 1063 of file hdf5_back_gen.py.

◆ template_args

dict hdf5_back_gen.template_args
Initial value:
1= {"MAP": ("key", "val"),
2 "VECTOR": ("elem",),
3 "SET": ("elem",),
4 "LIST": ("elem",),
5 "PAIR": ("first", "second")}

Definition at line 490 of file hdf5_back_gen.py.

◆ variable_length_types

list hdf5_back_gen.variable_length_types = ["MAP", "LIST", "SET", "VECTOR"]

Definition at line 495 of file hdf5_back_gen.py.

◆ VARIATION_DICT

hdf5_back_gen.VARIATION_DICT = OrderedDict()

Definition at line 37 of file hdf5_back_gen.py.

◆ VARS

list hdf5_back_gen.VARS = []

Definition at line 1064 of file hdf5_back_gen.py.

◆ VL_SPECIAL_TYPES

dict hdf5_back_gen.VL_SPECIAL_TYPES
Initial value:
1= {"VL_STRING": vl_write_vl_string,
2 "BLOB": vl_write_blob}

Definition at line 1768 of file hdf5_back_gen.py.

◆ VL_TO_FL_CONTAINERS

dict hdf5_back_gen.VL_TO_FL_CONTAINERS
Initial value:
1= {"VL_VECTOR": "VECTOR",
2 "VL_SET": "SET",
3 "VL_LIST": "LIST",
4 "VL_MAP": "MAP"}

Definition at line 1307 of file hdf5_back_gen.py.

◆ vl_write_blob

str hdf5_back_gen.vl_write_blob
Initial value:
1= """hasher_.Clear();
2hasher_.Update({var});
3Digest {key} = hasher_.digest();
4hid_t {keysds} = VLDataset({t.db}, true);
5hid_t {valsds} = VLDataset({t.db}, false);
6if (vlkeys_[{t.db}].count({key}) != 1) {{
7 AppendVLKey({keysds}, {t.db}, {key});
8 InsertVLVal({valsds}, {t.db}, {key}, ({var}).str());
9}}\n"""

Definition at line 1758 of file hdf5_back_gen.py.

◆ vl_write_vl_string

str hdf5_back_gen.vl_write_vl_string
Initial value:
1= """hasher_.Clear();
2hasher_.Update({var});
3Digest {key} = hasher_.digest();
4hid_t {keysds} = VLDataset({t.db}, true);
5hid_t {valsds} = VLDataset({t.db}, false);
6if (vlkeys_[{t.db}].count({key}) != 1) {{
7 AppendVLKey({keysds}, {t.db}, {key});
8 InsertVLVal({valsds}, {t.db}, {key}, {var});
9}}\n"""

Definition at line 1748 of file hdf5_back_gen.py.

◆ WRITE_BODY_PRIMITIVES

dict hdf5_back_gen.WRITE_BODY_PRIMITIVES
Initial value:
1= {"STRING": write_body_string,
2 "UUID": write_body_uuid}

Definition at line 1968 of file hdf5_back_gen.py.