Changeset 159934 in webkit
- Timestamp:
- Dec 2, 2013 8:38:58 AM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r159933 r159934 1 2013-12-02 Brian J. Burg <burg@cs.washington.edu> 2 3 jsc: implement a native readFile function 4 https://bugs.webkit.org/show_bug.cgi?id=125059 5 6 Reviewed by Filip Pizlo. 7 8 This adds a native readFile() function to jsc, used to slurp 9 an entire file into a JavaScript string. 10 11 * jsc.cpp: 12 (GlobalObject::finishCreation): Add readFile() to globals. 13 (functionReadFile): Added. 14 1 15 2013-12-02 László Langó <lango@inf.u-szeged.hu> 2 16 -
trunk/Source/JavaScriptCore/jsc.cpp
r159064 r159934 109 109 static EncodedJSValue JSC_HOST_CALL functionRun(ExecState*); 110 110 static EncodedJSValue JSC_HOST_CALL functionLoad(ExecState*); 111 static EncodedJSValue JSC_HOST_CALL functionReadFile(ExecState*); 111 112 static EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState*); 112 113 static EncodedJSValue JSC_HOST_CALL functionReadline(ExecState*); … … 227 228 addFunction(vm, "run", functionRun, 1); 228 229 addFunction(vm, "load", functionLoad, 1); 230 addFunction(vm, "readFile", functionReadFile, 1); 229 231 addFunction(vm, "checkSyntax", functionCheckSyntax, 1); 230 232 addFunction(vm, "jscStack", functionJSCStack, 1); … … 420 422 exec->vm().throwException(exec, evaluationException); 421 423 return JSValue::encode(result); 424 } 425 426 EncodedJSValue JSC_HOST_CALL functionReadFile(ExecState* exec) 427 { 428 String fileName = exec->argument(0).toString(exec)->value(exec); 429 Vector<char> script; 430 if (!fillBufferWithContentsOfFile(fileName, script)) 431 return JSValue::encode(exec->vm().throwException(exec, createError(exec, "Could not open file."))); 432 433 return JSValue::encode(jsString(exec, stringFromUTF(script.data()))); 422 434 } 423 435
Note: See TracChangeset
for help on using the changeset viewer.