SmalltalkChunkFileSourceWriter.st
author Claus Gittinger <cg@exept.de>
Wed, 24 Oct 2012 18:36:16 +0200
changeset 14426 6ac120dc7add
parent 14409 6f53326ef2da
child 14596 45bb7ac30ab0
permissions -rw-r--r--
changed: #initializeSystem temporary with traces
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
     1
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
     2
 COPYRIGHT (c) 2004 by eXept Software AG
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
     3
              All Rights Reserved
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
     4
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
     5
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
     6
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
     9
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    10
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    11
"
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
f700545e4350 initial checkin
ca
parents:
diff changeset
    13
11963
0419e28049e4 parent class changed to AbstractChunkFileSourceWriter
fm
parents: 11853
diff changeset
    14
AbstractSourceFileWriter subclass:#SmalltalkChunkFileSourceWriter
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
    15
	instanceVariableNames:'classBeingSaved methodsAlreadySaved'
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
    16
	classVariableNames:''
f700545e4350 initial checkin
ca
parents:
diff changeset
    17
	poolDictionaries:''
f700545e4350 initial checkin
ca
parents:
diff changeset
    18
	category:'Kernel-Classes'
f700545e4350 initial checkin
ca
parents:
diff changeset
    19
!
f700545e4350 initial checkin
ca
parents:
diff changeset
    20
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    21
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'!
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    22
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    23
copyright
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    24
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    25
 COPYRIGHT (c) 2004 by eXept Software AG
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    26
              All Rights Reserved
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    27
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    28
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    29
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    31
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    32
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    33
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    34
"
14409
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    35
!
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    36
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    37
documentation
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    38
"
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    39
    I know how to write smalltalk chunk file format
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    40
"
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    41
! !
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
    42
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    43
!SmalltalkChunkFileSourceWriter class methodsFor:'utilities - source code'!
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    44
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    45
methodTemplate
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    46
    "return a method definition template string"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    47
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    48
    |s|
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    49
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    50
    s := TextStream on:''.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    51
    s nextPutAll:
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    52
'message selector and argument names
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    53
    "comment stating purpose of this message"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    54
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    55
    |temporaries|
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    56
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    57
    statement.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    58
    statement.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    59
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    60
    "
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    61
     optional: comment giving example use
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    62
    "
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    63
'.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    64
    s cr.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    65
    s emphasis:(UserPreferences current commentEmphasisAndColor).
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    66
    s nextPutAll:
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    67
'"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    68
 change the above template into real code;
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    69
 remove this comment.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    70
 Then `accept'' either via the menu 
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    71
 or via the keyboard (usually CMD-A).
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    72
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    73
 You do not need this template; you can also
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    74
 select any existing methods code, change it,
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    75
 and finally `accept''. The method will then be
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    76
 installed under the selector as defined in the
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    77
 actual text - no matter which method is selected
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    78
 in the browser.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    79
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    80
 Or clear this text, type in the method from scratch
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    81
 and install it with `accept''.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    82
"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    83
'.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    84
    ^ s contents
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    85
!
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    86
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    87
versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    88
    "careful to avoid expansion by cvs here!!"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    89
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    90
    ^ ('version\    ^ ''$' , 'Header$''') withCRs
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    91
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    92
    "Created: / 21-08-2012 / 11:52:27 / cg"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    93
! !
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    94
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
    95
!SmalltalkChunkFileSourceWriter methodsFor:'source writing'!
f700545e4350 initial checkin
ca
parents:
diff changeset
    96
f700545e4350 initial checkin
ca
parents:
diff changeset
    97
fileOut:aClass on:outStreamArg withTimeStamp:stampIt withInitialize:initIt withDefinition:withDefinition methodFilter:methodFilter encoder:encoderOrNil
f700545e4350 initial checkin
ca
parents:
diff changeset
    98
    "file out my definition and all methods onto aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
    99
     If stampIt is true, a timeStamp comment is prepended.
f700545e4350 initial checkin
ca
parents:
diff changeset
   100
     If initIt is true, and the class implements a class-initialize method,
f700545e4350 initial checkin
ca
parents:
diff changeset
   101
     append a corresponding doIt expression for initialization.
f700545e4350 initial checkin
ca
parents:
diff changeset
   102
     The order by which the fileOut is done is used to put the version string at the end.
f700545e4350 initial checkin
ca
parents:
diff changeset
   103
     Thus, if the version string is expanded (by CVS), the characterPositions of methods should not move"
f700545e4350 initial checkin
ca
parents:
diff changeset
   104
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   105
    |collectionOfCategories comment versionMethods
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   106
     nonMeta meta classesImplementingInitialize outStream|
f700545e4350 initial checkin
ca
parents:
diff changeset
   107
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   108
    classBeingSaved := nonMeta := aClass theNonMetaclass.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   109
    meta := nonMeta class.
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   110
    methodsAlreadySaved := Set new.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   111
f700545e4350 initial checkin
ca
parents:
diff changeset
   112
    nonMeta isLoaded ifFalse:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   113
        ^ ClassDescription fileOutErrorSignal 
f700545e4350 initial checkin
ca
parents:
diff changeset
   114
            raiseRequestWith:nonMeta
f700545e4350 initial checkin
ca
parents:
diff changeset
   115
            errorString:' - will not fileOut unloaded class: ', nonMeta name
f700545e4350 initial checkin
ca
parents:
diff changeset
   116
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   117
f700545e4350 initial checkin
ca
parents:
diff changeset
   118
    encoderOrNil isNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   119
        outStream := outStreamArg.
f700545e4350 initial checkin
ca
parents:
diff changeset
   120
    ] ifFalse:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   121
        outStream := EncodedStream stream:outStreamArg encoder:encoderOrNil.
f700545e4350 initial checkin
ca
parents:
diff changeset
   122
        outStream nextPutAll:'"{ Encoding: ' , encoderOrNil nameOfEncoding , ' }"'; cr; cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   123
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   124
f700545e4350 initial checkin
ca
parents:
diff changeset
   125
    "
f700545e4350 initial checkin
ca
parents:
diff changeset
   126
     if there is a copyright method, add a copyright comment
f700545e4350 initial checkin
ca
parents:
diff changeset
   127
     at the beginning, taking the string from the copyright method.
f700545e4350 initial checkin
ca
parents:
diff changeset
   128
     We cannot do this unconditionally - that would lead to my copyrights
f700545e4350 initial checkin
ca
parents:
diff changeset
   129
     being put on your code ;-).
f700545e4350 initial checkin
ca
parents:
diff changeset
   130
     On the other hand: I want every file created by myself to have the
f700545e4350 initial checkin
ca
parents:
diff changeset
   131
     copyright string at the beginning be preserved .... even if the
f700545e4350 initial checkin
ca
parents:
diff changeset
   132
     code was edited in the browser and filedOut.
f700545e4350 initial checkin
ca
parents:
diff changeset
   133
    "
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   134
    self generateHeaderWithCopyrightOn:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   135
f700545e4350 initial checkin
ca
parents:
diff changeset
   136
    stampIt ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   137
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   138
        "/ first, a timestamp
f700545e4350 initial checkin
ca
parents:
diff changeset
   139
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   140
        outStream nextPutAll:(Smalltalk timeStamp).
f700545e4350 initial checkin
ca
parents:
diff changeset
   141
        outStream nextPutChunkSeparator. 
f700545e4350 initial checkin
ca
parents:
diff changeset
   142
        outStream cr; cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   143
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   144
f700545e4350 initial checkin
ca
parents:
diff changeset
   145
    withDefinition ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   146
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   147
        "/ then the definition(s)
f700545e4350 initial checkin
ca
parents:
diff changeset
   148
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   149
        self fileOutAllDefinitionsOf:nonMeta on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   150
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   151
        "/ a comment - if any
f700545e4350 initial checkin
ca
parents:
diff changeset
   152
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   153
        (comment := nonMeta comment) notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   154
            nonMeta fileOutCommentOn:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   155
            outStream cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   156
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   157
        "/
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   158
        "/ ST/X primitive definitions - if any
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   159
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   160
        nonMeta fileOutPrimitiveSpecsOn:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   161
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   162
f700545e4350 initial checkin
ca
parents:
diff changeset
   163
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   164
    "/ methods from all categories in metaclass (i.e. class methods)
f700545e4350 initial checkin
ca
parents:
diff changeset
   165
    "/ EXCEPT: the version method is placed at the very end, to
f700545e4350 initial checkin
ca
parents:
diff changeset
   166
    "/         avoid sourcePosition-shifts when checked out later.
f700545e4350 initial checkin
ca
parents:
diff changeset
   167
    "/         (RCS expands this string, so its size is not constant)
f700545e4350 initial checkin
ca
parents:
diff changeset
   168
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   169
    collectionOfCategories := meta categories asSortedCollection.
12045
ccb1c727370b changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents: 12043
diff changeset
   170
    versionMethods := meta methodDictionary values select:[:mthd | mthd isVersionMethod].
ccb1c727370b changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents: 12043
diff changeset
   171
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   172
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   173
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   174
        "/ documentation first (if any), but not the version method
f700545e4350 initial checkin
ca
parents:
diff changeset
   175
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   176
        (collectionOfCategories includes:'documentation') ifTrue:[
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   177
13754
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   178
"/            versionMethods do:[:versionMethod |
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   179
"/                |source|
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   180
"/
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   181
"/                source := versionMethod source.
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   182
"/                (source isEmptyOrNil or:[(source startsWith:nonMeta nameOfOldVersionMethod) not]) ifTrue:[
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   183
"/                    "something bad happend to the classes code"
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   184
"/
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   185
"/                    Class fileOutErrorSignal 
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   186
"/                        raiseRequestWith:aClass
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   187
"/                        errorString:' - bad source for version method (uncompiled class file?): ', (versionMethod displayString)
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   188
"/                ].
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   189
"/            ].
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   190
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   191
            self fileOutCategory:'documentation' of:meta except:versionMethods only:nil methodFilter:methodFilter on:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   192
            outStream cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   193
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   194
f700545e4350 initial checkin
ca
parents:
diff changeset
   195
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   196
        "/ initialization next (if any)
f700545e4350 initial checkin
ca
parents:
diff changeset
   197
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   198
        (collectionOfCategories includes:'initialization') ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   199
            self fileOutCategory:'initialization' of:meta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   200
            outStream cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   201
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   202
f700545e4350 initial checkin
ca
parents:
diff changeset
   203
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   204
        "/ instance creation next (if any)
f700545e4350 initial checkin
ca
parents:
diff changeset
   205
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   206
        (collectionOfCategories includes:'instance creation') ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   207
            self fileOutCategory:'instance creation' of:meta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   208
            outStream cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   209
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   210
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   211
            ((aCategory ~= 'documentation')
f700545e4350 initial checkin
ca
parents:
diff changeset
   212
            and:[(aCategory ~= 'initialization')
f700545e4350 initial checkin
ca
parents:
diff changeset
   213
            and:[aCategory ~= 'instance creation']]) ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   214
                self fileOutCategory:aCategory of:meta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   215
                outStream cr
f700545e4350 initial checkin
ca
parents:
diff changeset
   216
            ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   217
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   218
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   219
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   220
    "/ if there are any primitive definitions (vw-like ffi-primitives),
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   221
    "/ file them out first in the order: defines, types.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   222
    "/ Otherwise, we might have trouble when filing in later, because the types are needed
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   223
    "/ for the primitive calls.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   224
    nonMeta methodDictionary keysAndValuesDo:[:sel :m |
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   225
        m isVisualWorksTypedef ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   226
            self fileOutCategory:m category of:nonMeta except:nil only:(Array with:m) methodFilter:methodFilter on:outStream.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   227
        ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   228
    ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   229
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   230
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   231
    "/ methods from all categories
f700545e4350 initial checkin
ca
parents:
diff changeset
   232
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   233
    collectionOfCategories := nonMeta categories asSortedCollection.
f700545e4350 initial checkin
ca
parents:
diff changeset
   234
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   235
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   236
            self fileOutCategory:aCategory of:nonMeta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   237
            outStream cr
f700545e4350 initial checkin
ca
parents:
diff changeset
   238
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   239
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   240
f700545e4350 initial checkin
ca
parents:
diff changeset
   241
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   242
    "/ any private classes' methods
f700545e4350 initial checkin
ca
parents:
diff changeset
   243
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   244
    nonMeta privateClassesSorted do:[:aClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   245
        self fileOutAllMethodsOf:aClass on:outStream methodFilter:methodFilter
f700545e4350 initial checkin
ca
parents:
diff changeset
   246
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   247
f700545e4350 initial checkin
ca
parents:
diff changeset
   248
f700545e4350 initial checkin
ca
parents:
diff changeset
   249
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   250
    "/ finally, the previously skipped version method
f700545e4350 initial checkin
ca
parents:
diff changeset
   251
    "/
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   252
    versionMethods notEmpty ifTrue: [
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   253
        self fileOutCategory:'documentation' of:meta except:nil only:versionMethods methodFilter:methodFilter on:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   254
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   255
f700545e4350 initial checkin
ca
parents:
diff changeset
   256
    initIt ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   257
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   258
        "/ optionally an initialize message
f700545e4350 initial checkin
ca
parents:
diff changeset
   259
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   260
        classesImplementingInitialize := OrderedCollection new.
f700545e4350 initial checkin
ca
parents:
diff changeset
   261
f700545e4350 initial checkin
ca
parents:
diff changeset
   262
        (meta includesSelector:#initialize) ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   263
            classesImplementingInitialize add:nonMeta
f700545e4350 initial checkin
ca
parents:
diff changeset
   264
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   265
        nonMeta privateClassesSorted do:[:aPrivateClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   266
            (aPrivateClass theMetaclass includesSelector:#initialize) ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   267
                classesImplementingInitialize add:aPrivateClass
f700545e4350 initial checkin
ca
parents:
diff changeset
   268
            ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   269
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   270
        classesImplementingInitialize size ~~ 0 ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   271
            classesImplementingInitialize topologicalSort:[:a :b | b isSubclassOf:a].
f700545e4350 initial checkin
ca
parents:
diff changeset
   272
            outStream cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   273
            classesImplementingInitialize do:[:eachClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   274
                eachClass printClassNameOn:outStream. outStream nextPutAll:' initialize'.
f700545e4350 initial checkin
ca
parents:
diff changeset
   275
                outStream nextPutChunkSeparator.
f700545e4350 initial checkin
ca
parents:
diff changeset
   276
                outStream cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   277
            ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   278
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   279
    ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   280
10036
51489deaf8c5 care for non-comment in copyright method (JUN stuff)
Claus Gittinger <cg@exept.de>
parents: 8728
diff changeset
   281
    "Created: / 15-11-1995 / 12:53:06 / cg"
51489deaf8c5 care for non-comment in copyright method (JUN stuff)
Claus Gittinger <cg@exept.de>
parents: 8728
diff changeset
   282
    "Modified: / 01-04-1997 / 16:01:05 / stefan"
13754
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   283
    "Modified: / 29-09-2011 / 14:53:49 / cg"
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   284
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   285
f700545e4350 initial checkin
ca
parents:
diff changeset
   286
fileOutAllDefinitionsOf:aNonMetaClass on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   287
    "append expressions on aStream, which defines myself and all of my private classes."
f700545e4350 initial checkin
ca
parents:
diff changeset
   288
f700545e4350 initial checkin
ca
parents:
diff changeset
   289
    aNonMetaClass fileOutDefinitionOn:aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   290
    aStream nextPutChunkSeparator. 
f700545e4350 initial checkin
ca
parents:
diff changeset
   291
    aStream cr; cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   292
f700545e4350 initial checkin
ca
parents:
diff changeset
   293
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   294
    "/ optional classInstanceVariables
f700545e4350 initial checkin
ca
parents:
diff changeset
   295
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   296
    aNonMetaClass class instanceVariableString isBlank ifFalse:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   297
        aNonMetaClass fileOutClassInstVarDefinitionOn:aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   298
        aStream nextPutChunkSeparator. 
f700545e4350 initial checkin
ca
parents:
diff changeset
   299
        aStream cr; cr
f700545e4350 initial checkin
ca
parents:
diff changeset
   300
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   301
f700545e4350 initial checkin
ca
parents:
diff changeset
   302
    "/ here, the full nameSpace prefixes are output,
f700545e4350 initial checkin
ca
parents:
diff changeset
   303
    "/ to avoid confusing stc 
f700545e4350 initial checkin
ca
parents:
diff changeset
   304
    "/ (which otherwise could not find the correct superclass)
f700545e4350 initial checkin
ca
parents:
diff changeset
   305
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   306
    Class fileOutNameSpaceQuerySignal answer:false do:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   307
        Class forceNoNameSpaceQuerySignal answer:true do:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   308
            aNonMetaClass privateClassesSorted do:[:aClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   309
                 self fileOutAllDefinitionsOf:aClass on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   310
            ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   311
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   312
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   313
f700545e4350 initial checkin
ca
parents:
diff changeset
   314
    "Created: 15.10.1996 / 11:15:19 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   315
    "Modified: 22.3.1997 / 16:11:56 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   316
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   317
f700545e4350 initial checkin
ca
parents:
diff changeset
   318
fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter
f700545e4350 initial checkin
ca
parents:
diff changeset
   319
    |collectionOfCategories|
f700545e4350 initial checkin
ca
parents:
diff changeset
   320
f700545e4350 initial checkin
ca
parents:
diff changeset
   321
    collectionOfCategories := aClass class categories asSortedCollection.
f700545e4350 initial checkin
ca
parents:
diff changeset
   322
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   323
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   324
            self fileOutCategory:aCategory of:aClass class  methodFilter:methodFilter on:aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   325
            aStream cr
f700545e4350 initial checkin
ca
parents:
diff changeset
   326
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   327
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   328
    collectionOfCategories := aClass categories asSortedCollection.
f700545e4350 initial checkin
ca
parents:
diff changeset
   329
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   330
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   331
            self fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   332
            aStream cr
f700545e4350 initial checkin
ca
parents:
diff changeset
   333
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   334
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   335
f700545e4350 initial checkin
ca
parents:
diff changeset
   336
    aClass privateClassesSorted do:[:aClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   337
        self fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter
f700545e4350 initial checkin
ca
parents:
diff changeset
   338
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   339
f700545e4350 initial checkin
ca
parents:
diff changeset
   340
    "Created: 15.10.1996 / 11:13:00 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   341
    "Modified: 22.3.1997 / 16:12:17 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   342
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   343
f700545e4350 initial checkin
ca
parents:
diff changeset
   344
fileOutCategory:aCategory of:aClass except:skippedMethods only:savedMethods methodFilter:methodFilter on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   345
    "file out all methods belonging to aCategory, aString onto aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   346
     If skippedMethods is nonNil, those are not saved.
f700545e4350 initial checkin
ca
parents:
diff changeset
   347
     If savedMethods is nonNil, only those are saved.
f700545e4350 initial checkin
ca
parents:
diff changeset
   348
     If both are nil, all are saved. See version-method handling in
f700545e4350 initial checkin
ca
parents:
diff changeset
   349
     fileOut for what this is needed."
f700545e4350 initial checkin
ca
parents:
diff changeset
   350
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   351
    |sortedSelectors first prevPrivacy privacy interestingMethods cat|
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   352
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   353
    interestingMethods := OrderedCollection new.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   354
    aClass methodsDo:[:aMethod |
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   355
        |wanted|
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   356
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   357
        (methodsAlreadySaved includes:aMethod) ifFalse:[
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   358
            (aCategory = aMethod category) ifTrue:[
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   359
                (methodFilter isNil or:[methodFilter value:aMethod]) ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   360
                    skippedMethods notNil ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   361
                        wanted := (skippedMethods includesIdentical:aMethod) not
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   362
                    ] ifFalse:[
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   363
                        wanted := savedMethods isNil or:[ savedMethods includesIdentical:aMethod ].
11703
54e2c3acf7a7 skip non-symbol-selector methods when filing out
Claus Gittinger <cg@exept.de>
parents: 11701
diff changeset
   364
                    ].
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   365
                    wanted ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   366
                        aMethod selector isSymbol ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   367
                            interestingMethods add:aMethod
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   368
                        ] ifFalse:[
14378
3f49f1548631 changed: #fileOutCategory:of:except:only:methodFilter:on:
Stefan Vogel <sv@exept.de>
parents: 14326
diff changeset
   369
                            Transcript showCR:'skipping non-symbol method ', aMethod selector printString.
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   370
                        ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   371
                    ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   372
                ]
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   373
            ]
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   374
        ]
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   375
    ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   376
    interestingMethods notEmpty ifTrue:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   377
        first := true.
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   378
        prevPrivacy := nil.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   379
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   380
        "/
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   381
        "/ sort by selector
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   382
        "/
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   383
        sortedSelectors := interestingMethods collect:[:m | aClass selectorAtMethod:m].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   384
        sortedSelectors sortWith:interestingMethods.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   385
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   386
        interestingMethods do:[:eachMethod |
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   387
            privacy := eachMethod privacy.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   388
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   389
            first ifFalse:[
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   390
                privacy ~~ prevPrivacy ifTrue:[
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   391
                    first := true.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   392
                    aStream space.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   393
                    aStream nextPutChunkSeparator.
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   394
                ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   395
                aStream cr; cr
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   396
            ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   397
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   398
            first ifTrue:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   399
                aStream nextPutChunkSeparator.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   400
                aClass printClassNameOn:aStream.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   401
                privacy ~~ #public ifTrue:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   402
                    aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   403
                ] ifFalse:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   404
                    aStream nextPutAll:' methodsFor:'.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   405
                ].
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   406
                cat := aCategory.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   407
                cat isNil ifTrue:[ cat := '' ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   408
                aStream nextPutAll:aCategory asString storeString.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   409
                aStream nextPutChunkSeparator; cr; cr.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   410
                first := false.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   411
            ].
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   412
            self fileOutMethod:eachMethod on:aStream.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   413
            methodsAlreadySaved add:eachMethod.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   414
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   415
            prevPrivacy := privacy.
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   416
        ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   417
        aStream space.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   418
        aStream nextPutChunkSeparator.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   419
        aStream cr
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   420
    ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   421
f700545e4350 initial checkin
ca
parents:
diff changeset
   422
    "Modified: 28.8.1995 / 14:30:41 / claus"
f700545e4350 initial checkin
ca
parents:
diff changeset
   423
    "Modified: 12.6.1996 / 11:37:33 / stefan"
f700545e4350 initial checkin
ca
parents:
diff changeset
   424
    "Modified: 15.11.1996 / 11:32:21 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   425
    "Created: 1.4.1997 / 16:04:33 / stefan"
f700545e4350 initial checkin
ca
parents:
diff changeset
   426
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   427
f700545e4350 initial checkin
ca
parents:
diff changeset
   428
fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   429
    "file out all methods belonging to aCategory, aString onto aStream"
f700545e4350 initial checkin
ca
parents:
diff changeset
   430
f700545e4350 initial checkin
ca
parents:
diff changeset
   431
    self fileOutCategory:aCategory of:aClass except:nil only:nil methodFilter:methodFilter on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   432
f700545e4350 initial checkin
ca
parents:
diff changeset
   433
    "Created: 1.4.1997 / 16:04:44 / stefan"
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   434
!
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   435
12108
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   436
fileOutCommentEndOn:aStream
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   437
    "Writes a comment end mark on aStream."
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   438
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   439
    "/ intentionally left blank - make each line an EOL-comment instead
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   440
!
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   441
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   442
fileOutCommentLine:aString on:aStream
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   443
    "Writes a single line of comment on a comment to a stream."
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   444
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   445
    aStream 
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   446
        nextPutAll:'"/ ';
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   447
        nextPutAll: aString
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   448
!
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   449
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   450
fileOutCommentStartOn:aStream
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   451
    "Writes a comment start mark on aStream."
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   452
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   453
    "/ intentionally left blank - make each line an EOL-comment instead
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   454
!
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   455
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   456
fileOutMethod:aMethod on:aStream
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   457
    "file a single method onto aStream."
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   458
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   459
    |source possiblyRewrittenSource rewriteQuery|
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   460
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   461
    source := aMethod source.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   462
    source isNil ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   463
        Class fileOutErrorSignal 
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   464
            raiseRequestWith:aMethod mclass
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   465
            errorString:' - no source for method: ', (aMethod displayString)
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   466
    ] ifFalse:[
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   467
        "/ hook to allow for just-in-time rewriting of a method's sourceCode while filing out
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   468
        "/ used when saving version_XXX methods in a non-XXX sourceCodeManager
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   469
        "/ (i.e. to rewrite all non-CVS version methods while saving into a CVS repository)
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   470
        "/ this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   471
        "/ CVS repository without loosing the original string with the next checkout, because it also gets  
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   472
        "/ expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   473
        rewriteQuery := AbstractSourceFileWriter methodSourceRewriteQuery new.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   474
        rewriteQuery method:aMethod source:source.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   475
        possiblyRewrittenSource := (rewriteQuery query) ? source.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   476
        aStream nextChunkPut:possiblyRewrittenSource.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   477
"/possiblyRewrittenSource ~= source ifTrue: [
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   478
"/    Transcript showCR: possiblyRewrittenSource.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   479
"/].
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   480
    ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   481
!
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   482
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   483
fileOutMethods: methods on: stream
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   484
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   485
    methods do:
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   486
        [:method| |cat source privacy|
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   487
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   488
        stream nextPutChunkSeparator.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   489
        method mclass name printOn:stream.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   490
        "/        self printClassNameOn:aStream.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   491
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   492
        (privacy := method privacy) ~~ #public ifTrue:[
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   493
            stream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   494
        ] ifFalse:[
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   495
            stream nextPutAll:' methodsFor:'.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   496
        ].
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   497
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   498
        cat := method category ? ''.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   499
        stream nextPutAll:cat asString storeString.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   500
        stream nextPutChunkSeparator; cr; cr.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   501
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   502
        self fileOutMethod: method on: stream.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   503
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   504
        stream space.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   505
        stream nextPutChunkSeparator.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   506
        stream cr]
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   507
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   508
    "Created: / 30-12-2009 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   509
!
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   510
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   511
fileOutPackageDefinition:pkg on:aStream 
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   512
    (pkg notNil and:[ pkg ~= PackageId noProjectID ]) ifTrue:[
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   513
        aStream nextPutAll:'"{ Package: '''.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   514
        aStream nextPutAll:pkg asString.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   515
        aStream
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   516
            nextPutAll:''' }"'; cr; cr;
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   517
            nextPut:$!!; cr; cr
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   518
    ]
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   519
!
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   520
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   521
generateHeaderWithCopyrightOn:outStream
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   522
    |copyrightMethod copyrightText|
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   523
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   524
    "if there is a copyright method, add a copyright comment
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   525
     at the beginning, taking the string from the copyright method.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   526
     We cannot do this unconditionally - that would lead to my copyrights
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   527
     being put on your code ;-).
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   528
     On the other hand: I want every file created by myself to have the
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   529
     copyright string at the beginning be preserved .... even if the
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   530
     code was edited in the browser and filedOut."
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   531
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   532
    (copyrightMethod := classBeingSaved theMetaclass compiledMethodAt:#copyright) notNil ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   533
        "
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   534
         get the copyright method's comment-text, strip off empty and blank lines
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   535
         and insert at beginning.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   536
        "
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   537
        copyrightText := copyrightMethod comment.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   538
        copyrightText notEmptyOrNil ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   539
            copyrightText := copyrightText asCollectionOfLines asStringCollection.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   540
            copyrightText := copyrightText withoutLeadingBlankLines.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   541
            copyrightText := copyrightText withoutTrailingBlankLines.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   542
            copyrightText notEmpty ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   543
                copyrightText addFirst:'"'.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   544
                copyrightText addLast:'"'.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   545
                copyrightText := copyrightText asString.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   546
                outStream nextPutAllAsChunk:copyrightText.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   547
            ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   548
        ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   549
    ].
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   550
! !
f700545e4350 initial checkin
ca
parents:
diff changeset
   551
f700545e4350 initial checkin
ca
parents:
diff changeset
   552
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'!
f700545e4350 initial checkin
ca
parents:
diff changeset
   553
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   554
version_CVS
14409
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
   555
    ^ '$Header: /cvs/stx/stx/libbasic/SmalltalkChunkFileSourceWriter.st,v 1.18 2012-10-20 19:25:49 cg Exp $'
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   556
!
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   557
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   558
version_SVN
13462
2d4683974fc7 changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13420
diff changeset
   559
    ^ '§ Id: SmalltalkChunkFileSourceWriter.st 10643 2011-06-08 21:53:07Z vranyj1  §'
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   560
! !