From 2f1c313fd0f549cf75177fe7ac9950ad813d06be Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 14 Aug 2013 21:45:22 +0000 Subject: [PATCH] Windows: Fix 64-bit compile errors (issue #394). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1361 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef_dll/wrapper/cef_stream_resource_handler.cc | 2 +- tests/cefclient/cefclient_osr_widget_win.cpp | 4 ++-- tests/cefclient/client_app.cpp | 7 ++++--- tests/cefclient/dialog_test.cpp | 2 +- tests/cefclient/performance_test.cpp | 8 ++++---- tests/cefclient/performance_test_setup.h | 10 +++++----- tests/cefclient/performance_test_tests.cpp | 2 +- tests/unittests/request_handler_unittest.cc | 2 +- tests/unittests/stream_unittest.cc | 4 ++-- tests/unittests/test_handler.cc | 4 ++-- tests/unittests/test_util.cc | 6 +++--- 11 files changed, 26 insertions(+), 25 deletions(-) diff --git a/libcef_dll/wrapper/cef_stream_resource_handler.cc b/libcef_dll/wrapper/cef_stream_resource_handler.cc index 91f5e94cf..30a6c17cd 100644 --- a/libcef_dll/wrapper/cef_stream_resource_handler.cc +++ b/libcef_dll/wrapper/cef_stream_resource_handler.cc @@ -54,7 +54,7 @@ bool CefStreamResourceHandler::ReadResponse(void* data_out, int bytes_to_read, int& bytes_read, CefRefPtr callback) { - bytes_read = stream_->Read(data_out, 1, bytes_to_read); + bytes_read = static_cast(stream_->Read(data_out, 1, bytes_to_read)); return (bytes_read > 0); } diff --git a/tests/cefclient/cefclient_osr_widget_win.cpp b/tests/cefclient/cefclient_osr_widget_win.cpp index 0e686b86d..8fd97e5c3 100644 --- a/tests/cefclient/cefclient_osr_widget_win.cpp +++ b/tests/cefclient/cefclient_osr_widget_win.cpp @@ -144,8 +144,8 @@ void OSRWindow::OnCursorChange(CefRefPtr browser, return; // Change the plugin window's cursor. - SetClassLong(hWnd_, GCL_HCURSOR, - static_cast(reinterpret_cast(cursor))); + SetClassLongPtr(hWnd_, GCLP_HCURSOR, + static_cast(reinterpret_cast(cursor))); SetCursor(cursor); } diff --git a/tests/cefclient/client_app.cpp b/tests/cefclient/client_app.cpp index 41ec282ad..4f892e163 100644 --- a/tests/cefclient/client_app.cpp +++ b/tests/cefclient/client_app.cpp @@ -62,7 +62,7 @@ void SetListValue(CefRefPtr list, int index, switch (type) { case VTYPE_LIST: { CefRefPtr list = value->GetList(index); - new_value = CefV8Value::CreateArray(list->GetSize()); + new_value = CefV8Value::CreateArray(static_cast(list->GetSize())); SetList(list, new_value); } break; case VTYPE_BOOL: @@ -92,7 +92,7 @@ void SetListValue(CefRefPtr list, int index, void SetList(CefRefPtr source, CefRefPtr target) { ASSERT(target->IsArray()); - int arg_length = source->GetSize(); + int arg_length = static_cast(source->GetSize()); if (arg_length == 0) return; @@ -382,7 +382,8 @@ bool ClientApp::OnProcessMessageReceived( // Second argument is the list of message arguments. CefRefPtr list = message->GetArgumentList(); - CefRefPtr args = CefV8Value::CreateArray(list->GetSize()); + CefRefPtr args = + CefV8Value::CreateArray(static_cast(list->GetSize())); SetList(list, args); arguments.push_back(args); diff --git a/tests/cefclient/dialog_test.cpp b/tests/cefclient/dialog_test.cpp index a6171781d..672345d73 100644 --- a/tests/cefclient/dialog_test.cpp +++ b/tests/cefclient/dialog_test.cpp @@ -31,7 +31,7 @@ class RunFileDialogCallback : public CefRunFileDialogCallback { CefProcessMessage::Create(message_name_); CefRefPtr args = message->GetArgumentList(); CefRefPtr val = CefListValue::Create(); - for (size_t i = 0; i < file_paths.size(); ++i) + for (int i = 0; i < static_cast(file_paths.size()); ++i) val->SetString(i, file_paths[i]); args->SetList(0, val); diff --git a/tests/cefclient/performance_test.cpp b/tests/cefclient/performance_test.cpp index 71c5d4f51..3bcfb2e70 100644 --- a/tests/cefclient/performance_test.cpp +++ b/tests/cefclient/performance_test.cpp @@ -14,9 +14,9 @@ namespace performance_test { // Use more interations for a Release build. #ifdef NDEBUG -const size_t kDefaultIterations = 100000; +const int kDefaultIterations = 100000; #else -const size_t kDefaultIterations = 10000; +const int kDefaultIterations = 10000; #endif namespace { @@ -41,7 +41,7 @@ class V8Handler : public CefV8Handler { bool found = false; std::string test = arguments[0]->GetStringValue(); - for (size_t i = 0; i < kPerfTestsCount; ++i) { + for (int i = 0; i < kPerfTestsCount; ++i) { if (test == kPerfTests[i].name) { // Execute the test. int64 delta = kPerfTests[i].test(kPerfTests[i].iterations); @@ -63,7 +63,7 @@ class V8Handler : public CefV8Handler { } else if (name == kGetPerfTests) { // Retrieve the list of perf tests. retval = CefV8Value::CreateArray(kPerfTestsCount); - for (size_t i = 0; i < kPerfTestsCount; ++i) { + for (int i = 0; i < kPerfTestsCount; ++i) { CefRefPtr val = CefV8Value::CreateArray(2); val->SetValue(0, CefV8Value::CreateString(kPerfTests[i].name)); val->SetValue(1, CefV8Value::CreateUInt(kPerfTests[i].iterations)); diff --git a/tests/cefclient/performance_test_setup.h b/tests/cefclient/performance_test_setup.h index a4f2647ef..8a8301a5a 100644 --- a/tests/cefclient/performance_test_setup.h +++ b/tests/cefclient/performance_test_setup.h @@ -11,7 +11,7 @@ namespace performance_test { // Default number of iterations. -extern const size_t kDefaultIterations; +extern const int kDefaultIterations; // Test name. #define PERF_TEST_NAME(name) PerfTest##name @@ -24,7 +24,7 @@ extern const size_t kDefaultIterations; // Test function declaration. #define PERF_TEST_RESULT int64 #define PERF_TEST_PARAM_ITERATIONS iterations -#define PERF_TEST_PARAMS size_t PERF_TEST_PARAM_ITERATIONS +#define PERF_TEST_PARAMS int PERF_TEST_PARAM_ITERATIONS #define PERF_TEST_FUNC(name) \ PERF_TEST_RESULT PERF_TEST_NAME(name)(PERF_TEST_PARAMS) @@ -66,7 +66,7 @@ class CefTimer { { \ CefTimer _timer; \ _timer.Start(); \ - for (size_t _i = 0; _i < PERF_TEST_PARAM_ITERATIONS; ++_i) { + for (int _i = 0; _i < PERF_TEST_PARAM_ITERATIONS; ++_i) { #define PERF_ITERATIONS_END_EX(result) \ } \ @@ -87,12 +87,12 @@ class CefTimer { struct PerfTestEntry { const char* name; PerfTest* test; - size_t iterations; + int iterations; }; // Array of perf tests. extern const PerfTestEntry kPerfTests[]; -extern const size_t kPerfTestsCount; +extern const int kPerfTestsCount; } // namespace performance_test diff --git a/tests/cefclient/performance_test_tests.cpp b/tests/cefclient/performance_test_tests.cpp index 389a126a2..bde896914 100644 --- a/tests/cefclient/performance_test_tests.cpp +++ b/tests/cefclient/performance_test_tests.cpp @@ -323,6 +323,6 @@ const PerfTestEntry kPerfTests[] = { PERF_TEST_ENTRY(V8ContextEval), }; -const size_t kPerfTestsCount = (sizeof(kPerfTests) / sizeof(kPerfTests[0])); +const int kPerfTestsCount = (sizeof(kPerfTests) / sizeof(kPerfTests[0])); } // namespace performance_test diff --git a/tests/unittests/request_handler_unittest.cc b/tests/unittests/request_handler_unittest.cc index e0f9b237c..96d8b081b 100644 --- a/tests/unittests/request_handler_unittest.cc +++ b/tests/unittests/request_handler_unittest.cc @@ -275,7 +275,7 @@ class NetNotifyRendererTest : public ClientApp::RenderDelegate { NetNotifyTestType test_type = NNTT_NONE; // Extract the test type. - int pos = url.find("t="); + size_t pos = url.find("t="); int intval = 0; if (pos > 0 && base::StringToInt(url.substr(pos + 2, 1), &intval)) test_type = static_cast(intval); diff --git a/tests/unittests/stream_unittest.cc b/tests/unittests/stream_unittest.cc index 47da4523a..0aa6a0e9f 100644 --- a/tests/unittests/stream_unittest.cc +++ b/tests/unittests/stream_unittest.cc @@ -27,7 +27,7 @@ static void VerifyStreamReadBehavior(CefRefPtr stream, int res, read, offset = 0; do { read = std::min(static_cast(sizeof(buff)), contentSize-offset); - res = stream->Read(buff, 1, read); + res = static_cast(stream->Read(buff, 1, read)); ASSERT_EQ(read, res); ASSERT_TRUE(!memcmp(contentStr+offset, buff, res)); offset += res; @@ -47,7 +47,7 @@ static void VerifyStreamWriteBehavior(CefRefPtr stream, int res, write, offset = 0; do { write = std::min(10, contentSize-offset); - res = stream->Write(contentStr+offset, 1, write); + res = static_cast(stream->Write(contentStr+offset, 1, write)); ASSERT_EQ(write, res); offset += res; ASSERT_EQ(offset, stream->Tell()); diff --git a/tests/unittests/test_handler.cc b/tests/unittests/test_handler.cc index 5e19418cc..fe6e66d42 100644 --- a/tests/unittests/test_handler.cc +++ b/tests/unittests/test_handler.cc @@ -132,7 +132,7 @@ CefRefPtr TestHandler::GetResourceHandler( // Ignore the query component, if any. std::string urlStr = url; - int idx = urlStr.find('?'); + size_t idx = urlStr.find('?'); if (idx > 0) urlStr = urlStr.substr(0, idx); @@ -186,7 +186,7 @@ void TestHandler::AddResource(const std::string& url, const std::string& mimeType) { // Ignore the query component, if any. std::string urlStr = url; - int idx = urlStr.find('?'); + size_t idx = urlStr.find('?'); if (idx > 0) urlStr = urlStr.substr(0, idx); diff --git a/tests/unittests/test_util.cc b/tests/unittests/test_util.cc index 6ab167e7f..1ac25a632 100644 --- a/tests/unittests/test_util.cc +++ b/tests/unittests/test_util.cc @@ -182,10 +182,10 @@ void TestListEqual(CefRefPtr val1, EXPECT_TRUE(val1.get()); EXPECT_TRUE(val2.get()); - size_t size = val1->GetSize(); - EXPECT_EQ(size, val2->GetSize()); + int size = static_cast(val1->GetSize()); + EXPECT_EQ(size, static_cast(val2->GetSize())); - for (size_t i = 0; i < size; ++i) { + for (int i = 0; i < size; ++i) { CefValueType type = val1->GetType(i); EXPECT_EQ(type, val2->GetType(i)); switch (type) {