Ejemplo n.º 1
0
def paramCastFormatCode(parameter, types = typesBasic):

  cType = paramCast(parameter)

  # Find Type using parameter cast or parameter type.
  if cType:
    aType = findType(cType, types)
  else:
    pType = parameter.type.strip()
    aType = findType(pType, types)
  if not aType:
    return None

  format = None
  if aType.cast and len(aType.cast.strip()):
    # If Type has a cast, use that cast's Type format.
    castType = findType(aType.cast, types)
    if castType and castType.format and len(castType.format.strip()):
      format = castType.format.strip()
  elif cType:
    # If parameter has a cast, use that cast's Type format.
    if aType.format and len(aType.format.strip()):
      format = aType.format.strip()

  return format
Ejemplo n.º 2
0
def paramProxyFormatCode(parameter, types=typesBasic):

    cType = paramCast(parameter)

    # Find Type using parameter cast or parameter type.
    if cType:
        aType = findType(cType, types)
    else:
        pType = parameter.type.strip()
        aType = findType(pType, types)
    if not aType:
        return None

    format = None
    if aType.proxyType and len(aType.proxyType.strip()):
        # If Type has a proxyType, use that proxyType's Type format.
        if cType:
            mType = aType.regexc.match(cType).group(0)
        else:
            mType = aType.regexc.match(pType).group(0)
        proxyType = findType(
            mType.replace(typeStrip(mType), aType.proxyType.strip()), types)
        if proxyType and proxyType.format and len(proxyType.format.strip()):
            format = proxyType.format.strip()
    else:
        # Use Type format.
        if aType.format and len(aType.format.strip()):
            format = aType.format.strip()

    return format
Ejemplo n.º 3
0
def paramProxyTypeCode(parameter, types=typesBasic):

    cType = paramCast(parameter)

    # Find Type using parameter cast or parameter type.
    if cType:
        aType = findType(cType, types)
    else:
        pType = parameter.type.strip()
        aType = findType(pType, types)
    if not aType:
        return ''

    code = ''
    if aType.proxyType and len(aType.proxyType.strip()):
        # If Type has a proxyType, use that to derive a proxy type.
        if cType:
            mType = aType.regexc.match(cType).group(0)
        else:
            mType = aType.regexc.match(pType).group(0)
        code = mType.replace(typeStrip(mType), aType.proxyType.strip())
    elif cType:
        # If parameter has a cast, use that as proxy type.
        code = cType

    return code
Ejemplo n.º 4
0
def paramBaseTypeCode(parameter, types=typesBasic):

    cType = paramCast(parameter)

    # Find Type using parameter cast or parameter type.
    if cType:
        aType = findType(cType, types)
    else:
        pType = parameter.type.strip()
        aType = findType(pType, types)
    if not aType:
        return ''

    code = ''
    if aType.baseType and len(aType.baseType.strip()):
        # If Type has a baseType, use that as base type.
        code = aType.baseType.strip()
    elif cType:
        # If parameter has a cast, use that to derive a base type.
        code = typeStrip(cType)
    else:
        # Use parameter type to derive a base type.
        code = typeStrip(pType)

    # Special case for char **.
    if cType:
        if reCharPtrPtr.match(cType):
            return 'cgiArgs'
    else:
        if reCharPtrPtr.match(pType):
            return 'cgiArgs'

    return code
Ejemplo n.º 5
0
def paramProxyFormatCode(parameter, types = typesBasic):

  cType = paramCast(parameter)

  # Find Type using parameter cast or parameter type.
  if cType:
    aType = findType(cType, types)
  else:
    pType = parameter.type.strip()
    aType = findType(pType, types)
  if not aType:
    return None

  format = None
  if aType.proxyType and len(aType.proxyType.strip()):
    # If Type has a proxyType, use that proxyType's Type format.
    if cType:
      mType = aType.regexc.match(cType).group(0)
    else:
      mType = aType.regexc.match(pType).group(0)
    proxyType = findType(mType.replace(typeStrip(mType), aType.proxyType.strip()), types)
    if proxyType and proxyType.format and len(proxyType.format.strip()):
      format = proxyType.format.strip()
  else:
    # Use Type format.
    if aType.format and len(aType.format.strip()):
      format = aType.format.strip()

  return format
