1953 |
1953 |
1954 "Modified: 10.12.1995 / 16:31:50 / cg" |
1954 "Modified: 10.12.1995 / 16:31:50 / cg" |
1955 ! |
1955 ! |
1956 |
1956 |
1957 binaryFileOut |
1957 binaryFileOut |
|
1958 "create a file 'class.cls' consisting of all methods in myself |
|
1959 in a portable binary format. The methods source is saved by reference |
|
1960 to the classes sourceFile if there is any. |
|
1961 That sourcefile needs to be present after reload in order to be |
|
1962 browsable.". |
|
1963 |
|
1964 self binaryFileOutWithSourceMode:#reference |
|
1965 ! |
|
1966 |
|
1967 binaryFileOutWithSourceMode:sourceMode |
|
1968 "create a file 'class.cls' consisting of all methods in myself |
|
1969 in a portable binary format. |
|
1970 The argument controls how sources are to be saved: |
|
1971 #keep - include the source |
|
1972 #reference - include a reference to the sourceFile |
|
1973 #discard - dont save sources. |
|
1974 |
|
1975 With #reference, the sourceFile needs to be present after reload |
|
1976 in order to be browsable." |
|
1977 |
1958 |baseName fileName aStream| |
1978 |baseName fileName aStream| |
1959 |
1979 |
1960 baseName := (Smalltalk fileNameForClass:self name). |
1980 baseName := (Smalltalk fileNameForClass:self name). |
1961 fileName := baseName , '.cls'. |
1981 fileName := baseName , '.cls'. |
1962 aStream := FileStream newFileNamed:fileName. |
1982 aStream := FileStream newFileNamed:fileName. |
1963 |
1983 |
1964 aStream binary. |
1984 aStream binary. |
1965 self binaryFileOutOn:aStream. |
1985 self binaryFileOutOn:aStream sourceMode:sourceMode. |
1966 aStream close. |
1986 aStream close. |
1967 ! |
1987 ! |
1968 |
1988 |
1969 binaryFileOutOn:aStream |
1989 binaryFileOutOn:aStream |
|
1990 "append a binary representation of myself to aStream" |
|
1991 |
|
1992 self binaryFileOutOn:aStream sourceMode:#reference |
|
1993 ! |
|
1994 |
|
1995 binaryFileOutOn:aStream sourceMode:sourceMode |
|
1996 "append a binary representation of myself to aStream in |
|
1997 a portable binary format. |
|
1998 The argument controls how sources are to be saved: |
|
1999 #keep - include the source |
|
2000 #reference - include a reference to the sourceFile |
|
2001 #discard - dont save sources. |
|
2002 |
|
2003 With #reference, the sourceFile needs to be present after reload |
|
2004 in order to be browsable." |
|
2005 |
1970 |bos| |
2006 |bos| |
1971 |
2007 |
1972 bos := BinaryObjectStorage onNew:aStream. |
2008 bos := BinaryObjectStorage onNew:aStream. |
|
2009 bos sourceMode:sourceMode. |
1973 bos nextPutClasses:(Array with:self). |
2010 bos nextPutClasses:(Array with:self). |
1974 bos close. |
2011 bos close. |
1975 ! |
2012 ! |
1976 |
2013 |
1977 fileOut |
2014 fileOut |
1978 "create a file 'class.st' consisting of all methods in myself. |
2015 "create a file 'class.st' consisting of all methods in myself in |
|
2016 sourceForm, from which the class can be reconstructed (by filing in). |
1979 If the current project is not nil, create the file in the projects |
2017 If the current project is not nil, create the file in the projects |
1980 directory. Care is taken, to not clobber any existing file in |
2018 directory. Care is taken, to not clobber any existing file in |
1981 case of errors (for example: disk full). |
2019 case of errors (for example: disk full). |
1982 Also, since the classes methods need a valid sourcefile, the current |
2020 Also, since the classes methods need a valid sourcefile, the current |
1983 sourceFile may not be rewritten." |
2021 sourceFile may not be rewritten." |