<Type Name="CdeclFunction" FullName="Mono.Unix.Native.CdeclFunction">
  <TypeSignature Language="C#" Value="public sealed class CdeclFunction" />
  <AssemblyInfo>
    <AssemblyName>Mono.Posix</AssemblyName>
    <AssemblyVersion>1.0.5000.0</AssemblyVersion>
    <AssemblyVersion>2.0.0.0</AssemblyVersion>
  </AssemblyInfo>
  <ThreadingSafetyStatement>
  This type is safe for multithreaded operations.
  </ThreadingSafetyStatement>
  <Base>
    <BaseTypeName>System.Object</BaseTypeName>
  </Base>
  <Interfaces />
  <Docs>
    <summary>Permits calling a varargs (cdecl) function from a library.</summary>
    <remarks>
      <para>This class represents a single unmanaged function with "cdecl" calling convention -- that is, it can accept a variable number of arguments which are passed on the runtime stack.</para>
      <para>To use, create an instance, then call <see cref="M:Mono.Unix.Native.CdeclFunction.Invoke" /> with the appropriate number of arguments:</para>
      <example>
        <code lang="C#">
CdeclFunction printf = new CdeclFunction (
	"libc",       // the libraary
	"printf",     // the function name
	typeof (int)  // optional; the function's return type
);
printf.Invoke (new object[]{"hello, %s\n", "world!"});
  </code>
      </example>
      <para>In the background a P/Invoke definition for the method with the requested argument types will be generated and invoked, invoking the unmanaged function.  The generated methods are cached, so that subsequent calls with the same argument list do not generate new code, speeding up the call sequence.</para>
      <para>Invoking Cdecl functions is not guaranteed to be portable across all platforms.  For example, AMD64 requires that the caller set EAX to the number of floating point arguments passed in the SSE registers.  This is only required for variable argument/cdecl functions; consequently, the overload technique used by this class wouldn't normally work. Mono's AMD64 JIT works around this by always setting EAX on P/Invoke invocations, allowing CdeclFunction to work properly, but it will not necessarily always work.  See also: http://lwn.net/Articles/5201/?format=printable
</para>
      <para>Due to potential portability issues, cdecl functions should be avoided on most platforms.</para>
    </remarks>
  </Docs>
  <Members>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public CdeclFunction (string library, string method);" />
      <MemberType>Constructor</MemberType>
      <Parameters>
        <Parameter Name="library" Type="System.String" />
        <Parameter Name="method" Type="System.String" />
      </Parameters>
      <Docs>
        <param name="library">The library the cdecl function resides in.</param>
        <param name="method">The export to invoke from library.</param>
        <summary>Create a stub object to invoke a cdecl function.</summary>
        <remarks />
      </Docs>
      <AssemblyInfo>
        <AssemblyVersion>1.0.5000.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public CdeclFunction (string library, string method, Type returnType);" />
      <MemberType>Constructor</MemberType>
      <Parameters>
        <Parameter Name="library" Type="System.String" />
        <Parameter Name="method" Type="System.String" />
        <Parameter Name="returnType" Type="System.Type" />
      </Parameters>
      <Docs>
        <param name="library">The library the cdecl function resides in.</param>
        <param name="method">The export to invoke from library.</param>
        <param name="returnType">The return type of the function to invoke.  The default return type is <see cref="T:System.Void" />.</param>
        <summary>Create a stub object to invoke a cdecl function.</summary>
        <remarks />
      </Docs>
      <AssemblyInfo>
        <AssemblyVersion>1.0.5000.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
    </Member>
    <Member MemberName="Invoke">
      <MemberSignature Language="C#" Value="public object Invoke (object[] parameters);" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Object</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="parameters" Type="System.Object[]" />
      </Parameters>
      <Docs>
        <param name="parameters">The parameters to pass to the function.</param>
        <summary>Invoke the function specified in the constructor.</summary>
        <returns>The return value of the invoked cdecl function.</returns>
        <remarks>Invokes the specified function.</remarks>
      </Docs>
      <AssemblyInfo>
        <AssemblyVersion>1.0.5000.0</AssemblyVersion>
        <AssemblyVersion>2.0.0.0</AssemblyVersion>
      </AssemblyInfo>
    </Member>
  </Members>
</Type>