Ejemplo n.º 6
0
def paramBaseTypeCode(parameter, types = typesBasic):

  cType = paramCast(parameter)

  # Find Type using parameter cast or parameter type.
  if cType:
    aType = findType(cType, types)
  else:
    pType = parameter.type.strip()
    aType = findType(pType, types)
  if not aType:
    return ''

  code = ''
  if aType.baseType and len(aType.baseType.strip()):
    # If Type has a baseType, use that as base type.
    code = aType.baseType.strip()
  elif cType:
    # If parameter has a cast, use that to derive a base type.
    code = typeStrip(cType)
  else:
    # Use parameter type to derive a base type.
    code = typeStrip(pType)

  # Special case for char **.
  if cType:
    if reCharPtrPtr.match(cType):
      return 'cgiArgs'
  else:
    if reCharPtrPtr.match(pType):
      return 'cgiArgs'

  return code
Ejemplo n.º 7
0
def paramCastFormatCode(parameter, types=typesBasic):

    cType = paramCast(parameter)

    # Find Type using parameter cast or parameter type.
    if cType:
        aType = findType(cType, types)
    else:
        pType = parameter.type.strip()
        aType = findType(pType, types)
    if not aType:
        return None

    format = None
    if aType.cast and len(aType.cast.strip()):
        # If Type has a cast, use that cast's Type format.
        castType = findType(aType.cast, types)
        if castType and castType.format and len(castType.format.strip()):
            format = castType.format.strip()
    elif cType:
        # If parameter has a cast, use that cast's Type format.
        if aType.format and len(aType.format.strip()):
            format = aType.format.strip()

    return format
Ejemplo n.º 8
0
def paramProxyTypeCode(parameter, types = typesBasic):

  cType = paramCast(parameter)

  # Find Type using parameter cast or parameter type.
  if cType:
    aType = findType(cType, types)
  else:
    pType = parameter.type.strip()
    aType = findType(pType, types)
  if not aType:
    return ''

  code = ''
  if aType.proxyType and len(aType.proxyType.strip()):
    # If Type has a proxyType, use that to derive a proxy type.
    if cType:
      mType = aType.regexc.match(cType).group(0)
    else:
      mType = aType.regexc.match(pType).group(0)
    code = mType.replace(typeStrip(mType), aType.proxyType.strip())
  elif cType:
    # If parameter has a cast, use that as proxy type.
    code = cType

  return code
Ejemplo n.º 9
0
def paramProxyBaseTypeCode(parameter, types=typesBasic):

    cType = paramCast(parameter)

    # Find Type using parameter cast or parameter type.
    if cType:
        aType = findType(cType, types)
    else:
        pType = parameter.type.strip()
        aType = findType(pType, types)
    if not aType:
        return ''

    code = ''
    if aType.proxyType and len(aType.proxyType.strip()):
        # If Type has a proxyType, use that proxyType.
        if cType:
            mType = aType.regexc.match(cType).group(0)
        else:
            mType = aType.regexc.match(pType).group(0)
        proxyType = findType(
            mType.replace(typeStrip(mType), aType.proxyType.strip()), types)
        if proxyType:
            # If proxyType Type found, use that Type's baseType.
            code = proxyType.baseType.strip()
        else:
            # If proxyType Type not found, use proxyType to drive a base type.
            code = typeStrip(aType.proxyType)
    elif aType.baseType and len(aType.baseType.strip()):
        # If Type has a baseType, use that as a base type.
        code = aType.baseType.strip()
    elif cType:
        # If parameter has a cast, use that to derive a base type.
        code = typeStrip(cType)
    else:
        # Use parameter type to derive a base type.
        code = typeStrip(pType)

    # Special case for char **.
    if cType:
        if reCharPtrPtr.match(cType):
            return 'cgiArgs'
    else:
        if reCharPtrPtr.match(pType):
            return 'cgiArgs'

    # Special case for void *
    if cType:
        if reVoidPtr.match(cType):
            return cType
    else:
        if reVoidPtr.match(pType):
            return pType

    return code
