Class Method

java.lang.Object
net.codecrete.windowsapi.metadata.Method

public class Method extends Object
Method (function)

Describes the parameters, return type and further attributes of a Windows API function, COM interface function or delegate.

  • Constructor Details

    • Method

      public Method(String name, Namespace namespace, int methodDefIndex)
      Creates a new method.
      Parameters:
      name - the method name
      namespace - the method namespace
      methodDefIndex - the MethodDef index
  • Method Details

    • name

      public String name()
      Gets the method name.

      For architecture-specific methods, this is the modified method name, as used for Java code.

      Returns:
      the name
    • setName

      public void setName(String name)
      Sets the method name.

      For architecture-specific methods, this is the modified method name, as used for Java code.

      Parameters:
      name - the name
    • nativeName

      public String nativeName()
      Gets the native method name.

      For architecture-specific types, this is the original function name used by Windows.

      Returns:
      native method name
    • namespace

      public Namespace namespace()
      Gets the method's namespace.
      Returns:
      the namespace
    • methodDefIndex

      public int methodDefIndex()
      Gets the MethodDef index.
      Returns:
      the index
    • replaceTypes

      public void replaceTypes(UnaryOperator<Type> typeReplacer)
      Replaces the types of the parameters and return type with different types.

      If the type should not be changed, the given lambda should return the received type.

      Parameters:
      typeReplacer - lambda providing the target type for the current type
    • returnType

      public Type returnType()
      Gets this method's return type.

      If the method does not return anything, the return type is the primitive void type is returned.

      Returns:
      the return type
    • setReturnType

      public void setReturnType(Type returnType)
      Sets the return type.

      If the method does not return anything, the type must be set to the primitive void type.

      Parameters:
      returnType - the return type
    • parameters

      public Parameter[] parameters()
      Gets the method parameters.
      Returns:
      the parameters (as an array)
    • setParameters

      public void setParameters(Parameter[] parameters)
      Sets the method parameters.
      Parameters:
      parameters - the parameters
    • referencedTypes

      public Stream<Type> referencedTypes()
      Gets all types directly referenced by this method.
      Returns:
      the referenced types (as a stream)
    • dll

      public String dll()
      Gets the name of the DLL containing this Windows function.

      Not applicable to COM interface methods and delegates.

      Returns:
      the DLL name
    • setDll

      public void setDll(String dll)
      Sets the name of the DLL containing this Windows function.

      Not applicable to COM interface methods and delegates.

      Parameters:
      dll - the DLL name
    • hasReturnType

      public boolean hasReturnType()
      Indicates if this method returns anything, i.e., it is not set to the void type.
      Returns:
      true if the returns anything, false otherwise
    • supportsLastError

      public boolean supportsLastError()
      Indicates if this method uses the GetLastError function to provide error details.
      Returns:
      true if GetLastError is supported
    • setSupportsLastError

      public void setSupportsLastError(boolean supportsLastError)
      Sets if this method uses the GetLastError function to provide error details.
      Parameters:
      supportsLastError - true if GetLastError is supported, false otherwise
    • constantValue

      public Object constantValue()
      Returns the constant value returned by this method.

      A few Windows functions do not exist but are C macros returning a constant value. This is the constant value.

      Returns:
      the constant value
    • setConstantValue

      public void setConstantValue(Object constantValue)
      Returns the constant value returned by this method.

      A few Windows functions do not exist but are C macros returning a constant value. This is the constant value.

      Parameters:
      constantValue - the constant value
    • documentationUrl

      public final LazyString documentationUrl()
      Returns the URL to Microsoft's documentation about this type.
      Returns:
      the URL
    • setDocumentationUrl

      public final void setDocumentationUrl(LazyString documentationUrl)
      Sets the URL to Microsoft's documentation about this type.
      Parameters:
      documentationUrl - the URL