org.bridj
Class CRuntime

java.lang.Object
  extended by org.bridj.AbstractBridJRuntime
      extended by org.bridj.CRuntime
All Implemented Interfaces:
BridJRuntime
Direct Known Subclasses:
CPPRuntime, ObjectiveCRuntime

public class CRuntime
extends AbstractBridJRuntime

C runtime (used by default when no Runtime annotation is found).
Deals with registration and lifecycle of structs, functions, callbacks.
A shared C runtime instance can be retrieved with getInstance().

Author:
ochafik

Nested Class Summary
 class CRuntime.CTypeInfo<T extends NativeObject>
           
static class CRuntime.MethodCallInfoBuilder
           
 
Nested classes/interfaces inherited from interface org.bridj.BridJRuntime
BridJRuntime.TypeInfo<T extends NativeObject>
 
Field Summary
static String PROPERTY_bridj_c_defaultObjectSize
           
protected  Set<Class> rootCallbackClasses
           
 
Constructor Summary
CRuntime()
          Deprecated. use getInstance() instead
 
Method Summary
<T extends NativeObject>
Pointer<T>
allocate(Class<T> type, int constructorId, Object... args)
           
static
<T> Pointer<T>
createCToJavaCallback(MethodCallInfo mci, Type t)
           
<T extends NativeObject>
Class<? extends T>
getActualInstanceClass(Pointer<T> pInstance, Type officialType)
           
 org.bridj.CallbackNativeImplementer getCallbackNativeImplementer()
           
 int getDefaultStructSize()
           
 DynamicFunctionFactory getDynamicFunctionFactory(NativeLibrary library, Convention.Style callingConvention, Type returnType, Type... parameterTypes)
          Get a shared factory of native function wrappers that have a given signatures.
static CRuntime getInstance()
           
protected  NativeLibrary getNativeLibrary(Class<?> type)
           
protected  Level getSeverityOfMissingSymbol(Method method)
           
<T extends NativeObject>
Class<? extends T>
getTypeForCast(Type type)
           
<T extends NativeObject>
BridJRuntime.TypeInfo<T>
getTypeInfo(Type type)
           
protected  Method getUniqueAbstractCallbackMethod(Class type)
           
 boolean isAvailable()
           
 void register(Type type)
           
protected
<T extends CallbackInterface>
Pointer<T>
registerCallbackInstance(T instance)
           
protected  void registerFamily(Type type, NativeLibrary forcedLibrary, CRuntime.MethodCallInfoBuilder methodCallInfoBuilder)
           
protected  void registerNativeMethod(Class<?> type, NativeLibrary typeLibrary, Method method, NativeLibrary methodLibrary, NativeEntities.Builder builder, CRuntime.MethodCallInfoBuilder methodCallInfoBuilder)
           
protected  void setNativeObjectPeer(NativeObjectInterface instance, Pointer<? extends NativeObjectInterface> peer)
           
 long sizeOf(Type structType, StructIO io)
           
 
Methods inherited from class org.bridj.AbstractBridJRuntime
findConstructor, getType, isOverride, isOverridenSignature, log, log, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_bridj_c_defaultObjectSize

public static final String PROPERTY_bridj_c_defaultObjectSize
See Also:
Constant Field Values

rootCallbackClasses

protected Set<Class> rootCallbackClasses
Constructor Detail

CRuntime

@Deprecated
public CRuntime()
Deprecated. use getInstance() instead

Method Detail

getCallbackNativeImplementer

public org.bridj.CallbackNativeImplementer getCallbackNativeImplementer()

isAvailable

public boolean isAvailable()

getInstance

public static CRuntime getInstance()

getActualInstanceClass

public <T extends NativeObject> Class<? extends T> getActualInstanceClass(Pointer<T> pInstance,
                                                                          Type officialType)

getTypeInfo

public <T extends NativeObject> BridJRuntime.TypeInfo<T> getTypeInfo(Type type)

register

public void register(Type type)

registerFamily

protected void registerFamily(Type type,
                              NativeLibrary forcedLibrary,
                              CRuntime.MethodCallInfoBuilder methodCallInfoBuilder)

getNativeLibrary

protected NativeLibrary getNativeLibrary(Class<?> type)
                                  throws IOException
Throws:
IOException

getSeverityOfMissingSymbol

protected Level getSeverityOfMissingSymbol(Method method)

registerNativeMethod

protected void registerNativeMethod(Class<?> type,
                                    NativeLibrary typeLibrary,
                                    Method method,
                                    NativeLibrary methodLibrary,
                                    NativeEntities.Builder builder,
                                    CRuntime.MethodCallInfoBuilder methodCallInfoBuilder)
                             throws FileNotFoundException
Throws:
FileNotFoundException

allocate

public <T extends NativeObject> Pointer<T> allocate(Class<T> type,
                                                    int constructorId,
                                                    Object... args)

getDefaultStructSize

public int getDefaultStructSize()

sizeOf

public long sizeOf(Type structType,
                   StructIO io)

getUniqueAbstractCallbackMethod

protected Method getUniqueAbstractCallbackMethod(Class type)

getTypeForCast

public <T extends NativeObject> Class<? extends T> getTypeForCast(Type type)

getDynamicFunctionFactory

public DynamicFunctionFactory getDynamicFunctionFactory(NativeLibrary library,
                                                        Convention.Style callingConvention,
                                                        Type returnType,
                                                        Type... parameterTypes)
Get a shared factory of native function wrappers that have a given signatures.

Parameters:
library - library to which the allocated native thunks will be bound (can be null, in which case the native allocations will be bound to BridJ.getOrphanEntities())
callingConvention - calling convention used by the functions (if null, default is typically Convention.Style.CDecl)
returnType - return type of the functions
parameterTypes - parameter types of the functions Also see DynamicFunction and Pointer.asDynamicFunction(org.bridj.ann.Convention.Style, java.lang.reflect.Type, java.lang.reflect.Type[]).

createCToJavaCallback

public static <T> Pointer<T> createCToJavaCallback(MethodCallInfo mci,
                                                   Type t)

registerCallbackInstance

protected <T extends CallbackInterface> Pointer<T> registerCallbackInstance(T instance)

setNativeObjectPeer

protected void setNativeObjectPeer(NativeObjectInterface instance,
                                   Pointer<? extends NativeObjectInterface> peer)


Copyright © 2009-2012. All Rights Reserved.