Ejemplo n.º 10
0
def paramProxyBaseTypeCode(parameter, types = typesBasic):

  cType = paramCast(parameter)

  # Find Type using parameter cast or parameter type.
  if cType:
    aType = findType(cType, types)
  else:
    pType = parameter.type.strip()
    aType = findType(pType, types)
  if not aType:
    return ''

  code = ''
  if aType.proxyType and len(aType.proxyType.strip()):
    # If Type has a proxyType, use that proxyType.
    if cType:
      mType = aType.regexc.match(cType).group(0)
    else:
      mType = aType.regexc.match(pType).group(0)
    proxyType = findType(mType.replace(typeStrip(mType), aType.proxyType.strip()), types)
    if proxyType:
      # If proxyType Type found, use that Type's baseType.
      code = proxyType.baseType.strip()
    else:
      # If proxyType Type not found, use proxyType to drive a base type.
      code = typeStrip(aType.proxyType)
  elif aType.baseType and len(aType.baseType.strip()):
    # If Type has a baseType, use that as a base type.
    code = aType.baseType.strip()
  elif cType:
    # If parameter has a cast, use that to derive a base type.
    code = typeStrip(cType)
  else:
    # Use parameter type to derive a base type.
    code = typeStrip(pType)

  # Special case for char **.
  if cType:
    if reCharPtrPtr.match(cType):
      return 'cgiArgs'
  else:
    if reCharPtrPtr.match(pType):
      return 'cgiArgs'

  # Special case for void *
  if cType:
    if reVoidPtr.match(cType):
      return cType
  else:
    if reVoidPtr.match(pType):
      return pType

  return code
Ejemplo n.º 11
0
def paramCastTypeCode(parameter, types=typesBasic):

    cType = paramCast(parameter)

    # Find Type using parameter cast or parameter type.
    if cType:
        aType = findType(cType, types)
    else:
        pType = parameter.type.strip()
        aType = findType(pType, types)
    if not aType:
        return ''

    if aType.cast and len(aType.cast.strip()):
        # If Type has a cast, use that as cast.
        return '(%s) ' % aType.cast.strip()

    return ''
Ejemplo n.º 12
0
def paramCastTypeCode(parameter, types = typesBasic):

  cType = paramCast(parameter)

  # Find Type using parameter cast or parameter type.
  if cType:
    aType = findType(cType, types)
  else:
    pType = parameter.type.strip()
    aType = findType(pType, types)
  if not aType:
    return ''

  if aType.cast and len(aType.cast.strip()):
    # If Type has a cast, use that as cast.
    return '(%s) ' % aType.cast.strip()

  return ''
Ejemplo n.º 13
0
def paramInterceptTypeCode(parameter, types=typesBasic):

    if not getattr(parameter, 'intercept', None):
        return None

    aType = findType(parameter.type, types)
    if not aType:
        return None

    return aType
Ejemplo n.º 14
0
def paramInterceptTypeCode(parameter, types = typesBasic):

  if not getattr(parameter, 'intercept', None):
    return None

  aType = findType(parameter.type, types)
  if not aType:
    return None

  return aType
Ejemplo n.º 15
0
def paramTraceCastCode(parameter, types = typesBasic):

  cType = paramCast(parameter)

  # Find Type using parameter cast or parameter type.
  if cType:
    aType = findType(cType, types)
  else:
    pType = parameter.type.strip()
    aType = findType(pType, types)
  if not aType:
    return ''

  code = ''
  if aType.cast and len(aType.cast.strip()):
    # If Type has a cast, use that to derive a cast.
    if cType:
      mType = aType.regexc.match(cType).group(0)
    else:
      mType = aType.regexc.match(pType).group(0)
    code = '(%s) ' % mType.replace(typeStrip(mType), aType.cast.strip())
  elif cType:
    # If parameter has a cast, use that as cast.
    code = '(%s) ' % cType

  # Special handling for trace starts here.

  # Since trace uses format specification for casting, we do not need to explicitly cast.
  if cType:
    code = ''

  # Note: If we do not want to support a cast, set code to None.

  # Special handling for %c, %cs, %cu of non-pointer type.
  if aType.format and aType.format.find('%c') is not -1 and aType.dim == 0:
    if aType.format == '%cu':
      code = '(unsigned int) '
    else:
      code = '(int) '

  return code
Ejemplo n.º 16
0
def paramTraceCastCode(parameter, types=typesBasic):

    cType = paramCast(parameter)

    # Find Type using parameter cast or parameter type.
    if cType:
        aType = findType(cType, types)
    else:
        pType = parameter.type.strip()
        aType = findType(pType, types)
    if not aType:
        return ''

    code = ''
    if aType.cast and len(aType.cast.strip()):
        # If Type has a cast, use that to derive a cast.
        if cType:
            mType = aType.regexc.match(cType).group(0)
        else:
            mType = aType.regexc.match(pType).group(0)
        code = '(%s) ' % mType.replace(typeStrip(mType), aType.cast.strip())
    elif cType:
        # If parameter has a cast, use that as cast.
        code = '(%s) ' % cType

    # Special handling for trace starts here.

    # Since trace uses format specification for casting, we do not need to explicitly cast.
    if cType:
        code = ''

    # Note: If we do not want to support a cast, set code to None.

    # Special handling for %c, %cs, %cu of non-pointer type.
    if aType.format and aType.format.find('%c') is not -1 and aType.dim == 0:
        if aType.format == '%cu':
            code = '(unsigned int) '
        else:
            code = '(int) '

    return code
