oscript.data
Class ScriptPackage

java.lang.Object
  extended byoscript.data.Value
      extended byoscript.data.OObject
          extended byoscript.data.ScriptPackage
All Implemented Interfaces:
java.io.Serializable

public final class ScriptPackage
extends OObject

The implementation of a package system for scripts. This handles automatically importing script source files when the have not yet been loaded, or are out of date. The script package system relies on a couple of coding conventions:

The way the package system is used:
   const var foo = new ScriptPackage("/path/to/foo");
   var fb = new foo.bar.FooBar();
 
When resolving the request for the member FooBar, if the source file /path/to/foo/bar/FooBar.os has not yet been loaded, or has been modified since the last time it was accessed, the package system will create a new scope and import the source file into that scope. It will then return the public variable/function FooBar.

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

Field Summary
static java.lang.String[] MEMBER_NAMES
           
static java.lang.String PARENT_TYPE_NAME
           
static Value TYPE
          The type object for an instance of ScriptPackage.
static java.lang.String TYPE_NAME
           
 
Fields inherited from class oscript.data.OObject
EMPTY_EXPR_LIST_EVALUATOR
 
Fields inherited from class oscript.data.Value
DEBUG, NULL, UNDEFINED
 
Constructor Summary
ScriptPackage(MemberTable args)
          Class Constructor.
ScriptPackage(java.lang.String path)
          Class Constructor.
ScriptPackage(java.lang.String path, Scope parentScope)
          Class Constructor.
 
Method Summary
 java.lang.String castToString()
          Convert this object to a native java String value.
 Value getMember(int id, boolean exception)
          Get a member of this object.
protected  Value getTypeImpl()
          Get the type of this object.
protected  void populateMemberSet(java.util.Set s, boolean debugger)
          Derived classes that implement getMember(int, boolean) should also implement this.
 void reset()
          Clear the cached members.
 
Methods inherited from class oscript.data.Value
_getTypeMember, _populateTypeMemberSet, bopBitwiseAnd, bopBitwiseAndR, bopBitwiseOr, bopBitwiseOrR, bopBitwiseXor, bopBitwiseXorR, bopCast, 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, callAsConstructor, callAsExtends, callAsExtends, callAsExtends, callAsFunction, callAsFunction, callAsFunction, castToBoolean, castToExactNumber, castToInexactNumber, castToJavaObject, elementAt, elementsAt, getMember, getMember, getMember, getMember, getMember, getMonitor, getType, getTypeMember, getTypeMember, isA, length, memberSet, noSuchMember, opAssign, populateTypeMemberSet, 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
 

Field Detail

TYPE

public static final Value TYPE
The type object for an instance of ScriptPackage.


PARENT_TYPE_NAME

public static final java.lang.String PARENT_TYPE_NAME
See Also:
Constant Field Values

TYPE_NAME

public static final java.lang.String TYPE_NAME
See Also:
Constant Field Values

MEMBER_NAMES

public static final java.lang.String[] MEMBER_NAMES
Constructor Detail

ScriptPackage

public ScriptPackage(java.lang.String path,
                     Scope parentScope)
Class Constructor.

Parameters:
parentScope - the parent scope of this package

ScriptPackage

public ScriptPackage(java.lang.String path)
Class Constructor.


ScriptPackage

public ScriptPackage(MemberTable args)
              throws PackagedScriptObjectException
Class Constructor.

Parameters:
args - arguments to this constructor
Throws:
PackagedScriptObjectException(Exception) - if wrong number of args
PackagedScriptObjectException
Method Detail

getTypeImpl

protected Value getTypeImpl()
Get the type of this object. The returned type doesn't have to take into account the possibility of a script type extending a built-in type, since that is handled by Value.getType().

Overrides:
getTypeImpl in class OObject
Returns:
the object's type

reset

public void reset()
Clear the cached members. This is handy if you need to force reload members during development/debugging. Because of the potential expense incurred in reloading all members the next time they are accessed, this should only be used for development/debugging, and should not be used by deployed code


castToString

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

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

getMember

public Value getMember(int id,
                       boolean exception)
                throws PackagedScriptObjectException
Get a member of this object.

Overrides:
getMember in class OObject
Parameters:
id - the id of the symbol that maps to the member
exception - whether an exception should be thrown if the member object is not resolved
Returns:
a reference to the member
Throws:
PackagedScriptObjectException(NoSuchMethodException)
PackagedScriptObjectException(NoSuchMemberException)
PackagedScriptObjectException

populateMemberSet

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

Overrides:
populateMemberSet in class OObject
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:
getMember(int, boolean)