org.abora.gold.xpp.converters
Class Converter

java.lang.Object
  |
  +--org.abora.gold.java.AboraHeaper
        |
        +--org.abora.gold.xpp.basic.Heaper
              |
              +--org.abora.gold.xpp.converters.Converter

public class Converter
extends Heaper

Converters exist to convert an object that is of one data type to some other data type.
In order to understand why we use Converters for this, we first have to understand why the
two obvious C++ means for doing so are inadequate.
First, we could send a conversion message to the object that we''re converting from. This
has the disadvantage that the module which provides the object must know all the types
that we might want to convert it to. This effectively prevents the easy addition of new
types to an existing system (without coordinating overhead).
Second, we could use pseudo-constructors for the new type which were overloaded based of
the type of the argument (to be converted from). The problem is that overloading only
happens based on compile time type, and we want to invoke the converter that is most
specific based on the run-time type. Let''s say that "p" is declared as pointer to
Position, but at the moment it points to an Integer. If a converter has been provided by
someone for converting Integers to the target type we would prefer that one. The CHOOSE
macro doesn''t help, because that only converts run time types to particular compile time
types which the user of the CHOOSE macro thought to list.
Instead, one declares a static instance of each Converter which (at initialization time)
posts itself to a table of all converters, indexed by the from-class and the to-class. At
run-time, when we use the CONVERT macro to convert an object to a desired type, the most
specific converter based on the from-type hierarchy is selected. I believe that currently
any compatable to-type is acceptable (with no preference). The selected converter''s from
type may be a superclass of the from-object, and the converter''s to-type may be any
subclass of the requested to type.
Example:
"CONVERT(XuRegion,p)" when p is bound to a position will return a singleton region of the
same coordinate space as that of the position. In Smalltalk, one says "p convert:
XuRegion".
See Scaffold and WaldoMaker for services which are similar to that provided by Converter.
Eventually we hope to unify some of these.


Field Summary
protected static CategoryTable AllConverters
           
protected static Converter LastConverter
           
protected static Category LastFrom
           
protected static Category LastTo
           
 
Fields inherited from class org.abora.gold.xpp.basic.Heaper
AllBlasts, BecomeMap, GarbageCount, InGC, InitializedClasses, InitializingClasses, LastMemory, NextClientRequestNumber, NotOneElementSignal, PackageTable, PromiseNameTable, StringHashSBoxes
 
Fields inherited from class org.abora.gold.java.AboraHeaper
ActiveClubs, CurrentAuthor, CurrentBertCanopyCache, CurrentBertCrum, CurrentChunk, CurrentGrandMap, CurrentKeyMaster, CurrentPacker, CurrentSensorCanopyCache, CurrentServer, CurrentSession, CurrentSessions, CurrentTrace, InitialEditClub, InitialOwner, InitialReadClub, InitialSponsor, InsideTransactionFlag
 
Constructor Summary
Converter(Category from, Category to)
          remember the kind of converter this is.
 
Method Summary
 int actualHashForEqual()
           
static Heaper CONVERT(Category to, Heaper thing)
          convert using the best available converter
 Heaper convert(Heaper value)
          perform the conversion.
static Converter fetchConverter(Category from, Category to)
          find the best available converter.
static Heaper getConversion(Category to, Heaper value)
          get the best converter and use it to actually do the conversion.
Clients should only use the CONVERT macro instead
static Converter getConverter(Category from, Category to)
          find the best available converter.
static void initTimeInherited()
          create an instance of the converter.
static void initTimeNonInherited()
          create an instance and assign it to the class instance variable
 boolean isEqual(java.lang.Object other)
           
static void linkTimeNonInherited()
          create an instance and assign it to the class instance variable
static void suppressInitTimeInherited()
           