Ejemplo n.º 17
0
def paramFormatCode(parameter, types):

  # Find Type using parameter type.
  aType = findType(parameter.type, types)
  if not aType:
    return None

  format = None
  if aType.format and len(aType.format.strip()):
    format = aType.format.strip()

  return format
Ejemplo n.º 18
0
def paramFormatCode(parameter, types):

    # Find Type using parameter type.
    aType = findType(parameter.type, types)
    if not aType:
        return None

    format = None
    if aType.format and len(aType.format.strip()):
        format = aType.format.strip()

    return format
Ejemplo n.º 19
0
def paramDefaultCode(pType, types = typesBasic):

  # Check if Type has a default value.
  aType = findType(pType, types)
  if aType and aType.dim < 1 and aType.default and len(aType.default.strip()):
    return '%s' % aType.default.strip()

  rType = pType.strip()

  if rType.endswith('*'):
    return 'NULL'

  if rType in ['signed', 'signed int', 'int']:
    return '0'

  if rType in ['unsigned', 'unsigned int']:
    return '0u'

  return '(%s) 0' % rType
Ejemplo n.º 20
0
def paramDefaultCode(pType, types=typesBasic):

    # Check if Type has a default value.
    aType = findType(pType, types)
    if aType and aType.dim < 1 and aType.default and len(
            aType.default.strip()):
        return '%s' % aType.default.strip()

    rType = pType.strip()

    if rType.endswith('*'):
        return 'NULL'

    if rType in ['signed', 'signed int', 'int']:
        return '0'

    if rType in ['unsigned', 'unsigned int']:
        return '0u'

    return '(%s) 0' % rType
Ejemplo n.º 21
0
def paramDeclCode(parameter, types=typesBasic, size=None, name=None):

    pType = typeCode(parameter.type)
    aType = findType(pType, types)

    # Check max size for array.
    maxSize = parameter.maxSize
    if not maxSize:
        maxSize = size

    # Check for an integer size for array.
    intSize = None
    try:
        intSize = int(maxSize)
    except ValueError:
        pass

    # If no input <name>, use parameter name.
    if not name:
        name = parameter.name.strip()

    decl = None
    if aType.dim > 0 and pType[-1] == '*':
        # Array case.
        declType = pType[:-1]
        if intSize:
            # Use static array for integer sized array.
            decl = 'static %s%s[%d];' % (declType, name, intSize)
        else:
            # Use boost scoped_array for non-integer sized array.
            decl = 'boost::scoped_array<%s> %s(new %s[%s]);' % (
                declType.strip(), name, declType, maxSize)
    else:
        # Scalar case.
        decl = '%s%s;' % (pType, name)

    return decl
Ejemplo n.º 22
0
def paramDeclCode(parameter, types = typesBasic, size = None, name = None):

  pType = typeCode(parameter.type)
  aType = findType(pType, types)

  # Check max size for array.
  maxSize = parameter.maxSize
  if not maxSize:
    maxSize = size

  # Check for an integer size for array.
  intSize = None
  try:
    intSize = int(maxSize)
  except ValueError:
    pass

  # If no input <name>, use parameter name.
  if not name:
    name = parameter.name.strip()

  decl = None
  if aType.dim > 0 and pType[-1] == '*':
    # Array case.
    declType = pType[:-1]
    if intSize:
      # Use static array for integer sized array.
      decl = 'static %s%s[%d];' % (declType, name, intSize)
    else:
      # Use boost scoped_array for non-integer sized array.
      decl = 'boost::scoped_array<%s> %s(new %s[%s]);' % (declType.strip(), name, declType, maxSize)
  else:
    # Scalar case.
    decl = '%s%s;' % (pType, name)

  return decl
