Search in sources :

Example 36 with Pointer

use of com.sun.jna.Pointer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MappedFile method munlock.

public void munlock() {
    final long beginTime = System.currentTimeMillis();
    final long address = ((DirectBuffer) (this.mappedByteBuffer)).address();
    Pointer pointer = new Pointer(address);
    int ret = LibC.INSTANCE.munlock(pointer, new NativeLong(this.fileSize));
    log.info("munlock {} {} {} ret = {} time consuming = {}", address, this.fileName, this.fileSize, ret, System.currentTimeMillis() - beginTime);
}
Also used : DirectBuffer(sun.nio.ch.DirectBuffer) NativeLong(com.sun.jna.NativeLong) Pointer(com.sun.jna.Pointer)

Example 37 with Pointer

use of com.sun.jna.Pointer in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class MappedFile method mlock.

public void mlock() {
    final long beginTime = System.currentTimeMillis();
    final long address = ((DirectBuffer) (this.mappedByteBuffer)).address();
    Pointer pointer = new Pointer(address);
    {
        int ret = LibC.INSTANCE.mlock(pointer, new NativeLong(this.fileSize));
        log.info("mlock {} {} {} ret = {} time consuming = {}", address, this.fileName, this.fileSize, ret, System.currentTimeMillis() - beginTime);
    }
    {
        int ret = LibC.INSTANCE.madvise(pointer, new NativeLong(this.fileSize), LibC.MADV_WILLNEED);
        log.info("madvise {} {} {} ret = {} time consuming = {}", address, this.fileName, this.fileSize, ret, System.currentTimeMillis() - beginTime);
    }
}
Also used : DirectBuffer(sun.nio.ch.DirectBuffer) NativeLong(com.sun.jna.NativeLong) Pointer(com.sun.jna.Pointer)

Example 38 with Pointer

use of com.sun.jna.Pointer in project dukescript-presenters by dukescript.

the class WebKitPresenter method convertToString.

final String convertToString(JSC jsc, Pointer value) {
    int type = jsc.JSValueGetType(ctx, value);
    if (type == 5) {
        Pointer toStr = jsc.JSStringCreateWithUTF8CString("this.toString()");
        value = jsc.JSEvaluateScript(ctx, toStr, value, null, 0, null);
        jsc.JSStringRelease(toStr);
    }
    Object ret = convertToJava(jsc, String.class, value);
    return ret != null ? ret.toString() : "<null value>";
}
Also used : Pointer(com.sun.jna.Pointer)

Example 39 with Pointer

use of com.sun.jna.Pointer in project dukescript-presenters by dukescript.

the class Cocoa method nsString.

static Pointer nsString(String bd) {
    ObjC objC = ObjC.INSTANCE;
    Pointer stringClass = objC.objc_getClass("NSString");
    Pointer browserDemo = new Pointer(send(stringClass, "stringWithCString:encoding:", bd, 4));
    return browserDemo;
}
Also used : Pointer(com.sun.jna.Pointer)

Example 40 with Pointer

use of com.sun.jna.Pointer in project Terasology by MovingBlocks.

the class OpenVRProvider method setKeyboardOverlayShowing.

/**
 * Turn on the keyboard overlay. This is a keyboard that hovers in front of the user, that can be typed upon by
 * pointing the ray extending from the top of the controller at the key the user wants to press.
 * @param showingState - true or false
 * @return - true if successful. If this call fails, an error is logged.
 */
public static boolean setKeyboardOverlayShowing(boolean showingState) {
    int ret;
    if (showingState) {
        Pointer pointer = new Memory(3);
        pointer.setString(0, "mc");
        Pointer empty = new Memory(1);
        empty.setString(0, "");
        ret = vrOverlay.ShowKeyboard.apply(0, 0, pointer, 256, empty, (byte) 1, 0);
        // 0 = no error, > 0 see EVROverlayError
        keyboardShowing = 0 == ret;
        if (ret != 0) {
            logger.error("VR Overlay Error: " + vrOverlay.GetOverlayErrorNameFromEnum.apply(ret).getString(0));
        }
    } else {
        try {
            vrOverlay.HideKeyboard.apply();
        } catch (Error e) {
            logger.error("Error bringing up keyboard overlay: " + e.toString());
        }
        keyboardShowing = false;
    }
    return keyboardShowing;
}
Also used : Memory(com.sun.jna.Memory) Pointer(com.sun.jna.Pointer)

Aggregations

Pointer (com.sun.jna.Pointer)152 PointerByReference (com.sun.jna.ptr.PointerByReference)31 Test (org.junit.Test)31 Memory (com.sun.jna.Memory)23 File (java.io.File)21 ByteBuffer (java.nio.ByteBuffer)18 NativeLong (com.sun.jna.NativeLong)17 IntByReference (com.sun.jna.ptr.IntByReference)17 BufferedImage (java.awt.image.BufferedImage)15 FileInputStream (java.io.FileInputStream)11 HDDEDATA (com.sun.jna.platform.win32.Ddeml.HDDEDATA)8 HSZ (com.sun.jna.platform.win32.Ddeml.HSZ)8 DirectBuffer (sun.nio.ch.DirectBuffer)8 HCONV (com.sun.jna.platform.win32.Ddeml.HCONV)7 ConnectHandler (com.sun.jna.platform.win32.DdemlUtil.ConnectHandler)7 IDdeConnection (com.sun.jna.platform.win32.DdemlUtil.IDdeConnection)7 StandaloneDdeClient (com.sun.jna.platform.win32.DdemlUtil.StandaloneDdeClient)7 HANDLE (com.sun.jna.platform.win32.WinNT.HANDLE)7 IOException (java.io.IOException)7 CountDownLatch (java.util.concurrent.CountDownLatch)7