Top Description Inners Fields Constructors Methods
com.jogamp.gluegen

public Class ConstantDefinition

extends AliasedSymbolImpl
implements AliasedSemanticSymbol, ASTLocusTagProvider
Class Inheritance
All Implemented Interfaces
com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider, com.jogamp.gluegen.cgram.types.TypeComparator.AliasedSemanticSymbol, com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp, com.jogamp.gluegen.cgram.types.AliasedSymbol
Imports
java.math.BigInteger, java.util.Map, java.util.regex.Matcher, .Pattern, com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider, com.jogamp.gluegen.cgram.types.AliasedSymbol.AliasedSymbolImpl, .TypeComparator.AliasedSemanticSymbol, .TypeComparator.SemanticEqualityOp

Represents a [native] constant expression, comprises the [native] expression, see getNativeExpr() and the optional CNumber representation, see getNumber().

The representation of the equivalent java expression including the result type is covered by JavaExpr, which can be computed via computeJavaExpr(Map).

This class and its sub-classes define and convert all native expressions to Java space.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ConstantDefinition.CNumber

A Number, either integer, optionally [long, unsigned], or floating point, optionally [double].

public static class
ConstantDefinition.JavaExpr

A valid java expression, including its result type, usually generated from a native [C] expression, see JavaExpr#create(ConstantDefinition).

Field Summary

Modifier and TypeField and Description
private final ASTLocusTag
private final String
private final boolean
private final String
private final ConstantDefinition.CNumber
public static Pattern
patternCPPOperand

One of: + - * / | & ( ) << >>

Expression excludes patternDecimalOrIntNumber.

public static final Pattern
patternDecimalNumber

Complete pattern for floating point number, compatible and described in Double#valueOf(String).

public static final Pattern
patternDecimalOrIntNumber

Complete pattern for floating point and integer number, covering patternDecimalNumber and patternIntegerNumber.

public static Pattern
patternHexNumber

Complete pattern for hexadecimal number, including an optional sign [+-] and optional suffixes [uUlL].

public static final Pattern
patternIntegerNumber

Complete pattern for integer number, including an optional sign [+-] and optional suffixes [uUlL].

private final boolean
public static final long
public static final BigInteger

Constructor Summary

AccessConstructor and Description
public
ConstantDefinition(final String
unique name of this constant expression
name
,
final String
original [native] expression
nativeExpr
,
final ConstantDefinition.CNumber
optional CNumber representing this constant. If null, implementation attempts to derive a CNumber of the given nativeExpr.
number
,
final ASTLocusTag
AST location of the represented constant.
astLocus
)

Constructor for plain const-values, non-enumerates.

public
ConstantDefinition(final String
unique name of this constant expression
name
,
final String
original [native] expression
nativeExpr
,
final ConstantDefinition.CNumber
optional CNumber representing this constant. If null, implementation attempts to derive a CNumber of the given nativeExpr.
number
,
final String
optional name of the represented enumeration
enumName
,
final ASTLocusTag
AST location of the represented constant.
astLocus
)

Constructor for enumerates

private
ConstantDefinition(final String
unique name of this constant expression
name
,
final String
original [native] expression
nativeExpr
,
final ConstantDefinition.CNumber
optional CNumber representing this constant. If null, implementation attempts to derive a CNumber of the given nativeExpr.
number
,
final boolean
true if this constant is an enumerate, otherwise false.
isEnum
,
final String
optional name of the represented enumeration
enumName
,
final ASTLocusTag
AST location of the represented constant.
astLocus
)

Method Summary

Modifier and TypeMethod and Description
public final ConstantDefinition.JavaExpr
public static ConstantDefinition.CNumber
public static ConstantDefinition.CNumber
decodeDecimalNumber(final String v)

If the given string isDecimalNumber(String), return the decoded floating-point value, represented as a ANumber object, otherwise returns null.

public static ConstantDefinition.CNumber
decodeIntegerNumber(final String v)

If the given string isIntegerNumber(String), return the decoded integer value, represented as a ANumber, otherwise returns null.

private static long
decodeULong(final String v, final boolean neg)

public final boolean
equals(final Object
the reference object with which to compare.
arg
)

Overrides java.lang.Object.equals.

