Pass args array instead of arguments object
This commit is contained in:
parent
c27633dff4
commit
f894da13b0
1 changed files with 7 additions and 7 deletions
|
@ -88,7 +88,7 @@ const wrapArgs = function (args, visited) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return Array.prototype.slice.call(args).map(valueToMeta)
|
||||
return args.map(valueToMeta)
|
||||
}
|
||||
|
||||
// Populate object's members from descriptors.
|
||||
|
@ -102,14 +102,14 @@ const setObjectMembers = function (ref, object, metaId, members) {
|
|||
|
||||
let descriptor = { enumerable: member.enumerable }
|
||||
if (member.type === 'method') {
|
||||
const remoteMemberFunction = function () {
|
||||
const remoteMemberFunction = function (...args) {
|
||||
if (this && this.constructor === remoteMemberFunction) {
|
||||
// Constructor call.
|
||||
let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CONSTRUCTOR', metaId, member.name, wrapArgs(arguments))
|
||||
let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CONSTRUCTOR', metaId, member.name, wrapArgs(args))
|
||||
return metaToValue(ret)
|
||||
} else {
|
||||
// Call member function.
|
||||
let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CALL', metaId, member.name, wrapArgs(arguments))
|
||||
let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CALL', metaId, member.name, wrapArgs(args))
|
||||
return metaToValue(ret)
|
||||
}
|
||||
}
|
||||
|
@ -220,17 +220,17 @@ const metaToValue = function (meta) {
|
|||
|
||||
if (meta.type === 'function') {
|
||||
// A shadow class to represent the remote function object.
|
||||
let remoteFunction = function () {
|
||||
let remoteFunction = function (...args) {
|
||||
if (this && this.constructor === remoteFunction) {
|
||||
// Constructor call.
|
||||
let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_CONSTRUCTOR', meta.id, wrapArgs(arguments))
|
||||
let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_CONSTRUCTOR', meta.id, wrapArgs(args))
|
||||
// Returning object in constructor will replace constructed object
|
||||
// with the returned object.
|
||||
// http://stackoverflow.com/questions/1978049/what-values-can-a-constructor-return-to-avoid-returning-this
|
||||
return metaToValue(obj)
|
||||
} else {
|
||||
// Function call.
|
||||
let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_FUNCTION_CALL', meta.id, wrapArgs(arguments))
|
||||
let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_FUNCTION_CALL', meta.id, wrapArgs(args))
|
||||
return metaToValue(obj)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue