Skip to content

Commit

Permalink
MAINT: Use standard javascript coding conventions for function calls …
Browse files Browse the repository at this point in the history
…in hiwire
  • Loading branch information
Hood Chatham authored Jan 12, 2021
1 parent 3635b88 commit 96fcf0e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/core/hiwire.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,15 @@ EM_JS_REF(JsRef, hiwire_dir, (JsRef idobj), {
let jsobj = Module.hiwire.get_value(idobj);
let result = [];
do {
result.push.apply(result, Object.getOwnPropertyNames(jsobj));
} while ((jsobj = Object.getPrototypeOf(jsobj)));
result.push(... Object.getOwnPropertyNames(jsobj));
} while (jsobj = Object.getPrototypeOf(jsobj));
return Module.hiwire.new_value(result);
});

EM_JS_REF(JsRef, hiwire_call, (JsRef idfunc, JsRef idargs), {
let jsfunc = Module.hiwire.get_value(idfunc);
let jsargs = Module.hiwire.get_value(idargs);
return Module.hiwire.new_value(jsfunc.apply(jsfunc, jsargs));
return Module.hiwire.new_value(jsfunc(... jsargs));
});

EM_JS_REF(JsRef,
Expand All @@ -341,18 +341,13 @@ EM_JS_REF(JsRef,
let jsobj = Module.hiwire.get_value(idobj);
let jsname = UTF8ToString(ptrname);
let jsargs = Module.hiwire.get_value(idargs);
return Module.hiwire.new_value(jsobj[jsname].apply(jsobj, jsargs));
return Module.hiwire.new_value(jsobj[jsname](... jsargs));
});

EM_JS_REF(JsRef, hiwire_new, (JsRef idobj, JsRef idargs), {
function newCall(Cls)
{
return new (Function.prototype.bind.apply(Cls, arguments));
}
let jsobj = Module.hiwire.get_value(idobj);
let jsargs = Module.hiwire.get_value(idargs);
jsargs.unshift(jsobj);
return Module.hiwire.new_value(newCall.apply(newCall, jsargs));
return Module.hiwire.new_value(Reflect.construct(jsobj, jsargs));
});

EM_JS_NUM(int, hiwire_get_length, (JsRef idobj), {
Expand Down

0 comments on commit 96fcf0e

Please sign in to comment.