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
FieldsModifier and TypeFieldDescriptionstatic final StringThe 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.booleanCompares the specified object with this function descriptor for equality.inthashCode()Returns the hash code value for this function descriptor.static FunctionDescriptorof(MemoryLayout resLayout, MemoryLayout... argLayouts) Create a function descriptor with given return and argument layouts.static FunctionDescriptorofVoid(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:
-
-
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. Returnstrueif 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))
- the two function descriptors have equals return layouts (see
-
hashCode
public int hashCode()Returns the hash code value for this function descriptor. -
describeConstable
Description copied from interface:ConstableReturns anOptionalcontaining the nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be constructed.- Specified by:
describeConstablein interfaceConstable- Returns:
- An
Optionalcontaining the resulting nominal descriptor, or an emptyOptionalif one cannot be constructed.
-