The unwrapArgs relies on the valueToMeta function.
This commit is contained in:
parent
e7547363e2
commit
35441ad8fb
1 changed files with 14 additions and 14 deletions
|
@ -3,20 +3,6 @@ path = require 'path'
|
|||
objectsRegistry = require './objects_registry.js'
|
||||
v8_util = process.atomBinding 'v8_util'
|
||||
|
||||
# Convert array of meta data from renderer into array of real values.
|
||||
unwrapArgs = (processId, routingId, args) ->
|
||||
args.map (meta) ->
|
||||
switch meta.type
|
||||
when 'value' then meta.value
|
||||
when 'object' then objectsRegistry.get meta.id
|
||||
when 'function'
|
||||
ret = ->
|
||||
ipc.sendChannel processId, routingId, 'ATOM_RENDERER_CALLBACK', meta.id, valueToMeta(processId, routingId, arguments)
|
||||
v8_util.setDestructor ret, ->
|
||||
ipc.sendChannel processId, routingId, 'ATOM_RENDERER_RELEASE_CALLBACK', meta.id
|
||||
ret
|
||||
else throw new TypeError("Unknown type: #{meta.type}")
|
||||
|
||||
# Convert a real value into meta data.
|
||||
valueToMeta = (processId, routingId, value) ->
|
||||
meta = type: typeof value
|
||||
|
@ -47,6 +33,20 @@ valueToMeta = (processId, routingId, value) ->
|
|||
|
||||
meta
|
||||
|
||||
# Convert array of meta data from renderer into array of real values.
|
||||
unwrapArgs = (processId, routingId, args) ->
|
||||
args.map (meta) ->
|
||||
switch meta.type
|
||||
when 'value' then meta.value
|
||||
when 'object' then objectsRegistry.get meta.id
|
||||
when 'function'
|
||||
ret = ->
|
||||
ipc.sendChannel processId, routingId, 'ATOM_RENDERER_CALLBACK', meta.id, valueToMeta(processId, routingId, arguments)
|
||||
v8_util.setDestructor ret, ->
|
||||
ipc.sendChannel processId, routingId, 'ATOM_RENDERER_RELEASE_CALLBACK', meta.id
|
||||
ret
|
||||
else throw new TypeError("Unknown type: #{meta.type}")
|
||||
|
||||
ipc.on 'ATOM_BROWSER_REQUIRE', (event, processId, routingId, module) ->
|
||||
try
|
||||
event.result = valueToMeta processId, routingId, require(module)
|
||||
|
|
Loading…
Reference in a new issue