tools/generate_stubs/generate_stubs.py
def WriteModuleInitializeFunctions(self, outfile):
    """Write functions to initialize/query initlialization of the module.

    This creates 2 functions IsModuleInitialized and InitializeModule where
    "Module" is replaced with the module name, first letter capitalized.

    The InitializeModule function takes a handle that is retrieved from dlopen
    and attempts to assign each function pointer above via dlsym.

    The IsModuleInitialized returns true if none of the required functions
    pointers are nullptr.

    Args:
      outfile: The file handle to populate.
    """
    ptr_names = ['%s_ptr' % sig['name'] for sig in self.signatures]

    # Construct the conditional expression to check the initialization of
    # all the function pointers above.  It should generate a conjunction
    # with each pointer on its own line, indented by six spaces to match
    # the indentation level of MODULE_INITIALIZATION_CHECK_FUNCTION.
    initialization_conditional = ' &&\n         '.join(ptr_names)

    outfile.write(MODULE_INITIALIZATION_CHECK_FUNCTION %
                  (PosixStubWriter.IsInitializedName(
                      self.module_name), initialization_conditional))

    # Create function that initializes the module.
    outfile.write(MODULE_INITIALIZE_START %
                  PosixStubWriter.InitializeModuleName(self.module_name))
    for sig in self.signatures:
      outfile.write(
          STUB_POINTER_INITIALIZER % {
              'name': sig['name'],
              'return_type': sig['return_type'],
              'parameters': ', '.join(sig['params']),
              'logging_function': self.logging_function
          })
    outfile.write(MODULE_INITIALIZE_END)

    # Create function that uninitializes the module (sets all pointers to
    # nullptr).
    outfile.write(MODULE_UNINITIALIZE_START %
                  PosixStubWriter.UninitializeModuleName(self.module_name))
    for sig in self.signatures:
      outfile.write('  %s_ptr = nullptr;\n' % sig['name'])
    outfile.write(MODULE_UNINITIALIZE_END)
Write functions to initialize/query initlialization of the module.

    This creates 2 functions IsModuleInitialized and InitializeModule where
    "Module" is replaced with the module name, first letter capitalized.

    The InitializeModule function takes a handle that is retrieved from dlopen
    and attempts to assign each function pointer above via dlsym.

    The IsModuleInitialized returns true if none of the required functions
    pointers are nullptr.

    Args:
      outfile: The file handle to populate.
    
Write functions to initialize/query initlialization of the module.
This creates 2 functions IsModuleInitialized and InitializeModule where
"Module" is replaced with the module name, first letter capitalized.

The InitializeModule function takes a handle that is retrieved from dlopen
and attempts to assign each function pointer above via dlsym.

The IsModuleInitialized returns true if none of the required functions
pointers are nullptr.
Write functions to initialize / query initlialization of the module . This creates 2 functions IsModuleInitialized and InitializeModule where " Module " is replaced with the module name first letter capitalized . The InitializeModule function takes a handle that is retrieved from dlopen and attempts to assign each function pointer above via dlsym . The IsModuleInitialized returns true if none of the required functions pointers are nullptr .
def WriteModuleInitializeFunctions(self, outfile):
    ptr_names = ['%s_ptr' % sig['name'] for sig in self.signatures]
    initialization_conditional = ' &&\n         '.join(ptr_names)
    outfile.write(MODULE_INITIALIZATION_CHECK_FUNCTION %
                  (PosixStubWriter.IsInitializedName(
                      self.module_name), initialization_conditional))
    outfile.write(MODULE_INITIALIZE_START %
                  PosixStubWriter.InitializeModuleName(self.module_name))
    for sig in self.signatures:
      outfile.write(
          STUB_POINTER_INITIALIZER % {
              'name': sig['name'],
              'return_type': sig['return_type'],
              'parameters': ', '.join(sig['params']),
              'logging_function': self.logging_function
          })
    outfile.write(MODULE_INITIALIZE_END)
    outfile.write(MODULE_UNINITIALIZE_START %
                  PosixStubWriter.UninitializeModuleName(self.module_name))
    for sig in self.signatures:
      outfile.write('  %s_ptr = nullptr;\n' % sig['name'])
    outfile.write(MODULE_UNINITIALIZE_END)
def WriteModuleInitializeFunctions ( self , outfile ) : ptr_names = [ '%s_ptr' % sig [ 'name' ] for sig in self . signatures ] initialization_conditional = ' &&\n         ' . join ( ptr_names ) outfile . write ( MODULE_INITIALIZATION_CHECK_FUNCTION % ( PosixStubWriter . IsInitializedName ( self . module_name ) , initialization_conditional ) ) outfile . write ( MODULE_INITIALIZE_START % PosixStubWriter . InitializeModuleName ( self . module_name ) ) for sig in self . signatures : outfile . write ( STUB_POINTER_INITIALIZER % { 'name' : sig [ 'name' ] , 'return_type' : sig [ 'return_type' ] , 'parameters' : ', ' . join ( sig [ 'params' ] ) , 'logging_function' : self . logging_function } ) outfile . write ( MODULE_INITIALIZE_END ) outfile . write ( MODULE_UNINITIALIZE_START % PosixStubWriter . UninitializeModuleName ( self . module_name ) ) for sig in self . signatures : outfile . write ( '  %s_ptr = nullptr;\n' % sig [ 'name' ] ) outfile . write ( MODULE_UNINITIALIZE_END )
Write functions to initialize/query initlialization of the module.
Write functions to initialize / query initlialization of the module .
"""Write functions to initialize/query initlialization of the module.

    This creates 2 functions IsModuleInitialized and InitializeModule where
    "Module" is replaced with the module name, first letter capitalized.

    The InitializeModule function takes a handle that is retrieved from dlopen
    and attempts to assign each function pointer above via dlsym.

    The IsModuleInitialized returns true if none of the required functions
    pointers are nullptr.

    Args:
      outfile: The file handle to populate.
    """ # Construct the conditional expression to check the initialization of # all the function pointers above.  It should generate a conjunction # with each pointer on its own line, indented by six spaces to match # the indentation level of MODULE_INITIALIZATION_CHECK_FUNCTION. # Create function that initializes the module. # Create function that uninitializes the module (sets all pointers to # nullptr).
self
outfile
The file handle to populate.
The file handle to populate .