throw new Error("Invalid key #{id} for ObjectsStore") unless @has id
@objects[id]
- @forRenderView: (process_id, routing_id) ->
- key = "#{process_id}_#{routing_id}"
+ @forRenderView: (processId, routingId) ->
+ key = "#{processId}_#{routingId}"
@stores[key] = new ObjectsStore unless @stores[key]?
@stores[key]
# Also remember all windows.
windowsWeakMap.add obj if obj.constructor.name is 'Window'
-exports.add = (process_id, routing_id, obj) ->
+exports.add = (processId, routingId, obj) ->
# Some native objects may already been added to objectsWeakMap, be care not
# to add it twice.
objectsWeakMap.add obj unless obj.id?
# Store and reference the object, then return the storeId which points to
# where the object is stored. The caller can later dereference the object
# with the storeId.
- store = ObjectsStore.forRenderView process_id, routing_id
+ store = ObjectsStore.forRenderView processId, routingId
store.add obj
exports.get = (id) ->
keys = windowsWeakMap.keys()
windowsWeakMap.get key for key in keys
-exports.remove = (process_id, routing_id, storeId) ->
- ObjectsStore.forRenderView(process_id, routing_id).remove storeId
+exports.remove = (processId, routingId, storeId) ->
+ ObjectsStore.forRenderView(processId, routingId).remove storeId
# Convert a real value into a POD structure which carries information of this
# value.
class Meta
- constructor: (process_id, routing_id, value) ->
+ constructor: (processId, routingId, value) ->
@type = typeof value
@type = 'value' if value is null
@type = 'array' if Array.isArray value
if @type is 'array'
@members = []
- @members.push new Meta(process_id, routing_id, el) for el in value
+ @members.push new Meta(processId, routingId, el) for el in value
else if @type is 'object' or @type is 'function'
@name = value.constructor.name
# Reference the original value if it's an object, because when it's
# passed to renderer we would assume the renderer keeps a reference of
# it.
- @storeId = objectsRegistry.add process_id, routing_id, value
+ @storeId = objectsRegistry.add processId, routingId, value
@id = value.id
@members = []
@type = 'value'
@value = value
-ipc.on 'ATOM_INTERNAL_REQUIRE', (event, process_id, routing_id, module) ->
+ipc.on 'ATOM_INTERNAL_REQUIRE', (event, processId, routingId, module) ->
try
- event.result = new Meta(process_id, routing_id, require(module))
+ event.result = new Meta(processId, routingId, require(module))
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_CURRENT_WINDOW', (event, process_id, routing_id) ->
+ipc.on 'ATOM_INTERNAL_CURRENT_WINDOW', (event, processId, routingId) ->
try
windows = objectsRegistry.getAllWindows()
for window in windows
- break if window.getProcessID() == process_id and
- window.getRoutingID() == routing_id
- event.result = new Meta(process_id, routing_id, window)
+ break if window.getProcessID() == processId and
+ window.getRoutingID() == routingId
+ event.result = new Meta(processId, routingId, window)
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_CONSTRUCTOR', (event, process_id, routing_id, id, args) ->
+ipc.on 'ATOM_INTERNAL_CONSTRUCTOR', (event, processId, routingId, id, args) ->
try
constructor = objectsRegistry.get id
# Call new with array of arguments.
# http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
obj = new (Function::bind.apply(constructor, [null].concat(args)))
- event.result = new Meta(process_id, routing_id, obj)
+ event.result = new Meta(processId, routingId, obj)
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_FUNCTION_CALL', (event, process_id, routing_id, id, args) ->
+ipc.on 'ATOM_INTERNAL_FUNCTION_CALL', (event, processId, routingId, id, args) ->
try
func = objectsRegistry.get id
ret = func.apply global, args
- event.result = new Meta(process_id, routing_id, ret)
+ event.result = new Meta(processId, routingId, ret)
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_MEMBER_CALL', (event, process_id, routing_id, id, method, args) ->
+ipc.on 'ATOM_INTERNAL_MEMBER_CALL', (event, processId, routingId, id, method, args) ->
try
obj = objectsRegistry.get id
ret = obj[method].apply(obj, args)
- event.result = new Meta(process_id, routing_id, ret)
+ event.result = new Meta(processId, routingId, ret)
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_MEMBER_SET', (event, process_id, routing_id, id, name, value) ->
+ipc.on 'ATOM_INTERNAL_MEMBER_SET', (event, processId, routingId, id, name, value) ->
try
obj = objectsRegistry.get id
obj[name] = value
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_MEMBER_GET', (event, process_id, routing_id, id, name) ->
+ipc.on 'ATOM_INTERNAL_MEMBER_GET', (event, processId, routingId, id, name) ->
try
obj = objectsRegistry.get id
- event.result = new Meta(process_id, routing_id, obj[name])
+ event.result = new Meta(processId, routingId, obj[name])
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_REFERENCE', (event, process_id, routing_id, id) ->
+ipc.on 'ATOM_INTERNAL_REFERENCE', (event, processId, routingId, id) ->
try
obj = objectsRegistry.get id
- event.result = new Meta(process_id, routing_id, obj)
+ event.result = new Meta(processId, routingId, obj)
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_DEREFERENCE', (process_id, routing_id, storeId) ->
- objectsRegistry.remove process_id, routing_id, storeId
+ipc.on 'ATOM_INTERNAL_DEREFERENCE', (processId, routingId, storeId) ->
+ objectsRegistry.remove processId, routingId, storeId