javaclass

Changeset

171:bea01a58e7d5
2005-02-20 Paul Boddie raw files shortlog changelog graph Fixed multiple imports - the loaded_classes attribute was not removed. Added interfaces as base classes.
javaclass/bytecode.py (file)
     1.1 --- a/javaclass/bytecode.py	Sun Feb 13 22:39:06 2005 +0100
     1.2 +++ b/javaclass/bytecode.py	Sun Feb 20 23:02:23 2005 +0100
     1.3 @@ -2331,8 +2331,12 @@
     1.4  
     1.5          return cls
     1.6  
     1.7 -    def get_super_class(self):
     1.8 -        return self.class_file.super_class
     1.9 +    def get_base_class_references(self):
    1.10 +        class_names = []
    1.11 +        if self.class_file.super_class is not None:
    1.12 +            class_names.append(self.class_file.super_class)
    1.13 +        class_names += self.class_file.interfaces
    1.14 +        return class_names
    1.15  
    1.16      def get_base_classes(self, global_names):
    1.17  
    1.18 @@ -2343,21 +2347,24 @@
    1.19          tuple).
    1.20          """
    1.21  
    1.22 -        super_class = self.class_file.super_class
    1.23 -        if super_class is None:
    1.24 -            return ()
    1.25 -
    1.26 -        super_class_name = super_class.get_python_name()
    1.27 -        super_class_name_parts = super_class_name.split(".")
    1.28 +        base_classes = []
    1.29 +
    1.30 +        for class_ in self.get_base_class_references():
    1.31 +            base_classes.append(self._get_class(class_, global_names))
    1.32 +
    1.33 +        return tuple(base_classes)
    1.34 +
    1.35 +    def _get_class(self, class_, global_names):
    1.36 +        class_name = class_.get_python_name()
    1.37 +        class_name_parts = class_name.split(".")
    1.38          obj = global_names
    1.39 -        for super_class_name_part in super_class_name_parts[:-1]:
    1.40 +        for class_name_part in class_name_parts[:-1]:
    1.41              try:
    1.42 -                obj = obj[super_class_name_part].__dict__
    1.43 +                obj = obj[class_name_part].__dict__
    1.44              except KeyError:
    1.45                  raise AttributeError, "Cannot find '%s' when referencing Java class '%s'" % (
    1.46 -                    super_class_name_part, super_class_name)
    1.47 -        obj = obj[super_class_name_parts[-1]]
    1.48 -        return (obj,)
    1.49 +                    class_name_part, class_name)
    1.50 +        return obj[class_name_parts[-1]]
    1.51  
    1.52      def make_varnames(self, nlocals, method_is_static=0):
    1.53