Changeset 15225 in webkit for trunk/JavaScriptCore


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

Reviewed by Maciej.


  • Standardized which functions take a JSContext as an argument. The rule is: if you might execute JavaScript, you take a JSContext, otherwise you don't.


The FIXME in JSObjectRef.h requires refactoring some parts of Interpreter,
but not API changes, so I'm putting it off until later.

  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::JSCallbackObject): (KJS::JSCallbackObject::init):
  • API/JSCallbackObject.h:
  • API/JSContextRef.cpp: (JSContextCreate):
  • API/JSContextRef.h:
  • API/JSObjectRef.cpp: (JSObjectMake): (JSPropertyEnumeratorGetNext):
  • API/JSObjectRef.h:
  • API/testapi.c: (MyObject_initialize): (main):
  • JavaScriptCore.exp:
  • kjs/array_object.cpp: (ArrayInstance::setLength): (ArrayInstance::pushUndefinedObjectsToEnd):
  • kjs/nodes.cpp: (ForInNode::execute):
  • kjs/reference.cpp: (KJS::Reference::getPropertyName): (KJS::Reference::getValue):
  • kjs/reference.h:
  • kjs/scope_chain.cpp: (KJS::ScopeChain::print):
Location:
trunk/JavaScriptCore
Files:
14 edited

