Commit 6a7046b3 authored by haraken@chromium.org's avatar haraken@chromium.org

Make variable names about |className| in PrivateScriptRunner more consistent

After this CL:

- |className| means a class name of a dependency interface (e.g., "Document").

- |scriptClassName| means a class name of the script (e.g., "DocumentXSLT").

BUG=341031

Review URL: https://codereview.chromium.org/473783003

git-svn-id: svn://svn.chromium.org/blink/trunk@180261 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2eb01a52
...@@ -43,21 +43,21 @@ static void dumpJSError(String exceptionName, v8::Handle<v8::Message> message) ...@@ -43,21 +43,21 @@ static void dumpJSError(String exceptionName, v8::Handle<v8::Message> message)
#endif #endif
} }
static v8::Handle<v8::Value> compileAndRunPrivateScript(v8::Isolate* isolate, String className, const unsigned char* source, size_t size) static v8::Handle<v8::Value> compileAndRunPrivateScript(v8::Isolate* isolate, String scriptClassName, const unsigned char* source, size_t size)
{ {
v8::TryCatch block; v8::TryCatch block;
String sourceString(reinterpret_cast<const char*>(source), size); String sourceString(reinterpret_cast<const char*>(source), size);
String fileName = className + ".js"; String fileName = scriptClassName + ".js";
v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(v8String(isolate, sourceString), fileName, TextPosition::minimumPosition(), 0, isolate, NotSharableCrossOrigin, V8CacheOptionsOff); v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(v8String(isolate, sourceString), fileName, TextPosition::minimumPosition(), 0, isolate, NotSharableCrossOrigin, V8CacheOptionsOff);
if (block.HasCaught()) { if (block.HasCaught()) {
fprintf(stderr, "Private script error: Compile failed. (Class name = %s)\n", className.utf8().data()); fprintf(stderr, "Private script error: Compile failed. (Class name = %s)\n", scriptClassName.utf8().data());
dumpV8Message(block.Message()); dumpV8Message(block.Message());
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
v8::Handle<v8::Value> result = V8ScriptRunner::runCompiledInternalScript(script, isolate); v8::Handle<v8::Value> result = V8ScriptRunner::runCompiledInternalScript(script, isolate);
if (block.HasCaught()) { if (block.HasCaught()) {
fprintf(stderr, "Private script error: installClass() failed. (Class name = %s)\n", className.utf8().data()); fprintf(stderr, "Private script error: installClass() failed. (Class name = %s)\n", scriptClassName.utf8().data());
dumpV8Message(block.Message()); dumpV8Message(block.Message());
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
...@@ -68,15 +68,15 @@ static v8::Handle<v8::Value> compileAndRunPrivateScript(v8::Isolate* isolate, St ...@@ -68,15 +68,15 @@ static v8::Handle<v8::Value> compileAndRunPrivateScript(v8::Isolate* isolate, St
// are compiled when any of the JS files is requested. Ideally we should avoid compiling // are compiled when any of the JS files is requested. Ideally we should avoid compiling
// unrelated JS files. For example, if a method in XPartial-1.js is requested, we just // unrelated JS files. For example, if a method in XPartial-1.js is requested, we just
// need to compile X.js and XPartial-1.js, and don't need to compile XPartial-2.js. // need to compile X.js and XPartial-1.js, and don't need to compile XPartial-2.js.
static void installPrivateScript(v8::Isolate* isolate, String dependencyClassName) static void installPrivateScript(v8::Isolate* isolate, String className)
{ {
int compiledScriptCount = 0; int compiledScriptCount = 0;
// |kPrivateScriptSourcesForTesting| is defined in V8PrivateScriptSources.h, which is auto-generated // |kPrivateScriptSourcesForTesting| is defined in V8PrivateScriptSources.h, which is auto-generated
// by make_private_script_source.py. // by make_private_script_source.py.
#ifndef NDEBUG #ifndef NDEBUG
for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSourcesForTesting); index++) { for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSourcesForTesting); index++) {
if (dependencyClassName == kPrivateScriptSourcesForTesting[index].dependencyClassName) { if (className == kPrivateScriptSourcesForTesting[index].className) {
compileAndRunPrivateScript(isolate, kPrivateScriptSourcesForTesting[index].className, kPrivateScriptSourcesForTesting[index].source, kPrivateScriptSourcesForTesting[index].size); compileAndRunPrivateScript(isolate, kPrivateScriptSourcesForTesting[index].scriptClassName, kPrivateScriptSourcesForTesting[index].source, kPrivateScriptSourcesForTesting[index].size);
compiledScriptCount++; compiledScriptCount++;
} }
} }
...@@ -85,14 +85,14 @@ static void installPrivateScript(v8::Isolate* isolate, String dependencyClassNam ...@@ -85,14 +85,14 @@ static void installPrivateScript(v8::Isolate* isolate, String dependencyClassNam
// |kPrivateScriptSources| is defined in V8PrivateScriptSources.h, which is auto-generated // |kPrivateScriptSources| is defined in V8PrivateScriptSources.h, which is auto-generated
// by make_private_script_source.py. // by make_private_script_source.py.
for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) { for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) {
if (dependencyClassName == kPrivateScriptSources[index].dependencyClassName) { if (className == kPrivateScriptSources[index].className) {
compileAndRunPrivateScript(isolate, kPrivateScriptSources[index].className, kPrivateScriptSources[index].source, kPrivateScriptSources[index].size); compileAndRunPrivateScript(isolate, kPrivateScriptSources[index].scriptClassName, kPrivateScriptSources[index].source, kPrivateScriptSources[index].size);
compiledScriptCount++; compiledScriptCount++;
} }
} }
if (!compiledScriptCount) { if (!compiledScriptCount) {
fprintf(stderr, "Private script error: Target source code was not found. (Class name = %s)\n", dependencyClassName.utf8().data()); fprintf(stderr, "Private script error: Target source code was not found. (Class name = %s)\n", className.utf8().data());
RELEASE_ASSERT_NOT_REACHED(); RELEASE_ASSERT_NOT_REACHED();
} }
} }
......
...@@ -46,8 +46,8 @@ def main(): ...@@ -46,8 +46,8 @@ def main():
class_name, ', '.join(hex_values))) class_name, ', '.join(hex_values)))
contents.append('struct %s {' % source_name) contents.append('struct %s {' % source_name)
contents.append(""" contents.append("""
const char* scriptClassName;
const char* className; const char* className;
const char* dependencyClassName;
const unsigned char* source; const unsigned char* source;
size_t size; size_t size;
}; };
...@@ -55,9 +55,9 @@ def main(): ...@@ -55,9 +55,9 @@ def main():
""") """)
contents.append('struct %s k%s[] = {\n' % (source_name, source_name)) contents.append('struct %s k%s[] = {\n' % (source_name, source_name))
for input_filename in input_filenames: for input_filename in input_filenames:
class_name, ext = os.path.splitext(os.path.basename(input_filename)) script_class_name, ext = os.path.splitext(os.path.basename(input_filename))
dependency_class_name = extract_partial_interface_name(input_filename) or class_name class_name = extract_partial_interface_name(input_filename) or script_class_name
contents.append(' { "%s", "%s", kSourceOf%s, sizeof(kSourceOf%s) },\n' % (class_name, dependency_class_name, class_name, class_name)) contents.append(' { "%s", "%s", kSourceOf%s, sizeof(kSourceOf%s) },\n' % (script_class_name, class_name, script_class_name, script_class_name))
contents.append('};\n') contents.append('};\n')
with open(output_filename, 'w') as output_file: with open(output_filename, 'w') as output_file:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment