From c56c32a0fee9646de11914a35e6ab79ed55e0038 Mon Sep 17 00:00:00 2001 From: Gautam Jha Date: Tue, 2 Oct 2018 17:49:43 +0530 Subject: [PATCH 1/9] Win64 build fix --- Gruntfile.js | 32 +++++++++++--- appshell/appshell_extension_handler.h | 6 +-- appshell/appshell_extensions_platform.cpp | 2 +- appshell/appshell_extensions_win.cpp | 39 +++++++++-------- appshell/appshell_node_process_win.cpp | 2 +- appshell/cef_dark_window.cpp | 10 ++--- appshell/cef_host_window.cpp | 2 +- appshell/cef_main_window.cpp | 2 +- appshell/cef_registry.cpp | 2 +- appshell/cef_window.cpp | 6 +-- appshell/cef_window.h | 53 +++++++++++++++++++---- appshell/cefclient_win.cpp | 5 +-- appshell/client_app.cpp | 2 +- tasks/setup.js | 21 ++++++--- 14 files changed, 125 insertions(+), 59 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 61b57d255..9e81fec31 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -91,23 +91,43 @@ module.exports = function (grunt) { "src" : "<%= icu.url %>/icu_<%= icu.version %>_macosx64.zip" }, /* win */ - "cef-win": { + "cef-win32": { "dest" : "<%= downloads %>", "src" : "<%= cef.url %>/cef_binary_<%= cef.version %>_windows32.zip" }, - "cef-win-symbols": { + "cef-win32-symbols": { "src" : ["<%= cef.url %>/cef_binary_<%= cef.version %>_windows32_debug_symbols.zip", "<%= cef.url %>/cef_binary_<%= cef.version %>_windows32_release_symbols.zip"], "dest" : "<%= downloads %>/cefsymbols" }, - "node-win": { + "node-win32": { "dest" : "<%= downloads %>", "src" : "http://nodejs.org/dist/v<%= node.version %>/win-x86/node.exe" }, - "icu-win": { + "icu-win32": { "dest" : "<%= downloads %>", "src" : "<%= icu.url %>/icu_<%= icu.version %>_windows32.zip" }, - "vs-crt-win": { + "vs-crt-win32": { + "dest" : "<%= downloads %>", + "src" : "<%= vsCrt.url %>/vs<%= vsCrt.version %>-crt-ia32.zip" + }, + "cef-win64": { + "dest" : "<%= downloads %>", + "src" : "<%= cef.url %>/cef_binary_<%= cef.version %>_windows64.zip" + }, + "cef-win64-symbols": { + "src" : ["<%= cef.url %>/cef_binary_<%= cef.version %>_windows64_debug_symbols.zip", "<%= cef.url %>/cef_binary_<%= cef.version %>_windows64_release_symbols.zip"], + "dest" : "<%= downloads %>/cefsymbols" + }, + "node-win64": { + "dest" : "<%= downloads %>", + "src" : "http://nodejs.org/dist/v<%= node.version %>/win-x86/node.exe" + }, + "icu-win64": { + "dest" : "<%= downloads %>", + "src" : "<%= icu.url %>/icu_<%= icu.version %>_windows64.zip" + }, + "vs-crt-win64": { "dest" : "<%= downloads %>", "src" : "<%= vsCrt.url %>/vs<%= vsCrt.version %>-crt-ia32.zip" } @@ -332,7 +352,7 @@ module.exports = function (grunt) { "version" : "6.14.0" }, "icu": { - "url" : "http://s3.amazonaws.com/files.brackets.io/icu", + "url" : "http://localhost:8001", "version" : "58" }, "vsCrt": { diff --git a/appshell/appshell_extension_handler.h b/appshell/appshell_extension_handler.h index 588f42bbf..7d7a8953a 100644 --- a/appshell/appshell_extension_handler.h +++ b/appshell/appshell_extension_handler.h @@ -74,7 +74,7 @@ CefRefPtr ListValueToV8Value(CefRefPtr value, int inde 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: @@ -106,7 +106,7 @@ void SetListValue(CefRefPtr list, int index, switch (type) { case VTYPE_LIST: { CefRefPtr listValue = value->GetList(index); - new_value = CefV8Value::CreateArray(listValue->GetSize()); + new_value = CefV8Value::CreateArray(static_cast(listValue->GetSize())); SetList(listValue, new_value); } break; case VTYPE_BOOL: @@ -136,7 +136,7 @@ void SetListValue(CefRefPtr list, int index, void SetList(CefRefPtr source, CefRefPtr target) { DCHECK(target->IsArray()); - int arg_length = source->GetSize(); + int arg_length = static_cast(source->GetSize()); if (arg_length == 0) return; diff --git a/appshell/appshell_extensions_platform.cpp b/appshell/appshell_extensions_platform.cpp index 2337552c7..d7ac43625 100644 --- a/appshell/appshell_extensions_platform.cpp +++ b/appshell/appshell_extensions_platform.cpp @@ -32,7 +32,7 @@ void CharSetDetect::operator()(const char* bufferData, size_t bufferLength, std: const UCharsetMatch* charsetMatch_; // send text - ucsdet_setText(m_charsetDetector_, bufferData, bufferLength, &error); + ucsdet_setText(m_charsetDetector_, bufferData, static_cast(bufferLength), &error); if (U_FAILURE(error)) throw "Failed to set text"; diff --git a/appshell/appshell_extensions_win.cpp b/appshell/appshell_extensions_win.cpp index e91aa83cc..02ffd1dc6 100644 --- a/appshell/appshell_extensions_win.cpp +++ b/appshell/appshell_extensions_win.cpp @@ -25,6 +25,7 @@ #include "appshell/appshell_helpers.h" #include "native_menu_model.h" +#include "cef_window.h" #include #include @@ -278,7 +279,7 @@ void CALLBACK LiveBrowserMgrWin::CloseLiveBrowserAsyncCallback( HWND hwnd, UINT } else if(s_instance->m_closeLiveBrowserHeartbeatTimerId == 0){ //start a heartbeat timer to see if it closes after the message returned - s_instance->m_closeLiveBrowserHeartbeatTimerId = ::SetTimer(NULL, 0, 30, CloseLiveBrowserTimerCallback); + s_instance->m_closeLiveBrowserHeartbeatTimerId = ::SetTimer(NULL, 0, 30, bit_cast(&CloseLiveBrowserTimerCallback)); } } @@ -356,7 +357,7 @@ int32 OpenLiveBrowser(ExtensionString argURL, bool enableRemoteDebugging) args += argURL; // Args must be mutable - int argsBufSize = args.length() +1; + int argsBufSize = static_cast(args.length()) +1; std::vector argsBuf; argsBuf.resize(argsBufSize); wcscpy(&argsBuf[0], args.c_str()); @@ -399,13 +400,13 @@ void CloseLiveBrowser(CefRefPtr browser, CefRefPtrCloseLiveBrowserFireCallback(NO_ERROR); } else if (liveBrowserMgr->GetCloseCallback()) { // set a timeout for up to 10 seconds to close the browser - liveBrowserMgr->SetCloseTimeoutTimerId( ::SetTimer(NULL, 0, 10 * 1000, LiveBrowserMgrWin::CloseLiveBrowserTimerCallback) ); + liveBrowserMgr->SetCloseTimeoutTimerId( ::SetTimer(NULL, 0, 10 * 1000, bit_cast(&LiveBrowserMgrWin::CloseLiveBrowserTimerCallback)) ); } } int32 OpenURLInDefaultBrowser(ExtensionString url) { - DWORD result = (DWORD)ShellExecute(NULL, L"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); + DWORD_PTR result = bit_cast(ShellExecute(NULL, L"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL)); // If the result > 32, the function suceeded. If the result is <= 32, it is an // error code. @@ -498,7 +499,7 @@ int32 ShowOpenDialog(bool allowMultipleSelection, } else { // Multiple files are selected wchar_t fullPath[MAX_UNC_PATH]; - for (int i = (dir.length() + 1), fileIndex = 0; ; fileIndex++) { + for (int i = static_cast(dir.length() + 1), fileIndex = 0; ; fileIndex++) { // Get the next file name std::wstring file(&szFile[i]); @@ -515,7 +516,7 @@ int32 ShowOpenDialog(bool allowMultipleSelection, } // Go to the start of the next file name - i += file.length() + 1; + i += static_cast(file.length()) + 1; } } @@ -885,7 +886,7 @@ static void CharSetToWide(const std::string &aString, long codePage, std::wstrin int aUTF16Length = ::MultiByteToWideChar(codePage, // get destination buffer length 0, aString.data(), - aString.size(), + static_cast(aString.size()), NULL, NULL); @@ -896,7 +897,7 @@ static void CharSetToWide(const std::string &aString, long codePage, std::wstrin int wcharsWritten = ::MultiByteToWideChar(codePage, 0, aString.data(), - aString.size(), + static_cast(aString.size()), buf.get(), aUTF16Length); @@ -1025,7 +1026,7 @@ static void WideToCharSet(const std::wstring &aUTF16string, long codePage, std:: int aUTF8Length = ::WideCharToMultiByte(codePage, 0, aUTF16string.data(), - aUTF16string.size(), + static_cast(aUTF16string.size()), NULL, 0, NULL, @@ -1037,7 +1038,7 @@ static void WideToCharSet(const std::wstring &aUTF16string, long codePage, std:: int bytesWritten = ::WideCharToMultiByte(codePage, 0, aUTF16string.data(), - aUTF16string.size(), + static_cast(aUTF16string.size()), buf.get(), aUTF8Length, NULL, @@ -1084,7 +1085,7 @@ int32 WriteFile(ExtensionString filename, std::string contents, ExtensionString return ConvertWinErrorCode(GetLastError(), false); // TODO (issue 67) - Should write to temp file - if (!WriteFile(hFile, contents.c_str(), contents.length(), &dwBytesWritten, NULL)) { + if (!WriteFile(hFile, contents.c_str(), static_cast(contents.length()), &dwBytesWritten, NULL)) { error = ConvertWinErrorCode(GetLastError(), false); } @@ -1208,7 +1209,7 @@ bool isSlash(ExtensionString::value_type wc) { return wc == '/' || wc == '\\'; } void RemoveTrailingSlash(ExtensionString& filename) { - int last = filename.length() - 1; + int last = static_cast(filename.length()) - 1; if ((last >= 0) && isSlash(filename.at(last))) { filename.erase(last); } @@ -1286,7 +1287,7 @@ int32 ShowFolderInOSWindow(ExtensionString pathname) { } else { // File: open its containing folder with this file selected - ITEMIDLIST *pidl = ILCreateFromPath(pathname.c_str()); + auto pidl = ILCreateFromPath(pathname.c_str()); if (pidl) { SHOpenFolderAndSelectItems(pidl,0,0,0); ILFree(pidl); @@ -1519,7 +1520,7 @@ int32 AddMenu(CefRefPtr browser, ExtensionString itemTitle, Extensio menuInfo.fType = MFT_STRING; #endif menuInfo.dwTypeData = (LPWSTR)itemTitle.c_str(); - menuInfo.cch = itemTitle.size(); + menuInfo.cch = static_cast(itemTitle.size()); if (positionIdx == kAppend) { if (!InsertMenuItem(mainMenu, -1, TRUE, &menuInfo)) { @@ -1552,7 +1553,7 @@ bool canBeUsedAsShortcutKey(int unicode) bool UpdateAcceleratorTable(int32 tag, ExtensionString& keyStr) { - int keyStrLen = keyStr.length(); + int keyStrLen = static_cast(keyStr.length()); if (keyStrLen) { LPACCEL lpaccelNew; // pointer to new accelerator table HACCEL haccelOld; // handle to old accelerator table @@ -1827,7 +1828,7 @@ int32 AddMenuItem(CefRefPtr browser, ExtensionString parentCommand, menuInfo.fType = MFT_SEPARATOR; } menuInfo.dwTypeData = (LPWSTR)title.c_str(); - menuInfo.cch = itemTitle.size(); + menuInfo.cch = static_cast(itemTitle.size()); if (positionIdx >= 0) { InsertMenuItem(submenu, positionIdx, TRUE, &menuInfo); inserted = true; @@ -2007,7 +2008,7 @@ int32 SetMenuTitle(CefRefPtr browser, ExtensionString command, Exten #endif menuInfo.dwTypeData = (LPWSTR)newTitle.c_str(); menuInfo.hSubMenu = itemInfo.hSubMenu; - menuInfo.cch = newTitle.size(); + menuInfo.cch = static_cast(newTitle.size()); InsertMenuItem(mainMenu, position, TRUE, &menuInfo); } @@ -2015,7 +2016,7 @@ int32 SetMenuTitle(CefRefPtr browser, ExtensionString command, Exten } else { itemInfo.fType = MFT_STRING; // just to make sure itemInfo.dwTypeData = (LPWSTR)newTitle.c_str(); - itemInfo.cch = newTitle.size(); + itemInfo.cch = static_cast(newTitle.size()); if (!SetMenuItemInfo(menu, tag, FALSE, &itemInfo)) { return ConvertErrnoCode(GetLastError()); } @@ -2115,7 +2116,7 @@ int32 SetMenuItemShortcut(CefRefPtr browser, ExtensionString command itemInfo.fType = MFT_STRING; // just to make sure itemInfo.dwTypeData = (LPWSTR)titleStr.c_str(); - itemInfo.cch = titleStr.size(); + itemInfo.cch = static_cast(titleStr.size()); if (!SetMenuItemInfo(menu, tag, FALSE, &itemInfo)) { return ConvertErrnoCode(GetLastError()); diff --git a/appshell/appshell_node_process_win.cpp b/appshell/appshell_node_process_win.cpp index f7d6629d6..eb9d5b3da 100644 --- a/appshell/appshell_node_process_win.cpp +++ b/appshell/appshell_node_process_win.cpp @@ -302,7 +302,7 @@ void sendData(const std::string &data) { BOOL bSuccess = FALSE; dwWaitResult = WaitForSingleObject(hNodeMutex, INFINITE); if (dwWaitResult == WAIT_OBJECT_0) { // got the mutex - bSuccess = WriteFile(g_hChildStd_IN_Wr, data.c_str(), data.length(), &dwWritten, NULL); + bSuccess = WriteFile(g_hChildStd_IN_Wr, data.c_str(), static_cast(data.length()), &dwWritten, NULL); ReleaseMutex(hNodeMutex); if (!bSuccess) { // Failed to write, there's something wrong with this process. diff --git a/appshell/cef_dark_window.cpp b/appshell/cef_dark_window.cpp index b4c73b875..6e8e6211b 100644 --- a/appshell/cef_dark_window.cpp +++ b/appshell/cef_dark_window.cpp @@ -509,11 +509,11 @@ void cef_dark_window::DoDrawSystemMenuIcon(HDC hdc) // Start with the small if (!mWindowIcon) - mWindowIcon = reinterpret_cast(GetClassLongPtr(GCLP_HICONSM)); + mWindowIcon = bit_cast(GetClassLongPtr(GCLP_HICONSM)); // Then try to load the big icon if (!mWindowIcon) - mWindowIcon = reinterpret_cast(GetClassLongPtr(GCLP_HICON)); + mWindowIcon = bit_cast(GetClassLongPtr(GCLP_HICON)); // Otherwise we need an icon, so just use the standard Windows default // application Icon which may very between versions @@ -554,7 +554,7 @@ void cef_dark_window::DoDrawTitlebarText(HDC hdc) // Figure out how much space we need to draw ethe whole thing RECT rectTemp; ::SetRectEmpty(&rectTemp); - ::DrawText(hdc, szCaption, ::wcslen(szCaption), &rectTemp, DT_SINGLELINE|DT_CALCRECT|DT_NOPREFIX); + ::DrawText(hdc, szCaption, static_cast(::wcslen(szCaption)), &rectTemp, DT_SINGLELINE|DT_CALCRECT|DT_NOPREFIX); // Can it be centered within the window? if (((::RectWidth(windowRect) / 2) + (::RectWidth(rectTemp) / 2) + 1) < textRect.right) { @@ -945,7 +945,7 @@ BOOL cef_dark_window::HandleMeasureItem(LPMEASUREITEMSTRUCT lpMIS) SetRectEmpty(&rectTemp); // Calc the size of this menu item - ::DrawText(dc, szMenuString, ::wcslen(szMenuString), &rectTemp, DT_SINGLELINE|DT_CALCRECT); + ::DrawText(dc, szMenuString, static_cast(::wcslen(szMenuString)), &rectTemp, DT_SINGLELINE|DT_CALCRECT); lpMIS->itemHeight = ::RectHeight(rectTemp); lpMIS->itemWidth = ::RectWidth(rectTemp); @@ -999,7 +999,7 @@ BOOL cef_dark_window::HandleDrawItem(LPDRAWITEMSTRUCT lpDIS) int oldBkMode = ::SetBkMode(lpDIS->hDC, TRANSPARENT); - ::DrawText(lpDIS->hDC, szMenuString, ::wcslen(szMenuString), &lpDIS->rcItem, format); + ::DrawText(lpDIS->hDC, szMenuString, static_cast(::wcslen(szMenuString)), &lpDIS->rcItem, format); ::SelectObject(lpDIS->hDC, fontOld); ::SetBkMode(lpDIS->hDC, oldBkMode); diff --git a/appshell/cef_host_window.cpp b/appshell/cef_host_window.cpp index add7b5107..693dfd2e4 100644 --- a/appshell/cef_host_window.cpp +++ b/appshell/cef_host_window.cpp @@ -168,7 +168,7 @@ BOOL cef_host_window::HandleSize(BOOL bMinimize) if (GetProp(L"WasMinimized")) { DoRepaintClientArea(); } - SetProp(L"WasMinimized", (HANDLE)bMinimize); + SetPropW(L"WasMinimized", bit_cast(&bMinimize)); #endif NotifyWindowMovedOrResized(); return FALSE; diff --git a/appshell/cef_main_window.cpp b/appshell/cef_main_window.cpp index 2718c3fd9..836ee76be 100644 --- a/appshell/cef_main_window.cpp +++ b/appshell/cef_main_window.cpp @@ -292,7 +292,7 @@ BOOL cef_main_window::HandleClose() CefWindowHandle hwnd = SafeGetCefBrowserHwnd(); if (hwnd) { - BOOL closing = (BOOL)::GetProp(hwnd, ::kCefWindowClosingPropName); + DWORD_PTR closing = bit_cast(::GetProp(hwnd, ::kCefWindowClosingPropName)); if (closing) { if (!g_handler->CanCloseBrowser(GetBrowser())) { diff --git a/appshell/cef_registry.cpp b/appshell/cef_registry.cpp index 57319d900..db28ba5cf 100644 --- a/appshell/cef_registry.cpp +++ b/appshell/cef_registry.cpp @@ -36,7 +36,7 @@ void EnsureTrailingSeparator(LPWSTR pRet) if (!pRet) return; - int len = wcslen(pRet); + int len = static_cast(wcslen(pRet)); if (len > 0 && wcscmp(&(pRet[len-1]), L"\\") != 0) { wcscat(pRet, L"\\"); diff --git a/appshell/cef_window.cpp b/appshell/cef_window.cpp index 31c86b180..a749ed32b 100644 --- a/appshell/cef_window.cpp +++ b/appshell/cef_window.cpp @@ -125,7 +125,7 @@ bool cef_window::SubclassWindow(HWND hWnd) if (::GetProp(hWnd, ::gCefClientWindowPropName) != NULL) return false; mWnd = hWnd; - mSuperWndProc = (WNDPROC)SetWindowLongPtr(GWLP_WNDPROC, (LONG_PTR)&_WindowProc); + mSuperWndProc = bit_cast(SetWindowLongPtr(GWLP_WNDPROC, (LONG_PTR)&_WindowProc)); SetProp(::gCefClientWindowPropName, (HANDLE)this); return true; } @@ -178,13 +178,13 @@ LRESULT cef_window::DefaultWindowProc(UINT message, WPARAM wParam, LPARAM lParam // calls PostNcDestroy BOOL cef_window::HandleNcDestroy() { - WNDPROC superWndProc = WNDPROC(GetWindowLongPtr(GWLP_WNDPROC)); + WNDPROC superWndProc = bit_cast(GetWindowLongPtr(GWLP_WNDPROC)); RemoveProp(::gCefClientWindowPropName); DefaultWindowProc(WM_NCDESTROY, 0, 0); - if ((WNDPROC(GetWindowLongPtr(GWLP_WNDPROC)) == superWndProc) && (mSuperWndProc != NULL)) + if ((bit_cast(GetWindowLongPtr(GWLP_WNDPROC)) == superWndProc) && (mSuperWndProc != NULL)) SetWindowLongPtr(GWLP_WNDPROC, reinterpret_cast(mSuperWndProc)); mSuperWndProc = NULL; diff --git a/appshell/cef_window.h b/appshell/cef_window.h index d7e0361f7..031047e48 100644 --- a/appshell/cef_window.h +++ b/appshell/cef_window.h @@ -148,13 +148,13 @@ class cef_window HANDLE RemoveProp(LPCWSTR lpString) { return ::RemoveProp(mWnd, lpString); } - LONG GetWindowLongPtr(int nIndex) const + LONG_PTR GetWindowLongPtr(int nIndex) const { return ::GetWindowLongPtr(mWnd, nIndex); } - LONG SetWindowLongPtr(int nIndex, LONG dwNewLong) + LONG_PTR SetWindowLongPtr(int nIndex, LONG_PTR dwNewLong) { return ::SetWindowLongPtr(mWnd, nIndex, dwNewLong); } - LONG GetClassLongPtr(int nIndex) const + ULONG_PTR GetClassLongPtr(int nIndex) const { return ::GetClassLongPtr(mWnd, nIndex); } BOOL GetWindowInfo (PWINDOWINFO pwi) const @@ -200,10 +200,22 @@ class cef_window { return ::IsWindowVisible(mWnd); } void SetStyle(DWORD dwStyle) - { SetWindowLong(GWL_STYLE, dwStyle); } + { +#ifdef _WIN64 + SetWindowLong(mWnd, GWL_STYLE, dwStyle); +#else + SetWindowLong(GWL_STYLE, dwStyle); +#endif // __WIN64 + } DWORD GetStyle() const - { return GetWindowLong(GWL_STYLE); } + { +#ifdef _WIN64 + return GetWindowLong(mWnd,GWL_STYLE); +#else + return GetWindowLong(GWL_STYLE); +#endif // __WIN64 + } void RemoveStyle(DWORD dwStyle) { SetStyle(GetStyle() & ~dwStyle); } @@ -212,11 +224,22 @@ class cef_window { SetStyle(GetStyle() & dwStyle); } void SetExStyle(DWORD dwExStyle) - { SetWindowLong(GWL_EXSTYLE, dwExStyle); } - - DWORD GetExStyle() const - { return GetWindowLong(GWL_EXSTYLE); } + { +#ifdef _WIN64 + SetWindowLong(mWnd,GWL_EXSTYLE, dwExStyle); +#else + SetWindowLong(GWL_EXSTYLE, dwExStyle); +#endif // __WIN64 + } + DWORD GetExStyle() const + { +#ifdef _WIN64 + return GetWindowLong(mWnd, GWL_EXSTYLE); +#else + return GetWindowLong(GWL_EXSTYLE); +#endif // __WIN64 + } void RemoveExStyle(DWORD dwExStyle) { SetExStyle(GetExStyle() & ~dwExStyle); } @@ -249,3 +272,15 @@ class cef_window BOOL TrackNonClientMouseEvents(bool track = true); }; + + +#include +template +inline Dest bit_cast(Source const & src) +{ + static_assert(sizeof(Source) == sizeof(Dest), "Size of Source and Destination type must be same"); + Dest dest; + std::memcpy(&dest, &src, sizeof(Dest)); + return dest; +} + diff --git a/appshell/cefclient_win.cpp b/appshell/cefclient_win.cpp index a53ceb07a..492f994f4 100644 --- a/appshell/cefclient_win.cpp +++ b/appshell/cefclient_win.cpp @@ -13,7 +13,6 @@ #include "include/cef_version.h" #include "include/cef_browser.h" #include "include/cef_frame.h" -#include "include/cef_runnable.h" #include "client_handler.h" #include "config.h" #include "appshell/browser/resource.h" @@ -63,7 +62,7 @@ extern CefRefPtr g_handler; void StripColonNumber(std::wstring& str) { bool gotDigits = false; int index; - for (index = str.size() - 1; index >= 0; index--) { + for (index = static_cast(str.size()) - 1; index >= 0; index--) { if (!isdigit(str[index])) break; gotDigits = true; @@ -213,7 +212,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, // note: WM_COPYDATA will manage passing the string across process space COPYDATASTRUCT data; data.dwData = ID_WM_COPYDATA_SENDOPENFILECOMMAND; - data.cbData = (wstrFilename.length() + 1) * sizeof(WCHAR); + data.cbData = static_cast((wstrFilename.length() + 1) * sizeof(WCHAR)); data.lpData = (LPVOID)wstrFilename.c_str(); ::SendMessage(hFirstInstanceWnd, WM_COPYDATA, (WPARAM)(HWND)hFirstInstanceWnd, (LPARAM)(LPVOID)&data); // exit this instance diff --git a/appshell/client_app.cpp b/appshell/client_app.cpp index 828ac8084..e08cb7cdd 100644 --- a/appshell/client_app.cpp +++ b/appshell/client_app.cpp @@ -113,7 +113,7 @@ bool ClientApp::OnProcessMessageReceived( // which can lead to bad things. If the browser instance has been deleted, don't // invoke this callback. if (context->GetBrowser()) { - for (size_t i = 1; i < messageArgs->GetSize(); i++) { + for (int i = 1; i < static_cast(messageArgs->GetSize()); ++i) { arguments.push_back(appshell::ListValueToV8Value(messageArgs, i)); } diff --git a/tasks/setup.js b/tasks/setup.js index 381fe2fbc..54fb8ad85 100644 --- a/tasks/setup.js +++ b/tasks/setup.js @@ -65,9 +65,20 @@ module.exports = function (grunt) { return exec("unzip -q \"" + src + "\" -d \"" + dest + "\""); } + var target_archbit = grunt.option('force-target-word-size') || "32"; + + function platform_arch_suffix() + { + var arch = common.arch(); + if( arch == "") + { + return target_archbit; + } + return arch; + } // task: cef grunt.registerTask("cef", "Download and setup CEF", function () { - var config = "cef-" + platform + common.arch(), + var config = "cef-" + platform + platform_arch_suffix(), zipSrc = grunt.config("curl-dir." + config + ".src"), zipName = path.basename(zipSrc), zipDest = path.resolve(process.cwd(), path.join(grunt.config("curl-dir." + config + ".dest"), zipName)), @@ -127,7 +138,7 @@ module.exports = function (grunt) { // task: icu grunt.registerTask("icu", "Download and setup ICU", function () { - var config = "icu-" + platform + common.arch(), + var config = "icu-" + platform + platform_arch_suffix(), zipSrc = grunt.config("curl-dir." + config + ".src"), zipName = path.basename(zipSrc), zipDest = path.resolve(process.cwd(), path.join(grunt.config("curl-dir." + config + ".dest"), zipName)), @@ -181,7 +192,7 @@ module.exports = function (grunt) { // task: vs-crt grunt.registerTask("vs-crt", "Download and setup VS CRT dlls", function () { if (platform === "win") { - var config = "vs-crt-" + platform + common.arch(), + var config = "vs-crt-" + platform + platform_arch_suffix(), zipSrc = grunt.config("curl-dir." + config + ".src"), zipName = path.basename(zipSrc), zipDest = path.resolve(process.cwd(), path.join(grunt.config("curl-dir." + config + ".dest"), zipName)), @@ -255,7 +266,7 @@ module.exports = function (grunt) { } grunt.registerTask("cef-symbols", "Download and unpack the CEF symbols", function () { - var config = "cef-" + platform + common.arch() + "-symbols", + var config = "cef-" + platform + platform_arch_suffix() + "-symbols", zipSymbols = grunt.config("curl-dir." + config + ".src"); if (zipSymbols) { @@ -511,7 +522,7 @@ module.exports = function (grunt) { // task: node-download grunt.registerTask("node", "Download Node.js binaries and setup dependencies", function () { - var config = "node-" + platform + common.arch(), + var config = "node-" + platform + platform_arch_suffix(), nodeSrc = grunt.config("curl-dir." + config + ".src"), nodeDest = [], dest = grunt.config("curl-dir." + config + ".dest"), From e10bc650940dfc99163ab8d1101676bb5fcddd98 Mon Sep 17 00:00:00 2001 From: Gautam Jha Date: Tue, 2 Apr 2019 17:49:34 +0530 Subject: [PATCH 2/9] Some changes were missed --- Gruntfile.js | 4 +-- appshell/appshell_extensions.cpp | 6 ++-- appshell/appshell_extensions_win.cpp | 6 ++-- scripts/brackets_installer_projects_x64.bat | 39 +++++++++++++++++++++ scripts/build_projects_x64.bat | 36 +++++++++++++++++++ tasks/build.js | 24 +++++++++++-- 6 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 scripts/brackets_installer_projects_x64.bat create mode 100644 scripts/build_projects_x64.bat diff --git a/Gruntfile.js b/Gruntfile.js index 9e81fec31..6486688e2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -121,7 +121,7 @@ module.exports = function (grunt) { }, "node-win64": { "dest" : "<%= downloads %>", - "src" : "http://nodejs.org/dist/v<%= node.version %>/win-x86/node.exe" + "src" : "http://nodejs.org/dist/v<%= node.version %>/win-x64/node.exe" }, "icu-win64": { "dest" : "<%= downloads %>", @@ -352,7 +352,7 @@ module.exports = function (grunt) { "version" : "6.14.0" }, "icu": { - "url" : "http://localhost:8001", + "url" : "http://s3.amazonaws.com/files.brackets.io/icu", "version" : "58" }, "vsCrt": { diff --git a/appshell/appshell_extensions.cpp b/appshell/appshell_extensions.cpp index c5ac80bd8..a8d620311 100644 --- a/appshell/appshell_extensions.cpp +++ b/appshell/appshell_extensions.cpp @@ -811,8 +811,8 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate { ReadDir(path, dirContents); // Now we iterator through the contents of directoryContents. - size_t theSize = dirContents->GetSize(); - for ( size_t iFileEntry = 0; iFileEntry < theSize ; ++iFileEntry) { + int theSize = static_cast(dirContents->GetSize()); + for ( int iFileEntry = 0; iFileEntry < theSize ; ++iFileEntry) { CefRefPtr fileStats = CefListValue::Create(); #ifdef OS_WIN @@ -821,7 +821,7 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate { ExtensionString theFile = path + "/"; #endif - ExtensionString fileName = dirContents->GetString(iFileEntry); + ExtensionString fileName = dirContents->GetString(iFileEntry).ToWString(); theFile = theFile + fileName; ExtensionString realPath; diff --git a/appshell/appshell_extensions_win.cpp b/appshell/appshell_extensions_win.cpp index 02ffd1dc6..22ac9f2f5 100644 --- a/appshell/appshell_extensions_win.cpp +++ b/appshell/appshell_extensions_win.cpp @@ -617,10 +617,10 @@ int32 ReadDir(ExtensionString path, CefRefPtr& directoryContents) } // On Windows, list directories first, then files - size_t i, total = 0; - for (i = 0; i < resultDirs.size(); i++) + int i, total = 0; + for (i = 0; i < static_cast(resultDirs.size()); ++i) directoryContents->SetString(total++, resultDirs[i]); - for (i = 0; i < resultFiles.size(); i++) + for (i = 0; i < static_cast(resultFiles.size()); ++i) directoryContents->SetString(total++, resultFiles[i]); return NO_ERROR; diff --git a/scripts/brackets_installer_projects_x64.bat b/scripts/brackets_installer_projects_x64.bat new file mode 100644 index 000000000..ff21af21c --- /dev/null +++ b/scripts/brackets_installer_projects_x64.bat @@ -0,0 +1,39 @@ +:: Batch file that creates the custom DLLs required to build the windows installers +:: This file should *not* be called directly. It is called by the build.sh script. +@ECHO OFF + +IF DEFINED VS140COMNTOOLS GOTO VS2015 +IF DEFINED VS120COMNTOOLS GOTO VS2013 +IF DEFINED VS110COMNTOOLS GOTO VS2012 +IF DEFINED VS100COMNTOOLS GOTO VS2010 + +:VSNotInstalled +ECHO Visual Studio 2010, 2012, 2013 or 2015 must be installed. +GOTO Error + +:VS2015 +call "%VS140COMNTOOLS%/VsDevCmd.bat" +GOTO Build + +:VS2013 +call "%VS120COMNTOOLS%/VsDevCmd.bat" +GOTO Build + +:VS2012 +call "%VS110COMNTOOLS%/VsDevCmd.bat" +GOTO Build + +:VS2010 +call "%VS100COMNTOOLS%/VsDevCmd.bat" +GOTO Build + +:Build +msbuild.exe installer\win\LaunchBrackets\LaunchBracketsSolution.sln /nr:false /t:Clean /p:Platform=x64 /p:Configuration=Release +msbuild.exe installer\win\LaunchBrackets\LaunchBracketsSolution.sln /nr:false /t:Build /p:Platform=x64 /p:Configuration=Release + +msbuild.exe installer\win\BracketsConfigurator\BracketsConfiguratorSolution.sln /nr:false /t:Clean /p:Platform=x64 /p:Configuration=Release +msbuild.exe installer\win\BracketsConfigurator\BracketsConfiguratorSolution.sln /nr:false /t:Build /p:Platform=x64 /p:Configuration=Release +exit /b %ERRORLEVEL% + +:Error +exit /b 1 diff --git a/scripts/build_projects_x64.bat b/scripts/build_projects_x64.bat new file mode 100644 index 000000000..e1021d8fd --- /dev/null +++ b/scripts/build_projects_x64.bat @@ -0,0 +1,36 @@ +:: Batch file that sets up Visual Studio command line tools and builds appshell.sln +:: This file should *not* be called directly. It is called by the build.sh script. +@ECHO OFF + +IF DEFINED VS140COMNTOOLS GOTO VS2015 +IF DEFINED VS120COMNTOOLS GOTO VS2013 +IF DEFINED VS110COMNTOOLS GOTO VS2012 +IF DEFINED VS100COMNTOOLS GOTO VS2010 + +:VSNotInstalled +ECHO Visual Studio 2010, 2012, 2013 or 2015 must be installed. +GOTO Error + +:VS2015 +call "%VS140COMNTOOLS%/VsDevCmd.bat" +GOTO Build + +:VS2013 +call "%VS120COMNTOOLS%/VsDevCmd.bat" +GOTO Build + +:VS2012 +call "%VS110COMNTOOLS%/VsDevCmd.bat" +GOTO Build + +:VS2010 +call "%VS100COMNTOOLS%/VsDevCmd.bat" +GOTO Buildddddd + +:Build +msbuild.exe appshell.sln /nr:false /t:Clean /p:Platform=x64 /p:Configuration=Release +msbuild.exe appshell.sln /nr:false /t:Build /p:Platform=x64 /p:Configuration=Release +exit /b %ERRORLEVEL% + +:Error +exit /b 1 diff --git a/tasks/build.js b/tasks/build.js index 272fd8137..b3dc6b7a6 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -59,9 +59,18 @@ module.exports = function (grunt) { grunt.registerTask("full-build", ["git", "create-project", "build-www", "build", "stage", "package"]); grunt.registerTask("installer", ["set-release-optional", "full-build", "build-installer"]); + //Not to be used for MacOS + var target_wordsize_arg = grunt.option('force-target-word-size') || undefined; + + function platform_arch_suffix() + { + if(target_wordsize_arg){ return target_wordsize_arg; } + if (process.platform === "win32") { return "32"; } + return common.arch(); + } // task: build grunt.registerTask("build", "Build shell executable. Run 'grunt full-build' to update repositories, build the shell and package www files.", function (wwwBranch, shellBranch) { - grunt.task.run("build-" + platform); + grunt.task.run("build-" + platform + platform_arch_suffix()); }); // task: build-www @@ -96,7 +105,7 @@ module.exports = function (grunt) { }); // task: build-win - grunt.registerTask("build-win", "Build windows shell", function () { + grunt.registerTask("build-win32", "Build 32 bit windows shell", function () { var done = this.async(); spawn(["cmd.exe /c scripts\\build_projects.bat", "cmd.exe /c scripts\\brackets_installer_projects.bat"]).then(function () { @@ -107,6 +116,17 @@ module.exports = function (grunt) { }); }); + // task: build-x64 + grunt.registerTask("build-win64", "Build 64 bit windows shell", function () { + var done = this.async(); + + spawn(["cmd.exe /c scripts\\build_projects_x64.bat", "cmd.exe /c scripts\\brackets_installer_projects_x64.bat"]).then(function () { + done(); + }, function (err) { + grunt.log.error(err); + done(false); + }); + }); // task: build-linux grunt.registerTask("build-linux", "Build linux shell", function () { var done = this.async(); From 6c483ed7d29dee848ada1a22173dba3f064fe027 Mon Sep 17 00:00:00 2001 From: Gautam Jha Date: Fri, 3 May 2019 16:56:14 +0530 Subject: [PATCH 3/9] Fixed command line argument name for arch --- tasks/build.js | 10 ++-------- tasks/common.js | 7 ++++++- tasks/setup.js | 25 ++++++++----------------- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/tasks/build.js b/tasks/build.js index b3dc6b7a6..04510a1b0 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -60,17 +60,11 @@ module.exports = function (grunt) { grunt.registerTask("installer", ["set-release-optional", "full-build", "build-installer"]); //Not to be used for MacOS - var target_wordsize_arg = grunt.option('force-target-word-size') || undefined; + var target_arch_hint = grunt.option('arch') || undefined; - function platform_arch_suffix() - { - if(target_wordsize_arg){ return target_wordsize_arg; } - if (process.platform === "win32") { return "32"; } - return common.arch(); - } // task: build grunt.registerTask("build", "Build shell executable. Run 'grunt full-build' to update repositories, build the shell and package www files.", function (wwwBranch, shellBranch) { - grunt.task.run("build-" + platform + platform_arch_suffix()); + grunt.task.run("build-" + platform + common.arch(target_arch_hint)); }); // task: build-www diff --git a/tasks/common.js b/tasks/common.js index f095651b7..4a867b9ab 100644 --- a/tasks/common.js +++ b/tasks/common.js @@ -233,7 +233,12 @@ module.exports = function (grunt) { return _platform; } - function arch() { + function arch(hint) { + hint = !hint && platform() === 'win' ? 'ia32' : hint; + hint = platform() === 'mac' ? undefined : hint; + if (['x64', 'ia32'].includes(hint)) { + return hint.slice(-2); + } if (platform() === "linux") { if (process.arch === "x64") { return 64; diff --git a/tasks/setup.js b/tasks/setup.js index 54fb8ad85..3a085b68f 100644 --- a/tasks/setup.js +++ b/tasks/setup.js @@ -65,20 +65,11 @@ module.exports = function (grunt) { return exec("unzip -q \"" + src + "\" -d \"" + dest + "\""); } - var target_archbit = grunt.option('force-target-word-size') || "32"; - - function platform_arch_suffix() - { - var arch = common.arch(); - if( arch == "") - { - return target_archbit; - } - return arch; - } + var target_arch_hint = grunt.option('arch') || undefined; + // task: cef grunt.registerTask("cef", "Download and setup CEF", function () { - var config = "cef-" + platform + platform_arch_suffix(), + var config = "cef-" + platform + common.arch(target_arch_hint), zipSrc = grunt.config("curl-dir." + config + ".src"), zipName = path.basename(zipSrc), zipDest = path.resolve(process.cwd(), path.join(grunt.config("curl-dir." + config + ".dest"), zipName)), @@ -138,7 +129,7 @@ module.exports = function (grunt) { // task: icu grunt.registerTask("icu", "Download and setup ICU", function () { - var config = "icu-" + platform + platform_arch_suffix(), + var config = "icu-" + platform + common.arch(target_arch_hint), zipSrc = grunt.config("curl-dir." + config + ".src"), zipName = path.basename(zipSrc), zipDest = path.resolve(process.cwd(), path.join(grunt.config("curl-dir." + config + ".dest"), zipName)), @@ -192,7 +183,7 @@ module.exports = function (grunt) { // task: vs-crt grunt.registerTask("vs-crt", "Download and setup VS CRT dlls", function () { if (platform === "win") { - var config = "vs-crt-" + platform + platform_arch_suffix(), + var config = "vs-crt-" + platform + common.arch(target_arch_hint), zipSrc = grunt.config("curl-dir." + config + ".src"), zipName = path.basename(zipSrc), zipDest = path.resolve(process.cwd(), path.join(grunt.config("curl-dir." + config + ".dest"), zipName)), @@ -266,7 +257,7 @@ module.exports = function (grunt) { } grunt.registerTask("cef-symbols", "Download and unpack the CEF symbols", function () { - var config = "cef-" + platform + platform_arch_suffix() + "-symbols", + var config = "cef-" + platform + common.arch(target_arch_hint) + "-symbols", zipSymbols = grunt.config("curl-dir." + config + ".src"); if (zipSymbols) { @@ -522,7 +513,7 @@ module.exports = function (grunt) { // task: node-download grunt.registerTask("node", "Download Node.js binaries and setup dependencies", function () { - var config = "node-" + platform + platform_arch_suffix(), + var config = "node-" + platform + common.arch(target_arch_hint), nodeSrc = grunt.config("curl-dir." + config + ".src"), nodeDest = [], dest = grunt.config("curl-dir." + config + ".dest"), @@ -699,4 +690,4 @@ module.exports = function (grunt) { } else { grunt.registerTask("setup", ["cef", "node", "node-check", "icu", "create-project"]); } -}; \ No newline at end of file +}; From fd79cbb89160188803d7a54d0f267cc332fb5c07 Mon Sep 17 00:00:00 2001 From: Gautam Jha Date: Fri, 3 May 2019 17:21:19 +0530 Subject: [PATCH 4/9] enclosed bit_cast to namespace from_cpp20 --- appshell/appshell_extensions_win.cpp | 6 +++--- appshell/cef_dark_window.cpp | 4 ++-- appshell/cef_host_window.cpp | 2 +- appshell/cef_main_window.cpp | 2 +- appshell/cef_window.cpp | 6 +++--- appshell/cef_window.h | 18 ++++++++++-------- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/appshell/appshell_extensions_win.cpp b/appshell/appshell_extensions_win.cpp index 22ac9f2f5..799947fa7 100644 --- a/appshell/appshell_extensions_win.cpp +++ b/appshell/appshell_extensions_win.cpp @@ -279,7 +279,7 @@ void CALLBACK LiveBrowserMgrWin::CloseLiveBrowserAsyncCallback( HWND hwnd, UINT } else if(s_instance->m_closeLiveBrowserHeartbeatTimerId == 0){ //start a heartbeat timer to see if it closes after the message returned - s_instance->m_closeLiveBrowserHeartbeatTimerId = ::SetTimer(NULL, 0, 30, bit_cast(&CloseLiveBrowserTimerCallback)); + s_instance->m_closeLiveBrowserHeartbeatTimerId = ::SetTimer(NULL, 0, 30, from_cpp20::bit_cast(&CloseLiveBrowserTimerCallback)); } } @@ -400,13 +400,13 @@ void CloseLiveBrowser(CefRefPtr browser, CefRefPtrCloseLiveBrowserFireCallback(NO_ERROR); } else if (liveBrowserMgr->GetCloseCallback()) { // set a timeout for up to 10 seconds to close the browser - liveBrowserMgr->SetCloseTimeoutTimerId( ::SetTimer(NULL, 0, 10 * 1000, bit_cast(&LiveBrowserMgrWin::CloseLiveBrowserTimerCallback)) ); + liveBrowserMgr->SetCloseTimeoutTimerId( ::SetTimer(NULL, 0, 10 * 1000, from_cpp20::bit_cast(&LiveBrowserMgrWin::CloseLiveBrowserTimerCallback)) ); } } int32 OpenURLInDefaultBrowser(ExtensionString url) { - DWORD_PTR result = bit_cast(ShellExecute(NULL, L"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL)); + DWORD_PTR result = from_cpp20::bit_cast(ShellExecute(NULL, L"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL)); // If the result > 32, the function suceeded. If the result is <= 32, it is an // error code. diff --git a/appshell/cef_dark_window.cpp b/appshell/cef_dark_window.cpp index 6e8e6211b..afedc7ab8 100644 --- a/appshell/cef_dark_window.cpp +++ b/appshell/cef_dark_window.cpp @@ -509,11 +509,11 @@ void cef_dark_window::DoDrawSystemMenuIcon(HDC hdc) // Start with the small if (!mWindowIcon) - mWindowIcon = bit_cast(GetClassLongPtr(GCLP_HICONSM)); + mWindowIcon = from_cpp20::bit_cast(GetClassLongPtr(GCLP_HICONSM)); // Then try to load the big icon if (!mWindowIcon) - mWindowIcon = bit_cast(GetClassLongPtr(GCLP_HICON)); + mWindowIcon = from_cpp20::bit_cast(GetClassLongPtr(GCLP_HICON)); // Otherwise we need an icon, so just use the standard Windows default // application Icon which may very between versions diff --git a/appshell/cef_host_window.cpp b/appshell/cef_host_window.cpp index 693dfd2e4..0656cb8c5 100644 --- a/appshell/cef_host_window.cpp +++ b/appshell/cef_host_window.cpp @@ -168,7 +168,7 @@ BOOL cef_host_window::HandleSize(BOOL bMinimize) if (GetProp(L"WasMinimized")) { DoRepaintClientArea(); } - SetPropW(L"WasMinimized", bit_cast(&bMinimize)); + SetPropW(L"WasMinimized", from_cpp20::bit_cast(&bMinimize)); #endif NotifyWindowMovedOrResized(); return FALSE; diff --git a/appshell/cef_main_window.cpp b/appshell/cef_main_window.cpp index 836ee76be..6cc75c4fe 100644 --- a/appshell/cef_main_window.cpp +++ b/appshell/cef_main_window.cpp @@ -292,7 +292,7 @@ BOOL cef_main_window::HandleClose() CefWindowHandle hwnd = SafeGetCefBrowserHwnd(); if (hwnd) { - DWORD_PTR closing = bit_cast(::GetProp(hwnd, ::kCefWindowClosingPropName)); + DWORD_PTR closing = from_cpp20::bit_cast(::GetProp(hwnd, ::kCefWindowClosingPropName)); if (closing) { if (!g_handler->CanCloseBrowser(GetBrowser())) { diff --git a/appshell/cef_window.cpp b/appshell/cef_window.cpp index a749ed32b..2794b5e94 100644 --- a/appshell/cef_window.cpp +++ b/appshell/cef_window.cpp @@ -125,7 +125,7 @@ bool cef_window::SubclassWindow(HWND hWnd) if (::GetProp(hWnd, ::gCefClientWindowPropName) != NULL) return false; mWnd = hWnd; - mSuperWndProc = bit_cast(SetWindowLongPtr(GWLP_WNDPROC, (LONG_PTR)&_WindowProc)); + mSuperWndProc = from_cpp20::bit_cast(SetWindowLongPtr(GWLP_WNDPROC, (LONG_PTR)&_WindowProc)); SetProp(::gCefClientWindowPropName, (HANDLE)this); return true; } @@ -178,13 +178,13 @@ LRESULT cef_window::DefaultWindowProc(UINT message, WPARAM wParam, LPARAM lParam // calls PostNcDestroy BOOL cef_window::HandleNcDestroy() { - WNDPROC superWndProc = bit_cast(GetWindowLongPtr(GWLP_WNDPROC)); + WNDPROC superWndProc = from_cpp20::bit_cast(GetWindowLongPtr(GWLP_WNDPROC)); RemoveProp(::gCefClientWindowPropName); DefaultWindowProc(WM_NCDESTROY, 0, 0); - if ((bit_cast(GetWindowLongPtr(GWLP_WNDPROC)) == superWndProc) && (mSuperWndProc != NULL)) + if ((from_cpp20::bit_cast(GetWindowLongPtr(GWLP_WNDPROC)) == superWndProc) && (mSuperWndProc != NULL)) SetWindowLongPtr(GWLP_WNDPROC, reinterpret_cast(mSuperWndProc)); mSuperWndProc = NULL; diff --git a/appshell/cef_window.h b/appshell/cef_window.h index 031047e48..79cfef8e0 100644 --- a/appshell/cef_window.h +++ b/appshell/cef_window.h @@ -274,13 +274,15 @@ class cef_window }; -#include -template -inline Dest bit_cast(Source const & src) -{ - static_assert(sizeof(Source) == sizeof(Dest), "Size of Source and Destination type must be same"); - Dest dest; - std::memcpy(&dest, &src, sizeof(Dest)); - return dest; +#include +#include +namespace from_cpp20 { + template + inline auto bit_cast(Source const & src) -> typename std::enable_if::type + { + Dest dest; + std::memcpy(&dest, &src, sizeof(Dest)); + return dest; + } } From 2a8c8ccac04109fb9d699b5c553ba03bbdb69f6d Mon Sep 17 00:00:00 2001 From: Gautam Jha Date: Tue, 7 May 2019 17:07:16 +0530 Subject: [PATCH 5/9] Addressing review comments form vickramdhawal --- appshell/cef_window.h | 11 ++++++++++- tasks/common.js | 10 +--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/appshell/cef_window.h b/appshell/cef_window.h index 79cfef8e0..c8e144660 100644 --- a/appshell/cef_window.h +++ b/appshell/cef_window.h @@ -277,8 +277,17 @@ class cef_window #include #include namespace from_cpp20 { + template + struct int_or_ptr { + static constexpr bool value = std::is_pointer::value || std::is_integral::value; + }; template - inline auto bit_cast(Source const & src) -> typename std::enable_if::type + inline typename std::enable_if< + int_or_ptr::value && + int_or_ptr::value && + sizeof(Source) == sizeof(Dest), + Dest>::type + bit_cast(Source const & src) { Dest dest; std::memcpy(&dest, &src, sizeof(Dest)); diff --git a/tasks/common.js b/tasks/common.js index 4a867b9ab..48d55ab7c 100644 --- a/tasks/common.js +++ b/tasks/common.js @@ -234,19 +234,11 @@ module.exports = function (grunt) { } function arch(hint) { - hint = !hint && platform() === 'win' ? 'ia32' : hint; + hint = hint ? hint : process.arch; hint = platform() === 'mac' ? undefined : hint; if (['x64', 'ia32'].includes(hint)) { return hint.slice(-2); } - if (platform() === "linux") { - if (process.arch === "x64") { - return 64; - } else { - return 32; - } - } - return ""; } From 8269e9ab87f022909afa133b3528354440e17d3f Mon Sep 17 00:00:00 2001 From: Gautam Jha Date: Wed, 15 May 2019 15:46:36 +0530 Subject: [PATCH 6/9] Addressed review comments --- tasks/build.js | 2 +- tasks/common.js | 4 +++- tasks/setup.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tasks/build.js b/tasks/build.js index 04510a1b0..b1d96c6a9 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -60,7 +60,7 @@ module.exports = function (grunt) { grunt.registerTask("installer", ["set-release-optional", "full-build", "build-installer"]); //Not to be used for MacOS - var target_arch_hint = grunt.option('arch') || undefined; + var target_arch_hint = grunt.option('arch'); // task: build grunt.registerTask("build", "Build shell executable. Run 'grunt full-build' to update repositories, build the shell and package www files.", function (wwwBranch, shellBranch) { diff --git a/tasks/common.js b/tasks/common.js index 48d55ab7c..e37717872 100644 --- a/tasks/common.js +++ b/tasks/common.js @@ -234,8 +234,10 @@ module.exports = function (grunt) { } function arch(hint) { + if (platform() === 'mac') { + return ''; + } hint = hint ? hint : process.arch; - hint = platform() === 'mac' ? undefined : hint; if (['x64', 'ia32'].includes(hint)) { return hint.slice(-2); } diff --git a/tasks/setup.js b/tasks/setup.js index 3a085b68f..cd8f6764a 100644 --- a/tasks/setup.js +++ b/tasks/setup.js @@ -65,7 +65,7 @@ module.exports = function (grunt) { return exec("unzip -q \"" + src + "\" -d \"" + dest + "\""); } - var target_arch_hint = grunt.option('arch') || undefined; + var target_arch_hint = grunt.option('arch'); // task: cef grunt.registerTask("cef", "Download and setup CEF", function () { From 42f3d444e623a99d58cc7008091155e351bf6826 Mon Sep 17 00:00:00 2001 From: Gautam Jha Date: Wed, 15 May 2019 17:54:25 +0530 Subject: [PATCH 7/9] It was a typo --- scripts/build_projects_x64.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_projects_x64.bat b/scripts/build_projects_x64.bat index e1021d8fd..8ada762b9 100644 --- a/scripts/build_projects_x64.bat +++ b/scripts/build_projects_x64.bat @@ -25,7 +25,7 @@ GOTO Build :VS2010 call "%VS100COMNTOOLS%/VsDevCmd.bat" -GOTO Buildddddd +GOTO Build :Build msbuild.exe appshell.sln /nr:false /t:Clean /p:Platform=x64 /p:Configuration=Release From 3d6c56f1f3c5e0961ac5737492067e71ce2dfffb Mon Sep 17 00:00:00 2001 From: Gautam Jha Date: Tue, 28 May 2019 16:23:39 +0530 Subject: [PATCH 8/9] Using 64 bit vs-crt --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6486688e2..efbd2d09c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -129,7 +129,7 @@ module.exports = function (grunt) { }, "vs-crt-win64": { "dest" : "<%= downloads %>", - "src" : "<%= vsCrt.url %>/vs<%= vsCrt.version %>-crt-ia32.zip" + "src" : "<%= vsCrt.url %>/vs<%= vsCrt.version %>-crt-x64.zip" } }, "clean": { From 5029c2b758ce9f0065e10d2bf6b68993531c8eb6 Mon Sep 17 00:00:00 2001 From: Gautam Jha Date: Thu, 13 Jun 2019 12:34:16 +0530 Subject: [PATCH 9/9] Avoiding size truncation for size-t while converting to signed int --- appshell/appshell_extension_handler.h | 10 ++++++---- appshell/appshell_extensions.cpp | 4 ++-- appshell/appshell_extensions_win.cpp | 28 +++++++++++++++++---------- appshell/cef_registry.cpp | 2 +- appshell/cefclient_win.cpp | 7 ++++--- appshell/client_app.cpp | 3 ++- 6 files changed, 33 insertions(+), 21 deletions(-) diff --git a/appshell/appshell_extension_handler.h b/appshell/appshell_extension_handler.h index 7d7a8953a..4d19038ca 100644 --- a/appshell/appshell_extension_handler.h +++ b/appshell/appshell_extension_handler.h @@ -74,7 +74,8 @@ CefRefPtr ListValueToV8Value(CefRefPtr value, int inde switch (type) { case VTYPE_LIST: { CefRefPtr list = value->GetList(index); - new_value = CefV8Value::CreateArray(static_cast(list->GetSize())); + std::make_signed::type theSize = list->GetSize(); + new_value = CefV8Value::CreateArray(theSize); SetList(list, new_value); } break; case VTYPE_BOOL: @@ -106,7 +107,8 @@ void SetListValue(CefRefPtr list, int index, switch (type) { case VTYPE_LIST: { CefRefPtr listValue = value->GetList(index); - new_value = CefV8Value::CreateArray(static_cast(listValue->GetSize())); + std::make_signed::type theSize = listValue->GetSize(); + new_value = CefV8Value::CreateArray(theSize); SetList(listValue, new_value); } break; case VTYPE_BOOL: @@ -136,11 +138,11 @@ void SetListValue(CefRefPtr list, int index, void SetList(CefRefPtr source, CefRefPtr target) { DCHECK(target->IsArray()); - int arg_length = static_cast(source->GetSize()); + std::make_signed::type arg_length = source->GetSize(); if (arg_length == 0) return; - for (int i = 0; i < arg_length; ++i) + for (decltype(arg_length) i = 0; i < arg_length; ++i) SetListValue(target, i, source); } diff --git a/appshell/appshell_extensions.cpp b/appshell/appshell_extensions.cpp index a8d620311..c16f5b464 100644 --- a/appshell/appshell_extensions.cpp +++ b/appshell/appshell_extensions.cpp @@ -811,8 +811,8 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate { ReadDir(path, dirContents); // Now we iterator through the contents of directoryContents. - int theSize = static_cast(dirContents->GetSize()); - for ( int iFileEntry = 0; iFileEntry < theSize ; ++iFileEntry) { + std::make_signed::type theSize = dirContents->GetSize(); + for (decltype(theSize) iFileEntry = 0; iFileEntry < theSize ; ++iFileEntry) { CefRefPtr fileStats = CefListValue::Create(); #ifdef OS_WIN diff --git a/appshell/appshell_extensions_win.cpp b/appshell/appshell_extensions_win.cpp index 799947fa7..e4bd9e843 100644 --- a/appshell/appshell_extensions_win.cpp +++ b/appshell/appshell_extensions_win.cpp @@ -357,7 +357,7 @@ int32 OpenLiveBrowser(ExtensionString argURL, bool enableRemoteDebugging) args += argURL; // Args must be mutable - int argsBufSize = static_cast(args.length()) +1; + std::make_signed::type argsBufSize = args.length(); ++argsBufSize; std::vector argsBuf; argsBuf.resize(argsBufSize); wcscpy(&argsBuf[0], args.c_str()); @@ -499,7 +499,8 @@ int32 ShowOpenDialog(bool allowMultipleSelection, } else { // Multiple files are selected wchar_t fullPath[MAX_UNC_PATH]; - for (int i = static_cast(dir.length() + 1), fileIndex = 0; ; fileIndex++) { + std::make_signed::type dirLen = dir.length(); + for (decltype(dirLen) i = dirLen + 1, fileIndex = 0; /* Infinite loop */ ; fileIndex++) { // Get the next file name std::wstring file(&szFile[i]); @@ -516,7 +517,8 @@ int32 ShowOpenDialog(bool allowMultipleSelection, } // Go to the start of the next file name - i += static_cast(file.length()) + 1; + std::make_signed::type fileLen = file.length(); + i += fileLen + 1; } } @@ -617,11 +619,17 @@ int32 ReadDir(ExtensionString path, CefRefPtr& directoryContents) } // On Windows, list directories first, then files - int i, total = 0; - for (i = 0; i < static_cast(resultDirs.size()); ++i) - directoryContents->SetString(total++, resultDirs[i]); - for (i = 0; i < static_cast(resultFiles.size()); ++i) - directoryContents->SetString(total++, resultFiles[i]); + std::make_signed::type total = 0; + { + std::make_signed::type resultDirSize = resultDirs.size(); + for (decltype(resultDirSize) i = 0; i < resultDirSize; ++i) + directoryContents->SetString(total++, resultDirs[i]); + } + { + std::make_signed::type resultFileSize = resultFiles.size(); + for (decltype(resultFileSize) i = 0; i < resultFileSize; ++i) + directoryContents->SetString(total++, resultFiles[i]); + } return NO_ERROR; } @@ -1209,8 +1217,8 @@ bool isSlash(ExtensionString::value_type wc) { return wc == '/' || wc == '\\'; } void RemoveTrailingSlash(ExtensionString& filename) { - int last = static_cast(filename.length()) - 1; - if ((last >= 0) && isSlash(filename.at(last))) { + std::make_signed::type last = filename.length(); + if ((--last >= 0) && isSlash(filename.at(last))) { filename.erase(last); } } diff --git a/appshell/cef_registry.cpp b/appshell/cef_registry.cpp index db28ba5cf..1d110fe2e 100644 --- a/appshell/cef_registry.cpp +++ b/appshell/cef_registry.cpp @@ -36,7 +36,7 @@ void EnsureTrailingSeparator(LPWSTR pRet) if (!pRet) return; - int len = static_cast(wcslen(pRet)); + std::make_signed::type len = wcslen(pRet); if (len > 0 && wcscmp(&(pRet[len-1]), L"\\") != 0) { wcscat(pRet, L"\\"); diff --git a/appshell/cefclient_win.cpp b/appshell/cefclient_win.cpp index 492f994f4..3a2f3d49d 100644 --- a/appshell/cefclient_win.cpp +++ b/appshell/cefclient_win.cpp @@ -61,8 +61,8 @@ extern CefRefPtr g_handler; // built into brackets-shell, and I don't want to add one just for this simple case). void StripColonNumber(std::wstring& str) { bool gotDigits = false; - int index; - for (index = static_cast(str.size()) - 1; index >= 0; index--) { + std::make_signed::type index = str.size(); + for (--index; index >= 0; --index) { if (!isdigit(str[index])) break; gotDigits = true; @@ -212,7 +212,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance, // note: WM_COPYDATA will manage passing the string across process space COPYDATASTRUCT data; data.dwData = ID_WM_COPYDATA_SENDOPENFILECOMMAND; - data.cbData = static_cast((wstrFilename.length() + 1) * sizeof(WCHAR)); + std::make_signed::type theLen = wstrFilename.length(); + data.cbData = static_cast((theLen + 1) * sizeof(WCHAR)); data.lpData = (LPVOID)wstrFilename.c_str(); ::SendMessage(hFirstInstanceWnd, WM_COPYDATA, (WPARAM)(HWND)hFirstInstanceWnd, (LPARAM)(LPVOID)&data); // exit this instance diff --git a/appshell/client_app.cpp b/appshell/client_app.cpp index e08cb7cdd..fa343c773 100644 --- a/appshell/client_app.cpp +++ b/appshell/client_app.cpp @@ -113,7 +113,8 @@ bool ClientApp::OnProcessMessageReceived( // which can lead to bad things. If the browser instance has been deleted, don't // invoke this callback. if (context->GetBrowser()) { - for (int i = 1; i < static_cast(messageArgs->GetSize()); ++i) { + std::make_signed::type theSize = messageArgs->GetSize(); + for (decltype(theSize) i = 1; i < theSize; ++i) { arguments.push_back(appshell::ListValueToV8Value(messageArgs, i)); }