Title: [222695] trunk/Source/WebCore
- Revision
- 222695
- Author
- [email protected]
- Date
- 2017-10-01 20:17:18 -0700 (Sun, 01 Oct 2017)
Log Message
[Settings] Enums should not be passed by const reference
https://bugs.webkit.org/show_bug.cgi?id=177727
Patch by Sam Weinig <[email protected]> on 2017-10-01
Reviewed by Darin Adler.
* Scripts/GenerateSettings/GenerateSettingsImplementationFile.py:
* Scripts/GenerateSettings/GenerateSettingsHeaderFile.py:
(printGetterAndSetter):
Use the new typeIsAggregate predicate to determine whether to
use const reference or not.
(includeForSetting): Deleted.
Move includeForSetting to Settings.py with the rest of the Setting
helpers.
* Scripts/GenerateSettings/Settings.py:
(mapToIDLType):
(typeIsPrimitive):
(typeIsAggregate):
Add predicate to determine if a setting's type is an aggregate (struct or class)
or a primitive. Remove references to size_t, which is not used.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (222694 => 222695)
--- trunk/Source/WebCore/ChangeLog 2017-10-02 01:35:37 UTC (rev 222694)
+++ trunk/Source/WebCore/ChangeLog 2017-10-02 03:17:18 UTC (rev 222695)
@@ -1,5 +1,32 @@
2017-10-01 Sam Weinig <[email protected]>
+ [Settings] Enums should not be passed by const reference
+ https://bugs.webkit.org/show_bug.cgi?id=177727
+
+ Reviewed by Darin Adler.
+
+ * Scripts/GenerateSettings/GenerateSettingsImplementationFile.py:
+ * Scripts/GenerateSettings/GenerateSettingsHeaderFile.py:
+ (printGetterAndSetter):
+
+ Use the new typeIsAggregate predicate to determine whether to
+ use const reference or not.
+
+ (includeForSetting): Deleted.
+
+ Move includeForSetting to Settings.py with the rest of the Setting
+ helpers.
+
+ * Scripts/GenerateSettings/Settings.py:
+ (mapToIDLType):
+ (typeIsPrimitive):
+ (typeIsAggregate):
+
+ Add predicate to determine if a setting's type is an aggregate (struct or class)
+ or a primitive. Remove references to size_t, which is not used.
+
+2017-10-01 Sam Weinig <[email protected]>
+
Add support for DOM aborting (https://dom.spec.whatwg.org/#aborting-ongoing-activities)
https://bugs.webkit.org/show_bug.cgi?id=177718
Modified: trunk/Source/WebCore/Scripts/GenerateSettings/GenerateSettingsHeaderFile.py (222694 => 222695)
--- trunk/Source/WebCore/Scripts/GenerateSettings/GenerateSettingsHeaderFile.py 2017-10-02 01:35:37 UTC (rev 222694)
+++ trunk/Source/WebCore/Scripts/GenerateSettings/GenerateSettingsHeaderFile.py 2017-10-02 03:17:18 UTC (rev 222695)
@@ -25,7 +25,7 @@
import os.path
-from Settings import license, makeConditionalString, makeSetterFunctionName
+from Settings import license, makeConditionalString, makeSetterFunctionName, includeForSetting, typeIsAggregate
def generateSettingsHeaderFile(outputDirectory, settings):
@@ -77,32 +77,6 @@
outputFile.close()
-def includeForSetting(setting):
- # Always prefer an explicit include.
- if setting.include:
- return setting.include
-
- # Include nothing for primitive types.
- if setting.type == 'int':
- return None
- if setting.type == 'unsigned':
- return None
- if setting.type == 'double':
- return None
- if setting.type == 'float':
- return None
- if setting.type == 'bool':
- return None
-
- # Special case String, as it doesn't follow the pattern of being in a file with the
- # same name as the class.
- if setting.type == 'String':
- return "<wtf/text/WTFString.h>"
-
- # Default to using the type name for the include.
- return "\"" + setting.type + ".h\""
-
-
def printIncludes(outputFile, sortedUnconditionalSettingsNames, sortedConditionals, settingsByConditional, settings):
unconditionalIncludes = set()
includesByConditional = {}
@@ -142,7 +116,7 @@
# Export is only needed if the definition is not in the header.
webcoreExport = "WEBCORE_EXPORT " if setting.setNeedsStyleRecalcInAllFrames else ""
- if setting.type[0].islower():
+ if not typeIsAggregate(setting):
outputFile.write(" " + setting.type + " " + setting.name + "() const { return m_" + setting.name + "; } \n")
outputFile.write(" " + webcoreExport + "void " + setterFunctionName + "(" + setting.type + " " + setting.name + ")")
else:
Modified: trunk/Source/WebCore/Scripts/GenerateSettings/GenerateSettingsImplementationFile.py (222694 => 222695)
--- trunk/Source/WebCore/Scripts/GenerateSettings/GenerateSettingsImplementationFile.py 2017-10-02 01:35:37 UTC (rev 222694)
+++ trunk/Source/WebCore/Scripts/GenerateSettings/GenerateSettingsImplementationFile.py 2017-10-02 03:17:18 UTC (rev 222695)
@@ -25,7 +25,7 @@
import os.path
-from Settings import license, makeConditionalString, makeSetterFunctionName
+from Settings import license, makeConditionalString, makeSetterFunctionName, typeIsAggregate
def generateSettingsImplementationFile(outputDirectory, settings):
@@ -155,7 +155,7 @@
setterFunctionName = makeSetterFunctionName(setting)
- if setting.type[0].islower():
+ if not typeIsAggregate(setting):
outputFile.write("void SettingsGenerated::" + setterFunctionName + "(" + setting.type + " " + setting.name + ")\n")
else:
outputFile.write("void SettingsGenerated::" + setterFunctionName + "(const " + setting.type + "& " + setting.name + ")\n")
Modified: trunk/Source/WebCore/Scripts/GenerateSettings/Settings.py (222694 => 222695)
--- trunk/Source/WebCore/Scripts/GenerateSettings/Settings.py 2017-10-02 01:35:37 UTC (rev 222694)
+++ trunk/Source/WebCore/Scripts/GenerateSettings/Settings.py 2017-10-02 03:17:18 UTC (rev 222695)
@@ -104,7 +104,7 @@
# FIXME: Add support for more types including enumerate types.
if setting.type == 'int':
return 'long'
- if setting.type == 'unsigned' or setting.type == 'size_t':
+ if setting.type == 'unsigned':
return 'unsigned long'
if setting.type == 'double':
return 'double'
@@ -117,6 +117,50 @@
return None
+def typeIsPrimitive(setting):
+ if setting.type == 'int':
+ return True
+ if setting.type == 'unsigned':
+ return True
+ if setting.type == 'double':
+ return True
+ if setting.type == 'float':
+ return True
+ if setting.type == 'bool':
+ return True
+ return False
+
+
+def typeIsAggregate(setting):
+ # Special case supported aggregates (e.g. classes/structs)
+ if setting.type == 'String':
+ return True
+ if setting.type == 'IntSize':
+ return True
+
+ # Everything else is an enum
+ # FIXME: Should we make it a requirement to annotate enums or classes/structs in someway?
+ return False
+
+
+def includeForSetting(setting):
+ # Always prefer an explicit include.
+ if setting.include:
+ return setting.include
+
+ # Include nothing for primitive types.
+ if typeIsPrimitive(setting):
+ return None
+
+ # Special case String, as it doesn't follow the pattern of being in a file with the
+ # same name as the class.
+ if setting.type == 'String':
+ return "<wtf/text/WTFString.h>"
+
+ # Default to using the type name for the include.
+ return "\"" + setting.type + ".h\""
+
+
def parseInput(input):
settings = {}
for line in open(input, "r"):
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes