oscript.util
Interface MemberTable

All Known Implementing Classes:
OArray, OArray.OJavaArray

public interface MemberTable

A member table is a special array, with some special methods that don't need to exist for regular script arrays:

Since the member table is used by scope and to pass args to a function/ constructor, performance is critical, which is the reason for some of these methods.

Version:
1
Author:
Rob Clark (rob@ti.com)

Method Summary
 void ensureCapacity(int sz)
          Ensure that the member-table has sufficient capacity to accomodate the index sz.
 void free()
          Indication from creator of member-table that resources allocated from the stack are no longer needed and should be released.
 int length()
          Get the current size of the member-table.
 void push1(Value val)
          Push a single parameter into the table.
 void push2(Value val1, Value val2)
          Push two values into the table.
 void push3(Value val1, Value val2, Value val3)
          Push three values into the table.
 void push4(Value val1, Value val2, Value val3, Value val4)
          Push four values into the table.
 Reference referenceAt(int idx)
          Return the reference at the specified index.
 void reset()
          An indication from the creator of the member-table that, while the table itself is still required, the references referred to by the table are no longer required and can be freed.
 MemberTable safeCopy()
          Indication to the member-table that a "safe" copy is required.
 

Method Detail

referenceAt

Reference referenceAt(int idx)
Return the reference at the specified index. This does not necessarily grow the array, so the user should be sure to use ensureCapacity(int) to ensure the array has sufficient capacity before dereferencing an index into the table which is not known to exist.

Parameters:
idx - an index into the member-table
Returns:
a reference

ensureCapacity

void ensureCapacity(int sz)
Ensure that the member-table has sufficient capacity to accomodate the index sz. Grow the array, if necessary.

Parameters:
sz - the requested table size

safeCopy

MemberTable safeCopy()
Indication to the member-table that a "safe" copy is required. This means that the table may need to outlive the stack-frame that it was (possibly) allocated from. What it means to convert this table into a "safe" copy depends on the implementation of the table. A safe copy is still valid after free() is called.

Returns:
a safe copy of this table

push1

void push1(Value val)
Push a single parameter into the table.

Parameters:
val - the value to push

push2

void push2(Value val1,
           Value val2)
Push two values into the table.

Parameters:
val1 - the value to push
val2 - the value to push

push3

void push3(Value val1,
           Value val2,
           Value val3)
Push three values into the table.

Parameters:
val1 - the value to push
val2 - the value to push
val3 - the value to push

push4

void push4(Value val1,
           Value val2,
           Value val3,
           Value val4)
Push four values into the table.

Parameters:
val1 - the value to push
val2 - the value to push
val3 - the value to push
val4 - the value to push

reset

void reset()
An indication from the creator of the member-table that, while the table itself is still required, the references referred to by the table are no longer required and can be freed.


free

void free()
Indication from creator of member-table that resources allocated from the stack are no longer needed and should be released. (If the member table is needed after this point, a safe copy should have already been obtained by calling safeCopy().)


length

int length()
Get the current size of the member-table. The maximum index which can be referenced via referenceAt(int) is length()-1

Returns:
the current size