SmalltalkCodeGeneratorTool.st
author Jan Vrany <jan.vrany@labware.com>
Thu, 14 Oct 2021 11:55:23 +0200
branchjv
changeset 19614 0d756d4c5298
parent 19607 f9108fde4972
child 19642 cba345697a7d
permissions -rw-r--r--
Themes: use stylesheet to define colors for accept-cancel bars
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2002 by eXept Software AG
18226
346376844040 Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17136
diff changeset
     3
 COPYRIGHT (c) 2016 Jan Vrany
19598
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
     4
 COPYRIGHT (c) 2021 LabWare
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
              All Rights Reserved
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libtool' }"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
15515
895b2312db3e class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15069
diff changeset
    16
"{ NameSpace: Smalltalk }"
895b2312db3e class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15069
diff changeset
    17
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
CodeGeneratorTool subclass:#SmalltalkCodeGeneratorTool
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Interface-Browsers'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!SmalltalkCodeGeneratorTool class methodsFor:'documentation'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 2002 by eXept Software AG
18226
346376844040 Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17136
diff changeset
    30
 COPYRIGHT (c) 2016 Jan Vrany
19598
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
    31
 COPYRIGHT (c) 2021 LabWare
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
              All Rights Reserved
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 This software is furnished under a license and may be used
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 only in accordance with the terms of that license and with the
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 inclusion of the above copyright notice.   This software may not
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 be provided or otherwise made available to, or used by, any
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
 other person.  No title to or ownership of the software is
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
 hereby transferred.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
documentation
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    This utility class contains various code generation facilites;
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    these were extracted from the old and newBrowser.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    There is probably more to come...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    [author:]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
        Claus Gittiner
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
! !
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!SmalltalkCodeGeneratorTool class methodsFor:'code generation'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
initialMenuSpecMethodSourceForApplications
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    "return code for a menuSpec with typical stuff in it"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
'mainMenu
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    "This resource specification was automatically generated by the CodeGeneratorTool."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    "Do not manually edit this!! If it is corrupted,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
     the MenuEditor may not be able to read the specification."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
     MenuEditor new openOnClass:%1 andSelector:#mainMenu
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    <resource: #menu>
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    ^ ',(self initialMenuSpecForApplications decodeAsLiteralArray literalArrayEncoding storeString),'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
initialPageMenuSpecMethodSourceForWebApplications
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    "return code for a menuSpec with typical stuff in it"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
'mainMenu
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    "This resource specification was automatically generated by the CodeGeneratorTool."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    "Do not manually edit this!! If it is corrupted,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
     the MenuEditor may not be able to read the specification."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
     MenuEditor new openOnClass:%1 andSelector:#mainMenu
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    <resource: #menu>
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    ^ ',(self initialPageMenuSpecForWebApplications decodeAsLiteralArray literalArrayEncoding storeString),'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
     self initialPageMenuSpecMethodSourceForWebApplications
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
initialPageSpecMethodSourceForWebApplications
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    "return an empty pageSpec"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
'pageSpec
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    "This resource specification was automatically generated by the CodeGeneratorTool."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    "Do not manually edit this!! If it is corrupted,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
     the UIPainter may not be able to read the specification."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
     UIPainter new openOnClass:%1 andSelector:#pageSpec
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    <resource: #canvas>
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    ^ ',(self initialPageSpecForWebApplications decodeAsLiteralArray literalArrayEncoding storeString),'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
initialToolbarMenuSpecMethodSource
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    "return a menuSpec with typical stuff in it"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
'toolbarMenu
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    "This resource specification was automatically generated by the CodeGeneratorTool."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    "Do not manually edit this!! If it is corrupted,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
     the MenuEditor may not be able to read the specification."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
     MenuEditor new openOnClass:%1 andSelector:#toolbarMenu
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    <resource: #menu>
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    ^ ',(self initialToolbarMenuSpec decodeAsLiteralArray literalArrayEncoding storeString),'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
     self initialToolbarMenuSpecMethodSource
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
initialWindowSpecMethodSourceForApplications
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    "return an empty windowSpec with an initial menubar in it"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
'windowSpec
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    "This resource specification was automatically generated by the CodeGeneratorTool."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    "Do not manually edit this!! If it is corrupted,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
     the UIPainter may not be able to read the specification."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
     UIPainter new openOnClass:%1 andSelector:#windowSpec
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    <resource: #canvas>
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    ^ ',
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   161
        self initialWindowSpecForApplications2 decodeAsLiteralArray prettyPrintString
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
     self initialWindowSpecMethodSourceForApplications
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
initialWindowSpecMethodSourceForDialogs
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    "return an empty windowSpec for dialogs"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
'windowSpec
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    "This resource specification was automatically generated by the CodeGeneratorTool."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    "Do not manually edit this!! If it is corrupted,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
     the UIPainter may not be able to read the specification."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
     UIPainter new openOnClass:%1 andSelector:#windowSpec
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
    <resource: #canvas>
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    ^ ',
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   186
        self initialWindowSpecForDialogs decodeAsLiteralArray prettyPrintString
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
! !
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
!SmalltalkCodeGeneratorTool class methodsFor:'code generation-menus'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
createActionMethodFor:aSelector in:aClass category:aCategory redefine:redefine
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    |alreadyInSuperclass method code|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    (aClass includesSelector:aSelector) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
        ^ nil
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    alreadyInSuperclass := aClass superclass canUnderstand:aSelector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    (alreadyInSuperclass and:[redefine not]) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
        ^ nil
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    method := self methodNameTemplateFor:aSelector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    code := '%1
16627
38127b520bc8 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 16553
diff changeset
   206
    <resource: #uiCallback>
38127b520bc8 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 16553
diff changeset
   207
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    "automatically generated by UIEditor ..."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    "*** the code below performs no action"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    "*** (except for some feedback on the Transcript)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    "*** Please change as required and accept in the browser."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    "*** (and replace this comment by something more useful ;-)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
    "action to be added ..."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
16627
38127b520bc8 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 16553
diff changeset
   217
    Logger info:''action for #%2 ...''.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
