Metaclass.st
branchjv
changeset 17732 a1892eeca6c0
parent 17727 3945dfe4659c
child 17734 406b1590afe8
equal deleted inserted replaced
17731:295728e8f410 17732:a1892eeca6c0
    36 
    36 
    37 documentation
    37 documentation
    38 "
    38 "
    39     every classes class is a subclass of Metaclass.
    39     every classes class is a subclass of Metaclass.
    40     (i.e. every class is the sole instance of its Metaclass)
    40     (i.e. every class is the sole instance of its Metaclass)
    41     Metaclass provides support for creating new (sub)classes and/or 
    41     Metaclass provides support for creating new (sub)classes and/or
    42     changing the definition of an already existing class.
    42     changing the definition of an already existing class.
    43 
    43 
    44     [author:]
    44     [author:]
    45 	Claus Gittinger
    45 	Claus Gittinger
    46 
    46 
    62 ! !
    62 ! !
    63 
    63 
    64 !Metaclass class methodsFor:'class initialization'!
    64 !Metaclass class methodsFor:'class initialization'!
    65 
    65 
    66 initialize
    66 initialize
    67     ConfirmationQuerySignal := QuerySignal new defaultAnswer:true
    67     ConfirmationQuerySignal isNil ifTrue:[
       
    68         ConfirmationQuerySignal := Query newSignal defaultAnswer:true.
       
    69     ].
    68 
    70 
    69     "Modified: 31.7.1997 / 21:54:44 / cg"
    71     "Modified: 31.7.1997 / 21:54:44 / cg"
    70 ! !
    72 ! !
    71 
    73 
    72 !Metaclass class methodsFor:'creating metaclasses'!
    74 !Metaclass class methodsFor:'creating metaclasses'!
    93 ! !
    95 ! !
    94 
    96 
    95 !Metaclass class methodsFor:'queries'!
    97 !Metaclass class methodsFor:'queries'!
    96 
    98 
    97 asPrivate
    99 asPrivate
    98     ^ PrivateMetaclass 
   100     ^ PrivateMetaclass
    99 !
   101 !
   100 
   102 
   101 isBuiltInClass
   103 isBuiltInClass
   102     "return true if this class is known by the run-time-system.
   104     "return true if this class is known by the run-time-system.
   103      Here, true is returned for myself, false for subclasses."
   105      Here, true is returned for myself, false for subclasses."
   126 ! !
   128 ! !
   127 
   129 
   128 !Metaclass methodsFor:'autoload check'!
   130 !Metaclass methodsFor:'autoload check'!
   129 
   131 
   130 isLoaded
   132 isLoaded
   131     "return true, if the class has been loaded; 
   133     "return true, if the class has been loaded;
   132      redefined in Autoload; see comment there"
   134      redefined in Autoload; see comment there"
   133 
   135 
   134     ^ myClass isLoaded
   136     ^ myClass isLoaded
   135 
   137 
   136 
   138 
   158 ! !
   160 ! !
   159 
   161 
   160 !Metaclass methodsFor:'compiler interface'!
   162 !Metaclass methodsFor:'compiler interface'!
   161 
   163 
   162 browserClass
   164 browserClass
   163     "return the browser to use for this class - 
   165     "return the browser to use for this class -
   164      this can be redefined in special classes, to get different browsers"
   166      this can be redefined in special classes, to get different browsers"
   165 
   167 
   166     ^ UserPreferences systemBrowserClass.
   168     ^ UserPreferences systemBrowserClass.
   167 
   169 
   168     "Created: 3.5.1996 / 12:36:40 / cg"
   170     "Created: 3.5.1996 / 12:36:40 / cg"
   169 !
   171 !
   170 
   172 
   171 compilerClass
   173 compilerClass
   172     "return the compiler to use for this class - 
   174     "return the compiler to use for this class -
   173      this can be redefined in special classes, to compile classes with
   175      this can be redefined in special classes, to compile classes with
   174      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   176      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   175 
   177 
   176     ^ Compiler
   178     ^ self programmingLanguage compilerClass.
       
   179 
       
   180     "
       
   181      Array compilerClass
       
   182     "
   177 !
   183 !
   178 
   184 
   179 evaluatorClass
   185 evaluatorClass
   180     "return the compiler to use for expression evaluation for this class - 
   186     "return the compiler to use for expression evaluation for this class -
   181      this can be redefined in special classes, to evaluate expressions with
   187      this can be redefined in special classes, to evaluate expressions with
   182      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   188      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   183 
   189 
   184     ^ Compiler
   190     ^ self programmingLanguage evaluatorClass.
       
   191 
       
   192     "
       
   193      Array evaluatorClass
       
   194     "
   185 !
   195 !
   186 
   196 
   187 formatterClass
   197 formatterClass
   188     "return the parser to use for formatting (prettyPrinting) this class - 
   198     "return the parser to use for formatting (prettyPrinting) this class -
   189      this can be redefined in special classes, to format classes with
   199      this can be redefined in special classes, to format classes with
   190      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   200      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   191 
   201 
   192     ^ Parser
   202     ^ self programmingLanguage formatterClass.
   193 
   203 
   194     "Created: / 27.4.1998 / 15:33:34 / cg"
   204     "
   195 !
   205      Array formatterClass
   196 
   206     "
   197 language
   207 !
   198 
   208 
   199     ^SmalltalkLanguage instance
   209 parserClass
       
   210     "return the parser to use for parsing this class -
       
   211      this can be redefined in special classes, to parse classes with
       
   212      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
       
   213 
       
   214     ^ self programmingLanguage parserClass.
       
   215 
       
   216     "
       
   217      Array parserClass
       
   218     "
       
   219 !
       
   220 
       
   221 programmingLanguage
       
   222     "return the programming language in which this class is written"
       
   223 
       
   224     ^ SmalltalkLanguage instance
   200 
   225 
   201     "Created: / 15-08-2009 / 09:06:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
   226     "Created: / 15-08-2009 / 09:06:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
   202     "Modified: / 16-08-2009 / 10:37:08 / Jan Vrany <vranyj1@fel.cvut.cz>"
   227     "Modified: / 16-08-2009 / 10:37:08 / Jan Vrany <vranyj1@fel.cvut.cz>"
   203 !
   228 !
   204 
   229 
   205 parserClass
       
   206     "return the parser to use for parsing this class - 
       
   207      this can be redefined in special classes, to parse classes with
       
   208      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
       
   209 
       
   210     ^ Parser
       
   211 
       
   212     "Created: 18.4.1997 / 21:02:41 / cg"
       
   213 !
       
   214 
       
   215 realSubclassDefinerClass
   230 realSubclassDefinerClass
   216     ^ self evaluatorClass
   231     ^ self evaluatorClass
   217 !
   232 !
   218 
   233 
   219 subclassDefinerClass
   234 subclassDefinerClass
   220     "Answer an evaluator class appropriate for evaluating definitions of new 
   235     "Answer an evaluator class appropriate for evaluating definitions of new
   221      subclasses of this class."
   236      subclasses of this class."
   222 
   237 
   223     ^ self evaluatorClass
   238     ^ self evaluatorClass
   224 
   239 
   225 
   240 
   226 !
   241 !
   227 
   242 
   228 syntaxHighlighterClass
   243 syntaxHighlighterClass
   229     "return the class to use for syntaxHighlighting (prettyPrinting) this class - 
   244     "return the class to use for syntaxHighlighting (prettyPrinting) this class -
   230      this can be redefined in special classes, to highlight classes with
   245      this can be redefined in special classes, to highlight classes with
   231      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   246      Lisp, Prolog, ASN1, Basic :-) or whatever syntax."
   232 
   247 
   233     ^ SyntaxHighlighter
   248     ^ self programmingLanguage syntaxHighlighterClass.
   234 
   249 
   235     "Created: / 27.4.1998 / 15:34:08 / cg"
   250     "
       
   251      Array syntaxHighlighterClass
       
   252     "
   236 ! !
   253 ! !
   237 
   254 
   238 !Metaclass methodsFor:'copying'!
   255 !Metaclass methodsFor:'copying'!
   239 
   256 
   240 postCopy
   257 postCopy
   244 ! !
   261 ! !
   245 
   262 
   246 !Metaclass methodsFor:'creating classes'!
   263 !Metaclass methodsFor:'creating classes'!
   247 
   264 
   248 name:newName inEnvironment:aNameSpaceOrOwningClass
   265 name:newName inEnvironment:aNameSpaceOrOwningClass
   249              subclassOf:aClass
   266 	     subclassOf:aClass
   250              instanceVariableNames:stringOfInstVarNames
   267 	     instanceVariableNames:stringOfInstVarNames
   251              variable:variableBoolean
   268 	     variable:variableBoolean
   252              words:wordsBoolean
   269 	     words:wordsBoolean
   253              pointers:pointersBoolean
   270 	     pointers:pointersBoolean
   254              classVariableNames:stringOfClassVarNames
   271 	     classVariableNames:stringOfClassVarNames
   255              poolDictionaries:stringOfPoolNames
   272 	     poolDictionaries:stringOfPoolNames
   256              category:categoryString
   273 	     category:categoryString
   257              comment:commentString
   274 	     comment:commentString
   258              changed:changed
   275 	     changed:changed
   259 
   276 
   260     ^ self
   277     ^ self
   261         name:newName 
   278 	name:newName
   262         inEnvironment:aNameSpaceOrOwningClass
   279 	inEnvironment:aNameSpaceOrOwningClass
   263         subclassOf:aClass
   280 	subclassOf:aClass
   264         instanceVariableNames:stringOfInstVarNames
   281 	instanceVariableNames:stringOfInstVarNames
   265         variable:variableBoolean
   282 	variable:variableBoolean
   266         words:wordsBoolean
   283 	words:wordsBoolean
   267         pointers:pointersBoolean
   284 	pointers:pointersBoolean
   268         classVariableNames:stringOfClassVarNames
   285 	classVariableNames:stringOfClassVarNames
   269         poolDictionaries:stringOfPoolNames
   286 	poolDictionaries:stringOfPoolNames
   270         category:categoryString
   287 	category:categoryString
   271         comment:commentString
   288 	comment:commentString
   272         changed:changed
   289 	changed:changed
   273         classInstanceVariableNames:nil
   290 	classInstanceVariableNames:nil
   274 
   291 
   275     "Modified: 16.6.1997 / 11:53:58 / cg"
   292     "Modified: 16.6.1997 / 11:53:58 / cg"
   276 !
   293 !
   277 
   294 
   278 name:newName inEnvironment:aNameSpaceOrOwningClass
   295 name:newName inEnvironment:aNameSpaceOrOwningClass
   279              subclassOf:aClass
   296 	     subclassOf:aClass
   280              instanceVariableNames:stringOfInstVarNames
   297 	     instanceVariableNames:stringOfInstVarNames
   281              variable:variableBoolean
   298 	     variable:variableBoolean
   282              words:wordsBoolean
   299 	     words:wordsBoolean
   283              pointers:pointersBoolean
   300 	     pointers:pointersBoolean
   284              classVariableNames:stringOfClassVarNames
   301 	     classVariableNames:stringOfClassVarNames
   285              poolDictionaries:stringOfPoolNames
   302 	     poolDictionaries:stringOfPoolNames
   286              category:categoryString
   303 	     category:categoryString
   287              comment:commentString
   304 	     comment:commentString
   288              changed:changed
   305 	     changed:changed
   289              classInstanceVariableNames:stringOfClassInstVarNamesOrNil
   306 	     classInstanceVariableNames:stringOfClassInstVarNamesOrNil
   290 
   307 
   291     "this is the main workhorse for installing new classes - special care
   308     "this is the main workhorse for installing new classes - special care
   292      has to be taken, when changing an existing classes definition. In this
   309      has to be taken, when changing an existing classes definition. In this
   293      case, some or all of the methods and subclasses methods have to be
   310      case, some or all of the methods and subclasses methods have to be
   294      recompiled.
   311      recompiled.
   295      Also, the old class(es) are still kept (but not accessable as a global),
   312      Also, the old class(es) are still kept (but not accessable as a global),
   296      to allow existing instances some life. 
   313      to allow existing instances some life.
   297      This might change in the future.
   314      This might change in the future.
   298     "
   315     "
   299     |builder|
   316     |builder|
   300 
   317 
   301     builder := self newClassBuilder.
   318     builder := self newClassBuilder.
   302     builder name:newName 
   319     builder name:newName
   303         inEnvironment:aNameSpaceOrOwningClass
   320 	inEnvironment:aNameSpaceOrOwningClass
   304         subclassOf:aClass
   321 	subclassOf:aClass
   305         instanceVariableNames:stringOfInstVarNames
   322 	instanceVariableNames:stringOfInstVarNames
   306         variable:variableBoolean
   323 	variable:variableBoolean
   307         words:wordsBoolean
   324 	words:wordsBoolean
   308         pointers:pointersBoolean
   325 	pointers:pointersBoolean
   309         classVariableNames:stringOfClassVarNames
   326 	classVariableNames:stringOfClassVarNames
   310         poolDictionaries:stringOfPoolNames
   327 	poolDictionaries:stringOfPoolNames
   311         category:categoryString
   328 	category:categoryString
   312         comment:commentString
   329 	comment:commentString
   313         changed:changed
   330 	changed:changed
   314         classInstanceVariableNames:stringOfClassInstVarNamesOrNil.
   331 	classInstanceVariableNames:stringOfClassInstVarNamesOrNil.
   315     ^ builder buildClass.
   332     ^ builder buildClass.
   316 !
   333 !
   317 
   334 
   318 new
   335 new
   319     "create & return a new metaclass (a classes class).
   336     "create & return a new metaclass (a classes class).
   323      (confusing - isn't it ?)"
   340      (confusing - isn't it ?)"
   324 
   341 
   325     |newClass|
   342     |newClass|
   326 
   343 
   327     myClass notNil ifTrue:[
   344     myClass notNil ifTrue:[
   328         self error:'Each metaclass may only have one instance'.
   345 	self error:'Each metaclass may only have one instance'.
   329     ].
   346     ].
   330     newClass := self basicNew.
   347     newClass := self basicNew.
   331     newClass 
   348     newClass
   332         setSuperclass:Object
   349 	setSuperclass:Object
   333         methodDictionary:(MethodDictionary new)
   350 	methodDictionary:(MethodDictionary new)
   334         instSize:0 
   351 	instSize:0
   335         flags:(Behavior flagBehavior).
   352 	flags:(Behavior flagBehavior).
   336     myClass := newClass.
   353     myClass := newClass.
   337     ^ newClass
   354     ^ newClass
   338 
   355 
   339     "Modified: 1.4.1997 / 15:44:50 / stefan"
   356     "Modified: 1.4.1997 / 15:44:50 / stefan"
   340 !
   357 !
   356 
   373 
   357     "metaclasses are not found via Smalltalk allClassesDo:
   374     "metaclasses are not found via Smalltalk allClassesDo:
   358      here, walk over classes and enumerate corresponding metas"
   375      here, walk over classes and enumerate corresponding metas"
   359 
   376 
   360     self soleInstance subclassesDo:[:aSubClass |
   377     self soleInstance subclassesDo:[:aSubClass |
   361         aBlock value:aSubClass class
   378 	aBlock value:aSubClass class
   362     ].
   379     ].
   363 ! !
   380 ! !
   364 
   381 
   365 !Metaclass methodsFor:'fileOut'!
   382 !Metaclass methodsFor:'fileOut'!
   366 
   383 
   367 basicFileOutDefinitionOf:aClass on:aStream withNameSpace:forceNameSpace withPackage:showPackage 
   384 basicFileOutDefinitionOf:aClass on:aStream withNameSpace:forceNameSpace withPackage:showPackage
   368     "append an expression on aStream, which defines myself."
   385     "append an expression on aStream, which defines myself."
   369 
   386 
   370     |syntaxHilighting|
   387     |syntaxHilighting|
   371 
   388 
   372     UserPreferences isNil ifTrue:[
   389     UserPreferences isNil ifTrue:[
   373         syntaxHilighting := false
   390 	syntaxHilighting := false
   374     ] ifFalse:[
   391     ] ifFalse:[
   375         syntaxHilighting := UserPreferences current syntaxColoring.
   392 	syntaxHilighting := UserPreferences current syntaxColoring.
   376     ].
   393     ].
   377     self
   394     self
   378         basicFileOutDefinitionOf:aClass 
   395 	basicFileOutDefinitionOf:aClass
   379         on:aStream 
   396 	on:aStream
   380         withNameSpace:forceNameSpace 
   397 	withNameSpace:forceNameSpace
   381         withPackage:showPackage 
   398 	withPackage:showPackage
   382         syntaxHilighting:syntaxHilighting
   399 	syntaxHilighting:syntaxHilighting
   383 !
   400 !
   384 
   401 
   385 basicFileOutDefinitionOf:aClass on:aStream withNameSpace:forceNameSpace withPackage:showPackage syntaxHilighting:syntaxHilighting
   402 basicFileOutDefinitionOf:aClass on:aStream withNameSpace:forceNameSpace withPackage:showPackage syntaxHilighting:syntaxHilighting
   386     "append an expression on aStream, which defines myself."
   403     "append an expression on aStream, which defines myself."
   387 
   404 
   397     owner := aClass owningClass.
   414     owner := aClass owningClass.
   398     ns := aClass topNameSpace.
   415     ns := aClass topNameSpace.
   399 
   416 
   400     (showPackage and:[owner isNil]) ifTrue:[
   417     (showPackage and:[owner isNil]) ifTrue:[
   401         pkg := aClass getPackage.
   418         pkg := aClass getPackage.
   402         (pkg notNil and:[pkg ~= Project noProjectID]) ifTrue:[
   419         (pkg notNil and:[pkg ~= PackageId noProjectID]) ifTrue:[
   403             aStream nextPutAll:'"{ Package: '''.
   420             aStream nextPutAll:'"{ Package: '''.
   404             aStream nextPutAll:aClass package asString.
   421             aStream nextPutAll:aClass package asString.
   405             aStream nextPutAll:''' }"'; cr; cr.
   422             aStream nextPutAll:''' }"'; cr; cr.
   406         ]
   423         ]
   407     ].
   424     ].
   412     "/ and there is no need to complicate global lookup in stc...
   429     "/ and there is no need to complicate global lookup in stc...
   413 
   430 
   414     owner notNil ifTrue:[
   431     owner notNil ifTrue:[
   415         forceNoNameSpace := ForceNoNameSpaceQuerySignal query == true.
   432         forceNoNameSpace := ForceNoNameSpaceQuerySignal query == true.
   416         forceNoNameSpace ifFalse:[
   433         forceNoNameSpace ifFalse:[
   417             fullName := true.    
   434             fullName := true.
   418         ]
   435         ]
   419     ].
   436     ].
   420 
   437 
   421     fullName ifFalse:[
   438     fullName ifFalse:[
   422         (owner isNil or:[forceNameSpace]) ifTrue:[
   439         (owner isNil or:[forceNameSpace]) ifTrue:[
   447         "/ exists in my owning class,
   464         "/ exists in my owning class,
   448         "/ THEN we MUST add the smalltalk-prefix.
   465         "/ THEN we MUST add the smalltalk-prefix.
   449         "/ (otherwise, we get the private class as superclass when accepting the
   466         "/ (otherwise, we get the private class as superclass when accepting the
   450         "/  next time)
   467         "/  next time)
   451         (owner notNil
   468         (owner notNil
   452         and:[ superclassNamespace == Smalltalk 
   469         and:[ superclassNamespace == Smalltalk
   453         and:[ (owner privateClassesAt:superclass name) notNil ]]) ifTrue:[
   470         and:[ (owner privateClassesAt:superclass name) notNil ]]) ifTrue:[
   454             s := superclass nameWithNameSpacePrefix.
   471             s := superclass nameWithNameSpacePrefix.
   455         ] ifFalse:[
   472         ] ifFalse:[
   456             fullName ifTrue:[
   473             fullName ifTrue:[
   457                 s := superclass name.
   474                 s := superclass name.
   458             ] ifFalse:[
   475             ] ifFalse:[
   459                 (ns == superclassNamespace 
   476                 (ns == superclassNamespace
   460                 and:[superclass owningClass isNil]) ifTrue:[
   477                 and:[superclass owningClass isNil]) ifTrue:[
   461                     "/ superclass is in the same namespace and not private;
   478                     "/ superclass is in the same namespace and not private;
   462                     "/ still prepend namespace prefix for private classes,
   479                     "/ still prepend namespace prefix for private classes,
   463                     "/  to avoid confusing stc, which needs that information.
   480                     "/  to avoid confusing stc, which needs that information.
   464                     "/ LATE note (AUG2002) - no longer; stc was fixed.
   481                     "/ LATE note (AUG2002) - no longer; stc was fixed.
   491                         s := superclassNamespace name , '::' , superNameWithoutNameSpacePrefix
   508                         s := superclassNamespace name , '::' , superNameWithoutNameSpacePrefix
   492                     ] ifFalse:[
   509                     ] ifFalse:[
   493                         "/ no class with that name found in my namespace ...
   510                         "/ no class with that name found in my namespace ...
   494                         "/ if the superclass resides in Smalltalk,
   511                         "/ if the superclass resides in Smalltalk,
   495                         "/ suppress prefix; otherwise, use full prefix.
   512                         "/ suppress prefix; otherwise, use full prefix.
   496                         (superclassNamespace notNil 
   513                         (superclassNamespace notNil
   497                          and:[superclassNamespace ~~ Smalltalk]) ifTrue:[
   514                          and:[superclassNamespace ~~ Smalltalk]) ifTrue:[
   498                             (owner notNil
   515                             (owner notNil
   499                              and:[(topOwner := owner topOwningClass) notNil
   516                              and:[(topOwner := owner topOwningClass) notNil
   500                              and:[superclass topOwningClass notNil
   517                              and:[superclass topOwningClass notNil
   501                              and:[topOwner nameSpace == superclass topOwningClass "owningClass" nameSpace]
   518                              and:[topOwner nameSpace == superclass topOwningClass "owningClass" nameSpace]
   542     boldOff value.
   559     boldOff value.
   543     useStoreString ifTrue:[
   560     useStoreString ifTrue:[
   544         aStream nextPutAll:''''.
   561         aStream nextPutAll:''''.
   545     ].
   562     ].
   546 
   563 
   547     aStream crtab. 
   564     aStream crtab.
   548     aStream nextPutAll:'instanceVariableNames:'''.
   565     aStream nextPutAll:'instanceVariableNames:'''.
   549     boldOn value.
   566     boldOn value.
   550     aClass printInstVarNamesOn:aStream indent:16.
   567     aClass printInstVarNamesOn:aStream indent:16.
   551     boldOff value.
   568     boldOff value.
   552     aStream nextPutAll:''''.
   569     aStream nextPutAll:''''.
   598     "append an expression to define my classInstanceVariables on aStream"
   615     "append an expression to define my classInstanceVariables on aStream"
   599 
   616 
   600     |anySuperClassInstVar|
   617     |anySuperClassInstVar|
   601 
   618 
   602     myClass isLoaded ifFalse:[
   619     myClass isLoaded ifFalse:[
   603         ^ myClass basicFileOutDefinitionOn:aStream withNameSpace:withNameSpace
   620 	^ myClass basicFileOutDefinitionOn:aStream withNameSpace:withNameSpace
   604     ].
   621     ].
   605 
   622 
   606     withNameSpace ifTrue:[
   623     withNameSpace ifTrue:[
   607         myClass name printOn:aStream.
   624 	myClass name printOn:aStream.
   608     ] ifFalse:[
   625     ] ifFalse:[
   609         myClass printClassNameOn:aStream.
   626 	myClass printClassNameOn:aStream.
   610     ].
   627     ].
   611     aStream nextPutAll:' class instanceVariableNames:'''.
   628     aStream nextPutAll:' class instanceVariableNames:'''.
   612     self printInstVarNamesOn:aStream indent:8.
   629     self printInstVarNamesOn:aStream indent:8.
   613     aStream nextPutAll:''''.
   630     aStream nextPutAll:''''.
   614 
   631 
   615     "mhmh - good idea; saw this in SmallDraw sourcecode ..."
   632     "mhmh - good idea; saw this in SmallDraw sourcecode ..."
   616 
   633 
   617     anySuperClassInstVar := false.
   634     anySuperClassInstVar := false.
   618     myClass allSuperclassesDo:[:aSuperClass |
   635     myClass allSuperclassesDo:[:aSuperClass |
   619         aSuperClass class instVarNames do:[:ignored | anySuperClassInstVar := true].
   636 	aSuperClass class instVarNames do:[:ignored | anySuperClassInstVar := true].
   620     ].
   637     ].
   621 
   638 
   622     aStream cr; cr; nextPut:(Character doubleQuote); cr; space.
   639     aStream cr; cr; nextPut:(Character doubleQuote); cr; space.
   623     anySuperClassInstVar ifFalse:[
   640     anySuperClassInstVar ifFalse:[
   624         aStream  
   641 	aStream
   625             nextPutLine:'No other class instance variables are inherited by this class.'.
   642 	    nextPutLine:'No other class instance variables are inherited by this class.'.
   626     ] ifTrue:[
   643     ] ifTrue:[
   627         aStream  
   644 	aStream
   628             nextPutLine:'The following class instance variables are inherited by this class:'.
   645 	    nextPutLine:'The following class instance variables are inherited by this class:'.
   629         aStream cr.
   646 	aStream cr.
   630         myClass allSuperclassesDo:[:aSuperClass |
   647 	myClass allSuperclassesDo:[:aSuperClass |
   631             aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '.
   648 	    aStream tab; nextPutAll:aSuperClass name; nextPutAll:' - '.
   632             aStream nextPutLine:(aSuperClass class instanceVariableString).
   649 	    aStream nextPutLine:(aSuperClass class instanceVariableString).
   633         ].
   650 	].
   634 
   651 
   635     ].
   652     ].
   636     aStream nextPut:(Character doubleQuote); cr.
   653     aStream nextPut:(Character doubleQuote); cr.
   637 
   654 
   638     "Created: / 10.12.1995 / 16:31:25 / cg"
   655     "Created: / 10.12.1995 / 16:31:25 / cg"
   652      If initIt is true, and the class implements a class-initialize method,
   669      If initIt is true, and the class implements a class-initialize method,
   653      append a corresponding doIt expression for initialization.
   670      append a corresponding doIt expression for initialization.
   654      The order by which the fileOut is done is used to put the version string at the end.
   671      The order by which the fileOut is done is used to put the version string at the end.
   655      Thus, if the version string is expanded (by CVS), the characterPositions of methods should not move"
   672      Thus, if the version string is expanded (by CVS), the characterPositions of methods should not move"
   656 
   673 
   657     self language sourceFileWriterClass new
   674     self programmingLanguage sourceFileWriterClass new
   658         fileOut:myClass on:outStreamArg withTimeStamp:stampIt 
   675         fileOut:myClass on:outStreamArg withTimeStamp:stampIt
   659         withInitialize:initIt withDefinition:withDefinition 
   676         withInitialize:initIt withDefinition:withDefinition
   660         methodFilter:methodFilter encoder:encoderOrNil
   677         methodFilter:methodFilter encoder:encoderOrNil
   661 
   678 ! !
   662     "Modified: / 16-08-2009 / 09:52:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
   679 
   663 ! !
   680 !Metaclass methodsFor:'method templates'!
   664 
   681 
       
   682 versionMethodTemplateForSourceCodeManager:aSourceCodeManager
       
   683     ^ aSourceCodeManager versionMethodTemplateForSmalltalk
       
   684 ! !
       
   685 
       
   686 !Metaclass methodsFor:'misc ui support'!
       
   687 
       
   688 iconInBrowserSymbol
       
   689     "can be redefined for a private icon in the browser.
       
   690      The returned symbol must be a selector of the ToolbarIconLibrary."
       
   691 
       
   692     ^ nil
       
   693 ! !
   665 
   694 
   666 !Metaclass methodsFor:'private'!
   695 !Metaclass methodsFor:'private'!
   667 
   696 
   668 setSoleInstance:aClass 
   697 setSoleInstance:aClass
   669     myClass := aClass
   698     myClass := aClass
   670 
   699 
   671     "Created: 12.12.1995 / 13:46:22 / cg"
   700     "Created: 12.12.1995 / 13:46:22 / cg"
   672 ! !
   701 ! !
   673 
   702 
   674 !Metaclass methodsFor:'queries'!
   703 !Metaclass methodsFor:'queries'!
   675 
   704 
   676 category
   705 category
   677     "return my category"
   706     "return my category"
   678 
   707 
   679     myClass isNil ifTrue:[^ nil].    
   708     myClass isNil ifTrue:[^ nil].
   680     ^ myClass category
   709     ^ myClass category
   681 
   710 
   682     "Created: 2.4.1997 / 00:46:11 / stefan"
   711     "Created: 2.4.1997 / 00:46:11 / stefan"
   683 !
   712 !
   684 
   713 
   733      appended."
   762      appended."
   734 
   763 
   735     |nm|
   764     |nm|
   736 
   765 
   737     myClass isNil ifTrue:[
   766     myClass isNil ifTrue:[
   738         ^ #someMetaclass
   767 	^ #someMetaclass
   739     ].
   768     ].
   740 
   769 
   741     (nm := myClass name) isNil ifTrue:[
   770     (nm := myClass name) isNil ifTrue:[
   742         'Metaclass [warning]: no name in my class' errorPrintCR.
   771 	'Metaclass [warning]: no name in my class' errorPrintCR.
   743         ^ #'unnamed class'
   772 	^ #'unnamed class'
   744     ].
   773     ].
   745     ^ nm , ' class'
   774     ^ nm , ' class'
   746 
   775 
   747     "Modified: 10.1.1997 / 17:55:08 / cg"
   776     "Modified: 10.1.1997 / 17:55:08 / cg"
   748     "Modified: 1.4.1997 / 15:53:11 / stefan"
   777     "Modified: 1.4.1997 / 15:53:11 / stefan"
   774     ^ myClass package
   803     ^ myClass package
   775 
   804 
   776     "Created: 15.10.1996 / 19:44:51 / cg"
   805     "Created: 15.10.1996 / 19:44:51 / cg"
   777 !
   806 !
   778 
   807 
   779 soleInstance 
   808 soleInstance
   780     "return my sole class."
   809     "return my sole class."
   781 
   810 
   782     ^ myClass
   811     ^ myClass
   783 !
   812 !
   784 
   813 
   833 
   862 
   834     "Modified: 2.4.1997 / 01:17:04 / stefan"
   863     "Modified: 2.4.1997 / 01:17:04 / stefan"
   835 !
   864 !
   836 
   865 
   837 sourceFileSuffix
   866 sourceFileSuffix
   838     ^ self language sourceFileSuffix
   867     ^ self programmingLanguage sourceFileSuffix
   839 
   868 
   840     "Modified: / 15-08-2009 / 22:46:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
   869     "Modified: / 15-08-2009 / 22:46:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
   841 !
   870 !
   842 
   871 
   843 sourceStream
   872 sourceStream
   857 ! !
   886 ! !
   858 
   887 
   859 !Metaclass class methodsFor:'documentation'!
   888 !Metaclass class methodsFor:'documentation'!
   860 
   889 
   861 version
   890 version
   862     ^ '$Id: Metaclass.st 10465 2009-08-16 17:14:23Z vranyj1 $'
   891     ^ '$Id: Metaclass.st 10473 2009-10-24 15:48:19Z vranyj1 $'
       
   892 !
       
   893 
       
   894 version_CVS
       
   895     ^ '§Header: /cvs/stx/stx/libbasic/Metaclass.st,v 1.207 2009/10/13 11:11:15 stefan Exp §'
   863 ! !
   896 ! !
   864 
   897 
   865 Metaclass initialize!
   898 Metaclass initialize!
       
   899