eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Metaclass':

Home

everywhere
www.exept.de
for:
[back]

Class: Metaclass


Inheritance:

   Object
   |
   +--Behavior
      |
      +--ClassDescription
         |
         +--Metaclass
            |
            +--AutoloadMetaclass
            |
            +--JavaScriptMetaclass
            |
            +--PrivateMetaclass
            |
            +--SmalltalkShareClient::RemoteMetaclass

Package:
stx:libbasic
Category:
Kernel-Classes
Version:
rev: 1.208 date: 2010/04/03 10:46:40
user: cg
file: Metaclass.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

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.


Related information:

    Behavior
    ClassDescription
    Class

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

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

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

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
classes around as obsolete classes. This may also be true for all subclasses,
if class instance variables are added/removed.
Existing instances continue to be defined by their original classes.

Time will show, if this is an acceptable behavior or if we should migrate
instances to become insts. of the new classes.

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
Lisp, Prolog, ASN1, Basic :-) or whatever syntax.

o  evaluatorClass
return the compiler to use for expression evaluation for this class -
this can be redefined in special classes, to evaluate expressions with
Lisp, Prolog, ASN1, Basic :-) or whatever syntax.

o  formatterClass
return the parser to use for formatting (prettyPrinting) this class -
this can be redefined in special classes, to format classes with
Lisp, Prolog, ASN1, Basic :-) or whatever syntax.

o  parserClass
return the parser to use for parsing this class -
this can be redefined in special classes, to parse classes with
Lisp, Prolog, ASN1, Basic :-) or whatever syntax.

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

o  realSubclassDefinerClass

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
Lisp, Prolog, ASN1, Basic :-) or whatever syntax.

copying
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 subclasses methods have to be
recompiled.
Also, the old class(es) are still kept (but not accessable 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  instAndClassSelectorsAndMethodsDo: aTwoArgBlock

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

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  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  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  soleInstance
return my sole class.

o  subclasses
ask my non-meta for 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.

o  topOwningClass
return nil here - regular metaclasses are never private

source management
o  binaryRevision

o  sourceFileSuffix

o  sourceStream
return the classes source stream

o  sourceStreamFor: sourceFileName
return the sourceStream for a sourceFileName



ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 20:03:31 GMT