Legend:

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

    r15224 r15225  
    3838const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0, 0 };
    3939
    40 JSCallbackObject::JSCallbackObject(JSClassRef jsClass)
     40JSCallbackObject::JSCallbackObject(JSContextRef context, JSClassRef jsClass)
    4141    : JSObject()
    4242{
    43     init(jsClass);
    44 }
    45 
    46 JSCallbackObject::JSCallbackObject(JSClassRef jsClass, JSObject* prototype)
     43    init(context, jsClass);
     44}
     45
     46JSCallbackObject::JSCallbackObject(JSContextRef context, JSClassRef jsClass, JSObject* prototype)
    4747    : JSObject(prototype)
    4848{
    49     init(jsClass);
    50 }
    51 
    52 void JSCallbackObject::init(JSClassRef jsClass)
     49    init(context, jsClass);
     50}
     51
     52void JSCallbackObject::init(JSContextRef context, JSClassRef jsClass)
    5353{
    5454    m_privateData = 0;
     
    5959    do {
    6060        if (JSInitializeCallback initialize = jsClass->callbacks.initialize)
    61             initialize(thisRef);
     61            initialize(context, thisRef);
    6262    } while ((jsClass = jsClass->parent));
    6363}
  • trunk/JavaScriptCore/API/JSCallbackObject.h

    r15133 r15225  
    3737{
    3838public:
    39     JSCallbackObject(JSClassRef globalObjectClass);
    40     JSCallbackObject(JSClassRef globalObjectClass, JSObject* prototype);
     39    JSCallbackObject(JSContextRef, JSClassRef);
     40    JSCallbackObject(JSContextRef, JSClassRef, JSObject* prototype);
    4141    virtual ~JSCallbackObject();
    4242       
     
    7676    JSCallbackObject(const JSCallbackObject&);
    7777
    78     void init(JSClassRef jsClass);
     78    void init(JSContextRef, JSClassRef);
    7979   
    8080    static JSValue* cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r15224 r15225  
    4141    JSObject* globalObject;
    4242    if (globalObjectClass)
    43         globalObject = new JSCallbackObject(globalObjectClass);
     43        // FIXME: We need to pass a real ExecState here to support an initialize callback in globalObjectClass
     44        globalObject = new JSCallbackObject(0, globalObjectClass);
    4445    else
    4546        globalObject = new JSObject();
  • trunk/JavaScriptCore/API/JSContextRef.h

    r15224 r15225  
    111111}
    112112#endif
    113        
     113
    114114#endif // JSContextRef_h
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r15224 r15225  
    5454        return toRef(new JSObject(jsPrototype)); // slightly more efficient
    5555    else
    56         return toRef(new JSCallbackObject(jsClass, jsPrototype));
     56        return toRef(new JSCallbackObject(context, jsClass, jsPrototype));
    5757}
    5858
     
    282282}
    283283
    284 JSStringBufferRef JSPropertyEnumeratorGetNext(JSContextRef context, JSPropertyEnumeratorRef enumerator)
    285 {
    286     ExecState* exec = toJS(context);
     284JSStringBufferRef JSPropertyEnumeratorGetNext(JSPropertyEnumeratorRef enumerator)
     285{
    287286    ReferenceListIterator& iterator = enumerator->iterator;
    288287    if (iterator != enumerator->list.end()) {
    289         JSStringBufferRef result = toRef(iterator->getPropertyName(exec).ustring().rep());
     288        JSStringBufferRef result = toRef(iterator->getPropertyName().ustring().rep());
    290289        iterator++;
    291290        return result;
  • trunk/JavaScriptCore/API/JSObjectRef.h

    r15224 r15225  
    5858@typedef JSInitializeCallback
    5959@abstract The callback invoked when an object is first created.
     60@param context The execution context to use.
    6061@param object The JSObject being created.
    6162@discussion If you named your function Initialize, you would declare it like this:
    6263
    63 void Initialize(JSObjectRef object);
    64 */
    65 
    66 // FIXME: Needs to take a context argument, but can't because no context exists when we're creating the global object
     64void Initialize(JSContextRef context, JSObjectRef object);
     65*/
    6766typedef void
    68 (*JSInitializeCallback)         (JSObjectRef object);
     67(*JSInitializeCallback)         (JSContextRef context, JSObjectRef object);
    6968
    7069/*!
     
    493492@function
    494493@abstract Gets a property enumerator's next property.
    495 @param context The execution context to use.
    496494@param enumerator The JSPropertyEnumerator whose next property you want to get.
    497495@result A JSStringBuffer containing the property's name, or NULL if all properties have been enumerated.
    498496*/
    499 JSStringBufferRef JSPropertyEnumeratorGetNext(JSContextRef context, JSPropertyEnumeratorRef enumerator);
     497JSStringBufferRef JSPropertyEnumeratorGetNext(JSPropertyEnumeratorRef enumerator);
    500498
    501499/*!
  • trunk/JavaScriptCore/API/testapi.c

    r15224 r15225  
    123123
    124124static bool didInitialize = false;
    125 static void MyObject_initialize(JSObjectRef object)
     125static void MyObject_initialize(JSContextRef context, JSObjectRef object)
    126126{
    127127    UNUSED_PARAM(context);
     
    594594    JSPropertyEnumeratorRef enumerator = JSObjectCreatePropertyEnumerator(context, o);
    595595    int count = 0;
    596     while (JSPropertyEnumeratorGetNext(context, enumerator))
     596    while (JSPropertyEnumeratorGetNext(enumerator))
    597597        ++count;
    598598    JSPropertyEnumeratorRelease(enumerator);
  • trunk/JavaScriptCore/ChangeLog

    r15224 r15225  
     12006-07-07  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Maciej.
     4       
     5        - Standardized which functions take a JSContext as an argument. The rule is:
     6        if you might execute JavaScript, you take a JSContext, otherwise you don't.
     7       
     8        The FIXME in JSObjectRef.h requires refactoring some parts of Interpreter,
     9        but not API changes, so I'm putting it off until later.
     10
     11        * API/JSCallbackObject.cpp:
     12        (KJS::JSCallbackObject::JSCallbackObject):
     13        (KJS::JSCallbackObject::init):
     14        * API/JSCallbackObject.h:
     15        * API/JSContextRef.cpp:
     16        (JSContextCreate):
     17        * API/JSContextRef.h:
     18        * API/JSObjectRef.cpp:
     19        (JSObjectMake):
     20        (JSPropertyEnumeratorGetNext):
     21        * API/JSObjectRef.h:
     22        * API/testapi.c:
     23        (MyObject_initialize):
     24        (main):
     25        * JavaScriptCore.exp:
     26        * kjs/array_object.cpp:
     27        (ArrayInstance::setLength):
     28        (ArrayInstance::pushUndefinedObjectsToEnd):
     29        * kjs/nodes.cpp:
     30        (ForInNode::execute):
     31        * kjs/reference.cpp:
     32        (KJS::Reference::getPropertyName):
     33        (KJS::Reference::getValue):
     34        * kjs/reference.h:
     35        * kjs/scope_chain.cpp:
     36        (KJS::ScopeChain::print):
     37
    1382006-07-06  Geoffrey Garen  <[email protected]>
    239
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r15224 r15225  
    262262__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
    263263__ZNK3KJS9ExecState18lexicalInterpreterEv
    264 __ZNK3KJS9Reference15getPropertyNameEPNS_9ExecStateE
     264__ZNK3KJS9Reference15getPropertyNameEv
    265265__ZTVN3KJS19InternalFunctionImpE
    266266__ZTVN3KJS8JSObjectE
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r15125 r15225  
    252252      Reference ref = it++;
    253253      bool ok;
    254       unsigned index = ref.getPropertyName(exec).toArrayIndex(&ok);
     254      unsigned index = ref.getPropertyName().toArrayIndex(&ok);
    255255      if (ok && index > newLength) {
    256256        ref.deleteValue(exec);
     
    374374      Reference ref = it++;
    375375      storage[o] = ref.getValue(exec);
    376       JSObject::deleteProperty(exec, ref.getPropertyName(exec));
     376      JSObject::deleteProperty(exec, ref.getPropertyName());
    377377      o++;
    378378    }
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r15224 r15225  
    18841884
    18851885  while (propIt != propertyList.end()) {
    1886     Identifier name = propIt->getPropertyName(exec);
     1886    Identifier name = propIt->getPropertyName();
    18871887    if (!v->hasProperty(exec, name)) {
    18881888      propIt++;
  • trunk/JavaScriptCore/kjs/reference.cpp

    r13015 r15225  
    4444}
    4545
    46 Identifier Reference::getPropertyName(ExecState*) const
     46Identifier Reference::getPropertyName() const
    4747{
    4848  if (propertyNameIsNumber && prop.isNull())
     
    5656  if (!o || !o->isObject()) {
    5757    if (!o || o->isNull())
    58       return throwError(exec, ReferenceError, "Can't find variable: " + getPropertyName(exec).ustring());
     58      return throwError(exec, ReferenceError, "Can't find variable: " + getPropertyName().ustring());
    5959    return throwError(exec, ReferenceError, "Base is not an object");
    6060  }
  • trunk/JavaScriptCore/kjs/reference.h

    r13821 r15225  
    4141     * (ECMA 8.7)
    4242     */
    43     Identifier getPropertyName(ExecState *exec) const;
     43    Identifier getPropertyName() const;
    4444
    4545    /**
  • trunk/JavaScriptCore/kjs/scope_chain.cpp

    r14951 r15225  
    4949        fprintf(stderr, "----- [scope %p] -----\n", o);
    5050        for (ReferenceListIterator propIter = propertyList.begin(); propIter != propEnd; propIter++) {
    51             Identifier name = propIter->getPropertyName(exec);
     51            Identifier name = propIter->getPropertyName();
    5252            fprintf(stderr, "%s, ", name.ascii());
    5353        }
Note: See TracChangeset for help on using the changeset viewer.