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";
}
}
Aggregations