Package com.jogamp.gluegen
Class ConstantDefinition
- java.lang.Object
-
- com.jogamp.gluegen.cgram.types.AliasedSymbol.AliasedSymbolImpl
-
- com.jogamp.gluegen.ConstantDefinition
-
- All Implemented Interfaces:
ASTLocusTag.ASTLocusTagProvider
,AliasedSymbol
,TypeComparator.AliasedSemanticSymbol
,TypeComparator.SemanticEqualityOp
public class ConstantDefinition extends AliasedSymbol.AliasedSymbolImpl implements TypeComparator.AliasedSemanticSymbol, ASTLocusTag.ASTLocusTagProvider
Represents a [native] constant expression, comprises the [native] expression, seegetNativeExpr()
and the optionalConstantDefinition.CNumber
representation, seegetNumber()
.The representation of the equivalent java expression including the result type is covered by
ConstantDefinition.JavaExpr
, which can be computed viacomputeJavaExpr(Map)
.This class and its sub-classes define and convert all native expressions to Java space.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConstantDefinition.CNumber
A Number, either integer, optionally [long, unsigned], or floating point, optionally [double].static class
ConstantDefinition.JavaExpr
A valid java expression, including its result type, usually generated from a native [C] expression, seeJavaExpr#create(ConstantDefinition)
.-
Nested classes/interfaces inherited from interface com.jogamp.gluegen.cgram.types.AliasedSymbol
AliasedSymbol.AliasedSymbolImpl, AliasedSymbol.NoneAliasedSymbol
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
patternCPPOperand
One of:+
-
*
/
|
&
(
)
<<
>>
~
static Pattern
patternDecimalNumber
Complete pattern forfloating point
number, compatible and described inDouble.valueOf(String)
.static Pattern
patternDecimalOrIntNumber
Complete pattern forfloating point
andinteger
number, coveringpatternDecimalNumber
andpatternIntegerNumber
.static Pattern
patternHexNumber
Complete pattern forhexadecimal
number, including an optional sign[+-]
and optional suffixes[uUlL]
.static Pattern
patternIntegerNumber
Complete pattern forinteger
number, including an optional sign[+-]
and optional suffixes[uUlL]
.static long
UNSIGNED_INT_MAX_VALUE
static BigInteger
UNSIGNED_LONG_MAX_VALUE
-
Constructor Summary
Constructors Constructor Description ConstantDefinition(String name, String nativeExpr, ConstantDefinition.CNumber number, ASTLocusTag astLocus)
Constructor for plain const-values, non-enumerates.ConstantDefinition(String name, String nativeExpr, ConstantDefinition.CNumber number, String enumName, ASTLocusTag astLocus)
Constructor for enumerates
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstantDefinition.JavaExpr
computeJavaExpr(Map<String,ConstantDefinition.JavaExpr> constMap)
Computes thejava expression
based on this instance, seeJavaExpr#create(ConstantDefinition)
.static ConstantDefinition.CNumber
decodeANumber(String v)
static ConstantDefinition.CNumber
decodeDecimalNumber(String v)
If the given stringisDecimalNumber(String)
, return the decoded floating-point value, represented as aANumber
object, otherwise returnsnull
.static ConstantDefinition.CNumber
decodeIntegerNumber(String v)
If the given stringisIntegerNumber(String)
, return the decoded integer value, represented as aANumber
, otherwise returnsnull
.boolean
equals(Object arg)
Equality test by its givenname
.boolean
equalSemantics(TypeComparator.SemanticEqualityOp arg)
Semantic equality test for Types exclusive its givenname
.ASTLocusTag
getASTLocusTag()
Returns this instance'sASTLocusTag
, if available, otherwise returnsnull
.String
getEnumName()
Returnsnull
if this definition was not part of an enumeration, or if the enumeration is anonymous.String
getNativeExpr()
Returns the original [native] expression.ConstantDefinition.CNumber
getNumber()
Returns the parsedConstantDefinition.CNumber
of thenative expression
, ornull
if the latter does not comprise a single number, i.e.int
hashCode()
Hash by its givenname
.int
hashCodeSemantics()
Semantic hashcode for Types exclusive its givenname
.boolean
hasNumber()
static boolean
isConstantExpression(String value)
static boolean
isCPPOperand(String s)
Matches pattern for valid CPP operands, seepatternCPPOperand
.static boolean
isDecimalNumber(String s)
Matches pattern forfloating point
number, compatible and described inDouble.valueOf(String)
.static boolean
isDecimalOrIntNumber(String s)
Complete pattern forfloating point
andinteger
number, coveringpatternDecimalNumber
andpatternIntegerNumber
.boolean
isEnum()
static boolean
isHexNumber(String s)
MatchespatternHexNumber
.static boolean
isIdentifier(String value)
static boolean
isIntegerNumber(String s)
MatchesisHexNumber(String)
orpatternIntegerNumber
.static boolean
isNumber(String s)
MatchesisHexNumber(String)
orisDecimalOrIntNumber(String)
.String
toString()
-
Methods inherited from class com.jogamp.gluegen.cgram.types.AliasedSymbol.AliasedSymbolImpl
addAliasedName, getAliasedNames, getAliasedString, getName, getOrigName, hasAliases, rename
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.jogamp.gluegen.cgram.types.AliasedSymbol
addAliasedName, getAliasedNames, getAliasedString, getName, getOrigName, hasAliases, rename
-
-
-
-
Field Detail
-
UNSIGNED_INT_MAX_VALUE
public static final long UNSIGNED_INT_MAX_VALUE
- See Also:
- Constant Field Values
-
UNSIGNED_LONG_MAX_VALUE
public static final BigInteger UNSIGNED_LONG_MAX_VALUE
-
patternHexNumber
public static Pattern patternHexNumber
Complete pattern forhexadecimal
number, including an optional sign[+-]
and optional suffixes[uUlL]
.
-
patternDecimalNumber
public static final Pattern patternDecimalNumber
Complete pattern forfloating point
number, compatible and described inDouble.valueOf(String)
.
-
patternDecimalOrIntNumber
public static final Pattern patternDecimalOrIntNumber
Complete pattern forfloating point
andinteger
number, coveringpatternDecimalNumber
andpatternIntegerNumber
.
-
patternIntegerNumber
public static final Pattern patternIntegerNumber
Complete pattern forinteger
number, including an optional sign[+-]
and optional suffixes[uUlL]
.
-
patternCPPOperand
public static Pattern patternCPPOperand
-
-
Constructor Detail
-
ConstantDefinition
public ConstantDefinition(String name, String nativeExpr, ConstantDefinition.CNumber number, ASTLocusTag astLocus)
Constructor for plain const-values, non-enumerates.- Parameters:
name
- unique name of this constant expressionnativeExpr
- original [native] expressionnumber
- optionalConstantDefinition.CNumber
representing this constant. Ifnull
, implementation attempts to derive aConstantDefinition.CNumber
of the givennativeExpr
.astLocus
- AST location of the represented constant.
-
ConstantDefinition
public ConstantDefinition(String name, String nativeExpr, ConstantDefinition.CNumber number, String enumName, ASTLocusTag astLocus)
Constructor for enumerates- Parameters:
name
- unique name of this constant expressionnativeExpr
- original [native] expressionnumber
- optionalConstantDefinition.CNumber
representing this constant. Ifnull
, implementation attempts to derive aConstantDefinition.CNumber
of the givennativeExpr
.enumName
- optional name of the represented enumerationastLocus
- AST location of the represented constant.
-
-
Method Detail
-
getASTLocusTag
public ASTLocusTag getASTLocusTag()
Description copied from interface:ASTLocusTag.ASTLocusTagProvider
Returns this instance'sASTLocusTag
, if available, otherwise returnsnull
.- Specified by:
getASTLocusTag
in interfaceASTLocusTag.ASTLocusTagProvider
-
hashCodeSemantics
public final int hashCodeSemantics()
Description copied from interface:TypeComparator.SemanticEqualityOp
Semantic hashcode for Types exclusive its givenname
.- Specified by:
hashCodeSemantics
in interfaceTypeComparator.SemanticEqualityOp
- See Also:
TypeComparator.SemanticEqualityOp.equalSemantics(SemanticEqualityOp)
-
equalSemantics
public final boolean equalSemantics(TypeComparator.SemanticEqualityOp arg)
Description copied from interface:TypeComparator.SemanticEqualityOp
Semantic equality test for Types exclusive its givenname
.- Specified by:
equalSemantics
in interfaceTypeComparator.SemanticEqualityOp
- See Also:
TypeComparator.SemanticEqualityOp.hashCodeSemantics()
-
getNativeExpr
public String getNativeExpr()
Returns the original [native] expression.
-
getNumber
public ConstantDefinition.CNumber getNumber()
Returns the parsedConstantDefinition.CNumber
of thenative expression
, ornull
if the latter does not comprise a single number, i.e. is a complex expression.
-
hasNumber
public boolean hasNumber()
-
getEnumName
public String getEnumName()
Returnsnull
if this definition was not part of an enumeration, or if the enumeration is anonymous.
-
isEnum
public boolean isEnum()
-
computeJavaExpr
public final ConstantDefinition.JavaExpr computeJavaExpr(Map<String,ConstantDefinition.JavaExpr> constMap)
Computes thejava expression
based on this instance, seeJavaExpr#create(ConstantDefinition)
.
-
isConstantExpression
public static boolean isConstantExpression(String value)
-
isIdentifier
public static boolean isIdentifier(String value)
-
decodeANumber
public static ConstantDefinition.CNumber decodeANumber(String v)
- Parameters:
v
-
-
decodeIntegerNumber
public static ConstantDefinition.CNumber decodeIntegerNumber(String v)
If the given stringisIntegerNumber(String)
, return the decoded integer value, represented as aANumber
, otherwise returnsnull
.Method strips off sign prefix
+
and integer modifier suffixes[uUlL]
before utilizingLong.decode(String)
.- Parameters:
v
-
-
decodeDecimalNumber
public static ConstantDefinition.CNumber decodeDecimalNumber(String v)
If the given stringisDecimalNumber(String)
, return the decoded floating-point value, represented as aANumber
object, otherwise returnsnull
.Method utilizes
Double.valueOf(String)
.- Parameters:
v
-isDouble
- return value fordouble
flag
-
isNumber
public static boolean isNumber(String s)
MatchesisHexNumber(String)
orisDecimalOrIntNumber(String)
.
-
isIntegerNumber
public static boolean isIntegerNumber(String s)
MatchesisHexNumber(String)
orpatternIntegerNumber
.
-
isHexNumber
public static boolean isHexNumber(String s)
MatchespatternHexNumber
.
-
isDecimalNumber
public static boolean isDecimalNumber(String s)
Matches pattern forfloating point
number, compatible and described inDouble.valueOf(String)
.
-
isDecimalOrIntNumber
public static boolean isDecimalOrIntNumber(String s)
Complete pattern forfloating point
andinteger
number, coveringpatternDecimalNumber
andpatternIntegerNumber
.
-
isCPPOperand
public static boolean isCPPOperand(String s)
Matches pattern for valid CPP operands, seepatternCPPOperand
.
-
-