From e22eb835742606b3911956a344a66f3780dd0338 Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Tue, 17 May 2011 01:59:19 +0000 Subject: [PATCH] Minor improvement to the printing of Octave SWIG classes (by Karl Wette) Uses Octave's indentation functions to make sure the classes are printed at the correct indentation level, e.g. for a cell array containing SWIG-wrapped classes. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12672 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/octave/octrun.swg | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 5b90d91b3..657223f7a 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -849,26 +849,32 @@ namespace Swig { member_map tmp; load_members(tmp); - os << "{" << std::endl; + indent(os); + os << "{"; newline(os); + increment_indent_level(); for (unsigned int j = 0; j < types.size(); ++j) { + indent(os); if (types[j].first->clientdata) { const swig_octave_class *c = (const swig_octave_class *) types[j].first->clientdata; - os << " " << c->name << ", ptr = " << types[j].second.ptr << std::endl; + os << c->name << ", ptr = " << types[j].second.ptr; newline(os); } else { - os << " " << types[j].first->name << ", ptr = " << types[j].second.ptr << std::endl; + os << types[j].first->name << ", ptr = " << types[j].second.ptr; newline(os); } } for (member_map::const_iterator it = tmp.begin(); it != tmp.end(); ++it) { + indent(os); if (it->second.first) { const char *objtype = it->second.first->method ? "method" : "variable"; const char *modifier = (it->second.first->flags &1) ? "static " : (it->second.first->flags &2) ? "global " : ""; - os << " " << it->second.first->name << " (" << modifier << objtype << ")" << std::endl; + os << it->second.first->name << " (" << modifier << objtype << ")"; newline(os); assert(it->second.first->name == it->first); } else { - os << " " << it->first << std::endl; + os << it->first; newline(os); } } - os << "}" << std::endl; + decrement_indent_level(); + indent(os); + os << "}"; newline(os); } }; @@ -998,7 +1004,8 @@ namespace Swig { } void print(std::ostream &os, bool pr_as_read_syntax = false) const { - os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size() << std::endl; + indent(os); + os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size(); newline(os); }