Reflection Services

The reflection module is meant to provide a means of translating aspects of an object’s internal representation into a single-quoted string suitable for display and as such provides services beyond those of the global symbols table.

 

The String Intrinsic toSString() Method

The String intrinsic class provides the static method toSString(val, flgs). This method will translate any value, integer, object, list, function pointer, enumerator, etc., to a single-quoted string.

 

The flgs variable argument list has the following format:

 

<control_enumerator>, <reference_enumerator>, <special_flags>

 

The control_enumerator and the reference_enumerator are strictly used for formatting the internal representation of an object. The special_flags argument controls special aspects of the production of a single-quoted string.

 

control_enumerator – indicates to which associated mapping method control is passed:

 

·          MapObjReference – maps an object reference to a single-quoted string

·          MapObjStructure – maps an object’s structure to a single-quoted string

·          MapObjValue – maps an object’s value to a single-quoted string

 

reference_enumerator – indicates the format of the object reference:

 

·          MapObjRefSym – maps an object to its symbolic reference

·          MapObjRefTag – maps an object to its object reference tag, or if an object reference tag is not available, to its symbolic reference

·          MapObjRefAHref – maps an object to a command ahref using the object reference tag, or if an object reference tag is unavailable, the symbolic reference

 

special_flags – provide any further special flags for the production of the single-quoted string.

 

Object Reference

An object reference is a value by which the object can be referred to, either programmatically, as in the case of a symbolic reference, or through reference to a tag associated with the object. The mapping of an object reference to a single-quoted string may take the form of an object’s symbolic reference, an object reference tag, or a command ahref.

 

The single-quoted string representation of an object reference may be a symbolic like ‘me’ or an object reference tag such as ‘tads#4e0’ or a command ahref such as ‘@show tag tads#4e0’.

Object Structure

An object structure is the list produced by the getStructure() method converted to a single-quoted string. An object’s structure is the list of traits and properties produced as we traverse the object’s inheritance hierarchy.

 

Object Value

An object’s value is dependent upon the intrinsic class from which it derives. The following table identifies the kinds of values associated with each class:

 

Class

Value

Object

The Object Reference as determined by the reference_enumerator. If no enumerator is specified the default is the object’s symbolic reference.

BigNumber

The string representation of the numeric value of the BigNumber object limited to 12 significant digits.

ByteArray

The string representation of the ByteArray using the default display CharacterSet

CharacterSet

The string representation of the name of the CharacterSet

Collection

The string representation of an iteration of the Collection elements as converted to a List

List

The string representation of the List’s elements enclosed in ‘[]’ brackets.

LookupTable

The string representation of the merged keys List and values List.

RexPattern

The string representation of the original pattern string with html translation

String

The string representation of the String with html translation

Vector

The string representation of the Vector as converted to a List

TadsObject

The Object Reference as determined by the reference_enumerator. If no enumerator is specified the default is the object’s symbolic reference.

 

Mapping an Object’s Internal Representation to a Single-quoted String

Every object derived from the intrinsic class Object provides this general method for translating its internal representation into a single-quoted string. The method mapToSString([flgs]) takes a variable list argument that can have the following values:

 

 

Mapping an Object Reference to a Single-quoted String

Every Object class object defines the method mapObjReferenceToSString([flgs]). The method produces a single-quoted string representation of the object’s reference as determined by the reference_enumerator. If no reference_enumerator is provided the method defaults to the object’s symbolic reference.

 

Mapping an Object’s Symbolic Reference to a Single-quoted String

The mapObjRefSymToSString() method maps the object’s symbolic reference, as obtained from the global symbols table, to a single-quoted string.

 

Mapping an Object’s Reference Tag to a Single-quoted String

The mapObjRefTagToSString() method maps the object’s reference tag (obtained from getObjTagAndSym()) to a single-quoted string.

 

Mapping a Command AHref to a Single-quoted String

The mapObjRefAHrefToSString() method maps the last stored command aHref (by default @show) and the object’s reference tag or symbol to a single-quoted string.

Mapping an Object’s Structure to a Single-quoted String

The mapObjStructureToSString([flgs]) method maps the object structure (obtained from getStructure()) to a single-quoted string.

Mapping an Object’s Value to a Single-quoted String

The mapObjValueToSString([flgs]) method maps the object value (determined by the intrinsic class the object derives from, see table above) to a single-quoted string.

 

Special Mapping Representations

Single-quoted string representations of certain datatypes are worth noting.

 

Datatype

Representation

TypeList

[ ‘foo’, ‘bar’, ‘baz’ ]

TypeString

‘\’abcdefg\’’

TypeProp

&property

 

 

 

This file is part of the TADS 3 Proteus Library Extension

Copyright © 2001-2004 Kevin Forchione. All rights reserved.