diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
tree | e367e64a75991c554930278175d403c072de6bb8 /Source/JavaScriptCore/runtime/Options.cpp | |
parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source/JavaScriptCore/runtime/Options.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/Options.cpp | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/Source/JavaScriptCore/runtime/Options.cpp b/Source/JavaScriptCore/runtime/Options.cpp index 386eb4fcf..40711bfa3 100644 --- a/Source/JavaScriptCore/runtime/Options.cpp +++ b/Source/JavaScriptCore/runtime/Options.cpp @@ -36,7 +36,6 @@ #include <wtf/PageBlock.h> #include <wtf/StdLibExtras.h> #include <wtf/StringExtras.h> -#include <wtf/UnusedParam.h> #if OS(DARWIN) && ENABLE(PARALLEL_GC) #include <sys/sysctl.h> @@ -72,6 +71,11 @@ static bool parse(const char* string, double& value) return sscanf(string, "%lf", &value) == 1; } +static bool parse(const char* string, OptionRange& value) +{ + return value.init(string); +} + template<typename T> void overrideOptionWithHeuristic(T& variable, const char* name) { @@ -105,6 +109,59 @@ static unsigned computeNumberOfGCMarkers(int maxNumberOfGCMarkers) return cpusToUse; } +bool OptionRange::init(const char* rangeString) +{ + // rangeString should be in the form of [!]<low>[:<high>] + // where low and high are unsigned + + bool invert = false; + + if (m_state > Uninitialized) + return true; + + if (!rangeString) { + m_state = InitError; + return false; + } + + m_rangeString = rangeString; + + if (*rangeString == '!') { + invert = true; + rangeString++; + } + + int scanResult = sscanf(rangeString, " %u:%u", &m_lowLimit, &m_highLimit); + + if (!scanResult || scanResult == EOF) { + m_state = InitError; + return false; + } + + if (scanResult == 1) + m_highLimit = m_lowLimit; + + if (m_lowLimit > m_highLimit) { + m_state = InitError; + return false; + } + + m_state = invert ? Inverted : Normal; + + return true; +} + +bool OptionRange::isInRange(unsigned count) +{ + if (m_state < Normal) + return true; + + if ((m_lowLimit <= count) && (count <= m_highLimit)) + return m_state == Normal ? true : false; + + return m_state == Normal ? false : true; +} + Options::Entry Options::s_options[Options::numberOfOptions]; // Realize the names for each of the options: @@ -187,6 +244,7 @@ bool Options::setOption(const char* arg) #define FOR_EACH_OPTION(type_, name_, defaultValue_) \ if (!strncmp(arg, #name_, equalStr - arg)) { \ type_ value; \ + value = 0; \ bool success = parse(valueStr, value); \ if (success) { \ name_() = value; \ @@ -227,6 +285,9 @@ void Options::dumpOption(OptionID id, FILE* stream, const char* header, const ch case int32Type: fprintf(stream, "%d", s_options[id].u.int32Val); break; + case optionRangeType: + fprintf(stream, "%s", s_options[id].u.optionRangeVal.rangeString()); + break; } fprintf(stream, "%s", footer); } |