Changeset 15133 in webkit


Ignore:
Timestamp:
Jul 1, 2006 9:06:07 PM (18 years ago)
Author:
ggaren
Message:

Reviewed by Maciej.


  • Phase 2 in the JS API.


  • Added support for specifying static tables of values -- this should obviate the need for using complicated callbacks for most lookups.


  • API objects are now created with classes (JSClassRef) -- in order to support static values, and in order to prevent API objects from storing their data inline, and thus falling into the oversized (read: slow and prone to giving Maciej the frowny face) heap.


  • Added two specialized JSObject subclasses -- JSCallbackFunction and JSCallbackConstructor -- to allow JSFunctionMake and JSConstructorMake to continue to work with the new class model. Another solution to this problem would be to create a custom class object for each function and constructor you make. This solution is more code but also more efficient.


  • Substantially beefed up the minidom example to demonstrate and test a lot of these techniques. Its output is still pretty haphazard, though.


  • Gave the <kjs/ preface to some includes -- I'm told this matters to building on some versions of Linux.


  • Implemented JSValueIsInstanceOf and JSValueIsObjectOfClass


  • Removed GetDescription callback. Something in the class datastructure should take care of this.
  • API/JSBase.h:
  • API/JSCallbackConstructor.cpp: Added. (KJS::): (KJS::JSCallbackConstructor::JSCallbackConstructor): (KJS::JSCallbackConstructor::implementsConstruct): (KJS::JSCallbackConstructor::construct): (KJS::JSCallbackConstructor::setPrivate): (KJS::JSCallbackConstructor::getPrivate):
  • API/JSCallbackConstructor.h: Added. (KJS::JSCallbackConstructor::classInfo):
  • API/JSCallbackFunction.cpp: Added. (KJS::): (KJS::JSCallbackFunction::JSCallbackFunction): (KJS::JSCallbackFunction::implementsCall): (KJS::JSCallbackFunction::callAsFunction): (KJS::JSCallbackFunction::setPrivate): (KJS::JSCallbackFunction::getPrivate):
  • API/JSCallbackFunction.h: Added. (KJS::JSCallbackFunction::classInfo):
  • API/JSCallbackObject.cpp: (KJS::): (KJS::JSCallbackObject::JSCallbackObject): (KJS::JSCallbackObject::init): (KJS::JSCallbackObject::~JSCallbackObject): (KJS::JSCallbackObject::className): (KJS::JSCallbackObject::getOwnPropertySlot): (KJS::JSCallbackObject::put): (KJS::JSCallbackObject::deleteProperty): (KJS::JSCallbackObject::implementsConstruct): (KJS::JSCallbackObject::construct): (KJS::JSCallbackObject::implementsCall): (KJS::JSCallbackObject::callAsFunction): (KJS::JSCallbackObject::getPropertyList): (KJS::JSCallbackObject::toBoolean): (KJS::JSCallbackObject::toNumber): (KJS::JSCallbackObject::toString): (KJS::JSCallbackObject::inherits): (KJS::JSCallbackObject::staticValueGetter): (KJS::JSCallbackObject::staticFunctionGetter): (KJS::JSCallbackObject::callbackGetter):
  • API/JSCallbackObject.h:
  • API/JSCharBufferRef.cpp:
  • API/JSClassRef.cpp: Added. (JSClassCreate): (JSClassRetain): (JSClassRelease):
  • API/JSClassRef.h: Added. (StaticValueEntry::StaticValueEntry): (StaticFunctionEntry::StaticFunctionEntry): (JSClass::JSClass):
  • API/JSContextRef.cpp: (JSContextCreate): (JSEvaluate):
  • API/JSContextRef.h:
  • API/JSNode.c: Added. (JSNodePrototype_appendChild): (JSNodePrototype_removeChild): (JSNodePrototype_replaceChild): (JSNodePrototype_class): (JSNode_getNodeType): (JSNode_getChildNodes): (JSNode_getFirstChild): (JSNode_finalize): (JSNode_class): (JSNode_prototype): (JSNode_new): (JSNode_construct):
  • API/JSNode.h: Added.
  • API/JSNodeList.c: Added. (JSNodeListPrototype_item): (JSNodeListPrototype_class): (JSNodeList_length): (JSNodeList_getProperty): (JSNodeList_finalize): (JSNodeList_class): (JSNodeList_prototype): (JSNodeList_new):
  • API/JSNodeList.h: Added.
  • API/JSObjectRef.cpp: (JSObjectMake): (JSFunctionMake): (JSConstructorMake): (JSPropertyEnumerator::JSPropertyEnumerator): (JSObjectCreatePropertyEnumerator): (JSPropertyEnumeratorGetNext): (JSPropertyEnumeratorRetain): (JSPropertyEnumeratorRelease):
  • API/JSObjectRef.h: (JSObjectCallbacks::):
  • API/JSValueRef.cpp: (JSValueIsObjectOfClass): (JSValueIsInstanceOf):
  • API/JSValueRef.h:
  • API/Node.c: Added. (Node_new): (Node_appendChild): (Node_removeChild): (Node_replaceChild): (Node_ref): (Node_deref):
  • API/Node.h: Added.
  • API/NodeList.c: Added. (NodeList_new): (NodeList_length): (NodeList_item): (NodeList_ref): (NodeList_deref):
  • API/NodeList.h: Added.
  • API/minidom.c: (main): (print): (createStringWithContentsOfFile):
  • API/minidom.js:
  • API/testapi.c: (assertEqualsAsCharacters): (MyObject_getProperty): (MyObject_class): (myConstructor_callAsConstructor): (main):
  • API/testapi.js:
  • JavaScriptCore.xcodeproj/project.pbxproj:
