manual syntax fixes on rpc server
This commit is contained in:
Родитель
4d4f479721
Коммит
ee181294b3
|
@ -43,7 +43,6 @@ let getObjectMembers = function (object) {
|
|||
let getObjectPrototype = function (object) {
|
||||
let proto = Object.getPrototypeOf(object)
|
||||
if (proto === null || proto === Object.prototype) return null
|
||||
|
||||
return {
|
||||
members: getObjectMembers(proto),
|
||||
proto: getObjectPrototype(proto)
|
||||
|
@ -162,8 +161,7 @@ var unwrapArgs = function (sender, args) {
|
|||
return Promise.resolve({
|
||||
then: metaToValue(meta.then)
|
||||
})
|
||||
case 'object':
|
||||
{
|
||||
case 'object': {
|
||||
let ret = {}
|
||||
Object.defineProperty(ret.constructor, 'name', { value: meta.name })
|
||||
|
||||
|
@ -173,14 +171,13 @@ var unwrapArgs = function (sender, args) {
|
|||
ret[member.name] = metaToValue(member.value)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
||||
case 'function-with-return-value':
|
||||
returnValue = metaToValue(meta.value)
|
||||
return function () {
|
||||
return returnValue
|
||||
}
|
||||
case 'function':
|
||||
{
|
||||
case 'function': {
|
||||
// Cache the callbacks in renderer.
|
||||
let webContentsId = sender.getId()
|
||||
let callbacks = rendererFunctions[webContentsId]
|
||||
|
@ -208,7 +205,7 @@ var unwrapArgs = function (sender, args) {
|
|||
})
|
||||
callbacks.set(meta.id, callIntoRenderer)
|
||||
return callIntoRenderer
|
||||
}
|
||||
}
|
||||
default:
|
||||
throw new TypeError(`Unknown type: ${meta.type}`)
|
||||
}
|
||||
|
@ -226,13 +223,11 @@ var callFunction = function (event, func, caller, args) {
|
|||
if (funcMarkedAsync && !funcPassedCallback) {
|
||||
args.push(function (ret) {
|
||||
event.returnValue = valueToMeta(event.sender, ret, true)
|
||||
return event.returnValue
|
||||
})
|
||||
return func.apply(caller, args)
|
||||
} else {
|
||||
ret = func.apply(caller, args)
|
||||
event.returnValue = valueToMeta(event.sender, ret, true)
|
||||
return event.returnValue
|
||||
}
|
||||
} catch (error) {
|
||||
// Catch functions thrown further down in function invocation and wrap
|
||||
|
@ -246,10 +241,8 @@ var callFunction = function (event, func, caller, args) {
|
|||
ipcMain.on('ATOM_BROWSER_REQUIRE', function (event, module) {
|
||||
try {
|
||||
event.returnValue = valueToMeta(event.sender, process.mainModule.require(module))
|
||||
event.returnValue
|
||||
} catch (error) {
|
||||
event.returnValue = exceptionToMeta(error)
|
||||
event.returnValue
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -288,7 +281,7 @@ ipcMain.on('ATOM_BROWSER_CONSTRUCTOR', function (event, id, args) {
|
|||
|
||||
// Call new with array of arguments.
|
||||
// http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
|
||||
let obj = new Function.prototype.bind.apply(constructor, [null].concat(args))
|
||||
let obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)))
|
||||
event.returnValue = valueToMeta(event.sender, obj)
|
||||
} catch (error) {
|
||||
event.returnValue = exceptionToMeta(error)
|
||||
|
@ -311,7 +304,7 @@ ipcMain.on('ATOM_BROWSER_MEMBER_CONSTRUCTOR', function (event, id, method, args)
|
|||
let constructor = objectsRegistry.get(id)[method]
|
||||
|
||||
// Call new with array of arguments.
|
||||
let obj = new Function.prototype.bind.apply(constructor, [null].concat(args))
|
||||
let obj = new (Function.prototype.bind.apply(constructor, [null].concat(args)))
|
||||
event.returnValue = valueToMeta(event.sender, obj)
|
||||
} catch (error) {
|
||||
event.returnValue = exceptionToMeta(error)
|
||||
|
|
Загрузка…
Ссылка в новой задаче