JSObjectRef thisRef = toRef(this);
if (m_callback) {
- size_t argumentCount = args.size();
+ int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
- for (size_t i = 0; i < argumentCount; i++)
+ for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(args[i]);
return toJS(m_callback(ctx, thisRef, argumentCount, arguments, toRef(exec->exceptionSlot())));
}
JSObjectRef thisRef = toRef(this);
JSObjectRef thisObjRef = toRef(thisObj);
- size_t argumentCount = args.size();
+ int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
- for (size_t i = 0; i < argumentCount; i++)
+ for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(args[i]);
return toJS(m_callback(execRef, thisRef, thisObjRef, argumentCount, arguments, toRef(exec->exceptionSlot())));
}
} while ((jsClass = jsClass->parentClass));
// initialize from base to derived
- for (int i = initRoutines.size() - 1; i >= 0; i--) {
+ for (int i = static_cast<int>(initRoutines.size()) - 1; i >= 0; i--) {
JSObjectInitializeCallback initialize = initRoutines[i];
initialize(toRef(exec), toRef(this));
}
for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsConstructorCallback callAsConstructor = jsClass->callAsConstructor) {
- size_t argumentCount = args.size();
+ int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
- for (size_t i = 0; i < argumentCount; i++)
+ for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(args[i]);
return toJS(callAsConstructor(execRef, thisRef, argumentCount, arguments, toRef(exec->exceptionSlot())));
}
for (JSClassRef jsClass = m_class; jsClass; jsClass = jsClass->parentClass) {
if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) {
- size_t argumentCount = args.size();
+ int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
- for (size_t i = 0; i < argumentCount; i++)
+ for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(args[i]);
return toJS(callAsFunction(execRef, thisRef, thisObjRef, argumentCount, arguments, toRef(exec->exceptionSlot())));
}
JSStringRef JSPropertyNameArrayGetNameAtIndex(JSPropertyNameArrayRef array, size_t index)
{
- return toRef(array->array[index].ustring().rep());
+ return toRef(array->array[static_cast<unsigned>(index)].ustring().rep());
}
void JSPropertyNameAccumulatorAddName(JSPropertyNameAccumulatorRef array, JSStringRef propertyName)
JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars)
{
JSLock lock;
- return toRef(UString(reinterpret_cast<const UChar*>(chars), numChars).rep()->ref());
+ return toRef(UString(reinterpret_cast<const UChar*>(chars), static_cast<int>(numChars)).rep()->ref());
}
JSStringRef JSStringCreateWithUTF8CString(const char* string)
+2006-10-28 Darin Adler <darin@apple.com>
+
+ Reviewed by Geoff.
+
+ - made changes so the code compiles with the highest warning level
+ under MSVC (disabling some warnings, making some code fixes)
+
+ * API/JSCallbackConstructor.cpp:
+ (KJS::JSCallbackConstructor::construct):
+ * API/JSCallbackFunction.cpp:
+ (KJS::JSCallbackFunction::callAsFunction):
+ * API/JSCallbackObject.cpp:
+ (KJS::JSCallbackObject::init):
+ (KJS::JSCallbackObject::construct):
+ (KJS::JSCallbackObject::callAsFunction):
+ * API/JSObjectRef.cpp:
+ (JSPropertyNameArrayGetNameAtIndex):
+ * API/JSStringRef.cpp:
+ (JSStringCreateWithCharacters):
+ * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
+ * bindings/c/c_utility.cpp:
+ (KJS::Bindings::convertUTF8ToUTF16):
+ (KJS::Bindings::coerceValueToNPVariantStringType):
+ (KJS::Bindings::convertValueToNPVariant):
+ * kjs/DateMath.h:
+ (KJS::GregorianDateTime::GregorianDateTime):
+ * kjs/ExecState.h:
+ (KJS::ExecState::hadException):
+ * kjs/JSImmediate.h:
+ (KJS::JSImmediate::fromDouble):
+ (KJS::JSImmediate::toDouble):
+ (KJS::JSImmediate::NanAsBits):
+ (KJS::JSImmediate::oneAsBits):
+ * kjs/Parser.h:
+ * kjs/PropertyNameArray.h:
+ (KJS::PropertyNameArray::size):
+ * kjs/array_object.cpp:
+ (ArrayObjectImp::callAsFunction):
+ * kjs/bool_object.cpp:
+ (BooleanObjectImp::callAsFunction):
+ * kjs/collector.cpp:
+ (KJS::Collector::allocate):
+ (KJS::Collector::markCurrentThreadConservatively):
+ (KJS::Collector::collect):
+ * kjs/completion.h:
+ (KJS::Completion::isValueCompletion):
+ * kjs/date_object.cpp:
+ (KJS::findMonth):
+ * kjs/debugger.cpp:
+ (Debugger::sourceParsed):
+ (Debugger::sourceUnused):
+ (Debugger::exception):
+ (Debugger::atStatement):
+ (Debugger::callEvent):
+ (Debugger::returnEvent):
+ * kjs/dtoa.cpp:
+ * kjs/error_object.cpp:
+ (ErrorObjectImp::callAsFunction):
+ (NativeErrorImp::callAsFunction):
+ * kjs/function.cpp:
+ (KJS::FunctionImp::processVarDecls):
+ (KJS::GlobalFuncImp::callAsFunction):
+ * kjs/function_object.cpp:
+ (FunctionPrototype::callAsFunction):
+ * kjs/grammar.y:
+ * kjs/identifier.cpp:
+ (KJS::CStringTranslator::translate):
+ (KJS::Identifier::add):
+ * kjs/internal.h:
+ * kjs/lexer.cpp:
+ (Lexer::lex):
+ (Lexer::isIdentStart):
+ (Lexer::isIdentPart):
+ (isDecimalDigit):
+ (Lexer::isHexDigit):
+ (Lexer::isOctalDigit):
+ (Lexer::matchPunctuator):
+ (Lexer::singleEscape):
+ (Lexer::convertOctal):
+ (Lexer::convertHex):
+ (Lexer::convertUnicode):
+ (Lexer::record8):
+ * kjs/lexer.h:
+ * kjs/math_object.cpp:
+ (MathFuncImp::callAsFunction):
+ * kjs/number_object.cpp:
+ (integer_part_noexp):
+ (intPow10):
+ (NumberProtoFunc::callAsFunction):
+ (NumberObjectImp::callAsFunction):
+ * kjs/object.cpp:
+ (KJS::JSObject::deleteProperty):
+ (KJS::JSObject::callAsFunction):
+ (KJS::JSObject::toBoolean):
+ (KJS::JSObject::toObject):
+ * kjs/object.h:
+ (KJS::JSObject::getPropertySlot):
+ * kjs/property_map.cpp:
+ (KJS::isValid):
+ (KJS::PropertyMap::put):
+ (KJS::PropertyMap::insert):
+ (KJS::PropertyMap::containsGettersOrSetters):
+ * kjs/property_map.h:
+ (KJS::PropertyMap::hasGetterSetterProperties):
+ * kjs/property_slot.h:
+ * kjs/string_object.cpp:
+ (StringInstance::getPropertyNames):
+ (StringObjectImp::callAsFunction):
+ (StringObjectFuncImp::callAsFunction):
+ * kjs/ustring.cpp:
+ (KJS::UString::Rep::computeHash):
+ (KJS::UString::UString):
+ (KJS::UString::from):
+ (KJS::UString::append):
+ (KJS::UString::ascii):
+ (KJS::UString::operator=):
+ (KJS::UString::find):
+ (KJS::UString::rfind):
+ * kjs/ustring.h:
+ (KJS::UChar::high):
+ (KJS::UChar::low):
+ (KJS::UCharReference::low):
+ (KJS::UCharReference::high):
+ * kjs/value.cpp:
+ (KJS::JSValue::toUInt16):
+ * kjs/value.h:
+ * pcre/pcre_compile.c:
+ (get_othercase_range):
+ * pcre/pcre_exec.c:
+ (match):
+ * pcre/pcre_internal.h:
+ * wtf/HashFunctions.h:
+ (WTF::intHash):
+ (WTF::PtrHash::hash):
+ * wtf/MathExtras.h:
+ (isnan):
+ (lround):
+ (lroundf):
+ * wtf/StringExtras.h:
+ (strncasecmp):
+ * wtf/unicode/icu/UnicodeIcu.h:
+ (WTF::Unicode::isPrintableChar):
+
2006-10-26 W. Andy Carrel <wac@google.com>
Reviewed by Maciej.
RuntimeLibrary="3"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
- WarningLevel="1"
- Detect64BitPortabilityProblems="false"
+ WarningLevel="4"
+ WarnAsError="true"
+ Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
- DisableSpecificWarnings="4138; 4996; 4355"
+ DisableSpecificWarnings="4127;4355;4510;4512;4610;4706;4996"
ForcedIncludeFiles=""
/>
<Tool
RuntimeLibrary="2"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
- WarningLevel="1"
- Detect64BitPortabilityProblems="false"
+ WarningLevel="4"
+ WarnAsError="true"
+ Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
- DisableSpecificWarnings="4138; 4996; 4355"
+ DisableSpecificWarnings="4127;4355;4510;4512;4610;4706;4996"
ForcedIncludeFiles=""
/>
<Tool
BasicRuntimeChecks="3"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
- WarningLevel="1"
- Detect64BitPortabilityProblems="false"
+ WarningLevel="4"
+ WarnAsError="true"
+ Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
+ DisableSpecificWarnings="4127;4355;4510;4512;4610;4706;4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
assert(UTF16Chars);
if (UTF8Length == -1)
- UTF8Length = strlen(UTF8Chars);
+ UTF8Length = static_cast<int>(strlen(UTF8Chars));
// UTF16Length maximum length is the length of the UTF8 string, plus one to include terminator
// Without the plus one, it will convert ok, but a warning is generated from the converter as
{
UString ustring = value->toString(exec);
CString cstring = ustring.UTF8String();
- NPString string = { (const NPUTF8 *)cstring.c_str(), cstring.size() };
+ NPString string = { (const NPUTF8 *)cstring.c_str(), static_cast<uint32_t>(cstring.size()) };
NPN_InitializeVariantWithStringCopy(result, &string);
}
if (type == StringType) {
UString ustring = value->toString(exec);
CString cstring = ustring.UTF8String();
- NPString string = { (const NPUTF8 *)cstring.c_str(), cstring.size() };
+ NPString string = { (const NPUTF8 *)cstring.c_str(), static_cast<uint32_t>(cstring.size()) };
NPN_InitializeVariantWithStringCopy(result, &string);
} else if (type == NumberType) {
DOUBLE_TO_NPVARIANT(value->toNumber(exec), *result);
timeZone = new char[inZoneSize];
strncpy(timeZone, inTm.tm_zone, inZoneSize);
#else
- utcOffset = (getUTCOffset() / msPerSecond) + (isDST ? secondsPerHour : 0);
- timeZone = NULL;
+ utcOffset = static_cast<int>(getUTCOffset() / msPerSecond + isDST ? secondsPerHour : 0);
+ timeZone = 0;
#endif
}
void clearException() { m_exception = 0; }
JSValue* exception() const { return m_exception; }
JSValue** exceptionSlot() { return &m_exception; }
- bool hadException() const { return m_exception; }
+ bool hadException() const { return !!m_exception; }
private:
ExecState(Interpreter* interp, Context* con)
#include <stdint.h>
#include <stdlib.h>
+#if COMPILER(MSVC)
+#pragma warning(push)
+#pragma warning(disable: 4127)
+#pragma warning(disable: 4244)
+#pragma warning(disable: 4305)
+#pragma warning(disable: 4307)
+#pragma warning(disable: 4309)
+#endif
+
namespace KJS {
class ExecState;
const uint32_t NaN32AsBits = 0x7fc00000;
const uint64_t NaN64AsBits = 0x7ff80000ULL << 32;
- if (JSImmediate::is32bit())
+ if (is32bit())
return NaN32AsBits;
- else if (JSImmediate::is64bit())
+ else if (is64bit())
return NaN64AsBits;
else {
abort();
const uint32_t One32AsBits = 0x3f800000;
const uint64_t One64AsBits = 0x3ff00000ULL << 32;
- if (JSImmediate::is32bit())
+ if (is32bit())
return One32AsBits;
- else if (JSImmediate::is64bit())
+ else if (is64bit())
return One64AsBits;
else {
abort();
} // namespace KJS
+#if COMPILER(MSVC)
+#pragma warning(pop)
+#endif
+
#endif
class Node;
class ProgramNode;
- class UChar;
class UString;
+ struct UChar;
+
/**
* @internal
*
void add(const Identifier&);
iterator begin() const { return m_vector.begin(); }
iterator end() const { return m_vector.end(); }
- int size() const { return m_vector.size(); }
+ size_t size() const { return m_vector.size(); }
Identifier& operator[](unsigned i) { return m_vector[i]; }
const Identifier& operator[](unsigned i) const { return m_vector[i]; }
}
// ECMA 15.6.1
-JSValue *ArrayObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
+JSValue *ArrayObjectImp::callAsFunction(ExecState *exec, JSObject *, const List &args)
{
// equivalent to 'new Array(....)'
return construct(exec,args);
}
// ECMA 15.6.1
-JSValue *BooleanObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
+JSValue *BooleanObjectImp::callAsFunction(ExecState *exec, JSObject *, const List &args)
{
if (args.isEmpty())
return jsBoolean(false);
// could avoid the casts by using a cell offset, but this avoids a relatively-slow multiply
targetBlock->freeList = reinterpret_cast<CollectorCell *>(reinterpret_cast<char *>(newCell + 1) + newCell->u.freeCell.next);
- targetBlock->usedCells = targetBlockUsedCells + 1;
+ targetBlock->usedCells = static_cast<uint32_t>(targetBlockUsedCells + 1);
heap.numLiveObjects = numLiveObjects + 1;
return newCell;
void Collector::markCurrentThreadConservatively()
{
jmp_buf registers;
+#if COMPILER(MSVC)
+#pragma warning(push)
+#pragma warning(disable: 4611)
+#endif
setjmp(registers);
+#if COMPILER(MSVC)
+#pragma warning(pop)
+#endif
#if PLATFORM(DARWIN)
pthread_t thread = pthread_self();
}
}
- curBlock->usedCells = usedCells;
+ curBlock->usedCells = static_cast<uint32_t>(usedCells);
curBlock->freeList = freeList;
if (usedCells == 0) {
ComplType complType() const { return comp; }
JSValue *value() const { return val; }
Identifier target() const { return tar; }
- bool isValueCompletion() const { return val; }
+ bool isValueCompletion() const { return !!val; }
private:
ComplType comp;
JSValue *val;
// Do the formatting
const int bufsize=128;
char timebuffer[bufsize];
- int ret = strftime(timebuffer, bufsize, formatStrings[format], &localTM);
+ size_t ret = strftime(timebuffer, bufsize, formatStrings[format], &localTM);
if ( ret == 0 )
return jsString("");
JSValue *result = 0;
UString s;
#if !PLATFORM(DARWIN)
- const int bufsize=100;
- char timebuffer[bufsize];
CString oldlocale = setlocale(LC_TIME, 0);
if (!oldlocale.size())
oldlocale = setlocale(LC_ALL, 0);
for (int i = 0; i < 3; ++i) {
if (!*monthStr)
return -1;
- needle[i] = tolower(*monthStr++);
+ needle[i] = static_cast<char>(tolower(*monthStr++));
}
needle[3] = '\0';
const char *haystack = "janfebmaraprmayjunjulaugsepoctnovdec";
const char *str = strstr(haystack, needle);
if (str) {
- int position = str - haystack;
+ int position = static_cast<int>(str - haystack);
if (position % 3 == 0)
return position / 3;
}
return false;
}
-bool Debugger::sourceParsed(ExecState */*exec*/, int /*sourceId*/, const UString &/*sourceURL*/,
+bool Debugger::sourceParsed(ExecState*, int /*sourceId*/, const UString &/*sourceURL*/,
const UString &/*source*/, int /*startingLineNumber*/, int /*errorLine*/, const UString & /*errorMsg*/)
{
return true;
}
-bool Debugger::sourceUnused(ExecState */*exec*/, int /*sourceId*/)
+bool Debugger::sourceUnused(ExecState*, int /*sourceId*/)
{
return true;
}
-bool Debugger::exception(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
- JSValue */*exception*/)
+bool Debugger::exception(ExecState*, int /*sourceId*/, int /*lineno*/,
+ JSValue* /*exception */)
{
return true;
}
-bool Debugger::atStatement(ExecState */*exec*/, int /*sourceId*/, int /*firstLine*/,
+bool Debugger::atStatement(ExecState*, int /*sourceId*/, int /*firstLine*/,
int /*lastLine*/)
{
return true;
}
-bool Debugger::callEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
- JSObject */*function*/, const List &/*args*/)
+bool Debugger::callEvent(ExecState*, int /*sourceId*/, int /*lineno*/,
+ JSObject* /*function*/, const List &/*args*/)
{
return true;
}
-bool Debugger::returnEvent(ExecState */*exec*/, int /*sourceId*/, int /*lineno*/,
- JSObject */*function*/)
+bool Debugger::returnEvent(ExecState*, int /*sourceId*/, int /*lineno*/,
+ JSObject* /*function*/)
{
return true;
}
#include "config.h"
#include "dtoa.h"
+#if COMPILER(MSVC)
+#pragma warning(disable: 4244)
+#pragma warning(disable: 4245)
+#pragma warning(disable: 4554)
+#endif
+
#if PLATFORM(BIG_ENDIAN)
#define IEEE_MC68k
#else
}
// ECMA 15.9.2
-JSValue *ErrorObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
+JSValue *ErrorObjectImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
{
// "Error()" gives the sames result as "new Error()"
return construct(exec,args);
return obj;
}
-JSValue *NativeErrorImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
+JSValue *NativeErrorImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
{
return construct(exec,args);
}
#endif
}
-void FunctionImp::processVarDecls(ExecState */*exec*/)
+void FunctionImp::processVarDecls(ExecState*)
{
}
return s.toDouble( true /*tolerant*/, false /* NaN for empty string */ );
}
-JSValue *GlobalFuncImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
+JSValue *GlobalFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
{
JSValue *res = jsUndefined();
}
// ECMA 15.3.4
-JSValue *FunctionPrototype::callAsFunction(ExecState */*exec*/, JSObject */*thisObj*/, const List &/*args*/)
+JSValue *FunctionPrototype::callAsFunction(ExecState*, JSObject* /*thisObj*/, const List &/*args*/)
{
return jsUndefined();
}
static Node *makeTypeOfNode(Node *expr);
static Node *makeDeleteNode(Node *expr);
+#if COMPILER(MSVC)
+#pragma warning(disable: 4065)
+#pragma warning(disable: 4244)
+#pragma warning(disable: 4702)
+#endif
+
%}
%union {
namespace WTF {
- template<typename T> class DefaultHash;
- template<typename T> class StrHash;
+ template<typename T> struct DefaultHash;
+ template<typename T> struct StrHash;
template<> struct StrHash<KJS::UString::Rep *> {
static unsigned hash(const KJS::UString::Rep *key) { return key->hash(); }
static void translate(UString::Rep*& location, const char *c, unsigned hash)
{
- int length = strlen(c);
+ size_t length = strlen(c);
UChar *d = static_cast<UChar *>(fastMalloc(sizeof(UChar) * length));
- for (int i = 0; i != length; i++)
+ for (size_t i = 0; i != length; i++)
d[i] = c[i];
- UString::Rep *r = UString::Rep::create(d, length).release();
+ UString::Rep *r = UString::Rep::create(d, static_cast<int>(length)).release();
r->isIdentifier = 1;
r->rc = 0;
r->_hash = hash;
{
if (!c)
return &UString::Rep::null;
- int length = strlen(c);
+ size_t length = strlen(c);
if (length == 0)
return &UString::Rep::empty;
FunctionCode,
AnonymousCode };
- class AttachedInterpreter;
+ struct AttachedInterpreter;
class DebuggerImp {
public:
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
+ * Copyright (C) 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
#include "nodes.h"
#include <wtf/unicode/Unicode.h>
-static bool isDecimalDigit(unsigned short c);
+static bool isDecimalDigit(int);
// we can't specify the namespace in yacc's C output, so do it here
using namespace KJS;
}
} else if (current == '"' || current == '\'') {
state = InString;
- stringType = current;
+ stringType = static_cast<unsigned short>(current);
} else if (isIdentStart(current)) {
record16(current);
state = InIdentifierOrKeyword;
nextLine();
state = InString;
} else {
- record16(singleEscape(current));
+ record16(singleEscape(static_cast<unsigned short>(current)));
state = InString;
}
break;
return cr || lf || current == 0x2028 || current == 0x2029;
}
-bool Lexer::isIdentStart(unsigned short c)
+bool Lexer::isIdentStart(int c)
{
return (WTF::Unicode::category(c) & (WTF::Unicode::Letter_Uppercase
| WTF::Unicode::Letter_Lowercase
|| c == '$' || c == '_';
}
-bool Lexer::isIdentPart(unsigned short c)
+bool Lexer::isIdentPart(int c)
{
return (WTF::Unicode::category(c) & (WTF::Unicode::Letter_Uppercase
| WTF::Unicode::Letter_Lowercase
|| c == '$' || c == '_';
}
-static bool isDecimalDigit(unsigned short c)
+static bool isDecimalDigit(int c)
{
return (c >= '0' && c <= '9');
}
-bool Lexer::isHexDigit(unsigned short c)
+bool Lexer::isHexDigit(int c)
{
return (c >= '0' && c <= '9' ||
c >= 'a' && c <= 'f' ||
c >= 'A' && c <= 'F');
}
-bool Lexer::isOctalDigit(unsigned short c) const
+bool Lexer::isOctalDigit(int c)
{
return (c >= '0' && c <= '7');
}
-int Lexer::matchPunctuator(unsigned short c1, unsigned short c2,
- unsigned short c3, unsigned short c4)
+int Lexer::matchPunctuator(int c1, int c2, int c3, int c4)
{
if (c1 == '>' && c2 == '>' && c3 == '>' && c4 == '=') {
shift(4);
}
}
-unsigned short Lexer::singleEscape(unsigned short c) const
+unsigned short Lexer::singleEscape(unsigned short c)
{
switch(c) {
case 'b':
}
}
-unsigned short Lexer::convertOctal(unsigned short c1, unsigned short c2,
- unsigned short c3) const
+unsigned short Lexer::convertOctal(int c1, int c2, int c3)
{
- return ((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0');
+ return static_cast<unsigned short>((c1 - '0') * 64 + (c2 - '0') * 8 + c3 - '0');
}
-unsigned char Lexer::convertHex(unsigned short c)
+unsigned char Lexer::convertHex(int c)
{
if (c >= '0' && c <= '9')
- return (c - '0');
- else if (c >= 'a' && c <= 'f')
- return (c - 'a' + 10);
- else
- return (c - 'A' + 10);
+ return static_cast<unsigned char>(c - '0');
+ if (c >= 'a' && c <= 'f')
+ return static_cast<unsigned char>(c - 'a' + 10);
+ return static_cast<unsigned char>(c - 'A' + 10);
}
-unsigned char Lexer::convertHex(unsigned short c1, unsigned short c2)
+unsigned char Lexer::convertHex(int c1, int c2)
{
return ((convertHex(c1) << 4) + convertHex(c2));
}
-KJS::UChar Lexer::convertUnicode(unsigned short c1, unsigned short c2,
- unsigned short c3, unsigned short c4)
+KJS::UChar Lexer::convertUnicode(int c1, int c2, int c3, int c4)
{
return KJS::UChar((convertHex(c1) << 4) + convertHex(c2),
(convertHex(c3) << 4) + convertHex(c4));
}
-void Lexer::record8(unsigned short c)
+void Lexer::record8(int c)
{
- assert(c <= 0xff);
+ ASSERT(c >= 0);
+ ASSERT(c <= 0xff);
// enlarge buffer if full
if (pos8 >= size8 - 1) {
int lastToken;
State state;
- void setDone(State s);
+ void setDone(State);
unsigned int pos;
void shift(unsigned int p);
void nextLine();
bool isWhiteSpace() const;
bool isLineTerminator();
- bool isOctalDigit(unsigned short c) const;
+ static bool isOctalDigit(int);
- int matchPunctuator(unsigned short c1, unsigned short c2,
- unsigned short c3, unsigned short c4);
- unsigned short singleEscape(unsigned short c) const;
- unsigned short convertOctal(unsigned short c1, unsigned short c2,
- unsigned short c3) const;
+ int matchPunctuator(int c1, int c2, int c3, int c4);
+ static unsigned short singleEscape(unsigned short);
+ static unsigned short convertOctal(int c1, int c2, int c3);
public:
- static unsigned char convertHex(unsigned short c1);
- static unsigned char convertHex(unsigned short c1, unsigned short c2);
- static UChar convertUnicode(unsigned short c1, unsigned short c2,
- unsigned short c3, unsigned short c4);
- static bool isIdentStart(unsigned short c);
- static bool isIdentPart(unsigned short c);
- static bool isHexDigit(unsigned short c);
+ static unsigned char convertHex(int);
+ static unsigned char convertHex(int c1, int c2);
+ static UChar convertUnicode(int c1, int c2, int c3, int c4);
+ static bool isIdentStart(int);
+ static bool isIdentPart(int);
+ static bool isHexDigit(int);
#ifdef KJS_DEBUG_MEM
/**
private:
- void record8(unsigned short c);
- void record16(int c);
- void record16(UChar c);
+ void record8(int);
+ void record16(int);
+ void record16(UChar);
KJS::Identifier *makeIdentifier(UChar *buffer, unsigned int pos);
UString *makeUString(UChar *buffer, unsigned int pos);
putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
}
-JSValue *MathFuncImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
+JSValue *MathFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
{
double arg = args[0]->toNumber(exec);
double arg2 = args[1]->toNumber(exec);
break;
case MathObjectImp::Random:
if (!randomSeeded) {
- srand(time(0));
+ srand(static_cast<unsigned>(time(0)));
randomSeeded = true;
}
result = (double)rand() / RAND_MAX;
int decimalPoint;
int sign;
char *result = kjs_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
- int length = strlen(result);
+ size_t length = strlen(result);
UString str = sign ? "-" : "";
if (decimalPoint == 9999) {
} else {
Vector<char, 1024> buf(decimalPoint + 1);
- if (length <= decimalPoint) {
+ if (static_cast<int>(length) <= decimalPoint) {
strcpy(buf, result);
memset(buf + length, '0', decimalPoint - length);
} else
}
if (negative)
- return 1.0 / result;
- else
- return result;
+ return static_cast<double>(1.0 / result);
+ return static_cast<double>(result);
}
// ECMA 15.7.4.2 - 15.7.4.7
return jsString("NaN");
char *result = kjs_dtoa(x, 0, 0, &decimalPoint, &sign, NULL);
- int length = strlen(result);
+ size_t length = strlen(result);
decimalPoint += decimalAdjust;
int i = 0;
buf[i++] = result[0];
if (fractionDigits->isUndefined())
- f = length-1;
+ f = static_cast<int>(length) - 1;
if (length > 1 && f > 0) {
buf[i++] = '.';
- int haveFDigits = length-1;
+ int haveFDigits = static_cast<int>(length) - 1;
if (f < haveFDigits) {
strncpy(buf+i,result+1, f);
i += f;
}
else {
strcpy(buf+i,result+1);
- i += length-1;
+ i += static_cast<int>(length) - 1;
for (int j = 0; j < f-haveFDigits; j++)
buf[i++] = '0';
}
exponential = exponential * -1;
}
if (exponential >= 100) {
- buf[i++] = '0' + exponential / 100;
+ buf[i++] = static_cast<char>('0' + exponential / 100);
}
if (exponential >= 10) {
- buf[i++] = '0' + (exponential % 100) / 10;
+ buf[i++] = static_cast<char>('0' + (exponential % 100) / 10);
}
- buf[i++] = '0' + exponential % 10;
+ buf[i++] = static_cast<char>('0' + exponential % 10);
buf[i++] = '\0';
}
}
// ECMA 15.7.2
-JSValue *NumberObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
+JSValue *NumberObjectImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
{
if (args.isEmpty())
return jsNumber(0);
}
// ECMA 8.6.2.5
-bool JSObject::deleteProperty(ExecState */*exec*/, const Identifier &propertyName)
+bool JSObject::deleteProperty(ExecState* /*exec*/, const Identifier &propertyName)
{
unsigned attributes;
JSValue *v = _prop.get(propertyName, attributes);
return false;
}
-JSValue *JSObject::callAsFunction(ExecState */*exec*/, JSObject */*thisObj*/, const List &/*args*/)
+JSValue *JSObject::callAsFunction(ExecState* /*exec*/, JSObject* /*thisObj*/, const List &/*args*/)
{
assert(false);
return NULL;
static_cast<JSObject*>(_proto)->getPropertyNames(exec, propertyNames);
}
-bool JSObject::toBoolean(ExecState */*exec*/) const
+bool JSObject::toBoolean(ExecState*) const
{
return true;
}
return prim->toString(exec);
}
-JSObject *JSObject::toObject(ExecState */*exec*/) const
+JSObject *JSObject::toObject(ExecState*) const
{
return const_cast<JSObject*>(this);
}
namespace KJS {
- class HashTable;
- class HashEntry;
- class ListImp;
class InternalFunctionImp;
class PropertyNameArray;
+ struct HashEntry;
+ struct HashTable;
+
// ECMA 262-3 8.6.1
// Property attributes
enum Attribute { None = 0,
// Returns true if the key is not null or the deleted sentinel, false otherwise
static inline bool isValid(UString::Rep* key)
{
- return reinterpret_cast<uintptr_t>(key) & ~0x1;
+ return !!(reinterpret_cast<uintptr_t>(key) & ~0x1);
}
PropertyMap::~PropertyMap()
rep->ref();
_singleEntry.key = rep;
_singleEntry.value = value;
- _singleEntry.attributes = attributes;
+ _singleEntry.attributes = static_cast<short>(attributes);
checkConsistency();
return;
}
rep->ref();
entries[i].key = rep;
entries[i].value = value;
- entries[i].attributes = attributes;
+ entries[i].attributes = static_cast<short>(attributes);
entries[i].index = ++_table->lastIndexUsed;
++_table->keyCount;
entries[i].key = key;
entries[i].value = value;
- entries[i].attributes = attributes;
+ entries[i].attributes = static_cast<short>(attributes);
entries[i].index = index;
}
{
if (!_table) {
#if USE_SINGLE_ENTRY
- return _singleEntry.attributes & GetterSetter;
-#endif
+ return !!(_singleEntry.attributes & GetterSetter);
+#else
return false;
+#endif
}
for (int i = 0; i != _table->size; ++i) {
void save(SavedProperties &) const;
void restore(const SavedProperties &p);
- bool hasGetterSetterProperties() const { return _singleEntry.globalGetterSetterFlag; }
+ bool hasGetterSetterProperties() const { return !!_singleEntry.globalGetterSetterFlag; }
void setHasGetterSetterProperties(bool f) { _singleEntry.globalGetterSetterFlag = f; }
bool containsGettersOrSetters() const;
namespace KJS {
-class HashEntry;
class ExecState;
class JSObject;
+struct HashEntry;
+
#define VALUE_SLOT_MARKER ((GetValueFunc)1)
class PropertySlot
{
}
// ECMA 15.5.1
-JSValue *StringObjectImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
+JSValue *StringObjectImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
{
if (args.isEmpty())
return jsString("");
putDirect(lengthPropertyName, jsNumber(1), DontDelete|ReadOnly|DontEnum);
}
-JSValue *StringObjectFuncImp::callAsFunction(ExecState *exec, JSObject */*thisObj*/, const List &args)
+JSValue *StringObjectFuncImp::callAsFunction(ExecState *exec, JSObject* /*thisObj*/, const List &args)
{
UString s;
if (args.size()) {
{
char* buffer;
- int buffer_size = 0;
- int buffer_capacity = 1024;
+ size_t buffer_size = 0;
+ size_t buffer_capacity = 1024;
buffer = (char*)malloc(buffer_capacity);
FILE* f = fopen(fileName, "r");
uint32_t hash = PHI;
uint32_t tmp;
- unsigned l = strlen(s);
+ size_t l = strlen(s);
- int rem = l & 1;
+ size_t rem = l & 1;
l >>= 1;
// Main loop
m_rep = &Rep::null;
return;
}
- int length = strlen(c);
+ size_t length = strlen(c);
if (length == 0) {
m_rep = &Rep::empty;
return;
}
UChar *d = static_cast<UChar *>(fastMalloc(sizeof(UChar) * length));
- for (int i = 0; i < length; i++)
+ for (size_t i = 0; i < length; i++)
d[i].uc = c[i];
- m_rep = Rep::create(d, length);
+ m_rep = Rep::create(d, static_cast<int>(length));
}
UString::UString(const UChar *c, int length)
}
}
- return UString(p, end - p);
+ return UString(p, static_cast<int>(end - p));
}
UString UString::from(unsigned int u)
}
}
- return UString(p, end - p);
+ return UString(p, static_cast<int>(end - p));
}
UString UString::from(long l)
}
}
- return UString(p, end - p);
+ return UString(p, static_cast<int>(end - p));
}
UString UString::from(double d)
int sign;
char *result = kjs_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
- int length = strlen(result);
+ int length = static_cast<int>(strlen(result));
int i = 0;
if (sign) {
// decimalPoint can't be more than 3 digits decimal given the
// nature of float representation
int exponential = decimalPoint - 1;
- if (exponential < 0) {
- exponential = exponential * -1;
- }
- if (exponential >= 100) {
- buf[i++] = '0' + exponential / 100;
- }
- if (exponential >= 10) {
- buf[i++] = '0' + (exponential % 100) / 10;
- }
- buf[i++] = '0' + exponential % 10;
+ if (exponential < 0)
+ exponential = -exponential;
+ if (exponential >= 100)
+ buf[i++] = static_cast<char>('0' + exponential / 100);
+ if (exponential >= 10)
+ buf[i++] = static_cast<char>('0' + (exponential % 100) / 10);
+ buf[i++] = static_cast<char>('0' + exponential % 10);
buf[i++] = '\0';
}
{
int thisSize = size();
int thisOffset = m_rep->offset;
- int tSize = strlen(t);
+ int tSize = static_cast<int>(strlen(t));
int length = thisSize + tSize;
// possible cases:
char *q = statBuffer;
const UChar *limit = p + length;
while (p != limit) {
- *q = p->uc;
+ *q = static_cast<char>(p->uc);
++p;
++q;
}
UString &UString::operator=(const char *c)
{
- int l = c ? strlen(c) : 0;
+ int l = c ? static_cast<int>(strlen(c)) : 0;
UChar *d;
if (m_rep->rc == 1 && l <= m_rep->capacity && !m_rep->baseString && m_rep->offset == 0 && m_rep->preCapacity == 0) {
d = m_rep->buf;
++fdata;
for (const UChar *c = data() + pos; c <= end; c++)
if (c->uc == fchar && !memcmp(c + 1, fdata, fsizeminusone))
- return (c-data());
+ return static_cast<int>(c - data());
return -1;
}
const UChar *end = data() + size();
for (const UChar *c = data() + pos; c < end; c++)
if (*c == ch)
- return (c-data());
+ return static_cast<int>(c - data());
return -1;
}
const UChar *fdata = f.data();
for (const UChar *c = data() + pos; c >= data(); c--) {
if (*c == *fdata && !memcmp(c + 1, fdata + 1, fsizeminusone))
- return (c-data());
+ return static_cast<int>(c - data());
}
return -1;
pos = size() - 1;
for (const UChar *c = data() + pos; c >= data(); c--) {
if (*c == ch)
- return (c-data());
+ return static_cast<int>(c-data());
}
return -1;
/**
* @return The higher byte of the character.
*/
- unsigned char high() const { return uc >> 8; }
+ unsigned char high() const { return static_cast<unsigned char>(uc >> 8); }
/**
* @return The lower byte of the character.
*/
- unsigned char low() const { return uc; }
+ unsigned char low() const { return static_cast<unsigned char>(uc); }
/**
* @return the 16 bit Unicode value of the character
*/
/**
* @return Lower byte.
*/
- unsigned char low() const { return ref().uc; }
+ unsigned char low() const { return static_cast<unsigned char>(ref().uc); }
/**
* @return Higher byte.
*/
- unsigned char high() const { return ref().uc >> 8; }
+ unsigned char high() const { return static_cast<unsigned char>(ref().uc >> 8); }
private:
// not implemented, can only be constructed from UString
{
uint32_t i;
if (getUInt32(i))
- return i;
+ return static_cast<uint16_t>(i);
double d = roundValue(exec, const_cast<JSValue*>(this));
if (isNaN(d) || isInf(d))
namespace KJS {
-class ClassInfo;
class ExecState;
class JSObject;
class JSCell;
+struct ClassInfo;
+
/**
* JSValue is the base type for all primitives (Undefined, Null, Boolean,
* String, Number) and objects in ECMAScript.
static BOOL
get_othercase_range(int *cptr, int d, int *ocptr, int *odptr)
{
-int c, chartype, othercase, next;
+int c, chartype, othercase = 0, next;
for (c = *cptr; c <= d; c++)
{
pattern matching using an NFA algorithm, trying to mimic Perl as closely as
possible. There are also some static supporting functions. */
-
#include "pcre_internal.h"
+/* Avoid warnings on Windows. */
+#undef min
+#undef max
/* Structure for building a chain of data that actually lives on the
stack, for holding the values of the subject pointer at the start of each
#endif
#endif /* SUPPORT_UTF8 */
+#if !PCRE_UTF16
/* When not in UTF-8 mode, load a single-byte character. */
{
if (min > md->end_subject - eptr) RRETURN(MATCH_NOMATCH);
matching character if failing, up to the maximum. Alternatively, if
maximizing, find the maximum number of characters and work backwards. */
-#if PCRE_UTF16
- DPRINTF(("matching %c{%d,%d}\n", fc, min, max));
-#else
DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,
max, eptr));
-#endif
if ((ims & PCRE_CASELESS) != 0)
{
}
}
/* Control never gets here */
+#endif
/* Match a negated single one-byte character. The character we are
checking can be multibyte. */
#define INT_CAST(i) (i)
#endif
+#if COMPILER(MSVC)
+#pragma warning(disable: 4232)
+#pragma warning(disable: 4244)
+#endif
+
/* This header contains definitions that are shared between the different
modules, but which are not relevant to the exported API. This includes some
functions whose names all begin with "_pcre_". */
key ^= (key >> 15);
key += ~(key << 27);
key ^= (key >> 31);
- return key;
+ return static_cast<unsigned>(key);
}
template<typename T> struct IntHash {
// pointer identity hash function
template<typename T> struct PtrHash {
- static unsigned hash(T key) { return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key)); }
+ static unsigned hash(T key)
+ {
+#if COMPILER(MSVC)
+#pragma warning(push)
+#pragma warning(disable: 4244) // work around what seems to be a bug in MSVC's conversion warnings
+#endif
+ return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key));
+#if COMPILER(MSVC)
+#pragma warning(pop)
+#endif
+ }
static bool equal(T a, T b) { return a == b; }
};
template<typename P> struct PtrHash<RefPtr<P> > {
#endif
inline bool isinf(double num) { return !_finite(num) && !_isnan(num); }
-inline bool isnan(double num) { return _isnan(num); }
-inline long lround(double num) { return num > 0 ? num + 0.5 : ceil(num - 0.5); }
-inline long lroundf(float num) { return num > 0 ? num + 0.5f : ceilf(num - 0.5f); }
+inline bool isnan(double num) { return !!_isnan(num); }
+inline long lround(double num) { return static_cast<long>(num > 0 ? num + 0.5 : ceil(num - 0.5)); }
+inline long lroundf(float num) { return static_cast<long>(num > 0 ? num + 0.5f : ceilf(num - 0.5f)); }
inline double round(double num) { return num > 0 ? floor(num + 0.5) : ceil(num - 0.5); }
inline float roundf(float num) { return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f); }
inline bool signbit(double num) { return _copysign(1.0, num) < 0; }
return _vsnprintf(str, size, format, args);
}
-inline int strncasecmp(const char* s1, const char* s2, int len) { return strnicmp(s1, s2, len); }
+inline int strncasecmp(const char* s1, const char* s2, size_t len) { return strnicmp(s1, s2, len); }
#endif
inline bool isPrintableChar(int32_t c)
{
- return u_isprint(c);
+ return !!u_isprint(c);
}
inline CharCategory category(int32_t c)