@stores = {}
constructor: ->
- @nextId = 1
+ @nextId = 0
@objects = []
getNextId: ->
windowsWeakMap = new IDWeakMap
process.on 'ATOM_BROWSER_INTERNAL_NEW', (obj) ->
- # It's possible that user created a object in browser side and then want to
- # get it in renderer via remote.getObject. So we must add every native object
- # created in browser to the weak map even it may not be referenced by the
- # renderer.
- objectsWeakMap.add obj
-
- # Also remember all windows.
+ # Remember all windows.
if obj.constructor is BrowserWindow
id = windowsWeakMap.add obj
obj.on 'destroyed', ->
catch e
event.result = errorToMeta e
-ipc.on 'ATOM_BROWSER_REFERENCE', (event, processId, routingId, id) ->
- try
- obj = objectsRegistry.get id
- event.result = valueToMeta processId, routingId, obj
- catch e
- event.result = errorToMeta e
-
ipc.on 'ATOM_BROWSER_DEREFERENCE', (processId, routingId, storeId) ->
objectsRegistry.remove processId, routingId, storeId
meta = ipc.sendChannelSync 'ATOM_BROWSER_REQUIRE', module
moduleCache[module] = metaToValue meta
-# Get object with specified id.
-exports.getObject = (id) ->
- meta = ipc.sendChannelSync 'ATOM_BROWSER_REFERENCE', id
- metaToValue meta
-
# Get current window object.
windowCache = null
exports.getCurrentWindow = ->