Skip to content

Commit

Permalink
Fix a bunch of implicit casts detected by the Win64 compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
jkummerow@chromium.org committed Jun 19, 2012
1 parent 1f3a61d commit c3fda32
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions preparser/preparser-process.cc
@@ -1,4 +1,4 @@
// Copyright 2011 the V8 project authors. All rights reserved.
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
Expand Down Expand Up @@ -202,7 +202,7 @@ void fail(v8::PreParserData* data, const char* message, ...) {
fflush(stderr);
if (data != NULL) {
// Print preparser data to stdout.
uint32_t size = data->size();
uint32_t size = static_cast<uint32_t>(data->size());
fprintf(stderr, "LOG: data size: %u\n", size);
if (!WriteBuffer(stdout, data->data(), size)) {
perror("ERROR: Writing data");
Expand Down Expand Up @@ -232,7 +232,7 @@ struct ExceptionExpectation {

void CheckException(v8::PreParserData* data,
ExceptionExpectation* expects) {
PreparseDataInterpreter reader(data->data(), data->size());
PreparseDataInterpreter reader(data->data(), static_cast<int>(data->size()));
if (expects->throws) {
if (!reader.throws()) {
if (expects->type == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion samples/lineprocessor.cc
Expand Up @@ -347,7 +347,7 @@ v8::Handle<v8::String> ReadFile(const char* name) {
char* chars = new char[size + 1];
chars[size] = '\0';
for (int i = 0; i < size;) {
int read = fread(&chars[i], 1, size - i, file);
int read = static_cast<int>(fread(&chars[i], 1, size - i, file));
i += read;
}
fclose(file);
Expand Down
14 changes: 7 additions & 7 deletions samples/process.cc
@@ -1,4 +1,4 @@
// Copyright 2008 the V8 project authors. All rights reserved.
// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
Expand Down Expand Up @@ -351,7 +351,7 @@ Handle<Value> JsHttpRequestProcessor::MapGet(Local<String> name,

// Otherwise fetch the value and wrap it in a JavaScript string
const string& value = (*iter).second;
return String::New(value.c_str(), value.length());
return String::New(value.c_str(), static_cast<int>(value.length()));
}


Expand Down Expand Up @@ -443,31 +443,31 @@ Handle<Value> JsHttpRequestProcessor::GetPath(Local<String> name,
const string& path = request->Path();

// Wrap the result in a JavaScript string and return it.
return String::New(path.c_str(), path.length());
return String::New(path.c_str(), static_cast<int>(path.length()));
}


Handle<Value> JsHttpRequestProcessor::GetReferrer(Local<String> name,
const AccessorInfo& info) {
HttpRequest* request = UnwrapRequest(info.Holder());
const string& path = request->Referrer();
return String::New(path.c_str(), path.length());
return String::New(path.c_str(), static_cast<int>(path.length()));
}


Handle<Value> JsHttpRequestProcessor::GetHost(Local<String> name,
const AccessorInfo& info) {
HttpRequest* request = UnwrapRequest(info.Holder());
const string& path = request->Host();
return String::New(path.c_str(), path.length());
return String::New(path.c_str(), static_cast<int>(path.length()));
}


Handle<Value> JsHttpRequestProcessor::GetUserAgent(Local<String> name,
const AccessorInfo& info) {
HttpRequest* request = UnwrapRequest(info.Holder());
const string& path = request->UserAgent();
return String::New(path.c_str(), path.length());
return String::New(path.c_str(), static_cast<int>(path.length()));
}


Expand Down Expand Up @@ -557,7 +557,7 @@ Handle<String> ReadFile(const string& name) {
char* chars = new char[size + 1];
chars[size] = '\0';
for (int i = 0; i < size;) {
int read = fread(&chars[i], 1, size - i, file);
int read = static_cast<int>(fread(&chars[i], 1, size - i, file));
i += read;
}
fclose(file);
Expand Down
2 changes: 1 addition & 1 deletion samples/shell.cc
Expand Up @@ -205,7 +205,7 @@ v8::Handle<v8::String> ReadFile(const char* name) {
char* chars = new char[size + 1];
chars[size] = '\0';
for (int i = 0; i < size;) {
int read = fread(&chars[i], 1, size - i, file);
int read = static_cast<int>(fread(&chars[i], 1, size - i, file));
i += read;
}
fclose(file);
Expand Down
2 changes: 1 addition & 1 deletion src/assembler.cc
Expand Up @@ -363,7 +363,7 @@ void RelocInfoWriter::Write(const RelocInfo* rinfo) {
ASSERT(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize);
} else if (RelocInfo::IsConstPool(rmode)) {
WriteExtraTaggedPC(pc_delta, kPCJumpExtraTag);
WriteExtraTaggedConstPoolData(rinfo->data());
WriteExtraTaggedConstPoolData(static_cast<int>(rinfo->data()));
} else {
ASSERT(rmode > RelocInfo::LAST_COMPACT_ENUM);
int saved_mode = rmode - RelocInfo::LAST_COMPACT_ENUM;
Expand Down
8 changes: 4 additions & 4 deletions src/d8.cc
Expand Up @@ -284,9 +284,9 @@ Handle<Value> Shell::Load(const Arguments& args) {
return Undefined();
}

static size_t convertToUint(Local<Value> value_in, TryCatch* try_catch) {
if (value_in->IsUint32()) {
return value_in->Uint32Value();
static int32_t convertToUint(Local<Value> value_in, TryCatch* try_catch) {
if (value_in->IsInt32()) {
return value_in->Int32Value();
}

Local<Value> number = value_in->ToNumber();
Expand All @@ -312,7 +312,7 @@ static size_t convertToUint(Local<Value> value_in, TryCatch* try_catch) {
ThrowException(
String::New("Array length exceeds maximum length."));
}
return static_cast<size_t>(raw_value);
return raw_value;
}


Expand Down
4 changes: 2 additions & 2 deletions src/debug.cc
Expand Up @@ -1876,7 +1876,7 @@ static void RedirectActivationsToRecompiledCodeOnThread(
for (RelocIterator it(*frame_code, constpool_mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo();
if (info->pc() >= frame->pc()) break;
frame_const_pool_size += info->data();
frame_const_pool_size += static_cast<int>(info->data());
}
intptr_t frame_offset =
frame->pc() - frame_code->instruction_start() - frame_const_pool_size;
Expand All @@ -1902,7 +1902,7 @@ static void RedirectActivationsToRecompiledCodeOnThread(
} else {
ASSERT(RelocInfo::IsConstPool(info->rmode()));
// The size of the constant pool is encoded in the data.
new_code_const_pool_size += info->data();
new_code_const_pool_size += static_cast<int>(info->data());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/factory.cc
Expand Up @@ -725,7 +725,7 @@ Handle<String> Factory::EmergencyNewError(const char* type,
MaybeObject* maybe_arg = args->GetElement(i);
Handle<String> arg_str(reinterpret_cast<String*>(maybe_arg));
const char* arg = *arg_str->ToCString();
Vector<char> v2(p, space);
Vector<char> v2(p, static_cast<int>(space));
OS::StrNCpy(v2, arg, space);
space -= Min(space, strlen(arg));
p = &buffer[kBufferSize] - space;
Expand Down
2 changes: 1 addition & 1 deletion src/zone-inl.h
Expand Up @@ -100,7 +100,7 @@ void* ZoneObject::operator new(size_t size, Zone* zone) {

inline void* ZoneAllocationPolicy::New(size_t size) {
ASSERT(zone_);
return zone_->New(size);
return zone_->New(static_cast<int>(size));
}


Expand Down

0 comments on commit c3fda32

Please sign in to comment.