return 0;
}
-void JSCallbackObject::getPropertyList(ExecState* exec, ReferenceList& propertyList, bool recursive)
+void JSCallbackObject::getPropertyList(ReferenceList& propertyList, bool recursive)
{
- JSContextRef context = toRef(exec);
JSObjectRef thisRef = toRef(this);
for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parent) {
if (JSObjectAddPropertiesToListCallback addPropertiesToList = jsClass->callbacks.addPropertiesToList)
- addPropertiesToList(context, thisRef, toRef(&propertyList), toRef(exec->exceptionSlot()));
+ addPropertiesToList(thisRef, toRef(&propertyList));
if (__JSClass::StaticValuesTable* staticValues = jsClass->staticValues) {
typedef __JSClass::StaticValuesTable::const_iterator iterator;
}
}
- JSObject::getPropertyList(exec, propertyList, recursive);
+ JSObject::getPropertyList(propertyList, recursive);
}
bool JSCallbackObject::toBoolean(ExecState* exec) const
virtual bool implementsCall() const;
virtual JSValue* callAsFunction(ExecState*, JSObject* thisObj, const List &args);
- virtual void getPropertyList(ExecState*, ReferenceList& propertyList, bool recursive);
+ virtual void getPropertyList(ReferenceList& propertyList, bool recursive);
virtual bool toBoolean(ExecState*) const;
virtual double toNumber(ExecState*) const;
ReferenceListIterator iterator;
};
-JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSContextRef context, JSObjectRef object)
+JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSObjectRef object)
{
JSLock lock;
- ExecState* exec = toJS(context);
JSObject* jsObject = toJS(object);
JSPropertyEnumeratorRef enumerator = new __JSPropertyEnumerator();
- jsObject->getPropertyList(exec, enumerator->list);
+ jsObject->getPropertyList(enumerator->list);
enumerator->iterator = enumerator->list.begin();
return JSPropertyEnumeratorRetain(enumerator);
/*!
@typedef JSObjectAddPropertiesToListCallback
@abstract The callback invoked when adding an object's properties to a property list.
-@param context The current execution context.
@param object The JSObject whose properties need to be added to propertyList.
@param propertyList A JavaScript property list that will be used to enumerate object's properties.
-@param exception A pointer to a JSValueRef in which to return an exception, if any.
@discussion If you named your function GetPropertyList, you would declare it like this:
-void AddPropertiesToList(JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList, JSValueRef* exception);
+void AddPropertiesToList(JSObjectRef object, JSPropertyListRef propertyList);
Use JSPropertyListAdd to add properties to propertyList.
Property lists are used by JSPropertyEnumerators and JavaScript for...in loops.
*/
typedef void
-(*JSObjectAddPropertiesToListCallback) (JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList, JSValueRef* exception);
+(*JSObjectAddPropertiesToListCallback) (JSObjectRef object, JSPropertyListRef propertyList);
/*!
@typedef JSObjectCallAsFunctionCallback
@field getProperty The callback invoked when getting the value of a given property.
@field setProperty The callback invoked when setting the value of a given property.
@field deleteProperty The callback invoked when deleting a given property.
-@field getPropertyList The callback invoked when adding an object's properties to a property list.
+@field addPropertiesToList The callback invoked when adding an object's properties to a property list.
@field callAsFunction The callback invoked when an object is called as a function.
@field hasInstance The callback invoked when an object is used in an 'instanceof' expression.
@field callAsConstructor The callback invoked when an object is used as a constructor in a 'new' expression.
/*!
@function
@abstract Creates an enumerator for an object's properties.
-@param context The execution context to use.
@param object The object whose properties you want to enumerate.
@result A JSPropertyEnumerator with a list of object's properties. Ownership follows the Create Rule.
*/
-JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSContextRef context, JSObjectRef object);
+JSPropertyEnumeratorRef JSObjectCreatePropertyEnumerator(JSObjectRef object);
/*!
@function
@abstract Retains a property enumerator.
return false;
}
-static void MyObject_getPropertyList(JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList, JSValueRef* exception)
+static void MyObject_addPropertiesToList(JSObjectRef object, JSPropertyListRef propertyList)
{
UNUSED_PARAM(context);
MyObject_getProperty,
MyObject_setProperty,
MyObject_deleteProperty,
- MyObject_getPropertyList,
+ MyObject_addPropertiesToList,
MyObject_callAsFunction,
MyObject_callAsConstructor,
MyObject_hasInstance,
o = JSObjectMake(context, NULL, NULL);
JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber(1), kJSPropertyAttributeNone);
JSObjectSetProperty(context, o, jsCFIString, JSValueMakeNumber(1), kJSPropertyAttributeDontEnum);
- JSPropertyEnumeratorRef enumerator = JSObjectCreatePropertyEnumerator(context, o);
+ JSPropertyEnumeratorRef enumerator = JSObjectCreatePropertyEnumerator(o);
int count = 0;
while (JSPropertyEnumeratorGetNextName(enumerator))
++count;
+2006-07-12 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Maciej.
+
+ - Removed context and exception parameters from JSObjectGetPropertyEnumerator,
+ removing the spurious use of ExecState inside JavaScriptCore that made
+ us think this was necessary in the first place.
+
+ (StringInstance::getPropertyList): Use getString instead of toString because
+ we know we're dealing with a string -- we put it there in the first place.
+ While we're at it, store the string's size instead of retrieving it each time
+ through the loop, to avoid the unnecessary killing of puppies.
+ * kjs/string_object.h:
+
2006-07-12 Maciej Stachowiak <mjs@apple.com>
4eviewed by Geoff.
__ZN3KJS8JSObject14callAsFunctionEPNS_9ExecStateEPS0_RKNS_4ListE
__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateEj
-__ZN3KJS8JSObject15getPropertyListEPNS_9ExecStateERNS_13ReferenceListEb
+__ZN3KJS8JSObject15getPropertyListERNS_13ReferenceListEb
__ZN3KJS8JSObject18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
__ZN3KJS8JSObject22fillGetterPropertySlotERNS_12PropertySlotEPPNS_7JSValueE
__ZN3KJS8JSObject3putEPNS_9ExecStateERKNS_10IdentifierEPNS_7JSValueEi
virtual void put(ExecState *exec, unsigned propertyName, JSValue *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
- virtual void getPropertyList(ExecState*, ReferenceList& propertyList, bool recursive);
+ virtual void getPropertyList(ReferenceList& propertyList, bool recursive);
virtual void mark();
return JSObject::deleteProperty(exec, Identifier::from(index));
}
-void ArrayInstance::getPropertyList(ExecState* exec, ReferenceList& propertyList, bool recursive)
+void ArrayInstance::getPropertyList(ReferenceList& propertyList, bool recursive)
{
// avoid fetching this every time through the loop
JSValue *undefined = jsUndefined();
propertyList.append(Reference(this, i));
}
}
- return JSObject::getPropertyList(exec, propertyList, recursive);
+ return JSObject::getPropertyList(propertyList, recursive);
}
void ArrayInstance::resizeStorage(unsigned newLength)
KJS_CHECKEXCEPTION
v = e->toObject(exec);
- v->getPropertyList(exec, propertyList);
+ v->getPropertyList(propertyList);
ReferenceListIterator propIt = propertyList.begin();
return false;
}
-void JSObject::getPropertyList(ExecState *exec, ReferenceList& propertyList, bool recursive)
+void JSObject::getPropertyList(ReferenceList& propertyList, bool recursive)
{
_prop.addEnumerablesToReferenceList(propertyList, this);
info = info->parentClass;
}
if (_proto->isObject() && recursive)
- static_cast<JSObject*>(_proto)->getPropertyList(exec, propertyList, recursive);
+ static_cast<JSObject*>(_proto)->getPropertyList(propertyList, recursive);
}
bool JSObject::toBoolean(ExecState */*exec*/) const
* included in the list.
* @return A List of References to properties of the object.
**/
- virtual void getPropertyList(ExecState *exec, ReferenceList& propertyList, bool recursive = true);
+ virtual void getPropertyList(ReferenceList& propertyList, bool recursive = true);
/**
* Returns the internal value of the object. This is used for objects such
#ifndef NDEBUG
-void ScopeChain::print(ExecState* exec)
+void ScopeChain::print()
{
ScopeChainIterator scopeEnd = end();
for (ScopeChainIterator scopeIter = begin(); scopeIter != scopeEnd; ++scopeIter) {
JSObject* o = *scopeIter;
ReferenceList propertyList;
- o->getPropertyList(exec, propertyList, false);
+ o->getPropertyList(propertyList, false);
ReferenceListIterator propEnd = propertyList.end();
fprintf(stderr, "----- [scope %p] -----\n", o);
void mark();
#ifndef NDEBUG
- void print(ExecState*);
+ void print();
#endif
private:
return JSObject::deleteProperty(exec, propertyName);
}
-void StringInstance::getPropertyList(ExecState *exec, ReferenceList& propertyList, bool recursive)
+void StringInstance::getPropertyList(ReferenceList& propertyList, bool recursive)
{
//### FIXME: should avoid duplicates with prototype
- UString str = internalValue()->toString(exec);
- for (int i = 0; i < str.size(); i++)
+ int size = internalValue()->getString().size();
+ for (int i = 0; i < size; i++)
propertyList.append(Reference(this, i));
- return JSObject::getPropertyList(exec, propertyList, recursive);
+ return JSObject::getPropertyList(propertyList, recursive);
}
// ------------------------------ StringPrototype ---------------------------
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual void put(ExecState *exec, const Identifier &propertyName, JSValue *value, int attr = None);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
- virtual void getPropertyList(ExecState *exec, ReferenceList& propertyList, bool recursive);
+ virtual void getPropertyList(ReferenceList& propertyList, bool recursive);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;