def Generate(self): """Generates a Code object with the schema for the entire namespace. """ c = Code() (c.Append(self._GetHeader(sys.argv[0], self._namespace.name)) .Append()) self._AppendInterfaceObject(c) c.Append() c.Sblock('%s.prototype = {' % self._interface) for function in self._namespace.functions.values(): self._AppendFunction(c, function) c.TrimTrailingNewlines() c.Eblock('};') c.Append() for event in self._namespace.events.values(): self._AppendEvent(c, event) c.TrimTrailingNewlines() return c
def Generate(self): """Generates a Code object with the schema for the entire namespace. """ c = Code() # /abs/path/src/tools/json_schema_compiler/ script_dir = os.path.dirname(os.path.abspath(__file__)) # /abs/path/src/ src_root = os.path.normpath(os.path.join(script_dir, '..', '..')) # tools/json_schema_compiler/ src_to_script = os.path.relpath(script_dir, src_root) # tools/json_schema_compiler/compiler.py compiler_path = os.path.join(src_to_script, 'compiler.py') (c.Append(self._GetHeader(compiler_path, self._namespace.name)) .Append()) self._AppendNamespaceObject(c) for js_type in self._namespace.types.values(): self._AppendType(c, js_type) for prop in self._namespace.properties.values(): self._AppendProperty(c, prop) for function in self._namespace.functions.values(): self._AppendFunction(c, function) for event in self._namespace.events.values(): self._AppendEvent(c, event) c.TrimTrailingNewlines() return c
def Generate(self): """Generates a Code object with the schema for the entire namespace. """ c = Code() (c.Append(self._GetHeader(sys.argv[0], self._namespace.name)).Append()) c.Cblock(self._GenerateNamespaceObject()) for js_type in self._namespace.types.values(): c.Cblock(self._GenerateType(js_type)) for function in self._namespace.functions.values(): c.Cblock(self._GenerateFunction(function)) for event in self._namespace.events.values(): c.Cblock(self._GenerateEvent(event)) c.TrimTrailingNewlines() return c
def Generate(self): """Generates a Code object with the schema for the entire namespace. """ c = Code() (c.Append(self._GetHeader(sys.argv[0], self._namespace.name)).Append()) self._AppendNamespaceObject(c) for js_type in self._namespace.types.values(): self._AppendType(c, js_type) for function in self._namespace.functions.values(): self._AppendFunction(c, function) for event in self._namespace.events.values(): self._AppendEvent(c, event) c.TrimTrailingNewlines() return c