Skip to content
This repository
tree: 3b66047465
Fetching contributors…

Cannot retrieve contributors at this time

file 152 lines (117 sloc) 5.403 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
#!/usr/bin/python

class Api:

  def __init__(self):

    self.functions = []
    self.typedefs = []
    self.enums = []
    self.variables = []
    self.conditional = ''

  def add(self, item):

    if isinstance(item, Function):
      self.functions.append(item)
    elif isinstance(item, Typedef):
      self.typedefs.append(item)
    elif isinstance(item, Enum):
      self.enums.append(item)
    elif isinstance(item, Parameter):
      self.variables.append(item)
    else:
      raise TypeError, 'Unsupported Api type'

class Function:

  def __init__(self, name = ''):

    self.name = name
    self.ret = None
    self.parameters = []
    self.version = ''
    self.deprecated = ''
    self.category = ''
    self.public = True
    self.trace = True # Include in text trace
    self.play = True # Playback supported

  def add(self, parameter):

    if isinstance(parameter, Parameter):
      self.parameters.append(parameter)
    else:
      raise TypeError, 'Invalid Parameter type'

class Typedef:

  def __init__(self, name = '', type = ''):

    self.name = name
    self.type = type
    self.function = ''
    self.parameters = []
    self.version = ''
    self.deprecated = ''
    self.category = ''

  def add(self, parameter):

    if isinstance(parameter, Parameter):
      self.parameters.append(parameter)
    else:
      raise TypeError, 'Invalid Parameter type'

class Return:

  def __init__(self, type = '', default = '', cast = None, binary = False, size = None, maxSize = None, intercept = None, trace = True, play = True, filter = None):

    self.type = type # Type string, e.g. int
    self.default = default # Default value, e.g. 0
    self.cast = cast # Cast for trace and APIC purposes, e.g. void * -> char *
    self.binary = binary # Always treat as binary for trace purposes (always base64 encode)
    self.size = size # Array size expression, via helper functions etc
    self.maxSize = maxSize # Maximum array size
    self.intercept = intercept # Intercept the value
    self.trace = trace # Include in text trace
    self.play = play # Include in playback
    self.filter = filter # Filtering function

class Parameter:

  def __init__(self, name = '', type = '', default = '', cast = None, binary = False, size = None, maxSize = None, trace = True, play = True, filter = None, regalLog = None):

    self.name = name # Parameter name string, e.g. foo
    self.type = type # Type string, e.g. int
    self.default = default # Default value, e.g. 0
    self.cast = cast # Cast for trace and APIC purposes, e.g. void * -> char *
    self.binary = binary # Always treat as binary for trace purposes (always base64 encode)
    self.size = size # Array size expression, via helper functions etc
    self.maxSize = maxSize # Maximum array size
    self.input = True # Input parameter?
    self.output = False # Output parameter?
    self.trace = trace # Include in text trace
    self.play = play # Include in playback
    self.filter = filter # Filtering function
    self.regalLog = regalLog # Function for Regal logging purposes

def Input(name = '', type = '', default = '', cast = None, binary = False, size = None, maxSize = None, lookup = None, intercept = None, trace = True, play = True, filter = None, regalLog = None):

  parameter = Parameter(name, type, default, cast, binary, size, maxSize, trace, play, filter, regalLog)
  parameter.input = True
  parameter.output = False
  parameter.lookup = lookup
  parameter.intercept = intercept # Intercept the value
  return parameter

def Output(name = '', type = '', default = '', cast = None, binary = False, size = None, maxSize = None, intercept = None, trace = True, play = True, filter = None, regalLog = None):

  parameter = Parameter(name, type, default, cast, binary, size, maxSize, trace, play, filter, regalLog)
  parameter.input = False
  parameter.output = True
  parameter.intercept = intercept # Intercept the value
  return parameter

def InputOutput(name = '', type = '', default = '', cast = None, binary = False, size = None, maxSize = None, lookup = None, intercept = None, trace = True, play = True, filter = None, regalLog = None):

  parameter = Parameter(name, type, default, cast, binary, size, maxSize, trace, play, filter, regalLog)
  parameter.input = True
  parameter.output = True
  parameter.lookup = None
  parameter.intercept = None # Intercept the value
  return parameter

class Enum:

  def __init__(self, name = ''):

    self.name = name
    self.enumerants = []
    self.version = ''
    self.deprecated = ''
    self.category = ''
    self.default = None

  def add(self, enumerant):

    if isinstance(enumerant, Enumerant):
      self.enumerants.append(enumerant)
    else:
      raise TypeError, 'Invalid Enumerant type'

class Enumerant:

  def __init__(self, name = '', value = '', category = ''):

    self.name = name
    self.value = value
    self.version = ''
    self.deprecated = ''
    self.category = category
    self.public = True
Something went wrong with that request. Please try again.