Equality test by its given name.
private static boolean
equals(final String s1, final String s2)

public final boolean
public ASTLocusTag
getASTLocusTag()

Implements com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.getASTLocusTag.

Returns this instance's ASTLocusTag, if available, otherwise returns null.
public String
getEnumName()

Returns null if this definition was not part of an enumeration, or if the enumeration is anonymous.

public String
getNativeExpr()

Returns the original [native] expression.

public ConstantDefinition.CNumber
getNumber()

Returns the parsed CNumber of the native expression, or null if the latter does not comprise a single number, i.e. is a complex expression.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Hash by its given name.
public final int
public boolean
hasNumber()

Returns true if this instance represents has a number, otherwise false.

public static boolean
public static boolean
isCPPOperand(final String s)

Matches pattern for valid CPP operands, see patternCPPOperand.

public static boolean
isDecimalNumber(final String s)

Matches pattern for floating point number, compatible and described in Double#valueOf(String).

public static boolean
isDecimalOrIntNumber(final String s)

Complete pattern for floating point and integer number, covering patternDecimalNumber and patternIntegerNumber.

public boolean
public static boolean
public static boolean
isIdentifier(final String value)

public static boolean
public static boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from com.jogamp.gluegen.cgram.types.AliasedSymbol.AliasedSymbolImpl:
addAliasedNamegetAliasedNamesgetAliasedStringgetNamegetOrigNamehasAliasesrename

Field Detail

astLocusback to summary
private final ASTLocusTag astLocus
enumNameback to summary
private final String enumName
isEnumback to summary
private final boolean isEnum
nativeExprback to summary
private final String nativeExpr
numberback to summary
private final ConstantDefinition.CNumber number
patternCPPOperandback to summary
public static Pattern patternCPPOperand

One of: + - * / | & ( ) << >>

Expression excludes patternDecimalOrIntNumber.

patternDecimalNumberback to summary
public static final Pattern patternDecimalNumber

Complete pattern for floating point number, compatible and described in Double#valueOf(String).

patternDecimalOrIntNumberback to summary
public static final Pattern patternDecimalOrIntNumber

Complete pattern for floating point and integer number, covering patternDecimalNumber and patternIntegerNumber.

patternHexNumberback to summary
public static Pattern patternHexNumber

Complete pattern for hexadecimal number, including an optional sign [+-] and optional suffixes [uUlL].

patternIntegerNumberback to summary
public static final Pattern patternIntegerNumber

Complete pattern for integer number, including an optional sign [+-] and optional suffixes [uUlL].

relaxedEqSemback to summary
private final boolean relaxedEqSem
UNSIGNED_INT_MAX_VALUEback to summary
public static final long UNSIGNED_INT_MAX_VALUE
UNSIGNED_LONG_MAX_VALUEback to summary
public static final BigInteger UNSIGNED_LONG_MAX_VALUE

Constructor Detail

ConstantDefinitionback to summary
public ConstantDefinition(final String name, final String nativeExpr, final ConstantDefinition.CNumber number, final ASTLocusTag astLocus)

Constructor for plain const-values, non-enumerates.

Parameters
name:String

unique name of this constant expression

nativeExpr:String

original [native] expression

number:ConstantDefinition.CNumber

optional CNumber representing this constant. If null, implementation attempts to derive a CNumber of the given nativeExpr.

astLocus:ASTLocusTag

AST location of the represented constant.

ConstantDefinitionback to summary
public ConstantDefinition(final String name, final String nativeExpr, final ConstantDefinition.CNumber number, final String enumName, final ASTLocusTag astLocus)

Constructor for enumerates

Parameters
name:String

unique name of this constant expression

nativeExpr:String

original [native] expression

number:ConstantDefinition.CNumber

optional CNumber representing this constant. If null, implementation attempts to derive a CNumber of the given nativeExpr.

enumName:String

optional name of the represented enumeration

astLocus:ASTLocusTag

AST location of the represented constant.

ConstantDefinitionback to summary
private ConstantDefinition(final String name, final String nativeExpr, final ConstantDefinition.CNumber number, final boolean isEnum, final String enumName, final ASTLocusTag astLocus)
Parameters
name:String

unique name of this constant expression

