Esempio n. 1
0
 def CompileEventHandler(self, name, argNames, body, url, lineno):
     co = domcompile.compile_function(body,
                                      url,
                                      name,
                                      argNames,
                                      lineno=lineno - 1)
     g = {}
     exec co in g
     return g[name]
Esempio n. 2
0
 def CompileEventHandler(self, name, argNames, body, url, lineno, version):
     if __debug__:
         logger.debug("%s.CompileEventHandler %s %s:%s ('%s')",
                      self, name, url, lineno, body[:100])
     co = domcompile.compile_function(body, url, name, argNames,
                                      lineno=lineno-1)
     g = {}
     exec co in g
     handler = g[name]
     # Flag that this function started life as inline script code,
     # so we later ensure the correct globals are used when the event fires
     handler._nsdom_compiled = True
     return g[name]
Esempio n. 3
0
 def CompileEventHandler(self, name, argNames, body, url, lineno, version):
     if __debug__:
         logger.debug("%s.CompileEventHandler %s %s:%s ('%s')", self, name,
                      url, lineno, body[:100])
     co = domcompile.compile_function(body,
                                      url,
                                      name,
                                      argNames,
                                      lineno=lineno - 1)
     g = {}
     exec co in g
     handler = g[name]
     # Flag that this function started life as inline script code,
     # so we later ensure the correct globals are used when the event fires
     handler._nsdom_compiled = True
     return g[name]
Esempio n. 4
0
 def __init__(self, context, evt_name, handler, globs=None):
     self.context = context
     if callable(handler):
         self.func = handler
     else:
         # event name for addEventListener has no 'on' prefix
         func_name = "on" + evt_name
         # What to do about arg names?  It looks like onerror
         # still only gets one arg here anyway - handleEvent only takes
         # one!
         arg_names = ('event', )
         co = domcompile.compile_function(handler,
                                          "inline event '%s'" % evt_name,
                                          func_name, arg_names)
         # Could use globs here, but should not be necessary - all we
         # are doing is getting the function object from it.
         g = {}
         exec co in g
         self.func = g[func_name]
     self.globals = globs
Esempio n. 5
0
 def __init__(self, context, evt_name, handler, globs):
     # 'globs' are the globals the event handler will use, or None
     # if the handler should use the globals it was compiled with.
     self.context = context
     if callable(handler):
         self.func = handler
     else:
         # event name for addEventListener has no 'on' prefix
         func_name = "on" + evt_name
         # What to do about arg names?  It looks like onerror
         # still only gets one arg here anyway - handleEvent only takes
         # one!
         arg_names = ('event',)
         co = domcompile.compile_function(handler,
                                          "inline event '%s'" % evt_name,
                                          func_name,
                                          arg_names)
         # Could use globs here, but should not be necessary - all we
         # are doing is getting the function object from it.
         g = {}
         exec co in g
         self.func = g[func_name]
     self.globals = globs