javaclass

Change of classfile.py

55:2157b80a1b55
classfile.py
     1.1 --- a/classfile.py	Sun Nov 14 19:36:46 2004 +0100
     1.2 +++ b/classfile.py	Sun Nov 14 22:45:48 2004 +0100
     1.3 @@ -30,6 +30,8 @@
     1.4  def f8(data):
     1.5      return struct.unpack(">d", data[0:8])[0]
     1.6  
     1.7 +# Useful tables and constants.
     1.8 +
     1.9  descriptor_base_type_mapping = {
    1.10      "B" : "int",
    1.11      "C" : "str",
    1.12 @@ -43,6 +45,13 @@
    1.13      "[" : "list"
    1.14      }
    1.15  
    1.16 +PUBLIC, PRIVATE, PROTECTED, STATIC, FINAL,  SUPER,  SYNCHRONIZED, VOLATILE, TRANSIENT, NATIVE, INTERFACE, ABSTRACT, STRICT = \
    1.17 +0x0001, 0x0002,  0x0004,    0x0008, 0x0010, 0x0020, 0x0020,       0x0040,   0x0080,    0x0100, 0x0200,    0x0400,   0x0800
    1.18 +
    1.19 +def has_flags(flags, desired):
    1.20 +    desired_flags = reduce(lambda a, b: a | b, desired, 0)
    1.21 +    return (flags & desired_flags) == desired_flags
    1.22 +
    1.23  # Useful mix-ins.
    1.24  
    1.25  class PythonMethodUtils:
    1.26 @@ -50,6 +59,8 @@
    1.27          name = self.get_name()
    1.28          if str(name) == "<init>":
    1.29              name = "__init__"
    1.30 +        elif str(name) == "<clinit>":
    1.31 +            return "__clinit__"
    1.32          else:
    1.33              name = str(name)
    1.34          return name + "$" + self._get_descriptor_as_name()