Changeset 15384 in webkit for trunk/JavaScriptCore/API/testapi.c


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/testapi.c

    r15376 r15384  
    201201}
    202202
     203static bool MyObject_hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleValue, JSValueRef* exception)
     204{
     205    UNUSED_PARAM(context);
     206
     207    JSStringRef numberString = JSStringCreateWithUTF8CString("Number");
     208    JSObjectRef numberConstructor = JSValueToObject(context, JSObjectGetProperty(context, JSContextGetGlobalObject(context), numberString));
     209    JSStringRelease(numberString);
     210
     211    return JSValueIsInstanceOfConstructor(context, possibleValue, numberConstructor);
     212}
     213
    203214static JSValueRef MyObject_convertToType(JSContextRef context, JSObjectRef object, JSType type, JSValueRef* exception)
    204215{
     
    229240JSObjectCallbacks MyObject_callbacks = {
    230241    0,
    231     &MyObject_initialize,
    232     &MyObject_finalize,
    233     &MyObject_hasProperty,
    234     &MyObject_getProperty,
    235     &MyObject_setProperty,
    236     &MyObject_deleteProperty,
    237     &MyObject_getPropertyList,
    238     &MyObject_callAsFunction,
    239     &MyObject_callAsConstructor,
    240     &MyObject_convertToType,
     242    MyObject_initialize,
     243    MyObject_finalize,
     244    MyObject_hasProperty,
     245    MyObject_getProperty,
     246    MyObject_setProperty,
     247    MyObject_deleteProperty,
     248    MyObject_getPropertyList,
     249    MyObject_callAsFunction,
     250    MyObject_callAsConstructor,
     251    MyObject_hasInstance,
     252    MyObject_convertToType,
    241253};
    242254
Note: See TracChangeset for help on using the changeset viewer.