Ignore:
Timestamp:
Apr 2, 2015, 11:53:32 AM (10 years ago)
Author:
Yusuke Suzuki
Message:

Clean up EnumerationMode to easily extend
https://bugs.webkit.org/show_bug.cgi?id=143276

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

To make the followings easily,

  1. Adding new flag Include/ExcludeSymbols in the Object.getOwnPropertySymbols patch
  2. Make ExcludeSymbols implicitly default for the existing flags

we encapsulate EnumerationMode flags into EnumerationMode class.

And this class manages 2 flags. Later it will be extended to 3.

  1. DontEnumPropertiesMode (default is Exclude)
  2. JSObjectPropertiesMode (default is Include)
  3. SymbolPropertiesMode (default is Exclude)

SymbolPropertiesMode will be added in Object.getOwnPropertySymbols patch.

This patch replaces places using ExcludeDontEnumProperties
to EnumerationMode() value which represents default mode.

  • API/JSCallbackObjectFunctions.h:

(JSC::JSCallbackObject<Parent>::getOwnNonIndexPropertyNames):

  • API/JSObjectRef.cpp:

(JSObjectCopyPropertyNames):

  • bindings/ScriptValue.cpp:

(Deprecated::jsToInspectorValue):

  • bytecode/ObjectAllocationProfile.h:

(JSC::ObjectAllocationProfile::possibleDefaultPropertyCount):

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncSort):

  • runtime/EnumerationMode.h:

(JSC::EnumerationMode::EnumerationMode):
(JSC::EnumerationMode::includeDontEnumProperties):
(JSC::EnumerationMode::includeJSObjectProperties):
(JSC::shouldIncludeDontEnumProperties): Deleted.
(JSC::shouldExcludeDontEnumProperties): Deleted.
(JSC::shouldIncludeJSObjectPropertyNames): Deleted.
(JSC::modeThatSkipsJSObject): Deleted.

  • runtime/GenericArgumentsInlines.h:

(JSC::GenericArguments<Type>::getOwnPropertyNames):

  • runtime/JSArray.cpp:

(JSC::JSArray::getOwnNonIndexPropertyNames):

  • runtime/JSArrayBuffer.cpp:

(JSC::JSArrayBuffer::getOwnNonIndexPropertyNames):

  • runtime/JSArrayBufferView.cpp:

(JSC::JSArrayBufferView::getOwnNonIndexPropertyNames):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::getOwnNonIndexPropertyNames):

  • runtime/JSFunction.h:
  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::JSGenericTypedArrayView<Adaptor>::getOwnNonIndexPropertyNames):

  • runtime/JSLexicalEnvironment.cpp:

(JSC::JSLexicalEnvironment::getOwnNonIndexPropertyNames):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::Holder::appendNextProperty):
(JSC::Walker::walk):

  • runtime/JSObject.cpp:

(JSC::getClassPropertyNames):
(JSC::JSObject::getOwnPropertyNames):
(JSC::JSObject::getOwnNonIndexPropertyNames):
(JSC::JSObject::getGenericPropertyNames):

  • runtime/JSPropertyNameEnumerator.h:

(JSC::propertyNameEnumerator):

  • runtime/JSSymbolTableObject.cpp:

(JSC::JSSymbolTableObject::getOwnNonIndexPropertyNames):

  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorKeys):
(JSC::defineProperties):
(JSC::objectConstructorSeal):
(JSC::objectConstructorFreeze):
(JSC::objectConstructorIsSealed):
(JSC::objectConstructorIsFrozen):

  • runtime/RegExpObject.cpp:

(JSC::RegExpObject::getOwnNonIndexPropertyNames):
(JSC::RegExpObject::getPropertyNames):
(JSC::RegExpObject::getGenericPropertyNames):

  • runtime/StringObject.cpp:

(JSC::StringObject::getOwnPropertyNames):

  • runtime/Structure.cpp:

(JSC::Structure::getPropertyNamesFromStructure):

Source/WebCore:

Use default EnumerationMode().

  • bindings/js/Dictionary.cpp:

(WebCore::Dictionary::getOwnPropertiesAsStringHashMap):
(WebCore::Dictionary::getOwnPropertyNames):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::serialize):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):

  • bindings/scripts/test/JS/JSFloat64Array.h:
  • bindings/scripts/test/JS/JSTestEventTarget.h:
  • bridge/NP_jsobject.cpp:

(_NPN_Enumerate):

  • bridge/runtime_array.cpp:

(JSC::RuntimeArray::getOwnPropertyNames):

Source/WebKit/mac:

Use default EnumerationMode().

  • Plugins/Hosted/NetscapePluginInstanceProxy.mm:

(WebKit::NetscapePluginInstanceProxy::enumerate):

Source/WebKit2:

Use default EnumerationMode().

  • WebProcess/Plugins/Netscape/NPJSObject.cpp:

(WebKit::NPJSObject::enumerate):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r182205 r182280  
    7979
    8080        for (auto iter = table->begin(); iter != table->end(); ++iter) {
    81             if ((!(iter->attributes() & DontEnum) || shouldIncludeDontEnumProperties(mode)) && !((iter->attributes() & BuiltinOrFunction) && didReify))
     81            if ((!(iter->attributes() & DontEnum) || mode.includeDontEnumProperties()) && !((iter->attributes() & BuiltinOrFunction) && didReify))
    8282                propertyNames.add(Identifier::fromString(&vm, iter.key()));
    8383        }
     
    15191519void JSObject::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
    15201520{
    1521     if (!shouldIncludeJSObjectPropertyNames(mode)) {
     1521    if (!mode.includeJSObjectProperties()) {
    15221522        // We still have to get non-indexed properties from any subclasses of JSObject that have them.
    15231523        object->methodTable(exec->vm())->getOwnNonIndexPropertyNames(object, exec, propertyNames, mode);
     
    15731573            SparseArrayValueMap::const_iterator end = map->end();
    15741574            for (SparseArrayValueMap::const_iterator it = map->begin(); it != end; ++it) {
    1575                 if (shouldIncludeDontEnumProperties(mode) || !(it->value.attributes & DontEnum))
     1575                if (mode.includeDontEnumProperties() || !(it->value.attributes & DontEnum))
    15761576                    keys.uncheckedAppend(static_cast<unsigned>(it->key));
    15771577            }
     
    15951595    getClassPropertyNames(exec, object->classInfo(), propertyNames, mode, object->staticFunctionsReified());
    15961596
    1597     if (!shouldIncludeJSObjectPropertyNames(mode))
     1597    if (!mode.includeJSObjectProperties())
    15981598        return;
    15991599   
     
    28012801{
    28022802    VM& vm = exec->vm();
    2803     object->methodTable(vm)->getOwnPropertyNames(object, exec, propertyNames, modeThatSkipsJSObject(mode));
     2803    object->methodTable(vm)->getOwnPropertyNames(object, exec, propertyNames, EnumerationMode(mode, JSObjectPropertiesMode::Exclude));
    28042804
    28052805    if (object->prototype().isNull())
Note: See TracChangeset for help on using the changeset viewer.