Skip to content

Instantly share code, notes, and snippets.

@SeanTAllen
Created May 3, 2011 02:57
Show Gist options
  • Save SeanTAllen/952748 to your computer and use it in GitHub Desktop.
Save SeanTAllen/952748 to your computer and use it in GitHub Desktop.
Ugly pharo dumping to redline format
class := TestCase.
aStream := String new writeStream .
class superclass == nil
ifTrue: [aStream nextPutAll: 'ProtoObject']
ifFalse: [aStream nextPutAll: class superclass name].
aStream
nextPutAll: class kindOfSubclass;
store: class name;
crlf.
aStream
tab;
nextPutAll: 'instanceVariableNames: ';
store: class instanceVariablesString;
crlf.
aStream
tab;
nextPutAll: 'classVariableNames: ';
store: class classVariablesString;
crlf.
aStream
tab;
nextPutAll: 'poolDictionaries: ';
store: class sharedPoolsString;
crlf.
aStream
tab;
nextPutAll: 'classInstanceVariableNames: ';
store: class class instanceVariablesString;
nextPut: $.;
crlf;
crlf.
methods := class classSide methods asSortedCollection: [ :a :b | a selector < b selector ].
methods do: [ :method |
s := method getSource.
s := 'cdef ', s.
s := s withBlanksTrimmed.
s := s copyReplaceAll: String cr with: String crlf.
aStream
nextPutAll: s;
crlf;
crlf.
].
methods := class methods asSortedCollection: [ :a :b | a selector < b selector ].
methods do: [ :method |
s := method getSource.
s := 'def ', s.
s := s withBlanksTrimmed.
s := s copyReplaceAll: String cr with: String crlf.
aStream
nextPutAll: s;
crlf;
crlf.
].
file := StandardFileStream fileNamed: class name , '.st'.
file nextPutAll: aStream contents.
file close.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment