Changeset 14951 in webkit for trunk/JavaScriptCore/kjs/object.cpp


Ignore:
Timestamp:
Jun 21, 2006, 2:09:19 PM (19 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Anders.


  • First cut at C API to JavaScript. Includes a unit test, 'testapi.c', and the outline of a test app, 'minidom.c'.


Includes one change to JSC internals: Rename propList to getPropertyList and have it
take its target property list by reference so that subclasses can
add properties to the list before calling through to their superclasses.


Also, I just ran prepare-ChangeLog in about 10 seconds, and I would like
to give a shout-out to that.


  • API/APICast.h: Added. (toJS): (toRef):
  • API/JSBase.h: Added.
  • API/JSCallbackObject.cpp: Added. (KJS::): (KJS::JSCallbackObject::JSCallbackObject): (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::setPrivate): (KJS::JSCallbackObject::getPrivate): (KJS::JSCallbackObject::cachedValueGetter): (KJS::JSCallbackObject::callbackGetter):
  • API/JSCallbackObject.h: Added. (KJS::JSCallbackObject::classInfo):
  • API/JSCharBufferRef.cpp: Added. (JSStringMake): (JSCharBufferCreate): (JSCharBufferCreateUTF8): (JSCharBufferRetain): (JSCharBufferRelease): (JSValueCopyStringValue): (JSCharBufferGetLength): (JSCharBufferGetCharactersPtr): (JSCharBufferGetCharacters): (JSCharBufferGetMaxLengthUTF8): (JSCharBufferGetCharactersUTF8): (JSCharBufferIsEqual): (JSCharBufferIsEqualUTF8): (JSCharBufferCreateWithCFString): (CFStringCreateWithJSCharBuffer):
  • API/JSCharBufferRef.h: Added.
  • API/JSContextRef.cpp: Added. (JSContextCreate): (JSContextDestroy): (JSContextGetGlobalObject): (JSEvaluate): (JSCheckSyntax): (JSContextHasException): (JSContextGetException): (JSContextClearException): (JSContextSetException):
  • API/JSContextRef.h: Added.
  • API/JSObjectRef.cpp: Added. (JSValueToObject): (JSObjectMake): (JSFunctionMake): (JSObjectGetDescription): (JSObjectGetPrototype): (JSObjectSetPrototype): (JSObjectHasProperty): (JSObjectGetProperty): (JSObjectSetProperty): (JSObjectDeleteProperty): (JSObjectGetPrivate): (JSObjectSetPrivate): (JSObjectIsFunction): (JSObjectCallAsFunction): (JSObjectIsConstructor): (JSObjectCallAsConstructor): (JSPropertyListEnumerator::JSPropertyListEnumerator): (JSObjectCreatePropertyEnumerator): (JSPropertyEnumeratorGetNext): (JSPropertyEnumeratorRetain): (JSPropertyEnumeratorRelease): (JSPropertyListAdd):
  • API/JSObjectRef.h: Added.
  • API/JSValueRef.cpp: Added. (JSValueGetType): (JSValueIsUndefined): (JSValueIsNull): (JSValueIsBoolean): (JSValueIsNumber): (JSValueIsString): (JSValueIsObject): (JSValueIsEqual): (JSValueIsStrictEqual): (JSUndefinedMake): (JSNullMake): (JSBooleanMake): (JSNumberMake): (JSValueToBoolean): (JSValueToNumber): (JSGCProtect): (JSGCUnprotect): (JSGCCollect):
  • API/JSValueRef.h: Added.
  • API/JavaScriptCore.h: Added.
  • API/minidom.c: Added. (main):
  • API/minidom.html: Added.
  • API/minidom.js: Added.
  • API/testapi.c: Added. (assertEqualsAsBoolean): (assertEqualsAsNumber): (assertEqualsAsUTF8String): (assertEqualsAsCharactersPtr): (assertEqualsAsCharacters): (MyObject_initialize): (MyObject_copyDescription): (MyObject_hasProperty): (MyObject_getProperty): (MyObject_setProperty): (MyObject_deleteProperty): (MyObject_getPropertyList): (MyObject_callAsFunction): (MyObject_callAsConstructor): (MyObject_convertToType): (MyObject_finalize): (print_callAsFunction): (main): (createStringWithContentsOfFile):
  • API/testapi.js: Added.
  • ChangeLog:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • bindings/npruntime_impl.h:
  • kjs/array_instance.h:
  • kjs/array_object.cpp: (ArrayInstance::getPropertyList):
  • kjs/interpreter.cpp: (KJS::Interpreter::evaluate):
  • kjs/nodes.cpp: (ForInNode::execute):
  • kjs/object.cpp: (KJS::JSObject::put): (KJS::JSObject::canPut): (KJS::JSObject::deleteProperty): (KJS::JSObject::propertyIsEnumerable): (KJS::JSObject::getPropertyAttributes): (KJS::JSObject::getPropertyList):
  • kjs/object.h:
  • kjs/property_map.cpp: (KJS::PropertyMap::get):
  • kjs/property_map.h:
  • kjs/scope_chain.cpp: (KJS::ScopeChain::print):
  • kjs/string_object.cpp: (StringInstance::getPropertyList):
  • kjs/string_object.h:
  • kjs/ustring.h: (KJS::UString::Rep::ref):

JavaScriptGlue:

Reviewed by Anders.


  • Required for JS API: Rename propList to getPropertyList and have it take its target property list by reference so that subclasses can add properties to the list before calling through to their superclasses.
  • JSUtils.cpp: (KJSValueToCFTypeInternal):
  • JSValueWrapper.cpp: (JSValueWrapper::JSObjectCopyPropertyNames):
  • UserObjectImp.cpp: (UserObjectImp::getPropertyList):
  • UserObjectImp.h:
File:
1 edited

Legend:

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

    r13821 r14951  
    237237    obj = this;
    238238    while (true) {
    239       int attributes;
     239      unsigned attributes;
    240240      if (JSValue *gs = obj->_prop.get(propertyName, attributes)) {
    241241        if (attributes & GetterSetter) {
     
    278278bool JSObject::canPut(ExecState *, const Identifier &propertyName) const
    279279{
    280   int attributes;
     280  unsigned attributes;
    281281   
    282282  // Don't look in the prototype here. We can always put an override
     
    305305bool JSObject::deleteProperty(ExecState */*exec*/, const Identifier &propertyName)
    306306{
    307   int attributes;
     307  unsigned attributes;
    308308  JSValue *v = _prop.get(propertyName, attributes);
    309309  if (v) {
     
    453453bool JSObject::propertyIsEnumerable(ExecState*, const Identifier& propertyName) const
    454454{
    455   int attributes;
     455  unsigned attributes;
    456456 
    457457  if (!getPropertyAttributes(propertyName, attributes))
     
    461461}
    462462
    463 bool JSObject::getPropertyAttributes(const Identifier& propertyName, int& attributes) const
     463bool JSObject::getPropertyAttributes(const Identifier& propertyName, unsigned& attributes) const
    464464{
    465465  if (_prop.get(propertyName, attributes))
     
    476476}
    477477
    478 ReferenceList JSObject::propList(ExecState *exec, bool recursive)
    479 {
    480   ReferenceList list;
    481   if (_proto->isObject() && recursive)
    482     list = static_cast<JSObject*>(_proto)->propList(exec,recursive);
    483 
    484   _prop.addEnumerablesToReferenceList(list, this);
     478void JSObject::getPropertyList(ExecState *exec, ReferenceList& propertyList, bool recursive)
     479{
     480  _prop.addEnumerablesToReferenceList(propertyList, this);
    485481
    486482  // Add properties from the static hashtable of properties
     
    492488      for (int i = 0; i < size; ++i, ++e) {
    493489        if ( e->s && !(e->attr & DontEnum) )
    494           list.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap
     490          propertyList.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap
    495491      }
    496492    }
    497493    info = info->parentClass;
    498494  }
    499 
    500   return list;
     495  if (_proto->isObject() && recursive)
     496      static_cast<JSObject*>(_proto)->getPropertyList(exec, propertyList, recursive);
    501497}
    502498
Note: See TracChangeset for help on using the changeset viewer.