ptolemy.actor.lib.jni
Class PointerToken

java.lang.Object
  extended by ptolemy.data.Token
      extended by ptolemy.actor.lib.jni.PointerToken
All Implemented Interfaces:
java.io.Serializable

public class PointerToken
extends Token

A token that contains the memory location of a C object. Used to maintain C objects between JNI calls. Attempts to access the object from Java will raise an IllegalActionException.

Note that this class assumes a 32-bit memory size so that an pointer may be held in an integer. Actors that use this class are not likely to work on a 64-bit machine, see Bug 285 - Codegen PointerTokens do not work on 64 bit Java because PointerToken assumes 32 bits

Since:
Ptolemy II 7.1
Version:
$Id: PointerToken.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Teale Fristoe
See Also:
Serialized Form
Accepted Rating:
Red
Proposed Rating:
Red (tbf)

Nested Class Summary
static class PointerToken.PointerType
          The pointer type.
 
Field Summary
private static boolean _checked32Bit
          True if we have checked that we are on a 32 Bit platform.
private static boolean _is32Bit
          True if we are on a 32Bit platform.
private  int _value
          The memory address of the pointer.
static Type POINTER
          The Pointer type: the least upper bound of all the pointer types.
 
Fields inherited from class ptolemy.data.Token
NIL
 
Constructor Summary
PointerToken()
          Construct an empty token.
PointerToken(int pointer)
          Construct a token with the specified memory location.
 
Method Summary
private static void _check32Bit()
           
 Type getType()
          Return the type of this token.
 int getValue()
          Return the address of the pointer.
static boolean is32Bit()
          Return true if this is a 32bit JVM.
 BooleanToken isEqualTo(Token rightArgument)
          Test for equality of the values of this Token and the argument Token.
 java.lang.String toString()
          Return a String representation of the PointerToken, including the address.
 
Methods inherited from class ptolemy.data.Token
add, addReverse, divide, divideReverse, isCloseTo, isCloseTo, isNil, modulo, moduloReverse, multiply, multiplyReverse, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, one, pow, subtract, subtractReverse, zero, zeroReturnType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

POINTER

public static final Type POINTER
The Pointer type: the least upper bound of all the pointer types.


_checked32Bit

private static boolean _checked32Bit
True if we have checked that we are on a 32 Bit platform.


_is32Bit

private static boolean _is32Bit
True if we are on a 32Bit platform.


_value

private int _value
The memory address of the pointer.

Constructor Detail

PointerToken

public PointerToken()
Construct an empty token.


PointerToken

public PointerToken(int pointer)
             throws IllegalActionException
Construct a token with the specified memory location.

Parameters:
pointer - The specified object referred to by this token.
Throws:
IllegalActionException - If the argument is not of the appropriate type (may be thrown by derived classes, but is not thrown here).
Method Detail

getType

public Type getType()
Return the type of this token.

Overrides:
getType in class Token
Returns:
POINTER, the least upper bound of all the pointer types.

getValue

public int getValue()
Return the address of the pointer.

Returns:
The int that this Token was created with.

isEqualTo

public final BooleanToken isEqualTo(Token rightArgument)
                             throws IllegalActionException
Test for equality of the values of this Token and the argument Token. Two PointerTokens are equal if their addresses are equal.

Overrides:
isEqualTo in class Token
Parameters:
rightArgument - The Token to test against.
Returns:
A boolean token that contains the value true if the addresses are the same.
Throws:
IllegalActionException - Not thrown in this base class.

toString

public java.lang.String toString()
Return a String representation of the PointerToken, including the address.

Overrides:
toString in class Token
Returns:
A String representation of the PointerToken.

is32Bit

public static boolean is32Bit()
Return true if this is a 32bit JVM.

Returns:
true if this is a 32bit JVM.

_check32Bit

private static void _check32Bit()