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, see
getNativeExpr()
and the optional ConstantDefinition.CNumber representation, see getNumber().
The representation of the equivalent java expression including
the result type is covered by ConstantDefinition.JavaExpr,
which can be computed via computeJavaExpr(Map).
This class and its sub-classes define and convert all native expressions to Java space.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA Number, either integer, optionally [long, unsigned], or floating point, optionally [double].static classA 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
FieldsModifier and TypeFieldDescriptionstatic PatternOne of:+-*/|&()<<>>static final PatternComplete pattern forfloating pointnumber, compatible and described inDouble.valueOf(String).static final PatternComplete pattern forfloating pointandintegernumber, coveringpatternDecimalNumberandpatternIntegerNumber.static PatternComplete pattern forhexadecimalnumber, including an optional sign[+-]and optional suffixes[uUlL].static final PatternComplete pattern forintegernumber, including an optional sign[+-]and optional suffixes[uUlL].static final longstatic final BigInteger -
Constructor Summary
ConstructorsConstructorDescriptionConstantDefinition(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
Modifier and TypeMethodDescriptioncomputeJavaExpr(Map<String, ConstantDefinition.JavaExpr> constMap) Computes thejava expressionbased on this instance, seeJavaExpr#create(ConstantDefinition).static ConstantDefinition.CNumberstatic ConstantDefinition.CNumberIf the given stringisDecimalNumber(String), return the decoded floating-point value, represented as aANumberobject, otherwise returnsnull.static ConstantDefinition.CNumberIf the given stringisIntegerNumber(String), return the decoded integer value, represented as aANumber, otherwise returnsnull.final booleanEquality test by its givenname.final booleanSemantic equality test for Types exclusive its givenname.Returns this instance'sASTLocusTag, if available, otherwise returnsnull.Returnsnullif this definition was not part of an enumeration, or if the enumeration is anonymous.Returns the original [native] expression.Returns the parsedConstantDefinition.CNumberof thenative expression, ornullif the latter does not comprise a single number, i.e.final inthashCode()Hash by its givenname.final intSemantic hashcode for Types exclusive its givenname.booleanstatic booleanisConstantExpression(String value) static booleanMatches pattern for valid CPP operands, seepatternCPPOperand.static booleanMatches pattern forfloating pointnumber, compatible and described inDouble.valueOf(String).static booleanComplete pattern forfloating pointandintegernumber, coveringpatternDecimalNumberandpatternIntegerNumber.booleanisEnum()static booleanMatchespatternHexNumber.static booleanisIdentifier(String value) static booleanMatchesisHexNumber(String)orpatternIntegerNumber.static booleanMatchesisHexNumber(String)orisDecimalOrIntNumber(String).toString()Methods inherited from class com.jogamp.gluegen.cgram.types.AliasedSymbol.AliasedSymbolImpl
addAliasedName, getAliasedNames, getAliasedString, getName, getOrigName, hasAliases, renameMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.jogamp.gluegen.cgram.types.AliasedSymbol
addAliasedName, getAliasedNames, getAliasedString, getName, getOrigName, hasAliases, rename
-
Field Details
-
UNSIGNED_INT_MAX_VALUE
public static final long UNSIGNED_INT_MAX_VALUE- See Also:
-
UNSIGNED_LONG_MAX_VALUE
-
patternHexNumber
Complete pattern forhexadecimalnumber, including an optional sign[+-]and optional suffixes[uUlL]. -
patternDecimalNumber
Complete pattern forfloating pointnumber, compatible and described inDouble.valueOf(String). -
patternDecimalOrIntNumber
Complete pattern forfloating pointandintegernumber, coveringpatternDecimalNumberandpatternIntegerNumber. -
patternIntegerNumber
Complete pattern forintegernumber, including an optional sign[+-]and optional suffixes[uUlL]. -
patternCPPOperand
-
-
Constructor Details
-
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 Details
-
getASTLocusTag
Description copied from interface:ASTLocusTag.ASTLocusTagProviderReturns this instance'sASTLocusTag, if available, otherwise returnsnull.- Specified by:
getASTLocusTagin interfaceASTLocusTag.ASTLocusTagProvider
-
hashCode
public final int hashCode()Hash by its givenname. -
equals
Equality test by its givenname. -
hashCodeSemantics
public final int hashCodeSemantics()Description copied from interface:TypeComparator.SemanticEqualityOpSemantic hashcode for Types exclusive its givenname.- Specified by:
hashCodeSemanticsin interfaceTypeComparator.SemanticEqualityOp- See Also:
-
equalSemantics
Description copied from interface:TypeComparator.SemanticEqualityOpSemantic equality test for Types exclusive its givenname.- Specified by:
equalSemanticsin interfaceTypeComparator.SemanticEqualityOp- See Also:
-
getNativeExpr
Returns the original [native] expression. -
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
Returnsnullif this definition was not part of an enumeration, or if the enumeration is anonymous. -
isEnum
public boolean isEnum() -
toString
-
computeJavaExpr
public final ConstantDefinition.JavaExpr computeJavaExpr(Map<String, ConstantDefinition.JavaExpr> constMap) Computes thejava expressionbased on this instance, seeJavaExpr#create(ConstantDefinition). -
isConstantExpression
-
isIdentifier
-
decodeANumber
- Parameters:
v-
-
decodeIntegerNumber
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
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
MatchesisHexNumber(String)orisDecimalOrIntNumber(String). -
isIntegerNumber
MatchesisHexNumber(String)orpatternIntegerNumber. -
isHexNumber
MatchespatternHexNumber. -
isDecimalNumber
Matches pattern forfloating pointnumber, compatible and described inDouble.valueOf(String). -
isDecimalOrIntNumber
Complete pattern forfloating pointandintegernumber, coveringpatternDecimalNumberandpatternIntegerNumber. -
isCPPOperand
Matches pattern for valid CPP operands, seepatternCPPOperand.
-