pygccxml.parser.directory_cache module

directory cache implementation.

This module contains the implementation of a cache that uses individual files, stored in a dedicated cache directory, to store the cached contents.

The parser.directory_cache_t class instance could be passed as the cache argument of the parser.parse() function.

class directory_cache_t(directory='cache', compression=False, sha1_sigs=True)

Bases: pygccxml.parser.declarations_cache.cache_base_t

cache class that stores its data as multiple files inside a directory.

The cache stores one index file called index.dat which is always read by the cache when the cache object is created. Each header file will have its corresponding .cache file that stores the declarations found in the header file. The index file is used to determine whether a .cache file is still valid or not (by checking if one of the dependent files (i.e. the header file itself and all included files) have been modified since the last run).

cached_value(source_file, configuration)

Return the cached declarations or None.

Parameters:
  • source_file (str) – Header file name
  • configuration (parser.xml_generator_configuration_t) – Configuration object
Return type:

Cached declarations or None

flush()

Save the index table to disk.

logger = <logging.Logger object>
update(source_file, configuration, declarations, included_files)

Replace a cache entry by a new value.

Parameters:
  • source_file (str) – a C++ source file name.
  • configuration (xml_generator_configuration_t) – configuration object.
  • declarations (pickable object) – declarations contained in the source_file
  • included_files (list of str) – included files
class filename_entry_t(filename)

Bases: object

This is a record stored in the filename_repository_t class.

The class is an internal class used in the implementation of the filename_repository_t class and it just serves as a container for the file name and the reference count.

dec_ref_count()

Decrease the reference count by 1 and return the new count.

inc_ref_count()

Increase the reference count by 1.

class filename_repository_t(sha1_sigs)

Bases: object

File name repository.

This class stores file names and can check whether a file has been modified or not since a previous call. A file name is stored by calling acquire_filename() which returns an ID and a signature of the file. The signature can later be used to check if the file was modified by calling is_file_modified(). If the file name is no longer required release_filename() should be called so that the entry can be removed from the repository.

acquire_filename(name)

Acquire a file name and return its id and its signature.

is_file_modified(id_, signature)

Check if the file referred to by id_ has been modified.

release_filename(id_)

Release a file name.

update_id_counter()

Update the id_ counter so that it doesn’t grow forever.

class index_entry_t(filesigs, configsig)

Bases: object

Entry of the index table in the directory cache index.

Each cached header file (i.e. each .cache file) has a corresponding index_entry_t object. This object is used to determine whether the cache file with the declarations is still valid or not.

This class is a helper class for the directory_cache_t class.