symbian-qemu-0.9.1-12/python-2.6.1/Tools/bgen/bgen/bgenStackBuffer.py
author Martin Trojer <martin.trojer@nokia.com>
Mon, 09 Nov 2009 09:51:45 +0000
changeset 18 cb29cd53a788
parent 1 2fb8b9db1c86
permissions -rw-r--r--
Documentation edits, addition of e32test wiki page.

"""Buffers allocated on the stack."""


from bgenBuffer import FixedInputBufferType, FixedOutputBufferType


class StackOutputBufferType(FixedOutputBufferType):

    """Fixed output buffer allocated on the stack -- passed as (buffer, size).

    Instantiate with the buffer size as parameter.
    """

    def passOutput(self, name):
        return "%s__out__, %s" % (name, self.size)


class VarStackOutputBufferType(StackOutputBufferType):

    """Output buffer allocated on the stack -- passed as (buffer, &size).

    Instantiate with the buffer size as parameter.
    """

    def getSizeDeclarations(self, name):
        return []

    def getAuxDeclarations(self, name):
        return ["int %s__len__ = %s" % (name, self.size)]

    def passOutput(self, name):
        return "%s__out__, &%s__len__" % (name, name)

    def mkvalueArgs(self, name):
        return "%s__out__, (int)%s__len__" % (name, name)


class VarVarStackOutputBufferType(VarStackOutputBufferType):

    """Output buffer allocated on the stack -- passed as (buffer, size, &size).

    Instantiate with the buffer size as parameter.
    """

    def passOutput(self, name):
        return "%s__out__, %s__len__, &%s__len__" % (name, name, name)


class ReturnVarStackOutputBufferType(VarStackOutputBufferType):

    """Output buffer allocated on the stack -- passed as (buffer, size) -> size.

    Instantiate with the buffer size as parameter.
    The function's return value is the size.
    (XXX Should have a way to suppress returning it separately, too.)
    """

    def passOutput(self, name):
        return "%s__out__, %s__len__" % (name, name)

    def mkvalueArgs(self, name):
        return "%s__out__, (int)_rv" % name