本文整理汇总了Java中com.sun.jna.ptr.PointerByReference.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java PointerByReference.getValue方法的具体用法?Java PointerByReference.getValue怎么用?Java PointerByReference.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jna.ptr.PointerByReference
的用法示例。
在下文中一共展示了PointerByReference.getValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
/**
* Validates if the expression instance is valid
* @return ValidationResult object
*/
public ValidationResult validate() {
PointerByReference info = new PointerByReference();
PointerByReference error = new PointerByReference();
int hsResult = HyperscanLibrary.INSTANCE.hs_expression_info(this.expression, Util.bitEnumSetToInt(this.flags), info, error);
String errorMessage = "";
boolean isValid = true;
if(hsResult != 0) {
isValid = false;
CompileErrorStruct errorStruct = new CompileErrorStruct(error.getValue());
errorMessage = errorStruct.message;
errorStruct.setAutoRead(false);
HyperscanLibrary.INSTANCE.hs_free_compile_error(errorStruct);
}
else {
Native.free(Pointer.nativeValue(info.getValue()));
}
return new ValidationResult(errorMessage, isValid);
}
示例2: compile
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
/**
* Compiles an list of expressions into a database to use for scanning
* @param expressions List of expressions to compile
* @return Compiled database
* @throws Throwable CompileErrorException on errors concerning the pattern, otherwise different Throwable's
*/
public static Database compile(List<Expression> expressions) throws Throwable {
final int expressionsSize = expressions.size();
String[] expressionsStr = new String[expressionsSize];
int[] flags = new int[expressionsSize];
int[] ids = new int[expressionsSize];
for(int i = 0; i < expressionsSize; i++) {
expressionsStr[i] = expressions.get(i).getExpression();
flags[i] = Util.bitEnumSetToInt(expressions.get(i).getFlags());
ids[i] = i;
}
PointerByReference database = new PointerByReference();
PointerByReference error = new PointerByReference();
int hsError = HyperscanLibrary.INSTANCE.hs_compile_multi(expressionsStr, flags, ids, expressionsSize,
HS_MODE_BLOCK, Pointer.NULL, database, error);
handleErrors(hsError, error.getValue(), expressions);
return new Database(database.getValue(), expressions);
}
示例3: setMaxDetectableFaces
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
/**
*
* Note
track only one face:
frist:trackHandle = STMobileApiBridge.FACESDK_INSTANCE.st_mobile_tracker_106_create(modulePath, handlerPointer);
second: setMaxDetectableFaces(1)参数设为1
* track多张人脸:
* trackHandle = STMobileApiBridge.FACESDK_INSTANCE.st_mobile_tracker_106_create(modulePath, handlerPointer);
second:setMaxDetectableFaces(num)参数设为-1
*/
public STMobileMultiTrack106(Context context, int config) {
PointerByReference handlerPointer = new PointerByReference();
mContext = context;
synchronized(this.getClass())
{
copyModelIfNeed(BEAUTIFY_MODEL_NAME);
}
String modulePath = getModelPath(BEAUTIFY_MODEL_NAME);
int rst = STMobileApiBridge.FACESDK_INSTANCE.st_mobile_tracker_106_create(modulePath, config, handlerPointer);
if(rst != ResultCode.ST_OK.getResultCode())
{
return;
}
trackHandle = handlerPointer.getValue();
}
示例4: macImpl
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
/** try to install our custom rule profile into sandbox_init() to block execution */
private static void macImpl(Path tmpFile) throws IOException {
// first be defensive: we can give nice errors this way, at the very least.
boolean supported = Constants.MAC_OS_X;
if (supported == false) {
throw new IllegalStateException("bug: should not be trying to initialize seatbelt for an unsupported OS");
}
// we couldn't link methods, could be some really ancient OS X (< Leopard) or some bug
if (libc_mac == null) {
throw new UnsupportedOperationException("seatbelt unavailable: could not link methods. requires Leopard or above.");
}
// write rules to a temporary file, which will be passed to sandbox_init()
Path rules = Files.createTempFile(tmpFile, "es", "sb");
Files.write(rules, Collections.singleton(SANDBOX_RULES));
boolean success = false;
try {
PointerByReference errorRef = new PointerByReference();
int ret = libc_mac.sandbox_init(rules.toAbsolutePath().toString(), SANDBOX_NAMED, errorRef);
// if sandbox_init() fails, add the message from the OS (e.g. syntax error) and free the buffer
if (ret != 0) {
Pointer errorBuf = errorRef.getValue();
RuntimeException e = new UnsupportedOperationException("sandbox_init(): " + errorBuf.getString(0));
libc_mac.sandbox_free_error(errorBuf);
throw e;
}
logger.debug("OS X seatbelt initialization successful");
success = true;
} finally {
if (success) {
Files.delete(rules);
} else {
IOUtils.deleteFilesIgnoringExceptions(rules);
}
}
}
示例5: engiGetAggrElement
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
/**
* Returns a data field in the actual aggregate element.
*
* @param aggregate
* Existing aggregation
* @param elementIndex
* Position in the existing aggregation, first position is 0
* @param valueType
* Type of output value
* @return Value of the specific element in the aggregation
*/
public Object engiGetAggrElement(Pointer aggregate, int elementIndex, SdaiTypes valueType) {
Object returnValue = null;
switch (valueType) {
case INTEGER:
IntByReference intRef = new IntByReference();
engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), intRef);
returnValue = new Integer(intRef.getValue());
break;
case REAL:
DoubleByReference dblRef = new DoubleByReference();
engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), dblRef);
returnValue = new Double(dblRef.getValue());
break;
case STRING:
PointerByReference strRef = new PointerByReference();
engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), strRef);
Pointer strPtr = strRef.getValue();
if (strPtr != null)
returnValue = strPtr.getString(0);
break;
default:
PointerByReference ptrRef = new PointerByReference();
engine.engiGetAggrElement(aggregate, elementIndex, valueType.ordinal(), ptrRef);
returnValue = ptrRef.getValue();
break;
}
return returnValue;
}
示例6: sdaiGetAggrByIterator
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
/**
* Implementation postponed till version 1.10
*
* @param iterator
* Existing iterator
* @param valueType
* Type of output value
* @return
*/
public Object sdaiGetAggrByIterator(Pointer iterator, SdaiTypes valueType) {
Object returnValue = null;
switch (valueType) {
case REAL:
DoubleByReference dVal = new DoubleByReference();
engine.sdaiGetAggrByIterator(iterator, valueType.ordinal(), dVal);
returnValue = new Double(dVal.getValue());
break;
case INTEGER:
case BOOLEAN:
case LOGICAL:
IntByReference iVal = new IntByReference();
engine.sdaiGetAggrByIterator(iterator, valueType.ordinal(), iVal);
returnValue = new Integer(iVal.getValue());
break;
case STRING:
PointerByReference sVal = new PointerByReference();
engine.sdaiGetAggrByIterator(iterator, valueType.ordinal(), sVal);
returnValue = (String) sVal.getValue().getString(0);
break;
default:
PointerByReference ptr = new PointerByReference();
engine.sdaiGetAggrByIterator(iterator, valueType.ordinal(), ptr);
returnValue = ptr.getValue();
break;
}
return returnValue;
}
示例7: sdaiGetAttr
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
/**
* Returns the data value of the specified attribute in the actual instance.
* The actual instance is specified by a numeric instanceID that uniquely
* identifies an instance.
*
* @param instance
* A numeric instanceID that uniquely identifies an instance.
* @param attribute
* A numeric attributerID that uniquely identifies an attribute
* definition instance.
* @param valueType
* Type of output value.
* @return Output value of the specific element in the aggregation.
*/
public Object sdaiGetAttr(Pointer instance, int attribute, SdaiTypes valueType) {
Object returnValue = null;
switch (valueType) {
case REAL:
DoubleByReference dVal = new DoubleByReference();
engine.sdaiGetAggrByIterator(instance, valueType.ordinal(), dVal);
returnValue = new Double(dVal.getValue());
break;
case INTEGER:
case BOOLEAN:
case LOGICAL:
IntByReference iVal = new IntByReference();
engine.sdaiGetAggrByIterator(instance, valueType.ordinal(), iVal);
returnValue = new Integer(iVal.getValue());
break;
case STRING:
PointerByReference sVal = new PointerByReference();
engine.sdaiGetAggrByIterator(instance, valueType.ordinal(), sVal);
returnValue = (String) sVal.getValue().getString(0);
break;
default:
PointerByReference ptr = new PointerByReference();
engine.sdaiGetAggrByIterator(instance, valueType.ordinal(), ptr);
returnValue = ptr.getValue();
break;
}
return returnValue;
}
示例8: STMobileFaceDetection
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
public STMobileFaceDetection(Context context, int config) {
PointerByReference handlerPointer = new PointerByReference();
mContext = context;
synchronized(this.getClass())
{
copyModelIfNeed(DETECTION_MODEL_NAME);
}
String modulePath = getModelPath(DETECTION_MODEL_NAME);
int rst = STMobileApiBridge.FACESDK_INSTANCE.st_mobile_face_detection_create(modulePath, config, handlerPointer);
if(rst != ResultCode.ST_OK.getResultCode())
{
return;
}
detectHandle = handlerPointer.getValue();
}
示例9: probeInputFormat
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
private void probeInputFormat() throws FFmpegException {
PointerByReference ptr = new PointerByReference();
int retval = Avformat57Library.INSTANCE.av_probe_input_buffer(ioContext,
ptr,
"",
Pointer.NULL,
0,
FFMPEG_IO_BUFFER_SIZE);
if (retval != 0)
throw new FFmpegException("Failed to probe stream format! av_probe_input_buffer returned error code " + retval);
inputFormat = new AVInputFormat(ptr.getValue()); // FUCK OUTPUT ARGUMENT!
inputFormat.autoRead();
}
示例10: macImpl
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
/** try to install our custom rule profile into sandbox_init() to block execution */
private static void macImpl(Path tmpFile) throws IOException {
// first be defensive: we can give nice errors this way, at the very least.
boolean supported = Constants.MAC_OS_X;
if (supported == false) {
throw new IllegalStateException("bug: should not be trying to initialize seatbelt for an unsupported OS");
}
// we couldn't link methods, could be some really ancient OS X (< Leopard) or some bug
if (libc_mac == null) {
throw new UnsupportedOperationException("seatbelt unavailable: could not link methods. requires Leopard or above.");
}
// write rules to a temporary file, which will be passed to sandbox_init()
Path rules = Files.createTempFile(tmpFile, "es", "sb");
Files.write(rules, Collections.singleton(SANDBOX_RULES), StandardCharsets.UTF_8);
boolean success = false;
try {
PointerByReference errorRef = new PointerByReference();
int ret = libc_mac.sandbox_init(rules.toAbsolutePath().toString(), SANDBOX_NAMED, errorRef);
// if sandbox_init() fails, add the message from the OS (e.g. syntax error) and free the buffer
if (ret != 0) {
Pointer errorBuf = errorRef.getValue();
RuntimeException e = new UnsupportedOperationException("sandbox_init(): " + errorBuf.getString(0));
libc_mac.sandbox_free_error(errorBuf);
throw e;
}
logger.debug("OS X seatbelt initialization successful");
success = true;
} finally {
if (success) {
Files.delete(rules);
} else {
IOUtils.deleteFilesIgnoringExceptions(rules);
}
}
}
示例11: getVersionInfo
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private static int[] getVersionInfo(String path) {
if (installedBrowsers == null) {
findInstalledBrowsers();
}
IntByReference dwDummy = new IntByReference();
dwDummy.setValue(0);
int versionlength = com.sun.jna.platform.win32.Version.INSTANCE
.GetFileVersionInfoSize(path, dwDummy);
byte[] bufferarray = new byte[versionlength];
Pointer lpData = new Memory(bufferarray.length);
PointerByReference lplpBuffer = new PointerByReference();
IntByReference puLen = new IntByReference();
boolean fileInfoResult = com.sun.jna.platform.win32.Version.INSTANCE
.GetFileVersionInfo(path, 0, versionlength, lpData);
boolean verQueryVal = com.sun.jna.platform.win32.Version.INSTANCE
.VerQueryValue(lpData, "\\", lplpBuffer, puLen);
VS_FIXEDFILEINFO lplpBufStructure = new VS_FIXEDFILEINFO(
lplpBuffer.getValue());
lplpBufStructure.read();
int v1 = (lplpBufStructure.dwFileVersionMS).intValue() >> 16;
int v2 = (lplpBufStructure.dwFileVersionMS).intValue() & 0xffff;
int v3 = (lplpBufStructure.dwFileVersionLS).intValue() >> 16;
int v4 = (lplpBufStructure.dwFileVersionLS).intValue() & 0xffff;
return new int[] { v1, v2, v3, v4 };
}
示例12: plan
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
public boolean plan() {
ArrayList<PoseSteering> finalPath = new ArrayList<PoseSteering>();
for (int i = 0; i < this.goal.length; i++) {
Pose start_ = null;
Pose goal_ = this.goal[i];
if (i == 0) start_ = this.start;
else start_ = this.goal[i-1];
path = new PointerByReference();
pathLength = new IntByReference();
if (collisionCircleCenters == null) {
if (!INSTANCE.plan(mapFilename, mapResolution, robotRadius, start_.getX(), start_.getY(), start_.getTheta(), goal_.getX(), goal_.getY(), goal_.getTheta(), path, pathLength, distanceBetweenPathPoints, turningRadius)) return false;
}
else {
double[] xCoords = new double[collisionCircleCenters.length];
double[] yCoords = new double[collisionCircleCenters.length];
int numCoords = collisionCircleCenters.length;
for (int j = 0; j < collisionCircleCenters.length; j++) {
xCoords[j] = collisionCircleCenters[j].x;
yCoords[j] = collisionCircleCenters[j].y;
}
System.out.println("Path planning with " + collisionCircleCenters.length + " circle positions");
if (this.mapFilename != null) {
if (!INSTANCE.plan_multiple_circles(mapFilename, mapResolution, robotRadius, xCoords, yCoords, numCoords, start_.getX(), start_.getY(), start_.getTheta(), goal_.getX(), goal_.getY(), goal_.getTheta(), path, pathLength, distanceBetweenPathPoints, turningRadius)) return false;
}
else {
if (!INSTANCE.plan_multiple_circles_nomap(xCoords, yCoords, numCoords, start_.getX(), start_.getY(), start_.getTheta(), goal_.getX(), goal_.getY(), goal_.getTheta(), path, pathLength, distanceBetweenPathPoints, turningRadius)) return false;
}
}
final Pointer pathVals = path.getValue();
final PathPose valsRef = new PathPose(pathVals);
valsRef.read();
int numVals = pathLength.getValue();
PathPose[] pathPoses = (PathPose[])valsRef.toArray(numVals);
if (i == 0) finalPath.add(new PoseSteering(pathPoses[0].x, pathPoses[0].y, pathPoses[0].theta, 0.0));
for (int j = 1; j < pathPoses.length; j++) finalPath.add(new PoseSteering(pathPoses[j].x, pathPoses[j].y, pathPoses[j].theta, 0.0));
INSTANCE.cleanupPath(pathVals);
}
this.pathPS = finalPath.toArray(new PoseSteering[finalPath.size()]);
return true;
}
示例13: tryRead
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
@Nullable
public byte[] tryRead(byte[] buf) throws FFmpegException {
if (formatContext == null) throw new IllegalStateException("Decoder is already closed");
int retval;
while (true) {
retval = Avformat57Library.INSTANCE.av_read_frame(formatContext, packet);
if (retval < 0) return null;
packet.read();
if (packet.stream_index != audioStreamIndex) {
Avcodec57Library.INSTANCE.av_packet_unref(packet);
} else break;
}
retval = Avcodec57Library.INSTANCE.avcodec_send_packet(codecContext, packet.getPointer());
if (retval < 0 && retval != -11 && retval != AVERROR_EOF) {
throw new FFmpegException("Decode packet failed! avcodec_send_packet returned " + retval);
}
AVFrame frame = Avutil55Library.INSTANCE.av_frame_alloc();
retval = Avcodec57Library.INSTANCE.avcodec_receive_frame(codecContext, frame);
if (retval < 0 && retval != AVERROR_EOF) {
throw new FFmpegException("Decode packet failed! avcodec_receive_frame returned " + retval);
}
frame.read();
updatePosition(frame);
fixFrameArgs(frame);
long destNumSamplesPerChannel =
Avutil55Library.INSTANCE.av_rescale_rnd(
Swresample2Library.INSTANCE.swr_get_delay(swrContext, frame.sample_rate) + frame.nb_samples,
frame.sample_rate, frame.sample_rate, 0);
PointerByReference tempPtr = new PointerByReference(audioBuffer);
int numSamples = Swresample2Library.INSTANCE.swr_convert(swrContext, tempPtr,
(int) destNumSamplesPerChannel, frame.data, frame.nb_samples);
int dataSize = frame.channels * numSamples * Avutil55Library.INSTANCE.av_get_bytes_per_sample(sampleFormat);
Avutil55Library.INSTANCE.av_frame_free(new PointerByReference(frame.getPointer()));
audioBuffer = tempPtr.getValue();
if (buf != null && buf.length == dataSize) {
audioBuffer.read(0, buf, 0, dataSize);
return buf;
}
return audioBuffer.getByteArray(0, dataSize);
}
示例14: sdaiGetAttrBN
import com.sun.jna.ptr.PointerByReference; //导入方法依赖的package包/类
/**
* Returns the data value of the specified attribute in the actual instance.
* The actual instance is specified by a numeric instanceID that uniquely
* identifies an instance.
*
* @param instance
* A numeric instanceID that uniquely identifies an instance.
* @param attributeName
* A character that contains an attribute name existing in the
* mentioned instance.
* @param valueType
* Type of output value.
* @return Output value of the specific element in the aggregation.
*/
public Object sdaiGetAttrBN(Pointer instance, String attributeName, SdaiTypes valueType) {
PointerByReference ptrRef = new PointerByReference();
engine.sdaiGetAttrBN(instance, attributeName, valueType.ordinal(), ptrRef);
switch (valueType) {
case STRING:
return ptrRef.getValue().getString(0);
default:
return ptrRef.getValue();
}
}