Class Argument
Defined in File argument.h
Class Documentation
-
class Argument
The Argument class describes a single argument to an API call.
The function call can be part of a graphics API, a system API, or any API that is intercepted by the GPA call interceptor. Each function call has zero or more arguments, and each of these arguments is described in full by an instance of the Argument class.
Arguments are not standalone objects; they are constructed as part of the metadata for the API call, and are available via the Callable::Argument method. These metadata objects are defined based on data extracted from the parsed API headers; therefore, names and type strings are as they were defined in the original header file.
Note
The various overloaded constructors to Argument are implemented such that automatic type inference will produce an Argument with the correct generic BasicType.
Public Functions
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, char const *value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, char *value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, float value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, double value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, uint8_t value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, uint16_t value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, uint32_t value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, uint64_t value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, int8_t value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, int16_t value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, int32_t value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, int64_t value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
template<typename T>
inline Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, T*, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg, BasicType referencedType)
-
template<typename T>
inline Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, T const*, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg, BasicType referencedType)
-
template<typename T>
inline Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, T*, Argument const *elementCountArg, bool isOutParam)
-
template<typename T>
inline Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, T const*, Argument const *elementCountArg, bool isOutParam)
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, uint64_t, Argument const *elementCountArg)
-
template<typename T>
inline Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, T*, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
template<typename T>
inline Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, T const*, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
template<typename T>
inline Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, T&, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)
-
~Argument()
-
char const *Name() const
Argument name.
- Returns
The name of the argument as declared by the parsed API.
-
char const *TypeString() const
The type of the argument as declared by the parsed API.
This type may be different than the BasicType enum value returned by the Type method; the GPA Framework necessarily must translate any API-specific types into "generic" types defined by it. For example,
Foo* foo
may end up with a Type of BasicType::kPointer or BasicType::kHandle, depending on howFoo* foo
was used in the original API declaration.- Returns
Pointer to immutable string containing the original type declaration.
-
size_t Index() const
Index of this Argument in the API call's argument list.
- Returns
The zero-based index of the Argument in the API call's argument list.
-
BasicType Type() const
The GPA Framework type of the Argument as inferred from the type and context of the argument.
See also
Note
If the proper type could not be inferred from the argument's declared type and context, this function may return kUndefined.
- Returns
The API-independent type of this argument.
-
BasicType ReferencedType() const
For types that are pointers or references to one or more instances of another type, the type of the referenced object.
This is most common when the Argument has a Type of BasicType::kPointer or BasicType::kEmbedded, and references one or more instances of a struct or other primitive type. The caller can examine the combination of return values from Type, ReferencedType, IsStruct, and IsVector to determine whether or not the Argument references (for example, points to) another object.
- Returns
If the argument is a pointer, but is not a struct (isStruct() returns false), then this returns the API-independent type that this argument refers to; otherwise, returns BasicType::kUndefined.
-
Argument const *ElemCountArg() const
Access the Argument that provides the element count for vector (array) Arguments.
This method will return non-null when this Argument references an array. For example,
Foo* foo
references one or more objects of typeFoo
that are arranged contiguously in memory. If the original API accepts arrays ofFoo
, then ElemCountArg() will return non-null, regardless the actual number of elements specified by the Argument referenced by ElemCountArg() at runtime, even if the runtime number of elements is 1.- Returns
If argument references an array, return a pointer to another Argument in the call list, that describes the element count in the array; otherwise, returns nullptr.
-
size_t ConstantArrayElementCount() const
For constant-sized array arguments, access the number of elements in the array.
- Returns
If this Argument is a constant-sized array, the number of elements in the array. Otherwise, zero (0).
-
bool IsVector() const
Convenience method to detect whether the Argument references an array or vector of objects.
- Returns
true if this argument refers to, or contains, an array; false otherwise.
-
bool IsConstantSizedArray() const
Convenience method to detect whether the Argument is a constant-sized array.
If this method returns true, then ReferencedType() contains the type of the elements in the array. Obtain the constant number of elements in the array from ConstantArrayElementCount().
- Returns
true if this argument refers to, or contains, an array; false otherwise.
-
bool IsStruct() const
Convenience method to detect whether the Argument references one or more instances of a struct that is defined by and known to the original API.
- Returns
true if this argument refers to, or contains, a struct; false otherwise.
-
Struct const *StructDef() const
Provide access to the metadata that describes the API-specific struct layout referenced by this Argument.
Whenever this method returns non-null, or IsStruct returns true, this Argument refers to an instance of an API-defined struct. In order to inspect that struct layout, this method returns a pointer to an instances of a Struct class that provides the layout metadata. This will be true when Type returns kPointer, kEmbedded and, on rare occasions, kUserDefined; this is independent of whether IsVector returns true or false.
- Returns
Pointer to struct metadata if this argument refers to a struct (via pointer or embed), or nullptr otherwise.
-
Enum const *EnumDef() const
Provide access to the metadata that describes the API-specific enumeration referenced by this Argument.
- Returns
Pointer to enum metadata if this argument refers to an enumeration (via pointer or embed), or nullptr otherwise.
-
Union const *UnionDef() const
Provide access to the metadata that describes the API-specific union referenced by this Argument.
- Returns
Pointer to union metadata if this argument refers to a union (via pointer or embed), or nullptr otherwise.
-
bool IsIntegralPrimitive() const
Convenience method to detect whether the Argument references a primitive, integral type.
- Returns
If the argument is a 32- or 64-bit integer type (signed or unsigned), returns true. Otherwise, returns false.
-
bool IsOutParam() const
-
Argument(char const *name, char const *typeString, size_t index, size_t constElemCount, char const *value, Struct const *structDef, Enum const *enumDef, Union const *unionDef, Argument const *elementCountArg)