# HG changeset patch # User Paul Boddie # Date 1100468798 -3600 # Node ID 5a6e26d36f31dec2d94472b6a1c0d65f6566a02f # Parent 2157b80a1b55747c83a80d4d26abae0c7d2f1fa4 Added tentative support for class initialisation (although not enabled). diff -r 2157b80a1b55 -r 5a6e26d36f31 classhook.py --- a/classhook.py Sun Nov 14 22:45:48 2004 +0100 +++ b/classhook.py Sun Nov 14 22:46:38 2004 +0100 @@ -92,11 +92,16 @@ global_names = {} global_names.update(__builtins__.__dict__) + + # Set up the module. + module = self.hooks.add_module(name) + module.__path__ = [filename] # Process each class file, producing a genuine Python class. class_files = [] + classes = [] for class_filename in glob.glob(os.path.join(filename, "*" + os.extsep + "class")): print "Importing class", class_filename f = open(class_filename, "rb") @@ -106,8 +111,14 @@ translator = bytecode.ClassTranslator(class_file) cls = translator.process(global_names) module.__dict__[cls.__name__] = cls + classes.append(cls) - module.__path__ = [filename] + # Finally, call __clinit__ methods for all relevant classes. + + #for cls in classes: + # if hasattr(cls, "__clinit__"): + # cls.__clinit__() + return module importer = ihooks.ModuleImporter(loader=ClassLoader(hooks=ClassHooks()))