From 35441ad8fba0d6808ac320a67a21631fbcedaef7 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 4 May 2013 22:59:32 +0800 Subject: [PATCH] The unwrapArgs relies on the valueToMeta function. --- browser/atom/rpc_server.coffee | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/browser/atom/rpc_server.coffee b/browser/atom/rpc_server.coffee index 616425d6e4..9c222b36f5 100644 --- a/browser/atom/rpc_server.coffee +++ b/browser/atom/rpc_server.coffee @@ -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)