14 "{ NameSpace: Smalltalk }" |
16 "{ NameSpace: Smalltalk }" |
15 |
17 |
16 ClassDescription subclass:#Class |
18 ClassDescription subclass:#Class |
17 instanceVariableNames:'name category classvars comment subclasses classFilename package |
19 instanceVariableNames:'name category classvars comment subclasses classFilename package |
18 revision environment signature attributes' |
20 revision environment signature attributes' |
19 classVariableNames:'DefaultCategoryForSTV DefaultCategoryForVAGE |
21 classVariableNames:'DefaultCategoryForDolphin DefaultCategoryForSTV |
20 DefaultCategoryForDolphin ValidateSourceOnlyOnce ValidatedClasses |
|
21 SubclassCacheSequenceNumber |
|
22 DefaultCategoryForUncategorizedClasses |
22 DefaultCategoryForUncategorizedClasses |
23 DefaultCategoryForUndeclaredClasses' |
23 DefaultCategoryForUndeclaredClasses DefaultCategoryForVAGE |
|
24 SubclassCacheSequenceNumber ValidateSourceOnlyOnce |
|
25 ValidatedClasses' |
24 poolDictionaries:'' |
26 poolDictionaries:'' |
25 category:'Kernel-Classes' |
27 category:'Kernel-Classes' |
26 ! |
28 ! |
27 |
29 |
28 Array variableSubclass:#ArrayWithSequenceNumberValidation |
30 Array variableSubclass:#ArrayWithSequenceNumberValidation |
76 Class adds more functionality to classes; minimum stuff has already |
78 Class adds more functionality to classes; minimum stuff has already |
77 been defined in Behavior and ClassDescription; this adds naming, categories etc. |
79 been defined in Behavior and ClassDescription; this adds naming, categories etc. |
78 |
80 |
79 [Instance variables:] |
81 [Instance variables:] |
80 |
82 |
81 name <Symbol> the classes name |
83 name <Symbol> the classes name |
82 |
84 |
83 category <Symbol> the classes category |
85 category <Symbol> the classes category |
84 |
86 |
85 classvars <String> the names of the class variables; |
87 classvars <String> the names of the class variables; |
86 | <Collection of words> initially, stc generates a string; this is converted on the fly |
88 | <Collection of words> initially, stc generates a string; this is converted on the fly |
87 to an array of names. In the future, stc may be changed. |
89 to an array of names. In the future, stc may be changed. |
88 |
90 |
89 comment <String> the classes comment; either a string, |
91 comment <String> the classes comment; either a string, |
90 a number specifying the offset in classFilename, or nil |
92 a number specifying the offset in classFilename, or nil |
91 |
93 |
92 subclasses <Collection> cached collection of subclasses |
94 subclasses <Collection> cached collection of subclasses |
93 (not used for execution, but for the IDE to speed up certain operations) |
95 (not used for execution, but for the IDE to speed up certain operations) |
94 |
96 |
95 classFilename <String> the file (or nil) where the classes' sources are found |
97 classFilename <String> the file (or nil) where the classes' sources are found |
96 |
98 |
97 package <Symbol> the package, in which the class was defined (inserted by compilers) |
99 package <Symbol> the package, in which the class was defined (inserted by compilers) |
98 |
100 |
99 revision <String> revision string - inserted by stc |
101 revision <String> revision string - inserted by stc |
100 |
102 |
101 environment <Symbol | nil> cached environment (i.e. Smalltalk or a namespace) |
103 environment <Symbol | nil> cached environment (i.e. Smalltalk or a namespace) |
102 |
104 |
103 signature <SmallInteger> the classes signature (used to detect obsolete or changed classes with binaryStorage) |
105 signature <SmallInteger> the classes signature (used to detect obsolete or changed classes with binaryStorage) |
104 This is filled in lazy - i.e. upon the first signature query. |
106 This is filled in lazy - i.e. upon the first signature query. |
105 |
107 |
106 attributes <Array | nil> describes primitiveIncludes, primitiveFunctions etc. |
108 attributes <Array | nil> describes primitiveIncludes, primitiveFunctions etc. |
107 also a place to add additional attributes, without a need to recompile all classes. |
109 also a place to add additional attributes, without a need to recompile all classes. |
108 |
110 |
109 |
111 |
110 WARNING: layout known by compiler and runtime system |
112 WARNING: layout known by compiler and runtime system |
111 |
113 |
|
114 [note:] |
|
115 the subclasses instvar keeps a cached collection of the known subclasses in the system. |
|
116 this cache is lazyly flushed when a SubclassCacheSequenceNumber comparison detects a mismatch. |
|
117 (this seqNr is incremented, whenever something in any class hierarchy changes). |
|
118 This is a q&d mechanism to allow for no-overhead fileIn and package loading, |
|
119 and reasonable speedup in the hierarchy walkers (i.e. the browsers). |
|
120 (flushing all is obviously too much flushing, and we could do better in many situations) |
|
121 |
112 [author:] |
122 [author:] |
113 Claus Gittinger |
123 Claus Gittinger |
114 |
124 |
115 [see also:] |
125 [see also:] |
116 Behavior ClassDescription Metaclass |
126 Behavior ClassDescription Metaclass |
117 " |
127 " |
118 ! |
128 ! |
119 |
129 |
120 versionManagement |
130 versionManagement |
121 " |
131 " |
465 |
475 |
466 "Modified: / 06-12-2011 / 16:20:13 / cg" |
476 "Modified: / 06-12-2011 / 16:20:13 / cg" |
467 ! |
477 ! |
468 |
478 |
469 flushSubclassInfoFor:aClass |
479 flushSubclassInfoFor:aClass |
470 "throw away (forget) the cached subclass information for aClass, as created |
480 "throw away (forget) the cached subclass information for aClass, |
471 by #subclassInfo. |
481 as created by #subclassInfo. |
472 This is private protocol" |
482 This is private protocol" |
473 |
483 |
474 aClass notNil ifTrue:[ |
484 aClass notNil ifTrue:[ |
475 aClass flushSubclasses |
485 aClass flushSubclasses |
476 ]. |
486 ]. |
477 |
487 |
478 " |
488 " |
479 Class flushSubclassInfoFor:View |
489 Class flushSubclassInfoFor:View |
480 " |
490 " |
486 |
496 |
487 isBuiltInClass |
497 isBuiltInClass |
488 "return true if this class is known by the run-time-system. |
498 "return true if this class is known by the run-time-system. |
489 Here, true is returned for myself, false for subclasses." |
499 Here, true is returned for myself, false for subclasses." |
490 |
500 |
491 ^ self == Class class or:[self == Class] |
501 ^ self == (Class class) or:[self == Class] |
492 |
502 |
493 "Created: 15.4.1996 / 17:17:13 / cg" |
503 "Created: 15.4.1996 / 17:17:13 / cg" |
494 "Modified: 23.4.1996 / 15:56:58 / cg" |
504 "Modified: 23.4.1996 / 15:56:58 / cg" |
495 ! ! |
505 ! ! |
|
506 |
496 |
507 |
497 |
508 |
498 !Class methodsFor:'Compatibility-Dolphin'! |
509 !Class methodsFor:'Compatibility-Dolphin'! |
499 |
510 |
500 defaultCategoryForDolphinClasses |
511 defaultCategoryForDolphinClasses |
1732 "Modified: / 18-01-2011 / 20:41:17 / cg" |
1745 "Modified: / 18-01-2011 / 20:41:17 / cg" |
1733 ! |
1746 ! |
1734 |
1747 |
1735 sharedPools |
1748 sharedPools |
1736 "this returns a collection of the real pools (i.e. the PoolDictionaries), |
1749 "this returns a collection of the real pools (i.e. the PoolDictionaries), |
1737 not their names (see sharedPoolNames)" |
1750 not their names (see sharedPoolNames). |
|
1751 This cares for the namespace in which the class is located |
|
1752 |
|
1753 Notice, that for source compatibility with other smalltalks, |
|
1754 the namespace is not in the pool name, as to make it is easy to fileIn an alien class |
|
1755 into an ST/X namespace. |
|
1756 However, then we must resolve the actual pool later - i.e. here" |
1738 |
1757 |
1739 |ns ns2 pools| |
1758 |ns ns2 pools| |
1740 |
1759 |
1741 ns := self nameSpace. |
1760 ns := self nameSpace. |
1742 ns2 := self topNameSpace. |
1761 ns2 := self topNameSpace. |
1743 pools := |
1762 pools := |
1744 self sharedPoolNames |
1763 self sharedPoolNames |
1745 collect:[:eachName | |
1764 collect:[:eachName | |
1746 |pool| |
1765 |pool| |
1747 |
1766 |
1748 ns ~= Smalltalk ifTrue:[ |
1767 (ns notNil and:[ns ~= Smalltalk]) ifTrue:[ |
1749 pool := ns classNamed:eachName. |
1768 pool := ns classNamed:eachName. |
1750 ]. |
1769 ]. |
1751 pool isNil ifTrue:[ |
1770 pool isNil ifTrue:[ |
1752 ns2 ~= Smalltalk ifTrue:[ |
1771 (ns2 notNil and:[ns2 ~~ ns and:[ns2 ~= Smalltalk]]) ifTrue:[ |
1753 pool := ns2 classNamed:eachName. |
1772 pool := ns2 classNamed:eachName. |
1754 ]. |
1773 ]. |
1755 ]. |
|
1756 pool isNil ifTrue:[ |
|
1757 pool := Smalltalk classNamed:eachName. |
|
1758 pool isNil ifTrue:[ |
1774 pool isNil ifTrue:[ |
1759 Transcript showCR:('Warning: no such pool: ',eachName). |
1775 pool := Smalltalk classNamed:eachName. |
1760 ] |
1776 pool isNil ifTrue:[ |
|
1777 Transcript showCR:('Warning: no such pool: ',eachName). |
|
1778 ] |
|
1779 ]. |
1761 ]. |
1780 ]. |
1762 pool |
1781 pool |
1763 ] |
1782 ] |
1764 thenSelect:[:pool | pool notNil]. |
1783 thenSelect:[:pool | pool notNil]. |
1765 |
1784 |
1766 ^ pools. |
1785 ^ pools. |
1767 |
1786 |
1768 |
1787 |
1769 " |
1788 " |
|
1789 an example for a pool inside a namespace (in this case: a private pool): |
|
1790 UnixOperatingSystem::ELFFileHeader sharedPools |
|
1791 |
|
1792 Smalltalk allClasses |
|
1793 collect:[:cls | cls -> cls sharedPools] |
|
1794 thenSelect:[:assoc | assoc value notEmptyOrNil]. |
|
1795 |
1770 OSI::ASN1_Coder sharedPoolNames |
1796 OSI::ASN1_Coder sharedPoolNames |
1771 OSI::ASN1_Coder sharedPools |
1797 ZipArchive sharedPools |
1772 Croquet::OpenGL sharedPools |
1798 Croquet::OpenGL sharedPools |
1773 OpenGLRenderingContext sharedPools |
1799 OpenGLRenderingContext sharedPools |
1774 Character sharedPools |
1800 Character sharedPools |
1775 Win32OperatingSystem sharedPools |
1801 Win32OperatingSystem sharedPools |
1776 " |
1802 " |
4260 |
4285 |
4261 " |
4286 " |
4262 StandardSystemView whichClassDefinesClassVar:'ErrorSignal' |
4287 StandardSystemView whichClassDefinesClassVar:'ErrorSignal' |
4263 StandardSystemView whichClassDefinesClassVar:'Foo' |
4288 StandardSystemView whichClassDefinesClassVar:'Foo' |
4264 " |
4289 " |
4265 ! |
|
4266 |
|
4267 whichPoolDefinesPoolVar:aVariableName |
|
4268 "return the shared which defines the class variable named aVariableName or nil." |
|
4269 |
|
4270 self sharedPools do:[:eachPool | |
|
4271 (eachPool classVariableNames includes:aVariableName) ifTrue:[ ^ eachPool]. |
|
4272 ]. |
|
4273 ^ nil |
|
4274 |
|
4275 " |
|
4276 ZipArchiveConstants classVariableNames |
|
4277 ZipArchive sharedPools |
|
4278 ZipArchive whichPoolDefinesPoolVar:'ECREC_SIZE' |
|
4279 " |
|
4280 ! ! |
4290 ! ! |
4281 |
4291 |
4282 !Class methodsFor:'renaming'! |
4292 !Class methodsFor:'renaming'! |
4283 |
4293 |
4284 makePrivateIn:newOwner |
4294 makePrivateIn:newOwner |