Class Struct
Structs can either be independent or nested. An independent type has a namespace and
can be the enclosing type for nested types. Nested types have no namespace and must
be contained in an enclosing parent type. They often have artificial names like
_Anonymous_e__Struct. Nested types are typically used for unnamed structs or unions.
-
Field Summary
Fields inherited from class net.codecrete.windowsapi.metadata.Type
documentationUrl, name, namespace, nativeName, typeDefIndex -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNestedType(Type nestedType) Adds the given type as a nested type of this type.duplicate(int newTypeDefIndex) Creates a copy of this type and assigns it a differentTypeDefindex.Gets the parent type enclosing this type.Gets the field within this struct that is a flexible arraygetNestedType(String name) Gets the nested type with the given name.guid()Gets the GUID associated with this struct.booleanIndicates if this struct has a fixed size.booleanIndicates if this type contains nested types.booleanIndicates if this struct is only valid for certain processor architectures (X64, ARM64).booleanIndicates if the layout of this struct has been calculated.booleanisNested()Indicates if this type is a nested type.booleanisUnion()Indicates if this is a union.members()Gets this struct's members (fields).Gets the nested types.intReturns the package size, i.e., the alignment required by this struct.Returns the types directly references by this type.voidreplaceTypes(UnaryOperator<Type> typeReplacement) Replace the types directly referenced by this type with the provided replacements.voidsetArchitectureSpecific(boolean isArchitectureSpecific) Sets if this struct is only valid for certain processor architectures (X64, ARM64).voidsetFlexibleArrayMember(Member flexibleArrayMember) Sets the field within this struct that is a flexible arrayvoidMarks that the layout of this struct has been calculated.voidsetMembers(List<Member> members) Sets this struct's members (fields).voidsetPackageSize(int packageSize) Sets the package size, i.e., the alignment required by this struct.voidsetStructSize(int structSize) Sets the struct size (length).intGets the struct size (length).Gets the field within this struct that indicates the struct size.Methods inherited from class net.codecrete.windowsapi.metadata.Type
documentationUrl, isAnonymous, name, namespace, nativeName, setDocumentationUrl, setName, typeDefIndex
-
Constructor Details
-
Struct
public Struct(String name, Namespace namespace, int typeDefIndex, boolean isUnion, int packageSize, int structSize, Struct enclosingType, String structSizeMember, UUID guid) Creates a new instance.- Parameters:
name- the struct namenamespace- the namespacetypeDefIndex- theTypeDefindexisUnion- indicates if the new instance is a union (instead of a struct)packageSize- the package size (alignment) of this struct (in bytes)structSize- the size of this struct (in bytes)enclosingType- the enclosing type in case it is a nested typestructSizeMember- the struct field holding the struct's size (usually a member called {code cbSize}).guid- the GUID associated with the struct
-
-
Method Details
-
isUnion
public boolean isUnion()Indicates if this is a union.- Returns:
trueif it is a union,falseif it is a struct
-
packageSize
public int packageSize()Returns the package size, i.e., the alignment required by this struct.- Returns:
- the package size (in bytes)
-
setPackageSize
public void setPackageSize(int packageSize) Sets the package size, i.e., the alignment required by this struct.- Parameters:
packageSize- the package size (in bytes)
-
structSize
public int structSize()Gets the struct size (length).- Returns:
- the struct size (in bytes).
-
setStructSize
public void setStructSize(int structSize) Sets the struct size (length).- Parameters:
structSize- the struct size (in bytes).
-
isLayoutDone
public boolean isLayoutDone()Indicates if the layout of this struct has been calculated.- Returns:
- {code true} if it is done
-
setLayoutDone
public void setLayoutDone()Marks that the layout of this struct has been calculated. -
enclosingType
Gets the parent type enclosing this type.- Returns:
- the enclosing type, or
nullif this type is not nested
-
addNestedType
Adds the given type as a nested type of this type.- Parameters:
nestedType- the nested type
-
getNestedType
-
hasNestedTypes
public boolean hasNestedTypes()Indicates if this type contains nested types.- Returns:
trueif this type has nested types
-
nestedTypes
-
members
-
setMembers
-
isNested
public boolean isNested()Indicates if this type is a nested type.- Returns:
trueif this type is nested
-
hasFixedSize
public boolean hasFixedSize()Indicates if this struct has a fixed size.A struct does not have a fixed size if it contains a flexible array, i.e., an array with a variable number of elements.
- Returns:
trueif this struct has a fixed size
-
flexibleArrayMember
Gets the field within this struct that is a flexible array- Returns:
- the flexible array member, or
nullif there is no such member
-
setFlexibleArrayMember
Sets the field within this struct that is a flexible array- Parameters:
flexibleArrayMember- the flexible array member, ornullif there is no such member
-
structSizeMember
Gets the field within this struct that indicates the struct size.The Windows API can support multiple versions of the same struct if the struct has a field indicating the size of the struct. It must be set by the caller.
If the struct contains such a field, it is usually called
cbSize.- Returns:
- the field containing the struct size, or
nullif there is no such field
-
isArchitectureSpecific
public boolean isArchitectureSpecific()Indicates if this struct is only valid for certain processor architectures (X64, ARM64).If it is architecture-specific, there might be separate versions of each architecture, or it might not be supported on all architectures.
- Returns:
trueif it is architecture-specific
-
setArchitectureSpecific
public void setArchitectureSpecific(boolean isArchitectureSpecific) Sets if this struct is only valid for certain processor architectures (X64, ARM64).If it is architecture-specific, there might be separate versions of each architecture, or it might not be supported on all architectures.
- Parameters:
isArchitectureSpecific-trueif it is architecture-specific,falseif it is valid for all architecture
-
guid
-
referencedTypes
Description copied from class:TypeReturns the types directly references by this type.- Overrides:
referencedTypesin classType- Returns:
- Stream of types
-
duplicate
Creates a copy of this type and assigns it a differentTypeDefindex.- Parameters:
newTypeDefIndex- the newTypeDefindex- Returns:
- the copied type
-
replaceTypes
Description copied from class:TypeReplace the types directly referenced by this type with the provided replacements.The lambda for replacement lookup will return the same type if no replacement is needed.
- Overrides:
replaceTypesin classType- Parameters:
typeReplacement- lambda for looking up the replacement type.
-