Contents | Package | Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS

Class CFunc

java.lang.Object
    |
    +----CPtr
            |
            +----CFunc

public class CFunc
extends CPtr
An abstraction for a C function pointer. An instance of CFunc repesents a pointer to some C function. callXXX methods provide means to call the function; select a XXX variant based on the return type of the C function.

Beware that the copyIn, copyOut, setXXX, and getXXX methods inherited from the parent will indirect machine code.

Author:
Sheng Liang
See Also:
CPtr

Fields inherited from class CPtr
 NULL, SIZE
 

Constructor Summary
 CFunc(java.lang.String lib, java.lang.String fname, java.lang.String conv)
Create a new CFunc that is linked with a C function that follows a given calling convention.
 CFunc(java.lang.String lib, java.lang.String fname)
Create a new CFunc that is linked with a C function that follows the standard "C" calling convention.
 

Method Summary
CPtr  callCPtr(java.lang.Object[] args)
Call the C function being represented by this object.
double  callDouble(java.lang.Object[] args)
Call the C function being represented by this object.
float  callFloat(java.lang.Object[] args)
Call the C function being represented by this object.
int  callInt(java.lang.Object[] args)
Call the C function being represented by this object.
void  callVoid(java.lang.Object[] args)
Call the C function being represented by this object.
 
Methods inherited from class CPtr
 copyIn, copyIn, copyIn, copyIn, copyIn, copyIn, copyIn, copyOut, copyOut, copyOut, copyOut, copyOut, copyOut, copyOut, equals, getByte, getCPtr, getDouble, getFloat, getInt, getLong, getShort, getString, hashCode, setByte, setCPtr, setDouble, setFloat, setInt, setLong, setShort, setString
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CFunc

public CFunc(java.lang.String lib,
             java.lang.String fname,
             java.lang.String conv)
Create a new CFunc that is linked with a C function that follows a given calling convention.

The allocated instance represents a pointer to the named C function from the named library, called with the named calling convention.

Parameters:
lib - library in which to find the C function
fname - name of the C function to be linked with
conv - calling convention used by the C function

CFunc

public CFunc(java.lang.String lib,
             java.lang.String fname)
Create a new CFunc that is linked with a C function that follows the standard "C" calling convention.

The allocated instance represents a pointer to the named C function from the named library, called with the standard "C" calling convention.

Parameters:
lib - library in which to find the C function
fname - name of the C function to be linked with
Method Detail

callInt

public int callInt(java.lang.Object[] args)
Call the C function being represented by this object.
Parameters:
args - arguments to pass to the C function
Returns:
int value returned by the underlying C function

callVoid

public void callVoid(java.lang.Object[] args)
Call the C function being represented by this object.
Parameters:
args - arguments to pass to the C function

callFloat

public float callFloat(java.lang.Object[] args)
Call the C function being represented by this object.
Parameters:
args - arguments to pass to the C function
Returns:
float value returned by the underlying C function

callDouble

public double callDouble(java.lang.Object[] args)
Call the C function being represented by this object.
Parameters:
args - arguments to pass to the C function
Returns:
double value returned by the underlying C function

callCPtr

public CPtr callCPtr(java.lang.Object[] args)
Call the C function being represented by this object.
Parameters:
args - arguments to pass to the C function
Returns:
C pointer returned by the underlying C function

Contents | Package | Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS