当前位置: 首页>>代码示例>>Java>>正文


Java FromNativeContext类代码示例

本文整理汇总了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);
    }           
}
 
开发者ID:gstreamer-java,项目名称:gstreamer1.x-java,代码行数:19,代码来源:GTypeMapper.java

示例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);
}
 
开发者ID:armouroflight,项目名称:java-gobject,代码行数:17,代码来源:GTypeMapper.java

示例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;
}
 
开发者ID:ghedlund,项目名称:jpraat,代码行数:18,代码来源:NativeEnumConverter.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:WindowsNotifier.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:Win32APISupport.java

示例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);
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:11,代码来源:JnaLongEnumConverter.java

示例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;
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:10,代码来源:FixedArrayByReference.java

示例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);
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:10,代码来源:KernReturnTConverter.java

示例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;
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:10,代码来源:WStringByReference.java

示例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);
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:11,代码来源:JnaIntEnumConverter.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:W32API.java

示例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;
}
 
开发者ID:ac2cz,项目名称:FoxTelem,代码行数:9,代码来源:Kernel32Library.java

示例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;
}
 
开发者ID:jindrapetrik,项目名称:javactivex,代码行数:16,代码来源:WinNT.java

示例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);
	}
}
 
开发者ID:armouroflight,项目名称:java-gobject,代码行数:10,代码来源:GFlags.java

示例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;
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:16,代码来源:WinNT.java


注:本文中的com.sun.jna.FromNativeContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。