Ignore:
Timestamp:
Jul 12, 2006, 2:55:55 AM (19 years ago)
Author:
mjs
Message:

4eviewed by Geoff.


  • add handling of hasInstance callback for API objects
  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::implementsHasInstance): Check if callback is present. (KJS::JSCallbackObject::hasInstance): Invoke appropriate callback.
  • API/JSCallbackObject.h:
  • API/JSClassRef.cpp:
  • API/JSObjectRef.h:
  • API/testapi.c: (MyObject_hasInstance): Test case; should match what construct would do.
  • API/testapi.js:
File:
1 edited

Legend:

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

    r15376 r15384  
    236236}
    237237
     238bool JSCallbackObject::implementsHasInstance() const
     239{
     240    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent)
     241        if (jsClass->callbacks.hasInstance)
     242            return true;
     243
     244    return false;
     245}
     246
     247bool JSCallbackObject::hasInstance(ExecState *exec, JSValue *value)
     248{
     249    JSContextRef execRef = toRef(exec);
     250    JSObjectRef thisRef = toRef(this);
     251
     252    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent)
     253        if (JSObjectHasInstanceCallback hasInstance = jsClass->callbacks.hasInstance)
     254            return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot()));
     255
     256    ASSERT(0); // implementsHasInstance should prevent us from reaching here
     257    return 0;
     258}
     259
     260
    238261bool JSCallbackObject::implementsCall() const
    239262{
Note: See TracChangeset for help on using the changeset viewer.