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.CNumberrepresentation, 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 classConstantDefinition.CNumberA Number, either integer, optionally [long, unsigned], or floating point, optionally [double].static classConstantDefinition.JavaExprA 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 PatternpatternCPPOperandOne of:+-*/|&()<<>>~static PatternpatternDecimalNumberComplete pattern forfloating pointnumber, compatible and described inDouble.valueOf(String).static PatternpatternDecimalOrIntNumberComplete pattern forfloating pointandintegernumber, coveringpatternDecimalNumberandpatternIntegerNumber.static PatternpatternHexNumberComplete pattern forhexadecimalnumber, including an optional sign[+-]and optional suffixes[uUlL].static PatternpatternIntegerNumberComplete pattern forintegernumber, including an optional sign[+-]and optional suffixes[uUlL].static longUNSIGNED_INT_MAX_VALUEstatic BigIntegerUNSIGNED_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.JavaExprcomputeJavaExpr(Map<String,ConstantDefinition.JavaExpr> constMap)Computes thejava expressionbased on this instance, seeJavaExpr#create(ConstantDefinition).static ConstantDefinition.CNumberdecodeANumber(String v)static ConstantDefinition.CNumberdecodeDecimalNumber(String v)If the given stringisDecimalNumber(String), return the decoded floating-point value, represented as aANumberobject, otherwise returnsnull.static ConstantDefinition.CNumberdecodeIntegerNumber(String v)If the given stringisIntegerNumber(String), return the decoded integer value, represented as aANumber, otherwise returnsnull.booleanequals(Object arg)Equality test by its givenname.booleanequalSemantics(TypeComparator.SemanticEqualityOp arg)Semantic equality test for Types exclusive its givenname.ASTLocusTaggetASTLocusTag()Returns this instance'sASTLocusTag, if available, otherwise returnsnull.StringgetEnumName()Returnsnullif this definition was not part of an enumeration, or if the enumeration is anonymous.StringgetNativeExpr()Returns the original [native] expression.ConstantDefinition.CNumbergetNumber()Returns the parsedConstantDefinition.CNumberof thenative expression, ornullif the latter does not comprise a single number, i.e.inthashCode()Hash by its givenname.inthashCodeSemantics()Semantic hashcode for Types exclusive its givenname.booleanhasNumber()static booleanisConstantExpression(String value)static booleanisCPPOperand(String s)Matches pattern for valid CPP operands, seepatternCPPOperand.static booleanisDecimalNumber(String s)Matches pattern forfloating pointnumber, compatible and described inDouble.valueOf(String).static booleanisDecimalOrIntNumber(String s)Complete pattern forfloating pointandintegernumber, coveringpatternDecimalNumberandpatternIntegerNumber.booleanisEnum()static booleanisHexNumber(String s)MatchespatternHexNumber.static booleanisIdentifier(String value)static booleanisIntegerNumber(String s)MatchesisHexNumber(String)orpatternIntegerNumber.static booleanisNumber(String s)MatchesisHexNumber(String)orisDecimalOrIntNumber(String).StringtoString()-
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 forhexadecimalnumber, including an optional sign[+-]and optional suffixes[uUlL].
-
patternDecimalNumber
public static final Pattern patternDecimalNumber
Complete pattern forfloating pointnumber, compatible and described inDouble.valueOf(String).
-
patternDecimalOrIntNumber
public static final Pattern patternDecimalOrIntNumber
Complete pattern forfloating pointandintegernumber, coveringpatternDecimalNumberandpatternIntegerNumber.
-
patternIntegerNumber
public static final Pattern patternIntegerNumber
Complete pattern forintegernumber, 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.CNumberrepresenting this constant. Ifnull, implementation attempts to derive aConstantDefinition.CNumberof 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.CNumberrepresenting this constant. Ifnull, implementation attempts to derive aConstantDefinition.CNumberof 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.ASTLocusTagProviderReturns this instance'sASTLocusTag, if available, otherwise returnsnull.- Specified by:
getASTLocusTagin interfaceASTLocusTag.ASTLocusTagProvider
-
hashCodeSemantics
public final int hashCodeSemantics()
Description copied from interface:TypeComparator.SemanticEqualityOpSemantic hashcode for Types exclusive its givenname.- Specified by:
hashCodeSemanticsin interfaceTypeComparator.SemanticEqualityOp- See Also:
TypeComparator.SemanticEqualityOp.equalSemantics(SemanticEqualityOp)
-
equalSemantics
public final boolean equalSemantics(TypeComparator.SemanticEqualityOp arg)
Description copied from interface:TypeComparator.SemanticEqualityOpSemantic equality test for Types exclusive its givenname.- Specified by:
equalSemanticsin interfaceTypeComparator.SemanticEqualityOp- See Also:
TypeComparator.SemanticEqualityOp.hashCodeSemantics()
-
getNativeExpr
public String getNativeExpr()
Returns the original [native] expression.
-
getNumber
public ConstantDefinition.CNumber getNumber()
Returns the parsedConstantDefinition.CNumberof thenative expression, ornullif the latter does not comprise a single number, i.e. is a complex expression.
-
hasNumber
public boolean hasNumber()
-
getEnumName
public String getEnumName()
Returnsnullif 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 expressionbased 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 aANumberobject, otherwise returnsnull.Method utilizes
Double.valueOf(String).- Parameters:
v-isDouble- return value fordoubleflag
-
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 pointnumber, compatible and described inDouble.valueOf(String).
-
isDecimalOrIntNumber
public static boolean isDecimalOrIntNumber(String s)
Complete pattern forfloating pointandintegernumber, coveringpatternDecimalNumberandpatternIntegerNumber.
-
isCPPOperand
public static boolean isCPPOperand(String s)
Matches pattern for valid CPP operands, seepatternCPPOperand.
-
-