' bindWith:method with:aSelector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    alreadyInSuperclass ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
        code := code, (('\    super %1\' bindWith:method) withCRs).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    ].
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   223
    self compile:code forClass:aClass inCategory:(aCategory ? #actions).
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    ^ code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
createAspectMethodFor:aSelector in:aClass category:aCategory redefine:redefine
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    |alreadyInSuperclass method code text|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    (aClass includesSelector:aSelector) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
        ^ nil
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
    alreadyInSuperclass := aClass superclass canUnderstand:aSelector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    (alreadyInSuperclass and:[redefine not]) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
        ^ nil
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
    method := self methodNameTemplateFor:aSelector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    code := '%1
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
    "automatically generated by UIEditor ..."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    "*** the code below creates a default model when invoked"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    "*** (which may not be the one you wanted)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    "*** Please change as required and accept in the browser."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    "*** (and replace this comment by something more useful ;-)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    "aspect to be added ..."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
16627
38127b520bc8 #QUALITY by stefan
Stefan Vogel <sv@exept.de>
parents: 16553
diff changeset
   251
    Logger info:''aspect for #%2 ...''.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
' bindWith:method with:aSelector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    alreadyInSuperclass ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
        text := '    ^ super %1\' bindWith:method.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
        text := '    ^ builder valueAspectFor:#''%1'' initialValue:true\' bindWith:aSelector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    code := code, (text withCRs).
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   261
    self compile:code forClass:aClass inCategory:(aCategory ? #actions).
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    ^ code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
! !
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
14696
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   265
!SmalltalkCodeGeneratorTool class methodsFor:'compilation'!
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   266
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   267
compile:theCode forClass:aClass inCategory:cat
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   268
    "install some code for a class.
16428
0fe897bd7119 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16393
diff changeset
   269
     Return the new method or nil.
0fe897bd7119 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16393
diff changeset
   270
     If refactory browser stuff is avaliable, the refactory tools are used to support undo"
14696
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   271
16393
50c131b059ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 16355
diff changeset
   272
    | parser selector |
14696
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   273
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   274
    super compile:theCode forClass:aClass inCategory:cat.
16393
50c131b059ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 16355
diff changeset
   275
14696
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   276
    parser := Parser parseMethodSpecification: theCode in: aClass ignoreErrors: true ignoreWarnings: true.
16428
0fe897bd7119 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16393
diff changeset
   277
    (selector := parser selector) notNil ifTrue:[
16393
50c131b059ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 16355
diff changeset
   278
        ^ aClass compiledMethodAt: selector.
14696
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   279
    ].
16393
50c131b059ec #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 16355
diff changeset
   280
    ^ nil
14696
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   281
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   282
    "Created: / 05-08-2014 / 16:14:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   283
!
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   284
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   285
compile:theCode forClass:aClass inCategory:cat notifying: requestor
16428
0fe897bd7119 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16393
diff changeset
   286
    "install some code for a class. 
0fe897bd7119 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16393
diff changeset
   287
     Return the new method or nil.
14696
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   288
     If refactory browser stuff is avaliable the refactory tools are used to support undo"
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   289
16326
d7236edb4060 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16263
diff changeset
   290
    CompilationErrorHandlerQuery 
d7236edb4060 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16263
diff changeset
   291
        answer:requestor
d7236edb4060 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16263
diff changeset
   292
        do:[
d7236edb4060 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16263
diff changeset
   293
            ^ self compile:theCode forClass:aClass inCategory:cat
d7236edb4060 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16263
diff changeset
   294
        ]    
14696
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   295
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   296
    "Created: / 05-08-2014 / 16:04:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   297
! !
e74967e679d4 Added more methods to make it polymorphic with Compiler to some extent.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14572
diff changeset
   298
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
!SmalltalkCodeGeneratorTool class methodsFor:'private'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
methodNameTemplateFor:aSelector
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
    |numArgs method|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
    numArgs := aSelector numArgs.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
    numArgs == 1 ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
        method := aSelector, 'anArgument'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
    ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
        numArgs == 0 ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
            method := aSelector
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
        ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
            method := ''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
            aSelector keywords keysAndValuesDo:[:i :key|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
                method := method, key, 'arg', i printString, ' '.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
        ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
    ^ method
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
! !
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
16355
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   320
!SmalltalkCodeGeneratorTool class methodsFor:'utilities - source code'!
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   321
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   322
methodTemplate
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   323
    "return a method definition template string"
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   324
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   325
    |s|
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   326
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   327
    s := (TextStream ? WriteStream) on:''.
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   328
    s nextPutAll:
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   329
'message "selector and argument names"
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   330
    "comment stating purpose of this message"
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   331
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   332
    |temporaries|
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   333
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   334
    "statement."
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   335
    "statement."
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   336
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   337
    "
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   338
     optional: comment giving example use
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   339
    "
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   340
'.
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   341
    s cr.
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   342
    s emphasis:(UserPreferences current commentEmphasisAndColor).
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   343
    s nextPutAll:
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   344
'"
17075
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   345
 This is an autogenerated method template.
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   346
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   347
 If you don''t like this method template to appear,
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   348
 disable it either via the global or browser''s settings dialog,
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   349
 or by evaluating:
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   350
     UserPreferences current showMethodTemplate:false
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   351
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   352
 Change the above template into real code;
16355
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   353
 remove this comment.
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   354
 Then `accept'' either via the menu
16355
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   355
 or via the keyboard (usually CMD-A).
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   356
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   357
 You do not need this template; you can also
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   358
 select any existing methods code, change it,
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   359
 and finally `accept''. The method will then be
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   360
 installed under the selector as defined in the
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   361
 actual text - no matter which method is selected
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   362
 in the browser.
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   363
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   364
 Or clear this text, type in the method from scratch
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   365
 and install it with `accept''.
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   366
"
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   367
'.
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   368
    ^ s contents
17075
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   369
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   370
    "Modified: / 18-11-2016 / 01:34:20 / cg"
16355
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   371
!
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   372
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   373
methodTemplateForDocumentation
17080
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   374
    "return a documentation method definition template string"
16355
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   375
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   376
    |s|
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   377
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   378
    s := (TextStream ? WriteStream) on:''.
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   379
    s nextPutAll:
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   380
'documentation
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   381
'.
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   382
    s emphasis:(UserPreferences current commentEmphasisAndColor).
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   383
    s nextPutAll:(
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   384
'"
17075
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   385
    This is an autogenerated documentation template from ',Timestamp now printString,'.
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   386
    You can disable the generation of this template via the settings or by evaluating:
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   387
         UserPreferences current showMethodTemplate:false
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   388
16355
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   389
    comment describing this class.
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   390
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   391
    [instance variables:]
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   392
        describe instance variables
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   393
    [class variables:]
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   394
        describe class variables
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   395
    [see also:]
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   396
16355
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   397
    [author:]
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   398
        %1
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   399
"
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   400
' bindWith:(OperatingSystem getFullUserName)).
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   401
    ^ s contents
17075
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   402
7f86606cded8 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 16914
diff changeset
   403
    "Modified: / 18-11-2016 / 01:32:06 / cg"
17080
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   404
    "Modified (comment): / 18-11-2016 / 10:52:32 / cg"
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   405
!
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   406
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   407
methodTemplateForPackageDocumentation
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   408
    "return a documentation-method definition template string for packages"
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   409
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   410
    |s|
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   411
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   412
    s := (TextStream ? WriteStream) on:''.
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   413
    s nextPutAll:
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   414
'documentation
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   415
'.
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   416
    s emphasis:(UserPreferences current commentEmphasisAndColor).
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   417
    s nextPutAll:(
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   418
'"
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   419
    This is an autogenerated documentation template from ',Timestamp now printString,'.
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   420
    You can disable the generation of this template via the settings or by evaluating:
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   421
         UserPreferences current showMethodTemplate:false
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   422
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   423
    Package Documentation
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   424
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   425
    [see also:]
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   426
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   427
    [author:]
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   428
        %1
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   429
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   430
    [primary maintainer:]
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   431
        %1
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   432
"
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   433
' bindWith:(OperatingSystem getFullUserName)).
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   434
    ^ s contents
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   435
66da66f3cb75 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 17075
diff changeset
   436
    "Created: / 18-11-2016 / 10:49:08 / cg"
16355
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   437
!
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   438
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   439
methodTemplateForVersionMethodCVS
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   440
    "careful to avoid expansion by cvs here!!"
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   441
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   442
    ^ ('version_CVS\    ^ ''$' , 'Header$''') withCRs
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   443
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   444
    "Created: / 21-08-2012 / 11:52:27 / cg"
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   445
! !
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
   446
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
!SmalltalkCodeGeneratorTool methodsFor:'code generation'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
createClassInitializeMethodIn:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
    "create a #initialize method on the class side (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
    |nonMetaClass metaClass className code initializer bindings|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
    (metaClass includesSelector:#'initialize') ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
        bindings := Dictionary new.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
        bindings at:'INIT_CLASSINSTVARS' put:(
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
            String streamContents:[:s |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
                metaClass instVarNames do:[:eachClassInstVar |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
                    initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
                    s nextPutLine:('    "/ %1 := %2.' bindWith:eachClassInstVar with:initializer).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
                ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
            ]).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
        bindings at:'INIT_CLASSVARS' put:(
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
            String streamContents:[:s |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
                nonMetaClass classVarNames do:[:eachClassVar |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
                    initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
                    s nextPutLine:('    "/ %1 := %2.' bindWith:eachClassVar with:initializer).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
                ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
            ]).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
        code := (self codeFor_classInitialize) expandPlaceholdersWith:bindings.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
            compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   483
            inCategory:#initialization.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   485
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
    self executeCollectedChangesNamed:('Add Class Initializer to ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
createClassTypeTestMethodsIn:aClass forClasses:subClasses
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
    "create a #isXXX test methods (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
    | code|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
    subClasses do:[:eachSubClass |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
        |nm selector|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
        nm := eachSubClass nameWithoutPrefix.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
        selector := 'is' , nm.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
        (aClass includesSelector:selector) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
            code := (selector , '\    ^ false') withCRs.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
            self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
                compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
                forClass:aClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   506
                inCategory:#testing.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
        (eachSubClass includesSelector:selector) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
            code := (selector , '\    ^ true') withCRs.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
            self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
                compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
                forClass:eachSubClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   513
                inCategory:#testing.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
    self executeCollectedChangesNamed:'Add ClassType Tests'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
createEnumTypeCodeFor:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
    |nonMetaClass metaClass className enumValues code initCode runValue maxValue|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
    enumValues := nonMetaClass classVarNames.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
    enumValues do:[:eachVariableName |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
            createAccessMethodsFor:(Array with:eachVariableName)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
            in:metaClass  
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
            withChange:false
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
            asValueHolder:false
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
            readersOnly:true    
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
            writersOnly:false
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
    maxValue := enumValues 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
                    inject:0 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
                    into:[:maxSoFar :eachVariableName | 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
                            |oldVal val| 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
                            oldVal := nonMetaClass classVarAt:eachVariableName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
                            oldVal notNil ifTrue:[ val := oldVal numericValue ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
                            (val ? maxSoFar) max:maxSoFar
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
                         ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
16878
c36819d8f84d #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16786
diff changeset
   549
    initCode := WriteStream on:''.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
    initCode nextPutLine:'initialize'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
    runValue := maxValue + 1.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
    enumValues keysAndValuesDo:[:idx :eachVariableName |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
        |oldValue thisValue|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
        oldValue := nonMetaClass classVarAt:eachVariableName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
        oldValue notNil ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
            thisValue := oldValue numericValue.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
        ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
            thisValue := runValue.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
            runValue := runValue + 1.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
        initCode 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
            nextPutAll:'    ';
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
            nextPutAll:eachVariableName;
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
            nextPutAll:' := self basicNew'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
        (aClass canUnderstand:#'setNumericValue:') ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
            initCode nextPutAll:' setNumericValue: ',thisValue printString.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
        (aClass canUnderstand:#'setCssClassString:') ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
            initCode nextPutAll:('; setCssClassString: ''' , nonMetaClass nameWithoutPrefix asLowercaseFirst , eachVariableName , '''').
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
        (aClass canUnderstand:#'setName:') ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
            initCode nextPutAll:('; setName: ''' , eachVariableName asLowercaseFirst , '''').
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
        initCode nextPutLine:'.'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
    initCode cr.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
    initCode nextPutLine:'    "'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
    initCode nextPutLine:'     ',className, ' initialize'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
    initCode nextPutLine:'    "'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
    self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
        compile:(initCode contents)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
        forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   585
        inCategory:#'class initialization'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
    code := 'allStateNames\    ^ #( ' ,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
                ((enumValues collect:[:each | '#''',each asLowercaseFirst,'''']) asStringWith:' ') , ')',
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
                '\\    "\' ,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
                '     ',className, ' allStateNames\' ,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
                '    "\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
    self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
        compile:code withCRs
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
        forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   596
        inCategory:#queries.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
    self executeCollectedChangesNamed:('Generate EnumType Code for ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
    aClass initialize.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
    "Modified: / 1.2.1998 / 16:10:03 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
createExamplesMethodForViewClass:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
    "create an examples method"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
    |nonMetaClass metaClass className code|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   614
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
    (metaClass includesSelector:#examples) ifFalse:[
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   617
        code :=
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
'examples
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
 Notice that everything between [exBegin] and [exEnd] is extracted by the html-doc generator
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
 to create nicely formatted and clickable executable examples in the generated html-doc.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
 (see the browsers class-documentation menu items for more)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
 trying the widget as standAlone view:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
                                                        [exBegin]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
    %1 new open
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
                                                        [exEnd]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
 embedded in another view:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
                                                        [exBegin]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
    |top v|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
    top := StandardSystemView new.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
    top extent:300@300.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    v := %1 new.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
    v origin:10@10 corner:150@150.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   637
    top add:v.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
    top open
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
                                                        [exEnd]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
"
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   641
' bindWith:className.
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   642
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   643
        self
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
            compile:code
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
   645
            forClass:metaClass
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   646
            inCategory:#documentation.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
    self executeCollectedChangesNamed:('Add Example to ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
createInitializationMethodIn:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
    "create a #initialize methods (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
    |nonMetaClass metaClass className code initializer m|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   663
    (nonMetaClass includesSelector:#initialize) ifFalse:[
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
        code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
'initialize
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   666
    "Invoked when a new instance is created."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   668
    "/ please change as required (and remove this comment)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
        nonMetaClass instVarNames do:[:eachInstVar |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
            initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
            code := code , ('    "/ ' , eachInstVar , ' := ' , initializer , '.' , Character cr).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
        m := nonMetaClass responseTo:#initialize.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
        (m notNil and:[m messagesSent size == 0]) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
            "/ inherits an empty initialize.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
            code := code , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
    "/ super initialize.   -- commented since inherited method does nothing
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
        ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
            code := code , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
    super initialize.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
            compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   692
            inCategory:#initialization.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
    self executeCollectedChangesNamed:('Add Initialized Instance Creation to ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
createInitializedInstanceCreationMethodsIn:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
    "create a #new and #initialize methods (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
    |nonMetaClass metaClass className code m|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
    self createInitializationMethodIn:aClass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   711
    (metaClass includesSelector:#new) ifFalse:[
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
        m := metaClass responseTo:#new.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
        (m isNil 
19598
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
   714
        or:[ (m sendsSelector:#initialize) not 
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
        or:[ 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
            (Dialog 
9720
1ea182385871 changed: #createInitializedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents: 9706
diff changeset
   717
                confirmWithCancel:('The inherited #new method already seems to invoke #initialize.\Redefine ?' withCRs)
1ea182385871 changed: #createInitializedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents: 9706
diff changeset
   718
                default:false
1ea182385871 changed: #createInitializedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents: 9706
diff changeset
   719
                onCancel:[^ self] ) 
1ea182385871 changed: #createInitializedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents: 9706
diff changeset
   720
        ]]) ifTrue:[
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
            code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
'new
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
    "return an initialized instance"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
    ^ self basicNew initialize.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
            self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
                compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
                forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   730
                inCategory:#'instance creation'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
    self executeCollectedChangesNamed:('Add Initialized Instance Creation to ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
9720
1ea182385871 changed: #createInitializedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents: 9706
diff changeset
   736
    "Created: / 11-10-2001 / 22:18:55 / cg"
1ea182385871 changed: #createInitializedInstanceCreationMethodsIn:
Claus Gittinger <cg@exept.de>
parents: 9706
diff changeset
   737
    "Modified: / 30-01-2011 / 00:58:04 / cg"
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   739
13628
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   740
createIsAbstractMethodIn:aClass
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   741
    "create a #isAbstract query method (I'm tired of typing)"
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   742
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   743
    |metaClass className code|
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   744
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   745
    metaClass := aClass theMetaclass.
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   746
    className := aClass theNonMetaclass name.
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   747
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   748
    self startCollectChanges.
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   749
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   750
    (metaClass includesSelector:#isAbstract) ifFalse:[
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   751
        code :=
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   752
'isAbstract
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   753
    "Return if this class is an abstract class.
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   754
     True is returned here for myself only; false for subclasses.
16195
c32e5ada2087 #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16089
diff changeset
   755
     Abstract subclasses must redefine this again."
13628
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   756
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   757
    ^ self == ',className,'.
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   758
'.
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   759
            self 
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   760
                compile:code
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   761
                forClass:metaClass 
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   762
                inCategory:#'queries'.
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   763
    ].
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   764
    self executeCollectedChangesNamed:('Make ',className,' abstract').
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   765
!
a718ccbff353 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13591
diff changeset
   766
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   767
createParametrizedInstanceCreationMethodsNamed:selector in:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   768
    "create a #selector instance creation method (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   769
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
    |nonMetaClass metaClass className code initializer m dfn|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
    dfn := Method methodDefinitionTemplateForSelector:selector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
    (nonMetaClass includesSelector:selector asSymbol) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
        code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
'initialize',dfn asUppercaseFirst,'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
    "Invoked when a new instance is created for arg."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
    "/ please change as required (and remove these comments)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
    "/ do something with arg here (instVar-foo := arg)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
        nonMetaClass instVarNames do:[:eachInstVar |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
            initializer := 'nil'. "/ need more intelligence here (try to guess class from messages sent to it) ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   790
            code := code , ('    "/ ' , eachInstVar , ' := ' , initializer , '.' , Character cr).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   791
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   792
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   793
        m := nonMetaClass responseTo:#initialize.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
        (m notNil and:[ m messagesSent size == 0 ]) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
            "/ inherits an empty initialize.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
            code := code , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
    "/ super initialize.   -- commented since inherited method does nothing
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
        ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
            code := code , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
    super initialize.  
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
            compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   809
            inCategory:#initialization.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
    (metaClass includesSelector:selector) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
        m := metaClass responseTo:selector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   814
        (m isNil 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
        or:[ (Dialog confirmWithCancel:'The ',selector,'- method is already inherited. Redefine ?' onCancel:[^ self]) ])
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
        ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
            code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
dfn,'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
    "Create & return a new instance for arg."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
    ^ self basicNew initialize',dfn asUppercaseFirst,'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
            self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
                compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
                forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   826
                inCategory:#'instance creation'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
    self executeCollectedChangesNamed:('Add Parametrized Instance Creation to ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
createPoolInitializationCodeFor:aClass
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   834
    |nonMetaClass metaClass className poolVars initCode|
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
    poolVars := nonMetaClass classVarNames.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
16878
c36819d8f84d #OTHER by stefan
Stefan Vogel <sv@exept.de>
parents: 16786
diff changeset
   844
    initCode := WriteStream on:''.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
    initCode nextPutLine:'initialize'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
    poolVars do:[:eachVariableName |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
        |oldValue thisValue|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
        oldValue := nonMetaClass classVarAt:eachVariableName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
        oldValue notNil ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
            thisValue := oldValue.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
        ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
            thisValue := nil.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
        initCode 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
            nextPutAll:'    ';
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
            nextPutAll:eachVariableName;
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
            nextPutAll:' := ';
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
            nextPutAll:thisValue storeString;
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
            nextPutLine:'.'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
    initCode cr.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
    initCode nextPutLine:'    "'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
    initCode nextPutLine:'     ',className, ' initialize'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
    initCode nextPutLine:'    "'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
    self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
        compile:(initCode contents)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
        forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   871
        inCategory:#'class initialization'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
    self executeCollectedChangesNamed:('Generate Pool Initialization Code for ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
    aClass initialize.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
    "Created: / 25-10-2006 / 09:28:40 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
createRedefinedInstanceCreationMethodsIn:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   881
    "create a redefined #new methods"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
    |nonMetaClass metaClass className code|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
    (metaClass includesSelector:#'new') ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
        code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
'new
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
    ^ super new.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
            compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   898
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   899
            inCategory:#'redefined instance creation'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
    (metaClass includesSelector:#'new:') ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
        code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
'new:n
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   904
    ^ super new:n.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   905
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   906
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
            compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   908
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   909
            inCategory:#'redefined instance creation'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   910
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   911
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   912
    self executeCollectedChangesNamed:('Redefined Instance Creation to ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
9756
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   915
createSingletonPatternInstanceCreationMethodsIn:aClass usingVariable:varName
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   916
    "create redefined #new methods for singleton pattern.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   917
     Uses varName (typically a class-instvar) to keep the singleton instance."
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   918
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   919
    |nonMetaClass metaClass className code|
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   920
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   921
    nonMetaClass := aClass theNonMetaclass.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   922
    metaClass := aClass theMetaclass.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   923
    className := nonMetaClass name.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   924
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   925
    self startCollectChanges.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   926
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   927
    (metaClass includesSelector:#theOneAndOnlyInstance) ifFalse:[
9756
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   928
        code :=
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   929
'theOneAndOnlyInstance
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   930
    "returns a singleton"
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   931
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   932
    %1 isNil ifTrue:[
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   933
        %1 := self basicNew initialize.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   934
    ].
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   935
    ^ %1.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   936
'.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   937
        self 
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   938
            compile:(code bindWith:varName)
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   939
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   940
            inCategory:#'instance creation'.
9756
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   941
    ].
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   942
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   943
    (metaClass includesSelector:#new) ifFalse:[
9756
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   944
        code :=
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   945
'new
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   946
    "returns a singleton"
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   947
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   948
    ^ self theOneAndOnlyInstance.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   949
'.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   950
        self 
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   951
            compile:(code bindWith:varName)
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   952
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   953
            inCategory:#'instance creation'.
9756
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   954
    ].
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   955
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   956
   (metaClass includesSelector:#flushSingleton) ifFalse:[
9756
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   957
        code :=
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   958
'flushSingleton
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   959
    "flushes the cached singleton"
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   960
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   961
    %1 := nil
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   962
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   963
    "
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   964
     self flushSingleton
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   965
    "
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   966
'.
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   967
        self 
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   968
            compile:(code bindWith:varName)
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   969
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
   970
            inCategory:#'instance creation'.
9756
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   971
    ].
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   972
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   973
    self executeCollectedChangesNamed:('Singleton Pattern for ' , className).
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   974
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   975
    "Created: / 10-02-2011 / 16:32:48 / cg"
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   976
!
5a1787bbf85e added: #classMenuGenerateSingletonPatternInstanceCreationMethods
Claus Gittinger <cg@exept.de>
parents: 9720
diff changeset
   977
16695
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   978
createStandaloneStartupCodeFor:aClass
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   979
    "create an empty console application framework"
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   980
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   981
    |metaClass nonMetaclass className txt|
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   982
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   983
    targetClass := aClass.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   984
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   985
    self startCollectChanges.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   986
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   987
    metaClass := aClass theMetaclass.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   988
    nonMetaclass := aClass theNonMetaclass.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   989
    className := nonMetaclass name.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   990
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   991
    (metaClass includesSelector:#applicationRegistryPath) ifFalse:[
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   992
        txt := self codeFor_standAloneApplicationRegistryPathFor:nonMetaclass.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   993
        self
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   994
            compile:(txt bindWith:className)
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   995
            forClass:metaClass 
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   996
            inCategory:'constants & defaults'.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   997
    ].
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   998
    (metaClass includesSelector:#applicationUUID) ifFalse:[
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
   999
        txt := self codeFor_standAloneApplicationUUID.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1000
        self
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1001
            compile:(txt bindWith:className)
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1002
            forClass:metaClass 
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1003
            inCategory:'constants & defaults'.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1004
    ].
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1005
    (metaClass includesSelector:#usage) ifFalse:[
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1006
        txt := self codeFor_standAloneUsage.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1007
        self
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1008
            compile:(txt bindWith:className)
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1009
            forClass:metaClass 
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1010
            inCategory:'startup'.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1011
    ].
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1012
    (metaClass includesSelector:#'main:') ifFalse:[
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1013
        txt := self codeFor_standAloneMainFor:nonMetaclass.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1014
        self
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1015
            compile:(txt bindWith:className)
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1016
            forClass:metaClass 
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1017
            inCategory:'startup'.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1018
    ].
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1019
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1020
    self executeCollectedChangesNamed:('Add StandaloneStartup Code for ' , className).
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1021
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1022
    "Created: / 19-08-2011 / 02:01:31 / cg"
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1023
    "Modified: / 14-06-2016 / 07:37:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1024
!
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  1025
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
createStandardPrintOnMethodIn:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
    "create a #printOn: method (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
    |code nonMetaClass|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1034
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1035
    (nonMetaClass includesSelector:#printOn:) ifFalse:[
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
        code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
'printOn:aStream
16786
db6841c714f6 #OTHER by mawalch
mawalch
parents: 16779
diff changeset
  1038
    "append a printed representation of the receiver to the argument, aStream"
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
    super printOn:aStream.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
        nonMetaClass instVarNames do:[:eachInstVarName |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
            code := code , '    '.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
            code := code , 'aStream nextPutAll:'''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
            code := code , eachInstVarName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
            code := code , ': ''.' , Character cr.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
            code := code , '    '.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
            code := code , eachInstVarName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
            code := code , ' printOn:aStream.' , Character cr.
16786
db6841c714f6 #OTHER by mawalch
mawalch
parents: 16779
diff changeset
  1050
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
16786
db6841c714f6 #OTHER by mawalch
mawalch
parents: 16779
diff changeset
  1053
        self
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
            compile:code
16786
db6841c714f6 #OTHER by mawalch
mawalch
parents: 16779
diff changeset
  1055
            forClass:nonMetaClass
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1056
            inCategory:#'printing & storing'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
    self executeCollectedChangesNamed:('Add #printOn: to ' , nonMetaClass name).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
    "Created: / 11.10.2001 / 22:18:55 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
createStartupCodeFor:aClass forStartOf:anApplicationClassOrNil
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
    "create startup code (main)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
    |nonMetaClass metaClass className source 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
     hasAplicationClass anApplicationClassNameOrStartupClassName|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
    hasAplicationClass := anApplicationClassOrNil notNil.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1074
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1076
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
    (metaClass includesSelector:#main:) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1080
        source := String streamContents:[:stream |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
            stream nextPutAll: 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
'main:argv
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
    self verboseInfo:''starting %1''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
            hasAplicationClass ifTrue: [
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
                stream nextPutAll: 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
'    Smalltalk openDisplay.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
    Display notNil ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
        Display exitOnLastClose:true.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
    %1 open.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
'.
12458
ea3f2adb406f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12440
diff changeset
  1094
            ] ifFalse:[
ea3f2adb406f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12440
diff changeset
  1095
                stream nextPutAll: 
ea3f2adb406f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12440
diff changeset
  1096
'     "/ replace by real code
ea3f2adb406f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12440
diff changeset
  1097
     Stdout nextPutLine:''Hello World''.
ea3f2adb406f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12440
diff changeset
  1098
'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
        anApplicationClassNameOrStartupClassName := hasAplicationClass 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
            ifTrue: [anApplicationClassOrNil name]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
            ifFalse: [className.].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
            compile:(source bindWith:anApplicationClassNameOrStartupClassName)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1108
            inCategory:#startup.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
    self executeCollectedChangesNamed:('Add Startup Code to ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
createTestCaseSampleCodeFor:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
    "create an (almost) empty testCase class"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
    |nonMetaClass metaClass|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
    "/ className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
    ( nonMetaClass includesSelector:#test1 ) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
            compile:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
'test1
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
    "This is a demonstration testCase - it is meant to be removed eventually.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
     This testCase will PASS.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
     Double click on the TestCase class or open a TestRunner to see me checking...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
     - please add more methods like this..."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
    |o|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
    o := Array new:2.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
    self assert: ( o size == 2 ).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    self should: [ o at:0 ] raise:Error.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
    self shouldnt: [ o at:1 ] raise:Error.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
     self run:#test1
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
     self new test1
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1144
            inCategory:#tests.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1146
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
    ( nonMetaClass includesSelector:#test2 ) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
            compile:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
'test2
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
    "This is a demonstration testCase - it is meant to be removed eventually..
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
     This testCase WILL FAIL.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
     Double click on the TestCase class or open a TestRunner to see me checking...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
     - please add more methods like this..."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
    |o|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
    o := Array new:2.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
    self assert: ( o size == 3 ).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
     self run:#test2
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
     self new test2
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1167
            inCategory:#tests.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1168
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
    ( nonMetaClass includesSelector:#test3 ) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
            compile:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
'test3
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
    "This is a demonstration testCase - it is meant to be removed eventually..
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
     This testCase WILL generate an ERROR.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1176
     Double click on the TestCase class or open a TestRunner to see me checking...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
     - please add more methods like this..."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
    |o|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1180
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
    o := Array new:2.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
    self assert: ( o foo ).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1184
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
     self run:#test3
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
     self new test3
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1187
    "
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1190
            inCategory:#tests.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
    ( nonMetaClass includesSelector:#setUp ) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
            compile:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
'setUp
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
    "common setup - invoked before testing."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1198
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1199
    super setUp
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1200
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1201
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1202
            inCategory:#'initialize / release'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1203
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
    ( nonMetaClass includesSelector:#tearDown ) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
            compile:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1208
'tearDown
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
    "common cleanup - invoked after testing."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1210
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1211
    super tearDown
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1212
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1214
            inCategory:#'initialize / release'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
    ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
    "create acceptVisitor: in visitedClass and acceptXXX in visitorClass. (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1220
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
    |sel|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1222
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1223
    self assert:( visitedClass isMeta not ).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1224
    self assert:( visitorClass isMeta not ).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
    sel := ('visit' , visitedClass nameWithoutPrefix , ':').
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1229
    self createAcceptVisitorMethod:sel in:visitedClass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1230
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1231
    (visitorClass includesSelector:sel) ifFalse:[
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1232
        self
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1233
            compile:
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1234
(('%1anObject
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1235
    "dispatched back from the visited %2-object (visitor pattern)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1236
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
    "fall back to general object-case - please change as required"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
    ^ self visitObject:anObject
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
') bindWith:sel with:visitedClass nameWithoutPrefix asLowercaseFirst)
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1241
            forClass:visitorClass
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1242
            inCategory:#visiting.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1245
    (visitorClass includesSelector:#visitObject:) ifFalse:[
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1246
        self
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1247
            compile:
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1248
('visitObject:anObject
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
    "dispatched back from the visited objects (visitor pattern)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1251
    "general fallBack - please change as required"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1252
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1253
    self halt:''not yet implemented''
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1254
')
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1255
            forClass:visitorClass
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1256
            inCategory:#visiting.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1257
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1258
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1259
    (visitorClass includesSelector:#visit:) ifFalse:[
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1260
        self
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
            compile:
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1262
('visit:anObject
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
    "visit anObject (visitor pattern).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
     The object should call back one of my visitXXXX methods."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1265
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1266
    ^ anObject acceptVisitor:self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1267
')
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1268
            forClass:visitorClass
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1269
            inCategory:#visiting.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
    self executeCollectedChangesNamed:('Add Visitor Pattern').
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1274
13811
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1275
createVisitorMethodsIn:visitedClass andVisitorClass:visitorClass withParameter:withParameter withSuper:withSuper 
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1276
    "   
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1277
        This is much like createVisitorMethodsIn:andVisitorClass:,
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1278
        but:
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1279
        - if withParameter is true, generates
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1280
            #acceptVisitor:with:
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1281
            and
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1282
            #visit<CLASNAME>:with:
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1283
        - if withSuper is true, generates
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1284
            self visit<SUPERCLASSNAME>:[with:] in the visitXXX methods body"
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1285
    
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1286
    | sel  superSel  template |
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1287
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1288
    self assert:(visitedClass isMeta not).
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1289
    self assert:(visitorClass isMeta not).
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1290
    self startCollectChanges.
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1291
    sel := ('visit' , visitedClass nameWithoutPrefix , ':').
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1292
    superSel := ('visit' , visitedClass superclass nameWithoutPrefix , ':').
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1293
    template := '`@sel: object %1
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1294
    "Dispatched back from the visited object (visitor pattern)"
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1295
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1296
    ^ %2
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1297
    ' 
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1298
            bindWith:(withParameter ifTrue:['with: param'] ifFalse:[''])
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1299
            with:(withSuper 
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1300
                    ifTrue:[
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1301
                        'self `@superSel: anObject' 
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1302
                            , (withParameter ifTrue:[' with: param'] ifFalse:[''])
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1303
                    ]
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1304
                    ifFalse:['self subclassResponsibility']).
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1305
    self createAcceptVisitorMethod:sel in:visitedClass withParameter: withParameter.
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1306
    (visitorClass includesSelector:sel) ifFalse:[
19607
f9108fde4972 Move `CodeGenerator` and `CodeGeneratorTests` to namespace `Tools`
Jan Vrany <jan.vrany@labware.com>
parents: 19598
diff changeset
  1307
        self addChange:((Tools::CodeGenerator new)
13811
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1308
                    class:visitorClass;
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1309
                    protocol:'visiting';
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1310
                    source:template;
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1311
                    replace:'`@sel:' with:sel asSymbol;
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1312
                    replace:'`@superSel:' with:superSel asSymbol;
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1313
                    change)
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1314
    ].
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1315
    (visitorClass includesSelector:#visit:) ifFalse:[
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1316
        self 
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1317
            compile:('visit:object %1
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1318
    "visit anObject (visitor pattern).
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1319
     The object should call back one of my visitXXXX methods."
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1320
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1321
    ^ object acceptVisitor:self %1
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1322
' 
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1323
                    bindWith:(withParameter ifTrue:['with: parameter'] ifFalse:['']))
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1324
            forClass:visitorClass
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1325
            inCategory:'visiting'.
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1326
    ].
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1327
    self executeCollectedChangesNamed:('Add Visitor Pattern').
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1328
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1329
    "Created: / 05-08-2013 / 13:13:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1330
!
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1331
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1332
createWebApplicationCodeFor:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1333
    "create an empty webApplication framework"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1334
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1335
    |nonMetaClass metaClass className txt|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1336
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1337
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1338
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1339
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
    (metaClass includesSelector:#pageSpec) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1344
        txt := self class initialPageSpecMethodSourceForWebApplications.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1345
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1346
            compile:(txt bindWith:className)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1347
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1348
            inCategory:#'page specs'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1349
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1350
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
    self executeCollectedChangesNamed:('Add WebApplication Code for ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
    "Modified: / 1.2.1998 / 16:10:03 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1356
createWebServiceCodeFor:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1357
    "create an empty webService framework"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1358
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1359
    |nonMetaClass metaClass className txt|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1363
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1364
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1365
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1366
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1367
    (nonMetaClass includesSelector:#page1:) ifFalse:[
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
        txt :=
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1369
'page1:aRequest
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1370
    "This is a sample page-generation method. 
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1371
     This uses the simplest possible way to generate html: generating plain HTML. 
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1372
     See page2 for a more structured example."
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1373
15003
95e259bc509f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 14700
diff changeset
  1374
    <resource: #PAGE>
95e259bc509f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 14700
diff changeset
  1375
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
    |response|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1377
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1378
    response := aRequest response.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1379
    response nextPutLine:''<HTML>''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1380
    response nextPutLine:''  <HEAD>''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1381
    response nextPutLine:''  <TITLE>Hello</TITLE>''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
    response nextPutLine:''  </HEAD>''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
    response nextPutLine:''  <BODY>''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
    response nextPutLine:''    <H1>Hello World !!</H1>''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
    response nextPutLine:''  </BODY>''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
    response nextPutLine:''</HTML>''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
            compile:txt
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1391
            inCategory:#'response generation - pages'.
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1392
    ].
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1393
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1394
    (nonMetaClass includesSelector:#page2:) ifFalse:[
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1395
        txt :=
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1396
'page2:aRequest
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1397
    "This is a sample page-generation method. 
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1398
     This uses a slightly more convenient way to generate html: using an HTML tree builder. 
15006
51c4a44295be class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15005
diff changeset
  1399
     Even better examples to follow..."
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1400
15003
95e259bc509f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 14700
diff changeset
  1401
    <resource: #PAGE>
95e259bc509f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 14700
diff changeset
  1402
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1403
    |page|
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1404
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1405
    page := HTML::TreeBuilder newDocument.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1406
    page
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1407
        head;
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1408
            title:''Hello'';
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1409
        headEnd;
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1410
        body;
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1411
            h1:''Hello World'';
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1412
            div;
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1413
                nlsText:''here is some text and '';
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1414
                a; href:''page3''; 
15007
1214b261a086 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15006
diff changeset
  1415
                    text:''an anchor to page3'';
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1416
                aEnd;
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1417
                text:'' and an image: '';
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1418
                img:(httpServer graphicLinkIdFor:(ToolbarIconLibrary smiley_cool) expirationTimeDelta:30 seconds);
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1419
            divEnd;
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1420
        bodyEnd.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1421
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1422
    aRequest reply:(page htmlString).
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1423
'.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1424
        self
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1425
            compile:txt
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1426
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1427
            inCategory:#'response generation - pages'.
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1428
    ].
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1429
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1430
    (nonMetaClass includesSelector:#page3:) ifFalse:[
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1431
        txt :=
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1432
'page3:aRequest
15005
99f17b72f95d class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15004
diff changeset
  1433
    "This is a sample page which generates plain text (i.e. not html)."
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1434
15003
95e259bc509f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 14700
diff changeset
  1435
    <resource: #PAGE>
95e259bc509f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 14700
diff changeset
  1436
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1437
    aRequest response
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1438
        contentType:''text/plain'';
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1439
        data:''This is some plain text,
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1440
without any html formatting.''
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1441
'.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1442
        self
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1443
            compile:txt
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1444
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1445
            inCategory:#'response generation - pages'.
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1446
    ].
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1447
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1448
    (nonMetaClass includesSelector:#process:) ifFalse:[
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1449
        txt :=
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1450
'process:aRequest
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1451
    "This is the web services main processing method.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1452
     It will be invoked for every incoming webBrowser-request.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1453
     The argument, aRequest contains the parameters (url, fields, parameters etc.); browse HTTPRequest for details.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1454
     Its response object collects any returned html or other contents. Browse HTTPResponse for more info.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1455
15004
0df5dfbfbb1d class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15003
diff changeset
  1456
     Here, a simple dipatch method is used: a hardcoded switch on the URL...
0df5dfbfbb1d class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15003
diff changeset
  1457
     It uses the page-name directly as selector for the page-generating method.
0df5dfbfbb1d class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15003
diff changeset
  1458
     Because that would open a possible security hole (incoming url being #halt, for example),
0df5dfbfbb1d class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15003
diff changeset
  1459
     we only call methods which have been annotated with PAGE (see sample pages)"
9935
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1460
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1461
    |whichPage methodName method|
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1462
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1463
    whichPage := aRequest pathRelativeToService.
9935
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1464
    whichPage isEmpty ifTrue:[ whichPage := ''page1'' ].
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1465
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1466
    "/ to prevent intruders from calling any method, check if it one
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1467
    "/ of my own methods, which is marked as a PAGE-method.
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1468
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1469
    methodName := (whichPage,'':'') asSymbol.
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1470
    method := self class compiledMethodAt:methodName.
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1471
    "/ is there such a method ?
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1472
    method notNil ifTrue:[                                 
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1473
        "/ and it is marked as being a WebPage-generator ?
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1474
        (method hasResource:#''PAGE'') ifTrue:[
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1475
            self perform:methodName with:aRequest.
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1476
            ^ self
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1477
        ].
9934
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1478
    ].
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1479
    aRequest reportNotFound:''No such page in this service''.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1480
'.
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1481
        self
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1482
            compile:txt
e8885f059bea changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9756
diff changeset
  1483
            forClass:nonMetaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1484
            inCategory:#'response generation'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1485
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
    (metaClass includesSelector:#linkName) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1488
        txt :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1489
'linkName
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1490
    "return the default linkName path (with slash)."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1491
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1492
    ^ ''/NewService''
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1494
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1495
            compile:txt
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1496
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1497
            inCategory:#defaults.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1498
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
    (metaClass includesSelector:#settingsApplicationClass) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
        txt :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
'settingsApplicationClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
    "a SettingsApplication class - or nil (used in the settings dialog if non-nil)."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1504
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
    ^ nil
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1507
        self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1508
            compile:txt
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1509
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1510
            inCategory:#defaults.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1512
15067
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1513
    (nonMetaClass includesSelector:#addRequiredForeignServicesTo:) ifFalse:[
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1514
        txt :=
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1515
'addRequiredForeignServicesTo:aServer 
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1516
    "add any additional (usually file-) services"
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1517
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1518
    "/ uncomment to install additional standard file services
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1519
    "/ self addStandardFileServicesTo:aServer.
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1520
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1521
    "/ uncomment and add an instance variable named ''tentativeObjectService'' if you need
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1522
    "/ a tentative object service
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1523
    "/ tentativeObjectService := aServer tentativeObjectService.
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1524
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1525
    "/ uncomment to install a file service for my data files (in the ''data'' folder of my project directory
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1526
    "/ (aServer serviceForLink:(self linkName,''/data'') ifAbsent:nil) isNil ifTrue:[
15069
ca54ea5a83f9 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15067
diff changeset
  1527
    "/     aServer addFileServiceWithRootLinkName:(self linkName,''/data'')
15067
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1528
    "/                 rootDirectory:(self class projectDirectory / ''data'') 
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1529
    "/                 defaultFileName:nil.
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1530
    "/ ].
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1531
'.
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1532
        self
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1533
            compile:txt
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1534
            forClass:nonMetaClass 
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1535
            inCategory:#initialization.
dce943cf284f class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15007
diff changeset
  1536
    ].
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1537
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1538
    self executeCollectedChangesNamed:('Add WebService Code for ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1539
9935
5a0685d2ee90 changed: #createWebServiceCodeFor:
Claus Gittinger <cg@exept.de>
parents: 9934
diff changeset
  1540
    "Modified: / 02-06-2011 / 12:51:15 / cg"
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1541
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1542
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1543
createWidgetCodeFor:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1544
    "create usually required widget code (redraw, model update, event handling)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1545
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1546
    |nonMetaClass metaClass className compileTemplateAction|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1547
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1548
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1549
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1550
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1551
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
    className := nonMetaClass name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1553
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1554
    compileTemplateAction :=
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1555
        [:selector :templateSelector :category |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1556
            (nonMetaClass includesSelector:selector) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
                |txt|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1558
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1559
                txt := self perform:templateSelector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1560
                self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
                    compile:txt
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1562
                    forClass:nonMetaClass
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1563
                    inCategory:category.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1564
            ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1565
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1566
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1567
    #(
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1568
        initialize               code_forWidget_initialize  #'initialization & release'
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1569
        update:with:from:        code_forWidget_update      #'change & update'
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1570
        redrawX:y:width:height:  code_forWidget_redraw      #'drawing'
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1571
        buttonPress:x:y:         code_forWidget_buttonPress #'event handling'
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1572
        keyPress:x:y:            code_forWidget_keyPress    #'event handling'
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1573
        sizeChanged:             code_forWidget_sizeChanged #'event handling'
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1574
    ) inGroupsOf:3 do:compileTemplateAction.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1575
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1576
    self executeCollectedChangesNamed:('Add Widget Code for ' , className).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1577
! !
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1578
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1579
!SmalltalkCodeGeneratorTool methodsFor:'code generation-basic'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1580
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1581
createAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange asValueHolder:asValueHolder readersOnly:readersOnly writersOnly:writersOnly lazyInitialization:lazyInitialization
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1582
    "workhorse for creating access methods for instvars."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1583
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1584
    |classesClassVars generateCommentsForSetters generateCommentsForGetters|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1585
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1586
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1587
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1588
    generateCommentsForSetters := userPreferences generateCommentsForSetters.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1589
    generateCommentsForGetters := userPreferences generateCommentsForGetters.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1590
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1591
    classesClassVars := aClass theNonMetaclass allClassVarNames.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1592
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1593
    aCollectionOfVarNames do:[:name |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1594
        |source varType methodName defaultMethodName argName|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1595
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1596
        varType := (classesClassVars includes:name) 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1597
                        ifTrue:['static'] 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1598
                        ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1599
                            (aClass isMeta ifTrue:['classInstVar'] ifFalse:['instance'])].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1600
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1601
        methodName := name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1602
        name isUppercaseFirst ifTrue:[
10371
c35aa5f6abf6 changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents: 9960
diff changeset
  1603
            (name conform:[:ch | ch isLetter not or:[ch isUppercase]]) ifFalse:[      "/ allow all-uppercase for class-vars
c35aa5f6abf6 changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents: 9960
diff changeset
  1604
                methodName := methodName asLowercaseFirst. 
c35aa5f6abf6 changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents: 9960
diff changeset
  1605
            ]
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1606
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1607
        argName := 'something'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1608
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1609
        "/ the GETTER
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1610
        writersOnly ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1611
            lazyInitialization ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1612
                defaultMethodName := 'default' , name asUppercaseFirst.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1613
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1614
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1615
            "check, if method is not already present"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1616
            (aClass includesSelector:(methodName asSymbol)) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1617
                asValueHolder ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1618
                    source := methodName , '\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1619
                    generateComments ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1620
                        source := source , '    "return/create the ''%2'' value holder (automatically generated)"\\'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1621
                    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1622
                    source := source , '    %2 isNil ifTrue:[\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1623
                    lazyInitialization ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1624
                        source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1625
                                   , '        %2 := self class %3 asValue.\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1626
                    ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1627
                        source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1628
                                   , '        %2 := ValueHolder new.\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1629
                    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1630
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1631
                    withChange ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1632
                    source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1633
                               , '        %2 addDependent:self.\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1634
                    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1635
                    source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1636
                               , '    ].\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1637
                               , '    ^ %2'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1638
                ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1639
                    source := methodName , '\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1640
                    lazyInitialization ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1641
                        generateCommentsForGetters ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1642
                            source := source , '    "return the %1 instance variable ''%2'' with lazy instance creation (automatically generated)"\\'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1643
                        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1644
                        source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1645
                                    , '    %2 isNil ifTrue:[\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1646
                                    , '        %2 := self class %3.\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1647
                                    , '    ].\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1648
                                    , '    ^ %2'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1649
                    ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1650
                        generateCommentsForGetters ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1651
                            source := source , '    "return the %1 instance variable ''%2'' (automatically generated)"\\'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1652
                        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1653
                        source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1654
                                    , '    ^ %2'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1655
                    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1656
                ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1657
                source := (source bindWith:varType with:name with:defaultMethodName) withCRs.
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1658
                self compile:source forClass:aClass inCategory:(asValueHolder ifTrue:[#aspects] ifFalse:[#accessing]).
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1659
            ] ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1660
                Transcript showCR:'method ''', methodName , ''' already present'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1661
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1662
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1663
            "/ default for lazy on class side
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1664
            lazyInitialization ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1665
                (aClass theMetaclass includesSelector:(defaultMethodName asSymbol)) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1666
                    source := defaultMethodName , '\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1667
                    generateComments ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1668
                        source := source , '    "default value for the ''%2'' instance variable (automatically generated)"\\'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1669
                    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1670
                    source := source    
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1671
                               , '    self shouldImplement.\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1672
                               , '    ^ nil.'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1673
                    source := (source bindWith:varType with:name) withCRs.
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1674
                    self compile:source forClass:aClass theMetaclass inCategory:#defaults.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1675
                ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1676
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1677
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1678
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1679
        "/ the SETTER
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1680
        readersOnly ifFalse:[
14118
e05c6b42870d class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13811
diff changeset
  1681
            (aClass includesSelector:(methodName asMutator)) ifFalse:[
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1682
                ((methodName size > 2) and:[ (methodName startsWith:'is') and:[ (methodName at:3) isUppercase ]])
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1683
                ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1684
                    argName := 'aBoolean'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1685
                ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1686
                asValueHolder ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1687
                    source := methodName , ':%3\'.  "/ argName
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1688
                    generateComments ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1689
                        source := source , '    "set the ''%2'' value holder' , ' (automatically generated)"\\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1690
                    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1691
                    withChange ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1692
                        source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1693
                                  , '    |oldValue newValue|\\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1694
                                  , '    %2 notNil ifTrue:[\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1695
                                  , '        oldValue := %2 value.\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1696
                                  , '        %2 removeDependent:self.\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1697
                                  , '    ].\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1698
                                  , '    %2 := %3.\'        "/ argName
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1699
                                  , '    %2 notNil ifTrue:[\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1700
                                  , '        %2 addDependent:self.\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1701
                                  , '    ].\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1702
                                  , '    newValue := %2 value.\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1703
                                  , '    oldValue ~~ newValue ifTrue:[\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1704
                                  , '        self update:#value with:newValue from:%2.\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1705
                                  , '    ].\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1706
                    ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1707
                        source := source 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1708
                                  , '    %2 := %3.'.  "/ argName
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1709
                    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1710
                ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1711
                    source := methodName , ':%3\'.    "/ argName
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1712
                    withChange ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1713
                        generateComments ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1714
                            source := source , '    "set the value of the %1 variable ''%2'''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1715
                            source := source , ' and send a change notification (automatically generated)"\\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1716
                        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
                        source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1718
                                  , '    (%2 ~~ %3) ifTrue:[\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1719
                                  , '        %2 := %3.\'           "/ argName
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1720
                                  , '        self changed:#%2.\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1721
                                  , '     ].\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1722
                    ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1723
                        generateCommentsForSetters ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1724
                            source := source , '    "set the value of the %1 variable ''%2'''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1725
                            source := source , ' (automatically generated)"\\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1726
                        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1727
                        source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1728
                                  , '    %2 := %3.'.          "/ argName
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1729
                    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1730
                ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1731
                source := (source bindWith:varType with:name with:argName) withCRs.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1732
                self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1733
                    compile:source 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1734
                    forClass:aClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1735
                    inCategory:(asValueHolder ifTrue:[#aspects] ifFalse:[#accessing]).
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1736
            ] ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1737
                Transcript showCR:'method ''', methodName , ':'' already present'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1738
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1739
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1740
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1741
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1742
    self executeCollectedChangesNamed:('Add Accessors').
10371
c35aa5f6abf6 changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents: 9960
diff changeset
  1743
c35aa5f6abf6 changed: #createAccessMethodsFor:in:withChange:asValueHolder:readersOnly:writersOnly:lazyInitialization:
Claus Gittinger <cg@exept.de>
parents: 9960
diff changeset
  1744
    "Modified: / 21-07-2011 / 15:19:25 / cg"
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1745
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1746
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1747
createCollectionAccessMethodsFor:aCollectionOfVarNames in:aClass withChange:withChange
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
    |classesClassVars|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1749
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
    classesClassVars := aClass theNonMetaclass allClassVarNames.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1753
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
    aCollectionOfVarNames do:[:name |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
        |source varType methodNameBase methodName defaultMethodName|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1756
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1757
        varType := (classesClassVars includes:name) 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1758
                        ifTrue:['static'] 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1759
                        ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1760
                            (aClass isMeta ifTrue:['classInstVar'] ifFalse:['instance'])].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1761
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1762
        methodNameBase := name asUppercaseFirst.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1763
        (methodNameBase endsWith:'s') ifTrue:[
12712
b412eb74759b Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 12458
diff changeset
  1764
            methodNameBase := methodNameBase copyButLast:1.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1766
        methodName := 'add' , methodNameBase, ':'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1767
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1768
        "check, if method is not already present"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
        (aClass includesSelector:(methodName asSymbol)) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1770
            source := methodName , 'a%1\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
            generateComments ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1772
                source := source , '    "add a ',methodNameBase,'"\\'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1774
            source := source , '    %2 isNil ifTrue:[\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1775
                source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1776
                           , '        %2 := OrderedCollection new.\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1777
            source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1778
                       , '    ].\'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1779
                       , '    %2 add: a%1'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1780
            source := (source bindWith:methodNameBase with:name) withCRs.
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1781
            self compile:source forClass:aClass inCategory:#accessing.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1782
        ] ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1783
            Transcript showCR:'method ''', methodName , ''' already present'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1784
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1785
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1786
        methodName := 'remove' , methodNameBase, ':'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1787
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1788
        "check, if method is not already present"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1789
        (aClass includesSelector:(methodName asSymbol)) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1790
            source := methodName , 'a%1\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1791
            generateComments ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1792
                source := source , '    "remove a ',methodNameBase,'"\\'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1793
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1794
            source := source
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1795
                       , '    %2 remove: a%1'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1796
            source := (source bindWith:methodNameBase with:name) withCRs.
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1797
            self compile:source forClass:aClass inCategory:#accessing.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1798
        ] ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1799
            Transcript showCR:'method ''', methodName , ''' already present'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1800
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1801
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1802
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1803
    self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1804
        createAccessMethodsFor:aCollectionOfVarNames 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1805
        in:aClass 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1806
        withChange:withChange 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1807
        asValueHolder:false
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1808
        readersOnly:true
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1809
        writersOnly:false
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1810
        lazyInitialization:false.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1811
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1812
    self executeCollectedChangesNamed:('Add Collection Access').
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1813
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1814
    "Created: / 04-02-2007 / 15:52:31 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1815
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1816
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1817
createValueHoldersFor:aCollectionOfVarNames in:aClass lazyInitialization:lazyInitialization
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1818
    "workhorse for creating access methods for instvars."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1819
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1820
    |nonMetaClass metaClass classesClassVars generateCommentsForSetters generateCommentsForGetters|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1821
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1822
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1823
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1824
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1825
    self startCollectChanges.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1826
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1827
    generateCommentsForSetters := userPreferences generateCommentsForSetters.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1828
    generateCommentsForGetters := userPreferences generateCommentsForGetters.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1829
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1830
    classesClassVars := nonMetaClass allClassVarNames.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1831
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1832
    aCollectionOfVarNames do:[:name |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1833
        |source varType methodName holderMethodName defaultMethodName|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1834
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1835
        holderMethodName := name.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1836
        name isUppercaseFirst ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1837
            holderMethodName := holderMethodName asLowercaseFirst. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1838
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1839
        (holderMethodName endsWith:'Holder') ifTrue:[
12712
b412eb74759b Changed usage of deprecated #copyWithoutLast: to #copyButLast:
Stefan Vogel <sv@exept.de>
parents: 12458
diff changeset
  1840
            methodName := holderMethodName copyButLast:6.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1841
        ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1842
            methodName := holderMethodName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1843
            holderMethodName := methodName , 'Holder'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1844
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1845
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1846
        methodName notNil ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1847
            (metaClass includesSelector:(methodName asSymbol)) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1848
                source := '%1\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1849
                generateComments ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1850
                    source := source , '    "return the value in ''%2''"\\'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1851
                ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1852
                source := source , '    ^ self %2 value'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1853
                source := (source bindWith:methodName with:holderMethodName) withCRs.
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1854
                self compile:source forClass:nonMetaClass inCategory:#accessing.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1855
            ] ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1856
                Transcript showCR:'method ''', methodName , ''' already present'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1857
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1858
14118
e05c6b42870d class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13811
diff changeset
  1859
            (metaClass includesSelector:(methodName asMutator)) ifFalse:[
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1860
                source := '%1: newValue\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1861
                generateComments ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1862
                    source := source , '    "set the value in ''%2''"\\'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1863
                ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1864
                source := source , '    self %2 value: newValue'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1865
                source := (source bindWith:methodName with:holderMethodName) withCRs.
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1866
                self compile:source forClass:nonMetaClass inCategory:#accessing.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1867
            ] ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1868
                Transcript showCR:'method ''', methodName , ':'' already present'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1869
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1870
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1871
        (metaClass includesSelector:(holderMethodName asSymbol)) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1872
            source := '%1\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1873
            generateComments ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1874
                source := source , '    "return/create the valueHolder ''%1''"\\'. 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1875
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1876
            source := source , '    %1 isNil ifTrue:[\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1877
            source := source , '        %1 := ValueHolder with:nil "defaultValue here".\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1878
            source := source , '    ].\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1879
            source := source , '    ^ %1\'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1880
            source := (source bindWith:holderMethodName) withCRs.
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1881
            self compile:source forClass:nonMetaClass inCategory:#accessing.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1882
        ] ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1883
            Transcript showCR:'method ''', methodName , ''' already present'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1884
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1885
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1886
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1887
    self executeCollectedChangesNamed:('Add ValueHolder').
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1888
! !
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1889
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1890
!SmalltalkCodeGeneratorTool methodsFor:'code generation-individual methods'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1891
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1892
createAcceptVisitorMethod:selector in:aClass
13811
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1893
    ^ self createAcceptVisitorMethod:selector in:aClass withParameter: false.
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1894
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1895
    "Modified: / 05-08-2013 / 13:34:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1896
!
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1897
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1898
createAcceptVisitorMethod:selector in:aClass withParameter: withParameter
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1899
    "create an acceptVisitor: method
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1900
     (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1901
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1902
    self assert:( aClass isMeta not ).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1903
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1904
    (aClass includesSelector:#'acceptVisitor:') ifFalse:[
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1905
        self
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1906
            compile:
13811
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1907
(('acceptVisitor:visitor %2
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1908
    "Double dispatch back to the visitor, passing my type encoded in
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1909
     the selector (visitor pattern)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1910
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1911
    "stub code automatically generated - please change if required"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1912
13811
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1913
    ^ visitor %1self %2
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1914
') bindWith:selector with:(withParameter ifTrue:[' with: parameter'] ifFalse:['']))
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  1915
            forClass:aClass
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1916
            inCategory:#visiting.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1917
    ]
13811
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1918
11e9c27a7ff6 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 13628
diff changeset
  1919
    "Created: / 05-08-2013 / 13:34:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1920
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1921
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1922
createAcceptVisitorMethodIn:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1923
    "create an acceptVisitor: method
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1924
     (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1925
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1926
    self
14118
e05c6b42870d class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 13811
diff changeset
  1927
        createAcceptVisitorMethod:('visit' , aClass nameWithoutPrefix) asMutator
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1928
        in:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1929
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1930
12879
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1931
createAspectMethodFor:anAspectSymbol in:aClass
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1932
    "create an aspect method."
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1933
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1934
    |source aspect|
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1935
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1936
    aspect := anAspectSymbol asSymbol.
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1937
    source := String 
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1938
        streamContents:[:s |
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1939
            s nextPutAll:aspect asString.
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1940
            s nextPutAll:'
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1941
    |holder|
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1942
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1943
    (holder := builder bindingAt:',aspect storeString,') isNil ifTrue:[
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1944
        builder aspectAt:',aspect storeString,' put:(holder := nil asValue).
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1945
    ].
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1946
    ^ holder.
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1947
'.
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1948
        ].
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1949
    self compile:source forClass:aClass inCategory:#aspects.
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1950
!
a544ab64abc0 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12712
diff changeset
  1951
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1952
createCopyrightMethodFor:copyRightText for:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1953
    "add copyright method containing text,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1954
     but only if not already present."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1955
14426
98245d2f01a2 class: SmalltalkCodeGeneratorTool
Stefan Vogel <sv@exept.de>
parents: 14118
diff changeset
  1956
    |txt log thisYear initialYear scm firstRev firstRevDate|
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1957
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1958
    (aClass includesSelector:#copyright) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1959
        copyRightText notNil ifTrue:[
14426
98245d2f01a2 class: SmalltalkCodeGeneratorTool
Stefan Vogel <sv@exept.de>
parents: 14118
diff changeset
  1960
            initialYear := thisYear := Date today year.
12440
48bd9af25138 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 11841
diff changeset
  1961
            (copyRightText includes:$%) ifTrue:[
48bd9af25138 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 11841
diff changeset
  1962
                scm := aClass theNonMetaclass sourceCodeManager.
48bd9af25138 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 11841
diff changeset
  1963
                scm == CVSSourceCodeManager ifTrue:[
48bd9af25138 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 11841
diff changeset
  1964
                    log := CVSSourceCodeManager revisionLogOf:aClass fromRevision:'1.1' toRevision:'1.1'.
15708
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1965
                    log isNil ifTrue:[
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1966
                        initialYear := thisYear
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1967
                    ] ifFalse:[
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1968
                        (firstRev := (log at:#revisions) firstIfEmpty:nil) notNil ifTrue:[     
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1969
                            firstRevDate := firstRev at:#date ifAbsent:nil.
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1970
                            firstRevDate notNil ifTrue:[
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1971
                                firstRevDate := Date readFrom:firstRevDate onError:nil. 
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1972
                                firstRevDate notNil ifTrue:[    
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1973
                                    initialYear := firstRevDate year.
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1974
                                ]
12440
48bd9af25138 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 11841
diff changeset
  1975
                            ]
48bd9af25138 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 11841
diff changeset
  1976
                        ]
15708
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  1977
                    ].
12440
48bd9af25138 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 11841
diff changeset
  1978
                ].
48bd9af25138 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 11841
diff changeset
  1979
            ].
14426
98245d2f01a2 class: SmalltalkCodeGeneratorTool
Stefan Vogel <sv@exept.de>
parents: 14118
diff changeset
  1980
            thisYear ~= initialYear ifTrue:[
98245d2f01a2 class: SmalltalkCodeGeneratorTool
Stefan Vogel <sv@exept.de>
parents: 14118
diff changeset
  1981
                txt := copyRightText bindWith:(initialYear printString, '-', thisYear printString).
98245d2f01a2 class: SmalltalkCodeGeneratorTool
Stefan Vogel <sv@exept.de>
parents: 14118
diff changeset
  1982
            ] ifFalse:[
98245d2f01a2 class: SmalltalkCodeGeneratorTool
Stefan Vogel <sv@exept.de>
parents: 14118
diff changeset
  1983
                txt := copyRightText bindWith:initialYear.
98245d2f01a2 class: SmalltalkCodeGeneratorTool
Stefan Vogel <sv@exept.de>
parents: 14118
diff changeset
  1984
            ].
98245d2f01a2 class: SmalltalkCodeGeneratorTool
Stefan Vogel <sv@exept.de>
parents: 14118
diff changeset
  1985
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1986
            self compile:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1987
'copyright
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1988
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1989
' , txt , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1990
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1991
'             forClass:aClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  1992
              inCategory:#documentation.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1993
        ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1994
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1995
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1996
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1997
createDocumentationMethodFor:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1998
    "add documentation method containing doc template
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1999
     but only if not already present."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2000
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2001
    |metaClass nonMetaClass userName loginName hostName emailAddress code existingComment|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2002
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2003
    metaClass := aClass theMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2004
    nonMetaClass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2005
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2006
    (metaClass includesSelector:#documentation) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2007
        existingComment := nonMetaClass comment.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2008
        existingComment isEmptyOrNil ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2009
            (nonMetaClass isSubclassOf:HTTPService) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2010
                existingComment := '    [start Server with:]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2011
        HTTPServer startServerOnPort:8080
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2012
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2013
    [start with:]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2014
        (self new)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2015
            registerServiceOn:(HTTPServer runningServerOnPort:8080)'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2016
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2017
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2018
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2019
        userName := OperatingSystem getFullUserName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2020
        loginName := OperatingSystem getLoginName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2021
        hostName := OperatingSystem getHostName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2022
        emailAddress := loginName , '@' , hostName.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2023
9960
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2024
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2025
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2026
        "/ ugly; should ask the class for that    
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2027
        metaClass isJavaScriptMetaclass ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2028
            code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2029
'function documentation() {
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2030
/*
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2031
' , (existingComment ? '    documentation to be added.') , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2032
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2033
    [author:]
9960
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2034
        ' ", userName 
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2035
          , ' (' , emailAddress , ')' "
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2036
        , UserPreferences current historyManagerSignature , '
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2037
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2038
    [instance variables:]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2039
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2040
    [class variables:]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2041
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2042
    [see also:]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2043
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2044
*/
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2045
}
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2046
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2047
        ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2048
            code:= 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2049
'documentation
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2050
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2051
' , (existingComment ? '    documentation to be added.') , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2052
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2053
    [author:]
9960
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2054
        ' ", userName 
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2055
          , ' (' , emailAddress , ')' "
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2056
        , UserPreferences current historyManagerSignature , '
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2057
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2058
    [instance variables:]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2059
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2060
    [class variables:]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2061
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2062
    [see also:]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2063
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2064
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2065
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2066
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2067
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2068
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2069
            compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2070
            forClass:metaClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  2071
            inCategory:#documentation.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2072
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2073
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2074
    "Modified: / 24-11-2006 / 15:54:27 / cg"
9960
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2075
    "Modified: / 04-02-2011 / 08:24:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2076
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2077
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2078
createExamplesMethodFor:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2079
    "add examples method containing examples template
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2080
     but only if not already present."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2081
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2082
    |nonMetaclass fragment|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2083
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2084
    nonMetaclass := aClass theNonMetaclass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2085
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2086
    (nonMetaclass isSubclassOf:View) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2087
        self createExamplesMethodForViewClass:aClass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2088
        ^ self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2089
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2090
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2091
    (nonMetaclass isSubclassOf:ApplicationModel) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2092
        ^ self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2093
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2094
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2095
    (aClass includesSelector:#examples) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2096
        (nonMetaclass isSubclassOf:ApplicationModel) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2097
            fragment := '  Starting the application:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2098
                                                                [exBegin]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2099
    ' , nonMetaclass name , ' open
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2100
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2101
                                                                [exEnd]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2102
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2103
        ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2104
            fragment := ''
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2105
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2106
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2107
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2108
            compile:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2109
'examples
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2110
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2111
' , fragment , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2112
  more examples to be added:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2113
                                                                [exBegin]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2114
    ... add code fragment for 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2115
    ... executable example here ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2116
                                                                [exEnd]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2117
"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2118
'                   
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2119
            forClass:aClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  2120
            inCategory:#documentation.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2121
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2122
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2123
11841
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2124
createFalseReturnMethodFor:aSelector category:cat in:aClass
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2125
    "add a ^ false method;
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2126
     but only if not already present."
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2127
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2128
    (aClass includesSelector:aSelector) ifFalse:[
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2129
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2130
        self compile:
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2131
(Method methodDefinitionTemplateForSelector:aSelector) ,
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2132
'
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2133
    "return false here; to be redefined in subclass(es)"
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2134
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2135
    ^ false
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2136
'
11841
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2137
              forClass:aClass 
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2138
              inCategory:cat.
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2139
    ].
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2140
!
8df2e8a1dc3e +generate false return method
Claus Gittinger <cg@exept.de>
parents: 11759
diff changeset
  2141
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2142
createImageSpecMethodFor:anImage comment:comment in:aClass selector:sel
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2143
    |imageStoreStream mthd imageKey category|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2144
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2145
    anImage storeOn: (imageStoreStream := WriteStream on: '').
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2146
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2147
    "/ if that method already exists, do not overwrite the category
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  2148
    category := #'image specs'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2149
    (mthd := aClass compiledMethodAt:sel) notNil ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2150
        category := mthd category.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2151
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2152
16553
b45ee99763b4 #OTHER by mawalch
mawalch
parents: 16428
diff changeset
  2153
    imageKey :=  aClass "theNonMetaclass" name, ' ', sel.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2154
    Icon constantNamed: imageKey put:nil.
9960
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2155
    self
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2156
        compile: ((sel,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2157
            '\', comment,
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2158
            '\\' ,
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2159
            '    "\',
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2160
            '     self ' , sel , ' inspect\',
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2161
            '     ImageEditor openOnClass:self andSelector:#', sel, '\',
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2162
            '     Icon flushCachedIcons',
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2163
            '\    "',
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2164
            '\\',
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2165
            '    <resource: #image>',
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2166
            '\\',
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2167
            '    ^Icon\') withCRs,
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2168
            '        constantNamed:''', imageKey, '''\' withCRs,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2169
            '        ifAbsentPut:[', imageStoreStream contents, ']')
9960
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2170
        forClass:aClass
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2171
        inCategory: category.
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2172
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2173
    "Modified: / 01-07-2011 / 12:31:12 / cg"
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2174
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2175
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2176
createInitialHistoryMethodFor:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2177
    "add history method containing created-entry
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2178
     but only if not already present."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2179
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2180
    |code|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2181
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2182
    (aClass includesSelector:#history) ifFalse:[ 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2183
        HistoryManager notNil ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2184
            code := HistoryManager codeForInitialHistoryMethodIn:aClass.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2185
            self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2186
                compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2187
                forClass:aClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  2188
                inCategory:#documentation.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2189
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2190
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2191
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2192
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2193
createInstanceCreationMethodWithSetupFor:selector category:category in:aMetaClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2194
    "add an inst-creation method"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2195
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2196
    |template instMthd argNames|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2197
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2198
    (aMetaClass includesSelector:selector) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2199
        instMthd := aMetaClass theNonMetaclass compiledMethodAt:selector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2200
        (instMthd notNil     
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2201
        and:[  (argNames := instMthd methodArgNames) notEmptyOrNil ])
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2202
        ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2203
            template := Parser methodSpecificationForSelector:selector argNames:argNames.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2204
        ] ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2205
            template := Parser methodSpecificationForSelector:selector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2206
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2207
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2208
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2209
            compile:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2210
template , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2211
    ^ self new ' , template , '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2212
'                   
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2213
            forClass:aMetaClass 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2214
            inCategory:category.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2215
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2216
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2217
16241
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2218
createMultiSetterInstanceCreationMethodFor:aCollectionOfVarNames in:aClass
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2219
    "create a multi-setter instance creator method for instvars."
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2220
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2221
    |argPart source|
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2222
    
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2223
    self createMultiSetterMethodFor:aCollectionOfVarNames in:aClass.
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2224
    
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2225
    source := ''.
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2226
    aCollectionOfVarNames do:[:eachVar |
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2227
        source := source , (eachVar , ':' , eachVar , 'Arg ').
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2228
    ].
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2229
    argPart := source.
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2230
    
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2231
    source := source , Character cr.
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2232
    (userPreferences generateCommentsForSetters) ifTrue:[
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2233
        source := source , ('    "return a new instance with multiple instance variables initialized"' , Character cr , Character cr).
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2234
    ].
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2235
    source := source , ('    ^ self new ' , argPart).
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2236
    self compile:source forClass:aClass theMetaclass inCategory:#'instance creation'.
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2237
!
0d57786bae5c #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 16195
diff changeset
  2238
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2239
createMultiSetterMethodFor:aCollectionOfVarNames in:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2240
    "create a multi-setter method for instvars."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2241
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2242
    |source|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2243
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2244
    source := ''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2245
    aCollectionOfVarNames do:[:eachVar |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2246
        source := source , (eachVar , ':' , eachVar , 'Arg ').
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2247
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2248
    source := source , Character cr.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2249
    (userPreferences generateCommentsForSetters) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2250
        source := source , ('    "set instance variables"' , Character cr , Character cr).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2251
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2252
    aCollectionOfVarNames do:[:eachVar |
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2253
        source := source , ('    ' , eachVar , ' := ' , eachVar , 'Arg.' , Character cr).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2254
    ].
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  2255
    self compile:source forClass:aClass inCategory:#accessing.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2256
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2257
13591
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2258
createShouldImplementMethodFor:aSelector category:cat in:aClass
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2259
    "add a subclassResponsibility method;
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2260
     but only if not already present."
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2261
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2262
    (aClass includesSelector:aSelector) ifFalse:[
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2263
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2264
        self compile:
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2265
(Method methodDefinitionTemplateForSelector:aSelector) ,
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2266
'
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2267
    "raise an error: this method should be implemented (TODO)"
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2268
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2269
    ^ self shouldImplement
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2270
' 
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2271
              forClass:aClass 
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2272
              inCategory:cat.
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2273
    ].
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2274
!
36a35e7a4710 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 12879
diff changeset
  2275
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2276
createSubclassResponsibilityMethodFor:aSelector category:cat in:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2277
    "add a subclassResponsibility method;
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2278
     but only if not already present."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2279
19598
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2280
    | subclasses implementors header |
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2281
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2282
    (aClass includesSelector:aSelector) ifTrue: [ ^ self ].
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2283
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2284
    "/ Find 'closest' implementors to pick argument names from.
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2285
    implementors := #().
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2286
    subclasses := aClass subclasses.
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2287
    [ implementors isEmpty and:[ subclasses notEmpty ] ] whileTrue: [ 
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2288
        implementors := SystemBrowser findImplementorsOf:aSelector in: subclasses ignoreCase: false.
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2289
        implementors notEmpty ifTrue: [ 
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2290
            subclasses := (subclasses gather: [ :cls | cls subclasses ]).
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2291
        ].
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2292
    ].
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2293
    implementors notEmpty ifTrue: [ 
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2294
        | implementor |
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2295
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2296
        "/ JV@2021-05-05: Here we just pick anyone, but is it
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2297
        "/ a good idea? Shouldn;t we check all implementors having
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2298
        "/ the same arg names and warn if not? Dunno.
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2299
        implementor := implementors anyOne.
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2300
        header := implementor methodDefinitionTemplate.
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2301
    ] ifFalse: [ 
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2302
        header := SmalltalkLanguage current methodDefinitionTemplateForSelector: aSelector. 
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2303
    ].
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2304
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2305
    self compile:
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2306
header ,
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2307
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2308
    ^ self subclassResponsibility
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2309
' 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2310
              forClass:aClass 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2311
              inCategory:cat.
19598
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2312
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2313
    "Modified: / 05-05-2021 / 10:34:17 / Jan Vrany <jan.vrany@labware.com>"
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2314
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2315
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2316
createUpdateMethodIn:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2317
    "create an update:with:from:-method
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2318
     (I'm tired of typing)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2319
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2320
    |code|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2321
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  2322
    (aClass includesSelector:#update:with:from:) ifFalse:[
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2323
        generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2324
            code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2325
'update:something with:aParameter from:changedObject
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2326
    super update:something with:aParameter from:changedObject
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2327
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2328
        ] ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2329
            code :=
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2330
'update:something with:aParameter from:changedObject
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2331
    "Invoked when an object that I depend upon sends a change notification."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2332
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2333
    "stub code automatically generated - please change as required"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2334
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2335
    "/ changedObject == someOfMyValueHolders ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2336
    "/     self doSomethingApropriate.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2337
    "/     ^ self.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2338
    "/ ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2339
    super update:something with:aParameter from:changedObject
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2340
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2341
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2342
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2343
        self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2344
            compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2345
            forClass:aClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  2346
            inCategory:#'change & update'.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2347
    ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2348
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2349
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2350
createVersionMethodFor:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2351
    <resource: #obsolete>
11759
475918fd2d85 changed: #createVersionMethodFor:
Claus Gittinger <cg@exept.de>
parents: 11640
diff changeset
  2352
    "add a version method containing RCS template
475918fd2d85 changed: #createVersionMethodFor:
Claus Gittinger <cg@exept.de>
parents: 11640
diff changeset
  2353
     but only if not already present and it's not a private class."
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2354
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2355
    |code|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2356
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2357
    self obsoleteMethodWarning.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2358
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2359
    aClass isPrivate ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2360
        (aClass includesSelector:#version) ifFalse:[
16355
b680900382b8 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 16326
diff changeset
  2361
            code := aClass programmingLanguage methodTemplateForVersionMethodCVS.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2362
            self 
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2363
                compile:code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2364
                forClass:aClass 
11523
d0f296d32d73 changed:30 methods
Stefan Vogel <sv@exept.de>
parents: 11223
diff changeset
  2365
                inCategory:#documentation.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2366
        ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2367
    ].
11759
475918fd2d85 changed: #createVersionMethodFor:
Claus Gittinger <cg@exept.de>
parents: 11640
diff changeset
  2368
475918fd2d85 changed: #createVersionMethodFor:
Claus Gittinger <cg@exept.de>
parents: 11640
diff changeset
  2369
    "Modified (comment): / 21-08-2012 / 11:54:57 / cg"
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2370
! !
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2371
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2372
!SmalltalkCodeGeneratorTool methodsFor:'code templates'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2373
11169
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2374
anyApplicationClassInProjectOf:aClass
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2375
    |prjDefinition|
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2376
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2377
    prjDefinition := aClass projectDefinitionClass.
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2378
    prjDefinition isNil ifTrue:[ ^ nil ].
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2379
    ^ (prjDefinition allClasses 
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2380
        select:[:cls | cls isSubclassOf:ApplicationModel])
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2381
            firstIfEmpty:nil.
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2382
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2383
    "Created: / 21-01-2012 / 13:24:12 / cg"
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2384
!
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2385
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2386
codeFor_classInitialize
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2387
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2388
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2389
'initialize
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2390
%(INIT_CLASSINSTVARS)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2391
%(INIT_CLASSVARS)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2392
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2393
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2394
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2395
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2396
'initialize
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2397
    "Invoked at system start or when the class is dynamically loaded."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2398
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2399
    "/ please change as required (and remove this comment)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2400
%(INIT_CLASSINSTVARS)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2401
%(INIT_CLASSVARS)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2402
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2403
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2404
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2405
codeFor_closeAccept
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2406
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2407
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2408
'closeAccept
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2409
    ^ super closeAccept
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2410
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2411
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2412
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2413
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2414
'closeAccept
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2415
    "This is a hook method generated by the Browser/CodeGeneratorTool.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2416
     It will be invoked when your dialog-window is closed with OK."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2417
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2418
    "/ add any actions as required here ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2419
    Transcript showCR:''dialog accepted''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2420
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2421
    "/ do not remove the one below (otherwise, the dialog will not close itself)...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2422
    ^ super closeAccept
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2423
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2424
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2425
    "Created: / 27-10-2006 / 10:03:31 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2426
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2427
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2428
codeFor_closeDownViews
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2429
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2430
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2431
'closeDownViews
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2432
    ^ super closeDownViews
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2433
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2434
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2435
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2436
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2437
'closeDownViews
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2438
    "This is a hook method generated by the Browser/CodeGeneratorTool.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2439
     It will be invoked when your app/dialog-window is really closed.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2440
     See also #closeDownViews, which is invoked before and may suppress the close
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2441
     or ask the user for confirmation."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2442
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2443
    "/ change the code below as required ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2444
    "/ This should cleanup any leftover resources
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2445
    "/ (for example, temporary files)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2446
    "/ super closeRequest will initiate the closeDown
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2447
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2448
    "/ add your code here
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2449
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2450
    "/ do not remove the one below ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2451
    ^ super closeDownViews
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2452
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2453
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2454
    "Created: / 27-10-2006 / 10:01:32 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2455
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2456
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2457
codeFor_closeRequest
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2458
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2459
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2460
'closeRequest
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2461
    self hasUnsavedChanges ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2462
        (self confirm:(resources string:''Close without saving ?'')) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2463
            ^ self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2464
        ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2465
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2466
    ^ super closeRequest
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2467
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2468
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2469
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2470
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2471
'closeRequest
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2472
    "This is a hook method generated by the Browser/CodeGeneratorTool.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2473
     It will be invoked when your app/dialog-window is about to be
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2474
     closed (this method has a chance to suppress the close).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2475
     See also #closeDownViews, which is invoked when the close is really done."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2476
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2477
    "/ change the code below as required ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2478
    "/ Closing can be suppressed, by simply returning.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2479
    "/ The ''super closeRequest'' at the end will initiate the real closeDown
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2480
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2481
    self hasUnsavedChanges ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2482
        (self confirm:(resources string:''Close without saving ?'')) ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2483
            ^ self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2484
        ]
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2485
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2486
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2487
    ^ super closeRequest
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2488
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2489
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2490
    "Created: / 27-10-2006 / 10:01:06 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2491
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2492
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2493
codeFor_emptyMenuActionCodeFor:selector menuItem:item
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2494
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2495
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2496
selector,'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2497
    self warn:''no action for ''''',item,''''' defined.''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2498
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2499
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2500
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2501
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2502
selector,'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2503
    "This method was generated by the Browser/CodeGeneratorTool.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2504
     It will be invoked when the menu-item ''',item,''' is selected."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2505
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2506
    "/ change below and add any actions as required here ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2507
    self warn:''no action for ''''',item,''''' defined.''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2508
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2509
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2510
    "Created: / 27-10-2006 / 10:16:43 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2511
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2512
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2513
codeFor_hasUnsavedChanges
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2514
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2515
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2516
'hasUnsavedChanges
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2517
    ^ false.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2518
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2519
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2520
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2521
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2522
'hasUnsavedChanges
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2523
    "Return true, if any unsaved changes are present
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2524
     (i.e. the contents needs to be saved or else will be lost)"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2525
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2526
    "/ add real code as required (or remove the halt and always return false)...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2527
    "/ self halt:''check this code''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2528
    ^ false.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2529
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2530
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2531
    "Created: / 27-10-2006 / 10:00:36 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2532
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2533
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2534
codeFor_menuSaveAs
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2535
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2536
'menuSaveAs
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2537
    "This method was generated by the Browser/CodeGeneratorTool.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2538
     It will be invoked when the menu-item ''saveAs'' is selected."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2539
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2540
    "/ change below as required... (see examples in Dialog class for more options)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2541
    Dialog
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2542
        requestSaveFileName:(resources string:''Save'')
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2543
        default:''foo.txt''
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2544
        fromDirectory:nil
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2545
        action:[:fileName | self doSaveAs:fileName]
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2546
        appendAction:nil.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2547
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2548
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2549
    "Created: / 27-10-2006 / 10:01:57 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2550
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2551
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2552
codeFor_openAboutThisApplication
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2553
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2554
'openAboutThisApplication
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2555
    "This method was generated by the Browser/CodeGeneratorTool.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2556
     It will be invoked when the menu-item ''help-about'' is selected."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2557
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2558
    "/ could open a customized aboutBox here ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2559
    super openAboutThisApplication
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2560
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2561
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2562
    "Created: / 27-10-2006 / 10:03:13 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2563
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2564
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2565
codeFor_openDocumentation
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2566
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2567
'openDocumentation
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2568
    "This method was generated by the Browser/CodeGeneratorTool.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2569
     It will be invoked when the menu-item ''help-documentation'' is selected."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2570
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2571
    "/ change below as required ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2572
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2573
    "/ to open an HTML viewer on some document (under ''doc/online/<language>/'' ):
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2574
    self openDocumentationFile:''TOP.html''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2575
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2576
    "/ add application-specific help files under the ''doc/online/<language>/help/appName''
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2577
    "/ directory, and open a viewer with:
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2578
    "/ self openDocumentationFile:''help/<MyApplication>/TOP.html''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2579
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2580
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2581
    "Created: / 27-10-2006 / 10:02:55 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2582
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2583
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2584
codeFor_postBuildWith
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2585
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2586
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2587
'postBuildWith:aBuilder
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2588
    ^ super postBuildWith:aBuilder
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2589
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2590
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2591
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2592
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2593
'postBuildWith:aBuilder
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2594
    "This is a hook method generated by the Browser/CodeGeneratorTool.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2595
     It will be invoked during the initialization of your app/dialog,
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2596
     after all of the visual components have been built,
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2597
     but BEFORE the top window is made visible.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2598
     Add any app-specific actions here (reading files, setting up values etc.)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2599
     See also #postOpenWith:, which is invoked after opening."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2600
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2601
    "/ add any code here ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2602
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2603
    ^ super postBuildWith:aBuilder
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2604
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2605
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2606
    "Created: / 27-10-2006 / 09:59:33 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2607
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2608
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2609
codeFor_postOpenWith
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2610
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2611
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2612
'postOpenWith:aBuilder
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2613
    ^ super postOpenWith:aBuilder
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2614
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2615
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2616
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2617
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2618
'postOpenWith:aBuilder
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2619
    "This is a hook method generated by the Browser/CodeGeneratorTool.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2620
     It will be invoked right after the applications window has been opened.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2621
     Add any app-specific actions here (starting background processes etc.).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2622
     See also #postBuildWith:, which is invoked before opening."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2623
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2624
    "/ add any code here ...
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2625
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2626
    ^ super postOpenWith:aBuilder
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2627
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2628
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2629
    "Created: / 27-10-2006 / 09:59:56 / cg"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2630
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2631
11169
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2632
codeFor_standAloneApplicationRegistryPathFor:aClassOrNil
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2633
    |pkg appClass|
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2634
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2635
    pkg := 'someUniqueName'.
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2636
    aClassOrNil notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2637
        (appClass := self anyApplicationClassInProjectOf:aClassOrNil) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2638
            pkg := appClass nameWithoutPrefix.
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2639
        ]
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2640
    ].
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2641
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2642
    generateComments ifFalse:[
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2643
        ^
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2644
'applicationRegistryPath
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2645
    ^ #(''stx'' ''%1'')
11169
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2646
' bindWith:pkg.
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2647
    ].
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2648
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2649
    ^
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2650
'applicationRegistryPath
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2651
    "for windows only:
15515
895b2312db3e class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15069
diff changeset
  2652
     the key under which this application stores its process ID in the registry
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2653
     as a collection of path-components.
15515
895b2312db3e class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15069
diff changeset
  2654
     i.e. if #(''foo'' ''bar'' ''baz'') is returned here, the current application''s ID will be stored
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2655
     in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID.
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2656
     (would also be used as a relative path for a temporary lock file under unix).
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2657
     Used to detect if another instance of this application is already running."
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2658
11169
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2659
    ^ #(''stx'' ''%1'')
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2660
'  bindWith:pkg.
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2661
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2662
    "Created: / 21-01-2012 / 11:23:40 / cg"
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2663
!
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2664
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2665
codeFor_standAloneApplicationUUID
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2666
    generateComments ifFalse:[
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2667
        ^
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2668
'applicationUUID
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2669
    ^ UUID fromString:''', UUID genUUID printString, '''
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2670
'.
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2671
    ].
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2672
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2673
    ^
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2674
'applicationUUID
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2675
    "answer an application-specific unique uuid.
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2676
     This is used as the name of some exclusive OS-resource, which is used to find out,
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2677
     if another instance of this application is already running.
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2678
     Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used.
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2679
     If redefined, please return a real UUID (i.e. UUID fromString:''.....'') and not a string or
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2680
     similar possibly conflicting identifier.
16903
245c704778d5 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 16900
diff changeset
  2681
     You can paste a fresh worldwide unique id via the editor''s ''more''-''misc''-''paste UUID'' menu function."
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2682
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2683
    ^ UUID fromString:''', UUID genUUID printString, '''
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2684
'.
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2685
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2686
    "Created: / 19-08-2011 / 02:13:19 / cg"
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2687
!
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2688
16695
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2689
codeFor_standAloneMainFor:aClass
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2690
    | application code |
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2691
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2692
    application := self anyApplicationClassInProjectOf:aClass.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2693
    code := 'main: argv
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2694
    "Application entry point. `argv` is the array of command arguments (as Array of Strings)"
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2695
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2696
    | optparser positional |
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2697
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2698
    optparser := CmdLineParser new.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2699
    optparser
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2700
"/        on: #(''-s'' ''--long'') do:[ ... ];
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2701
"/        on: #(''-I'' ''--include'') do:[ :value | includes add: value ];
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2702
          on: #(''-h'' ''--help'') do:[ self usage. Smalltalk exitIfStandalone:0 ].
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2703
    [
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2704
        positional := optparser parse:argv.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2705
    ] on: CmdLineOptionError do:[:ex |
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2706
        Stderr nextPutAll: ''ERROR: ''; nextPutLine: ex description.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2707
        Smalltalk exitIfStandalone:0.        
10598
6c40487903e5 changed: #codeFor_standAloneMain
Claus Gittinger <cg@exept.de>
parents: 10593
diff changeset
  2708
    ].
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2709
'.
16695
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2710
    application notNil ifTrue:[ 
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2711
        code := code , '
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2712
    %1 open.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2713
' bindWith: application name  
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2714
    ] ifFalse:[
16695
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2715
        code := code , '
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2716
    Stdout nextPutLine:''Hello World''.
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2717
    Stdout nextPutLine:(positional asStringWith:Character space)              
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2718
'
16900
1bd3cf6ce330 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16878
diff changeset
  2719
    ].
16695
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2720
    ^ code    
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2721
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2722
    "    
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2723
    self new codeFor_standAloneMainFor: HelloWorld0Start
16900
1bd3cf6ce330 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16878
diff changeset
  2724
    "
16695
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2725
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2726
    "Created: / 14-06-2016 / 07:28:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
11169
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2727
!
Claus Gittinger <cg@exept.de>
parents: 10598
diff changeset
  2728
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2729
codeFor_standAloneUsage
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2730
    ^
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2731
'usage
16900
1bd3cf6ce330 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16878
diff changeset
  2732
    "output some command-line usage infos on stderr"
1bd3cf6ce330 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16878
diff changeset
  2733
    
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2734
    Stderr nextPutLine:''usage: '',self applicationName,'' [options...]''.
16900
1bd3cf6ce330 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16878
diff changeset
  2735
    Stderr nextPutLine:''  --noInfoPrint ........ disable diagnostic messages''.
1bd3cf6ce330 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16878
diff changeset
  2736
    Stderr nextPutLine:''  -h ................... output this message''.
1bd3cf6ce330 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16878
diff changeset
  2737
    Stderr nextPutLine:''  -a <file> ............ a-argument(s)''.
1bd3cf6ce330 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16878
diff changeset
  2738
    Stderr nextPutLine:''  -b <file> ............ b-argument(s)''.
1bd3cf6ce330 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16878
diff changeset
  2739
    Stderr nextPutLine:''  -c ................... c-option''.
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2740
'.
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2741
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2742
    "Created: / 19-08-2011 / 02:22:46 / cg"
16672
d65bbfc8a2f7 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 16627
diff changeset
  2743
    "Modified: / 06-06-2016 / 14:59:19 / cg"
10591
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2744
!
91a0e6defc80 standalone code
Claus Gittinger <cg@exept.de>
parents: 10371
diff changeset
  2745
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2746
code_forWidget_buttonPress
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2747
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2748
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2749
'buttonPress:button x:x y:y
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
    Transcript show:''button: ''; showCR:button.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2751
    super buttonPress:button x:x y:y
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2752
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2753
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2754
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2755
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
'buttonPress:button x:x y:y
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2757
    "called when a mouse-button is pressed. button is the button-nr (1 for left-button).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2758
     x/y are the mouse position at the time of the click.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2759
     There are also corresponding buttonRelease and buttonMotion methods which could be
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2760
     redefined...."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2761
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2762
    Transcript show:''button: ''; showCR:button.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2763
    "/ super-code handles middleButtonMenu, if it was assigned (with middleButtonmenu:)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2764
    super buttonPress:button x:x y:y
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2765
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2766
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2767
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2768
code_forWidget_initialize
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2769
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2770
'initialize
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2771
    super initialize "/ to initialize inherited state
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2772
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2773
    "/ add code to initialize private variables,
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2774
    "/ and sub-components as required.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2775
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2776
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2777
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2778
code_forWidget_keyPress
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2779
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2780
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2781
'keyPress:key x:x y:y
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2782
"/    key == #Copy ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2783
"/    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2784
"/    key == #Cut ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2785
"/    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2786
    Transcript show:''key: ''; showCR:key.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2787
    super keyPress:key x:x y:y
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2788
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2789
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2790
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2791
'keyPress:key x:x y:y
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2792
    "called when a keyboard-key was pressed. key is either a character (for ordinary keys)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2793
     or a symbol, such as #Copy, #Cut or #Paste.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2794
     x/y are the mouse position at the time of the key-press.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2795
     There is also a corresponding keyRelease method which could be redefined...."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2796
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2797
    Transcript show:''key: ''; showCR:key.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2798
    super keyPress:key x:x y:y
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2799
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2800
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2801
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2802
code_forWidget_redraw
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2803
    |sel comment code|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2804
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2805
    sel := 'redrawX:x y:y width:w height:h'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2806
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2807
        comment := ''.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2808
    ] ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2809
        comment := '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2810
    "called to redraw a part of the widgets area. x/y define the origin, w/h the size of
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2811
     that area. The clipping region has already been set by the caller, so even if the code
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2812
     below draws outside the redraw-area, it will not affect what is on the screen.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2813
     Therefore, the example below can fill the rectangle in the redraw area, but still draw
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2814
     the cross in the outside regions."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2815
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2816
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2817
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2818
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2819
    code := '
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2820
    self paint:Color red.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2821
    self fillRectangleX:x y:y width:w height:h.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2822
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2823
    self paint:Color yellow.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
    self displayLineFrom:0@0 to:(width@height).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2825
    self displayLineFrom:width@0 to:(0@height).
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2826
'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2827
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2828
    ^ sel,comment,code
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2829
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2830
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2831
code_forWidget_sizeChanged
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2832
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2833
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2834
'sizeChanged:how
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2835
    self invalidate.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2836
    super sizeChanged:how.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2837
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2838
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2839
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2840
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2841
'sizeChanged:how
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2842
    "Invoked whenever the size of the view changes.
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2843
     Here, we force a full redraw, which might not be needed all the time"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2844
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2845
    self invalidate.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2846
    super sizeChanged:how.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2847
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2848
!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2849
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2850
code_forWidget_update
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2851
    generateComments ifFalse:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2852
        ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2853
'update:something with:aParameter from:changedObject
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2854
    changedObject == model ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2855
        self invalidate.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2856
        ^ self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2858
    super update:something with:aParameter from:changedObject
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2859
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2860
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2861
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2862
    ^
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2863
'update:something with:aParameter from:changedObject
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2864
    "Invoked when an object that I depend upon sends a change notification."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2865
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2866
    "stub code automatically generated - please change as required"
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2867
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2868
    changedObject == model ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2869
        self invalidate.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2870
        ^ self
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2871
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2872
    super update:something with:aParameter from:changedObject
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2873
'
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2874
! !
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2875
14700
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2876
!SmalltalkCodeGeneratorTool methodsFor:'compilation'!
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2877
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2878
compilerClass
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2879
    "Return a real compiler classto use to compile code"
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2880
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2881
    ^ Compiler
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2882
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2883
    "Created: / 05-08-2014 / 21:03:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2884
! !
37395f593258 Fixes in CodeGeneatorTool for to handle properly mixed-language classes.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 14696
diff changeset
  2885
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2886
!SmalltalkCodeGeneratorTool methodsFor:'private'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2887
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2888
codeFor_shouldImplementFor:selector inClass:aClass
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2889
    "used in the 'generate required protocol' to generate a shouldImplement-sending
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2890
     method for each subclassClassresponsibility method above aClass."
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2891
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2892
    |mthd comment implClass methodBodyStream searcher errorMessageString|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2893
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2894
    (aClass notNil
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2895
    and:[ aClass superclass notNil ]) ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2896
        implClass := aClass superclass whichClassImplements:selector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2897
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2898
    implClass isNil ifTrue:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2899
        ^ ((Method methodDefinitionTemplateForSelector:selector),'\    ^ self shouldImplement\') withCRs
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2900
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2901
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2902
    mthd := implClass compiledMethodAt:selector.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2903
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2904
    methodBodyStream := '' writeStream.
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2905
    methodBodyStream
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2906
        nextPutAll:mthd methodDefinitionTemplate; cr;
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2907
        nextPutAll:'    "'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2908
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2909
    "/ include the comment of the subclassResponsibility-sending method
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2910
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2911
    comment := mthd methodComment.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2912
    comment isEmptyOrNil ifTrue:[
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2913
        methodBodyStream
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2914
            nextPutAll:('superclass <1s> says that I am responsible to implement this method'
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2915
                        expandMacrosWith:implClass name)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2916
    ] ifFalse:[
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2917
        comment
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2918
            asStringCollection do:[:eachLine|
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2919
                methodBodyStream nextPutAll:eachLine.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2920
            ] separatedBy:[
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2921
                methodBodyStream cr; nextPutAll:'     '.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2922
            ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2923
    ].
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2924
    methodBodyStream
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2925
        nextPut:$"; cr; cr.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2926
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2927
    "/ include the argument of the subclassResponsibility:-sending method
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2928
    self canUseRefactoringSupport ifTrue:[
19598
700dc78db841 Improve generated code for subclass responsibility
Jan Vrany <jan.vrany@labware.com>
parents: 18226
diff changeset
  2929
        (mthd sendsSelector:#subclassResponsibility:) ifTrue:[
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2930
            searcher := ParseTreeSearcher new.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2931
            searcher
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2932
                    matches: 'self subclassResponsibility: `''.*'''
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2933
                    do:[:node :answer |
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2934
                        errorMessageString := node arguments first value.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2935
                        true.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2936
                    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2937
            searcher executeTree: (mthd parseTree) initialAnswer: false.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2938
        ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2939
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2940
    errorMessageString notEmptyOrNil ifTrue:[
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2941
        methodBodyStream
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2942
            nextPutAll:'    ^ self shouldImplement:';
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2943
            nextPutLine:(errorMessageString storeString)
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2944
    ] ifFalse:[
16779
288875950e56 #OTHER by mawalch
mawalch
parents: 16672
diff changeset
  2945
        methodBodyStream
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2946
            nextPutLine:'    ^ self shouldImplement'.
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2947
    ].
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2948
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2949
    ^ methodBodyStream contents
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2950
! !
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2951
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2952
!SmalltalkCodeGeneratorTool class methodsFor:'documentation'!
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2953
10593
25f79d0bf830 changed: #codeFor_standAloneDoRealWorkMethod
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
  2954
version
15708
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  2955
    ^ '$Header$'
10593
25f79d0bf830 changed: #codeFor_standAloneDoRealWorkMethod
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
  2956
!
25f79d0bf830 changed: #codeFor_standAloneDoRealWorkMethod
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
  2957
25f79d0bf830 changed: #codeFor_standAloneDoRealWorkMethod
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
  2958
version_CVS
15708
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  2959
    ^ '$Header$'
10593
25f79d0bf830 changed: #codeFor_standAloneDoRealWorkMethod
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
  2960
!
25f79d0bf830 changed: #codeFor_standAloneDoRealWorkMethod
Claus Gittinger <cg@exept.de>
parents: 10591
diff changeset
  2961
16695
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2962
version_HG
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2963
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2964
    ^ '$Changeset: <not expanded> $'
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2965
!
a8eda516effa Use new CmdLineParser when generating initial application startup code.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16676
diff changeset
  2966
9960
324ad5515d57 changed:
Claus Gittinger <cg@exept.de>
parents: 9935
diff changeset
  2967
version_SVN
15708
1b35e4573788 class: SmalltalkCodeGeneratorTool
Claus Gittinger <cg@exept.de>
parents: 15515
diff changeset
  2968
    ^ '$Id$'
9706
382fbd22e5b6 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2969
! !
12440
48bd9af25138 added: #copyright
Claus Gittinger <cg@exept.de>
parents: 11841
diff changeset
  2970