本文整理汇总了Java中com.sun.jna.FromNativeContext类的典型用法代码示例。如果您正苦于以下问题:Java FromNativeContext类的具体用法?Java FromNativeContext怎么用?Java FromNativeContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FromNativeContext类属于com.sun.jna包,在下文中一共展示了FromNativeContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
public Object fromNative(Object result, FromNativeContext context) {
if (result == null) {
return null;
}
if (context instanceof MethodResultContext) {
MethodResultContext functionContext = (MethodResultContext) context;
Method method = functionContext.getMethod();
Pointer ptr = (Pointer) result;
String s = ptr.getString(0);
if (method.isAnnotationPresent(FreeReturnValue.class)
|| method.isAnnotationPresent(CallerOwnsReturn.class)) {
GlibAPI.GLIB_API.g_free(ptr);
}
return s;
} else {
return ((Pointer) result).getString(0);
}
}
示例2: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
@SuppressWarnings(value = "unchecked")
public Object fromNative(Object result, FromNativeContext context) {
if (result == null) {
return null;
}
if (context instanceof FunctionResultContext) {
return NativeObject.Internals.objectFor((Pointer) result, context.getTargetType(), true);
}
if (context instanceof CallbackParameterContext || context instanceof StructureReadContext) {
return NativeObject.Internals.objectFor((Pointer) result, context.getTargetType(), false);
}
if (context instanceof MethodResultContext) {
throw new RuntimeException("Got illegal MethodResultContext in GTypeMapper");
}
throw new IllegalStateException("Cannot convert to NativeObject from " + context);
}
示例3: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
public Object fromNative(Object obj, FromNativeContext ctx) {
final Integer nativeVal = (Integer) obj;
final Class<?> targetClazz = ctx.getTargetType();
Object retVal = null;
if(targetClazz != null &&
NativeEnum.class.isAssignableFrom(targetClazz)) {
final Object[] enumVals = targetClazz.getEnumConstants();
for(Object enumVal:enumVals) {
final NativeEnum ne = (NativeEnum)enumVal;
if(ne.getNativeValue() == nativeVal) {
retVal = ne;
break;
}
}
}
return retVal;
}
示例4: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
/** Override to the appropriate object for INVALID_HANDLE_VALUE. */
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
Object o = super.fromNative(nativeValue, context);
if (INVALID_HANDLE_VALUE.equals(o))
return INVALID_HANDLE_VALUE;
return o;
}
示例5: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
Object o = super.fromNative(nativeValue, context);
if (InvalidHandle.equals(o)) {
return InvalidHandle;
}
return o;
}
示例6: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
@Override
public Object fromNative(Object input, FromNativeContext context) {
if (!JnaLongEnum.class.isAssignableFrom(context.getTargetType())) {
throw new IllegalStateException("JnaLongEnumConverter can only convert objects implementing JnaLongEnum");
}
@SuppressWarnings("rawtypes")
Class targetClass = context.getTargetType();
Object[] enumValues = targetClass.getEnumConstants();
return ((JnaLongEnum<?>) enumValues[0]).typeForValue((long) input);
}
示例7: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
// Always pass along null pointer values
if (nativeValue == null) {
return null;
}
super.setPointer((Pointer) nativeValue);
return this;
}
示例8: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
@Override
public Object fromNative(Object input, FromNativeContext context) {
if (!KernReturnT.class.isAssignableFrom(context.getTargetType())) {
throw new IllegalStateException(
"KernReturnTConverter can only convert objects implementing KernReturnT"
);
}
return DefaultKernReturnT.typeOf((int) input);
}
示例9: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
// Always pass along null pointer values
if (nativeValue == null) {
return null;
}
setPointer((Pointer) nativeValue);
return this;
}
示例10: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
@Override
public Object fromNative(Object input, FromNativeContext context) {
if (!JnaIntEnum.class.isAssignableFrom(context.getTargetType())) {
throw new IllegalStateException("JnaIntEnumConverter can only convert objects implementing JnaIntEnum");
}
@SuppressWarnings("rawtypes")
Class targetClass = context.getTargetType();
Object[] enumValues = targetClass.getEnumConstants();
return ((JnaIntEnum<?>) enumValues[0]).typeForValue((int) input);
}
示例11: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
/** Override to the appropriate object for INVALID_HANDLE_VALUE. */
public Object fromNative(Object nativeValue, FromNativeContext context) {
Object o = super.fromNative(nativeValue, context);
if (INVALID_HANDLE_VALUE.equals(o))
return INVALID_HANDLE_VALUE;
return o;
}
示例12: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
public Object fromNative(Object nativeValue, FromNativeContext context) {
Object o = super.fromNative(nativeValue, context);
if (SetUpApiLibrary.NULL.equals(o))
return SetUpApiLibrary.NULL;
if (SetUpApiLibrary.INVALID_HANDLE_VALUE.equals(o))
return SetUpApiLibrary.INVALID_HANDLE_VALUE;
return o;
}
示例13: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
/**
* Override to the appropriate object for INVALID_HANDLE_VALUE.
*
* @param nativeValue
* @param context
* @return
*/
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
Object o = super.fromNative(nativeValue, context);
if (WinBase.INVALID_HANDLE_VALUE.equals(o)) {
return WinBase.INVALID_HANDLE_VALUE;
}
return o;
}
示例14: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public final Object fromNative(Object nativeValue, FromNativeContext context) {
try {
return context.getTargetType().getConstructor(new Class<?>[] { int[].class })
.newInstance(new Object[] { new int[] { (Integer) nativeValue } });
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例15: fromNative
import com.sun.jna.FromNativeContext; //导入依赖的package包/类
/**
* Override to the appropriate object for INVALID_HANDLE_VALUE.
*
* @param nativeValue nativeValue
* @param context context
* @return result
*/
@Override
public Object fromNative(Object nativeValue, FromNativeContext context) {
Object o = super.fromNative(nativeValue, context);
if (WinBase.INVALID_HANDLE_VALUE.equals(o)) {
return WinBase.INVALID_HANDLE_VALUE;
}
return o;
}