svgui/pyjs/pyjs.py
changeset 1776 81aa8aaccdd4
parent 1775 b45f2768fab1
child 1782 5b6ad7a7fd9d
equal deleted inserted replaced
1775:b45f2768fab1 1776:81aa8aaccdd4
   184 def gen_mod_import(parentName, importName, dynamic=1):
   184 def gen_mod_import(parentName, importName, dynamic=1):
   185     #pyjs_ajax_eval("%(n)s.cache.js", null, true);
   185     #pyjs_ajax_eval("%(n)s.cache.js", null, true);
   186     return """
   186     return """
   187     pyjslib.import_module(sys.loadpath, '%(p)s', '%(n)s', %(d)d, false);
   187     pyjslib.import_module(sys.loadpath, '%(p)s', '%(n)s', %(d)d, false);
   188     """ % ({'p': parentName, 'd': dynamic, 'n': importName}) + \
   188     """ % ({'p': parentName, 'd': dynamic, 'n': importName}) + \
   189     mod_var_name_decl(importName)
   189         mod_var_name_decl(importName)
   190 
   190 
   191 
   191 
   192 class Translator:
   192 class Translator:
   193 
   193 
   194     def __init__(self, mn, module_name, raw_module_name, src, debug, mod, output,
   194     def __init__(self, mn, module_name, raw_module_name, src, debug, mod, output,
   804             None,
   804             None,
   805             [ast.Discard(ast.CallFunc(ast.Name("JS"), [ast.Const(
   805             [ast.Discard(ast.CallFunc(ast.Name("JS"), [ast.Const(
   806                 #            I attempted lazy initialization, but then you can't access static class members
   806                 #            I attempted lazy initialization, but then you can't access static class members
   807                 #            "    if(!__"+base_class+".__was_initialized__)"+
   807                 #            "    if(!__"+base_class+".__was_initialized__)"+
   808                 #            "        __" + class_name + "_initialize();\n" +
   808                 #            "        __" + class_name + "_initialize();\n" +
   809             "    var instance = new " + UU + class_name_ + "();\n" +
   809                 "    var instance = new " + UU + class_name_ + "();\n" +
   810                 "    if(instance.__init__) instance.__init__.apply(instance, arguments);\n" +
   810                 "    if(instance.__init__) instance.__init__.apply(instance, arguments);\n" +
   811                 "    return instance;"
   811                 "    return instance;"
   812             )]))])
   812             )]))])
   813 
   813 
   814         self._function(clsfunc, False)
   814         self._function(clsfunc, False)