# HG changeset patch # User Paul Boddie # Date 1102555042 -3600 # Node ID 78da4286ff0a68f4e47507011592d092e73b5fcd # Parent f08b72e9f0605ed2250f32bfe99505269a695c9c Made i2c a null operation since char values are treated like int values in Java. Changed the special notation for Java-callable methods so that methods may be more easily written in Python. Commented out various trace statements. diff -r f08b72e9f060 -r 78da4286ff0a bytecode.py --- a/bytecode.py Wed Dec 08 23:02:46 2004 +0100 +++ b/bytecode.py Thu Dec 09 02:17:22 2004 +0100 @@ -1240,9 +1240,7 @@ pass def i2c(self, arguments, program): - program.load_global("chr") # Stack: value, chr - program.rot_two() # Stack: chr, value - program.call_function(1) # Stack: result + pass def i2d(self, arguments, program): program.load_global("float") # Stack: value, float diff -r f08b72e9f060 -r 78da4286ff0a classfile.py --- a/classfile.py Wed Dec 08 23:02:46 2004 +0100 +++ b/classfile.py Thu Dec 09 02:17:22 2004 +0100 @@ -58,6 +58,11 @@ # Useful mix-ins. class PythonMethodUtils: + symbol_sep = "___" # was "$" + type_sep = "__" # replaces "/" + array_sep = "_array_" # was "[]" + base_seps = ("_", "_") # was "<" and ">" + def get_python_name(self): name = self.get_name() if str(name) == "": @@ -66,22 +71,22 @@ return "__clinit__" else: name = str(name) - return name + "$" + self._get_descriptor_as_name() + return name + self.symbol_sep + self._get_descriptor_as_name() def _get_descriptor_as_name(self): l = [] for descriptor_type in self.get_descriptor()[0]: l.append(self._get_type_as_name(descriptor_type)) - return "$".join(l) + return self.symbol_sep.join(l) def _get_type_as_name(self, descriptor_type, s=""): base_type, object_type, array_type = descriptor_type if base_type == "L": - return object_type + s + return object_type.replace("/", self.type_sep) + s elif base_type == "[": - return self._get_type_as_name(array_type, s + "[]") + return self._get_type_as_name(array_type, s + self.array_sep) else: - return "<" + base_type + ">" + s + return self.base_seps[0] + base_type + self.base_seps[1] + s class PythonNameUtils: def get_python_name(self): diff -r f08b72e9f060 -r 78da4286ff0a classhook.py --- a/classhook.py Wed Dec 08 23:02:46 2004 +0100 +++ b/classhook.py Thu Dec 09 02:17:22 2004 +0100 @@ -137,7 +137,7 @@ else: archive, archive_path, path = self._get_archive_and_path(dir, name) - print "Processing name", name, "in", dir, "producing", path, "within archive", archive + #print "Processing name", name, "in", dir, "producing", path, "within archive", archive if self._find_module_at_path(path, archive): if archive is not None: @@ -175,7 +175,7 @@ def _find_module_at_path(self, path, archive): if self.hooks.path_isdir(path, archive): - print "Looking in", path, "using archive", archive + #print "Looking in", path, "using archive", archive # Look for classes in the directory. @@ -184,7 +184,7 @@ # Otherwise permit importing where directories containing classes exist. - print "Filenames are", self.hooks.listdir(path, archive) + #print "Filenames are", self.hooks.listdir(path, archive) for filename in self.hooks.listdir(path, archive): pathname = self.hooks.path_join(path, filename) result = self._find_module_at_path(pathname, archive) @@ -209,7 +209,7 @@ if datatype not in (JAVA_PACKAGE, JAVA_ARCHIVE): return ihooks.ModuleLoader.load_module(self, name, stuff) - print "Loading", archive, filename, info + #print "Loading", archive, filename, info # Set up the module. @@ -229,13 +229,13 @@ # Get the real filename. filename = self._get_path_in_archive(filename) - print "Real filename", filename + #print "Real filename", filename # Load the class files. class_files = {} for class_filename in self.hooks.matching(filename, os.extsep + "class", archive): - print "Loading class", class_filename + #print "Loading class", class_filename s = self.hooks.read(class_filename, archive) class_file = classfile.ClassFile(s) class_files[str(class_file.this_class.get_name())] = class_file