Ignore:
Timestamp:
Jul 7, 2006, 7:02:47 PM (19 years ago)
Author:
ggaren
Message:

Reviewed by Maciej.


More API action.


  • Headerdoc finished

Semantic Changes:

  • Added a JSContextRef argument to many functions, because you need a JSContextRef for doing virtually anything. I expect to add this argument to even more functions in a future patch.


  • Removed the globalObjectPrototype argument to JSContextCreate because you can't create an object until you have a context, so it's impossible to pass a prototype object to JSContextCreate. That's OK because (1) there's no reason to give the global object a prototype and (2) if you really want to, you can just use a separate call to JSObjectSetPrototype.


  • Removed the JSClassRef argument to JSClassCreate because it was unnecessary, and you need to be able to make the global object's class before you've created a JSContext.


  • Added an optional exception parameter to JSFunctionMakeWithBody because anything less would be uncivilized.


  • Made the return value parameter to JSObjectGetProperty optional to match all other return value parameters in the API.


  • Made JSObjectSetPrivate/JSObjectGetPrivate work on JSCallbackFunctions and JSCallbackConstructors. You could use an abstract base class or strategic placement of m_privateData in the class structure to implement this, but the former seemed like overkill, and the latter seemed too dangerous.


  • Fixed a bug where JSPropertyEnumeratorGetNext would skip the first property.

Cosmetic Changes:

  • Reversed the logic of the JSChar #ifdef to avoid confusing headerdoc


  • Removed function names from @function declarations because headeroc can parse them automatically, and I wanted to rule out manual mismatch.
  • Changed Error::create to take a const UString& instead of a UString* because it was looking at me funny.


  • Renamed JSStringBufferCreateWithCFString to JSStringBufferCreateCF because the latter is more concise and it matches JSStringBufferCreateUTF8.


  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::getOwnPropertySlot): (KJS::JSCallbackObject::put): (KJS::JSCallbackObject::deleteProperty): (KJS::JSCallbackObject::getPropertyList): (KJS::JSCallbackObject::toBoolean): (KJS::JSCallbackObject::toNumber): (KJS::JSCallbackObject::toString):
  • API/JSClassRef.cpp: (JSClassCreate):
  • API/JSContextRef.cpp: (JSContextCreate): (JSContextSetException):
  • API/JSContextRef.h:
  • API/JSNode.c: (JSNodePrototype_class): (JSNode_class):
  • API/JSNodeList.c: (JSNodeListPrototype_class): (JSNodeList_class):
  • API/JSObjectRef.cpp: (JSObjectGetProperty): (JSObjectGetPrivate): (JSObjectSetPrivate): (JSObjectCallAsFunction): (JSObjectCallAsConstructor): (JSPropertyEnumeratorGetNext):
  • API/JSObjectRef.h:
  • API/JSStringBufferRef.cpp: (JSStringBufferCreateCF):
  • API/JSStringBufferRef.h:
  • API/JSValueRef.cpp: (JSValueIsInstanceOf):
  • API/JSValueRef.h:
  • API/minidom.c: (main):
  • API/minidom.js:
  • API/testapi.c: (MyObject_hasProperty): (MyObject_setProperty): (MyObject_deleteProperty): (MyObject_getPropertyList): (MyObject_convertToType): (MyObject_class): (main):
  • JavaScriptCore.exp:
File:
1 edited

Legend:

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

    r15212 r15224  
    3535#endif
    3636
    37 JSContextRef JSContextCreate(JSClassRef globalObjectClass, JSObjectRef globalObjectPrototype);
     37/*!
     38@function
     39@abstract Creates a JavaScript execution context.
     40@discussion JSContextCreate allocates a global object and populates it with all the
     41 built-in JavaScript objects, such as Object, Function, String, and Array.
     42@param globalObjectClass The class to use when creating the JSContext's global object.
     43 Pass NULL to use the default object class.
     44@result A JSContext with a global object of class globalObjectClass.
     45*/
     46JSContextRef JSContextCreate(JSClassRef globalObjectClass);
     47
     48/*!
     49@function
     50@abstract       Destroys a JavaScript execution context, freeing its resources.
     51@param context  The JSContext to destroy.
     52*/
    3853void JSContextDestroy(JSContextRef context);
    3954
     55/*!
     56@function
     57@abstract       Returns the global object of a JavaScript execution context.
     58@param context  The JSContext whose global object you want to retrieve.
     59@result         context's global object.
     60*/
    4061JSObjectRef JSContextGetGlobalObject(JSContextRef context);
    4162
    42 JSValueRef JSContextGetException(JSContextRef context); // NULL if there is no exception
     63/*!
     64@function
     65@abstract       Returns the current exception in a JavaScript execution context.
     66@param context  The JSContext whose exception you want to retrieve.
     67@result         A JSValue representing context's exception, or NULL if no exception has been set.
     68*/
     69JSValueRef JSContextGetException(JSContextRef context);
     70/*!
     71@function
     72@abstract       Sets an exception in a JavaScript execution context.
     73@param context  The JSContext whose exception you want to set.
     74@param value    The exception you want to set.
     75*/
    4376void JSContextSetException(JSContextRef context, JSValueRef value);
     77/*!
     78@function
     79@abstract       Clears the exception in a JavaScript execution context.
     80@param context  The JSContext whose exception you want to clear.
     81*/
    4482void JSContextClearException(JSContextRef context);
    45    
     83
    4684// Evaluation
    4785/*!
    48   @function JSEvaluate
    49   Evaluates a string of JavaScript
    50   @param context            execution context to use
    51   @param script             a character buffer containing the JavaScript to evaluate
    52   @param thisObject         the object to use as "this," or NULL to use the global object as "this."
    53   @param sourceURL          URL to the file containing the JavaScript, or NULL - this is only used for error reporting
    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, if any; can be NULL
    56   @result                   result of evaluation, or NULL if an uncaught exception was thrown
     86@function
     87@abstract                 Evaluates a string of JavaScript.
     88@param context            The execution context to use.
     89@param script             A JSStringBuffer containing the script to evaluate.
     90@param thisObject         The object to use as "this," or NULL to use the global object as "this."
     91@param sourceURL          A JSStringBuffer containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
     92@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
     93@param exception          A pointer to a JSValueRef in which to store an uncaught exception, if any. Pass NULL if you do not care to store an uncaught exception.
     94@result                   The JSValue that results from evaluating script, or NULL if an uncaught exception is thrown.
    5795*/
    5896JSValueRef JSEvaluate(JSContextRef context, JSStringBufferRef script, JSObjectRef thisObject, JSStringBufferRef sourceURL, int startingLineNumber, JSValueRef* exception);
    5997
    6098/*!
    61   @function JSCheckSyntax
    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
    69 
     99@function JSCheckSyntax
     100@abstract                 Checks for syntax errors in a string of JavaScript.
     101@param context            The execution context to use.
     102@param script             A JSStringBuffer containing the JavaScript to check for syntax errors.
     103@param sourceURL          A JSStringBuffer containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
     104@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
     105@param exception          A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception.
     106@result                   true if the script is syntactically correct, otherwise false.
    70107*/
    71108bool JSCheckSyntax(JSContextRef context, JSStringBufferRef script, JSStringBufferRef sourceURL, int startingLineNumber, JSValueRef* exception);
Note: See TracChangeset for help on using the changeset viewer.