javaclass

Changeset

56:5a6e26d36f31
2004-11-14 Paul Boddie raw files shortlog changelog graph Added tentative support for class initialisation (although not enabled).
classhook.py (file)
     1.1 --- a/classhook.py	Sun Nov 14 22:45:48 2004 +0100
     1.2 +++ b/classhook.py	Sun Nov 14 22:46:38 2004 +0100
     1.3 @@ -92,11 +92,16 @@
     1.4  
     1.5          global_names = {}
     1.6          global_names.update(__builtins__.__dict__)
     1.7 +
     1.8 +        # Set up the module.
     1.9 +
    1.10          module = self.hooks.add_module(name)
    1.11 +        module.__path__ = [filename]
    1.12  
    1.13          # Process each class file, producing a genuine Python class.
    1.14  
    1.15          class_files = []
    1.16 +        classes = []
    1.17          for class_filename in glob.glob(os.path.join(filename, "*" + os.extsep + "class")):
    1.18              print "Importing class", class_filename
    1.19              f = open(class_filename, "rb")
    1.20 @@ -106,8 +111,14 @@
    1.21              translator = bytecode.ClassTranslator(class_file)
    1.22              cls = translator.process(global_names)
    1.23              module.__dict__[cls.__name__] = cls
    1.24 +            classes.append(cls)
    1.25  
    1.26 -        module.__path__ = [filename]
    1.27 +        # Finally, call __clinit__ methods for all relevant classes.
    1.28 +
    1.29 +        #for cls in classes:
    1.30 +        #    if hasattr(cls, "__clinit__"):
    1.31 +        #        cls.__clinit__()
    1.32 +
    1.33          return module
    1.34  
    1.35  importer = ihooks.ModuleImporter(loader=ClassLoader(hooks=ClassHooks()))