author | Stefan Vogel <sv@exept.de> |
Tue, 31 May 2016 16:10:07 +0200 | |
changeset 19919 | 298d23c7785b |
parent 19911 | 0b24a97a0bb7 |
child 19945 | 9c7cd0ca7991 |
child 19958 | 8d7c3bde4483 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
18668 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
5363 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
17279 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1 | 16 |
Object subclass:#Smalltalk |
18668 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'StartBlocks ImageStartBlocks ExitBlocks CachedClasses |
|
19 |
NumberOfClassesHint SystemPath StartupClass StartupSelector |
|
20 |
StartupArguments CommandLine CommandName CommandLineArguments |
|
21 |
CachedAbbreviations VerboseStartup VerboseLoading Verbose |
|
22 |
SilentLoading Initializing StandAlone HeadlessOperation IsPlugin |
|
19427 | 23 |
IsSharedLibraryComponent IsSTScript DebuggingStandAlone Debugging |
24 |
LogDoits LoadBinaries RealSystemPath ResourcePath SourcePath |
|
25 |
BinaryPath FileInPath PackagePath BinaryDirName ResourceDirName |
|
18668 | 26 |
SourceDirName BitmapDirName PackageDirName FileInDirName |
27 |
ChangeFileName ImageStartTime ImageRestartTime DemoMode |
|
28 |
SaveEmergencyImage SpecialObjectArray CallbackSignal |
|
29 |
ClassesFailedToInitialize HasNoConsole IgnoreHalt |
|
30 |
PackageToPathMapping IgnoreAssertions' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'System-Support' |
|
1 | 33 |
! |
34 |
||
19597 | 35 |
Smalltalk comment:'documentation' |
8845
17288e4e99eb
remember, where autoload decl came from
Claus Gittinger <cg@exept.de>
parents:
8821
diff
changeset
|
36 |
! |
17288e4e99eb
remember, where autoload decl came from
Claus Gittinger <cg@exept.de>
parents:
8821
diff
changeset
|
37 |
|
1750
36ff7e62388a
care for privateClasses in remove
Claus Gittinger <cg@exept.de>
parents:
1713
diff
changeset
|
38 |
!Smalltalk class methodsFor:'documentation'! |
70 | 39 |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
40 |
copyright |
617 | 41 |
" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
42 |
COPYRIGHT (c) 1988 by Claus Gittinger |
18668 | 43 |
All Rights Reserved |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
44 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
45 |
This software is furnished under a license and may be used |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
46 |
only in accordance with the terms of that license and with the |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
47 |
inclusion of the above copyright notice. This software may not |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
48 |
be provided or otherwise made available to, or used by, any |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
49 |
other person. No title to or ownership of the software is |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
50 |
hereby transferred. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
51 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
52 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
53 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
54 |
documentation |
70 | 55 |
" |
56 |
This is one of the central classes in the system; |
|
57 |
it provides all system-startup, shutdown and maintenance support. |
|
745
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
58 |
Also global variables are (conceptionally) kept here. |
70 | 59 |
|
60 |
As you will notice, this is NOT a Dictionary |
|
3062
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
61 |
- my implementation of globals is totally different |
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
62 |
due to the need to be able to access globals from c-code as well, |
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
63 |
I do not use associations for globals, but instead keep the |
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
64 |
name<->value relations in the VM and access globals via utility |
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
65 |
functions found there. |
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
66 |
|
70 | 67 |
However, it provides the known enumeration protocol. |
3062
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
68 |
It may change to become a subclass of collection at some time, |
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
69 |
to inherit more collection stuff ... |
70 | 70 |
|
745
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
71 |
|
1286 | 72 |
[Instance variables:] |
18668 | 73 |
none - all handling is done in the VM |
1286 | 74 |
|
75 |
[Class variables:] |
|
76 |
||
18668 | 77 |
StartBlocks <Collection> blocks to be executed in a separate process after |
78 |
everything has been initialized. These blocks will |
|
79 |
be deleted after execution and therefore not be |
|
80 |
executed after an image restart. Initial processes |
|
81 |
(such as the Launcher) are usually started here. |
|
82 |
These blocks are added by smalltalk.rc/private.rc etc. |
|
83 |
via #addStartBlock during early initialization. |
|
84 |
||
85 |
ImageStartBlocks |
|
86 |
<Collection> blocks to be executed in a separate process after |
|
87 |
everything has been initialized. These blocks will be |
|
88 |
executed after an image restart. |
|
89 |
These blocks are usually added by smalltalk_r.rc etc. |
|
90 |
||
91 |
ExitBlocks <Collection> blocks to evaluate before system is |
|
92 |
left. Not currently used (GNU-ST compatibility). |
|
93 |
||
94 |
SystemPath <Collection> path to search for system files (sources, bitmaps etc) |
|
95 |
Set to a default here, but typically changed from some |
|
96 |
startup.rc file |
|
97 |
||
98 |
PackagePath <Collection> path to search for package. |
|
99 |
This is going to replace the above systemPath, and a classes |
|
100 |
resources will eventually searched in its package directory. |
|
101 |
This list defines the path, where packages are searched for, |
|
102 |
initially this is something like /opt/smalltalk/packages. |
|
103 |
Set to a default here, but typically changed from some |
|
104 |
startup.rc file |
|
105 |
||
106 |
StartupClass <Class> class and selector, where the system starts up |
|
107 |
StartupSelector <Symbol> (right after VM initialization) |
|
108 |
StartupArguments <Array> If an image is saved while those being nonNil, |
|
109 |
the image will come up there. |
|
110 |
Allows for customized images to be generated from a standard ST/X. |
|
111 |
StandAlone programs also set those during initialization. |
|
112 |
||
113 |
CommandLine <String> Unix (OS-) command line |
|
114 |
||
115 |
CommandName <String> the command (i.e. argv[0]) |
|
116 |
||
117 |
CommandLineArguments <Array> Unix (OS-) command line arguments broken into words |
|
118 |
CommandName has been stripped off. |
|
119 |
(initially set by the VM) |
|
120 |
||
121 |
SilentLoading <Boolean> OBSOLETE: |
|
122 |
suppresses messages during fileIn and in compiler |
|
123 |
(can be set to true from a customized main.c) |
|
124 |
||
125 |
VerboseLoading <Boolean> generate messages during fileIn and in compiler |
|
126 |
(can be set to true from a customized main.c) |
|
127 |
||
128 |
Initializing <Boolean> true while (re-)initializing |
|
129 |
Controls the behavior of certain error |
|
130 |
reporters (for example: suppress dialogBoxes) |
|
131 |
while the system is not yet fit for full operation. |
|
132 |
||
133 |
StandAlone <Boolean> true, if this is a standalone app; |
|
134 |
if true the process scheduler watches for |
|
135 |
which processes are still running, and |
|
136 |
exits ST/X, when the last non-background |
|
137 |
and non-system process exits. |
|
138 |
Can be set in an application-specific startup script, |
|
139 |
or, for standAlone programs, by C-code during initialization. |
|
140 |
||
141 |
HeadlessOperation if true, a non-existing Display connection |
|
142 |
<Boolean> will NOT lead to an error-exit during startup. |
|
143 |
Default is false. |
|
144 |
Can be set in an application-specific startup script, |
|
145 |
or, for standAlone programs, by C-code during initialization. |
|
146 |
||
147 |
LogDoits <Boolean> if true, doits are also logged in the changes |
|
148 |
file. Default is false, since the changes file |
|
149 |
may become huge if every tiny doIt is saved there ... |
|
150 |
||
151 |
LoadBinaries <Boolean> if true, we attempt to load classes rom a binary |
|
152 |
file, if present. If false, this is always suppressed. |
|
153 |
||
154 |
SaveEmergencyImage <Boolean> if true (the default), an emergency image |
|
155 |
is saved, if the main Display looses its |
|
156 |
connection. This is useful if you have a |
|
157 |
flaky display connection (serial line) |
|
158 |
and want to have your stuff saved automatically |
|
159 |
in case of a broken connection. |
|
160 |
||
161 |
IgnoreAssertions <Boolean> if true, assertions are ignored (i.e. no errors reported). |
|
162 |
Usually false in the development system, true in a standalone deployed app. |
|
1650
b4b36961d1bc
Add StartBlocks and ImageStartBlocks.
Stefan Vogel <sv@exept.de>
parents:
1647
diff
changeset
|
163 |
|
745
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
164 |
strictly private classVariables (helpers): |
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
165 |
|
18668 | 166 |
CachedClasses <Collection> known classes (cached for faster class enumeration) |
167 |
||
168 |
CachedAbbreviations |
|
169 |
<Dictionary> className to filename mappings |
|
170 |
||
171 |
RealSystemPath <Collection> cached collection of directories along the path |
|
172 |
which really exist. Caching avoids long checks |
|
173 |
for existing directories on broken NFS volumes. |
|
174 |
||
175 |
SourcePath <Collection> cached names of really existing directories |
|
176 |
These are remembered, as in NFS systems, |
|
177 |
ResourcePath the time to lookup files may become long |
|
178 |
BinaryPath (especially, if some directories are on machines |
|
179 |
FileInPath which are not up ...). |
|
180 |
Therefore, the set of really |
|
181 |
existing directories is cached when the SystemPath |
|
182 |
is walked the first time. |
|
183 |
A consequence is that you have to invoke |
|
184 |
flushSystemPath, when you create any of those |
|
185 |
directories while running |
|
186 |
(and want the running ST/X to look there) |
|
3062
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
187 |
|
1286 | 188 |
|
189 |
[author:] |
|
18668 | 190 |
Claus Gittinger |
3062
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
191 |
|
5b8a2aa07108
write an emergency snapshot image,
Claus Gittinger <cg@exept.de>
parents:
3044
diff
changeset
|
192 |
[see also:] |
18668 | 193 |
ObjectMemory |
194 |
StandaloneStartup |
|
195 |
GetOpt |
|
196 |
ReadEvalPrintLoop |
|
70 | 197 |
" |
8945 | 198 |
! |
199 |
||
200 |
readme_resources |
|
201 |
" |
|
202 |
What is a resource file: |
|
18668 | 203 |
resource files contain language transformation and sometimes |
204 |
UI-look specifics such as icons etc. |
|
8945 | 205 |
|
206 |
Where are resources stored in the image: |
|
18668 | 207 |
Resource files are only read on demand (i.e. when needed) and only read once |
208 |
i.e. they are cached in the image). |
|
209 |
The cached data is held in a per-class class-instVar named 'ClassResources'. |
|
210 |
With only a few exceptions, the only classes which need resources are the GUI |
|
211 |
classes under the SimpleView hierarchy. |
|
8945 | 212 |
|
213 |
How does the system find resources: |
|
18668 | 214 |
The idea is that the system-provided resource files can be overwritten |
215 |
by the user or an application configuration. |
|
216 |
This works via a hierarchy of directories where resources are searched for, |
|
217 |
with the systems standard resource-files being at the end of that chain. |
|
218 |
||
219 |
When searching for a resource file for class X, the following files are searched |
|
220 |
in order: |
|
221 |
{ResourcePath} / resources / X.rs |
|
222 |
{SystemPath} / (CLASSES-PACKAGE-PATH) / X.rs |
|
223 |
{ResourcePath} / (CLASSES-PACKAGE-PATH) / X.rs |
|
8945 | 224 |
" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
225 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
226 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
227 |
!Smalltalk class methodsFor:'initialization'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
228 |
|
11057 | 229 |
basicInitializeSystem |
16180 | 230 |
"initialize all other classes. |
16655 | 231 |
This one is the very first entry into the smalltalk world |
232 |
[with error handling, via the initializeSystem], |
|
233 |
right after startup, usually immediately followed by Smalltalk>>start. |
|
234 |
||
11057 | 235 |
Notice: |
18668 | 236 |
this is NOT called when an image is restarted; in this |
237 |
case the show starts in Smalltalk>>restart." |
|
11057 | 238 |
|
13771 | 239 |
Compiler := ByteCodeCompiler. |
240 |
Compiler isNil ifTrue:[ |
|
18668 | 241 |
" |
242 |
ByteCodeCompiler is not in the system (i.e. has not been linked in) |
|
243 |
this allows at least immediate evaluations for runtime systems without compiler |
|
244 |
NOTICE: a parser is always needed, otherwise we cannot read resource files etc. |
|
245 |
" |
|
246 |
Compiler := Parser |
|
16164 | 247 |
]. |
13771 | 248 |
|
11057 | 249 |
"/ |
250 |
"/ start catching SIGSEGV and SIGBUS |
|
251 |
"/ |
|
252 |
OperatingSystem enableHardSignalInterrupts. |
|
253 |
||
254 |
self initGlobalsFromEnvironment. |
|
255 |
||
256 |
"/ |
|
257 |
"/ sorry - there are some, which MUST be initialized before .. |
|
258 |
"/ reason: if any error happens during init, we need Signals, Stdout etc. to be there |
|
259 |
"/ |
|
15265 | 260 |
SmallInteger initialize. |
11057 | 261 |
Object initialize. |
18283 | 262 |
UninterpretedBytes initialize. |
16691 | 263 |
OperatingSystem initialize. |
11057 | 264 |
Stream initialize. |
265 |
PositionableStream initialize. |
|
266 |
Filename initialize. |
|
267 |
ObjectMemory initialize. |
|
268 |
ExternalStream initialize. |
|
12745
e944659a6a52
changed: #basicInitializeSystem
Claus Gittinger <cg@exept.de>
parents:
12744
diff
changeset
|
269 |
ProcessorScheduler initialize. |
11057 | 270 |
|
271 |
self initStandardStreams. "/ setup Stdin, Stdout etc. |
|
272 |
||
273 |
"/ |
|
274 |
"/ sorry, path must be set before ... |
|
275 |
"/ reason: some classes need it during initialize (they might need resources, bitmaps etc) |
|
276 |
"/ |
|
17534 | 277 |
"/ but, on OSX we need the CharacterEncoder to be initialized |
278 |
CharacterEncoder initialize. |
|
11057 | 279 |
self initSystemPath. |
280 |
||
281 |
"/ |
|
14427 | 282 |
"/ in case, someone needs the objectFileLoader early |
283 |
"/ |
|
16675 | 284 |
ObjectFileLoader notNil ifTrue:[ |
18668 | 285 |
ObjectFileLoader initialize. |
16675 | 286 |
]. |
14427 | 287 |
|
288 |
"/ |
|
11057 | 289 |
"/ now, finally, initialize all other classes |
290 |
"/ |
|
291 |
self initializeModules. |
|
292 |
||
293 |
ImageStartTime := Timestamp now. |
|
294 |
||
295 |
self initInterrupts. |
|
296 |
self initUserPreferences. |
|
297 |
||
16668
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
298 |
"/ just to make sure: if any prefs affect any resources, |
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
299 |
"/ flush them here, so they are reread in any case. |
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
300 |
"/ required for some apps, for example to show the menu correctly (see launcher's help menu) |
16675 | 301 |
ApplicationModel notNil ifTrue:[ |
18668 | 302 |
ApplicationModel flushAllClassResources. |
16675 | 303 |
]. |
16668
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
304 |
|
11057 | 305 |
"/ |
306 |
"/ give classes a chance to perform 2nd-level initialization |
|
307 |
"/ now, we are certain, that all other classes have been initialized |
|
308 |
"/ (especially: streams and signals can now be used) |
|
309 |
"/ |
|
310 |
ObjectMemory changed:#initialized. |
|
311 |
||
312 |
"Modified: / 08-01-1997 / 19:58:12 / stefan" |
|
313 |
"Modified: / 05-12-2006 / 21:48:58 / cg" |
|
14427 | 314 |
"Modified: / 24-10-2012 / 18:45:15 / sr" |
11057 | 315 |
! |
316 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
317 |
initGlobalsFromEnvironment |
617 | 318 |
"setup globals from the shell-environment" |
319 |
||
320 |
|envString i langString terrString| |
|
321 |
||
5406 | 322 |
StandAlone isNil ifTrue:[ |
18668 | 323 |
StandAlone := false. |
5406 | 324 |
]. |
6559
2ec6d0d1b821
Changed Workstation initialization
Stefan Vogel <sv@exept.de>
parents:
6539
diff
changeset
|
325 |
HeadlessOperation isNil ifTrue:[ |
18668 | 326 |
HeadlessOperation := false. |
6559
2ec6d0d1b821
Changed Workstation initialization
Stefan Vogel <sv@exept.de>
parents:
6539
diff
changeset
|
327 |
]. |
5406 | 328 |
|
617 | 329 |
" |
330 |
extract Language and LanguageTerritory from LANG variable. |
|
5846 | 331 |
valid are for example: |
18668 | 332 |
en_en / en |
333 |
en_us |
|
334 |
en_gb |
|
335 |
de_de / de |
|
336 |
de_at (for Austria) |
|
5846 | 337 |
" |
338 |
||
339 |
Language := #en. |
|
994
6163ae7aaf9b
territory defaults to #us (instead of #usa)
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
340 |
LanguageTerritory := #us. |
617 | 341 |
|
5846 | 342 |
|
343 |
"Format of LANG is: language[_territory][.codeset][@modifier] |
|
18668 | 344 |
language ISO-639 Language code |
345 |
territory ISO-3166 Contry code" |
|
7779
6d88d32bdd64
Language stuff: use OperatingSystem>>getLanguage to get
Stefan Vogel <sv@exept.de>
parents:
7763
diff
changeset
|
346 |
|
6d88d32bdd64
Language stuff: use OperatingSystem>>getLanguage to get
Stefan Vogel <sv@exept.de>
parents:
7763
diff
changeset
|
347 |
envString := OperatingSystem getLanguage. |
3991
7b53bc45bf91
(isNil or:[isEmpty ]) -> (size == 0)
Claus Gittinger <cg@exept.de>
parents:
3988
diff
changeset
|
348 |
envString size > 0 ifTrue:[ |
18668 | 349 |
i := envString indexOf:$@. |
350 |
(i ~~ 0) ifTrue:[ |
|
351 |
LanguageModifier := (envString copyFrom:(i + 1)) asLowercase asSymbol. |
|
352 |
envString := envString copyTo:(i - 1). |
|
353 |
] ifFalse:[ |
|
354 |
LanguageModifier := nil. |
|
355 |
]. |
|
356 |
i := envString indexOf:$.. |
|
357 |
(i ~~ 0) ifTrue:[ |
|
358 |
LanguageCodeset := (envString copyFrom:(i + 1)) asLowercase asSymbol. |
|
359 |
envString := envString copyTo:(i - 1). |
|
360 |
] ifFalse:[ |
|
361 |
LanguageCodeset := #'iso8859-1'. |
|
362 |
]. |
|
363 |
i := envString indexOf:$_. |
|
364 |
(i == 0) ifTrue:[ |
|
365 |
langString := envString. |
|
366 |
terrString := envString |
|
367 |
] ifFalse:[ |
|
368 |
langString := envString copyTo:(i - 1). |
|
369 |
terrString := envString copyFrom:(i + 1) |
|
370 |
]. |
|
371 |
langString := langString asLowercase. |
|
372 |
terrString := terrString asLowercase. |
|
373 |
(langString = 'c' or:[terrString = 'c']) ifTrue:[ |
|
374 |
('Smalltalk [info]: ignoring wrong LANG setting (',langString,'_',terrString,') - using english') infoPrintCR. |
|
375 |
] ifFalse:[ |
|
376 |
Language := langString asSymbol. |
|
377 |
LanguageTerritory := terrString asSymbol |
|
378 |
] |
|
617 | 379 |
]. |
380 |
||
381 |
" |
|
382 |
Smalltalk initGlobalsFromEnvironment |
|
383 |
" |
|
994
6163ae7aaf9b
territory defaults to #us (instead of #usa)
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
384 |
|
14011
d33d2c6497f4
changed: #initGlobalsFromEnvironment
Claus Gittinger <cg@exept.de>
parents:
13998
diff
changeset
|
385 |
"Modified: / 14-02-2012 / 15:25:08 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
386 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
387 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
388 |
initInterrupts |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
389 |
"initialize interrupts" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
390 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
391 |
OperatingSystem enableUserInterrupts. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
392 |
OperatingSystem enableHardSignalInterrupts. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
393 |
OperatingSystem enableCrashSignalInterrupts. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
394 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
395 |
ObjectMemory userInterruptHandler:self. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
396 |
ObjectMemory signalInterruptHandler:self. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
397 |
ObjectMemory recursionInterruptHandler:self. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
398 |
|
14805 | 399 |
OperatingSystem isOSXlike ifTrue:[ |
18668 | 400 |
"/ OSX sends SIGABRT for NSExceptions |
401 |
OperatingSystem operatingSystemSignal:(OperatingSystem sigABRT) install:NSException. |
|
402 |
OperatingSystem enableAbortInterrupts. |
|
14805 | 403 |
]. |
404 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
405 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
406 |
Smalltalk initInterrupts |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
407 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
408 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
409 |
"Modified: 20.8.1997 / 09:35:49 / stefan" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
410 |
! |
617 | 411 |
|
412 |
initStandardStreams |
|
413 |
"initialize some well-known streams" |
|
414 |
||
415 |
Stdout := NonPositionableExternalStream forStdout. |
|
416 |
Stderr := NonPositionableExternalStream forStderr. |
|
417 |
Stdin := NonPositionableExternalStream forStdin. |
|
10145
cca90547778e
allow for different OS's to initialize the Printer differently
Claus Gittinger <cg@exept.de>
parents:
10143
diff
changeset
|
418 |
PrinterStream notNil ifTrue:[ |
18668 | 419 |
Printer := PrinterStream defaultPrinter. |
10145
cca90547778e
allow for different OS's to initialize the Printer differently
Claus Gittinger <cg@exept.de>
parents:
10143
diff
changeset
|
420 |
]. |
617 | 421 |
Transcript := Stderr |
422 |
||
963
fef0f2ed2709
more for standAlone (nonGraphical) mode
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
423 |
" |
fef0f2ed2709
more for standAlone (nonGraphical) mode
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
424 |
Smalltalk initStandardStreams |
fef0f2ed2709
more for standAlone (nonGraphical) mode
Claus Gittinger <cg@exept.de>
parents:
962
diff
changeset
|
425 |
" |
10145
cca90547778e
allow for different OS's to initialize the Printer differently
Claus Gittinger <cg@exept.de>
parents:
10143
diff
changeset
|
426 |
|
cca90547778e
allow for different OS's to initialize the Printer differently
Claus Gittinger <cg@exept.de>
parents:
10143
diff
changeset
|
427 |
"Modified: / 25-10-2006 / 17:36:46 / cg" |
617 | 428 |
! |
429 |
||
430 |
initStandardTools |
|
10646 | 431 |
"predefine some tools which we might need later |
617 | 432 |
- if the view-classes exist, |
433 |
they will redefine Inspector and Debugger for graphical interfaces" |
|
434 |
||
435 |
Display notNil ifTrue:[ |
|
18668 | 436 |
InspectorView notNil ifTrue:[ |
437 |
Inspector := InspectorView |
|
438 |
]. |
|
439 |
DebugView notNil ifTrue:[ |
|
440 |
Debugger := DebugView |
|
441 |
]. |
|
442 |
"/ Display initialize |
|
13303
1aa90c41dd35
changed: #initStandardTools
Claus Gittinger <cg@exept.de>
parents:
13212
diff
changeset
|
443 |
]. |
1aa90c41dd35
changed: #initStandardTools
Claus Gittinger <cg@exept.de>
parents:
13212
diff
changeset
|
444 |
|
1aa90c41dd35
changed: #initStandardTools
Claus Gittinger <cg@exept.de>
parents:
13212
diff
changeset
|
445 |
"/ make the changeFilePath an absolute one, |
1aa90c41dd35
changed: #initStandardTools
Claus Gittinger <cg@exept.de>
parents:
13212
diff
changeset
|
446 |
"/ in case some stupid windows fileDialog changes the current directory... |
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
447 |
ObjectMemory |
18668 | 448 |
nameForChanges:(Filename currentDirectory / ObjectMemory nameForChangesLocal) |
449 |
asAbsoluteFilename pathName |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
450 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
451 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
452 |
Smalltalk initStandardTools |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
453 |
" |
13303
1aa90c41dd35
changed: #initStandardTools
Claus Gittinger <cg@exept.de>
parents:
13212
diff
changeset
|
454 |
|
1aa90c41dd35
changed: #initStandardTools
Claus Gittinger <cg@exept.de>
parents:
13212
diff
changeset
|
455 |
"Modified: / 09-02-2011 / 20:44:47 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
456 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
457 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
458 |
initSystemPath |
617 | 459 |
"setup path where system files are searched for. |
460 |
the default path is set to: |
|
18868 | 461 |
. |
462 |
<directory of exe> (WIN32 only) |
|
463 |
$HOME (if defined) |
|
464 |
$HOME/.smalltalk (if defined & existing) |
|
465 |
$SMALLTALK_LIBDIR (if defined & existing) |
|
466 |
$STX_LIBDIR (if defined & existing) |
|
467 |
$STX_TOPDIR (if defined & existing) |
|
468 |
REGISTRY('HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\<CurrentVersion>\LibDir') (WIN32 only) |
|
469 |
REGISTRY('HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\LibDir') (WIN32 only) |
|
470 |
<standard places> |
|
9021 | 471 |
|
472 |
standard places (unix): |
|
18868 | 473 |
/opt/smalltalk/<release> (if existing) |
474 |
/opt/smalltalk (if existing) |
|
475 |
/usr/local/lib/smalltalk (if existing) |
|
476 |
/usr/lib/smalltalk (if existing) |
|
477 |
/lib/smalltalk (if existing) |
|
4001
fa75465bd263
made systemPath setup OS-specific
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
478 |
|
fa75465bd263
made systemPath setup OS-specific
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
479 |
win32: |
18868 | 480 |
\programs\exept\smalltalk (if existing) |
481 |
\programs\smalltalk (if existing) |
|
482 |
\smalltalk (if existing) |
|
4001
fa75465bd263
made systemPath setup OS-specific
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
483 |
|
fa75465bd263
made systemPath setup OS-specific
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
484 |
vms: |
18868 | 485 |
$stx:lib (if existing) |
486 |
$stx:root (if existing) |
|
617 | 487 |
|
488 |
of course, it is possible to add entries from the 'smalltalk.rc' |
|
489 |
startup file; add expressions such as: |
|
18868 | 490 |
Smalltalk systemPath addFirst:'/foo/bar/baz'. |
491 |
or: |
|
492 |
Smalltalk systemPath addLast:'/fee/foe/foo'. |
|
4001
fa75465bd263
made systemPath setup OS-specific
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
493 |
|
fa75465bd263
made systemPath setup OS-specific
Claus Gittinger <cg@exept.de>
parents:
3991
diff
changeset
|
494 |
However, smalltalk.rc itself must be found along the above path. |
617 | 495 |
" |
496 |
||
2928 | 497 |
ChangeFileName := 'changes'. |
498 |
OperatingSystem isVMSlike ifTrue:[ |
|
18868 | 499 |
BitmapDirName := 'bitmaps.dir'. |
500 |
BinaryDirName := 'binary.dir'. |
|
501 |
SourceDirName := 'source.dir'. |
|
502 |
ResourceDirName := 'resources.dir'. |
|
503 |
FileInDirName := 'filein.dir'. |
|
504 |
PackageDirName := 'packages.dir'. |
|
2928 | 505 |
] ifFalse:[ |
18868 | 506 |
BitmapDirName := 'bitmaps'. |
507 |
BinaryDirName := 'binary'. |
|
508 |
SourceDirName := 'source'. |
|
509 |
ResourceDirName := 'resources'. |
|
510 |
FileInDirName := 'fileIn'. |
|
511 |
PackageDirName := 'packages'. |
|
16234 | 512 |
]. |
513 |
||
514 |
SystemPath isEmptyOrNil ifTrue:[ |
|
18868 | 515 |
SystemPath := OperatingSystem defaultSystemPath. |
516 |
self flushPathCaches |
|
16234 | 517 |
]. |
518 |
||
519 |
PackagePath isEmptyOrNil ifTrue:[ |
|
18868 | 520 |
PackagePath := OperatingSystem defaultPackagePath. |
521 |
]. |
|
522 |
self addWorkspaceDirectoryToPackagePath. |
|
617 | 523 |
|
524 |
" |
|
525 |
Smalltalk initSystemPath |
|
526 |
Smalltalk systemPath |
|
11679
69e588cca61f
Do not use relative pathnames when searching for packages, etc.
Stefan Vogel <sv@exept.de>
parents:
11670
diff
changeset
|
527 |
|
69e588cca61f
Do not use relative pathnames when searching for packages, etc.
Stefan Vogel <sv@exept.de>
parents:
11670
diff
changeset
|
528 |
OperatingSystem defaultSystemPath |
69e588cca61f
Do not use relative pathnames when searching for packages, etc.
Stefan Vogel <sv@exept.de>
parents:
11670
diff
changeset
|
529 |
OperatingSystem defaultPackagePath |
617 | 530 |
" |
5139 | 531 |
|
5145 | 532 |
"Modified: / 24.12.1999 / 00:23:35 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
533 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
534 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
535 |
initUserPreferences |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
536 |
"setup other stuff" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
537 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
538 |
LogDoits := false. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
539 |
LoadBinaries := false. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
540 |
SaveEmergencyImage := (StandAlone ~~ true). |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
541 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
542 |
"Modified: / 24.10.1997 / 18:22:47 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
543 |
! |
617 | 544 |
|
7526 | 545 |
initializeClass:aClass |
546 |
"sent from VM via #initializeModules" |
|
547 |
||
7527 | 548 |
Error handle:[:ex | |
19427 | 549 |
ObjectMemory printStackBacktrace. |
550 |
ClassesFailedToInitialize isNil ifTrue:[ |
|
551 |
ClassesFailedToInitialize := IdentitySet new. |
|
552 |
]. |
|
553 |
ClassesFailedToInitialize add:aClass. |
|
554 |
('Smalltalk [warning]: error during initialize of ' , aClass name,': ', ex description printString) errorPrintCR. |
|
555 |
ex suspendedContext fullPrintAll. |
|
556 |
'------------------------------------------------' errorPrintCR. |
|
557 |
(Debugging == true) ifTrue:[ |
|
558 |
ex reject |
|
559 |
]. |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
560 |
] do:[ |
19427 | 561 |
aClass initialize |
13675 | 562 |
]. |
563 |
||
564 |
"Modified: / 11-09-2011 / 17:01:32 / cg" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
565 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
566 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
567 |
initializeModules |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
568 |
"perform module specific initialization and |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
569 |
send #initialize to all classes. |
16180 | 570 |
Notice: this is NOT called when an image is restarted" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
571 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
572 |
self initializeModulesOnce. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
573 |
ClassesFailedToInitialize size > 0 ifTrue:[ |
18668 | 574 |
('Smalltalk [info]: retry initialization of failed class(es)...') infoPrintCR. |
575 |
ClassesFailedToInitialize := nil. |
|
576 |
self initializeModulesOnce. |
|
577 |
ClassesFailedToInitialize size > 0 ifTrue:[ |
|
578 |
('Smalltalk [error]: class(es) persist to fail during initialize') errorPrintCR. |
|
579 |
] |
|
10122 | 580 |
]. |
581 |
||
582 |
ProjectDefinition initializeAllProjectDefinitions. |
|
583 |
||
584 |
"Modified: / 23-10-2006 / 16:40:39 / cg" |
|
7527 | 585 |
! |
586 |
||
7563 | 587 |
initializeModulesOnce |
588 |
"perform module specific initialization and |
|
589 |
send #initialize to all classes. |
|
7527 | 590 |
Notice: this is not called when an image is restarted" |
4963 | 591 |
|
617 | 592 |
%{ |
18349 | 593 |
#ifdef __SCHTEAM__ |
594 |
STClass.initializeAllClasses(__c__); |
|
595 |
return __c__._RETURN_self(); |
|
596 |
#else |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1682
diff
changeset
|
597 |
__init_registered_modules__(3); |
4963 | 598 |
|
1481 | 599 |
@global(DemoMode) = __getDemoMode() ? true : false; |
5410 | 600 |
RETURN (self); |
18349 | 601 |
#endif /* not SCHTEAM */ |
5410 | 602 |
%}. |
603 |
^ self primitiveFailed |
|
617 | 604 |
! |
605 |
||
7563 | 606 |
initializeSystem |
16655 | 607 |
"initialize all classes; setup dispatcher processes etc. |
3499 | 608 |
This one is the very first entry into the smalltalk world, |
16655 | 609 |
right after startup, usually immediately followed by Smalltalk>>start. |
610 |
Here, a few specific initializations are done, then the actual initialization is |
|
611 |
done inside an error handler in basicInitializeSystem. |
|
10071 | 612 |
Notice: |
18669 | 613 |
this is called by the VM's main entry. You will not find senders from Smalltalk. |
18385 | 614 |
Also Notice: |
18669 | 615 |
this is NOT called when an image is restarted; |
616 |
in this case the show starts in Smalltalk>>restart." |
|
211 | 617 |
|
19510 | 618 |
|idx shellArgs| |
6841
37bc69fc9240
set StandAlone flag earlier (during initSystem);
Claus Gittinger <cg@exept.de>
parents:
6837
diff
changeset
|
619 |
|
12861 | 620 |
NumberOfClassesHint := 10000. |
8964
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
621 |
|
3499 | 622 |
Initializing := true. |
623 |
AbstractOperatingSystem initializeConcreteClass. |
|
624 |
||
18307
c1d97d109f88
also care for empty cmd-line args (could be empty OrderedCollection)
Claus Gittinger <cg@exept.de>
parents:
18293
diff
changeset
|
625 |
CommandLineArguments isEmptyOrNil ifTrue:[ |
18669 | 626 |
CommandLineArguments := #('stx') asOrderedCollection. |
5400 | 627 |
]. |
4006
c7ad38c52eb9
must set CommandLineArguments earlier (to be available in initializeSystem)
Claus Gittinger <cg@exept.de>
parents:
4001
diff
changeset
|
628 |
CommandLine := CommandLineArguments copy. |
c7ad38c52eb9
must set CommandLineArguments earlier (to be available in initializeSystem)
Claus Gittinger <cg@exept.de>
parents:
4001
diff
changeset
|
629 |
CommandLineArguments := CommandLineArguments asOrderedCollection. |
6842 | 630 |
CommandName := CommandLineArguments removeFirst. "/ the command |
4006
c7ad38c52eb9
must set CommandLineArguments earlier (to be available in initializeSystem)
Claus Gittinger <cg@exept.de>
parents:
4001
diff
changeset
|
631 |
|
18669 | 632 |
SilentLoading := false. |
633 |
VerboseLoading := false. |
|
634 |
VerboseStartup := false. |
|
635 |
Verbose := false. |
|
636 |
self initializeVerboseFlags. |
|
348 | 637 |
|
19427 | 638 |
DebuggingStandAlone := Debugging := false. |
19510 | 639 |
|
640 |
"/ if no argument was given, look for an environment variable named |
|
641 |
"/ STX_DEFAULT_ARGS. If set, take that. |
|
642 |
"/ if any argument was given, unless a --noShellArgs argument is given, |
|
643 |
"/ slice in the value from "STX_MORE_ARGS" at the beginning. |
|
644 |
"/ |
|
645 |
"/ These allow for args like "--quick --infoPrint" to be automatically prepended |
|
19511 | 646 |
idx := CommandLineArguments indexOfAny:#('--noShellArgs' '--noshellargs'). |
19510 | 647 |
(idx ~~ 0) ifTrue:[ |
648 |
CommandLineArguments removeIndex:idx. |
|
649 |
] ifFalse:[ |
|
650 |
CommandLineArguments isEmpty ifTrue:[ |
|
651 |
shellArgs := OperatingSystem getEnvironment:'STX_DEFAULT_ARGS'. |
|
652 |
shellArgs notEmptyOrNil ifTrue:[ |
|
653 |
shellArgs := shellArgs asCollectionOfWords. |
|
654 |
CommandLineArguments addAll:shellArgs. |
|
655 |
]. |
|
656 |
] ifFalse:[ |
|
657 |
"/ prepend shell environment args from "STX_ARGS" |
|
658 |
shellArgs := OperatingSystem getEnvironment:'STX_MORE_ARGS'. |
|
659 |
shellArgs notEmptyOrNil ifTrue:[ |
|
660 |
shellArgs := shellArgs asCollectionOfWords. |
|
661 |
CommandLineArguments addAllFirst:shellArgs. |
|
662 |
]. |
|
663 |
]. |
|
664 |
]. |
|
665 |
||
19427 | 666 |
idx := CommandLineArguments indexOf:'--debug'. |
667 |
Debugging := (idx ~~ 0). |
|
668 |
||
6841
37bc69fc9240
set StandAlone flag earlier (during initSystem);
Claus Gittinger <cg@exept.de>
parents:
6837
diff
changeset
|
669 |
StandAlone ifTrue:[ |
18669 | 670 |
InfoPrinting := false. |
671 |
ObjectMemory infoPrinting:false. |
|
672 |
IgnoreAssertions := true. |
|
673 |
||
19427 | 674 |
DebuggingStandAlone := Debugging. |
18669 | 675 |
DebuggingStandAlone ifTrue:[ |
676 |
Inspector := MiniInspector. |
|
677 |
Debugger := MiniDebugger. |
|
678 |
IgnoreAssertions := false. |
|
679 |
]. |
|
6841
37bc69fc9240
set StandAlone flag earlier (during initSystem);
Claus Gittinger <cg@exept.de>
parents:
6837
diff
changeset
|
680 |
] ifFalse:[ |
18669 | 681 |
"/ |
682 |
"/ define low-level debugging tools - graphical classes are not prepared yet |
|
683 |
"/ to handle things. |
|
684 |
"/ This will bring us into the MiniDebugger when an error occurs during startup. |
|
685 |
"/ |
|
686 |
Inspector := MiniInspector. |
|
687 |
Debugger := MiniDebugger. |
|
688 |
IgnoreAssertions := false. |
|
14432 | 689 |
]. |
690 |
||
11057 | 691 |
Error handle:[:ex | |
18669 | 692 |
StandAlone ifTrue:[ |
693 |
DebuggingStandAlone ifFalse:[ |
|
694 |
'Startup Error - use "--debug" command line argument for more info' errorPrintCR. |
|
695 |
Smalltalk exit:1. |
|
696 |
]. |
|
697 |
'Smalltalk [error]: Error during early initialization:' errorPrintCR. |
|
698 |
thisContext fullPrintAll. |
|
699 |
]. |
|
700 |
ex reject. |
|
11057 | 701 |
] do:[ |
18669 | 702 |
self basicInitializeSystem |
14432 | 703 |
]. |
13091
bc840cd6f1ae
--verboseLoading command line arg (shlib loading trace)
Claus Gittinger <cg@exept.de>
parents:
13061
diff
changeset
|
704 |
|
bc840cd6f1ae
--verboseLoading command line arg (shlib loading trace)
Claus Gittinger <cg@exept.de>
parents:
13061
diff
changeset
|
705 |
"Modified: / 12-10-2010 / 11:27:47 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
706 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
707 |
|
18669 | 708 |
initializeVerboseFlags |
709 |
|idx| |
|
710 |
||
19430 | 711 |
(idx := CommandLineArguments indexOf:'--ignoreHalt') ~~ 0 ifTrue:[ |
712 |
IgnoreHalt := true. |
|
713 |
CommandLineArguments removeIndex:idx |
|
714 |
]. |
|
18669 | 715 |
(idx := CommandLineArguments indexOf:'--silentStartup') ~~ 0 ifTrue:[ |
716 |
SilentLoading := true. |
|
717 |
CommandLineArguments removeIndex:idx |
|
718 |
]. |
|
719 |
(idx := CommandLineArguments indexOf:'--verboseLoading') ~~ 0 ifTrue:[ |
|
720 |
VerboseLoading := true. |
|
721 |
CommandLineArguments removeIndex:idx |
|
722 |
]. |
|
723 |
(idx := CommandLineArguments indexOf:'--verboseStartup') ~~ 0 ifTrue:[ |
|
724 |
VerboseLoading := true. |
|
725 |
VerboseStartup := true. |
|
726 |
CommandLineArguments removeIndex:idx |
|
727 |
]. |
|
728 |
(idx := CommandLineArguments indexOf:'--verbose') ~~ 0 ifTrue:[ |
|
729 |
Verbose := true. |
|
730 |
VerboseLoading := true. |
|
731 |
VerboseStartup := true. |
|
732 |
CommandLineArguments removeIndex:idx |
|
733 |
]. |
|
734 |
! |
|
735 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
736 |
isInitialized |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
737 |
"this returns true, if the system is properly initialized; |
16170
ca4d03def070
endOfDipatch if running scripts
Claus Gittinger <cg@exept.de>
parents:
16164
diff
changeset
|
738 |
i.e. false during startup. |
15980 | 739 |
Especially, the whole display/viewing stuff and process escheduling |
740 |
is not working correctly until initialized." |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
741 |
|
18251
9b7f8e531a16
isInitialized query during very early start
Claus Gittinger <cg@exept.de>
parents:
18248
diff
changeset
|
742 |
Initializing isNil ifTrue:[^ false]. "/ if called very early |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
743 |
^ Initializing not |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
744 |
! |
1 | 745 |
|
7563 | 746 |
reinitStandardStreams |
747 |
"reinitialize some well-known streams. |
|
748 |
Tis must be done very early during startup, to allow for |
|
477
8710aba7876b
oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
749 |
debug and trace messages to be output |
8710aba7876b
oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
750 |
(otherwise, the file-descriptors are invalid)" |
8710aba7876b
oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
751 |
|
8710aba7876b
oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents:
457
diff
changeset
|
752 |
Stdout reOpen. Stderr reOpen. Stdin reOpen. |
161 | 753 |
! ! |
754 |
||
16593 | 755 |
!Smalltalk class methodsFor:'Compatibility-GNU'! |
756 |
||
757 |
system:command |
|
758 |
"GNU-Smalltalk compatibility: execute an OS command" |
|
759 |
||
760 |
OperatingSystem executeCommand:command |
|
761 |
||
762 |
" |
|
763 |
Smalltalk system:'ls' |
|
764 |
" |
|
765 |
! ! |
|
766 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
767 |
!Smalltalk class methodsFor:'Compatibility-Squeak'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
768 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
769 |
beep |
17343 | 770 |
"output an audible beep or bell" |
771 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
772 |
Screen current beep |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
773 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
774 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
775 |
garbageCollect |
15009 | 776 |
"for Squeak compatibility" |
777 |
||
778 |
ObjectMemory garbageCollect |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
779 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
780 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
781 |
garbageCollectMost |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
782 |
"collect recently created garbage; return the amount of freeSpace. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
783 |
In ST/X, only the newSpace is collected here, and the sum of |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
784 |
newSpace + freeListSpace is returned." |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
785 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
786 |
ObjectMemory scavenge. |
15009 | 787 |
^ ObjectMemory freeSpace + (ObjectMemory newSpaceSize - ObjectMemory newSpaceUsed) |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
788 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
789 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
790 |
isMorphic |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
791 |
^ false |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
792 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
793 |
|
10844 | 794 |
platformName |
795 |
"not yet fully implemented (I have to figure out, what squeak returns in each case...)" |
|
796 |
||
797 |
^ OperatingSystem platformName asUppercaseFirst |
|
798 |
||
799 |
" |
|
800 |
Smalltalk platformName -> 'Win32' |
|
801 |
" |
|
802 |
! |
|
803 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
804 |
registerExternalObject: anObject |
7563 | 805 |
"Register the given object in the external objects array and return its index. |
4584
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
806 |
If it is already there, just return its index. |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
807 |
ExternalObjects are protected from GC and can be accessed easily from |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
808 |
primitive code (via the global Smalltalk:SpecialObjectArray)" |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
809 |
|
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
810 |
| objects firstEmptyIndex obj sz newObjects | |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
811 |
|
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
812 |
objects := SpecialObjectArray. |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
813 |
objects isNil ifTrue:[ |
18668 | 814 |
objects := Array new:5. |
4584
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
815 |
]. |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
816 |
|
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
817 |
"find the first empty slot and look if already registered" |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
818 |
firstEmptyIndex := 0. |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
819 |
1 to: objects size do: [:i | |
18668 | 820 |
obj := objects at: i. |
821 |
obj == anObject ifTrue: [^ i]. "object already there, just return its index" |
|
822 |
(obj == nil and: [firstEmptyIndex = 0]) ifTrue: [ |
|
823 |
firstEmptyIndex := i |
|
824 |
] |
|
4584
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
825 |
]. |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
826 |
|
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
827 |
"if no empty slots, expand the array" |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
828 |
firstEmptyIndex = 0 ifTrue: [ |
18668 | 829 |
sz := objects size. |
830 |
newObjects := objects species new: sz + 20. "grow linearly" |
|
831 |
newObjects replaceFrom: 1 to: sz with: objects startingAt: 1. |
|
832 |
firstEmptyIndex := sz + 1. |
|
833 |
SpecialObjectArray := newObjects. |
|
834 |
objects := newObjects |
|
4584
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
835 |
]. |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
836 |
|
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
837 |
objects at: firstEmptyIndex put: anObject. |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
838 |
^ firstEmptyIndex |
789c83e8cae0
some squeak compatibility stuff
Claus Gittinger <cg@exept.de>
parents:
4524
diff
changeset
|
839 |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
840 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
841 |
|
12358 | 842 |
removeClassNamed: aName |
17576 | 843 |
"Invoked from fileouts: if there is currently a class in the system named aName, then remove it. |
844 |
Also needed by the refactory browser. |
|
845 |
If anything untoward happens, report it in the Transcript." |
|
12358 | 846 |
|
847 |
| oldClass | |
|
848 |
||
849 |
(oldClass := self at: aName asSymbol ifAbsent: [nil]) isNil ifTrue:[ |
|
18668 | 850 |
Transcript showCR: 'Removal of class named ', aName, ' ignored because it does not exist.'. |
851 |
^ self |
|
12358 | 852 |
]. |
853 |
oldClass removeFromSystem |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
854 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
855 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
856 |
!Smalltalk class methodsFor:'Compatibility-V''Age'! |
6722
8388292bc41d
allClassesImplementing & allMethodCategories
Claus Gittinger <cg@exept.de>
parents:
6715
diff
changeset
|
857 |
|
7563 | 858 |
allClassesImplementing:aSelector |
12304
b0dc1c58de1a
changed: #allClassesImplementing:
Claus Gittinger <cg@exept.de>
parents:
12301
diff
changeset
|
859 |
^ self allClassesForWhich:[:cls | cls includesSelector:aSelector]. |
9506 | 860 |
|
861 |
"Modified: / 10-08-2006 / 12:12:17 / cg" |
|
9090 | 862 |
! |
863 |
||
16459 | 864 |
declareConstant:constantName poolName:poolNameArg value:value |
865 |
"visualAge compatible pool variable declaration. |
|
16562 | 866 |
called when a V'age application is filed in |
16459 | 867 |
(or one of its changes is accepted via the change browser)" |
868 |
||
869 |
|ns poolName pool| |
|
870 |
||
871 |
"/ when coming from the change-browser, |
|
872 |
"/ a namespace override may be given... |
|
873 |
ns := Class nameSpaceQuerySignal query. |
|
874 |
(ns isNil or:[ns == Smalltalk]) ifTrue:[ |
|
18668 | 875 |
poolName := poolNameArg asSymbol |
16459 | 876 |
] ifFalse:[ |
18668 | 877 |
poolName := (ns name,'::',poolNameArg) asSymbol |
16459 | 878 |
]. |
9090 | 879 |
pool := self classNamed:poolName. |
880 |
pool declareConstant:constantName value:value |
|
881 |
! |
|
882 |
||
16459 | 883 |
declarePoolDictionary:poolDictionaryNameArg |
884 |
"visualAge compatible pool declaration. |
|
16562 | 885 |
called when a V'age application is filed in |
16459 | 886 |
(or one of its changes is accepted via the change browser)" |
887 |
||
888 |
|ns poolName| |
|
889 |
||
890 |
poolName := poolDictionaryNameArg asSymbol. |
|
891 |
||
892 |
"/ "/ when coming from the change-browser, |
|
893 |
"/ "/ a namespace override may be given... |
|
894 |
"/ ns := Class nameSpaceQuerySignal query. |
|
895 |
"/ (ns isNil or:[ns == Smalltalk]) ifTrue:[ |
|
896 |
"/ poolName := poolDictionaryNameArg asSymbol |
|
897 |
"/ ] ifFalse:[ |
|
898 |
"/ poolName := (ns name,'::',poolDictionaryNameArg) asSymbol |
|
899 |
"/ ]. |
|
900 |
^ SharedPool subclass:(poolName asSymbol) |
|
18668 | 901 |
instanceVariableNames:'' |
902 |
classVariableNames:'' |
|
903 |
poolDictionaries:'' |
|
904 |
category:'* VAST Pools' |
|
13998
890d42903662
added: #declareVariable:poolName:
Claus Gittinger <cg@exept.de>
parents:
13958
diff
changeset
|
905 |
|
890d42903662
added: #declareVariable:poolName:
Claus Gittinger <cg@exept.de>
parents:
13958
diff
changeset
|
906 |
"Modified: / 07-02-2012 / 15:56:16 / cg" |
890d42903662
added: #declareVariable:poolName:
Claus Gittinger <cg@exept.de>
parents:
13958
diff
changeset
|
907 |
! |
890d42903662
added: #declareVariable:poolName:
Claus Gittinger <cg@exept.de>
parents:
13958
diff
changeset
|
908 |
|
16459 | 909 |
declareVariable:varName poolName:poolNameArg |
910 |
"visualAge compatible pool declaration. |
|
16562 | 911 |
called when a V'age application is filed in |
16459 | 912 |
(or one of its changes is accepted via the change browser)" |
913 |
||
914 |
|ns poolName pool| |
|
915 |
||
916 |
"/ when coming from the change-browser, |
|
917 |
"/ a namespace override may be given... |
|
918 |
ns := Class nameSpaceQuerySignal query. |
|
919 |
(ns isNil or:[ns == Smalltalk]) ifTrue:[ |
|
18668 | 920 |
poolName := poolNameArg asSymbol |
16459 | 921 |
] ifFalse:[ |
18668 | 922 |
poolName := (ns name,'::',poolNameArg) asSymbol |
16459 | 923 |
]. |
13998
890d42903662
added: #declareVariable:poolName:
Claus Gittinger <cg@exept.de>
parents:
13958
diff
changeset
|
924 |
pool := self classNamed:poolName. |
890d42903662
added: #declareVariable:poolName:
Claus Gittinger <cg@exept.de>
parents:
13958
diff
changeset
|
925 |
pool declareVariable:varName |
890d42903662
added: #declareVariable:poolName:
Claus Gittinger <cg@exept.de>
parents:
13958
diff
changeset
|
926 |
|
890d42903662
added: #declareVariable:poolName:
Claus Gittinger <cg@exept.de>
parents:
13958
diff
changeset
|
927 |
"Created: / 07-02-2012 / 15:57:05 / cg" |
6722
8388292bc41d
allClassesImplementing & allMethodCategories
Claus Gittinger <cg@exept.de>
parents:
6715
diff
changeset
|
928 |
! ! |
8388292bc41d
allClassesImplementing & allMethodCategories
Claus Gittinger <cg@exept.de>
parents:
6715
diff
changeset
|
929 |
|
7295 | 930 |
!Smalltalk class methodsFor:'Compatibility-VW5.4'! |
6094
79ebf84b51bd
first attempt in supporting vw5.4 definitions
Claus Gittinger <cg@exept.de>
parents:
6080
diff
changeset
|
931 |
|
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
932 |
defineClass:nameSymbol superclass:superclass indexedType:indexed private:private instanceVariableNames:instVars classInstanceVariableNames:classInstVars imports:imports category:category |
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
933 |
^ self |
18668 | 934 |
defineClass:nameSymbol |
935 |
superclass:superclass |
|
936 |
indexedType:indexed |
|
937 |
private:private |
|
938 |
instanceVariableNames:instVars |
|
939 |
classInstanceVariableNames:classInstVars |
|
940 |
imports:imports |
|
941 |
category:category |
|
942 |
attributes:nil |
|
12033 | 943 |
! |
944 |
||
7563 | 945 |
defineClass:nameSymbol superclass:superclass indexedType:indexed private:private instanceVariableNames:instVars classInstanceVariableNames:classInstVars imports:imports category:category attributes:annotations |
6094
79ebf84b51bd
first attempt in supporting vw5.4 definitions
Claus Gittinger <cg@exept.de>
parents:
6080
diff
changeset
|
946 |
|newClass| |
79ebf84b51bd
first attempt in supporting vw5.4 definitions
Claus Gittinger <cg@exept.de>
parents:
6080
diff
changeset
|
947 |
|
79ebf84b51bd
first attempt in supporting vw5.4 definitions
Claus Gittinger <cg@exept.de>
parents:
6080
diff
changeset
|
948 |
indexed == #none ifTrue:[ |
18668 | 949 |
newClass := superclass |
950 |
subclass:nameSymbol |
|
951 |
instanceVariableNames:instVars |
|
952 |
classVariableNames:'' |
|
953 |
poolDictionaries:'' |
|
954 |
category:category |
|
955 |
inEnvironment:self. |
|
956 |
classInstVars size > 0 ifTrue:[ |
|
957 |
newClass class instanceVariableNames:classInstVars. |
|
958 |
]. |
|
959 |
^ newClass |
|
6851 | 960 |
]. |
961 |
self shouldImplement. |
|
12033 | 962 |
! |
963 |
||
964 |
defineNameSpace:nameSymbol private:private imports:imports category:category |
|
965 |
|newNameSpace| |
|
966 |
||
967 |
private ifTrue:[self halt]. "/ what to do ? |
|
968 |
imports withoutSeparators notEmpty ifTrue:[self halt]. "/ what to do ? |
|
969 |
newNameSpace := NameSpace name:nameSymbol. |
|
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
970 |
newNameSpace setCategory:category. |
12033 | 971 |
^ newNameSpace |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
972 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
973 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
974 |
!Smalltalk class methodsFor:'accessing'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
975 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
976 |
associationAt:aKey |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
977 |
"return a key-value association for aKey. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
978 |
Since ST/X's Smalltalk as no real dictionary, this is |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
979 |
simulated here." |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
980 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
981 |
|val| |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
982 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
983 |
val := self at:aKey ifAbsent:nil. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
984 |
val isNil ifTrue:[^ nil]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
985 |
^ Association key:aKey value:val |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
986 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
987 |
"Created: / 1.11.1997 / 13:27:20 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
988 |
! |
3083 | 989 |
|
7563 | 990 |
associationAt:aKey ifAbsent:exceptionBlock |
991 |
"return a key-value association for aKey, or the value |
|
3610
12f32c1fe72b
added #associationAt:ifAbsent: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3565
diff
changeset
|
992 |
from exceptionBlock, if no such key is present. |
14973 | 993 |
Since ST/X's Smalltalk as no real dictionary, this is simulated here. |
994 |
Warning: this is a comatibility interface only, with a different semantic as |
|
18668 | 995 |
the original ST80 implementation. The returned assoc is created on the fly, |
996 |
and not the one stored in the receiver (there are not assocs there)" |
|
3610
12f32c1fe72b
added #associationAt:ifAbsent: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3565
diff
changeset
|
997 |
|
12f32c1fe72b
added #associationAt:ifAbsent: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3565
diff
changeset
|
998 |
|val| |
12f32c1fe72b
added #associationAt:ifAbsent: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3565
diff
changeset
|
999 |
|
12f32c1fe72b
added #associationAt:ifAbsent: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3565
diff
changeset
|
1000 |
val := self at:aKey ifAbsent:nil. |
12f32c1fe72b
added #associationAt:ifAbsent: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3565
diff
changeset
|
1001 |
val isNil ifTrue:[^ exceptionBlock value]. |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1002 |
^ Association key:aKey value:val |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1003 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1004 |
"Created: / 18.6.1998 / 17:05:24 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1005 |
! |
3610
12f32c1fe72b
added #associationAt:ifAbsent: for ST80 compatibility.
Claus Gittinger <cg@exept.de>
parents:
3565
diff
changeset
|
1006 |
|
7563 | 1007 |
at:aKey |
10071 | 1008 |
"retrieve the value stored under aKey, a symbol. |
1009 |
Return nil if not present |
|
1956 | 1010 |
(this will be changed to trigger an error - better use #at:ifAbsent:)" |
453 | 1011 |
|
16831 | 1012 |
aKey class == Symbol ifFalse:[self error:'expected symbol']. |
6080
15ea3cbf6003
renamed: #allSelectorsAndMethodsDo: into: #instAndClassSelectorsAndMethodsDo:
Claus Gittinger <cg@exept.de>
parents:
6074
diff
changeset
|
1013 |
|
453 | 1014 |
%{ /* NOCONTEXT */ |
18287 | 1015 |
#ifdef __SCHTEAM__ |
1016 |
{ |
|
18668 | 1017 |
STSymbol keySymbol = aKey.asSTSymbol(); |
1018 |
STObject val = STSmalltalkEnvironment.GetResolvedBindingOrNull(keySymbol); |
|
1019 |
||
1020 |
return context._RETURN( val == null ? Nil : val ); |
|
18287 | 1021 |
} |
1022 |
/* NOT REACHED */ |
|
1023 |
#else |
|
453 | 1024 |
RETURN ( __GLOBAL_GET(aKey) ); |
18287 | 1025 |
#endif |
5406 | 1026 |
%}. |
5410 | 1027 |
^ self primitiveFailed |
453 | 1028 |
! |
1029 |
||
7563 | 1030 |
at:aKey ifAbsent:aBlock |
1031 |
"retrieve the value stored at aKey. |
|
7565 | 1032 |
If there is nothing stored under this key, return the value of |
1033 |
the evaluation of aBlock." |
|
453 | 1034 |
|
1035 |
(self includesKey:aKey) ifTrue:[ |
|
18668 | 1036 |
^ self at:aKey |
453 | 1037 |
]. |
1038 |
^ aBlock value |
|
1039 |
||
1040 |
" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1041 |
Smalltalk at:#fooBar <- returns nil |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1042 |
Smalltalk at:#fooBar ifAbsent:['sorry'] <- no error |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1043 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1044 |
! |
453 | 1045 |
|
15068 | 1046 |
at:aKey ifAbsentPut:aBlock |
1047 |
"return the element indexed by aKey if present, |
|
1048 |
if not present, store the result of evaluating valueBlock |
|
1049 |
under aKey and return it." |
|
1050 |
||
1051 |
^ self at:aKey ifAbsent:[ self at:aKey put:aBlock value ]. |
|
1052 |
||
1053 |
"Created: / 29-05-2007 / 12:41:12 / cg" |
|
1054 |
! |
|
1055 |
||
7563 | 1056 |
at:aKey ifPresent:aBlock |
1057 |
"try to retrieve the value stored at aKey. |
|
1058 |
If there is nothing stored under this key, do nothing. |
|
4870 | 1059 |
Otherwise, evaluate aBlock, passing the retrieved value as argument." |
1060 |
||
13883 | 1061 |
|val| |
1062 |
||
4870 | 1063 |
(self includesKey:aKey) ifTrue:[ |
18668 | 1064 |
(val := self at:aKey) notNil ifTrue:[ |
1065 |
^ aBlock value:val |
|
1066 |
] |
|
4870 | 1067 |
]. |
1068 |
^ nil |
|
1069 |
||
1070 |
" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1071 |
Smalltalk at:#fooBar ifPresent:[:what | Transcript showCR:what]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1072 |
Smalltalk at:#Object ifPresent:[:what | Transcript showCR:what]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1073 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1074 |
|
13883 | 1075 |
"Modified: / 27-12-2011 / 10:14:30 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1076 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1077 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1078 |
at:aKey put:aValue |
7563 | 1079 |
"store the argument aValue under aKey, a symbol. |
1080 |
Return aValue (sigh)." |
|
453 | 1081 |
|
1082 |
|oldValue| |
|
1083 |
||
1084 |
%{ |
|
18287 | 1085 |
#ifdef __SCHTEAM__ |
1086 |
{ |
|
18668 | 1087 |
STSymbol keySymbol = aKey.asSTSymbol(); |
1088 |
oldValue = STSmalltalkEnvironment.SetBinding(keySymbol, aValue); |
|
18287 | 1089 |
} |
1090 |
#else |
|
453 | 1091 |
oldValue = __GLOBAL_SET(aKey, aValue, (OBJ *)0); |
18287 | 1092 |
#endif |
453 | 1093 |
%}. |
1094 |
CachedClasses notNil ifTrue:[ |
|
18668 | 1095 |
oldValue isBehavior ifTrue:[ |
1096 |
oldValue name == aKey ifTrue:[ |
|
1097 |
CachedClasses remove:oldValue ifAbsent:[] |
|
1098 |
] |
|
1099 |
]. |
|
1100 |
aValue isBehavior ifTrue:[ |
|
1101 |
aValue name == aKey ifTrue:[ |
|
1102 |
CachedClasses add:aValue |
|
1103 |
] ifFalse:[ |
|
1104 |
CachedClasses := nil |
|
1105 |
] |
|
1106 |
]. |
|
453 | 1107 |
]. |
745
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
1108 |
^ aValue. |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1109 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1110 |
"Modified: 19.4.1996 / 11:31:49 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1111 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1112 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1113 |
includesKey:aKey |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1114 |
"return true, if the key is known" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1115 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1116 |
"/ for debugging - this is a common mistake, |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1117 |
"/ to try to access a class by nameString, instead |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1118 |
"/ of by symbol. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1119 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1120 |
"/ aKey class == String ifTrue:[self halt]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1121 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1122 |
%{ /* NOCONTEXT */ |
18287 | 1123 |
#ifdef __SCHTEAM__ |
1124 |
STSymbol keySymbol = aKey.asSTSymbol(); |
|
18668 | 1125 |
return __c__._RETURN( STSmalltalkEnvironment.HasBinding(keySymbol) ? STObject.True : STObject.False); |
18287 | 1126 |
/* NOT REACHED */ |
1127 |
#else |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1128 |
RETURN ( __GLOBAL_KEYKNOWN(aKey) ); |
18287 | 1129 |
#endif |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1130 |
%}. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1131 |
^ self primitiveFailed |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1132 |
! |
453 | 1133 |
|
7563 | 1134 |
keyAtValue:anObject |
1135 |
"return the symbol under which anObject is stored - or nil" |
|
453 | 1136 |
|
1137 |
self keysDo:[:aKey | |
|
18668 | 1138 |
(self at:aKey) == anObject ifTrue:[^ aKey] |
453 | 1139 |
]. |
1140 |
^ nil |
|
1141 |
||
1142 |
"Smalltalk keyAtValue:Object" |
|
1143 |
! |
|
1144 |
||
7563 | 1145 |
keys |
1146 |
"return a collection with all keys in the Smalltalk dictionary" |
|
1147 |
||
1148 |
|keys| |
|
453 | 1149 |
|
1150 |
keys := IdentitySet new. |
|
1151 |
self keysDo:[:k | keys add:k]. |
|
1152 |
^ keys |
|
617 | 1153 |
! |
1154 |
||
7563 | 1155 |
removeKey:aKey |
1156 |
"remove the association stored under the key-argument from the globals dictionary. |
|
10071 | 1157 |
WARNING: |
18668 | 1158 |
this is somewhat dangerous: conceptionally, the association is removed, |
1159 |
to which machine & byte compiled code refers if it accesses a global. |
|
1160 |
If there are still global accesses in some literalArray or from machine-compiled code, |
|
1161 |
it continues to reference the globals value via that obsolete association and gets a nil |
|
1162 |
value. (which is correct) |
|
1163 |
However, if that global is later reintroduced, a new association will be created and |
|
1164 |
the new global now referenced via the new association. |
|
1165 |
The old accesses will still see nil, although the globals value is actually non-nil |
|
1166 |
(this is questionable). |
|
1167 |
To avoid this problem, the #removeClass: method never removed the key." |
|
617 | 1168 |
|
1169 |
CachedClasses := nil. |
|
1170 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1171 |
%{ /* NOCONTEXT */ |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1172 |
RETURN ( __GLOBAL_REMOVE(aKey) ); |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1173 |
%}. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1174 |
^ self primitiveFailed |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1175 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1176 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1177 |
|
10538 | 1178 |
startBlocks |
1179 |
^ StartBlocks |
|
1180 |
! |
|
1181 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1182 |
values |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1183 |
"return a collection with all values in the Smalltalk dictionary" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1184 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1185 |
|values| |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1186 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1187 |
values := OrderedCollection new. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1188 |
self do:[:v | values add:v]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1189 |
^ values |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1190 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1191 |
"Created: 20.6.1997 / 16:58:28 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1192 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1193 |
|
13540 | 1194 |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1195 |
!Smalltalk class methodsFor:'browsing'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1196 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1197 |
browseAllCallsOn:aSelectorSymbol |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1198 |
"{ Pragma: +optSpace }" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1199 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1200 |
"startup a browser for all methods sending a particular message" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1201 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1202 |
UserPreferences systemBrowserClass browseAllCallsOn:aSelectorSymbol |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1203 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1204 |
" |
10071 | 1205 |
Smalltalk browseAllCallsOn:#at:put: |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1206 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1207 |
! |
617 | 1208 |
|
7563 | 1209 |
browseAllSelect:aBlock |
1210 |
"{ Pragma: +optSpace }" |
|
1211 |
||
1212 |
"startup a browser for all methods for which aBlock returns true" |
|
617 | 1213 |
|
6020 | 1214 |
UserPreferences systemBrowserClass browseAllSelect:aBlock |
617 | 1215 |
|
1216 |
" |
|
1217 |
Smalltalk browseAllSelect:[:m | m literals isNil] |
|
1218 |
" |
|
1219 |
! |
|
1220 |
||
7563 | 1221 |
browseChanges |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1222 |
"{ Pragma: +optSpace }" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1223 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1224 |
"startup a changes browser" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1225 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1226 |
ChangesBrowser notNil ifTrue:[ |
18668 | 1227 |
ChangesBrowser open |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1228 |
] ifFalse:[ |
18668 | 1229 |
self warn:'no ChangesBrowser built in' |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1230 |
] |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1231 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1232 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1233 |
Smalltalk browseChanges |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1234 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1235 |
! |
453 | 1236 |
|
7563 | 1237 |
browseClass:aClass |
1238 |
"{ Pragma: +optSpace }" |
|
1239 |
||
11375 | 1240 |
"startup a browser on aClass. |
11150 | 1241 |
The broser will only show that class (i.e. be a singleClass-browser). |
1242 |
See browseInClass: for a full browser, which has aClass selected initially." |
|
6970 | 1243 |
|
1244 |
UserPreferences systemBrowserClass browseClass:aClass |
|
1245 |
||
1246 |
" |
|
10071 | 1247 |
Smalltalk browseClass:Array |
6970 | 1248 |
" |
1249 |
! |
|
1250 |
||
7563 | 1251 |
browseImplementorsMatching:aSelectorSymbolOrMatchPattern |
1252 |
"{ Pragma: +optSpace }" |
|
6819 | 1253 |
|
1254 |
"startup a browser for all methods implementing a message matching" |
|
1255 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1256 |
UserPreferences systemBrowserClass browseImplementorsMatching:aSelectorSymbolOrMatchPattern |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1257 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1258 |
" |
10071 | 1259 |
Smalltalk browseImplementorsOf:#'at:put:' |
1260 |
Smalltalk browseImplementorsMatching:#'at:*' |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1261 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1262 |
! |
6819 | 1263 |
|
7563 | 1264 |
browseImplementorsOf:aSelectorSymbol |
1265 |
"{ Pragma: +optSpace }" |
|
1266 |
||
1267 |
"startup a browser for all methods implementing a particular message" |
|
453 | 1268 |
|
6020 | 1269 |
UserPreferences systemBrowserClass browseImplementorsOf:aSelectorSymbol |
453 | 1270 |
|
1271 |
" |
|
10071 | 1272 |
Smalltalk browseImplementorsOf:#at:put: |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1273 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1274 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1275 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1276 |
browseInClass:aClass |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1277 |
"{ Pragma: +optSpace }" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1278 |
|
11150 | 1279 |
"startup a full browser showing aClass. |
1280 |
The browser will be a full browser with aClass initially selekted. |
|
1281 |
See browseClass: for a singleClass browser, which shows only a single class." |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1282 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1283 |
UserPreferences systemBrowserClass openInClass:aClass |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1284 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1285 |
" |
10071 | 1286 |
Smalltalk browseInClass:Array |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1287 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1288 |
! |
6970 | 1289 |
|
7563 | 1290 |
browseInClass:aClass selector:selector |
1291 |
"{ Pragma: +optSpace }" |
|
1292 |
||
11150 | 1293 |
"startup a full browser showing aClass>>selector. |
1294 |
The browser will be a full browser with aClass initially selekted. |
|
1295 |
See browseClass: for a singleClass browser, which shows only a single class." |
|
6970 | 1296 |
|
1297 |
UserPreferences systemBrowserClass openInClass:aClass selector:selector |
|
1298 |
||
1299 |
" |
|
1300 |
Smalltalk browseInClass:Array selector:#at: |
|
1301 |
" |
|
453 | 1302 |
! ! |
1303 |
||
1750
36ff7e62388a
care for privateClasses in remove
Claus Gittinger <cg@exept.de>
parents:
1713
diff
changeset
|
1304 |
!Smalltalk class methodsFor:'class management'! |
453 | 1305 |
|
18732 | 1306 |
basicRemoveClass:aClass |
1307 |
"remove the argument, aClass from the smalltalk dictionary; |
|
1308 |
we have to flush the caches since these methods are now void. |
|
1309 |
Also, class variables of aClass are removed." |
|
1310 |
||
1311 |
|sym cSym names oldName oldNameSym actualName wrongName| |
|
1312 |
||
1313 |
aClass isNil ifTrue:[^ self]. |
|
1314 |
||
1315 |
oldName := aClass name. |
|
1316 |
sym := oldNameSym := oldName asSymbol. |
|
1317 |
((self at:oldNameSym) == aClass) ifFalse:[ |
|
1318 |
"check other name ..." |
|
1319 |
(self includes:aClass) ifFalse:[ |
|
1320 |
'Smalltalk [warning]: no such class: ' errorPrint. oldName errorPrintCR. |
|
1321 |
^ self |
|
1322 |
]. |
|
1323 |
" |
|
1324 |
the class has changed its name - without telling me ... |
|
1325 |
what should be done in this case ? |
|
1326 |
" |
|
1327 |
'Smalltalk [warning]: class ' errorPrint. oldName errorPrint. |
|
1328 |
' has changed its name' errorPrintCR. |
|
1329 |
||
1330 |
"/ |
|
1331 |
"/ might be an alias (i.e. removing a compatibility name) |
|
1332 |
"/ |
|
1333 |
actualName := self keyAtValue:aClass. |
|
1334 |
('Smalltalk [info]: ' , oldName , ' is actually stored as ' , actualName , '.') infoPrintCR. |
|
1335 |
sym := actualName asSymbol. |
|
1336 |
oldName := actualName asString. |
|
1337 |
wrongName := true. |
|
1338 |
]. |
|
1339 |
||
1340 |
self at:sym put:nil. "nil it out for compiled accesses" |
|
1341 |
||
1342 |
"/ |
|
1343 |
"/ see comment in removeKey: on why we dont remove it here |
|
1344 |
"/ |
|
1345 |
"/ self removeKey:sym. "/ remove key - this actually fails, if there are |
|
1346 |
"/ still compiled code references." |
|
1347 |
||
1348 |
"remove private classes" |
|
1349 |
||
1350 |
aClass privateClassesSorted do:[:somePrivateClass | |
|
1351 |
aClass privateClassesAt:(somePrivateClass nameWithoutPrefix) asSymbol put:nil. |
|
1352 |
]. |
|
1353 |
||
1354 |
"remove class variables" |
|
1355 |
||
1356 |
names := aClass classVariableString asCollectionOfWords. |
|
1357 |
names do:[:name | |
|
1358 |
cSym := aClass globalKeyForClassVar:name. |
|
1359 |
self at:cSym asSymbol put:nil. |
|
1360 |
||
1361 |
"/ |
|
1362 |
"/ see comment in removeKey: on why we dont remove it here |
|
1363 |
"/ |
|
1364 |
"/ self removeKey:cSym |
|
1365 |
]. |
|
1366 |
||
1367 |
||
1368 |
"/ actually could get along with less flushing |
|
1369 |
"/ (entries for aClass and subclasses only) |
|
1370 |
"/ but we have to delay this, until we have the set of subclasses |
|
1371 |
"/ at hand - for now, searching for all subclasses is way more |
|
1372 |
"/ expensive then cache flushing. |
|
1373 |
"/ |
|
1374 |
"/ aClass allSubclassesDo:[:aSubclass | |
|
1375 |
"/ ObjectMemory flushInlineCachesForClass:aSubclass. |
|
1376 |
"/ ObjectMemory flushMethodCacheFor:aSubclass |
|
1377 |
"/ ]. |
|
1378 |
"/ ObjectMemory flushInlineCachesForClass:aClass. |
|
1379 |
"/ ObjectMemory flushMethodCacheFor:aClass |
|
1380 |
||
1381 |
ObjectMemory flushInlineCaches. |
|
1382 |
ObjectMemory flushMethodCache. |
|
1383 |
||
1384 |
aClass addChangeRecordForClassRemove. |
|
1385 |
self changed:#classRemove with:aClass. |
|
1386 |
||
1387 |
aClass setCategory:#'* removed *'. |
|
1388 |
||
1389 |
"/ self flushCachedClasses. |
|
1390 |
"/ Class flushSubclassInfo. |
|
1391 |
self flushCachedClass:aClass. |
|
1392 |
Class flushSubclassInfoFor:aClass superclass. |
|
1393 |
Class flushSubclassInfoFor:aClass. |
|
1394 |
||
1395 |
wrongName == true ifTrue:[ |
|
1396 |
"/ |
|
1397 |
"/ an alias (i.e. removing a compatibility name) |
|
1398 |
"/ |
|
1399 |
"/ check if there are more refs to it ... |
|
1400 |
[self includes:aClass] whileTrue:[ |
|
1401 |
actualName := self keyAtValue:aClass. |
|
1402 |
('Smalltalk [info]: ' , aClass name , ' is also registered under the name ' , actualName |
|
1403 |
, ' - remove that binding too.') infoPrintCR. |
|
1404 |
self at:actualName put:nil. |
|
1405 |
]. |
|
1406 |
]. |
|
1407 |
||
1408 |
"Modified: / 18-11-2006 / 17:16:31 / cg" |
|
1409 |
! |
|
1410 |
||
7563 | 1411 |
changeCategoryOf:aClass to:newCategory |
1412 |
"change a classes category, add a change record, |
|
5253
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1413 |
send change notifications" |
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1414 |
|
8405 | 1415 |
|ns oldCategory| |
1416 |
||
1417 |
oldCategory := aClass category. |
|
1418 |
oldCategory ~= newCategory ifTrue:[ |
|
18668 | 1419 |
aClass category:(newCategory withoutSeparators asSymbol). |
1420 |
||
1421 |
"notify change of category" |
|
1422 |
ns := aClass environment ? self. |
|
1423 |
ns changed:#organization with:(aClass -> oldCategory). |
|
1424 |
ns ~~ self ifTrue:[ |
|
1425 |
self changed:#organization with:(aClass -> oldCategory). |
|
1426 |
] |
|
5253
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1427 |
]. |
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1428 |
|
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1429 |
" |
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1430 |
Smalltalk changeCategoryOf:NewApplication to:#myApplications |
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1431 |
" |
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1432 |
|
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1433 |
"Modified: / 11.2.2000 / 11:36:27 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1434 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1435 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1436 |
defineNameSpace: name private: private imports: imports category: category attributes: annotations |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1437 |
NameSpace name:name |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1438 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1439 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1440 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1441 |
flushCachedClass:aClass |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1442 |
CachedClasses notNil ifTrue:[ |
18668 | 1443 |
CachedClasses remove:aClass ifAbsent:[]. |
12700 | 1444 |
]. |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1445 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1446 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1447 |
flushCachedClasses |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1448 |
CachedClasses := nil. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1449 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1450 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1451 |
Smalltalk flushCachedClasses |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1452 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1453 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1454 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1455 |
removeClass:aClass |
7563 | 1456 |
"remove the argument, aClass from the smalltalk dictionary; |
453 | 1457 |
we have to flush the caches since these methods are now void. |
18732 | 1458 |
Also, class variables of aClass are removed. |
1459 |
Recompile accessors to aClass." |
|
1460 |
||
1461 |
|oldNameSym ns ons| |
|
1462 |
||
1463 |
oldNameSym := aClass name asSymbol. |
|
4781 | 1464 |
ns := aClass nameSpace. |
1465 |
aClass topOwningClass notNil ifTrue:[ |
|
18732 | 1466 |
ons := aClass topOwningClass nameSpace |
1467 |
]. |
|
1468 |
||
1469 |
self basicRemoveClass:aClass. |
|
4724
44793fe70787
recompile ns classes after a class remove
Claus Gittinger <cg@exept.de>
parents:
4723
diff
changeset
|
1470 |
|
4781 | 1471 |
ns ~~ Smalltalk ifTrue:[ |
18732 | 1472 |
ons notNil ifTrue:[ |
1473 |
ClassBuilder |
|
1474 |
recompileGlobalAccessorsTo:oldNameSym |
|
1475 |
in:ons |
|
1476 |
except:nil |
|
1477 |
]. |
|
1478 |
(ns notNil and:[ns ~~ ons]) ifTrue:[ |
|
1479 |
ClassBuilder |
|
1480 |
recompileGlobalAccessorsTo:oldNameSym |
|
1481 |
in:ns |
|
1482 |
except:nil |
|
1483 |
]. |
|
1484 |
]. |
|
1485 |
! |
|
1486 |
||
1487 |
removeClasses:aCollectionOfClasses |
|
1488 |
"remove aCollectionOfClasses from the smalltalk dictionary; |
|
1489 |
we have to flush the caches since these methods are now void. |
|
1490 |
Also, class variables of aClass are removed. |
|
1491 |
Recompile accessors to the classes - after all classes in the collection have been removed." |
|
1492 |
||
1493 |
|tuples| |
|
1494 |
||
1495 |
tuples := aCollectionOfClasses collect:[:eachClass| |
|
1496 |
Array |
|
1497 |
with:eachClass name asSymbol |
|
1498 |
with:eachClass nameSpace |
|
1499 |
with:( |
|
1500 |
eachClass topOwningClass notNil ifTrue:[ |
|
1501 |
eachClass topOwningClass nameSpace |
|
1502 |
] ifFalse:[nil]) |
|
1503 |
]. |
|
1504 |
||
1505 |
aCollectionOfClasses do:[:eachClass| |
|
1506 |
self basicRemoveClass:eachClass. |
|
1507 |
]. |
|
1508 |
||
1509 |
tuples do:[:eachClssymNsOnsTuple| |
|
1510 |
|oldNameSym ns ons| |
|
1511 |
||
1512 |
oldNameSym := eachClssymNsOnsTuple at:1. |
|
1513 |
ns := eachClssymNsOnsTuple at:2. |
|
1514 |
ons := eachClssymNsOnsTuple at:3. |
|
1515 |
||
1516 |
ns ~~ Smalltalk ifTrue:[ |
|
1517 |
ons notNil ifTrue:[ |
|
1518 |
ClassBuilder |
|
1519 |
recompileGlobalAccessorsTo:oldNameSym |
|
1520 |
in:ons |
|
1521 |
except:nil |
|
1522 |
]. |
|
1523 |
(ns notNil and:[ns ~~ ons]) ifTrue:[ |
|
1524 |
ClassBuilder |
|
1525 |
recompileGlobalAccessorsTo:oldNameSym |
|
1526 |
in:ns |
|
1527 |
except:nil |
|
1528 |
]. |
|
1529 |
] |
|
1530 |
]. |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1531 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1532 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1533 |
renameClass:aClass to:newName |
7563 | 1534 |
"rename aClass to newName. Most of the work is in |
1525
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1535 |
renaming the classVariables (create & copy over values) |
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1536 |
and patching the classes methods to access the new variables." |
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1537 |
|
2270
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1538 |
|oldName oldSym newSym names oldCVSym newCVSym value oldNameToNewName |
3698
8bce45214d24
fixed renaming of a private class (must recompile owner)
Claus Gittinger <cg@exept.de>
parents:
3678
diff
changeset
|
1539 |
oldNameSpace newNameSpace oldBaseName newBaseName privateClasses |
5610
af0d91fe32fc
rename fixed (if it implies a nameSpace or ownership change)
Claus Gittinger <cg@exept.de>
parents:
5601
diff
changeset
|
1540 |
oldBaseNameWithoutPrefix newBaseNameWithoutPrefix i1 i2 nm ns subns |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
1541 |
oldMetaclass newMetaclass newCategory| |
5610
af0d91fe32fc
rename fixed (if it implies a nameSpace or ownership change)
Claus Gittinger <cg@exept.de>
parents:
5601
diff
changeset
|
1542 |
|
af0d91fe32fc
rename fixed (if it implies a nameSpace or ownership change)
Claus Gittinger <cg@exept.de>
parents:
5601
diff
changeset
|
1543 |
"/ check for all intermediate namespaces / owning classes |
5253
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1544 |
i1 := 1. |
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1545 |
i2 := 1. |
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1546 |
ns := self. |
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1547 |
[i2 ~~ 0] whileTrue:[ |
18668 | 1548 |
i2 := newName indexOfSubCollection:'::' startingAt:i1. |
1549 |
i2 ~~ 0 ifTrue:[ |
|
1550 |
nm := newName copyFrom:i1 to:i2-1. |
|
1551 |
ns isNameSpace ifTrue:[ |
|
1552 |
subns := ns at:nm asSymbol ifAbsent:nil. |
|
1553 |
subns isNil ifTrue:[ |
|
1554 |
self error:'Nonexisting namespace: ',nm. |
|
1555 |
^ nil. |
|
1556 |
]. |
|
1557 |
] ifFalse:[ |
|
1558 |
subns := ns privateClassesAt:nm asSymbol. |
|
1559 |
subns isNil ifTrue:[ |
|
1560 |
self error:'Cannot create a namespace below a class' |
|
1561 |
] |
|
1562 |
]. |
|
1563 |
ns := subns. |
|
1564 |
i1 := i2 + 2. |
|
1565 |
]. |
|
5253
c6b2933882fe
rename with namespace involved;
Claus Gittinger <cg@exept.de>
parents:
5247
diff
changeset
|
1566 |
]. |
617 | 1567 |
|
1568 |
oldName := aClass name. |
|
6734 | 1569 |
oldNameSpace := aClass topNameSpace. |
2319
640bb389f90a
recompile when moving classes across namespaces
Claus Gittinger <cg@exept.de>
parents:
2317
diff
changeset
|
1570 |
oldBaseName := aClass nameWithoutNameSpacePrefix. |
3698
8bce45214d24
fixed renaming of a private class (must recompile owner)
Claus Gittinger <cg@exept.de>
parents:
3678
diff
changeset
|
1571 |
oldBaseNameWithoutPrefix := aClass nameWithoutPrefix. |
617 | 1572 |
oldSym := oldName asSymbol. |
2485
9f4a11a4521f
new #privateClasses semantic
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
1573 |
privateClasses := aClass privateClassesSorted. |
2270
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1574 |
|
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1575 |
((self at:oldSym) ~~ aClass) ifTrue:[ |
18668 | 1576 |
'Smalltalk [warning]: rename failed - name is different from key' errorPrintCR. |
1577 |
^ self |
|
2270
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1578 |
]. |
617 | 1579 |
|
1525
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1580 |
"/ rename the class |
617 | 1581 |
|
1847
6e567214b167
care for className being a symbol, when renaming classes
Claus Gittinger <cg@exept.de>
parents:
1758
diff
changeset
|
1582 |
newSym := newName asSymbol. |
1525
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1583 |
|
5610
af0d91fe32fc
rename fixed (if it implies a nameSpace or ownership change)
Claus Gittinger <cg@exept.de>
parents:
5601
diff
changeset
|
1584 |
"/ change the owning class |
af0d91fe32fc
rename fixed (if it implies a nameSpace or ownership change)
Claus Gittinger <cg@exept.de>
parents:
5601
diff
changeset
|
1585 |
ns isNameSpace ifFalse:[ |
18668 | 1586 |
aClass isPrivate ifTrue:[ |
1587 |
aClass class setOwningClass:ns. |
|
1588 |
] ifFalse:[ |
|
1589 |
"/ sigh - must make a PrivateMetaclass from Metaclass |
|
1590 |
oldMetaclass := aClass class. |
|
1591 |
newMetaclass := PrivateMetaclass new. |
|
1592 |
newMetaclass flags:(oldMetaclass flags). |
|
1593 |
newMetaclass setSuperclass:(oldMetaclass superclass). |
|
1594 |
newMetaclass instSize:(oldMetaclass instSize). |
|
1595 |
newMetaclass setInstanceVariableString:(oldMetaclass instanceVariableString). |
|
1596 |
newMetaclass setMethodDictionary:(oldMetaclass methodDictionary). |
|
1597 |
newMetaclass setSoleInstance:aClass. |
|
1598 |
newMetaclass setOwningClass:ns. |
|
1599 |
||
1600 |
aClass changeClassTo:newMetaclass. |
|
1601 |
ObjectMemory flushCaches. |
|
1602 |
] |
|
5610
af0d91fe32fc
rename fixed (if it implies a nameSpace or ownership change)
Claus Gittinger <cg@exept.de>
parents:
5601
diff
changeset
|
1603 |
] ifTrue:[ |
18668 | 1604 |
aClass isPrivate ifTrue:[ |
1605 |
newCategory := aClass topOwningClass category. |
|
1606 |
||
1607 |
"/ sigh - must make a Metaclass from PrivateMetaclass |
|
1608 |
oldMetaclass := aClass class. |
|
1609 |
||
1610 |
newMetaclass := Metaclass new. |
|
1611 |
newMetaclass flags:(oldMetaclass flags). |
|
1612 |
newMetaclass setSuperclass:(oldMetaclass superclass). |
|
1613 |
newMetaclass instSize:(oldMetaclass instSize). |
|
1614 |
newMetaclass setInstanceVariableString:(oldMetaclass instanceVariableString). |
|
1615 |
newMetaclass setMethodDictionary:(oldMetaclass methodDictionary). |
|
1616 |
newMetaclass setSoleInstance:aClass. |
|
1617 |
||
1618 |
aClass category:newCategory. |
|
1619 |
aClass changeClassTo:newMetaclass. |
|
1620 |
ObjectMemory flushCaches. |
|
1621 |
] |
|
5610
af0d91fe32fc
rename fixed (if it implies a nameSpace or ownership change)
Claus Gittinger <cg@exept.de>
parents:
5601
diff
changeset
|
1622 |
]. |
af0d91fe32fc
rename fixed (if it implies a nameSpace or ownership change)
Claus Gittinger <cg@exept.de>
parents:
5601
diff
changeset
|
1623 |
|
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
1624 |
aClass setName:newSym. |
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
1625 |
|
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
1626 |
"/ store it in Smalltalk |
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
1627 |
self at:oldSym put:nil. |
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
1628 |
|
878
c09b016c6674
do not remove a global-assoc when classes are removed (see comment there)
Claus Gittinger <cg@exept.de>
parents:
857
diff
changeset
|
1629 |
"/ |
1525
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1630 |
"/ see comment in #removeKey: on why we dont remove it it here |
878
c09b016c6674
do not remove a global-assoc when classes are removed (see comment there)
Claus Gittinger <cg@exept.de>
parents:
857
diff
changeset
|
1631 |
"/ |
c09b016c6674
do not remove a global-assoc when classes are removed (see comment there)
Claus Gittinger <cg@exept.de>
parents:
857
diff
changeset
|
1632 |
"/ self removeKey:oldSym. |
617 | 1633 |
self at:newSym put:aClass. |
1634 |
||
1525
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1635 |
"/ create new class variables and copy over values |
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1636 |
|
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1637 |
oldNameToNewName := IdentityDictionary new. |
617 | 1638 |
|
1639 |
names := aClass classVariableString asCollectionOfWords. |
|
1640 |
names do:[:name | |
|
18668 | 1641 |
oldCVSym := (oldSym , ':' , name) asSymbol. |
1642 |
value := self at:oldCVSym. |
|
1643 |
self at:oldCVSym put:nil. |
|
1644 |
||
1645 |
"/ |
|
1646 |
"/ see comment in #removeKey: on why we dont remove it it here |
|
1647 |
"/ |
|
1648 |
"/ self removeKey:cSym. |
|
1649 |
||
1650 |
newCVSym := (newSym , ':' , name) asSymbol. |
|
1651 |
self at:newCVSym put:value. |
|
1652 |
||
1653 |
oldNameToNewName at:oldCVSym put:newCVSym. |
|
1525
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1654 |
]. |
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1655 |
|
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1656 |
"/ patch methods literal arrays from oldCVname to newCVname |
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1657 |
|
935b12ecf8ff
in renameClass: patch literals of all methods to access the renamed
Claus Gittinger <cg@exept.de>
parents:
1481
diff
changeset
|
1658 |
oldNameToNewName keysAndValuesDo:[:oldNameSym :newNameSym | |
18668 | 1659 |
aClass withAllSubclasses do:[:aSubClass | |
1660 |
Transcript showCR:'changing global accesses from ''' , oldNameSym , ''' into ''' , newNameSym , ''' in class: ''' , aSubClass name , ''' ...'. |
|
1661 |
aSubClass instAndClassSelectorsAndMethodsDo:[:sel :aMethod | |
|
1662 |
aMethod changeLiteral:oldNameSym to:newNameSym |
|
1663 |
]. |
|
1664 |
]. |
|
1665 |
||
1666 |
"/ and also in privateClasses ? ... |
|
2270
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1667 |
|
2485
9f4a11a4521f
new #privateClasses semantic
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
1668 |
"/ privateClasses size > 0 ifTrue:[ |
2270
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1669 |
"/ privateClasses do:[:aPrivateClass | |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1670 |
"/ aPrivateClass withAllSubclasses do:[:aSubClass | |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1671 |
"/ aSubClass class methodDictionary do:[:aMethod | |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1672 |
"/ aMethod changeLiteral:oldNameSym to:newNameSym |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1673 |
"/ ]. |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1674 |
"/ aSubClass methodDictionary do:[:aMethod | |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1675 |
"/ aMethod changeLiteral:oldNameSym to:newNameSym |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1676 |
"/ ] |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1677 |
"/ ]. |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1678 |
"/ ] |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1679 |
"/ ] |
617 | 1680 |
]. |
1681 |
||
2270
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1682 |
aClass addChangeRecordForClassRename:oldSym to:newSym. |
76c239686353
when renaming a class, also rename any private classes.
Claus Gittinger <cg@exept.de>
parents:
2249
diff
changeset
|
1683 |
|
5333
d80386e06d21
rename into other namespace did not work
Claus Gittinger <cg@exept.de>
parents:
5328
diff
changeset
|
1684 |
"/ clear the namespace (for namespace query to work) |
d80386e06d21
rename into other namespace did not work
Claus Gittinger <cg@exept.de>
parents:
5328
diff
changeset
|
1685 |
aClass setEnvironment:nil. |
6734 | 1686 |
newNameSpace := aClass topNameSpace. |
2405
939f4e751ef3
dont forget to rename private classes as well.
Claus Gittinger <cg@exept.de>
parents:
2379
diff
changeset
|
1687 |
|
2485
9f4a11a4521f
new #privateClasses semantic
Claus Gittinger <cg@exept.de>
parents:
2476
diff
changeset
|
1688 |
privateClasses size > 0 ifTrue:[ |
18668 | 1689 |
"/ must rename privateClasses as well |
1690 |
Class withoutUpdatingChangesDo:[ |
|
1691 |
privateClasses do:[:aPrivateClass | |
|
1692 |
self renameClass:aPrivateClass |
|
1693 |
to:(newSym , '::' , aPrivateClass nameWithoutPrefix). |
|
1694 |
||
1695 |
Transcript showCR:'recompiling methods in ''' , newNameSpace name , ''' accessing ''' , oldName , '::' , aPrivateClass nameWithoutPrefix , ''' ...'. |
|
1696 |
aClass theNonMetaclass recompileMethodsAccessingGlobal:(oldName , '::' , aPrivateClass nameWithoutPrefix) asSymbol. |
|
1697 |
aClass theMetaclass recompileMethodsAccessingGlobal:(oldName , '::' , aPrivateClass nameWithoutPrefix) asSymbol. |
|
1698 |
aClass theNonMetaclass recompileMethodsAccessingGlobal:(aPrivateClass nameWithoutPrefix) asSymbol. |
|
1699 |
aClass theMetaclass recompileMethodsAccessingGlobal:(aPrivateClass nameWithoutPrefix) asSymbol. |
|
9822
38acd1c5eeab
recompile methods which access private classes when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
9819
diff
changeset
|
1700 |
"/ ClassBuilder |
10071 | 1701 |
"/ recompileGlobalAccessorsTo:(oldName , '::' , aPrivateClass nameWithoutPrefix) asSymbol |
1702 |
"/ in:newNameSpace |
|
9822
38acd1c5eeab
recompile methods which access private classes when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
9819
diff
changeset
|
1703 |
"/ except:nil. |
18668 | 1704 |
] |
1705 |
] |
|
2405
939f4e751ef3
dont forget to rename private classes as well.
Claus Gittinger <cg@exept.de>
parents:
2379
diff
changeset
|
1706 |
]. |
939f4e751ef3
dont forget to rename private classes as well.
Claus Gittinger <cg@exept.de>
parents:
2379
diff
changeset
|
1707 |
|
2319
640bb389f90a
recompile when moving classes across namespaces
Claus Gittinger <cg@exept.de>
parents:
2317
diff
changeset
|
1708 |
oldNameSpace ~~ newNameSpace ifTrue:[ |
5246
2ca7b20c4108
create namespaces as requried, when renaming a class
Claus Gittinger <cg@exept.de>
parents:
5214
diff
changeset
|
1709 |
|
18668 | 1710 |
"/ all those referencing the class from the old nameSpace |
1711 |
"/ must be recompiled ... |
|
1712 |
"/ (to now access the global from smalltalk) |
|
1713 |
||
1714 |
oldNameSpace ~~ Smalltalk ifTrue:[ |
|
1715 |
Transcript showCR:'recompiling methods in ''' , oldNameSpace name , ''' accessing ''' , oldName , ''' ...'. |
|
1716 |
||
1717 |
ClassBuilder |
|
1718 |
recompileGlobalAccessorsTo:oldName asSymbol |
|
1719 |
in:oldNameSpace |
|
1720 |
except:nil. |
|
1721 |
]. |
|
1722 |
||
1723 |
"/ all referencing the class in the new namespace |
|
1724 |
"/ as well; to now access the new class. |
|
1725 |
||
1726 |
(newNameSpace notNil and:[newNameSpace ~~ Smalltalk]) ifTrue:[ |
|
1727 |
Transcript showCR:'recompiling methods in ''' , newNameSpace name , ''' accessing ''' , oldBaseName , ''' ...'. |
|
1728 |
||
1729 |
ClassBuilder |
|
1730 |
recompileGlobalAccessorsTo:oldBaseName asSymbol |
|
1731 |
in:newNameSpace |
|
1732 |
except:nil. |
|
1733 |
]. |
|
3698
8bce45214d24
fixed renaming of a private class (must recompile owner)
Claus Gittinger <cg@exept.de>
parents:
3678
diff
changeset
|
1734 |
] ifFalse:[ |
18668 | 1735 |
"/ all references to a global with my new name in my owning class |
1736 |
"/ must now be redirected to myself. |
|
1737 |
||
1738 |
aClass isPrivate ifTrue:[ |
|
1739 |
newBaseName := aClass nameWithoutNameSpacePrefix. |
|
1740 |
newBaseNameWithoutPrefix := aClass nameWithoutPrefix. |
|
1741 |
||
1742 |
Transcript showCR:'recompiling methods accessing ''' , oldBaseNameWithoutPrefix , ''' in: ''' , aClass owningClass name , ''' ...'. |
|
1743 |
aClass owningClass recompileMethodsAccessingGlobal:oldBaseNameWithoutPrefix. |
|
1744 |
aClass owningClass class recompileMethodsAccessingGlobal:oldBaseNameWithoutPrefix. |
|
1745 |
||
1746 |
Transcript showCR:'recompiling methods accessing ''' , oldBaseName , ''' in: ''' , aClass owningClass name , ''' ...'. |
|
1747 |
aClass owningClass recompileMethodsAccessingGlobal:oldBaseName. |
|
1748 |
aClass owningClass class recompileMethodsAccessingGlobal:oldBaseName. |
|
1749 |
||
1750 |
Transcript showCR:'recompiling methods accessing ''' , newBaseNameWithoutPrefix , ''' in: ''' , aClass owningClass name , ''' ...'. |
|
1751 |
aClass owningClass recompileMethodsAccessingGlobal:newBaseNameWithoutPrefix. |
|
1752 |
aClass owningClass class recompileMethodsAccessingGlobal:newBaseNameWithoutPrefix. |
|
1753 |
||
1754 |
Transcript showCR:'recompiling methods accessing ''' , newBaseName , ''' in: ''' , aClass owningClass name , ''' ...'. |
|
1755 |
aClass owningClass recompileMethodsAccessingGlobal:newBaseName. |
|
1756 |
aClass owningClass class recompileMethodsAccessingGlobal:newBaseName. |
|
1757 |
] |
|
4040
b27f87d9772d
must send a change-notifiction, when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
4028
diff
changeset
|
1758 |
]. |
b27f87d9772d
must send a change-notifiction, when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
4028
diff
changeset
|
1759 |
|
b27f87d9772d
must send a change-notifiction, when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
4028
diff
changeset
|
1760 |
aClass changed:#definition. |
b27f87d9772d
must send a change-notifiction, when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
4028
diff
changeset
|
1761 |
"/ because of the change of my superclasses name ... |
b27f87d9772d
must send a change-notifiction, when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
4028
diff
changeset
|
1762 |
aClass allSubclassesDo:[:subClass | |
18668 | 1763 |
subClass changed:#definition. |
7996
facae0a118da
when a class is renamed, add change records for all subclasses
Claus Gittinger <cg@exept.de>
parents:
7992
diff
changeset
|
1764 |
]. |
facae0a118da
when a class is renamed, add change records for all subclasses
Claus Gittinger <cg@exept.de>
parents:
7992
diff
changeset
|
1765 |
"/ because of the change of my superclasses name ... |
facae0a118da
when a class is renamed, add change records for all subclasses
Claus Gittinger <cg@exept.de>
parents:
7992
diff
changeset
|
1766 |
aClass subclassesDo:[:subClass | |
18668 | 1767 |
subClass addChangeRecordForClass:subClass. |
4040
b27f87d9772d
must send a change-notifiction, when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
4028
diff
changeset
|
1768 |
]. |
5613
b534e427f028
change message when renaming a class
Claus Gittinger <cg@exept.de>
parents:
5611
diff
changeset
|
1769 |
self changed:#definition. |
14611 | 1770 |
self changed:#classRename with:(Array with:aClass with:oldName). |
3698
8bce45214d24
fixed renaming of a private class (must recompile owner)
Claus Gittinger <cg@exept.de>
parents:
3678
diff
changeset
|
1771 |
|
9822
38acd1c5eeab
recompile methods which access private classes when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
9819
diff
changeset
|
1772 |
"Created: / 29-10-1995 / 19:58:32 / cg" |
38acd1c5eeab
recompile methods which access private classes when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
9819
diff
changeset
|
1773 |
"Modified: / 18-06-1996 / 14:20:50 / stefan" |
38acd1c5eeab
recompile methods which access private classes when renaming a class.
Claus Gittinger <cg@exept.de>
parents:
9819
diff
changeset
|
1774 |
"Modified: / 05-09-2006 / 12:52:25 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1775 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1776 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1777 |
!Smalltalk class methodsFor:'copying'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1778 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1779 |
deepCopy |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1780 |
"redefined to return self - there is only one Smalltalk dictionary" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1781 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1782 |
^ self |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1783 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1784 |
"Modified: 18.5.1996 / 12:13:33 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1785 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1786 |
|
10952 | 1787 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1788 |
"return a deep copy of the receiver. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1789 |
Redefined to return the receiver - there is only one Smalltalk dictionary" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1790 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1791 |
^ self |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1792 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1793 |
"Modified: 18.5.1996 / 12:13:36 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1794 |
! |
453 | 1795 |
|
7563 | 1796 |
shallowCopy |
1797 |
"redefined to return self - there is only one Smalltalk dictionary" |
|
617 | 1798 |
|
1799 |
^ self |
|
1410 | 1800 |
|
1801 |
"Modified: 18.5.1996 / 12:13:39 / cg" |
|
617 | 1802 |
! |
1803 |
||
7563 | 1804 |
simpleDeepCopy |
1805 |
"redefined to return self - there is only one Smalltalk dictionary" |
|
453 | 1806 |
|
1807 |
^ self |
|
1410 | 1808 |
|
1809 |
"Modified: 18.5.1996 / 12:13:42 / cg" |
|
453 | 1810 |
! ! |
1811 |
||
1750
36ff7e62388a
care for privateClasses in remove
Claus Gittinger <cg@exept.de>
parents:
1713
diff
changeset
|
1812 |
!Smalltalk class methodsFor:'debugging ST/X'! |
453 | 1813 |
|
7563 | 1814 |
compileTrace:aBoolean |
1815 |
"dump generated inline code (NOOP if VM was compiled without the trace-debug option)" |
|
7325 | 1816 |
%{ |
1817 |
extern char __compileTrace__; |
|
1818 |
||
1819 |
__compileTrace__ = (aBoolean == true) ? 1 : 0; |
|
1820 |
%} |
|
1821 |
" |
|
1822 |
Smalltalk compileTrace:true |
|
1823 |
Smalltalk compileTrace:false |
|
1824 |
" |
|
1825 |
! |
|
1826 |
||
7563 | 1827 |
debugBreakPoint |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1828 |
"{ Pragma: +optSpace }" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1829 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1830 |
"call the dummy debug function, on which a breakpoint |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1831 |
can be put in adb, sdb, dbx or gdb. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1832 |
WARNING: this method is for debugging only |
18668 | 1833 |
it will be removed without notice." |
453 | 1834 |
%{ |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1835 |
__PATCHUPCONTEXTS(__context); |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1836 |
__debugBreakPoint__(); |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1837 |
%}. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1838 |
^ self |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1839 |
! |
453 | 1840 |
|
7563 | 1841 |
exitWithCoreDump |
1842 |
"{ Pragma: +optSpace }" |
|
1843 |
||
1844 |
"abort program and dump core" |
|
1845 |
||
1846 |
OperatingSystem exitWithCoreDump |
|
4096
d292495070db
exitWithCoreDump was duplicate
Claus Gittinger <cg@exept.de>
parents:
4067
diff
changeset
|
1847 |
"/ never returns |
d292495070db
exitWithCoreDump was duplicate
Claus Gittinger <cg@exept.de>
parents:
4067
diff
changeset
|
1848 |
|
d292495070db
exitWithCoreDump was duplicate
Claus Gittinger <cg@exept.de>
parents:
4067
diff
changeset
|
1849 |
"Be careful evaluating this |
d292495070db
exitWithCoreDump was duplicate
Claus Gittinger <cg@exept.de>
parents:
4067
diff
changeset
|
1850 |
Smalltalk exitWithCoreDump |
d292495070db
exitWithCoreDump was duplicate
Claus Gittinger <cg@exept.de>
parents:
4067
diff
changeset
|
1851 |
" |
617 | 1852 |
! |
1853 |
||
7563 | 1854 |
fatalAbort |
1855 |
"{ Pragma: +optSpace }" |
|
1856 |
||
1857 |
"report a fatal-error, print a stack backtrace and exit with core dump. |
|
617 | 1858 |
(You may turn off the stack print with debugPrinting:false)" |
18287 | 1859 |
|
1860 |
self fatalAbort:'fatalAbort' |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1861 |
! |
617 | 1862 |
|
7563 | 1863 |
fatalAbort:aMessage |
1864 |
"{ Pragma: +optSpace }" |
|
1865 |
||
1866 |
"report a fatal-error; print a stack backtrace and exit with core dump |
|
617 | 1867 |
(You may turn off the stack print with debugPrinting:false)" |
1868 |
||
1869 |
%{ |
|
18287 | 1870 |
#ifdef __SCHTEAM__ |
1871 |
STMain.fatalAbort( aMessage ); |
|
1872 |
/* NOT REACHED */ |
|
1873 |
#else |
|
617 | 1874 |
char *msg; |
1875 |
||
12481
805176d238d2
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
12413
diff
changeset
|
1876 |
if (__isStringLike(aMessage)) |
18668 | 1877 |
msg = (char *) __stringVal(aMessage); |
617 | 1878 |
else |
18668 | 1879 |
msg = "fatalAbort"; |
617 | 1880 |
|
1881 |
__fatal0(__context, msg); |
|
1882 |
/* NEVER RETURNS */ |
|
18287 | 1883 |
#endif |
5410 | 1884 |
%}. |
1885 |
^ self primitiveFailed |
|
5441 | 1886 |
! |
1887 |
||
13135
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1888 |
ignoreHalt |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1889 |
"return true, if halts are ignored. |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1890 |
Usually, this is done in standAlone applications" |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1891 |
|
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1892 |
IgnoreHalt isNil ifTrue:[ |
18668 | 1893 |
^ self isStandAloneApp |
13135
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1894 |
]. |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1895 |
^ IgnoreHalt |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1896 |
|
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1897 |
"Created: / 18-11-2010 / 11:20:16 / cg" |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1898 |
! |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1899 |
|
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1900 |
ignoreHalt:aBoolean |
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
1901 |
"control if halts are to be ignored; |
13135
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1902 |
usually, this is done in standAlone applications" |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1903 |
|
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1904 |
IgnoreHalt := aBoolean |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1905 |
|
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1906 |
" |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1907 |
Smalltalk ignoreHalt:true. |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1908 |
self halt. |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1909 |
Smalltalk ignoreHalt:false. |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1910 |
self halt. |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1911 |
" |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1912 |
|
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1913 |
"Created: / 18-11-2010 / 11:20:27 / cg" |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1914 |
! |
1031ffdd98fd
ignoreHalt is now a classVar
Claus Gittinger <cg@exept.de>
parents:
13129
diff
changeset
|
1915 |
|
18329 | 1916 |
verbose |
1917 |
^ Verbose |
|
1918 |
! |
|
1919 |
||
1920 |
verbose:aBoolean |
|
1921 |
Verbose := aBoolean |
|
1922 |
! |
|
1923 |
||
7563 | 1924 |
vmInstructionTrace:aBoolean |
13947 | 1925 |
self halt:'not yet implemented' |
1926 |
||
1927 |
"Modified: / 19-01-2012 / 10:15:35 / cg" |
|
7563 | 1928 |
! ! |
1929 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1930 |
!Smalltalk class methodsFor:'enumerating'! |
7563 | 1931 |
|
453 | 1932 |
allBehaviorsDo:aBlock |
5580
374e843aa424
allBehaviorsDo now enumerates both classes and metaclasses
Claus Gittinger <cg@exept.de>
parents:
5579
diff
changeset
|
1933 |
"evaluate the argument, aBlock for all classes and metaclasses in the system" |
374e843aa424
allBehaviorsDo now enumerates both classes and metaclasses
Claus Gittinger <cg@exept.de>
parents:
5579
diff
changeset
|
1934 |
|
374e843aa424
allBehaviorsDo now enumerates both classes and metaclasses
Claus Gittinger <cg@exept.de>
parents:
5579
diff
changeset
|
1935 |
self allClassesAndMetaclassesDo:aBlock |
453 | 1936 |
|
1937 |
" |
|
2588
090cf1da8036
handle abort signal in readEvalPrint loop
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
1938 |
Smalltalk allBehaviorsDo:[:aClass | aClass name printCR] |
453 | 1939 |
" |
7563 | 1940 |
! |
1941 |
||
1942 |
allClassCategories |
|
1943 |
"return a set of all class categories in the system" |
|
1944 |
||
1945 |
|allCategories| |
|
6217
e0f4f3959c49
reuse allClassesInCategory-stuff
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
1946 |
|
e0f4f3959c49
reuse allClassesInCategory-stuff
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
1947 |
allCategories := Set new. |
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
1948 |
Smalltalk allClassesDo:[:cls | |
18668 | 1949 |
|category| |
1950 |
||
1951 |
category := cls category. |
|
1952 |
category notNil ifTrue:[ |
|
1953 |
allCategories add:category. |
|
1954 |
]. |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1955 |
]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1956 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1957 |
^ allCategories. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1958 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1959 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1960 |
Smalltalk allClassCategories |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1961 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1962 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1963 |
"Created: / 17.11.2001 / 12:13:09 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1964 |
! |
6217
e0f4f3959c49
reuse allClassesInCategory-stuff
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
1965 |
|
7563 | 1966 |
allClassesAndMetaclassesDo:aBlock |
1967 |
"evaluate the argument, aBlock for all classes and metaclasses in the system." |
|
5579
26af506d271e
added #allClassesAndMetaclasses
Claus Gittinger <cg@exept.de>
parents:
5550
diff
changeset
|
1968 |
|
5940
804fb27727a6
oops - allClassesAndMetaclassesDo: evaluated block twice for
Claus Gittinger <cg@exept.de>
parents:
5916
diff
changeset
|
1969 |
|already| |
804fb27727a6
oops - allClassesAndMetaclassesDo: evaluated block twice for
Claus Gittinger <cg@exept.de>
parents:
5916
diff
changeset
|
1970 |
|
12861 | 1971 |
already := IdentitySet new:NumberOfClassesHint*2. |
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
1972 |
self allClassesDo:[:eachClass | |
18668 | 1973 |
|cls| |
1974 |
||
1975 |
cls := eachClass theNonMetaclass. |
|
1976 |
(already includes:cls) ifFalse:[ |
|
1977 |
aBlock value:cls. |
|
1978 |
already add:cls. |
|
1979 |
]. |
|
1980 |
cls := cls class. |
|
1981 |
(already includes:cls) ifFalse:[ |
|
1982 |
aBlock value:cls. |
|
1983 |
already add:cls. |
|
1984 |
]. |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1985 |
]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
1986 |
! |
5579
26af506d271e
added #allClassesAndMetaclasses
Claus Gittinger <cg@exept.de>
parents:
5550
diff
changeset
|
1987 |
|
7563 | 1988 |
allClassesDo:aBlock |
1989 |
"evaluate the argument, aBlock for all classes in the system." |
|
5580
374e843aa424
allBehaviorsDo now enumerates both classes and metaclasses
Claus Gittinger <cg@exept.de>
parents:
5579
diff
changeset
|
1990 |
|
5765 | 1991 |
self allClasses do:aBlock |
453 | 1992 |
|
1993 |
" |
|
2588
090cf1da8036
handle abort signal in readEvalPrint loop
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
1994 |
Smalltalk allClassesDo:[:aClass | aClass name printCR] |
453 | 1995 |
" |
1996 |
! |
|
1997 |
||
9506 | 1998 |
allClassesForWhich:filter |
10071 | 1999 |
"return a collection with all classes in the system, |
9506 | 2000 |
for which filter evaluates to true." |
2001 |
||
2002 |
|collectedClasses| |
|
2003 |
||
2004 |
collectedClasses := OrderedCollection new. |
|
2005 |
self allClassesForWhich:filter do:[:cls | |
|
18668 | 2006 |
collectedClasses add:cls |
9506 | 2007 |
]. |
2008 |
^ collectedClasses |
|
2009 |
||
2010 |
" |
|
10071 | 2011 |
Smalltalk |
18668 | 2012 |
allClassesForWhich:[:cls | cls name startsWith:'Po'] |
9506 | 2013 |
" |
2014 |
||
2015 |
"Created: / 10-08-2006 / 12:11:31 / cg" |
|
2016 |
! |
|
2017 |
||
9292 | 2018 |
allClassesForWhich:filter do:aBlock |
2019 |
"evaluate the argument, aBlock for all classes in the system, for which filter evaluates to true." |
|
2020 |
||
2021 |
self allClassesDo:[:cls | |
|
18668 | 2022 |
(filter value:cls) ifTrue:[ aBlock value:cls ]. |
10071 | 2023 |
]. |
2024 |
||
2025 |
" |
|
2026 |
Smalltalk |
|
18668 | 2027 |
allClassesForWhich:[:cls | cls name startsWith:'Po'] |
2028 |
do:[:aClass | Transcript showCR:aClass name] |
|
9292 | 2029 |
" |
2030 |
! |
|
2031 |
||
7563 | 2032 |
allClassesInCategory:aCategory |
2033 |
"return a collection of for all classes in aCategory; |
|
1299 | 2034 |
The order of the classes is not defined." |
2035 |
||
9506 | 2036 |
^ self allClassesForWhich:[:cls | cls category = aCategory] |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2037 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2038 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2039 |
Smalltalk allClassesInCategory:'Views-Basic' |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2040 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2041 |
|
9506 | 2042 |
"Modified: / 10-08-2006 / 12:13:32 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2043 |
! |
1299 | 2044 |
|
7563 | 2045 |
allClassesInCategory:aCategory do:aBlock |
2046 |
"evaluate the argument, aBlock for all classes in the aCategory; |
|
453 | 2047 |
The order of the classes is not defined." |
2048 |
||
2049 |
aCategory notNil ifTrue:[ |
|
18668 | 2050 |
self allClassesForWhich:[:cls | cls category = aCategory] do:aBlock |
453 | 2051 |
] |
2052 |
||
2053 |
" |
|
9490 | 2054 |
Smalltalk allClassesInCategory:'Views-Basic' do:[:aClass | Transcript showCR:aClass] |
2055 |
" |
|
2056 |
||
2057 |
"Modified: / 09-08-2006 / 17:18:50 / fm" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2058 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2059 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2060 |
allClassesInCategory:aCategory inOrderDo:aBlock |
7563 | 2061 |
"evaluate the argument, aBlock for all classes in aCategory; |
453 | 2062 |
superclasses come first - then subclasses" |
2063 |
||
2064 |
|classes| |
|
2065 |
||
2066 |
aCategory notNil ifTrue:[ |
|
18668 | 2067 |
classes := OrderedCollection new. |
2068 |
self allClassesInCategory:aCategory do:[:aClass | |
|
2069 |
classes add:aClass |
|
2070 |
]. |
|
2071 |
classes topologicalSort:[:a :b | b isSubclassOf:a]. |
|
2072 |
classes do:aBlock |
|
453 | 2073 |
] |
2074 |
||
2075 |
" |
|
2588
090cf1da8036
handle abort signal in readEvalPrint loop
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
2076 |
Smalltalk allClassesInCategory:'Views-Basic' inOrderDo:[:aClass | aClass name printCR] |
453 | 2077 |
" |
6217
e0f4f3959c49
reuse allClassesInCategory-stuff
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
2078 |
|
e0f4f3959c49
reuse allClassesInCategory-stuff
Claus Gittinger <cg@exept.de>
parents:
6188
diff
changeset
|
2079 |
"Modified: / 17.11.2001 / 12:18:15 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2080 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2081 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2082 |
allClassesInOrderDo:aBlock |
7563 | 2083 |
"evaluate the argument, aBlock for all classes in the system; |
5406 | 2084 |
Evaluation order is by inheritance: superclasses come first." |
2085 |
||
2086 |
|already| |
|
2087 |
||
8964
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
2088 |
already := IdentitySet new:NumberOfClassesHint. |
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
2089 |
self allClassesDo:[:eachClass | |
18668 | 2090 |
(already includes:eachClass) ifFalse:[ |
2091 |
eachClass allSuperclasses reverseDo:[:eachSuperClass | |
|
2092 |
(already includes:eachSuperClass) ifFalse:[ |
|
2093 |
already add:eachSuperClass. |
|
2094 |
aBlock value:eachSuperClass. |
|
2095 |
]. |
|
2096 |
]. |
|
2097 |
already add:eachClass. |
|
2098 |
aBlock value:eachClass. |
|
2099 |
] |
|
8964
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
2100 |
]. |
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
2101 |
|
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
2102 |
" |
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
2103 |
Smalltalk allClassesInOrderDo:[:aClass | Transcript showCR:aClass name] |
5406 | 2104 |
" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2105 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2106 |
|
9506 | 2107 |
allClassesInPackage:aPackageID |
2108 |
"evaluate the argument, aBlock for all classes a package; |
|
10087 | 2109 |
The order of the classes is not defined. |
2110 |
The returned collection may include private classes" |
|
9506 | 2111 |
|
2112 |
^ self allClassesForWhich:[:cls | cls package = aPackageID] |
|
2113 |
||
2114 |
" |
|
10071 | 2115 |
Smalltalk allClassesInPackage:'bosch:dapasx' |
9506 | 2116 |
" |
2117 |
||
2118 |
"Created: / 10-08-2006 / 12:14:10 / cg" |
|
10087 | 2119 |
"Modified: / 12-10-2006 / 23:48:43 / cg" |
9506 | 2120 |
! |
2121 |
||
9490 | 2122 |
allClassesInPackage:aPackageID do:aBlock |
2123 |
"evaluate the argument, aBlock for all classes a package; |
|
2124 |
The order of the classes is not defined." |
|
2125 |
||
2126 |
^ self allClassesForWhich:[:cls | cls package = aPackageID] do:aBlock |
|
2127 |
||
2128 |
" |
|
10071 | 2129 |
Smalltalk allClassesInPackage:'bosch:dapasx' do:[:aClass | Transcript showCR:aClass] |
9490 | 2130 |
" |
2131 |
||
2132 |
"Created: / 09-08-2006 / 17:14:17 / fm" |
|
2133 |
! |
|
2134 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2135 |
allKeysDo:aBlock |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2136 |
"evaluate the argument, aBlock for all keys in the Smalltalk dictionary" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2137 |
|
17385 | 2138 |
self keysDo:aBlock |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2139 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2140 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2141 |
allMethodCategories |
12298 | 2142 |
"return a set of all method-categories (protocols) in the system" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2143 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2144 |
|allCategories| |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2145 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2146 |
allCategories := Set new. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2147 |
Smalltalk allClassesDo:[:cls | |
18668 | 2148 |
allCategories addAll:cls categories. |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2149 |
]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2150 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2151 |
^ allCategories. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2152 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2153 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2154 |
Smalltalk allMethodCategories |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2155 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2156 |
! |
6722
8388292bc41d
allClassesImplementing & allMethodCategories
Claus Gittinger <cg@exept.de>
parents:
6715
diff
changeset
|
2157 |
|
9259 | 2158 |
allMethodsDo:aBlock |
12298 | 2159 |
"enumerate all methods in all classes" |
12000 | 2160 |
|
9259 | 2161 |
Smalltalk allClassesDo:[:eachClass | |
18668 | 2162 |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | |
2163 |
aBlock value:mthd |
|
2164 |
] |
|
12298 | 2165 |
]. |
2166 |
! |
|
2167 |
||
14933 | 2168 |
allMethodsForWhich:aBlock |
2169 |
"return a collection of methods for which aBlock returns true" |
|
2170 |
||
2171 |
|coll| |
|
2172 |
||
2173 |
coll := OrderedCollection new. |
|
2174 |
Smalltalk allClassesDo:[:eachClass | |
|
18668 | 2175 |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | |
2176 |
(aBlock value:mthd) ifTrue:[ |
|
2177 |
coll add:mthd |
|
2178 |
]. |
|
2179 |
] |
|
14933 | 2180 |
]. |
2181 |
^ coll |
|
2182 |
! |
|
2183 |
||
12300
e72e90ea410f
changed: #allMethodsWithSelectorDo:
Claus Gittinger <cg@exept.de>
parents:
12299
diff
changeset
|
2184 |
allMethodsWithSelectorDo:aTwoArgBlock |
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
2185 |
"enumerate all methods in all classes and evaluate aBlock |
12300
e72e90ea410f
changed: #allMethodsWithSelectorDo:
Claus Gittinger <cg@exept.de>
parents:
12299
diff
changeset
|
2186 |
with method and selector as arguments." |
12299
3ed13f5685b9
added: #allMethodsForWhich:do:
Claus Gittinger <cg@exept.de>
parents:
12298
diff
changeset
|
2187 |
|
3ed13f5685b9
added: #allMethodsForWhich:do:
Claus Gittinger <cg@exept.de>
parents:
12298
diff
changeset
|
2188 |
Smalltalk allClassesDo:[:eachClass | |
18668 | 2189 |
eachClass instAndClassSelectorsAndMethodsDo:[:sel :mthd | |
2190 |
aTwoArgBlock value:mthd value:sel |
|
2191 |
] |
|
12299
3ed13f5685b9
added: #allMethodsForWhich:do:
Claus Gittinger <cg@exept.de>
parents:
12298
diff
changeset
|
2192 |
]. |
3ed13f5685b9
added: #allMethodsForWhich:do:
Claus Gittinger <cg@exept.de>
parents:
12298
diff
changeset
|
2193 |
! |
3ed13f5685b9
added: #allMethodsForWhich:do:
Claus Gittinger <cg@exept.de>
parents:
12298
diff
changeset
|
2194 |
|
7563 | 2195 |
associationsDo:aBlock |
10071 | 2196 |
"evaluate the argument, aBlock for all key/value pairs |
617 | 2197 |
in the Smalltalk dictionary" |
2198 |
||
2199 |
self keysDo:[:aKey | |
|
18668 | 2200 |
aBlock value:(aKey -> (self at:aKey)) |
617 | 2201 |
] |
2202 |
||
2588
090cf1da8036
handle abort signal in readEvalPrint loop
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
2203 |
"Smalltalk associationsDo:[:assoc | assoc printCR]" |
617 | 2204 |
! |
2205 |
||
7563 | 2206 |
basicKeys |
2207 |
"for rel > 5 only" |
|
2208 |
||
18349 | 2209 |
%{ |
2210 |
#ifdef __SCHTEAM__ |
|
18668 | 2211 |
STObject[] keys = STSmalltalkEnvironment.GetKeyVector(); |
18349 | 2212 |
return __c__._RETURN( new STVector(keys) ); |
2213 |
#endif |
|
2214 |
%}. |
|
7563 | 2215 |
self primitiveFailed |
2216 |
! |
|
2217 |
||
2218 |
do:aBlock |
|
2219 |
"evaluate the argument, aBlock for all values in the Smalltalk dictionary" |
|
617 | 2220 |
|
2221 |
|work| |
|
2222 |
||
2223 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1682
diff
changeset
|
2224 |
__GLOBALS_DO(&aBlock, &work); |
5406 | 2225 |
RETURN (self); |
2226 |
%}. |
|
2227 |
self keysDo:[:aKey | |
|
18668 | 2228 |
aBlock value:(self at:aKey) |
5406 | 2229 |
] |
617 | 2230 |
! |
2231 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2232 |
keysAndValuesDo:aBlock |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2233 |
"evaluate the two-arg block, aBlock for all keys and values" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2234 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2235 |
self keysDo:[:aKey | |
18668 | 2236 |
aBlock value:aKey value:(self at:aKey) |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2237 |
] |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2238 |
! |
617 | 2239 |
|
9077
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2240 |
keysAndValuesSelect:selectBlockWith2Args thenCollect:collectBlockWith2Args |
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2241 |
|collected| |
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2242 |
|
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2243 |
collected := OrderedCollection new. |
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2244 |
self keysAndValuesDo:[:eachKey :eachValue | |
18668 | 2245 |
(selectBlockWith2Args value:eachKey value:eachValue) ifTrue:[ |
2246 |
collected add:(collectBlockWith2Args value:eachKey value:eachValue) |
|
2247 |
]. |
|
9077
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2248 |
]. |
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2249 |
^ collected |
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2250 |
|
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2251 |
" |
10071 | 2252 |
Smalltalk |
18668 | 2253 |
keysAndValuesSelect:[:nm :val | (nm startsWith:'Ab') and:[val notNil]] |
2254 |
thenCollect:[:nm :val | nm] |
|
9077
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2255 |
" |
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2256 |
! |
327b64542a83
+keysAndValuesSelect:thenCollect:
Claus Gittinger <cg@exept.de>
parents:
9054
diff
changeset
|
2257 |
|
7563 | 2258 |
keysDo:aBlock |
2259 |
"evaluate the argument, aBlock for all keys in the Smalltalk dictionary" |
|
617 | 2260 |
|work| |
2261 |
||
2262 |
%{ /* NOREGISTER - work may not be placed into a register here */ |
|
1688
8a42db1eea60
removed all COMMA_CON / CON_COMMA uses
Claus Gittinger <cg@exept.de>
parents:
1682
diff
changeset
|
2263 |
__GLOBALKEYS_DO(&aBlock, &work); |
5406 | 2264 |
RETURN (self); |
2265 |
%}. |
|
2266 |
self basicKeys do:[:aKey | |
|
18668 | 2267 |
aBlock value:aKey |
5406 | 2268 |
] |
453 | 2269 |
! ! |
2270 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2271 |
!Smalltalk class methodsFor:'message control'! |
453 | 2272 |
|
7563 | 2273 |
silentLoading |
12408 | 2274 |
"returns the Silentloading class variable, which globally controls if compilation |
2275 |
messages are shown on the transcript during a fileIn." |
|
7563 | 2276 |
|
10355
b1cb807fd03c
Make sure, that #silentLoading does not return nil
Stefan Vogel <sv@exept.de>
parents:
10329
diff
changeset
|
2277 |
^ SilentLoading ? false |
7563 | 2278 |
! |
2279 |
||
2280 |
silentLoading:aBoolean |
|
2281 |
"{ Pragma: +optSpace }" |
|
2282 |
||
2283 |
"allows access to the Silentloading class variable, which controls |
|
12408 | 2284 |
messages (especially during fileIn) onto the transcript. |
453 | 2285 |
You can save a snapshot with this flag set to true, which makes |
2286 |
the image come up silent. Can also be set, to read in files unlogged." |
|
2287 |
||
2288 |
|prev| |
|
2289 |
||
2290 |
prev := SilentLoading. |
|
2291 |
SilentLoading := aBoolean. |
|
2292 |
^ prev |
|
12409 | 2293 |
! |
2294 |
||
2295 |
silentlyLoadingDo:aBlock |
|
2296 |
"evaluates aBlock with silent loading on - no compilation messages (except errors) |
|
2297 |
are shown on the transcript" |
|
2298 |
||
2299 |
|sav| |
|
2300 |
||
2301 |
sav := SilentLoading. |
|
2302 |
SilentLoading := true. |
|
2303 |
aBlock ensure:[ SilentLoading := sav ]. |
|
453 | 2304 |
! ! |
2305 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2306 |
!Smalltalk class methodsFor:'misc accessing'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2307 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2308 |
beHeadless:aBoolean |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2309 |
"set/clear the headlessOperation flag." |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2310 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2311 |
HeadlessOperation := aBoolean |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2312 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2313 |
|
10231 | 2314 |
beSTScript:aBoolean |
2315 |
"set/clear the isSTScript flag." |
|
2316 |
||
2317 |
IsSTScript := aBoolean |
|
2318 |
||
2319 |
"Created: / 06-12-2006 / 16:43:36 / cg" |
|
2320 |
! |
|
2321 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2322 |
standAloneApp:aBoolean |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2323 |
"set/clear the StandAlone flag." |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2324 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2325 |
StandAlone := aBoolean |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2326 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2327 |
|
18197 | 2328 |
|
12250 | 2329 |
!Smalltalk class methodsFor:'private-system management-packages'! |
2330 |
||
17324 | 2331 |
basicLoadPackage:aPackageString fromDirectory:packageDirOrStringOrNil asAutoloaded:doLoadAsAutoloaded |
2332 |
"load a package referenced by aPackageString - a string like 'stx:libbasic'. |
|
2333 |
The package is either located in packageDirOrStringOrNil, or in the current directory (if nil). |
|
2334 |
Answer true, if the load succeeded, false if it failed" |
|
2335 |
||
19589 | 2336 |
|packageDirOrNil binaryClassLibraryFilename projectDefinitionFilename |
2337 |
projectDefinitionClass projectDefinitionClassName silent somethingHasBeenLoaded |
|
2338 |
loadOK errorInInitialize| |
|
17324 | 2339 |
|
2340 |
packageDirOrStringOrNil notNil ifTrue:[ |
|
19589 | 2341 |
packageDirOrNil := packageDirOrStringOrNil asFilename. |
2342 |
]. |
|
2343 |
silent := VerboseLoading not |
|
2344 |
and:[SilentLoading or:[StandAlone or:[InfoPrinting not]]]. |
|
17324 | 2345 |
|
2346 |
"For now: have to read the project definition first!! |
|
2347 |
The class library may contain subclasses of classes in prerequisite packages - |
|
19589 | 2348 |
so the prerequisite packages have to be loaded first. |
2349 |
Normally there is a project definiton, use that one to pull in the rest" |
|
17324 | 2350 |
|
2351 |
"maybe, it is already in the image" |
|
2352 |
projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageString. |
|
19906 | 2353 |
projectDefinitionClass notNil ifTrue:[ |
2354 |
projectDefinitionClass checkForLoad. |
|
17324 | 2355 |
]. |
2356 |
||
2357 |
"Is there a shared library (.dll or .so) ?" |
|
17439
1928276a394c
added class variable IgnoreAssertions
Claus Gittinger <cg@exept.de>
parents:
17438
diff
changeset
|
2358 |
binaryClassLibraryFilename := ObjectFileLoader |
19589 | 2359 |
binaryClassFilenameForPackage:aPackageString |
2360 |
inDirectory:packageDirOrNil. |
|
17324 | 2361 |
|
2362 |
(binaryClassLibraryFilename notNil and:[binaryClassLibraryFilename exists]) ifTrue:[ |
|
19589 | 2363 |
|loadErrorOccurred| |
2364 |
||
2365 |
loadErrorOccurred := false. |
|
2366 |
ObjectFileLoader objectFileLoadErrorNotification handle:[:ex | |
|
2367 |
loadErrorOccurred := true. |
|
2368 |
ex proceedWith:true. |
|
2369 |
] do:[ |
|
2370 |
loadOK := (ObjectFileLoader loadObjectFile:binaryClassLibraryFilename) notNil. |
|
2371 |
"/ loadOK := self loadPackage:aPackageString fromClassLibrary:binaryClassLibraryFilename. |
|
2372 |
]. |
|
2373 |
(loadOK and:[loadErrorOccurred not]) ifTrue:[ |
|
2374 |
"now, all compiled classes have been loaded. |
|
2375 |
keep classes in the package which are autoloaded as autoloaded." |
|
2376 |
^ true |
|
2377 |
]. |
|
2378 |
||
2379 |
loadErrorOccurred ifTrue:[ |
|
2380 |
self breakPoint:#cg. |
|
2381 |
projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageString. |
|
2382 |
projectDefinitionClass notNil ifTrue:[ |
|
19907 | 2383 |
projectDefinitionClass |
2384 |
checkForLoad; |
|
2385 |
loadPreRequisitesAsAutoloaded:doLoadAsAutoloaded. |
|
19589 | 2386 |
]. |
2387 |
]. |
|
17324 | 2388 |
]. |
2389 |
packageDirOrNil isNil ifTrue:[ |
|
19589 | 2390 |
^ PackageNotFoundError raiseRequestWith:aPackageString. |
17324 | 2391 |
]. |
2392 |
||
2393 |
"fallback - go through the project definition" |
|
2394 |
projectDefinitionClass isNil ifTrue:[ |
|
19589 | 2395 |
projectDefinitionClassName := ProjectDefinition projectDefinitionClassNameForDefinitionOf:aPackageString. |
2396 |
"/ try to load the project definition class |
|
2397 |
projectDefinitionFilename := (packageDirOrNil / projectDefinitionClassName) withSuffix:'st'. |
|
2398 |
projectDefinitionFilename exists ifFalse:[ |
|
2399 |
projectDefinitionFilename := (packageDirOrNil / 'source' / projectDefinitionClassName) withSuffix:'st'. |
|
2400 |
]. |
|
2401 |
projectDefinitionFilename exists ifTrue:[ |
|
2402 |
Class withoutUpdatingChangesDo:[ |
|
2403 |
Smalltalk silentlyLoadingDo:[ |
|
2404 |
Error handle:[:ex | |
|
2405 |
"/ catch error during initialization; |
|
2406 |
ex suspendedContext withAllSendersDo:[:sender | |
|
2407 |
(sender selector == #initialize |
|
2408 |
and:[sender receiver isBehavior |
|
2409 |
and:[sender receiver name = projectDefinitionClassName]] |
|
2410 |
) ifTrue:[ |
|
2411 |
errorInInitialize := true |
|
2412 |
]. |
|
2413 |
]. |
|
2414 |
errorInInitialize ifFalse:[ ex reject ]. |
|
2415 |
] do:[ |
|
2416 |
projectDefinitionFilename fileIn. |
|
2417 |
]. |
|
2418 |
]. |
|
2419 |
]. |
|
2420 |
errorInInitialize ifTrue:[ |
|
2421 |
Transcript showCR:'Smalltalk [warning]: an error happened in #initialize - retry after loading package.'. |
|
2422 |
]. |
|
2423 |
projectDefinitionClass := ProjectDefinition definitionClassForPackage:aPackageString. |
|
2424 |
]. |
|
17324 | 2425 |
]. |
2426 |
projectDefinitionClass notNil ifTrue:[ |
|
19906 | 2427 |
projectDefinitionClass |
2428 |
autoload; |
|
2429 |
checkForLoad; |
|
2430 |
loadPreRequisitesAsAutoloaded:doLoadAsAutoloaded. |
|
2431 |
||
19589 | 2432 |
somethingHasBeenLoaded := projectDefinitionClass loadAsAutoloaded:doLoadAsAutoloaded. |
2433 |
errorInInitialize ifTrue:[ |
|
2434 |
Transcript showCR:('Smalltalk [info]: retrying #initialize'). |
|
2435 |
projectDefinitionClass initialize. |
|
2436 |
]. |
|
2437 |
(silent not and:[somethingHasBeenLoaded]) ifTrue:[ |
|
2438 |
Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageString , ' from project definition'). |
|
2439 |
]. |
|
2440 |
^ true. |
|
17324 | 2441 |
]. |
2442 |
||
2443 |
"/ source files-file loading no longer supported |
|
2444 |
"/ however, allow for autoload-stub loaded |
|
2445 |
doLoadAsAutoloaded ifTrue:[ |
|
19589 | 2446 |
self |
2447 |
recursiveInstallAutoloadedClassesFrom:packageDirOrNil |
|
2448 |
rememberIn:Set new |
|
2449 |
maxLevels:2 |
|
2450 |
noAutoload:false |
|
2451 |
packageTop:packageDirOrNil |
|
2452 |
showSplashInLevels:0. |
|
2453 |
^ true |
|
17324 | 2454 |
]. |
2455 |
||
2456 |
^ PackageNotFoundError raiseRequestWith:aPackageString errorString:' - no projectDef, dll or loadAll found'. |
|
2457 |
||
2458 |
" |
|
2459 |
Smalltalk loadPackageWithId:'stx:libbasic' |
|
2460 |
Smalltalk loadPackageWithId:'stx:goodies/persistency' |
|
2461 |
Smalltalk loadPackageWithId:'exept:ctypes' |
|
2462 |
" |
|
2463 |
||
2464 |
"Modified: / 29-07-2011 / 19:55:35 / cg" |
|
2465 |
! |
|
2466 |
||
12250 | 2467 |
loadExtensionsForPackage:aPackageId |
13415 | 2468 |
| extensionsLoaded | |
13621
85297bc6cfa8
comment/format in: #loadExtensionsForPackage:
Claus Gittinger <cg@exept.de>
parents:
13602
diff
changeset
|
2469 |
|
13415 | 2470 |
extensionsLoaded := false. |
18924 | 2471 |
ProgrammingLanguage allDo:[:programmingLanguage| |
19856 | 2472 |
"/ evaluating or here - want all extensions to be loaded |
18924 | 2473 |
extensionsLoaded := extensionsLoaded | (self loadExtensionsForPackage:aPackageId language: programmingLanguage) |
13621
85297bc6cfa8
comment/format in: #loadExtensionsForPackage:
Claus Gittinger <cg@exept.de>
parents:
13602
diff
changeset
|
2474 |
]. |
85297bc6cfa8
comment/format in: #loadExtensionsForPackage:
Claus Gittinger <cg@exept.de>
parents:
13602
diff
changeset
|
2475 |
^ extensionsLoaded |
13415 | 2476 |
|
2477 |
"Modified: / 18-02-2007 / 11:03:26 / cg" |
|
2478 |
"Modified: / 02-01-2010 / 10:43:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13621
85297bc6cfa8
comment/format in: #loadExtensionsForPackage:
Claus Gittinger <cg@exept.de>
parents:
13602
diff
changeset
|
2479 |
"Modified (format): / 04-09-2011 / 09:19:24 / cg" |
13415 | 2480 |
! |
2481 |
||
18924 | 2482 |
loadExtensionsForPackage:aPackageId language: programmingLanguage |
13771 | 2483 |
|mgr packageDirName inStream projectDefinition extensionsFilename mod dir |
13621
85297bc6cfa8
comment/format in: #loadExtensionsForPackage:
Claus Gittinger <cg@exept.de>
parents:
13602
diff
changeset
|
2484 |
extensionsRevisionString extensionsRevisionInfo| |
12250 | 2485 |
|
18924 | 2486 |
programmingLanguage supportsExtensionMethods ifFalse:[^false]. |
13415 | 2487 |
|
12250 | 2488 |
packageDirName := aPackageId copyReplaceAll:$: with:$/. |
2489 |
packageDirName := self getPackageFileName:packageDirName. |
|
2490 |
||
2491 |
(packageDirName notNil and:[Class tryLocalSourceFirst]) ifTrue:[ |
|
18924 | 2492 |
(self loadExtensionsFromDirectory:packageDirName language: programmingLanguage) ifTrue:[ |
2493 |
^ true. |
|
2494 |
]. |
|
2495 |
packageDirName := nil. "do not try again" |
|
12250 | 2496 |
]. |
2497 |
||
2498 |
" |
|
2499 |
if there is a sourceCodeManager, ask it first for the extensions |
|
2500 |
" |
|
15958 | 2501 |
(Smalltalk at:#AbstractSourceCodeManager) notNil ifTrue:[ |
18924 | 2502 |
mgr := AbstractSourceCodeManager managerForPackage: aPackageId |
15958 | 2503 |
]. |
12250 | 2504 |
mgr notNil ifTrue:[ |
18924 | 2505 |
extensionsFilename := 'extensions.' , programmingLanguage sourceFileSuffix. |
2506 |
||
2507 |
projectDefinition := ProjectDefinition definitionClassForPackage:aPackageId. |
|
2508 |
projectDefinition notNil ifTrue:[ |
|
2509 |
mod := aPackageId asPackageId module. |
|
2510 |
dir := aPackageId asPackageId directory. |
|
2511 |
extensionsRevisionString := projectDefinition perform:(mgr nameOfVersionMethodForExtensions) ifNotUnderstood:nil. |
|
2512 |
extensionsRevisionString notNil ifTrue:[ |
|
2513 |
extensionsRevisionInfo := mgr revisionInfoFromString:extensionsRevisionString inClass:nil. |
|
2514 |
extensionsRevisionInfo notNil ifTrue:[ |
|
2515 |
extensionsRevisionInfo fileName = extensionsFilename ifFalse:[ |
|
2516 |
"JV@2011-10-23: following condition is never satisfied for |
|
2517 |
filed-in packages. The whole scheme of extensionVersion_XXX |
|
2518 |
works ONLY for compiled packages as it depends on fact, that |
|
2519 |
extension Init() routine is called AFTER all classes are inited, |
|
2520 |
therefore the extensionVersion_XXX methods from extensions.st |
|
2521 |
overwrites methods coming from package definition class. All this |
|
2522 |
is so tricky and error prone, that we have to come up with better |
|
2523 |
solution!!" |
|
2524 |
packageDirName notNil ifTrue:[ |
|
2525 |
^ self loadExtensionsFromDirectory:packageDirName language: programmingLanguage |
|
2526 |
] ifFalse:[ |
|
2527 |
^ false |
|
2528 |
] |
|
2529 |
] |
|
2530 |
] |
|
2531 |
]. |
|
2532 |
SourceCodeManagerError handle:[:ex | |
|
2533 |
] do:[ |
|
2534 |
inStream := mgr streamForExtensionFile:extensionsFilename package:aPackageId directory:dir module:mod cache:true. |
|
2535 |
]. |
|
2536 |
]. |
|
2537 |
inStream isNil ifTrue:[ |
|
2538 |
SourceCodeManagerError handle:[:ex | |
|
2539 |
] do:[ |
|
2540 |
inStream := mgr getMostRecentSourceStreamForFile:extensionsFilename inPackage:aPackageId. |
|
2541 |
]. |
|
2542 |
]. |
|
2543 |
inStream notNil ifTrue:[ |
|
2544 |
Class withoutUpdatingChangeSetDo:[ |
|
2545 |
inStream fileIn. |
|
2546 |
]. |
|
2547 |
inStream close. |
|
2548 |
VerboseLoading ifTrue:[ |
|
2549 |
Transcript showCR:('loaded extensions for ',aPackageId,' from repository'). |
|
2550 |
]. |
|
2551 |
^ true |
|
2552 |
] |
|
12250 | 2553 |
]. |
2554 |
||
2555 |
packageDirName notNil ifTrue:[ |
|
18924 | 2556 |
^ self loadExtensionsFromDirectory:packageDirName language: programmingLanguage |
12250 | 2557 |
]. |
2558 |
^ false |
|
2559 |
||
13415 | 2560 |
"Created: / 02-01-2010 / 10:41:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2561 |
"Modified: / 19-03-2011 / 10:03:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13814 | 2562 |
"Modified: / 04-11-2011 / 13:41:29 / cg" |
15958 | 2563 |
"Modified: / 23-10-2011 / 19:35:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12250 | 2564 |
! |
2565 |
||
2566 |
loadExtensionsFromDirectory:packageDirOrString |
|
13415 | 2567 |
| extensionsLoaded | |
18924 | 2568 |
|
13415 | 2569 |
extensionsLoaded := false. |
18924 | 2570 |
ProgrammingLanguage allDo:[:programmingLanguage| |
19856 | 2571 |
"/ evaluating or here - want all extensions to be loaded |
18924 | 2572 |
extensionsLoaded := extensionsLoaded | (self loadExtensionsFromDirectory: packageDirOrString language: programmingLanguage) |
2573 |
]. |
|
2574 |
^ extensionsLoaded |
|
13415 | 2575 |
|
2576 |
"Modified: / 02-01-2010 / 10:40:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2577 |
! |
|
2578 |
||
2579 |
loadExtensionsFromDirectory:packageDirOrString language: language |
|
12250 | 2580 |
|packageDir f| |
2581 |
||
2582 |
packageDir := packageDirOrString asFilename. |
|
2583 |
||
13415 | 2584 |
f := packageDir / ('extensions.' , language sourceFileSuffix). |
12250 | 2585 |
f exists ifTrue:[ |
18668 | 2586 |
Class withoutUpdatingChangeSetDo:[ |
2587 |
f fileIn. |
|
2588 |
]. |
|
2589 |
VerboseLoading ifTrue:[ |
|
2590 |
Transcript showCR:('loaded extensions: ' , f pathName). |
|
2591 |
]. |
|
2592 |
^ true |
|
15958 | 2593 |
]. |
2594 |
^ true"/false |
|
13415 | 2595 |
|
2596 |
"Created: / 02-01-2010 / 10:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
13814 | 2597 |
"Modified: / 04-11-2011 / 13:41:19 / cg" |
15958 | 2598 |
"Modified: / 31-01-2013 / 11:33:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12250 | 2599 |
! |
2600 |
||
14589 | 2601 |
loadPackage:aPackageStringArg asAutoloaded:doLoadAsAutoloaded |
12782 | 2602 |
"make certain, that some particular package is loaded into the system. |
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
2603 |
Return true on success, false otherwise." |
12782 | 2604 |
|
14589 | 2605 |
|packageId packageString packageDir def sourceCodeManager| |
2606 |
||
17588 | 2607 |
packageString := aPackageStringArg. |
2608 |
||
2609 |
"/ a little convenience: so you can stx packages with loadPackage:'goodies/soap' |
|
2610 |
(packageString includes:$:) ifFalse:[ |
|
19919 | 2611 |
packageString := 'stx:',packageString. |
17588 | 2612 |
]. |
12782 | 2613 |
|
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
2614 |
"if I am here, so must my package" |
14892 | 2615 |
packageString = self package ifTrue:[^ true]. |
13129
0ac3f6a28aaf
changed: #loadPackage:asAutoloaded:
Claus Gittinger <cg@exept.de>
parents:
13120
diff
changeset
|
2616 |
|
17588 | 2617 |
packageId := aPackageStringArg asPackageId. |
2618 |
||
12782 | 2619 |
"/ if there is a projectDefinition, let it load itself... |
14589 | 2620 |
def := packageId projectDefinitionClass. |
14833 | 2621 |
(def notNil and:[def isLoaded]) ifTrue:[ |
19919 | 2622 |
def loadAsAutoloaded:doLoadAsAutoloaded. |
2623 |
^ true. |
|
14589 | 2624 |
]. |
2625 |
||
2626 |
packageDir := self packageDirectoryForPackageId:packageId. |
|
16144 | 2627 |
|
2628 |
[ |
|
19919 | 2629 |
self |
2630 |
loadPackage:packageString |
|
2631 |
fromDirectory:packageDir |
|
2632 |
asAutoloaded:doLoadAsAutoloaded. |
|
16144 | 2633 |
] on:PackageLoadError do:[:ex| |
19919 | 2634 |
ex creator ~~ PackageNotCompatibleError ifTrue:[ |
2635 |
AbstractSourceCodeManager notNil ifTrue:[ |
|
2636 |
sourceCodeManager := AbstractSourceCodeManager sourceCodeManagerForPackage:packageString. |
|
2637 |
sourceCodeManager notNil ifTrue:[ |
|
2638 |
^ sourceCodeManager loadPackageWithId:packageString fromRepositoryAsAutoloaded:doLoadAsAutoloaded |
|
2639 |
]. |
|
2640 |
]. |
|
2641 |
]. |
|
2642 |
ex reject. |
|
16144 | 2643 |
]. |
2644 |
||
2645 |
^ true |
|
12782 | 2646 |
|
2647 |
" |
|
2648 |
Smalltalk loadPackageWithId:'stx:libbasic' |
|
2649 |
Smalltalk loadPackageWithId:'stx:goodies/persistency' |
|
2650 |
Smalltalk loadPackageWithId:'exept:ctypes' |
|
2651 |
" |
|
2652 |
||
13129
0ac3f6a28aaf
changed: #loadPackage:asAutoloaded:
Claus Gittinger <cg@exept.de>
parents:
13120
diff
changeset
|
2653 |
"Modified: / 16-11-2010 / 17:42:49 / cg" |
12782 | 2654 |
! |
2655 |
||
12250 | 2656 |
loadPackage:packageId fromAllSourceFilesInDirectory:aDirectory |
2657 |
"load all source files found in aDirectory and treat them like |
|
2658 |
a package. Allows for initial import of alien ST-code as a new package. |
|
2659 |
Experimental." |
|
2660 |
||
2661 |
|p t new anyFail repeatCount| |
|
2662 |
||
2663 |
"/ problem: dependencies. |
|
2664 |
"/ solution: repeat twice, so that superclasses are present the second time |
|
2665 |
||
2666 |
Class packageQuerySignal answer:packageId asSymbol do:[ |
|
18668 | 2667 |
|any| |
2668 |
||
2669 |
repeatCount := 0. |
|
2670 |
[ |
|
2671 |
repeatCount := repeatCount + 1. |
|
2672 |
anyFail := false. |
|
2673 |
aDirectory directoryContents do:[:file | |
|
2674 |
|fn| |
|
2675 |
||
2676 |
fn := aDirectory / file. |
|
2677 |
(fn hasSuffix:'st') ifTrue:[ |
|
2678 |
Metaclass confirmationQuerySignal answer:false |
|
2679 |
do:[ |
|
2680 |
Error |
|
2681 |
handle:[:ex | |
|
2682 |
anyFail := true |
|
2683 |
] |
|
2684 |
do:[ |
|
2685 |
(self fileIn:fn) ifFalse:[ |
|
2686 |
anyFail := true |
|
2687 |
] ifTrue:[ |
|
2688 |
any := true. |
|
2689 |
] |
|
2690 |
] |
|
2691 |
] |
|
2692 |
] |
|
2693 |
]. |
|
2694 |
any ifFalse:[ |
|
2695 |
^ false "/ no file found |
|
2696 |
] |
|
2697 |
] doWhile:[anyFail and:[repeatCount<2]]. |
|
12250 | 2698 |
]. |
2699 |
||
2700 |
new := (p := Project projectWithId:packageId) isNil. |
|
2701 |
new ifTrue:[ p := Project new]. |
|
2702 |
||
2703 |
p name:packageId. |
|
2704 |
p directory:aDirectory. |
|
2705 |
p package:packageId. |
|
2706 |
t := packageId asCollectionOfSubstringsSeparatedByAny:'/\:'. |
|
2707 |
p repositoryModule:(t first). |
|
2708 |
p repositoryDirectory:(packageId copyFrom:t first size + 2). |
|
2709 |
p isLoaded:true. |
|
2710 |
||
2711 |
new ifTrue:[Project addLoadedProject:p]. |
|
16144 | 2712 |
anyFail ifTrue:[ |
18668 | 2713 |
^ PackageLoadError raiseRequestWith:packageId. |
16144 | 2714 |
]. |
2715 |
^ true |
|
12250 | 2716 |
! |
2717 |
||
2718 |
loadPackage:packageId fromClassLibrary:aFilename |
|
2719 |
"load a package from a compiled classLib. |
|
2720 |
Experimental." |
|
2721 |
||
2722 |
|p t new| |
|
2723 |
||
2724 |
(self fileIn:aFilename) ifFalse:[ |
|
18668 | 2725 |
(self fileInClassLibrary:aFilename) ifFalse:[ |
2726 |
^ false. |
|
2727 |
] |
|
12250 | 2728 |
]. |
2729 |
||
2730 |
new := (p := Project projectWithId:packageId) isNil. |
|
2731 |
new ifTrue:[ p := Project new]. |
|
2732 |
||
2733 |
p name:packageId. |
|
2734 |
p directory:aFilename directory. |
|
2735 |
p package:packageId. |
|
2736 |
t := packageId asCollectionOfSubstringsSeparatedByAny:'/\:'. |
|
2737 |
p repositoryModule:(t first). |
|
2738 |
p repositoryDirectory:(packageId copyFrom:t first size + 2). |
|
2739 |
p isLoaded:true. |
|
2740 |
||
2741 |
new ifTrue:[Project addLoadedProject:p]. |
|
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
2742 |
|
12250 | 2743 |
^ true |
2744 |
! |
|
2745 |
||
12782 | 2746 |
loadPackage:aPackageString fromDirectory:packageDirOrStringOrNil asAutoloaded:doLoadAsAutoloaded |
2747 |
"load a package referenced by aPackageString - a string like 'stx:libbasic'. |
|
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
2748 |
The package is either located in packageDirOrStringOrNil, or in the current directory (if nil). |
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
2749 |
Answer true, if the load succeeded, false if it failed" |
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
2750 |
|
17324 | 2751 |
|ret| |
2752 |
||
17439
1928276a394c
added class variable IgnoreAssertions
Claus Gittinger <cg@exept.de>
parents:
17438
diff
changeset
|
2753 |
PackageLoadInProgressQuery |
18668 | 2754 |
answerNotifyLoading:aPackageString asSymbol |
2755 |
do:[ |
|
2756 |
ret := self basicLoadPackage:aPackageString fromDirectory:packageDirOrStringOrNil asAutoloaded:doLoadAsAutoloaded |
|
2757 |
]. |
|
17324 | 2758 |
^ ret |
17350 | 2759 |
|
2760 |
" |
|
2761 |
Smalltalk loadPackage:'stx:goodies/communication' |
|
2762 |
" |
|
12782 | 2763 |
! |
2764 |
||
12250 | 2765 |
loadPackage:packageId fromLoadAllFile:aFilename |
12782 | 2766 |
<resource: #obsolete> |
12250 | 2767 |
"load a package from a loadAll - loader script. |
2768 |
Experimental." |
|
2769 |
||
2770 |
|p t new| |
|
2771 |
||
2772 |
Metaclass confirmationQuerySignal answer:false |
|
2773 |
do:[ |
|
18668 | 2774 |
(self fileIn:aFilename) ifFalse:[ |
2775 |
self warn:'Failed to load the package ', packageId printString. |
|
2776 |
^ false. |
|
2777 |
] |
|
12250 | 2778 |
]. |
2779 |
||
2780 |
new := (p := Project projectWithId:packageId) isNil. |
|
2781 |
new ifTrue:[ p := Project new]. |
|
2782 |
||
2783 |
p name:packageId. |
|
2784 |
p directory:aFilename directory. |
|
2785 |
p package:packageId. |
|
2786 |
t := packageId asCollectionOfSubstringsSeparatedByAny:'/\:'. |
|
2787 |
p repositoryModule:(t first). |
|
2788 |
p repositoryDirectory:(packageId copyFrom:t first size + 2). |
|
2789 |
p isLoaded:true. |
|
2790 |
||
2791 |
new ifTrue:[Project addLoadedProject:p]. |
|
2792 |
^ true |
|
2793 |
! |
|
2794 |
||
2795 |
loadPackage:aPackageId fromZIPArchive:f asAutoloaded:doLoadAsAutoloaded |
|
2796 |
"load a package from a .zip delivery file. |
|
2797 |
Experimental." |
|
2798 |
||
19906 | 2799 |
PackageLoadError |
2800 |
raiseWith:aPackageId |
|
2801 |
errorString:' - package loading from zip is not yet implemented'. |
|
12250 | 2802 |
! |
2803 |
||
2804 |
loadPackageFromAbbrevFile:aPackageId asAutoloaded:doLoadAsAutoloaded |
|
12782 | 2805 |
<resource: #obsolete> |
12250 | 2806 |
|abbrevFile packageDir| |
2807 |
||
2808 |
packageDir := self packageDirectoryForPackageId:aPackageId. |
|
2809 |
packageDir isNil ifTrue:[^ false]. |
|
2810 |
||
2811 |
"/ abbrev.stc ? |
|
12377 | 2812 |
abbrevFile := packageDir / 'abbrev.stc'. |
12250 | 2813 |
abbrevFile exists ifFalse:[^ false]. |
2814 |
||
2815 |
Smalltalk installAutoloadedClassesFrom:abbrevFile pathName. |
|
2816 |
||
2817 |
doLoadAsAutoloaded ifFalse:[ |
|
18668 | 2818 |
"/ force autoloading... |
2819 |
Smalltalk allClassesInPackage:aPackageId do:[:eachClass | eachClass autoload]. |
|
12250 | 2820 |
]. |
2821 |
||
2822 |
self loadExtensionsFromDirectory:packageDir. |
|
13814 | 2823 |
VerboseLoading ifTrue:[ |
18668 | 2824 |
Transcript showCR:('Smalltalk [info]: loaded package: ' , aPackageId , ' from abbrev file: ' , abbrevFile pathName). |
12250 | 2825 |
]. |
2826 |
^ true |
|
2827 |
||
13814 | 2828 |
"Modified: / 04-11-2011 / 13:43:29 / cg" |
12250 | 2829 |
! ! |
2830 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2831 |
!Smalltalk class methodsFor:'queries'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2832 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2833 |
allClasses |
7563 | 2834 |
"return an unordered collection of all classes in the system. |
10071 | 2835 |
Only globally anchored classes are returned |
453 | 2836 |
(i.e. anonymous ones have to be aquired by Behavior allSubInstances)" |
2837 |
||
2838 |
|classes| |
|
2839 |
||
745
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2840 |
"/ you may wonder, what this while is for, here ... |
453 | 2841 |
"/ the reason is that if we modify the class hierarchy in |
4067 | 2842 |
"/ another view (background fileIn), while building up the |
453 | 2843 |
"/ cachedClasses set, this may be flushed (invalidated) by the |
2844 |
"/ other process in the meanwhile. |
|
2845 |
"/ If that happens, we restart the set-building here |
|
2846 |
"/ |
|
2847 |
[(classes := CachedClasses) isNil] whileTrue:[ |
|
18668 | 2848 |
CachedClasses := classes := IdentitySet new:NumberOfClassesHint. |
2849 |
self keysAndValuesDo:[:eachName :eachGlobal | |
|
2850 |
(eachGlobal notNil and:[eachGlobal isBehavior]) ifTrue:[ |
|
2851 |
"/ sigh - would like to skip over aliases |
|
2852 |
"/ but this cannot be done simply by comparing |
|
2853 |
"/ the classes name against the store-key |
|
2854 |
"/ i.e. cannot do: |
|
2855 |
"/ anObject name == sym ifTrue:[ |
|
2856 |
"/ classes add:anObject |
|
2857 |
"/ ] |
|
2858 |
"/ because that would lead to ignore all java |
|
2859 |
"/ classes, which are stored under a different |
|
2860 |
"/ key. |
|
2861 |
||
2862 |
(eachGlobal name == eachName |
|
2863 |
or:[eachGlobal isJavaClass]) ifTrue:[ |
|
2864 |
classes add:eachGlobal |
|
2865 |
]. |
|
2866 |
] |
|
2867 |
]. |
|
2868 |
NumberOfClassesHint := classes size. |
|
453 | 2869 |
]. |
2870 |
^ classes |
|
2871 |
||
8964
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
2872 |
" |
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
2873 |
CachedClasses := nil. |
453 | 2874 |
Smalltalk allClasses |
745
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2875 |
|
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2876 |
to get the list sorted by name: |
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2877 |
|
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2878 |
Smalltalk allClasses asSortedCollection:[:a :b | a name < b name] |
453 | 2879 |
" |
745
d16f199a1551
added imageStart & restart timestamps
Claus Gittinger <cg@exept.de>
parents:
736
diff
changeset
|
2880 |
|
13851
5ab434e0a636
changed: #mainStartup: for scripting stand alone apps
Claus Gittinger <cg@exept.de>
parents:
13850
diff
changeset
|
2881 |
"Modified: / 06-12-2011 / 12:41:42 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2882 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2883 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2884 |
allClassesAndMetaclasses |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2885 |
"return an unordered collection of all classes with their metaclasses in the system." |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2886 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2887 |
|classes| |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2888 |
|
8964
91b012315d91
Avoid rehashing of sets in #allClasses..
Stefan Vogel <sv@exept.de>
parents:
8960
diff
changeset
|
2889 |
classes := IdentitySet new:NumberOfClassesHint*2. |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2890 |
self allClassesDo:[:eachClass | |
18668 | 2891 |
classes add:(eachClass theNonMetaclass). |
2892 |
classes add:(eachClass theMetaclass). |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2893 |
]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2894 |
^ classes |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2895 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2896 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
2897 |
allClassesWithAllPrivateClasses |
7563 | 2898 |
"return an unordered collection of all classes in the Smalltalk namespace. |
10173
765b385fd1b8
changed #listAtCategoryNamed:
Claus Gittinger <cg@exept.de>
parents:
10169
diff
changeset
|
2899 |
Only globally anchored classes are returned; Namespaces are not included. |
4642 | 2900 |
(i.e. anonymous ones have to be aquired by Behavior allSubInstances)" |
2901 |
||
10071 | 2902 |
^ self allClasses select:[:aClass | |
18668 | 2903 |
|owner| |
2904 |
||
2905 |
(aClass isRealNameSpace not) |
|
2906 |
and:[ |
|
2907 |
owner := aClass topOwningClass. |
|
2908 |
(owner ? aClass) nameSpace == Smalltalk |
|
2909 |
] |
|
4642 | 2910 |
] |
2911 |
||
2912 |
" |
|
2913 |
Smalltalk allClassesWithAllPrivateClasses |
|
2914 |
" |
|
10173
765b385fd1b8
changed #listAtCategoryNamed:
Claus Gittinger <cg@exept.de>
parents:
10169
diff
changeset
|
2915 |
|
765b385fd1b8
changed #listAtCategoryNamed:
Claus Gittinger <cg@exept.de>
parents:
10169
diff
changeset
|
2916 |
"Modified: / 10-11-2006 / 17:24:00 / cg" |
4642 | 2917 |
! |
2918 |
||
15068 | 2919 |
allExtensions |
2920 |
"return a collection of all extension methods (methods added from another package)" |
|
2921 |
||
2922 |
|methods| |
|
2923 |
||
2924 |
methods := OrderedCollection new. |
|
2925 |
self allClassesDo:[:eachClass | |
|
18668 | 2926 |
|classPackage| |
2927 |
||
2928 |
classPackage := eachClass package. |
|
2929 |
eachClass instAndClassMethodsDo:[:mthd | |
|
2930 |
mthd package ~= classPackage ifTrue:[ methods add:mthd ]. |
|
2931 |
]. |
|
15068 | 2932 |
]. |
2933 |
^ methods |
|
2934 |
||
2935 |
" |
|
2936 |
Smalltalk allExtensions |
|
2937 |
" |
|
2938 |
! |
|
2939 |
||
11153 | 2940 |
allExtensionsForPackage:aProjectID |
14890 | 2941 |
"return a collection of all extension methods for a given projectID" |
2942 |
||
11153 | 2943 |
|methods| |
2944 |
||
2945 |
methods := OrderedCollection new. |
|
2946 |
self allClassesDo:[:eachClass | |
|
18668 | 2947 |
methods addAll:(eachClass extensionsFrom:aProjectID). |
11153 | 2948 |
]. |
2949 |
^ methods |
|
2950 |
! |
|
2951 |
||
9227 | 2952 |
allImplementorsOf:aSelector |
12919
a7ea070197c9
comment/format in: #allImplementorsOf:
Claus Gittinger <cg@exept.de>
parents:
12911
diff
changeset
|
2953 |
"return a collection of classes which implement the given selector" |
a7ea070197c9
comment/format in: #allImplementorsOf:
Claus Gittinger <cg@exept.de>
parents:
12911
diff
changeset
|
2954 |
|
9227 | 2955 |
|implementors| |
2956 |
||
2957 |
implementors := OrderedCollection new. |
|
19681 | 2958 |
self allImplementorsOf:aSelector do:[:cls | implementors add:cls]. |
2959 |
^ implementors |
|
2960 |
||
2961 |
" |
|
2962 |
Smalltalk allImplementorsOf:#isNil |
|
2963 |
(Smalltalk allImplementorsOf:#add:) size |
|
2964 |
" |
|
2965 |
||
2966 |
"Modified: / 30-04-2016 / 17:37:39 / cg" |
|
2967 |
! |
|
2968 |
||
2969 |
allImplementorsOf:aSelector do:aBlock |
|
2970 |
"enumerate all classes which implement the given selector" |
|
2971 |
||
9227 | 2972 |
self allClassesDo:[:cls | |
19681 | 2973 |
(cls includesSelector:aSelector) ifTrue:[ |
2974 |
aBlock value:cls. |
|
2975 |
]. |
|
2976 |
(cls class includesSelector:aSelector) ifTrue:[ |
|
2977 |
aBlock value:cls class. |
|
2978 |
]. |
|
2979 |
]. |
|
2980 |
||
2981 |
" |
|
2982 |
Smalltalk allImplementorsOf:#isNil do:[:cls | Transcript showCR:cls] |
|
2983 |
Smalltalk allImplementorsOf:#add: do:[:cls | Transcript showCR:cls] |
|
2984 |
" |
|
2985 |
||
2986 |
"Created: / 30-04-2016 / 17:36:45 / cg" |
|
9227 | 2987 |
! |
2988 |
||
19475 | 2989 |
allLoadedPackageIDs |
2990 |
||
2991 |
^ self allPackageIdsIncludingUnloadedClasses: false |
|
2992 |
||
2993 |
||
2994 |
" |
|
2995 |
Smalltalk allLoadedPackageIDs |
|
2996 |
" |
|
2997 |
! |
|
2998 |
||
12376 | 2999 |
allLoadedProjectIDs |
19475 | 3000 |
<resource: #obsolete> |
3001 |
self obsoleteMethodWarning:'use allLoadedPackageIDs'. |
|
3002 |
^ self allPackageIdsIncludingUnloadedClasses: false |
|
12376 | 3003 |
|
3004 |
||
3005 |
" |
|
3006 |
Smalltalk allLoadedProjectIDs |
|
3007 |
" |
|
3008 |
! |
|
3009 |
||
19475 | 3010 |
allPackageIDs |
3011 |
||
3012 |
^ self allPackageIdsIncludingUnloadedClasses: true |
|
3013 |
||
3014 |
" |
|
3015 |
Smalltalk allPackageIDs |
|
3016 |
" |
|
3017 |
! |
|
3018 |
||
3019 |
allPackageIdsIncludingUnloadedClasses: includeUnloadedClasses |
|
3020 |
"Returns all package ids. |
|
3021 |
Excludes packages coming from unloaded classes if includeUnloadedClasses is false. |
|
3022 |
" |
|
3023 |
||
3024 |
|allProjects| |
|
3025 |
||
3026 |
allProjects := Set new. |
|
3027 |
self allClassesDo:[:eachClass | |
|
3028 |
|cls pkg| |
|
3029 |
||
3030 |
eachClass isRealNameSpace ifFalse:[ |
|
3031 |
(includeUnloadedClasses or:[eachClass isLoaded]) ifTrue:[ |
|
3032 |
cls := eachClass theNonMetaclass. |
|
3033 |
cls isPrivate ifTrue:[ |
|
3034 |
cls := cls topOwningClass |
|
3035 |
]. |
|
3036 |
pkg := cls package. |
|
3037 |
pkg size > 0 ifTrue:[ |
|
3038 |
allProjects add:pkg. |
|
3039 |
] ifFalse:[ |
|
3040 |
"/ for now, nameSpaces are not in any package; |
|
3041 |
"/ this might change. Then, 0-sized packages are |
|
3042 |
"/ illegal, and the following should be enabled. |
|
3043 |
"/ self halt |
|
3044 |
]. |
|
3045 |
cls isJavaClass ifFalse:[ |
|
3046 |
cls instAndClassSelectorsAndMethodsDo:[:sel :mthd | |
|
3047 |
allProjects add:mthd package asSymbol. |
|
3048 |
]. |
|
3049 |
]. |
|
3050 |
]. |
|
3051 |
]. |
|
3052 |
]. |
|
3053 |
allProjects := allProjects asOrderedCollection sort. |
|
3054 |
^ allProjects |
|
3055 |
||
3056 |
" |
|
3057 |
Smalltalk allProjectsIdsIncludingUnloadedClasses: true |
|
3058 |
Smalltalk allProjectsIdsIncludingUnloadedClasses: false |
|
3059 |
" |
|
3060 |
! |
|
3061 |
||
9254 | 3062 |
allProjectIDs |
19475 | 3063 |
<resource: #obsolete> |
3064 |
self obsoleteMethodWarning:'use allPackageIDs'. |
|
3065 |
^ self allPackageIDs |
|
12376 | 3066 |
|
3067 |
" |
|
3068 |
Smalltalk allProjectIDs |
|
3069 |
" |
|
3070 |
! |
|
3071 |
||
3072 |
allProjectsIdsIncludingUnloadedClasses: includeUnloadedClasses |
|
19475 | 3073 |
<resource: #obsolete> |
12376 | 3074 |
"Returns all projects ids. |
3075 |
Excludes projects coming from unloaded classes if includeUnloadedClasses is false. |
|
3076 |
" |
|
3077 |
||
19475 | 3078 |
self obsoleteMethodWarning:'use allPackageIdsIncludingUnloadedClasses:'. |
3079 |
^ self allPackageIdsIncludingUnloadedClasses: includeUnloadedClasses |
|
9254 | 3080 |
|
3081 |
" |
|
12376 | 3082 |
Smalltalk allProjectsIdsIncludingUnloadedClasses: true |
3083 |
Smalltalk allProjectsIdsIncludingUnloadedClasses: false |
|
9254 | 3084 |
" |
3085 |
! |
|
3086 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3087 |
cellAt:aName |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3088 |
"{ Pragma: +optSpace }" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3089 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3090 |
"return the address of a global cell |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3091 |
- used internally for compiler only" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3092 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3093 |
%{ /* NOCONTEXT */ |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3094 |
RETURN ( __GLOBAL_GETCELL(aName) ); |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3095 |
%}. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3096 |
^ self primitiveFailed |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3097 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3098 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3099 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3100 |
classCategoryCompletion:aPartialCategory |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3101 |
"given a partial class category name, return an array consisting of |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3102 |
2 entries: 1st: the best (longest) match |
18668 | 3103 |
2nd: collection consisting of matching categories" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3104 |
|
9508 | 3105 |
^ DoWhatIMeanSupport classCategoryCompletion:aPartialCategory inEnvironment:self |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3106 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3107 |
" |
10071 | 3108 |
Smalltalk classCategoryCompletion:'Sys' |
3109 |
Smalltalk classCategoryCompletion:'System' |
|
3110 |
Smalltalk classCategoryCompletion:'System-BinaryStorage' |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3111 |
" |
9508 | 3112 |
|
3113 |
"Modified: / 10-08-2006 / 13:06:34 / cg" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3114 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3115 |
|
8570 | 3116 |
classNamed:aString |
3117 |
"return the class with name aString, or nil if absent. |
|
3118 |
To get to the metaClass, append ' class' to the string. |
|
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3119 |
To get a nameSpace or private class, prefix the name as required. |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3120 |
If a private class of an autoloaded class is referenced, the owning class |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3121 |
will be loaded." |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3122 |
|
10127 | 3123 |
|cls sym nonMeta idx prefix rest namespace nsNameSymbol| |
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3124 |
|
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3125 |
"Quick try - if everything is loaded, this will succeed. |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3126 |
But be careful, to not invent new symbols ..." |
453 | 3127 |
sym := aString asSymbolIfInterned. |
3128 |
sym notNil ifTrue:[ |
|
18668 | 3129 |
cls := self at:sym ifAbsent:nil. |
3130 |
cls isBehavior ifTrue:[^ cls]. |
|
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3131 |
]. |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3132 |
|
1480
df0bea6285f8
Change the name of a classes Metaclass from e.g. "SmallIntegerclass" to
Stefan Vogel <sv@exept.de>
parents:
1461
diff
changeset
|
3133 |
(aString endsWith:' class') ifTrue:[ |
18668 | 3134 |
nonMeta := self classNamed:(aString copyButLast:6). |
3135 |
nonMeta notNil ifTrue:[ |
|
3136 |
^ nonMeta theMetaclass |
|
3137 |
]. |
|
13602
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3138 |
]. |
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3139 |
|
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3140 |
"no success yet. Try if this is a private class of an autoloaded class" |
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3141 |
cls isNil ifTrue:[ |
18668 | 3142 |
idx := aString indexOfSubCollection:'::'. |
3143 |
idx ~~ 0 ifTrue:[ |
|
3144 |
prefix := aString copyTo:idx-1. |
|
3145 |
nsNameSymbol := prefix asSymbolIfInterned. |
|
3146 |
nsNameSymbol notNil ifTrue:[ |
|
3147 |
rest := aString copyFrom:idx+2. |
|
3148 |
namespace := self at:prefix asSymbolIfInterned ifAbsent:nil. |
|
3149 |
"namespace may be the owner of a private class. |
|
3150 |
NameSpaces and Behaviors have the same protocol" |
|
3151 |
[namespace isBehavior] whileTrue:[ |
|
3152 |
idx := rest indexOfSubCollection:'::'. |
|
3153 |
idx ~~ 0 ifTrue:[ |
|
3154 |
prefix := rest copyTo:idx-1. |
|
3155 |
rest := rest copyFrom:idx+2. |
|
3156 |
"this does an implicit autoload if required" |
|
3157 |
namespace := namespace privateClassesAt:prefix. |
|
3158 |
] ifFalse:[ |
|
3159 |
namespace isLoaded ifTrue:[ |
|
3160 |
cls := namespace privateClassesAt:rest. |
|
3161 |
cls isBehavior ifTrue:[^ cls]. |
|
3162 |
]. |
|
3163 |
namespace := nil. "force exit of loop" |
|
3164 |
]. |
|
3165 |
]. |
|
3166 |
]. |
|
3167 |
]. |
|
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3168 |
]. |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3169 |
|
453 | 3170 |
^ nil |
3171 |
||
3172 |
" |
|
10071 | 3173 |
Smalltalk classNamed:'Object' |
3174 |
Smalltalk classNamed:'Authentication::BasicAuthenticator::BasicAuthenticationData' |
|
3175 |
Smalltalk classNamed:'Authentication::BasicAuthenticator::BasicAuthenticationData class' |
|
3176 |
Smalltalk classNamed:'Authentication::BasicAuthenticator' |
|
3177 |
Smalltalk classNamed:'fooBar' |
|
3178 |
Smalltalk classNamed:'true' |
|
3179 |
Smalltalk classNamed:'Object class' |
|
3180 |
Smalltalk classNamed:'Metaclass' |
|
3181 |
Smalltalk classNamed:'Array' |
|
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3182 |
Smalltalk classNamed:'Array class' |
453 | 3183 |
" |
644
9363244ef25d
classNamed: fixed for metaclasses; handle matchCharacters in classNameCompletion
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
3184 |
|
9468 | 3185 |
"Created: / 24-11-1995 / 17:30:22 / cg" |
3186 |
"Modified: / 19-06-1996 / 14:22:21 / stefan" |
|
10127 | 3187 |
"Modified: / 23-10-2006 / 18:06:53 / cg" |
13602
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3188 |
"Modified (comment): / 20-08-2011 / 16:43:07 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3189 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3190 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3191 |
classNames |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3192 |
"return a collection of all classNames in the system" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3193 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3194 |
^ self allClasses collect:[:aClass | aClass name] |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3195 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3196 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3197 |
Smalltalk classNames |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3198 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3199 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3200 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3201 |
classnameCompletion:aPartialClassName |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3202 |
"given a partial classname, return an array consisting of |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3203 |
2 entries: 1st: the best (longest) match |
18668 | 3204 |
2nd: collection consisting of matching names" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3205 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3206 |
^ DoWhatIMeanSupport classnameCompletion:aPartialClassName inEnvironment:self |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3207 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3208 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3209 |
classnameCompletion:aPartialClassName inEnvironment:anEnvironment |
7563 | 3210 |
"given a partial classname, return an array consisting of |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3211 |
2 entries: 1st: the best (longest) match |
18668 | 3212 |
2nd: collection consisting of matching names" |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3213 |
|
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3214 |
^ DoWhatIMeanSupport classnameCompletion:aPartialClassName inEnvironment:anEnvironment |
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3215 |
|
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3216 |
" |
10071 | 3217 |
Smalltalk classnameCompletion:'Arr' |
3218 |
Smalltalk classnameCompletion:'Arra' |
|
3219 |
Smalltalk classnameCompletion:'arra' |
|
3220 |
Smalltalk classnameCompletion:'*rray' |
|
3221 |
||
3222 |
Smalltalk classnameCompletion:'Arr cl' |
|
3223 |
Smalltalk classnameCompletion:'*rray cl' |
|
453 | 3224 |
" |
644
9363244ef25d
classNamed: fixed for metaclasses; handle matchCharacters in classNameCompletion
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
3225 |
|
9363244ef25d
classNamed: fixed for metaclasses; handle matchCharacters in classNameCompletion
Claus Gittinger <cg@exept.de>
parents:
630
diff
changeset
|
3226 |
"Created: 24.11.1995 / 17:24:45 / cg" |
2523
04db1fd74e0d
try ignoring case in classNameCompletion
Claus Gittinger <cg@exept.de>
parents:
2514
diff
changeset
|
3227 |
"Modified: 3.4.1997 / 18:25:01 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3228 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3229 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3230 |
defaultNameSpace |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3231 |
"return the default namespace, where new classes are installed, |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3232 |
if NO special nameSpace handler is present" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3233 |
|
9562
7d36dbb02bb3
code cleanup - remove old obsolete Project code
Claus Gittinger <cg@exept.de>
parents:
9550
diff
changeset
|
3234 |
^ Project defaultNameSpace. |
7d36dbb02bb3
code cleanup - remove old obsolete Project code
Claus Gittinger <cg@exept.de>
parents:
9550
diff
changeset
|
3235 |
|
7d36dbb02bb3
code cleanup - remove old obsolete Project code
Claus Gittinger <cg@exept.de>
parents:
9550
diff
changeset
|
3236 |
"Created: / 19-12-1996 / 23:49:25 / cg" |
7d36dbb02bb3
code cleanup - remove old obsolete Project code
Claus Gittinger <cg@exept.de>
parents:
9550
diff
changeset
|
3237 |
"Modified: / 17-08-2006 / 14:01:22 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3238 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3239 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3240 |
globalNameCompletion:aPartialGlobalName |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3241 |
"given a partial globalName, return an array consisting of |
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3242 |
2 entries: 1st: the best (longest) match |
18668 | 3243 |
2nd: collection consisting of matching names" |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3244 |
|
12614
b8fca618dcb6
changed: #globalNameCompletion:
Claus Gittinger <cg@exept.de>
parents:
12613
diff
changeset
|
3245 |
^ DoWhatIMeanSupport globalNameCompletion:aPartialGlobalName inEnvironment:self match:true |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3246 |
|
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3247 |
" |
10071 | 3248 |
Smalltalk globalnameCompletion:'Arr' |
3249 |
Smalltalk globalnameCompletion:'Arra' |
|
3250 |
Smalltalk globalnameCompletion:'arra' |
|
3251 |
Smalltalk globalnameCompletion:'*rray' |
|
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3252 |
" |
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3253 |
|
9508 | 3254 |
"Created: / 24-11-1995 / 17:24:45 / cg" |
3255 |
"Modified: / 10-08-2006 / 13:05:39 / cg" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3256 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3257 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3258 |
globalnameCompletion:aPartialGlobalName |
7563 | 3259 |
"given a partial globalName, return an array consisting of |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3260 |
2 entries: 1st: the best (longest) match |
18668 | 3261 |
2nd: collection consisting of matching names" |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3262 |
|
8358 | 3263 |
<resource:#obsolete> |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3264 |
self obsoleteMethodWarning:'use #globalNameCompletion:'. |
9508 | 3265 |
^ DoWhatIMeanSupport globalNameCompletion:aPartialGlobalName inEnvironment:self |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3266 |
|
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3267 |
" |
10071 | 3268 |
Smalltalk globalnameCompletion:'Arr' |
3269 |
Smalltalk globalnameCompletion:'Arra' |
|
3270 |
Smalltalk globalnameCompletion:'arra' |
|
3271 |
Smalltalk globalnameCompletion:'*rray' |
|
5736 | 3272 |
" |
3273 |
||
9508 | 3274 |
"Created: / 24-11-1995 / 17:24:45 / cg" |
3275 |
"Modified: / 10-08-2006 / 13:05:48 / cg" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3276 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3277 |
|
13771 | 3278 |
hasClassNamed:aString |
3279 |
Symbol |
|
18668 | 3280 |
hasInterned:aString |
3281 |
ifTrue:[:aSymbol | ^ (self at:aSymbol ifAbsent:[ nil ]) isClass ]. |
|
13602
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3282 |
^ false |
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3283 |
|
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3284 |
"Created: / 26-08-2009 / 11:43:03 / Jaroslav Havlin <havlij6@fel.cvut.cz>" |
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3285 |
"Modified: / 20-08-2011 / 16:41:31 / cg" |
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3286 |
! |
5fe3c7ce7d7e
comment/format in: #classNamed:
Claus Gittinger <cg@exept.de>
parents:
13601
diff
changeset
|
3287 |
|
9290 | 3288 |
hasNameSpaces |
3289 |
"can be redefined by dummy namespaces/environments, to suppress |
|
3290 |
the namespace display in a browser (PocketSmalltalk)" |
|
3291 |
||
3292 |
^ true |
|
3293 |
! |
|
3294 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3295 |
hasNamespaces |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3296 |
"can be redefined by dummy namespaces/environments, to suppress |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3297 |
the namespace display in a browser (PocketSmalltalk)" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3298 |
|
9290 | 3299 |
<resource:#obsolete> |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3300 |
^ true |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3301 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3302 |
|
10432
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3303 |
hasSelectorNameSpaces |
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3304 |
"for now return false |
10999 | 3305 |
Selector namespaces are being implemented and supported by the VM, |
10432
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3306 |
but not yet fully supported by all tools... |
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3307 |
Therefore, for now, do not generate code which uses this feature." |
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3308 |
|
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3309 |
^ false |
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3310 |
|
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3311 |
"Created: / 05-03-2007 / 13:26:28 / cg" |
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3312 |
! |
9d0a4de5e69c
preps for selectorNamespaces.
Claus Gittinger <cg@exept.de>
parents:
10429
diff
changeset
|
3313 |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3314 |
includes:something |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3315 |
"this should come from Collection. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3316 |
will change the inheritance - Smalltalk is actually a collection" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3317 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3318 |
self do:[:element | element = something ifTrue:[^ true]]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3319 |
^ false |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3320 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3321 |
|
14987 | 3322 |
includesIdentical:something |
3323 |
"this should come from Collection. |
|
3324 |
will change the inheritance - Smalltalk is actually a collection" |
|
3325 |
||
3326 |
self do:[:element | element == something ifTrue:[^ true]]. |
|
3327 |
^ false |
|
3328 |
! |
|
3329 |
||
10041
1ef0cb09523b
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9937
diff
changeset
|
3330 |
isBrowserStartable |
1ef0cb09523b
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9937
diff
changeset
|
3331 |
^ false. |
1ef0cb09523b
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9937
diff
changeset
|
3332 |
|
1ef0cb09523b
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9937
diff
changeset
|
3333 |
"Created: / 06-10-2006 / 11:46:52 / cg" |
1ef0cb09523b
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9937
diff
changeset
|
3334 |
! |
1ef0cb09523b
protocol for startability via browser slightly changed
Claus Gittinger <cg@exept.de>
parents:
9937
diff
changeset
|
3335 |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3336 |
isNameSpace |
9227 | 3337 |
"return true, if the receiver is a nameSpace." |
3338 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3339 |
^ true |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3340 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3341 |
"Created: 11.10.1996 / 18:10:43 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3342 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3343 |
|
10169 | 3344 |
isRealNameSpace |
3345 |
"return true, if the receiver is a nameSpace, but not Smalltalk (which is also a class)." |
|
3346 |
||
3347 |
^ false |
|
3348 |
||
3349 |
"Created: / 10-11-2006 / 17:02:19 / cg" |
|
3350 |
! |
|
3351 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3352 |
isTopLevelNameSpace |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3353 |
^ true |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3354 |
! |
7563 | 3355 |
|
3356 |
isTopLevelNamespace |
|
3357 |
"obsolete - use isTopLevelNameSpace" |
|
5365 | 3358 |
|
7432 | 3359 |
<resource:#obsolete> |
3360 |
||
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3361 |
self obsoleteMethodWarning:'use #isTopLevelNameSpace'. |
4458 | 3362 |
^ true |
3363 |
||
3364 |
"Created: 11.10.1996 / 18:10:43 / cg" |
|
3365 |
! |
|
3366 |
||
9081 | 3367 |
keyIsClassVariableNameKey:aKey |
3368 |
|i| |
|
3369 |
||
3370 |
i := aKey lastIndexOf:$:. |
|
3371 |
i ~~ 0 ifTrue:[ |
|
18668 | 3372 |
i > 1 ifTrue:[ |
3373 |
(aKey at:(i-1)) == $: ifFalse:[ |
|
3374 |
^ true. |
|
3375 |
]. |
|
3376 |
]. |
|
9081 | 3377 |
]. |
3378 |
^ false. |
|
3379 |
||
3380 |
" |
|
10071 | 3381 |
self keyIsClassVariableNameKey:'foo::bar' |
3382 |
self keyIsClassVariableNameKey:'foo:bar' |
|
3383 |
self keyIsClassVariableNameKey:':bar' |
|
3384 |
self keyIsClassVariableNameKey:'::bar' |
|
9081 | 3385 |
" |
3386 |
! |
|
3387 |
||
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3388 |
loadedClassNamed:aString |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3389 |
"Same as #classNamed, |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3390 |
but a private class of an autoloaded class will not be found." |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3391 |
|
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3392 |
|cls sym nonMeta| |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3393 |
|
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3394 |
"Quick try - if everything is loaded, this will succeed. |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3395 |
But be careful, to not invent new symbols ..." |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3396 |
sym := aString asSymbolIfInterned. |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3397 |
sym notNil ifTrue:[ |
18668 | 3398 |
cls := self at:sym ifAbsent:nil. |
3399 |
cls isBehavior ifTrue:[^ cls]. |
|
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3400 |
]. |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3401 |
|
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3402 |
(aString endsWith:' class') ifTrue:[ |
18668 | 3403 |
nonMeta := self loadedClassNamed:(aString copyButLast:6). |
3404 |
nonMeta notNil ifTrue:[ |
|
3405 |
^ nonMeta theMetaclass |
|
3406 |
]. |
|
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3407 |
]. |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3408 |
^ nil |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3409 |
|
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3410 |
" |
10071 | 3411 |
Smalltalk loadedClassNamed:'Object' |
3412 |
Smalltalk loadedClassNamed:'Authentication::BasicAuthenticator::BasicAuthenticationData' |
|
3413 |
Smalltalk loadedClassNamed:'Authentication::BasicAuthenticator::BasicAuthenticationData class' |
|
3414 |
Smalltalk loadedClassNamed:'Authentication::BasicAuthenticator' |
|
3415 |
Smalltalk loadedClassNamed:'fooBar' |
|
3416 |
Smalltalk loadedClassNamed:'true' |
|
3417 |
Smalltalk loadedClassNamed:'Object class' |
|
3418 |
Smalltalk loadedClassNamed:'Metaclass' |
|
3419 |
Smalltalk loadedClassNamed:'Array' |
|
9374
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3420 |
Smalltalk loadedClassNamed:'Array class' |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3421 |
" |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3422 |
! |
8198d65aadd3
#classNamed: now loads autoloaded classes if a (possibly) private class of an
Stefan Vogel <sv@exept.de>
parents:
9292
diff
changeset
|
3423 |
|
7563 | 3424 |
methodProtocolCompletion:aPartialProtocolName |
3425 |
"given a partial method protocol name, return an array consisting of |
|
10071 | 3426 |
2 entries: 1st: the best (longest) match |
18668 | 3427 |
2nd: collection consisting of matching protocols" |
7999
475bba3ead9a
moved all input completion methods from Smalltalk to DoWhatIMeanSupport.
Claus Gittinger <cg@exept.de>
parents:
7996
diff
changeset
|
3428 |
|
9508 | 3429 |
^ DoWhatIMeanSupport methodProtocolCompletion:aPartialProtocolName inEnvironment:self |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3430 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3431 |
" |
10071 | 3432 |
Smalltalk methodProtocolCompletion:'doc' |
3433 |
Smalltalk methodProtocolCompletion:'docu' |
|
3434 |
Smalltalk methodProtocolCompletion:'documenta' |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3435 |
" |
9508 | 3436 |
|
3437 |
"Modified: / 10-08-2006 / 13:05:20 / cg" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3438 |
! |
5505
e99e8e9cbfef
added #methodProtocolCompletion:
Claus Gittinger <cg@exept.de>
parents:
5504
diff
changeset
|
3439 |
|
7563 | 3440 |
numberOfGlobals |
3441 |
"return the number of global variables in the system" |
|
3442 |
||
3443 |
|tally "{ Class: SmallInteger }" | |
|
617 | 3444 |
|
3445 |
tally := 0. |
|
3446 |
self do:[:obj | tally := tally + 1]. |
|
3447 |
^ tally |
|
3448 |
||
3449 |
"Smalltalk numberOfGlobals" |
|
3450 |
! |
|
3451 |
||
7563 | 3452 |
referencesAny:aCollection |
3453 |
"redefined, since the references are only kept in the VM's symbol table" |
|
3260 | 3454 |
|
3455 |
self keysAndValuesDo:[:key :val | |
|
18668 | 3456 |
aCollection do:[:anObject | |
3457 |
(key == anObject) ifTrue:[^ true]. |
|
3458 |
(val == anObject ) ifTrue:[^ true]. |
|
3459 |
] |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3460 |
]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3461 |
^ super referencesAny:aCollection |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3462 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3463 |
"Created: / 2.2.1998 / 16:01:20 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3464 |
! |
3260 | 3465 |
|
7563 | 3466 |
referencesDerivedInstanceOf:aClass |
3467 |
"redefined, since the references are only kept in the VM's symbol table" |
|
617 | 3468 |
|
3469 |
self keysAndValuesDo:[:key :val | |
|
18668 | 3470 |
(key isKindOf:aClass) ifTrue:[^ true]. |
3471 |
(val isKindOf:aClass) ifTrue:[^ true]. |
|
617 | 3472 |
]. |
3473 |
^ super referencesDerivedInstanceOf:aClass |
|
3474 |
! |
|
3475 |
||
7563 | 3476 |
referencesInstanceOf:aClass |
3477 |
"redefined, since the references are only kept in the VM's symbol table" |
|
617 | 3478 |
|
3479 |
self keysAndValuesDo:[:key :val | |
|
18668 | 3480 |
(key isMemberOf:aClass) ifTrue:[^ true]. |
3481 |
(val isMemberOf:aClass) ifTrue:[^ true]. |
|
617 | 3482 |
]. |
3483 |
^ super referencesInstanceOf:aClass |
|
3484 |
! |
|
3485 |
||
7563 | 3486 |
referencesObject:anObject |
3487 |
"redefined, since the references are only kept in the VM's symbol table" |
|
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
3488 |
|
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
3489 |
self keysAndValuesDo:[:key :val | |
18668 | 3490 |
(key == anObject) ifTrue:[^ true]. |
3491 |
(val == anObject ) ifTrue:[^ true]. |
|
6074
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
3492 |
]. |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
3493 |
^ super referencesObject:anObject |
d91c99700e3b
renamed #references: (conflict with RB's #references)
Claus Gittinger <cg@exept.de>
parents:
6033
diff
changeset
|
3494 |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3495 |
"Modified: / 3.2.1998 / 14:22:46 / cg" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3496 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3497 |
|
15766 | 3498 |
resolveName:aName inClass:aClass |
7563 | 3499 |
"resolve aName as if compiled within aClass; |
3026 | 3500 |
i.e. if it has a private class with this name, return it; |
3501 |
if aName is known within the classes namespace, return that. |
|
3502 |
Otherwise, return a global with that name. |
|
3503 |
This should be used whereever Smalltalk>>at: used to be used, |
|
3504 |
to resolve a global by name." |
|
3505 |
||
15766 | 3506 |
|nameUsed sym cls ns| |
3507 |
||
3508 |
aName isNil ifTrue:[^ nil]. |
|
3509 |
aName isBehavior ifTrue:[^ aName]. "/ already resolved |
|
3510 |
nameUsed := aName. |
|
3511 |
||
3512 |
(nameUsed startsWith:'Smalltalk::') ifTrue:[ |
|
18668 | 3513 |
nameUsed := nameUsed copyFrom:12. |
3514 |
^ self at:(nameUsed asSymbol) ifAbsent:nil. |
|
15766 | 3515 |
]. |
3516 |
||
3517 |
sym := nameUsed asSymbol. |
|
3026 | 3518 |
|
3519 |
cls := aClass privateClassesAt:sym. |
|
3520 |
cls notNil ifTrue:[^ cls]. |
|
3521 |
||
3522 |
ns := aClass nameSpace. |
|
3523 |
(ns notNil and:[ns ~~ Smalltalk]) ifTrue:[ |
|
18668 | 3524 |
ns isNameSpace ifTrue:[ |
3525 |
cls := ns at:sym ifAbsent:nil. |
|
3526 |
] ifFalse:[ |
|
3527 |
cls := ns privateClassesAt:sym |
|
3528 |
]. |
|
3529 |
cls notNil ifTrue:[^ cls]. |
|
3025 | 3530 |
]. |
3026 | 3531 |
^ self at:sym ifAbsent:nil. |
4356 | 3532 |
|
3533 |
"Modified: / 9.7.1999 / 01:18:07 / cg" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3534 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3535 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3536 |
selectorCompletion:aPartialSymbolName |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3537 |
"given a partial selector, return an array consisting of |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3538 |
2 entries: 1st: the longest match |
18668 | 3539 |
2nd: collection consisting of matching implemented selectors" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3540 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3541 |
^ DoWhatIMeanSupport selectorCompletion:aPartialSymbolName inEnvironment:self |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3542 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3543 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3544 |
selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3545 |
"given a partial selector, return an array consisting of |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3546 |
2 entries: 1st: the longest match |
18668 | 3547 |
2nd: collection consisting of matching implemented selectors" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3548 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3549 |
^ DoWhatIMeanSupport selectorCompletion:aPartialSymbolName inEnvironment:anEnvironment |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3550 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3551 |
" |
10071 | 3552 |
Smalltalk selectorCompletion:'at:p' |
3553 |
Smalltalk selectorCompletion:'nextP' |
|
3554 |
Smalltalk selectorCompletion:'nextp' |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3555 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3556 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3557 |
"Modified: / 7.6.1996 / 08:44:33 / stefan" |
3565
966a108e3765
also do caseless selectorCompletion
Claus Gittinger <cg@exept.de>
parents:
3560
diff
changeset
|
3558 |
"Modified: / 14.6.1998 / 15:54:03 / cg" |
19681 | 3559 |
! |
3560 |
||
3561 |
someImplementorOf:aSelector |
|
3562 |
"return any class, which implement the given selector. Nil if there is none. |
|
3563 |
(useful to search, if there is one at all)" |
|
3564 |
||
3565 |
self allImplementorsOf:aSelector do:[:cls | ^ cls]. |
|
3566 |
^ nil. |
|
3567 |
||
3568 |
" |
|
3569 |
Smalltalk someImplementorOf:#isNil |
|
3570 |
Smalltalk someImplementorOf:#add: |
|
3571 |
" |
|
3572 |
||
3573 |
"Created: / 30-04-2016 / 17:39:19 / cg" |
|
453 | 3574 |
! ! |
3575 |
||
4431 | 3576 |
!Smalltalk class methodsFor:'queries-system'! |
3577 |
||
7563 | 3578 |
dialectName |
8736 | 3579 |
^ #SmalltalkX |
7563 | 3580 |
|
3581 |
" |
|
3582 |
Smalltalk dialectName |
|
3583 |
" |
|
3584 |
! |
|
3585 |
||
3586 |
dialectReleaseVersion |
|
7348 | 3587 |
^ self versionString |
3588 |
||
3589 |
" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3590 |
Smalltalk dialectReleaseVersion |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3591 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3592 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3593 |
|
15958 | 3594 |
isAmber |
15980 | 3595 |
"is this an Amber Smalltalk system ? |
3596 |
Return false here - this may be useful to write portable |
|
15958 | 3597 |
applications - add #isAmber to your Amber Smalltalk, |
3598 |
returning true there." |
|
3599 |
||
3600 |
^ false |
|
3601 |
||
3602 |
"Created: / 18-12-2013 / 15:43:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3603 |
! |
|
3604 |
||
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3605 |
isDolphinSmalltalk |
16803 | 3606 |
"is this a Dolphin Smalltalk system ? |
15980 | 3607 |
Return false here - this may be useful to write portable |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3608 |
applications - add #isDolphinSmalltalk to your dolphin, |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3609 |
returning true there." |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3610 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3611 |
^ false |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3612 |
! |
4970 | 3613 |
|
15958 | 3614 |
isGemStone |
15980 | 3615 |
"is this a GemStone Smalltalk system ? |
3616 |
Return false here - this may be useful to write portable |
|
15958 | 3617 |
applications - add #isGemStone to your GemStone/S, |
3618 |
returning true there." |
|
3619 |
||
3620 |
^ false |
|
3621 |
||
3622 |
"Created: / 18-12-2013 / 15:43:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3623 |
! |
|
3624 |
||
3625 |
isPharo |
|
15980 | 3626 |
"is this a Pharo Smalltalk system ? |
3627 |
Return false here - this may be useful to write portable |
|
15958 | 3628 |
applications - add #isPharo to your Pharo, |
3629 |
returning true there." |
|
3630 |
||
3631 |
^ false |
|
3632 |
||
3633 |
"Created: / 18-12-2013 / 15:42:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3634 |
! |
|
3635 |
||
7563 | 3636 |
isSmalltalkMT |
15980 | 3637 |
"is this a Smalltalk-MT system ? |
3638 |
Return false here - this may be useful to write portable |
|
7563 | 3639 |
applications - add #isSmalltalkMT to your smalltalk-MT, |
4970 | 3640 |
returning true there." |
3641 |
||
3642 |
^ false |
|
3643 |
! |
|
3644 |
||
7563 | 3645 |
isSmalltalkV |
15980 | 3646 |
"is this a Smalltalk/V system ? |
3647 |
Return false here - this may be useful to write portable |
|
7563 | 3648 |
applications - add #isSmalltalkV to your smalltalkV, |
4431 | 3649 |
returning true there." |
3650 |
||
3651 |
^ false |
|
3652 |
! |
|
3653 |
||
7563 | 3654 |
isSmalltalkX |
16803 | 3655 |
"is this a Smalltalk/X system ? |
15980 | 3656 |
Return true here - this may be useful to write portable |
7563 | 3657 |
applications - add #isSmalltalkX to your other smalltalks, |
4431 | 3658 |
returning false there." |
3659 |
||
3660 |
^ true |
|
3661 |
! |
|
3662 |
||
7563 | 3663 |
isSqueak |
15980 | 3664 |
"is this a SqueakSmalltalk system ? |
3665 |
Return false here - this may be useful to write portable |
|
7563 | 3666 |
applications - add #isSqueak to your squeak, |
4431 | 3667 |
returning true there." |
3668 |
||
3669 |
^ false |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3670 |
! |
4431 | 3671 |
|
16013 | 3672 |
isSqueakLike |
3673 |
"is this a Squeak, Pharo, Cuis or similar Smalltalk system ? |
|
3674 |
Return false here - this may be useful to write portable |
|
3675 |
applications - add #isSqueakLike to your squeak, pharo,... |
|
3676 |
returning true there." |
|
3677 |
||
3678 |
^ false |
|
3679 |
! |
|
3680 |
||
7563 | 3681 |
isVisualAge |
15980 | 3682 |
"is this a VisualAge Smalltalk system ? |
3683 |
Return false here - this may be useful to write portable |
|
7563 | 3684 |
applications - add #isVisualAge to your visualAge, |
4431 | 3685 |
returning true there." |
3686 |
||
3687 |
^ false |
|
3688 |
! |
|
3689 |
||
17369 | 3690 |
isVisualSmalltalkEnterprise |
16843 | 3691 |
"is this a VSE Smalltalk system ? |
3692 |
Return false here - this may be useful to write portable |
|
3693 |
applications - add #isVisualSmallalkEnterprise to your VSE, |
|
3694 |
returning true there." |
|
3695 |
||
3696 |
^ false |
|
3697 |
! |
|
3698 |
||
7563 | 3699 |
isVisualWorks |
15980 | 3700 |
"is this a VisualWorks Smalltalk system ? |
3701 |
Return false here - this may be useful to write portable |
|
7563 | 3702 |
applications - add #isVisualWorks to your visualWorks, |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3703 |
returning true there." |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3704 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3705 |
^ false |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3706 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3707 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
3708 |
!Smalltalk class methodsFor:'startup'! |
1 | 3709 |
|
9032 | 3710 |
browserWindowStartup |
13056
1fa92a4cd9cc
comment in #browserWindowStartup
Claus Gittinger <cg@exept.de>
parents:
13014
diff
changeset
|
3711 |
"invoked, when st/x is started as a plugin in a (currently firefox) browser. |
1fa92a4cd9cc
comment in #browserWindowStartup
Claus Gittinger <cg@exept.de>
parents:
13014
diff
changeset
|
3712 |
In contrast to squeak (where a single window is used to show the display bitmap), |
1fa92a4cd9cc
comment in #browserWindowStartup
Claus Gittinger <cg@exept.de>
parents:
13014
diff
changeset
|
3713 |
the browser window is used as a pseudo root-window for a single aplication window. |
1fa92a4cd9cc
comment in #browserWindowStartup
Claus Gittinger <cg@exept.de>
parents:
13014
diff
changeset
|
3714 |
If required, that app must ensure that multiple apps (if any) are setup as a |
1fa92a4cd9cc
comment in #browserWindowStartup
Claus Gittinger <cg@exept.de>
parents:
13014
diff
changeset
|
3715 |
multiwindow application. |
1fa92a4cd9cc
comment in #browserWindowStartup
Claus Gittinger <cg@exept.de>
parents:
13014
diff
changeset
|
3716 |
Actually, control is transferred to PluginSupport, which is suppoesed to know what to do" |
1fa92a4cd9cc
comment in #browserWindowStartup
Claus Gittinger <cg@exept.de>
parents:
13014
diff
changeset
|
3717 |
|
9032 | 3718 |
|windowIDString numericWindowID windowID params idx process| |
3719 |
||
3720 |
idx := CommandLineArguments indexOf:'--browserWindow:'. |
|
3721 |
windowIDString := CommandLineArguments at:idx+1. |
|
3722 |
numericWindowID := Integer fromString:windowIDString. |
|
3723 |
windowID := ExternalAddress newAddress:numericWindowID. |
|
3724 |
||
3725 |
idx := CommandLineArguments indexOf:'--browserParameters:'. |
|
3726 |
idx ~~ 0 ifTrue:[ |
|
18668 | 3727 |
params := Dictionary new. |
3728 |
(CommandLineArguments copyFrom:idx+1) pairWiseDo:[:key :value | |
|
3729 |
params at:key put:value. |
|
3730 |
]. |
|
9032 | 3731 |
]. |
3732 |
||
3733 |
'browserWindow is: ' errorPrint. windowID errorPrintCR. |
|
3734 |
'browserParameters are: ' errorPrint. params errorPrintCR. |
|
3735 |
'Display is: ' errorPrint. Display errorPrintCR. |
|
3736 |
||
3737 |
process := [ |
|
18668 | 3738 |
PluginSupport |
3739 |
startInBrowserWithWindowID:windowID |
|
3740 |
parameters:params. |
|
9032 | 3741 |
] newProcess. |
9043
e6106f500263
do not use numeric process prios
Claus Gittinger <cg@exept.de>
parents:
9036
diff
changeset
|
3742 |
process priority:(Processor userSchedulingPriority). |
9032 | 3743 |
process name:'browser start handler'. |
3744 |
process beGroupLeader. |
|
3745 |
process resume. |
|
3746 |
process := nil. |
|
3747 |
||
3748 |
Processor dispatchLoop. |
|
3749 |
Smalltalk exit. |
|
13056
1fa92a4cd9cc
comment in #browserWindowStartup
Claus Gittinger <cg@exept.de>
parents:
13014
diff
changeset
|
3750 |
|
1fa92a4cd9cc
comment in #browserWindowStartup
Claus Gittinger <cg@exept.de>
parents:
13014
diff
changeset
|
3751 |
"Modified: / 11-09-2010 / 14:06:59 / cg" |
9032 | 3752 |
! |
3753 |
||
7563 | 3754 |
displayInitializationDone |
3755 |
"inform the restart, that the display has been initialized" |
|
6559
2ec6d0d1b821
Changed Workstation initialization
Stefan Vogel <sv@exept.de>
parents:
6539
diff
changeset
|
3756 |
|
2ec6d0d1b821
Changed Workstation initialization
Stefan Vogel <sv@exept.de>
parents:
6539
diff
changeset
|
3757 |
CallbackSignal raiseRequest. |
2ec6d0d1b821
Changed Workstation initialization
Stefan Vogel <sv@exept.de>
parents:
6539
diff
changeset
|
3758 |
! |
2ec6d0d1b821
Changed Workstation initialization
Stefan Vogel <sv@exept.de>
parents:
6539
diff
changeset
|
3759 |
|
13893 | 3760 |
executeStartBlocks |
3761 |
|startBlocks| |
|
3762 |
||
3763 |
startBlocks := self startBlocks. |
|
3764 |
startBlocks notNil ifTrue:[ |
|
18668 | 3765 |
'Smalltalk [info]: execute startBlocks...' infoPrintCR. |
3766 |
startBlocks do:[:aBlock| |
|
3767 |
Error handle:[:ex | |
|
3768 |
InfoPrinting == true ifTrue:[ |
|
3769 |
'Smalltalk [warning]: error caught in startBlock: ' infoPrint. |
|
3770 |
ex description infoPrintCR. |
|
3771 |
ex infoPrintCR. |
|
3772 |
thisContext fullPrintAll. |
|
3773 |
]. |
|
3774 |
] do: aBlock |
|
3775 |
]. |
|
3776 |
startBlocks removeAll. |
|
13893 | 3777 |
]. |
3778 |
||
3779 |
"Created: / 07-01-2012 / 12:58:39 / cg" |
|
3780 |
! |
|
3781 |
||
11375 | 3782 |
hideSplashWindow |
3783 |
%{ |
|
3784 |
#ifdef WIN32 |
|
3785 |
extern void __win32_hideSplashScreen(); |
|
3786 |
||
3787 |
__win32_hideSplashScreen(); |
|
3788 |
#endif |
|
3789 |
%} |
|
3790 |
! |
|
3791 |
||
7563 | 3792 |
mainStartup:graphicalMode |
3793 |
"common start/restart action, if there is a Display, initialize it |
|
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3794 |
and start dispatching; otherwise go into a read-eval-print loop." |
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3795 |
|
9012 | 3796 |
|process imageName thisIsARestart idx| |
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3797 |
|
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3798 |
imageName := ObjectMemory imageName. |
2249
cdb6c87f0707
send returnFromSnapshot notification later -
Claus Gittinger <cg@exept.de>
parents:
2212
diff
changeset
|
3799 |
thisIsARestart := imageName notNil. |
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3800 |
|
19788 | 3801 |
true "graphicalMode" ifTrue:[ |
3802 |
Display isNil ifTrue:[ |
|
3803 |
(StartupClass notNil |
|
3804 |
and:[ (StartupClass perform:#isHeadless ifNotUnderstood:false) ]) ifFalse:[ |
|
3805 |
self openDisplay. |
|
3806 |
]. |
|
3807 |
]. |
|
10644 | 3808 |
]. |
3809 |
||
10645 | 3810 |
StandAlone ifFalse:[ |
19788 | 3811 |
" |
3812 |
enable the graphical debugger/inspector |
|
3813 |
(they could have been (re)defined as autoloaded in the patches file) |
|
3814 |
" |
|
3815 |
self initStandardTools. |
|
10645 | 3816 |
]. |
3817 |
||
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3818 |
" |
10071 | 3819 |
if there is a display, start its event dispatcher |
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3820 |
" |
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3821 |
Display notNil ifTrue:[ |
19788 | 3822 |
Display deviceIOTimeoutErrorSignal handlerBlock:[:ex | |
3823 |
SaveEmergencyImage == true ifTrue:[ |
|
3824 |
'Display [warning]: broken display connection - emergency save in ''crash.img''.' infoPrintCR. |
|
3825 |
ObjectMemory primSnapShotOn:'crash.img'. |
|
3826 |
]. |
|
3827 |
'Display [warning]: broken display connection - exit.' infoPrintCR. |
|
3828 |
self exit:11. |
|
3829 |
]. |
|
3830 |
Display startDispatch. |
|
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3831 |
]. |
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3832 |
|
9016 | 3833 |
idx := CommandLineArguments indexOf:'--browserWindow:'. |
9029 | 3834 |
IsPlugin := (idx ~~ 0). |
3835 |
IsPlugin ifTrue:[ |
|
19788 | 3836 |
'Smalltalk [info]: startup browser window...' infoPrintCR. |
3837 |
self browserWindowStartup. |
|
3838 |
"/ not reached |
|
9012 | 3839 |
]. |
3840 |
||
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3841 |
Initializing := false. |
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3842 |
|
2074
01f7e1396c18
fixed standalone startup (broke when startupblocks where invented ...)
Claus Gittinger <cg@exept.de>
parents:
2050
diff
changeset
|
3843 |
"/ start a process, which evaluates all StartBlocks |
01f7e1396c18
fixed standalone startup (broke when startupblocks where invented ...)
Claus Gittinger <cg@exept.de>
parents:
2050
diff
changeset
|
3844 |
"/ this used to be done right here (in this system-process), |
01f7e1396c18
fixed standalone startup (broke when startupblocks where invented ...)
Claus Gittinger <cg@exept.de>
parents:
2050
diff
changeset
|
3845 |
"/ but lead to trouble, when it suspended. |
01f7e1396c18
fixed standalone startup (broke when startupblocks where invented ...)
Claus Gittinger <cg@exept.de>
parents:
2050
diff
changeset
|
3846 |
"/ Therefore, it is now done by an extra user-process. |
01f7e1396c18
fixed standalone startup (broke when startupblocks where invented ...)
Claus Gittinger <cg@exept.de>
parents:
2050
diff
changeset
|
3847 |
|
7043
d88be9c553d2
Release references to processes in #mainStartup:
Stefan Vogel <sv@exept.de>
parents:
7040
diff
changeset
|
3848 |
process := [ |
19788 | 3849 |
'Smalltalk [info]: startup process 1 active.' infoPrintCR. |
3850 |
StartBlocks notNil ifTrue:[ |
|
3851 |
self executeStartBlocks. |
|
3852 |
StartBlocks := nil. |
|
3853 |
]. |
|
3854 |
ImageStartBlocks notNil ifTrue:[ |
|
3855 |
'Smalltalk [info]: execute imageStartBlocks...' infoPrintCR. |
|
3856 |
ImageStartBlocks do:[:aBlock| |
|
3857 |
aBlock value |
|
3858 |
]. |
|
3859 |
]. |
|
3860 |
StandAlone ifFalse:[ |
|
3861 |
(SilentLoading == true) ifFalse:[ "i.e. undefined counts as false" |
|
3862 |
thisIsARestart ifTrue:[ |
|
3863 |
Transcript cr. |
|
3864 |
Transcript showCR:('Smalltalk restarted from:' |
|
3865 |
, imageName |
|
3866 |
, ' (saved ' |
|
3867 |
, ObjectMemory imageSaveTime printString |
|
3868 |
, ')' ). |
|
3869 |
] ifFalse:[ |
|
3870 |
Transcript showCR:(self hello). |
|
3871 |
Transcript showCR:(self copyrightString). |
|
3872 |
]. |
|
3873 |
Transcript cr. |
|
3874 |
]. |
|
3875 |
||
3876 |
DemoMode==true ifTrue:[ |
|
3877 |
Transcript showCR:'*** Restricted use: ***'. |
|
3878 |
Transcript showCR:'*** This program may be used for education only. ***'. |
|
3879 |
Transcript showCR:'*** Please read the files COPYRIGHT and LICENSE ***'. |
|
3880 |
Transcript showCR:'*** for more details. ***'. |
|
3881 |
Transcript cr. |
|
3882 |
]. |
|
3883 |
]. |
|
3884 |
||
3885 |
thisIsARestart ifTrue:[ |
|
3886 |
"/ |
|
3887 |
"/ the final late notification - users can now assume that |
|
3888 |
"/ views, forms etc. have been recreated. |
|
3889 |
||
3890 |
ObjectMemory changed:#returnFromSnapshot. |
|
3891 |
] |
|
7039
6f1c02381145
Do not keep reference to start block handler process.
Stefan Vogel <sv@exept.de>
parents:
7000
diff
changeset
|
3892 |
|
7040 | 3893 |
] newProcess. |
3894 |
||
9043
e6106f500263
do not use numeric process prios
Claus Gittinger <cg@exept.de>
parents:
9036
diff
changeset
|
3895 |
process priority:(Processor userSchedulingPriority). |
7043
d88be9c553d2
Release references to processes in #mainStartup:
Stefan Vogel <sv@exept.de>
parents:
7040
diff
changeset
|
3896 |
process name:'start block handler'. |
d88be9c553d2
Release references to processes in #mainStartup:
Stefan Vogel <sv@exept.de>
parents:
7040
diff
changeset
|
3897 |
process beGroupLeader. |
d88be9c553d2
Release references to processes in #mainStartup:
Stefan Vogel <sv@exept.de>
parents:
7040
diff
changeset
|
3898 |
process resume. |
d88be9c553d2
Release references to processes in #mainStartup:
Stefan Vogel <sv@exept.de>
parents:
7040
diff
changeset
|
3899 |
process := nil. |
1650
b4b36961d1bc
Add StartBlocks and ImageStartBlocks.
Stefan Vogel <sv@exept.de>
parents:
1647
diff
changeset
|
3900 |
|
10139
a3f6265978ad
Start bachgroundCollector and -Finalizer in mainStartup
Stefan Vogel <sv@exept.de>
parents:
10131
diff
changeset
|
3901 |
ObjectMemory startBackgroundCollectorAt:5. |
a3f6265978ad
Start bachgroundCollector and -Finalizer in mainStartup
Stefan Vogel <sv@exept.de>
parents:
10131
diff
changeset
|
3902 |
ObjectMemory startBackgroundFinalizationAt:5. |
1650
b4b36961d1bc
Add StartBlocks and ImageStartBlocks.
Stefan Vogel <sv@exept.de>
parents:
1647
diff
changeset
|
3903 |
|
2074
01f7e1396c18
fixed standalone startup (broke when startupblocks where invented ...)
Claus Gittinger <cg@exept.de>
parents:
2050
diff
changeset
|
3904 |
"/ start a process, which evaluates the startupClass>>startupSelector |
01f7e1396c18
fixed standalone startup (broke when startupblocks where invented ...)
Claus Gittinger <cg@exept.de>
parents:
2050
diff
changeset
|
3905 |
"/ message. |
01f7e1396c18
fixed standalone startup (broke when startupblocks where invented ...)
Claus Gittinger <cg@exept.de>
parents:
2050
diff
changeset
|
3906 |
|
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3907 |
(StartupClass notNil and:[StartupSelector notNil]) ifTrue:[ |
19788 | 3908 |
" |
3909 |
allow more customization by reading an image specific rc-file |
|
3910 |
" |
|
3911 |
thisIsARestart ifTrue:[ |
|
3912 |
(imageName asFilename hasSuffix:'img') ifTrue:[ |
|
3913 |
imageName := imageName copyButLast:4 |
|
3914 |
]. |
|
3915 |
self fileIn:(imageName , '.rc') |
|
3916 |
]. |
|
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3917 |
|
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3918 |
"/ Display notNil ifTrue:[ |
6559
2ec6d0d1b821
Changed Workstation initialization
Stefan Vogel <sv@exept.de>
parents:
6539
diff
changeset
|
3919 |
"/ Display exitOnLastClose:true. |
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3920 |
"/ ]. |
2086 | 3921 |
"/ Processor exitWhenNoMoreUserProcesses:true. |
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3922 |
|
19788 | 3923 |
process := [ |
3924 |
'Smalltalk [info]: startup process 2 active.' infoPrintCR. |
|
3925 |
StandAlone ifTrue:[ |
|
3926 |
AbortOperationRequest handle:[:ex | |
|
3927 |
'Smalltalk [info]: aborted - exit.' infoPrintCR. |
|
3928 |
OperatingSystem exit:1 |
|
3929 |
] do:[ |
|
3930 |
('Smalltalk [info]: call ',StartupSelector,' of ',StartupClass name,' (1)') infoPrintCR. |
|
3931 |
StartupClass perform:StartupSelector withArguments:StartupArguments. |
|
3932 |
] |
|
3933 |
] ifFalse:[ |
|
3934 |
('Smalltalk [info]: call ',StartupSelector,' of ',StartupClass name,' (2)') infoPrintCR. |
|
3935 |
StartupClass perform:StartupSelector withArguments:StartupArguments. |
|
3936 |
]. |
|
3937 |
||
3938 |
"/ |
|
3939 |
"/ non-GUI apps exit after the startup; |
|
3940 |
"/ assume that GUI apps have created & opened some view ... |
|
3941 |
"/ |
|
3942 |
Display isNil ifTrue:[ |
|
3943 |
'Smalltalk [info]: no Display - exit.' infoPrintCR. |
|
3944 |
Smalltalk exit:11. |
|
3945 |
]. |
|
16666 | 3946 |
"/ "/ |
3947 |
"/ "/ GUI apps exit after the last user process has finished |
|
3948 |
"/ "/ |
|
3949 |
"/ Display exitOnLastClose:true. |
|
3950 |
"/ Processor exitWhenNoMoreUserProcesses:true. |
|
19788 | 3951 |
] newProcess. |
3952 |
process priority:(Processor userSchedulingPriority). |
|
3953 |
process name:'main'. |
|
3954 |
process beGroupLeader. |
|
3955 |
process resume. |
|
3956 |
process := nil. "do not refer to process" |
|
11681
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3957 |
]. |
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3958 |
|
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3959 |
StandAlone ifTrue:[ |
19788 | 3960 |
Display notNil ifTrue:[ |
3961 |
FlyByHelp notNil ifTrue:[ |
|
3962 |
FlyByHelp start |
|
3963 |
]. |
|
3964 |
]. |
|
16211 | 3965 |
]. |
3966 |
||
3967 |
Display notNil ifTrue:[ |
|
19788 | 3968 |
Display exitOnLastClose:true. |
16211 | 3969 |
]. |
11681
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3970 |
" |
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3971 |
if view-classes exist, start dispatching; |
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3972 |
otherwise go into a read-eval-print loop |
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3973 |
" |
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3974 |
((Display notNil and:[graphicalMode]) |
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3975 |
or:[process notNil |
13851
5ab434e0a636
changed: #mainStartup: for scripting stand alone apps
Claus Gittinger <cg@exept.de>
parents:
13850
diff
changeset
|
3976 |
or:[HeadlessOperation |
5ab434e0a636
changed: #mainStartup: for scripting stand alone apps
Claus Gittinger <cg@exept.de>
parents:
13850
diff
changeset
|
3977 |
or:[StandAlone]]]) ifTrue:[ |
19788 | 3978 |
Processor exitWhenNoMoreUserProcesses:true. |
3979 |
Processor dispatchLoop. |
|
3980 |
"done - the last process finished" |
|
3981 |
'Smalltalk [info]: last process finished - exit.' infoPrintCR. |
|
11681
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3982 |
] ifFalse:[ |
19788 | 3983 |
StandAlone ifFalse:[ |
3984 |
self readEvalPrint |
|
3985 |
] |
|
11681
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3986 |
]. |
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3987 |
|
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3988 |
self exit |
4c274a7ef60c
Fix stc compile error in prev change
Stefan Vogel <sv@exept.de>
parents:
11679
diff
changeset
|
3989 |
|
13526 | 3990 |
"Created: / 18-07-1996 / 21:07:39 / cg" |
3991 |
"Modified: / 09-09-1996 / 17:42:50 / stefan" |
|
13893 | 3992 |
"Modified: / 07-01-2012 / 12:59:23 / cg" |
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3993 |
! |
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
3994 |
|
10641 | 3995 |
openDisplay |
3996 |
"try to open a display connection. |
|
3997 |
If so, also read display- and keyboard.rc" |
|
3998 |
||
13385 | 3999 |
|commandName| |
4000 |
||
4001 |
commandName := Smalltalk commandName. |
|
4002 |
(commandName, ' [info]: opening display...') infoPrintCR. |
|
10649 | 4003 |
|
10641 | 4004 |
Display isNil ifTrue:[ |
18668 | 4005 |
Screen notNil ifTrue:[ |
4006 |
[ |
|
4007 |
Screen openDefaultDisplay:nil. |
|
4008 |
] on:Screen deviceOpenErrorSignal do:[:ex| |
|
4009 |
('%1 [error]: No display connection to: %2' bindWith:commandName with:ex parameter) errorPrintCR. |
|
4010 |
(commandName, ' [info]: Either set the DISPLAY environment variable,') infoPrintCR. |
|
4011 |
(commandName, ' [info]: or start smalltalk with a -display argument.') infoPrintCR. |
|
4012 |
HeadlessOperation == true ifFalse:[ |
|
4013 |
OperatingSystem exit:1. |
|
4014 |
]. |
|
4015 |
]. |
|
4016 |
||
4017 |
Display notNil ifTrue:[ |
|
4018 |
(self secureFileIn:'display.rc') ifFalse:[ |
|
4019 |
"/ 'Smalltalk [warning]: no display.rc found; screen setting might be wrong.' errorPrintCR. |
|
4020 |
(self secureFileIn:'keyboard.rc') ifFalse:[ |
|
4021 |
"/ 'Smalltalk [warning]: no keyboard.rc found; shortkey setting might be wrong.' errorPrintCR. |
|
4022 |
] |
|
4023 |
] |
|
4024 |
]. |
|
4025 |
] |
|
10641 | 4026 |
] |
4027 |
||
4028 |
"Created: / 06-12-2006 / 15:38:17 / cg" |
|
4029 |
! |
|
4030 |
||
4031 |
readEvalPrint |
|
4032 |
"{ Pragma: +optSpace }" |
|
4033 |
||
16090 | 4034 |
Transcript showCR:(self hello). |
4035 |
Transcript showCR:(self copyrightString). |
|
4036 |
Transcript cr. |
|
4037 |
Transcript showCR:'Read-eval-print loop; exit with "#exit"; help with "?"'. |
|
4038 |
||
16170
ca4d03def070
endOfDipatch if running scripts
Claus Gittinger <cg@exept.de>
parents:
16164
diff
changeset
|
4039 |
ReadEvalPrintLoop new |
18668 | 4040 |
prompt:'ST> '; |
4041 |
doChunkFormat:false; |
|
4042 |
error:Stderr; |
|
4043 |
readEvalPrintLoop |
|
10641 | 4044 |
|
4045 |
"Modified: / 07-12-2006 / 17:35:19 / cg" |
|
4046 |
! |
|
4047 |
||
4048 |
restart |
|
4049 |
"startup after an image has been loaded; |
|
18385 | 4050 |
This is called by the VM's main entry - you should not find senders from Smalltalk. |
4051 |
||
10641 | 4052 |
there are three change-notifications made to dependents of ObjectMemory, |
4053 |
which allow a stepwise re-init: #earlyRestart, #restarted and #returnFromSnapshot. |
|
4054 |
||
4055 |
#earlySystemInstallation is sent for ST80 compatibility |
|
4056 |
||
4057 |
#earlyRestart is send first, nothing has been setup yet. |
|
18668 | 4058 |
(should be used to flush all device dependent entries) |
10641 | 4059 |
|
4060 |
#restarted is send right after. |
|
18668 | 4061 |
(should be used to recreate external resources (fds, bitmaps etc) |
10641 | 4062 |
|
4063 |
#returnFromSnapshot is sent last |
|
18668 | 4064 |
(should be used to restart processes, reOpen Streams which cannot |
4065 |
be automatically be reopened (i.e. Sockets, Pipes) and so on. |
|
4066 |
(Notice that positionable fileStreams are already reopened and repositioned) |
|
10641 | 4067 |
" |
4068 |
||
4069 |
|deb insp transcript idx| |
|
4070 |
||
4071 |
"/ |
|
4072 |
"/ when we arrive here, all objects from our previous life |
|
4073 |
"/ have been reloaded - however, some may still contain invalid device |
|
4074 |
"/ handles, display information etc. |
|
4075 |
"/ also, dynamically loaded modules have not yet been reloaded yet. |
|
4076 |
"/ and the concrete OS, concrete FileName etc. are still refering to |
|
4077 |
"/ the previous classes. |
|
4078 |
||
4079 |
Initializing := true. |
|
4080 |
AbstractOperatingSystem initializeConcreteClass. |
|
4081 |
||
4082 |
ImageRestartTime := Timestamp now. |
|
4083 |
||
4084 |
CommandLine := CommandLineArguments copy. |
|
4085 |
CommandLineArguments := CommandLineArguments asOrderedCollection. |
|
4086 |
CommandName := CommandLineArguments removeFirst. "/ the command |
|
4087 |
||
4088 |
idx := CommandLineArguments indexOf:'-q'. |
|
4089 |
idx == 0 ifTrue:[ |
|
18668 | 4090 |
idx := CommandLineArguments indexOf:'--silent'. |
10641 | 4091 |
]. |
4092 |
idx ~~ 0 ifTrue:[ |
|
18668 | 4093 |
Object infoPrinting:false. |
4094 |
ObjectMemory infoPrinting:false. |
|
4095 |
CommandLineArguments removeAtIndex:idx. |
|
16269 | 4096 |
]. |
4097 |
||
10641 | 4098 |
"/ start catching SIGSEGV and SIGBUS |
4099 |
OperatingSystem enableHardSignalInterrupts. |
|
4100 |
||
4101 |
"/ reinit Filename |
|
4102 |
Filename reinitialize. |
|
4103 |
||
4104 |
"/ flush cached path directories (may have changed in the meanwhile) |
|
4105 |
self flushPathCaches. |
|
15334 | 4106 |
self reinitializePackagePath. |
10641 | 4107 |
|
4108 |
"/ reinit the default streams: Stdin, Stdout and Stderr |
|
4109 |
"/ after that, we can write to stderr. |
|
4110 |
self reinitStandardStreams. |
|
4111 |
||
4112 |
"/ redirect Transcript to Stderr during startup |
|
4113 |
transcript := Transcript. |
|
4114 |
Transcript := Stderr. |
|
4115 |
||
4116 |
"/ temporary switch back to dumb interface - |
|
4117 |
"/ to handle errors while view-stuff is not yet reinitialized |
|
4118 |
insp := Inspector. |
|
4119 |
deb := Debugger. |
|
4120 |
deb notNil ifTrue:[ |
|
18668 | 4121 |
deb reinitialize |
10641 | 4122 |
]. |
4123 |
Inspector := MiniInspector. |
|
4124 |
Debugger := MiniDebugger. |
|
4125 |
||
4126 |
"/ reload any dynamically loaded objects. |
|
4127 |
"/ this must be done before doing anything else below, |
|
4128 |
"/ because the Processor may restart processes which use |
|
4129 |
"/ this code. |
|
4130 |
"/ Also, a dynamic object might be registered as dependent of |
|
4131 |
"/ ObjectFileLoader; therefore, must reload before doing any notifications. |
|
4132 |
||
4133 |
ObjectFileLoader notNil ifTrue:[ |
|
18668 | 4134 |
ObjectFileLoader reloadAllRememberedObjectFiles. |
16269 | 4135 |
]. |
4136 |
||
10641 | 4137 |
"/ invalidate all display connections. |
4138 |
"/ This is required to avoid trouble if someone accesses |
|
4139 |
"/ a display during early startup. |
|
4140 |
Screen notNil ifTrue:[ |
|
18668 | 4141 |
Screen allScreens do:[:eachDisplay | |
4142 |
eachDisplay invalidateConnection. |
|
4143 |
]. |
|
10641 | 4144 |
]. |
4145 |
||
4146 |
ObjectMemory changed:#earlySystemInstallation. |
|
4147 |
||
4148 |
"/ reinitialize the Processor - restartable processes |
|
4149 |
"/ are now restarted here (but not yet scheduled). |
|
4150 |
Processor reinitialize. |
|
4151 |
||
4152 |
"/ flush device handles & recreate OS resources (if possible) |
|
4153 |
"/ (mostly view/GC/color & font stuff) |
|
4154 |
ObjectMemory |
|
18668 | 4155 |
changed:#earlyRestart; changed:#restarted. |
16269 | 4156 |
|
10641 | 4157 |
"/ start catching SIGINT and SIGQUIT |
4158 |
OperatingSystem enableUserInterrupts. |
|
4159 |
OperatingSystem enableCrashSignalInterrupts. |
|
12782 | 4160 |
ObjectMemory restoreGarbageCollectorSettings. |
10641 | 4161 |
|
4162 |
"/ give user a chance to re-customize things in smalltalk_r.rc. |
|
4163 |
"/ reading if smalltalk_r.rc may be suppressed by the --faststart argument. |
|
4164 |
idx := CommandLineArguments indexOf:'--faststart'. |
|
4165 |
idx == 0 ifTrue:[ |
|
18668 | 4166 |
idx := CommandLineArguments indexOf:'--fastStart'. |
10641 | 4167 |
]. |
4168 |
idx ~~ 0 ifTrue:[ |
|
18668 | 4169 |
CommandLineArguments removeAtIndex:idx. |
10641 | 4170 |
] ifFalse:[ |
18668 | 4171 |
CallbackSignal := QuerySignal new. |
4172 |
[ |
|
4173 |
Class withoutUpdatingChangesDo:[ |
|
4174 |
(self fileIn:(self commandName , '_r.rc')) ifFalse:[ |
|
4175 |
"no _r.rc file where executable is; try default smalltalk_r.rc" |
|
4176 |
self fileIn:'smalltalk_r.rc' |
|
4177 |
]. |
|
4178 |
] |
|
4179 |
] on:CallbackSignal do:[:ex| |
|
4180 |
"/ now, display and view-stuff works; |
|
4181 |
"/ back to the previous debugging interface |
|
4182 |
Inspector := insp. |
|
4183 |
Debugger := deb. |
|
4184 |
||
4185 |
"/ reinstall Transcript, if not changed during restart. |
|
4186 |
"/ if there was no Transcript, go to stderr |
|
4187 |
(transcript notNil and:[Transcript == Stderr]) ifTrue:[ |
|
4188 |
Transcript := transcript. |
|
4189 |
]. |
|
4190 |
Initializing := false. |
|
4191 |
ex proceed. |
|
4192 |
]. |
|
4193 |
CallbackSignal := nil. |
|
10641 | 4194 |
]. |
4195 |
||
4196 |
"/ reinitialization (restart) of Display is normally performed |
|
4197 |
"/ in the restart script. If this has not been run for some reason, |
|
4198 |
"/ do in now. |
|
4199 |
Initializing ifTrue:[ |
|
18668 | 4200 |
Display notNil ifTrue:[ |
4201 |
[ |
|
4202 |
Display reinitializeFor:Screen defaultDisplayName. |
|
4203 |
] on:Screen deviceOpenErrorSignal do:[ |
|
4204 |
'Smalltalk [error]: Cannot restart connection to: ' errorPrint. |
|
4205 |
Screen defaultDisplayName errorPrintCR. |
|
4206 |
OperatingSystem exit:1. |
|
4207 |
]. |
|
4208 |
]. |
|
4209 |
"/ now, display and view-stuff works; |
|
4210 |
"/ back to the previous debugging interface |
|
4211 |
||
4212 |
Inspector := insp. |
|
4213 |
Debugger := deb. |
|
4214 |
||
4215 |
"/ reinstall Transcript, if not changed during restart. |
|
4216 |
"/ if there was no Transcript, go to stderr |
|
4217 |
||
4218 |
(transcript notNil and:[Transcript == Stderr]) ifTrue:[ |
|
4219 |
Transcript := transcript. |
|
4220 |
]. |
|
4221 |
Initializing := false. |
|
10641 | 4222 |
]. |
4223 |
Screen notNil ifTrue:[ |
|
18668 | 4224 |
"clean up leftover screens (and views) that haven't been reopened. |
4225 |
Operate on a copy, since brokenConnection removes us from AllScreens" |
|
4226 |
Screen allScreens copy do:[:eachDisplay | |
|
4227 |
eachDisplay isOpen ifFalse:[ |
|
4228 |
'Smalltalk [info]: cannot reopen secondary display: ' errorPrint. |
|
4229 |
eachDisplay errorPrintCR. |
|
4230 |
eachDisplay cleanupAfterDispatch; brokenConnection. |
|
4231 |
] |
|
4232 |
]. |
|
10641 | 4233 |
]. |
4234 |
||
4235 |
deb := insp := transcript := nil. "avoid dangling refs" |
|
13526 | 4236 |
(StartupClass perform:#keepSplashWindowOpen ifNotUnderstood:[false]) ifFalse:[ |
18668 | 4237 |
self hideSplashWindow. "/ if there is one, it's now time to hide it |
13526 | 4238 |
]. |
10641 | 4239 |
self mainStartup:true |
4240 |
||
13526 | 4241 |
"Modified: / 03-08-1999 / 09:42:21 / stefan" |
4242 |
"Modified: / 29-07-2011 / 17:58:23 / cg" |
|
1 | 4243 |
! |
4244 |
||
11399 | 4245 |
showSplashMessage:aString |
4246 |
"put the message into the splash screen (if there is one). |
|
4247 |
Use this for messages during startup" |
|
4248 |
||
4249 |
self showSplashMessage:aString color:nil. |
|
4250 |
! |
|
4251 |
||
11388 | 4252 |
showSplashMessage:aMessageStringOrNil color:rgbValueOrNil |
11389 | 4253 |
"put the message into the splash screen (if there is one)." |
4254 |
||
11388 | 4255 |
%{ |
4256 |
#ifdef WIN32 |
|
4257 |
extern void __win32_splashMessage(); |
|
4258 |
char *msg = (char *)0; |
|
4259 |
int clr = 0; |
|
4260 |
||
12481
805176d238d2
change __isString() to __isStringLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
12413
diff
changeset
|
4261 |
if (__isStringLike(aMessageStringOrNil)) { |
18668 | 4262 |
msg = __stringVal(aMessageStringOrNil); |
11388 | 4263 |
} |
4264 |
if (__isSmallInteger(rgbValueOrNil)) { |
|
18668 | 4265 |
clr = __intVal(rgbValueOrNil); |
4266 |
__win32_splashMessageColor(clr); |
|
11388 | 4267 |
} |
4268 |
__win32_splashMessage(msg); |
|
4269 |
#endif |
|
4270 |
%} |
|
4271 |
! |
|
4272 |
||
4273 |
splashInfo:aString |
|
11389 | 4274 |
"like infoPrintCR, |
4275 |
but in addition put the message into the splash screen (if there is one). |
|
4276 |
Use this for info messages during startup" |
|
4277 |
||
12883 | 4278 |
aString notNil ifTrue:[ aString infoPrintCR ]. |
11388 | 4279 |
self showSplashMessage:aString color:nil. |
4280 |
! |
|
4281 |
||
7563 | 4282 |
start |
4283 |
"main startup, if there is a Display, initialize it |
|
4284 |
and start dispatching; otherwise go into a read-eval-print loop." |
|
617 | 4285 |
|
15872 | 4286 |
|idx graphicalMode arg didReadRCFile keepSplashWindow| |
960
e3b75f50d0cd
changes for standAlone operation
Claus Gittinger <cg@exept.de>
parents:
948
diff
changeset
|
4287 |
|
19597 | 4288 |
graphicalMode := Smalltalk isSmalltalkDevelopmentSystem. |
617 | 4289 |
Initializing := true. |
4290 |
||
15872 | 4291 |
keepSplashWindow := StartupClass perform:#keepSplashWindowOpen ifNotUnderstood:[false]. |
4292 |
"/ now done AFTER reading smalltalk.rc |
|
4293 |
"/ keepSplashWindow ifFalse:[ |
|
4294 |
"/ self hideSplashWindow. "/ if there is one, it's now time to hide it |
|
4295 |
"/ ]. |
|
13526 | 4296 |
|
617 | 4297 |
" |
4298 |
while reading patches- and rc-file, do not add things into change-file |
|
4299 |
" |
|
4300 |
Class withoutUpdatingChangesDo:[ |
|
18669 | 4301 |
|commandFile defaultRC prevCatchSetting |
4302 |
isEval isPrint isFilter isRepl idxFileArg process| |
|
4303 |
||
4304 |
isEval := isPrint := isFilter := isRepl := false. |
|
4305 |
didReadRCFile := false. |
|
4306 |
||
4307 |
StandAlone ifFalse:[ |
|
4308 |
self initializeVerboseFlags. |
|
4309 |
||
4310 |
"/ |
|
4311 |
"/ look for any '-q', '-e', '-l' or '-f' command line arguments |
|
4312 |
"/ and handle them; |
|
4313 |
"/ read startup and patches file |
|
4314 |
"/ |
|
4315 |
idx := CommandLineArguments indexOfAny:#('-R' '--repl'). |
|
4316 |
isRepl := (idx ~~ 0). |
|
4317 |
||
4318 |
idx := CommandLineArguments indexOfAny:#('-q' '--silent'). |
|
4319 |
idx ~~ 0 ifTrue:[ |
|
4320 |
Object infoPrinting:false. |
|
4321 |
ObjectMemory infoPrinting:false. |
|
4322 |
CommandLineArguments removeAtIndex:idx. |
|
4323 |
SilentLoading := true. |
|
4324 |
]. |
|
4325 |
||
4326 |
[ |
|
4327 |
idx := CommandLineArguments indexOfAny:#('-pp' '--packagePath'). |
|
4328 |
idx ~~ 0 |
|
4329 |
] whileTrue:[ |
|
4330 |
arg := CommandLineArguments at:idx + 1. |
|
4331 |
CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx. |
|
4332 |
self packagePath addLast:arg. |
|
4333 |
VerboseStartup == true ifTrue:[ |
|
4334 |
('Smalltalk [info]: add to packagePath: "', arg, '".') infoPrintCR. |
|
4335 |
]. |
|
4336 |
]. |
|
4337 |
||
4338 |
[ |
|
4339 |
idx := CommandLineArguments indexOfAny:#('-l' '--load'). |
|
4340 |
idx ~~ 0 |
|
4341 |
] whileTrue:[ |
|
4342 |
arg := CommandLineArguments at:idx + 1. |
|
4343 |
CommandLineArguments removeAtIndex:idx+1; removeAtIndex:idx. |
|
4344 |
arg asFilename exists ifTrue:[ |
|
4345 |
Smalltalk fileIn:arg |
|
4346 |
] ifFalse:[ |
|
4347 |
Smalltalk loadPackage:arg |
|
4348 |
]. |
|
4349 |
]. |
|
4350 |
||
4351 |
"/ look for a '-e filename' or '--execute filename' argument |
|
4352 |
"/ this will force fileIn of filename only, no standard startup. |
|
4353 |
||
4354 |
idx := CommandLineArguments indexOfAny:#('-e' '--execute' '--script'). |
|
4355 |
idx ~~ 0 ifTrue:[ |
|
4356 |
SilentLoading := true. |
|
4357 |
CommandName := arg := CommandLineArguments at:idx + 1. |
|
4358 |
||
4359 |
CommandLineArguments |
|
4360 |
removeAtIndex:idx+1; removeAtIndex:idx. |
|
4361 |
||
4362 |
self startSchedulerAndBackgroundCollector. |
|
4363 |
keepSplashWindow ifFalse:[ self hideSplashWindow ]. |
|
4364 |
Initializing := false. |
|
4365 |
||
4366 |
process := [ |
|
4367 |
VerboseStartup == true ifTrue:[ |
|
4368 |
('Smalltalk [info]: reading script from: "', arg, '".') infoPrintCR. |
|
4369 |
]. |
|
4370 |
UserInterrupt handle:[:ex | |
|
19427 | 4371 |
Debugging == true ifTrue:[ |
19429 | 4372 |
'user interrupt (type "c" to continue; "x" to exit; "?" for help).' errorPrintCR. |
4373 |
"/ thisContext fullPrintAll. |
|
4374 |
MiniDebugger enter. |
|
4375 |
ex proceed. |
|
19426 | 4376 |
]. |
18669 | 4377 |
self exit:128+(OperatingSystem sigINT). |
4378 |
] do:[ |
|
4379 |
arg = '-' ifTrue:[ |
|
4380 |
self fileInStream:Stdin |
|
4381 |
lazy:nil |
|
4382 |
silent:nil |
|
4383 |
logged:false |
|
4384 |
addPath:nil |
|
4385 |
] ifFalse:[ |
|
4386 |
IsSTScript := true. |
|
4387 |
self fileIn:arg. |
|
4388 |
]. |
|
4389 |
]. |
|
4390 |
"/ after the script, if Screen has been opened and there are any open windows, |
|
4391 |
"/ then do not exit |
|
4392 |
Display notNil ifTrue:[ |
|
4393 |
Display exitOnLastClose:true. |
|
4394 |
Display checkForEndOfDispatch. |
|
4395 |
Processor exitWhenNoMoreUserProcesses:true. |
|
4396 |
] ifFalse:[ |
|
4397 |
self exit. |
|
4398 |
]. |
|
4399 |
] newProcess. |
|
4400 |
process priority:(Processor userSchedulingPriority). |
|
4401 |
process name:'main'. |
|
4402 |
process beGroupLeader. |
|
4403 |
process resume. |
|
4404 |
||
4405 |
Processor dispatchLoop. |
|
4406 |
self exit |
|
4407 |
]. |
|
4408 |
||
4409 |
"look for a '-f filename' or '--file filename' argument |
|
4410 |
if scripting, this is loaded before -P, -E or -R action. |
|
4411 |
if not scripting, this will force evaluation of filename instead of smalltalk.rc" |
|
4412 |
idxFileArg := CommandLineArguments indexOfAny:#('-f' '--file'). |
|
4413 |
(idxFileArg ~~ 0) ifTrue:[ |
|
4414 |
commandFile := CommandLineArguments at:idxFileArg+1. |
|
4415 |
CommandLineArguments removeAtIndex:idxFileArg+1; removeAtIndex:idxFileArg. |
|
4416 |
]. |
|
4417 |
||
4418 |
"/ look for a '-E expr' or '--eval expr' argument (-P or --print to print the result of evaluation) |
|
4419 |
"/ or -F/--filter or a '--repl' argument |
|
4420 |
"/ E, P and F this will force evaluation of expr only, no standard startup |
|
4421 |
"/ repl go into an interactive loop. |
|
4422 |
idx := CommandLineArguments indexOfAny:#('-E' '--eval'). |
|
4423 |
(isEval := (idx ~~ 0)) ifFalse:[ |
|
4424 |
idx := CommandLineArguments indexOfAny:#('-P' '--print'). |
|
4425 |
(isPrint := (idx ~~ 0)) ifFalse:[ |
|
4426 |
idx := CommandLineArguments indexOfAny:#('-F' '--filter'). |
|
4427 |
(isFilter := (idx ~~ 0)) ifFalse:[ |
|
4428 |
idx := CommandLineArguments indexOfAny:#('-R' '--repl'). |
|
4429 |
isRepl := (idx ~~ 0) |
|
4430 |
]. |
|
4431 |
]. |
|
4432 |
]. |
|
4433 |
||
4434 |
(isEval | isPrint | isFilter | isRepl) ifTrue:[ |
|
4435 |
isRepl ifFalse:[ |
|
4436 |
CommandLineArguments size <= idx ifTrue:[ |
|
4437 |
'stx: missing argument after -E/-P/-F' errorPrintCR. |
|
4438 |
self exit:1. |
|
4439 |
]. |
|
4440 |
arg := CommandLineArguments at:idx + 1. |
|
4441 |
CommandLineArguments removeAtIndex:idx+1. |
|
4442 |
]. |
|
4443 |
CommandLineArguments removeAtIndex:idx. |
|
4444 |
||
4445 |
self startSchedulerAndBackgroundCollector. |
|
4446 |
keepSplashWindow ifFalse:[ self hideSplashWindow ]. |
|
4447 |
Initializing := false. |
|
4448 |
||
4449 |
"/ enable this, so we can provide $1..$n in the script |
|
4450 |
ParserFlags allowDollarInIdentifier:true. |
|
4451 |
ParserFlags warnDollarInIdentifier:false. |
|
4452 |
||
4453 |
"/ add bindings for arguments |
|
4454 |
CommandLineArguments doWithIndex:[:arg :i | |
|
4455 |
Workspace workspaceVariableAt:('_$',i printString) put:arg. |
|
4456 |
]. |
|
4457 |
||
4458 |
"/ all of the above allow for a -f file to be loaded before any other action |
|
4459 |
(commandFile notNil) ifTrue:[ |
|
4460 |
VerboseStartup == true ifTrue:[ |
|
4461 |
('Smalltalk [info]: reading command file from: "', commandFile, '".') infoPrintCR. |
|
4462 |
]. |
|
4463 |
(self secureFileIn:commandFile) ifFalse:[ |
|
4464 |
('Smalltalk [error]: "', commandFile, '" not found.') errorPrintCR. |
|
4465 |
OperatingSystem exit:1. |
|
4466 |
] |
|
4467 |
]. |
|
4468 |
||
4469 |
isRepl ifTrue:[ |
|
4470 |
self readEvalPrint. |
|
4471 |
self exit. |
|
4472 |
]. |
|
4473 |
||
4474 |
process := [ |
|
4475 |
VerboseStartup == true ifTrue:[ |
|
4476 |
('Smalltalk [info]: executing expression: "', arg, '".') infoPrintCR. |
|
4477 |
]. |
|
4478 |
UserInterrupt handle:[:ex | |
|
19427 | 4479 |
Debugging == true ifTrue:[ |
19429 | 4480 |
'user interrupt (type "c" to continue; "x" to exit; "?" for help).' errorPrintCR. |
4481 |
"/ thisContext fullPrintAll. |
|
4482 |
MiniDebugger enter. |
|
4483 |
ex proceed. |
|
19426 | 4484 |
]. |
18669 | 4485 |
self exit:128+(OperatingSystem sigINT). |
4486 |
] do:[ |
|
4487 |
isFilter ifTrue:[ |
|
4488 |
"/ --filter - apply code to each input line. |
|
4489 |
"/ compile code only once |
|
4490 |
Compiler |
|
4491 |
compile:'doIt:line ',arg |
|
4492 |
forClass:String |
|
4493 |
notifying:(EvalScriptingErrorHandler new source:arg). |
|
4494 |
||
4495 |
[Stdin atEnd] whileFalse:[ |
|
4496 |
|line| |
|
4497 |
||
4498 |
line := Stdin nextLine. |
|
4499 |
line doIt:line. |
|
4500 |
]. |
|
4501 |
] ifFalse:[ |
|
4502 |
"/ --print or --eval |
|
4503 |
|rslt| |
|
4504 |
||
4505 |
rslt := Parser new |
|
4506 |
evaluate:arg |
|
4507 |
notifying:(EvalScriptingErrorHandler new source:arg) |
|
4508 |
compile:true. |
|
4509 |
isPrint ifTrue:[ |
|
4510 |
rslt printCR. |
|
4511 |
]. |
|
4512 |
]. |
|
4513 |
]. |
|
4514 |
||
4515 |
"/ after the script, if Screen has been opened and there are any open windows, |
|
4516 |
"/ then do not exit |
|
4517 |
Display notNil ifTrue:[ |
|
4518 |
Display exitOnLastClose:true. |
|
4519 |
Display checkForEndOfDispatch. |
|
4520 |
Processor exitWhenNoMoreUserProcesses:true. |
|
4521 |
VerboseStartup == true ifTrue:[ |
|
4522 |
('Smalltalk [info]: display opened.') infoPrintCR. |
|
4523 |
]. |
|
4524 |
] ifFalse:[ |
|
4525 |
VerboseStartup == true ifTrue:[ |
|
4526 |
('Smalltalk [info]: no display - exit after script.') infoPrintCR. |
|
4527 |
]. |
|
4528 |
self exit. |
|
4529 |
]. |
|
4530 |
] newProcess. |
|
4531 |
process priority:(Processor userSchedulingPriority). |
|
4532 |
process name:'main'. |
|
4533 |
process beGroupLeader. |
|
4534 |
process resume. |
|
4535 |
||
4536 |
Processor dispatchLoop. |
|
4537 |
VerboseStartup == true ifTrue:[ |
|
4538 |
('Smalltalk [info]: exit normally.') infoPrintCR. |
|
4539 |
]. |
|
4540 |
self exit |
|
4541 |
]. |
|
4542 |
]. |
|
4543 |
||
4544 |
commandFile notNil ifTrue:[ |
|
4545 |
SilentLoading := true. "/ suppress the hello & copyright messages |
|
4546 |
self addStartBlock: |
|
4547 |
[ |
|
4548 |
(self secureFileIn:commandFile) ifFalse:[ |
|
4549 |
('Smalltalk [error]: startup file "', commandFile, '" not found.') errorPrintCR. |
|
4550 |
OperatingSystem exit:1. |
|
4551 |
]. |
|
4552 |
]. |
|
16091 | 4553 |
|
4554 |
"/ self startSchedulerAndBackgroundCollector. |
|
4555 |
"/ keepSplashWindow ifFalse:[ self hideSplashWindow ]. |
|
4556 |
"/ Initializing := false. |
|
4557 |
"/ |
|
4558 |
"/ (self secureFileIn:commandFile) ifFalse:[ |
|
4559 |
"/ ('Smalltalk [error]: startup file "', commandFile, '" not found.') errorPrintCR. |
|
4560 |
"/ OperatingSystem exit:1. |
|
4561 |
"/ ]. |
|
18669 | 4562 |
] ifFalse:[ |
4563 |
"/ look for <command>.rc |
|
4564 |
"/ if not found, read smalltalk.rc (or stxapp.rc for standAlone operation) |
|
4565 |
||
4566 |
commandFile := self commandName asFilename withSuffix:'rc'. |
|
4567 |
(didReadRCFile := commandFile exists and:[self secureFileIn:commandFile]) ifFalse:[ |
|
4568 |
StandAlone ifFalse:[ |
|
4569 |
defaultRC := 'smalltalk.rc' "/asFilename |
|
4570 |
] ifTrue:[ |
|
4571 |
defaultRC := 'stxapp.rc' "/asFilename |
|
4572 |
]. |
|
4573 |
"JV@2011-11-01: DO NOT check defaultRC exist - this prevents smalltalk to |
|
4574 |
to be started with different working directory than stx/projects/smalltalk !!!!!!" |
|
4575 |
||
4576 |
"/didReadRCFile := defaultRC exists and:[self secureFileIn:defaultRC]. |
|
4577 |
didReadRCFile := (self getSystemFileName:defaultRC) notNil |
|
4578 |
and:[self secureFileIn:defaultRC]. |
|
4579 |
didReadRCFile ifFalse:[ |
|
4580 |
StandAlone ifFalse:[ |
|
4581 |
'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR. |
|
4582 |
graphicalMode := false. |
|
4583 |
] |
|
4584 |
] |
|
4585 |
]. |
|
4586 |
||
4587 |
"/ ('StandAlone is %1' bindWith:StandAlone) printCR. |
|
4588 |
"/ ('Headless is %1' bindWith:HeadlessOperation) printCR. |
|
4589 |
"/ ('Display is %1' bindWith:Display) printCR. |
|
4590 |
"/ ('Screen is %1' bindWith:Screen) printCR. |
|
4591 |
||
4592 |
keepSplashWindow ifFalse:[ self hideSplashWindow ]. |
|
4593 |
didReadRCFile ifFalse:[ |
|
4594 |
'private.rc' asFilename exists ifTrue:[ self secureFileIn:'private.rc' ]. |
|
4595 |
||
4596 |
"/ |
|
4597 |
"/ No RC file found; |
|
4598 |
"/ Setup more default stuff |
|
4599 |
"/ |
|
4600 |
StandAlone ifFalse:[ |
|
4601 |
"/ its a smalltalk - proceed in interpreter. |
|
4602 |
'Smalltalk [warning]: no startup rc-file found. Going into line-by-line interpreter.' infoPrintCR. |
|
4603 |
graphicalMode := false. |
|
4604 |
]. |
|
4605 |
||
4606 |
"/ setup more defaults... |
|
13537 | 4607 |
"/ ObjectMemory startBackgroundCollectorAt:5. |
4608 |
"/ ObjectMemory startBackgroundFinalizationAt:5. |
|
18669 | 4609 |
self addStartBlock:[ |
4610 |
self startSchedulerAndBackgroundCollector |
|
4611 |
]. |
|
4612 |
]. |
|
4613 |
]. |
|
4614 |
(CommandLineArguments includes:'--scripting') ifTrue:[ |
|
4615 |
self addStartBlock:[ |
|
4616 |
StandaloneStartup handleScriptingOptionsFromArguments:CommandLineArguments. |
|
4617 |
]. |
|
4618 |
]. |
|
617 | 4619 |
]. |
4620 |
||
10644 | 4621 |
HeadlessOperation ifTrue:[ |
18669 | 4622 |
graphicalMode := false. |
15872 | 4623 |
]. |
4624 |
||
4625 |
keepSplashWindow ifFalse:[ self hideSplashWindow ]. |
|
1578
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
4626 |
self mainStartup:graphicalMode |
9df8cc1ec5c4
start & restart actions merged into a common method.
Claus Gittinger <cg@exept.de>
parents:
1573
diff
changeset
|
4627 |
|
15872 | 4628 |
"Modified: / 17-12-2013 / 16:44:40 / cg" |
13536
839fe9c57304
added: #startSchedulerAndBackgroundCollector
Claus Gittinger <cg@exept.de>
parents:
13532
diff
changeset
|
4629 |
! |
839fe9c57304
added: #startSchedulerAndBackgroundCollector
Claus Gittinger <cg@exept.de>
parents:
13532
diff
changeset
|
4630 |
|
839fe9c57304
added: #startSchedulerAndBackgroundCollector
Claus Gittinger <cg@exept.de>
parents:
13532
diff
changeset
|
4631 |
startSchedulerAndBackgroundCollector |
839fe9c57304
added: #startSchedulerAndBackgroundCollector
Claus Gittinger <cg@exept.de>
parents:
13532
diff
changeset
|
4632 |
Processor startTimeSlicing. |
839fe9c57304
added: #startSchedulerAndBackgroundCollector
Claus Gittinger <cg@exept.de>
parents:
13532
diff
changeset
|
4633 |
Processor supportDynamicPriorities:true. |
13537 | 4634 |
|
4635 |
ObjectMemory startBackgroundCollectorAt:5. |
|
4636 |
ObjectMemory startBackgroundFinalizationAt:5. |
|
13536
839fe9c57304
added: #startSchedulerAndBackgroundCollector
Claus Gittinger <cg@exept.de>
parents:
13532
diff
changeset
|
4637 |
ObjectMemory backgroundCollectProcess priorityRange:(4 to:9). |
839fe9c57304
added: #startSchedulerAndBackgroundCollector
Claus Gittinger <cg@exept.de>
parents:
13532
diff
changeset
|
4638 |
ObjectMemory backgroundFinalizationProcess priorityRange:(4 to:9). |
839fe9c57304
added: #startSchedulerAndBackgroundCollector
Claus Gittinger <cg@exept.de>
parents:
13532
diff
changeset
|
4639 |
|
839fe9c57304
added: #startSchedulerAndBackgroundCollector
Claus Gittinger <cg@exept.de>
parents:
13532
diff
changeset
|
4640 |
"Created: / 31-07-2011 / 20:01:33 / cg" |
11808
14b417cf2b51
Define #startStartBlockProcess
Stefan Vogel <sv@exept.de>
parents:
11690
diff
changeset
|
4641 |
! |
14b417cf2b51
Define #startStartBlockProcess
Stefan Vogel <sv@exept.de>
parents:
11690
diff
changeset
|
4642 |
|
14b417cf2b51
Define #startStartBlockProcess
Stefan Vogel <sv@exept.de>
parents:
11690
diff
changeset
|
4643 |
startStartBlockProcess |
14b417cf2b51
Define #startStartBlockProcess
Stefan Vogel <sv@exept.de>
parents:
11690
diff
changeset
|
4644 |
"at the end of the smalltalk initialization, start all actions that |
14b417cf2b51
Define #startStartBlockProcess
Stefan Vogel <sv@exept.de>
parents:
11690
diff
changeset
|
4645 |
were delayed until the ProcessorScheduler is running in a separate process" |
14b417cf2b51
Define #startStartBlockProcess
Stefan Vogel <sv@exept.de>
parents:
11690
diff
changeset
|
4646 |
|
14b417cf2b51
Define #startStartBlockProcess
Stefan Vogel <sv@exept.de>
parents:
11690
diff
changeset
|
4647 |
|p| |
14b417cf2b51
Define #startStartBlockProcess
Stefan Vogel <sv@exept.de>
parents:
11690
diff
changeset
|
4648 |
|
14b417cf2b51
Define #startStartBlockProcess
Stefan Vogel <sv@exept.de>
parents:
11690
diff
changeset
|
4649 |
p := |
18668 | 4650 |
[ |
4651 |
self executeStartBlocks. |
|
4652 |
] newProcess. |
|
12022 | 4653 |
|
4654 |
p |
|
18668 | 4655 |
priority:(Processor userSchedulingPriority); |
4656 |
name:'start block handler'; |
|
4657 |
beGroupLeader; |
|
4658 |
resume. |
|
13892 | 4659 |
|
13893 | 4660 |
"Modified: / 07-01-2012 / 12:59:01 / cg" |
1097 | 4661 |
! ! |
4662 |
||
13947 | 4663 |
!Smalltalk class methodsFor:'startup and exit'! |
4664 |
||
4665 |
addExitBlock:aBlock |
|
4666 |
"{ Pragma: +optSpace }" |
|
4667 |
||
4668 |
"add a block to be executed when Smalltalk finishes. |
|
4669 |
This feature is currently not used anywhere - but could be useful for |
|
4670 |
cleanup in stand alone applications. |
|
4671 |
||
4672 |
Better use: ObjectMemory>>#addDependent: and handle the change message |
|
4673 |
#aboutToQuit." |
|
4674 |
||
4675 |
ExitBlocks isNil ifTrue:[ |
|
18668 | 4676 |
ExitBlocks := OrderedCollection with:aBlock |
13947 | 4677 |
] ifFalse:[ |
18668 | 4678 |
ExitBlocks add:aBlock |
13947 | 4679 |
] |
4680 |
! |
|
4681 |
||
4682 |
addImageStartBlock:aBlock |
|
4683 |
"{ Pragma: +optSpace }" |
|
4684 |
||
4685 |
"add a blocks to be executed in a separate process after |
|
4686 |
everything has been initialized. |
|
4687 |
These blocks will be executed after an image restart." |
|
4688 |
||
4689 |
ImageStartBlocks isNil ifTrue:[ |
|
18668 | 4690 |
ImageStartBlocks := OrderedCollection with:aBlock |
13947 | 4691 |
] ifFalse:[ |
18668 | 4692 |
ImageStartBlocks add:aBlock |
13947 | 4693 |
] |
4694 |
||
4695 |
"Created: 9.9.1996 / 16:48:20 / stefan" |
|
4696 |
! |
|
4697 |
||
4698 |
addStartBlock:aBlock |
|
15980 | 4699 |
"to be called ONLY during very early startup (before the process scheduler |
4700 |
is started) to add a block to be executed in a separate process after |
|
4701 |
everything has been initialized. |
|
4702 |
Used to allow a startup script (which is executed BEFORE the scheduler and |
|
4703 |
UI display is startup up) to add actions which require those subsystems to |
|
4704 |
be operating. |
|
4705 |
These blocks will be executed only once and not be executed after an image restart. |
|
13947 | 4706 |
Initial processes such as the launcher are usually started here |
15980 | 4707 |
(see smalltalk.rc / private.rc). |
4708 |
ONLY to be called from such an rc file." |
|
13947 | 4709 |
|
4710 |
"{ Pragma: +optSpace }" |
|
4711 |
||
15980 | 4712 |
"/ to protect against "mis-users" of this mehtod... |
4713 |
Initializing ifFalse:[ |
|
18668 | 4714 |
aBlock value |
16170
ca4d03def070
endOfDipatch if running scripts
Claus Gittinger <cg@exept.de>
parents:
16164
diff
changeset
|
4715 |
] ifTrue:[ |
18668 | 4716 |
StartBlocks isNil ifTrue:[ |
4717 |
StartBlocks := OrderedCollection with:aBlock |
|
4718 |
] ifFalse:[ |
|
4719 |
StartBlocks add:aBlock |
|
4720 |
] |
|
15980 | 4721 |
]. |
13947 | 4722 |
|
4723 |
"Created: / 09-09-1996 / 16:46:53 / stefan" |
|
4724 |
"Modified (comment): / 18-08-2011 / 09:18:42 / cg" |
|
4725 |
! |
|
4726 |
||
4727 |
exit |
|
4728 |
"{ Pragma: +optSpace }" |
|
4729 |
||
4730 |
"finish the Smalltalk system" |
|
4731 |
||
4732 |
self exit:0 |
|
4733 |
"not reached" |
|
4734 |
||
4735 |
"Be careful evaluating this |
|
4736 |
Smalltalk exit |
|
4737 |
" |
|
4738 |
! |
|
4739 |
||
4740 |
exit:statusInteger |
|
4741 |
"{ Pragma: +optSpace }" |
|
4742 |
||
4743 |
"finish the Smalltalk system" |
|
4744 |
||
4745 |
ObjectMemory changed:#aboutToExit. "/ for ST/X backward compatibility |
|
4746 |
ObjectMemory changed:#aboutToQuit. "/ for ST-80 compatibility |
|
4747 |
ExitBlocks notNil ifTrue:[ |
|
18668 | 4748 |
ExitBlocks do:[:aBlock | |
4749 |
aBlock value |
|
4750 |
] |
|
13947 | 4751 |
]. |
4752 |
OperatingSystem exit:statusInteger |
|
4753 |
"not reached" |
|
4754 |
||
4755 |
"Be careful evaluating this |
|
4756 |
Smalltalk exit:1 |
|
4757 |
" |
|
19014 | 4758 |
! |
4759 |
||
4760 |
exitOrError:exitCode |
|
4761 |
"exit only if running as standalone application. |
|
4762 |
Raise an error in the development system. |
|
4763 |
Useful for testing standalone apps which should not kill |
|
4764 |
your development system." |
|
4765 |
||
4766 |
self isStandAloneApp ifTrue:[ |
|
4767 |
self exit:exitCode. |
|
4768 |
]. |
|
4769 |
self error:'standalone smalltalk would exit here with exit code: ', exitCode printString. |
|
4770 |
||
4771 |
" |
|
4772 |
self exitOrError:0 |
|
4773 |
" |
|
13947 | 4774 |
! ! |
4775 |
||
1750
36ff7e62388a
care for privateClasses in remove
Claus Gittinger <cg@exept.de>
parents:
1713
diff
changeset
|
4776 |
!Smalltalk class methodsFor:'startup queries'! |
1097 | 4777 |
|
10641 | 4778 |
commandLine |
4779 |
"return the full command line arguments (with which ST/X was started)" |
|
4780 |
||
4781 |
^ CommandLine |
|
4782 |
||
4783 |
" |
|
4784 |
Smalltalk commandLine |
|
4785 |
" |
|
4786 |
||
4787 |
"Created: 19.7.1996 / 11:09:06 / cg" |
|
4788 |
! |
|
4789 |
||
4790 |
commandLineArgumentNamed:aString |
|
16110 | 4791 |
"extract a named argument from the command line arguments. |
4792 |
This searches for the given string in the command line and returns the next argument after it." |
|
10641 | 4793 |
|
4794 |
|args index| |
|
4795 |
||
4796 |
args := self commandLineArguments. |
|
4797 |
index := args indexOf:aString. |
|
4798 |
(index between:1 and:(args size - 1)) ifTrue:[ |
|
18668 | 4799 |
^ args at:index+1 |
10641 | 4800 |
]. |
4801 |
^ nil. |
|
4802 |
||
4803 |
" |
|
4804 |
self commandLineArgumentNamed:'-display' |
|
4805 |
" |
|
4806 |
! |
|
4807 |
||
4808 |
commandLineArguments |
|
4809 |
"return the user command line arguments; |
|
4810 |
This is a collection of strings (separated command line words), |
|
4811 |
from which the internal startup arguments have already been removed. |
|
4812 |
I.e. if started with: 'smalltalk -I -f xxx foo bar baz', |
|
4813 |
the commandLineArguments will be #('foo' 'bar' 'baz'). |
|
4814 |
In contrast, the value returned by #commandLine will be the full set of words." |
|
4815 |
||
4816 |
^ CommandLineArguments |
|
4817 |
||
4818 |
"Modified: 19.7.1996 / 11:11:03 / cg" |
|
4819 |
! |
|
4820 |
||
4821 |
commandName |
|
4822 |
"return the excutables name - this is normally 'stx', |
|
4823 |
but can be something else for standAlone apps." |
|
4824 |
||
4825 |
^ CommandName. |
|
4826 |
||
4827 |
" |
|
4828 |
Smalltalk commandName |
|
4829 |
" |
|
4830 |
||
4831 |
"Modified: 19.7.1996 / 11:11:16 / cg" |
|
4832 |
! |
|
4833 |
||
4834 |
hasNoConsole |
|
4835 |
"return true, if this is a console-less application (i.e. I am winstx) |
|
4836 |
i.e. there should be no writing to stdout/stderr" |
|
4837 |
||
4838 |
^ HasNoConsole ? false |
|
4839 |
||
4840 |
" |
|
10071 | 4841 |
Smalltalk hasNoConsole |
9054 | 4842 |
" |
4843 |
! |
|
4844 |
||
17435 | 4845 |
ignoreAssertions |
4846 |
"return true, if assertions are to be ignored (i.e. not executed). |
|
4847 |
This is false by default in an IDE (i.e. full smalltalk), |
|
4848 |
but can be set to true for standAlone applications |
|
4849 |
(whether that is a good idea and helps, is another question) |
|
17439
1928276a394c
added class variable IgnoreAssertions
Claus Gittinger <cg@exept.de>
parents:
17438
diff
changeset
|
4850 |
However, it may make the app a little faster, if assertions are compatational |
17435 | 4851 |
expensive, as they are skipped (the stc compiler is generatig code which skips those)." |
4852 |
||
17439
1928276a394c
added class variable IgnoreAssertions
Claus Gittinger <cg@exept.de>
parents:
17438
diff
changeset
|
4853 |
^ IgnoreAssertions ? false |
17435 | 4854 |
! |
4855 |
||
17438 | 4856 |
ignoreAssertions:aBoolean |
4857 |
"set to true, if assertions are to be ignored (i.e. not executed). |
|
4858 |
This is false by default in an IDE (i.e. full smalltalk), |
|
4859 |
but can be set to true for standAlone applications |
|
4860 |
(whether that is a good idea and helps, is another question) |
|
17439
1928276a394c
added class variable IgnoreAssertions
Claus Gittinger <cg@exept.de>
parents:
17438
diff
changeset
|
4861 |
However, it may make the app a little faster, if assertions are compatational |
17438 | 4862 |
expensive, as they are skipped (the stc compiler is generatig code which skips those)." |
4863 |
||
17439
1928276a394c
added class variable IgnoreAssertions
Claus Gittinger <cg@exept.de>
parents:
17438
diff
changeset
|
4864 |
IgnoreAssertions := aBoolean |
17438 | 4865 |
! |
4866 |
||
10641 | 4867 |
isHeadless |
4868 |
"return true, if this is a headless application |
|
4869 |
i.e. no default Display connection is required/used" |
|
4870 |
||
4871 |
^ HeadlessOperation ? false |
|
4872 |
||
4873 |
" |
|
10071 | 4874 |
Smalltalk isHeadless |
9029 | 4875 |
" |
4876 |
! |
|
4877 |
||
10641 | 4878 |
isPlugin |
4879 |
"return true, if this is a plugin application |
|
4880 |
i.e. running in a browserWindow" |
|
4881 |
||
4882 |
^ IsPlugin ? false |
|
4883 |
||
4884 |
" |
|
10071 | 4885 |
Smalltalk isPlugin |
9029 | 4886 |
" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
4887 |
! |
4957 | 4888 |
|
10641 | 4889 |
isSTScript |
4890 |
"return true, if this is stscript. i.e. the stx scripting engine." |
|
4891 |
||
4892 |
^ IsSTScript ? false |
|
4893 |
||
4894 |
" |
|
4895 |
Smalltalk isSTScript |
|
4896 |
" |
|
4897 |
||
4898 |
"Created: / 06-12-2006 / 16:41:21 / cg" |
|
4899 |
! |
|
4900 |
||
4901 |
isSharedLibraryComponent |
|
4902 |
"return true, if this is a shared library component of another application |
|
4903 |
i.e. a dll within another app." |
|
4904 |
||
4905 |
^ IsSharedLibraryComponent ? false |
|
4906 |
||
4907 |
" |
|
4908 |
Smalltalk isSharedLibraryComponent |
|
4909 |
" |
|
4910 |
||
4911 |
"Created: / 10-08-2006 / 13:09:34 / cg" |
|
4912 |
! |
|
4913 |
||
4914 |
isSmalltalkDevelopmentSystem |
|
4915 |
"return true, if this is a real smalltalk system |
|
17421 | 4916 |
i.e. NOT a stripped or a linked standAlone application (such as the webServer) |
10641 | 4917 |
and NOT a plugIn (i.e. running in a browser) |
4918 |
and NOT a sharedLibrary component (i.e. a dll in another app). |
|
17421 | 4919 |
This is used to determine, whether debugging is possible/desired or not." |
10641 | 4920 |
|
4921 |
self isPlugin ifTrue:[^ false]. "/ I am a browser-plugin |
|
4922 |
self isSharedLibraryComponent ifTrue:[^ false]. "/ I am a COM-ponent |
|
4923 |
self isSTScript ifTrue:[^ true ]. "/ I am stScript |
|
10999 | 4924 |
^ self isStandAloneApp not. |
10641 | 4925 |
|
4926 |
" |
|
4927 |
Smalltalk isSmalltalkDevelopmentSystem |
|
4928 |
" |
|
4929 |
||
4930 |
"Created: / 10-08-2006 / 13:12:49 / cg" |
|
4931 |
"Modified: / 06-12-2006 / 16:42:56 / cg" |
|
15565 | 4932 |
"Modified (comment): / 27-07-2013 / 15:36:20 / cg" |
10641 | 4933 |
! |
4934 |
||
4935 |
isStandAloneApp |
|
4936 |
"return true, if this is a standAlone application |
|
4937 |
i.e. a stripped & linked application (such as the webServer) |
|
4938 |
in contrast to a full smalltalk (development) system." |
|
4939 |
||
4940 |
^ StandAlone ? false |
|
4941 |
||
4942 |
" |
|
10071 | 4943 |
Smalltalk isStandAloneApp |
9029 | 4944 |
" |
617 | 4945 |
! |
4946 |
||
13947 | 4947 |
isStandAloneDebug |
4948 |
"return true, if this is a standAlone application which |
|
4949 |
was started with the -debug option." |
|
4950 |
||
4951 |
^ DebuggingStandAlone ? false |
|
4952 |
||
4953 |
" |
|
4954 |
Smalltalk isStandAloneDebug |
|
4955 |
" |
|
4956 |
||
4957 |
"Created: / 19-01-2012 / 10:17:41 / cg" |
|
4958 |
! |
|
4959 |
||
10641 | 4960 |
startupArguments |
4961 |
"return the arguments passed to StartupClass when stx gets started. |
|
4962 |
Usually these are nil, |
|
4963 |
but saving an image with a non-nil StartupClass/StartupSelector/StartupArgs allows for |
|
4964 |
a simple way to configure and create stand-alone applications" |
|
4965 |
||
4966 |
^ StartupArguments |
|
4967 |
||
4968 |
" |
|
10071 | 4969 |
Smalltalk startupArguments |
9029 | 4970 |
" |
7563 | 4971 |
! |
4972 |
||
10641 | 4973 |
startupClass |
4974 |
"return the class, that will get the start message when smalltalk |
|
4975 |
starts and its non-nil. Usually this is nil, |
|
4976 |
but saving an image with a non-nil StartupClass/StartupSelector/StartupArgs allows for |
|
4977 |
a simple way to configure and create stand-alone applications" |
|
4978 |
||
4979 |
^ StartupClass |
|
4980 |
||
4981 |
" |
|
10071 | 4982 |
Smalltalk startupClass |
9029 | 4983 |
" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
4984 |
! |
8570 | 4985 |
|
10641 | 4986 |
startupClass:aClass selector:aSymbol arguments:anArrayOrNil |
4987 |
"{ Pragma: +optSpace }" |
|
4988 |
||
4989 |
"set the class, selector and arguments to be performed when smalltalk |
|
4990 |
starts. Setting those before saving a snapshot, will make the saved |
|
4991 |
image come up executing your application (instead of the normal mainloop)" |
|
4992 |
||
4993 |
StartupClass := aClass. |
|
4994 |
StartupSelector := aSymbol. |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
4995 |
StartupArguments := anArrayOrNil |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
4996 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
4997 |
|
10641 | 4998 |
startupSelector |
4999 |
"return the selector, that will be sent to StartupClass. |
|
5000 |
Usually this is nil, |
|
5001 |
but saving an image with a non-nil StartupClass/StartupSelector allows for |
|
5002 |
a simple way to configure and create stand-alone applications" |
|
5003 |
||
5004 |
^ StartupSelector |
|
5005 |
||
5006 |
" |
|
10071 | 5007 |
Smalltalk startupSelector |
9029 | 5008 |
" |
10641 | 5009 |
! |
5010 |
||
5011 |
wasStartedFromImage |
|
5012 |
"return true, if this smalltalk was started from an image, |
|
5013 |
as opposed to a fresh and clean startup" |
|
5014 |
||
5015 |
^ ImageRestartTime notNil |
|
5016 |
||
5017 |
" |
|
5018 |
Smalltalk wasStartedFromImage |
|
5019 |
" |
|
70 | 5020 |
! ! |
5021 |
||
1750
36ff7e62388a
care for privateClasses in remove
Claus Gittinger <cg@exept.de>
parents:
1713
diff
changeset
|
5022 |
!Smalltalk class methodsFor:'system environment'! |
1069 | 5023 |
|
10641 | 5024 |
language |
5025 |
"return the language setting" |
|
5026 |
||
5027 |
^ Language |
|
5028 |
||
5029 |
" |
|
5030 |
Smalltalk language |
|
5031 |
" |
|
5032 |
||
5033 |
"Modified: 26.4.1996 / 17:10:05 / cg" |
|
5034 |
! |
|
5035 |
||
5036 |
language:aLanguageSymbol |
|
10991 | 5037 |
"set the language - send out change notifications" |
10641 | 5038 |
|
18733 | 5039 |
aLanguageSymbol ~= Language ifTrue:[ |
5040 |
Language := aLanguageSymbol asSymbol. |
|
5041 |
self changed:#Language |
|
5042 |
]. |
|
10641 | 5043 |
|
5044 |
" |
|
5045 |
Smalltalk language:#de |
|
5046 |
" |
|
5047 |
||
5048 |
"Modified: / 19-10-2006 / 23:17:29 / cg" |
|
5049 |
! |
|
5050 |
||
5051 |
language:aLanguageSymbol territory:aTerritorySymbol |
|
10991 | 5052 |
"set the language & territory - send out change notifications" |
10641 | 5053 |
|
18733 | 5054 |
((Language ~= aLanguageSymbol) or:[ LanguageTerritory ~= aTerritorySymbol]) ifTrue:[ |
5055 |
Language := aLanguageSymbol asSymbol. |
|
5056 |
LanguageTerritory := aTerritorySymbol asSymbol. |
|
5057 |
self changed:#Language |
|
5058 |
]. |
|
10641 | 5059 |
|
5060 |
" |
|
5061 |
Smalltalk language:#de territory:#de |
|
5062 |
" |
|
5063 |
||
5064 |
"Created: / 19-10-2006 / 22:16:22 / cg" |
|
5065 |
"Modified: / 19-10-2006 / 23:17:36 / cg" |
|
5066 |
! |
|
5067 |
||
13212
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5068 |
languageAndTerritory |
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5069 |
"return the language and territory in the format lang-terr (i.e. de-de, en-us)" |
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5070 |
|
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5071 |
^ Language , '-' , (LanguageTerritory ? Language) |
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5072 |
|
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5073 |
" |
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5074 |
Smalltalk languageAndTerritory |
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5075 |
" |
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5076 |
|
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5077 |
"Created: / 16-01-2011 / 10:19:42 / cg" |
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5078 |
! |
e75edfda9b2e
added: #languageAndTerritory
Claus Gittinger <cg@exept.de>
parents:
13135
diff
changeset
|
5079 |
|
10641 | 5080 |
languageTerritory |
5081 |
"return the language territory setting" |
|
7563 | 5082 |
|
5083 |
^ LanguageTerritory |
|
5084 |
! |
|
5085 |
||
10641 | 5086 |
languageTerritory:aTerritorySymbol |
10991 | 5087 |
"set the language territory - send out change notifications" |
10641 | 5088 |
|
18924 | 5089 |
aTerritorySymbol ~= LanguageTerritory ifTrue:[ |
5090 |
LanguageTerritory := aTerritorySymbol asSymbol. |
|
5091 |
self changed:#LanguageTerritory |
|
5092 |
]. |
|
5093 |
||
10641 | 5094 |
" |
5095 |
Time now |
|
5096 |
||
5097 |
Smalltalk languageTerritory:#us. |
|
5098 |
Time now |
|
5099 |
||
5100 |
Smalltalk languageTerritory:#de. |
|
5101 |
Time now |
|
5102 |
" |
|
5103 |
||
5104 |
"Modified: / 19-10-2006 / 23:17:40 / cg" |
|
5105 |
! |
|
5106 |
||
5107 |
setLanguage:aLanguageSymbol |
|
10991 | 5108 |
"set the language without change notification" |
10641 | 5109 |
|
5110 |
Language := aLanguageSymbol. |
|
10991 | 5111 |
! |
5112 |
||
5113 |
setLanguage:aLanguageSymbol territory:aTerritorySymbol |
|
5114 |
"set the language & territory - no change notification" |
|
5115 |
||
5116 |
Language := aLanguageSymbol asSymbol. |
|
5117 |
LanguageTerritory := aTerritorySymbol asSymbol. |
|
1069 | 5118 |
! ! |
5119 |
||
1750
36ff7e62388a
care for privateClasses in remove
Claus Gittinger <cg@exept.de>
parents:
1713
diff
changeset
|
5120 |
!Smalltalk class methodsFor:'system management'! |
70 | 5121 |
|
10641 | 5122 |
compressSources |
5123 |
"{ Pragma: +optSpace }" |
|
5124 |
||
5125 |
"compress the sources file, and remove all method source strings |
|
5126 |
from the system and replace them by refs to a string in the source file. |
|
5127 |
This is a bit different in ST/X than in other smalltalks, |
|
5128 |
since we use per-class sourcefiles for the compiled classes, |
|
5129 |
and a mix of in-memory strings and one-for-all sourceFile for |
|
5130 |
incremental compiled methods. |
|
5131 |
Therefore, only those sources which are not coming from compiled |
|
5132 |
methods are put into the 'st.src' file - all others are untouched. |
|
5133 |
This is being automated - so dont care for now." |
|
5134 |
||
5135 |
|newStream table source pos fileName| |
|
5136 |
||
5137 |
" |
|
5138 |
first, find all methods which contain either a string-ref |
|
5139 |
or an external string in the 'st.src' file |
|
5140 |
" |
|
5141 |
newStream := 'src.tmp' asFilename writeStream. |
|
5142 |
||
5143 |
table := IdentityDictionary new:100. |
|
5144 |
||
5145 |
Method allSubInstancesDo:[:aMethod | |
|
18668 | 5146 |
source := nil. |
5147 |
aMethod sourcePosition notNil ifTrue:[ |
|
5148 |
aMethod sourceFilename = 'st.src' ifTrue:[ |
|
5149 |
source := aMethod source. |
|
5150 |
] |
|
5151 |
] ifFalse:[ |
|
5152 |
source := aMethod source |
|
5153 |
]. |
|
5154 |
||
5155 |
source notNil ifTrue:[ |
|
5156 |
pos := newStream position + 1. |
|
5157 |
newStream nextChunkPut:source. |
|
5158 |
||
5159 |
" |
|
5160 |
dont change the methods info - maybe some write error |
|
5161 |
occurs later, in that case we abort and leave everything |
|
5162 |
untouched. |
|
5163 |
" |
|
5164 |
table at:aMethod put:pos |
|
5165 |
] |
|
11655
4306fb61b9f8
sync common source file before replacing the old copy
Stefan Vogel <sv@exept.de>
parents:
11624
diff
changeset
|
5166 |
]. |
4306fb61b9f8
sync common source file before replacing the old copy
Stefan Vogel <sv@exept.de>
parents:
11624
diff
changeset
|
5167 |
|
4306fb61b9f8
sync common source file before replacing the old copy
Stefan Vogel <sv@exept.de>
parents:
11624
diff
changeset
|
5168 |
newStream syncData; close. |
10641 | 5169 |
|
5170 |
" |
|
5171 |
now, rename the new source file, |
|
5172 |
" |
|
5173 |
fileName := (ObjectMemory nameForSources). |
|
5174 |
'src.tmp' asFilename renameTo:fileName. |
|
5175 |
||
5176 |
"good - now go over all changed methods, and change their |
|
5177 |
source reference" |
|
5178 |
||
5179 |
table keysAndValuesDo:[:aMethod :pos | |
|
18668 | 5180 |
aMethod localSourceFilename:fileName position:pos. |
10641 | 5181 |
"/ aMethod printCR. |
5182 |
]. |
|
5183 |
||
5184 |
" |
|
5185 |
Smalltalk compressSources |
|
5186 |
" |
|
5187 |
||
5188 |
"Modified: 16.1.1997 / 01:25:58 / cg" |
|
5189 |
! |
|
5190 |
||
5191 |
generateSingleSourceFile |
|
5192 |
"{ Pragma: +optSpace }" |
|
5193 |
||
5194 |
"generate the sources file, and remove all method source strings |
|
5195 |
from the system and replace them by refs to a string in the source file. |
|
5196 |
This makes the image independent from the per-class source files |
|
5197 |
and makes transportation of endUser applications easier, since |
|
5198 |
only 3 files (executable, image and sourceFile) need to be |
|
5199 |
transported." |
|
5200 |
||
5201 |
|newStream table source pos fileName| |
|
5202 |
||
5203 |
newStream := 'src.tmp' asFilename writeStream. |
|
5204 |
||
5205 |
table := IdentityDictionary new:100. |
|
5206 |
||
5207 |
Method allSubInstancesDo:[:aMethod | |
|
18668 | 5208 |
source := aMethod source. |
5209 |
source notNil ifTrue:[ |
|
5210 |
pos := newStream position + 1. |
|
5211 |
newStream nextChunkPut:source. |
|
5212 |
||
5213 |
" |
|
5214 |
dont change the methods info - maybe some write error |
|
5215 |
occurs later, in that case we abort and leave everything |
|
5216 |
untouched. |
|
5217 |
" |
|
5218 |
table at:aMethod put:pos |
|
5219 |
] |
|
11655
4306fb61b9f8
sync common source file before replacing the old copy
Stefan Vogel <sv@exept.de>
parents:
11624
diff
changeset
|
5220 |
]. |
4306fb61b9f8
sync common source file before replacing the old copy
Stefan Vogel <sv@exept.de>
parents:
11624
diff
changeset
|
5221 |
|
4306fb61b9f8
sync common source file before replacing the old copy
Stefan Vogel <sv@exept.de>
parents:
11624
diff
changeset
|
5222 |
newStream syncData; close. |
10641 | 5223 |
|
5224 |
" |
|
5225 |
now, rename the new source file, |
|
5226 |
" |
|
5227 |
fileName := (ObjectMemory nameForSources). |
|
5228 |
'src.tmp' asFilename renameTo:fileName. |
|
5229 |
||
5230 |
"good - now go over all changed methods, and change their |
|
5231 |
source reference" |
|
5232 |
||
5233 |
table keysAndValuesDo:[:aMethod :pos | |
|
18668 | 5234 |
aMethod localSourceFilename:fileName position:pos. |
10641 | 5235 |
"/ aMethod printCR. |
5236 |
]. |
|
5237 |
||
5238 |
" |
|
5239 |
Smalltalk generateSingleSourceFile |
|
5240 |
" |
|
5241 |
||
5242 |
"Modified: 16.1.1997 / 01:25:58 / cg" |
|
5243 |
"Created: 17.10.1997 / 13:00:56 / cg" |
|
5244 |
! |
|
5245 |
||
15596 | 5246 |
installAutoloadedClassFromSourceFile:aFilename |
5247 |
"install aFilename (which must be a smalltalk source file) as autoloaded class |
|
5248 |
(extract the class definition chunk from the file and create an autoloaded |
|
5249 |
class stub for it)" |
|
5250 |
||
5251 |
|chunks filename| |
|
5252 |
||
5253 |
filename := aFilename asFilename. |
|
5254 |
||
5255 |
ChangeSet::InvalidChangeChunkError handle:[:ex | |
|
18668 | 5256 |
^ self |
15596 | 5257 |
] do:[ |
18668 | 5258 |
filename readingFileDo:[:s| |
5259 |
chunks := ChangeSet fromStream:s while:[:chunk | chunk isMethodChange not]. |
|
5260 |
]. |
|
16170
ca4d03def070
endOfDipatch if running scripts
Claus Gittinger <cg@exept.de>
parents:
16164
diff
changeset
|
5261 |
]. |
ca4d03def070
endOfDipatch if running scripts
Claus Gittinger <cg@exept.de>
parents:
16164
diff
changeset
|
5262 |
|
ca4d03def070
endOfDipatch if running scripts
Claus Gittinger <cg@exept.de>
parents:
16164
diff
changeset
|
5263 |
chunks |
18668 | 5264 |
select:[:eachChunk | eachChunk isClassDefinitionChange] |
5265 |
thenDo:[:eachClassChunk | |
|
5266 |
eachClassChunk installAsAutoloadedClassIfPublicWithFilename:filename asAbsoluteFilename "withoutSuffix" name "baseName" |
|
5267 |
]. |
|
15596 | 5268 |
|
5269 |
"Created: / 01-08-2013 / 16:57:26 / cg" |
|
5270 |
! |
|
5271 |
||
10641 | 5272 |
installAutoloadedClassNamed:clsName category:cat package:package revision:revisionOrNil |
5273 |
"create & install an autoload stub for a class named: clsName, |
|
5274 |
to be loaded from package. |
|
5275 |
If revisionOrNil is non-nil, set it up to load exactly that revision |
|
5276 |
(otherwise, the newest revision will be loaded" |
|
5277 |
||
5278 |
^ self |
|
18668 | 5279 |
installAutoloadedClassNamed:clsName |
5280 |
category:cat |
|
5281 |
package:package |
|
5282 |
revision:revisionOrNil |
|
5283 |
numClassInstVars:nil. |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5284 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5285 |
|
10641 | 5286 |
installAutoloadedClassNamed:clsName category:cat package:package revision:revisionOrNil numClassInstVars:numClassInstVarsOrNil |
5287 |
"create & install an autoload stub for a class named: clsName, |
|
5288 |
to be loaded from package. |
|
5289 |
If revisionOrNil is non-nil, set it up to load exactly that revision |
|
5290 |
(otherwise, the newest revision will be loaded" |
|
5291 |
||
5292 |
|clsSym cls| |
|
5293 |
||
5294 |
clsSym := clsName asSymbol. |
|
5295 |
||
5296 |
"/ install if not already compiled-in |
|
5297 |
(cls := self at:clsSym) isNil ifTrue:[ |
|
18668 | 5298 |
Autoload subclass:clsSym |
5299 |
instanceVariableNames:'' |
|
5300 |
classVariableNames:'' |
|
5301 |
poolDictionaries:'' |
|
5302 |
category:cat |
|
5303 |
inEnvironment:Smalltalk. |
|
5304 |
||
5305 |
cls := self at:clsSym. |
|
5306 |
cls isNil ifTrue:[ |
|
5307 |
('Smalltalk [warning]: failed to install ' , clsName , ' as autoloaded.') infoPrintCR. |
|
5308 |
] ifFalse:[ |
|
5309 |
cls package:package asSymbol. |
|
5310 |
revisionOrNil notNil ifTrue:[ |
|
5311 |
cls setBinaryRevision:revisionOrNil |
|
5312 |
] |
|
5313 |
] |
|
10641 | 5314 |
] ifFalse:[ |
18668 | 5315 |
"/ class already present - however, if unloaded, check for category/package change |
5316 |
cls isLoaded ifFalse:[ |
|
5317 |
package ~= cls package ifTrue:[ |
|
5318 |
cls withoutUpdatingChangesDo:[ |
|
5319 |
cls package:package asSymbol. |
|
5320 |
]. |
|
5321 |
]. |
|
5322 |
cat ~= cls category ifTrue:[ |
|
5323 |
cls withoutUpdatingChangesDo:[ |
|
5324 |
cls category:cat. |
|
5325 |
]. |
|
5326 |
]. |
|
5327 |
]. |
|
10641 | 5328 |
]. |
5329 |
^ cls. |
|
5330 |
||
5331 |
"Created: / 05-11-1998 / 15:10:25 / cg" |
|
5332 |
"Modified: / 16-01-2007 / 12:56:18 / cg" |
|
11169
32fda240ee57
#installAutoloadedClassNamed:category:package:revision:numClassInstVars:
Stefan Vogel <sv@exept.de>
parents:
11153
diff
changeset
|
5333 |
|
10641 | 5334 |
! |
5335 |
||
5336 |
installAutoloadedClasses |
|
11679
69e588cca61f
Do not use relative pathnames when searching for packages, etc.
Stefan Vogel <sv@exept.de>
parents:
11670
diff
changeset
|
5337 |
"scan all packages and install all classes found there as |
10641 | 5338 |
autoloaded. This takes some time ..." |
5339 |
||
11679
69e588cca61f
Do not use relative pathnames when searching for packages, etc.
Stefan Vogel <sv@exept.de>
parents:
11670
diff
changeset
|
5340 |
|dirsConsulted| |
69e588cca61f
Do not use relative pathnames when searching for packages, etc.
Stefan Vogel <sv@exept.de>
parents:
11670
diff
changeset
|
5341 |
|
17588 | 5342 |
LoadInProgressQuery answerNotifyLoadingDo:[ |
18668 | 5343 |
dirsConsulted := Set new. |
5344 |
||
5345 |
"/ along the package-path |
|
5346 |
self packagePath do:[:eachPathComponent | |
|
5347 |
(dirsConsulted includes:eachPathComponent) ifFalse:[ |
|
5348 |
self |
|
5349 |
recursiveInstallAutoloadedClassesFrom:eachPathComponent |
|
5350 |
rememberIn:dirsConsulted |
|
5351 |
maxLevels:15 |
|
5352 |
noAutoload:false |
|
5353 |
packageTop:eachPathComponent |
|
5354 |
showSplashInLevels:2. |
|
5355 |
] |
|
5356 |
]. |
|
5357 |
self splashInfo:nil. |
|
17548 | 5358 |
]. |
10641 | 5359 |
|
5360 |
" |
|
5361 |
Smalltalk installAutoloadedClasses |
|
5362 |
" |
|
5363 |
||
5364 |
"Created: / 14.2.1997 / 17:32:57 / cg" |
|
5365 |
"Modified: / 13.12.1999 / 11:56:50 / cg" |
|
5366 |
! |
|
5367 |
||
5368 |
installAutoloadedClassesFrom:anAbbrevFilePath |
|
5369 |
"read the given abbreviation file; install all classes found there as |
|
5370 |
autoloaded. This takes some time ..." |
|
5371 |
||
5372 |
|f s| |
|
5373 |
||
5374 |
f := self getSystemFileName:anAbbrevFilePath. |
|
5375 |
f isNil ifTrue:[f := self getPackageFileName:anAbbrevFilePath]. |
|
5376 |
||
5377 |
f notNil ifTrue:[ |
|
19911 | 5378 |
f := f asFilename. |
5379 |
f isDirectory ifTrue:[ |
|
5380 |
f := f construct:'abbrev.stc' |
|
5381 |
]. |
|
5382 |
[ |
|
5383 |
s := f readStream. |
|
5384 |
self installAutoloadedClassesFromStream:s. |
|
5385 |
s close. |
|
5386 |
] on:FileStream openErrorSignal |
|
5387 |
do:[:ex| "do nothing"]. |
|
10641 | 5388 |
] |
5389 |
||
5390 |
" |
|
5391 |
Smalltalk installAutoloadedClassesFrom:'include/abbrev.stc' |
|
19911 | 5392 |
Smalltalk installAutoloadedClassesFrom:'../../goodies/communication/abbrev.stc' |
10641 | 5393 |
" |
5394 |
||
5395 |
"Modified: / 5.11.1998 / 15:10:51 / cg" |
|
5396 |
! |
|
5397 |
||
13531
6ab20c7e1dec
added: #installAutoloadedClassesFromAbbrevFile:
Claus Gittinger <cg@exept.de>
parents:
13529
diff
changeset
|
5398 |
installAutoloadedClassesFromAbbrevFile:aFilename |
6ab20c7e1dec
added: #installAutoloadedClassesFromAbbrevFile:
Claus Gittinger <cg@exept.de>
parents:
13529
diff
changeset
|
5399 |
aFilename readingFileDo:[:abbrevStream | |
19911 | 5400 |
self installAutoloadedClassesFromStream:abbrevStream. |
13531
6ab20c7e1dec
added: #installAutoloadedClassesFromAbbrevFile:
Claus Gittinger <cg@exept.de>
parents:
13529
diff
changeset
|
5401 |
] |
6ab20c7e1dec
added: #installAutoloadedClassesFromAbbrevFile:
Claus Gittinger <cg@exept.de>
parents:
13529
diff
changeset
|
5402 |
|
19911 | 5403 |
" |
5404 |
self installAutoloadedClassesFromAbbrevFile:('../../goodies/communication/abbrev.stc' asFilename) |
|
5405 |
" |
|
5406 |
||
13531
6ab20c7e1dec
added: #installAutoloadedClassesFromAbbrevFile:
Claus Gittinger <cg@exept.de>
parents:
13529
diff
changeset
|
5407 |
"Created: / 29-07-2011 / 20:39:21 / cg" |
6ab20c7e1dec
added: #installAutoloadedClassesFromAbbrevFile:
Claus Gittinger <cg@exept.de>
parents:
13529
diff
changeset
|
5408 |
! |
6ab20c7e1dec
added: #installAutoloadedClassesFromAbbrevFile:
Claus Gittinger <cg@exept.de>
parents:
13529
diff
changeset
|
5409 |
|
10641 | 5410 |
installAutoloadedClassesFromStream:anAbbrevFileStream |
5411 |
"read the given abbreviation file; |
|
5412 |
install all classes found there as autoloaded, and also update the |
|
5413 |
abbreviation (className-to-fileName mapping) table. |
|
5414 |
This takes some time ..." |
|
5415 |
||
5416 |
|s2 l abbrevFileName info clsName cls abbrev package cat numClassInstVars words w| |
|
5417 |
||
5418 |
anAbbrevFileStream isFileStream ifTrue:[ |
|
19911 | 5419 |
abbrevFileName := anAbbrevFileStream pathName. |
5420 |
info := 'declared from: ', abbrevFileName. |
|
10641 | 5421 |
]. |
5422 |
||
5423 |
"/ yes, create any required nameSpace, without asking user. |
|
5424 |
Class createNameSpaceQuerySignal answer:true do:[ |
|
5425 |
||
19911 | 5426 |
[anAbbrevFileStream atEnd] whileFalse:[ |
5427 |
l := anAbbrevFileStream nextLine withoutSeparators. |
|
5428 |
"Skip empty lines and comments" |
|
5429 |
(l notEmpty and:[l first ~= $#]) ifTrue:[ |
|
5430 |
"/ must do it manually, caring for quoted strings. |
|
10641 | 5431 |
"/ words := line asCollectionOfWords. |
5432 |
||
19911 | 5433 |
words := OrderedCollection new. |
5434 |
s2 := l readStream. |
|
5435 |
[s2 atEnd] whileFalse:[ |
|
5436 |
s2 skipSeparators. |
|
5437 |
s2 peek == $' ifTrue:[ |
|
5438 |
s2 next. |
|
5439 |
w := s2 upTo:$'. |
|
5440 |
s2 skipSeparators. |
|
5441 |
] ifFalse:[ |
|
5442 |
w := s2 upToSeparator |
|
5443 |
]. |
|
5444 |
words add:w |
|
5445 |
]. |
|
5446 |
words size < 3 ifTrue:[ |
|
5447 |
'Smalltalk [warning]: bad abbrev entry' errorPrint. |
|
5448 |
anAbbrevFileStream isFileStream ifTrue:[ |
|
5449 |
' (in ''' errorPrint. |
|
5450 |
anAbbrevFileStream pathName errorPrint. |
|
5451 |
''')' errorPrint |
|
5452 |
]. |
|
5453 |
': ' errorPrint. l errorPrintCR |
|
5454 |
] ifFalse:[ |
|
5455 |
clsName := (words at:1) asSymbol. |
|
5456 |
abbrev := (words at:2). |
|
5457 |
package := (words at:3) asSymbol. |
|
5458 |
cat := words at:4 ifAbsent:nil. |
|
5459 |
numClassInstVars := words at:5 ifAbsent:'0'. |
|
5460 |
numClassInstVars := Integer readFrom:numClassInstVars onError:[0]. |
|
5461 |
||
5462 |
(cat size == 0) ifTrue:[ |
|
5463 |
cat := 'autoloaded' |
|
5464 |
]. |
|
5465 |
||
5466 |
"/ on the fly, update the abbreviations |
|
5467 |
self setFilename:abbrev forClass:clsName package:package. |
|
5468 |
||
5469 |
"/ ' autoloaded: ' print. clsName print. ' in ' print. cat printCR. |
|
5470 |
||
5471 |
cls := self |
|
5472 |
installAutoloadedClassNamed:clsName |
|
5473 |
category:cat |
|
5474 |
package:package |
|
5475 |
revision:nil |
|
5476 |
numClassInstVars:numClassInstVars. |
|
10641 | 5477 |
|
5478 |
"/ info notNil ifTrue:[ |
|
5479 |
"/ cls setComment:info. |
|
5480 |
"/ ]. |
|
19911 | 5481 |
] |
5482 |
] |
|
5483 |
] |
|
4458 | 5484 |
] |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5485 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5486 |
|
10641 | 5487 |
loadBinaries |
5488 |
"return true, if binaries should be loaded into the system, |
|
5489 |
false if this should be suppressed. The default is false (for now)." |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5490 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5491 |
^ LoadBinaries |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5492 |
! |
3044 | 5493 |
|
10641 | 5494 |
loadBinaries:aBoolean |
5495 |
"{ Pragma: +optSpace }" |
|
5496 |
||
5497 |
"turn on/off loading of binary objects" |
|
5498 |
||
5499 |
aBoolean ifTrue:[ |
|
18668 | 5500 |
(ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles]) ifTrue:[ |
5501 |
LoadBinaries := true. |
|
5502 |
^ self |
|
5503 |
]. |
|
5504 |
'Smalltalk [info]: this system does not support binary loading' infoPrintCR. |
|
10641 | 5505 |
]. |
5506 |
LoadBinaries := false |
|
5507 |
||
5508 |
"Modified: 10.1.1997 / 15:11:00 / cg" |
|
5509 |
! |
|
5510 |
||
5511 |
logDoits |
|
5512 |
"return true if doits should go into the changes file |
|
5513 |
as well as changes - by default, this is off, since |
|
5514 |
it can blow up the changes file enormously ... |
|
5515 |
" |
|
5516 |
||
5517 |
^ LogDoits |
|
5518 |
||
5519 |
" |
|
5520 |
LogDoits := false |
|
3044 | 5521 |
LogDoits := true |
5522 |
" |
|
5523 |
! |
|
5524 |
||
10641 | 5525 |
logDoits:aBoolean |
5526 |
"{ Pragma: +optSpace }" |
|
5527 |
||
5528 |
"turn on/off logging of doits in the changes file. |
|
5529 |
By default, this is off, since it can blow up the |
|
5530 |
changes file enormously ... |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5531 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5532 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5533 |
LogDoits := aBoolean |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5534 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5535 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5536 |
|
10641 | 5537 |
makeBytecodeMethods |
5538 |
"{ Pragma: +optSpace }" |
|
5539 |
||
5540 |
"walk over all methods and make each a bytecode method |
|
5541 |
iff it does not contain primitive C code. |
|
5542 |
Experimental and not yet used." |
|
5543 |
||
5544 |
Method allSubInstancesDo:[:aMethod | |
|
18707 | 5545 |
|newMethod| |
5546 |
||
5547 |
aMethod hasPrimitiveCode ifFalse:[ |
|
5548 |
"/ aMethod errorPrintCR. |
|
5549 |
newMethod := aMethod asByteCodeMethod. |
|
5550 |
newMethod ~~ aMethod ifTrue:[ |
|
5551 |
newMethod isNil ifTrue:[ |
|
5552 |
'Smalltalk>>makeBytecodeMethods could nor recompile: ' errorPrint. aMethod errorPrintCR. |
|
5553 |
] ifFalse:[ |
|
5554 |
aMethod becomeSameAs:newMethod |
|
5555 |
]. |
|
5556 |
] |
|
5557 |
]. |
|
10641 | 5558 |
]. |
5559 |
||
5560 |
" |
|
5561 |
Smalltalk makeBytecodeMethods |
|
5562 |
" |
|
5563 |
||
5564 |
"Modified: 16.1.1997 / 01:25:58 / cg" |
|
5565 |
"Created: 17.10.1997 / 13:52:19 / cg" |
|
5566 |
! |
|
5567 |
||
14269
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5568 |
recursiveInstallAutoloadedClassesFrom:aTopDirectory |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5569 |
"scan all packages and install all classes found there as |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5570 |
autoloaded. This takes some time ..." |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5571 |
|
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5572 |
|dirsConsulted| |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5573 |
|
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5574 |
dirsConsulted := Set new. |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5575 |
|
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5576 |
self |
18707 | 5577 |
recursiveInstallAutoloadedClassesFrom:aTopDirectory |
5578 |
rememberIn:dirsConsulted |
|
5579 |
maxLevels:15 |
|
5580 |
noAutoload:false |
|
5581 |
packageTop:nil |
|
5582 |
showSplashInLevels:-1. |
|
14269
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5583 |
|
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5584 |
|
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5585 |
" |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5586 |
Smalltalk recursiveInstallAutoloadedClassesFrom:'..\..\..\cg\private\euler' |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5587 |
" |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5588 |
|
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5589 |
"Created: / 31-07-2012 / 15:27:40 / cg" |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5590 |
! |
b540d11186f4
added: #recursiveInstallAutoloadedClassesFrom:
Claus Gittinger <cg@exept.de>
parents:
14210
diff
changeset
|
5591 |
|
10641 | 5592 |
recursiveInstallAutoloadedClassesFrom:aDirectory rememberIn:dirsConsulted maxLevels:maxLevels noAutoload:noAutoloadIn packageTop:packageTopPath |
5593 |
"read all abbrev.stc files from and under aDirectory |
|
5594 |
and install autoloaded classes. |
|
15783 | 5595 |
If a file called NOAUTOLOAD is found, no classes there are installed as autoloaded, |
5596 |
but classes in subdirectories are installed, if the subdirectory contains a file |
|
5597 |
named AUTOLOAD. |
|
5598 |
If a file called NOSUBAUTOLOAD is found, no classes there and below are installed as autoloaded. |
|
10641 | 5599 |
If a file called NOPACKAGES is found, no further searching is done in that directory or below." |
5600 |
||
11391 | 5601 |
self |
18668 | 5602 |
recursiveInstallAutoloadedClassesFrom:aDirectory rememberIn:dirsConsulted |
5603 |
maxLevels:maxLevels noAutoload:noAutoloadIn packageTop:packageTopPath |
|
5604 |
showSplashInLevels:0. |
|
11391 | 5605 |
|
5606 |
" |
|
5607 |
Smalltalk installAutoloadedClasses |
|
5608 |
" |
|
5609 |
||
5610 |
"Modified: / 17-08-2006 / 16:48:43 / cg" |
|
5611 |
! |
|
5612 |
||
12022 | 5613 |
recursiveInstallAutoloadedClassesFrom:aDirectory rememberIn:dirsConsulted |
11391 | 5614 |
maxLevels:maxLevels noAutoload:noAutoloadIn packageTop:packageTopPath |
5615 |
showSplashInLevels:showSplashInLevels |
|
5616 |
"read all abbrev.stc files from and under aDirectory |
|
5617 |
and install autoloaded classes. |
|
15783 | 5618 |
If a file called NOAUTOLOAD is found, no classes there are installed as autoloaded, |
5619 |
but classes in subdirectories are installed, if the subdirectory contains a file |
|
5620 |
named AUTOLOAD. |
|
5621 |
If a file called NOSUBAUTOLOAD is found, no classes there and below are installed as autoloaded. |
|
11391 | 5622 |
If a file called NOPACKAGES is found, no further searching is done in that directory or below." |
5623 |
||
15783 | 5624 |
|dir noAutoloadHere dirName directoryContents haveAbbrevDotSTC| |
10641 | 5625 |
|
5626 |
dir := aDirectory asFilename. |
|
15958 | 5627 |
|
5628 |
"/ Care for non-existent directories" |
|
5629 |
dir exists ifFalse:[ ^ self ]. |
|
5630 |
||
15783 | 5631 |
dirName := dir physicalPathName. "take care of symbolic links" |
11392 | 5632 |
|
5633 |
(dirsConsulted includes:dirName) ifTrue:[ |
|
19117 | 5634 |
^ self |
10641 | 5635 |
]. |
5636 |
||
12377 | 5637 |
(dir / 'NOPACKAGES') exists ifTrue:[ |
19117 | 5638 |
^ self. |
10641 | 5639 |
]. |
12377 | 5640 |
(dir / 'NOSUBAUTOLOAD') exists ifTrue:[ |
19117 | 5641 |
^ self. |
10641 | 5642 |
]. |
11392 | 5643 |
|
15783 | 5644 |
maxLevels == 0 ifTrue:[ |
19117 | 5645 |
Transcript showCR:('Autoload: max directory nesting reached in %1' bindWith:dir pathName). |
5646 |
^ self |
|
15783 | 5647 |
]. |
5648 |
||
5649 |
dirsConsulted add:dirName. |
|
10641 | 5650 |
noAutoloadHere := noAutoloadIn. |
5651 |
noAutoloadHere ifFalse:[ |
|
19117 | 5652 |
(dir / 'NOAUTOLOAD') exists ifTrue:[ |
5653 |
noAutoloadHere := true. |
|
5654 |
]. |
|
10641 | 5655 |
] ifTrue:[ |
19117 | 5656 |
(dir / 'AUTOLOAD') exists ifTrue:[ |
5657 |
noAutoloadHere := false. |
|
5658 |
]. |
|
10641 | 5659 |
]. |
5660 |
||
11393 | 5661 |
showSplashInLevels >= 0 ifTrue:[ |
19117 | 5662 |
self showSplashMessage:('Smalltalk [info]: installing autoloaded classes found under "%1"...' |
5663 |
bindWith:(dirName contractAtBeginningTo:35)). |
|
11392 | 5664 |
]. |
5665 |
||
10641 | 5666 |
"/ |
5667 |
"/ suppress installation as autoloaded in this and everything |
|
5668 |
"/ below; however, still traverse the directories to find packages ... |
|
5669 |
"/ |
|
15596 | 5670 |
haveAbbrevDotSTC := false. |
10641 | 5671 |
noAutoloadHere ifFalse:[ |
19117 | 5672 |
[ |
5673 |
self installAutoloadedClassesFromAbbrevFile:(dir / 'abbrev.stc'). |
|
5674 |
haveAbbrevDotSTC := true. |
|
5675 |
] on:FileStream openErrorSignal |
|
5676 |
do:[:ex| |
|
5677 |
"ignore this file" |
|
5678 |
]. |
|
10641 | 5679 |
]. |
5680 |
||
5681 |
[ |
|
19117 | 5682 |
directoryContents := dir directoryContents. |
10641 | 5683 |
] on:FileStream openErrorSignal do:[:ex| |
19117 | 5684 |
"non-accessible directory: we are done" |
5685 |
^ self |
|
16199 | 5686 |
]. |
5687 |
||
5688 |
directoryContents := directoryContents select:[:fn | (fn startsWith:'.') not] as:Set. |
|
10641 | 5689 |
|
12911
0822e257daeb
comment/format in: #installAutoloadedClasses
Stefan Vogel <sv@exept.de>
parents:
12883
diff
changeset
|
5690 |
directoryContents removeAllFoundIn:#( |
19117 | 5691 |
'objbc' 'objvc' 'objmingw' |
5692 |
'doc' |
|
5693 |
'CVS' |
|
5694 |
'bitmaps' |
|
5695 |
'resources' |
|
5696 |
'source' |
|
5697 |
'not_delivered' |
|
5698 |
'not_ported' |
|
5699 |
). |
|
12911
0822e257daeb
comment/format in: #installAutoloadedClasses
Stefan Vogel <sv@exept.de>
parents:
12883
diff
changeset
|
5700 |
dir baseName = 'stx' ifTrue:[ |
19117 | 5701 |
directoryContents removeAllFoundIn:#( |
5702 |
'configurations' |
|
5703 |
'include' |
|
5704 |
'rules' |
|
5705 |
'stc' |
|
5706 |
'support' |
|
5707 |
). |
|
12911
0822e257daeb
comment/format in: #installAutoloadedClasses
Stefan Vogel <sv@exept.de>
parents:
12883
diff
changeset
|
5708 |
]. |
0822e257daeb
comment/format in: #installAutoloadedClasses
Stefan Vogel <sv@exept.de>
parents:
12883
diff
changeset
|
5709 |
|
0822e257daeb
comment/format in: #installAutoloadedClasses
Stefan Vogel <sv@exept.de>
parents:
12883
diff
changeset
|
5710 |
directoryContents do:[:eachFilenameString | |
19117 | 5711 |
|f| |
5712 |
||
5713 |
f := dir / eachFilenameString. |
|
5714 |
f isDirectory ifTrue:[ |
|
5715 |
self |
|
5716 |
recursiveInstallAutoloadedClassesFrom:f |
|
5717 |
rememberIn:dirsConsulted |
|
5718 |
maxLevels:maxLevels-1 |
|
5719 |
noAutoload:noAutoloadHere |
|
5720 |
packageTop:packageTopPath |
|
5721 |
showSplashInLevels:showSplashInLevels - 1. |
|
5722 |
] ifFalse:[ |
|
5723 |
(noAutoloadHere not and:[haveAbbrevDotSTC not]) ifTrue:[ |
|
5724 |
f suffix = 'st' ifTrue:[ |
|
5725 |
[ |
|
5726 |
self installAutoloadedClassFromSourceFile:f. |
|
5727 |
f directory baseName = 'libbasic' ifTrue:[self halt]. |
|
5728 |
] on:FileStream openErrorSignal do:[:ex| |
|
5729 |
"ignore this file, but write a warning" |
|
5730 |
Transcript showCR:('Autoload: cannot install %1. (%2)' bindWith:f pathName with:ex description). |
|
5731 |
]. |
|
5732 |
] |
|
5733 |
]. |
|
5734 |
] |
|
10641 | 5735 |
]. |
5736 |
||
11393 | 5737 |
showSplashInLevels >= 0 ifTrue:[ |
19117 | 5738 |
self showSplashMessage:('Smalltalk [info]: installing autoloaded classes from "%1"...' |
5739 |
bindWith:(dirName contractAtBeginningTo:35)). |
|
11392 | 5740 |
]. |
5741 |
||
10641 | 5742 |
" |
5743 |
Smalltalk installAutoloadedClasses |
|
5744 |
" |
|
5745 |
||
15596 | 5746 |
"Modified: / 01-08-2013 / 16:57:49 / cg" |
10641 | 5747 |
! |
5748 |
||
5749 |
replaceReferencesTo:anObject with:newRef |
|
12194
208afdcf182b
comment/format in: #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
12172
diff
changeset
|
5750 |
"if the receiver refers to the argument, anObject, replace this reference with newRef. |
208afdcf182b
comment/format in: #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
12172
diff
changeset
|
5751 |
Return true, if any reference was changed. |
208afdcf182b
comment/format in: #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
12172
diff
changeset
|
5752 |
Notice: this does not change the class-reference." |
208afdcf182b
comment/format in: #replaceReferencesTo:with:
Claus Gittinger <cg@exept.de>
parents:
12172
diff
changeset
|
5753 |
|
10641 | 5754 |
|toAdd| |
5755 |
||
5756 |
toAdd := OrderedCollection new. |
|
5757 |
self keysAndValuesDo:[:key :val | |
|
18668 | 5758 |
(key == anObject) ifTrue:[ |
5759 |
self shouldImplement. |
|
5760 |
]. |
|
5761 |
(val == anObject ) ifTrue:[ |
|
5762 |
toAdd add:(key -> newRef) |
|
5763 |
]. |
|
10641 | 5764 |
]. |
5765 |
toAdd do:[:each | |
|
18668 | 5766 |
self at:(each key) put:(each value) |
10641 | 5767 |
]. |
5768 |
! |
|
5769 |
||
5770 |
saveEmergencyImage:aBoolean |
|
5771 |
"set/clear the flag which controls if ST/X should save an |
|
5772 |
emergency image in case of a broken display connection. |
|
5773 |
The default is true. |
|
5774 |
This may be useful, if you work with an unsecure display |
|
5775 |
(serial line), and want to have a chance of proceeding after |
|
5776 |
a crash. In multiheaded applications, this only affects |
|
5777 |
crashes of the master Display connection (the initial connection); |
|
5778 |
errors on other displays are reported to the views and treated |
|
5779 |
like window destroy from the windowManager." |
|
5780 |
||
5781 |
SaveEmergencyImage := aBoolean |
|
5782 |
||
5783 |
"Modified: / 24.10.1997 / 18:22:26 / cg" |
|
5784 |
! |
|
5785 |
||
5786 |
systemOrganization |
|
5787 |
"for partial ST80 compatibility; |
|
5788 |
In ST80, Smalltalk organization returns a systemOrganizer, which |
|
5789 |
keeps track of class-categories, while all classes return a classOrganizer |
|
5790 |
from #organization, which keeps track of method categories of that class. |
|
5791 |
Since in ST/X, Smalltalk is a class, there is now a conflict. |
|
5792 |
To make a workaround possible, use #systemOrganization when porting |
|
5793 |
VW apps to ST/X to get the class-categories. |
|
5794 |
Read the documentation in SystemOrganizer for more info." |
|
5795 |
||
5796 |
^ SystemOrganizer for:nil |
|
5797 |
||
5798 |
"Created: / 20.6.1998 / 12:24:02 / cg" |
|
5799 |
"Modified: / 20.6.1998 / 12:41:34 / cg" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5800 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5801 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5802 |
!Smalltalk class methodsFor:'system management-fileIn'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5803 |
|
10641 | 5804 |
fileIn:aFileName |
5805 |
"read in the named file - look for it in some standard places; |
|
5806 |
return true if ok, false if failed. |
|
5807 |
This method can load almost anything which makes sense: |
|
18668 | 5808 |
.st - source files |
5809 |
.cls - binary smalltalk bytecode files |
|
5810 |
.so - binary compiled machine code class libraries |
|
5811 |
[.class - java bytecode -- soon to come]" |
|
10641 | 5812 |
|
5813 |
^ self fileIn:aFileName lazy:nil silent:nil logged:false |
|
5814 |
||
5815 |
" |
|
5816 |
Smalltalk fileIn:'source/TicTacToe.st' |
|
5817 |
Smalltalk fileIn:'binary/TicTacToe.cls' |
|
5818 |
Smalltalk fileIn:'binary/TicTacToe.so' |
|
5819 |
" |
|
5820 |
||
5821 |
"Created: 28.10.1995 / 17:06:28 / cg" |
|
5822 |
! |
|
5823 |
||
5824 |
fileIn:aFileName inPackage:aPackageID |
|
5825 |
"read in the named file in a packages directory." |
|
5826 |
||
5827 |
|dir| |
|
5828 |
||
5829 |
dir := self getPackageDirectoryForPackage:aPackageID. |
|
5830 |
dir isNil ifTrue:[^ false]. |
|
5831 |
||
5832 |
dir := dir asFilename. |
|
5833 |
^ (self fileIn:(dir construct:aFileName)) |
|
5834 |
or:[ self fileIn:((dir construct:'source') construct:aFileName) ] |
|
5835 |
! |
|
5836 |
||
5837 |
fileIn:aFileName lazy:lazy |
|
5838 |
"read in the named file - look for it in some standard places; |
|
5839 |
return true if ok, false if failed. |
|
5840 |
If lazy is true, no code is generated for methods, instead stubs |
|
5841 |
are created which compile themself when first executed. This allows |
|
5842 |
for much faster fileIn (but slows down the first execution later). |
|
5843 |
Since no syntax checks are done when doing lazy fileIn, use this only for |
|
5844 |
code which is known to be syntactically correct." |
|
5845 |
||
5846 |
^ self fileIn:aFileName lazy:lazy silent:nil logged:false |
|
5847 |
||
5848 |
" |
|
5849 |
Smalltalk fileIn:'source/TicTacToe.st' lazy:true |
|
5850 |
" |
|
5851 |
||
5852 |
"Created: 28.10.1995 / 17:06:36 / cg" |
|
5853 |
! |
|
5854 |
||
5855 |
fileIn:aFileName lazy:lazy silent:silent |
|
5856 |
"read in the named file - look for it in some standard places; |
|
5857 |
return true if ok, false if failed. |
|
5858 |
If lazy is true, no code is generated for methods, instead stubs |
|
5859 |
are created which compile themself when first executed. This allows |
|
5860 |
for much faster fileIn (but slows down the first execution later). |
|
5861 |
Since no syntax checks are done when doing lazy fileIn, use this only for |
|
5862 |
code which is known to be syntactically correct. |
|
5863 |
If silent is true, no compiler messages are output to the transcript. |
|
5864 |
Giving nil for silent/lazy will use the current settings." |
|
5865 |
||
5866 |
^ self fileIn:aFileName lazy:lazy silent:silent logged:false |
|
5867 |
||
5868 |
"Created: 28.10.1995 / 17:06:41 / cg" |
|
5869 |
! |
|
5870 |
||
5871 |
fileIn:aFileNameOrString lazy:lazy silent:silent logged:logged |
|
5872 |
"read in the named file - look for it in some standard places; |
|
5873 |
return true if ok, false if failed. |
|
5874 |
If lazy is true, no code is generated for methods, instead stubs |
|
5875 |
are created which compile themself when first executed. This allows |
|
5876 |
for much faster fileIn (but slows down the first execution later). |
|
5877 |
Since no syntax checks are done when doing lazy fileIn, use this only for |
|
5878 |
code which is known to be syntactically correct. |
|
5879 |
If silent is true, no compiler messages are output to the transcript. |
|
5880 |
Giving nil for silent/lazy will use the current settings. |
|
5881 |
This method can load almost anything which makes sense: |
|
18668 | 5882 |
.st - source files |
5883 |
.cls - binary smalltalk bytecode files |
|
5884 |
.so - binary compiled machine code class libraries |
|
5885 |
[.class - java bytecode -- soon to come]" |
|
15594 | 5886 |
|
15665 | 5887 |
|fileNameString inStream path morePath bos| |
10641 | 5888 |
|
5889 |
fileNameString := aFileNameOrString asString. |
|
5890 |
||
5891 |
" |
|
5892 |
an object or shared object ? |
|
5893 |
" |
|
5894 |
(ObjectFileLoader notNil |
|
5895 |
and:[ObjectFileLoader hasValidBinaryExtension:fileNameString]) ifTrue:[ |
|
18668 | 5896 |
"/ LoadBinaries ifFalse:[^ false]. |
5897 |
path := self getBinaryFileName:fileNameString. |
|
5898 |
path isNil ifTrue:[ |
|
5899 |
path := self getSystemFileName:fileNameString. |
|
5900 |
]. |
|
5901 |
path isNil ifTrue:[^ false]. |
|
5902 |
^ (ObjectFileLoader loadObjectFile:path) notNil |
|
15594 | 5903 |
]. |
5904 |
||
5905 |
inStream := self systemFileStreamFor:fileNameString. |
|
5906 |
inStream isNil ifTrue:[^ false]. |
|
10641 | 5907 |
|
5908 |
(fileNameString asFilename hasSuffix:'cls') ifTrue:[ |
|
18668 | 5909 |
BinaryObjectStorage notNil ifTrue:[ |
5910 |
[ |
|
5911 |
inStream binary. |
|
5912 |
bos := BinaryObjectStorage onOld:inStream. |
|
5913 |
bos next. |
|
5914 |
] ensure:[ |
|
5915 |
bos close. |
|
5916 |
]. |
|
5917 |
^ true |
|
5918 |
]. |
|
5919 |
^ false |
|
15594 | 5920 |
]. |
10641 | 5921 |
|
5922 |
(fileNameString includes:$/) ifTrue:[ |
|
18668 | 5923 |
"/ temporarily prepend the file's directory |
5924 |
"/ to the searchPath. |
|
5925 |
"/ This allows fileIn-driver files to refer to local |
|
5926 |
"/ files via a relative path, and drivers to fileIn other |
|
5927 |
"/ drivers ... |
|
5928 |
morePath := inStream pathName asFilename directoryName. |
|
15594 | 5929 |
]. |
15665 | 5930 |
^ self fileInStream:inStream lazy:lazy silent:silent logged:logged addPath:morePath |
15594 | 5931 |
|
5932 |
" |
|
5933 |
Smalltalk fileIn:'clients/TicTacToe/TicTacToe.st' lazy:true silent:true |
|
5934 |
Smalltalk fileIn:'keyboard.rc' |
|
10641 | 5935 |
" |
5936 |
||
5937 |
"Modified: / 08-09-2006 / 19:21:16 / cg" |
|
5938 |
! |
|
5939 |
||
5940 |
fileIn:aFileName logged:logged |
|
5941 |
"read in the named file - look for it in some standard places; |
|
5942 |
return true if ok, false if failed. |
|
5943 |
The argument logged controls, if the changefile is to be updated." |
|
5944 |
||
5945 |
^ self fileIn:aFileName lazy:nil silent:nil logged:logged |
|
5946 |
||
5947 |
" |
|
5948 |
Smalltalk fileIn:'source/TicTacToe.st' logged:false |
|
5949 |
" |
|
5950 |
! |
|
5951 |
||
5952 |
fileIn:aFileName silent:silent |
|
5953 |
"read in the named file - look for it in some standard places; |
|
5954 |
return true if ok, false if failed. |
|
5955 |
If silent is true, no compiler messages are output to the transcript." |
|
5956 |
||
5957 |
^ self fileIn:aFileName lazy:nil silent:silent logged:false |
|
5958 |
||
5959 |
" |
|
5960 |
Smalltalk fileIn:'source/TicTacToe.st' silent:true |
|
5961 |
" |
|
5962 |
||
5963 |
"Created: 28.10.1995 / 17:06:36 / cg" |
|
5964 |
! |
|
5965 |
||
5966 |
fileInChanges |
|
5967 |
"read in the last changes file - bringing the system to the state it |
|
5968 |
had when left the last time. |
|
5969 |
WARNING: this method is rubbish: it should only read things after the |
|
18668 | 5970 |
last '**snapshot**' - entry |
5971 |
(instead of the complete changes file)." |
|
10641 | 5972 |
|
5973 |
" |
|
5974 |
do NOT update the changes file now ... |
|
5975 |
" |
|
5976 |
self fileIn:ChangeFileName logged:false |
|
5977 |
||
5978 |
" |
|
10071 | 5979 |
Smalltalk fileInChanges |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5980 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
5981 |
! |
1 | 5982 |
|
10641 | 5983 |
fileInClass:aClassName |
5984 |
"find a source/object file for aClassName and -if found - load it. |
|
5985 |
search is in some standard places trying driver-file (.ld), object-file (.o) and |
|
5986 |
finally source file (.st) in that order. |
|
5987 |
The file is first searched for using the class name, then the abbreviated name." |
|
5988 |
||
5989 |
^ self |
|
18668 | 5990 |
fileInClass:aClassName |
5991 |
package:nil |
|
5992 |
initialize:true |
|
5993 |
lazy:false |
|
5994 |
silent:nil |
|
10641 | 5995 |
|
5996 |
"Modified: / 9.1.1998 / 14:41:46 / cg" |
|
5997 |
! |
|
5998 |
||
5999 |
fileInClass:aClassName fromObject:aFileName |
|
6000 |
"read in the named object file and dynamic-link it into the system |
|
6001 |
- look for it in some standard places. |
|
6002 |
Only install the named class from this object file. |
|
6003 |
Return true if ok, false if failed." |
|
6004 |
||
6005 |
|path ok| |
|
6006 |
||
6007 |
" |
|
6008 |
check if the dynamic loader class is in |
|
6009 |
" |
|
6010 |
(LoadBinaries not or:[ObjectFileLoader isNil]) ifTrue:[^ false]. |
|
6011 |
||
6012 |
(path := self getBinaryFileName:aFileName) isNil ifTrue:[^ false]. |
|
6013 |
ok := (ObjectFileLoader loadClass:aClassName fromObjectFile:path) notNil. |
|
6014 |
ok ifTrue:[ |
|
18668 | 6015 |
VerboseLoading ifTrue:[ |
6016 |
Transcript show:' loaded ' , aClassName , ' from ' ; showCR:aFileName. |
|
6017 |
] |
|
10641 | 6018 |
]. |
6019 |
^ ok |
|
6020 |
||
6021 |
" |
|
6022 |
Smalltalk fileInClass:'AbstractPath' fromObject:'../../goodies/Paths/AbstrPath.so' |
|
6023 |
Smalltalk fileInClass:'ClockView' fromObject:'../../libwidg3/libwidg3.so' |
|
6024 |
" |
|
6025 |
||
13814 | 6026 |
"Modified: / 04-11-2011 / 13:42:24 / cg" |
10641 | 6027 |
! |
6028 |
||
6029 |
fileInClass:aClassName initialize:doInit |
|
6030 |
"find a source/object file for aClassName and -if found - load it. |
|
6031 |
search is in some standard places trying driver-file (.ld), object-file (.o) and |
|
6032 |
finally source file (.st) in that order. |
|
6033 |
The file is first searched for using the class name, then the abbreviated name." |
|
6034 |
||
6035 |
^ self |
|
18668 | 6036 |
fileInClass:aClassName |
6037 |
package:nil |
|
6038 |
initialize:doInit |
|
6039 |
lazy:false |
|
6040 |
silent:nil |
|
10641 | 6041 |
|
6042 |
"Modified: / 9.1.1998 / 14:42:02 / cg" |
|
6043 |
! |
|
6044 |
||
6045 |
fileInClass:aClassName initialize:doInit lazy:loadLazy |
|
6046 |
"find a source/object file for aClassName and -if found - load it. |
|
6047 |
search is in some standard places trying driver-file (.ld), object-file (.o) and |
|
6048 |
finally source file (.st) in that order. |
|
6049 |
The file is first searched for using the class name, then the abbreviated name." |
|
6050 |
||
6051 |
^ self |
|
18668 | 6052 |
fileInClass:aClassName |
6053 |
package:nil |
|
6054 |
initialize:doInit |
|
6055 |
lazy:loadLazy |
|
6056 |
silent:nil |
|
10641 | 6057 |
|
6058 |
"Modified: / 9.1.1998 / 14:42:19 / cg" |
|
6059 |
! |
|
6060 |
||
6061 |
fileInClass:aClassName initialize:doInit lazy:loadLazy silent:beSilent |
|
6062 |
"find a source/object file for aClassName and -if found - load it. |
|
6063 |
Search is in some standard places, trying driver-file (.ld), object-file (.so / .o) and |
|
6064 |
finally source file (.st), in that order. |
|
6065 |
The file is first searched for using the class name, then the abbreviated name. |
|
6066 |
The argument doInit controlls if the class should be sent a #initialize after the |
|
19867 | 6067 |
load; loadLazy tells if it should be loaded lazily. beSilent tells if the compiler |
10641 | 6068 |
should not send notes to the transcript; it can be true, false or nil, where |
6069 |
nil uses the value from SilentLoading." |
|
6070 |
||
6071 |
^ self |
|
19867 | 6072 |
fileInClass:aClassName |
6073 |
package:nil |
|
6074 |
initialize:doInit |
|
6075 |
lazy:loadLazy |
|
6076 |
silent:beSilent |
|
10641 | 6077 |
|
6078 |
"Modified: / 9.1.1998 / 14:42:28 / cg" |
|
6079 |
! |
|
6080 |
||
6081 |
fileInClass:aClassName package:package |
|
6082 |
"find a source/object file for aClassName and -if found - load it. |
|
6083 |
search is in some standard places trying driver-file (.ld), object-file (.o) and |
|
6084 |
finally source file (.st) in that order. |
|
6085 |
The file is first searched for using the class name, then the abbreviated name." |
|
6086 |
||
6087 |
^ self |
|
18668 | 6088 |
fileInClass:aClassName |
6089 |
package:package |
|
6090 |
initialize:true |
|
6091 |
lazy:false |
|
6092 |
silent:nil |
|
10641 | 6093 |
|
6094 |
"Created: / 08-01-2007 / 10:06:09 / cg" |
|
6095 |
! |
|
6096 |
||
10999 | 6097 |
fileInClass:aClassName package:package initialize:doInit lazy:loadLazy silent:beSilent |
10641 | 6098 |
"find a source/object file for aClassName and -if found - load it. |
6099 |
This is the workhorse for autoloading. |
|
10999 | 6100 |
Search is in some standard places, trying driver-file (.ld), object-file (.so / .o) and |
10641 | 6101 |
finally source file (.st), in that order. |
6102 |
The file is first searched for using the class name, then the abbreviated name. |
|
6103 |
The argument doInit controlls if the class should be sent a #initialize after the |
|
19867 | 6104 |
load; loadLazy tells if it should be loaded lazily. beSilent tells if the compiler |
10641 | 6105 |
should not send notes to the transcript; it can be true, false or nil, where |
6106 |
nil uses the value from SilentLoading." |
|
6107 |
||
10999 | 6108 |
|classFileName alternativeClassFileName libName newClass ok wasLazy wasSilent sharedLibExtension inStream mgr |
10641 | 6109 |
filenameToSet packageDir packageFile bos| |
6110 |
||
17588 | 6111 |
ClassLoadInProgressQuery answerNotifyLoading:aClassName do:[ |
17582 | 6112 |
|
19867 | 6113 |
wasLazy := Compiler compileLazy:loadLazy. |
6114 |
beSilent notNil ifTrue:[ |
|
6115 |
wasSilent := self silentLoading:beSilent. |
|
6116 |
]. |
|
6117 |
||
6118 |
classFileName := Smalltalk fileNameForClass:aClassName. |
|
6119 |
(classFileName = aClassName) ifTrue:[ |
|
6120 |
"/ no abbrev.stc translation for className |
|
6121 |
(aClassName includes:$:) ifTrue:[ |
|
6122 |
"/ a nameSpace name |
|
6123 |
alternativeClassFileName := classFileName copyFrom:(classFileName lastIndexOf:$:)+1 |
|
6124 |
]. |
|
6125 |
]. |
|
6126 |
||
6127 |
classFileName asFilename isAbsolute ifTrue:[ |
|
6128 |
classFileName asFilename suffix notEmptyOrNil ifTrue:[ |
|
6129 |
ok := self fileIn:classFileName lazy:loadLazy silent:beSilent. |
|
6130 |
] ifFalse:[ |
|
6131 |
ok := self fileInSourceFile:classFileName lazy:loadLazy silent:beSilent. |
|
6132 |
] |
|
6133 |
] ifFalse:[ |
|
6134 |
classFileName := classFileName copyReplaceAll:$: with:$_ ifNone:classFileName. |
|
6135 |
[ |
|
6136 |
Class withoutUpdatingChangesDo:[ |
|
6137 |
|zarFn zar entry| |
|
6138 |
||
6139 |
ok := false. |
|
6140 |
||
6141 |
package notNil ifTrue:[ |
|
6142 |
packageDir := package asPackageId packageDirectory. |
|
6143 |
"/ packageDir := package asString. |
|
6144 |
"/ packageDir := packageDir copyReplaceAll:$: with:$/. |
|
6145 |
packageDir isNil ifTrue:[ |
|
6146 |
packageDir := self packageDirectoryForPackageId:package |
|
6147 |
]. |
|
6148 |
packageDir notNil ifTrue:[ |
|
6149 |
packageDir := packageDir asFilename. |
|
6150 |
]. |
|
6151 |
]. |
|
6152 |
||
6153 |
Class packageQuerySignal answer:package do:[ |
|
6154 |
" |
|
6155 |
then, if dynamic linking is available, |
|
6156 |
" |
|
6157 |
(LoadBinaries and:[ObjectFileLoader notNil]) ifTrue:[ |
|
6158 |
sharedLibExtension := ObjectFileLoader sharedLibraryExtension. |
|
6159 |
" |
|
6160 |
first look for a class packages shared binary in binary/xxx.o |
|
6161 |
" |
|
6162 |
libName := self libraryFileNameOfClass:aClassName. |
|
6163 |
libName notNil ifTrue:[ |
|
6164 |
(ok := self fileInClass:aClassName fromObject:(libName, sharedLibExtension)) |
|
6165 |
ifFalse:[ |
|
6166 |
sharedLibExtension ~= '.o' ifTrue:[ |
|
6167 |
ok := self fileInClass:aClassName fromObject:(libName, '.o') |
|
6168 |
] |
|
6169 |
]. |
|
6170 |
]. |
|
6171 |
" |
|
6172 |
then, look for a shared binary in binary/xxx.o |
|
6173 |
" |
|
6174 |
ok ifFalse:[ |
|
6175 |
(ok := self fileInClass:aClassName fromObject:(classFileName, sharedLibExtension)) |
|
6176 |
ifFalse:[ |
|
6177 |
sharedLibExtension ~= '.o' ifTrue:[ |
|
6178 |
ok := self fileInClass:aClassName fromObject:(classFileName, '.o') |
|
6179 |
]. |
|
6180 |
ok ifFalse:[ |
|
6181 |
alternativeClassFileName notNil ifTrue:[ |
|
6182 |
(ok := self fileInClass:aClassName fromObject:(alternativeClassFileName, sharedLibExtension)) |
|
6183 |
ifFalse:[ |
|
6184 |
sharedLibExtension ~= '.o' ifTrue:[ |
|
6185 |
ok := self fileInClass:aClassName fromObject:(alternativeClassFileName, '.o') |
|
6186 |
] |
|
6187 |
] |
|
6188 |
]. |
|
6189 |
]. |
|
6190 |
]. |
|
6191 |
]. |
|
6192 |
]. |
|
6193 |
||
6194 |
" |
|
6195 |
if that did not work, look for a compiled-bytecode file ... |
|
6196 |
" |
|
6197 |
ok ifFalse:[ |
|
6198 |
(ok := self fileIn:(classFileName , '.cls') lazy:loadLazy silent:beSilent) |
|
6199 |
ifFalse:[ |
|
6200 |
alternativeClassFileName notNil ifTrue:[ |
|
6201 |
ok := self fileIn:(alternativeClassFileName , '.cls') lazy:loadLazy silent:beSilent |
|
6202 |
] |
|
6203 |
] |
|
6204 |
]. |
|
6205 |
" |
|
6206 |
if that did not work, and the classes package is known, |
|
6207 |
look for an st-cls file |
|
6208 |
in a package subdir of the source-directory ... |
|
6209 |
" |
|
6210 |
ok ifFalse:[ |
|
6211 |
(packageDir notNil and:[BinaryObjectStorage notNil]) ifTrue:[ |
|
6212 |
packageFile := self getPackageFileName:((packageDir / 'classes' / classFileName) addSuffix:'cls'). |
|
6213 |
packageFile isNil ifTrue:[ |
|
6214 |
packageFile := (packageDir / 'classes' / classFileName) addSuffix:'cls'. |
|
6215 |
]. |
|
6216 |
(ok := self fileIn:packageFile lazy:loadLazy silent:beSilent) |
|
6217 |
ifFalse:[ |
|
6218 |
alternativeClassFileName notNil ifTrue:[ |
|
6219 |
packageFile := self getPackageFileName:((packageDir / 'classes' / alternativeClassFileName) addSuffix:'cls'). |
|
6220 |
packageFile isNil ifTrue:[ |
|
6221 |
packageFile := ((packageDir / 'classes' / alternativeClassFileName) addSuffix:'cls'). |
|
6222 |
]. |
|
6223 |
ok := self fileIn:packageFile lazy:loadLazy silent:beSilent |
|
6224 |
] |
|
6225 |
]. |
|
6226 |
||
6227 |
zarFn := self getPackageFileName:(packageDir / 'classes.zip'). |
|
6228 |
zarFn notNil ifTrue:[ |
|
6229 |
zar := ZipArchive oldFileNamed:zarFn. |
|
6230 |
zar notNil ifTrue:[ |
|
6231 |
entry := zar extract:(classFileName , '.cls'). |
|
6232 |
(entry isNil and:[alternativeClassFileName notNil]) ifTrue:[ |
|
6233 |
entry := zar extract:(alternativeClassFileName , '.cls'). |
|
6234 |
]. |
|
6235 |
entry notNil ifTrue:[ |
|
6236 |
bos := BinaryObjectStorage onOld:(entry asByteArray readStream). |
|
6237 |
bos next. |
|
6238 |
bos close. |
|
6239 |
ok := true |
|
6240 |
]. |
|
6241 |
] |
|
6242 |
] |
|
6243 |
] |
|
6244 |
]. |
|
6245 |
||
6246 |
" |
|
6247 |
if that did not work, look for an st-source file ... |
|
6248 |
" |
|
6249 |
ok ifFalse:[ |
|
6250 |
filenameToSet := classFileName. |
|
6251 |
(ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent) |
|
6252 |
ifFalse:[ |
|
6253 |
alternativeClassFileName notNil ifTrue:[ |
|
6254 |
filenameToSet := alternativeClassFileName. |
|
6255 |
ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent |
|
6256 |
]. |
|
6257 |
ok ifFalse:[ |
|
6258 |
" |
|
6259 |
... and in the standard source-directory |
|
6260 |
" |
|
6261 |
filenameToSet := 'source' asFilename / classFileName. |
|
6262 |
(ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent) |
|
6263 |
ifFalse:[ |
|
6264 |
alternativeClassFileName notNil ifTrue:[ |
|
6265 |
filenameToSet := 'source' asFilename / alternativeClassFileName. |
|
6266 |
ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent |
|
6267 |
] |
|
6268 |
] |
|
6269 |
] |
|
6270 |
]. |
|
6271 |
" |
|
6272 |
if that did not work, and the classes package is known, |
|
6273 |
look for an st-source file |
|
6274 |
in a package subdir of the source-directory ... |
|
6275 |
" |
|
6276 |
ok ifFalse:[ |
|
6277 |
packageDir notNil ifTrue:[ |
|
6278 |
packageFile := self getPackageSourceFileName:(packageDir / 'source' / classFileName). |
|
6279 |
packageFile isNil ifTrue:[ |
|
6280 |
packageFile := (packageDir / 'source' / classFileName). |
|
6281 |
]. |
|
6282 |
filenameToSet := packageFile. |
|
6283 |
(ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent) |
|
6284 |
ifFalse:[ |
|
6285 |
alternativeClassFileName notNil ifTrue:[ |
|
6286 |
packageFile := self getPackageSourceFileName:(packageDir / 'source' / alternativeClassFileName). |
|
6287 |
packageFile isNil ifTrue:[ |
|
6288 |
packageFile := (packageDir / 'source' / alternativeClassFileName). |
|
6289 |
]. |
|
6290 |
filenameToSet := packageFile. |
|
6291 |
ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent |
|
6292 |
]. |
|
6293 |
ok ifFalse:[ |
|
6294 |
packageFile := self getPackageSourceFileName:(packageDir / classFileName). |
|
6295 |
packageFile isNil ifTrue:[ |
|
6296 |
packageFile := (packageDir / classFileName). |
|
6297 |
]. |
|
6298 |
filenameToSet := packageFile. |
|
6299 |
(ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent) |
|
6300 |
ifFalse:[ |
|
6301 |
alternativeClassFileName notNil ifTrue:[ |
|
6302 |
packageFile := self getPackageFileName:(packageDir / alternativeClassFileName). |
|
6303 |
packageFile isNil ifTrue:[ |
|
6304 |
packageFile := packageDir / alternativeClassFileName. |
|
6305 |
]. |
|
6306 |
filenameToSet := packageFile. |
|
6307 |
ok := self fileInSourceFile:packageFile lazy:loadLazy silent:beSilent |
|
6308 |
]. |
|
6309 |
ok ifFalse:[ |
|
6310 |
" |
|
6311 |
... and in the standard source-directory |
|
6312 |
" |
|
6313 |
filenameToSet := 'source' asFilename / packageDir / classFileName. |
|
6314 |
(ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent) |
|
6315 |
ifFalse:[ |
|
6316 |
alternativeClassFileName notNil ifTrue:[ |
|
6317 |
filenameToSet := 'source' asFilename / packageDir / alternativeClassFileName. |
|
6318 |
ok := self fileInSourceFile:filenameToSet lazy:loadLazy silent:beSilent |
|
6319 |
] |
|
6320 |
] |
|
6321 |
] |
|
6322 |
]. |
|
6323 |
]. |
|
6324 |
]. |
|
6325 |
] |
|
6326 |
]. |
|
6327 |
" |
|
6328 |
if that did not work, and the classes package is known, |
|
6329 |
look for a zipArchive containing a class entry. |
|
6330 |
" |
|
6331 |
ok ifFalse:[ |
|
6332 |
packageDir notNil ifTrue:[ |
|
6333 |
zarFn := self getPackageFileName:(packageDir / 'source.zip'). |
|
6334 |
zarFn isNil ifTrue:[ |
|
6335 |
zarFn := packageDir withSuffix:'zip'. |
|
6336 |
zarFn := self getSourceFileName:zarFn. |
|
6337 |
]. |
|
6338 |
(zarFn notNil and:[zarFn asFilename exists]) ifTrue:[ |
|
6339 |
zar := ZipArchive oldFileNamed:zarFn. |
|
6340 |
zar notNil ifTrue:[ |
|
6341 |
entry := zar extract:(classFileName , '.st'). |
|
6342 |
(entry isNil and:[alternativeClassFileName notNil]) ifTrue:[ |
|
6343 |
entry := zar extract:(alternativeClassFileName , '.st'). |
|
6344 |
]. |
|
6345 |
entry notNil ifTrue:[ |
|
6346 |
filenameToSet := zarFn. |
|
6347 |
ok := self |
|
6348 |
fileInStream:(entry asString readStream) |
|
6349 |
lazy:loadLazy |
|
6350 |
silent:beSilent |
|
6351 |
logged:false |
|
6352 |
addPath:nil |
|
6353 |
]. |
|
6354 |
] |
|
6355 |
] |
|
6356 |
] |
|
6357 |
]. |
|
6358 |
||
6359 |
" |
|
6360 |
if that did not work, |
|
6361 |
look for a zipArchive containing a class entry. |
|
6362 |
" |
|
6363 |
ok ifFalse:[ |
|
6364 |
zarFn := self getSourceFileName:'source.zip'. |
|
6365 |
zarFn notNil ifTrue:[ |
|
6366 |
zar := ZipArchive oldFileNamed:zarFn. |
|
6367 |
zar notNil ifTrue:[ |
|
6368 |
entry := zar extract:(zarFn := classFileName , '.st'). |
|
6369 |
(entry isNil and:[alternativeClassFileName notNil]) ifTrue:[ |
|
6370 |
entry := zar extract:(zarFn := alternativeClassFileName , '.st'). |
|
6371 |
]. |
|
6372 |
entry notNil ifTrue:[ |
|
6373 |
filenameToSet := zarFn. |
|
6374 |
ok := self |
|
6375 |
fileInStream:(entry asString readStream) |
|
6376 |
lazy:loadLazy |
|
6377 |
silent:beSilent |
|
6378 |
logged:false |
|
6379 |
addPath:nil |
|
6380 |
]. |
|
6381 |
] |
|
6382 |
] |
|
6383 |
]. |
|
6384 |
ok ifFalse:[ |
|
6385 |
" |
|
6386 |
if there is a sourceCodeManager, ask it for the classes sourceCode |
|
6387 |
" |
|
6388 |
(mgr := Smalltalk at:#SourceCodeManager) notNil ifTrue:[ |
|
6389 |
inStream := mgr getMostRecentSourceStreamForClassNamed:aClassName inPackage:package. |
|
6390 |
inStream notNil ifTrue:[ |
|
6391 |
filenameToSet := nil. |
|
6392 |
ok := self fileInStream:inStream lazy:loadLazy silent:beSilent logged:false addPath:nil. |
|
6393 |
] |
|
6394 |
]. |
|
6395 |
]. |
|
6396 |
]. |
|
6397 |
] |
|
6398 |
]. |
|
6399 |
] ensure:[ |
|
6400 |
Compiler compileLazy:wasLazy. |
|
6401 |
wasSilent notNil ifTrue:[ |
|
6402 |
self silentLoading:wasSilent |
|
6403 |
] |
|
6404 |
]. |
|
6405 |
]. |
|
6406 |
||
6407 |
ok ifTrue:[ |
|
6408 |
newClass := self at:(aClassName asSymbol). |
|
6409 |
newClass notNil ifTrue:[ |
|
6410 |
"set the classes name - but do not change if already set" |
|
6411 |
filenameToSet notNil ifTrue:[ |
|
6412 |
newClass getClassFilename isNil ifTrue:[ |
|
6413 |
newClass setClassFilename:(filenameToSet asFilename baseName) |
|
6414 |
]. |
|
6415 |
]. |
|
6416 |
||
6417 |
doInit ifTrue:[ |
|
6418 |
newClass initialize |
|
6419 |
] |
|
6420 |
] |
|
6421 |
]. |
|
10641 | 6422 |
]. |
6423 |
||
6424 |
^ newClass |
|
6425 |
||
13415 | 6426 |
"Created: / 09-01-1998 / 14:40:32 / cg" |
6427 |
"Modified: / 05-06-1999 / 14:53:01 / cg" |
|
6428 |
"Modified: / 16-08-2009 / 14:52:53 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
10641 | 6429 |
! |
6430 |
||
6431 |
fileInClassLibrary:aClassLibraryName |
|
6432 |
"find an object file containing a binary class library in some standard places |
|
6433 |
and load it. This install all of its contained classes. |
|
6434 |
Return true if ok, false if not. |
|
6435 |
Notice: the argument may not have an extension (by purpose); |
|
18668 | 6436 |
the sharedLib extension (.dll / .so / .sl) is added here, to |
6437 |
make the caller independent of the underlying operatingSystem." |
|
10641 | 6438 |
|
6439 |
|path fn| |
|
6440 |
||
16144 | 6441 |
ObjectFileLoader isNil ifTrue:[ |
18668 | 6442 |
^ PackageLoadError raiseRequestWith:aClassLibraryName errorString:' - no ObjectFileLoader'. |
16144 | 6443 |
]. |
10641 | 6444 |
|
6445 |
fn := aClassLibraryName asFilename withSuffix:(ObjectFileLoader sharedLibrarySuffix). |
|
6446 |
fn := fn pathName. |
|
6447 |
||
6448 |
path := self getBinaryFileName:fn. |
|
6449 |
path isNil ifTrue:[ |
|
18668 | 6450 |
path := self getSystemFileName:fn. |
16144 | 6451 |
]. |
6452 |
path isNil ifTrue:[ |
|
18668 | 6453 |
^ PackageNotFoundError raiseRequestWith:aClassLibraryName. |
16144 | 6454 |
]. |
6455 |
||
6456 |
(ObjectFileLoader loadObjectFile:path) isNil ifTrue:[ |
|
18668 | 6457 |
^ PackageLoadError raiseRequestWith:aClassLibraryName. |
16144 | 6458 |
]. |
6459 |
^ true. |
|
6460 |
||
10641 | 6461 |
|
6462 |
" |
|
6463 |
Smalltalk fileInClassLibrary:'libtable' |
|
6464 |
Smalltalk fileInClassLibrary:'binary/libwidg3' |
|
6465 |
" |
|
6466 |
||
6467 |
"Modified: 8.1.1997 / 17:58:56 / cg" |
|
6468 |
! |
|
6469 |
||
6470 |
fileInClassLibrary:aClassLibraryName inPackage:packageID |
|
6471 |
"find an object file containing a binary class library in some standard places |
|
6472 |
and load it. This installs all of its contained classes. |
|
6473 |
Return true if ok, false if not. |
|
6474 |
Notice: the argument may not have an extension (by purpose); |
|
18668 | 6475 |
the sharedLib extension (.dll / .so / .sl) is added here, to |
6476 |
make the caller independent of the underlying operatingSystem." |
|
11689
d08d5db473c5
Find windows DLLs under package\objbc in development environment
Stefan Vogel <sv@exept.de>
parents:
11681
diff
changeset
|
6477 |
|
11690 | 6478 |
|baseName handle libraryFilename packagePath| |
10641 | 6479 |
|
16144 | 6480 |
ObjectFileLoader isNil ifTrue:[ |
18668 | 6481 |
^ PackageLoadError raiseRequestWith:packageID errorString:' - no ObjectFileLoader' |
16144 | 6482 |
]. |
10641 | 6483 |
|
6484 |
baseName := aClassLibraryName asFilename withSuffix:(ObjectFileLoader sharedLibrarySuffix). |
|
6485 |
baseName exists ifTrue:[ |
|
18668 | 6486 |
"/ load local file first... |
6487 |
handle := ObjectFileLoader loadObjectFile:baseName. |
|
12744
80f6da0fee57
changed: #fileInClassLibrary:inPackage:
Claus Gittinger <cg@exept.de>
parents:
12700
diff
changeset
|
6488 |
]. |
80f6da0fee57
changed: #fileInClassLibrary:inPackage:
Claus Gittinger <cg@exept.de>
parents:
12700
diff
changeset
|
6489 |
handle isNil ifTrue:[ |
18668 | 6490 |
packagePath := self getPackageDirectoryForPackage:packageID. |
6491 |
packagePath isNil ifTrue:[ |
|
6492 |
^ PackageNotFoundError raiseRequestWith:packageID. |
|
6493 |
]. |
|
6494 |
packagePath := packagePath asFilename. |
|
6495 |
libraryFilename := packagePath / baseName. |
|
6496 |
libraryFilename exists ifFalse:[ |
|
6497 |
libraryFilename := nil. |
|
6498 |
#('objbc' 'objvc') do:[:eachPossibleCompiledCodeDir | |
|
6499 |
"in windows, with Borland compiler, DLLs in development environment are under objbc; |
|
6500 |
with MSVC, they are under objvc" |
|
6501 |
libraryFilename isNil ifTrue:[ |
|
6502 |
libraryFilename := packagePath / eachPossibleCompiledCodeDir / baseName. |
|
6503 |
libraryFilename exists ifFalse:[ libraryFilename := nil ] |
|
6504 |
]. |
|
6505 |
]. |
|
6506 |
]. |
|
6507 |
(libraryFilename notNil and:[libraryFilename exists]) ifTrue:[ |
|
6508 |
handle := ObjectFileLoader loadObjectFile:libraryFilename pathName. |
|
6509 |
]. |
|
16144 | 6510 |
]. |
6511 |
||
6512 |
handle isNil ifTrue:[ |
|
18668 | 6513 |
^ PackageNotFoundError raiseRequestWith:packageID. |
16144 | 6514 |
]. |
12744
80f6da0fee57
changed: #fileInClassLibrary:inPackage:
Claus Gittinger <cg@exept.de>
parents:
12700
diff
changeset
|
6515 |
"/ handle notNil ifTrue:[ |
80f6da0fee57
changed: #fileInClassLibrary:inPackage:
Claus Gittinger <cg@exept.de>
parents:
12700
diff
changeset
|
6516 |
"/ Transcript showCR:(' Smalltalk: loaded %1.' bindWith:libraryFilename pathName). |
80f6da0fee57
changed: #fileInClassLibrary:inPackage:
Claus Gittinger <cg@exept.de>
parents:
12700
diff
changeset
|
6517 |
"/ ]. |
16144 | 6518 |
^ true. |
10641 | 6519 |
|
6520 |
" |
|
6521 |
Smalltalk fileInClassLibrary:'libtable' |
|
6522 |
Smalltalk fileInClassLibrary:'binary/libwidg3' |
|
6523 |
Smalltalk fileInClassLibrary:'refactoryBrowser' inPackage:'stx:goodies/refactoryBrowser' |
|
6524 |
" |
|
6525 |
||
13787
1695a24d0fa7
changed: #fileInClassLibrary:inPackage:
Claus Gittinger <cg@exept.de>
parents:
13785
diff
changeset
|
6526 |
"Modified: / 08-10-2011 / 00:08:51 / cg" |
10641 | 6527 |
! |
6528 |
||
15073 | 6529 |
fileInSourceFile:filenameArg lazy:loadLazy silent:beSilent |
18560 | 6530 |
"Try all available programming languages for a matching suffix" |
13415 | 6531 |
|
15073 | 6532 |
|filename| |
6533 |
||
6534 |
filename := filenameArg asFilename. |
|
18668 | 6535 |
"/ ProgrammingLanguage allDo:[:lang| |
18572
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6536 |
"/ | f | |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6537 |
"/ |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6538 |
"/ "/ cg: changed: did try all languages to load (eg. wether suffix matched or not. |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6539 |
"/ "/ I don't think, that is a good idea, as all of them languages might start parsing... |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6540 |
"/ (filename hasSuffix:lang sourceFileSuffix) ifTrue:[ |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6541 |
"/ (self fileIn:f lazy:loadLazy silent:beSilent) ifTrue:[ |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6542 |
"/ ^ true |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6543 |
"/ ]. |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6544 |
"/ ] |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6545 |
"/ ]. |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6546 |
"/ revert to old code to get stuff running again- please review - (autoload problems) |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6547 |
ProgrammingLanguage allDo:[:lang| | f | |
18668 | 6548 |
f := (filename hasSuffix:lang sourceFileSuffix) |
6549 |
ifTrue:[filename] |
|
6550 |
ifFalse:[filename addSuffix:lang sourceFileSuffix]. |
|
6551 |
(self fileIn:f lazy:loadLazy silent:beSilent) |
|
6552 |
ifTrue:[^ true] |
|
18572
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6553 |
]. |
b088a44b9681
\"/ revert to old code to get stuff running again- please review - (autoload problems)
Michael Beyl <mb@exept.de>
parents:
18560
diff
changeset
|
6554 |
|
15073 | 6555 |
^ false |
13415 | 6556 |
|
6557 |
"Created: / 16-08-2009 / 14:45:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
6558 |
! |
|
6559 |
||
10641 | 6560 |
fileInStream:streamArg |
6561 |
^ self fileInStream:streamArg lazy:nil silent:nil logged:false addPath:nil |
|
6562 |
! |
|
6563 |
||
6564 |
fileInStream:streamArg lazy:lazy silent:silent logged:logged addPath:morePath |
|
6565 |
"read sourceCode from aStream; |
|
6566 |
return true if ok, false if failed. |
|
6567 |
If lazy is true, no code is generated for methods, instead stubs |
|
6568 |
are created which compile themself when first executed. This allows |
|
6569 |
for much faster fileIn (but slows down the first execution later). |
|
6570 |
Since no syntax checks are done when doing lazy fileIn, use this only for |
|
6571 |
code which is known to be syntactically correct. |
|
6572 |
If silent is true, no compiler messages are output to the transcript. |
|
6573 |
Giving nil for silent/lazy will use the current settings. |
|
6574 |
If morePath is nonNil, it is prepended to the systemPath temporarily during the |
|
6575 |
fileIn. This allows for st-expressions to refer to more files (i.e. fileIn more) |
|
6576 |
using a relative path." |
|
6577 |
||
11427 | 6578 |
|inStream wasLazy wasSilent oldSystemPath oldRealPath| |
10641 | 6579 |
|
6580 |
inStream := streamArg. |
|
6581 |
inStream isNil ifTrue:[^ false]. |
|
19385 | 6582 |
inStream isLineNumberReadStream ifFalse:[ |
6583 |
inStream := LineNumberReadStream on:inStream. |
|
6584 |
]. |
|
12611
38d61d374d89
care for nonPositionable stream (stdin) in fileIn
Claus Gittinger <cg@exept.de>
parents:
12557
diff
changeset
|
6585 |
inStream := EncodedStream isNil |
18669 | 6586 |
ifTrue:[ inStream ] |
6587 |
ifFalse:[ EncodedStream decodedStreamFor:inStream ]. |
|
10641 | 6588 |
|
6589 |
lazy notNil ifTrue:[wasLazy := Compiler compileLazy:lazy]. |
|
6590 |
silent notNil ifTrue:[wasSilent := self silentLoading:silent]. |
|
6591 |
morePath notNil ifTrue:[ |
|
18669 | 6592 |
oldSystemPath := SystemPath copy. |
6593 |
SystemPath addFirst:morePath. |
|
6594 |
oldRealPath := RealSystemPath. |
|
6595 |
RealSystemPath := nil. |
|
6596 |
]. |
|
6597 |
||
10641 | 6598 |
[ |
18669 | 6599 |
(Class updateChangeFileQuerySignal , Class updateChangeListQuerySignal) answer:logged do:[ |
6600 |
"JV: Changed to give ProgrammingLanguage to choose |
|
6601 |
proper reader" |
|
6602 |
(ProgrammingLanguage forStream: inStream) fileInStream: inStream |
|
6603 |
] |
|
10641 | 6604 |
] ensure:[ |
18669 | 6605 |
morePath notNil ifTrue:[ |
6606 |
"take care, someone could have changed SystemPath during fileIn!!" |
|
6607 |
(SystemPath copyFrom:2) = oldSystemPath ifTrue:[ |
|
6608 |
SystemPath := oldSystemPath. |
|
6609 |
RealSystemPath := oldRealPath. |
|
6610 |
] ifFalse:[ |
|
6611 |
(oldSystemPath includes:morePath) ifFalse:[ |
|
6612 |
SystemPath remove:morePath ifAbsent:[]. |
|
6613 |
]. |
|
6614 |
RealSystemPath := nil. |
|
6615 |
]. |
|
6616 |
]. |
|
6617 |
lazy notNil ifTrue:[Compiler compileLazy:wasLazy]. |
|
6618 |
silent notNil ifTrue:[self silentLoading:wasSilent]. |
|
6619 |
inStream close |
|
10641 | 6620 |
]. |
6621 |
^ true |
|
6622 |
||
6623 |
" |
|
6624 |
Smalltalk fileInStream:('source/TicTacToe.st' asFilename readStream) lazy:true silent:true |
|
6625 |
" |
|
6626 |
||
13415 | 6627 |
"Modified: / 05-11-1996 / 20:03:35 / cg" |
6628 |
"Modified: / 16-08-2009 / 11:06:05 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
10641 | 6629 |
! |
6630 |
||
6631 |
isClassLibraryLoaded:name |
|
6632 |
"return true, if a particular class library is already loaded" |
|
6633 |
||
6634 |
ObjectMemory |
|
18668 | 6635 |
binaryModuleInfo |
6636 |
do:[:entry | |
|
6637 |
entry type == #classLibrary ifTrue:[ |
|
6638 |
entry libraryName = name ifTrue:[ |
|
6639 |
^ true "/ already loaded |
|
6640 |
] |
|
6641 |
]. |
|
6642 |
]. |
|
10641 | 6643 |
|
6644 |
^ false |
|
6645 |
||
6646 |
" |
|
6647 |
Smalltalk isClassLibraryLoaded:'libstx_libbasic' |
|
6648 |
Smalltalk isClassLibraryLoaded:'libstx_libwidg3' |
|
6649 |
Smalltalk isClassLibraryLoaded:'libstx_libboss' |
|
6650 |
" |
|
6651 |
||
6652 |
"Modified: / 23-08-2006 / 15:54:46 / cg" |
|
6653 |
! |
|
6654 |
||
6655 |
loadClassLibraryIfAbsent:name |
|
6656 |
"dynamically load a classLibrary, if not already loaded |
|
6657 |
and the system supports dynamic loading. |
|
6658 |
Return true, if the library is loaded, false if not. |
|
6659 |
This entry is called without system specific filename |
|
6660 |
extensions - it is portable among different architectures |
|
6661 |
as long as corresponding files (x.so / x.dll / x.sl / x.o) |
|
6662 |
are be present ..." |
|
6663 |
||
6664 |
(self isClassLibraryLoaded:name) ifTrue:[ ^ true ]. "/ already loaded |
|
6665 |
^ self fileInClassLibrary:name |
|
6666 |
||
6667 |
" |
|
6668 |
Smalltalk loadClassLibraryIfAbsent:'libbasic' |
|
6669 |
Smalltalk loadClassLibraryIfAbsent:'libwidg3' |
|
6670 |
" |
|
6671 |
||
6672 |
"Modified: 31.10.1996 / 16:57:24 / cg" |
|
6673 |
! |
|
6674 |
||
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
6675 |
secureFileIn:aFileName |
10641 | 6676 |
"read in the named file, looking for it at standard places. |
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
6677 |
Catch various errors during fileIn. |
13000 | 6678 |
Return true if ok, false if failed" |
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
6679 |
|
10641 | 6680 |
|retVal| |
6681 |
||
16025 | 6682 |
Parser isNil ifTrue:[^ false]. "/ for small stand alone apps. |
10641 | 6683 |
retVal := false. |
16025 | 6684 |
|
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
6685 |
(SignalSet |
18668 | 6686 |
with:AbortOperationRequest |
6687 |
with:TerminateProcessRequest |
|
6688 |
with:Parser parseErrorSignal) |
|
6689 |
handle:[:ex | ex return ] |
|
6690 |
do:[ retVal := self fileIn:aFileName ]. |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
6691 |
^ retVal |
10641 | 6692 |
! |
6693 |
||
6694 |
silentFileIn:aFilename |
|
6695 |
"same as fileIn:, but do not output 'compiled...'-messages on Transcript. |
|
6696 |
Main use is during startup." |
|
6697 |
||
13353 | 6698 |
self silentlyLoadingDo:[ |
18668 | 6699 |
self fileIn:aFilename |
13353 | 6700 |
]. |
3044 | 6701 |
! ! |
6702 |
||
6703 |
!Smalltalk class methodsFor:'system management-files'! |
|
6704 |
||
18868 | 6705 |
addWorkspaceDirectoryToPackagePath |
6706 |
"{ Pragma: +optSpace }" |
|
6707 |
||
6708 |
|workspaceDirectory| |
|
6709 |
||
6710 |
(workspaceDirectory := UserPreferences current workspaceDirectory) notNil ifTrue:[ |
|
6711 |
(workspaceDirectory := workspaceDirectory asFilename) exists ifTrue:[ |
|
6712 |
PackagePath addFirst:workspaceDirectory |
|
6713 |
] |
|
6714 |
]. |
|
6715 |
! |
|
6716 |
||
10641 | 6717 |
bitmapFileStreamFor:aFileName |
6718 |
"search aFileName in some standard places; |
|
6719 |
return a readonly fileStream or nil if not found. |
|
6720 |
Searches in subdirectories named 'bitmaps' in the SystemPath. |
|
6721 |
Notice: this does not look in the package-specific bitmaps directories." |
|
6722 |
||
6723 |
|aString| |
|
6724 |
||
6725 |
aString := self getBitmapFileName:aFileName. |
|
6726 |
aString notNil ifTrue:[ |
|
18668 | 6727 |
^ aString asFilename readStreamOrNil |
10641 | 6728 |
]. |
6729 |
^ nil |
|
6730 |
! |
|
6731 |
||
6732 |
bitmapFromFileNamed:aFileName forClass:aClass |
|
6733 |
"backward compatibility: |
|
6734 |
search aFileName in some standard places: |
|
6735 |
first in the redefinable bitmaps path, |
|
6736 |
then in the classes own package directory if existing. |
|
6737 |
Return an image or nil." |
|
6738 |
||
6739 |
^ self imageFromFileNamed:aFileName forClass:aClass |
|
6740 |
||
6741 |
" |
|
6742 |
Smalltalk bitmapFromFileNamed:'SmalltalkX.xbm' forClass:View |
|
6743 |
" |
|
6744 |
! |
|
6745 |
||
6746 |
bitmapFromFileNamed:aFileName inPackage:aPackage |
|
6747 |
"backward compatibility: |
|
6748 |
search aFileName in some standard places: |
|
6749 |
first in the redefinable bitmaps path, |
|
6750 |
then in the package directory if existing. |
|
6751 |
Return an image or nil." |
|
6752 |
||
6753 |
^ self imageFromFileNamed:aFileName inPackage:aPackage |
|
6754 |
||
6755 |
" |
|
6756 |
Smalltalk bitmapFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libview' |
|
6757 |
Smalltalk bitmapFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libtool' |
|
6758 |
" |
|
6759 |
! |
|
6760 |
||
6761 |
classNameForFile:aFileName |
|
6762 |
"return the className which corresponds to an abbreviated fileName, |
|
6763 |
or nil if no special translation applies. The given filename arg may |
|
6764 |
include a '.st' suffix (but no other)." |
|
6765 |
||
6766 |
|fn| |
|
6767 |
||
6768 |
(aFileName asFilename hasSuffix:'st') ifTrue:[ |
|
18668 | 6769 |
fn := aFileName copyButLast:3 |
10641 | 6770 |
] ifFalse:[ |
18668 | 6771 |
fn := aFileName |
10641 | 6772 |
]. |
6773 |
^ self filenameAbbreviations keyAtEqualValue:fn ifAbsent:[fn]. |
|
6774 |
||
6775 |
" |
|
6776 |
Smalltalk classNameForFile:'DrawObj' |
|
6777 |
Smalltalk classNameForFile:'DrawObj.st' |
|
6778 |
Smalltalk classNameForFile:'ArrColl.st' |
|
6779 |
Smalltalk classNameForFile:'ArrColl.chg' |
|
6780 |
" |
|
6781 |
||
6782 |
"Modified: 11.12.1995 / 14:51:10 / cg" |
|
6783 |
! |
|
6784 |
||
6785 |
constructPathFor:aDirectoryName |
|
6786 |
"search for aDirectory in SystemPath; |
|
6787 |
return a collection of pathes which include that directory." |
|
6788 |
||
6789 |
^ self realSystemPath select:[:dirName | |
|
18668 | 6790 |
|fullPath| |
6791 |
||
6792 |
fullPath := dirName asFilename construct:aDirectoryName. |
|
6793 |
"/ fullPath exists and:[fullPath isDirectory and:[fullPath isReadable]] |
|
6794 |
fullPath isDirectory and:[fullPath isReadable] |
|
10641 | 6795 |
]. |
6796 |
! |
|
6797 |
||
6798 |
fileInFileStreamFor:aFileName |
|
6799 |
"obsolete |
|
6800 |
search aFileName in some standard places; |
|
6801 |
return a readonly fileStream or nil if not found. |
|
6802 |
Searches in subdirectories named 'fileIn' in SystemPath" |
|
6803 |
||
6804 |
|aString| |
|
6805 |
||
6806 |
aString := self getFileInFileName:aFileName. |
|
6807 |
aString notNil ifTrue:[ |
|
18668 | 6808 |
^ aString asFilename readStreamOrNil |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
6809 |
]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
6810 |
^ nil |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
6811 |
! |
7758 | 6812 |
|
12022 | 6813 |
fileNameForClass:aClassOrClassName |
6814 |
"return a actual or expected (or most wanted) filename for aClassOrClassName |
|
6815 |
- only the base name (without directory part) and without suffix." |
|
6816 |
||
15958 | 6817 |
|cls nonMetaclass nm nameWithPrefix nameWithoutPrefix compatQuery compatPkg | |
12022 | 6818 |
|
12301 | 6819 |
"/ This was added as an extension of libsvn - should be no longer needed |
15958 | 6820 |
"/ JV@2012-09-25: but it actually is. The problem is that class filename |
6821 |
"/ is stored in the class itself and used to generate abbrev.stc and |
|
6822 |
"/ prerequisites in makefiles. But if you renamed such a stc-compiled class, |
|
6823 |
"/ the filename remains the same, but SVN __ALWAYS__ keep container name |
|
6824 |
"/ and class name in sync. Therefore build files gets messed up. Indeed, this |
|
6825 |
"/ should be fixed in code that files-out the package and generates build files. |
|
6826 |
"/ Certainly a hack, but do not remove this until fixed elsewhere |
|
6827 |
||
6828 |
compatQuery := Smalltalk classNamed: 'SVN::CompatModeQuery'. |
|
6829 |
(compatQuery notNil |
|
6830 |
and:[compatQuery isLoaded |
|
18668 | 6831 |
and:[compatQuery query not]]) ifTrue:[ |
6832 |
nm := aClassOrClassName isBehavior |
|
6833 |
ifTrue:[aClassOrClassName name] |
|
6834 |
ifFalse:[aClassOrClassName]. |
|
6835 |
nm := nm copyReplaceAll:$: with:$_ ifNone:nm. |
|
6836 |
^nm |
|
15958 | 6837 |
]. |
6838 |
||
16122
18c865388947
Fix in Smalltalk>>#fileNameForClass: - required by libscm to support nested packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16117
diff
changeset
|
6839 |
"/ Same for another query for new libscm. Here we have to do |
18c865388947
Fix in Smalltalk>>#fileNameForClass: - required by libscm to support nested packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16117
diff
changeset
|
6840 |
"/ this only for packages that are being filed out and NOT for others. |
18c865388947
Fix in Smalltalk>>#fileNameForClass: - required by libscm to support nested packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16117
diff
changeset
|
6841 |
"/ The problem is that this method is also used for getting filenames |
18c865388947
Fix in Smalltalk>>#fileNameForClass: - required by libscm to support nested packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16117
diff
changeset
|
6842 |
"/ of classes OUTSIDE filed-out package when generating makefile dependencies. |
15958 | 6843 |
compatQuery := Smalltalk classNamed: 'SCMCompatModeQuery'. |
6844 |
(compatQuery notNil |
|
6845 |
and:[compatQuery isLoaded |
|
18668 | 6846 |
and:[(compatPkg := compatQuery query) notNil]]) ifTrue:[ |
6847 |
| compatPkgs | |
|
6848 |
"/ Originally libscm could only fileout one package at time so |
|
6849 |
"/ the query answered one package name. However, to support nested |
|
6850 |
"/ packages, libscm is being rewritten to commit multiple packages |
|
6851 |
"/ at once, so query answers a collection of packages. The code below |
|
6852 |
"/ makes sure it works for both. |
|
6853 |
compatPkgs := compatPkg isString ifTrue:[ Array with: compatPkg] ifFalse:[ compatPkg ]. |
|
6854 |
nm := aClassOrClassName isBehavior |
|
6855 |
ifTrue:[aClassOrClassName name] |
|
6856 |
ifFalse:[aClassOrClassName]. |
|
6857 |
cls := Smalltalk at: nm asSymbol. |
|
6858 |
(cls notNil and:[compatPkgs includes: cls package]) ifTrue:[ |
|
6859 |
nm := nm copyReplaceAll:$: with:$_. |
|
6860 |
^nm |
|
6861 |
]. |
|
15958 | 6862 |
]. |
12301 | 6863 |
|
12022 | 6864 |
aClassOrClassName isBehavior ifTrue:[ |
18668 | 6865 |
cls := aClassOrClassName. |
12022 | 6866 |
] ifFalse:[ |
18668 | 6867 |
cls := Smalltalk classNamed:aClassOrClassName. |
6868 |
cls isNil ifTrue:[ |
|
6869 |
nameWithPrefix := aClassOrClassName. |
|
6870 |
nameWithoutPrefix := (aClassOrClassName copyFrom:(aClassOrClassName lastIndexOf:$:)+1). |
|
6871 |
]. |
|
12022 | 6872 |
]. |
6873 |
||
6874 |
cls notNil ifTrue:[ |
|
18668 | 6875 |
nonMetaclass := cls theNonMetaclass. |
6876 |
nm := nonMetaclass getClassFilename. |
|
6877 |
nm isNil ifTrue:[ |
|
6878 |
|revisionInfo| |
|
6879 |
||
6880 |
(revisionInfo := cls revisionInfo) notNil ifTrue:[ |
|
6881 |
nm := revisionInfo fileName. |
|
6882 |
]. |
|
6883 |
]. |
|
6884 |
nm notNil ifTrue:[ |
|
6885 |
^ nm asFilename withoutSuffix baseName |
|
6886 |
]. |
|
6887 |
nameWithPrefix := nonMetaclass name. |
|
6888 |
nameWithoutPrefix := nonMetaclass nameWithoutPrefix. |
|
12022 | 6889 |
]. |
6890 |
||
6891 |
CachedAbbreviations notNil ifTrue:[ |
|
18668 | 6892 |
nameWithPrefix := nameWithPrefix asSymbol. |
6893 |
(CachedAbbreviations includesKey:nameWithPrefix) ifTrue:[ |
|
6894 |
^ (CachedAbbreviations at:nameWithPrefix) asFilename baseName |
|
6895 |
]. |
|
6896 |
nameWithoutPrefix := nameWithoutPrefix asSymbol. |
|
6897 |
(CachedAbbreviations includesKey:nameWithoutPrefix) ifTrue:[ |
|
6898 |
^ (CachedAbbreviations at:nameWithoutPrefix) asFilename baseName |
|
6899 |
]. |
|
12022 | 6900 |
]. |
6901 |
||
6902 |
^ nameWithPrefix copyReplaceAll:$: with:$_ |
|
6903 |
||
6904 |
" |
|
6905 |
Smalltalk fileNameForClass:#Complex |
|
6906 |
Smalltalk fileNameForClass:'SmallInteger' |
|
6907 |
Smalltalk fileNameForClass:'UnixOperatingSystem' |
|
6908 |
Smalltalk fileNameForClass:'Launcher' |
|
6909 |
Smalltalk fileNameForClass:'SomeUnknownClass' |
|
6910 |
||
6911 |
Smalltalk fileNameForClass:HTML::Encoder |
|
6912 |
Smalltalk fileNameForClass:OSI::FTAMOperation |
|
6913 |
Smalltalk fileNameForClass:'OSI::Foobar' |
|
6914 |
Smalltalk fileNameForClass:(Workflow::UnsuccessfulFinishReasons) |
|
6915 |
Workflow::UnsuccessfulFinishReasons classFilename |
|
6916 |
" |
|
6917 |
||
6918 |
"Modified: / 06-10-2006 / 16:16:01 / cg" |
|
16122
18c865388947
Fix in Smalltalk>>#fileNameForClass: - required by libscm to support nested packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16117
diff
changeset
|
6919 |
"Modified: / 23-02-2014 / 10:39:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
18c865388947
Fix in Smalltalk>>#fileNameForClass: - required by libscm to support nested packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16117
diff
changeset
|
6920 |
"Modified (comment): / 23-02-2014 / 12:39:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
12022 | 6921 |
! |
6922 |
||
10641 | 6923 |
filenameAbbreviations |
6924 |
"return a dictionary containing the classname-to-filename |
|
6925 |
mappings. (needed for sys5.3 users, where filenames are limited |
|
6926 |
to 14 chars)" |
|
6927 |
||
6928 |
CachedAbbreviations isNil ifTrue:[ |
|
18668 | 6929 |
self readAbbreviations |
10641 | 6930 |
]. |
6931 |
^ CachedAbbreviations |
|
6932 |
||
6933 |
"flush with: |
|
6934 |
||
6935 |
CachedAbbreviations := nil |
|
6936 |
" |
|
6937 |
" |
|
6938 |
Smalltalk filenameAbbreviations |
|
6939 |
" |
|
6940 |
! |
|
6941 |
||
13368 | 6942 |
findPackageDirectoryForPackage:aPackage |
6943 |
"find a packages directory along a number of standard places" |
|
6944 |
||
6945 |
|relDir| |
|
6946 |
||
6947 |
relDir := Smalltalk relativePackagePathForPackage:aPackage. |
|
6948 |
relDir asFilename isAbsolute ifTrue:[^ relDir]. |
|
6949 |
||
6950 |
^ Smalltalk getPackageFileName:relDir. |
|
6951 |
||
6952 |
" |
|
6953 |
Smalltalk findPackageDirectoryForPackage:'stx:libview/resources' |
|
6954 |
Smalltalk findPackageDirectoryForPackage:'stx:libview' |
|
6955 |
" |
|
6956 |
! |
|
6957 |
||
10641 | 6958 |
flushPathCaches |
6959 |
"{ Pragma: +optSpace }" |
|
6960 |
||
6961 |
"forget pathCaches - these are collections containing valid directory names, |
|
6962 |
where system files (resource, bitmaps etc.) are found. |
|
6963 |
A flush is only required, if a new system directory has been created while |
|
6964 |
the system is active, and those files should override the others |
|
6965 |
(for example, if you created a private resource directory)" |
|
6966 |
||
6967 |
RealSystemPath := ResourcePath := SourcePath := |
|
15332 | 6968 |
BinaryPath := FileInPath := nil. |
6969 |
||
10641 | 6970 |
" |
6971 |
Smalltalk flushPathCaches |
|
6972 |
" |
|
6973 |
! |
|
6974 |
||
6975 |
getBinaryFileName:aFileName |
|
6976 |
"obsolete |
|
6977 |
search aFileName in some standard places |
|
6978 |
(subdirectories named 'binary' in SystemPath); |
|
6979 |
return the absolute filename or nil if none is found." |
|
6980 |
||
6981 |
BinaryPath isNil ifTrue:[ |
|
18668 | 6982 |
BinaryPath := self constructPathFor:BinaryDirName |
10641 | 6983 |
]. |
6984 |
||
6985 |
^ self searchPath:BinaryPath for:aFileName in:BinaryDirName |
|
6986 |
||
6987 |
"Modified: 18.7.1996 / 15:53:49 / cg" |
|
6988 |
! |
|
6989 |
||
6990 |
getBitmapFileName:aFileName |
|
6991 |
"for backward compatibility: |
|
6992 |
search aFileName in some standard places |
|
6993 |
(subdirectories named 'bitmaps' in SystemPath); |
|
6994 |
Return the pathName or nil if none is found." |
|
6995 |
||
6996 |
^ self getBitmapFileName:aFileName forPackage:nil |
|
6997 |
||
6998 |
" |
|
6999 |
Smalltalk getBitmapFileName:'SBrowser.xbm' |
|
7000 |
" |
|
7001 |
||
7002 |
"Modified: 18.7.1996 / 15:53:55 / cg" |
|
7003 |
! |
|
7004 |
||
7005 |
getBitmapFileName:aFileName forPackage:aPackageIDOrNil |
|
7006 |
"for backward compatibility. |
|
7007 |
search aFileName in some standard places: |
|
7008 |
first in the redefinable bitmaps path, |
|
7009 |
then in the package directory if existing. |
|
7010 |
Return a path or nil. |
|
7011 |
Search order is: |
|
18668 | 7012 |
bitmaps/<pkg>/file |
7013 |
resources/<pkg>/bitmaps/file |
|
7014 |
<pkg>/bitmaps/file |
|
10641 | 7015 |
" |
7016 |
||
7017 |
|f dir packageDir pF| |
|
7018 |
||
15225 | 7019 |
f := aFileName asString withoutPrefix:'bitmaps/'. |
10641 | 7020 |
|
7021 |
aPackageIDOrNil isNil ifTrue:[ |
|
18668 | 7022 |
"/ this will be an error in the future |
10641 | 7023 |
"/ 'Smalltalk [warning]: bitmap file access without package: ' infoPrint. aFileName infoPrintCR. |
7024 |
"/ self halt. |
|
7025 |
||
18668 | 7026 |
pF := self searchPath:(self realSystemPath) for:aFileName in:('bitmaps'). |
7027 |
pF notNil ifTrue:[ |
|
7028 |
^ pF. |
|
7029 |
]. |
|
7030 |
f ~= aFileName ifTrue:[ |
|
7031 |
pF := self searchPath:(self realSystemPath) for:f in:('bitmaps'). |
|
7032 |
pF notNil ifTrue:[ |
|
7033 |
^ pF. |
|
7034 |
]. |
|
7035 |
]. |
|
7036 |
^ nil |
|
11077
14df4640ed89
image by package and filename access fixed
Claus Gittinger <cg@exept.de>
parents:
11057
diff
changeset
|
7037 |
]. |
14df4640ed89
image by package and filename access fixed
Claus Gittinger <cg@exept.de>
parents:
11057
diff
changeset
|
7038 |
|
14df4640ed89
image by package and filename access fixed
Claus Gittinger <cg@exept.de>
parents:
11057
diff
changeset
|
7039 |
dir := self projectDirectoryForPackage:aPackageIDOrNil. |
14df4640ed89
image by package and filename access fixed
Claus Gittinger <cg@exept.de>
parents:
11057
diff
changeset
|
7040 |
dir notNil ifTrue:[ |
18668 | 7041 |
pF := dir asFilename / f. |
7042 |
pF exists ifTrue:[ |
|
7043 |
^ pF. |
|
7044 |
]. |
|
7045 |
pF := dir asFilename / 'bitmaps' /f. |
|
7046 |
pF exists ifTrue:[ |
|
7047 |
^ pF. |
|
7048 |
]. |
|
10641 | 7049 |
]. |
7050 |
||
7051 |
packageDir := aPackageIDOrNil copyReplaceAll:$: with:$/. |
|
7052 |
||
7053 |
pF := self searchPath:(self realSystemPath) for:aFileName in:('bitmaps/',packageDir). |
|
7054 |
pF notNil ifTrue:[ |
|
18668 | 7055 |
^ pF. |
10641 | 7056 |
]. |
7057 |
pF := self searchPath:(self realSystemPath) for:aFileName in:('resources/',packageDir,'/bitmaps'). |
|
7058 |
pF notNil ifTrue:[ |
|
18668 | 7059 |
^ pF. |
11077
14df4640ed89
image by package and filename access fixed
Claus Gittinger <cg@exept.de>
parents:
11057
diff
changeset
|
7060 |
]. |
14df4640ed89
image by package and filename access fixed
Claus Gittinger <cg@exept.de>
parents:
11057
diff
changeset
|
7061 |
|
10641 | 7062 |
^ nil |
7063 |
||
7064 |
" |
|
7065 |
Smalltalk imageFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libview' |
|
7066 |
Smalltalk imageFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libtool' |
|
7067 |
Smalltalk imageFromFileNamed:'bitmaps/gifImages/garfield.gif' inPackage:'stx:goodies' |
|
7068 |
Smalltalk imageFromFileNamed:'CheckOn10_xp.xpm' inPackage:'stx:libwidg' |
|
7069 |
" |
|
7070 |
||
7071 |
"Modified: / 11-10-2006 / 13:53:18 / cg" |
|
7072 |
! |
|
7073 |
||
7074 |
getFileInFileName:aFileName |
|
7075 |
"obsolete |
|
7076 |
search aFileName in some standard places |
|
7077 |
(subdirectories named 'fileIn' in SystemPath); |
|
7078 |
return the absolute filename or nil if none is found." |
|
7079 |
||
7080 |
FileInPath isNil ifTrue:[ |
|
18668 | 7081 |
FileInPath := self constructPathFor:FileInDirName |
10641 | 7082 |
]. |
7083 |
||
7084 |
^ self searchPath:FileInPath for:aFileName in:FileInDirName |
|
7085 |
||
7086 |
"Modified: 18.7.1996 / 15:53:59 / cg" |
|
7087 |
! |
|
7088 |
||
7089 |
getPackageDirectoryForPackage:aPackageID |
|
7090 |
"search for a particular package; return its directory, or nil. |
|
7091 |
Stand alone applications might get nil, if there are only binaries installed." |
|
7092 |
||
19121 | 7093 |
|packageId checkForPackageDirectory module packageSubDirectory| |
7094 |
||
7095 |
packageId := aPackageID asPackageId. |
|
7096 |
module := packageId module. |
|
7097 |
packageSubDirectory := packageId directory. |
|
10641 | 7098 |
|
7099 |
checkForPackageDirectory := |
|
19121 | 7100 |
[:moduleDir | |
7101 |
|packageDir| |
|
7102 |
||
7103 |
moduleDir isDirectory ifTrue:[ |
|
7104 |
packageDir := moduleDir / packageSubDirectory. |
|
7105 |
packageDir isDirectory ifTrue:[ |
|
7106 |
^ packageDir |
|
7107 |
] |
|
7108 |
]. |
|
7109 |
]. |
|
10641 | 7110 |
|
7111 |
self packagePath do:[:aPath | |
|
19121 | 7112 |
|moduleDir| |
7113 |
||
7114 |
moduleDir := aPath asFilename / module. |
|
7115 |
checkForPackageDirectory value:moduleDir. |
|
10641 | 7116 |
]. |
7117 |
||
7118 |
^ nil |
|
7119 |
||
7120 |
" |
|
7121 |
Smalltalk getPackageDirectoryForPackage:(Array package) |
|
7122 |
Smalltalk getPackageDirectoryForPackage:'stx:goodies/bitmaps' |
|
7123 |
Smalltalk getPackageDirectoryForPackage:'stx:libview' |
|
7124 |
" |
|
7125 |
||
7126 |
"Modified: / 06-10-2006 / 11:49:27 / cg" |
|
7127 |
! |
|
7128 |
||
7129 |
getPackageFileName:aFileName |
|
7130 |
"search aFileName in some standard places |
|
7131 |
(packagePath and subdirectories named 'packages' in SystemPath); |
|
7132 |
return the absolute filename or nil if none is found." |
|
7133 |
||
7134 |
|f| |
|
7135 |
||
7136 |
"/ search along packagePath ... |
|
7137 |
f := self searchPath:self packagePath for:aFileName in:nil. |
|
7138 |
f isNil ifTrue:[ |
|
18668 | 7139 |
"/ search under packages-directory along systemPath ... |
7140 |
f := self searchPath:self realSystemPath for:aFileName in:PackageDirName. |
|
7141 |
"/ kludge - allow for stx-directory to be named differently |
|
7142 |
f isNil ifTrue:[ |
|
7143 |
(aFileName asString startsWith:('stx' , Filename separator)) ifTrue:[ |
|
7144 |
f := '..' asFilename / '..' / (aFileName copyFrom:5). |
|
7145 |
] |
|
7146 |
]. |
|
10641 | 7147 |
]. |
7148 |
(f notNil and:[(f := f asFilename) exists]) ifTrue:[ |
|
18668 | 7149 |
^ f pathName |
7758 | 7150 |
]. |
7151 |
^ nil |
|
10641 | 7152 |
|
7153 |
" |
|
16668
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
7154 |
Smalltalk getPackageFileName:'stx/libview/resources/normal.style' |
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
7155 |
Smalltalk getPackageFileName:'stx/libview/styles/normal.style' |
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
7156 |
Smalltalk getPackageFileName:'stx/libview/source.zip' |
10641 | 7157 |
" |
7158 |
! |
|
7159 |
||
15074 | 7160 |
getPackageSourceFileName:filenameWithoutSuffixArg |
13415 | 7161 |
"search aFileName in some standard places and try all available languages" |
7162 |
||
15074 | 7163 |
|filenameWithoutSuffix| |
7164 |
||
7165 |
filenameWithoutSuffix:= filenameWithoutSuffixArg asFilename. |
|
7166 |
||
16170
ca4d03def070
endOfDipatch if running scripts
Claus Gittinger <cg@exept.de>
parents:
16164
diff
changeset
|
7167 |
ProgrammingLanguage |
18668 | 7168 |
allDo:[:lang | |
7169 |
|file| |
|
7170 |
||
7171 |
file := self |
|
7172 |
getPackageFileName:(filenameWithoutSuffix addSuffix:lang sourceFileSuffix). |
|
7173 |
file notNil ifTrue:[ ^ file ] |
|
7174 |
]. |
|
15074 | 7175 |
^ nil |
13415 | 7176 |
|
7177 |
"Created: / 16-08-2009 / 14:44:58 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
7178 |
! |
|
7179 |
||
10641 | 7180 |
getResourceFileName:aFileName |
12547
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7181 |
<resource: #obsolete> |
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7182 |
|
10641 | 7183 |
"search aFileName in some standard places |
7184 |
(subdirectories named 'resources' in SystemPath); |
|
12547
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7185 |
return the absolute filename or nil if none is found. |
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7186 |
Obsolete: you must now provide a package argument." |
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7187 |
|
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7188 |
self obsoleteMethodWarning:'use getResourceFileName:forPackage:'. |
10641 | 7189 |
^ self getResourceFileName:aFileName forPackage:nil |
7190 |
||
7191 |
" |
|
7192 |
Smalltalk getResourceFileName:'SystemBrowser.rs' |
|
7193 |
" |
|
7194 |
||
7195 |
"Modified: 18.7.1996 / 15:54:03 / cg" |
|
7196 |
! |
|
7197 |
||
7198 |
getResourceFileName:aFileName forClass:aClassOrNil |
|
7199 |
"search aFileName in some standard places |
|
7200 |
(subdirectories named 'resource' in SystemPath); |
|
7201 |
and in aClasses package directory. |
|
7202 |
Return the absolute filename or nil if none is found." |
|
7203 |
||
7204 |
|pkgOrNil| |
|
7205 |
||
7206 |
aClassOrNil notNil ifTrue:[ |
|
18668 | 7207 |
pkgOrNil := aClassOrNil package. |
10641 | 7208 |
]. |
7209 |
^ self getResourceFileName:aFileName forPackage:pkgOrNil. |
|
7210 |
||
7211 |
" |
|
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
7212 |
Smalltalk getResourceFileName:'de.rs' forClass:SystemBrowser |
10641 | 7213 |
" |
7214 |
! |
|
7215 |
||
7216 |
getResourceFileName:aFileName forPackage:aPackageIDOrNil |
|
7217 |
"search aFileName in some standard places |
|
7218 |
(subdirectories named 'resource' in SystemPath); |
|
7219 |
and in a packages directory. |
|
7220 |
Return the absolute filename or nil if none is found. |
|
7221 |
Search order is: |
|
18668 | 7222 |
resources/<pkg>/file |
7223 |
<pkg>/resources/file |
|
10641 | 7224 |
" |
7225 |
||
7226 |
|pF f dir packageDir| |
|
7227 |
||
15225 | 7228 |
f := aFileName asString withoutPrefix:'resources/'. |
10641 | 7229 |
|
7230 |
aPackageIDOrNil isNil ifTrue:[ |
|
18668 | 7231 |
"/ this will be an error in the future |
10641 | 7232 |
"/ 'Smalltalk [warning]: resource file access without package: ' infoPrint. aFileName infoPrintCR. |
7233 |
"/ self halt. |
|
7234 |
||
18668 | 7235 |
pF := self searchPath:(self realSystemPath) for:aFileName in:('resources'). |
7236 |
pF notNil ifTrue:[ |
|
7237 |
^ pF. |
|
7238 |
]. |
|
12547
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7239 |
"/ pF := self searchPath:(self realSystemPath) for:aFileName in:('resources/styles'). |
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7240 |
"/ pF notNil ifTrue:[ |
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7241 |
"/ ^ pF. |
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7242 |
"/ ]. |
18668 | 7243 |
f ~= aFileName ifTrue:[ |
7244 |
pF := self searchPath:(self realSystemPath) for:f in:('resources'). |
|
7245 |
pF notNil ifTrue:[ |
|
7246 |
^ pF. |
|
7247 |
]. |
|
12547
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7248 |
"/ pF := self searchPath:(self realSystemPath) for:f in:('resources/styles'). |
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7249 |
"/ pF notNil ifTrue:[ |
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7250 |
"/ ^ pF. |
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7251 |
"/ ]. |
18668 | 7252 |
]. |
7253 |
^ nil |
|
10641 | 7254 |
]. |
7255 |
||
7256 |
packageDir := aPackageIDOrNil copyReplaceAll:$: with:$/. |
|
7257 |
||
7258 |
pF := self searchPath:(self realSystemPath) for:aFileName in:('resources/',packageDir). |
|
7259 |
pF notNil ifTrue:[ |
|
18668 | 7260 |
^ pF. |
10641 | 7261 |
]. |
7262 |
||
12547
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7263 |
"/ the following code finds the file within the IDE's own hierarchy |
10641 | 7264 |
dir := self projectDirectoryForPackage:aPackageIDOrNil. |
7265 |
dir notNil ifTrue:[ |
|
18668 | 7266 |
dir := dir asFilename. |
7267 |
||
7268 |
(pF := dir / 'resources' / f) exists ifTrue:[ ^ pF name ]. |
|
12547
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7269 |
"/ (pF := dir / 'styles' / f) exists ifTrue:[ ^ pF name ]. |
12377 | 7270 |
|
18668 | 7271 |
"resolve something like: 'ASN/definition.asn1'" |
7272 |
(pF := dir / f) exists ifTrue:[ ^ pF name ]. |
|
12377 | 7273 |
]. |
7274 |
||
10641 | 7275 |
^ nil |
7276 |
||
7277 |
" |
|
7278 |
Smalltalk getResourceFileName:'SystemBrowser.rs' forPackage:'stx:libtool' |
|
7279 |
Smalltalk getResourceFileName:'normal.style' forPackage:'stx:libview' |
|
12547
30fda24cebb5
comment/format in: #getResourceFileName:forClass:
Claus Gittinger <cg@exept.de>
parents:
12539
diff
changeset
|
7280 |
Smalltalk getResourceFileName:'styles/normal.style' forPackage:'stx:libview' |
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
7281 |
Smalltalk getResourceFileName:'styles/mswindowsXP.style' forPackage:'stx:libview' |
10641 | 7282 |
Smalltalk getResourceFileName:'Foo.rs' forPackage:'stx:libview' |
7283 |
" |
|
7284 |
||
7285 |
"Modified: / 11-10-2006 / 13:53:43 / cg" |
|
7286 |
! |
|
7287 |
||
7288 |
getSourceFileName:aFileName |
|
7289 |
"search aFileName in some standard places |
|
7290 |
(subdirectories named 'source' in SystemPath); |
|
7291 |
return the absolute filename or nil if none is found. |
|
7292 |
This is used to find a sourceFile for a methods source, |
|
7293 |
if no sourceCodeManager is available." |
|
7294 |
||
7295 |
|f| |
|
7296 |
||
7297 |
SourcePath isNil ifTrue:[ |
|
18668 | 7298 |
SourcePath := self constructPathFor:SourceDirName |
10641 | 7299 |
]. |
7300 |
||
7301 |
"/ first, try a source subdir along the path. |
|
7302 |
SourcePath notNil ifTrue:[ |
|
18668 | 7303 |
f := self searchPath:SourcePath for:aFileName in:SourceDirName. |
10641 | 7304 |
]. |
7305 |
f isNil ifTrue:[ |
|
18668 | 7306 |
"/ then, try it itself along the path. |
7307 |
f := self searchPath:self realSystemPath for:aFileName in:nil |
|
10641 | 7308 |
]. |
7309 |
^ f |
|
7310 |
||
7311 |
" |
|
7312 |
Smalltalk getSourceFileName:'Smalltalk.st' |
|
7313 |
Smalltalk getSourceFileName:'ArrColl.st' |
|
7314 |
" |
|
7315 |
||
7316 |
"Modified: 18.7.1996 / 15:54:07 / cg" |
|
7317 |
! |
|
7318 |
||
7319 |
getSystemFileName:aFileNameOrString |
|
7320 |
"search aFileNameOrString in some standard places; |
|
7321 |
return the absolute filename or nil if none is found. |
|
7322 |
see comment in Smalltalk>>initSystemPath. |
|
7323 |
This should be used to access resources such as bitmaps, doc-files, |
|
7324 |
and other help files. |
|
7325 |
" |
|
7326 |
||
7327 |
"credits for this method go to Markus ...." |
|
7328 |
||
7329 |
|fn nameString| |
|
7330 |
||
7331 |
fn := aFileNameOrString asFilename. |
|
7332 |
nameString := fn name. |
|
7333 |
fn isAbsolute ifTrue:[ |
|
18668 | 7334 |
"dont use path for absolute file names" |
7335 |
||
7336 |
^ nameString |
|
10641 | 7337 |
]. |
7338 |
||
7339 |
self realSystemPath do:[:dirName | |
|
18668 | 7340 |
|realName| |
7341 |
||
7342 |
realName := dirName asFilename / nameString. |
|
7343 |
"/ |
|
7344 |
"/ here, we also return true if its a directory |
|
7345 |
"/ (Even if unreadable). |
|
7346 |
"/ It could be that the file itself is still readable. |
|
7347 |
"/ |
|
7348 |
(realName isDirectory or:[realName isReadable]) ifTrue: [ |
|
7349 |
^ realName name |
|
7350 |
] |
|
10641 | 7351 |
]. |
7352 |
^ nil |
|
7353 |
||
7354 |
" |
|
7355 |
Smalltalk getSystemFileName:'doc/online/english/TOP.html' |
|
7356 |
Smalltalk getSystemFileName:'bitmaps/SBrowser.xbm' |
|
7357 |
Smalltalk getSystemFileName:'bitmaps/foo' |
|
7358 |
Smalltalk getSystemFileName:'resources/View.rs' |
|
7359 |
Smalltalk getSystemFileName:'resources/iris.style' |
|
7360 |
" |
|
7361 |
||
7362 |
"Modified: / 6.5.1999 / 10:40:37 / cg" |
|
7363 |
! |
|
7364 |
||
7365 |
imageFromFileNamed:aFileName forClass:aClass |
|
7366 |
"search aFileName in some standard places: |
|
7367 |
first in the redefinable bitmaps path, then in the classes |
|
7368 |
own package directory if existing. |
|
7369 |
Return an image or nil." |
|
7370 |
||
7371 |
|classPackage img| |
|
7372 |
||
7373 |
classPackage := aClass package. |
|
7374 |
img := self imageFromFileNamed:aFileName inPackage:classPackage. |
|
7375 |
img isNil ifTrue:[ |
|
18668 | 7376 |
"/ try under the goodies package ... |
7377 |
classPackage ~= 'stx:goodies' ifTrue:[ |
|
7378 |
img := self imageFromFileNamed:aFileName inPackage:'stx:goodies'. |
|
7379 |
] |
|
10641 | 7380 |
]. |
7381 |
^ img |
|
7382 |
||
7383 |
" |
|
7384 |
Smalltalk imageFromFileNamed:'SmalltalkX.xbm' forClass:View |
|
7385 |
" |
|
7386 |
! |
|
7387 |
||
7388 |
imageFromFileNamed:aFileName inPackage:aPackage |
|
7389 |
"search aFileName in some standard places: |
|
7390 |
first in the redefinable bitmaps path, |
|
7391 |
then in the package directory if existing. |
|
7392 |
Return an image or nil. |
|
7393 |
Search order is: |
|
18668 | 7394 |
bitmaps/<pkg>/file |
7395 |
resources/<pkg>/bitmaps/file |
|
7396 |
<pkg>/bitmaps/file |
|
10641 | 7397 |
" |
7398 |
||
7399 |
|path| |
|
7400 |
||
7401 |
path := self getBitmapFileName:aFileName forPackage:aPackage. |
|
7402 |
path notNil ifTrue:[ |
|
18668 | 7403 |
^ Image fromFile:path. |
10641 | 7404 |
]. |
7405 |
^ nil |
|
7406 |
||
7407 |
" |
|
7408 |
Smalltalk imageFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libview' |
|
7409 |
Smalltalk imageFromFileNamed:'SmalltalkX.xbm' inPackage:'stx:libtool' |
|
7410 |
Smalltalk imageFromFileNamed:'bitmaps/gifImages/garfield.gif' inPackage:'stx:goodies' |
|
7411 |
Smalltalk imageFromFileNamed:'CheckOn10_xp.xpm' inPackage:'stx:libwidg' |
|
7412 |
Smalltalk imageFromFileNamed:'ComboDn_xp.xpm' inPackage:'stx:libwidg' |
|
7413 |
" |
|
7414 |
||
7415 |
"Modified: / 08-09-2006 / 18:02:04 / cg" |
|
7416 |
! |
|
7417 |
||
7418 |
libraryFileNameOfClass:aClassOrClassName |
|
7419 |
"for a given class, return the name of a classLibrary which contains |
|
7420 |
binary code for it. |
|
7421 |
Read the libinfo file 'liblist.stc' (which is created during the compilation process) |
|
7422 |
for an entry for aClassOrClassName. |
|
7423 |
Search for the className in the first col, and return the value found in |
|
7424 |
the 2nd col. |
|
7425 |
Return nil if no entry is found. |
|
7426 |
||
7427 |
A nil returns means that this class is either built-in or not present |
|
7428 |
in a package-class library (i.e. either as separate .o or separate .st file). |
|
7429 |
Otherwise, the returned name is the classLibrary object of that class. |
|
7430 |
The classes code can be loaded from that file if binary loading is supported." |
|
7431 |
||
7432 |
|aStream line words n aClassName| |
|
7433 |
||
7434 |
aClassOrClassName isBehavior ifTrue:[ |
|
18668 | 7435 |
aClassName := aClassOrClassName name |
10641 | 7436 |
] ifFalse:[ |
18668 | 7437 |
aClassName := aClassOrClassName |
10641 | 7438 |
]. |
7439 |
aClassName := aClassName asString. |
|
7440 |
||
7441 |
#('include/liblist.stc') "/ filenames |
|
7442 |
with:#(2) "/ column |
|
7443 |
do:[:fileName :col | |
|
7444 |
||
18668 | 7445 |
aStream := self systemFileStreamFor:fileName. |
7446 |
aStream notNil ifTrue:[ |
|
7447 |
[aStream atEnd] whileFalse:[ |
|
7448 |
line := aStream nextLine. |
|
7449 |
line notNil ifTrue:[ |
|
7450 |
(line startsWith:'#') ifFalse:[ |
|
7451 |
words := line asCollectionOfWords. |
|
7452 |
(n := words size) > 1 ifTrue:[ |
|
7453 |
(words at:1) = aClassName ifTrue:[ |
|
7454 |
n >= col ifTrue:[ |
|
7455 |
aStream close. |
|
7456 |
^ (words at:col) withoutSeparators |
|
7457 |
] |
|
7458 |
] |
|
7459 |
] |
|
7460 |
] |
|
7461 |
] |
|
7462 |
]. |
|
7463 |
aStream close |
|
7464 |
]. |
|
10641 | 7465 |
]. |
7466 |
||
7467 |
^ nil |
|
7468 |
||
7469 |
" |
|
7470 |
Smalltalk libraryFileNameOfClass:'ClockView' |
|
7471 |
Smalltalk libraryFileNameOfClass:'Bag' |
|
7472 |
" |
|
7473 |
||
7474 |
"Modified: 6.11.1995 / 15:41:39 / cg" |
|
7475 |
! |
|
7476 |
||
7477 |
packagePath |
|
15781 | 7478 |
"return a collection of additional directory names, where smalltalk |
10641 | 7479 |
looks for package directories. |
7480 |
Notice, that directories named 'packages' under the systemPath are |
|
7481 |
always consulted - even if not in the packagePath" |
|
7482 |
||
7483 |
^ PackagePath |
|
7484 |
||
7485 |
" |
|
7486 |
Smalltalk packagePath |
|
7487 |
Smalltalk packagePath addLast:'/opt/smalltalk' |
|
7488 |
Smalltalk packagePath addFirst:'/usr/local/otherPackages' |
|
7489 |
" |
|
7490 |
! |
|
7491 |
||
7492 |
packagePath:aPath |
|
7493 |
"set the packagePath; |
|
7494 |
a collection of additional directorynames, where smalltalk |
|
7495 |
looks for package directories. |
|
7496 |
Notice, that directories named 'packages' under the systemPath are |
|
7497 |
always consulted - even if not in the packagePath" |
|
7498 |
||
7499 |
PackagePath := aPath asOrderedCollection |
|
7500 |
||
7501 |
" |
|
7502 |
Smalltalk packagePath:#( '.' '/opt/stx' '/opt/smalltalk' '/usr/local/otherPackages') |
|
7503 |
" |
|
7504 |
! |
|
7505 |
||
7506 |
projectDirectoryForClass:aClass |
|
7507 |
"given a class, return the path to its package directory; |
|
7508 |
nil if not found." |
|
7509 |
||
7510 |
|pkg| |
|
7511 |
||
7512 |
pkg := aClass package. |
|
7513 |
pkg isNil ifTrue:[^ nil]. |
|
7514 |
||
7515 |
^ self projectDirectoryForPackage:pkg. |
|
7516 |
||
7517 |
" |
|
7518 |
Smalltalk projectDirectoryForClass:Array |
|
7519 |
Smalltalk projectDirectoryForClass:View |
|
7520 |
" |
|
7521 |
! |
|
7522 |
||
7523 |
projectDirectoryForPackage:aPackage |
|
7524 |
"given a packageID, return the path to its package directory; |
|
7525 |
nil if not found." |
|
7526 |
||
7527 |
|prj prjDir| |
|
7528 |
||
16642 | 7529 |
^ aPackage asPackageId packageDirectory. |
7530 |
||
10641 | 7531 |
"/ there might be a package specific resource directory ... |
7532 |
"/ in the directory, from which the project was loaded |
|
7533 |
prj := Project projectWithId:aPackage. |
|
7534 |
prj notNil ifTrue:[ |
|
18668 | 7535 |
prjDir := prj directory. |
10641 | 7536 |
]. |
7537 |
(prjDir notNil and:[prjDir asFilename exists]) ifFalse:[ |
|
18668 | 7538 |
prjDir := Smalltalk getPackageFileName:(aPackage copyReplaceAll:$: with:$/). |
10641 | 7539 |
]. |
7540 |
^ prjDir |
|
7541 |
||
7542 |
" |
|
16668
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
7543 |
Smalltalk projectDirectoryForPackage:'stx:libbasic' |
10641 | 7544 |
Smalltalk projectDirectoryForPackage:'exept:smartcard' |
16668
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
7545 |
Smalltalk projectDirectoryForPackage:'stx' |
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
7546 |
Smalltalk projectDirectoryForPackage:'bosch' |
b88318df967d
flush cached class resources AFTER reading the user preferences
Claus Gittinger <cg@exept.de>
parents:
16666
diff
changeset
|
7547 |
Smalltalk projectDirectoryForPackage:'bosch:foo' |
10641 | 7548 |
" |
7549 |
||
7550 |
"Modified: / 07-10-2006 / 17:45:58 / cg" |
|
7551 |
! |
|
7552 |
||
7553 |
readAbbreviations |
|
7554 |
"read classname to filename mappings from include/abbrev.stc. |
|
7555 |
sigh - all for those poor sys5.3 or MSDOS people with short filenames ..." |
|
7556 |
||
7557 |
"since installAutoloadedClasses also reads all abbreviations, use it" |
|
7558 |
||
7559 |
CachedAbbreviations := IdentityDictionary new. |
|
7560 |
self installAutoloadedClasses. |
|
7561 |
^ CachedAbbreviations. |
|
7562 |
||
7563 |
" |
|
7564 |
Smalltalk readAbbreviations |
|
7565 |
" |
|
7566 |
||
7567 |
"Modified: / 10.12.1999 / 17:48:53 / cg" |
|
7568 |
! |
|
7569 |
||
7570 |
readAbbreviationsFromStream:aStream |
|
7571 |
"read classname to filename mappings from aStream. |
|
7572 |
sigh - all for those poor sys5.3 or MSDOS people with short filenames ..." |
|
7573 |
||
11375 | 7574 |
self |
18668 | 7575 |
withAbbreviationsFromStream:aStream |
7576 |
do:[:className :abbrev :pkg | |
|
7577 |
self setFilename:abbrev forClass:className package:pkg. |
|
7578 |
]. |
|
10641 | 7579 |
|
7580 |
"Modified: / 13.12.1999 / 11:54:17 / cg" |
|
7581 |
! |
|
7582 |
||
7583 |
realSystemPath |
|
16642 | 7584 |
"return the realSystemPath - that's the directory names from |
10641 | 7585 |
SystemPath which exist and are readable" |
7586 |
||
7587 |
|nP| |
|
7588 |
||
7589 |
RealSystemPath isNil ifTrue:[ |
|
18668 | 7590 |
OperatingSystem isVMSlike ifTrue:[ |
7591 |
"/ temporary kludge: since we cannot currently |
|
7592 |
"/ check for existence of a name like 'volume:', |
|
7593 |
"/ leave those in the Path without a check. |
|
7594 |
RealSystemPath := SystemPath select:[:dirName | |f| |
|
7595 |
f := dirName asFilename. |
|
7596 |
f isVolumeOnly or:[(f isDirectory) and:[f isReadable]] |
|
7597 |
] |
|
7598 |
] ifFalse:[ |
|
7599 |
RealSystemPath := SystemPath |
|
7600 |
select:[:eachDirectoryName | |f| |
|
7601 |
f := eachDirectoryName asFilename. |
|
7602 |
(f isDirectory) and:[f isReadable] |
|
7603 |
] thenCollect:[:eachDirectoryName| |
|
7604 |
eachDirectoryName asFilename pathName. |
|
7605 |
]. |
|
7606 |
||
7607 |
"/ remove duplicates (but keep order) |
|
7608 |
nP := OrderedCollection new. |
|
7609 |
RealSystemPath do:[:p | |
|
7610 |
(nP includes:p) ifFalse:[ |
|
7611 |
nP add:p |
|
7612 |
] |
|
7613 |
]. |
|
7614 |
(nP includes:'.') ifFalse:[ |
|
7615 |
nP add:'.' |
|
7616 |
]. |
|
7617 |
RealSystemPath := nP. |
|
7618 |
]. |
|
617 | 7619 |
]. |
7620 |
^ RealSystemPath |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7621 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7622 |
|
10641 | 7623 |
recursiveReadAllAbbreviationsFrom:aDirectory |
7624 |
self recursiveReadAllAbbreviationsFrom:aDirectory maxLevels:15 |
|
7625 |
! |
|
7626 |
||
7627 |
recursiveReadAllAbbreviationsFrom:aDirectory maxLevels:maxLevels |
|
7628 |
"read all abbreviations from and under aDirectory." |
|
7629 |
||
7630 |
|abbrevStream dir directoryContents| |
|
7631 |
||
7632 |
maxLevels == 0 ifTrue:[ |
|
7633 |
"/ 'Smalltalk [warning]: max directory nesting reached.' infoPrintCR. |
|
19117 | 7634 |
^ self |
10641 | 7635 |
]. |
7636 |
||
7637 |
dir := aDirectory asFilename. |
|
7638 |
dir exists ifFalse:[^ self]. |
|
7639 |
||
7640 |
[ |
|
19117 | 7641 |
abbrevStream := (dir / 'abbrev.stc') asFilename readStream. |
7642 |
self readAbbreviationsFromStream:abbrevStream. |
|
7643 |
abbrevStream close. |
|
10641 | 7644 |
] on:FileStream openErrorSignal do:[:ex| "ignore this file"]. |
7645 |
||
7646 |
[ |
|
19117 | 7647 |
directoryContents := dir directoryContents. |
10641 | 7648 |
] on:FileStream openErrorSignal do:[:ex| |
19117 | 7649 |
"non-accessible directory: we are done" |
7650 |
^ self |
|
10641 | 7651 |
]. |
7652 |
||
7653 |
directoryContents do:[:aFilename | |
|
19117 | 7654 |
|f| |
7655 |
||
7656 |
(#( |
|
7657 |
'doc' |
|
7658 |
'CVS' |
|
7659 |
'bitmaps' |
|
7660 |
'resources' |
|
7661 |
'source' |
|
7662 |
) includes:aFilename) ifFalse:[ |
|
7663 |
f := dir / aFilename. |
|
7664 |
f isDirectory ifTrue:[ |
|
7665 |
self recursiveReadAllAbbreviationsFrom:f maxLevels:maxLevels-1 |
|
7666 |
] |
|
7667 |
]. |
|
4458 | 7668 |
]. |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7669 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7670 |
|
15334 | 7671 |
reinitializePackagePath |
7672 |
"{ Pragma: +optSpace }" |
|
18868 | 7673 |
|
15334 | 7674 |
PackagePath notNil ifTrue:[ |
18868 | 7675 |
PackagePath := PackagePath select:[:p | p asFilename exists]. |
15334 | 7676 |
]. |
7677 |
PackagePath isEmptyOrNil ifTrue:[ |
|
18868 | 7678 |
PackagePath := OperatingSystem defaultPackagePath |
7679 |
]. |
|
7680 |
self addWorkspaceDirectoryToPackagePath. |
|
15334 | 7681 |
! |
7682 |
||
13368 | 7683 |
relativePackagePathForPackage:aPackage |
7684 |
|path| |
|
7685 |
||
7686 |
PackageToPathMapping notNil ifTrue:[ |
|
18668 | 7687 |
path := PackageToPathMapping at:aPackage ifAbsent:nil. |
7688 |
PackageToPathMapping notNil ifTrue:[^ path]. |
|
13370 | 7689 |
]. |
7690 |
^ aPackage copyReplaceAll:$: with:$/. |
|
13368 | 7691 |
|
7692 |
" |
|
7693 |
PackageToPathMapping := Dictionary new. |
|
7694 |
PackageToPathMapping at:'expeccoNET:server' put:'expeccoNET_oldVersion/server'. |
|
7695 |
PackageToPathMapping at:'expeccoNET:server/ui' put:'expeccoNET_oldVersion/server/ui'. |
|
7696 |
||
7697 |
Smalltalk relativePackagePathForPackage:'stx:libview/resources' |
|
7698 |
Smalltalk relativePackagePathForPackage:'stx:libview' |
|
7699 |
" |
|
7700 |
! |
|
7701 |
||
10641 | 7702 |
resourceDirectoryForPackage:aPackage |
7703 |
"given a packageID, return the path to its resource directory; |
|
7704 |
nil if not found." |
|
7705 |
||
7706 |
|prjDir rsrcDir| |
|
7707 |
||
11183
9a4e7475a655
care for nil project when asked for a resource directory
Claus Gittinger <cg@exept.de>
parents:
11174
diff
changeset
|
7708 |
aPackage notNil ifTrue:[ |
18668 | 7709 |
prjDir := self projectDirectoryForPackage:aPackage. |
7710 |
||
7711 |
(prjDir notNil |
|
7712 |
and:[(prjDir := prjDir asFilename) exists |
|
7713 |
and:[(rsrcDir := prjDir / 'resources') exists]]) ifTrue:[ |
|
7714 |
^ rsrcDir |
|
7715 |
]. |
|
7716 |
rsrcDir := self getSystemFileName:('resources/' , (aPackage copyReplaceAll:$: with:$/)). |
|
7717 |
rsrcDir notNil ifTrue:[ |
|
7718 |
^ rsrcDir asFilename |
|
7719 |
]. |
|
10641 | 7720 |
]. |
7721 |
^ nil |
|
7722 |
||
7723 |
" |
|
7724 |
Smalltalk resourceDirectoryForPackage:'stx:libbasic' |
|
7725 |
Smalltalk resourceDirectoryForPackage:'exept:expecco' |
|
7726 |
Smalltalk resourceDirectoryForPackage:'exept:smartcard' |
|
7727 |
" |
|
7728 |
! |
|
7729 |
||
7730 |
resourceFileStreamFor:aFileName |
|
7731 |
"search aFileName in some standard places; |
|
7732 |
return a readonly fileStream or nil if not found. |
|
7733 |
Searches in subdirectories named 'resource' in SystemPath" |
|
7734 |
||
7735 |
^ self resourceFileStreamFor:aFileName forClass:nil |
|
7736 |
! |
|
7737 |
||
7738 |
resourceFileStreamFor:aFileName forClass:aClassOrNil |
|
7739 |
"search aFileName in some standard places and in the classes |
|
7740 |
package-resource directory. |
|
7741 |
Return a readonly fileStream or nil if not found. |
|
7742 |
Searches in subdirectories named 'resource' in SystemPath" |
|
7743 |
||
7744 |
|aString| |
|
7745 |
||
7746 |
aString := self getResourceFileName:aFileName forClass:aClassOrNil. |
|
7747 |
aString notNil ifTrue:[ |
|
18668 | 7748 |
^ aString asFilename readStreamOrNil |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7749 |
]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7750 |
^ nil |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7751 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7752 |
|
10641 | 7753 |
searchPath:aPath for:aFileName in:aDirName |
7754 |
"search aPath for a subdirectory named aDirectory with a file |
|
7755 |
named aFileName" |
|
7756 |
||
7757 |
|f| |
|
7758 |
||
7759 |
((f := aFileName asFilename) isAbsolute |
|
7760 |
or:[f isExplicitRelative]) ifTrue:[ |
|
18668 | 7761 |
"/ |
7762 |
"/ dont use path for absolute or explicit .-relative file names |
|
7763 |
"/ |
|
7764 |
^ aFileName |
|
10641 | 7765 |
]. |
7766 |
||
7767 |
aPath notNil ifTrue:[ |
|
18668 | 7768 |
aPath do:[:dirName | |
7769 |
|realName dir| |
|
7770 |
||
7771 |
dir := dirName asFilename. |
|
7772 |
aDirName notNil ifTrue:[ |
|
7773 |
realName := dir / aDirName / aFileName. |
|
7774 |
] ifFalse:[ |
|
7775 |
realName := dir / aFileName. |
|
7776 |
]. |
|
7777 |
(realName isReadable) ifTrue:[ |
|
7778 |
^ realName name |
|
7779 |
] |
|
7780 |
]. |
|
11108 | 7781 |
]. |
7782 |
||
7783 |
"/ not needed - executing dir is always in SearchPath |
|
12377 | 7784 |
"/ realName := Filename currentDirectory / aFileName. |
11108 | 7785 |
"/ (realName isReadable) ifTrue:[ |
7786 |
"/ ^ realName name |
|
7787 |
"/ ]. |
|
10641 | 7788 |
^ nil. |
7789 |
||
7790 |
"Modified: / 29.4.1999 / 15:06:43 / cg" |
|
7791 |
! |
|
7792 |
||
7793 |
setFilename:aFileNameString forClass:aClassNameString package:aPackageNameString |
|
7794 |
|classNameSymbol oldAbbrev oldPath newPath cls abbrevs| |
|
7795 |
||
7796 |
CachedAbbreviations isNil ifTrue:[ |
|
18668 | 7797 |
CachedAbbreviations := IdentityDictionary new. |
10641 | 7798 |
]. |
7799 |
||
7800 |
abbrevs := CachedAbbreviations. |
|
7801 |
aClassNameString ~= aFileNameString ifTrue:[ |
|
18668 | 7802 |
classNameSymbol := aClassNameString asSymbol. |
7803 |
oldAbbrev := abbrevs at:classNameSymbol ifAbsent:nil. |
|
7804 |
oldAbbrev notNil ifTrue:[ |
|
7805 |
oldAbbrev ~= aFileNameString ifTrue:[ |
|
7806 |
oldAbbrev asFilename isAbsolute |
|
7807 |
ifTrue:[ oldPath := oldAbbrev ] |
|
7808 |
ifFalse:[ oldPath := (self projectDirectoryForPackage:aPackageNameString) asFilename constructString: oldAbbrev ]. |
|
7809 |
aFileNameString asFilename isAbsolute |
|
7810 |
ifTrue:[ newPath := aFileNameString ] |
|
7811 |
ifFalse:[ newPath := (self projectDirectoryForPackage:aPackageNameString) asFilename constructString: aFileNameString ]. |
|
7812 |
||
7813 |
oldPath ~= newPath ifTrue:[ |
|
7814 |
StandAlone ifFalse:[ |
|
7815 |
('Smalltalk [warning]: autoload path change for: ',aClassNameString,' in package ',aPackageNameString) infoPrintCR. |
|
7816 |
('Smalltalk [info]: old: ',oldPath) infoPrintCR. |
|
7817 |
('Smalltalk [info]: new: ',newPath) infoPrintCR. |
|
7818 |
] |
|
7819 |
] |
|
7820 |
]. |
|
7821 |
"overwrite old abbreviation with new one, |
|
7822 |
to allow fixing of bad abbrev files" |
|
7823 |
]. |
|
7824 |
||
7825 |
cls := self classNamed:aFileNameString. |
|
7826 |
cls notNil ifTrue:[ |
|
7827 |
cls name ~= aClassNameString ifTrue:[ |
|
7828 |
"/ ok, there is a class named after this abbrev ... |
|
7829 |
"/ this is only a conflict, if the other class has no |
|
7830 |
"/ abbreviation (or the same). |
|
7831 |
(abbrevs at:(cls name asSymbol) ifAbsent:cls name) = aFileNameString ifTrue:[ |
|
7832 |
cls isNameSpace ifFalse:[ |
|
7833 |
aPackageNameString = cls package ifTrue:[ |
|
7834 |
StandAlone ifFalse:[ |
|
7835 |
('Smalltalk [warning]: conflict for: ' , cls name , |
|
7836 |
' in package ' , aPackageNameString) infoPrintCR. |
|
7837 |
('Smalltalk [warning]: (' , aClassNameString , ' -> ' , aFileNameString |
|
7838 |
, ')') infoPrintCR |
|
7839 |
] |
|
7840 |
] |
|
7841 |
] |
|
7842 |
] |
|
7843 |
] |
|
7844 |
]. |
|
7845 |
abbrevs at:classNameSymbol put:aFileNameString. |
|
8470
d79e917d4f36
Define #setFilename:forClass:package: to define an abbreviation.
Stefan Vogel <sv@exept.de>
parents:
8445
diff
changeset
|
7846 |
] |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7847 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7848 |
|
10641 | 7849 |
sourceDirectoryNameOfClass:aClassOrClassName |
7850 |
"for a given class, return the pathname relative to TOP of the classes source code. |
|
7851 |
Read the files 'abbrev.stc' and 'liblist.stc' (which are created during the compilation process) |
|
7852 |
for an entry for aClassOrClassName. |
|
7853 |
Search for the className in the first col, and return the value found in |
|
7854 |
the 3rd col. |
|
7855 |
Return nil if no entry is found." |
|
7856 |
||
7857 |
|aStream line words n aClassName| |
|
7858 |
||
7859 |
aClassOrClassName isBehavior ifTrue:[ |
|
18668 | 7860 |
aClassName := aClassOrClassName name |
10641 | 7861 |
] ifFalse:[ |
18668 | 7862 |
aClassName := aClassOrClassName |
10641 | 7863 |
]. |
7864 |
aClassName := aClassName asString. |
|
7865 |
||
7866 |
#('include/abbrev.stc' 'include/liblist.stc') "/ filenames |
|
7867 |
with:#(3 2) "/ column |
|
7868 |
do:[:fileName :col | |
|
7869 |
||
18668 | 7870 |
aStream := self systemFileStreamFor:fileName. |
7871 |
aStream notNil ifTrue:[ |
|
7872 |
[aStream atEnd] whileFalse:[ |
|
7873 |
line := aStream nextLine. |
|
7874 |
line notNil ifTrue:[ |
|
7875 |
(line startsWith:'#') ifFalse:[ |
|
7876 |
words := line asCollectionOfWords. |
|
7877 |
(n := words size) > 1 ifTrue:[ |
|
7878 |
(words at:1) = aClassName ifTrue:[ |
|
7879 |
n >= col ifTrue:[ |
|
7880 |
aStream close. |
|
7881 |
^ (words at:col) withoutSeparators |
|
7882 |
] |
|
7883 |
] |
|
7884 |
] |
|
7885 |
] |
|
7886 |
] |
|
7887 |
]. |
|
7888 |
aStream close |
|
7889 |
]. |
|
10641 | 7890 |
]. |
7891 |
||
7892 |
^ nil |
|
7893 |
||
7894 |
" |
|
7895 |
Smalltalk sourceDirectoryNameOfClass:'ClockView' |
|
7896 |
Smalltalk sourceDirectoryNameOfClass:'Bag' |
|
7897 |
Smalltalk sourceDirectoryNameOfClass:'GLWireCubeDemoView' |
|
7898 |
Smalltalk sourceDirectoryNameOfClass:'SomeNonExistingClass' |
|
7899 |
" |
|
7900 |
||
7901 |
"Created: 6.11.1995 / 15:43:30 / cg" |
|
7902 |
"Modified: 9.12.1995 / 23:54:14 / cg" |
|
7903 |
"Modified: 3.1.1997 / 11:26:44 / stefan" |
|
7904 |
! |
|
7905 |
||
7906 |
sourceFileStreamFor:aFileName |
|
7907 |
"search aFileName in some standard places; |
|
7908 |
return a readonly fileStream or nil if not found. |
|
7909 |
Searches in subdirectories named 'source' in SystemPath" |
|
7910 |
||
7911 |
|aString| |
|
7912 |
||
7913 |
aString := self getSourceFileName:aFileName. |
|
7914 |
aString notNil ifTrue:[ |
|
18668 | 7915 |
^ aString asFilename readStreamOrNil |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7916 |
]. |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7917 |
^ nil |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7918 |
! |
7758 | 7919 |
|
10641 | 7920 |
systemFileStreamFor:aFileName |
7921 |
"search aFileName in some standard places; |
|
7922 |
return a readonly fileStream or nil if not found. |
|
7923 |
see comment in Smalltalk>>initSystemPath" |
|
7924 |
||
7925 |
|aString| |
|
7926 |
||
7927 |
aString := self getSystemFileName:aFileName. |
|
7928 |
aString notNil ifTrue:[ |
|
18668 | 7929 |
^ aString asFilename readStreamOrNil |
617 | 7930 |
]. |
7931 |
^ nil |
|
7932 |
! |
|
7933 |
||
10641 | 7934 |
systemPath |
7935 |
"return a collection of directorynames, where smalltalk |
|
7936 |
looks for system files |
|
7937 |
(usually in subdirs such as resources, bitmaps, source etc.) |
|
7938 |
see comment in Smalltalk>>initSystemPath." |
|
7939 |
||
7940 |
^ SystemPath |
|
7941 |
||
7942 |
" |
|
7943 |
Smalltalk systemPath |
|
7944 |
Smalltalk systemPath addLast:'someOtherDirectoryPath' |
|
7945 |
" |
|
7946 |
! |
|
7947 |
||
7948 |
systemPath:aPath |
|
7949 |
"set the collection of directorynames, where smalltalk |
|
7950 |
looks for system files |
|
7951 |
(usually in subdirs such as resources, bitmaps, source etc.) |
|
7952 |
see comment in Smalltalk>>initSystemPath." |
|
7953 |
||
7954 |
SystemPath := aPath. |
|
7955 |
self flushPathCaches |
|
7956 |
||
7957 |
" |
|
7958 |
Smalltalk systemPath |
|
7959 |
Smalltalk systemPath:(Smalltalk systemPath copy addLast:'someOtherDirectoryPath') |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
7960 |
" |
11301
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7961 |
! |
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7962 |
|
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7963 |
withAbbreviationsFromStream:aStream do:aBlock |
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7964 |
"read classname to filename mappings from aStream. |
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7965 |
Evaluate aBlock for each tuple: |
18668 | 7966 |
class-name , abbrev-name, package |
11301
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7967 |
Sigh - all for those poor sys5.3 or MSDOS people with short filenames..." |
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7968 |
|
13415 | 7969 |
|line lineNo words nm abbrev pkg category size s w| |
7970 |
||
7971 |
lineNo := 0. |
|
11301
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7972 |
[aStream atEnd] whileFalse:[ |
18668 | 7973 |
line := aStream nextLine. |
7974 |
lineNo := lineNo + 1. |
|
7975 |
line notEmptyOrNil ifTrue:[ |
|
7976 |
(line startsWith:'#') ifFalse:[ |
|
7977 |
||
7978 |
"/ must do it manually, caring for quoted strings. |
|
11301
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7979 |
"/ words := line asCollectionOfWords. |
f65ffb560925
refactored abbreviation-reading
Claus Gittinger <cg@exept.de>
parents:
11232
diff
changeset
|
7980 |
|
18668 | 7981 |
words := OrderedCollection new. |
7982 |
s := line readStream. |
|
7983 |
[s atEnd] whileFalse:[ |
|
7984 |
s skipSeparators. |
|
7985 |
s peek == $' ifTrue:[ |
|
7986 |
s next. |
|
7987 |
w := s upTo:$'. |
|
7988 |
s skipSeparators. |
|
7989 |
] ifFalse:[ |
|
7990 |
w := s upToSeparator |
|
7991 |
]. |
|
7992 |
words add:w |
|
7993 |
]. |
|
7994 |
words size >= 3 ifTrue:[ |
|
7995 |
nm := (words at:1) withoutSeparators. |
|
7996 |
abbrev := (words at:2) withoutSeparators. |
|
7997 |
pkg := (words at:3) withoutSeparators. |
|
7998 |
aBlock argumentCount = 3 ifTrue:[ |
|
7999 |
aBlock value:nm value:abbrev value:pkg. |
|
8000 |
] ifFalse:[ |
|
8001 |
words size >= 4 ifTrue:[ |
|
8002 |
category := words at:4. |
|
8003 |
]. |
|
8004 |
words size = 5 ifTrue:[ |
|
8005 |
size := (words at:5) asNumber |
|
8006 |
]. |
|
8007 |
aBlock value:nm value:abbrev value:pkg value: category value: size |
|
8008 |
] |
|
8009 |
] ifFalse:[ |
|
8010 |
('Smalltalk [warning]: malformed line ', lineNo printString , ' in ' , (aStream pathName)) infoPrintCR. |
|
8011 |
] |
|
8012 |
] |
|
8013 |
] |
|
13518
b81bc64782b1
not ifTrue -> ifFalse (trying the rewrite tool ;-)
Claus Gittinger <cg@exept.de>
parents:
13506
diff
changeset
|
8014 |
]. |
b81bc64782b1
not ifTrue -> ifFalse (trying the rewrite tool ;-)
Claus Gittinger <cg@exept.de>
parents:
13506
diff
changeset
|
8015 |
|
13415 | 8016 |
"Modified: / 06-03-2011 / 18:17:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13546
8993c10243a2
changed: #withAbbreviationsFromStream:do:
Claus Gittinger <cg@exept.de>
parents:
13540
diff
changeset
|
8017 |
"Modified: / 04-08-2011 / 21:35:00 / cg" |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8018 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8019 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8020 |
!Smalltalk class methodsFor:'system management-packages'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8021 |
|
16159 | 8022 |
isPackageLoaded:aPackageIdOrPackage |
8023 |
|projectDefinition| |
|
8024 |
||
8025 |
projectDefinition := aPackageIdOrPackage asPackageId projectDefinitionClass. |
|
16161 | 8026 |
^ projectDefinition notNil and:[projectDefinition isLoaded and:[projectDefinition isFullyLoaded]] |
16159 | 8027 |
|
8028 |
" |
|
8029 |
Smalltalk isPackageLoaded:'stx:goodies/persistency' |
|
16170
ca4d03def070
endOfDipatch if running scripts
Claus Gittinger <cg@exept.de>
parents:
16164
diff
changeset
|
8030 |
Smalltalk isPackageLoaded:'stx:goodies/refactoryBrowser/lint' |
ca4d03def070
endOfDipatch if running scripts
Claus Gittinger <cg@exept.de>
parents:
16164
diff
changeset
|
8031 |
Smalltalk isPackageLoaded:'stx:goodies/refactoryBrowser/lint/spelling' |
16159 | 8032 |
" |
8033 |
! |
|
8034 |
||
10641 | 8035 |
loadPackage:aPackageIdOrPackage |
12250 | 8036 |
"make certain, that some particular package is loaded into the system. |
8037 |
Return true if loaded, false otherwise." |
|
11668 | 8038 |
|
8039 |
^ self loadPackage:aPackageIdOrPackage asAutoloaded:false |
|
8040 |
||
8041 |
" |
|
8042 |
Smalltalk loadPackage:'stx:libbasic' |
|
8043 |
Smalltalk loadPackage:'stx:goodies/persistency' |
|
8044 |
Smalltalk loadPackage:'cg:cparser' |
|
8045 |
Smalltalk loadPackage:'cg:rose' |
|
8046 |
" |
|
8047 |
! |
|
8048 |
||
10641 | 8049 |
packageDirectoryForPackageId:aPackageId |
12250 | 8050 |
"used by classes to find the location of their resource- and bitmap directories. |
8051 |
||
8052 |
Notice that the directory structure is different between the development |
|
8053 |
environment (top for packages is ../../../stx) and delivered stand alone executables, |
|
8054 |
where the top is specified via a shell environment variable, and is typically ../lib. |
|
8055 |
At runtime, Smalltalk knows about the systemPath setting." |
|
8056 |
||
10641 | 8057 |
|packageDirName packageDir| |
8058 |
||
14589 | 8059 |
packageDirName := aPackageId asPackageId string copyReplaceAll:$: with:$/. |
10641 | 8060 |
|
8061 |
packageDir := self getPackageFileName:packageDirName. |
|
8062 |
packageDir isNil ifTrue:[ |
|
18668 | 8063 |
^ nil. |
10641 | 8064 |
]. |
8065 |
^ packageDir asFilename |
|
8066 |
||
8067 |
" |
|
11375 | 8068 |
Smalltalk packageDirectoryForPackageId:'stx:libbasic' |
10641 | 8069 |
Smalltalk packageDirectoryForPackageId:'stx:goodies/persistency' |
8070 |
Smalltalk packageDirectoryForPackageId:'exept:ctypes' |
|
8071 |
" |
|
12250 | 8072 |
! |
8073 |
||
18794 | 8074 |
requirePackage:aPackageIdOrPackage |
8075 |
"make certain, that some particular package is loaded into the system. |
|
8076 |
Return true if loaded, false otherwise. |
|
8077 |
Just an alias which is easier to remember" |
|
8078 |
||
8079 |
^ self loadPackage:aPackageIdOrPackage |
|
8080 |
||
8081 |
" |
|
8082 |
Smalltalk loadPackage:'stx:libbasic' |
|
8083 |
Smalltalk loadPackage:'stx:goodies/persistency' |
|
8084 |
Smalltalk loadPackage:'cg:cparser' |
|
8085 |
Smalltalk loadPackage:'cg:rose' |
|
8086 |
" |
|
8087 |
! |
|
8088 |
||
12250 | 8089 |
unloadPackage:aPackageIdOrPackage |
8090 |
|projectDefinition| |
|
8091 |
||
8092 |
projectDefinition := aPackageIdOrPackage. |
|
8093 |
projectDefinition isProjectDefinition ifFalse:[ |
|
18668 | 8094 |
projectDefinition := projectDefinition asPackageId projectDefinitionClass. |
8095 |
projectDefinition isNil ifTrue:[ |
|
8096 |
'Smalltalk [info] trying to unload non-existing package: ' infoPrint. aPackageIdOrPackage infoPrintCR. |
|
8097 |
^ self. |
|
8098 |
]. |
|
12250 | 8099 |
]. |
8100 |
projectDefinition unloadPackage. |
|
8101 |
||
8102 |
" |
|
8103 |
Smalltalk loadPackage:'stx:goodies/persistency' |
|
8104 |
Smalltalk unloadPackage:'stx:goodies/persistency' |
|
8105 |
" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8106 |
! ! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8107 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8108 |
!Smalltalk class methodsFor:'system management-undeclared variables'! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8109 |
|
10641 | 8110 |
clearUndeclaredVariables |
8111 |
"remove all undeclared variables" |
|
8112 |
||
8113 |
(Smalltalk at:#Undeclared) do:[:eachKey | |
|
18668 | 8114 |
Smalltalk removeKey:(self undeclaredPrefix , eachKey) asSymbol. |
10641 | 8115 |
]. |
8116 |
(Smalltalk at:#Undeclared) removeAll. |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8117 |
Smalltalk removeKey:#Undeclared. |
10641 | 8118 |
! |
8119 |
||
8120 |
undeclaredPrefix |
|
8121 |
"the prefix used for undeclared variables" |
|
8122 |
||
8123 |
^ 'Undeclared:::' |
|
8124 |
||
8125 |
"Created: / 31.10.1997 / 01:13:10 / cg" |
|
7758 | 8126 |
! ! |
8127 |
||
8128 |
!Smalltalk class methodsFor:'time-versions'! |
|
8129 |
||
10641 | 8130 |
configuration |
8131 |
"{ Pragma: +optSpace }" |
|
8132 |
||
8133 |
"for developers only: return the configuration, with which |
|
8134 |
this smalltalk was compiled." |
|
8135 |
||
8136 |
%{ /* NOCONTEXT */ |
|
8137 |
extern char *__getConfigurationString(); |
|
8138 |
||
8139 |
RETURN (__MKSTRING(__getConfigurationString() COMMA_SND)); |
|
8140 |
%}. |
|
8141 |
^ 'unknownOS/unknownCONF:unknownPACK' |
|
8142 |
||
8143 |
" |
|
10071 | 8144 |
Smalltalk configuration |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8145 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8146 |
! |
453 | 8147 |
|
10641 | 8148 |
copyrightString |
8149 |
"{ Pragma: +optSpace }" |
|
8150 |
||
8151 |
"return a copyright string" |
|
8152 |
||
8153 |
%{ /* NOCONTEXT */ |
|
8154 |
#ifndef __getCopyrightString |
|
8155 |
extern OBJ __getCopyrightString(); |
|
8156 |
#endif |
|
8157 |
||
8158 |
RETURN (__getCopyrightString()); |
|
8159 |
%}. |
|
8160 |
^ self primitiveFailed |
|
8161 |
||
8162 |
" |
|
7758 | 8163 |
Smalltalk copyrightString |
8164 |
" |
|
8165 |
! |
|
8166 |
||
10641 | 8167 |
distributorString |
8168 |
"{ Pragma: +optSpace }" |
|
8169 |
||
8170 |
"return a string describing the distributor of this software" |
|
8171 |
||
8172 |
%{ /* NOCONTEXT */ |
|
8173 |
#ifndef __getDistributorString |
|
8174 |
extern OBJ __getDistributorString(); |
|
8175 |
#endif |
|
8176 |
||
8177 |
RETURN (__getDistributorString()); |
|
8178 |
%}. |
|
8179 |
^ 'eXept Software AG, Germany' |
|
8180 |
||
8181 |
" |
|
8182 |
Smalltalk distributorString |
|
8183 |
" |
|
8184 |
! |
|
8185 |
||
8186 |
expirationTime |
|
8187 |
"{ Pragma: +optSpace }" |
|
8188 |
||
8189 |
"for developers only: return the time when the system will expire. |
|
8190 |
after this time it will not run any longer. |
|
8191 |
It returns nil, if no expiration time has been set (system runs forever :-))" |
|
8192 |
||
8193 |
|exp| |
|
8194 |
||
8195 |
%{ |
|
8196 |
extern unsigned int __getExpirationTime(); |
|
8197 |
||
8198 |
exp = __MKUINT(__getExpirationTime()); |
|
8199 |
%}. |
|
8200 |
exp == 0 ifTrue:[ |
|
18668 | 8201 |
^ nil |
10641 | 8202 |
]. |
8203 |
^ Timestamp new fromOSTime:(exp * 1000). "OSTime is ms since 1970" |
|
8204 |
||
8205 |
" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8206 |
Smalltalk expirationTime |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8207 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8208 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8209 |
|
10641 | 8210 |
fullVersionString |
8211 |
"{ Pragma: +optSpace }" |
|
8212 |
||
8213 |
"return a full version string" |
|
8214 |
||
19516 | 8215 |
^ 'Smalltalk/X release %1%2 of %3' |
8216 |
bindWith:(self versionString) |
|
8217 |
with:((ExternalAddress pointerSize == 8) |
|
8218 |
ifTrue:[' (64bit)'] |
|
8219 |
ifFalse:['']) |
|
8220 |
with:(self versionDate) |
|
8221 |
||
8222 |
" |
|
8223 |
Smalltalk fullVersionString |
|
10641 | 8224 |
" |
8225 |
||
8226 |
"Created: / 27.10.1997 / 17:03:09 / cg" |
|
8227 |
"Modified: / 27.10.1997 / 17:04:02 / cg" |
|
8228 |
! |
|
8229 |
||
8230 |
hello |
|
8231 |
"{ Pragma: +optSpace }" |
|
8232 |
||
8233 |
"return a greeting string" |
|
8234 |
||
8235 |
"stupid: this should come from a resource file ... |
|
18924 | 8236 |
but I don't use it here, to allow mini-systems without |
10641 | 8237 |
Resource-stuff." |
8238 |
||
19187 | 8239 |
|proto lang bit bitsPerWordString| |
10641 | 8240 |
|
8241 |
lang := Language. |
|
19187 | 8242 |
bit := 'bit'. |
8243 |
||
10641 | 8244 |
(lang == #de) ifTrue:[ |
19187 | 8245 |
proto := 'Willkommen bei %1 (%4Version %2 von %3)'. bit := 'Bit'. |
10641 | 8246 |
] ifFalse:[ (lang == #fr) ifTrue:[ |
19681 | 8247 |
proto := 'Salut, Bienvenue à %1 (%4version %2 de %3)' |
10641 | 8248 |
] ifFalse:[ (lang == #it) ifTrue:[ |
19187 | 8249 |
proto := 'Ciao, benvenuto al %1 (%4versione %2 di %3)' |
10641 | 8250 |
] ifFalse:[ (lang == #es) ifTrue:[ |
19187 | 8251 |
proto := 'Hola, bienvenida a %1 (%4version %2 de %3)' |
18924 | 8252 |
] ifFalse:[ (lang == #pt) ifTrue:[ |
19681 | 8253 |
proto := 'Olá!!, mem-vindo a %1 (%4version %2 de %3)' |
10641 | 8254 |
] ifFalse:[ (lang == #no) ifTrue:[ |
19187 | 8255 |
proto := 'Hei, verdenmottakelse til %1 (%4versjon %2 av %3)' |
10641 | 8256 |
]]]]]]. |
8257 |
||
8258 |
"/ ... more needed here ... |
|
8259 |
||
8260 |
proto isNil ifTrue:[ |
|
19187 | 8261 |
proto := 'Hello World - welcome to %1 (%4version %2 of %3)'. |
8262 |
]. |
|
19492 | 8263 |
ExternalAddress pointerSize ~~ 4 ifTrue:[ |
8264 |
bitsPerWordString := (ExternalAddress pointerSize * 8) printString,bit,' '. |
|
19187 | 8265 |
] ifFalse:[ |
8266 |
bitsPerWordString := '' |
|
8267 |
]. |
|
10641 | 8268 |
|
8269 |
^ proto bindWith:('SmallTalk/X' allBold) |
|
18924 | 8270 |
with:(self versionString) |
8271 |
with:(self versionDate) |
|
19187 | 8272 |
with:bitsPerWordString |
10641 | 8273 |
|
8274 |
" |
|
8275 |
Smalltalk language:#us. |
|
19187 | 8276 |
Smalltalk hello |
10641 | 8277 |
|
8278 |
Smalltalk language:#de. |
|
8279 |
Smalltalk hello |
|
8280 |
||
8281 |
Smalltalk language:#no. |
|
8282 |
Smalltalk hello |
|
8283 |
||
8284 |
Transcript showCR:(Smalltalk hello) |
|
8285 |
Stdout showCR:(Smalltalk hello) |
|
8286 |
" |
|
8287 |
||
8288 |
"Modified: 18.5.1996 / 14:25:13 / cg" |
|
8289 |
! |
|
8290 |
||
8291 |
imageRestartTime |
|
8292 |
"return a timestamp for the moment when this image was restarted. |
|
8293 |
If we do not execute from an image (i.e. fresh start), return nil." |
|
8294 |
||
8295 |
^ ImageRestartTime |
|
8296 |
||
8297 |
" |
|
8298 |
Smalltalk imageStartTime |
|
8299 |
Smalltalk imageRestartTime |
|
8300 |
" |
|
8301 |
||
8302 |
"Created: 13.12.1995 / 17:44:20 / cg" |
|
8303 |
"Modified: 6.3.1996 / 11:56:35 / cg" |
|
8304 |
! |
|
8305 |
||
8306 |
imageSaveTime |
|
8307 |
"{ Pragma: +optSpace }" |
|
8308 |
||
8309 |
"return a timestamp for the moment when this image was saved" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8310 |
|
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8311 |
^ ObjectMemory imageSaveTime |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8312 |
! |
7758 | 8313 |
|
10641 | 8314 |
imageStartTime |
8315 |
"{ Pragma: +optSpace }" |
|
8316 |
||
8317 |
"return a timestamp for the moment when this system started the first time |
|
8318 |
(i.e. the first initial start without an image)" |
|
8319 |
||
8320 |
^ ImageStartTime |
|
8321 |
||
8322 |
" |
|
8323 |
Smalltalk imageStartTime |
|
8324 |
Smalltalk imageRestartTime |
|
8325 |
" |
|
8326 |
||
8327 |
"Created: 13.12.1995 / 17:44:14 / cg" |
|
8328 |
"Modified: 13.12.1995 / 17:45:47 / cg" |
|
8329 |
! |
|
8330 |
||
8331 |
majorVersionNr |
|
8332 |
"{ Pragma: +optSpace }" |
|
8333 |
||
8334 |
"return the major version number. |
|
8335 |
This is only incremented for very fundamental changes, |
|
8336 |
which make old object files totally incompatible |
|
8337 |
(for example, if the layout/representation of fundamental |
|
8338 |
classes changes). |
|
8339 |
||
8340 |
ST/X revision Naming is: |
|
18668 | 8341 |
<major>.<minor>.<revision>.<release>" |
10641 | 8342 |
|
12867
2b9cbcea983b
version bump - layout of Class, Method and Context changed.
Claus Gittinger <cg@exept.de>
parents:
12861
diff
changeset
|
8343 |
^ 6 |
10641 | 8344 |
|
8345 |
" |
|
8346 |
Smalltalk majorVersionNr |
|
8347 |
" |
|
8348 |
||
8349 |
"Modified: 8.11.1996 / 19:59:21 / cg" |
|
8350 |
! |
|
8351 |
||
8352 |
minorVersionNr |
|
8353 |
"{ Pragma: +optSpace }" |
|
8354 |
||
8355 |
"return the minor version number. |
|
8356 |
This is incremented for changes which make some old object |
|
8357 |
files incompatible, or the protocol changes such that some |
|
8358 |
classes need rework. |
|
8359 |
||
8360 |
ST/X revision Naming is: |
|
18668 | 8361 |
<major>.<minor>.<revision>.<release>" |
13489 | 8362 |
|
8363 |
^ 2 |
|
10641 | 8364 |
|
8365 |
" |
|
8366 |
Smalltalk minorVersionNr |
|
8367 |
" |
|
8368 |
||
8369 |
"Modified: / 16-08-2006 / 09:37:25 / cg" |
|
8370 |
! |
|
8371 |
||
8372 |
releaseIdentification |
|
8373 |
"{ Pragma: +optSpace }" |
|
8374 |
||
8375 |
"for developers only: return the release |
|
8376 |
(to further identify the version in case of errors)" |
|
8377 |
||
8378 |
%{ /* NOCONTEXT */ |
|
8379 |
extern OBJ __getRel(); |
|
8380 |
||
8381 |
RETURN (__getRel()); |
|
8382 |
%}. |
|
8383 |
^ 'ST/X_experimental' |
|
8384 |
||
8385 |
" |
|
8386 |
Smalltalk releaseIdentification |
|
8387 |
" |
|
8388 |
! |
|
8389 |
||
8390 |
releaseNr |
|
8391 |
"{ Pragma: +optSpace }" |
|
8392 |
||
14542 | 8393 |
"return the release number. |
8394 |
Now releaseNr is the build number (BUILD_NUMBER from Jenkins) |
|
10641 | 8395 |
|
8396 |
ST/X revision Naming is: |
|
18668 | 8397 |
<major>.<minor>.<revision>.<release>" |
14529 | 8398 |
|
8399 |
|releaseNumber| |
|
8400 |
||
8401 |
releaseNumber := Smalltalk versionBuildNumber. |
|
8402 |
releaseNumber isEmpty ifTrue:[ |
|
18668 | 8403 |
^ 0. |
14529 | 8404 |
]. |
8405 |
^ releaseNumber |
|
10641 | 8406 |
|
8407 |
" |
|
8408 |
Smalltalk releaseNr |
|
12867
2b9cbcea983b
version bump - layout of Class, Method and Context changed.
Claus Gittinger <cg@exept.de>
parents:
12861
diff
changeset
|
8409 |
Smalltalk versionString |
10641 | 8410 |
" |
8411 |
||
8412 |
"Created: / 10-12-1995 / 01:42:19 / cg" |
|
8413 |
"Modified: / 10-02-2007 / 14:49:51 / cg" |
|
8414 |
! |
|
8415 |
||
8416 |
revisionNr |
|
8417 |
"{ Pragma: +optSpace }" |
|
8418 |
||
8419 |
"return the revision number. |
|
8420 |
Incremented for releases which fix bugs/add features |
|
8421 |
and represent a stable workable version which got published |
|
8422 |
to the outside world. |
|
8423 |
||
8424 |
ST/X revision Naming is: |
|
18668 | 8425 |
<major>.<minor>.<revision>.<release>" |
16944 | 8426 |
|
8427 |
^ 5 |
|
10641 | 8428 |
|
8429 |
" |
|
8430 |
Smalltalk revisionNr |
|
13323
68e5bb82f5f7
changed: #loadPackage:fromClassLibrary:
Stefan Vogel <sv@exept.de>
parents:
13303
diff
changeset
|
8431 |
Smalltalk hello string |
13014 | 8432 |
" |
8433 |
||
14210 | 8434 |
"Modified: / 18-07-2012 / 19:09:42 / cg" |
14898 | 8435 |
"Modified: / 19-03-2013 / 10:48:59 / az" |
10641 | 8436 |
! |
8437 |
||
8438 |
timeStamp |
|
8439 |
"return a string useful for timestamping a file. |
|
8440 |
The returned string is padded with spaces for a constant |
|
8441 |
length (to avoid changing a files size in fileOut with unchanged |
|
8442 |
class)." |
|
8443 |
||
8444 |
^ ('''' , self timeStampString , '''') paddedTo:80 with:(Character space) |
|
8445 |
! |
|
8446 |
||
8447 |
timeStamp:aStream |
|
8448 |
"write a string useful for timestamping a file onto aStream. |
|
8449 |
ST80 compatibility" |
|
8450 |
||
8451 |
aStream nextPutAll:(self timeStamp). |
|
8452 |
||
8453 |
"Created: / 18.6.1998 / 17:22:58 / cg" |
|
8454 |
! |
|
8455 |
||
8456 |
timeStampString |
|
8457 |
"return a string useful for timestamping a file." |
|
8458 |
||
8459 |
|dateString| |
|
8460 |
||
8461 |
dateString := String streamContents:[:s | Date today printOn:s language:#en]. "/ MUST be english !!!! |
|
8462 |
||
8463 |
^ ('From Smalltalk/X, Version:' , (Smalltalk versionString) , ' on ' |
|
8464 |
, dateString , ' at ' , Time now printString |
|
7758 | 8465 |
) |
8466 |
! |
|
8467 |
||
14529 | 8468 |
versionBuildNumber |
8469 |
"{ Pragma: +optSpace }" |
|
8470 |
||
8471 |
"return the executables build number - that's the jenkins build #. |
|
8472 |
Empty if not built by jenkins" |
|
8473 |
||
8474 |
%{ /* NOCONTEXT */ |
|
8475 |
extern char *__getBuildNumberString(); |
|
8476 |
||
8477 |
RETURN (__MKSTRING(__getBuildNumberString() COMMA_SND) ); |
|
8478 |
%}. |
|
8479 |
^ '' |
|
8480 |
||
8481 |
" |
|
8482 |
Smalltalk versionBuildNumber |
|
8483 |
" |
|
8484 |
! |
|
8485 |
||
10641 | 8486 |
versionDate |
8487 |
"{ Pragma: +optSpace }" |
|
8488 |
||
14522 | 8489 |
"return the executables build date - that's the date when the smalltalk |
10641 | 8490 |
executable was built" |
8491 |
||
8492 |
%{ /* NOCONTEXT */ |
|
8493 |
extern char *__getBuildDateString(); |
|
8494 |
||
8495 |
RETURN (__MKSTRING(__getBuildDateString() COMMA_SND) ); |
|
8496 |
%}. |
|
8497 |
^ 'today' |
|
8498 |
||
8499 |
" |
|
10071 | 8500 |
Smalltalk versionDate |
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8501 |
" |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8502 |
! |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8503 |
|
10641 | 8504 |
versionString |
8505 |
"{ Pragma: +optSpace }" |
|
8506 |
||
8507 |
"return the version string" |
|
8508 |
||
8509 |
^ (self majorVersionNr printString , |
|
8510 |
'.', |
|
8511 |
self minorVersionNr printString , |
|
8512 |
'.', |
|
14529 | 8513 |
self revisionNr printString, |
8514 |
'.', |
|
8515 |
self releaseNr printString) |
|
13771 | 8516 |
|
10641 | 8517 |
|
8518 |
" |
|
8583
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8519 |
Smalltalk versionString |
2952bfabeaf7
oops - garbage was checked in
Claus Gittinger <cg@exept.de>
parents:
8570
diff
changeset
|
8520 |
" |
10641 | 8521 |
! |
8522 |
||
8523 |
vmMajorVersionNr |
|
8524 |
"{ Pragma: +optSpace }" |
|
8525 |
||
8526 |
"return the VMs major version number." |
|
8527 |
%{ |
|
8528 |
RETURN (__mkSmallInteger(4)); |
|
8529 |
%}. |
|
8530 |
^ 4 |
|
8531 |
||
8532 |
" |
|
8533 |
Smalltalk vmMajorVersionNr |
|
8534 |
" |
|
2 | 8535 |
! ! |
453 | 8536 |
|
1750
36ff7e62388a
care for privateClasses in remove
Claus Gittinger <cg@exept.de>
parents:
1713
diff
changeset
|
8537 |
!Smalltalk class methodsFor:'documentation'! |
630 | 8538 |
|
13532
638f9bfab880
changed: #recursiveInstallAutoloadedClassesFrom:rememberIn:maxLevels:noAutoload:packageTop:showSplashInLevels:
Claus Gittinger <cg@exept.de>
parents:
13531
diff
changeset
|
8539 |
version |
18560 | 8540 |
^ '$Header$' |
13532
638f9bfab880
changed: #recursiveInstallAutoloadedClassesFrom:rememberIn:maxLevels:noAutoload:packageTop:showSplashInLevels:
Claus Gittinger <cg@exept.de>
parents:
13531
diff
changeset
|
8541 |
! |
638f9bfab880
changed: #recursiveInstallAutoloadedClassesFrom:rememberIn:maxLevels:noAutoload:packageTop:showSplashInLevels:
Claus Gittinger <cg@exept.de>
parents:
13531
diff
changeset
|
8542 |
|
12172
d90a72004f43
changed: #fileNameForClass:
Claus Gittinger <cg@exept.de>
parents:
12033
diff
changeset
|
8543 |
version_CVS |
18560 | 8544 |
^ '$Header$' |
13415 | 8545 |
! |
8546 |
||
8547 |
version_SVN |
|
15225 | 8548 |
^ '$ Id: Smalltalk.st 10648 2011-06-23 15:55:10Z vranyj1 $' |
630 | 8549 |
! ! |
18669 | 8550 |