Ignore:
Timestamp:
Jul 17, 2006, 1:20:28 AM (19 years ago)
Author:
ggaren
Message:

Reviewed by Maciej.


  • Changed JSObjectMakeConstructor to JSObjectMakeConstructorWithCallback, to match JSObjectMakeFunctionWithCallback.


  • Added prototype parameter, so the generated constructor automatically works with hasInstance / instanceof


  • Moved hasInstance implementation from InternalFunctionImp to JSObject so that subclasses can inherit it without inheriting function-related baggage. More refactoring here would be good, but this seems like a good short-term solution.

(KJS::JSCallbackFunction::implementsHasInstance): override and return false,
because callback functions aren't constructors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/internal.cpp

    r14834 r15482  
    217217}
    218218
    219 bool InternalFunctionImp::hasInstance(ExecState *exec, JSValue *value)
    220 {
    221   if (!value->isObject())
    222     return false;
    223 
    224   JSValue *prot = get(exec,prototypePropertyName);
    225   if (!prot->isObject() && !prot->isNull()) {
    226     throwError(exec, TypeError, "Invalid prototype encountered in instanceof operation.");
    227     return false;
    228   }
    229 
    230   JSObject *v = static_cast<JSObject *>(value);
    231   while ((v = v->prototype()->getObject())) {
    232     if (v == prot)
    233       return true;
    234   }
    235   return false;
    236 }
    237 
    238219// ------------------------------ global functions -----------------------------
    239220
Note: See TracChangeset for help on using the changeset viewer.