more on binary class storage (sourceMode argument)
authorClaus Gittinger <cg@exept.de>
Wed, 24 Jan 1996 21:47:30 +0100
changeset 894 138c21732ab9
parent 893 0c91a0be9d6a
child 895 c3bb8e614ee3
more on binary class storage (sourceMode argument)
Class.st
--- a/Class.st	Wed Jan 24 21:47:08 1996 +0100
+++ b/Class.st	Wed Jan 24 21:47:30 1996 +0100
@@ -1955,6 +1955,26 @@
 !
 
 binaryFileOut
+    "create a file 'class.cls' consisting of all methods in myself
+     in a portable binary format. The methods source is saved by reference
+     to the classes sourceFile if there is any.
+     That sourcefile needs to be present after reload in order to be
+     browsable.".
+
+    self binaryFileOutWithSourceMode:#reference
+!
+
+binaryFileOutWithSourceMode:sourceMode
+    "create a file 'class.cls' consisting of all methods in myself
+     in a portable binary format. 
+     The argument controls how sources are to be saved:
+	#keep - include the source
+	#reference - include a reference to the sourceFile
+	#discard - dont save sources.
+
+     With #reference, the sourceFile needs to be present after reload 
+     in order to be browsable."
+
     |baseName fileName aStream|
 
     baseName := (Smalltalk fileNameForClass:self name).
@@ -1962,20 +1982,38 @@
     aStream := FileStream newFileNamed:fileName.
 
     aStream binary.
-    self binaryFileOutOn:aStream.
+    self binaryFileOutOn:aStream sourceMode:sourceMode.
     aStream close.
 !
 
 binaryFileOutOn:aStream
+    "append a binary representation of myself to aStream"
+
+    self binaryFileOutOn:aStream sourceMode:#reference 
+!
+
+binaryFileOutOn:aStream sourceMode:sourceMode
+    "append a binary representation of myself to aStream in
+     a portable binary format. 
+     The argument controls how sources are to be saved:
+	#keep - include the source
+	#reference - include a reference to the sourceFile
+	#discard - dont save sources.
+
+     With #reference, the sourceFile needs to be present after reload 
+     in order to be browsable."
+
     |bos|
 
     bos := BinaryObjectStorage onNew:aStream.
+    bos sourceMode:sourceMode.
     bos nextPutClasses:(Array with:self).
     bos close.
 !
 
 fileOut
-    "create a file 'class.st' consisting of all methods in myself.
+    "create a file 'class.st' consisting of all methods in myself in
+     sourceForm, from which the class can be reconstructed (by filing in).
      If the current project is not nil, create the file in the projects
      directory. Care is taken, to not clobber any existing file in
      case of errors (for example: disk full). 
@@ -3684,6 +3722,6 @@
 !Class class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.122 1996-01-24 19:45:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.123 1996-01-24 20:47:30 cg Exp $'
 ! !
 Class initialize!