nativeExpr:String

original [native] expression

number:ConstantDefinition.CNumber

optional CNumber representing this constant. If null, implementation attempts to derive a CNumber of the given nativeExpr.

isEnum:boolean

true if this constant is an enumerate, otherwise false.

enumName:String

optional name of the represented enumeration

astLocus:ASTLocusTag

AST location of the represented constant.

Method Detail

computeJavaExprback to summary
public final ConstantDefinition.JavaExpr computeJavaExpr(final Map<String, ConstantDefinition.JavaExpr> constMap)

Computes the java expression based on this instance, see JavaExpr#create(ConstantDefinition).

decodeANumberback to summary
public static ConstantDefinition.CNumber decodeANumber(final String v)

Returns either decodeIntegerNumber(String), decodeDecimalNumber(String) or null.

decodeDecimalNumberback to summary
public static ConstantDefinition.CNumber decodeDecimalNumber(final String v)

If the given string isDecimalNumber(String), return the decoded floating-point value, represented as a ANumber object, otherwise returns null.

Method utilizes Double#valueOf(String).

decodeIntegerNumberback to summary
public static ConstantDefinition.CNumber decodeIntegerNumber(final String v)

If the given string isIntegerNumber(String), return the decoded integer value, represented as a ANumber, otherwise returns null.

Method strips off sign prefix + and integer modifier suffixes [uUlL] before utilizing Long#decode(String).

decodeULongback to summary
private static long decodeULong(final String v, final boolean neg) throws NumberFormatException
equalsback to summary
public final boolean equals(final Object arg)

Overrides java.lang.Object.equals.

Equality test by its given name.

Parameters
arg:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
equalsback to summary
private static boolean equals(final String s1, final String s2)
equalSemanticsback to summary
public final boolean equalSemantics(final TypeComparator.SemanticEqualityOp arg)

Implements com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp.equalSemantics.

Doc from com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp.equalSemantics.

Semantic equality test for Types exclusive its given name.

Annotations
@Override
getASTLocusTagback to summary
public ASTLocusTag getASTLocusTag()

Implements com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.getASTLocusTag.

Doc from com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.getASTLocusTag.

Returns this instance's ASTLocusTag, if available, otherwise returns null.

Annotations
@Override
getEnumNameback to summary
public String getEnumName()

Returns null if this definition was not part of an enumeration, or if the enumeration is anonymous.

getNativeExprback to summary
public String getNativeExpr()

Returns the original [native] expression.

getNumberback to summary
public ConstantDefinition.CNumber getNumber()

Returns the parsed CNumber of the native expression, or null if the latter does not comprise a single number, i.e. is a complex expression.

hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Hash by its given name.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
hashCodeSemanticsback to summary
public final int hashCodeSemantics()

Implements com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp.hashCodeSemantics.

Doc from com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp.hashCodeSemantics.

Semantic hashcode for Types exclusive its given name.

Annotations
@Override
hasNumberback to summary
public boolean hasNumber()

Returns true if this instance represents has a number, otherwise false.

isConstantExpressionback to summary
public static boolean isConstantExpression(final String value)
isCPPOperandback to summary
public static boolean isCPPOperand(final String s)

Matches pattern for valid CPP operands, see patternCPPOperand.

isDecimalNumberback to summary
public static boolean isDecimalNumber(final String s)

Matches pattern for floating point number, compatible and described in Double#valueOf(String).

isDecimalOrIntNumberback to summary
public static boolean isDecimalOrIntNumber(final String s)

Complete pattern for floating point and integer number, covering patternDecimalNumber and patternIntegerNumber.

isEnumback to summary
public boolean isEnum()
isHexNumberback to summary
public static boolean isHexNumber(final String s)

Matches patternHexNumber.

isIdentifierback to summary
public static boolean isIdentifier(final String value)
isIntegerNumberback to summary
public static boolean isIntegerNumber(final String s)

Matches isHexNumber(String) or patternIntegerNumber.

isNumberback to summary
public static boolean isNumber(final String s)

Matches isHexNumber(String) or isDecimalOrIntNumber(String).

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.jogamp.gluegen back to summary

public Class ConstantDefinition.CNumber

extends Object
Class Inheritance

