svgui/pyjs/lib/pyjslib.py
changeset 1730 64d8f52bc8c8
parent 728 e0424e96e3fd
child 1736 7e61baa047f0
equal deleted inserted replaced
1726:d51af006fa6b 1730:64d8f52bc8c8
    18 from __pyjamas__ import JS
    18 from __pyjamas__ import JS
    19 
    19 
    20 # must declare import _before_ importing sys
    20 # must declare import _before_ importing sys
    21 
    21 
    22 def import_module(path, parent_module, module_name, dynamic=1, async=False):
    22 def import_module(path, parent_module, module_name, dynamic=1, async=False):
    23     """ 
    23     """
    24     """
    24     """
    25 
    25 
    26     JS("""
    26     JS("""
    27         var cache_file;
    27         var cache_file;
    28 
    28 
    36         {
    36         {
    37             path = './';
    37             path = './';
    38         }
    38         }
    39 
    39 
    40         var override_name = sys.platform + "." + module_name;
    40         var override_name = sys.platform + "." + module_name;
    41         if (((sys.overrides != null) && 
    41         if (((sys.overrides != null) &&
    42              (sys.overrides.has_key(override_name))))
    42              (sys.overrides.has_key(override_name))))
    43         {
    43         {
    44             cache_file =  sys.overrides.__getitem__(override_name) ;
    44             cache_file =  sys.overrides.__getitem__(override_name) ;
    45         }
    45         }
    46         else
    46         else
    65         if (typeof (module_load_request[module_name]) == 'undefined')
    65         if (typeof (module_load_request[module_name]) == 'undefined')
    66         {
    66         {
    67             module_load_request[module_name] = 1;
    67             module_load_request[module_name] = 1;
    68         }
    68         }
    69 
    69 
    70         /* following a load, this first executes the script 
    70         /* following a load, this first executes the script
    71          * "preparation" function MODULENAME_loaded_fn()
    71          * "preparation" function MODULENAME_loaded_fn()
    72          * and then sets up the loaded module in the namespace
    72          * and then sets up the loaded module in the namespace
    73          * of the parent.
    73          * of the parent.
    74          */
    74          */
    75 
    75 
   199         self.idx = 0;
   199         self.idx = 0;
   200         self.dynamic = dynamic
   200         self.dynamic = dynamic
   201         self.parent_mod = parent_mod
   201         self.parent_mod = parent_mod
   202 
   202 
   203     def next(self):
   203     def next(self):
   204         
   204 
   205         for i in range(len(self.app_modlist[self.idx])):
   205         for i in range(len(self.app_modlist[self.idx])):
   206             app = self.app_modlist[self.idx][i]
   206             app = self.app_modlist[self.idx][i]
   207             import_module(self.path, self.parent_mod, app, self.dynamic, True);
   207             import_module(self.path, self.parent_mod, app, self.dynamic, True);
   208         self.idx += 1
   208         self.idx += 1
   209 
   209 
  1107 
  1107 
  1108 def isinstance(object_, classinfo):
  1108 def isinstance(object_, classinfo):
  1109     if pyjslib.isUndefined(object_):
  1109     if pyjslib.isUndefined(object_):
  1110         return False
  1110         return False
  1111     if not pyjslib.isObject(object_):
  1111     if not pyjslib.isObject(object_):
  1112         
  1112 
  1113         return False
  1113         return False
  1114     if _isinstance(classinfo, Tuple):
  1114     if _isinstance(classinfo, Tuple):
  1115         for ci in classinfo:
  1115         for ci in classinfo:
  1116             if isinstance(object_, ci):
  1116             if isinstance(object_, ci):
  1117                 return True
  1117                 return True
  1360 
  1360 
  1361     JS(" var bss = null; ")
  1361     JS(" var bss = null; ")
  1362     if bases:
  1362     if bases:
  1363         JS("bss = bases.l;")
  1363         JS("bss = bases.l;")
  1364     JS(" return pyjs_type(clsname, bss, mths); ")
  1364     JS(" return pyjs_type(clsname, bss, mths); ")
  1365