static void suppressLinkTimeInherited()
           
 
Methods inherited from class org.abora.gold.xpp.basic.Heaper
abstractDeclarationFor, abstractTypeFor, addMethodAttributeToInOf, addPackage, addPackageCategory, allClientProtocolOn, argumentTypesFor, arrow, blast, blast, BLAST, cachePromiseNameTable, cachePromiseNameTableIn, canYouBecome, cast, cleanPromiseClasses, cleanupGarbage, clientClassesDo, clientFunctionsOn, clientMethodsOn, clientProtocol, clientProtocolDo, clientProtocolOn, clientProtocolOn, collectibleClasses, compare, compileClientSubclasses, compileConstantPromiseMethods, compileCreateFromRcvr, compileEQ, compileGeneratedClassMethod, compileGeneratedMethod, compileHook, compilePromise, compilePromiseDefaultMethods, compilePromiseFluidDeclarations, compilePromiseHandlers, compilePromiseMethods, compileRequestCreateMsgInArguments, compileRequestEvaluateMsgInReturningArguments, compileRPCSpecialistEvaluateMsgForReturningArguments, compileSendSelfTo, compileSendSelfToSendHook, compileStubbleMethods, compileSubclassStubbleMethods, computeMangle, computePreorder, constantTypeValue, convert, convertCopyDeclarations, convertDeferredDeclarations, convertProxyDeclarations, convertSubclassCopyDeclarations, convertSubclassDeferredDeclarations, convertSubclassProxyDeclarations, copyReferencesToType, create, create, create, create, create, create, create, create, create, create, createRequestClassArguments, definesProxyMethods, delete, deref, destroy, destruct, destructor, enum, enumFlags, equals, exportName, fetchAttribute, fetchPackage, fetchSuperCategory, fileOutClientProtocol, findCategory, findSenderAndReceiverMethods, findTailInto, flushPromiseNameTable, foo, freezeClientClasses, freezeClientProtocol, freezeStProtocol, frozenClasses, garbageCollect, garbageCollectFrom, gcOpportunity, gcOpportunity, generatedCategory, generatePromiseNames, getCategory, getOrMakePackage, getSuperCategory, handlerSignaturesFrom, hash, hashForEqual, hasProxyMethods, info_clientClasses, info_clientSideClasses, info_promiseClasses, info_stProtocol, inGC, initializedClasses, initializingClasses, initPackages, initStringHashSBoxes, inspectPieces, instanceSize, IntegerVar, isByProxy, isConstructed, isDestructed, isEqual, isEqualOrSubclassOf, isGenerated, isIntType, isKindOf, isRawType, isUnlocked, make, makeClassTable, makeFillTable, makeRequestTable, mangle, markChildren, markCount, markInstances, mayBecome, mayBecomeAnySubclassOf, new1, newX, nonCopyVariables, notWorking, pack, packageClasses, packagingCategory, parseExportName, passe, pointerToStaticMember, pointerToStaticMember, pointerToVirtualMember, preorderMax, preorderNumber, printOn, PROBLEM, problems, promiseClass, promiseDefaultValue, promiseName, promiseNameTable, promiseToAbstract, registerPackageCategory, removeGeneratedCode, removeStubbleMethods, removeSubclassGeneratedCode, removeSubclassStubbleMethods, requestProcedure, requestProceduresFrom, returnTypeFor, rootName, scheduleTermination, sendProxyTo, sendSelfTo, serverNameFor, setGC, signal, signals, smalltalkSelector, stClientProtocol, stubbleSelectorTokenReturnsArguments, subclassNonCopyVariables, takeOop, togglePromiseName, togglePromiseOfParse, unimplemented, unmangle, verifyFreeze, wipeStubble
 
Methods inherited from class org.abora.gold.java.AboraHeaper
asOop, basicInspect, displayString, error, hack, halt, inspect, knownBug, mightNotImplement, REQUIRES, shouldImplement, shouldNotImplement, stubbleForSubclassResponsibility, thingToDo, willNotImplement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AllConverters

protected static CategoryTable AllConverters

LastConverter

protected static Converter LastConverter

LastFrom

protected static Category LastFrom

LastTo

protected static Category LastTo
Constructor Detail

Converter

public Converter(Category from,
                 Category to)
remember the kind of converter this is. It is in the parameters passed to this by
subclass
constructors that a concrete Converter class declares what types it knows how to convert
to what.
See any subclass's constructor.

Method Detail

convert

public Heaper convert(Heaper value)
perform the conversion. This is defined by those who define a new converter, but not
directly called
by clients. Clients invoke conversion purely by using the CONVERT macro


actualHashForEqual

public int actualHashForEqual()
Overrides:
actualHashForEqual in class Heaper

isEqual

public boolean isEqual(java.lang.Object other)

fetchConverter

public static Converter fetchConverter(Category from,
                                       Category to)
find the best available converter. See class comment for definition of best.


getConversion

public static Heaper getConversion(Category to,
                                   Heaper value)
get the best converter and use it to actually do the conversion.
Clients should only use the CONVERT macro instead


getConverter

public static Converter getConverter(Category from,
                                     Category to)
find the best available converter. See class comment for definition of best.


initTimeInherited

public static void initTimeInherited()
create an instance of the converter. The constructor places it into the AllConverters
table


initTimeNonInherited

public static void initTimeNonInherited()
create an instance and assign it to the class instance variable


linkTimeNonInherited

public static void linkTimeNonInherited()
create an instance and assign it to the class instance variable


suppressInitTimeInherited

public static void suppressInitTimeInherited()

suppressLinkTimeInherited

public static void suppressLinkTimeInherited()

CONVERT

public static Heaper CONVERT(Category to,
                             Heaper thing)
convert using the best available converter



Translation - Copyright © 2003 David G Jones. All Rights Reserved.
Original Udanax-Gold - Copyright © 1979-1999 Udanax.com. All rights reserved.