com.jogamp.gluegen.runtime
Class ProcAddressTable

java.lang.Object
  extended by com.jogamp.gluegen.runtime.ProcAddressTable

public abstract class ProcAddressTable
extends Object

Superclass for all generated ProcAddressTables. A ProcAddressTable is a cache of pointers to the dynamically-linkable C functions this autogenerated Java binding has exposed. Some libraries such as OpenGL, OpenAL and others define function pointer signatures rather than statically linkable entry points for the purposes of being able to query at run-time whether a particular extension is available. This table acts as a cache of these function pointers. Each function pointer is typically looked up at run-time by a platform-dependent mechanism such as dlsym(), wgl/glXGetProcAddress(), or alGetProcAddress(). If the field containing the function pointer is 0, the function is considered to be unavailable and can not be called.

Author:
Kenneth Russel, Michael Bien, Sven Gothel
See Also:
FunctionAddressResolver, DynamicLookupHelper

Field Summary
protected static boolean DEBUG
           
protected static String DEBUG_PREFIX
           
protected static int debugNum
           
static String PROCADDRESS_VAR_PREFIX
           
 
Constructor Summary
ProcAddressTable()
           
ProcAddressTable(FunctionAddressResolver resolver)
           
 
Method Summary
protected  Field fieldForFunction(String name)
           
protected  String fieldToFunctionName(String addressFieldName)
           
 long getAddressFor(String functionName)
          This is a convenience method to get (by name) the native function pointer for a given function.
protected static PrintStream getDebugOutStream()
           
 Set getNullPointerFunctions()
          Returns all functions pointing to null.
 void initEntry(String name, DynamicLookupHelper lookup)
          Initializes the mapping for a single function.
protected  boolean isAddressField(String fieldName)
           
 boolean isFunctionAvailable(String functionName)
          Returns true only if non null function pointer to this function exists.
 void reset(DynamicLookupHelper lookup)
          Resets the complete table.
protected  void setEntry(Field addressField, String funcName, DynamicLookupHelper lookup)
           
 Map toMap()
          Returns this table as map with the function name as key and the address as value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROCADDRESS_VAR_PREFIX

public static final String PROCADDRESS_VAR_PREFIX
See Also:
Constant Field Values

DEBUG

protected static boolean DEBUG

DEBUG_PREFIX

protected static String DEBUG_PREFIX

debugNum

protected static int debugNum
Constructor Detail

ProcAddressTable

public ProcAddressTable()

ProcAddressTable

public ProcAddressTable(FunctionAddressResolver resolver)
Method Detail

reset

public void reset(DynamicLookupHelper lookup)
           throws RuntimeException
Resets the complete table.

Throws:
RuntimeException

initEntry

public void initEntry(String name,
                      DynamicLookupHelper lookup)
Initializes the mapping for a single function.

Throws:
IllegalArgumentException - if this function is not in this table.

setEntry

protected void setEntry(Field addressField,
                        String funcName,
                        DynamicLookupHelper lookup)

fieldToFunctionName

protected String fieldToFunctionName(String addressFieldName)

fieldForFunction

protected Field fieldForFunction(String name)

isAddressField

protected boolean isAddressField(String fieldName)

getDebugOutStream

protected static PrintStream getDebugOutStream()

toMap

public Map toMap()
Returns this table as map with the function name as key and the address as value.


isFunctionAvailable

public boolean isFunctionAvailable(String functionName)
Returns true only if non null function pointer to this function exists.


getAddressFor

public long getAddressFor(String functionName)
This is a convenience method to get (by name) the native function pointer for a given function. It lets you avoid having to manually compute the "PROCADDRESS_VAR_PREFIX + <functionName>" member variable name and look it up via reflection.

Throws:
IllegalArgumentException - if this function is not in this table.

getNullPointerFunctions

public Set getNullPointerFunctions()
Returns all functions pointing to null.


toString

public String toString()
Overrides:
toString in class Object