Changeset 15163 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
Jul 5, 2006, 9:52:54 AM (19 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Maciej.

  • Return syntax error in JSCheckSyntax through a JSValueRef* exception argument


  • API/JSBase.h:
  • API/JSContextRef.cpp: (JSCheckSyntax):
  • API/testapi.c: (main):
  • JavaScriptCore.exp:
  • kjs/interpreter.cpp: (KJS::Interpreter::checkSyntax):
  • kjs/interpreter.h:

JavaScriptGlue:

Reviewed by Maciej.


  • JSRun.cpp: (JSRun::CheckSyntax): Updated to use new checkSyntax syntax in JSC.
  • JavaScriptGlue.xcodeproj/project.pbxproj:
Location:
trunk/JavaScriptCore/API
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSBase.h

    r15149 r15163  
    5353  @param sourceURL          URL to the file containing the JavaScript, or NULL - this is only used for error reporting
    5454  @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, or NULL
     55  @param exception          pointer to a JSValueRef in which to store an uncaught exception, if any; can be NULL
    5656  @result                   result of evaluation, or NULL if an uncaught exception was thrown
    5757*/
     
    6060/*!
    6161  @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
    6669
    6770*/
    68 bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script);
     71bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script, JSCharBufferRef sourceURL, int startingLineNumber, JSValueRef* exception);
    6972
    7073// Garbage collection
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r15149 r15163  
    9595}
    9696
    97 bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script)
     97bool JSCheckSyntax(JSContextRef context, JSCharBufferRef script, JSCharBufferRef sourceURL, int startingLineNumber, JSValueRef* exception)
    9898{
    9999    JSLock lock;
     100
    100101    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;
    103112}
    104113
  • trunk/JavaScriptCore/API/testapi.c

    r15149 r15163  
    495495    JSCharBufferRef goodSyntaxBuf = JSCharBufferCreateUTF8("x = 1;");
    496496    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));
    499499
    500500    JSValueRef result;
Note: See TracChangeset for help on using the changeset viewer.