tools/generate_stubs/generate_stubs.py
def WriteUmbrellaInitializer(cls, module_names, namespace, outfile,
                               logging_function):
    """Writes a single function that will open + initialize each module.

    This intializer will take in an stl map of that lists the correct
    dlopen target for each module.  The map type is
    std::map<enum StubModules, vector<std::string>> which matches one module
    to a list of paths to try in dlopen.

    This function is an all-or-nothing function.  If any module fails to load,
    all other modules are dlclosed, and the function returns.  Though it is
    not enforced, this function should only be called once.

    Args:
      module_names: A list with the names of the modules in this stub file.
      namespace: The namespace these functions should be in.
      outfile: The file handle to populate with pointer definitions.
    """
    outfile.write(UMBRELLA_INITIALIZER_START % namespace)
    outfile.write(UMBRELLA_INITIALIZER_CLEANUP_FUNCTION)

    # Create the initialization function that calls all module initializers,
    # checks if they succeeded, and backs out module loads on an error.
    outfile.write(UMBRELLA_INITIALIZER_INITIALIZE_FUNCTION_START %
                  {'logging_function': logging_function})
    outfile.write(
        '\n  // Initialize each module if we have not already failed.\n')
    for module in module_names:
      outfile.write('  %s(opened_libraries[%s]);\n' %
                    (PosixStubWriter.InitializeModuleName(module),
                     PosixStubWriter.EnumName(module)))
    outfile.write('\n')

    # Output code to check the initialization status, clean up on error.
    initializer_checks = [
        '!%s()' % PosixStubWriter.IsInitializedName(name)
        for name in module_names
    ]
    uninitializers = [
        '%s()' % PosixStubWriter.UninitializeModuleName(name)
        for name in module_names
    ]
    outfile.write(
        UMBRELLA_INITIALIZER_CHECK_AND_CLEANUP % {
            'conditional': ' ||\n      '.join(initializer_checks),
            'uninitializers': ';\n    '.join(uninitializers)
        })
    outfile.write('\n}  // namespace %s\n' % namespace)
Writes a single function that will open + initialize each module.

    This intializer will take in an stl map of that lists the correct
    dlopen target for each module.  The map type is
    std::map<enum StubModules, vector<std::string>> which matches one module
    to a list of paths to try in dlopen.

    This function is an all-or-nothing function.  If any module fails to load,
    all other modules are dlclosed, and the function returns.  Though it is
    not enforced, this function should only be called once.

    Args:
      module_names: A list with the names of the modules in this stub file.
      namespace: The namespace these functions should be in.
      outfile: The file handle to populate with pointer definitions.
    
Writes a single function that will open + initialize each module.
This intializer will take in an stl map of that lists the correct
dlopen target for each module.  The map type is
std::map> which matches one module
to a list of paths to try in dlopen.

This function is an all-or-nothing function.  If any module fails to load,
all other modules are dlclosed, and the function returns.  Though it is
not enforced, this function should only be called once.
Writes a single function that will open + initialize each module . This intializer will take in an stl map of that lists the correct dlopen target for each module . The map type is std :: map > which matches one module to a list of paths to try in dlopen . This function is an all - or - nothing function . If any module fails to load all other modules are dlclosed and the function returns . Though it is not enforced this function should only be called once .
def WriteUmbrellaInitializer(cls, module_names, namespace, outfile,
                               logging_function):
    outfile.write(UMBRELLA_INITIALIZER_START % namespace)
    outfile.write(UMBRELLA_INITIALIZER_CLEANUP_FUNCTION)
    outfile.write(UMBRELLA_INITIALIZER_INITIALIZE_FUNCTION_START %
                  {'logging_function': logging_function})
    outfile.write(
        '\n  // Initialize each module if we have not already failed.\n')
    for module in module_names:
      outfile.write('  %s(opened_libraries[%s]);\n' %
                    (PosixStubWriter.InitializeModuleName(module),
                     PosixStubWriter.EnumName(module)))
    outfile.write('\n')
    initializer_checks = [
        '!%s()' % PosixStubWriter.IsInitializedName(name)
        for name in module_names
    ]
    uninitializers = [
        '%s()' % PosixStubWriter.UninitializeModuleName(name)
        for name in module_names
    ]
    outfile.write(
        UMBRELLA_INITIALIZER_CHECK_AND_CLEANUP % {
            'conditional': ' ||\n      '.join(initializer_checks),
            'uninitializers': ';\n    '.join(uninitializers)
        })
    outfile.write('\n}  // namespace %s\n' % namespace)
def WriteUmbrellaInitializer ( cls , module_names , namespace , outfile , logging_function ) : outfile . write ( UMBRELLA_INITIALIZER_START % namespace ) outfile . write ( UMBRELLA_INITIALIZER_CLEANUP_FUNCTION ) outfile . write ( UMBRELLA_INITIALIZER_INITIALIZE_FUNCTION_START % { 'logging_function' : logging_function } ) outfile . write ( '\n  // Initialize each module if we have not already failed.\n' ) for module in module_names : outfile . write ( '  %s(opened_libraries[%s]);\n' % ( PosixStubWriter . InitializeModuleName ( module ) , PosixStubWriter . EnumName ( module ) ) ) outfile . write ( '\n' ) initializer_checks = [ '!%s()' % PosixStubWriter . IsInitializedName ( name ) for name in module_names ] uninitializers = [ '%s()' % PosixStubWriter . UninitializeModuleName ( name ) for name in module_names ] outfile . write ( UMBRELLA_INITIALIZER_CHECK_AND_CLEANUP % { 'conditional' : ' ||\n      ' . join ( initializer_checks ) , 'uninitializers' : ';\n    ' . join ( uninitializers ) } ) outfile . write ( '\n}  // namespace %s\n' % namespace )
Writes a single function that will open + initialize each module.
Writes a single function that will open + initialize each module .
"""Writes a single function that will open + initialize each module.

    This intializer will take in an stl map of that lists the correct
    dlopen target for each module.  The map type is
    std::map<enum StubModules, vector<std::string>> which matches one module
    to a list of paths to try in dlopen.

    This function is an all-or-nothing function.  If any module fails to load,
    all other modules are dlclosed, and the function returns.  Though it is
    not enforced, this function should only be called once.

    Args:
      module_names: A list with the names of the modules in this stub file.
      namespace: The namespace these functions should be in.
      outfile: The file handle to populate with pointer definitions.
    """ # Create the initialization function that calls all module initializers, # checks if they succeeded, and backs out module loads on an error. # Output code to check the initialization status, clean up on error.
cls
module_names
A list with the names of the modules in this stub file.
A list with the names of the modules in this stub file .
namespace
The namespace these functions should be in.
The namespace these functions should be in .
outfile
The file handle to populate with pointer definitions.
The file handle to populate with pointer definitions .
logging_function