本文整理汇总了Java中org.bridj.CRuntime类的典型用法代码示例。如果您正苦于以下问题:Java CRuntime类的具体用法?Java CRuntime怎么用?Java CRuntime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CRuntime类属于org.bridj包,在下文中一共展示了CRuntime类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import org.bridj.CRuntime; //导入依赖的package包/类
@Override
public boolean matches(Type type, Annotations annotations) {
Class<?> typeClass = getTypeClass(type);
if (!Callback.class.isAssignableFrom(typeClass))
return false;
Method method = CRuntime.getInstance().getFastestCallbackMethod(typeClass);
if (method == null)
return false;
return function.matches(method);
}
示例2: getArgumentsStackSize
import org.bridj.CRuntime; //导入依赖的package包/类
static int getArgumentsStackSize(Method method) {
int total = 0;
Type[] paramTypes = method.getGenericParameterTypes();
Annotation[][] anns = method.getParameterAnnotations();
for (int iArg = 0, nArgs = paramTypes.length; iArg < nArgs; iArg++) {
Class<?> paramType = getTypeClass(paramTypes[iArg]);
if (paramType == int.class) {
total += 4;
} else if (paramType == long.class) {
Annotation[] as = anns[iArg];
if (isAnnotationPresent(Ptr.class, as) || isAnnotationPresent(org.bridj.ann.CLong.class, as)) //if (hasInstance(anns[iArg], Ptr.class, CLong.class))
{
total += Pointer.SIZE;
} else {
total += 8;
}
} else if (paramType == float.class) {
total += 4;
} else if (paramType == double.class) {
total += 8;
} else if (paramType == byte.class) {
total += 1;
} else if (paramType == char.class) {
total += Platform.WCHAR_T_SIZE;
} else if (paramType == CLong.class) {
total += Platform.CLONG_SIZE;
} else if (paramType == SizeT.class) {
total += Platform.SIZE_T_SIZE;
} else if (paramType == TimeT.class) {
total += Platform.TIME_T_SIZE;
} else if (paramType == short.class) {
total += 2;
} else if (paramType == boolean.class) {
total += 1;
} else if (Pointer.class.isAssignableFrom(paramType)) {
total += Pointer.SIZE;
} else if (NativeObject.class.isAssignableFrom(paramType)) {
total += ((CRuntime) BridJ.getRuntime(paramType)).sizeOf(paramTypes[iArg], null);
} else if (FlagSet.class.isAssignableFrom(paramType)) {
total += 4; // TODO
} else {
throw new RuntimeException("Type not handled : " + paramType.getName());
}
}
return total;
}