SmalltalkChunkFileSourceWriter.st
author Claus Gittinger <cg@exept.de>
Wed, 05 Feb 2014 18:17:24 +0100
changeset 15953 6ad068b28f7d
parent 15421 bfe697cc8b21
child 16878 19f06d12b7da
permissions -rw-r--r--
merged in jv's changes
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
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
    15
	instanceVariableNames:'classBeingSaved methodsAlreadySaved generatingSourceForOriginal'
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
    16
	classVariableNames:''
f700545e4350 initial checkin
ca
parents:
diff changeset
    17
	poolDictionaries:''
15421
bfe697cc8b21 class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents: 15085
diff changeset
    18
	category:'Kernel-Classes-Support'
8227
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
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    43
!SmalltalkChunkFileSourceWriter class methodsFor:'simple API'!
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    44
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    45
fileOut:aClass on:aStream
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    46
    self fileOut:aClass on:aStream withTimeStamp:true
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    47
        withInitialize:true withDefinition:true
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    48
        methodFilter:nil encoder:nil
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    49
!
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    50
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    51
fileOut:aClass on:aStream withTimeStamp:withTimeStamp
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    52
        withInitialize:initIt withDefinition:withDefinition
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    53
        methodFilter:methodFilter encoder:encoderOrNil
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    54
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    55
    self new
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    56
        fileOut:aClass on:aStream withTimeStamp:withTimeStamp
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    57
        withInitialize:initIt withDefinition:withDefinition
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    58
        methodFilter:methodFilter encoder:encoderOrNil
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    59
! !
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    60
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    61
!SmalltalkChunkFileSourceWriter class methodsFor:'utilities - source code'!
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    62
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    63
methodTemplate
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    64
    "return a method definition template string"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    65
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    66
    |s|
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    67
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    68
    s := TextStream on:''.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    69
    s nextPutAll:
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    70
'message selector and argument names
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    71
    "comment stating purpose of this message"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    72
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    73
    |temporaries|
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    74
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    75
    statement.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    76
    statement.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    77
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    78
    "
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    79
     optional: comment giving example use
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    80
    "
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    81
'.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    82
    s cr.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    83
    s emphasis:(UserPreferences current commentEmphasisAndColor).
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    84
    s nextPutAll:
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    85
'"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    86
 change the above template into real code;
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    87
 remove this comment.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    88
 Then `accept'' either via the menu 
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    89
 or via the keyboard (usually CMD-A).
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    90
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    91
 You do not need this template; you can also
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    92
 select any existing methods code, change it,
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    93
 and finally `accept''. The method will then be
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    94
 installed under the selector as defined in the
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    95
 actual text - no matter which method is selected
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    96
 in the browser.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    97
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    98
 Or clear this text, type in the method from scratch
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    99
 and install it with `accept''.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   100
"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   101
'.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   102
    ^ s contents
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   103
!
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   104
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   105
versionMethodTemplateForCVS
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   106
    "careful to avoid expansion by cvs here!!"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   107
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   108
    ^ ('version\    ^ ''$' , 'Header$''') withCRs
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   109
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   110
    "Created: / 21-08-2012 / 11:52:27 / cg"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   111
! !
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   112
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   113
!SmalltalkChunkFileSourceWriter methodsFor:'accessing'!
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   114
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   115
generatingSourceForOriginal:aBoolean
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   116
    "if false (the default), the source of the current (in image) code is generated.
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   117
     That means, that any extension method which shadows some other original method,
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   118
     that extension method's code is generated.
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   119
     if true, the code of the original method is generated.
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   120
     Use a true value, when generating code for a SCM checkin operation, as then we do not
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   121
     want the extension to shadow the original"
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   122
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   123
    generatingSourceForOriginal := aBoolean.
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   124
! !
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   125
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   126
!SmalltalkChunkFileSourceWriter methodsFor:'source writing'!
f700545e4350 initial checkin
ca
parents:
diff changeset
   127
f700545e4350 initial checkin
ca
parents:
diff changeset
   128
fileOut:aClass on:outStreamArg withTimeStamp:stampIt withInitialize:initIt withDefinition:withDefinition methodFilter:methodFilter encoder:encoderOrNil
f700545e4350 initial checkin
ca
parents:
diff changeset
   129
    "file out my definition and all methods onto aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   130
     If stampIt is true, a timeStamp comment is prepended.
f700545e4350 initial checkin
ca
parents:
diff changeset
   131
     If initIt is true, and the class implements a class-initialize method,
f700545e4350 initial checkin
ca
parents:
diff changeset
   132
     append a corresponding doIt expression for initialization.
f700545e4350 initial checkin
ca
parents:
diff changeset
   133
     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
   134
     Thus, if the version string is expanded (by CVS), the characterPositions of methods should not move"
f700545e4350 initial checkin
ca
parents:
diff changeset
   135
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   136
    |collectionOfCategories comment versionMethods
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   137
     nonMeta meta classesImplementingInitialize outStream|
f700545e4350 initial checkin
ca
parents:
diff changeset
   138
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   139
    classBeingSaved := nonMeta := aClass theNonMetaclass.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   140
    meta := nonMeta class.
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   141
    methodsAlreadySaved := Set new.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   142
f700545e4350 initial checkin
ca
parents:
diff changeset
   143
    nonMeta isLoaded ifFalse:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   144
        ^ ClassDescription fileOutErrorSignal 
f700545e4350 initial checkin
ca
parents:
diff changeset
   145
            raiseRequestWith:nonMeta
f700545e4350 initial checkin
ca
parents:
diff changeset
   146
            errorString:' - will not fileOut unloaded class: ', nonMeta name
f700545e4350 initial checkin
ca
parents:
diff changeset
   147
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   148
f700545e4350 initial checkin
ca
parents:
diff changeset
   149
    encoderOrNil isNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   150
        outStream := outStreamArg.
f700545e4350 initial checkin
ca
parents:
diff changeset
   151
    ] ifFalse:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   152
        outStream := EncodedStream stream:outStreamArg encoder:encoderOrNil.
f700545e4350 initial checkin
ca
parents:
diff changeset
   153
        outStream nextPutAll:'"{ Encoding: ' , encoderOrNil nameOfEncoding , ' }"'; cr; cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   154
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   155
f700545e4350 initial checkin
ca
parents:
diff changeset
   156
    "
f700545e4350 initial checkin
ca
parents:
diff changeset
   157
     if there is a copyright method, add a copyright comment
f700545e4350 initial checkin
ca
parents:
diff changeset
   158
     at the beginning, taking the string from the copyright method.
f700545e4350 initial checkin
ca
parents:
diff changeset
   159
     We cannot do this unconditionally - that would lead to my copyrights
f700545e4350 initial checkin
ca
parents:
diff changeset
   160
     being put on your code ;-).
f700545e4350 initial checkin
ca
parents:
diff changeset
   161
     On the other hand: I want every file created by myself to have the
f700545e4350 initial checkin
ca
parents:
diff changeset
   162
     copyright string at the beginning be preserved .... even if the
f700545e4350 initial checkin
ca
parents:
diff changeset
   163
     code was edited in the browser and filedOut.
f700545e4350 initial checkin
ca
parents:
diff changeset
   164
    "
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   165
    self generateHeaderWithCopyrightOn:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   166
f700545e4350 initial checkin
ca
parents:
diff changeset
   167
    stampIt ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   168
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   169
        "/ first, a timestamp
f700545e4350 initial checkin
ca
parents:
diff changeset
   170
        "/
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   171
        self generateTimestampOn:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   172
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   173
f700545e4350 initial checkin
ca
parents:
diff changeset
   174
    withDefinition ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   175
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   176
        "/ then the definition(s)
f700545e4350 initial checkin
ca
parents:
diff changeset
   177
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   178
        self fileOutAllDefinitionsOf:nonMeta on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   179
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   180
        "/ a comment - if any
f700545e4350 initial checkin
ca
parents:
diff changeset
   181
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   182
        (comment := nonMeta comment) notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   183
            nonMeta fileOutCommentOn:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   184
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   185
        "/
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   186
        "/ ST/X primitive definitions - if any
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   187
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   188
        nonMeta fileOutPrimitiveSpecsOn:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   189
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   190
f700545e4350 initial checkin
ca
parents:
diff changeset
   191
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   192
    "/ methods from all categories in metaclass (i.e. class methods)
f700545e4350 initial checkin
ca
parents:
diff changeset
   193
    "/ EXCEPT: the version method is placed at the very end, to
f700545e4350 initial checkin
ca
parents:
diff changeset
   194
    "/         avoid sourcePosition-shifts when checked out later.
f700545e4350 initial checkin
ca
parents:
diff changeset
   195
    "/         (RCS expands this string, so its size is not constant)
f700545e4350 initial checkin
ca
parents:
diff changeset
   196
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   197
    collectionOfCategories := meta categories asSortedCollection.
12045
ccb1c727370b changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents: 12043
diff changeset
   198
    versionMethods := meta methodDictionary values select:[:mthd | mthd isVersionMethod].
ccb1c727370b changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents: 12043
diff changeset
   199
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   200
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   201
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   202
        "/ documentation first (if any), but not the version method
f700545e4350 initial checkin
ca
parents:
diff changeset
   203
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   204
        (collectionOfCategories includes:'documentation') ifTrue:[
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   205
13754
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   206
"/            versionMethods do:[:versionMethod |
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   207
"/                |source|
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   208
"/
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   209
"/                source := versionMethod source.
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   210
"/                (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
   211
"/                    "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
   212
"/
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   213
"/                    Class fileOutErrorSignal 
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   214
"/                        raiseRequestWith:aClass
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   215
"/                        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
   216
"/                ].
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   217
"/            ].
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   218
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   219
            self fileOutCategory:'documentation' of:meta except:versionMethods only:nil methodFilter:methodFilter on:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   220
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   221
f700545e4350 initial checkin
ca
parents:
diff changeset
   222
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   223
        "/ initialization next (if any)
f700545e4350 initial checkin
ca
parents:
diff changeset
   224
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   225
        (collectionOfCategories includes:'initialization') ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   226
            self fileOutCategory:'initialization' of:meta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   227
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   228
f700545e4350 initial checkin
ca
parents:
diff changeset
   229
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   230
        "/ instance creation next (if any)
f700545e4350 initial checkin
ca
parents:
diff changeset
   231
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   232
        (collectionOfCategories includes:'instance creation') ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   233
            self fileOutCategory:'instance creation' of:meta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   234
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   235
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   236
            ((aCategory ~= 'documentation')
f700545e4350 initial checkin
ca
parents:
diff changeset
   237
            and:[(aCategory ~= 'initialization')
f700545e4350 initial checkin
ca
parents:
diff changeset
   238
            and:[aCategory ~= 'instance creation']]) ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   239
                self fileOutCategory:aCategory of:meta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   240
            ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   241
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   242
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   243
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   244
    "/ 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
   245
    "/ 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
   246
    "/ 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
   247
    "/ for the primitive calls.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   248
    nonMeta methodDictionary keysAndValuesDo:[:sel :m |
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   249
        m isVisualWorksTypedef ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   250
            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
   251
        ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   252
    ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   253
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   254
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   255
    "/ methods from all categories
f700545e4350 initial checkin
ca
parents:
diff changeset
   256
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   257
    collectionOfCategories := nonMeta categories asSortedCollection.
f700545e4350 initial checkin
ca
parents:
diff changeset
   258
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   259
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   260
            self fileOutCategory:aCategory of:nonMeta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   261
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   262
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   263
f700545e4350 initial checkin
ca
parents:
diff changeset
   264
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   265
    "/ any private classes' methods
f700545e4350 initial checkin
ca
parents:
diff changeset
   266
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   267
    nonMeta privateClassesSorted do:[:aClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   268
        self fileOutAllMethodsOf:aClass on:outStream methodFilter:methodFilter
f700545e4350 initial checkin
ca
parents:
diff changeset
   269
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   270
f700545e4350 initial checkin
ca
parents:
diff changeset
   271
f700545e4350 initial checkin
ca
parents:
diff changeset
   272
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   273
    "/ finally, the previously skipped version method
f700545e4350 initial checkin
ca
parents:
diff changeset
   274
    "/
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   275
    versionMethods notEmpty ifTrue: [
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   276
        self fileOutCategory:'documentation' of:meta except:nil only:versionMethods methodFilter:methodFilter on:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   277
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   278
f700545e4350 initial checkin
ca
parents:
diff changeset
   279
    initIt ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   280
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   281
        "/ optionally an initialize message
f700545e4350 initial checkin
ca
parents:
diff changeset
   282
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   283
        classesImplementingInitialize := OrderedCollection new.
f700545e4350 initial checkin
ca
parents:
diff changeset
   284
f700545e4350 initial checkin
ca
parents:
diff changeset
   285
        (meta includesSelector:#initialize) ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   286
            classesImplementingInitialize add:nonMeta
f700545e4350 initial checkin
ca
parents:
diff changeset
   287
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   288
        nonMeta privateClassesSorted do:[:aPrivateClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   289
            (aPrivateClass theMetaclass includesSelector:#initialize) ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   290
                classesImplementingInitialize add:aPrivateClass
f700545e4350 initial checkin
ca
parents:
diff changeset
   291
            ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   292
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   293
        classesImplementingInitialize size ~~ 0 ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   294
            classesImplementingInitialize topologicalSort:[:a :b | b isSubclassOf:a].
f700545e4350 initial checkin
ca
parents:
diff changeset
   295
            outStream cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   296
            classesImplementingInitialize do:[:eachClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   297
                eachClass printClassNameOn:outStream. outStream nextPutAll:' initialize'.
f700545e4350 initial checkin
ca
parents:
diff changeset
   298
                outStream nextPutChunkSeparator.
f700545e4350 initial checkin
ca
parents:
diff changeset
   299
                outStream 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
    ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   303
10036
51489deaf8c5 care for non-comment in copyright method (JUN stuff)
Claus Gittinger <cg@exept.de>
parents: 8728
diff changeset
   304
    "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
   305
    "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
   306
    "Modified: / 29-09-2011 / 14:53:49 / cg"
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   307
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   308
f700545e4350 initial checkin
ca
parents:
diff changeset
   309
fileOutAllDefinitionsOf:aNonMetaClass on:aStream
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   310
    self fileOutAllDefinitionsOf:aNonMetaClass on:aStream withNameSpace: true.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   311
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   312
    "Created: / 15-10-1996 / 11:15:19 / cg"
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   313
    "Modified: / 22-03-1997 / 16:11:56 / cg"
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   314
    "Modified: / 04-02-2014 / 20:00:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   315
!
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   316
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   317
fileOutAllDefinitionsOf:aNonMetaClass on:aStream withNameSpace: withNameSpacePragma
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   318
    "append expressions on aStream, which defines myself and all of my private classes."
f700545e4350 initial checkin
ca
parents:
diff changeset
   319
15085
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   320
    |s|
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   321
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   322
    s := CharacterWriteStream on:(String new:50).
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   323
    self fileOutDefinitionOf:aNonMetaClass on:s withNameSpace: withNameSpacePragma.
15085
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   324
    aStream nextChunkPut:(s contents).
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   325
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   326
    "/ self fileOutDefinitionOf:aNonMetaClass on:aStream.
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   327
    "/ aStream nextPutChunkSeparator. 
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   328
    aStream cr; cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   329
f700545e4350 initial checkin
ca
parents:
diff changeset
   330
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   331
    "/ optional classInstanceVariables
f700545e4350 initial checkin
ca
parents:
diff changeset
   332
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   333
    aNonMetaClass class instanceVariableString isBlank ifFalse:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   334
        aNonMetaClass fileOutClassInstVarDefinitionOn:aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   335
        aStream nextPutChunkSeparator. 
f700545e4350 initial checkin
ca
parents:
diff changeset
   336
        aStream cr; cr
f700545e4350 initial checkin
ca
parents:
diff changeset
   337
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   338
f700545e4350 initial checkin
ca
parents:
diff changeset
   339
    "/ here, the full nameSpace prefixes are output,
f700545e4350 initial checkin
ca
parents:
diff changeset
   340
    "/ to avoid confusing stc 
f700545e4350 initial checkin
ca
parents:
diff changeset
   341
    "/ (which otherwise could not find the correct superclass)
f700545e4350 initial checkin
ca
parents:
diff changeset
   342
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   343
    Class fileOutNameSpaceQuerySignal answer:false do:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   344
        Class forceNoNameSpaceQuerySignal answer:true do:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   345
            aNonMetaClass privateClassesSorted do:[:aClass |
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   346
                 self fileOutAllDefinitionsOf:aClass on:aStream withNameSpace: false
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   347
            ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   348
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   349
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   350
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   351
    "Created: / 04-02-2014 / 20:00:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   352
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   353
f700545e4350 initial checkin
ca
parents:
diff changeset
   354
fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter
f700545e4350 initial checkin
ca
parents:
diff changeset
   355
    |collectionOfCategories|
f700545e4350 initial checkin
ca
parents:
diff changeset
   356
f700545e4350 initial checkin
ca
parents:
diff changeset
   357
    collectionOfCategories := aClass class categories asSortedCollection.
f700545e4350 initial checkin
ca
parents:
diff changeset
   358
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   359
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   360
            self fileOutCategory:aCategory of:aClass class  methodFilter:methodFilter on:aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   361
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   362
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   363
    collectionOfCategories := aClass categories asSortedCollection.
f700545e4350 initial checkin
ca
parents:
diff changeset
   364
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   365
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   366
            self fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   367
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   368
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   369
f700545e4350 initial checkin
ca
parents:
diff changeset
   370
    aClass privateClassesSorted do:[:aClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   371
        self fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter
f700545e4350 initial checkin
ca
parents:
diff changeset
   372
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   373
f700545e4350 initial checkin
ca
parents:
diff changeset
   374
    "Created: 15.10.1996 / 11:13:00 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   375
    "Modified: 22.3.1997 / 16:12:17 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   376
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   377
f700545e4350 initial checkin
ca
parents:
diff changeset
   378
fileOutCategory:aCategory of:aClass except:skippedMethods only:savedMethods methodFilter:methodFilter on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   379
    "file out all methods belonging to aCategory, aString onto aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   380
     If skippedMethods is nonNil, those are not saved.
f700545e4350 initial checkin
ca
parents:
diff changeset
   381
     If savedMethods is nonNil, only those are saved.
f700545e4350 initial checkin
ca
parents:
diff changeset
   382
     If both are nil, all are saved. See version-method handling in
f700545e4350 initial checkin
ca
parents:
diff changeset
   383
     fileOut for what this is needed."
f700545e4350 initial checkin
ca
parents:
diff changeset
   384
14983
a0b8519d7c50 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14596
diff changeset
   385
    |sortedSelectors first prevPrivacy privacy interestingMethods cat prjDef|
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   386
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   387
    interestingMethods := OrderedCollection new.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   388
    aClass methodsDo:[:aMethod |
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   389
        |wanted|
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   390
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   391
        (methodsAlreadySaved includes:aMethod) ifFalse:[
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   392
            (aCategory = aMethod category) ifTrue:[
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   393
                (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
   394
                    skippedMethods notNil ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   395
                        wanted := (skippedMethods includesIdentical:aMethod) not
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   396
                    ] ifFalse:[
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   397
                        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
   398
                    ].
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   399
                    wanted ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   400
                        aMethod selector isSymbol ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   401
                            interestingMethods add:aMethod
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   402
                        ] ifFalse:[
14378
3f49f1548631 changed: #fileOutCategory:of:except:only:methodFilter:on:
Stefan Vogel <sv@exept.de>
parents: 14326
diff changeset
   403
                            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
   404
                        ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   405
                    ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   406
                ]
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   407
            ]
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   408
        ]
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   409
    ].
14983
a0b8519d7c50 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14596
diff changeset
   410
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   411
    interestingMethods notEmpty ifTrue:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   412
        "/
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   413
        "/ sort by selector
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   414
        "/
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   415
        sortedSelectors := interestingMethods collect:[:m | aClass selectorAtMethod:m].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   416
        sortedSelectors sortWith:interestingMethods.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   417
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   418
        generatingSourceForOriginal == true ifTrue:[
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   419
            "/ care for methods which have been shadowed by an extension from another package!!
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   420
            (prjDef := aClass theNonMetaclass projectDefinitionClass) notNil ifTrue:[
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   421
                prjDef hasSavedOverwrittenMethods ifTrue:[
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   422
                    interestingMethods := interestingMethods collect:[:m |
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   423
                                                |originalOrNil|
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   424
                                                
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   425
                                                (m package ~~ aClass package) ifTrue:[ 
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   426
                                                    originalOrNil := prjDef savedOverwrittenMethods at:(aClass name -> m selector) ifAbsent:nil.
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   427
                                                    originalOrNil notNil ifTrue:[ 
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   428
                                                        self breakPoint:#cg 
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   429
                                                    ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   430
                                                ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   431
                                                originalOrNil ? m
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   432
                                          ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   433
                ]
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   434
            ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   435
        ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   436
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   437
        first := true.
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   438
        prevPrivacy := nil.
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   439
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   440
        interestingMethods do:[:eachMethod |
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   441
            privacy := eachMethod privacy.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   442
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   443
            first ifFalse:[
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   444
                privacy ~~ prevPrivacy ifTrue:[
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   445
                    first := true.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   446
                    aStream space.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   447
                    aStream nextPutChunkSeparator.
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   448
                ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   449
                aStream cr; cr
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   450
            ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   451
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   452
            first ifTrue:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   453
                aStream nextPutChunkSeparator.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   454
                aClass printClassNameOn:aStream.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   455
                privacy ~~ #public ifTrue:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   456
                    aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   457
                ] ifFalse:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   458
                    aStream nextPutAll:' methodsFor:'.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   459
                ].
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   460
                cat := aCategory.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   461
                cat isNil ifTrue:[ cat := '' ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   462
                aStream nextPutAll:aCategory asString storeString.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   463
                aStream nextPutChunkSeparator; cr; cr.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   464
                first := false.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   465
            ].
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   466
            self fileOutMethod:eachMethod on:aStream.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   467
            methodsAlreadySaved add:eachMethod.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   468
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   469
            prevPrivacy := privacy.
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   470
        ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   471
        aStream space.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   472
        aStream nextPutChunkSeparator.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   473
        aStream cr
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   474
    ].
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   475
    aStream cr
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   476
f700545e4350 initial checkin
ca
parents:
diff changeset
   477
    "Modified: 28.8.1995 / 14:30:41 / claus"
f700545e4350 initial checkin
ca
parents:
diff changeset
   478
    "Modified: 12.6.1996 / 11:37:33 / stefan"
f700545e4350 initial checkin
ca
parents:
diff changeset
   479
    "Modified: 15.11.1996 / 11:32:21 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   480
    "Created: 1.4.1997 / 16:04:33 / stefan"
f700545e4350 initial checkin
ca
parents:
diff changeset
   481
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   482
f700545e4350 initial checkin
ca
parents:
diff changeset
   483
fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   484
    "file out all methods belonging to aCategory, aString onto aStream"
f700545e4350 initial checkin
ca
parents:
diff changeset
   485
f700545e4350 initial checkin
ca
parents:
diff changeset
   486
    self fileOutCategory:aCategory of:aClass except:nil only:nil methodFilter:methodFilter on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   487
f700545e4350 initial checkin
ca
parents:
diff changeset
   488
    "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
   489
!
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   490
12108
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   491
fileOutCommentEndOn:aStream
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   492
    "Writes a comment end mark on aStream."
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   493
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   494
    "/ intentionally left blank - make each line an EOL-comment instead
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   495
!
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   496
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   497
fileOutCommentLine:aString on:aStream
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   498
    "Writes a single line of comment on a comment to a stream."
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   499
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   500
    aStream 
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   501
        nextPutAll:'"/ ';
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   502
        nextPutAll: aString
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   503
!
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   504
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   505
fileOutCommentStartOn:aStream
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   506
    "Writes a comment start mark on aStream."
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   507
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   508
    "/ intentionally left blank - make each line an EOL-comment instead
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   509
!
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   510
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   511
fileOutDefinitionOf:aNonMetaClass on:aStream
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   512
    aNonMetaClass fileOutDefinitionOn:aStream.
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   513
!
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   514
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   515
fileOutDefinitionOf:aNonMetaClass on:aStream withNameSpace: withNameSpacePragma
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   516
    aNonMetaClass basicFileOutDefinitionOn:aStream withNameSpace: withNameSpacePragma
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   517
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   518
    "Created: / 04-02-2014 / 20:00:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   519
!
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   520
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   521
fileOutMethod:aMethod on:aStream
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   522
    "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
   523
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   524
    |source possiblyRewrittenSource rewriteQuery|
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   525
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   526
    source := aMethod source.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   527
    source isNil ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   528
        Class fileOutErrorSignal 
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   529
            raiseRequestWith:aMethod mclass
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   530
            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
   531
    ] ifFalse:[
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   532
        "/ hook to allow for just-in-time rewriting of a method's sourceCode while filing out
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   533
        "/ used when saving version_XXX methods in a non-XXX sourceCodeManager
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   534
        "/ (i.e. to rewrite all non-CVS version methods while saving into a CVS repository)
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   535
        "/ this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   536
        "/ CVS repository without loosing the original string with the next checkout, because it also gets  
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   537
        "/ expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   538
        rewriteQuery := AbstractSourceFileWriter methodSourceRewriteQuery new.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   539
        rewriteQuery method:aMethod source:source.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   540
        possiblyRewrittenSource := (rewriteQuery query) ? source.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   541
        aStream nextChunkPut:possiblyRewrittenSource.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   542
"/possiblyRewrittenSource ~= source ifTrue: [
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   543
"/    Transcript showCR: possiblyRewrittenSource.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   544
"/].
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   545
    ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   546
!
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   547
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   548
fileOutMethods: methods on: stream
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   549
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   550
    methods do:[:method| 
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   551
        |cat source privacy|
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   552
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   553
        stream nextPutChunkSeparator.
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   554
        "JV@2012-09-05: Support for filing out Java extension methods"
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   555
        method mclass theNonMetaclass isJavaClass ifTrue:[
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   556
            | class classBinaryName comps |
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   557
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   558
            class := method mclass theNonMetaclass .
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   559
            "Sigh, make it compatible with old and new naming of Java classes
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   560
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   561
            old -> aJavaClass name == #'java/lang/Object'
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   562
            new -> aJavaClass name == JAVA::java::lang::Object
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   563
                   aJavaClass binaryName == #'java/lang/Object'
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   564
            "
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   565
            classBinaryName := (class respondsTo: #binaryName) 
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   566
                                    ifTrue:[ class binaryName ]
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   567
                                    ifFalse:[ class name ].      
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   568
            stream nextPutAll:'(Java classForName:'''.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   569
            stream nextPutAll:(classBinaryName copyReplaceAll:$/ with: $.).
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   570
            stream nextPutAll:''')'.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   571
            method mclass isMetaclass ifTrue:[
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   572
                stream nextPutAll: ' class'.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   573
            ].
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   574
        ] ifFalse:[
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   575
            method mclass name printOn:stream.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   576
        ].
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   577
        "/        self printClassNameOn:aStream.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   578
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   579
        (privacy := method privacy) ~~ #public ifTrue:[
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   580
            stream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   581
        ] ifFalse:[
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   582
            stream nextPutAll:' methodsFor:'.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   583
        ].
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   584
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   585
        cat := method category ? ''.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   586
        stream nextPutAll:cat asString storeString.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   587
        stream nextPutChunkSeparator; cr; cr.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   588
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   589
        self fileOutMethod: method on: stream.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   590
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   591
        stream space.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   592
        stream nextPutChunkSeparator.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   593
        stream cr]
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   594
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   595
    "Created: / 30-12-2009 / 18:43:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   596
    "Modified: / 09-10-2013 / 08:57:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   597
!
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   598
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   599
fileOutPackageDefinition:pkg on:aStream 
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   600
    (pkg notNil and:[ pkg ~= PackageId noProjectID ]) ifTrue:[
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   601
        aStream nextPutAll:'"{ Package: '''.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   602
        aStream nextPutAll:pkg asString.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   603
        aStream
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   604
            nextPutAll:''' }"'; cr; cr;
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   605
            nextPut:$!!; cr; cr
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   606
    ]
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   607
!
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   608
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   609
generateHeaderWithCopyrightOn:outStream
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   610
    |copyrightMethod copyrightText|
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   611
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   612
    "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
   613
     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
   614
     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
   615
     being put on your code ;-).
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   616
     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
   617
     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
   618
     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
   619
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   620
    (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
   621
        "
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   622
         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
   623
         and insert at beginning.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   624
        "
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   625
        copyrightText := copyrightMethod comment.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   626
        copyrightText notEmptyOrNil ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   627
            copyrightText := copyrightText asCollectionOfLines asStringCollection.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   628
            copyrightText := copyrightText withoutLeadingBlankLines.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   629
            copyrightText := copyrightText withoutTrailingBlankLines.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   630
            copyrightText notEmpty ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   631
                copyrightText addFirst:'"'.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   632
                copyrightText addLast:'"'.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   633
                copyrightText := copyrightText asString.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   634
                outStream nextPutAllAsChunk:copyrightText.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   635
            ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   636
        ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   637
    ].
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   638
!
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   639
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   640
generateTimestampOn:outStream
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   641
    outStream nextPutAll:(Smalltalk timeStamp).
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   642
    outStream nextPutChunkSeparator. 
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   643
    outStream cr; cr.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   644
! !
f700545e4350 initial checkin
ca
parents:
diff changeset
   645
f700545e4350 initial checkin
ca
parents:
diff changeset
   646
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'!
f700545e4350 initial checkin
ca
parents:
diff changeset
   647
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   648
version
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   649
    ^ '$Header: /cvs/stx/stx/libbasic/SmalltalkChunkFileSourceWriter.st,v 1.24 2014-02-05 17:17:24 cg Exp $'
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   650
!
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   651
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   652
version_CVS
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   653
    ^ '$Header: /cvs/stx/stx/libbasic/SmalltalkChunkFileSourceWriter.st,v 1.24 2014-02-05 17:17:24 cg Exp $'
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   654
!
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   655
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   656
version_SVN
15421
bfe697cc8b21 class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents: 15085
diff changeset
   657
    ^ '$ Id: SmalltalkChunkFileSourceWriter.st 10643 2011-06-08 21:53:07Z vranyj1  $'
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   658
! !
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   659