eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Metaclass':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Metaclass


Inheritance:

   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

Description:


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.

copyright

COPYRIGHT (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.

Class protocol:

Signal constants
o  confirmationQuerySignal
return the query signal which is raised to ask if user
confirmation dialogs should be opened.
If unhandled, they are.

class initialization
o  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
o  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
o  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
o  asPrivate

o  isBuiltInClass
return true if this class is known by the run-time-system.
Here, true is returned for myself, false for subclasses.


Instance protocol:

Compatibility-ST80
o  comment: aString
ignored - sometimes found in ST-80 fileOut files.
Comments are supposed to be defined via class messages.

o  sourceCodeTemplate
ST80 compatibility - return a definition message for myself.
Same as #definition

Compatibility-Squeak
o  instanceVariableString: aString
for compatibility

o  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
o  isLoaded
return true, if the class has been loaded;
redefined in Autoload; see comment there

class instance variables
o  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
o  browserClass
return the browser to use for this class -
this can be redefined in special classes, to get different browsers

o  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):

     Array compilerClass

o  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):

     Array evaluatorClass

o  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):

     Array formatterClass

o  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):

     Array parserClass

o  programmingLanguage
return the programming language in which this class is written

o  realSubclassDefinerClass
Answer an evaluator class appropriate for evaluating definitions of new
subclasses of this class.

o  subclassDefinerClass
Answer an evaluator class appropriate for evaluating definitions of new
subclasses of this class.

o  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
o  postCopy
redefined - a copy may have a new instance

creating classes
o  name: newName inEnvironment: aNameSpaceOrOwningClass subclassOf: aClass instanceVariableNames: stringOfInstVarNames variable: variableBoolean words: wordsBoolean pointers: pointersBoolean classVariableNames: stringOfClassVarNames poolDictionaries: stringOfPoolNames category: categoryString comment: commentString changed: changed

o  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.

o  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 ?)

o  newClassBuilder

enumerating
o  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

o  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.

o  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
o  basicFileOutDefinitionOf: aClass on: aStream withNameSpace: forceNameSpace withPackage: showPackage
append an expression on aStream, which defines myself.

o  basicFileOutDefinitionOf: aClass on: aStream withNameSpace: forceNameSpace withPackage: showPackage syntaxHilighting: syntaxHilighting
append an expression on aStream, which defines myself.

o  fileOutClassInstVarDefinitionOn: aStream withNameSpace: withNameSpace
append an expression to define my classInstanceVariables on aStream

o  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.

o  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
o  versionMethodTemplateForSourceCodeManager: aSourceCodeManager

misc ui support
o  iconInBrowserSymbol
can be redefined for a private icon in the browser.
The returned symbol must be a selector of the ToolbarIconLibrary.

private
o  setSoleInstance: aClass

queries
o  category
return my category

o  comment
return my comment

o  environment
return the namespace I am contained in; ST-80 compatible name

o  getPackage
return my package-id

o  hasExtensions
return true if I have extensions

o  hasExtensionsFrom: aPackageID
return true if I have extensions from a package

o  isBuiltInClass
return true if this class is known by the run-time-system.
Here, true is returned for myself, false for subclasses.

o  isMeta
return true, if the receiver is some kind of metaclass;
true is returned here. Redefines isMeta in Object

o  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.

o  name
return my name - that is the name of my sole class, with ' class'
appended.

o  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)

o  owningClass
return nil here - regular metaclasses are never private

o  package
return my package-id

o  projectDefinitionClass
return the project definition of the classes' package.
Eg. for Array, this would return the stx_libbasic project definition class.

o  soleInstance
return my sole class.

o  subclasses
ask my non-meta for subclasses

Usage example(s):

     Integer class subclasses

o  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.

o  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

o  topOwningClass
return nil here - regular metaclasses are never private

source management
o  binaryRevision
Object binaryRevision
Object class binaryRevision

o  binaryRevisionString
Object binaryRevisionString
Object class binaryRevisionString

o  sourceCodeManagerFromBinaryRevision

o  sourceFileSuffix
Answers a default suffix for source files, i.e.
'st' for Smalltalk, 'js' for JavaScript or 'rb' for Ruby', etc.

o  sourceStream
return the classes source stream

o  sourceStreamFor: sourceFileName
return the sourceStream for a sourceFileName



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 22 Dec 2024 01:17:45 GMT