Changeset 15163 in webkit for trunk/JavaScriptCore/API
- Timestamp:
- Jul 5, 2006, 9:52:54 AM (19 years ago)
- Location:
- trunk/JavaScriptCore/API
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/JSBase.h
r15149 r15163 53 53 @param sourceURL URL to the file containing the JavaScript, or NULL - this is only used for error reporting 54 54 @param startingLineNumber the JavaScript's starting line number in the file located at sourceURL - this is only used for error reporting 55 @param exception pointer to a JSValueRef in which to store an uncaught exception, orNULL55 @param exception pointer to a JSValueRef in which to store an uncaught exception, if any; can be NULL 56 56 @result result of evaluation, or NULL if an uncaught exception was thrown 57 57 */ … … 60 60 /*! 61 61 @function JSCheckSyntax 62 Checks for syntax errors in a string of JavaScript code 63 @param context execution context to use 64 @param script a string containing the script source code 65 @result true if the script is syntactically correct, false otherwise 62 Check for syntax errors in a string of JavaScript 63 @param context execution context to use 64 @param script a character buffer containing the JavaScript to evaluate 65 @param sourceURL URL to the file containing the JavaScript, or NULL - this is only used for error reporting 66 @param startingLineNumber the JavaScript's starting line number in the file located at sourceURL - this is only used for error reporting 67 @param exception pointer to a JSValueRef in which to store a syntax error, if any; can be NULL 68 @result true if the script is syntactically correct, false otherwise 66 69 67 70 */ 68 bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script );71 bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script, JSCharBufferRef sourceURL, int startingLineNumber, JSValueRef* exception); 69 72 70 73 // Garbage collection -
trunk/JavaScriptCore/API/JSContextRef.cpp
r15149 r15163 95 95 } 96 96 97 bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script )97 bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script, JSCharBufferRef sourceURL, int startingLineNumber, JSValueRef* exception) 98 98 { 99 99 JSLock lock; 100 100 101 ExecState* exec = toJS(context); 101 UString::Rep* rep = toJS(script); 102 return exec->dynamicInterpreter()->checkSyntax(UString(rep)); 102 UString::Rep* scriptRep = toJS(script); 103 UString::Rep* sourceURLRep = toJS(sourceURL); 104 Completion completion = exec->dynamicInterpreter()->checkSyntax(UString(sourceURLRep), startingLineNumber, UString(scriptRep)); 105 if (completion.complType() == Throw) { 106 if (exception) 107 *exception = toRef(completion.value()); 108 return false; 109 } 110 111 return true; 103 112 } 104 113 -
trunk/JavaScriptCore/API/testapi.c
r15149 r15163 495 495 JSCharBufferRef goodSyntaxBuf = JSCharBufferCreateUTF8("x = 1;"); 496 496 JSCharBufferRef badSyntaxBuf = JSCharBufferCreateUTF8("x := 1;"); 497 assert(JSCheckSyntax(context, goodSyntaxBuf ));498 assert(!JSCheckSyntax(context, badSyntaxBuf ));497 assert(JSCheckSyntax(context, goodSyntaxBuf, NULL, 0, NULL)); 498 assert(!JSCheckSyntax(context, badSyntaxBuf, NULL, 0, NULL)); 499 499 500 500 JSValueRef result;
Note:
See TracChangeset
for help on using the changeset viewer.