Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-10-12 22:49:41 +0400
committerRyan Dahl <ry@tinyclouds.org>2010-10-12 22:49:41 +0400
commitc4636a578cee61a8a3b570146e168f7dffec9998 (patch)
tree1c9cd0f96ebb748e9cdbb8ea50ab7a11cba2faa9 /tools
parent901d5fd0d2475f8f912f9a73d14805d6898c8e02 (diff)
Dynamically load native scripts
Diffstat (limited to 'tools')
-rwxr-xr-xtools/js2c.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/tools/js2c.py b/tools/js2c.py
index 64e5c2b625e..db4885553bb 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -211,13 +211,30 @@ namespace node {
%(source_lines)s\
+struct _native {
+ const char* name;
+ const char* source;
+};
+
+static const struct _native natives[] = {
+
+%(native_lines)s\
+
+ { NULL, NULL } /* sentinel */
+
+};
+
}
#endif
"""
+NATIVE_DECLARATION = """\
+ { "%(id)s", %(id)s_native },
+"""
+
SOURCE_DECLARATION = """\
- static const char native_%(id)s[] = { %(data)s };
+ const char %(id)s_native[] = { %(data)s };
"""
@@ -252,6 +269,9 @@ def JS2C(source, target):
# Build source code lines
source_lines = [ ]
source_lines_empty = []
+
+ native_lines = []
+
for s in modules:
delay = str(s).endswith('-delay.js')
lines = ReadFile(str(s))
@@ -269,6 +289,7 @@ def JS2C(source, target):
ids.append((id, len(lines)))
source_lines.append(SOURCE_DECLARATION % { 'id': id, 'data': data })
source_lines_empty.append(SOURCE_DECLARATION % { 'id': id, 'data': 0 })
+ native_lines.append(NATIVE_DECLARATION % { 'id': id })
# Build delay support functions
get_index_cases = [ ]
@@ -312,6 +333,7 @@ def JS2C(source, target):
'builtin_count': len(ids) + len(delay_ids),
'delay_count': len(delay_ids),
'source_lines': "\n".join(source_lines),
+ 'native_lines': "\n".join(native_lines),
'get_index_cases': "".join(get_index_cases),
'get_script_source_cases': "".join(get_script_source_cases),
'get_script_name_cases': "".join(get_script_name_cases)