Transfer Buffer through "remote"

This commit is contained in:
Cheng Zhao 2015-06-09 17:46:33 +08:00
parent 200a19dad9
commit 4b12a95d37
2 changed files with 7 additions and 0 deletions

View file

@ -10,6 +10,8 @@ wrapArgs = (args) ->
valueToMeta = (value) ->
if Array.isArray value
type: 'array', value: wrapArgs(value)
else if Buffer.isBuffer value
type: 'buffer', value: Array::slice.call(value, 0)
else if value? and typeof value is 'object' and v8Util.getHiddenValue value, 'atomId'
type: 'remote-object', id: v8Util.getHiddenValue value, 'atomId'
else if value? and typeof value is 'object'
@ -30,6 +32,7 @@ metaToValue = (meta) ->
switch meta.type
when 'value' then meta.value
when 'array' then (metaToValue(el) for el in meta.members)
when 'buffer' then new Buffer(meta.value)
when 'error'
throw new Error("#{meta.message}\n#{meta.stack}")
else