A Number, either integer, optionally [long, unsigned], or floating point, optionally [double].

Field Summary

Modifier and TypeField and Description
public final double
f

The value if !

public final long
i

The value if isInteger

public final boolean
isDouble

true if number is a double precision floating point, i.e. !

public final boolean
isInteger

true if number is integer and value stored in i, otherwise false for floating point and value stored in f.

public final boolean
isLong

true if number is a long isInteger.

public final boolean
isUnsigned

true if number is an unsigned isInteger.

Constructor Summary

AccessConstructor and Description
public
CNumber(final boolean isLong, final boolean isUnsigned, final long value)

ctor for integer number

public
CNumber(final boolean isDouble, final double value)

ctor for floating point number

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(final Object
the reference object with which to compare.
arg
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public final String
public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

fback to summary
public final double f

The value if !isInteger

iback to summary
public final long i

The value if isInteger

isDoubleback to summary
public final boolean isDouble

true if number is a double precision floating point, i.e. !isInteger.

isIntegerback to summary
public final boolean isInteger

true if number is integer and value stored in i, otherwise false for floating point and value stored in f.

isLongback to summary
public final boolean isLong

true if number is a long isInteger.

isUnsignedback to summary
public final boolean isUnsigned

true if number is an unsigned isInteger.

Constructor Detail

CNumberback to summary
public CNumber(final boolean isLong, final boolean isUnsigned, final long value)

ctor for integer number

CNumberback to summary
public CNumber(final boolean isDouble, final double value)

ctor for floating point number

Method Detail

equalsback to summary
public boolean equals(final Object arg)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
arg:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toJavaStringback to summary
public final String toJavaString()
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

com.jogamp.gluegen back to summary

public Class ConstantDefinition.JavaExpr

extends Object
Class Inheritance

A valid java expression, including its result type, usually generated from a native [C] expression, see JavaExpr#create(ConstantDefinition).

Field Summary

Modifier and TypeField and Description
public final String
public final Number
public final String
public final ConstantDefinition.CNumber

Constructor Summary

AccessConstructor and Description
public
JavaExpr(final String javaExpression, final ConstantDefinition.CNumber resultType)

Method Summary

Modifier and TypeMethod and Description
public static ConstantDefinition.JavaExpr
compute(final ConstantDefinition constDef, final Map<String, ConstantDefinition.JavaExpr> constMap)

Computes a valid java expression based on the given ConstantDefinition, which may either be a single CNumber, see ConstantDefinition#getNumber(), or represents a native expression, see ConstantDefinition#getExpr().

private static ConstantDefinition.CNumber
private static ConstantDefinition.CNumber
getANumber(final ConstantDefinition constDef, final String value)

private static ConstantDefinition.CNumber
processValue(final ConstantDefinition constDef, final String sValue, final Map<String, ConstantDefinition.JavaExpr> constMap, ConstantDefinition.CNumber resultType, final StringBuilder javaExpr)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

javaExpressionback to summary
public final String javaExpression
resultJavaTypeback to summary
public final Number resultJavaType
resultJavaTypeNameback to summary
public final String resultJavaTypeName
resultTypeback to summary
public final ConstantDefinition.CNumber resultType

Constructor Detail

JavaExprback to summary
public JavaExpr(final String javaExpression, final ConstantDefinition.CNumber resultType)

Method Detail

computeback to summary
public static ConstantDefinition.JavaExpr compute(final ConstantDefinition constDef, final Map<String, ConstantDefinition.JavaExpr> constMap)

Computes a valid java expression based on the given ConstantDefinition, which may either be a single CNumber, see ConstantDefinition#getNumber(), or represents a native expression, see ConstantDefinition#getExpr().

evalTypeback to summary
private static ConstantDefinition.CNumber evalType(final ConstantDefinition.CNumber resultType, final ConstantDefinition.CNumber type)
getANumberback to summary
private static ConstantDefinition.CNumber getANumber(final ConstantDefinition constDef, final String value)
processValueback to summary
private static ConstantDefinition.CNumber processValue(final ConstantDefinition constDef, final String sValue, final Map<String, ConstantDefinition.JavaExpr> constMap, ConstantDefinition.CNumber resultType, final StringBuilder javaExpr)