SmalltalkChunkFileSourceWriter.st
author Claus Gittinger <cg@exept.de>
Fri, 29 Apr 2016 11:46:44 +0200
changeset 19672 4977d6cce6a9
parent 18554 ead4614d7aaa
child 19691 5e613f6255d9
child 19875 85383ff294d8
permissions -rw-r--r--
#REFACTORING by cg class: SmalltalkChunkFileSourceWriter added: #methodTemplateForDocumentation changed: #methodTemplate #versionMethodTemplateForCVS code generation (templates) should be in codeGenerator
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
17333
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
    14
"{ NameSpace: Smalltalk }"
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
    15
11963
0419e28049e4 parent class changed to AbstractChunkFileSourceWriter
fm
parents: 11853
diff changeset
    16
AbstractSourceFileWriter subclass:#SmalltalkChunkFileSourceWriter
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
    17
	instanceVariableNames:'classBeingSaved methodsAlreadySaved'
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
    18
	classVariableNames:''
f700545e4350 initial checkin
ca
parents:
diff changeset
    19
	poolDictionaries:''
15421
bfe697cc8b21 class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents: 15085
diff changeset
    20
	category:'Kernel-Classes-Support'
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
    21
!
f700545e4350 initial checkin
ca
parents:
diff changeset
    22
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    23
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'!
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
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    26
"
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    27
 COPYRIGHT (c) 2004 by eXept Software AG
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    28
              All Rights Reserved
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    29
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    30
 This software is furnished under a license and may be used
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    31
 only in accordance with the terms of that license and with the
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    33
 be provided or otherwise made available to, or used by, any
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    34
 other person.  No title to or ownership of the software is
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    35
 hereby transferred.
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    36
"
14409
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    37
!
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
documentation
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    40
"
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    41
    I know how to write smalltalk chunk file format
6f53326ef2da added: #documentation
Claus Gittinger <cg@exept.de>
parents: 14378
diff changeset
    42
"
8728
d70396dc4e96 copyright
Claus Gittinger <cg@exept.de>
parents: 8227
diff changeset
    43
! !
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
    44
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    45
!SmalltalkChunkFileSourceWriter class methodsFor:'simple API'!
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    46
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    47
fileOut:aClass on:aStream
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    48
    self fileOut:aClass on:aStream withTimeStamp:true
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    49
        withInitialize:true withDefinition:true
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    50
        methodFilter:nil encoder:nil
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    51
!
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    52
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    53
fileOut:aClass on:aStream withTimeStamp:withTimeStamp
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    54
        withInitialize:initIt withDefinition:withDefinition
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    55
        methodFilter:methodFilter encoder:encoderOrNil
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    56
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    57
    self new
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    58
        fileOut:aClass on:aStream withTimeStamp:withTimeStamp
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    59
        withInitialize:initIt withDefinition:withDefinition
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    60
        methodFilter:methodFilter encoder:encoderOrNil
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    61
! !
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
    62
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    63
!SmalltalkChunkFileSourceWriter class methodsFor:'utilities - source code'!
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    64
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    65
methodTemplate
19672
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
    66
    <resource: #obsolete>
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    67
    "return a method definition template string"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    68
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    69
    |s|
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    70
19672
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
    71
    self obsoleteMethodWarning:'use codeGenerator'.
18554
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
    72
    s := (TextStream ? WriteStream) on:''.
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    73
    s nextPutAll:
18554
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
    74
