Esempio n. 1
0
def apiDispatchFuncInitCode(apis, args, dispatchName, exclude=[], filter = lambda x : True):
  categoryPrev = None
  code = ''

  for api in apis:

    code += '\n'
    if api.name in cond:
      code += '#if %s\n' % cond[api.name]

    for function in api.functions:

      if not function.needsContext:
        continue

      if not filter(function):
        continue

      if getattr(function,'regalOnly',False)==True:
        continue

      if function.name in exclude or function.category in exclude:
        continue

      name   = function.name
      params = paramsDefaultCode(function.parameters, True)
      callParams = paramsNameCode(function.parameters)
      rType  = typeCode(function.ret.type)
      category  = getattr(function, 'category', None)
      version   = getattr(function, 'version', None)

      if category:
        category = category.replace('_DEPRECATED', '')
      elif version:
        category = version.replace('.', '_')
        category = 'GL_VERSION_' + category

      # Close prev category block.
      if categoryPrev and not (category == categoryPrev):
        code += '\n'

      # Begin new category block.
      if category and not (category == categoryPrev):
        code += '  // %s\n\n' % category

      categoryPrev = category

      code += '  tbl.%s = %s_%s;\n' % ( name, dispatchName, name )

    if api.name in cond:
      code += '#endif // %s\n' % cond[api.name]
    code += '\n'

  # Close pending if block.
  if categoryPrev:
    code += '\n'

  return code
def generateGMockFunctionApi(apis):
  for api in apis:
    if api.name != 'gl':
      continue

    for function in api.functions:
      if not function.needsContext:
        continue
      if getattr(function, 'regalOnly', False):
        continue
      if not function.category in [ 'GL_VERSION_1_0', 'GL_VERSION_1_1', 'GL_VERSION_2_0'] and \
         not function.name     in [ ]:
        continue

      yield dict(
          PREFIX="gmock_",
          NAME=function.name,
          RTYPE=typeCode(function.ret.type).strip(),
          PARAM_COUNT=len(function.parameters),
          PARAM_TYPES=paramsTypeCode(function.parameters, True),
          PARAM_NAMES=paramsNameCode(function.parameters),
          PARAM_TYPES_NAMES=paramsDefaultCode(function.parameters, True))
def generateGMockFunctionApi(apis):
  for api in apis:
    if api.name != 'gl':
      continue

    for function in api.functions:
      if not function.needsContext:
        continue
      if getattr(function, 'regalOnly', False):
        continue
      if (function.category not in functionCategoriesToMock and
          function.name not in explicitFunctionsToMock):
        continue

      yield dict(
          PREFIX="gmock_",
          NAME=function.name,
          RTYPE=typeCode(function.ret.type).strip(),
          PARAM_COUNT=len(function.parameters),
          PARAM_TYPES=paramsTypeCode(function.parameters, True),
          PARAM_NAMES=paramsNameCode(function.parameters),
          PARAM_TYPES_NAMES=paramsDefaultCode(function.parameters, True))
def apiDispatchFuncInitCode(apis, args, dispatchName, exclude=[], filter = lambda x : True, cond = None):

  if not cond:
    cond = condDefault

  categoryPrev = None
  code = ''

  for api in apis:

    code += '\n'
    if api.name in cond:
      code += '#if %s\n' % cond[api.name]

    for function in api.functions:

      if not function.needsContext:
        continue

      if not filter(function):
        continue

      if getattr(function,'regalOnly',False)==True:
        continue

      if function.name in exclude or function.category in exclude:
        continue

      name   = function.name
      params = paramsDefaultCode(function.parameters, True)
      callParams = paramsNameCode(function.parameters)
      rType  = typeCode(function.ret.type)
      category  = getattr(function, 'category', None)
      version   = getattr(function, 'version', None)

      if category:
        category = category.replace('_DEPRECATED', '')
      elif version:
        category = version.replace('.', '_')
        category = 'GL_VERSION_' + category

      # Close prev category block.
      if categoryPrev and not (category == categoryPrev):
        code += '\n'

      # Begin new category block.
      if category and not (category == categoryPrev):
        code += '  // %s\n\n' % category

      categoryPrev = category

      if dispatchName!=None:
        code += '  tbl.%s = %s_%s;\n' % ( name, dispatchName, name )
      else:
        code += '    tbl.%s = %s;\n' % ( name, name )

    if api.name in cond:
      code += '#endif // %s\n' % cond[api.name]
    code += '\n'

  # Close pending if block.
  if categoryPrev:
    code += '\n'

  return code