Use camelCase not under_score, I forgot it's coffee script.
This commit is contained in:
parent
99f6a5678a
commit
948e50285d
9 changed files with 38 additions and 38 deletions
|
@ -1,5 +1,5 @@
|
||||||
EventEmitter = require('events').EventEmitter
|
EventEmitter = require('events').EventEmitter
|
||||||
send = process.atom_binding('ipc').send
|
send = process.atomBinding('ipc').send
|
||||||
|
|
||||||
class Ipc extends EventEmitter
|
class Ipc extends EventEmitter
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
@ -8,8 +8,8 @@ class Ipc extends EventEmitter
|
||||||
process.on 'ATOM_INTERNAL_MESSAGE_SYNC', (args...) =>
|
process.on 'ATOM_INTERNAL_MESSAGE_SYNC', (args...) =>
|
||||||
@emit(args...)
|
@emit(args...)
|
||||||
|
|
||||||
send: (process_id, routing_id, args...) ->
|
send: (processId, routingId, args...) ->
|
||||||
@sendChannel(process_id, routing_id, 'message', args...)
|
@sendChannel(processId, routingId, 'message', args...)
|
||||||
|
|
||||||
sendChannel: (args...) ->
|
sendChannel: (args...) ->
|
||||||
send('ATOM_INTERNAL_MESSAGE', args...)
|
send('ATOM_INTERNAL_MESSAGE', args...)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
EventEmitter = require('events').EventEmitter
|
EventEmitter = require('events').EventEmitter
|
||||||
|
|
||||||
Window = process.atom_binding('window').Window
|
Window = process.atomBinding('window').Window
|
||||||
Window.prototype.__proto__ = EventEmitter.prototype
|
Window.prototype.__proto__ = EventEmitter.prototype
|
||||||
|
|
||||||
module.exports = Window
|
module.exports = Window
|
||||||
|
|
|
@ -2,7 +2,7 @@ fs = require 'fs'
|
||||||
path = require 'path'
|
path = require 'path'
|
||||||
|
|
||||||
# Enable idle gc.
|
# Enable idle gc.
|
||||||
process.atom_binding('idle_gc').start()
|
process.atomBinding('idle_gc').start()
|
||||||
|
|
||||||
# Provide default Content API implementations.
|
# Provide default Content API implementations.
|
||||||
atom = {}
|
atom = {}
|
||||||
|
|
|
@ -26,8 +26,8 @@ class ObjectsStore
|
||||||
throw new Error("Invalid key #{id} for ObjectsStore") unless @has id
|
throw new Error("Invalid key #{id} for ObjectsStore") unless @has id
|
||||||
@objects[id]
|
@objects[id]
|
||||||
|
|
||||||
@forRenderView: (process_id, routing_id) ->
|
@forRenderView: (processId, routingId) ->
|
||||||
key = "#{process_id}_#{routing_id}"
|
key = "#{processId}_#{routingId}"
|
||||||
@stores[key] = new ObjectsStore unless @stores[key]?
|
@stores[key] = new ObjectsStore unless @stores[key]?
|
||||||
@stores[key]
|
@stores[key]
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ process.on 'ATOM_BROWSER_INTERNAL_NEW', (obj) ->
|
||||||
# Also remember all windows.
|
# Also remember all windows.
|
||||||
windowsWeakMap.add obj if obj.constructor.name is 'Window'
|
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
|
# Some native objects may already been added to objectsWeakMap, be care not
|
||||||
# to add it twice.
|
# to add it twice.
|
||||||
objectsWeakMap.add obj unless obj.id?
|
objectsWeakMap.add obj unless obj.id?
|
||||||
|
@ -60,7 +60,7 @@ exports.add = (process_id, routing_id, obj) ->
|
||||||
# Store and reference the object, then return the storeId which points to
|
# Store and reference the object, then return the storeId which points to
|
||||||
# where the object is stored. The caller can later dereference the object
|
# where the object is stored. The caller can later dereference the object
|
||||||
# with the storeId.
|
# with the storeId.
|
||||||
store = ObjectsStore.forRenderView process_id, routing_id
|
store = ObjectsStore.forRenderView processId, routingId
|
||||||
store.add obj
|
store.add obj
|
||||||
|
|
||||||
exports.get = (id) ->
|
exports.get = (id) ->
|
||||||
|
@ -70,5 +70,5 @@ exports.getAllWindows = () ->
|
||||||
keys = windowsWeakMap.keys()
|
keys = windowsWeakMap.keys()
|
||||||
windowsWeakMap.get key for key in keys
|
windowsWeakMap.get key for key in keys
|
||||||
|
|
||||||
exports.remove = (process_id, routing_id, storeId) ->
|
exports.remove = (processId, routingId, storeId) ->
|
||||||
ObjectsStore.forRenderView(process_id, routing_id).remove storeId
|
ObjectsStore.forRenderView(processId, routingId).remove storeId
|
||||||
|
|
|
@ -5,21 +5,21 @@ objectsRegistry = require './objects_registry.js'
|
||||||
# Convert a real value into a POD structure which carries information of this
|
# Convert a real value into a POD structure which carries information of this
|
||||||
# value.
|
# value.
|
||||||
class Meta
|
class Meta
|
||||||
constructor: (process_id, routing_id, value) ->
|
constructor: (processId, routingId, value) ->
|
||||||
@type = typeof value
|
@type = typeof value
|
||||||
@type = 'value' if value is null
|
@type = 'value' if value is null
|
||||||
@type = 'array' if Array.isArray value
|
@type = 'array' if Array.isArray value
|
||||||
|
|
||||||
if @type is 'array'
|
if @type is 'array'
|
||||||
@members = []
|
@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'
|
else if @type is 'object' or @type is 'function'
|
||||||
@name = value.constructor.name
|
@name = value.constructor.name
|
||||||
|
|
||||||
# Reference the original value if it's an object, because when it's
|
# 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
|
# passed to renderer we would assume the renderer keeps a reference of
|
||||||
# it.
|
# it.
|
||||||
@storeId = objectsRegistry.add process_id, routing_id, value
|
@storeId = objectsRegistry.add processId, routingId, value
|
||||||
@id = value.id
|
@id = value.id
|
||||||
|
|
||||||
@members = []
|
@members = []
|
||||||
|
@ -28,68 +28,68 @@ class Meta
|
||||||
@type = 'value'
|
@type = 'value'
|
||||||
@value = value
|
@value = value
|
||||||
|
|
||||||
ipc.on 'ATOM_INTERNAL_REQUIRE', (event, process_id, routing_id, module) ->
|
ipc.on 'ATOM_INTERNAL_REQUIRE', (event, processId, routingId, module) ->
|
||||||
try
|
try
|
||||||
event.result = new Meta(process_id, routing_id, require(module))
|
event.result = new Meta(processId, routingId, require(module))
|
||||||
catch e
|
catch e
|
||||||
event.result = type: 'error', value: e.message
|
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
|
try
|
||||||
windows = objectsRegistry.getAllWindows()
|
windows = objectsRegistry.getAllWindows()
|
||||||
for window in windows
|
for window in windows
|
||||||
break if window.getProcessID() == process_id and
|
break if window.getProcessID() == processId and
|
||||||
window.getRoutingID() == routing_id
|
window.getRoutingID() == routingId
|
||||||
event.result = new Meta(process_id, routing_id, window)
|
event.result = new Meta(processId, routingId, window)
|
||||||
catch e
|
catch e
|
||||||
event.result = type: 'error', value: e.message
|
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
|
try
|
||||||
constructor = objectsRegistry.get id
|
constructor = objectsRegistry.get id
|
||||||
# Call new with array of arguments.
|
# Call new with array of arguments.
|
||||||
# http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
|
# http://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible
|
||||||
obj = new (Function::bind.apply(constructor, [null].concat(args)))
|
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
|
catch e
|
||||||
event.result = type: 'error', value: e.message
|
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
|
try
|
||||||
func = objectsRegistry.get id
|
func = objectsRegistry.get id
|
||||||
ret = func.apply global, args
|
ret = func.apply global, args
|
||||||
event.result = new Meta(process_id, routing_id, ret)
|
event.result = new Meta(processId, routingId, ret)
|
||||||
catch e
|
catch e
|
||||||
event.result = type: 'error', value: e.message
|
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
|
try
|
||||||
obj = objectsRegistry.get id
|
obj = objectsRegistry.get id
|
||||||
ret = obj[method].apply(obj, args)
|
ret = obj[method].apply(obj, args)
|
||||||
event.result = new Meta(process_id, routing_id, ret)
|
event.result = new Meta(processId, routingId, ret)
|
||||||
catch e
|
catch e
|
||||||
event.result = type: 'error', value: e.message
|
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
|
try
|
||||||
obj = objectsRegistry.get id
|
obj = objectsRegistry.get id
|
||||||
obj[name] = value
|
obj[name] = value
|
||||||
catch e
|
catch e
|
||||||
event.result = type: 'error', value: e.message
|
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
|
try
|
||||||
obj = objectsRegistry.get id
|
obj = objectsRegistry.get id
|
||||||
event.result = new Meta(process_id, routing_id, obj[name])
|
event.result = new Meta(processId, routingId, obj[name])
|
||||||
catch e
|
catch e
|
||||||
event.result = type: 'error', value: e.message
|
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
|
try
|
||||||
obj = objectsRegistry.get id
|
obj = objectsRegistry.get id
|
||||||
event.result = new Meta(process_id, routing_id, obj)
|
event.result = new Meta(processId, routingId, obj)
|
||||||
catch e
|
catch e
|
||||||
event.result = type: 'error', value: e.message
|
event.result = type: 'error', value: e.message
|
||||||
|
|
||||||
ipc.on 'ATOM_INTERNAL_DEREFERENCE', (process_id, routing_id, storeId) ->
|
ipc.on 'ATOM_INTERNAL_DEREFERENCE', (processId, routingId, storeId) ->
|
||||||
objectsRegistry.remove process_id, routing_id, storeId
|
objectsRegistry.remove processId, routingId, storeId
|
||||||
|
|
|
@ -21,7 +21,7 @@ AtomBindings::~AtomBindings() {
|
||||||
void AtomBindings::BindTo(v8::Handle<v8::Object> process) {
|
void AtomBindings::BindTo(v8::Handle<v8::Object> process) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
|
|
||||||
node::SetMethod(process, "atom_binding", Binding);
|
node::SetMethod(process, "atomBinding", Binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -42,7 +42,7 @@ v8::Handle<v8::Value> AtomBindings::Binding(const v8::Arguments& args) {
|
||||||
|
|
||||||
// Cached in process.__atom_binding_cache.
|
// Cached in process.__atom_binding_cache.
|
||||||
v8::Local<v8::Object> binding_cache;
|
v8::Local<v8::Object> binding_cache;
|
||||||
v8::Local<v8::String> bc_name = v8::String::New("__atom_binding_cache");
|
v8::Local<v8::String> bc_name = v8::String::New("__atomBindingCache");
|
||||||
if (process->Has(bc_name)) {
|
if (process->Has(bc_name)) {
|
||||||
binding_cache = process->Get(bc_name)->ToObject();
|
binding_cache = process->Get(bc_name)->ToObject();
|
||||||
DCHECK(!binding_cache.IsEmpty());
|
DCHECK(!binding_cache.IsEmpty());
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
IDWeakMap = process.atom_binding('id_weak_map').IDWeakMap
|
IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap
|
||||||
|
|
||||||
module.exports = IDWeakMap
|
module.exports = IDWeakMap
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
EventEmitter = require('events').EventEmitter
|
EventEmitter = require('events').EventEmitter
|
||||||
ipc = process.atom_binding('ipc')
|
ipc = process.atomBinding('ipc')
|
||||||
|
|
||||||
class Ipc extends EventEmitter
|
class Ipc extends EventEmitter
|
||||||
constructor: ->
|
constructor: ->
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
ipc = require 'ipc'
|
ipc = require 'ipc'
|
||||||
v8_util = process.atom_binding 'v8_util'
|
v8_util = process.atomBinding 'v8_util'
|
||||||
|
|
||||||
# Transform the description of value into a value or delegate object.
|
# Transform the description of value into a value or delegate object.
|
||||||
metaToValue = (meta) ->
|
metaToValue = (meta) ->
|
||||||
|
|
Loading…
Reference in a new issue