Ejemplo n.º 23
0
def paramTraceFormatCode(parameter, types=typesBasic):

    cType = paramCast(parameter)

    # Find Type using parameter cast or parameter type.
    if cType:
        aType = findType(cType, types)
    else:
        pType = parameter.type.strip()
        aType = findType(pType, types)
    if not aType:
        return None

    format = None
    if aType.cast and len(aType.cast.strip()):
        # If Type has a cast, use that cast's Type format.
        castType = findType(aType.cast, types)
        if castType and castType.format and len(castType.format.strip()):
            format = castType.format.strip()
    else:
        # Use Type format.
        if aType.format and len(aType.format.strip()):
            format = aType.format.strip()

    # Special handling for trace starts here.

    if not format:
        return None

    # Special handling for %c, %cs, %cu.
    # Handle as integer, strings or binary data
    #
    #   signed char         %c --------> %d         dim=0
    #   signed char         %cs -------> %d         ...
    #   unsigned char       %cu -------> %u
    #   signed char array   %c[] ------> %s         dim=1
    #   signed char array   %cs[] -----> %s         ...
    #   unsigned char array %cu[] -----> %s
    #   signed char array   %c[...] ---> %c[...]
    #   signed char array   %cs[...] --> %c[...]
    #   unsigned char array %cu[...] --> %c[...]
    #   [Undefined]                                 dim>1

    if format.find('%c') is not -1:

        # If it's a scalar, treat as integer
        if aType.dim == 0:
            if format == '%cu':
                return '%u'
            else:
                return '%d'

        # If it's an unsized array, treat as string
        # If it's binary and known size, treat as unsigned char array
        # otherwise char array.

        if aType.dim == 1:
            if not parameter.size:
                return '%s'
            if parameter.binary:
                return '%cu'
            else:
                return '%c'

        print 'Warning: %c not supported with dim > 1.'
        return None

    return format
Ejemplo n.º 24
0
def paramTraceFormatCode(parameter, types = typesBasic):

  cType = paramCast(parameter)

  # Find Type using parameter cast or parameter type.
  if cType:
    aType = findType(cType, types)
  else:
    pType = parameter.type.strip()
    aType = findType(pType, types)
  if not aType:
    return None

  format = None
  if aType.cast and len(aType.cast.strip()):
    # If Type has a cast, use that cast's Type format.
    castType = findType(aType.cast, types)
    if castType and castType.format and len(castType.format.strip()):
      format = castType.format.strip()
  else:
    # Use Type format.
    if aType.format and len(aType.format.strip()):
      format = aType.format.strip()

  # Special handling for trace starts here.

  if not format:
    return None

  # Special handling for %c, %cs, %cu.
  # Handle as integer, strings or binary data
  #
  #   signed char         %c --------> %d         dim=0
  #   signed char         %cs -------> %d         ...
  #   unsigned char       %cu -------> %u
  #   signed char array   %c[] ------> %s         dim=1
  #   signed char array   %cs[] -----> %s         ...
  #   unsigned char array %cu[] -----> %s
  #   signed char array   %c[...] ---> %c[...]
  #   signed char array   %cs[...] --> %c[...]
  #   unsigned char array %cu[...] --> %c[...]
  #   [Undefined]                                 dim>1

  if format.find('%c') is not -1:

    # If it's a scalar, treat as integer
    if aType.dim == 0:
      if format == '%cu':
        return '%u'
      else:
        return '%d'

    # If it's an unsized array, treat as string
    # If it's binary and known size, treat as unsigned char array
    # otherwise char array.

    if aType.dim == 1:
      if not parameter.size:
        return '%s'
      if parameter.binary:
        return '%cu'
      else:
        return '%c'

    print 'Warning: %c not supported with dim > 1.'
    return None

  return format
Ejemplo n.º 25
0
def paramSizeCode(parameter, types, parameters, ret = None):

  aType = findType(parameter.type, types) or findType(parameter.cast, types)
  if not aType:
    return None, None

  format = aType.format
  dim    = aType.dim

  # Parameters with no size expression

  sizeEx = parameter.size
  if not sizeEx:

    # Scalar case.
    if dim == 0:
      return '', ''

    # Special case for null-terminated char (regular/signed/unsigned) array.
    elif dim == 1 and format and format.find('%c') is not -1:
      return '', ''

    # Special case for null-terminated string array.
    elif dim == 1 and format == '%s':
      return '[]', ''

    else:
      return None, None

  # Parameters with size expression

  # Split by *

  if isinstance(sizeEx, int):
    sizeParameters = [sizeEx]
  else:
    sizeParameters = map(str.strip, sizeEx.strip().split('*'))

  sizeFormat = '%d' # Trace supports [], [%d] and [%ld] for arrays.
  code       = []

  for i in sizeParameters:

    # Check if i is an integer

    try:
      code.append('%s' % int(i))
      continue
    except ValueError:
      pass

