def setInputArraySizeType( baseOperation, size, type, argName=0 ): """Decorate function with vector-handling code for a single argument if OpenGL.ERROR_ON_COPY is False, then we return the named argument, converting to the passed array type, optionally checking that the array matches size. if OpenGL.ERROR_ON_COPY is True, then we will dramatically simplify this function, only wrapping if size is True, i.e. only wrapping if we intend to do a size check on the array. """ function = wrapper.wrapper( baseOperation ) if not hasattr( function, 'returnValues' ): if isinstance( argName, str): function.setReturnValues( converters.returnPyArgument(argName) ) else: raise TypeError( """Argname should be a string/unicode: %s"""%(type(argName)) ) if size is not None: function.setPyConverter( argName, asArrayTypeSize(type, size) ) else: function.setPyConverter( argName, asArrayType(type) ) function.setCConverter( argName, converters.getPyArgsName( argName ) ) return function
def wrapPointerFunction( name, baseFunction, glType, arrayType,startArgs, defaultSize ): """Wrap the given pointer-setting function""" function= wrapper.wrapper( baseFunction ) if 'ptr' in baseFunction.argNames: pointer_name = 'ptr' else: pointer_name = 'pointer' assert not getattr( function, 'pyConverters', None ), """Reusing wrappers?""" if arrayType: arrayModuleType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[ glType ] function.setPyConverter( pointer_name, arrays.asArrayType(arrayModuleType) ) else: function.setPyConverter( pointer_name, arrays.AsArrayOfType(pointer_name,'type') ) function.setCConverter( pointer_name, converters.getPyArgsName( pointer_name ) ) if 'size' in function.argNames: function.setPyConverter( 'size' ) function.setCConverter( 'size', arrays.arraySizeOfFirstType(arrayModuleType,defaultSize) ) if 'type' in function.argNames: function.setPyConverter( 'type' ) function.setCConverter( 'type', glType ) if 'stride' in function.argNames: function.setPyConverter( 'stride' ) function.setCConverter( 'stride', 0 ) function.setStoreValues( arrays.storePointerType( pointer_name, arrayType ) ) function.setReturnValues( wrapper.returnPyArgument( pointer_name ) ) return name,function
def setInputArraySizeType( baseOperation, size, type, argName=0 ): """Decorate function with vector-handling code for a single argument if OpenGL.ERROR_ON_COPY is False, then we return the named argument, converting to the passed array type, optionally checking that the array matches size. if OpenGL.ERROR_ON_COPY is True, then we will dramatically simplify this function, only wrapping if size is True, i.e. only wrapping if we intend to do a size check on the array. """ function = wrapper.wrapper( baseOperation ) if not hasattr( function, 'returnValues' ): if isinstance( argName, (str,unicode)): function.setReturnValues( converters.returnPyArgument(argName) ) else: raise TypeError( """Argname should be a string/unicode: %s"""%(type(argName)) ) if size is not None: function.setPyConverter( argName, asArrayTypeSize(type, size) ) else: function.setPyConverter( argName, asArrayType(type) ) function.setCConverter( argName, converters.getPyArgsName( argName ) ) return function
def wrapPointerFunction(name, baseFunction, glType, arrayType,startArgs, defaultSize): """Wrap the given pointer-setting function""" function= wrapper.wrapper(baseFunction) if "ptr" in baseFunction.argNames: pointer_name = "ptr" else: pointer_name = "pointer" assert not getattr(function, "pyConverters", None), """Reusing wrappers?""" if arrayType: arrayModuleType = arraydatatype.GL_CONSTANT_TO_ARRAY_TYPE[ glType ] function.setPyConverter(pointer_name, arrayhelpers.asArrayType(arrayModuleType)) else: function.setPyConverter(pointer_name, arrayhelpers.AsArrayOfType(pointer_name,"type")) function.setCConverter(pointer_name, converters.getPyArgsName(pointer_name)) if "size" in function.argNames: function.setPyConverter("size") function.setCConverter("size", arrayhelpers.arraySizeOfFirstType(arrayModuleType,defaultSize)) if "type" in function.argNames: function.setPyConverter("type") function.setCConverter("type", glType) if "stride" in function.argNames: function.setPyConverter("stride") function.setCConverter("stride", 0) function.setStoreValues(arrayhelpers.storePointerType(pointer_name, arrayType)) function.setReturnValues(wrapper.returnPyArgument(pointer_name)) return name,function
def setInputArraySizeType( baseOperation, size, type, argName=0 ): """Decorate function with vector-handling code for a single argument This assumes *no* argument expansion, i.e. a 1:1 correspondence... """ function = wrapper.wrapper( baseOperation ) if not hasattr( function, 'returnValues' ): function.setReturnValues( returnPointer ) if size is not None: function.setPyConverter( argName, asArrayTypeSize(type, size) ) else: function.setPyConverter( argName, asArrayType(type) ) function.setCConverter( argName, converters.getPyArgsName( argName ) ) return function
def setInputArraySizeType(baseOperation, size, type, argName=0): """Decorate function with vector-handling code for a single argument if OpenGL.ERROR_ON_COPY is False, then we return the named argument, converting to the passed array type, optionally checking that the array matches size. if OpenGL.ERROR_ON_COPY is True, then we will dramatically simplify this function, only wrapping if size is True, i.e. only wrapping if we intend to do a size check on the array. """ if size is not None: function = wrapper.wrapper(baseOperation) # return value is always the source array... function.setPyConverter(argName, asArrayTypeSize(type, size)) function.setCConverter(argName, converters.getPyArgsName(argName)) else: function = baseOperation return function
def setInputArraySizeType( baseOperation, size, type, argName=0 ): """Decorate function with vector-handling code for a single argument if OpenGL.ERROR_ON_COPY is False, then we return the named argument, converting to the passed array type, optionally checking that the array matches size. if OpenGL.ERROR_ON_COPY is True, then we will dramatically simplify this function, only wrapping if size is True, i.e. only wrapping if we intend to do a size check on the array. """ if size is not None: function = wrapper.wrapper( baseOperation ) # return value is always the source array... function.setPyConverter( argName, asArrayTypeSize(type, size) ) function.setCConverter( argName, converters.getPyArgsName( argName ) ) else: function = baseOperation return function