Package com.jogamp.gluegen.cgram.types
Class FunctionType
- java.lang.Object
-
- com.jogamp.gluegen.cgram.types.Type
-
- com.jogamp.gluegen.cgram.types.FunctionType
-
- All Implemented Interfaces:
ASTLocusTag.ASTLocusTagProvider
,TypeComparator.SemanticEqualityOp
,Cloneable
public class FunctionType extends Type implements Cloneable
Describes a function type, used to model both function declarations and (via PointerType) function pointers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FunctionType.ParameterConsumer
forEachParameter(ParameterConsumer)
Consumer
-
Field Summary
-
Fields inherited from class com.jogamp.gluegen.cgram.types.Type
relaxedEqSem
-
-
Constructor Summary
Constructors Constructor Description FunctionType(String name, SizeThunk size, Type returnType, int cvAttributes)
FunctionType(String name, SizeThunk size, Type returnType, int cvAttributes, ASTLocusTag astLocus)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addArgument(Type argumentType, String argumentName)
Add an argument's name and type.FunctionType
asFunction()
Casts this to a FunctionType or returns null if not a FunctionType.protected boolean
equalSemanticsImpl(Type arg)
protected boolean
equalsImpl(Type arg)
int
forEachParameter(FunctionType.ParameterConsumer c)
String
getArgumentName(int i)
Returns the name of the ith argument.Type
getArgumentType(int i)
Returns the type of the ith argument.int
getNumArguments()
StringBuilder
getParameterList(StringBuilder buf, boolean useTypedef, String callingConvention)
Returns the function parameter list, i.e.StringBuilder
getParameterList(StringBuilder buf, boolean useTypedef, String callingConvention, List<Integer> exclude)
Returns the function parameter list, i.e.Type
getReturnType()
Returns the return type of this function.protected int
hashCodeImpl()
protected int
hashCodeSemanticsImpl()
void
setArgumentName(int i, String name)
String
toString()
Returns a string representation of this type.String
toString(String functionName, boolean emitNativeTag)
String
toString(String functionName, boolean emitNativeTag, boolean isPointer)
String
toString(String functionName, String callingConvention, boolean emitNativeTag, boolean isPointer)
void
visit(TypeVisitor arg)
Traverse thisType
and all of its component types; for example, the return type and argument types of a FunctionType.-
Methods inherited from class com.jogamp.gluegen.cgram.types.Type
arrayDimension, asArray, asBit, asCompound, asDouble, asEnum, asFloat, asInt, asPointer, asVoid, clearCache, clone, equals, equalSemantics, getArrayBaseOrPointerTargetType, getASTLocusTag, getBaseType, getCName, getCName, getCVAttributes, getCVAttributesString, getDebugString, getName, getName, getSignature, getSize, getSize, getTargetFunction, getTargetType, hashCode, hashCodeSemantics, hasSize, isAnon, isArray, isBaseTypeConst, isBit, isCompound, isConst, isDouble, isEnum, isFloat, isFunction, isFunctionPointer, isInt, isPointer, isPrimitive, isTypedef, isVoid, isVolatile, newCVVariant, pointerDepth, setTypedefName
-
-
-
-
Method Detail
-
hashCodeImpl
protected int hashCodeImpl()
- Specified by:
hashCodeImpl
in classType
-
equalsImpl
protected boolean equalsImpl(Type arg)
- Specified by:
equalsImpl
in classType
-
hashCodeSemanticsImpl
protected int hashCodeSemanticsImpl()
- Specified by:
hashCodeSemanticsImpl
in classType
-
equalSemanticsImpl
protected boolean equalSemanticsImpl(Type arg)
- Specified by:
equalSemanticsImpl
in classType
-
asFunction
public FunctionType asFunction()
Description copied from class:Type
Casts this to a FunctionType or returns null if not a FunctionType.- Overrides:
asFunction
in classType
-
getReturnType
public Type getReturnType()
Returns the return type of this function.
-
getNumArguments
public int getNumArguments()
-
getArgumentName
public String getArgumentName(int i)
Returns the name of the ith argument. May return null if no argument names were available during parsing.
-
getArgumentType
public Type getArgumentType(int i)
Returns the type of the ith argument.
-
getParameterList
public StringBuilder getParameterList(StringBuilder buf, boolean useTypedef, String callingConvention)
Returns the function parameter list, i.e. a comma separated list of argument type and name.- Parameters:
buf
- StringBuilder instanceuseTypedef
- if true and type is typedef'ed, use its namecallingConvention
- optional calling-convention- Returns:
- given StringBuilder instance
-
getParameterList
public StringBuilder getParameterList(StringBuilder buf, boolean useTypedef, String callingConvention, List<Integer> exclude)
Returns the function parameter list, i.e. a comma separated list of argument type and name.- Parameters:
buf
- StringBuilder instanceuseTypedef
- if true and type is typedef'ed, use its namecallingConvention
- optional calling-conventionexclude
- optional list of excluded parameter indices- Returns:
- given StringBuilder instance
-
forEachParameter
public int forEachParameter(FunctionType.ParameterConsumer c)
-
addArgument
public void addArgument(Type argumentType, String argumentName)
Add an argument's name and type. Use null for unknown argument names.
-
setArgumentName
public void setArgumentName(int i, String name)
-
toString
public String toString()
Description copied from class:Type
Returns a string representation of this type. The returned string is suitable for use as a type specifier for native C. It does contain an expanded description of structs/unions, hence may not be suitable for type declarations.
-
toString
public String toString(String functionName, String callingConvention, boolean emitNativeTag, boolean isPointer)
-
visit
public void visit(TypeVisitor arg)
Description copied from class:Type
Traverse thisType
and all of its component types; for example, the return type and argument types of a FunctionType.
-
-