|
Class: Metaclass
Object
|
+--Behavior
|
+--ClassDescription
|
+--Metaclass
|
+--AutoloadMetaclass
|
+--JavaScriptMetaclass
|
+--PrivateMetaclass
|
+--SmalltalkShareClient::RemoteMetaclass
- Package:
- stx:libbasic
- Category:
- Kernel-Classes
- Version:
- rev:
1.241
date: 2023/11/22 13:02:19
- user: cg
- file: Metaclass.st directory: libbasic
- module: stx stc-classLibrary: libbasic
every classes class is a subclass of Metaclass.
(i.e. every class is the sole instance of its Metaclass)
Metaclass provides support for creating new (sub)classes and/or
changing the definition of an already existing class.
copyrightCOPYRIGHT (c) 1988 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
Signal constants
-
confirmationQuerySignal
-
return the query signal which is raised to ask if user
confirmation dialogs should be opened.
If unhandled, they are.
class initialization
-
initialize
-
(comment from inherited method)
the classvariable 'UpdatingChanges' controls if changes are put
into the changes-file; normally this variable is set to true, but
(for example) during fileIn or when changes are applied, it is set to false
to avoid putting too much junk into the changes-file.
creating metaclasses
-
new
-
creating a new metaclass - have to set the new classes
flags correctly to have it behave like a metaclass ...
Not for normal applications - creating new metaclasses is a very
tricky thing; should be left to the gurus ;-)
Usage example(s):
Metaclass new <- new metaclass
Metaclass new new <- new class
Metaclass new new new <- new instance
|
method templates
-
classTemplateFor: aSuperClass in: categoryString asNamespace: asNameSpace private: isPrivate
-
returning nil here, will let the browser generate a template.
However, special metaclasses (other languages)
may redefine this
queries
-
asPrivate
-
-
isBuiltInClass
-
return true if this class is known by the run-time-system.
Here, true is returned for myself, false for subclasses.
Compatibility-ST80
-
comment: aString
-
ignored - sometimes found in ST-80 fileOut files.
Comments are supposed to be defined via class messages.
-
sourceCodeTemplate
-
ST80 compatibility - return a definition message for myself.
Same as #definition
Compatibility-Squeak
-
instanceVariableString: aString
-
for compatibility
-
isTrait
( an extension from the stx:libcompat package )
-
(comment from inherited method)
Return true if the receiver is a trait.
Note: Do not override in any class except TraitBehavior.
autoload check
-
isLoaded
-
return true, if the class has been loaded;
redefined in Autoload; see comment there
class instance variables
-
instanceVariableNames: aString
-
changing / adding class-inst vars -
this actually creates a new metaclass and class, leaving the original
class hanging around as obsolete classes.
This may also be true for all subclasses, if class instance variables are added/removed in a superclass.
Existing instances (i.e. insts of the class) are migrated to become instances of the new class(es).
However, if the old class is referenced somewhere (in a collection),
that reference will still point to the old, now obsolete class.
Time will show, if that is a problem and should be fixed.
compiler interface
-
browserClass
-
return the browser to use for this class -
this can be redefined in special classes, to get different browsers
-
compilerClass
-
return the compiler to use for this class -
this can be redefined in special classes, to compile classes with
JavaScript, Ruby, Lisp, Prolog, ASN1, Basic :-) or whatever syntax.
Usage example(s):
-
evaluatorClass
-
return the compiler to use for expression evaluation for this class -
this can be redefined in special classes, to evaluate expressions with
JavaScript, Ruby, Lisp, Prolog, ASN1, Basic :-) or whatever syntax.
Usage example(s):
-
formatterClass
-
return a class to use for formatting (prettyPrinting) this class -
this can be redefined in special classes, to format classes with
JavaScript, Ruby, Lisp, Prolog, ASN1, Basic :-) or whatever syntax.
Usage example(s):
-
parserClass
-
return the parser to use for parsing this class -
this can be redefined in special classes, to parse classes with
JavaScript, Ruby, Lisp, Prolog, ASN1, Basic :-) or whatever syntax.
Usage example(s):
-
programmingLanguage
-
return the programming language in which this class is written
-
realSubclassDefinerClass
-
Answer an evaluator class appropriate for evaluating definitions of new
subclasses of this class.
-
subclassDefinerClass
-
Answer an evaluator class appropriate for evaluating definitions of new
subclasses of this class.
-
syntaxHighlighterClass
-
return the class to use for syntaxHighlighting (prettyPrinting) this class -
this can be redefined in special classes, to highlight classes with
JavaScript, Ruby, Lisp, Prolog, ASN1, Basic :-) or whatever syntax.
Usage example(s):
Array syntaxHighlighterClass
|
copying-private
-
postCopy
-
redefined - a copy may have a new instance
creating classes
-
name: newName inEnvironment: aNameSpaceOrOwningClass subclassOf: aClass instanceVariableNames: stringOfInstVarNames variable: variableBoolean words: wordsBoolean pointers: pointersBoolean classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryString comment: commentString changed: changed
-
-
name: newName inEnvironment: aNameSpaceOrOwningClass subclassOf: aClass instanceVariableNames: stringOfInstVarNames variable: variableBoolean words: wordsBoolean pointers: pointersBoolean classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryString comment: commentString changed: changed classInstanceVariableNames: stringOfClassInstVarNamesOrNil
-
this is the main workhorse for installing new classes - special care
has to be taken, when changing an existing classes definition. In this
case, some or all of the methods and subclass-methods have to be
recompiled.
Also, the old class(es) are still kept (but not accessible as a global),
to allow existing instances some life.
This might change in the future.
-
new
-
create & return a new metaclass (a classes class).
Since metaclasses only have one instance (the class),
complain if there is already one.
You get a new class by sending #new to the returned metaclass
(confusing - isn't it ?)
-
newClassBuilder
-
enumerating
-
instAndClassMethodsDo: aOneArgBlock
-
evaluate the argument, aBlock for all methods of mySelf and my non-metaclass
See methodsDo: for a method which only enumerates methods in me, the metaclass
-
instAndClassSelectorsAndMethodsDo: aTwoArgBlock
-
(comment from inherited method)
evaluate the argument, aBlock for all selectors of mySelf and my metaclass,
passing the corresponding method as second argument.
This enumerates methods both here and in my corresponding nonMeta/meta class.
See selectorsAndMethodsDo: for a method which only enumerates methods here.
-
subclassesDo: aBlock
-
evaluate the argument, aBlock for all immediate subclasses.
This will only enumerate globally known classes - for anonymous
behaviors, you have to walk over all instances of Behavior.
fileOut
-
basicFileOutDefinitionOf: aClass on: aStream withNameSpace: forceNameSpace withPackage: showPackage
-
append an expression on aStream, which defines myself.
-
basicFileOutDefinitionOf: aClass on: aStream withNameSpace: forceNameSpace withPackage: showPackage syntaxHilighting: syntaxHilighting
-
append an expression on aStream, which defines myself.
-
fileOutClassInstVarDefinitionOn: aStream withNameSpace: withNameSpace
-
append an expression to define my classInstanceVariables on aStream
-
fileOutDefinitionOn: aStream
-
(comment from inherited method)
dummy fileOut defined here.
This allows different Behavior-like objects
(alien classes) to be handled by the browser as well.
-
fileOutOn: outStreamArg withTimeStamp: stampIt withInitialize: initIt withDefinition: withDefinition methodFilter: methodFilter encoder: encoderOrNil
-
file out my definition and all methods onto aStream.
If stampIt is true, a timeStamp comment is prepended.
If initIt is true, and the class implements a class-initialize method,
append a corresponding doIt expression for initialization.
The order by which the fileOut is done is used to put the version string at the end.
Thus, if the version string is expanded (by CVS), the characterPositions of methods should not move
method templates
-
versionMethodTemplateForSourceCodeManager: aSourceCodeManager
-
misc ui support
-
iconInBrowserSymbol
-
can be redefined for a private icon in the browser.
The returned symbol must be a selector of the ToolbarIconLibrary.
private
-
setSoleInstance: aClass
-
queries
-
category
-
return my category
-
comment
-
return my comment
-
environment
-
return the namespace I am contained in; ST-80 compatible name
-
getPackage
-
return my package-id
-
hasExtensions
-
return true if I have extensions
-
hasExtensionsFrom: aPackageID
-
return true if I have extensions from a package
-
isBuiltInClass
-
return true if this class is known by the run-time-system.
Here, true is returned for myself, false for subclasses.
-
isMeta
-
return true, if the receiver is some kind of metaclass;
true is returned here. Redefines isMeta in Object
-
logFacility
-
the 'log facility';
this is used by the Logger both as a prefix to the log message,
and maybe (later) used to filter and/or control per-facility log thresholds.
-
name
-
return my name - that is the name of my sole class, with ' class'
appended.
-
nameSpace
-
return the nameSpace I am contained in.
Due to the implementation of nameSpaces (as classVariables),
a class can only be contained in one nameSpace (which is the desired)
-
owningClass
-
return nil here - regular metaclasses are never private
-
package
-
return my package-id
-
projectDefinitionClass
-
return the project definition of the classes' package.
Eg. for Array, this would return the stx_libbasic project definition class.
-
soleInstance
-
return my sole class.
-
subclasses
-
ask my non-meta for subclasses
Usage example(s):
-
theMetaclass
-
return the metaClass of the class-meta pair.
Here, return myself, because I am the metaclass.
Also implemented in my class, which also returns me.
-
theNonMetaclass
-
return the nonMetaClass of the class-meta pair.
Here, return my class object, because I am the metaclass.
Also implemented in my class, which returns itself.
Sigh: ST/X naming; Squeak calls this theNonMetaClass
-
topOwningClass
-
return nil here - regular metaclasses are never private
source management
-
binaryRevision
-
Object binaryRevision
Object class binaryRevision
-
binaryRevisionString
-
Object binaryRevisionString
Object class binaryRevisionString
-
sourceCodeManagerFromBinaryRevision
-
-
sourceFileSuffix
-
Answers a default suffix for source files, i.e.
'st' for Smalltalk, 'js' for JavaScript or 'rb' for Ruby', etc.
-
sourceStream
-
return the classes source stream
-
sourceStreamFor: sourceFileName
-
return the sourceStream for a sourceFileName
|