def constructFunction( self, functionName, dll, resultType=ctypes.c_int, argTypes=(), doc = None, argNames = (), extension = None, deprecated = False, module = None, ): """Core operation to create a new base ctypes function raises AttributeError if can't find the procedure... """ if extension == 'GL_VERSION_GL_1_1': extension = None if extension and not self.checkExtension( extension ): raise AttributeError( """Extension not available""" ) argTypes = [ self.finalArgType( t ) for t in argTypes ] if extension and not self.EXTENSIONS_USE_BASE_FUNCTIONS: # what about the VERSION values??? if self.checkExtension( extension ): pointer = self.getExtensionProcedure( as_8_bit(functionName) ) if pointer: func = self.functionTypeFor( dll )( resultType, *argTypes )( pointer ) else: raise AttributeError( """Extension %r available, but no pointer for function %r"""%(extension,functionName)) else: raise AttributeError( """No extension %r"""%(extension,)) else: func = ctypesloader.buildFunction( self.functionTypeFor( dll )( resultType, *argTypes ), functionName, dll, ) func.__doc__ = doc func.argNames = list(argNames or ()) func.__name__ = functionName func.DLL = dll func.extension = extension func.deprecated = deprecated func = self.wrapLogging( self.wrapContextCheck( self.errorChecking( func, dll ), dll, ) ) if MODULE_ANNOTATIONS: if not module: module = _find_module( ) if module: func.__module__ = module return func
def constructFunction(self, functionName, dll, resultType=ctypes.c_int, argTypes=(), doc=None, argNames=(), extension=None, deprecated=False, module=None, force_extension=False, error_checker=None): """Core operation to create a new base ctypes function raises AttributeError if can"t find the procedure... """ is_core = (not extension) or extension.split("_")[1] == "VERSION" if (not is_core) and not self.checkExtension(extension): raise AttributeError("""Extension not available""") argTypes = [self.finalArgType(t) for t in argTypes] if force_extension or ((not is_core) and (not self.EXTENSIONS_USE_BASE_FUNCTIONS)): # what about the VERSION values??? pointer = self.getExtensionProcedure(as_8_bit(functionName)) if pointer: func = self.functionTypeFor(dll)(resultType, *argTypes)(pointer) else: raise AttributeError( f"Extension {extension!r} available, but no pointer for function {functionName!r}" ) else: func = ctypesloader.buildFunction( self.functionTypeFor(dll)(resultType, *argTypes), functionName, dll) func.__doc__ = doc func.argNames = list(argNames or ()) func.__name__ = functionName func.DLL = dll func.extension = extension func.deprecated = deprecated func = self.wrapLogging( self.wrapContextCheck( self.errorChecking(func, dll, error_checker=error_checker), dll)) if MODULE_ANNOTATIONS: if not module: module = _find_module() if module: func.__module__ = module return func
def constructFunction( self, functionName, dll, resultType=ctypes.c_int, argTypes=(), doc = None, argNames = (), extension = None, ): """Core operation to create a new base ctypes function raises AttributeError if can't find the procedure... """ if extension and not self.checkExtension( extension ): raise AttributeError( """Extension not available""" ) if extension and not self.EXTENSIONS_USE_BASE_FUNCTIONS: # what about the VERSION values??? if self.checkExtension( extension ): pointer = self.getExtensionProcedure( functionName ) if pointer: func = self.functionTypeFor( dll )( resultType, *argTypes )( pointer ) else: AttributeError( """Extension %r available, but no pointer for function %r"""%(extension,functionName)) else: raise AttributeError( """No extension %r"""%(extension,)) else: func = ctypesloader.buildFunction( self.functionTypeFor( dll )( resultType, *argTypes ), functionName, dll, ) func.__doc__ = doc func.argNames = list(argNames or ()) func.__name__ = functionName func.DLL = dll func.extension = extension func = self.wrapLogging( self.errorChecking( func )) return func
def constructFunction( self, functionName, dll, resultType=ctypes.c_int, argTypes=(), doc=None, argNames=(), extension=None, ): """Core operation to create a new base ctypes function raises AttributeError if can't find the procedure... """ if extension and not self.checkExtension(extension): raise AttributeError("""Extension not available""") if extension and not self.EXTENSIONS_USE_BASE_FUNCTIONS: # what about the VERSION values??? if self.checkExtension(extension): pointer = self.getExtensionProcedure(functionName) if pointer: func = self.functionTypeFor(dll)(resultType, *argTypes)(pointer) else: AttributeError( """Extension %r available, but no pointer for function %r""" % (extension, functionName)) else: raise AttributeError("""No extension %r""" % (extension, )) else: func = ctypesloader.buildFunction( self.functionTypeFor(dll)(resultType, *argTypes), functionName, dll, ) func.__doc__ = doc func.argNames = list(argNames or ()) func.__name__ = functionName func.DLL = dll func.extension = extension func = self.wrapLogging(self.errorChecking(func)) return func