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
This commit is contained in:
Xavier Delacour 2011-05-17 01:59:19 +00:00
commit e22eb83574

View file

@ -849,26 +849,32 @@ namespace Swig {
member_map tmp; member_map tmp;
load_members(tmp); load_members(tmp);
os << "{" << std::endl; indent(os);
os << "{"; newline(os);
increment_indent_level();
for (unsigned int j = 0; j < types.size(); ++j) { for (unsigned int j = 0; j < types.size(); ++j) {
indent(os);
if (types[j].first->clientdata) { if (types[j].first->clientdata) {
const swig_octave_class *c = (const swig_octave_class *) 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 { } 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) { for (member_map::const_iterator it = tmp.begin(); it != tmp.end(); ++it) {
indent(os);
if (it->second.first) { if (it->second.first) {
const char *objtype = it->second.first->method ? "method" : "variable"; const char *objtype = it->second.first->method ? "method" : "variable";
const char *modifier = (it->second.first->flags &1) ? "static " : (it->second.first->flags &2) ? "global " : ""; 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); assert(it->second.first->name == it->first);
} else { } 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 { 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);
} }