OpenGL.converters
Implementations for common converter types
Classes
class CallFuncPyConverter(
PyConverter
):
class CConverter(
Converter
):
Converter sub-class for use in Wrapper.cConverters
This class just defines the interface for a cConverter-style
Converter object
__call__(
self
,
pyArgs
,
index
,
baseOperation
)
Calculate C-compatible Python object from Python arguments
- pyArgs
- set of Python argument objects converted by pyConverters from the incoming arguments
- index
- our index in baseOperation.cConverters
- baseOperation
- the Wrapper object which we are supporting
Base class for Converter types
Converter objects are callable objects used with the
OpenGL.wrapper.Wrapper class to simplify the wrapping
of functions by collecting commonly used functionality
into a reusable function.
Each Converter has two (class) attributes:
- argNames
- list of argument names for initialisation
- indexLookups
- set of (indexname, argName,methodName) values to lookup on wrapper. These allow us to use argument-name references to refer to which arguments to use when processing (prevents the need to revise pointers when we change the API for a function).
Converters can be any of the Wrapper API helper functions,
so the callable interface can vary among Converter classes.
class DefaultCConverter(
CConverter
):
NULL or Default CConverter, returns same-named Python argument
Used primarily to allow for specifying a converter that explicitly
says "use the default behaviour". This is *not* a finalise-ing
converter, it is passed in the index explicitly and just retrieves
that index from pyArgs when called.
Raises informative errors if the index cannot be resolved in pyArgs
class getPyArgsName(
CConverter
):
class Output(
CConverter
):
CConverter generating static-size typed output arrays
Produces an output array of given type (arrayType) and
size using self.lookup() to determine the size of the
array to be produced, where the lookup function is passed
as an initialisation argument.
Provides also:
oldStyleReturn( ... ) for use in the default case of
PyOpenGL compatability mode, where result arrays of
size (1,) are returned as scalar values.
arrayType
index
inIndex
outIndex
size
class OutputOrInput(
Output
):
class PyConverter(
Converter
):
Converter sub-class for use in Wrapper.pyConverters
This class just defines the interface for a pyConverter-style
Converter object
class returnCArgument(
ReturnValues
):
class returnPyArgument(
ReturnValues
):
class ReturnValues(
Converter
):
Converter sub-class for use as Wrapper.returnValues
This class just defines the interface for a returnValues-style
Converter object
__call__(
self
,
result
,
baseOperation
,
pyArgs
,
cArgs
)
Return a final value to the caller
- result
- the raw ctypes result value
- baseOperation
- the Wrapper object which we are supporting
- pyArgs
- the set of Python arguments produced by pyConverters
- cArgs
- the set of C-compatible arguments produced by CConverter
return the Python object for the final result
class SizedOutput(
Output
):
Output generating dynamically-sized typed output arrays
Takes an extra parameter "specifier", which is the name of
a Python argument to be passed to the lookup function in order
to determine the appropriate size for the output array.
arrayType
index
lookup
specifier
class SizedOutputOrInput(
SizedOutput
):
class StringLengths(
CConverter
):
CConverter for processing array-of-pointers-to-strings data-type
Converter is a CConverter for the array-of-lengths for a
array-of-pointers-to-strings data-type used to pass a set
of code fragments to the GLSL compiler.
Provides also:
- stringArray
- PyConverter callable ensuring list-of-strings format for the python argument
- stringArrayForC
- CResolver converting the array to POINTER(c_char_p) format for passing to C
- totalCount
- CConverter callable giving count of string pointers (that is, length of the pointer array)