Location:
trunk/JavaScriptCore
Files:
14 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSBase.h

    r15096 r15133  
    3131typedef struct __JSContext* JSContextRef;
    3232typedef struct __JSCharBuffer* JSCharBufferRef;
     33typedef struct __JSClass* JSClassRef;
    3334typedef struct __JSPropertyList* JSPropertyListRef;
    34 typedef struct __JSPropertyListEnumerator* JSPropertyListEnumeratorRef;
     35typedef struct __JSPropertyEnumerator* JSPropertyEnumeratorRef;
    3536
    3637/* Base type of all JS values, and polymorphic functions on them */
  • trunk/JavaScriptCore/API/JSCallbackObject.cpp

    r14951 r15133  
    2828#include "JSCallbackObject.h"
    2929#include "JSCharBufferRef.h"
     30#include "JSClassRef.h"
    3031#include "JSObjectRef.h"
    3132#include "internal.h"
     33#include "reference.h"
    3234#include "reference_list.h"
    3335
    3436namespace KJS {
    3537
    36 const ClassInfo JSCallbackObject::info = { "JSCallbackObject", 0, 0, 0 };
    37 
    38 JSCallbackObject::JSCallbackObject(const JSObjectCallbacks* callbacks)
     38const ClassInfo JSCallbackObject::info = { "CallbackObject", 0, 0, 0 };
     39
     40JSCallbackObject::JSCallbackObject(JSClassRef jsClass)
    3941    : JSObject()
    40     , m_privateData(0)
    41     , m_callbacks(*callbacks)
    42 {
     42{
     43    init(jsClass);
     44}
     45
     46JSCallbackObject::JSCallbackObject(JSClassRef jsClass, JSObject* prototype)
     47    : JSObject(prototype)
     48{
     49    init(jsClass);
     50}
     51
     52void JSCallbackObject::init(JSClassRef jsClass)
     53{
     54    m_privateData = 0;
     55    m_class = JSClassRetain(jsClass);
     56
    4357    JSObjectRef thisRef = toRef(this);
    4458   
    4559    do {
    46         if (JSInitializeCallback initialize = callbacks->initialize)
     60        if (JSInitializeCallback initialize = jsClass->callbacks.initialize)
    4761            initialize(thisRef);
    48     } while ((callbacks = callbacks->parentCallbacks));
    49 }
    50 
    51 JSCallbackObject::JSCallbackObject(const JSObjectCallbacks* callbacks, JSObject* prototype)
    52     : JSObject(prototype)
    53     , m_privateData(0)
    54     , m_callbacks(*callbacks)
    55 {
    56     JSObjectRef thisRef = toRef(this);
    57    
    58     do {
    59         if (JSInitializeCallback initialize = callbacks->initialize)
    60             initialize(thisRef);
    61     } while ((callbacks = callbacks->parentCallbacks));
     62    } while ((jsClass = jsClass->parent));
    6263}
    6364
     
    6667    JSObjectRef thisRef = toRef(this);
    6768   
    68     for (JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks)
    69         if (JSFinalizeCallback finalize = callbacks->finalize)
     69    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent)
     70        if (JSFinalizeCallback finalize = jsClass->callbacks.finalize)
    7071            finalize(thisRef);
     72   
     73    JSClassRelease(m_class);
    7174}
    7275
    7376UString JSCallbackObject::className() const
    7477{
    75     JSObjectRef thisRef = toRef(this);
    76    
    77     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    78         if (JSCopyDescriptionCallback copyDescriptionCallback = callbacks->copyDescription) {
    79             JSCharBufferRef descriptionBuf = copyDescriptionCallback(thisRef);
    80             UString description(toJS(descriptionBuf));
    81             JSCharBufferRelease(descriptionBuf);
    82             return description;
    83         }
    84     }
    85    
    86     return JSObject::className();
     78    return classInfo()->className;
    8779}
    8880
     
    9183    JSObjectRef thisRef = toRef(this);
    9284    JSCharBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
    93 
    94     // optional optimization for cases when we only need to know if the property exists, not its value
    95     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    96         if (JSHasPropertyCallback hasPropertyCallback = callbacks->hasProperty) {
     85   
     86    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
     87        // optional optimization to bypass getProperty in cases when we only need to know if the property exists
     88        if (JSHasPropertyCallback hasPropertyCallback = jsClass->callbacks.hasProperty) {
    9789            if (hasPropertyCallback(thisRef, propertyNameRef)) {
    98                 slot.setCustom(0, callbackGetter);
    99                 return true;
    100             }
    101         }
    102     }
    103    
    104     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    105         if (JSGetPropertyCallback getPropertyCallback = callbacks->getProperty) {
     90                slot.setCustom(this, callbackGetter);
     91                return true;
     92            }
     93        } else if (JSGetPropertyCallback getPropertyCallback = jsClass->callbacks.getProperty) {
    10694            JSValueRef returnValue;
    107             if (getPropertyCallback(thisRef, propertyNameRef, &returnValue)) {
    108                 slot.setCustom(reinterpret_cast<JSObject*>(returnValue), cachedValueGetter); // cache the value so we don't have to compute it again
    109                 return true;
    110             }
    111         }
    112     }
     95            if (getPropertyCallback(toRef(exec), thisRef, propertyNameRef, &returnValue)) {
     96                // cache the value so we don't have to compute it again
     97                // FIXME: This violates the PropertySlot design a little bit.
     98                // We should either use this optimization everywhere, or nowhere.
     99                slot.setCustom(reinterpret_cast<JSObject*>(returnValue), cachedValueGetter);
     100                return true;
     101            }
     102        }
     103
     104        if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
     105            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
     106                if (entry->getProperty) {
     107                    slot.setCustom(this, staticValueGetter);
     108                    return true;
     109                }
     110            }
     111        }
     112       
     113        if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     114            if (staticFunctions->contains(propertyName.ustring().rep())) {
     115                slot.setCustom(this, staticFunctionGetter);
     116                return true;
     117            }
     118        }
     119    }
     120
    113121    return JSObject::getOwnPropertySlot(exec, propertyName, slot);
    114122}
     
    124132    JSCharBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
    125133
    126     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    127         if (JSSetPropertyCallback setPropertyCallback = callbacks->setProperty) {
     134    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
     135        if (JSSetPropertyCallback setPropertyCallback = jsClass->callbacks.setProperty) {
    128136            if (setPropertyCallback(thisRef, propertyNameRef, value))
    129137                return;
    130138        }
     139   
     140        if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
     141            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
     142                if (entry->attributes & kJSPropertyAttributeReadOnly)
     143                    return;
     144                if (JSSetPropertyCallback setPropertyCallback = entry->setProperty) {
     145                    if (setPropertyCallback(thisRef, propertyNameRef, value))
     146                        return;
     147                }
     148            }
     149        }
     150       
     151        if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     152            if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
     153                if (entry->attributes & kJSPropertyAttributeReadOnly)
     154                    return;
     155                putDirect(propertyName, value, attr); // put as override property
     156                return;
     157            }
     158        }
    131159    }
    132160    return JSObject::put(exec, propertyName, value, attr);
     
    143171    JSCharBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
    144172   
    145     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    146         if (JSDeletePropertyCallback deletePropertyCallback = callbacks->deleteProperty) {
     173    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
     174        if (JSDeletePropertyCallback deletePropertyCallback = jsClass->callbacks.deleteProperty) {
    147175            if (deletePropertyCallback(thisRef, propertyNameRef))
    148176                return true;
    149177        }
     178
     179        if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
     180            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep())) {
     181                if (entry->attributes & kJSPropertyAttributeDontDelete)
     182                    return false;
     183                return true;
     184            }
     185        }
     186       
     187        if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     188            if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
     189                if (entry->attributes & kJSPropertyAttributeDontDelete)
     190                    return false;
     191                return true;
     192            }
     193        }
    150194    }
    151195    return JSObject::deleteProperty(exec, propertyName);
     
    159203bool JSCallbackObject::implementsConstruct() const
    160204{
    161     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks)
    162         if (callbacks->callAsConstructor)
     205    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent)
     206        if (jsClass->callbacks.callAsConstructor)
    163207            return true;
    164208
     
    171215    JSObjectRef thisRef = toRef(this);
    172216   
    173     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    174         if (JSCallAsConstructorCallback callAsConstructorCallback = callbacks->callAsConstructor) {
     217    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
     218        if (JSCallAsConstructorCallback callAsConstructorCallback = jsClass->callbacks.callAsConstructor) {
    175219            size_t argc = args.size();
    176220            JSValueRef argv[argc];
     
    181225    }
    182226   
    183     ASSERT(false);
     227    ASSERT(0); // implementsConstruct should prevent us from reaching here
    184228    return 0;
    185229}
     
    187231bool JSCallbackObject::implementsCall() const
    188232{
    189     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks)
    190         if (callbacks->callAsFunction)
     233    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent)
     234        if (jsClass->callbacks.callAsFunction)
    191235            return true;
    192236   
     
    200244    JSObjectRef thisObjRef = toRef(thisObj);
    201245
    202     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    203         if (JSCallAsFunctionCallback callAsFunctionCallback = callbacks->callAsFunction) {
     246    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
     247        if (JSCallAsFunctionCallback callAsFunctionCallback = jsClass->callbacks.callAsFunction) {
    204248            size_t argc = args.size();
    205249            JSValueRef argv[argc];
     
    210254    }
    211255
    212     ASSERT(false);
     256    ASSERT(0); // implementsCall should prevent us from reaching here
    213257    return 0;
    214258}
     
    218262    JSObjectRef thisRef = toRef(this);
    219263
    220     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks)
    221         if (JSGetPropertyListCallback getPropertyListCallback = callbacks->getPropertyList)
     264    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
     265        if (JSGetPropertyListCallback getPropertyListCallback = jsClass->callbacks.getPropertyList)
    222266            getPropertyListCallback(thisRef, toRef(&propertyList));
    223267
     268        if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
     269            typedef __JSClass::StaticValuesTable::const_iterator iterator;
     270            iterator end = staticValues->end();
     271            for (iterator it = staticValues->begin(); it != end; ++it) {
     272                UString::Rep* name = it->first.get();
     273                StaticValueEntry* entry = it->second;
     274                if (entry->getProperty && !(entry->attributes & kJSPropertyAttributeDontEnum))
     275                    propertyList.append(Reference(this, Identifier(name)));
     276            }
     277        }
     278
     279        if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     280            typedef __JSClass::StaticFunctionsTable::const_iterator iterator;
     281            iterator end = staticFunctions->end();
     282            for (iterator it = staticFunctions->begin(); it != end; ++it) {
     283                UString::Rep* name = it->first.get();
     284                StaticFunctionEntry* entry = it->second;
     285                if (!(entry->attributes & kJSPropertyAttributeDontEnum))
     286                    propertyList.append(Reference(this, Identifier(name)));
     287            }
     288        }
     289    }
     290
    224291    JSObject::getPropertyList(exec, propertyList, recursive);
    225292}
     
    229296    JSObjectRef thisRef = toRef(this);
    230297
    231     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    232         if (JSConvertToTypeCallback convertToTypeCallback = callbacks->convertToType) {
     298    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
     299        if (JSConvertToTypeCallback convertToTypeCallback = jsClass->callbacks.convertToType) {
    233300            JSValueRef returnValue;
    234301            if (convertToTypeCallback(thisRef, kJSTypeBoolean, &returnValue))
     
    243310    JSObjectRef thisRef = toRef(this);
    244311
    245     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    246         if (JSConvertToTypeCallback convertToTypeCallback = callbacks->convertToType) {
     312    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
     313        if (JSConvertToTypeCallback convertToTypeCallback = jsClass->callbacks.convertToType) {
    247314            JSValueRef returnValue;
    248315            if (convertToTypeCallback(thisRef, kJSTypeNumber, &returnValue))
     
    257324    JSObjectRef thisRef = toRef(this);
    258325
    259     for (const JSObjectCallbacks* callbacks = &m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    260         if (JSConvertToTypeCallback convertToTypeCallback = callbacks->convertToType) {
     326    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
     327        if (JSConvertToTypeCallback convertToTypeCallback = jsClass->callbacks.convertToType) {
    261328            JSValueRef returnValue;
    262329            if (convertToTypeCallback(thisRef, kJSTypeString, &returnValue))
     
    277344}
    278345
     346bool JSCallbackObject::inherits(JSClassRef c) const
     347{
     348    for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent)
     349        if (jsClass == c)
     350            return true;
     351    return false;
     352}
     353
    279354JSValue* JSCallbackObject::cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
    280355{
     
    284359}
    285360
    286 JSValue* JSCallbackObject::callbackGetter(ExecState*, JSObject* originalObject, const Identifier& propertyName, const PropertySlot&)
    287 {
    288     ASSERT(originalObject->inherits(&JSCallbackObject::info));
    289     JSObjectRef thisRef = toRef(originalObject);
    290     JSCharBufferRef propertyNameRef= toRef(propertyName.ustring().rep());
    291 
    292     for (const JSObjectCallbacks* callbacks = &static_cast<JSCallbackObject*>(originalObject)->m_callbacks; callbacks; callbacks = callbacks->parentCallbacks) {
    293         if (JSGetPropertyCallback getPropertyCallback = callbacks->getProperty) {
    294             JSValueRef returnValue;
    295             if (getPropertyCallback(thisRef, propertyNameRef, &returnValue)) {
     361JSValue* JSCallbackObject::staticValueGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
     362{
     363    ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info));
     364    JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
     365
     366    JSObjectRef thisRef = toRef(thisObj);
     367    JSCharBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
     368
     369    for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parent) {
     370        JSValueRef returnValue;
     371       
     372        if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues)
     373            if (StaticValueEntry* entry = staticValues->get(propertyName.ustring().rep()))
     374                if (JSGetPropertyCallback getPropertyCallback = entry->getProperty)
     375                    if (getPropertyCallback(toRef(exec), thisRef, propertyNameRef, &returnValue))
     376                        return toJS(returnValue);
     377    }
     378
     379    return jsUndefined();
     380}
     381
     382JSValue* JSCallbackObject::staticFunctionGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
     383{
     384    ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info));
     385    JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
     386
     387    if (JSValue* cachedOrOverrideValue = thisObj->getDirect(propertyName))
     388        return toJS(cachedOrOverrideValue);
     389
     390    for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parent) {
     391        if (__JSClass::StaticFunctionsTable* staticFunctions = jsClass->staticFunctions) {
     392            if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.ustring().rep())) {
     393                JSValue* v = toJS(JSFunctionMake(toRef(exec), entry->callAsFunction));
     394                thisObj->putDirect(propertyName, v, entry->attributes);
     395                return v;
     396            }
     397        }
     398    }
     399
     400    return jsUndefined();
     401}
     402
     403JSValue* JSCallbackObject::callbackGetter(ExecState* exec, JSObject*, const Identifier& propertyName, const PropertySlot& slot)
     404{
     405    ASSERT(slot.slotBase()->inherits(&JSCallbackObject::info));
     406    JSCallbackObject* thisObj = static_cast<JSCallbackObject*>(slot.slotBase());
     407
     408    JSObjectRef thisRef = toRef(thisObj);
     409    JSCharBufferRef propertyNameRef = toRef(propertyName.ustring().rep());
     410
     411    for (JSClassRef jsClass = thisObj->m_class; jsClass; jsClass = jsClass->parent) {
     412        JSValueRef returnValue;
     413
     414        if (JSGetPropertyCallback getPropertyCallback = jsClass->callbacks.getProperty)
     415            if (getPropertyCallback(toRef(exec), thisRef, propertyNameRef, &returnValue))
    296416                return toJS(returnValue);
    297             }
    298         }
    299417    }
    300418
  • trunk/JavaScriptCore/API/JSCallbackObject.h

    r14951 r15133  
    3737{
    3838public:
    39     JSCallbackObject(const JSObjectCallbacks* callbacks);
    40     JSCallbackObject(const JSObjectCallbacks* callbacks, JSObject* prototype);
     39    JSCallbackObject(JSClassRef globalObjectClass);
     40    JSCallbackObject(JSClassRef globalObjectClass, JSObject* prototype);
    4141    virtual ~JSCallbackObject();
    4242       
     
    6969    virtual const ClassInfo *classInfo() const { return &info; }
    7070    static const ClassInfo info;
     71
     72    bool inherits(JSClassRef) const;
    7173   
    7274private:
     
    7476    JSCallbackObject(const JSCallbackObject&);
    7577
     78    void init(JSClassRef jsClass);
     79   
    7680    static JSValue* cachedValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
     81    static JSValue* staticValueGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot);
     82    static JSValue* staticFunctionGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot);
    7783    static JSValue* callbackGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
     84   
    7885    void* m_privateData;
    79     JSObjectCallbacks m_callbacks;
     86    JSClassRef m_class;
    8087};
    8188
  • trunk/JavaScriptCore/API/JSCharBufferRef.cpp

    r14951 r15133  
    2828#include "JSCharBufferRef.h"
    2929
    30 #include <JavaScriptCore/JSLock.h>
    31 #include <JavaScriptCore/JSType.h>
    32 #include <JavaScriptCore/internal.h>
    33 #include <JavaScriptCore/operations.h>
    34 #include <JavaScriptCore/ustring.h>
    35 #include <JavaScriptCore/value.h>
     30#include <kjs/JSLock.h>
     31#include <kjs/JSType.h>
     32#include <kjs/internal.h>
     33#include <kjs/operations.h>
     34#include <kjs/ustring.h>
     35#include <kjs/value.h>
    3636
    3737using namespace KJS;
  • trunk/JavaScriptCore/API/JSContextRef.cpp

    r14951 r15133  
    3535using namespace KJS;
    3636
    37 JSContextRef JSContextCreate(const JSObjectCallbacks* globalObjectCallbacks, JSObjectRef globalObjectPrototype)
     37JSContextRef JSContextCreate(JSClassRef globalObjectClass, JSObjectRef globalObjectPrototype)
    3838{
    3939    JSLock lock;
     
    4242
    4343    JSObject* globalObject;
    44     if (globalObjectCallbacks == &kJSObjectCallbacksNone) // slightly more efficient
     44    if (globalObjectClass) {
     45        if (jsPrototype)
     46            globalObject = new JSCallbackObject(globalObjectClass, jsPrototype);
     47        else
     48            globalObject = new JSCallbackObject(globalObjectClass);
     49    } else {
     50        // creates a slightly more efficient object
    4551        if (jsPrototype)
    4652            globalObject = new JSObject(jsPrototype);
    4753        else
    4854            globalObject = new JSObject();
    49     else if (jsPrototype)
    50         globalObject = new JSCallbackObject(globalObjectCallbacks, jsPrototype);
    51     else
    52         globalObject = new JSCallbackObject(globalObjectCallbacks);
     55    }
    5356
    5457    Interpreter* interpreter = new Interpreter(globalObject); // adds the built-in object prototype to the global object
     
    7881    Completion completion = exec->dynamicInterpreter()->evaluate(UString(sourceURLRep), startingLineNumber, UString(scriptRep), jsThisValue);
    7982
    80     *returnValue = toRef(completion.value());
     83    if (returnValue)
     84        *returnValue = completion.value() ? toRef(completion.value()) : toRef(jsUndefined());
     85
    8186    return completion.complType() != Throw;
    8287}
  • trunk/JavaScriptCore/API/JSContextRef.h

    r14951 r15133  
    3535#endif
    3636
    37 JSContextRef JSContextCreate(const JSObjectCallbacks* globalObjectCallbacks, JSObjectRef globalObjectPrototype);
     37JSContextRef JSContextCreate(JSClassRef globalObjectClass, JSObjectRef globalObjectPrototype);
    3838void JSContextDestroy(JSContextRef context);
    3939
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r15043 r15133  
    2828#include "JSValueRef.h"
    2929#include "JSObjectRef.h"
     30#include "JSCallbackConstructor.h"
     31#include "JSCallbackFunction.h"
    3032#include "JSCallbackObject.h"
    3133
     
    3638
    3739using namespace KJS;
    38 
    39 const JSObjectCallbacks kJSObjectCallbacksNone = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    4040
    4141JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value)
     
    5252}   
    5353
    54 JSObjectRef JSObjectMake(JSContextRef context, const JSObjectCallbacks* callbacks, JSObjectRef prototype)
     54JSObjectRef JSObjectMake(JSContextRef context, JSClassRef jsClass, JSObjectRef prototype)
    5555{
    5656    JSLock lock;
     
    6262        jsPrototype = exec->lexicalInterpreter()->builtinObjectPrototype();
    6363
    64     if (callbacks == &kJSObjectCallbacksNone)
     64    if (!jsClass)
    6565        return toRef(new JSObject(jsPrototype)); // slightly more efficient
    6666    else
    67         return toRef(new JSCallbackObject(callbacks, jsPrototype));
     67        return toRef(new JSCallbackObject(jsClass, jsPrototype));
    6868}
    6969
    7070JSObjectRef JSFunctionMake(JSContextRef context, JSCallAsFunctionCallback callback)
    7171{
    72     ExecState* exec = toJS(context);
    73     JSObjectCallbacks callbacks = kJSObjectCallbacksNone;
    74     callbacks.callAsFunction = callback;
    75 
    76     return JSObjectMake(context, &callbacks, toRef(exec->lexicalInterpreter()->builtinFunctionPrototype()));
     72    JSLock lock;
     73    ExecState* exec = toJS(context);
     74    return toRef(new JSCallbackFunction(exec, callback));
    7775}
    7876
    7977JSObjectRef JSConstructorMake(JSContextRef context, JSCallAsConstructorCallback callback)
    8078{
    81     ExecState* exec = toJS(context);
    82     JSObjectCallbacks callbacks = kJSObjectCallbacksNone;
    83     callbacks.callAsConstructor = callback;
    84    
    85     return JSObjectMake(context, &callbacks, toRef(exec->lexicalInterpreter()->builtinObjectPrototype()));
     79    JSLock lock;
     80    ExecState* exec = toJS(context);
     81    return toRef(new JSCallbackConstructor(exec, callback));
    8682}
    8783
     
    224220}
    225221
    226 struct __JSPropertyListEnumerator
    227 {
    228     __JSPropertyListEnumerator() : refCount(0), iterator(list.end())
     222struct __JSPropertyEnumerator
     223{
     224    __JSPropertyEnumerator() : refCount(0), iterator(list.end())
    229225    {
    230226    }
     
    235231};
    236232
    237 JSPropertyListEnumeratorRef JSObjectCreatePropertyEnumerator(JSContextRef context, JSObjectRef object)
    238 {
    239     JSLock lock;
    240     ExecState* exec = toJS(context);
    241     JSObject* jsObject = toJS(object);
    242    
    243     JSPropertyListEnumeratorRef enumerator = new __JSPropertyListEnumerator();
     233JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSContextRef context, JSObjectRef object)
     234{
     235    JSLock lock;
     236    ExecState* exec = toJS(context);
     237    JSObject* jsObject = toJS(object);
     238   
     239    JSPropertyEnumeratorRef enumerator = new __JSPropertyEnumerator();
    244240    jsObject->getPropertyList(exec, enumerator->list);
    245241    enumerator->iterator = enumerator->list.begin();
    246242   
    247     return enumerator;
    248 }
    249 
    250 JSCharBufferRef JSPropertyEnumeratorGetNext(JSContextRef context, JSPropertyListEnumeratorRef enumerator)
     243    return JSPropertyEnumeratorRetain(enumerator);
     244}
     245
     246JSCharBufferRef JSPropertyEnumeratorGetNext(JSContextRef context, JSPropertyEnumeratorRef enumerator)
    251247{
    252248    ExecState* exec = toJS(context);
     
    259255}
    260256
    261 JSPropertyListEnumeratorRef JSPropertyEnumeratorRetain(JSPropertyListEnumeratorRef enumerator)
     257JSPropertyEnumeratorRef JSPropertyEnumeratorRetain(JSPropertyEnumeratorRef enumerator)
    262258{
    263259    ++enumerator->refCount;
     
    265261}
    266262
    267 void JSPropertyEnumeratorRelease(JSPropertyListEnumeratorRef enumerator)
     263void JSPropertyEnumeratorRelease(JSPropertyEnumeratorRef enumerator)
    268264{
    269265    if (--enumerator->refCount == 0)
  • trunk/JavaScriptCore/API/JSObjectRef.h

    r15043 r15133  
    2929
    3030#include "JSBase.h"
     31#include "JSValueRef.h"
    3132
    3233#ifdef __cplusplus
     
    4849(*JSFinalizeCallback)           (JSObjectRef object);
    4950
    50 typedef JSCharBufferRef
    51 (*JSCopyDescriptionCallback)    (JSObjectRef object);
    52 
    5351typedef bool
    5452(*JSHasPropertyCallback)        (JSObjectRef object, JSCharBufferRef propertyName);
    5553
    5654typedef bool
    57 (*JSGetPropertyCallback)        (JSObjectRef object, JSCharBufferRef propertyName, JSValueRef* returnValue);
     55(*JSGetPropertyCallback)        (JSContextRef context, JSObjectRef object, JSCharBufferRef propertyName, JSValueRef* returnValue);
    5856
    5957typedef bool
     
    7775typedef struct __JSObjectCallbacks {
    7876    int                         version; // current (and only) version is 0
    79     struct __JSObjectCallbacks* parentCallbacks; // pass NULL for the default object callbacks
    8077    JSInitializeCallback        initialize;
    8178    JSFinalizeCallback          finalize;
    82     JSCopyDescriptionCallback   copyDescription;
    8379    JSHasPropertyCallback       hasProperty;
    8480    JSGetPropertyCallback       getProperty;
     
    9389extern const JSObjectCallbacks kJSObjectCallbacksNone;
    9490
     91typedef struct {
     92    const char* const name; // FIXME: convert UTF8
     93    JSGetPropertyCallback getProperty;
     94    JSSetPropertyCallback setProperty;
     95    JSPropertyAttributes attributes;
     96} JSStaticValue;
     97
     98typedef struct {
     99    const char* const name; // FIXME: convert UTF8
     100    JSCallAsFunctionCallback callAsFunction;
     101    JSPropertyAttributes attributes;
     102} JSStaticFunction;
     103
     104JSClassRef JSClassCreate(JSContextRef context, JSStaticValue* staticValues, JSStaticFunction* staticFunctions, const JSObjectCallbacks* callbacks, JSClassRef parentClass);
     105void JSClassRelease(JSClassRef jsClass);
     106JSClassRef JSClassRetain(JSClassRef jsClass);
     107
    95108// pass NULL as prototype to get the built-in object prototype
    96 JSObjectRef JSObjectMake(JSContextRef context, const JSObjectCallbacks* callbacks, JSObjectRef prototype);
     109JSObjectRef JSObjectMake(JSContextRef context, JSClassRef jsClass, JSObjectRef prototype);
    97110
    98111// Will be assigned the built-in function prototype
     
    120133
    121134// Used for enumerating the names of an object's properties like a for...in loop would
    122 JSPropertyListEnumeratorRef JSObjectCreatePropertyEnumerator(JSContextRef context, JSObjectRef object);
    123 JSPropertyListEnumeratorRef JSPropertyEnumeratorRetain(JSPropertyListEnumeratorRef enumerator);
    124 void JSPropertyEnumeratorRelease(JSPropertyListEnumeratorRef enumerator);
    125 JSCharBufferRef JSPropertyEnumeratorGetNext(JSContextRef context, JSPropertyListEnumeratorRef enumerator);
     135JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSContextRef context, JSObjectRef object);
     136JSPropertyEnumeratorRef JSPropertyEnumeratorRetain(JSPropertyEnumeratorRef enumerator);
     137void JSPropertyEnumeratorRelease(JSPropertyEnumeratorRef enumerator);
     138JSCharBufferRef JSPropertyEnumeratorGetNext(JSContextRef context, JSPropertyEnumeratorRef enumerator);
    126139
    127140// Used for adding property names to a for...in enumeration
  • trunk/JavaScriptCore/API/JSValueRef.cpp

    r14951 r15133  
    2525 */
    2626
     27#include "APICast.h"
     28#include "JSCallbackObject.h"
    2729#include "JSValueRef.h"
    28 #include "APICast.h"
    29 #include <JavaScriptCore/JSType.h>
    30 #include <JavaScriptCore/internal.h>
    31 #include <JavaScriptCore/operations.h>
    32 #include <JavaScriptCore/protect.h>
    33 #include <JavaScriptCore/ustring.h>
    34 #include <JavaScriptCore/value.h>
     30
     31#include <kjs/JSType.h>
     32#include <kjs/internal.h>
     33#include <kjs/operations.h>
     34#include <kjs/protect.h>
     35#include <kjs/ustring.h>
     36#include <kjs/value.h>
    3537
    3638#include <wtf/Assertions.h>
     
    98100}
    99101
     102bool JSValueIsObjectOfClass(JSValueRef value, JSClassRef jsClass)
     103{
     104    JSValue* jsValue = toJS(value);
     105   
     106    if (JSObject* o = jsValue->getObject())
     107        if (o->inherits(&JSCallbackObject::info))
     108            return static_cast<JSCallbackObject*>(o)->inherits(jsClass);
     109    return false;
     110}
     111
    100112bool JSValueIsEqual(JSContextRef context, JSValueRef a, JSValueRef b)
    101113{
     
    124136}
    125137
     138bool JSValueIsInstanceOf(JSContextRef context, JSValueRef value, JSObjectRef object)
     139{
     140    ExecState* exec = toJS(context);
     141    JSValue* jsValue = toJS(value);
     142    JSObject* jsObject = toJS(object);
     143    if (!jsObject->implementsHasInstance())
     144        return false;
     145    bool result = jsObject->hasInstance(exec, jsValue);
     146    if (exec->hadException())
     147        exec->clearException();
     148    return result;
     149}
     150
    126151JSValueRef JSUndefinedMake()
    127152{
  • trunk/JavaScriptCore/API/JSValueRef.h

    r15096 r15133  
    108108*/
    109109bool JSValueIsObject(JSValueRef value);
     110bool JSValueIsObjectOfClass(JSValueRef value, JSClassRef jsClass);
    110111
    111112// Comparing values
     
    140141  @result        true if value is an instance of object
    141142*/
    142 bool JSValueIsInstanceOf(JSValueRef value, JSObjectRef object);
     143bool JSValueIsInstanceOf(JSContextRef context, JSValueRef value, JSObjectRef object);
    143144
    144145// Creating values
  • trunk/JavaScriptCore/API/minidom.c

    r14951 r15133  
    2626
    2727#include "JavaScriptCore.h"
     28#include "JSNode.h"
    2829#include <wtf/UnusedParam.h>
     30
     31static char* createStringWithContentsOfFile(const char* fileName);
     32static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[]);
    2933
    3034int main(int argc, char* argv[])
     
    3337    UNUSED_PARAM(argv);
    3438   
     39    JSContextRef context = JSContextCreate(NULL, NULL);
     40    JSObjectRef globalObject = JSContextGetGlobalObject(context);
     41   
     42    JSCharBufferRef printBuf = JSCharBufferCreateUTF8("print");
     43    JSObjectSetProperty(context, globalObject, printBuf, JSFunctionMake(context, print), kJSPropertyAttributeNone);
     44    JSCharBufferRelease(printBuf);
     45   
     46    JSCharBufferRef nodeBuf = JSCharBufferCreateUTF8("Node");
     47    JSObjectSetProperty(context, globalObject, nodeBuf, JSConstructorMake(context, JSNode_construct), kJSPropertyAttributeNone);
     48    JSCharBufferRelease(nodeBuf);
     49   
     50    char* script = createStringWithContentsOfFile("minidom.js");
     51    JSCharBufferRef scriptBuf = JSCharBufferCreateUTF8(script);
     52    JSValueRef result;
     53    JSEvaluate(context, globalObject, scriptBuf, NULL, 0, &result);
     54
     55    if (JSValueIsUndefined(result))
     56        printf("PASS: Test script executed successfully.\n");
     57    else {
     58        printf("FAIL: Test script returned unexcpected value:\n");
     59        JSCharBufferRef resultBuf = JSValueCopyStringValue(context, result);
     60        CFStringRef resultCF = CFStringCreateWithJSCharBuffer(kCFAllocatorDefault, resultBuf);
     61        CFShow(resultCF);
     62        CFRelease(resultCF);
     63        JSCharBufferRelease(resultBuf);
     64    }
     65    JSCharBufferRelease(scriptBuf);
     66    free(script);
     67
     68#if 0 // used for leak/finalize debugging   
     69    int i;
     70    for (i = 0; i < 1000; i++) {
     71        JSObjectRef o = JSObjectMake(context, NULL, NULL);
     72        (void)o;
     73    }
     74    JSGCCollect();
     75#endif
     76   
     77    JSContextDestroy(context);
     78    printf("PASS: Program exited normally.\n");
    3579    return 0;
    3680}
     81
     82static JSValueRef print(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[])
     83{
     84    if (argc > 0) {
     85        JSCharBufferRef stringBuf = JSValueCopyStringValue(context, argv[0]);
     86        size_t numChars = JSCharBufferGetMaxLengthUTF8(stringBuf);
     87        char string[numChars];
     88        JSCharBufferGetCharactersUTF8(stringBuf, string, numChars);
     89        printf("%s\n", string);
     90    }
     91   
     92    return JSUndefinedMake();
     93}
     94
     95static char* createStringWithContentsOfFile(const char* fileName)
     96{
     97    char* buffer;
     98   
     99    int buffer_size = 0;
     100    int buffer_capacity = 1024;
     101    buffer = (char*)malloc(buffer_capacity);
     102   
     103    FILE* f = fopen(fileName, "r");
     104    if (!f) {
     105        fprintf(stderr, "Could not open file: %s\n", fileName);
     106        return 0;
     107    }
     108   
     109    while (!feof(f) && !ferror(f)) {
     110        buffer_size += fread(buffer + buffer_size, 1, buffer_capacity - buffer_size, f);
     111        if (buffer_size == buffer_capacity) { // guarantees space for trailing '\0'
     112            buffer_capacity *= 2;
     113            buffer = (char*)realloc(buffer, buffer_capacity);
     114            assert(buffer);
     115        }
     116       
     117        assert(buffer_size < buffer_capacity);
     118    }
     119    fclose(f);
     120    buffer[buffer_size] = '\0';
     121   
     122    return buffer;
     123}
  • trunk/JavaScriptCore/API/minidom.js

    r14951 r15133  
    2626
    2727// For browser-based testing
    28 if (window) {
     28if (typeof window != 'undefined') {
    2929    /*
    3030    The methods and constructors below approximate what that the native host should provide
     
    6060    }
    6161
    62     Node.prototype.tag = "Node";
     62    Node.prototype.nodeType = "Node";
    6363
    6464    Node.prototype.appendChild = function(child) {
     
    7474
    7575        printSpaces(numSpaces);
    76         print('<' + this.tag + '>' + '\n');
     76        print('<' + this.nodeType + '>' + '\n');
    7777       
    7878        var childNodesLength = this.childNodes.length;
     
    8181       
    8282        printSpaces(numSpaces);
    83         print('</' + this.tag + '>\n');
     83        print('</' + this.nodeType + '>\n');
    8484    }
    8585
     
    9191    TextNode.prototype = new Node();
    9292   
    93     TextNode.prototype.tag = "Text";
     93    TextNode.prototype.nodeType = "Text";
    9494   
    9595    TextNode.prototype.serialize = function(numSpaces) {
     
    105105    Element.prototype = new Node();
    106106   
    107     Element.prototype.tag = "Element";
     107    Element.prototype.nodeType = "Element";
    108108
    109109    RootElement = function()
     
    113113    RootElement.prototype = new Element();
    114114
    115     RootElement.prototype.tag = "Root";
     115    RootElement.prototype.nodeType = "Root";
    116116   
    117117    HeroElement = function()
     
    121121    HeroElement.prototype = new Element();
    122122
    123     HeroElement.prototype.tag = "Hero";
     123    HeroElement.prototype.nodeType = "Hero";
    124124
    125125    VillainElement = function()
     
    129129    VillainElement.prototype = new Element();
    130130
    131     VillainElement.prototype.tag = "Villain";
     131    VillainElement.prototype.nodeType = "Villain";
    132132
    133133    NameElement = function()
     
    137137    NameElement.prototype = new Element();
    138138
    139     NameElement.prototype.tag = "Name";
     139    NameElement.prototype.nodeType = "Name";
    140140
    141141    WeaponElement = function()
     
    145145    WeaponElement.prototype = new Element();
    146146
    147     WeaponElement.prototype.tag = "Weapon";
     147    WeaponElement.prototype.nodeType = "Weapon";
    148148
    149149    Document = function()
     
    168168function test()
    169169{
     170    print("Node is " + Node);
     171    for (var p in Node)
     172        print(p + ": " + Node[p]);
     173   
     174    node = new Node();
     175    print("node is " + node);
     176    for (var p in node)
     177        print(p + ": " + node[p]);
     178
     179    child1 = new Node();
     180    child2 = new Node();
     181    child3 = new Node();
     182   
     183    node.appendChild(child1);
     184    node.appendChild(child2);
     185
     186    for (var i = 0; i < node.childNodes.length + 1; i++) {
     187        print("item " + i + ": " + node.childNodes.item(i));
     188    }
     189   
     190    for (var i = 0; i < node.childNodes.length + 1; i++) {
     191        print(i + ": " + node.childNodes[i]);
     192    }
     193
     194    node.removeChild(child1);
     195    node.replaceChild(child3, child2);
     196   
     197    for (var i = 0; i < node.childNodes.length + 1; i++) {
     198        print("item " + i + ": " + node.childNodes.item(i));
     199    }
     200
     201    for (var i = 0; i < node.childNodes.length + 1; i++) {
     202        print(i + ": " + node.childNodes[i]);
     203    }
     204
     205    try {
     206        node.appendChild(null);
     207    } catch(e) {
     208        print("caught: " + e);
     209    }
     210   
     211    try {
     212        var o = new Object();
     213        o.appendChild = node.appendChild;
     214        o.appendChild(node);
     215    } catch(e) {
     216        print("caught: " + e);
     217    }
     218   
     219    try {
     220        node.appendChild();
     221    } catch(e) {
     222        print("caught: " + e);
     223    }
     224
     225    /*
    170226    var element, name, weapon;
    171227   
     
    173229    document.appendChild(document.createElement('Root'));
    174230
    175     /* Tank Girl */
     231    // Tank Girl
    176232    element = document.createElement('Hero');
    177233
     
    195251
    196252
    197     /* Skeletor */
     253    // Skeletor
    198254    element = document.createElement('Villain');
    199255
     
    212268    document.firstChild.appendChild(element);
    213269
    214     /* Serialize */
     270    // Serialize
    215271    document.serialize();
     272    */
    216273}
     274
     275test();
  • trunk/JavaScriptCore/API/testapi.c

    r15043 r15133  
    108108    CFRelease(expectedValueAsCFString);
    109109   
    110     assert(memcmp(jsBuffer, cfBuffer, cfLength * sizeof(UniChar)) == 0);
    111     assert(jsLength == (size_t)cfLength);
     110    if (memcmp(jsBuffer, cfBuffer, cfLength * sizeof(UniChar)) != 0)
     111        fprintf(stderr, "assertEqualsAsCharacters failed: jsBuffer != cfBuffer\n");
     112   
     113    if (jsLength != (size_t)cfLength)
     114        fprintf(stderr, "assertEqualsAsCharacters failed: jsLength(%ld) != cfLength(%ld)\n", jsLength, cfLength);
    112115   
    113116    JSCharBufferRelease(valueAsString);
     
    125128    UNUSED_PARAM(object);
    126129    didInitialize = true;
    127 }
    128 
    129 static JSCharBufferRef MyObject_copyDescription(JSObjectRef object)
    130 {
    131     UNUSED_PARAM(object);
    132     return JSCharBufferCreateUTF8("MyObject");
    133130}
    134131
     
    146143}
    147144
    148 static bool MyObject_getProperty(JSObjectRef object, JSCharBufferRef propertyName, JSValueRef* returnValue)
    149 {
     145static bool MyObject_getProperty(JSContextRef context, JSObjectRef object, JSCharBufferRef propertyName, JSValueRef* returnValue)
     146{
     147    UNUSED_PARAM(context);
    150148    UNUSED_PARAM(object);
    151149   
     
    252250}
    253251
    254 JSObjectCallbacks MyObjectCallbacks = {
    255     0,
     252JSObjectCallbacks MyObject_callbacks = {
    256253    0,
    257254    &MyObject_initialize,
    258255    &MyObject_finalize,
    259     &MyObject_copyDescription,
    260256    &MyObject_hasProperty,
    261257    &MyObject_getProperty,
     
    268264};
    269265
     266static JSClassRef MyObject_class(JSContextRef context)
     267{
     268    static JSClassRef jsClass;
     269    if (!jsClass) {
     270        jsClass = JSClassCreate(context, NULL, NULL, &MyObject_callbacks, NULL);
     271    }
     272   
     273    return jsClass;
     274}
     275
    270276static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functionObject, JSObjectRef thisObject, size_t argc, JSValueRef argv[])
    271277{
     
    289295    UNUSED_PARAM(constructorObject);
    290296   
    291     JSObjectRef result = JSObjectMake(context, &kJSObjectCallbacksNone, 0);
     297    JSObjectRef result = JSObjectMake(context, NULL, 0);
    292298    if (argc > 0) {
    293299        JSCharBufferRef valueBuffer = JSCharBufferCreateUTF8("value");
     
    306312    UNUSED_PARAM(argv);
    307313   
    308     context = JSContextCreate(&kJSObjectCallbacksNone, 0);
     314    context = JSContextCreate(NULL, NULL);
    309315
    310316    JSValueRef jsUndefined = JSUndefinedMake();
     
    468474    // GDB says jsGlobalValue actually ends up being marked by the stack crawl, so this
    469475    // exercise is a bit academic. Not sure why that happens, or how to avoid it.
    470     jsGlobalValue = JSObjectMake(context, &kJSObjectCallbacksNone, 0);
     476    jsGlobalValue = JSObjectMake(context, NULL, 0);
    471477    JSGCCollect();
    472478    assert(JSValueIsObject(jsGlobalValue));
     
    507513    JSCharBufferRelease(badSyntaxBuf);
    508514
    509     JSObjectRef myObject = JSObjectMake(context, &MyObjectCallbacks, 0);
     515    JSCharBufferRef arrayBuf = JSCharBufferCreateUTF8("Array");
     516    JSValueRef v;
     517    assert(JSObjectGetProperty(context, globalObject, arrayBuf, &v));
     518    JSObjectRef arrayConstructor = JSValueToObject(context, v);
     519    JSCharBufferRelease(arrayBuf);
     520    JSValueRef arrayObject;
     521    assert(JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, &arrayObject));
     522    assert(JSValueIsInstanceOf(context, arrayObject, arrayConstructor));
     523    assert(!JSValueIsInstanceOf(context, JSNullMake(), arrayConstructor));
     524   
     525    JSObjectRef myObject = JSObjectMake(context, MyObject_class(context), NULL);
    510526    assert(didInitialize);
    511527    JSCharBufferRef myObjectBuf = JSCharBufferCreateUTF8("MyObject");
     
    538554
    539555    // Allocate a few dummies so that at least one will be collected
    540     JSObjectMake(context, &MyObjectCallbacks, 0);
    541     JSObjectMake(context, &MyObjectCallbacks, 0);
     556    JSObjectMake(context, MyObject_class(context), 0);
     557    JSObjectMake(context, MyObject_class(context), 0);
    542558    JSGCCollect();
    543559    assert(didFinalize);
    544560
    545561    JSContextDestroy(context);
    546     printf("PASS: All assertions passed.\n");
     562    printf("PASS: Program exited normally.\n");
    547563    return 0;
    548564}
  • trunk/JavaScriptCore/API/testapi.js

    r15043 r15133  
    3434    }
    3535   
    36     if (evalA == b || isNaN(evalA) && isNaN(b))
     36    if (evalA == b || isNaN(evalA) && typeof evalA == 'number' && isNaN(b) && typeof b == 'number')
    3737        print("PASS: " + a + " should be " + b + " and is.", "green");
    3838    else
     
    7575shouldBe("MyObject ? 1 : 0", 0); // toBoolean
    7676shouldBe("+MyObject", 1); // toNumber
    77 shouldBe("(MyObject + '').indexOf('MyObject') != -1", true); // toString
     77shouldBe("(MyObject.toString())", "[object CallbackObject]"); // toString
    7878shouldBe("MyObject - 0", NaN); // toPrimitive
    7979
  • trunk/JavaScriptCore/ChangeLog

    r15125 r15133  
     12006-06-29  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Maciej.
     4       
     5        - Phase 2 in the JS API.
     6       
     7        - Added support for specifying static tables of values -- this should
     8        obviate the need for using complicated callbacks for most lookups.
     9       
     10        -  API objects are now created with classes (JSClassRef) -- in order to support
     11        static values, and in order to prevent API objects from storing their
     12        data inline, and thus falling into the oversized (read: slow and prone to
     13        giving Maciej the frowny face) heap.
     14       
     15        - Added two specialized JSObject subclasses -- JSCallbackFunction and JSCallbackConstructor --
     16        to allow JSFunctionMake and JSConstructorMake to continue to work with
     17        the new class model. Another solution to this problem would be to create
     18        a custom class object for each function and constructor you make. This
     19        solution is more code but also more efficient.
     20       
     21        - Substantially beefed up the minidom example to demonstrate and test a
     22        lot of these techniques. Its output is still pretty haphazard, though.
     23       
     24        - Gave the <kjs/ preface to some includes -- I'm told this matters to
     25        building on some versions of Linux.
     26       
     27        - Implemented JSValueIsInstanceOf and JSValueIsObjectOfClass
     28       
     29        - Removed GetDescription callback. Something in the class datastructure
     30        should take care of this.
     31
     32        * API/JSBase.h:
     33        * API/JSCallbackConstructor.cpp: Added.
     34        (KJS::):
     35        (KJS::JSCallbackConstructor::JSCallbackConstructor):
     36        (KJS::JSCallbackConstructor::implementsConstruct):
     37        (KJS::JSCallbackConstructor::construct):
     38        (KJS::JSCallbackConstructor::setPrivate):
     39        (KJS::JSCallbackConstructor::getPrivate):
     40        * API/JSCallbackConstructor.h: Added.
     41        (KJS::JSCallbackConstructor::classInfo):
     42        * API/JSCallbackFunction.cpp: Added.
     43        (KJS::):
     44        (KJS::JSCallbackFunction::JSCallbackFunction):
     45        (KJS::JSCallbackFunction::implementsCall):
     46        (KJS::JSCallbackFunction::callAsFunction):
     47        (KJS::JSCallbackFunction::setPrivate):
     48        (KJS::JSCallbackFunction::getPrivate):
     49        * API/JSCallbackFunction.h: Added.
     50        (KJS::JSCallbackFunction::classInfo):
     51        * API/JSCallbackObject.cpp:
     52        (KJS::):
     53        (KJS::JSCallbackObject::JSCallbackObject):
     54        (KJS::JSCallbackObject::init):
     55        (KJS::JSCallbackObject::~JSCallbackObject):
     56        (KJS::JSCallbackObject::className):
     57        (KJS::JSCallbackObject::getOwnPropertySlot):
     58        (KJS::JSCallbackObject::put):
     59        (KJS::JSCallbackObject::deleteProperty):
     60        (KJS::JSCallbackObject::implementsConstruct):
     61        (KJS::JSCallbackObject::construct):
     62        (KJS::JSCallbackObject::implementsCall):
     63        (KJS::JSCallbackObject::callAsFunction):
     64        (KJS::JSCallbackObject::getPropertyList):
     65        (KJS::JSCallbackObject::toBoolean):
     66        (KJS::JSCallbackObject::toNumber):
     67        (KJS::JSCallbackObject::toString):
     68        (KJS::JSCallbackObject::inherits):
     69        (KJS::JSCallbackObject::staticValueGetter):
     70        (KJS::JSCallbackObject::staticFunctionGetter):
     71        (KJS::JSCallbackObject::callbackGetter):
     72        * API/JSCallbackObject.h:
     73        * API/JSCharBufferRef.cpp:
     74        * API/JSClassRef.cpp: Added.
     75        (JSClassCreate):
     76        (JSClassRetain):
     77        (JSClassRelease):
     78        * API/JSClassRef.h: Added.
     79        (StaticValueEntry::StaticValueEntry):
     80        (StaticFunctionEntry::StaticFunctionEntry):
     81        (__JSClass::__JSClass):
     82        * API/JSContextRef.cpp:
     83        (JSContextCreate):
     84        (JSEvaluate):
     85        * API/JSContextRef.h:
     86        * API/JSNode.c: Added.
     87        (JSNodePrototype_appendChild):
     88        (JSNodePrototype_removeChild):
     89        (JSNodePrototype_replaceChild):
     90        (JSNodePrototype_class):
     91        (JSNode_getNodeType):
     92        (JSNode_getChildNodes):
     93        (JSNode_getFirstChild):
     94        (JSNode_finalize):
     95        (JSNode_class):
     96        (JSNode_prototype):
     97        (JSNode_new):
     98        (JSNode_construct):
     99        * API/JSNode.h: Added.
     100        * API/JSNodeList.c: Added.
     101        (JSNodeListPrototype_item):
     102        (JSNodeListPrototype_class):
     103        (JSNodeList_length):
     104        (JSNodeList_getProperty):
     105        (JSNodeList_finalize):
     106        (JSNodeList_class):
     107        (JSNodeList_prototype):
     108        (JSNodeList_new):
     109        * API/JSNodeList.h: Added.
     110        * API/JSObjectRef.cpp:
     111        (JSObjectMake):
     112        (JSFunctionMake):
     113        (JSConstructorMake):
     114        (__JSPropertyEnumerator::__JSPropertyEnumerator):
     115        (JSObjectCreatePropertyEnumerator):
     116        (JSPropertyEnumeratorGetNext):
     117        (JSPropertyEnumeratorRetain):
     118        (JSPropertyEnumeratorRelease):
     119        * API/JSObjectRef.h:
     120        (__JSObjectCallbacks::):
     121        * API/JSValueRef.cpp:
     122        (JSValueIsObjectOfClass):
     123        (JSValueIsInstanceOf):
     124        * API/JSValueRef.h:
     125        * API/Node.c: Added.
     126        (Node_new):
     127        (Node_appendChild):
     128        (Node_removeChild):
     129        (Node_replaceChild):
     130        (Node_ref):
     131        (Node_deref):
     132        * API/Node.h: Added.
     133        * API/NodeList.c: Added.
     134        (NodeList_new):
     135        (NodeList_length):
     136        (NodeList_item):
     137        (NodeList_ref):
     138        (NodeList_deref):
     139        * API/NodeList.h: Added.
     140        * API/minidom.c:
     141        (main):
     142        (print):
     143        (createStringWithContentsOfFile):
     144        * API/minidom.js:
     145        * API/testapi.c:
     146        (assertEqualsAsCharacters):
     147        (MyObject_getProperty):
     148        (MyObject_class):
     149        (myConstructor_callAsConstructor):
     150        (main):
     151        * API/testapi.js:
     152        * JavaScriptCore.xcodeproj/project.pbxproj:
     153
    11542006-06-26  Kevin Ollivier  <kevino@theolliviers.com>
    2155       
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r15064 r15133  
    1515_JSCharBufferRelease
    1616_JSCheckSyntax
     17_JSClassCreate
    1718_JSConstructorMake
    1819_JSContextClearException
     
    2627_JSFunctionMake
    2728_JSGCCollect
     29_JSGCProtect
    2830_JSGCUnprotect
    2931_JSNullMake
    3032_JSNumberMake
     33_JSObjectCallAsConstructor
     34_JSObjectGetPrivate
     35_JSObjectGetProperty
    3136_JSObjectMake
     37_JSObjectSetPrivate
    3238_JSObjectSetProperty
    3339_JSPropertyListAdd
     
    3743_JSValueGetType
    3844_JSValueIsEqual
     45_JSValueIsInstanceOf
    3946_JSValueIsObject
     47_JSValueIsObjectOfClass
    4048_JSValueIsStrictEqual
    4149_JSValueIsUndefined
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r15085 r15133  
    3838                142711390A460BBB0080EEEA /* JSBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 142711380A460BBB0080EEEA /* JSBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
    3939                143A97E60A4A06E200456B66 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */; };
     40                1440057F0A5335640005F061 /* JSNode.c in Sources */ = {isa = PBXBuildFile; fileRef = 1440F6420A4F8B6A0005F061 /* JSNode.c */; };
     41                144005CB0A5338D10005F061 /* JSNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 1440F6410A4F8B6A0005F061 /* JSNode.h */; };
     42                144005CC0A5338F80005F061 /* Node.h in Headers */ = {isa = PBXBuildFile; fileRef = 1440051F0A531D3B0005F061 /* Node.h */; };
     43                1440063F0A53598A0005F061 /* Node.c in Sources */ = {isa = PBXBuildFile; fileRef = 144005200A531D3B0005F061 /* Node.c */; };
     44                1440074A0A536CC20005F061 /* NodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 144007480A536CC20005F061 /* NodeList.h */; };
     45                1440074B0A536CC20005F061 /* NodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 144007490A536CC20005F061 /* NodeList.c */; };
     46                144007570A5370D20005F061 /* JSNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = 144007550A5370D20005F061 /* JSNodeList.h */; };
     47                144007580A5370D20005F061 /* JSNodeList.c in Sources */ = {isa = PBXBuildFile; fileRef = 144007560A5370D20005F061 /* JSNodeList.c */; };
    4048                1440F6100A4F85670005F061 /* testapi.c in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A2D0A3E91F600BAF59C /* testapi.c */; };
     49                1440F8910A508B100005F061 /* JSCallbackFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1440F88F0A508B100005F061 /* JSCallbackFunction.h */; };
     50                1440F8920A508B100005F061 /* JSCallbackFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440F8900A508B100005F061 /* JSCallbackFunction.cpp */; };
     51                1440F8AE0A508D200005F061 /* JSCallbackConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 1440F8AC0A508D200005F061 /* JSCallbackConstructor.h */; };
     52                1440F8AF0A508D200005F061 /* JSCallbackConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440F8AD0A508D200005F061 /* JSCallbackConstructor.cpp */; };
     53                1440FCE30A51E46B0005F061 /* JSClassRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 1440FCE10A51E46B0005F061 /* JSClassRef.h */; };
     54                1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1440FCE20A51E46B0005F061 /* JSClassRef.cpp */; };
    4155                14760864099C633800437128 /* JSImmediate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14760863099C633800437128 /* JSImmediate.cpp */; };
    4256                1482B6EB0A4300B300517CFC /* JSValueRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 1482B6EA0A4300B300517CFC /* JSValueRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    5266                14ABDF5F0A437FEF00ECCA01 /* JSCallbackObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 14ABDF5D0A437FEF00ECCA01 /* JSCallbackObject.h */; };
    5367                14ABDF600A437FEF00ECCA01 /* JSCallbackObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */; };
     68                14B8EC720A5652090062BE54 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */; };
    5469                14BD534C0A3E0AEA00BAF59C /* SavedBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BD534A0A3E0AEA00BAF59C /* SavedBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
    5570                14BD53F50A3E12D800BAF59C /* ExecState.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BD53F30A3E12D800BAF59C /* ExecState.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    254269/* End PBXBuildFile section */
    255270
     271/* Begin PBXBuildStyle section */
     272                14C137130A560E70006CA9AF /* Development */ = {
     273                        isa = PBXBuildStyle;
     274                        buildSettings = {
     275                                COPY_PHASE_STRIP = NO;
     276                        };
     277                        name = Development;
     278                };
     279                14C137140A560E70006CA9AF /* Deployment */ = {
     280                        isa = PBXBuildStyle;
     281                        buildSettings = {
     282                                COPY_PHASE_STRIP = YES;
     283                        };
     284                        name = Deployment;
     285                };
     286/* End PBXBuildStyle section */
     287
    256288/* Begin PBXContainerItemProxy section */
    257289                141211350A48796100480255 /* PBXContainerItemProxy */ = {
     
    325357                141211200A48793C00480255 /* minidom */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = minidom; sourceTree = BUILT_PRODUCTS_DIR; };
    326358                142711380A460BBB0080EEEA /* JSBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBase.h; sourceTree = "<group>"; };
     359                1440051F0A531D3B0005F061 /* Node.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Node.h; sourceTree = "<group>"; };
     360                144005200A531D3B0005F061 /* Node.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = Node.c; sourceTree = "<group>"; };
     361                144007480A536CC20005F061 /* NodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeList.h; sourceTree = "<group>"; };
     362                144007490A536CC20005F061 /* NodeList.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = NodeList.c; sourceTree = "<group>"; };
     363                144007550A5370D20005F061 /* JSNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNodeList.h; sourceTree = "<group>"; };
     364                144007560A5370D20005F061 /* JSNodeList.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = JSNodeList.c; sourceTree = "<group>"; };
     365                1440F6410A4F8B6A0005F061 /* JSNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNode.h; sourceTree = "<group>"; };
     366                1440F6420A4F8B6A0005F061 /* JSNode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = JSNode.c; sourceTree = "<group>"; };
     367                1440F88F0A508B100005F061 /* JSCallbackFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackFunction.h; sourceTree = "<group>"; };
     368                1440F8900A508B100005F061 /* JSCallbackFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackFunction.cpp; sourceTree = "<group>"; };
     369                1440F8AC0A508D200005F061 /* JSCallbackConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackConstructor.h; sourceTree = "<group>"; };
     370                1440F8AD0A508D200005F061 /* JSCallbackConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackConstructor.cpp; sourceTree = "<group>"; };
     371                1440FCE10A51E46B0005F061 /* JSClassRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSClassRef.h; sourceTree = "<group>"; };
     372                1440FCE20A51E46B0005F061 /* JSClassRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSClassRef.cpp; sourceTree = "<group>"; };
    327373                14760863099C633800437128 /* JSImmediate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImmediate.cpp; sourceTree = "<group>"; };
    328374                1482B6EA0A4300B300517CFC /* JSValueRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSValueRef.h; sourceTree = "<group>"; };
     
    338384                14ABDF5D0A437FEF00ECCA01 /* JSCallbackObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObject.h; sourceTree = "<group>"; };
    339385                14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackObject.cpp; sourceTree = "<group>"; };
     386                14B8ECA60A5653980062BE54 /* JavaScriptCore.exp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.exports; path = JavaScriptCore.exp; sourceTree = "<group>"; };
    340387                14BD534A0A3E0AEA00BAF59C /* SavedBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SavedBuiltins.h; sourceTree = "<group>"; };
    341388                14BD53F30A3E12D800BAF59C /* ExecState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExecState.h; sourceTree = "<group>"; };
     
    350397                14F137580A3A727E00F26F90 /* Context.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Context.cpp; sourceTree = "<group>"; };
    351398                14F137820A3A765B00F26F90 /* context.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = context.h; sourceTree = "<group>"; };
    352                 45E12D8806A49B0F00E9DF84 /* testkjs.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; path = testkjs.cpp; sourceTree = "<group>"; tabWidth = 8; };
     399                45E12D8806A49B0F00E9DF84 /* testkjs.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = testkjs.cpp; path = ../kjs/testkjs.cpp; sourceTree = "<group>"; tabWidth = 8; };
    353400                5114F47B05E4426200D1BBBD /* runtime_root.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; name = runtime_root.cpp; path = bindings/runtime_root.cpp; sourceTree = "<group>"; tabWidth = 8; };
    354401                5114F47C05E4426200D1BBBD /* runtime_root.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = runtime_root.h; path = bindings/runtime_root.h; sourceTree = "<group>"; tabWidth = 8; };
     
    554601                        buildActionMask = 2147483647;
    555602                        files = (
     603                                14B8EC720A5652090062BE54 /* CoreFoundation.framework in Frameworks */,
    556604                                141211310A48794D00480255 /* JavaScriptCore.framework in Frameworks */,
    557605                        );
     
    612660                        children = (
    613661                                937B63CC09E766D200A671DD /* DerivedSources.make */,
     662                                14B8ECA60A5653980062BE54 /* JavaScriptCore.exp */,
     663                                141211000A48772600480255 /* tests */,
    614664                                1432EBD70A34CAD400717B9F /* API */,
    615665                                65417200039E01BA0058BFEB /* kjs */,
     
    641691                        isa = PBXGroup;
    642692                        children = (
     693                                144005170A531CB50005F061 /* minidom */,
    643694                                14BD5A2D0A3E91F600BAF59C /* testapi.c */,
    644695                                14D857740A4696C80032146C /* testapi.js */,
    645                                 141211020A48780900480255 /* minidom.c */,
    646                                 1412110D0A48788700480255 /* minidom.js */,
     696                                45E12D8806A49B0F00E9DF84 /* testkjs.cpp */,
    647697                        );
    648698                        name = tests;
     699                        path = API;
    649700                        sourceTree = "<group>";
    650701                };
     
    655706                                14BD5A2F0A3E91F600BAF59C /* JavaScriptCore.h */,
    656707                                142711380A460BBB0080EEEA /* JSBase.h */,
     708                                1440F8AD0A508D200005F061 /* JSCallbackConstructor.cpp */,
     709                                1440F8AC0A508D200005F061 /* JSCallbackConstructor.h */,
     710                                1440F8900A508B100005F061 /* JSCallbackFunction.cpp */,
     711                                1440F88F0A508B100005F061 /* JSCallbackFunction.h */,
    657712                                14ABDF5E0A437FEF00ECCA01 /* JSCallbackObject.cpp */,
    658713                                14ABDF5D0A437FEF00ECCA01 /* JSCallbackObject.h */,
    659714                                1482B74C0A43032800517CFC /* JSCharBufferRef.cpp */,
    660715                                1482B74B0A43032800517CFC /* JSCharBufferRef.h */,
     716                                1440FCE20A51E46B0005F061 /* JSClassRef.cpp */,
     717                                1440FCE10A51E46B0005F061 /* JSClassRef.h */,
    661718                                14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */,
    662719                                14BD5A2A0A3E91F600BAF59C /* JSContextRef.h */,
     
    665722                                14BD5A2B0A3E91F600BAF59C /* JSValueRef.cpp */,
    666723                                1482B6EA0A4300B300517CFC /* JSValueRef.h */,
    667                                 141211000A48772600480255 /* tests */,
    668724                        );
    669725                        path = API;
     726                        sourceTree = "<group>";
     727                };
     728                144005170A531CB50005F061 /* minidom */ = {
     729                        isa = PBXGroup;
     730                        children = (
     731                                1440F6420A4F8B6A0005F061 /* JSNode.c */,
     732                                1440F6410A4F8B6A0005F061 /* JSNode.h */,
     733                                144007560A5370D20005F061 /* JSNodeList.c */,
     734                                144007550A5370D20005F061 /* JSNodeList.h */,
     735                                141211020A48780900480255 /* minidom.c */,
     736                                1412110D0A48788700480255 /* minidom.js */,
     737                                144005200A531D3B0005F061 /* Node.c */,
     738                                1440051F0A531D3B0005F061 /* Node.h */,
     739                                144007490A536CC20005F061 /* NodeList.c */,
     740                                144007480A536CC20005F061 /* NodeList.h */,
     741                        );
     742                        name = minidom;
    670743                        sourceTree = "<group>";
    671744                };
     
    863936                                F692A87F0255597D01FF60F7 /* string_object.cpp */,
    864937                                F692A8800255597D01FF60F7 /* string_object.h */,
    865                                 45E12D8806A49B0F00E9DF84 /* testkjs.cpp */,
    866938                                F692A8840255597D01FF60F7 /* types.h */,
    867939                                F692A8850255597D01FF60F7 /* ustring.cpp */,
     
    9381010
    9391011/* Begin PBXHeadersBuildPhase section */
     1012                144005C70A5338C60005F061 /* Headers */ = {
     1013                        isa = PBXHeadersBuildPhase;
     1014                        buildActionMask = 2147483647;
     1015                        files = (
     1016                                144005CB0A5338D10005F061 /* JSNode.h in Headers */,
     1017                                144005CC0A5338F80005F061 /* Node.h in Headers */,
     1018                                1440074A0A536CC20005F061 /* NodeList.h in Headers */,
     1019                                144007570A5370D20005F061 /* JSNodeList.h in Headers */,
     1020                        );
     1021                        runOnlyForDeploymentPostprocessing = 0;
     1022                };
    9401023                932F5B3F0822A1C700736975 /* Headers */ = {
    9411024                        isa = PBXHeadersBuildPhase;
     
    10651148                                14ABDF5F0A437FEF00ECCA01 /* JSCallbackObject.h in Headers */,
    10661149                                142711390A460BBB0080EEEA /* JSBase.h in Headers */,
     1150                                1440F8910A508B100005F061 /* JSCallbackFunction.h in Headers */,
     1151                                1440F8AE0A508D200005F061 /* JSCallbackConstructor.h in Headers */,
     1152                                1440FCE30A51E46B0005F061 /* JSClassRef.h in Headers */,
    10671153                        );
    10681154                        runOnlyForDeploymentPostprocessing = 0;
     
    10761162                        buildPhases = (
    10771163                                1412111D0A48793C00480255 /* Sources */,
     1164                                1440025E0A52563F0005F061 /* ShellScript */,
    10781165                                1412111E0A48793C00480255 /* Frameworks */,
     1166                                144005C70A5338C60005F061 /* Headers */,
    10791167                        );
    10801168                        buildRules = (
     
    11671255                        isa = PBXProject;
    11681256                        buildConfigurationList = 149C277108902AFE008A9EFC /* Build configuration list for PBXProject "JavaScriptCore" */;
     1257                        buildSettings = {
     1258                        };
     1259                        buildStyles = (
     1260                                14C137130A560E70006CA9AF /* Development */,
     1261                                14C137140A560E70006CA9AF /* Deployment */,
     1262                        );
    11691263                        hasScannedForEncodings = 1;
    11701264                        mainGroup = 0867D691FE84028FC02AAC07 /* JavaScriptCore */;
     
    11841278
    11851279/* Begin PBXShellScriptBuildPhase section */
     1280                1440025E0A52563F0005F061 /* ShellScript */ = {
     1281                        isa = PBXShellScriptBuildPhase;
     1282                        buildActionMask = 2147483647;
     1283                        files = (
     1284                        );
     1285                        inputPaths = (
     1286                        );
     1287                        outputPaths = (
     1288                        );
     1289                        runOnlyForDeploymentPostprocessing = 0;
     1290                        shellPath = /bin/sh;
     1291                        shellScript = "cp \"${SRCROOT}/API/minidom.js\" \"${BUILT_PRODUCTS_DIR}\"";
     1292                };
    11861293                14D857B50A469C100032146C /* ShellScript */ = {
    11871294                        isa = PBXShellScriptBuildPhase;
     
    12321339                        buildActionMask = 2147483647;
    12331340                        files = (
     1341                                1440063F0A53598A0005F061 /* Node.c in Sources */,
     1342                                1440057F0A5335640005F061 /* JSNode.c in Sources */,
    12341343                                141211340A48795800480255 /* minidom.c in Sources */,
     1344                                1440074B0A536CC20005F061 /* NodeList.c in Sources */,
     1345                                144007580A5370D20005F061 /* JSNodeList.c in Sources */,
    12351346                        );
    12361347                        runOnlyForDeploymentPostprocessing = 0;
     
    13301441                                1482B7E40A43076000517CFC /* JSObjectRef.cpp in Sources */,
    13311442                                14ABDF600A437FEF00ECCA01 /* JSCallbackObject.cpp in Sources */,
     1443                                1440F8920A508B100005F061 /* JSCallbackFunction.cpp in Sources */,
     1444                                1440F8AF0A508D200005F061 /* JSCallbackConstructor.cpp in Sources */,
     1445                                1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */,
    13321446                        );
    13331447                        runOnlyForDeploymentPostprocessing = 0;
     
    14851599                        buildSettings = {
    14861600                                DEBUG_DEFINES = "";
    1487                                 DEBUG_INFORMATION_FORMAT = dwarf;
     1601                                DEBUG_INFORMATION_FORMAT = stabs;
    14881602                                DYLIB_COMPATIBILITY_VERSION = 1;
    14891603                                DYLIB_CURRENT_VERSION = 1;
Note: See TracChangeset for help on using the changeset viewer.