Fix the argument passing convention

This commit is contained in:
Namhyeon Go 2024-08-25 15:28:03 +09:00
parent e4a8357715
commit 82ac8e5d02
3 changed files with 12 additions and 5 deletions

View File

@ -334,7 +334,8 @@ namespace WelsonJS.Service
object[] parameters = new object[] {
scriptName,
eventType,
new ArrayList(args)
new ArrayList(args),
args.Length
};
//scriptControl.AddObject("extern_arguments", new ArrayList(args), true);

10
app.js
View File

@ -592,8 +592,14 @@ function initializeWindow(name, args, w, h) {
}
}
function dispatchServiceEvent(name, eventType, w_args) {
function dispatchServiceEvent(name, eventType, w_args, argl) {
var app = require(name);
var args = [];
// convert the arguments to Array
for (var i = 0; i < argl; i++) {
args.push(w_args(i));
}
// load the service
if (app) {
@ -610,7 +616,7 @@ function dispatchServiceEvent(name, eventType, w_args) {
if (eventType in action) {
try {
return (function(f) {
return (typeof f !== "function" ? null : f(w_args));
return (typeof f !== "function" ? null : f(args));
})(action[eventType]);
} catch (e) {
console.error("Exception:", e.message);

View File

@ -21,11 +21,11 @@ function onServiceElapsedTime() {
}
function onMessageReceived() {
return "onMessageReceived recevied. " + args.join(', ');
return "onMessageReceived recevied. " + args.join(', ');
}
function onServiceScreenTime(args) {
return "onServiceScreenTime recevied. " + args(0);
return "onServiceScreenTime recevied. " + args.join(', ');
}
function onFileCreated(args) {