'message "selector and argument names"
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    75
    "comment stating purpose of this message"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    76
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    77
    |temporaries|
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    78
18554
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
    79
    "statement."
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
    80
    "statement."
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    81
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    82
    "
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    83
     optional: comment giving example use
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    84
    "
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    85
'.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    86
    s cr.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    87
    s emphasis:(UserPreferences current commentEmphasisAndColor).
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    88
    s nextPutAll:
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    89
'"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    90
 change the above template into real code;
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    91
 remove this comment.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    92
 Then `accept'' either via the menu 
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    93
 or via the keyboard (usually CMD-A).
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    94
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    95
 You do not need this template; you can also
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    96
 select any existing methods code, change it,
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    97
 and finally `accept''. The method will then be
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    98
 installed under the selector as defined in the
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
    99
 actual text - no matter which method is selected
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   100
 in the browser.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   101
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   102
 Or clear this text, type in the method from scratch
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   103
 and install it with `accept''.
18554
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
   104
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
   105
 If you don''t like this method template to appear,
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
   106
 disable it either via the global or browser''s settings dialog,
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
   107
 or by evaluating:
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
   108
     UserPreferences current showMethodTemplate:false
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   109
"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   110
'.
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   111
    ^ s contents
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   112
!
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   113
19672
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   114
methodTemplateForDocumentation
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   115
    <resource: #obsolete>
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   116
    "return a method definition template string"
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   117
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   118
    |s|
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   119
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   120
    self obsoleteMethodWarning:'use codeGenerator'.
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   121
    s := (TextStream ? WriteStream) on:''.
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   122
    s nextPutAll:
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   123
'documentation
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   124
'.
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   125
    s emphasis:(UserPreferences current commentEmphasisAndColor).
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   126
    s nextPutAll:(
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   127
'"
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   128
    comment describing this class.
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   129
    you can disable the generation of this template by evaluating:
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   130
         UserPreferences current showMethodTemplate:false
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   131
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   132
    [instance variables:]
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   133
        describe instance variables
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   134
    [class variables:]
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   135
        describe class variables
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   136
    [see also:]
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   137
        
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   138
    [author:]
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   139
        %1
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   140
"
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   141
' bindWith:(OperatingSystem getFullUserName)).
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   142
    ^ s contents
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   143
!
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   144
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   145
versionMethodTemplateForCVS
19672
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   146
    <resource: #obsolete>
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   147
    "careful to avoid expansion by cvs here!!"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   148
19672
4977d6cce6a9 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 18554
diff changeset
   149
    self obsoleteMethodWarning:'use methodTemplateForVersionMethodCVS'.
18554
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
   150
    ^ ('version_CVS\    ^ ''$' , 'Header$''') withCRs
14326
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   151
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   152
    "Created: / 21-08-2012 / 11:52:27 / cg"
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   153
! !
Claus Gittinger <cg@exept.de>
parents: 13754
diff changeset
   154
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   155
!SmalltalkChunkFileSourceWriter methodsFor:'source writing'!
f700545e4350 initial checkin
ca
parents:
diff changeset
   156
16880
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   157
fileOut:aClass on:outStreamArg withTimeStamp:stampIt withInitialize:initIt withDefinition:withDefinition methodFilter:methodFilter
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   158
    |encoder any16Bit|
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   159
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   160
    any16Bit := aClass withAllPrivateClasses contains:[:cls |
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   161
                 cls instAndClassMethods contains:[:m |
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   162
                        (methodFilter isNil or:[ (methodFilter value:m) ])
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   163
                        and:[ 
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   164
                            |src|
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   165
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   166
                            src := m source.
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   167
                            src notNil and:[src isWideString]
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   168
                        ]]].
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   169
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   170
    any16Bit ifTrue:[
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   171
        encoder := CharacterEncoder encoderForUTF8.
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   172
    ].
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   173
    ^ self
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   174
        fileOut: aClass 
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   175
        on:outStreamArg
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   176
        withTimeStamp:stampIt
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   177
        withInitialize:initIt
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   178
        withDefinition:withDefinition
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   179
        methodFilter:methodFilter
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   180
        encoder:encoder
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   181
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   182
    "Created: / 04-10-2014 / 12:11:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   183
!
150ff012bd46 Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16878
diff changeset
   184
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   185
fileOut:aClass on:outStreamArg withTimeStamp:stampIt withInitialize:initIt withDefinition:withDefinition methodFilter:methodFilter encoder:encoderOrNil
f700545e4350 initial checkin
ca
parents:
diff changeset
   186
    "file out my definition and all methods onto aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   187
     If stampIt is true, a timeStamp comment is prepended.
f700545e4350 initial checkin
ca
parents:
diff changeset
   188
     If initIt is true, and the class implements a class-initialize method,
f700545e4350 initial checkin
ca
parents:
diff changeset
   189
     append a corresponding doIt expression for initialization.
17153
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   190
     The order by which the fileOut is done is used to put the version method at the end.
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   191
     Thus, if the version string is expanded (by CVS), the characterPositions of all other methods should not move.
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   192
     Notice that any extensions version method is NOT written when a project definition is saved;
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   193
     it is ABSOLUTELY required, that it is saved to the extensions.st file only (because the expanded version string
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   194
     would be the version string of the project definition file and NOT the version string of the extensions file).
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   195
     todo: code duplication with JavaScriptSourceFileWriter - please refactor"
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   196
17153
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   197
    |collectionOfCategories comment versionMethods extensionVersionMethods
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   198
     nonMeta meta classesImplementingInitialize outStream 
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   199
     allMetaClassSelectors versionSelectors extensionVersionSelectors
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   200
     allVersionMethods|
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   201
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   202
    self todo:'code duplication with JavaScriptSourceFileWriter - please refactor'.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   203
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   204
    classBeingSaved := nonMeta := aClass theNonMetaclass.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   205
    meta := nonMeta class.
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   206
    methodsAlreadySaved := Set new.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   207
f700545e4350 initial checkin
ca
parents:
diff changeset
   208
    nonMeta isLoaded ifFalse:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   209
        ^ ClassDescription fileOutErrorSignal 
f700545e4350 initial checkin
ca
parents:
diff changeset
   210
            raiseRequestWith:nonMeta
f700545e4350 initial checkin
ca
parents:
diff changeset
   211
            errorString:' - will not fileOut unloaded class: ', nonMeta name
f700545e4350 initial checkin
ca
parents:
diff changeset
   212
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   213
f700545e4350 initial checkin
ca
parents:
diff changeset
   214
    encoderOrNil isNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   215
        outStream := outStreamArg.
f700545e4350 initial checkin
ca
parents:
diff changeset
   216
    ] ifFalse:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   217
        outStream := EncodedStream stream:outStreamArg encoder:encoderOrNil.
f700545e4350 initial checkin
ca
parents:
diff changeset
   218
        outStream nextPutAll:'"{ Encoding: ' , encoderOrNil nameOfEncoding , ' }"'; cr; cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   219
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   220
f700545e4350 initial checkin
ca
parents:
diff changeset
   221
    "
f700545e4350 initial checkin
ca
parents:
diff changeset
   222
     if there is a copyright method, add a copyright comment
f700545e4350 initial checkin
ca
parents:
diff changeset
   223
     at the beginning, taking the string from the copyright method.
f700545e4350 initial checkin
ca
parents:
diff changeset
   224
     We cannot do this unconditionally - that would lead to my copyrights
f700545e4350 initial checkin
ca
parents:
diff changeset
   225
     being put on your code ;-).
f700545e4350 initial checkin
ca
parents:
diff changeset
   226
     On the other hand: I want every file created by myself to have the
f700545e4350 initial checkin
ca
parents:
diff changeset
   227
     copyright string at the beginning be preserved .... even if the
f700545e4350 initial checkin
ca
parents:
diff changeset
   228
     code was edited in the browser and filedOut.
f700545e4350 initial checkin
ca
parents:
diff changeset
   229
    "
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   230
    self generateHeaderWithCopyrightOn:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   231
f700545e4350 initial checkin
ca
parents:
diff changeset
   232
    stampIt ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   233
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   234
        "/ first, a timestamp
f700545e4350 initial checkin
ca
parents:
diff changeset
   235
        "/
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   236
        self generateTimestampOn:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   237
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   238
f700545e4350 initial checkin
ca
parents:
diff changeset
   239
    withDefinition ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   240
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   241
        "/ then the definition(s)
f700545e4350 initial checkin
ca
parents:
diff changeset
   242
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   243
        self fileOutAllDefinitionsOf:nonMeta on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   244
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   245
        "/ a comment - if any
f700545e4350 initial checkin
ca
parents:
diff changeset
   246
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   247
        (comment := nonMeta comment) notNil ifTrue:[
17335
1e44f87fe4d6 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17333
diff changeset
   248
            self fileOutClassCommentOf:nonMeta on:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   249
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   250
        "/
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   251
        "/ ST/X primitive definitions - if any
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   252
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   253
        nonMeta fileOutPrimitiveSpecsOn:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   254
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   255
f700545e4350 initial checkin
ca
parents:
diff changeset
   256
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   257
    "/ methods from all categories in metaclass (i.e. class methods)
f700545e4350 initial checkin
ca
parents:
diff changeset
   258
    "/ EXCEPT: the version method is placed at the very end, to
f700545e4350 initial checkin
ca
parents:
diff changeset
   259
    "/         avoid sourcePosition-shifts when checked out later.
f700545e4350 initial checkin
ca
parents:
diff changeset
   260
    "/         (RCS expands this string, so its size is not constant)
f700545e4350 initial checkin
ca
parents:
diff changeset
   261
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   262
    collectionOfCategories := meta categories asSortedCollection.
17153
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   263
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   264
    allMetaClassSelectors := meta methodDictionary keys.
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   265
    versionSelectors := allMetaClassSelectors select:[:selector | AbstractSourceCodeManager isVersionMethodSelector:selector ].
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   266
    versionMethods := versionSelectors collect:[:eachSelector | meta methodDictionary at:eachSelector].
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   267
    extensionVersionSelectors := allMetaClassSelectors select:[:selector | AbstractSourceCodeManager isExtensionsVersionMethodSelector:selector ]. 
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   268
    extensionVersionMethods := extensionVersionSelectors collect:[:eachSelector | meta methodDictionary at:eachSelector].
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   269
    allVersionMethods := Set new addAll:versionMethods; addAll:extensionVersionMethods; yourself.
12045
ccb1c727370b changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
fm
parents: 12043
diff changeset
   270
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   271
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   272
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   273
        "/ documentation first (if any), but not the version method
f700545e4350 initial checkin
ca
parents:
diff changeset
   274
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   275
        (collectionOfCategories includes:'documentation') ifTrue:[
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   276
13754
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   277
"/            versionMethods do:[:versionMethod |
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   278
"/                |source|
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   279
"/
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   280
"/                source := versionMethod source.
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   281
"/                (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
   282
"/                    "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
   283
"/
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   284
"/                    Class fileOutErrorSignal 
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   285
"/                        raiseRequestWith:aClass
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   286
"/                        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
   287
"/                ].
0ce8b7b9e6ee changed: #fileOut:on:withTimeStamp:withInitialize:withDefinition:methodFilter:encoder:
Claus Gittinger <cg@exept.de>
parents: 13462
diff changeset
   288
"/            ].
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   289
17153
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   290
            self fileOutCategory:'documentation' of:meta except:allVersionMethods only:nil methodFilter:methodFilter on:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   291
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   292
f700545e4350 initial checkin
ca
parents:
diff changeset
   293
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   294
        "/ initialization next (if any)
f700545e4350 initial checkin
ca
parents:
diff changeset
   295
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   296
        (collectionOfCategories includes:'initialization') ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   297
            self fileOutCategory:'initialization' of:meta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   298
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   299
f700545e4350 initial checkin
ca
parents:
diff changeset
   300
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   301
        "/ instance creation next (if any)
f700545e4350 initial checkin
ca
parents:
diff changeset
   302
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   303
        (collectionOfCategories includes:'instance creation') ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   304
            self fileOutCategory:'instance creation' of:meta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   305
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   306
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   307
            ((aCategory ~= 'documentation')
f700545e4350 initial checkin
ca
parents:
diff changeset
   308
            and:[(aCategory ~= 'initialization')
f700545e4350 initial checkin
ca
parents:
diff changeset
   309
            and:[aCategory ~= 'instance creation']]) ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   310
                self fileOutCategory:aCategory of:meta methodFilter:methodFilter on:outStream.
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
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   315
    "/ 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
   316
    "/ 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
   317
    "/ 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
   318
    "/ for the primitive calls.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   319
    nonMeta methodDictionary keysAndValuesDo:[:sel :m |
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   320
        m isVisualWorksTypedef ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   321
            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
   322
        ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   323
    ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   324
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   325
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   326
    "/ methods from all categories
f700545e4350 initial checkin
ca
parents:
diff changeset
   327
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   328
    collectionOfCategories := nonMeta 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:nonMeta methodFilter:methodFilter on:outStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   332
        ]
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
    "/ any private classes' methods
f700545e4350 initial checkin
ca
parents:
diff changeset
   337
    "/
17153
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   338
    nonMeta privateClassesSorted do:[:eachPrivateClass |
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   339
        self fileOutAllMethodsOf:eachPrivateClass on:outStream methodFilter:methodFilter
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   340
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   341
f700545e4350 initial checkin
ca
parents:
diff changeset
   342
f700545e4350 initial checkin
ca
parents:
diff changeset
   343
    "/
17153
91e8d99118e0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 16880
diff changeset
   344
    "/ finally, the previously skipped version method (but not the extensionsVersion methods!!)
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   345
    "/
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   346
    versionMethods notEmpty ifTrue: [
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   347
        self fileOutCategory:'documentation' of:meta except:nil only:versionMethods methodFilter:methodFilter on:outStream.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   348
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   349
f700545e4350 initial checkin
ca
parents:
diff changeset
   350
    initIt ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   351
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   352
        "/ optionally an initialize message
f700545e4350 initial checkin
ca
parents:
diff changeset
   353
        "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   354
        classesImplementingInitialize := OrderedCollection new.
f700545e4350 initial checkin
ca
parents:
diff changeset
   355
f700545e4350 initial checkin
ca
parents:
diff changeset
   356
        (meta includesSelector:#initialize) ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   357
            classesImplementingInitialize add:nonMeta
f700545e4350 initial checkin
ca
parents:
diff changeset
   358
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   359
        nonMeta privateClassesSorted do:[:aPrivateClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   360
            (aPrivateClass theMetaclass includesSelector:#initialize) ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   361
                classesImplementingInitialize add:aPrivateClass
f700545e4350 initial checkin
ca
parents:
diff changeset
   362
            ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   363
        ].
17333
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   364
        classesImplementingInitialize notEmpty ifTrue:[
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   365
            outStream cr.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   366
            classesImplementingInitialize topologicalSort:[:a :b | b isSubclassOf:a].
f700545e4350 initial checkin
ca
parents:
diff changeset
   367
            classesImplementingInitialize do:[:eachClass |
17333
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   368
                self generateCallToInitializerFor:eachClass on:outStream
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   369
            ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   370
        ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   371
    ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   372
10036
51489deaf8c5 care for non-comment in copyright method (JUN stuff)
Claus Gittinger <cg@exept.de>
parents: 8728
diff changeset
   373
    "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
   374
    "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
   375
    "Modified: / 29-09-2011 / 14:53:49 / cg"
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   376
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   377
f700545e4350 initial checkin
ca
parents:
diff changeset
   378
fileOutAllDefinitionsOf:aNonMetaClass on:aStream
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   379
    self fileOutAllDefinitionsOf:aNonMetaClass on:aStream withNameSpace: true.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   380
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   381
    "Created: / 15-10-1996 / 11:15:19 / cg"
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   382
    "Modified: / 22-03-1997 / 16:11:56 / cg"
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   383
    "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
   384
!
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   385
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   386
fileOutAllDefinitionsOf:aNonMetaClass on:aStream withNameSpace: withNameSpacePragma
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   387
    "append expressions on aStream, which defines myself and all of my private classes."
f700545e4350 initial checkin
ca
parents:
diff changeset
   388
15085
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   389
    |s|
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   390
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   391
    s := CharacterWriteStream on:(String new:50).
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   392
    self fileOutDefinitionOf:aNonMetaClass on:s withNameSpace: withNameSpacePragma.
15085
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   393
    aStream nextChunkPut:(s contents).
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   394
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   395
    "/ self fileOutDefinitionOf:aNonMetaClass on:aStream.
328f314c2e19 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14985
diff changeset
   396
    "/ aStream nextPutChunkSeparator. 
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   397
    aStream cr; cr.
f700545e4350 initial checkin
ca
parents:
diff changeset
   398
f700545e4350 initial checkin
ca
parents:
diff changeset
   399
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   400
    "/ optional classInstanceVariables
f700545e4350 initial checkin
ca
parents:
diff changeset
   401
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   402
    aNonMetaClass class instanceVariableString isBlank ifFalse:[
17333
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   403
        self fileOutClassInstVarDefinitionOf:aNonMetaClass on:aStream
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   404
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   405
f700545e4350 initial checkin
ca
parents:
diff changeset
   406
    "/ here, the full nameSpace prefixes are output,
f700545e4350 initial checkin
ca
parents:
diff changeset
   407
    "/ to avoid confusing stc 
f700545e4350 initial checkin
ca
parents:
diff changeset
   408
    "/ (which otherwise could not find the correct superclass)
f700545e4350 initial checkin
ca
parents:
diff changeset
   409
    "/
f700545e4350 initial checkin
ca
parents:
diff changeset
   410
    Class fileOutNameSpaceQuerySignal answer:false do:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   411
        Class forceNoNameSpaceQuerySignal answer:true do:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   412
            aNonMetaClass privateClassesSorted do:[:aClass |
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   413
                 self fileOutAllDefinitionsOf:aClass on:aStream withNameSpace: false
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   414
            ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   415
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   416
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   417
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   418
    "Created: / 04-02-2014 / 20:00:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   419
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   420
f700545e4350 initial checkin
ca
parents:
diff changeset
   421
fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter
f700545e4350 initial checkin
ca
parents:
diff changeset
   422
    |collectionOfCategories|
f700545e4350 initial checkin
ca
parents:
diff changeset
   423
f700545e4350 initial checkin
ca
parents:
diff changeset
   424
    collectionOfCategories := aClass class categories asSortedCollection.
f700545e4350 initial checkin
ca
parents:
diff changeset
   425
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   426
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   427
            self fileOutCategory:aCategory of:aClass class  methodFilter:methodFilter on:aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   428
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   429
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   430
    collectionOfCategories := aClass categories asSortedCollection.
f700545e4350 initial checkin
ca
parents:
diff changeset
   431
    collectionOfCategories notNil ifTrue:[
f700545e4350 initial checkin
ca
parents:
diff changeset
   432
        collectionOfCategories do:[:aCategory |
f700545e4350 initial checkin
ca
parents:
diff changeset
   433
            self fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   434
        ]
f700545e4350 initial checkin
ca
parents:
diff changeset
   435
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   436
f700545e4350 initial checkin
ca
parents:
diff changeset
   437
    aClass privateClassesSorted do:[:aClass |
f700545e4350 initial checkin
ca
parents:
diff changeset
   438
        self fileOutAllMethodsOf:aClass on:aStream methodFilter:methodFilter
f700545e4350 initial checkin
ca
parents:
diff changeset
   439
    ].
f700545e4350 initial checkin
ca
parents:
diff changeset
   440
f700545e4350 initial checkin
ca
parents:
diff changeset
   441
    "Created: 15.10.1996 / 11:13:00 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   442
    "Modified: 22.3.1997 / 16:12:17 / cg"
f700545e4350 initial checkin
ca
parents:
diff changeset
   443
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   444
f700545e4350 initial checkin
ca
parents:
diff changeset
   445
fileOutCategory:aCategory of:aClass except:skippedMethods only:savedMethods methodFilter:methodFilter on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   446
    "file out all methods belonging to aCategory, aString onto aStream.
f700545e4350 initial checkin
ca
parents:
diff changeset
   447
     If skippedMethods is nonNil, those are not saved.
f700545e4350 initial checkin
ca
parents:
diff changeset
   448
     If savedMethods is nonNil, only those are saved.
f700545e4350 initial checkin
ca
parents:
diff changeset
   449
     If both are nil, all are saved. See version-method handling in
f700545e4350 initial checkin
ca
parents:
diff changeset
   450
     fileOut for what this is needed."
f700545e4350 initial checkin
ca
parents:
diff changeset
   451
14983
a0b8519d7c50 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14596
diff changeset
   452
    |sortedSelectors first prevPrivacy privacy interestingMethods cat prjDef|
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   453
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   454
    interestingMethods := OrderedCollection new.
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   455
    aClass methodsDo:[:each |
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   456
        | wanted method shadowed |
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   457
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   458
        method := each.
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   459
        (methodsAlreadySaved includes:method) ifFalse:[
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   460
            (aCategory = method category) ifTrue:[
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   461
                wanted := methodFilter isNil or:[methodFilter value:method].
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   462
                wanted ifFalse:[ 
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   463
                    "/ care for methods which have been shadowed by an extension from another package!!
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   464
                    "/ The problem is that we cannot easily introspect the filter, so we cannot know
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   465
                    "/ if the filter is for package or not. In most (all?) cases it is as this method
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   466
                    "/ is mostly used by source code management, so if the filter filters method out,
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   467
                    "/ try afain for possibly shadowed method.
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   468
                    methodFilter notNil ifTrue:[ 
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   469
                        shadowed := method shadowedMethod.
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   470
                        shadowed notNil ifTrue:[ 
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   471
                            wanted := methodFilter value: shadowed.
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   472
                        ].
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   473
                    ].
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   474
                ].
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   475
                wanted ifTrue:[
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   476
                    skippedMethods notNil ifTrue:[
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   477
                        wanted := (skippedMethods includesIdentical:method) not
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   478
                    ] ifFalse:[
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   479
                        wanted := savedMethods isNil or:[ savedMethods includesIdentical:method ].
11703
54e2c3acf7a7 skip non-symbol-selector methods when filing out
Claus Gittinger <cg@exept.de>
parents: 11701
diff changeset
   480
                    ].
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   481
                    wanted ifTrue:[
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   482
                        (method selector isSymbol) ifTrue:[
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   483
                            interestingMethods add:method
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   484
                        ] ifFalse:[
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   485
                            Transcript showCR:'skipping non-symbol method ', method selector printString.
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   486
                        ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   487
                    ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   488
                ]
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   489
            ]
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   490
        ]
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   491
    ].
14983
a0b8519d7c50 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14596
diff changeset
   492
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   493
    interestingMethods notEmpty ifTrue:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   494
        "/
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   495
        "/ sort by selector
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   496
        "/
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   497
        sortedSelectors := interestingMethods collect:[:m | aClass selectorAtMethod:m].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   498
        sortedSelectors sortWith:interestingMethods.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   499
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   500
        generatingSourceForOriginal == true ifTrue:[
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   501
            "/ 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
   502
            (prjDef := aClass theNonMetaclass projectDefinitionClass) notNil ifTrue:[
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   503
                prjDef hasSavedOverwrittenMethods ifTrue:[
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   504
                    interestingMethods := interestingMethods collect:[:m |
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   505
                                                |originalOrNil|
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   506
                                                
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   507
                                                (m package ~~ aClass package) ifTrue:[ 
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   508
                                                    originalOrNil := prjDef savedOverwrittenMethodForClass:aClass selector:m selector.
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   509
                                                    originalOrNil notNil ifTrue:[ 
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   510
                                                        1.
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   511
                                                        self breakPoint:#cg 
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   512
                                                    ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   513
                                                ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   514
                                                originalOrNil ? m
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   515
                                          ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   516
                ]
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   517
            ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   518
        ].
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   519
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   520
        first := true.
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   521
        prevPrivacy := nil.
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   522
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   523
        interestingMethods do:[:eachMethod |
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   524
            privacy := eachMethod privacy.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   525
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   526
            first ifFalse:[
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   527
                privacy ~~ prevPrivacy ifTrue:[
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   528
                    first := true.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   529
                    aStream space.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   530
                    aStream nextPutChunkSeparator.
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   531
                ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   532
                aStream cr; cr
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   533
            ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   534
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   535
            first ifTrue:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   536
                aStream nextPutChunkSeparator.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   537
                aClass printClassNameOn:aStream.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   538
                privacy ~~ #public ifTrue:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   539
                    aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   540
                ] ifFalse:[
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   541
                    aStream nextPutAll:' methodsFor:'.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   542
                ].
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   543
                cat := aCategory.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   544
                cat isNil ifTrue:[ cat := '' ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   545
                aStream nextPutAll:aCategory asString storeString.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   546
                aStream nextPutChunkSeparator; cr; cr.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   547
                first := false.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   548
            ].
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   549
            self fileOutMethod:eachMethod on:aStream.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   550
            methodsAlreadySaved add:eachMethod.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   551
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   552
            prevPrivacy := privacy.
11701
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   553
        ].
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   554
        aStream space.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   555
        aStream nextPutChunkSeparator.
b52763115eb1 use method enumerator
Claus Gittinger <cg@exept.de>
parents: 11595
diff changeset
   556
        aStream cr
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   557
    ].
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   558
    aStream cr
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   559
16878
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   560
    "Modified: / 28-08-1995 / 14:30:41 / claus"
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   561
    "Modified: / 12-06-1996 / 11:37:33 / stefan"
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   562
    "Modified: / 15-11-1996 / 11:32:21 / cg"
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   563
    "Created: / 01-04-1997 / 16:04:33 / stefan"
19f06d12b7da Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15953
diff changeset
   564
    "Modified: / 03-10-2014 / 23:16:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   565
!
f700545e4350 initial checkin
ca
parents:
diff changeset
   566
f700545e4350 initial checkin
ca
parents:
diff changeset
   567
fileOutCategory:aCategory of:aClass methodFilter:methodFilter on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   568
    "file out all methods belonging to aCategory, aString onto aStream"
f700545e4350 initial checkin
ca
parents:
diff changeset
   569
f700545e4350 initial checkin
ca
parents:
diff changeset
   570
    self fileOutCategory:aCategory of:aClass except:nil only:nil methodFilter:methodFilter on:aStream
f700545e4350 initial checkin
ca
parents:
diff changeset
   571
f700545e4350 initial checkin
ca
parents:
diff changeset
   572
    "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
   573
!
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   574
17335
1e44f87fe4d6 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17333
diff changeset
   575
fileOutClassCommentOf:aNonMetaClass on:aStream
1e44f87fe4d6 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17333
diff changeset
   576
    aNonMetaClass fileOutCommentOn:aStream.
1e44f87fe4d6 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17333
diff changeset
   577
!
1e44f87fe4d6 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17333
diff changeset
   578
17333
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   579
fileOutClassInstVarDefinitionOf:aNonMetaClass on:aStream
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   580
    aNonMetaClass fileOutClassInstVarDefinitionOn:aStream.
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   581
    aStream nextPutChunkSeparator. 
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   582
    aStream cr; cr
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   583
!
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   584
12108
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   585
fileOutCommentEndOn:aStream
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   586
    "Writes a comment end mark on aStream."
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   587
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   588
    "/ intentionally left blank - make each line an EOL-comment instead
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   589
!
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   590
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   591
fileOutCommentLine:aString on:aStream
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   592
    "Writes a single line of comment on a comment to a stream."
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   593
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   594
    aStream 
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   595
        nextPutAll:'"/ ';
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   596
        nextPutAll: aString
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   597
!
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   598
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   599
fileOutCommentStartOn:aStream
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   600
    "Writes a comment start mark on aStream."
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   601
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   602
    "/ intentionally left blank - make each line an EOL-comment instead
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   603
!
Claus Gittinger <cg@exept.de>
parents: 12045
diff changeset
   604
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   605
fileOutDefinitionOf:aNonMetaClass on:aStream
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   606
    aNonMetaClass fileOutDefinitionOn:aStream.
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   607
!
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   608
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   609
fileOutDefinitionOf:aNonMetaClass on:aStream withNameSpace: withNameSpacePragma
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   610
    aNonMetaClass basicFileOutDefinitionOn:aStream withNameSpace: withNameSpacePragma
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   611
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   612
    "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
   613
!
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   614
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   615
fileOutMethod:aMethod on:aStream
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   616
    "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
   617
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   618
    |source possiblyRewrittenSource rewriteQuery|
11853
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
    source := aMethod source.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   621
    source isNil ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   622
        Class fileOutErrorSignal 
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   623
            raiseRequestWith:aMethod mclass
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   624
            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
   625
    ] ifFalse:[
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   626
        "/ hook to allow for just-in-time rewriting of a method's sourceCode while filing out
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   627
        "/ used when saving version_XXX methods in a non-XXX sourceCodeManager
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   628
        "/ (i.e. to rewrite all non-CVS version methods while saving into a CVS repository)
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   629
        "/ this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   630
        "/ CVS repository without loosing the original string with the next checkout, because it also gets  
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   631
        "/ expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN.
17401
2d776a4f4258 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17335
diff changeset
   632
        "/ also used, when generating sourcecode for another Smalltalk system (VSE fileout)
2d776a4f4258 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17335
diff changeset
   633
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   634
        rewriteQuery := AbstractSourceFileWriter methodSourceRewriteQuery new.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   635
        rewriteQuery method:aMethod source:source.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   636
        possiblyRewrittenSource := (rewriteQuery query) ? source.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   637
        aStream nextChunkPut:possiblyRewrittenSource.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   638
"/possiblyRewrittenSource ~= source ifTrue: [
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   639
"/    Transcript showCR: possiblyRewrittenSource.
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   640
"/].
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   641
    ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   642
!
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   643
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   644
fileOutMethods: methods on: stream
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   645
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   646
    methods do:[:method| 
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   647
        |cat source privacy|
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   648
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   649
        stream nextPutChunkSeparator.
15953
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   650
        "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
   651
        method mclass theNonMetaclass isJavaClass ifTrue:[
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   652
            | class classBinaryName comps |
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   653
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   654
            class := method mclass theNonMetaclass .
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   655
            "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
   656
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   657
            old -> aJavaClass name == #'java/lang/Object'
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   658
            new -> aJavaClass name == JAVA::java::lang::Object
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   659
                   aJavaClass binaryName == #'java/lang/Object'
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   660
            "
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   661
            classBinaryName := (class respondsTo: #binaryName) 
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   662
                                    ifTrue:[ class binaryName ]
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   663
                                    ifFalse:[ class name ].      
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   664
            stream nextPutAll:'(Java classForName:'''.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   665
            stream nextPutAll:(classBinaryName copyReplaceAll:$/ with: $.).
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   666
            stream nextPutAll:''')'.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   667
            method mclass isMetaclass ifTrue:[
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   668
                stream nextPutAll: ' class'.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   669
            ].
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   670
        ] ifFalse:[
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   671
            method mclass name printOn:stream.
6ad068b28f7d merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 15421
diff changeset
   672
        ].
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   673
        "/        self printClassNameOn:aStream.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   674
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   675
        (privacy := method privacy) ~~ #public ifTrue:[
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   676
            stream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   677
        ] ifFalse:[
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   678
            stream nextPutAll:' methodsFor:'.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   679
        ].
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   680
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   681
        cat := method category ? ''.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   682
        stream nextPutAll:cat asString storeString.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   683
        stream nextPutChunkSeparator; cr; cr.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   684
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   685
        self fileOutMethod: method on: stream.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   686
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   687
        stream space.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   688
        stream nextPutChunkSeparator.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   689
        stream cr]
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   690
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   691
    "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
   692
    "Modified: / 09-10-2013 / 08:57:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   693
!
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   694
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   695
fileOutPackageDefinition:pkg on:aStream 
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   696
    (pkg notNil and:[ pkg ~= PackageId noProjectID ]) ifTrue:[
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   697
        aStream nextPutAll:'"{ Package: '''.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   698
        aStream nextPutAll:pkg asString.
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   699
        aStream
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   700
            nextPutAll:''' }"'; cr; cr;
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   701
            nextPut:$!!; cr; cr
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   702
    ]
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   703
!
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   704
17333
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   705
generateCallToInitializerFor:aClass on:aStream
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   706
    aClass printClassNameOn:aStream. aStream nextPutAll:' initialize'.
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   707
    aStream nextPutChunkSeparator.
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   708
    aStream cr.
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   709
!
937efc261475 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17153
diff changeset
   710
11853
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   711
generateHeaderWithCopyrightOn:outStream
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   712
    |copyrightMethod copyrightText|
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   713
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   714
    "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
   715
     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
   716
     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
   717
     being put on your code ;-).
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   718
     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
   719
     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
   720
     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
   721
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   722
    (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
   723
        "
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   724
         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
   725
         and insert at beginning.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   726
        "
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   727
        copyrightText := copyrightMethod comment.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   728
        copyrightText notEmptyOrNil ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   729
            copyrightText := copyrightText asCollectionOfLines asStringCollection.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   730
            copyrightText := copyrightText withoutLeadingBlankLines.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   731
            copyrightText := copyrightText withoutTrailingBlankLines.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   732
            copyrightText notEmpty ifTrue:[
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   733
                copyrightText addFirst:'"'.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   734
                copyrightText addLast:'"'.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   735
                copyrightText := copyrightText asString.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   736
                outStream nextPutAllAsChunk:copyrightText.
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   737
            ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   738
        ].
7c3265d8931e save typedef methods before others to ensure that types
Claus Gittinger <cg@exept.de>
parents: 11703
diff changeset
   739
    ].
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   740
!
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   741
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   742
generateTimestampOn:outStream
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   743
    outStream nextPutAll:(Smalltalk timeStamp).
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   744
    outStream nextPutChunkSeparator. 
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   745
    outStream cr; cr.
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   746
! !
f700545e4350 initial checkin
ca
parents:
diff changeset
   747
f700545e4350 initial checkin
ca
parents:
diff changeset
   748
!SmalltalkChunkFileSourceWriter class methodsFor:'documentation'!
f700545e4350 initial checkin
ca
parents:
diff changeset
   749
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   750
version
18554
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
   751
    ^ '$Header$'
14985
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   752
!
2e24694bc6f4 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14983
diff changeset
   753
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   754
version_CVS
18554
ead4614d7aaa class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 17401
diff changeset
   755
    ^ '$Header$'
12043
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   756
!
80c7abaa0adf changed:
fm
parents: 11963
diff changeset
   757
13420
4d862171657d Jan's changes
vrany
parents: 12108
diff changeset
   758
version_SVN
15421
bfe697cc8b21 class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents: 15085
diff changeset
   759
    ^ '$ Id: SmalltalkChunkFileSourceWriter.st 10643 2011-06-08 21:53:07Z vranyj1  $'
8227
f700545e4350 initial checkin
ca
parents:
diff changeset
   760
! !
14596
45bb7ac30ab0 class: SmalltalkChunkFileSourceWriter
Claus Gittinger <cg@exept.de>
parents: 14409
diff changeset
   761