本文整理汇总了Java中org.bridj.Pointer.allocate方法的典型用法代码示例。如果您正苦于以下问题:Java Pointer.allocate方法的具体用法?Java Pointer.allocate怎么用?Java Pointer.allocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bridj.Pointer
的用法示例。
在下文中一共展示了Pointer.allocate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: controlTest
import org.bridj.Pointer; //导入方法依赖的package包/类
@Test
public void controlTest() {
Pointer<Byte> name = Pointer.pointerToCString("base");
Pointer<Byte> program = Pointer.pointerToCString(PROGRAM3);
clingo_part p = new clingo_part();
p.name(name);
p.params(null);
p.size(0);
Pointer<clingo_part> parts = Pointer.allocate(clingo_part.class);
parts.set(p);
Pointer<Integer> major = Pointer.allocateInt();
Pointer<Integer> minor = Pointer.allocateInt();
Pointer<Integer> revision = Pointer.allocateInt();
LIB.clingo_version(major, minor, revision);
System.out.println("Clingo library version: " + major.getInt() + "." + minor.getInt() + "." + revision.getInt());
// create a control object and pass command line arguments
Pointer<Pointer<clingo_control>> control = Pointer.allocatePointer(clingo_control.class);
if (!LIB.clingo_control_new(null, 0, null, null, 20, control)) {
error(control, "Could not create controller");
}
long startTime = System.currentTimeMillis();
// add a logic program to the base part
if (!LIB.clingo_control_add(control.get(), name, null, 0, program)) {
error(control, "Error add the program to controller");
}
// ground the base part
if (!LIB.clingo_control_ground(control.get(), parts, 1, null, null)) {
error(control, "Error ground the program");
}
if (!solve(control)) {
error(control, "Error solving the program");
}
float endTime = (System.currentTimeMillis() - startTime) / 1000f;
System.out.println("Time:" + String.format(TIME_FORMAT, endTime) + "s");
LIB.clingo_control_free(control.get());
}