Changeset 15481 in webkit for trunk/JavaScriptCore/API


Ignore:
Timestamp:
Jul 17, 2006, 1:14:39 AM (19 years ago)
Author:
mjs
Message:

Reviewed by Geoff.


  • add a JSContextRef parameter to all JSValueRef, JSObjectRef, and JSContextRef operations; except JSObject{Get,Set}PrivateData which can be assumed to be simple pure accessors.


Also renamed the parameter "context" to "ctx" because it makes the code read better with this pervasive
but usually uninteresting parameter.

  • API/JSBase.cpp: (JSEvaluateScript): (JSCheckScriptSyntax): (JSGarbageCollect):
  • API/JSBase.h:
  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::JSCallbackObject): (KJS::JSCallbackObject::init): (KJS::JSCallbackObject::getOwnPropertySlot): (KJS::JSCallbackObject::put): (KJS::JSCallbackObject::deleteProperty): (KJS::JSCallbackObject::toNumber): (KJS::JSCallbackObject::toString):
  • API/JSContextRef.cpp: (JSGlobalContextCreate): (JSGlobalContextRetain): (JSGlobalContextRelease): (JSContextGetGlobalObject):
  • API/JSContextRef.h:
  • API/JSNode.c: (JSNodePrototype_appendChild): (JSNodePrototype_removeChild): (JSNodePrototype_replaceChild): (JSNode_getNodeType): (JSNode_getFirstChild): (JSNode_prototype):
  • API/JSNodeList.c: (JSNodeListPrototype_item): (JSNodeList_length): (JSNodeList_getProperty): (JSNodeList_prototype):
  • API/JSObjectRef.cpp: (JSObjectMake): (JSObjectMakeFunctionWithCallback): (JSObjectMakeConstructor): (JSObjectMakeFunction): (JSObjectGetPrototype): (JSObjectSetPrototype): (JSObjectHasProperty): (JSObjectGetProperty): (JSObjectSetProperty): (JSObjectGetPropertyAtIndex): (JSObjectSetPropertyAtIndex): (JSObjectDeleteProperty): (JSObjectIsFunction): (JSObjectCallAsFunction): (JSObjectIsConstructor): (JSObjectCallAsConstructor): (JSObjectCopyPropertyNames):
  • API/JSObjectRef.h:
  • API/JSStringRef.cpp:
  • API/JSValueRef.cpp: (JSValueGetType): (JSValueIsUndefined): (JSValueIsNull): (JSValueIsBoolean): (JSValueIsNumber): (JSValueIsString): (JSValueIsObject): (JSValueIsObjectOfClass): (JSValueIsEqual): (JSValueIsStrictEqual): (JSValueIsInstanceOfConstructor): (JSValueMakeUndefined): (JSValueMakeNull): (JSValueMakeBoolean): (JSValueMakeNumber): (JSValueMakeString): (JSValueToBoolean): (JSValueToNumber): (JSValueToStringCopy): (JSValueToObject): (JSValueProtect): (JSValueUnprotect):
  • API/JSValueRef.h:
  • API/minidom.c: (print):
  • API/testapi.c: (MyObject_getProperty): (MyObject_deleteProperty): (MyObject_callAsFunction): (MyObject_callAsConstructor): (MyObject_convertToType): (print_callAsFunction): (main):
Location:
trunk/JavaScriptCore/API
Files:
14 edited