#    # Check if i is a variable
#
#    if reVariable.match(i):
#      code.append(i)
#      continue

    # Check if i is a conditional expression: a ? b : c

    if reConditional.match(i):
      code.append('(%s)' % i)
      sizeFormat = '%ld'
      continue

    # Check if i is a helper function.
    sizeHelper = helperFuncCode(i)
    if sizeHelper == None:
      return None, None
    elif len(sizeHelper):
      code.append('(%s)' % sizeHelper)
      sizeFormat = '%ld'
      continue

    pFormat = None
    pDim    = None

    # Get format and dim for i.
    if i == 'ret':
      if not ret:
        return None, None
      pName = 'ret'
      rType = findType(ret.type, types)
      if not rType:
        return None, None
      pFormat = rType.format
      pDim    = rType.dim
    else:
      for j in range(len(parameters)):
        param = parameters[j]
        pName = paramNameCode(param.name, j)
        if i == pName:
          sType = findType(param.type, types)
          if not sType:
            return None, None
          pFormat = sType.format
          pDim    = sType.dim
          break

    if not pFormat or pDim is None:
      return None, None

    # Convert size format from %d to %ld.
    if pFormat == '%ld':
      sizeFormat = '%ld'

    if pDim == 0:
      code.append('%s' % i)
    elif pDim == 1:
      code.append('(*%s)' % i)
    else:
      return None, None

  return '[%s]' % sizeFormat, ' * '.join(code)
Ejemplo n.º 26
0
def paramSizeCode(parameter, types, parameters, ret=None):

    aType = findType(parameter.type, types) or findType(parameter.cast, types)
    if not aType:
        return None, None

    format = aType.format
    dim = aType.dim

    # Parameters with no size expression

    sizeEx = parameter.size
    if not sizeEx:

        # Scalar case.
        if dim == 0:
            return '', ''

        # Special case for null-terminated char (regular/signed/unsigned) array.
        elif dim == 1 and format and format.find('%c') is not -1:
            return '', ''

        # Special case for null-terminated string array.
        elif dim == 1 and format == '%s':
            return '[]', ''

        else:
            return None, None

    # Parameters with size expression

    # Split by *

    if isinstance(sizeEx, int):
        sizeParameters = [sizeEx]
    else:
        sizeParameters = map(str.strip, sizeEx.strip().split('*'))

    sizeFormat = '%d'  # Trace supports [], [%d] and [%ld] for arrays.
    code = []

    for i in sizeParameters:

        # Check if i is an integer

        try:
            code.append('%s' % int(i))
            continue
        except ValueError:
            pass

#    # Check if i is a variable
#
#    if reVariable.match(i):
#      code.append(i)
#      continue

# Check if i is a conditional expression: a ? b : c

        if reConditional.match(i):
            code.append('(%s)' % i)
            sizeFormat = '%ld'
            continue

        # Check if i is a helper function.
        sizeHelper = helperFuncCode(i)
        if sizeHelper == None:
            return None, None
        elif len(sizeHelper):
            code.append('(%s)' % sizeHelper)
            sizeFormat = '%ld'
            continue

        pFormat = None
        pDim = None

        # Get format and dim for i.
        if i == 'ret':
            if not ret:
                return None, None
            pName = 'ret'
            rType = findType(ret.type, types)
            if not rType:
                return None, None
            pFormat = rType.format
            pDim = rType.dim
        else:
            for j in range(len(parameters)):
                param = parameters[j]
                pName = paramNameCode(param.name, j)
                if i == pName:
                    sType = findType(param.type, types)
                    if not sType:
                        return None, None
                    pFormat = sType.format
                    pDim = sType.dim
                    break

        if not pFormat or pDim is None:
            return None, None

        # Convert size format from %d to %ld.
        if pFormat == '%ld':
            sizeFormat = '%ld'

        if pDim == 0:
            code.append('%s' % i)
        elif pDim == 1:
            code.append('(*%s)' % i)
        else:
            return None, None

    return '[%s]' % sizeFormat, ' * '.join(code)