def __init__(self, objects, interface): #: list of header names self.headers = [] #: odict of babbisch objects. self.objects = objects #: Dictionary containing the user-defined YAML interface. self.interface = interface #: list of script functions self.scripts = [] self.load_scripts() # load 'em #: Dictionary mapping tag types to artificial wrapper (ooc) names. self.artificial = {} #: Dictionary mapping entity tags to MemberInfo instances. self.methods = {} #: Dictionay mapping entity tags to dictionaries mapping property names to MemberInfo instances. self.properties = defaultdict(dict) #: odict {name: codegen} of artificial wrappers getting merged in `run` self._codegens = odict() #: odict {name: codegen} of *all* codegens. self.codegens = odict() # fill in all primitive types self.create_primitives() #: list of all function names whose return codes should be checked self.checked_functions = set() # do the settings yay oo.apply_settings(self)
def make_check_func(errors): func = Function(ERROR_CHECKING_FUNCTION, args=odict([('code', 'Int')]), rettype='Int') func.code.extend([ 'if(code != 0) {', INDENT, 'Failure new(match(code) {', INDENT ]) for error in errors: func.code.append('case %s => "%s"' % (error, error)) func.code.extend(['case => code toString()', DEDENT, '}) throw()', DEDENT, '}', 'return code']) return func
def __init__(self, name, modifiers=None, args=None, rettype=None, code=None): if modifiers is None: modifiers = [] if args is None: args = odict() if code is None: code = [] suffix = '' if '~' in name: name, suffix = [i.strip() for i in name.split('~', 1)] self.name = name self.modifiers = modifiers self.arguments = args self.rettype = rettype self.code = code self.suffix = suffix self.varargs = False
def main(): interface = None try: filename = sys.argv[1] except IndexError: print 'Usage: babbisch-ooc interface.yaml' return 1 with open(filename, 'r') as f: interface = yaml.load(f) # load all objects objects = odict() for filename in interface.get('Files', ()): with open(filename, 'r') as f: objects.update(json.load(f)) # create an oo client client = OOClient(objects, interface) print client.run()
def __init__(self, name, modifiers=None): self.name = name self.values = odict() if modifiers is None: modifiers = [] self.modifiers = modifiers
def make_check_exception(): cls = Class('Failure', 'Exception') init = Method('init~withCode', args=odict([('code', 'String')])) init.code.append('super(code)') cls.add_member(init) return cls