Legend:

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

    r15445 r15481  
    3636using namespace KJS;
    3737
    38 JSValueRef JSEvaluateScript(JSContextRef context, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
     38JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
    3939{
    4040    JSLock lock;
    41     ExecState* exec = toJS(context);
     41    ExecState* exec = toJS(ctx);
    4242    JSObject* jsThisObject = toJS(thisObject);
    4343    UString::Rep* scriptRep = toJS(script);
     
    5959}
    6060
    61 bool JSCheckScriptSyntax(JSContextRef context, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
     61bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
    6262{
    6363    JSLock lock;
    6464
    65     ExecState* exec = toJS(context);
     65    ExecState* exec = toJS(ctx);
    6666    UString::Rep* scriptRep = toJS(script);
    6767    UString::Rep* sourceURLRep = toJS(sourceURL);
     
    7676}
    7777
    78 void JSGarbageCollect()
     78void JSGarbageCollect(JSContextRef)
    7979{
    8080    JSLock lock;
  • trunk/JavaScriptCore/API/JSBase.h

    r15480 r15481  
    6868@function
    6969@abstract                 Evaluates a string of JavaScript.
    70 @param context            The execution context to use.
     70@param ctx            The execution context to use.
    7171@param script             A JSString containing the script to evaluate.
    7272@param thisObject         The object to use as "this," or NULL to use the global object as "this."
     
    7676@result                   The JSValue that results from evaluating script, or NULL if an exception is thrown.
    7777*/
    78 JSValueRef JSEvaluateScript(JSContextRef context, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
     78JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
    7979
    8080/*!
    8181@function JSCheckScriptSyntax
    8282@abstract                 Checks for syntax errors in a string of JavaScript.
    83 @param context            The execution context to use.
     83@param ctx            The execution context to use.
    8484@param script             A JSString containing the script to check for syntax errors.
    8585@param sourceURL          A JSString 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.
     
    8888@result                   true if the script is syntactically correct, otherwise false.
    8989*/
    90 bool JSCheckScriptSyntax(JSContextRef context, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
     90bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
    9191
    9292/*!
    9393@function
    9494@abstract Performs a JavaScript garbage collection.
     95@param ctx  The execution context to use.
    9596@discussion JavaScript values that are on the machine stack, in a register,
    9697 protected by JSValueProtect, set as the global object of an execution context,
     
    100101 collect as needed.
    101102*/
    102 void JSGarbageCollect(void);
     103void JSGarbageCollect(JSContextRef ctx);
    103104
    104105#ifdef __cplusplus
  • trunk/JavaScriptCore/API/JSCallbackObject.cpp

    r15480 r15481  
    3838const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0, 0 };
    3939
    40 JSCallbackObject::JSCallbackObject(JSContextRef context, JSClassRef jsClass)
     40JSCallbackObject::JSCallbackObject(JSContextRef ctx, JSClassRef jsClass)
    4141    : JSObject()
    4242{
    43     init(context, jsClass);
    44 }
    45 
    46 JSCallbackObject::JSCallbackObject(JSContextRef context, JSClassRef jsClass, JSValue* prototype)
     43    init(ctx, jsClass);
     44}
     45
     46JSCallbackObject::JSCallbackObject(JSContextRef ctx, JSClassRef jsClass, JSValue* prototype)
    4747    : JSObject(prototype)
    4848{
    49     init(context, jsClass);
    50 }
    51 
    52 void JSCallbackObject::init(JSContextRef context, JSClassRef jsClass)
    53 {
    54     ExecState* exec = toJS(context);
     49    init(ctx, jsClass);
     50}
     51
     52void JSCallbackObject::init(JSContextRef ctx, JSClassRef jsClass)
     53{
     54    ExecState* exec = toJS(ctx);
    5555   
    5656    m_privateData = 0;
     
    6161    do {
    6262        if (JSObjectInitializeCallback initialize = jsClass->initialize)
    63             initialize(context, thisRef, toRef(exec->exceptionSlot()));
     63            initialize(ctx, thisRef, toRef(exec->exceptionSlot()));
    6464    } while ((jsClass = jsClass->parentClass));
    6565}
     
    8686bool JSCallbackObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    8787{
    88     JSContextRef context = toRef(exec);
     88    JSContextRef ctx = toRef(exec);
    8989    JSObjectRef thisRef = toRef(this);
    9090    JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
     
    9393        // optional optimization to bypass getProperty in cases when we only need to know if the property exists
    9494        if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) {
    95             if (hasProperty(context, thisRef, propertyNameRef)) {
     95            if (hasProperty(ctx, thisRef, propertyNameRef)) {
    9696                slot.setCustom(this, callbackGetter);
    9797                return true;
    9898            }
    9999        } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
    100             if (JSValueRef value = getProperty(context, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) {
     100            if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot()))) {
    101101                // cache the value so we don't have to compute it again
    102102                // FIXME: This violates the PropertySlot design a little bit.
     
    132132void JSCallbackObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
    133133{
    134     JSContextRef context = toRef(exec);
     134    JSContextRef ctx = toRef(exec);
    135135    JSObjectRef thisRef = toRef(this);
    136136    JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
     
    139139    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    140140        if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
    141             if (setProperty(context, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())))
     141            if (setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot())))
    142142                return;
    143143        }
     
    148148                    return;
    149149                if (JSObjectSetPropertyCallback setProperty = entry->setProperty)
    150                     setProperty(context, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()));
     150                    setProperty(ctx, thisRef, propertyNameRef, valueRef, toRef(exec->exceptionSlot()));
    151151                else
    152152                    throwError(exec, ReferenceError, "Writable static value property defined with NULL setProperty callback.");
     
    174174bool JSCallbackObject::deleteProperty(ExecState* exec, const Identifier& propertyName)
    175175{
    176     JSContextRef context = toRef(exec);
     176    JSContextRef ctx = toRef(exec);
    177177    JSObjectRef thisRef = toRef(this);
    178178    JSStringRef propertyNameRef = toRef(propertyName.ustring().rep());
     
    180180    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
    181181        if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
    182             if (deleteProperty(context, thisRef, propertyNameRef, toRef(exec->exceptionSlot())))
     182            if (deleteProperty(ctx, thisRef, propertyNameRef, toRef(exec->exceptionSlot())))
    183183                return true;
    184184        }
     
    326326double JSCallbackObject::toNumber(ExecState* exec) const
    327327{
    328     JSContextRef context = toRef(exec);
     328    JSContextRef ctx = toRef(exec);
    329329    JSObjectRef thisRef = toRef(this);
    330330
    331331    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    332332        if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType)
    333             if (JSValueRef value = convertToType(context, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot())))
     333            if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot())))
    334334                return toJS(value)->getNumber();
    335335
     
    339339UString JSCallbackObject::toString(ExecState* exec) const
    340340{
    341     JSContextRef context = toRef(exec);
     341    JSContextRef ctx = toRef(exec);
    342342    JSObjectRef thisRef = toRef(this);
    343343
    344344    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass)
    345345        if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType)
    346             if (JSValueRef value = convertToType(context, thisRef, kJSTypeString, toRef(exec->exceptionSlot())))
     346            if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot())))
    347347                return toJS(value)->getString();
    348348
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r15437 r15481  
    4747
    4848    Interpreter* interpreter = new Interpreter(globalObject); // adds the built-in object prototype to the global object
    49     JSGlobalContextRef context = reinterpret_cast<JSGlobalContextRef>(interpreter->globalExec());
    50     return JSGlobalContextRetain(context);
     49    JSGlobalContextRef ctx = reinterpret_cast<JSGlobalContextRef>(interpreter->globalExec());
     50    return JSGlobalContextRetain(ctx);
    5151}
    5252
    53 JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef context)
     53JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx)
    5454{
    5555    JSLock lock;
    56     ExecState* exec = toJS(context);
     56    ExecState* exec = toJS(ctx);
    5757    exec->dynamicInterpreter()->ref();
    58     return context;
     58    return ctx;
    5959}
    6060
    61 void JSGlobalContextRelease(JSGlobalContextRef context)
     61void JSGlobalContextRelease(JSGlobalContextRef ctx)
    6262{
    6363    JSLock lock;
    64     ExecState* exec = toJS(context);
     64    ExecState* exec = toJS(ctx);
    6565    exec->dynamicInterpreter()->deref();
    6666}
    6767
    68 JSObjectRef JSContextGetGlobalObject(JSContextRef context)
     68JSObjectRef JSContextGetGlobalObject(JSContextRef ctx)
    6969{
    70     ExecState* exec = toJS(context);
     70    ExecState* exec = toJS(ctx);
    7171    return toRef(exec->dynamicInterpreter()->globalObject());
    7272}
  • trunk/JavaScriptCore/API/JSContextRef.h

    r15437 r15481  
    5151@function
    5252@abstract Retains a global JavaScript execution context.
    53 @param context The JSGlobalContext to retain.
    54 @result A JSGlobalContext that is the same as context.
     53@param ctx The JSGlobalContext to retain.
     54@result A JSGlobalContext that is the same as ctx.
    5555*/
    56 JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef context);
     56JSGlobalContextRef JSGlobalContextRetain(JSGlobalContextRef ctx);
    5757
    5858/*!
    5959@function
    6060@abstract Releases a global JavaScript execution context.
    61 @param context The JSGlobalContext to release.
     61@param ctx The JSGlobalContext to release.
    6262*/
    63 void JSGlobalContextRelease(JSGlobalContextRef context);
     63void JSGlobalContextRelease(JSGlobalContextRef ctx);
    6464
    6565/*!
    6666@function
    6767@abstract Gets the global object of a JavaScript execution context.
    68 @param context The JSContext whose global object you want to get.
    69 @result context's global object.
     68@param ctx The JSContext whose global object you want to get.
     69@result ctx's global object.
    7070*/
    71 JSObjectRef JSContextGetGlobalObject(JSContextRef context);
     71JSObjectRef JSContextGetGlobalObject(JSContextRef ctx);
    7272
    7373#ifdef __cplusplus
  • trunk/JavaScriptCore/API/JSNode.c

    r15465 r15481  
    3939
    4040    // Example of throwing a type error for invalid values
    41     if (!JSValueIsObjectOfClass(thisObject, JSNode_class(context))) {
     41    if (!JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) {
    4242        JSStringRef message = JSStringCreateWithUTF8CString("TypeError: appendChild can only be called on nodes");
    43         *exception = JSValueMakeString(message);
     43        *exception = JSValueMakeString(context, message);
    4444        JSStringRelease(message);
    45     } else if (argumentCount < 1 || !JSValueIsObjectOfClass(arguments[0], JSNode_class(context))) {
     45    } else if (argumentCount < 1 || !JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) {
    4646        JSStringRef message = JSStringCreateWithUTF8CString("TypeError: first argument to appendChild must be a node");
    47         *exception = JSValueMakeString(message);
     47        *exception = JSValueMakeString(context, message);
    4848        JSStringRelease(message);
    4949    } else {
     
    5454    }
    5555
    56     return JSValueMakeUndefined();
     56    return JSValueMakeUndefined(context);
    5757}
    5858
     
    6464    // Example of ignoring invalid values
    6565    if (argumentCount > 0) {
    66         if (JSValueIsObjectOfClass(thisObject, JSNode_class(context))) {
    67             if (JSValueIsObjectOfClass(arguments[0], JSNode_class(context))) {
     66        if (JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) {
     67            if (JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) {
    6868                Node* node = JSObjectGetPrivate(thisObject);
    6969                Node* child = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL));
     
    7474    }
    7575   
    76     return JSValueMakeUndefined();
     76    return JSValueMakeUndefined(context);
    7777}
    7878
     
    8383   
    8484    if (argumentCount > 1) {
    85         if (JSValueIsObjectOfClass(thisObject, JSNode_class(context))) {
    86             if (JSValueIsObjectOfClass(arguments[0], JSNode_class(context))) {
    87                 if (JSValueIsObjectOfClass(arguments[1], JSNode_class(context))) {
     85        if (JSValueIsObjectOfClass(context, thisObject, JSNode_class(context))) {
     86            if (JSValueIsObjectOfClass(context, arguments[0], JSNode_class(context))) {
     87                if (JSValueIsObjectOfClass(context, arguments[1], JSNode_class(context))) {
    8888                    Node* node = JSObjectGetPrivate(thisObject);
    8989                    Node* newChild = JSObjectGetPrivate(JSValueToObject(context, arguments[0], NULL));
     
    9696    }
    9797   
    98     return JSValueMakeUndefined();
     98    return JSValueMakeUndefined(context);
    9999}
    100100
     
    125125    if (node) {
    126126        JSStringRef nodeType = JSStringCreateWithUTF8CString(node->nodeType);
    127         JSValueRef value = JSValueMakeString(nodeType);
     127        JSValueRef value = JSValueMakeString(context, nodeType);
    128128        JSStringRelease(nodeType);
    129129        return value;
     
    147147    UNUSED_PARAM(object);
    148148   
    149     return JSValueMakeUndefined();
     149    return JSValueMakeUndefined(context);
    150150}
    151151
     
    183183    if (!prototype) {
    184184        prototype = JSObjectMake(context, JSNodePrototype_class(context), NULL);
    185         JSValueProtect(prototype);
     185        JSValueProtect(context, prototype);
    186186    }
    187187    return prototype;
  • trunk/JavaScriptCore/API/JSNodeList.c

    r15465 r15481  
    3939    }
    4040   
    41     return JSValueMakeUndefined();
     41    return JSValueMakeUndefined(context);
    4242}
    4343
     
    6565    NodeList* nodeList = JSObjectGetPrivate(thisObject);
    6666    assert(nodeList);
    67     return JSValueMakeNumber(NodeList_length(nodeList));
     67    return JSValueMakeNumber(context, NodeList_length(nodeList));
    6868}
    6969
     
    7777    NodeList* nodeList = JSObjectGetPrivate(thisObject);
    7878    assert(nodeList);
    79     double index = JSValueToNumber(context, JSValueMakeString(propertyName), exception);
     79    double index = JSValueToNumber(context, JSValueMakeString(context, propertyName), exception);
    8080    unsigned uindex = index;
    8181    if (uindex == index) { // false for NaN
     
    116116    if (!prototype) {
    117117        prototype = JSObjectMake(context, JSNodeListPrototype_class(context), NULL);
    118         JSValueProtect(prototype);
     118        JSValueProtect(context, prototype);
    119119    }
    120120    return prototype;
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r15480 r15481  
    6060}
    6161
    62 JSObjectRef JSObjectMake(JSContextRef context, JSClassRef jsClass, JSValueRef prototype)
    63 {
    64     JSLock lock;
    65 
    66     ExecState* exec = toJS(context);
     62JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, JSValueRef prototype)
     63{
     64    JSLock lock;
     65
     66    ExecState* exec = toJS(ctx);
    6767    JSValue* jsPrototype = toJS(prototype);
    6868
     
    7373        return toRef(new JSObject(jsPrototype)); // slightly more efficient
    7474    else
    75         return toRef(new JSCallbackObject(context, jsClass, jsPrototype));
    76 }
    77 
    78 JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef context, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)
    79 {
    80     JSLock lock;
    81     ExecState* exec = toJS(context);
     75        return toRef(new JSCallbackObject(ctx, jsClass, jsPrototype));
     76}
     77
     78JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction)
     79{
     80    JSLock lock;
     81    ExecState* exec = toJS(ctx);
    8282    Identifier nameID = name ? Identifier(toJS(name)) : Identifier("anonymous");
    8383   
     
    8585}
    8686
    87 JSObjectRef JSObjectMakeConstructor(JSContextRef context, JSObjectCallAsConstructorCallback callAsConstructor)
    88 {
    89     JSLock lock;
    90     ExecState* exec = toJS(context);
     87JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSObjectCallAsConstructorCallback callAsConstructor)
     88{
     89    JSLock lock;
     90    ExecState* exec = toJS(ctx);
    9191    return toRef(new JSCallbackConstructor(exec, callAsConstructor));
    9292}
    9393
    94 JSObjectRef JSObjectMakeFunction(JSContextRef context, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
    95 {
    96     JSLock lock;
    97    
    98     ExecState* exec = toJS(context);
     94JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
     95{
     96    JSLock lock;
     97   
     98    ExecState* exec = toJS(ctx);
    9999    UString::Rep* bodyRep = toJS(body);
    100100    UString::Rep* sourceURLRep = sourceURL ? toJS(sourceURL) : &UString::Rep::null;
     
    117117}
    118118
    119 JSValueRef JSObjectGetPrototype(JSObjectRef object)
     119JSValueRef JSObjectGetPrototype(JSContextRef, JSObjectRef object)
    120120{
    121121    JSObject* jsObject = toJS(object);
     
    123123}
    124124
    125 void JSObjectSetPrototype(JSObjectRef object, JSValueRef value)
     125void JSObjectSetPrototype(JSContextRef, JSObjectRef object, JSValueRef value)
    126126{
    127127    JSObject* jsObject = toJS(object);
     
    131131}
    132132
    133 bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
    134 {
    135     JSLock lock;
    136     ExecState* exec = toJS(context);
     133bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
     134{
     135    JSLock lock;
     136    ExecState* exec = toJS(ctx);
    137137    JSObject* jsObject = toJS(object);
    138138    UString::Rep* nameRep = toJS(propertyName);
     
    141141}
    142142
    143 JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
    144 {
    145     JSLock lock;
    146     ExecState* exec = toJS(context);
     143JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
     144{
     145    JSLock lock;
     146    ExecState* exec = toJS(ctx);
    147147    JSObject* jsObject = toJS(object);
    148148    UString::Rep* nameRep = toJS(propertyName);
     
    157157}
    158158
    159 void JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)
    160 {
    161     JSLock lock;
    162     ExecState* exec = toJS(context);
     159void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception)
     160{
     161    JSLock lock;
     162    ExecState* exec = toJS(ctx);
    163163    JSObject* jsObject = toJS(object);
    164164    UString::Rep* nameRep = toJS(propertyName);
     
    173173}
    174174
    175 JSValueRef JSObjectGetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception)
    176 {
    177     JSLock lock;
    178     ExecState* exec = toJS(context);
     175JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception)
     176{
     177    JSLock lock;
     178    ExecState* exec = toJS(ctx);
    179179    JSObject* jsObject = toJS(object);
    180180
     
    189189
    190190
    191 void JSObjectSetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception)
    192 {
    193     JSLock lock;
    194     ExecState* exec = toJS(context);
     191void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception)
     192{
     193    JSLock lock;
     194    ExecState* exec = toJS(ctx);
    195195    JSObject* jsObject = toJS(object);
    196196    JSValue* jsValue = toJS(value);
     
    204204}
    205205
    206 bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
    207 {
    208     JSLock lock;
    209     ExecState* exec = toJS(context);
     206bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
     207{
     208    JSLock lock;
     209    ExecState* exec = toJS(ctx);
    210210    JSObject* jsObject = toJS(object);
    211211    UString::Rep* nameRep = toJS(propertyName);
     
    242242}
    243243
    244 bool JSObjectIsFunction(JSObjectRef object)
     244bool JSObjectIsFunction(JSContextRef, JSObjectRef object)
    245245{
    246246    JSObject* jsObject = toJS(object);
     
    248248}
    249249
    250 JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    251 {
    252     JSLock lock;
    253     ExecState* exec = toJS(context);
     250JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     251{
     252    JSLock lock;
     253    ExecState* exec = toJS(ctx);
    254254    JSObject* jsObject = toJS(object);
    255255    JSObject* jsThisObject = toJS(thisObject);
     
    272272}
    273273
    274 bool JSObjectIsConstructor(JSObjectRef object)
     274bool JSObjectIsConstructor(JSContextRef, JSObjectRef object)
    275275{
    276276    JSObject* jsObject = toJS(object);
     
    278278}
    279279
    280 JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    281 {
    282     JSLock lock;
    283     ExecState* exec = toJS(context);
     280JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     281{
     282    JSLock lock;
     283    ExecState* exec = toJS(ctx);
    284284    JSObject* jsObject = toJS(object);
    285285   
     
    308308};
    309309
    310 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef context, JSObjectRef object)
    311 {
    312     JSLock lock;
    313     JSObject* jsObject = toJS(object);
    314     ExecState* exec = toJS(context);
     310JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object)
     311{
     312    JSLock lock;
     313    JSObject* jsObject = toJS(object);
     314    ExecState* exec = toJS(ctx);
    315315   
    316316    JSPropertyNameArrayRef propertyNames = new OpaqueJSPropertyNameArray();
  • trunk/JavaScriptCore/API/JSObjectRef.h

    r15480 r15481  
    6161@typedef JSObjectInitializeCallback
    6262@abstract The callback invoked when an object is first created.
    63 @param context The execution context to use.
     63@param ctx The execution context to use.
    6464@param object The JSObject being created.
    6565@param exception A pointer to a JSValueRef in which to return an exception, if any.
    6666@discussion If you named your function Initialize, you would declare it like this:
    6767
    68 void Initialize(JSContextRef context, JSObjectRef object, JSValueRef* exception);
     68void Initialize(JSContextRef ctx, JSObjectRef object, JSValueRef* exception);
    6969*/
    7070typedef void
    71 (*JSObjectInitializeCallback) (JSContextRef context, JSObjectRef object, JSValueRef* exception);
     71(*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object, JSValueRef* exception);
    7272
    7373/*!
     
    8585@typedef JSObjectHasPropertyCallback
    8686@abstract The callback invoked when determining whether an object has a property.
    87 @param context The current execution context.
     87@param ctx The execution context to use.
    8888@param object The JSObject to search for the property.
    8989@param propertyName A JSString containing the name of the property look up.
     
    9191@discussion If you named your function HasProperty, you would declare it like this:
    9292
    93 bool HasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
     93bool HasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
    9494
    9595If this function returns false, the hasProperty request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain.
     
    100100*/
    101101typedef bool
    102 (*JSObjectHasPropertyCallback) (JSContextRef context, JSObjectRef object, JSStringRef propertyName);
     102(*JSObjectHasPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
    103103
    104104/*!
    105105@typedef JSObjectGetPropertyCallback
    106106@abstract The callback invoked when getting a property's value.
    107 @param context The current execution context.
     107@param ctx The execution context to use.
    108108@param object The JSObject to search for the property.
    109109@param propertyName A JSString containing the name of the property to get.
     
    112112@discussion If you named your function GetProperty, you would declare it like this:
    113113
    114 JSValueRef GetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
     114JSValueRef GetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
    115115
    116116If this function returns NULL, the get request forwards to object's statically declared properties, then its parent class chain (which includes the default object class), then its prototype chain.
    117117*/
    118118typedef JSValueRef
    119 (*JSObjectGetPropertyCallback) (JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
     119(*JSObjectGetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
    120120
    121121/*!
    122122@typedef JSObjectSetPropertyCallback
    123123@abstract The callback invoked when setting a property's value.
    124 @param context The current execution context.
     124@param ctx The execution context to use.
    125125@param object The JSObject on which to set the property's value.
    126126@param propertyName A JSString containing the name of the property to set.
     
    130130@discussion If you named your function SetProperty, you would declare it like this:
    131131
    132 bool SetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
     132bool SetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
    133133
    134134If this function returns false, the set request forwards to object's statically declared properties, then its parent class chain (which includes the default object class).
    135135*/
    136136typedef bool
    137 (*JSObjectSetPropertyCallback) (JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
     137(*JSObjectSetPropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
    138138
    139139/*!
    140140@typedef JSObjectDeletePropertyCallback
    141141@abstract The callback invoked when deleting a property.
    142 @param context The current execution context.
     142@param ctx The execution context to use.
    143143@param object The JSObject in which to delete the property.
    144144@param propertyName A JSString containing the name of the property to delete.
     
    147147@discussion If you named your function DeleteProperty, you would declare it like this:
    148148
    149 bool DeleteProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
     149bool DeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
    150150
    151151If this function returns false, the delete request forwards to object's statically declared properties, then its parent class chain (which includes the default object class).
    152152*/
    153153typedef bool
    154 (*JSObjectDeletePropertyCallback) (JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
     154(*JSObjectDeletePropertyCallback) (JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
    155155
    156156/*!
    157157@typedef JSObjectGetPropertyNamesCallback
    158158@abstract The callback invoked to get the names of an object's properties.
    159 @param context The current execution context.
     159@param ctx The execution context to use.
    160160@param object The JSObject whose property names need to be appended to propertyNames.
    161161@param accumulator A JavaScript property name accumulator, to which the object should add the names of its properties.
    162162@discussion If you named your function GetPropertyNames, you would declare it like this:
    163163
    164 void GetPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef accumulator);
     164void GetPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef accumulator);
    165165
    166166Use JSPropertyNameAccumulatorAddName to add property names to accumulator.
     
    174174*/
    175175typedef void
    176 (*JSObjectGetPropertyNamesCallback) (JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
     176(*JSObjectGetPropertyNamesCallback) (JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
    177177
    178178/*!
    179179@typedef JSObjectCallAsFunctionCallback
    180180@abstract The callback invoked when an object is called as a function.
    181 @param context The current execution context.
     181@param ctx The execution context to use.
    182182@param function A JSObject that is the function being called.
    183183@param thisObject A JSObject that is the 'this' variable in the function's scope.
     
    188188@discussion If you named your function CallAsFunction, you would declare it like this:
    189189
    190 JSValueRef CallAsFunction(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
     190JSValueRef CallAsFunction(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
    191191
    192192If your callback were invoked by the JavaScript expression 'myObject.myMemberFunction()', function would be set to myMemberFunction, and thisObject would be set to myObject.
     
    195195*/
    196196typedef JSValueRef
    197 (*JSObjectCallAsFunctionCallback) (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
     197(*JSObjectCallAsFunctionCallback) (JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
    198198
    199199/*!
    200200@typedef JSObjectCallAsConstructorCallback
    201201@abstract The callback invoked when an object is used as a constructor in a 'new' expression.
    202 @param context The current execution context.
     202@param ctx The execution context to use.
    203203@param constructor A JSObject that is the constructor being called.
    204204@param argumentCount An integer count of the number of arguments in arguments.
     
    208208@discussion If you named your function CallAsConstructor, you would declare it like this:
    209209
    210 JSObjectRef CallAsConstructor(JSContextRef context, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
     210JSObjectRef CallAsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
    211211
    212212If your callback were invoked by the JavaScript expression 'new myConstructorFunction()', constructor would be set to myConstructorFunction.
     
    215215*/
    216216typedef JSObjectRef
    217 (*JSObjectCallAsConstructorCallback) (JSContextRef context, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
     217(*JSObjectCallAsConstructorCallback) (JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
    218218
    219219/*!
    220220@typedef JSObjectHasInstanceCallback
    221221@abstract hasInstance The callback invoked when an object is used as the target of an 'instanceof' expression.
    222 @param context The current execution context.
     222@param ctx The execution context to use.
    223223@param constructor The JSObject that is the target of the 'instanceof' expression.
    224224@param possibleInstance The JSValue being tested to determine if it is an instance of constructor.
     
    228228@discussion If you named your function HasInstance, you would declare it like this:
    229229
    230 bool HasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
     230bool HasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
    231231
    232232If your callback were invoked by the JavaScript expression 'someValue instanceof myObject', constructor would be set to myObject and possibleInstance would be set to someValue.
     
    237237*/
    238238typedef bool
    239 (*JSObjectHasInstanceCallback)  (JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
     239(*JSObjectHasInstanceCallback)  (JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
    240240
    241241/*!
    242242@typedef JSObjectConvertToTypeCallback
    243243@abstract The callback invoked when converting an object to a particular JavaScript type.
    244 @param context The current execution context.
     244@param ctx The execution context to use.
    245245@param object The JSObject to convert.
    246246@param type A JSType specifying the JavaScript type to convert to.
     
    249249@discussion If you named your function ConvertToType, you would declare it like this:
    250250
    251 JSValueRef ConvertToType(JSContextRef context, JSObjectRef object, JSType type, JSValueRef* exception);
     251JSValueRef ConvertToType(JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);
    252252
    253253If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class).
     
    256256*/
    257257typedef JSValueRef
    258 (*JSObjectConvertToTypeCallback) (JSContextRef context, JSObjectRef object, JSType type, JSValueRef* exception);
     258(*JSObjectConvertToTypeCallback) (JSContextRef ctx, JSObjectRef object, JSType type, JSValueRef* exception);
    259259
    260260/*!
     
    376376@function
    377377@abstract Creates a JavaScript object with a given class and prototype.
    378 @param context The execution context to use.
     378@param ctx The execution context to use.
    379379@param jsClass The JSClass to assign to the object. Pass NULL to use the default object class.
    380380@param prototype The prototype to assign to the object. Pass NULL to use the default object prototype.
    381381@result A JSObject with the given class and prototype.
    382382*/
    383 JSObjectRef JSObjectMake(JSContextRef context, JSClassRef jsClass, JSValueRef prototype);
     383JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, JSValueRef prototype);
    384384
    385385/*!
    386386@function
    387387@abstract Convenience method for creating a JavaScript function with a given callback as its implementation.
    388 @param context The execution context to use.
     388@param ctx The execution context to use.
    389389@param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
    390390@param callAsFunction The JSObjectCallAsFunctionCallback to invoke when the function is called.
    391391@result A JSObject that is an anonymous function. The object's prototype will be the default function prototype.
    392392*/
    393 JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef context, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction);
     393JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction);
    394394/*!
    395395@function
    396396@abstract Convenience method for creating a JavaScript constructor with a given callback as its implementation.
    397 @param context The execution context to use.
     397@param ctx The execution context to use.
    398398@param callAsConstructor The JSObjectCallAsConstructorCallback to invoke when the constructor is used in a 'new' expression.
    399399@result A JSObject that is a constructor. The object's prototype will be the default object prototype.
    400400*/
    401 JSObjectRef JSObjectMakeConstructor(JSContextRef context, JSObjectCallAsConstructorCallback callAsConstructor);
     401JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSObjectCallAsConstructorCallback callAsConstructor);
    402402
    403403/*!
    404404@function
    405405@abstract Creates a function with a given script as its body.
    406 @param context The execution context to use.
     406@param ctx The execution context to use.
    407407@param name A JSString containing the function's name. This will be used when converting the function to string. Pass NULL to create an anonymous function.
    408408@param parameterCount An integer count of the number of parameter names in parameterNames.
     
    415415@discussion Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.
    416416*/
    417 JSObjectRef JSObjectMakeFunction(JSContextRef context, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
     417JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
    418418
    419419/*!
    420420@function
    421421@abstract Gets an object's prototype.
     422@param ctx  The execution context to use.
    422423@param object A JSObject whose prototype you want to get.
    423424@result A JSValue containing the object's prototype.
    424425*/
    425 JSValueRef JSObjectGetPrototype(JSObjectRef object);
     426JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object);
     427
    426428/*!
    427429@function
    428430@abstract Sets an object's prototype.
     431@param ctx  The execution context to use.
    429432@param object The JSObject whose prototype you want to set.
    430433@param value A JSValue to set as the object's prototype.
    431434*/
    432 void JSObjectSetPrototype(JSObjectRef object, JSValueRef value);
     435void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value);
    433436
    434437/*!
     
    439442@result true if the object has a property whose name matches propertyName, otherwise false.
    440443*/
    441 bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
     444bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
    442445
    443446/*!
    444447@function
    445448@abstract Gets a property from an object.
    446 @param context The execution context to use.
     449@param ctx The execution context to use.
    447450@param object The JSObject whose property you want to get.
    448451@param propertyName A JSString containing the property's name.
     
    450453@result The property's value if object has the property, otherwise the undefined value.
    451454*/
    452 JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
     455JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
    453456
    454457/*!
    455458@function
    456459@abstract Sets a property on an object.
    457 @param context The execution context to use.
     460@param ctx The execution context to use.
    458461@param object The JSObject whose property you want to set.
    459462@param propertyName A JSString containing the property's name.
     
    462465@param attributes A logically ORed set of JSPropertyAttributes to give to the property.
    463466*/
    464 void JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception);
     467void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception);
    465468
    466469/*!
    467470@function
    468471@abstract Deletes a property from an object.
    469 @param context The execution context to use.
     472@param ctx The execution context to use.
    470473@param object The JSObject whose property you want to delete.
    471474@param propertyName A JSString containing the property's name.
     
    473476@result true if the delete operation succeeds, otherwise false (for example, if the property has the kJSPropertyAttributeDontDelete attribute set).
    474477*/
    475 bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
     478bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
    476479
    477480/*!
    478481@function
    479482@abstract Gets a property from an object by numeric index.
    480 @param context The execution context to use.
     483@param ctx The execution context to use.
    481484@param object The JSObject whose property you want to get.
    482485@param propertyIndex The property's name as a number
     
    485488@discussion Calling JSObjectGetPropertyAtIndex is equivalent to calling JSObjectGetProperty with a string containing propertyIndex, but it enables optimized access to JavaScript arrays.
    486489*/
    487 JSValueRef JSObjectGetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception);
     490JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception);
    488491
    489492/*!
    490493@function
    491494@abstract Sets a property on an object by numeric index.
    492 @param context The execution context to use.
     495@param ctx The execution context to use.
    493496@param object The JSObject whose property you want to set.
    494497@param propertyIndex The property's name as a number
     
    497500@discussion Calling JSObjectSetPropertyAtIndex is equivalent to calling JSObjectSetProperty with a string containing propertyIndex, but it enables optimized access to JavaScript arrays.
    498501*/
    499 void JSObjectSetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception);
     502void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception);
    500503
    501504/*!
     
    520523@function
    521524@abstract Tests whether an object can be called as a function.
     525@param ctx  The execution context to use.
    522526@param object The JSObject to test.
    523527@result true if the object can be called as a function, otherwise false.
    524528*/
    525 bool JSObjectIsFunction(JSObjectRef object);
     529bool JSObjectIsFunction(JSContextRef ctx, JSObjectRef object);
     530
    526531/*!
    527532@function
    528533@abstract Calls an object as a function.
    529 @param context The execution context to use.
     534@param ctx The execution context to use.
    530535@param object The JSObject to call as a function.
    531536@param thisObject The object to use as "this," or NULL to use the global object as "this."
     
    535540@result The JSValue that results from calling object as a function, or NULL if an exception is thrown or object is not a function.
    536541*/
    537 JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
     542JSValueRef JSObjectCallAsFunction(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
     543
    538544/*!
    539545@function
    540546@abstract Tests whether an object can be called as a constructor.
     547@param ctx  The execution context to use.
    541548@param object The JSObject to test.
    542549@result true if the object can be called as a constructor, otherwise false.
    543550*/
    544 bool JSObjectIsConstructor(JSObjectRef object);
     551bool JSObjectIsConstructor(JSContextRef ctx, JSObjectRef object);
     552
    545553/*!
    546554@function
    547555@abstract Calls an object as a constructor.
    548 @param context The execution context to use.
     556@param ctx The execution context to use.
    549557@param object The JSObject to call as a constructor.
    550558@param argumentCount An integer count of the number of arguments in arguments.
     
    553561@result The JSObject that results from calling object as a constructor, or NULL if an exception is thrown or object is not a constructor.
    554562*/
    555 JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
     563JSObjectRef JSObjectCallAsConstructor(JSContextRef ctx, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
    556564
    557565/*!
    558566@function
    559567@abstract Get the names of all enumerable properties of an object.
    560 @param context The execution context to use.
     568@param ctx The execution context to use.
    561569@param object The object from which to get property names.
    562570@result A JSPropertyNameArray containing the names of all the object's enumerable properties.
    563571*/
    564 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef context, JSObjectRef object);
     572JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object);
    565573
    566574/*!
  • trunk/JavaScriptCore/API/JSStringRef.cpp

    r15404 r15481  
    3636
    3737using namespace KJS;
    38 
    39 JSValueRef JSValueMakeString(JSStringRef string)
    40 {
    41     JSLock lock;
    42     UString::Rep* rep = toJS(string);
    43     return toRef(jsString(UString(rep)));
    44 }
    4538
    4639JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars)
  • trunk/JavaScriptCore/API/JSValueRef.cpp

    r15443 r15481  
    4040#include <algorithm> // for std::min
    4141
    42 JSType JSValueGetType(JSValueRef value)
     42JSType JSValueGetType(JSContextRef, JSValueRef value)
    4343{
    4444    KJS::JSValue* jsValue = toJS(value);
     
    6464using namespace KJS; // placed here to avoid conflict between KJS::JSType and JSType, above.
    6565
    66 bool JSValueIsUndefined(JSValueRef value)
     66bool JSValueIsUndefined(JSContextRef, JSValueRef value)
    6767{
    6868    JSValue* jsValue = toJS(value);
     
    7070}
    7171
    72 bool JSValueIsNull(JSValueRef value)
     72bool JSValueIsNull(JSContextRef, JSValueRef value)
    7373{
    7474    JSValue* jsValue = toJS(value);
     
    7676}
    7777
    78 bool JSValueIsBoolean(JSValueRef value)
     78bool JSValueIsBoolean(JSContextRef, JSValueRef value)
    7979{
    8080    JSValue* jsValue = toJS(value);
     
    8282}
    8383
    84 bool JSValueIsNumber(JSValueRef value)
     84bool JSValueIsNumber(JSContextRef, JSValueRef value)
    8585{
    8686    JSValue* jsValue = toJS(value);
     
    8888}
    8989
    90 bool JSValueIsString(JSValueRef value)
     90bool JSValueIsString(JSContextRef, JSValueRef value)
    9191{
    9292    JSValue* jsValue = toJS(value);
     
    9494}
    9595
    96 bool JSValueIsObject(JSValueRef value)
     96bool JSValueIsObject(JSContextRef, JSValueRef value)
    9797{
    9898    JSValue* jsValue = toJS(value);
     
    100100}
    101101
    102 bool JSValueIsObjectOfClass(JSValueRef value, JSClassRef jsClass)
     102bool JSValueIsObjectOfClass(JSContextRef, JSValueRef value, JSClassRef jsClass)
    103103{
    104104    JSValue* jsValue = toJS(value);
     
    110110}
    111111
    112 bool JSValueIsEqual(JSContextRef context, JSValueRef a, JSValueRef b, JSValueRef* exception)
    113 {
    114     JSLock lock;
    115     ExecState* exec = toJS(context);
     112bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception)
     113{
     114    JSLock lock;
     115    ExecState* exec = toJS(ctx);
    116116    JSValue* jsA = toJS(a);
    117117    JSValue* jsB = toJS(b);
     
    126126}
    127127
    128 bool JSValueIsStrictEqual(JSContextRef context, JSValueRef a, JSValueRef b)
    129 {
    130     JSLock lock;
    131     ExecState* exec = toJS(context);
     128bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b)
     129{
     130    JSLock lock;
     131    ExecState* exec = toJS(ctx);
    132132    JSValue* jsA = toJS(a);
    133133    JSValue* jsB = toJS(b);
     
    138138}
    139139
    140 bool JSValueIsInstanceOfConstructor(JSContextRef context, JSValueRef value, JSObjectRef constructor, JSValueRef* exception)
    141 {
    142     ExecState* exec = toJS(context);
     140bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception)
     141{
     142    ExecState* exec = toJS(ctx);
    143143    JSValue* jsValue = toJS(value);
    144144    JSObject* jsConstructor = toJS(constructor);
     
    154154}
    155155
    156 JSValueRef JSValueMakeUndefined()
     156JSValueRef JSValueMakeUndefined(JSContextRef)
    157157{
    158158    return toRef(jsUndefined());
    159159}
    160160
    161 JSValueRef JSValueMakeNull()
     161JSValueRef JSValueMakeNull(JSContextRef)
    162162{
    163163    return toRef(jsNull());
    164164}
    165165
    166 JSValueRef JSValueMakeBoolean(bool value)
     166JSValueRef JSValueMakeBoolean(JSContextRef, bool value)
    167167{
    168168    return toRef(jsBoolean(value));
    169169}
    170170
    171 JSValueRef JSValueMakeNumber(double value)
     171JSValueRef JSValueMakeNumber(JSContextRef, double value)
    172172{
    173173    JSLock lock;
     
    175175}
    176176
    177 bool JSValueToBoolean(JSContextRef context, JSValueRef value)
    178 {
    179     ExecState* exec = toJS(context);
     177JSValueRef JSValueMakeString(JSContextRef, JSStringRef string)
     178{
     179    JSLock lock;
     180    UString::Rep* rep = toJS(string);
     181    return toRef(jsString(UString(rep)));
     182}
     183
     184bool JSValueToBoolean(JSContextRef ctx, JSValueRef value)
     185{
     186    ExecState* exec = toJS(ctx);
    180187    JSValue* jsValue = toJS(value);
    181188    return jsValue->toBoolean(exec);
    182189}
    183190
    184 double JSValueToNumber(JSContextRef context, JSValueRef value, JSValueRef* exception)
    185 {
    186     JSLock lock;
    187     JSValue* jsValue = toJS(value);
    188     ExecState* exec = toJS(context);
     191double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
     192{
     193    JSLock lock;
     194    JSValue* jsValue = toJS(value);
     195    ExecState* exec = toJS(ctx);
    189196
    190197    double number = jsValue->toNumber(exec);
     
    198205}
    199206
    200 JSStringRef JSValueToStringCopy(JSContextRef context, JSValueRef value, JSValueRef* exception)
    201 {
    202     JSLock lock;
    203     JSValue* jsValue = toJS(value);
    204     ExecState* exec = toJS(context);
     207JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
     208{
     209    JSLock lock;
     210    JSValue* jsValue = toJS(value);
     211    ExecState* exec = toJS(ctx);
    205212   
    206213    JSStringRef stringRef = toRef(jsValue->toString(exec).rep()->ref());
     
    214221}
    215222
    216 JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value, JSValueRef* exception)
    217 {
    218     JSLock lock;
    219     ExecState* exec = toJS(context);
     223JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception)
     224{
     225    JSLock lock;
     226    ExecState* exec = toJS(ctx);
    220227    JSValue* jsValue = toJS(value);
    221228   
     
    230237}   
    231238
    232 void JSValueProtect(JSValueRef value)
     239void JSValueProtect(JSContextRef, JSValueRef value)
    233240{
    234241    JSLock lock;
     
    237244}
    238245
    239 void JSValueUnprotect(JSValueRef value)
     246void JSValueUnprotect(JSContextRef, JSValueRef value)
    240247{
    241248    JSLock lock;
  • trunk/JavaScriptCore/API/JSValueRef.h

    r15443 r15481  
    5858@function
    5959@abstract       Returns a JavaScript value's type.
     60@param ctx  The execution context to use.
    6061@param value    The JSValue whose type you want to obtain.
    6162@result         A value of type JSType that identifies value's type.
    6263*/
    63 JSType JSValueGetType(JSValueRef value);
     64JSType JSValueGetType(JSContextRef ctx, JSValueRef value);
    6465
    6566/*!
    6667@function
    6768@abstract       Tests whether a JavaScript value's type is the undefined type.
     69@param ctx  The execution context to use.
    6870@param value    The JSValue to test.
    6971@result         true if value's type is the undefined type, otherwise false.
    7072*/
    71 bool JSValueIsUndefined(JSValueRef value);
     73bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value);
    7274
    7375/*!
    7476@function
    7577@abstract       Tests whether a JavaScript value's type is the null type.
     78@param ctx  The execution context to use.
    7679@param value    The JSValue to test.
    7780@result         true if value's type is the null type, otherwise false.
    7881*/
    79 bool JSValueIsNull(JSValueRef value);
     82bool JSValueIsNull(JSContextRef ctx, JSValueRef value);
    8083
    8184/*!
    8285@function
    8386@abstract       Tests whether a JavaScript value's type is the boolean type.
     87@param ctx  The execution context to use.
    8488@param value    The JSValue to test.
    8589@result         true if value's type is the boolean type, otherwise false.
    8690*/
    87 bool JSValueIsBoolean(JSValueRef value);
     91bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value);
    8892
    8993/*!
    9094@function
    9195@abstract       Tests whether a JavaScript value's type is the number type.
     96@param ctx  The execution context to use.
    9297@param value    The JSValue to test.
    9398@result         true if value's type is the number type, otherwise false.
    9499*/
    95 bool JSValueIsNumber(JSValueRef value);
     100bool JSValueIsNumber(JSContextRef ctx, JSValueRef value);
    96101
    97102/*!
    98103@function
    99104@abstract       Tests whether a JavaScript value's type is the string type.
     105@param ctx  The execution context to use.
    100106@param value    The JSValue to test.
    101107@result         true if value's type is the string type, otherwise false.
    102108*/
    103 bool JSValueIsString(JSValueRef value);
     109bool JSValueIsString(JSContextRef ctx, JSValueRef value);
    104110
    105111/*!
    106112@function
    107113@abstract       Tests whether a JavaScript value's type is the object type.
     114@param ctx  The execution context to use.
    108115@param value    The JSValue to test.
    109116@result         true if value's type is the object type, otherwise false.
    110117*/
    111 bool JSValueIsObject(JSValueRef value);
     118bool JSValueIsObject(JSContextRef ctx, JSValueRef value);
    112119
    113120/*!
    114121@function
    115122@abstract       Tests whether a JavaScript value is an object with a given
     123@param ctx  The execution context to use.
    116124 class in its class chain.
    117125@param value    The JSValue to test.
     
    119127 otherwise false.
    120128*/
    121 bool JSValueIsObjectOfClass(JSValueRef value, JSClassRef jsClass);
     129bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass);
    122130
    123131// Comparing values
     
    126134@function
    127135@abstract Tests whether two JavaScript values are equal, as compared by the JS == operator.
    128 @param context The execution context to use.
     136@param ctx The execution context to use.
    129137@param a The first value to test.
    130138@param b The second value to test.
     
    132140@result true if the two values are equal, false if they are not equal or an exception is thrown.
    133141*/
    134 bool JSValueIsEqual(JSContextRef context, JSValueRef a, JSValueRef b, JSValueRef* exception);
     142bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception);
    135143
    136144/*!
    137145@function
    138146@abstract       Tests whether two JavaScript values are strict equal, as compared by the JS === operator.
    139 @param context  The execution context to use.
     147@param ctx  The execution context to use.
    140148@param a        The first value to test.
    141149@param b        The second value to test.
    142150@result         true if the two values are strict equal, otherwise false.
    143151*/
    144 bool JSValueIsStrictEqual(JSContextRef context, JSValueRef a, JSValueRef b);
     152bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b);
    145153
    146154/*!
    147155@function
    148156@abstract Tests whether a JavaScript value is an object constructed by a given constructor, as compared by the JS instanceof operator.
    149 @param context The execution context to use.
     157@param ctx The execution context to use.
    150158@param value The JSValue to test.
    151159@param object The constructor to test against.
     
    153161@result true if value is an object constructed by constructor, as compared by the JS instanceof operator, otherwise false.
    154162*/
    155 bool JSValueIsInstanceOfConstructor(JSContextRef context, JSValueRef value, JSObjectRef constructor, JSValueRef* exception);
     163bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception);
    156164
    157165// Creating values
     
    159167/*!
    160168@function
    161 @abstract   Creates a JavaScript value of the undefined type.
    162 @result     The unique undefined value.
    163 */
    164 JSValueRef JSValueMakeUndefined(void);
    165 
    166 /*!
    167 @function
    168 @abstract   Creates a JavaScript value of the null type.
    169 @result     The unique null value.
    170 */
    171 JSValueRef JSValueMakeNull(void);
     169@abstract       Creates a JavaScript value of the undefined type.
     170@param ctx  The execution context to use.
     171@result         The unique undefined value.
     172*/
     173JSValueRef JSValueMakeUndefined(JSContextRef ctx);
     174
     175/*!
     176@function
     177@abstract       Creates a JavaScript value of the null type.
     178@param ctx  The execution context to use.
     179@result         The unique null value.
     180*/
     181JSValueRef JSValueMakeNull(JSContextRef ctx);
    172182
    173183/*!
    174184@function
    175185@abstract       Creates a JavaScript value of the boolean type.
     186@param ctx  The execution context to use.
    176187@param boolean  The bool to assign to the newly created JSValue.
    177188@result         A JSValue of the boolean type, representing the value of boolean.
    178189*/
    179 
    180 JSValueRef JSValueMakeBoolean(bool boolean);
     190JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool boolean);
    181191
    182192/*!
    183193@function
    184194@abstract       Creates a JavaScript value of the number type.
     195@param ctx  The execution context to use.
    185196@param number   The double to assign to the newly created JSValue.
    186197@result         A JSValue of the number type, representing the value of number.
    187198*/
    188 JSValueRef JSValueMakeNumber(double number);
     199JSValueRef JSValueMakeNumber(JSContextRef ctx, double number);
    189200
    190201/*!
    191202@function
    192203@abstract       Creates a JavaScript value of the string type.
     204@param ctx  The execution context to use.
    193205@param string   The JSString to assign to the newly created JSValue. The
    194206 newly created JSValue retains string, and releases it upon garbage collection.
    195207@result         A JSValue of the string type, representing the value of string.
    196208*/
    197 JSValueRef JSValueMakeString(JSStringRef string);
     209JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string);
    198210
    199211// Converting to primitive values
     
    202214@function
    203215@abstract       Converts a JavaScript value to boolean and returns the resulting boolean.
    204 @param context  The execution context to use.
     216@param ctx  The execution context to use.
    205217@param value    The JSValue to convert.
    206218@result         The boolean result of conversion.
    207219*/
    208 bool JSValueToBoolean(JSContextRef context, JSValueRef value);
     220bool JSValueToBoolean(JSContextRef ctx, JSValueRef value);
    209221
    210222/*!
    211223@function
    212224@abstract       Converts a JavaScript value to number and returns the resulting number.
    213 @param context  The execution context to use.
     225@param ctx  The execution context to use.
    214226@param value    The JSValue to convert.
    215227@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
    216228@result         The numeric result of conversion, or NaN if an exception is thrown.
    217229*/
    218 double JSValueToNumber(JSContextRef context, JSValueRef value, JSValueRef* exception);
     230double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception);
    219231
    220232/*!
    221233@function
    222234@abstract       Converts a JavaScript value to string and copies the result into a JavaScript string.
    223 @param context  The execution context to use.
     235@param ctx  The execution context to use.
    224236@param value    The JSValue to convert.
    225237@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
    226238@result         A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule.
    227239*/
    228 JSStringRef JSValueToStringCopy(JSContextRef context, JSValueRef value, JSValueRef* exception);
     240JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception);
    229241
    230242/*!
    231243@function
    232244@abstract Converts a JavaScript value to object and returns the resulting object.
    233 @param context  The execution context to use.
     245@param ctx  The execution context to use.
    234246@param value    The JSValue to convert.
    235247@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
    236248@result         The JSObject result of conversion, or NULL if an exception is thrown.
    237249*/
    238 JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value, JSValueRef* exception);
     250JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception);
    239251
    240252// Garbage collection
     
    242254@function
    243255@abstract       Protects a JavaScript value from garbage collection.
     256@param ctx  The execution context to use.
    244257@param value    The JSValue to protect.
    245258@discussion     A value may be protected multiple times and must be unprotected an
    246259 equal number of times before becoming eligible for garbage collection.
    247260*/
    248 void JSValueProtect(JSValueRef value);
     261void JSValueProtect(JSContextRef ctx, JSValueRef value);
    249262
    250263/*!
    251264@function
    252265@abstract       Unprotects a JavaScript value from garbage collection.
     266@param ctx      The execution context to use.
    253267@param value    The JSValue to unprotect.
    254268@discussion     A value may be protected multiple times and must be unprotected an
    255269 equal number of times before becoming eligible for garbage collection.
    256270*/
    257 void JSValueUnprotect(JSValueRef value);
     271void JSValueUnprotect(JSContextRef ctx, JSValueRef value);
    258272
    259273#ifdef __cplusplus
  • trunk/JavaScriptCore/API/minidom.c

    r15480 r15481  
    8989    }
    9090   
    91     return JSValueMakeUndefined();
     91    return JSValueMakeUndefined(context);
    9292}
    9393
  • trunk/JavaScriptCore/API/testapi.c

    r15480 r15481  
    130130   
    131131    if (JSStringIsEqualToUTF8CString(propertyName, "alwaysOne")) {
    132         return JSValueMakeNumber(1);
     132        return JSValueMakeNumber(context, 1);
    133133    }
    134134   
    135135    if (JSStringIsEqualToUTF8CString(propertyName, "myPropertyName")) {
    136         return JSValueMakeNumber(1);
     136        return JSValueMakeNumber(context, 1);
    137137    }
    138138
    139139    if (JSStringIsEqualToUTF8CString(propertyName, "cantFind")) {
    140         return JSValueMakeUndefined();
     140        return JSValueMakeUndefined(context);
    141141    }
    142142   
    143143    if (JSStringIsEqualToUTF8CString(propertyName, "0")) {
    144         *exception = JSValueMakeNumber(1);
    145         return JSValueMakeNumber(1);
     144        *exception = JSValueMakeNumber(context, 1);
     145        return JSValueMakeNumber(context, 1);
    146146    }
    147147   
     
    170170   
    171171    if (JSStringIsEqualToUTF8CString(propertyName, "throwOnDelete")) {
    172         *exception = JSValueMakeNumber(2);
     172        *exception = JSValueMakeNumber(context, 2);
    173173        return false;
    174174    }
     
    198198    UNUSED_PARAM(thisObject);
    199199
    200     if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(0)))
    201         return JSValueMakeNumber(1);
    202    
    203     return JSValueMakeUndefined();
     200    if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(context, 0)))
     201        return JSValueMakeNumber(context, 1);
     202   
     203    return JSValueMakeUndefined(context);
    204204}
    205205
     
    209209    UNUSED_PARAM(object);
    210210
    211     if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(0)))
    212         return JSValueToObject(context, JSValueMakeNumber(1), NULL);
    213    
    214     return JSValueToObject(context, JSValueMakeNumber(0), NULL);
     211    if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(context, 0)))
     212        return JSValueToObject(context, JSValueMakeNumber(context, 1), NULL);
     213   
     214    return JSValueToObject(context, JSValueMakeNumber(context, 0), NULL);
    215215}
    216216
     
    233233    switch (type) {
    234234    case kJSTypeNumber:
    235         return JSValueMakeNumber(1);
     235        return JSValueMakeNumber(context, 1);
    236236    default:
    237237        break;
     
    305305    }
    306306   
    307     return JSValueMakeUndefined();
     307    return JSValueMakeUndefined(context);
    308308}
    309309
     
    332332   
    333333    JSObjectRef globalObject = JSContextGetGlobalObject(context);
    334     assert(JSValueIsObject(globalObject));
    335    
    336     JSValueRef jsUndefined = JSValueMakeUndefined();
    337     JSValueRef jsNull = JSValueMakeNull();
    338     JSValueRef jsTrue = JSValueMakeBoolean(true);
    339     JSValueRef jsFalse = JSValueMakeBoolean(false);
    340     JSValueRef jsZero = JSValueMakeNumber(0);
    341     JSValueRef jsOne = JSValueMakeNumber(1);
    342     JSValueRef jsOneThird = JSValueMakeNumber(1.0 / 3.0);
    343     JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, JSValueMakeNull());
     334    assert(JSValueIsObject(context, globalObject));
     335   
     336    JSValueRef jsUndefined = JSValueMakeUndefined(context);
     337    JSValueRef jsNull = JSValueMakeNull(context);
     338    JSValueRef jsTrue = JSValueMakeBoolean(context, true);
     339    JSValueRef jsFalse = JSValueMakeBoolean(context, false);
     340    JSValueRef jsZero = JSValueMakeNumber(context, 0);
     341    JSValueRef jsOne = JSValueMakeNumber(context, 1);
     342    JSValueRef jsOneThird = JSValueMakeNumber(context, 1.0 / 3.0);
     343    JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, JSValueMakeNull(context));
    344344
    345345    // FIXME: test funny utf8 characters
    346346    JSStringRef jsEmptyIString = JSStringCreateWithUTF8CString("");
    347     JSValueRef jsEmptyString = JSValueMakeString(jsEmptyIString);
     347    JSValueRef jsEmptyString = JSValueMakeString(context, jsEmptyIString);
    348348   
    349349    JSStringRef jsOneIString = JSStringCreateWithUTF8CString("1");
    350     JSValueRef jsOneString = JSValueMakeString(jsOneIString);
     350    JSValueRef jsOneString = JSValueMakeString(context, jsOneIString);
    351351
    352352#if defined(__APPLE__)
     
    360360
    361361    JSStringRef jsCFIString = JSStringCreateWithCFString(cfString);
    362     JSValueRef jsCFString = JSValueMakeString(jsCFIString);
     362    JSValueRef jsCFString = JSValueMakeString(context, jsCFIString);
    363363   
    364364    CFStringRef cfEmptyString = CFStringCreateWithCString(kCFAllocatorDefault, "", kCFStringEncodingUTF8);
    365365   
    366366    JSStringRef jsCFEmptyIString = JSStringCreateWithCFString(cfEmptyString);
    367     JSValueRef jsCFEmptyString = JSValueMakeString(jsCFEmptyIString);
     367    JSValueRef jsCFEmptyString = JSValueMakeString(context, jsCFEmptyIString);
    368368
    369369    CFIndex cfStringLength = CFStringGetLength(cfString);
     
    373373                          buffer);
    374374    JSStringRef jsCFIStringWithCharacters = JSStringCreateWithCharacters(buffer, cfStringLength);
    375     JSValueRef jsCFStringWithCharacters = JSValueMakeString(jsCFIStringWithCharacters);
     375    JSValueRef jsCFStringWithCharacters = JSValueMakeString(context, jsCFIStringWithCharacters);
    376376   
    377377    JSStringRef jsCFEmptyIStringWithCharacters = JSStringCreateWithCharacters(buffer, CFStringGetLength(cfEmptyString));
    378     JSValueRef jsCFEmptyStringWithCharacters = JSValueMakeString(jsCFEmptyIStringWithCharacters);
    379 #endif // __APPLE__
    380 
    381     assert(JSValueGetType(jsUndefined) == kJSTypeUndefined);
    382     assert(JSValueGetType(jsNull) == kJSTypeNull);
    383     assert(JSValueGetType(jsTrue) == kJSTypeBoolean);
    384     assert(JSValueGetType(jsFalse) == kJSTypeBoolean);
    385     assert(JSValueGetType(jsZero) == kJSTypeNumber);
    386     assert(JSValueGetType(jsOne) == kJSTypeNumber);
    387     assert(JSValueGetType(jsOneThird) == kJSTypeNumber);
    388     assert(JSValueGetType(jsEmptyString) == kJSTypeString);
    389     assert(JSValueGetType(jsOneString) == kJSTypeString);
    390 #if defined(__APPLE__)
    391     assert(JSValueGetType(jsCFString) == kJSTypeString);
    392     assert(JSValueGetType(jsCFStringWithCharacters) == kJSTypeString);
    393     assert(JSValueGetType(jsCFEmptyString) == kJSTypeString);
    394     assert(JSValueGetType(jsCFEmptyStringWithCharacters) == kJSTypeString);
     378    JSValueRef jsCFEmptyStringWithCharacters = JSValueMakeString(context, jsCFEmptyIStringWithCharacters);
     379#endif // __APPLE__
     380
     381    assert(JSValueGetType(context, jsUndefined) == kJSTypeUndefined);
     382    assert(JSValueGetType(context, jsNull) == kJSTypeNull);
     383    assert(JSValueGetType(context, jsTrue) == kJSTypeBoolean);
     384    assert(JSValueGetType(context, jsFalse) == kJSTypeBoolean);
     385    assert(JSValueGetType(context, jsZero) == kJSTypeNumber);
     386    assert(JSValueGetType(context, jsOne) == kJSTypeNumber);
     387    assert(JSValueGetType(context, jsOneThird) == kJSTypeNumber);
     388    assert(JSValueGetType(context, jsEmptyString) == kJSTypeString);
     389    assert(JSValueGetType(context, jsOneString) == kJSTypeString);
     390#if defined(__APPLE__)
     391    assert(JSValueGetType(context, jsCFString) == kJSTypeString);
     392    assert(JSValueGetType(context, jsCFStringWithCharacters) == kJSTypeString);
     393    assert(JSValueGetType(context, jsCFEmptyString) == kJSTypeString);
     394    assert(JSValueGetType(context, jsCFEmptyStringWithCharacters) == kJSTypeString);
    395395#endif // __APPLE__
    396396
     
    419419   
    420420    exception = NULL;
    421     assert(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber(1), &exception));
     421    assert(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber(context, 1), &exception));
    422422    assert(exception);
    423423   
     
    510510   
    511511    jsGlobalValue = JSObjectMake(context, NULL, NULL);
    512     JSValueProtect(jsGlobalValue);
    513     JSGarbageCollect();
    514     assert(JSValueIsObject(jsGlobalValue));
    515     JSValueUnprotect(jsGlobalValue);
     512    JSValueProtect(context, jsGlobalValue);
     513    JSGarbageCollect(context);
     514    assert(JSValueIsObject(context, jsGlobalValue));
     515    JSValueUnprotect(context, jsGlobalValue);
    516516
    517517    JSStringRef goodSyntax = JSStringCreateWithUTF8CString("x = 1;");
     
    532532    result = JSEvaluateScript(context, badSyntax, NULL, NULL, 1, &exception);
    533533    assert(!result);
    534     assert(JSValueIsObject(exception));
     534    assert(JSValueIsObject(context, exception));
    535535   
    536536    JSStringRef array = JSStringCreateWithUTF8CString("Array");
     
    539539    result = JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, NULL);
    540540    assert(result);
    541     assert(JSValueIsObject(result));
     541    assert(JSValueIsObject(context, result));
    542542    assert(JSValueIsInstanceOfConstructor(context, result, arrayConstructor, NULL));
    543     assert(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull(), arrayConstructor, NULL));
     543    assert(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull(context), arrayConstructor, NULL));
    544544
    545545    o = JSValueToObject(context, result, NULL);
    546546    exception = NULL;
    547     assert(JSValueIsUndefined(JSObjectGetPropertyAtIndex(context, o, 0, &exception)));
     547    assert(JSValueIsUndefined(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception)));
    548548    assert(!exception);
    549549   
    550     JSObjectSetPropertyAtIndex(context, o, 0, JSValueMakeNumber(1), &exception);
     550    JSObjectSetPropertyAtIndex(context, o, 0, JSValueMakeNumber(context, 1), &exception);
    551551    assert(!exception);
    552552   
     
    562562    JSStringRef line = JSStringCreateWithUTF8CString("line");
    563563    assert(!JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception));
    564     assert(JSValueIsObject(exception));
     564    assert(JSValueIsObject(context, exception));
    565565    v = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), line, NULL);
    566566    assertEqualsAsNumber(v, 2); // FIXME: Lexer::setCode bumps startingLineNumber by 1 -- we need to change internal callers so that it doesn't have to (saying '0' to mean '1' in the API would be really confusing -- it's really confusing internally, in fact)
     
    573573    JSStringRelease(functionBody);
    574574    assert(!exception);
    575     assert(JSObjectIsFunction(function));
     575    assert(JSObjectIsFunction(context, function));
    576576    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
    577577    assert(v);
     
    583583    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, &exception);
    584584    assert(v && !exception);
    585     assert(JSValueIsUndefined(v));
     585    assert(JSValueIsUndefined(context, v));
    586586   
    587587    exception = NULL;
     
    592592    function = JSObjectMakeFunction(context, foo, 1, argumentNames, functionBody, NULL, 1, &exception);
    593593    assert(function && !exception);
    594     JSValueRef arguments[] = { JSValueMakeNumber(2) };
     594    JSValueRef arguments[] = { JSValueMakeNumber(context, 2) };
    595595    v = JSObjectCallAsFunction(context, function, NULL, 1, arguments, &exception);
    596596    JSStringRelease(foo);
     
    598598   
    599599    string = JSValueToStringCopy(context, function, NULL);
    600     assertEqualsAsUTF8String(JSValueMakeString(string), "function foo(foo) \n{\n  return foo;\n}");
     600    assertEqualsAsUTF8String(JSValueMakeString(context, string), "function foo(foo) \n{\n  return foo;\n}");
    601601    JSStringRelease(string);
    602602
     
    618618   
    619619    o = JSObjectMake(context, NULL, NULL);
    620     JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber(1), kJSPropertyAttributeNone, NULL);
    621     JSObjectSetProperty(context, o, jsCFIString,  JSValueMakeNumber(1), kJSPropertyAttributeDontEnum, NULL);
     620    JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber(context, 1), kJSPropertyAttributeNone, NULL);
     621    JSObjectSetProperty(context, o, jsCFIString,  JSValueMakeNumber(context, 1), kJSPropertyAttributeDontEnum, NULL);
    622622    JSPropertyNameArrayRef nameArray = JSObjectCopyPropertyNames(context, o);
    623623    size_t expectedCount = JSPropertyNameArrayGetCount(nameArray);
     
    645645    JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8);
    646646    result = JSEvaluateScript(context, script, NULL, NULL, 1, &exception);
    647     if (JSValueIsUndefined(result))
     647    if (JSValueIsUndefined(context, result))
    648648        printf("PASS: Test script executed successfully.\n");
    649649    else {
     
    661661    JSObjectMake(context, MyObject_class(context), 0);
    662662    JSObjectMake(context, MyObject_class(context), 0);
    663     JSGarbageCollect();
     663    JSGarbageCollect(context);
    664664    assert(didFinalize);
    665665
Note: See TracChangeset for help on using the changeset viewer.