зеркало из https://github.com/mozilla/pluotsorbet.git
Port some midp/midp.js natives to Native.create
This commit is contained in:
Родитель
5a837af056
Коммит
d31622cdaf
79
midp/midp.js
79
midp/midp.js
|
@ -141,8 +141,8 @@ MIDP.messagesTBL = [
|
||||||
["satsa"]
|
["satsa"]
|
||||||
];
|
];
|
||||||
|
|
||||||
Native["com/sun/midp/security/Permissions.getGroupMessages.(Ljava/lang/String;)[Ljava/lang/String;"] = function(ctx, stack) {
|
Native.create("com/sun/midp/security/Permissions.getGroupMessages.(Ljava/lang/String;)[Ljava/lang/String;", function(ctx, jName) {
|
||||||
var name = util.fromJavaString(stack.pop());
|
var name = util.fromJavaString(jName);
|
||||||
var list = null;
|
var list = null;
|
||||||
MIDP.groupTBL.forEach(function(e, n) {
|
MIDP.groupTBL.forEach(function(e, n) {
|
||||||
if (e === name) {
|
if (e === name) {
|
||||||
|
@ -153,8 +153,8 @@ Native["com/sun/midp/security/Permissions.getGroupMessages.(Ljava/lang/String;)[
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
stack.push(list);
|
return list;
|
||||||
}
|
});
|
||||||
|
|
||||||
MIDP.membersTBL = [
|
MIDP.membersTBL = [
|
||||||
["javax.microedition.io.Connector.http",
|
["javax.microedition.io.Connector.http",
|
||||||
|
@ -209,8 +209,8 @@ MIDP.membersTBL = [
|
||||||
["javax.microedition.apdu.sat"],
|
["javax.microedition.apdu.sat"],
|
||||||
];
|
];
|
||||||
|
|
||||||
Native["com/sun/midp/security/Permissions.loadGroupPermissions.(Ljava/lang/String;)[Ljava/lang/String;"] = function(ctx, stack) {
|
Native.create("com/sun/midp/security/Permissions.loadGroupPermissions.(Ljava/lang/String;)[Ljava/lang/String;", function(ctx, jName) {
|
||||||
var name = util.fromJavaString(stack.pop());
|
var name = util.fromJavaString(jName);
|
||||||
var list = null;
|
var list = null;
|
||||||
MIDP.groupTBL.forEach(function(e, n) {
|
MIDP.groupTBL.forEach(function(e, n) {
|
||||||
if (e === name) {
|
if (e === name) {
|
||||||
|
@ -221,11 +221,10 @@ Native["com/sun/midp/security/Permissions.loadGroupPermissions.(Ljava/lang/Strin
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
stack.push(list);
|
return list;
|
||||||
}
|
});
|
||||||
|
|
||||||
Native["com/sun/midp/main/CommandState.restoreCommandState.(Lcom/sun/midp/main/CommandState;)V"] = function(ctx, stack) {
|
Native.create("com/sun/midp/main/CommandState.restoreCommandState.(Lcom/sun/midp/main/CommandState;)V", function(ctx, state) {
|
||||||
var state = stack.pop();
|
|
||||||
var suiteId = (MIDP.midletClassName === "internal") ? -1 : 1;
|
var suiteId = (MIDP.midletClassName === "internal") ? -1 : 1;
|
||||||
state.class.getField("I.suiteId.I").set(state, suiteId);
|
state.class.getField("I.suiteId.I").set(state, suiteId);
|
||||||
state.class.getField("I.midletClassName.Ljava/lang/String;").set(state, ctx.newString(MIDP.midletClassName));
|
state.class.getField("I.midletClassName.Ljava/lang/String;").set(state, ctx.newString(MIDP.midletClassName));
|
||||||
|
@ -233,7 +232,7 @@ Native["com/sun/midp/main/CommandState.restoreCommandState.(Lcom/sun/midp/main/C
|
||||||
state.class.getField("I.arg0.Ljava/lang/String;").set(state, ctx.newString((args.length > 0) ? args[0] : ""));
|
state.class.getField("I.arg0.Ljava/lang/String;").set(state, ctx.newString((args.length > 0) ? args[0] : ""));
|
||||||
state.class.getField("I.arg1.Ljava/lang/String;").set(state, ctx.newString((args.length > 1) ? args[1] : ""));
|
state.class.getField("I.arg1.Ljava/lang/String;").set(state, ctx.newString((args.length > 1) ? args[1] : ""));
|
||||||
state.class.getField("I.arg2.Ljava/lang/String;").set(state, ctx.newString((args.length > 2) ? args[2] : ""));
|
state.class.getField("I.arg2.Ljava/lang/String;").set(state, ctx.newString((args.length > 2) ? args[2] : ""));
|
||||||
}
|
});
|
||||||
|
|
||||||
MIDP.domainTBL = [
|
MIDP.domainTBL = [
|
||||||
"manufacturer",
|
"manufacturer",
|
||||||
|
@ -244,13 +243,13 @@ MIDP.domainTBL = [
|
||||||
"maximum,unsecured",
|
"maximum,unsecured",
|
||||||
];
|
];
|
||||||
|
|
||||||
Native["com/sun/midp/security/Permissions.loadDomainList.()[Ljava/lang/String;"] = function(ctx, stack) {
|
Native.create("com/sun/midp/security/Permissions.loadDomainList.()[Ljava/lang/String;", function(ctx) {
|
||||||
var list = ctx.newArray("[Ljava/lang/String;", MIDP.domainTBL.length);
|
var list = ctx.newArray("[Ljava/lang/String;", MIDP.domainTBL.length);
|
||||||
MIDP.domainTBL.forEach(function (e, n) {
|
MIDP.domainTBL.forEach(function (e, n) {
|
||||||
list[n] = ctx.newString(e);
|
list[n] = ctx.newString(e);
|
||||||
});
|
});
|
||||||
stack.push(list);
|
return list;
|
||||||
}
|
});
|
||||||
|
|
||||||
MIDP.NEVER = 0;
|
MIDP.NEVER = 0;
|
||||||
MIDP.ALLOW = 1;
|
MIDP.ALLOW = 1;
|
||||||
|
@ -296,63 +295,61 @@ MIDP.unidentifiedTBL = {
|
||||||
satsa: { max: MIDP.NEVER, default: MIDP.NEVER},
|
satsa: { max: MIDP.NEVER, default: MIDP.NEVER},
|
||||||
};
|
};
|
||||||
|
|
||||||
Native["com/sun/midp/security/Permissions.getDefaultValue.(Ljava/lang/String;Ljava/lang/String;)B"] = function(ctx, stack) {
|
Native.create("com/sun/midp/security/Permissions.getDefaultValue.(Ljava/lang/String;Ljava/lang/String;)B", function(ctx, domain, group) {
|
||||||
var group = util.fromJavaString(stack.pop()), domain = util.fromJavaString(stack.pop());
|
|
||||||
var allow = MIDP.NEVER;
|
var allow = MIDP.NEVER;
|
||||||
switch (domain) {
|
switch (util.fromJavaString(domain)) {
|
||||||
case "manufacturer":
|
case "manufacturer":
|
||||||
case "maximum":
|
case "maximum":
|
||||||
case "operator":
|
case "operator":
|
||||||
allow = MIDP.ALLOW;
|
allow = MIDP.ALLOW;
|
||||||
break;
|
break;
|
||||||
case "identified_third_party":
|
case "identified_third_party":
|
||||||
allow = MIDP.identifiedTBL[group].default;
|
allow = MIDP.identifiedTBL[util.fromJavaString(group)].default;
|
||||||
break;
|
break;
|
||||||
case "unidentified_third_party":
|
case "unidentified_third_party":
|
||||||
allow = MIDP.unidentifiedTBL[group].default;
|
allow = MIDP.unidentifiedTBL[util.fromJavaString(group)].default;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stack.push(allow);
|
return allow;
|
||||||
}
|
});
|
||||||
|
|
||||||
Native["com/sun/midp/security/Permissions.getMaxValue.(Ljava/lang/String;Ljava/lang/String;)B"] = function(ctx, stack) {
|
Native.create("com/sun/midp/security/Permissions.getMaxValue.(Ljava/lang/String;Ljava/lang/String;)B", function(ctx, domain, group) {
|
||||||
var group = util.fromJavaString(stack.pop()), domain = util.fromJavaString(stack.pop());
|
|
||||||
var allow = MIDP.NEVER;
|
var allow = MIDP.NEVER;
|
||||||
switch (domain) {
|
switch (util.fromJavaString(domain)) {
|
||||||
case "manufacturer":
|
case "manufacturer":
|
||||||
case "maximum":
|
case "maximum":
|
||||||
case "operator":
|
case "operator":
|
||||||
allow = MIDP.ALLOW;
|
allow = MIDP.ALLOW;
|
||||||
break;
|
break;
|
||||||
case "identified_third_party":
|
case "identified_third_party":
|
||||||
allow = MIDP.identifiedTBL[group].max;
|
allow = MIDP.identifiedTBL[util.fromJavaString(group)].max;
|
||||||
break;
|
break;
|
||||||
case "unidentified_third_party":
|
case "unidentified_third_party":
|
||||||
allow = MIDP.unidentifiedTBL[group].max;
|
allow = MIDP.unidentifiedTBL[util.fromJavaString(group)].max;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stack.push(allow);
|
return allow;
|
||||||
}
|
});
|
||||||
|
|
||||||
Native["com/sun/midp/security/Permissions.loadingFinished.()V"] = function(ctx, stack) {
|
Native.create("com/sun/midp/security/Permissions.loadingFinished.()V", function(ctx) {
|
||||||
console.warn("Permissions.loadingFinished.()V not implemented");
|
console.warn("Permissions.loadingFinished.()V not implemented");
|
||||||
}
|
});
|
||||||
|
|
||||||
Native["com/sun/midp/main/MIDletSuiteUtils.getIsolateId.()I"] = function(ctx, stack) {
|
Native.create("com/sun/midp/main/MIDletSuiteUtils.getIsolateId.()I", function(ctx) {
|
||||||
stack.push(ctx.runtime.isolate.id);
|
return ctx.runtime.isolate.id;
|
||||||
}
|
});
|
||||||
|
|
||||||
Native["com/sun/midp/main/MIDletSuiteUtils.registerAmsIsolateId.()V"] = function(ctx, stack) {
|
Native.create("com/sun/midp/main/MIDletSuiteUtils.registerAmsIsolateId.()V", function(ctx) {
|
||||||
MIDP.AMSIsolateId = ctx.runtime.isolate.id;
|
MIDP.AMSIsolateId = ctx.runtime.isolate.id;
|
||||||
}
|
});
|
||||||
|
|
||||||
Native["com/sun/midp/main/MIDletSuiteUtils.getAmsIsolateId.()I"] = function(ctx, stack) {
|
Native.create("com/sun/midp/main/MIDletSuiteUtils.getAmsIsolateId.()I", function(ctx) {
|
||||||
stack.push(MIDP.AMSIsolateId);
|
return MIDP.AMSIsolateId;
|
||||||
}
|
});
|
||||||
|
|
||||||
Native["com/sun/midp/main/MIDletSuiteUtils.isAmsIsolate.()Z"] = function(ctx, stack) {
|
Native.create("com/sun/midp/main/MIDletSuiteUtils.isAmsIsolate.()Z", function(ctx) {
|
||||||
stack.push((MIDP.AMSIsolateId == ctx.runtime.isolate.id) ? 1 : 0);
|
return MIDP.AMSIsolateId == ctx.runtime.isolate.id;
|
||||||
}
|
});
|
||||||
|
|
||||||
Native["com/sun/midp/main/MIDletSuiteUtils.vmBeginStartUp.(I)V"] = function(ctx, stack) {
|
Native["com/sun/midp/main/MIDletSuiteUtils.vmBeginStartUp.(I)V"] = function(ctx, stack) {
|
||||||
var midletIsolateId = stack.pop();
|
var midletIsolateId = stack.pop();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче