Add remote.getObject API to get object in browser by it's ID.

This commit is contained in:
Cheng Zhao 2013-04-26 22:25:30 +08:00
parent d4d1230107
commit cc921fed1e
4 changed files with 38 additions and 16 deletions

View file

@ -3,7 +3,7 @@ v8_util = process.atom_binding 'v8_util'
generateFromPainObject = (plain) ->
switch plain.type
when 'error' then throw new Error('Remote Error: ' + plain.value)
when 'error' then throw new Error(plain.value)
when 'value' then plain.value
when 'array' then (generateFromPainObject(el) for el in plain.members)
else
@ -56,3 +56,8 @@ generateFromPainObject = (plain) ->
exports.require = (module) ->
plain = ipc.sendChannelSync 'ATOM_INTERNAL_REQUIRE', module
generateFromPainObject plain
# Get object with specified id.
exports.getObject = (id) ->
plain = ipc.sendChannelSync 'ATOM_INTERNAL_GET_OBJECT', id
generateFromPainObject plain