java.lang.Object
jdk.incubator.foreign.FunctionDescriptor
- All Implemented Interfaces:
Constable
A function descriptor is made up of zero or more argument layouts and zero or one return layout. A function descriptor
is used to model the signature of foreign functions.
Unless otherwise specified, passing a null
argument, or an array argument containing one or more null
elements to a method in this class causes a NullPointerException
to be thrown.
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
The name of the function descriptor attribute (seeattributes()
used to mark trivial functions. -
Method Summary
Modifier and TypeMethodDescriptionReturns the argument layouts associated with this function.Returns the attribute with the given name (if it exists).Returns a stream of the attribute names associated with this function descriptor.boolean
Compares the specified object with this function descriptor for equality.int
hashCode()
Returns the hash code value for this function descriptor.static FunctionDescriptor
of(MemoryLayout resLayout, MemoryLayout... argLayouts)
Create a function descriptor with given return and argument layouts.static FunctionDescriptor
ofVoid(MemoryLayout... argLayouts)
Create a function descriptor with given argument layouts and no return layout.Returns the return layout associated with this function.toString()
Returns a string representation of this function descriptor.withAppendedArgumentLayouts(MemoryLayout... addedLayouts)
Create a new function descriptor with the given argument layouts appended to the argument layout array of this function descriptor.withAttribute(String name, Constable value)
Returns a new function descriptor which features the same attributes as this descriptor, plus the newly specified attribute.withReturnLayout(MemoryLayout newReturn)
Create a new function descriptor with the given memory layout as the new return layout.Create a new function descriptor with the return layout dropped.
-
Field Details
-
TRIVIAL_ATTRIBUTE_NAME
The name of the function descriptor attribute (seeattributes()
used to mark trivial functions. The attribute value must be a boolean.- See Also:
- Constant Field Values
-
-
Method Details
-
attribute
Returns the attribute with the given name (if it exists).- Parameters:
name
- the attribute name.- Returns:
- the attribute with the given name (if it exists).
-
attributes
Returns a stream of the attribute names associated with this function descriptor.- Returns:
- a stream of the attribute names associated with this function descriptor.
-
withAttribute
Returns a new function descriptor which features the same attributes as this descriptor, plus the newly specified attribute. If this descriptor already contains an attribute with the same name, the existing attribute value is overwritten in the returned descriptor.- Parameters:
name
- the attribute name.value
- the attribute value.- Returns:
- a new function descriptor which features the same attributes as this descriptor, plus the newly specified attribute.
-
returnLayout
Returns the return layout associated with this function.- Returns:
- the return layout.
-
argumentLayouts
Returns the argument layouts associated with this function.- Returns:
- the argument layouts.
-
of
Create a function descriptor with given return and argument layouts.- Parameters:
resLayout
- the return layout.argLayouts
- the argument layouts.- Returns:
- the new function descriptor.
-
ofVoid
Create a function descriptor with given argument layouts and no return layout.- Parameters:
argLayouts
- the argument layouts.- Returns:
- the new function descriptor.
-
withAppendedArgumentLayouts
Create a new function descriptor with the given argument layouts appended to the argument layout array of this function descriptor.- Parameters:
addedLayouts
- the argument layouts to append.- Returns:
- the new function descriptor.
-
withReturnLayout
Create a new function descriptor with the given memory layout as the new return layout.- Parameters:
newReturn
- the new return layout.- Returns:
- the new function descriptor.
-
withVoidReturnLayout
Create a new function descriptor with the return layout dropped.- Returns:
- the new function descriptor.
-
toString
Returns a string representation of this function descriptor. -
equals
Compares the specified object with this function descriptor for equality. Returnstrue
if and only if the specified object is also a function descriptor, and all of the following conditions are met:- the two function descriptors have equals return layouts (see
MemoryLayout.equals(Object)
), or both have no return layout - the two function descriptors have argument layouts that are pair-wise equal (see
MemoryLayout.equals(Object)
)
- Overrides:
equals
in classObject
- Parameters:
other
- the object to be compared for equality with this function descriptor.- Returns:
true
if the specified object is equal to this function descriptor.- See Also:
Object.hashCode()
,HashMap
- the two function descriptors have equals return layouts (see
-
hashCode
public int hashCode()Returns the hash code value for this function descriptor.- Overrides:
hashCode
in classObject
- Returns:
- the hash code value for this function descriptor.
- See Also:
Object.equals(java.lang.Object)
,System.identityHashCode(java.lang.Object)
-
describeConstable
Description copied from interface:Constable
Returns anOptional
containing the nominal descriptor for this instance, if one can be constructed, or an emptyOptional
if one cannot be constructed.- Specified by:
describeConstable
in interfaceConstable
- Returns:
- An
Optional
containing the resulting nominal descriptor, or an emptyOptional
if one cannot be constructed.
-