Hi! On Sunday 25 April 2004 17:01, Will Coleda wrote: > I'm adding an object or two, and wanted to write my own __dump() method > so I can be dumped out by Data::Dumper. > > Right now, there doesn't seem to be a way to integrate nicely with the > indent level of the data structure I'm embedded in, so I see things > like: > > PerlArray (size:2) [ > PMC 'TclWord' (size:1) [ > chunk:puts > ], > PMC 'TclWord' (size:1) [ > chunk:$b(a) > ] > ] > > > I see a few options: > > (1) Tell me the indent level, so I can handle it manually. Oh, this is not documented yet :-(
from t/pmc/dumper.t: .sub __dump method .param pmc dumper .param string name .local string subindent .local string indent .local string name (subindent, indent) = dumper."newIndent"() print "{\n" print subindent print "this is\n" print subindent print "_" classname name, self print name print "::__dump\n" print indent print "}" dumper."deleteIndent"() .pcc_begin_return .pcc_end_return .end > (2) Have me return a DS instead of printing directly. You can create a data structure and dump it, returning another DS is not possible. > (3) Pass me an object as one of the parameters, with handy utility > methods for dumping strings and other predefined types. .sub __dump method .param pmc dumper .param string name .local pmc hash hash = ... dumper."dumpHash"( name, hash ) .pcc_begin_return .pcc_end_return .end > > -- > Will "Coke" Coleda will at coleda > dot com jens