Search in sources :

Example 91 with Pointer

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

the class WebKitPresenter method jsContext.

final void jsContext(Pointer ctx) {
    this.ctx = ctx;
    JSC jsc = shell.jsc();
    onFinalize = new WebKitPresenter.OnFinalize();
    javaClazz = jsc.JSClassCreate(new JSC.JSClassDefinition(onFinalize));
    boolean testInstance = false;
    assert testInstance = true;
    if (testInstance) {
        Pointer testObj = jsc.JSObjectMake(ctx, javaClazz, null);
        assert isJavaClazz(testObj) : "Own classes has to be recognized";
    }
    {
        Pointer jsGlobal = ctx;
        Pointer arrArg = jsc.JSStringCreateWithUTF8CString("x");
        Pointer arrT = jsc.JSStringCreateWithUTF8CString("var res = x.constructor === Array ? x.length : -1; return res;");
        Pointer arrFn = jsc.JSObjectMakeFunction(jsGlobal, null, 1, new Pointer[] { arrArg }, arrT, null, 0, null);
        arrayLength = arrFn;
        jsc.JSValueProtect(ctx, arrFn);
        assert !isJavaClazz(arrayLength) : "functions aren't Java classes";
    }
    {
        Pointer trueScr = jsc.JSStringCreateWithUTF8CString("true");
        valueTrue = jsc.JSEvaluateScript(ctx, trueScr, null, null, 1, null);
        jsc.JSStringRelease(trueScr);
        jsc.JSValueProtect(ctx, valueTrue);
        int vT = jsc.JSValueGetType(ctx, valueTrue);
        assert vT == 2;
        assert !isJavaClazz(valueTrue) : "true isn't Java class";
    }
    {
        Pointer falseScr = jsc.JSStringCreateWithUTF8CString("false");
        valueFalse = jsc.JSEvaluateScript(ctx, falseScr, null, null, 1, null);
        jsc.JSValueProtect(ctx, valueFalse);
        jsc.JSStringRelease(falseScr);
        int vF = jsc.JSValueGetType(ctx, valueFalse);
        assert vF == 2;
        assert !isJavaClazz(valueFalse) : "false isn't Java class";
    }
}
Also used : Pointer(com.sun.jna.Pointer) JSC(com.dukescript.presenters.renderer.JSC)

Aggregations

Pointer (com.sun.jna.Pointer)91 PointerByReference (com.sun.jna.ptr.PointerByReference)20 Memory (com.sun.jna.Memory)15 IntByReference (com.sun.jna.ptr.IntByReference)15 Test (org.junit.Test)12 HDDEDATA (com.sun.jna.platform.win32.Ddeml.HDDEDATA)8 HSZ (com.sun.jna.platform.win32.Ddeml.HSZ)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 File (java.io.File)7 CountDownLatch (java.util.concurrent.CountDownLatch)7 HWND (com.sun.jna.platform.win32.WinDef.HWND)6 ULONG (com.sun.jna.platform.win32.WinDef.ULONG)6 BufferedImage (java.awt.image.BufferedImage)5 Function (com.sun.jna.Function)4 ULONG_PTR (com.sun.jna.platform.win32.BaseTSD.ULONG_PTR)4 ExecuteHandler (com.sun.jna.platform.win32.DdemlUtil.ExecuteHandler)4