本文整理汇总了Java中org.bridj.Callback类的典型用法代码示例。如果您正苦于以下问题:Java Callback类的具体用法?Java Callback怎么用?Java Callback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Callback类属于org.bridj包,在下文中一共展示了Callback类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: matches
import org.bridj.Callback; //导入依赖的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);
}
开发者ID:nativelibs4java,项目名称:BridJ,代码行数:11,代码来源:Demangler.java
示例2: parseCallback
import org.bridj.Callback; //导入依赖的package包/类
@SuppressWarnings("unused")
private void parseCallback(Element root, ParsingContext context) {
//Note: I expect never getting here from an anonymous callback type for now
String name = root.getAttributeValue("name");
Set<String> foundTypes = (Set<String>)context.getExtra(Constants.CONTEXT_EXTRA_DEFINED_TYPES);
foundTypes.add("" + context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE) + '.' + name);
ParsingContext nextContext = context.copy();
parseElements(root.getChildElements(), nextContext);
// The context should now have the return type, and parameter list.
ConvertedType returnType = (ConvertedType) nextContext.getExtra(Constants.CONTEXT_EXTRA_RETURN_TYPE);
List<ParameterDescriptor> parametersList = (List<ParameterDescriptor>) nextContext.getExtra(Constants.CONTEXT_EXTRA_PARAM_TYPES);
if (checkUndefined(root, nextContext)) {
return;
}
if (checkStructByValue(returnType, parametersList)) {
System.out.println("Skipped callback type " + name + " because it takes or returns struct by value");
return;
}
//Abstract class
//XXX: why neutralize, or why not together with the prefix?
String className = context.getCurrentPackage() + '.' + context.getExtra(Constants.CONTEXT_EXTRA_PREFIX) + NameUtils.neutralizeKeyword(name);
JDefinedClass callbackType;
try {
callbackType = context.getCm()._class(JMod.PUBLIC | JMod.ABSTRACT, className, ClassType.CLASS);
} catch (JClassAlreadyExistsException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return;
}
callbackType._extends(context.getCm().ref(Callback.class).narrow(callbackType));
//apply() method
JMethod applyMethod = callbackType.method(JMod.PUBLIC | JMod.ABSTRACT, returnType.getJType(), "apply");
for (ParameterDescriptor param : parametersList) {
applyMethod.param(param.getType().getJType(), param.getName());
}
ConvertedType convType = new ConvertedType(
context.getCm(),
(String)context.getExtra(Constants.CONTEXT_EXTRA_NAMESPACE),
name,
root.getAttributeValue("type",Constants.GIR_XMLNS_C),
false
);
convType.setJType(context.getCm().ref(Pointer.class).narrow(callbackType));
context.registerType(convType);
}
开发者ID:gstreamer-java,项目名称:gir2java,代码行数:53,代码来源:GirParser.java
注:本文中的org.bridj.Callback类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论