From d70c8b180945fb0da94f8a83c790bc1e1d889444 Mon Sep 17 00:00:00 2001 From: Joe Shochet Date: Thu, 1 Feb 2001 04:22:31 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/ffi/FFIExternalObject.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/direct/src/ffi/FFIExternalObject.py b/direct/src/ffi/FFIExternalObject.py index 9d375e0c39..d076d6cb5b 100644 --- a/direct/src/ffi/FFIExternalObject.py +++ b/direct/src/ffi/FFIExternalObject.py @@ -173,16 +173,27 @@ class FFIExternalObject: def __repr__(self): # Print this info for all objects baseRepr = ('<' + self.__class__.__name__ + ' instance at C++ pointer: ' + `self.this` + '>') + # Lots of Panda classes have an write or output function defined that takes an Ostream + # We create a LineStream for the write or output function to write to, then we extract + # the string out of it and return it as our repr + import LineStream + lineStream = LineStream.LineStream() try: - # Lots of Panda classes have an output function defined that takes an Ostream - # We create a LineStream for the output function to write to, then we extract - # the string out of it and return it as our repr - import LineStream - lineStream = LineStream.LineStream() - self.output(lineStream) - return baseRepr + '\n' + lineStream.getLine() + # First try the write function, that is the better one + self.write(lineStream) + while lineStream.isTextAvailable(): + baseRepr = baseRepr + '\n' + lineStream.getLine() except: - return baseRepr + try: + # Ok, no write function, lets try output then + self.output(lineStream) + while lineStream.isTextAvailable(): + baseRepr = baseRepr + '\n' + lineStream.getLine() + except: + pass + + # In any case, return the baseRepr + return baseRepr def __hash__(self): return self.this