|
Class: Behavior
Object
|
+--Behavior
|
+--ClassDescription
|
+--Structure
- Package:
- stx:libbasic
- Category:
- Kernel-Classes
- Version:
- rev:
1.486
date: 2024/03/27 12:09:25
- user: cg
- file: Behavior.st directory: libbasic
- module: stx stc-classLibrary: libbasic
Every class in the system inherits from Behavior (via Class, ClassDescription);
so here is where most of the class messages end up being implemented.
(to answer a FAQ: 'Point basicNew' will be done here :-)
Beginners should keep in mind, that all classes are instances (of subclasses)
of Behavior, therefore you will find the above mentioned 'basicNew:' method
under the 'instance'-methods of Behavior - NOT under the class methods
('Behavior new' will create and return a new class, while sending 'new' to
any instance of Behavior (i.e. any class) will return an instance of that class).
Behavior provides minimum support for all class-like objects, which define behavior
of other objects. Additional stuff (meta info) is found in ClassDescription and Class.
Behavior provides all mechanisms needed to create instances (on the class side),
and send messages to them.
However, Behavior does not provide the (symbolic) information needed to compile methods
for a class or to get useful information in inspectors or browsers.
For experts:
Since instances of Behavior provide all that is needed to interact with the VM's
message dispatch mechanism, these can be used as 'light weight' classes.
I.e. it is possible, to generate completely anonymous classes (and instances thereof)
on the fly - 'Behavior new new' is such a thingy.
The selectors and methods are organized in a MethodDictionary (which is not a true
dictionary, but an Array with alternating selector/method entries).
This avoids the need for knowledge about Dictionaries in the runtime library (VM)
(lookup and search in these is seldom anyway, so the added benefit from using a
hashed dictionary is almost void).
[Instance variables:]
superclass <Class> the classes superclass
methodDictionary <MethodDictionary> inst-selectors and methods
instSize <SmallInteger> the number of instance variables
flags <SmallInteger> special flag bits coded in a number
not for application use
flag bits (see stc.h):
NOTICE: layout known by compiler and runtime system; be careful when changing
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.
virtualMachineRelationshipExpert info follows:
--------------------
NOTICE:
the stuff described below may not be available on other
Smalltalk implementations; be aware that these error mechanisms
are ST/X specials and applications using these (tricks) may
not be portable to other systems.
WARNING:
do not try the examples below on (some) other smalltalk systems;
it has been reported, that some crash badly when doing this .... ;-)
Instances of Behavior and subclasses (i.e. in sloppy words: classes)
play a special role w.r.t. the VM. Only objects whose class-slot is marked
as being behaviorLike (in the flag-instvar) are considered to be classLike
and a message lookup will be done for it in the well known way.
Thus, if an object has a class for which its class does NOT have
this flag bit set, the VM will trigger an error on a message send.
Why is this so:
---------------
the above lets every object play the role of a class,
which has been flagged as behaviorLike in its class's flag.
Thus, you can create arbitrary new classLike objects and have the VM
play with them.
This may offer the flexibility to create a totally different object scheme
on top of ST/X (for example: Self like objects) where any object can play
a classRole for another object or even for itself.
[A concrete application of this is found in the Structure class,
which creates objects which are their own class !
This may look to be of theoretical value at first sight,
however, such a construct saves memory, by not requiring an extra
class object per Structure object.]
Be aware, that the VM trusts the isBehaviorLike flag - IF it is set for some
object, the VM EXPECTS the object selector and methodDictionaries to be found
at the instance positions as defined here.
(i.e. instanceVariables with contents and semantic corresponding to
superclass
flags
methodDictionary
must be present and have the same instVar-index as here).
The VM (and the system) may crash badly, if this is not the case.
Since every class in the system derives from Behavior, the flag setting
(and instance variable layout) is correct for all 'normal' classes.
If you experiment by creating new behaviorLike objects, please take
care of this flag. If you want to use the VM's lookup function, the
instVars 'superclass' and 'methodDictionary' are required
and have to be at the same instVar index.
(we suggest, you subclass Behavior, to make certain)
Vice versa, defining 'dumb classes', which have the behaviorLike bit turned
off may be useful as well; if a message is sent to an instance of such
a thingy, the VM performs a recovery sequence, which is much like the
#doesNotUnderstand: mechanism - however, since the instance is no good
receiver of such a message, a #cannotSendMessage:to: is now sent to the
class (which is not a real class), passing the original message (selector
and arguments) along with the original receiver.
The default behavior for this message is to raise an internalError signal -
however, you may redefine this in your 'dum class' for recovery.
One possible use of this is to provide new message send algorithms - the
class may lookup a method and invoke it directly, via the #valueWithReceiver:
interface.
All of the above is pure expert stuff
- You do not have to care about the above details if you are a 'normal'
ST-programmer, though (and even most of those will never use these features).
Examples (only of theoretical interest):
----------------------------------------
take away the behaviorLike-flag from a class.
-> The instances will not understand any messages, since the VM will
not recognize its class as being a class ...
|newMeta notRecognizedAsClass someInstance|
newMeta := Metaclass new.
newMeta flags:0.
notRecognizedAsClass := newMeta new.
someInstance := notRecognizedAsClass new.
someInstance perform:#isNil
Of course, this is an exception which can be handled ...:
Example:
|newMeta notRecognizedAsClass someInstance|
newMeta := Metaclass new.
newMeta flags:0.
notRecognizedAsClass := newMeta new.
someInstance := notRecognizedAsClass new.
Object errorSignal handle:[:ex |
ex return
] do:[
someInstance perform:#isNil
]
likewise, a doesNotUnderstand-notUnderstood can be handled:
Example:
|newMeta funnyClass someInstance|
newMeta := Metaclass new.
funnyClass := newMeta new.
funnyClass setSuperclass:nil.
someInstance := funnyClass new.
Object errorSignal handle:[:ex |
ex return
] do:[
someInstance perform:#isNil
]
more examples, which try to trick the VM ;-):
badly playing around with a classes internals ...
|newClass someInstance|
newClass := Class new.
newClass setSuperclass:nil.
someInstance := newClass new.
someInstance inspect
|newClass someInstance|
newClass := Class new.
newClass setSuperclass:newClass.
someInstance := newClass new.
someInstance inspect
|newClass someInstance|
newClass := Class new.
newClass setSuperclass:1.
someInstance := newClass new.
someInstance inspect
Example:
creating totally anonymous classes:
|newClass someInstance|
newClass := Class new.
someInstance := newClass new.
someInstance inspect
Example:
creating totally anonymous metaclasses:
|newMeta newClass someInstance|
newMeta := Metaclass new.
newClass := newMeta new.
someInstance := newClass new.
someInstance inspect
PS: if you experiment with new behaviorLike objects, you may want
to turn off the VM's debugPrintouts
with:
'Smalltalk debugPrinting:false'
and:
'Smalltalk infoPrinting:false'
Meta-Object-Protocol support:
-----------------------------
the above tricks do not affect the inline caches, and are therefore somewhat slow.
Another hook is the lookupObject which, if non-nil, is consulted to do the lookup
instead of the hardwired VM lookup algorithm, and provide a method as return value.
This method (if non-nil) will be put into the inline-and polymorph caches for speedy
call the next time. If non-nil, the lookup object is sent the:
lookupMethodForSelector:aSelector
directedTo:searchClass
for:aReceiver
withArguments:argArrayOrNil
from:sendingContext
message.
'searchClass' is the object class or any of its superclasses (for directed/super sends).
You can return any arbitrary method there - for example to implement multiple inheritance,
selector namespace tricks or multi-dispatch on argument types (double dispatch for a method).
Be aware, that the returned method is cached, and the lookup is not consulted again for the
same receiver/callsite combination. So the returned method should check if it's ok to be called
again (maybe, a synthetic method is generated and returned).
creating new classes
-
new
-
creates and return a new behavior (which is like a class,
but without the symbolic & name information).
Not for normal applications.
Sending the returned behavior the #new message gives you
an instance if it.
Notice: the returned class is given a superclass of Object;
this allows for its new instances to be inspected and the like.
Usage example(s):
Behavior new <- a new behavior
Behavior new new <- an instance of it
ClassDescription new <- a new classDescription
ClassDescription new new <- an instance of it
Class new <- a new class
Class new new <- an instance of it
Metaclass new <- a new metaclass
Metaclass new new <- an instance (i.e. a class) of it
Metaclass new new new <- an instance of this new class
|
flag bit constants
-
flagAlien
-
Return the flag code for Alien objects for Translucent Object implementation
-
flagBehavior
-
return the flag code which marks Behavior-like instances.
Inline C-code and the VM check this single bit in the flag value when
checking for behaviors.
-
flagBlock
-
return the flag code which marks Block-like instances.
The VM and compiled code check for this bit in the flag
value when checking for blocks to be evaluated from bytecode
or calling the block's code immediately.
-
flagBlockContext
-
return the flag code which marks BlockContext-like instances.
The VM checks this single bit in the flag value when
checking for blockContexts.
-
flagBytes
-
return the flag code for byte-valued indexed instances.
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for byte valued
variable instances.
Usage example(s):
-
flagContext
-
return the flag code which marks Context-like instances.
The VM checks this single bit in the flag value when
checking for contexts.
-
flagDoubles
-
return the flag code for double-valued indexed instances (i.e. 8-byte reals).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for double valued
variable instances.
Usage example(s):
Behavior flagDoubles
(ByteArray flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles)
(DoubleArray flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles)
(Object flags bitAnd:(Behavior maskIndexType)) == (Behavior flagDoubles)
|
-
flagExternalBytes
-
return the flag code which marks ExternalBytes-like instances.
Inline C-code and the VM check this single bit in the flag value when
checking for an externalBytes-like objet.
-
flagFloat
-
return the flag code which marks Float-like instances.
Inline C-code and the VM check this single bit in the flag value when
checking for a float.
-
flagFloats
-
return the flag code for float-valued indexed instances (i.e. 4-byte reals).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for double valued
variable instances.
Usage example(s):
-
flagForSymbolic: aSymbol
-
return the flag code for indexed instances with aSymbolic type.
The argument may be one of
#float, #double,
#word, #signedWord,
#long, #signedLong
#longLong, #signedLongLong,
#byte
#weakObjects
For VW compatibility, also accept:
#objects, #bytes, #weak.
-
flagJavaArray
-
return the flag code which marks Java array-like instances.
The VM checks this single bit in the flag value when
checking for a java arrays.
-
flagJavaClass
-
return the flag code which marks JavaClass-like instances.
The VM checks this single bit in the flag value when
checking for a javaClass.
-
flagJavaMethod
-
return the flag code which marks JavaMethod-like instances.
Inline C-code and the VM check this single bit in the flag value when
checking for a method.
-
flagLongLongs
-
return the flag code for longlong-valued indexed instances (i.e. 8-byte).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for
unsigned long valued variable instances.
Usage example(s):
-
flagLongs
-
return the flag code for long-valued indexed instances (i.e. 4-byte).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for
unsigned long valued variable instances.
Usage example(s):
-
flagMetaMethod
-
return the flag code which marks MetaMethod-like instances.
Inline C-code and the VM check this single bit in the flag value when
about to evaluate a method.
-
flagMethod
-
return the flag code which marks Method-like instances.
Inline C-code and the VM check this single bit in the flag value when
checking for a method.
-
flagNonObjectInst
-
return the flag code which marks instances which have a
non-object instance variable (in slot 1).
(these are ignored by the garbage collector)
-
flagNotIndexed
-
return the flag code for non-indexed instances.
You have to mask the flag value with indexMask when comparing
it with flagNotIndexed.
-
flagPointers
-
return the flag code for pointer indexed instances (i.e. Array of object).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for
pointer variable instances.
Usage example(s):
-
flagRegular
-
return the flag code which marks regular instances.
-
flagSignedLongLongs
-
return the flag code for signed longlong-valued indexed instances (i.e. 8-byte).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for
signed long valued variable instances.
Usage example(s):
Behavior flagSignedLongLongs
|
-
flagSignedLongs
-
return the flag code for signed long-valued indexed instances (i.e. 4-byte).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for
signed long valued variable instances.
Usage example(s):
-
flagSignedWords
-
return the flag code for signed word-valued indexed instances (i.e. 2-byte).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for
signed word valued variable instances.
Usage example(s):
-
flagSymbol
-
return the flag code which marks Symbol-like instances.
Inline C-code and the VM check this single bit in the flag value when
checking for symbols.
-
flagVarArgBlock
-
return the flag code which marks varArg Block-like instances
with respect to byteCode interpretation & code calling.
-
flagWeak
-
return the flag code for weak-object-pointer indexed instances.
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for
weak pointer variable instances.
Usage example(s):
-
flagWeakPointers
-
return the flag code for weak pointer indexed instances (i.e. WeakArray).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for weak pointers.
-
flagWords
-
return the flag code for word-valued indexed instances (i.e. 2-byte unsigned ints).
The VM masks the flag value with the indexMask (maskIndexType)
and compares it to this flag value, when checking for
unsigned word valued variable instances.
Usage example(s):
-
maskIndexType
-
return a mask to extract all index-type bits
helpers
-
classesSortedByLoadOrder2: aCollectionOfClasses
-
return a copy of the given collection of classes, which is sorted
by inheritance and superclass-of-any-private class.
This is the optimal order for loading, and the required order for compilation.
This is an alternate algorithm showing cycles
Usage example(s):
Class classesSortedByLoadOrder:stx_libbasic compiled_classes_common
Class classesSortedByLoadOrder2:stx_libbasic compiled_classes_common
Class classesSortedByLoadOrder:stx_libjava compiled_classes_common
Class classesSortedByLoadOrder2:stx_libjava compiled_classes_common
|
-
classesSortedByLoadOrder: someClasses
-
return a copy of the given collection of classes, which is sorted
by inheritance and superclass-of-any-private class.
This is the optimal order for loading, and the required order for compilation
Usage example(s):
Class classesSortedByLoadOrder:(Smalltalk allClassesInPackage:'stx:libbasic')
Class classesSortedByLoadOrder:(Smalltalk allClassesInPackage:'stx:libbasic3')
Class classesSortedByLoadOrder:(Smalltalk allClassesInPackage:'stx:libwidg')
Class classesSortedByLoadOrder:(Smalltalk allClassesInPackage:'stx:libjava')
|
-
commonSuperclassOf: listOfClassesOrClassNames
-
given a list of classes (or names), return the common superclass.
A helper for the browser, some dialogs and some refactorings.
Returns Object, if there is no common superclass
(or nil, if any inherits from nil) .
Usage example(s):
Class commonSuperclassOf:#(Array OrderedCollection Set)
Class commonSuperclassOf:#(Character Number Point)
Class commonSuperclassOf:#(Character View)
|
misc
-
autoload
-
for compatibility with autoloaded classes - dummy here
queries
-
definitionSelectorFirstParts
-
return a collection of partial class-definition selectors
-
definitionSelectors
-
return a collection class-definition selectors
-
isBuiltInClass
-
return true if this class is known by the run-time-system.
Here, true is returned for myself, false for subclasses.
-
supportsMethodCategories
-
return true, if my methods are categorized.
This is a hook for the browser to allow alien classes
to be handled (actually, this is not yet used).
Compatibility-Dolphin
-
allSubinstances
-
Compatibility method - do not use in new code.
Same as allSubInstances; added for Dolphin compatibility
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
fromJSON: aString
( an extension from the stx:goodies/communication package )
-
reconstruct an instance of myself from the json-store string.
The string is typically the result of toJSON.
Notice, that not all objects are JSON encodable
-
guid: aUUID
-
Compatibility method - do not use in new code.
An ignored dummy; for Dolphin compatibility.
-
lookupMethod: selector
-
Compatibility method - do not use in new code.
Return the method for given selector aSelector or nil.
Only methods in the receiver - not in the superclass chain are returned.
For dolphin compatibility.
TODO: fixme if I am wrong, and dolphin does a full lookup here. If that is the case,
change to use lookupMethodFor:aSelector below.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
Compatibility-Squeak
-
allSelectorsInProtocol: aProtocol
( an extension from the stx:libcompat package )
-
Return all selectors defined in this class that take this number of arguments.
Usage example(s):
SmallInteger allSelectorsInProtocol:#testing
Behavior allSelectorsInProtocol:'Compatibility-Squeak'
|
-
classSide
-
alias for theMetaclass - return the metaclass
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
defaultNameStemForInstances
( an extension from the stx:libcompat package )
-
Answer a basis for names of default instances of the receiver
-
instanceSide
-
alias for theNonMetaclass - return the non-metaclass
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
kindOfSubclass
( an extension from the stx:libcompat package )
-
Answer a String that is the keyword that describes the receiver's kind
of subclass, either a regular subclass, a variableSubclass, a
variableByteSubclass, a variableWordSubclass, or a weakSubclass.
Usage example(s):
Array kindOfSubclass
WeakArray kindOfSubclass
|
-
lookupSelector: aSelector
-
return the method for a selector - Squeak compatibility
-
selectorsWithArgs: numberOfArgs
-
Return all selectors defined in this class that take this number of arguments.
Usage example(s):
SmallInteger selectorsWithArgs:0
SmallInteger selectorsWithArgs:1
SmallInteger selectorsWithArgs:2
SmallInteger selectorsWithArgs:3
SmallInteger selectorsWithArgs:4
|
-
theMetaClass
-
alias for theMetaclass (Squeak) - return the class.
Sigh: in ST/X it is called theMetaclass; please use that.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
theNonMetaClass
-
alias for theNonMetaclass (Squeak) - return the class.
sigh: in ST/X it is called theNonMetaclass; please use that.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
Compatibility-VW
-
>> aSelector
-
return the method stored under the given selector; nil if there is none
Usage example(s):
self compiledMethodAt:#compiledMethodAt:
self >> #compiledMethodAt:
|
-
findSelector: aSelector
-
return an array filled with class and method, which would be executed if aSelector was sent to
an instance of the receiver.
I.e. the selector arrays of the receiver
and all of its superclasses are searched for aSelector.
Return nil if instances do not understand aSelector
Usage example(s):
-
fixedFieldsMask
-
Mask on the format word to indicate the number of fixed fields in instances
of a behavior. If this is non-zero, the behavior must be pointer-type
-
format
-
Answer an Integer that encodes the kinds and numbers of
variables of instances of the receiver.
See instSize method for reference to the fixedFieldsMask bit mask of the format.
See isVariable method for reference to the indexableMask bit mask of the format.
See isBits method for reference to the pointersMask bit mask of the format.
All other bits of the format are unused and should be 0.
-
getMethodDictionary
-
ST 80 compatibility: return the receiver's method dictionary.
-
instVarIndexFor: aVariableName ifAbsent: exceptionValue
-
alias for #instVarOffsetOf: for VW compatibility.
Usage example(s):
Point instVarIndexFor:#x => 1
Point instVarIndexFor:#z => nil
Point instVarIndexFor:#x ifAbsent:[123] => 1
Point instVarIndexFor:#z ifAbsent:[123] => 123
|
-
instanceBehavior
-
Answer the instance behavior of the receiver.
This is the receiver for non metaclasses.
Metaclass overrides this to answer a Metaclass's sole instance.
Same as #theNonMetaclass - for VW compatibility
Javascript support
-
js_new
( an extension from the stx:libjavascript package )
-
redefinable JS-new
-
js_new: size
( an extension from the stx:libjavascript package )
-
redefinable JS-new:
-
js_new: sizeDim1 new: sizeDim2
( an extension from the stx:libjavascript package )
-
redefinable JS-new:
-
js_new: sizeDim1 new: sizeDim2 new: sizeDim3
( an extension from the stx:libjavascript package )
-
redefinable JS-new:
RefactoringBrowser
-
parseTreeFor: aSelector
( an extension from the stx:goodies/refactoryBrowser/parser package )
-
parse a method given a selector - return a parseTree
Usage example(s):
Behavior parseTreeFor:#'parseTreeFor:'
|
-
realClass
-
for compatibility with RBAbstractClass
accessing
-
addSelector: newSelector withMethod: newMethod
-
add the method given by 2nd argument under the selector given by
1st argument to the methodDictionary. Flushes all caches.
-
basicAddSelector: newSelector withMethod: newMethod
-
add the method given by 2nd argument under the selector given by
1st argument to the methodDictionary. Flushes all caches.
-
basicRemoveSelector: aSelector
-
remove the selector, aSelector and its associated method
from the methodDictionary
-
containingNameSpace
-
return the namespace which contains me.
Defined here as a dummy; actually only real classes should ever be put into a namespace.
-
flags
-
return the receiver's flag bits.
see flagXXX methods on my class side for details
-
instSize
-
return the number of instance variables of the receiver.
This includes all superclass instance variables.
-
instVarIndexFor: aVariableName
-
return the index (as used in instVarAt:/instVarAt:put:) of a named instance.
Returns the variable's index (1..instSize) for valid variable names,
nil for illegal names.
Usage example(s):
Point instVarIndexFor:'x'
View instVarIndexFor:'paint'
Button instVarIndexFor:'logo'
|
-
instVarOffsetOf: aVariableName
-
return the index (as used in instVarAt:/instVarAt:put:) of a named instance
variable (1..instSize) for valid variable names, nil for illegal names.
This was the original ST/X's method for this functionality;
senders have been changed to use instVarIndexFor:.
Kept for backward compatibility;
please use instVarIndexFor: for VW and Squeak compatibility
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
lookupObject
-
return the lookupObject (Jan's MetaObjectProtocol support) or nil.
If non-nil, no lookup is performed by the VM, instead the VM asks the lookupObject
to provide a method for message sends.
Usage example(s):
to make sure that subclasses get a lookupObject, if they need it.
|
Usage example(s):
lookupObject notNil ifTrue:[^ lookupObject].
|
-
lookupObject: anObject
-
check if it is valid; the reason is that the VM gets into bad trouble,
-
methodDictionary
-
return the receiver's method dictionary.
-
methodDictionary: dict
-
set the receiver's method dictionary and flush inline caches.
-
package
-
for protocol compatibility with class
-
removeSelector: aSelector
-
remove the selector, aSelector and its associated method
from the methodDictionary
-
selectors
-
return the receiver's selector array as an OrderedCollection.
Notice: this may not be compatible with ST-80.
(should we return a Set ?)
-
superclass
-
return the receiver's superclass
autoload check
-
autoload
-
force autoloading - do nothing here;
redefined in Autoload; see comment there
-
isLoaded
-
return true, if the class has been loaded;
redefined in Autoload; see comment there
-
wasAutoloaded
-
return true, if this class came into the system via an
autoload; false otherwise.
Returning false here. This allows different Behavior-like objects
(alien classes) to be handled by the browser as well.
cleanup
-
flushSubclasses
-
I don't keep my subclasses - but if anyone inherits from me,
it better knows how to ignore this
-
lowSpaceCleanup
-
ignored here - redefined in some classes to
cleanup in low-memory situations
compiler interface
-
browserClass
-
return the browser to use for this class -
this can be redefined in special classes, to get different browsers
-
compiler
-
return the compiler to use for this class.
OBSOLETE: This is the old ST/X interface, kept for migration.
Don't use it - it will vanish.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
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.
-
dllPath
-
if a class contains ExternalFunctions,
return a collection of pathNames where to find the DLLs
containing the external functions.
Do not code absolute path names here - keep them in the system settings.
Use this if the DLL location is kept in some registry entry.
-
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.
-
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.
-
language
-
return the programming language to use for this class.
OBSOLETE: This is an old interface which will vanish (easily confused with UI-national language).
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
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.
-
programmingLanguage
-
-
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.
compiling
-
compile: code
-
compile code, aString for this class;
if successful update the method dictionary.
Returns the new method or nil (on failure).
-
compile: code categorized: methodCategory
-
compile code, aString for this class;
if successful update the method dictionary.
Returns the new method or nil (on failure).
-
compile: code categorized: methodCategory notifying: requestor
-
compile code, aString for this class;
if successful update the method dictionary.
Returns the new method or nil (on failure).
-
compile: code notifying: requestor
-
compile code, aString for this class; on any error, notify
requestor, anObject with the error reason.
Returns the new method or nil (on failure).
copying
-
canCloneFrom: anObject
-
return true, if this class can clone an obsolete object as retrieved
by a binary load. Subclasses which do not want to have obsolete objects
be converted, should redefine this method to return false.
(However, conversion is never done silently in a binary load; you
have to have a handler for the binaryload errors and for the conversion
request signal.)
-
cloneFrom: aPrototype
-
return an instance of myself with variables initialized from
a prototype.
This is eg. used when instances of obsolete classes are
binary loaded and a conversion is done on the obsolete object.
UserClasses may redefine this for better conversions.
Usage example(s):
Class withoutUpdatingChangesDo:[
Point subclass:#Point3D
instanceVariableNames:'z'
classVariableNames:''
poolDictionaries:''
category:'testing'.
(Point3D cloneFrom:1@2) inspect.
]
|
Usage example(s):
Class withoutUpdatingChangesDo:[
Point variableSubclass:#Point3D
instanceVariableNames:'z'
classVariableNames:''
poolDictionaries:''
category:'testing'.
(Point3D cloneFrom:#(1 2 3)) inspect.
]
|
Usage example(s):
|someObject|
Class withoutUpdatingChangesDo:[
Object subclass:#TestClass1
instanceVariableNames:'foo bar'
classVariableNames:''
poolDictionaries:''
category:'testing'.
someObject := TestClass1 new.
someObject instVarAt:1 put:'foo'; instVarAt:2 put:'bar'.
Object subclass:#TestClass2
instanceVariableNames:'bar foo'
classVariableNames:''
poolDictionaries:''
category:'testing'.
(TestClass2 cloneFrom:someObject) inspect.
]
|
-
deepCopyUsing: aDictionary postCopySelector: postCopySelector
-
return a deep copy of the receiver
- return the receiver here - time will show if this is ok
-
simpleDeepCopy
-
return a deep copy of the receiver
- return the receiver here - time will show if this is ok
dummy changes management
-
addChangeRecordForClassRemove: aClassName
-
add a change record that some class has been removed.
Defined as dummy here, since Behavior does not know about change management.
(only Classes do). This allows different Behavior-like
objects (alien classes) to be handled by the browser as well.
dummy fileOut
-
fileOutDefinitionOn: aStream
-
dummy fileOut defined here.
This allows different Behavior-like objects
(alien classes) to be handled by the browser as well.
enumerating
-
allDerivedInstancesDo: aBlock
-
evaluate aBlock for all of my instances and all instances of subclasses.
This method is going to be removed for protocol compatibility with
other STs; use allSubInstancesDo:
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
allInstVarNamesDo: aBlock
-
evaluate aBlock qith all the instance variable name-strings
this includes all superclass-instance variables.
Instvars of superclasses come first.
Usage example(s):
String streamContents:[:s|
SortedCollection allInstVarNamesDo:[:eachVarName| s nextPutLine:eachVarName].
].
SortedCollection instVarNames
|
-
allInstancesDo: aBlock
-
evaluate aBlock for all of my instances
Usage example(s):
StandardSystemView allInstancesDo:[:v | Transcript showCR:(v name)]
|
-
allOwningclassesDo: aBlock
-
evaluate aBlock for all of my owners (i.e. owner, owner-of-owner etc).
Usage example(s):
Method::MethodWhoInfo allOwningclassesDo:[:c | Transcript showCR:(c name)]
|
-
allSelectorsAndMethodsDo: aTwoArgBlock
-
evaluate the argument, aBlock for all selectors of mySelf and my metaclass,
passing the corresponding method as second argument
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
allSubInstancesDetect: aBlock ifNone: failBlock
-
evaluate aBlock for my instances and all instances of subclasses
until aBlock returns true. Answer the found instance.
Usage example(s):
View allSubInstancesDetect:[:v | v name = 'EditTextView'] ifNone:nil
|
-
allSubInstancesDo: aBlock
-
evaluate aBlock for all of my instances and all instances of subclasses
Usage example(s):
StandardSystemView allSubInstancesDo:[:v | Transcript showCR:(v name)]
|
-
allSubclassesDo: aBlock
-
evaluate aBlock for all of my subclasses.
There is no specific order, in which the entries are enumerated.
Warning:
This will only enumerate globally known classes - for anonymous
behaviors, you have to walk over all instances of Behavior.
Usage example(s):
Collection allSubclassesDo:[:c | Transcript showCR:(c name)]
Collection class allSubclassesDo:[:c | Transcript showCR:(c name)]
|
-
allSubclassesInOrderDo: aBlock
-
evaluate aBlock for all of my subclasses.
The subclasses are enumerated breadth first (i.e. all of a classes superclasses
come before a class, which comes before any of its subclasses).
However, within one inheritance level, there is no specific order,
in which the entries are enumerated.
Warning:
This will only enumerate globally known classes - for anonymous
behaviors, you have to walk over all instances of Behavior.
Usage example(s):
Collection allSubclassesInOrderDo:[:c | Transcript showCR:(c name)]
Collection class allSubclassesInOrderDo:[:c | Transcript showCR:(c name)]
|
-
allSubclassesSelect: aSelectBlock
-
evaluate aSelectBlock for all of my subclasses.
Answer a collection of my subclasess for which aSelectBlock evaluates to true.
There is no specific order, in which the entries are enumerated.
NameSpaces are excluded from the list.
Warning:
This will only enumerate globally known classes - for anonymous
behaviors, you have to walk over all instances of Behavior.
Usage example(s):
Collection allSubclassesSelect:[:c | c name startsWith:$S]
|
-
allSuperclassesDo: aBlock
-
evaluate aBlock for all of my superclasses
Usage example(s):
String allSuperclassesDo:[:c | Transcript showCR:(c name)]
|
-
instAndClassMethodsDo: aOneArgBlock
-
evaluate the argument, aBlock for all methods of mySelf and my metaclass
See methodsDo: for a method which only enumerates methods in me;
See selectorsAndMethodsDo: for a method which also passes the selector.
-
instAndClassSelectorsAndMethodsDo: aTwoArgBlock
-
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.
-
methodsDo: aOneArgBlock
-
evaluate the argument, aBlock for all my methods.
This only enumerates methods contained here,
not in my corresponding nonMeta/meta class.
See instAndClassMethodsDo: for a method which does this.
Usage example(s):
UndefinedObject methodsDo:[:m | Transcript showCR:m whoString]
UndefinedObject selectorsDo:[:sym | Transcript showCR:sym]
UndefinedObject methodDictionary
|
-
privateClassesDo: aBlock
-
evaluate aBlock on all of my (immediate) private classes (if any).
Evaluation is in no particular order.
-
selectorsAndMethodsDo: aTwoArgBlock
-
evaluate the argument, aBlock for all my selectors,
passing the corresponding method as second argument.
This only enumerates methods contained here,
not in my corresponding nonMeta/meta class.
See instAndClassSelectorsAndMethodsDo: for a method which does this.
-
selectorsDo: aOneArgBlock
-
evaluate the argument, aBlock for all my selectors.
This only enumerates selectors of methods contained here,
not in my corresponding nonMeta/meta class.
-
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.
-
whichClassSatisfies: aBlock
-
return the first class along the superclass-chain, which satisfies aBlock.
Return nil, if there is none.
Usage example(s):
SimpleView whichClassSatisfies:[:cls | cls instanceVariableNames includes:'gc']
|
-
withAllSubclassesDo: aBlock
-
evaluate aBlock for mySelf and all of my subclasses.
There is no specific order, in which the entries are enumerated.
Warning:
This will only enumerate globally known classes - for anonymous
behaviors, you have to walk over all instances of Behavior.
Usage example(s):
Collection withAllSubclassesDo:[:c | Transcript showCR:(c name)]
Collection class withAllSubclassesDo:[:c | Transcript showCR:(c name)]
|
-
withAllSuperclassesDo: aBlock
-
evaluate aBlock for the class and all of its superclasses
Usage example(s):
String withAllSuperclassesDo:[:each| Transcript showCR:each]
|
error handling
-
abstractClassInstantiationError
-
sent by an abstract classes redefined new method
initialization
-
deinitialize
-
deinitialize is sent to a class before it is physically unloaded.
This is only done with classes which have been loaded in from a binary
file. Classes may release any primitive memory or other stuff which is
not visible to smalltalk (for example, release internal memory).
The default action here is to do nothing.
-
initialize
-
initialize is sent to a class either during startup,
(for all statically compiled-in classes) or after a class
has been loaded into the system (either bytecodes or machinecode).
The default action here is to do nothing.
-
postAutoload
-
postAutoload is sent to a class after it has been autoloaded.
This gives it a chance to arrange for automatic unloading to be done
after a while ...
This is NOT sent to statically compiled in or explicitely filedIn
classes.
The default action here is to do nothing.
-
reinitialize
-
reinitialize is sent to a class when an image has been restarted.
I.e. when the system is restarted.
This gives classes a chance to flush any device dependent or otherwise
obsolete data which may be a leftover from the previous live.
The default action here is to do nothing.
inspecting
-
inspectorExtraAttributes
( an extension from the stx:libtool package )
-
extra (pseudo instvar) entries to be shown in an inspector.
-
inspectorValueListIconFor: anInspector
( an extension from the stx:libtool package )
-
returns the icon to be shown alongside the value list of an inspector
-
inspectorValueStringInListFor: anInspector
( an extension from the stx:libtool package )
-
returns a string to be shown in the inspector's selection list
instance creation
-
basicNew
-
return an instance of myself without indexed variables.
If the receiver-class has indexed instvars, the new object will have
a basicSize of zero -
i.e. 'aClass basicNew' is equivalent to 'aClass basicNew:0'.
** Do not redefine this method in any class **
-
basicNew: anInteger
-
return an instance of myself with anInteger indexed variables.
If the receiver-class has no indexed instvars, this is only allowed
if the argument, anInteger is zero.
** Do not redefine this method in any class **
-
decodeFromLiteralArray: anArray
-
create & return a new instance from information encoded in anArray.
Usage example(s):
Rectangle
decodeFromLiteralArray:#(Rectangle 10 10 100 100)
|
-
fromString: aString
-
reconstruct an instance of myself from the ascii-store string.
These bytes are typically the result from storing into a string/stream.
Same as readFrom:, for Dolphin compatibility.
-
new
-
return an instance of myself without indexed variables
-
new: anInteger
-
return an instance of myself with anInteger indexed variables
-
niceBasicNew: anInteger
-
same as basicNew:anInteger, but tries to avoid long pauses
due to garbage collection. This method checks to see if
allocation is possible without a pause, and does a background
incremental garbage collect first if there is not enough memory
available at the moment for fast allocation.
This is useful in low-priority background processes which like to
avoid disturbing any higher priority foreground process while allocating
big amounts of memory. Of course, using this method only makes
sense for big or huge objects (say > 200k).
EXPERIMENTAL: this is a non-standard interface and should only
be used for special applications. There is no guarantee, that this
method will be available in future ST/X releases.
-
readFrom: aStringOrStream
-
read an object's printed representation from the argument, aStream
and return it.
The read object must be a kind of myself;
if it's not, an error is raised.
This is the reverse operation to 'storeOn:'.
WARNING: storeOn: does not handle circular references and multiple
references to the same object.
Use #storeBinary:/readBinaryFrom: for this.
SECURITY WARNING: if aStringOrStream is from an unsafe source,
BAD things may be evaluated, like
'Smalltalk exit' or even
'Filename rootDirectory recursiveXXXRemove'
Usage example(s):
Object readFrom:'Transcript showCR:''BAD SIDE EFFECT in Object>>#readFrom:'''.
|s|
s := WriteStream on:String new.
#(1 2 3 4) storeOn:s.
Object readFrom:(ReadStream on:s contents)
|
-
readFrom: aStringOrStream onError: exceptionBlock
-
read an object's printed representation from the argument, aStream
and return it (i.e. the stream should contain some representation of
the object which was created using #storeOn:).
The read object must be a kind of myself.
If it's not, the value of exceptionBlock is returned.
To get any object, use 'Object readFrom:...',
To get any number, use 'Number readFrom:...' and so on.
This is the reverse operation to 'storeOn:'.
WARNING: storeOn: does not handle circular references and multiple
references to the same object.
Use #storeBinary:/readBinaryFrom: for this.
SECURITY WARNING: if aStringOrStream is from an unsafe source,
BAD things may be evaluated, like
'Smalltalk exit' or even
'Filename rootDirectory recursiveXXXRemove'
Usage example(s):
|s|
s := WriteStream on:String new.
#(1 2 3 4) storeOn:s.
Transcript showCR:(
Array readFrom:(ReadStream on:s contents) onError:'not an Array'
)
|
Usage example(s):
|s|
s := WriteStream on:String new.
#[1 2 3 4] storeOn:s.
Transcript showCR:(
Array readFrom:(ReadStream on:s contents) onError:'not an Array'
)
|
Usage example(s):
Object readFrom:'''abc''' onError:['bla']
Object readFrom:'4711' onError:['bla']
Object readFrom:'Transcript showCR:''BAD SIDE EFFECT in Object>>#readFrom:''' onError:['bla'].
Object readFrom:'illegal' onError:['bla']
String readFrom:'illegal' onError:'bla'
|
-
readFromString: aString
-
create an object from its printed representation.
For most classes, the string is expected to be in a format created by
storeOn: or storeString; however, some (Time, Date) expect a user
readable string here.
See comments in Behavior>>readFromString:onError:,
Behavior>>readFrom: and Behavior>>readFrom:onError:
Usage example(s):
Integer readFromString:'12345678901234567890'
Point readFromString:'1@2'
Point readFromString:'1'
|
-
readFromString: aString onError: exceptionBlock
-
create an object from its printed representation.
Here, the string is expected to be in a format created by
storeOn: or storeString;
However, some classes (Time, Date) may redefine it to expect a user readable string here.
See comments in Behavior>>readFrom: and Behavior>>readFrom:onError:
Usage example(s):
Integer readFromString:'12345678901234567890'
Integer readFromString:'abc'
Integer readFromString:'abc' onError:0
Point readFromString:'1@2'
Point readFromString:'0'
Point readFromString:'0' onError:[0@0]
|
-
uninitializedNew
-
create an instance of myself with uninitialized contents.
For all classes except ByteArray, this is the same as #basicNew.
-
uninitializedNew: anInteger
-
create an instance of myself with uninitialized contents.
For all classes except ByteArray, this is the same as #basicNew:.
misc ui support
-
browse
-
open a browser showing the receiver. Returns the browser
Usage example(s):
Array browserClass
Array browse
|
-
browse: selector
-
open a browser showing the receiver.
Returns the browser
Usage example(s):
-
classOperationsMenu
-
a chance to return additional menu items for the browser's class-menu
-
iconInBrowserSymbol
( an extension from the stx:libtool package )
-
can be redefined for a private icon in the browser (for me and my subclasses).
The returned symbol must be a selector of the ToolbarIconLibrary.
The browser will use this as index into the toolbariconlibrary
-
sourceCodeTemplate
-
-
toolListIcon
-
VisualWorks icon retrieval for the browser list.
Only redefined in VW classes.
Notice, that ST/X uses a better scheme, where the class only
returns a symbol, which is used to map into the icon library.
Thus allowing different icons as per view style
printing & storing
-
displayOn: aGCOrStream
-
return a string to display the receiver - include the
count for your convenience.
although behaviors have no name, we return something
useful here - there are many places (inspectors) where
a classes name is asked for.
Implementing this message here allows instances of anonymous classes
to show a reasonable name.
-
printOn: aStream
-
(comment from inherited method)
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.
The default here is to output the receiver's class name.
BUT: this method is heavily redefined for objects which
can print prettier.
private-accessing
-
flags: aNumber
-
set the flags.
see flagXXX methods on my class side for details.
This method is for special uses only - there will be no recompilation
and no change record written here;
Warning:
the flags slot specifies the layout and behavior of my instances slots
and affects both the VM's and the class library's behavior.
It is required to be consistent and correct.
Setting it to a wrong value may severely affect the system's operation,
and even crash the system (in the garbage collector).
Do NOT use it, unless you really know what you are doing.
-
instSize: aNumber
-
set the instance size.
This method is for special uses only - there will be no recompilation
and no change record written here;
Warning:
the instSize slot specifies the size of my instances and affects
both the VM's and the class library's behavior.
It is required to be consistent and correct.
Setting it to a wrong value may severely affect the system's operation,
and even crash the system (in the garbage collector).
Do NOT use it, unless you really know what you are doing.
-
primAddSelector: aSelector withMethod: newMethod
-
add the method given by 2nd argument under the selector given by
the 1st argument to the methodDictionary.
Does NOT flush any caches, does NOT write a change record.
Do not use this in normal situations, strange behavior will be
the consequence.
I.e. executing obsolete methods, since the old method will still
be executed out of the caches.
-
setMethodDictionary: dict
-
set the receiver's method dictionary.
Convert dict to a MethodDictionary if necessary.
Do not flush inline caches, therefore old cached methods may be executed
after this call
-
setSuperclass: aClass
-
set the superclass of the receiver.
this method is for special uses only - there will be no recompilation
and no change record written here. Also, if the receiver class has
already been in use, future operation of the system is not guaranteed to
be correct, since no caches are flushed.
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)
-
setSuperclass: aClass instSize: i
-
set some inst vars.
this method is for special uses only - there will be no recompilation
and no change record is written here. Also, if the receiver class has
already been in use, future operation of the system is not guaranteed to
be correct, since no caches are flushed.
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)
-
setSuperclass: aClass methodDictionary: d instSize: i flags: f
-
set some inst vars.
this method is for special uses only - there will be no recompilation
and no change record is written here. Also, if the receiver class has
already been in use, future operation of the system is not guaranteed to
be correct, since no caches are flushed.
Therefore: do NOT use it; use Behavior>>superclass: (or flush the caches, at least)
private-helpers
-
addAllClassVarNamesTo: aCollection
-
helper - add the name-strings of the class variables and of the class-vars
of all superclasses to the argument, aCollection. Return aCollection
-
addAllInstVarNamesTo: aCollection
-
helper for allInstVarNames - add the name-strings of the instance variables
and of the inst-vars of all superclasses to the argument, aCollection.
Return aCollection.
-
getLookupObject
-
return the lookupObject (Jan's MetaObjectProtocol support) or nil.
If non-nil, no lookup is performed by the VM, instead the lookupObject
has to provide a method object for message sends.
-
setLookupObject: aLookupObjectOrNil
-
set the lookupObject (Jan's MetaObjectProtocol support) or nil.
If non-nil, no lookup is performed by the VM, instead the lookupObject
has to provide a method object for message sends.
queries
-
category
-
return the category of the class.
Returning nil here, since Behavior does not define a category
(only ClassDescriptions do).
Usage example(s):
Point category
Behavior new category
|
-
comment
-
return the comment of the class.
Returning nil here, since Behavior does not define a category
(only Classes do). This allows different Behavior-like objects
(alien classes) to be handled by the browser as well.
-
definitionSelector
-
return the selector with which I was (can be) defined in my superclass
Usage example(s):
Object definitionSelector
Array definitionSelector
ByteArray definitionSelector
FloatArray definitionSelector
|
-
definitionSelectorPrivate
-
return the selector with which I was (can be) defined in my superclass
as a private class
Usage example(s):
Array definitionSelector
Array definitionSelectorPrivate
|
-
environment
-
return the namespace I am contained in; ST-80 compatible name.
Not normally needed here, but added to allow for instances of anonymous behaviors
to be inspected or browsed.
-
firstDefinitionSelectorPart
-
return the first part of the selector with which I was (can be) defined in my superclass
-
fullName
-
Answer the name of the receiver, fully qualified.
-
hasExtensions
-
-
isAbstract
-
true if this is an abstract class
(has no direct instances, should not be instantiated).
Usually, this means that it only provides shared protocol for its
subclasses, which should be used.
Notice: this does not have any semantic effect;
it is purely for the browser (shows an 'A'-Indicator)
and for documentation.
To enforce abstractness, a subclass should redefine new, to raise an exception.
(which some do, but many are too lazy to do)
-
isBehavior
-
return true, if the receiver is describing another object's behavior.
Defined to avoid the need to use isKindOf:
Usage example(s):
True isBehavior
true isBehavior
|
-
isBrowserStartable
-
return true, if this is an application class,
which can be started from the browser
-
isBuiltInClass
-
return true if this class is known by the run-time-system.
Here, false is returned as default.
Notice, this is instance protocol, which means that any class
other than those special ones) are non-builtIn by default.
-
isMockupClassForTest
-
a class used as mockup/target for a testf;
one which is not to be used outside the thest
-
isObsolete
-
return true, if the receiver is obsolete
(i.e. has been replaced by a different class or was removed,
but is still referenced by instances).
Not normally needed here, but added to allow for instances of anonymous behaviors
to be inspected or browsed.
-
isPrivate
-
return true, if the receiver is some private class
-
isStartableWithMain
-
return true, if this is an application class,
which can be started via #main / #main:
-
isStartableWithStart
-
return true, if this is an application class,
which can be started via #start
-
isUtilityClass
-
a utility class is one which is not to be instantiated,
but only provides a number of utility functions on the class side.
It is usually also abstract
-
isVisualStartable
-
-
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.
-
methodsCount
( an extension from the stx:libtool package )
-
Return a number of methods or nil if number of methods
is not known (such as for lazy-loaded classes)
-
name
-
although behaviors have no name, we return something
useful here - there are many places (inspectors) where
a classes name is asked for.
Implementing this message here allows anonymous classes
and instances of them to be inspected.
-
nameInBrowser
-
return a nameString as shown in browsers
-
nameSpace
-
return the namespace I am contained in.
Not normally needed here, but added to allow for instances of anonymous behaviors
to be inspected or browsed.
-
nameWithArticle
-
return a string consisting of classname preceeded by an article.
(don't expect me to write national variants for this ... :-)
If you have special preferences, redefine it...
Usage example(s):
SmallInteger nameWithArticle
|
-
owningClass
-
return my owning class - nil if I am a public class
-
owningClassOrYourself
-
return my owning class if I am private, myself otherwise
-
privateClassesAt: aClassNameStringOrSymbol
-
return a private class if present; nil otherwise.
Not normally needed here, but added to allow for instances of anonymous behaviors
to be inspected or browsed.
-
realSharedPoolNames
-
this returns the namespace aware pool names.
Not normally needed here, but added to allow for instances of anonymous behaviors
to be inspected or browsed.
-
revision
-
-
sourceCodeAt: aSelector
-
return the method's source for given selector aSelector or nil.
Only methods in the receiver - not in the superclass chain are considered.
Usage example(s):
True sourceCodeAt:#ifTrue:
Object sourceCodeAt:#==
Behavior sourceCodeAt:#sourceCodeAt:
|
-
sourceCodeAt: aSelector ifAbsent: exceptionalValue
-
return the method's source for given selector aSelector or exceptionalValue.
Only methods in the receiver - not in the superclass chain are considered.
-
sourceCodeManager
-
return the sourceCodeManager of the class.
Returning nil here, since Behavior does not define any sourceCode management.
(only Classes do). This allows different Behavior-like objects
(alien classes) to be handled by the browser as well.
-
supportsMethodCategories
-
return true, if my methods are categorized.
This is a hook for the browser to allow alien classes
to be handled (actually, this is not yet used).
-
theMetaclass
-
return the metaClass of the class-meta pair.
Here, return my metaclass object, because I am the class.
Also implemented in my metaclass, which returns itself.
Sigh: ST/X naming; Squeak calls this theMetaClass
and Pharo calls it classSide
-
theNonMetaclass
-
return the nonMetaClass of the class-meta pair.
Here, return myself, because I am the nonMetaclass.
Also implemented in my metaclass, which also returns me.
Sigh: ST/X naming; Squeak calls this theNonMetaClass
and Pharo calls it instanceSide
-
topNameSpace
-
return the nameSpace of my topOwningClass (if private) or my own nameSpace.
Not normally needed here, but added to allow for instances of anonymous behaviors
to be inspected or browsed.
-
topOwningClass
-
return my outermost owning class - nil if I am a public class
queries-inheritance
-
allSubclasses
-
return a collection of all subclasses (direct AND indirect) of
the receiver. There will be no specific order, in which entries
are returned. NameSpaces are excluded from the list.
Usage example(s):
-
allSubclassesInOrder
-
return a collection of all subclasses (direct AND indirect) of
the receiver. Higher level subclasses will come before lower ones.
NameSpaces are excluded from the list.
Usage example(s):
Collection allSubclassesInOrder
|
-
allSuperclasses
-
return a collection of the receiver's accumulated superclasses
Usage example(s):
-
canBeSubclassed
-
return true, if it's allowed to create subclasses of the receiver.
This method is redefined in SmallInteger and UndefinedObject, since
instances are detected by their pointer-fields, i.e. they do not have
a class entry (you don't have to understand this :-)
-
commonSuperclass: aClass
-
Return the common superclass of the receiver and aClass.
Assumes that there is a common superclass of any two classes.
(might return nil, if either the receiver or the argument inherits from nil)
Usage example(s):
Integer commonSuperclass:Fraction
SmallInteger commonSuperclass:Fraction
View commonSuperclass:Form
View commonSuperclass:Image
View commonSuperclass:View
Integer commonSuperclass:Autoload
Integer commonSuperclass:Object
|
-
hasMultipleSuperclasses
-
Return true, if this class inherits from other classes
(beside its primary superclass).
This method is a preparation for a future multiple inheritance extension
- currently it is not supported by the VM
-
includesBehavior: aClass
-
return true, if the receiver includes the behavior of aClass;
i.e. if is either identical to a class or inherits from it.
Usage example(s):
True includesBehavior:Object
True includesBehavior:Boolean
True includesBehavior:True
True includesBehavior:False
|
-
inheritsFrom: aClass
-
return true, if the receiver inherits methods from aClass;
i.e. if aClass is on the receiver's superclass chain.
Usage example(s):
True inheritsFrom:Object
LinkedList inheritsFrom:Array
|
-
isSubclassOf: aClass
-
return true, if I am a subclass of the argument, aClass
Usage example(s):
String isSubclassOf:Collection
LinkedList isSubclassOf:Array
1 isSubclassOf:Number <- will fail since 1 is no class
Number isSubclassOf:1
|
-
mutableClass
-
Return a version of me with mutable instances.
Only redefined in the immutable collections
(of which instances are created by the compiler)
-
subclasses
-
return a collection of the direct subclasses of the receiver
-
superclasses
-
return a collection of the receiver's immediate superclasses.
This method is a preparation for a future multiple inheritance extension
- currently it is not supported by the VM
Usage example(s):
-
withAllSubclasses
-
return a collection containing the receiver and
all subclasses (direct AND indirect) of the receiver
Usage example(s):
Collection withAllSubclasses
|
-
withAllSuperclasses
-
return a collection containing the receiver and all
of the receiver's accumulated superclasses
Usage example(s):
String withAllSuperclasses
|
queries-instances
-
allDerivedInstances
-
return a collection of all instances of myself and
instances of all subclasses of myself.
This method is going to be removed for protocol compatibility with
other STs; use allSubInstances
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
allInstances
-
return a collection of all my instances
Usage example(s):
-
allInstancesForWhich: predicate do: action
-
perform action on all instances for which predicate returns true
Usage example(s):
ScrollBar allInstancesForWhich:[:s | s shown] do:[:s | Transcript showCR:s topView label]
|
-
allInstancesSelect: predicate
-
return all instances for which predicate returns true
Usage example(s):
ScrollBar allInstancesSelect:[:s | s shown]
|
-
allInstancesWeakly: doWeakly
-
return a collection of all my instances.
If weakly is true, a weak collection is returned.
-
allSubInstances
-
return a collection of all instances of myself and
instances of all subclasses of myself.
Usage example(s):
-
anyInstance
-
return any of my instances; raise an error, if there is none
Usage example(s):
ScrollBar anyInstance
SmallInteger anyInstance
|
-
anySubInstance
-
return any of my or derived instances; raise an error, if there is none
Usage example(s):
-
derivedInstanceCount
-
return the number of instances of myself and of subclasses
Usage example(s):
View derivedInstanceCount
SequenceableCollection derivedInstanceCount
Object derivedInstanceCount
|
-
hasDerivedInstances
-
return true, if there are any instances of myself or of any subclass
Usage example(s):
Object hasDerivedInstances - certainly true
SharedQueue hasDerivedInstances
|
-
hasImmediateInstances
-
return true if this class has immediate instances
i.e. if the instances are represented in the pointer itself and
no real object header/storage is used for the object.
Redefined in classes which have so (only SmallInteger and UndefinedObject)
-
hasImmutableInstances
-
are this classes' instances immutable?
-
hasInstances
-
return true, if there are any instances of myself
Usage example(s):
Object hasInstances
SequenceableCollection hasInstances
Float hasInstances
SmallInteger hasInstances
|
-
hasSharedInstances
-
return true if this class can share instances when stored binary,
that is, instances with the same value can be stored by reference.
False is returned here, only redefined in classes which have unified
instances (or should be treated so).
-
instanceCount
-
return the number of instances of myself.
Usage example(s):
View instanceCount
Object instanceCount
Float instanceCount
SequenceableCollection instanceCount
SmallInteger instanceCount .... mhmh - hear, hear
|
queries-instlayout
-
elementByteSize
-
for bit-like containers, return the number of bytes stored per element.
For pointer indexed classes, 0 is returned
-
isAlienBehavior
-
Returns true iff I'm an alien behavior.
-
isBits
-
return true, if instances have indexed byte or short instance variables.
Ignore long, float and double arrays, since ST-80 code using isBits are probably
not prepared to handle them correctly.
-
isBitsExtended
-
return true, if instances have indexed byte, short, long or longlong instance variables.
Ignore float and double arrays.
This is really the thing we expect #isBits to return, however, #isBits
is defined to only return true for byte- and wordIndexed instances.
This avoids confusion of ST80 code, which is not prepared for long or longLong
instVars.
-
isBytes
-
return true, if instances have indexed byte instance variables
-
isDoubles
-
return true, if instances have indexed double instance variables
-
isFixed
-
return true, if instances do not have indexed instance variables
-
isFloats
-
return true, if instances have indexed float instance variables
-
isFloatsOrDoubles
-
return true, if instances have indexed float or double instance variables
Usage example(s):
(Object new) class isFloatsOrDoubles
(Point new) class isFloatsOrDoubles
(Array new) class isFloatsOrDoubles
(ByteArray new) class isFloatsOrDoubles
(FloatArray new) class isFloatsOrDoubles
(DoubleArray new) class isFloatsOrDoubles
|
-
isLongLongs
-
return true, if instances have indexed long-long instance variables (8 byte uints)
-
isLongs
-
return true, if instances have indexed long instance variables (4 byte uints)
-
isPointers
-
return true, if instances have pointer instance variables
i.e. are either non-indexed or have indexed pointer variables
-
isSignedLongLongs
-
return true, if instances have indexed signed long-long instance variables (8 byte ints)
-
isSignedLongs
-
return true, if instances have indexed signed long instance variables (4 byte ints)
Usage example(s):
#u16(1 2 3) class isSignedLongs
#s16(1 2 3) class isSignedWords
#s16(1 2 3) class isBytes
#s16(1 2 3) class isVariable
|
-
isSignedWords
-
return true, if instances have indexed signed short instance variables
-
isVariable
-
return true, if instances have indexed instance variables
-
isWeakPointers
-
return true, if instances have weak pointer instance variables
-
isWords
-
return true, if instances have indexed short instance variables
-
sizeOfInst: n
-
return the number of bytes required for an instance of
myself with n indexed instance variables.
The argument n should be zero for classes without indexed instance variables.
See Behavior>>niceNew: for an application of this.
Usage example(s):
DoubleArray sizeOfInst:8
IntegerArray sizeOfInst:8
|
queries-protocol
-
allSelectors
-
return a collection of all selectors understood by the receiver;
this includes my selectors and all superclass selectors
(i.e. the receiver's full protocol)
Usage example(s):
Point allSelectors
View allSelectors
Array allSelectors
|
-
cachedLookupMethodFor: aSelector
-
return the method, which would be executed if aSelector was sent to
an instance of the receiver. I.e. the selector arrays of the receiver
and all of its superclasses are searched for aSelector.
Return the method, or nil if instances do not understand aSelector.
This interface provides exactly the same information as #lookupMethodFor:,
but uses the lookup-cache in the VM for faster search.
However, keep in mind, that doing a lookup through the cache also adds new
entries and can thus slow down the system by polluting the cache with
irrelevant entries. (do NOT loop over all objects calling this method).
Does NOT (currently) handle MI
Usage example(s):
String cachedLookupMethodFor:#=
String cachedLookupMethodFor:#asOrderedCollection
|
-
canUnderstand: aSelector
-
return true, if the receiver or one of its superclasses implements aSelector.
(i.e. true if my instances understand aSelector).
I think this is a bad name (it sounds more like instance protocol,
and something like #instancesRespondTo: would have been better),
but well, we are compatible (sigh).
Usage example(s):
True canUnderstand:#ifTrue:
True canUnderstand:#==
True canUnderstand:#do:
|
-
compiledMethodAt: aSelector
-
return the method for given selector aSelector or nil.
Only methods in the receiver - not in the superclass chain are tested.
Usage example(s):
Object compiledMethodAt:#==
(Object compiledMethodAt:#==) category
|
-
compiledMethodAt: aSelector ifAbsent: exceptionValue
-
return the method for given selector aSelector or the value
of exceptionValue if not present.
Only methods in the receiver - not in the superclass chain are tested.
Usage example(s):
Object compiledMethodAt:#==
(Object compiledMethodAt:#==) category
|
-
compiledMethodNamed: methodName
-
Warning: this method is here to support multiple languages.
Do not use in code that works just with the smalltalk code.
Use compiledMethodAt: selector instead
Usage example(s):
Object compiledMethodNamed:#==
(Object compiledMethodNamed:#==) category
|
-
compiledMethodNamed: name ifAbsent: exceptionValue
-
Warning: this method is here to support multiple languages.
Do not use in code that works just with the smalltalk code.
Use compiledMethodAt: selector instead
Usage example(s):
Object compiledMethodNamed:#==
(Object compiledMethodNamed:#==) category
|
-
containsMethod: aMethod
-
Return true, if the argument, aMethod is a method of myself
-
hasMethods
-
return true, if there are any (local) methods in this class
Usage example(s):
True hasMethods
True class hasMethods
|
-
implements: aSelector
-
return true, if the receiver implements aSelector.
(i.e. implemented in THIS class - NOT in a superclass).
This is semantically equivalent to includesSelector: (which is ST/80/Squeak compatibility).
Caveat:
This simply checks for the selector being present in the classes
selector table - therefore, it does not care for ignoredMethods.
(but: you should not use this method for protocol-testing, anyway).
Hint:
Don't use this method to check if someone responds to a message -
use #canUnderstand: on the class or #respondsTo: on the instance
to do this.
-
includesSelector: aSelector
-
return true, if the methodDictionary of THIS class includes a method for aSelector.
(i.e. if aSelector is implemented in THIS class - NOT in a superclass).
This is semantically equivalent to implements: (ST/80/Squeak compatibility).
Hint:
Don't use this method to check if someone responds to a message -
use #canUnderstand: on the class or #respondsTo: on the instance
to do this.
Caveat:
This simply checks for the selector being present in the classes
selector table - therefore, it does not care for ignoredMethods.
(but: you should not use this method for protocol-testing, anyway).
Usage example(s):
Object includesSelector:#==
Object includesSelector:#murks
Object includesSelector:nil
|
-
instAndClassMethods
-
-
lookupMethodFor: aSelector
-
return the method, which would be executed if aSelector was sent to
an instance of the receiver. I.e. the selector arrays of the receiver
and all of its superclasses are searched for aSelector.
Return the method, or nil if instances do not understand aSelector.
EXPERIMENTAL: take care of multiple superclasses.
Usage example(s):
String lookupMethodFor:#==
String lookupMethodFor:#collect:
|
-
responseTo: aSelector
-
return the method (from here or the inheritance chain),
which implements aSelector; return nil if none.
Usage example(s):
String responseTo:#==
String responseTo:#collect:
String responseTo:#,
|
-
selectorAtMethod: aMethod
-
Return the selector for given method aMethod.
Usage example(s):
|m|
m := Object compiledMethodAt:#copy.
Fraction selectorAtMethod:m.
|
Usage example(s):
|m|
m := Object compiledMethodAt:#copy.
Object selectorAtMethod:m.
|
-
selectorAtMethod: aMethod ifAbsent: failBlock
-
return the selector for given method aMethod
or the value of failBlock, if not found.
Usage example(s):
|m|
m := Object compiledMethodAt:#copy.
Object selectorAtMethod:m ifAbsent:['oops'].
|
Usage example(s):
|m|
m := Object compiledMethodAt:#copy.
Fraction selectorAtMethod:m ifAbsent:['oops'].
|
-
whichClassImplements: aSelector
-
obsolete interface;
use whichClassIncludesSelector: for ST-80 compatibility.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
whichClassIncludesSelector: aSelector
-
return the class in the inheritance chain, which implements the method
for aSelector; return nil if none.
EXPERIMENTAL: handle multiple superclasses
Usage example(s):
String whichClassIncludesSelector:#==
String whichClassIncludesSelector:#collect:
|
queries-variables
-
allClassVarNames
-
return a collection of all the class variable name-strings
this includes all superclass-class variables
Usage example(s):
-
allInstVarNames
-
return a collection of all the instance variable name-strings
this includes all superclass-instance variables.
Instvars of superclasses come first (i.e. the position matches
the instVarAt:-index).
Usage example(s):
Point allInstVarNames => OrderedCollection(#x #y)
Point instSize => 2
Dictionary instVarNames => #(valueArray)
Dictionary allInstVarNames => OrderedCollection(#tally #keyArray #valueArray)
Dictionary instSize => 3
Dictionary superclass allInstVarNames => OrderedCollection(#tally #keyArray)
Dictionary superclass instSize => 2
|
-
allInstanceVariableNames
-
alias for allInstVarNames
-
classVarNames
-
return a collection of the class variable name-strings.
Returning empty here, since Behavior does not define any classVariables.
(only Classes do). This allows different Behavior-like objects
(alien classes) to be handled by the browser as well.
Traditionally, this was called classVarNames, but newer versions of squeak
seem to have changed to use classVariableNames.
So you probably should use the alias
-
classVariableNames
-
alias for classVarNames.
Traditionally, this was called classVarNames, but newer versions of squeak
seem to have changed to use classVariableNames.
So you probably should use this alias
Usage example(s):
Infinity classVariableNames
|
-
classVariableString
-
return a string of the class variables names.
Returning empty here, since Behavior does not define any classVariables.
(only Classes do). This allows different Behavior-like objects
(alien classes) to be handled by the browser as well.
-
instVarIndexOf: varName
-
return the index of an instvar (1..).
Return 0, if there is no such variable.
Follows the algorithm of the compilers in case of duplicate names.
This was the original ST/X's method for this functionality;
senders have been changed to use instVarIndexFor:.
Kept for backward compatibility;
please use instVarIndexFor: for VW and Squeak compatibility
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
instVarNames
-
return a collection of my instance variable name-strings
(excluding inherited instVar names).
Here, a list of synthetic names is generated.
Ask for allInstVarNames, to get all of them.
Behavior does not provide this info - generate synthetic names.
Traditionally, this was called instVarNames, but newer versions of squeak
seem to have changed to use instanceVariableNames.
So you probably should use the alias
-
instanceVariableNames
-
alias for instVarNames.
Traditionally, this was called instVarNames, but newer versions of squeak
seem to have changed to use instanceVariableNames.
So you probably should use this alias
Usage example(s):
Point instanceVariableNames
|
-
instanceVariableString
-
return a string with dummy names here - typically, your
objects are instances of Class, not Behavior,
so this is only invoked for very artificial behaviors.
Usage example(s):
Behavior new instanceVariableString
(Behavior new instSize:2) instanceVariableString
|
-
whichClassDefinesClassVar: aStringOrText
-
Behavior does not support classVariables
Usage example(s):
TextView whichClassDefinesClassVar:'CachedScales'
TextView whichClassDefinesClassVar:'xxx'
|
-
whichClassDefinesInstVar: aString
-
-
whichSelectorsAssign: instVarName
-
Answer a set of selectors whose methods write the argument, instVarName,
as a named instance variable.
-
whichSelectorsRead: instVarName
-
Answer a set of selectors whose methods read the argument, instVarName,
as a named instance variable.
-
whichSelectorsReferTo: someLiteralConstant
-
return a collection of selectors of methods which refer to the argument.
Search the literal arrays of my methods to do this.
Usage example(s):
String whichSelectorsReferTo:#at:
String whichSelectorsReferTo:CharacterArray
|
-
whichSelectorsReferToClassVariable: nameOfClassVariable
-
return a collection of selectors of methods which refer to the argument.
Search the literal arrays of my methods to do this.
Usage example(s):
Object whichSelectorsReferToClassVariable:#Dependencies
|
-
whichSelectorsReferToGlobal: nameOfGlobal
-
return a collection of selectors of methods which refer to the argument.
Search the literal arrays of my methods to do this.
Usage example(s):
Object whichSelectorsReferToGlobal:#Debugger
|
-
whichSelectorsWrite: instVarName
-
Answer a set of selectors whose methods write the argument, instVarName,
as a named instance variable.
snapshots
-
postSnapshot
-
sent by ObjectMemory to all classes, after a snapshot has been written.
Nothing done here. This can be redefined in classes which like to know
about snapshooting.
-
preSnapshot
-
sent by ObjectMemory to all classes, before a snapshot is written.
Nothing done here. This can be redefined in classes which like to know
about snapshooting.
tracing
-
traceInto: aRequestor level: level from: referrer
-
double dispatch into tracer, passing my type implicitely in the selector
visiting
-
acceptVisitor: aVisitor with: aParameter
-
dispatch for visitor pattern; send #visitBehavior:with: to aVisitor
|