8 be provided or otherwise made available to, or used by, any |
8 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
9 other person. No title to or ownership of the software is |
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 |
12 |
13 'From Smalltalk/X, Version:2.10.7 on 28-oct-1995 at 17:08:56' ! |
13 'From Smalltalk/X, Version:2.10.8 on 29-oct-1995 at 19:51:30' ! |
14 |
14 |
15 ClassDescription subclass:#Class |
15 ClassDescription subclass:#Class |
16 instanceVariableNames:'classvars comment subclasses classFilename package revision |
16 instanceVariableNames:'classvars comment subclasses classFilename package revision |
17 history' |
17 history' |
18 classVariableNames:'UpdatingChanges FileOutErrorSignal CatchMethodRedefinitions |
18 classVariableNames:'UpdatingChanges FileOutErrorSignal CatchMethodRedefinitions |
19 MethodRedefinitionSignal UpdateChangeFileQuerySignal' |
19 MethodRedefinitionSignal UpdateChangeFileQuerySignal' |
20 poolDictionaries:'' |
20 poolDictionaries:'' |
21 category:'Kernel-Classes' |
21 category:'Kernel-Classes' |
22 ! |
22 ! |
23 |
23 |
24 Class comment:' |
|
25 COPYRIGHT (c) 1989 by Claus Gittinger |
|
26 All Rights Reserved |
|
27 |
|
28 $Header: /cvs/stx/stx/libbasic/Class.st,v 1.63 1995-10-28 16:44:51 cg Exp $ |
|
29 '! |
|
30 |
|
31 !Class class methodsFor:'documentation'! |
24 !Class class methodsFor:'documentation'! |
32 |
25 |
33 version |
26 version |
34 " |
27 " |
35 $Header: /cvs/stx/stx/libbasic/Class.st,v 1.63 1995-10-28 16:44:51 cg Exp $ |
28 $Header: /cvs/stx/stx/libbasic/Class.st,v 1.64 1995-10-29 19:26:30 cg Exp $ |
36 " |
29 "! |
37 ! |
|
38 |
30 |
39 documentation |
31 documentation |
40 " |
32 " |
41 Class adds more functionality to classes; minimum stuff has already |
33 Class adds more functionality to classes; minimum stuff has already |
42 been defined in Behavior and ClassDescription; this adds naming, categories etc. |
34 been defined in Behavior and ClassDescription; this adds naming, categories etc. |
179 prev := UpdatingChanges. |
171 prev := UpdatingChanges. |
180 UpdatingChanges := aBoolean. |
172 UpdatingChanges := aBoolean. |
181 ^ prev |
173 ^ prev |
182 ! |
174 ! |
183 |
175 |
184 updatingChanges |
|
185 "return true if changes are recorded" |
|
186 |
|
187 ^ UpdatingChanges |
|
188 ! |
|
189 |
|
190 catchMethodRedefinitions:aBoolean |
176 catchMethodRedefinitions:aBoolean |
191 "turn on/off redefinition catching. Return the prior value of the flag." |
177 "turn on/off redefinition catching. Return the prior value of the flag." |
192 |
178 |
193 |prev| |
179 |prev| |
194 |
180 |
195 prev := CatchMethodRedefinitions. |
181 prev := CatchMethodRedefinitions. |
196 CatchMethodRedefinitions := aBoolean. |
182 CatchMethodRedefinitions := aBoolean. |
197 ^ prev |
183 ^ prev |
|
184 ! |
|
185 |
|
186 updatingChanges |
|
187 "return true if changes are recorded" |
|
188 |
|
189 ^ UpdatingChanges |
198 ! |
190 ! |
199 |
191 |
200 catchMethodRedefinitions |
192 catchMethodRedefinitions |
201 "return the redefinition catching flag." |
193 "return the redefinition catching flag." |
202 |
194 |
275 poolDictionaries:s |
267 poolDictionaries:s |
276 category:'ST/V classes' |
268 category:'ST/V classes' |
277 ! ! |
269 ! ! |
278 |
270 |
279 !Class methodsFor:'accessing'! |
271 !Class methodsFor:'accessing'! |
|
272 |
|
273 allClassVarNames |
|
274 "return a collection of all the class variable name-strings |
|
275 this includes all superclass-class variables" |
|
276 |
|
277 ^ self addAllClassVarNamesTo:(OrderedCollection new) |
|
278 |
|
279 " |
|
280 Float allClassVarNames |
|
281 " |
|
282 ! |
280 |
283 |
281 classVarNames |
284 classVarNames |
282 "return a collection of the class variable name-strings. |
285 "return a collection of the class variable name-strings. |
283 Only names of class variables defined in this class are included |
286 Only names of class variables defined in this class are included |
284 in the returned collection - use allClassVarNames, to get all known names." |
287 in the returned collection - use allClassVarNames, to get all known names." |
355 cat := categoryStringOrSymbol |
358 cat := categoryStringOrSymbol |
356 ]. |
359 ]. |
357 category := cat asSymbol |
360 category := cat asSymbol |
358 ! |
361 ! |
359 |
362 |
360 allClassVarNames |
363 revision |
361 "return a collection of all the class variable name-strings |
364 "return the revision-ID of the class. |
362 this includes all superclass-class variables" |
365 This is valid for stc-compiled classes only, and corresponds to the |
363 |
366 rcs-id of the source from which this class was compiled. |
364 ^ self addAllClassVarNamesTo:(OrderedCollection new) |
367 To check if a source corresponds to a compiled binary, compare this |
365 |
368 ID with the one found in the version-methods comment." |
366 " |
369 |
367 Float allClassVarNames |
370 ^ revision |
|
371 |
|
372 " |
|
373 Object revision |
368 " |
374 " |
369 ! |
375 ! |
370 |
376 |
371 classVariableString |
377 classVariableString |
372 "return a string of the class variables names. |
378 "return a string of the class variables names. |
378 |
384 |
379 " |
385 " |
380 Object classVariableString |
386 Object classVariableString |
381 Float classVariableString |
387 Float classVariableString |
382 " |
388 " |
383 ! |
|
384 |
|
385 classVarAt:aSymbol |
|
386 "return the value of a class variable. |
|
387 Currently, this returns nil if there is no such classvar - |
|
388 this may change." |
|
389 |
|
390 " |
|
391 this hides the (current) implementation of classVariables |
|
392 from the outside world. Currently, classvars are stored in |
|
393 the Smalltalk dictionary with a funny name, since there are |
|
394 no classPools yet. |
|
395 " |
|
396 ^ Smalltalk at:(self name , ':' , aSymbol) asSymbol |
|
397 ! |
389 ! |
398 |
390 |
399 comment |
391 comment |
400 "return the comment (aString) of the class" |
392 "return the comment (aString) of the class" |
401 |
393 |
420 " |
412 " |
421 Object comment |
413 Object comment |
422 " |
414 " |
423 ! |
415 ! |
424 |
416 |
|
417 classVarAt:aSymbol |
|
418 "return the value of a class variable. |
|
419 Currently, this returns nil if there is no such classvar - |
|
420 this may change." |
|
421 |
|
422 " |
|
423 this hides the (current) implementation of classVariables |
|
424 from the outside world. Currently, classvars are stored in |
|
425 the Smalltalk dictionary with a funny name, since there are |
|
426 no classPools yet. |
|
427 " |
|
428 ^ Smalltalk at:(self name , ':' , aSymbol) asSymbol |
|
429 ! |
|
430 |
425 classVarAt:aSymbol put:something |
431 classVarAt:aSymbol put:something |
426 "store something in a classvariable. |
432 "store something in a classvariable. |
427 Currently this creates a global with a funny name if no such |
433 Currently this creates a global with a funny name if no such |
428 classVar exists - this may change." |
434 classVar exists - this may change." |
429 |
435 |
469 |
478 |
470 setPackage:aStringOrSymbol |
479 setPackage:aStringOrSymbol |
471 "set the package of the class." |
480 "set the package of the class." |
472 |
481 |
473 package := aStringOrSymbol |
482 package := aStringOrSymbol |
474 ! |
|
475 |
|
476 revision |
|
477 "return the revision-ID of the class. |
|
478 This is valid for stc-compiled classes only, and corresponds to the |
|
479 rcs-id of the source from which this class was compiled. |
|
480 To check if a source corresponds to a compiled binary, compare this |
|
481 ID with the one found in the version-methods comment." |
|
482 |
|
483 ^ revision |
|
484 |
|
485 " |
|
486 Object revision |
|
487 " |
|
488 ! |
483 ! |
489 |
484 |
490 revision:aString |
485 revision:aString |
491 "set the revision-ID. |
486 "set the revision-ID. |
492 This should normally not be done in the running system, as the source-manager |
487 This should normally not be done in the running system, as the source-manager |
510 "set the history of the class." |
505 "set the history of the class." |
511 |
506 |
512 history := aString |
507 history := aString |
513 ! |
508 ! |
514 |
509 |
|
510 primitiveDefinitionsString |
|
511 "return the primitiveDefinition string or nil" |
|
512 |
|
513 ^ self getPrimitiveSpecsAt:1 |
|
514 |
|
515 " |
|
516 Object primitiveDefinitionsString |
|
517 String primitiveDefinitionsString |
|
518 " |
|
519 ! |
|
520 |
|
521 primitiveVariablesString |
|
522 "return the primitiveVariables string or nil" |
|
523 |
|
524 ^ self getPrimitiveSpecsAt:2 |
|
525 ! |
|
526 |
|
527 primitiveFunctionsString |
|
528 "return the primitiveFunctions string or nil" |
|
529 |
|
530 ^ self getPrimitiveSpecsAt:3 |
|
531 ! |
|
532 |
515 history:aString |
533 history:aString |
516 "set the history of the class." |
534 "set the history of the class." |
517 |
535 |
518 history := aString |
536 history := aString |
519 ! |
537 ! |
522 "return the primitiveSpec or nil" |
540 "return the primitiveSpec or nil" |
523 |
541 |
524 ^ primitiveSpec |
542 ^ primitiveSpec |
525 ! |
543 ! |
526 |
544 |
527 primitiveDefinitionsString |
|
528 "return the primitiveDefinition string or nil" |
|
529 |
|
530 ^ self getPrimitiveSpecsAt:1 |
|
531 |
|
532 " |
|
533 Object primitiveDefinitionsString |
|
534 String primitiveDefinitionsString |
|
535 " |
|
536 ! |
|
537 |
|
538 primitiveVariablesString |
|
539 "return the primitiveVariables string or nil" |
|
540 |
|
541 ^ self getPrimitiveSpecsAt:2 |
|
542 ! |
|
543 |
|
544 primitiveFunctionsString |
|
545 "return the primitiveFunctions string or nil" |
|
546 |
|
547 ^ self getPrimitiveSpecsAt:3 |
|
548 ! |
|
549 |
|
550 primitiveSpec:anArrayOf3ElementsOrNil |
545 primitiveSpec:anArrayOf3ElementsOrNil |
551 "set the primitiveSpec or nil" |
546 "set the primitiveSpec or nil" |
552 |
547 |
553 primitiveSpec := anArrayOf3ElementsOrNil |
548 primitiveSpec := anArrayOf3ElementsOrNil |
554 ! |
549 ! |
555 |
550 |
556 primitiveDefinitions:aString |
551 primitiveDefinitions:aString |
557 "set the primitiveDefinition string" |
552 "set the primitiveDefinition string" |
558 |
553 |
559 self setPrimitiveSpecsAt:1 to:aString. |
554 self setPrimitiveSpecsAt:1 to:aString. |
560 self addChangeRecordForPrimitiveDefinitions:self |
555 self addChangeRecordForPrimitiveDefinitions:self. |
|
556 self updateVersionString. |
|
557 |
|
558 "Created: 29.10.1995 / 19:41:39 / cg" |
561 ! |
559 ! |
562 |
560 |
563 primitiveVariables:aString |
561 primitiveVariables:aString |
564 "set the primitiveVariable string" |
562 "set the primitiveVariable string" |
565 |
563 |
566 self setPrimitiveSpecsAt:2 to:aString. |
564 self setPrimitiveSpecsAt:2 to:aString. |
567 self addChangeRecordForPrimitiveVariables:self |
565 self addChangeRecordForPrimitiveVariables:self. |
|
566 self updateVersionString. |
|
567 |
|
568 "Created: 29.10.1995 / 19:41:58 / cg" |
568 ! |
569 ! |
569 |
570 |
570 primitiveFunctions:aString |
571 primitiveFunctions:aString |
571 "set the primitiveFunction string" |
572 "set the primitiveFunction string" |
572 |
573 |
573 self setPrimitiveSpecsAt:3 to:aString. |
574 self setPrimitiveSpecsAt:3 to:aString. |
574 self addChangeRecordForPrimitiveFunctions:self |
575 self addChangeRecordForPrimitiveFunctions:self. |
|
576 self updateVersionString. |
|
577 |
|
578 "Created: 29.10.1995 / 19:41:48 / cg" |
575 ! |
579 ! |
576 |
580 |
577 classFilename |
581 classFilename |
578 "return the name of the file from which the class was compiled. |
582 "return the name of the file from which the class was compiled. |
579 This is currently NOT used." |
583 This is currently NOT used." |
637 aStream close. |
641 aStream close. |
638 OperatingSystem removeFile:'__temp'. |
642 OperatingSystem removeFile:'__temp'. |
639 ^ code |
643 ^ code |
640 ! |
644 ! |
641 |
645 |
642 sharedPools |
|
643 "ST/X does not (currently) support pools" |
|
644 |
|
645 ^ #() |
|
646 ! |
|
647 |
|
648 addClassVarName:aString |
646 addClassVarName:aString |
649 "add a class variable if not already there and initialize it with nil. |
647 "add a class variable if not already there and initialize it with nil. |
650 Also writes a change record and notifies dependents. |
648 Also writes a change record and notifies dependents. |
651 BUG: Currently, no recompilation is done - this will change." |
649 BUG: Currently, no recompilation is done - this will change." |
652 |
650 |
653 (self classVarNames includes:aString) ifFalse:[ |
651 (self classVarNames includes:aString) ifFalse:[ |
654 self classVariableString:(self classVariableString , ' ' , aString). |
652 self classVariableString:(self classVariableString , ' ' , aString). |
655 self addChangeRecordForClass:self. |
653 self addChangeRecordForClass:self. |
|
654 self updateVersionString. |
656 self changed:#definition. |
655 self changed:#definition. |
657 ] |
656 ] |
|
657 |
|
658 "Created: 29.10.1995 / 19:40:51 / cg" |
|
659 ! |
|
660 |
|
661 sharedPools |
|
662 "ST/X does not (currently) support pools" |
|
663 |
|
664 ^ #() |
658 ! |
665 ! |
659 |
666 |
660 setClassVariableString:aString |
667 setClassVariableString:aString |
661 "set the classes classvarnames string. |
668 "set the classes classvarnames string. |
662 This is a dangerous (low level) operation, since the |
669 This is a dangerous (low level) operation, since the |
677 (names includes:aString) ifTrue:[ |
684 (names includes:aString) ifTrue:[ |
678 newNames := ''. |
685 newNames := ''. |
679 names do:[:nm | nm ~= aString ifTrue:[newNames := newNames , nm , ' ']]. |
686 names do:[:nm | nm ~= aString ifTrue:[newNames := newNames , nm , ' ']]. |
680 self classVariableString:newNames withoutSpaces. |
687 self classVariableString:newNames withoutSpaces. |
681 self addChangeRecordForClass:self. |
688 self addChangeRecordForClass:self. |
|
689 self updateVersionString. |
682 self changed:#definition. |
690 self changed:#definition. |
683 ] |
691 ] |
|
692 |
|
693 "Created: 29.10.1995 / 19:42:08 / cg" |
684 ! |
694 ! |
685 |
695 |
686 renameCategory:oldCategory to:newCategory |
696 renameCategory:oldCategory to:newCategory |
687 "rename a category (changes category of those methods). |
697 "rename a category (changes category of those methods). |
688 Appends a change record and notifies dependents." |
698 Appends a change record and notifies dependents." |
735 raiseErrorString:(' ' , name , '>>' , newSelector) |
748 raiseErrorString:(' ' , name , '>>' , newSelector) |
736 ] |
749 ] |
737 ] |
750 ] |
738 ]. |
751 ]. |
739 (super addSelector:newSelector withMethod:newMethod) ifTrue:[ |
752 (super addSelector:newSelector withMethod:newMethod) ifTrue:[ |
740 self addChangeRecordForMethod:newMethod |
753 self updateVersionString. |
741 ] |
754 self addChangeRecordForMethod:newMethod. |
|
755 ] |
|
756 |
|
757 "Created: 29.10.1995 / 19:42:42 / cg" |
742 ! |
758 ! |
743 |
759 |
744 removeSelector:aSelector |
760 removeSelector:aSelector |
745 "remove the selector, aSelector and its associated method |
761 "remove the selector, aSelector and its associated method |
746 from the methodDictionary. |
762 from the methodDictionary. |
747 Append a change record to the changes file and tell dependents." |
763 Append a change record to the changes file and tell dependents." |
748 |
764 |
749 (super removeSelector:aSelector) ifTrue:[ |
765 (super removeSelector:aSelector) ifTrue:[ |
750 self addChangeRecordForRemoveSelector:aSelector. |
766 self addChangeRecordForRemoveSelector:aSelector. |
|
767 self updateVersionString. |
751 self changed:#methodDictionary with:aSelector. |
768 self changed:#methodDictionary with:aSelector. |
752 ] |
769 ] |
|
770 |
|
771 "Created: 29.10.1995 / 19:42:47 / cg" |
753 ! |
772 ! |
754 |
773 |
755 unload |
774 unload |
756 "if the receiver was autoloaded, unload and reinstall it as |
775 "if the receiver was autoloaded, unload and reinstall it as |
757 autoloaded. Can be used to get rid of no longer needed autoloaded |
776 autoloaded. Can be used to get rid of no longer needed autoloaded |
902 " |
921 " |
903 ! ! |
922 ! ! |
904 |
923 |
905 !Class methodsFor:'changes management'! |
924 !Class methodsFor:'changes management'! |
906 |
925 |
907 withoutUpdatingChangesDo:aBlock |
926 addChangeRecordForMethod:aMethod to:aStream |
908 "turn off change file update while evaluating aBlock. |
927 "append a method-change-record to aStream" |
909 This method makes sure, that the update-flag is correctly restored |
928 |
910 in case of an abort or other error." |
929 self fileOutMethod:aMethod on:aStream. |
911 |
|
912 UpdateChangeFileQuerySignal handle:[:ex | |
|
913 ex proceedWith:false |
|
914 ] do:[ |
|
915 aBlock value |
|
916 ]. |
|
917 ! |
930 ! |
918 |
931 |
919 changesStream |
932 changesStream |
920 "return a Stream for the writing changes file - or nil if no update is wanted" |
933 "return a Stream for the writing changes file - or nil if no update is wanted" |
921 |
934 |
922 |aStream fileName| |
935 |aStream fileName| |
923 |
936 |
924 (UpdateChangeFileQuerySignal raise) ifTrue:[ |
937 (UpdateChangeFileQuerySignal raise) ifTrue:[ |
925 fileName := ObjectMemory nameForChanges. |
938 fileName := ObjectMemory nameForChanges. |
926 aStream := FileStream oldFileNamed:fileName. |
939 aStream := FileStream oldFileNamed:fileName. |
927 aStream isNil ifTrue:[ |
940 aStream isNil ifTrue:[ |
928 aStream := FileStream newFileNamed:fileName. |
941 aStream := FileStream newFileNamed:fileName. |
929 aStream isNil ifTrue:[ |
942 aStream isNil ifTrue:[ |
930 self warn:'cannot create/update the changes file'. |
943 self warn:'cannot create/update the changes file'. |
931 ^ nil |
944 ^ nil |
932 ] |
945 ] |
933 ]. |
946 ]. |
934 aStream setToEnd |
947 aStream setToEnd |
935 ]. |
948 ]. |
936 ^ aStream |
949 ^ aStream |
937 |
950 |
938 "Created: 28.10.1995 / 16:53:43 / cg" |
951 "Created: 28.10.1995 / 16:53:43 / cg" |
939 "Modified: 28.10.1995 / 16:55:03 / cg" |
952 "Modified: 28.10.1995 / 16:55:03 / cg" |
940 ! |
|
941 |
|
942 writingChangePerform:aSelector with:anArgument |
|
943 |aStream| |
|
944 |
|
945 self writingChangeDo:[:stream | |
|
946 self perform:aSelector with:anArgument with:stream. |
|
947 ] |
|
948 |
|
949 "Created: 28.10.1995 / 16:50:48 / cg" |
|
950 ! |
|
951 |
|
952 addChangeRecordForMethod:aMethod to:aStream |
|
953 "append a method-change-record to aStream" |
|
954 |
|
955 self fileOutMethod:aMethod on:aStream. |
|
956 ! |
953 ! |
957 |
954 |
958 writingChangeDo:aBlock |
955 writingChangeDo:aBlock |
959 "common helper to write a change record. |
956 "common helper to write a change record. |
960 Opens the changefile and executes aBlock passing the stream |
957 Opens the changefile and executes aBlock passing the stream |
976 ]. |
973 ]. |
977 aStream close |
974 aStream close |
978 ] |
975 ] |
979 ! |
976 ! |
980 |
977 |
|
978 writingChangePerform:aSelector with:anArgument |
|
979 |aStream| |
|
980 |
|
981 self writingChangeDo:[:stream | |
|
982 self perform:aSelector with:anArgument with:stream. |
|
983 ] |
|
984 |
|
985 "Created: 28.10.1995 / 16:50:48 / cg" |
|
986 ! |
|
987 |
|
988 withoutUpdatingChangesDo:aBlock |
|
989 "turn off change file update while evaluating aBlock. |
|
990 This method makes sure, that the update-flag is correctly restored |
|
991 in case of an abort or other error." |
|
992 |
|
993 UpdateChangeFileQuerySignal handle:[:ex | |
|
994 ex proceedWith:false |
|
995 ] do:[ |
|
996 aBlock value |
|
997 ]. |
|
998 ! |
|
999 |
|
1000 addChangeRecordForMethod:aMethod |
|
1001 "add a method-change-record to the changes file" |
|
1002 |
|
1003 (UpdateChangeFileQuerySignal raise) "UpdatingChanges" ifTrue:[ |
|
1004 self writingChangePerform:#addChangeRecordForMethod:to: with:aMethod. |
|
1005 "this test allows a smalltalk without Projects/ChangeSets" |
|
1006 Project notNil ifTrue:[ |
|
1007 Project addMethodChange:aMethod in:self |
|
1008 ] |
|
1009 ] |
|
1010 ! |
|
1011 |
981 sourcesStream |
1012 sourcesStream |
982 "return a stream for writing the sources file. |
1013 "return a stream for writing the sources file. |
983 Notice, in ST/X, it is noncommon to use a single |
1014 Notice, in ST/X, it is noncommon to use a single |
984 source file; typically each classes source is kept |
1015 source file; typically each classes source is kept |
985 in a separate file." |
1016 in a separate file." |
987 |aStream fileName| |
1018 |aStream fileName| |
988 |
1019 |
989 fileName := ObjectMemory nameForSources. |
1020 fileName := ObjectMemory nameForSources. |
990 aStream := FileStream oldFileNamed:fileName. |
1021 aStream := FileStream oldFileNamed:fileName. |
991 aStream isNil ifTrue:[ |
1022 aStream isNil ifTrue:[ |
992 aStream := FileStream newFileNamed:fileName. |
1023 aStream := FileStream newFileNamed:fileName. |
993 aStream isNil ifTrue:[ |
1024 aStream isNil ifTrue:[ |
994 Transcript showCr:'cannot update sources file'. |
1025 Transcript showCr:'cannot update sources file'. |
995 ^ nil |
1026 ^ nil |
996 ] |
1027 ] |
997 ]. |
1028 ]. |
998 aStream setToEnd. |
1029 aStream setToEnd. |
999 ^ aStream |
1030 ^ aStream |
1000 |
1031 |
1001 "Created: 28.10.1995 / 16:53:17 / cg" |
1032 "Created: 28.10.1995 / 16:53:17 / cg" |
1112 aStream nextPutAll:(' renameCategory:' , oldCategory storeString). |
1143 aStream nextPutAll:(' renameCategory:' , oldCategory storeString). |
1113 aStream nextPutAll:(' to:' , newCategory storeString). |
1144 aStream nextPutAll:(' to:' , newCategory storeString). |
1114 aStream nextPutChunkSeparator. |
1145 aStream nextPutChunkSeparator. |
1115 ! |
1146 ! |
1116 |
1147 |
1117 addChangeRecordForMethod:aMethod |
|
1118 "add a method-change-record to the changes file" |
|
1119 |
|
1120 (UpdateChangeFileQuerySignal raise) "UpdatingChanges" ifTrue:[ |
|
1121 self writingChangePerform:#addChangeRecordForMethod:to: with:aMethod. |
|
1122 "this test allows a smalltalk without Projects/ChangeSets" |
|
1123 Project notNil ifTrue:[ |
|
1124 Project addMethodChange:aMethod in:self |
|
1125 ] |
|
1126 ] |
|
1127 ! |
|
1128 |
|
1129 addChangeRecordForChangeCategory:category to:aStream |
|
1130 "append a category change record to aStream" |
|
1131 |
|
1132 self printClassNameOn:aStream. |
|
1133 aStream nextPutAll:(' category:' , category storeString). |
|
1134 aStream nextPutChunkSeparator. |
|
1135 ! |
|
1136 |
|
1137 addInfoRecord:aMessage to:aStream |
1148 addInfoRecord:aMessage to:aStream |
1138 "append an info-record (snapshot, class fileOut etc.) to aStream" |
1149 "append an info-record (snapshot, class fileOut etc.) to aStream" |
1139 |
1150 |
1140 aStream nextPutAll:('''---- ' , aMessage , ' ', |
1151 aStream nextPutAll:('''---- ' , aMessage , ' ', |
1141 Date today printString , ' ' , |
1152 Date today printString , ' ' , |
1142 Time now printString , |
1153 Time now printString , |
1143 ' ----'''). |
1154 ' ----'''). |
1144 aStream nextPutChunkSeparator. |
1155 aStream nextPutChunkSeparator. |
1145 ! |
1156 ! |
1146 |
1157 |
|
1158 addChangeRecordForChangeCategory:category to:aStream |
|
1159 "append a category change record to aStream" |
|
1160 |
|
1161 self printClassNameOn:aStream. |
|
1162 aStream nextPutAll:(' category:' , category storeString). |
|
1163 aStream nextPutChunkSeparator. |
|
1164 ! |
|
1165 |
|
1166 addChangeRecordForClass:aClass |
|
1167 "add a class-definition-record to the changes file" |
|
1168 |
|
1169 self writingChangePerform:#addChangeRecordForClass:to: with:aClass. |
|
1170 ! |
|
1171 |
1147 addChangeRecordForSnapshot:aFileName to:aStream |
1172 addChangeRecordForSnapshot:aFileName to:aStream |
1148 "add a snapshot-record to aStream" |
1173 "add a snapshot-record to aStream" |
1149 |
1174 |
1150 self addInfoRecord:('snapshot ' , aFileName) to:aStream |
1175 self addInfoRecord:('snapshot ' , aFileName) to:aStream |
1151 ! |
|
1152 |
|
1153 addChangeRecordForClass:aClass |
|
1154 "add a class-definition-record to the changes file" |
|
1155 |
|
1156 self writingChangePerform:#addChangeRecordForClass:to: with:aClass. |
|
1157 ! |
1176 ! |
1158 |
1177 |
1159 addChangeRecordForRemoveSelector:aSelector |
1178 addChangeRecordForRemoveSelector:aSelector |
1160 "add a method-remove-record to the changes file" |
1179 "add a method-remove-record to the changes file" |
1161 |
1180 |
1233 "add a class-remove-record to the changes file" |
1252 "add a class-remove-record to the changes file" |
1234 |
1253 |
1235 self writingChangePerform:#addChangeRecordForClassRemove:to: with:oldName. |
1254 self writingChangePerform:#addChangeRecordForClassRemove:to: with:oldName. |
1236 ! |
1255 ! |
1237 |
1256 |
|
1257 addInfoRecord:aMessage |
|
1258 "add an info-record (snapshot, class fileOut etc.) to the changes file" |
|
1259 |
|
1260 self writingChangePerform:#addInfoRecord:to: with:aMessage. |
|
1261 ! |
|
1262 |
1238 addChangeRecordForRenameCategory:oldCategory to:newCategory |
1263 addChangeRecordForRenameCategory:oldCategory to:newCategory |
1239 "add a category-rename record to the changes file" |
1264 "add a category-rename record to the changes file" |
1240 |
1265 |
1241 self writingChangeDo:[:aStream | |
1266 self writingChangeDo:[:aStream | |
1242 self addChangeRecordForRenameCategory:oldCategory to:newCategory to:aStream. |
1267 self addChangeRecordForRenameCategory:oldCategory to:newCategory to:aStream. |
1243 ] |
1268 ] |
1244 ! |
1269 ! |
1245 |
1270 |
|
1271 addChangeRecordForClassFileOut:aClass |
|
1272 "append a class-was-filedOut-record to the changes file" |
|
1273 |
|
1274 self addInfoRecord:('fileOut ' , aClass name) |
|
1275 ! |
|
1276 |
1246 addChangeRecordForChangeCategory |
1277 addChangeRecordForChangeCategory |
1247 "add a category change record to the changes file" |
1278 "add a category change record to the changes file" |
1248 |
1279 |
1249 self writingChangePerform:#addChangeRecordForChangeCategory:to: with:category. |
1280 self writingChangePerform:#addChangeRecordForChangeCategory:to: with:category. |
1250 ! |
1281 ! |
1251 |
1282 |
1252 addInfoRecord:aMessage |
|
1253 "add an info-record (snapshot, class fileOut etc.) to the changes file" |
|
1254 |
|
1255 self writingChangePerform:#addInfoRecord:to: with:aMessage. |
|
1256 ! |
|
1257 |
|
1258 addChangeRecordForSnapshot:aFileName |
1283 addChangeRecordForSnapshot:aFileName |
1259 "add a snapshot-record to the changes file" |
1284 "add a snapshot-record to the changes file" |
1260 |
1285 |
1261 self addInfoRecord:('snapshot ' , aFileName) |
1286 self addInfoRecord:('snapshot ' , aFileName) |
1262 ! |
|
1263 |
|
1264 addChangeRecordForClassFileOut:aClass |
|
1265 "append a class-was-filedOut-record to the changes file" |
|
1266 |
|
1267 self addInfoRecord:('fileOut ' , aClass name) |
|
1268 ! ! |
1287 ! ! |
1269 |
1288 |
1270 !Class methodsFor:'compiling'! |
1289 !Class methodsFor:'compiling'! |
1271 |
1290 |
1272 compile:code |
1291 compile:code |
1536 ] ifFalse:[ |
1555 ] ifFalse:[ |
1537 s := category asString storeString |
1556 s := category asString storeString |
1538 ]. |
1557 ]. |
1539 aStream nextPutAll:s. |
1558 aStream nextPutAll:s. |
1540 aStream cr |
1559 aStream cr |
1541 ! |
|
1542 |
|
1543 fileOutCommentOn:aStream |
|
1544 "append an expression on aStream, which defines my comment" |
|
1545 |
|
1546 |comment s| |
|
1547 |
|
1548 aStream nextPutAll:name; nextPutAll:' comment:'. |
|
1549 (comment := self comment) isNil ifTrue:[ |
|
1550 s := '''''' |
|
1551 ] ifFalse:[ |
|
1552 s := comment storeString |
|
1553 ]. |
|
1554 aStream nextPutAll:s. |
|
1555 aStream cr |
|
1556 ! |
|
1557 |
|
1558 fileOutPrimitiveDefinitionsOn:aStream |
|
1559 "append primitive defs (if any) to aStream." |
|
1560 |
|
1561 |s| |
|
1562 |
|
1563 " |
|
1564 primitive definitions - if any |
|
1565 " |
|
1566 (s := self primitiveDefinitionsString) notNil ifTrue:[ |
|
1567 aStream nextPutChunkSeparator; |
|
1568 nextPutAll:name; nextPutAll:' primitiveDefinitions'; |
|
1569 nextPutChunkSeparator; |
|
1570 cr. |
|
1571 aStream nextPutAll:s. |
|
1572 aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr |
|
1573 ]. |
|
1574 (s := self primitiveVariablesString) notNil ifTrue:[ |
|
1575 aStream nextPutChunkSeparator; |
|
1576 nextPutAll:name; nextPutAll:' primitiveVariables'; |
|
1577 nextPutChunkSeparator; |
|
1578 cr. |
|
1579 aStream nextPutAll:s. |
|
1580 aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr |
|
1581 ]. |
|
1582 ! |
|
1583 |
|
1584 fileOutPrimitiveSpecsOn:aStream |
|
1585 "append primitive defs (if any) to aStream." |
|
1586 |
|
1587 |s| |
|
1588 |
|
1589 " |
|
1590 primitive definitions - if any |
|
1591 " |
|
1592 self fileOutPrimitiveDefinitionsOn:aStream. |
|
1593 " |
|
1594 primitive functions - if any |
|
1595 " |
|
1596 (s := self primitiveFunctionsString) notNil ifTrue:[ |
|
1597 aStream nextPutChunkSeparator; |
|
1598 nextPutAll:name; nextPutAll:' primitiveFunctions'; |
|
1599 nextPutChunkSeparator; |
|
1600 cr. |
|
1601 aStream nextPutAll:s. |
|
1602 aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr |
|
1603 ]. |
|
1604 ! |
1560 ! |
1605 |
1561 |
1606 fileOutMethod:aMethod on:aStream |
1562 fileOutMethod:aMethod on:aStream |
1607 "file out the method, aMethod onto aStream" |
1563 "file out the method, aMethod onto aStream" |
1608 |
1564 |
1708 ] |
1664 ] |
1709 |
1665 |
1710 "Modified: 28.8.1995 / 14:30:41 / claus" |
1666 "Modified: 28.8.1995 / 14:30:41 / claus" |
1711 ! |
1667 ! |
1712 |
1668 |
1713 fileOutClassInstVarDefinitionOn:aStream |
1669 fileOutPrimitiveDefinitionsOn:aStream |
1714 "append an expression to define my classInstanceVariables on aStream" |
1670 "append primitive defs (if any) to aStream." |
1715 |
1671 |
1716 aStream nextPutAll:(name , ' class instanceVariableNames:'''). |
1672 |s| |
1717 self class printInstVarNamesOn:aStream indent:8. |
1673 |
1718 aStream nextPutAll:''''. |
1674 " |
1719 |
1675 primitive definitions - if any |
1720 "mhmh - good idea; saw this in SmallDraw sourcecode ..." |
1676 " |
1721 |
1677 (s := self primitiveDefinitionsString) notNil ifTrue:[ |
1722 aStream cr; cr; nextPut:(Character doubleQuote); cr. |
1678 aStream nextPutChunkSeparator; |
1723 aStream space; |
1679 nextPutAll:name; nextPutAll:' primitiveDefinitions'; |
1724 nextPutAll:'The following class instance variables are inherited by this class:'; |
1680 nextPutChunkSeparator; |
1725 cr; cr. |
1681 cr. |
1726 self allSuperclassesDo:[:aSuperClass | |
1682 aStream nextPutAll:s. |
1727 aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '. |
1683 aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr |
1728 aStream nextPutAll:(aSuperClass class instanceVariableString); cr. |
1684 ]. |
1729 ]. |
1685 (s := self primitiveVariablesString) notNil ifTrue:[ |
1730 aStream nextPut:(Character doubleQuote); cr. |
1686 aStream nextPutChunkSeparator; |
|
1687 nextPutAll:name; nextPutAll:' primitiveVariables'; |
|
1688 nextPutChunkSeparator; |
|
1689 cr. |
|
1690 aStream nextPutAll:s. |
|
1691 aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr |
|
1692 ]. |
|
1693 ! |
|
1694 |
|
1695 fileOutCommentOn:aStream |
|
1696 "append an expression on aStream, which defines my comment" |
|
1697 |
|
1698 |comment s| |
|
1699 |
|
1700 aStream nextPutAll:name; nextPutAll:' comment:'. |
|
1701 (comment := self comment) isNil ifTrue:[ |
|
1702 s := '''''' |
|
1703 ] ifFalse:[ |
|
1704 s := comment storeString |
|
1705 ]. |
|
1706 aStream nextPutAll:s. |
|
1707 aStream cr |
|
1708 ! |
|
1709 |
|
1710 fileOutPrimitiveSpecsOn:aStream |
|
1711 "append primitive defs (if any) to aStream." |
|
1712 |
|
1713 |s| |
|
1714 |
|
1715 " |
|
1716 primitive definitions - if any |
|
1717 " |
|
1718 self fileOutPrimitiveDefinitionsOn:aStream. |
|
1719 " |
|
1720 primitive functions - if any |
|
1721 " |
|
1722 (s := self primitiveFunctionsString) notNil ifTrue:[ |
|
1723 aStream nextPutChunkSeparator; |
|
1724 nextPutAll:name; nextPutAll:' primitiveFunctions'; |
|
1725 nextPutChunkSeparator; |
|
1726 cr. |
|
1727 aStream nextPutAll:s. |
|
1728 aStream nextPutChunkSeparator; space; nextPutChunkSeparator; cr; cr |
|
1729 ]. |
1731 ! |
1730 ! |
1732 |
1731 |
1733 fileOutOn:aStream |
1732 fileOutOn:aStream |
1734 "file out my definition and all methods onto aStream" |
1733 "file out my definition and all methods onto aStream" |
1735 |
1734 |
1859 aStream nextPutChunkSeparator. |
1858 aStream nextPutChunkSeparator. |
1860 aStream cr |
1859 aStream cr |
1861 ] |
1860 ] |
1862 ! |
1861 ! |
1863 |
1862 |
1864 fileOutCategory:aCategory |
|
1865 "create a file 'class-category.st' consisting of all methods in aCategory. |
|
1866 If the current project is not nil, create the file in the projects |
|
1867 directory." |
|
1868 |
|
1869 |aStream fileName| |
|
1870 |
|
1871 fileName := name , '-' , aCategory , '.st'. |
|
1872 fileName replaceAll:(Character space) by:$_. |
|
1873 |
|
1874 " |
|
1875 this test allows a smalltalk to be built without Projects/ChangeSets |
|
1876 " |
|
1877 Project notNil ifTrue:[ |
|
1878 fileName := Project currentProjectDirectory , fileName. |
|
1879 ]. |
|
1880 |
|
1881 " |
|
1882 if file exists, save original in a .sav file |
|
1883 " |
|
1884 fileName asFilename exists ifTrue:[ |
|
1885 fileName asFilename copyTo:(fileName , '.sav') |
|
1886 ]. |
|
1887 aStream := FileStream newFileNamed:fileName. |
|
1888 aStream isNil ifTrue:[ |
|
1889 ^ FileOutErrorSignal |
|
1890 raiseRequestWith:fileName |
|
1891 errorString:('cannot create file:', fileName) |
|
1892 ]. |
|
1893 self fileOutCategory:aCategory on:aStream. |
|
1894 aStream close |
|
1895 ! |
|
1896 |
|
1897 fileOut |
1863 fileOut |
1898 "create a file 'class.st' consisting of all methods in myself. |
1864 "create a file 'class.st' consisting of all methods in myself. |
1899 If the current project is not nil, create the file in the projects |
1865 If the current project is not nil, create the file in the projects |
1900 directory. Care is taken, to not clobber any existing file in |
1866 directory. Care is taken, to not clobber any existing file in |
1901 case of errors (for example: disk full). |
1867 case of errors (for example: disk full). |
1975 since we can see in that changeBrowser, which changes have |
1941 since we can see in that changeBrowser, which changes have |
1976 already found their way into a sourceFile and which must be |
1942 already found their way into a sourceFile and which must be |
1977 applied again |
1943 applied again |
1978 " |
1944 " |
1979 self addChangeRecordForClassFileOut:self |
1945 self addChangeRecordForClassFileOut:self |
|
1946 ! |
|
1947 |
|
1948 fileOutClassInstVarDefinitionOn:aStream |
|
1949 "append an expression to define my classInstanceVariables on aStream" |
|
1950 |
|
1951 aStream nextPutAll:(name , ' class instanceVariableNames:'''). |
|
1952 self class printInstVarNamesOn:aStream indent:8. |
|
1953 aStream nextPutAll:''''. |
|
1954 |
|
1955 "mhmh - good idea; saw this in SmallDraw sourcecode ..." |
|
1956 |
|
1957 aStream cr; cr; nextPut:(Character doubleQuote); cr. |
|
1958 aStream space; |
|
1959 nextPutAll:'The following class instance variables are inherited by this class:'; |
|
1960 cr; cr. |
|
1961 self allSuperclassesDo:[:aSuperClass | |
|
1962 aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '. |
|
1963 aStream nextPutAll:(aSuperClass class instanceVariableString); cr. |
|
1964 ]. |
|
1965 aStream nextPut:(Character doubleQuote); cr. |
|
1966 ! |
|
1967 |
|
1968 fileOutCategory:aCategory |
|
1969 "create a file 'class-category.st' consisting of all methods in aCategory. |
|
1970 If the current project is not nil, create the file in the projects |
|
1971 directory." |
|
1972 |
|
1973 |aStream fileName| |
|
1974 |
|
1975 fileName := name , '-' , aCategory , '.st'. |
|
1976 fileName replaceAll:(Character space) by:$_. |
|
1977 |
|
1978 " |
|
1979 this test allows a smalltalk to be built without Projects/ChangeSets |
|
1980 " |
|
1981 Project notNil ifTrue:[ |
|
1982 fileName := Project currentProjectDirectory , fileName. |
|
1983 ]. |
|
1984 |
|
1985 " |
|
1986 if file exists, save original in a .sav file |
|
1987 " |
|
1988 fileName asFilename exists ifTrue:[ |
|
1989 fileName asFilename copyTo:(fileName , '.sav') |
|
1990 ]. |
|
1991 aStream := FileStream newFileNamed:fileName. |
|
1992 aStream isNil ifTrue:[ |
|
1993 ^ FileOutErrorSignal |
|
1994 raiseRequestWith:fileName |
|
1995 errorString:('cannot create file:', fileName) |
|
1996 ]. |
|
1997 self fileOutCategory:aCategory on:aStream. |
|
1998 aStream close |
1980 ! |
1999 ! |
1981 |
2000 |
1982 fileOutMethod:aMethod |
2001 fileOutMethod:aMethod |
1983 "create a file 'class-method.st' consisting of the method, aMethod. |
2002 "create a file 'class-method.st' consisting of the method, aMethod. |
1984 If the current project is not nil, create the file in the projects |
2003 If the current project is not nil, create the file in the projects |
2348 ] |
2367 ] |
2349 ! ! |
2368 ! ! |
2350 |
2369 |
2351 !Class methodsFor:'private'! |
2370 !Class methodsFor:'private'! |
2352 |
2371 |
|
2372 updateVersionString |
|
2373 "update my version string, to reflect a change w.r.t. |
|
2374 the original source. |
|
2375 The original version string is kept as a reference i.e. |
|
2376 Header: /files/CVS/stx/libbasic/Class.st,v 1.63 1995/10/28 16:44:51 cg Exp $ |
|
2377 is changed into: |
|
2378 Header: /files/CVS/stx/libbasic/Class.st,v 1.63mod 1995/10/28 16:44:51 cg Exp $ |
|
2379 " |
|
2380 |
|
2381 |cls vs m idx leftPart rightPart vsnString| |
|
2382 |
|
2383 cls := self. |
|
2384 self isMeta ifFalse:[ |
|
2385 cls := self class |
|
2386 ]. |
|
2387 m := cls compiledMethodAt:#version. |
|
2388 m isNil ifTrue:[^ self]. |
|
2389 vs := self versionString. |
|
2390 vs isNil ifTrue:[^ self]. |
|
2391 |
|
2392 "/ search for ,v |
|
2393 idx := vs indexOfSubCollection:'.st,v'. |
|
2394 idx == 0 ifTrue:[^ self]. |
|
2395 leftPart := vs copyTo:(idx - 1 + 5). |
|
2396 rightPart := (vs copyFrom:(idx + 5)) withoutSpaces. |
|
2397 idx := rightPart indexOfSeparator. |
|
2398 idx == 0 ifTrue:[^ self]. |
|
2399 vsnString := rightPart copyTo:idx - 1. |
|
2400 rightPart := rightPart copyFrom:idx + 1. |
|
2401 vsnString ~= self revision ifTrue:[ |
|
2402 "/ alread a modified class |
|
2403 "/ ('already modified: ' , vsnString) printNL. |
|
2404 ^ self |
|
2405 ]. |
|
2406 m source:'version |
|
2407 " |
|
2408 ' , leftPart , ' ' , vsnString , 'mod' , ' ' , rightPart , ' |
|
2409 "'. |
|
2410 |
|
2411 "/ ('updated to :' , vsnString , 'mod') printNL. |
|
2412 |
|
2413 " |
|
2414 Class updateVersionString |
|
2415 Number updateVersionString |
|
2416 ProcessMonitor updateVersionString |
|
2417 " |
|
2418 |
|
2419 "Created: 29.10.1995 / 19:25:15 / cg" |
|
2420 "Modified: 29.10.1995 / 19:39:38 / cg" |
|
2421 ! |
|
2422 |
|
2423 versionString |
|
2424 "return my version string; that one is extracted from the |
|
2425 classes #version methods source code. |
|
2426 If the source is not accessable or no such method exists, |
|
2427 nil is returned." |
|
2428 |
|
2429 |cls m src lines idx| |
|
2430 |
|
2431 cls := self. |
|
2432 self isMeta ifFalse:[ |
|
2433 cls := self class |
|
2434 ]. |
|
2435 m := cls compiledMethodAt:#version. |
|
2436 m isNil ifTrue:[^ nil]. |
|
2437 src := m source. |
|
2438 src isNil ifTrue:[^ nil]. |
|
2439 lines := src asCollectionOfLines. |
|
2440 idx := lines findFirst:[:l | |
|
2441 l withoutSpaces startsWith:'$Header' |
|
2442 ]. |
|
2443 idx == 0 ifTrue:[^ nil]. |
|
2444 ^ lines at:idx. |
|
2445 |
|
2446 " |
|
2447 Smalltalk allClassesDo:[:cls | |
|
2448 Transcript showCr:cls versionString |
|
2449 ]. |
|
2450 |
|
2451 Number versionString |
|
2452 " |
|
2453 |
|
2454 "Created: 29.10.1995 / 19:28:03 / cg" |
|
2455 ! |
|
2456 |
2353 addAllClassVarNamesTo:aCollection |
2457 addAllClassVarNamesTo:aCollection |
2354 "helper - add the name-strings of the class variables and of the class-vars |
2458 "helper - add the name-strings of the class variables and of the class-vars |
2355 of all superclasses to the argument, aCollection. Return aCollection" |
2459 of all superclasses to the argument, aCollection. Return aCollection" |
2356 |
2460 |
2357 (superclass notNil) ifTrue:[ |
2461 (superclass notNil) ifTrue:[ |
2359 ]. |
2463 ]. |
2360 classvars notNil ifTrue:[ |
2464 classvars notNil ifTrue:[ |
2361 aCollection addAll:(classvars asCollectionOfWords). |
2465 aCollection addAll:(classvars asCollectionOfWords). |
2362 ]. |
2466 ]. |
2363 ^ aCollection |
2467 ^ aCollection |
2364 ! |
|
2365 |
|
2366 addCategoriesTo:aCollection |
|
2367 "helper - add categories to the argument, aCollection" |
|
2368 |
|
2369 methodArray do:[:aMethod | |
|
2370 |cat| |
|
2371 |
|
2372 cat := aMethod category. |
|
2373 (aCollection includes:cat) ifFalse:[ |
|
2374 aCollection add:cat |
|
2375 ] |
|
2376 ] |
|
2377 ! |
2468 ! |
2378 |
2469 |
2379 getPrimitiveSpecsAt:index |
2470 getPrimitiveSpecsAt:index |
2380 "return a primitiveSpecification component as string or nil" |
2471 "return a primitiveSpecification component as string or nil" |
2381 |
2472 |
2401 ^ nil |
2492 ^ nil |
2402 ]. |
2493 ]. |
2403 ^ pos |
2494 ^ pos |
2404 ! |
2495 ! |
2405 |
2496 |
|
2497 addCategoriesTo:aCollection |
|
2498 "helper - add categories to the argument, aCollection" |
|
2499 |
|
2500 methodArray do:[:aMethod | |
|
2501 |cat| |
|
2502 |
|
2503 cat := aMethod category. |
|
2504 (aCollection includes:cat) ifFalse:[ |
|
2505 aCollection add:cat |
|
2506 ] |
|
2507 ] |
|
2508 ! |
|
2509 |
2406 addAllCategoriesTo:aCollection |
2510 addAllCategoriesTo:aCollection |
2407 "helper - add categories and all superclasses categories |
2511 "helper - add categories and all superclasses categories |
2408 to the argument, aCollection" |
2512 to the argument, aCollection" |
2409 |
2513 |
2410 (superclass notNil) ifTrue:[ |
2514 (superclass notNil) ifTrue:[ |
2421 ]. |
2525 ]. |
2422 primitiveSpec at:index put:aString |
2526 primitiveSpec at:index put:aString |
2423 ! ! |
2527 ! ! |
2424 |
2528 |
2425 !Class methodsFor:'queries'! |
2529 !Class methodsFor:'queries'! |
2426 |
|
2427 categories |
|
2428 "Return a Collection of all method-category strings known in class. |
|
2429 The returned collection is not sorted by any order." |
|
2430 |
|
2431 |newList cat| |
|
2432 |
|
2433 newList := OrderedCollection new. |
|
2434 methodArray do:[:aMethod | |
|
2435 cat := aMethod category. |
|
2436 newList indexOf:cat ifAbsent:[newList add:cat] |
|
2437 ]. |
|
2438 ^ newList |
|
2439 |
|
2440 " |
|
2441 Point categories |
|
2442 " |
|
2443 ! |
|
2444 |
2530 |
2445 isClass |
2531 isClass |
2446 "return true, if the receiver is some kind of class |
2532 "return true, if the receiver is some kind of class |
2447 (a real class, not just behavior); |
2533 (a real class, not just behavior); |
2448 true is returned here - the method is redefined from Object. |
2534 true is returned here - the method is redefined from Object. |
2458 Class new isBehavior |
2544 Class new isBehavior |
2459 Class new isClass |
2545 Class new isClass |
2460 " |
2546 " |
2461 ! |
2547 ! |
2462 |
2548 |
2463 allCategories |
2549 categories |
2464 "Return a Collection of all method-category strings known in class |
2550 "Return a Collection of all method-category strings known in class. |
2465 and all superclasses. The returned collection is not sorted by any order." |
2551 The returned collection is not sorted by any order." |
2466 |
2552 |
2467 |coll| |
2553 |newList cat| |
2468 |
2554 |
2469 coll := OrderedCollection new. |
2555 newList := OrderedCollection new. |
2470 self addAllCategoriesTo:coll. |
2556 methodArray do:[:aMethod | |
2471 ^ coll |
2557 cat := aMethod category. |
|
2558 newList indexOf:cat ifAbsent:[newList add:cat] |
|
2559 ]. |
|
2560 ^ newList |
2472 |
2561 |
2473 " |
2562 " |
2474 Point categories |
2563 Point categories |
2475 Point allCategories |
|
2476 " |
2564 " |
2477 ! |
2565 ! |
2478 |
2566 |
2479 whichClassDefinesClassVar:aVariableName |
2567 whichClassDefinesClassVar:aVariableName |
2480 "return the class which defines the class variable |
2568 "return the class which defines the class variable |
2502 autoload; false otherwise. |
2590 autoload; false otherwise. |
2503 This is not an attribute of the class, but instead remembered in |
2591 This is not an attribute of the class, but instead remembered in |
2504 Autoload. The interface here is for covenience." |
2592 Autoload. The interface here is for covenience." |
2505 |
2593 |
2506 ^ Autoload wasAutoloaded:self |
2594 ^ Autoload wasAutoloaded:self |
|
2595 ! |
|
2596 |
|
2597 allCategories |
|
2598 "Return a Collection of all method-category strings known in class |
|
2599 and all superclasses. The returned collection is not sorted by any order." |
|
2600 |
|
2601 |coll| |
|
2602 |
|
2603 coll := OrderedCollection new. |
|
2604 self addAllCategoriesTo:coll. |
|
2605 ^ coll |
|
2606 |
|
2607 " |
|
2608 Point categories |
|
2609 Point allCategories |
|
2610 " |
2507 ! |
2611 ! |
2508 |
2612 |
2509 whichClassDefinesInstVar:aVariableName |
2613 whichClassDefinesInstVar:aVariableName |
2510 "return the class which defines the instance variable |
2614 "return the class which defines the instance variable |
2511 named aVariableName. This method should not be used for |
2615 named aVariableName. This method should not be used for |