oscript.data
Class BuiltinType

java.lang.Object
  extended by oscript.data.Value
      extended by oscript.data.Type
          extended by oscript.data.JavaClassWrapper
              extended by oscript.data.BuiltinType
All Implemented Interfaces:
java.io.Serializable

public class BuiltinType
extends JavaClassWrapper

A BuiltinType instance is used to represent a built-in type. This is similar to JavaClassWrapper, in that it allows a java type to be sub-classed or instantiated, but it's difference is that it restricts access. Because the Value interface has dummy methods for all the possible methods it's subclass may implement, we have to do this to prevent the built-in types from appearing to have methods that they don't have. For example:

   var m = true.bopPlus;
 
The Value dummy methods throw the appropriate exceptions if you try and use a non-existant method, for example:
   var v = true + false;
 
To accomodate the possibility of things changing between when an object referencing this object is serialized, and when it is read back from a serial data stream (in a different invokation of the JVM), only the class- name is stored. The other paramters are loaded as via reflection as static fields of the named class:

Version:
1.38
Author:
Rob Clark (rob@ti.com)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class oscript.data.JavaClassWrapper
JavaClassWrapper.Base, JavaClassWrapper.Derived, JavaClassWrapper.JavaClassWrapperImpl
 
Field Summary
 
Fields inherited from class oscript.data.JavaClassWrapper
impl, javaClass, MEMBER_NAMES, PARENT_TYPE_NAME, TYPE, TYPE_NAME, wrapperImpl
 
Fields inherited from class oscript.data.Type
HIDDEN_TYPE
 
Fields inherited from class oscript.data.Value
DEBUG, NULL, UNDEFINED
 
Method Summary
 Value bopCast(Value val)
          Perform the cast operation, (a)b is equivalent to a.bopCast(b)
 java.lang.String castToString()
          Convert this object to a native java String value.
protected  java.lang.Object doConstruct(StackFrame sf, MemberTable args, boolean isWrapper)
          Overloaded, because of how we handle args to the constructor.
protected  Value getTypeMember(Value obj, int id)
          Overloaded to hide "non-existant" methods.
protected  void init()
          Initialize this object.
 boolean isA(Value type)
          If this object is a type, determine if an instance of this type is an instance of the specified type, ie.
static BuiltinType makeBuiltinType(java.lang.String className)
          Get an instance of a built-in type.
protected  void populateMemberSet(java.util.Set s, boolean debugger)
          Derived classes that implement JavaClassWrapper.getMember(int, boolean) should also implement this.
protected  void populateTypeMemberSet(java.util.Set s, boolean debugger)
          Derived classes that implement getTypeMember(oscript.data.Value, int) should also implement this.
 
Methods inherited from class oscript.data.JavaClassWrapper
callAsConstructor, callAsExtends, castToJavaObject, forName, getClassLoader, getClassWrapper, getClassWrapper, getMember, getName, getTypeImpl, getTypeMemberImpl
 
Methods inherited from class oscript.data.Value
_getTypeMember, _populateTypeMemberSet, bopBitwiseAnd, bopBitwiseAndR, bopBitwiseOr, bopBitwiseOrR, bopBitwiseXor, bopBitwiseXorR, bopCastR, bopDivide, bopDivideR, bopEquals, bopEqualsR, bopGreaterThan, bopGreaterThanOrEquals, bopGreaterThanOrEqualsR, bopGreaterThanR, bopInstanceOf, bopInstanceOfR, bopLeftShift, bopLeftShiftR, bopLessThan, bopLessThanOrEquals, bopLessThanOrEqualsR, bopLessThanR, bopLogicalAnd, bopLogicalAndR, bopLogicalOr, bopLogicalOrR, bopMinus, bopMinusR, bopMultiply, bopMultiplyR, bopNotEquals, bopNotEqualsR, bopPlus, bopPlusR, bopRemainder, bopRemainderR, bopSignedRightShift, bopSignedRightShiftR, bopUnsignedRightShift, bopUnsignedRightShiftR, callAsConstructor, callAsConstructor, callAsExtends, callAsExtends, callAsFunction, callAsFunction, callAsFunction, castToBoolean, castToExactNumber, castToInexactNumber, elementAt, elementsAt, getMember, getMember, getMember, getMember, getMember, getMonitor, getType, getTypeMember, length, memberSet, noSuchMember, opAssign, readExternal, toString, unhand, uopBitwiseNot, uopDecrement, uopIncrement, uopLogicalNot, uopMinus, uopPlus, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

makeBuiltinType

public static final BuiltinType makeBuiltinType(java.lang.String className)
Get an instance of a built-in type. This method ensures that only a single instance representing a type gets created, regardless of the number of times this is called. This is needed to keep things sane when serialization is going on.

Parameters:
className - the name of the java class implementing the built-in type.

init

protected void init()
Description copied from class: JavaClassWrapper
Initialize this object. Initialization is done on demand because impl and wrapperImpl are transient, and might not exist if this object gets unserialized...

Overrides:
init in class JavaClassWrapper

isA

public boolean isA(Value type)
If this object is a type, determine if an instance of this type is an instance of the specified type, ie. if this is type, or a subclass.

Overrides:
isA in class JavaClassWrapper
Parameters:
type - the type to compare this type to
Returns:
true or false
Throws:
PackagedScriptObjectException(NoSuchMemberException)

castToString

public java.lang.String castToString()
                              throws PackagedScriptObjectException
Convert this object to a native java String value.

Overrides:
castToString in class JavaClassWrapper
Returns:
a String value
Throws:
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException

bopCast

public Value bopCast(Value val)
              throws PackagedScriptObjectException
Perform the cast operation, (a)b is equivalent to a.bopCast(b)

Overrides:
bopCast in class Value
Parameters:
val - the other value
Returns:
the result
Throws:
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException

getTypeMember

protected Value getTypeMember(Value obj,
                              int id)
Overloaded to hide "non-existant" methods. (Ie. methods from Value base class.)

Overrides:
getTypeMember in class JavaClassWrapper
Parameters:
obj - an object of this type
id - the id of the symbol that maps to the member
Returns:
a reference to the member, or null
See Also:
Value.populateTypeMemberSet(java.util.Set, boolean)

doConstruct

protected java.lang.Object doConstruct(StackFrame sf,
                                       MemberTable args,
                                       boolean isWrapper)
Overloaded, because of how we handle args to the constructor.

Overrides:
doConstruct in class JavaClassWrapper

populateTypeMemberSet

protected void populateTypeMemberSet(java.util.Set s,
                                     boolean debugger)
Derived classes that implement getTypeMember(oscript.data.Value, int) should also implement this.

Overrides:
populateTypeMemberSet in class JavaClassWrapper
Parameters:
s - the set to populate
debugger - true if being used by debugger, in which case both public and private/protected field names should be returned
See Also:
getTypeMember(oscript.data.Value, int)

populateMemberSet

protected void populateMemberSet(java.util.Set s,
                                 boolean debugger)
Derived classes that implement JavaClassWrapper.getMember(int, boolean) should also implement this.

Overrides:
populateMemberSet in class JavaClassWrapper
Parameters:
s - the set to populate
debugger - true if being used by debugger, in which case both public and private/protected field names should be returned
See Also:
JavaClassWrapper.getMember(int, boolean)