Author: ashaposhnikov
Date: Sun Jun 25 01:09:00 2017
New Revision: 75190
URL:
http://svn.reactos.org/svn/reactos?rev=75190&view=rev
Log:
[RAPPS]
* available.cpp: Replaced macros with inline functions.
* gui.cpp: Fixed typo.
Modified:
branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
Sun Jun 25 01:09:00 2017
@@ -9,37 +9,52 @@
#include "rapps.h"
-#define ADD_TEXT(a, b, c, d) \
- if (b[0] != '\0') \
- { \
- LoadStringW(hInst, a, szText, _countof(szText)); \
- InsertRichEditText(szText, c); \
- InsertRichEditText(b, d); \
- } \
-
-#define ADD_TEXT_NEWL(a, b) \
- LoadStringW(hInst, a, szText, _countof(szText)); \
- InsertRichEditText(L"\n", 0); \
- InsertRichEditText(szText, b); \
- InsertRichEditText(L"\n", 0);
-
-#define GET_STRING1(a, b) \
- if (!ParserGetString(a, b, _countof(b), FindFileData.cFileName)) \
- continue;
-
-#define GET_STRING2(a, b) \
- if (!ParserGetString(a, b, _countof(b), FindFileData.cFileName)) \
- b[0] = '\0';
+
+template<typename T, size_t N, size_t N2>
+inline void _AddText(T (&szText)[N], UINT a, T (&b)[N2], DWORD c, DWORD d) {
+ if (b[0] != '\0')
+ {
+ LoadStringW(hInst, a, szText, N);
+ InsertRichEditText(szText, c);
+ InsertRichEditText(b, d);
+ }
+}
+
+template<typename T, size_t N>
+inline void _AddTextNewl(T (&szText)[N], UINT a, DWORD b) {
+ LoadStringW(hInst, a, szText, N);
+ InsertRichEditText(L"\n", 0);
+ InsertRichEditText(szText, b);
+ InsertRichEditText(L"\n", 0);
+}
+
+template<typename T, size_t N, size_t N2>
+inline BOOL _GetString(LPCWSTR a, T(&b)[N], T (&cFileName)[N2]) {
+ return ParserGetString(a, b, N, cFileName);
+}
+
+template<typename T, size_t N, size_t N2>
+inline void _GetStringNullFailure(LPCWSTR a, T(&b)[N], T (&cFileName)[N2]) {
+ if (!_GetString(a, b, cFileName)) {
+ b[0] = '\0';
+ }
+}
//App is "installed" if the RegName is in the registry
-#define APP_INSTALL_CHECK_K(Info, key) \
- (*Info->szRegName && (IsInstalledApplicationEx(Info->szRegName, FALSE,
key) \
- || IsInstalledApplicationEx(Info->szRegName, TRUE, key)))
+inline bool _AppInstallCheckKey(PAPPLICATION_INFO Info, REGSAM key) {
+ return *Info->szRegName
+ && (IsInstalledApplicationEx(Info->szRegName, TRUE, key)
+ || IsInstalledApplicationEx(Info->szRegName, FALSE, key));
+}
+
//Check both registry keys in 64bit system
//TODO: check system type beforehand to avoid double checks?
-#define APP_INSTALL_CHECK(Info) \
- (APP_INSTALL_CHECK_K(Info, KEY_WOW64_32KEY) || APP_INSTALL_CHECK_K(Info,
KEY_WOW64_64KEY))
+inline bool _AppInstallCheck(PAPPLICATION_INFO Info) {
+ return _AppInstallCheckKey(Info, KEY_WOW64_32KEY)
+ || _AppInstallCheckKey(Info, KEY_WOW64_64KEY);
+}
+
LIST_ENTRY CachedEntriesHead = { &CachedEntriesHead, &CachedEntriesHead };
PLIST_ENTRY pCachedEntry = &CachedEntriesHead;
@@ -53,20 +68,20 @@
if (!Info) return FALSE;
NewRichEditText(Info->szName, CFE_BOLD);
- if (APP_INSTALL_CHECK(Info))
- {
- ADD_TEXT_NEWL(IDS_STATUS_INSTALLED, CFE_ITALIC);
+ if (_AppInstallCheck(Info))
+ {
+ _AddTextNewl(szText, IDS_STATUS_INSTALLED, CFE_ITALIC);
} else
{
- ADD_TEXT_NEWL(IDS_STATUS_NOTINSTALLED, CFE_ITALIC);
- }
-
- ADD_TEXT(IDS_AINFO_VERSION, Info->szVersion, CFE_BOLD, 0);
- ADD_TEXT(IDS_AINFO_LICENSE, Info->szLicense, CFE_BOLD, 0);
- ADD_TEXT(IDS_AINFO_SIZE, Info->szSize, CFE_BOLD, 0);
- ADD_TEXT(IDS_AINFO_URLSITE, Info->szUrlSite, CFE_BOLD, CFE_LINK);
- ADD_TEXT(IDS_AINFO_DESCRIPTION, Info->szDesc, CFE_BOLD, 0);
- ADD_TEXT(IDS_AINFO_URLDOWNLOAD, Info->szUrlDownload, CFE_BOLD, CFE_LINK);
+ _AddTextNewl(szText, IDS_STATUS_NOTINSTALLED, CFE_ITALIC);
+ }
+
+ _AddText(szText, IDS_AINFO_VERSION, Info->szVersion, CFE_BOLD, 0);
+ _AddText(szText, IDS_AINFO_LICENSE, Info->szLicense, CFE_BOLD, 0);
+ _AddText(szText, IDS_AINFO_SIZE, Info->szSize, CFE_BOLD, 0);
+ _AddText(szText, IDS_AINFO_URLSITE, Info->szUrlSite, CFE_BOLD, CFE_LINK);
+ _AddText(szText, IDS_AINFO_DESCRIPTION, Info->szDesc, CFE_BOLD, 0);
+ _AddText(szText, IDS_AINFO_URLDOWNLOAD, Info->szUrlDownload, CFE_BOLD, CFE_LINK);
return TRUE;
}
@@ -272,17 +287,20 @@
if (Info->szUrlDownload[0] == 0)
{
- GET_STRING1(L"Name", Info->szName);
- GET_STRING1(L"URLDownload", Info->szUrlDownload);
-
- GET_STRING2(L"RegName", Info->szRegName);
- GET_STRING2(L"Version", Info->szVersion);
- GET_STRING2(L"License", Info->szLicense);
- GET_STRING2(L"Description", Info->szDesc);
- GET_STRING2(L"Size", Info->szSize);
- GET_STRING2(L"URLSite", Info->szUrlSite);
- GET_STRING2(L"CDPath", Info->szCDPath);
- GET_STRING2(L"SHA1", Info->szSHA1);
+ if (!_GetString(L"Name", Info->szName, FindFileData.cFileName)
+ || !_GetString(L"URLDownload", Info->szUrlDownload,
FindFileData.cFileName))
+ {
+ continue;
+ }
+
+ _GetStringNullFailure(L"RegName", Info->szRegName,
FindFileData.cFileName);
+ _GetStringNullFailure(L"Version", Info->szVersion,
FindFileData.cFileName);
+ _GetStringNullFailure(L"License", Info->szLicense,
FindFileData.cFileName);
+ _GetStringNullFailure(L"Description", Info->szDesc,
FindFileData.cFileName);
+ _GetStringNullFailure(L"Size", Info->szSize,
FindFileData.cFileName);
+ _GetStringNullFailure(L"URLSite", Info->szUrlSite,
FindFileData.cFileName);
+ _GetStringNullFailure(L"CDPath", Info->szCDPath,
FindFileData.cFileName);
+ _GetStringNullFailure(L"SHA1", Info->szSHA1,
FindFileData.cFileName);
}
if (!lpEnumProc(Info))
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1] Sun Jun
25 01:09:00 2017
@@ -1182,7 +1182,7 @@
hImageListView = ImageList_Create(LISTVIEW_ICON_SIZE,
LISTVIEW_ICON_SIZE,
GetSystemColorDepth() | ILC_MASK,
- 0, 1000);
+ 0, 1);
hImageListView = ListView_SetImageList(hListView, hImageListView, LVSIL_SMALL);
if (hImageListView)