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):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.