Internal built-in module code should be wrapped under api namespace.
This commit is contained in:
parent
ef2056c3f5
commit
488d72e41b
6 changed files with 21 additions and 15 deletions
8
atom.gyp
8
atom.gyp
|
@ -12,12 +12,12 @@
|
|||
'lib_sources': [
|
||||
'app/atom_main_delegate.cc',
|
||||
'app/atom_main_delegate.h',
|
||||
'browser/api/atom_api_extensions.cc',
|
||||
'browser/api/atom_api_extensions.h',
|
||||
'browser/api/atom_api_window.cc',
|
||||
'browser/api/atom_api_window.h',
|
||||
'browser/api/atom_bindings.cc',
|
||||
'browser/api/atom_bindings.h',
|
||||
'browser/api/atom_extensions.cc',
|
||||
'browser/api/atom_extensions.h',
|
||||
'browser/api/atom_window.cc',
|
||||
'browser/api/atom_window.h',
|
||||
'browser/atom_browser_client.cc',
|
||||
'browser/atom_browser_client.h',
|
||||
'browser/atom_browser_main_parts.cc',
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
#undef NODE_EXT_LIST_START
|
||||
#undef NODE_EXT_LIST_ITEM
|
||||
#undef NODE_EXT_LIST_END
|
||||
|
@ -18,7 +20,7 @@ namespace atom {
|
|||
#define NODE_EXT_LIST_ITEM NODE_MODULE_DECL
|
||||
#define NODE_EXT_LIST_END
|
||||
|
||||
#include "browser/api/atom_extensions.h"
|
||||
#include "browser/api/atom_api_extensions.h"
|
||||
|
||||
#undef NODE_EXT_LIST_START
|
||||
#undef NODE_EXT_LIST_ITEM
|
||||
|
@ -29,12 +31,12 @@ namespace atom {
|
|||
#define NODE_EXT_LIST_ITEM NODE_EXT_STRING
|
||||
#define NODE_EXT_LIST_END NULL};
|
||||
|
||||
#include "browser/api/atom_extensions.h" // NOLINT
|
||||
#include "browser/api/atom_api_extensions.h" // NOLINT
|
||||
|
||||
node::node_module_struct* get_builtin_module(const char *name) {
|
||||
char buf[128];
|
||||
node::node_module_struct *cur = NULL;
|
||||
snprintf(buf, sizeof(buf), "atom_%s", name);
|
||||
snprintf(buf, sizeof(buf), "atom_api_%s", name);
|
||||
/* TODO: you could look these up in a hash, but there are only
|
||||
* a few, and once loaded they are cached. */
|
||||
for (int i = 0; node_module_list[i] != NULL; i++) {
|
||||
|
@ -47,4 +49,6 @@ node::node_module_struct* get_builtin_module(const char *name) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
|
@ -6,6 +6,6 @@
|
|||
|
||||
NODE_EXT_LIST_START
|
||||
|
||||
NODE_EXT_LIST_ITEM(atom_window)
|
||||
NODE_EXT_LIST_ITEM(atom_api_window)
|
||||
|
||||
NODE_EXT_LIST_END
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "browser/api/atom_window.h"
|
||||
#include "browser/api/atom_api_window.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -12,4 +12,4 @@ static void Initialize(v8::Handle<v8::Object> target) {
|
|||
|
||||
} // namespace atom
|
||||
|
||||
NODE_MODULE(atom_window, atom::Initialize)
|
||||
NODE_MODULE(atom_api_window, atom::Initialize)
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_API_ATOM_WINDOW_H_
|
||||
#define ATOM_BROWSER_API_ATOM_WINDOW_H_
|
||||
#ifndef ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|
||||
#define ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|
||||
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_object_wrap.h"
|
||||
|
@ -12,4 +12,4 @@ namespace atom {
|
|||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_API_ATOM_WINDOW_H_
|
||||
#endif // ATOM_BROWSER_API_ATOM_API_WINDOW_H_
|
|
@ -11,8 +11,10 @@ using node::node_isolate;
|
|||
|
||||
namespace atom {
|
||||
|
||||
// Defined in atom_extensions.cc.
|
||||
// Defined in atom_api_extensions.cc.
|
||||
namespace api {
|
||||
node::node_module_struct* get_builtin_module(const char *name);
|
||||
}
|
||||
|
||||
v8::Persistent<v8::Object> AtomBindings::binding_cache_;
|
||||
|
||||
|
@ -49,7 +51,7 @@ v8::Handle<v8::Value> AtomBindings::Binding(const v8::Arguments& args) {
|
|||
return scope.Close(exports);
|
||||
}
|
||||
|
||||
if ((modp = get_builtin_module(*module_v)) != NULL) {
|
||||
if ((modp = api::get_builtin_module(*module_v)) != NULL) {
|
||||
exports = v8::Object::New();
|
||||
// Internal bindings don't have a "module" object,
|
||||
// only exports.
|
||||
|
|
Loading…
Add table
Reference in a new issue