2013-04-14 07:36:48 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
#include "base/strings/string_util.h"
|
2013-04-14 07:36:48 +00:00
|
|
|
#include "vendor/node/src/node_version.h"
|
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
#include "common/v8/node_common.h"
|
|
|
|
|
2013-04-14 07:36:48 +00:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
#undef NODE_EXT_LIST_START
|
|
|
|
#undef NODE_EXT_LIST_ITEM
|
|
|
|
#undef NODE_EXT_LIST_END
|
|
|
|
|
|
|
|
#define NODE_EXT_LIST_START
|
|
|
|
#define NODE_EXT_LIST_ITEM NODE_MODULE_DECL
|
|
|
|
#define NODE_EXT_LIST_END
|
|
|
|
|
2013-04-21 06:53:26 +00:00
|
|
|
#include "common/api/atom_extensions.h"
|
2013-04-14 07:36:48 +00:00
|
|
|
|
|
|
|
#undef NODE_EXT_LIST_START
|
|
|
|
#undef NODE_EXT_LIST_ITEM
|
|
|
|
#undef NODE_EXT_LIST_END
|
|
|
|
|
|
|
|
#define NODE_EXT_STRING(x) &x ## _module,
|
|
|
|
#define NODE_EXT_LIST_START node::node_module_struct *node_module_list[] = {
|
|
|
|
#define NODE_EXT_LIST_ITEM NODE_EXT_STRING
|
|
|
|
#define NODE_EXT_LIST_END NULL};
|
|
|
|
|
2013-04-21 06:53:26 +00:00
|
|
|
#include "common/api/atom_extensions.h" // NOLINT
|
2013-04-14 07:36:48 +00:00
|
|
|
|
2013-04-21 06:53:26 +00:00
|
|
|
node::node_module_struct* GetBuiltinModule(const char *name, bool is_browser) {
|
2013-04-25 07:36:01 +00:00
|
|
|
char common[128];
|
|
|
|
char spec[128];
|
2013-04-14 07:36:48 +00:00
|
|
|
node::node_module_struct *cur = NULL;
|
2013-07-01 13:47:21 +00:00
|
|
|
base::snprintf(common, sizeof(common), "atom_common_%s", name);
|
|
|
|
base::snprintf(spec, sizeof(spec),
|
|
|
|
(is_browser ? "atom_browser_%s": "atom_renderer_%s"),
|
|
|
|
name);
|
2013-04-14 07:36:48 +00:00
|
|
|
/* 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++) {
|
|
|
|
cur = node_module_list[i];
|
2013-04-25 07:36:01 +00:00
|
|
|
if (strcmp(cur->modname, common) == 0 || strcmp(cur->modname, spec) == 0) {
|
2013-04-14 07:36:48 +00:00
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace atom
|