def generate_body(package): result = [ 'pragma Style_Checks (Off);', 'pragma Warnings (Off, "*is already use-visible*");', 'pragma Warnings (Off, "*redundant with clause in body*");', '', 'with Interfaces.C; use Interfaces.C;', 'pragma Unreferenced (Interfaces.C);', 'with Interfaces.C.Strings; use Interfaces.C.Strings;' 'pragma Unreferenced (Interfaces.C.Strings);', '', 'package body {} is'.format(fmt_name(package.name)), '' ] for elt in package.elements: if not is_wrapper_needed(elt): continue # In that case, we do not expose the C declaration. The user # should use the wrappers. include(get_prototype(elt, decl=True), result, indent=True) def callback(tr, subp): include(tr.wrapper_body(subp), result, indent=True) result.append('') transform_fixpoint(elt, callback) result.append('end {};'.format(fmt_name(package.name))) return result
def decodeNumber16(self): bstr = self.body c = 0 i = 0 while i < len(bstr): ca = bstr[i] if utils.include(ca, "0", "9") or utils.include(ca, "a", "f"): self.board.cell[c] = int(ca, 16) elif ca == "-": self.board.cell[c] = int(bstr[i + 1:i + 1 + 2], 16) i += 2 elif ca == "+": self.board.cell[c] = int(bstr[i + 1:i + 1 + 3], 16) i += 3 elif ca == "=": self.board.cell[c] = int(bstr[i + 1:i + 1 + 3], 16) + 4096 i += 3 elif ca == "%": self.board.cell[c] = int(bstr[i + 1:i + 1 + 3], 16) + 8192 i += 3 elif ca == ".": self.board.cell[c] = -2 elif ca >= "g" and ca <= "z": c += int(ca, 36) - 16 c += 1 if c >= len(self.board.cell): break i += 1 self.body = self.body[i + 1:]
def decodeArrowNumber16(self): c = 0 i = 0 bstr = self.body while i < len(bstr): ca = bstr[i] if utils.include(ca, "0", "4"): ca1 = bstr[i + 1] self.board.cell[c] = (int(ca, 16), int(ca1, 16) if ca1 != "." else -2) i += 1 elif utils.include(ca, "5", "9"): self.board.cell[c] = (int(ca, 16) - 5, int(bstr[i + 1:i + 1 + 2], 16)) i += 2 elif ca == "-": self.board.cell[c] = (int(bstr[i + 1:i + 1 + 1], 16), int(bstr[i + 2:i + 2 + 3], 16)) i += 4 elif ca >= "a" and ca <= "z": c += int(ca, 36) - 10 c += 1 if c >= self.rows * self.cols: break i += 1 self.body = bstr[i + 1:]
def __checkXRC(self): for base_cls in self.__class__.__bases__: cls_name = base_cls.__name__ if cls_name.startswith('xrc'): include(self, XrcCtrlMixin) break else: include(self, CtrlMixin)
def decode(self): c = 0 i = 0 bstr = self.body board = self.board while i < len(bstr): ca = bstr[i] if utils.include(ca, '0', '8'): self.board.cell[c] = [int(ca, 10)] elif ca == '9': self.board.cell[c] = [1, 1, 1, 1] elif ca == '.': self.board.cell[c] = [-2] elif utils.include(ca, 'a', 'f'): num = int(bstr[i:i + 2], 36) val = [] if 360 <= num < 396: num -= 360 val = [0, 0] val[0] = int(num / 6) num -= val[0] * 6 val[1] = num elif 396 <= num < 460: num -= 396 val = [0, 0, 0] val[0] = int(num / 16) num -= val[0] * 16 val[1] = int(num / 4) num -= val[1] * 4 val[2] = num elif 460 <= num < 476: num -= 460 val = [0, 0, 0, 0] val[0] = int(num / 8) num -= val[0] * 8 val[1] = int(num / 4) num -= val[1] * 4 val[2] = int(num / 2) num -= val[2] * 2 val[3] = num self.board.cell[c] = [v if v != 0 else -2 for v in val] i += 1 elif utils.include(ca, 'g', 'z'): c += int(ca, 36) - 16 if self.board.cell[c] != None: self.board.cell[c].sort() c += 1 if c >= self.rows * self.cols: break i += 1 self.body = bstr[i + 1:]
def Service__init__(): ################################################## ### Setting db ### ################################################## db = momoko.Pool(**config.DB_SETTING) future = db.connect() tornado.ioloop.IOLoop.instance().add_future(future, lambda f: tornado.ioloop.IOLoop.instance().stop()) tornado.ioloop.IOLoop.instance().start() ################################################## ### Setting Service ### ################################################## Service.db = db Service.log = log Service.form_validation = form_validation ################################################## ### Importing Service Module ### ################################################## include(Service, "./service", ["base.py"], True, False,) Service.Permission = T() include(Service.Permission, "./permission/", ["base.py"], True, True)
def decode(self): ec = 0 i = 0 bstr = self.body while i <= len(bstr): ca = bstr[i] if utils.include(ca, "0", "9") or utils.include(ca, "a", "f"): self.board.excell[ec] = int(bstr[i:i + 1], 16) elif ca == "-": self.board.excell[ec] = int(bstr[i:i + 2], 16) i += 2 elif ca == ".": self.board.excell[ec] = -2 elif "g" <= ca <= "z": ec += int(ca, 36) - 16 ec += 1 if (ec >= len(self.board.excell)): break i += 1 self.body = bstr[i + 1:]
def wrapper_body(self, subp): result = [] wrapper_fn = self.wrapper_fn(subp) include(get_prototype(wrapper_fn), result) call_args = {arg.name: arg.name for arg in subp.args} is_fnct = isinstance(subp, Function) local_vars = [] wrapper_body = [] if is_fnct: return_variable = LocalVariable('Return_Value', subp.return_type, None) local_vars.append(return_variable) for arg in subp.args: if arg.type in self.from_types: (vars, new_arg_name) = self.convert_arg(arg) local_vars.extend(vars) call_args[arg.name] = new_arg_name wrapper_body.append('is') if local_vars: longest_name = max(len(var.name) for var in local_vars) for var in local_vars: wrapper_body.append('{}{} : {}{};'.format( INDENT, var.name.ljust(longest_name), var.type, ' := {}'.format(var.value) if var.value else '')) wrapper_body.append('begin') # Generate the call to the C subprogram. call = subp.name if subp.args: call = '{} ({})'.format( call, ', '.join(call_args[arg.name] for arg in subp.args)) if is_fnct: wrapper_body.append('{}{} := {};'.format(INDENT, return_variable.name, call)) if subp.return_type in self.from_types: include(self.convert_return(return_variable), wrapper_body, indent=True) else: wrapper_body.append('{}return {};'.format( INDENT, return_variable.name)) else: wrapper_body.append('{}{};'.format(INDENT, call)) wrapper_body.append('end {};'.format(wrapper_fn.name)) include(wrapper_body, result) return result
def decode4Cell(self): c = 0 i = 0 bstr = self.body bd = self.board for i in range(len(bstr)): ca = bstr[i] if utils.include(ca, "0", "4"): bd.cell[c] = int(ca, 16) elif utils.include(ca, "5", "9"): bd.cell[c] = int(ca, 16) - 5 c += 1 elif utils.include(ca, "a", "e"): bd.cell[c] = int(ca, 16) - 10 c += 2 elif utils.include(ca, "g", "z"): c += int(ca, 36) - 16 elif ca == ".": bd.cell[c] = -2 c += 1 if c >= len(bd.cell): break self.body = self.body[i + 1:]
from tornado import web from tornado.web import URLSpec as url from sockjs.tornado import SockJSRouter from settings import settings from utils import include from apps.main.views import UbernowRequestHandler # Register SocjJsRouter Connection SockjsWebsocketRouter = SockJSRouter(UbernowRequestHandler, '/ubernow') urls = [ url(r"/static/(.*)", web.StaticFileHandler, {"path": settings.get('static_path')}), ] urls += include(r"/", "apps.main.urls") urls = urls + SockjsWebsocketRouter.urls
def callback(tr, subp): include(tr.wrapper_body(subp), result, indent=True) result.append('')
from tornado import web from tornado.web import URLSpec as url # from sockjs.tornado import SockJSRouter from settings import settings from utils import include # from apps.webapp.views import LogWebsocketHandler # # Register SocjJsRouter Connection # SockjsWebsocketRouter = SockJSRouter(LogWebsocketHandler, '/log') urls = [ url(r"/static/(.*)", web.StaticFileHandler, {"path": settings.get('static_path')}), ] urls += include(r"/", "apps.webapp.urls") # urls = urls + SockjsWebsocketRouter.urls