org.bridj
Class CRuntime
java.lang.Object
org.bridj.AbstractBridJRuntime
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
Method Summary |
|
allocate(Class<T> type,
int constructorId,
Object... args)
|
static
|
createCToJavaCallback(MethodCallInfo mci,
Type 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)
|
|
getTypeForCast(Type type)
|
|
getTypeInfo(Type type)
|
protected Method |
getUniqueAbstractCallbackMethod(Class type)
|
boolean |
isAvailable()
|
void |
register(Type type)
|
protected
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PROPERTY_bridj_c_defaultObjectSize
public static final String PROPERTY_bridj_c_defaultObjectSize
- See Also:
- Constant Field Values
rootCallbackClasses
protected Set<Class> rootCallbackClasses
CRuntime
@Deprecated
public CRuntime()
- Deprecated. use
getInstance()
instead
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 functionsparameterTypes
- 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.