Skip to content

Commit

Permalink
more 4241 & Intel C++ support
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Jan 17, 2015
1 parent 379f92d commit 54dc1f5
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 46 deletions.
8 changes: 7 additions & 1 deletion far/changelog
@@ -1,4 +1,10 @@
drkns 17.01.2015 09:38:11 +0200 - build 4241
drkns 17.01.2015 16:00:16 +0200 - build 4242

1. Продолжение 4241.

1. Поддержка компиляции в Intel C++ 14.

drkns 17.01.2015 09:38:11 +0200 - build 4241

1. Race condition при far /?

Expand Down
4 changes: 2 additions & 2 deletions far/codepage.cpp
Expand Up @@ -57,7 +57,7 @@ const wchar_t *NamesOfCodePagesKey = L"CodePages.Names";
const wchar_t *FavoriteCodePagesKey = L"CodePages.Favorites";

// Èñòî÷íèê âûçîâà êàëëáàêà ïðîõîäà ïî êîäîâûì ñòðàíèöàì
ENUM(codepages::CodePagesCallbackCallSource)
ENUM(CodePagesCallbackCallSource)
{
CodePageSelect,
CodePagesFill,
Expand All @@ -84,7 +84,7 @@ enum StandardCodePagesMenuItems
class system_codepages_enumerator
{
public:
const static codepages::codepages_data* context;
static const codepages::codepages_data* context;

static BOOL CALLBACK enum_cp(wchar_t *cpNum)
{
Expand Down
2 changes: 1 addition & 1 deletion far/codepage.hpp
Expand Up @@ -52,6 +52,7 @@ inline bool IsUnicodeOrUtfCodePage(uintptr_t cp) { return IsUnicodeCodePage(cp)
class Dialog;
struct DialogBuilderListItem2;
class VMenu2;
ENUM(CodePagesCallbackCallSource);

class codepages: noncopyable
{
Expand Down Expand Up @@ -101,7 +102,6 @@ class codepages: noncopyable
uintptr_t currentCodePage;
int favoriteCodePages, normalCodePages;
bool selectedCodePages;
ENUM(CodePagesCallbackCallSource);
CodePagesCallbackCallSource CallbackCallSource;

class codepages_data
Expand Down
14 changes: 4 additions & 10 deletions far/common/enum.hpp
Expand Up @@ -27,14 +27,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifdef __GNUC__
# define ENUM(ENUM_NAME) enum ENUM_NAME:int
#endif

#ifdef _MSC_VER
# if _MSC_VER>1600
# define ENUM(ENUM_NAME) enum ENUM_NAME:int
# else
# define ENUM(ENUM_NAME) enum ENUM_NAME
# endif
#if defined _MSC_VER && _MSC_VER < 1700
#define ENUM(ENUM_NAME) enum ENUM_NAME
#else
#define ENUM(ENUM_NAME) enum ENUM_NAME:int
#endif
2 changes: 1 addition & 1 deletion far/configdb.cpp
Expand Up @@ -2294,7 +2294,7 @@ HierarchicalConfigUniquePtr Database::CreateHierarchicalConfig(dbcheck DbId, con
return HierarchicalConfigUniquePtr(cfg.release());
}

ENUM(Database::dbcheck)
ENUM(dbcheck)
{
CHECK_NONE = 0,
CHECK_FILTERS = BIT(0),
Expand Down
23 changes: 22 additions & 1 deletion far/configdb.hpp
Expand Up @@ -58,6 +58,7 @@ class GeneralConfig: public XmlConfig, virtual public transactional
{
public:
virtual ~GeneralConfig() {}

virtual bool SetValue(const string& Key, const string& Name, const string& Value) = 0;
virtual bool SetValue(const string& Key, const string& Name, const wchar_t* Value) = 0;
virtual bool SetValue(const string& Key, const string& Name, unsigned __int64 Value) = 0;
Expand All @@ -66,12 +67,20 @@ class GeneralConfig: public XmlConfig, virtual public transactional
typename std::enable_if<!std::is_pointer<T>::value && !std::is_integral<T>::value, bool>::type
SetValue(const string& Key, const string& Name, const T& Value)
{
static_assert(std::is_pod<T>::value, "This template requires a POD type");
return SetValue(Key, Name, &Value, sizeof(Value));
}

virtual bool GetValue(const string& Key, const string& Name, long long *Value, long long Default) = 0;
virtual bool GetValue(const string& Key, const string& Name, string &strValue, const wchar_t *Default) = 0;
virtual int GetValue(const string& Key, const string& Name, void *Value, size_t Size, const void *Default) = 0;
template<class T>
typename std::enable_if<!std::is_pointer<T>::value && !std::is_integral<T>::value, bool>::type
GetValue(const string& Key, const string& Name, T& Value)
{
static_assert(std::is_pod<T>::value, "This template requires a POD type");
return GetValue(Key, Name, &Value, sizeof(Value)) != 0;
}

virtual bool DeleteValue(const string& Key, const string& Name) = 0;
virtual bool EnumValues(const string& Key, DWORD Index, string &strName, string &strValue) = 0;
Expand Down Expand Up @@ -106,6 +115,7 @@ class HierarchicalConfig: public XmlConfig, virtual public transactional
virtual unsigned __int64 CreateKey(unsigned __int64 Root, const string& Name, const string* Description=nullptr) = 0;
virtual unsigned __int64 GetKeyID(unsigned __int64 Root, const string& Name) = 0;
virtual bool SetKeyDescription(unsigned __int64 Root, const string& Description) = 0;

virtual bool SetValue(unsigned __int64 Root, const string& Name, const string& Value) = 0;
virtual bool SetValue(unsigned __int64 Root, const string& Name, const wchar_t* Value) = 0;
virtual bool SetValue(unsigned __int64 Root, const string& Name, unsigned __int64 Value) = 0;
Expand All @@ -114,11 +124,21 @@ class HierarchicalConfig: public XmlConfig, virtual public transactional
typename std::enable_if<!std::is_pointer<T>::value && !std::is_integral<T>::value, bool>::type
SetValue(unsigned __int64 Root, const string& Name, const T& Value)
{
static_assert(std::is_pod<T>::value, "This template requires a POD type");
return SetValue(Root, Name, &Value, sizeof(Value));
}

virtual bool GetValue(unsigned __int64 Root, const string& Name, unsigned __int64 *Value) = 0;
virtual bool GetValue(unsigned __int64 Root, const string& Name, string &strValue) = 0;
virtual int GetValue(unsigned __int64 Root, const string& Name, void *Value, size_t Size) = 0;
template<class T>
typename std::enable_if<!std::is_pointer<T>::value && !std::is_integral<T>::value, bool>::type
GetValue(unsigned __int64 Root, const string& Name, T& Value)
{
static_assert(std::is_pod<T>::value, "This template requires a POD type");
return GetValue(Root, Name, &Value, sizeof(Value)) != 0;
}

virtual bool DeleteKeyTree(unsigned __int64 KeyID) = 0;
virtual bool DeleteValue(unsigned __int64 Root, const string& Name) = 0;
virtual bool EnumKeys(unsigned __int64 Root, DWORD Index, string &strName) = 0;
Expand Down Expand Up @@ -270,6 +290,8 @@ class HistoryConfig: public XmlConfig, virtual public transactional
HistoryConfig() {}
};

ENUM(dbcheck);

class Database: noncopyable
{
public:
Expand Down Expand Up @@ -300,7 +322,6 @@ class Database: noncopyable
HierarchicalConfigUniquePtr CreatePanelModeConfig();

private:
ENUM(dbcheck);
template<class T> HierarchicalConfigUniquePtr CreateHierarchicalConfig(dbcheck DbId, const string& dbn, const char *xmln, bool Local = false, bool plugin = false);
template<class T> std::unique_ptr<T> CreateDatabase(const char *son = nullptr);
void TryImportDatabase(XmlConfig *p, const char *son = nullptr, bool plugin=false);
Expand Down
4 changes: 2 additions & 2 deletions far/cpp.hpp
Expand Up @@ -145,7 +145,7 @@ namespace std

// already included in VC2014
#if defined _MSC_VER && _MSC_VER < 1900
#ifndef __clang__
#if !defined __clang__ && !defined __INTEL_COMPILER
#define noexcept throw()
#endif
#endif
Expand All @@ -159,7 +159,7 @@ namespace std
#endif

// already fixed in VC2013
#if defined _MSC_VER && _MSC_VER < 1800
#if defined _MSC_VER && _MSC_VER < 1800 || defined __INTEL_COMPILER
// operator :: doesn't work with decltype(T) in VC prior to 2013, this trick fixes it:
#define decltype(T) std::enable_if<true, decltype(T)>::type
#endif
2 changes: 2 additions & 0 deletions far/far.vcxproj
Expand Up @@ -476,6 +476,8 @@ cl /nologo /c /Fo"$(IntDir)%(Filename)_c++.testobj" /TP api_test.c
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
<SmallerTypeCheck Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</SmallerTypeCheck>
<SmallerTypeCheck Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</SmallerTypeCheck>
</ClCompile>
<ClCompile Include="sqlitedb.cpp" />
<ClCompile Include="stddlg.cpp" />
Expand Down
10 changes: 5 additions & 5 deletions far/filefilter.cpp
Expand Up @@ -759,7 +759,7 @@ void FileFilter::InitFilter()
}

DWORD Flags[FFFT_COUNT] = {};
cfg->GetValue(root,L"FoldersFilterFFlags", Flags, sizeof(Flags));
cfg->GetValue(root,L"FoldersFilterFFlags", Flags);

for (DWORD i=FFFT_FIRST; i < FFFT_COUNT; i++)
FoldersFilter->SetFlags((enumFileFilterFlagsType)i, Flags[i]);
Expand All @@ -785,8 +785,8 @@ void FileFilter::InitFilter()
NewItem.SetMask(UseMask != 0, strMask);

FILETIME DateAfter = {}, DateBefore = {};
cfg->GetValue(key,L"DateAfter", &DateAfter, sizeof(DateAfter));
cfg->GetValue(key,L"DateBefore", &DateBefore, sizeof(DateBefore));
cfg->GetValue(key,L"DateAfter", DateAfter);
cfg->GetValue(key,L"DateBefore", DateBefore);

unsigned __int64 UseDate = 0;
cfg->GetValue(key,L"UseDate",&UseDate);
Expand Down Expand Up @@ -821,7 +821,7 @@ void FileFilter::InitFilter()
NewItem.SetAttr(UseAttr != 0, (DWORD)AttrSet, (DWORD)AttrClear);

DWORD Flags[FFFT_COUNT] = {};
cfg->GetValue(key,L"FFlags", Flags, sizeof(Flags));
cfg->GetValue(key,L"FFlags", Flags);

for (DWORD i=FFFT_FIRST; i < FFFT_COUNT; i++)
NewItem.SetFlags((enumFileFilterFlagsType)i, Flags[i]);
Expand All @@ -842,7 +842,7 @@ void FileFilter::InitFilter()
//Àâòî ôèëüòðû îíè òîëüêî äëÿ ôàéëîâ, ïàïêè íå äîëæíû ê íèì ïîäõîäèòü
NewItem.SetAttr(1, 0, FILE_ATTRIBUTE_DIRECTORY);
DWORD Flags[FFFT_COUNT] = {};
cfg->GetValue(key,L"FFlags", Flags, sizeof(Flags));
cfg->GetValue(key,L"FFlags", Flags);

for (DWORD i=FFFT_FIRST; i < FFFT_COUNT; i++)
NewItem.SetFlags((enumFileFilterFlagsType)i, Flags[i]);
Expand Down
20 changes: 10 additions & 10 deletions far/hilight.cpp
Expand Up @@ -219,9 +219,9 @@ static void LoadFilter(HierarchicalConfig *cfg, unsigned __int64 key, FileFilter
}

FILETIME DateAfter = {};
cfg->GetValue(key,HLS.DateAfter, &DateAfter, sizeof(DateAfter));
cfg->GetValue(key,HLS.DateAfter, DateAfter);
FILETIME DateBefore = {};
cfg->GetValue(key,HLS.DateBefore, &DateBefore, sizeof(DateBefore));
cfg->GetValue(key,HLS.DateBefore, DateBefore);
unsigned __int64 UseDate = 0;
cfg->GetValue(key,HLS.UseDate,&UseDate);
unsigned __int64 DateType = 0;
Expand Down Expand Up @@ -270,14 +270,14 @@ static void LoadFilter(HierarchicalConfig *cfg, unsigned __int64 key, FileFilter
HData.SetSortGroup(SortGroup);

HighlightFiles::highlight_item Colors = {};
cfg->GetValue(key,HLS.NormalColor, &Colors.Color[HighlightFiles::NORMAL_COLOR].FileColor, sizeof(FarColor));
cfg->GetValue(key,HLS.SelectedColor, &Colors.Color[HighlightFiles::SELECTED_COLOR].FileColor, sizeof(FarColor));
cfg->GetValue(key,HLS.CursorColor, &Colors.Color[HighlightFiles::UNDERCURSOR_COLOR].FileColor, sizeof(FarColor));
cfg->GetValue(key,HLS.SelectedCursorColor, &Colors.Color[HighlightFiles::SELECTEDUNDERCURSOR_COLOR].FileColor, sizeof(FarColor));
cfg->GetValue(key,HLS.MarkCharNormalColor, &Colors.Color[HighlightFiles::NORMAL_COLOR].MarkColor, sizeof(FarColor));
cfg->GetValue(key,HLS.MarkCharSelectedColor, &Colors.Color[HighlightFiles::SELECTED_COLOR].MarkColor, sizeof(FarColor));
cfg->GetValue(key,HLS.MarkCharCursorColor, &Colors.Color[HighlightFiles::UNDERCURSOR_COLOR].MarkColor, sizeof(FarColor));
cfg->GetValue(key,HLS.MarkCharSelectedCursorColor, &Colors.Color[HighlightFiles::SELECTEDUNDERCURSOR_COLOR].MarkColor, sizeof(FarColor));
cfg->GetValue(key,HLS.NormalColor, Colors.Color[HighlightFiles::NORMAL_COLOR].FileColor);
cfg->GetValue(key,HLS.SelectedColor, Colors.Color[HighlightFiles::SELECTED_COLOR].FileColor);
cfg->GetValue(key,HLS.CursorColor, Colors.Color[HighlightFiles::UNDERCURSOR_COLOR].FileColor);
cfg->GetValue(key,HLS.SelectedCursorColor, Colors.Color[HighlightFiles::SELECTEDUNDERCURSOR_COLOR].FileColor);
cfg->GetValue(key,HLS.MarkCharNormalColor, Colors.Color[HighlightFiles::NORMAL_COLOR].MarkColor);
cfg->GetValue(key,HLS.MarkCharSelectedColor, Colors.Color[HighlightFiles::SELECTED_COLOR].MarkColor);
cfg->GetValue(key,HLS.MarkCharCursorColor, Colors.Color[HighlightFiles::UNDERCURSOR_COLOR].MarkColor);
cfg->GetValue(key,HLS.MarkCharSelectedCursorColor, Colors.Color[HighlightFiles::SELECTEDUNDERCURSOR_COLOR].MarkColor);

unsigned __int64 MarkChar;
if (cfg->GetValue(key,HLS.MarkChar,&MarkChar))
Expand Down
1 change: 0 additions & 1 deletion far/sqlite.c
Expand Up @@ -34,7 +34,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma warning(push, 1)
#pragma warning(disable:4701)
#pragma runtime_checks("c", off)
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstrict-overflow"
Expand Down
6 changes: 3 additions & 3 deletions far/syslog.cpp
Expand Up @@ -651,7 +651,7 @@ void ManagerClass_Dump(const wchar_t *Title,FILE *fp)
if (i)
{
i->GetTypeAndName(Type,Name);
fwprintf(fp,L"\twindow: %p Type='%s' Name='%s'\n", i, Type.data(), Name.data());
fwprintf(fp,L"\twindow: %p Type='%s' Name='%s'\n", i.get(), Type.data(), Name.data());
}
else
fwprintf(fp,L"\twindow nullptr\n");
Expand All @@ -664,7 +664,7 @@ void ManagerClass_Dump(const wchar_t *Title,FILE *fp)
if (i)
{
i->GetTypeAndName(Type,Name);
fwprintf(fp,L"\tModalStack Item %p Type='%s' Name='%s'\n", i, Type.data(), Name.data());
fwprintf(fp,L"\tModalStack Item %p Type='%s' Name='%s'\n", i.get(), Type.data(), Name.data());
}
else
fwprintf(fp,L"\tModalStack Item nullptr\n");
Expand All @@ -677,7 +677,7 @@ void ManagerClass_Dump(const wchar_t *Title,FILE *fp)
else
Man->m_currentWindow->GetTypeAndName(Type,Name);

fwprintf(fp,L"\tCurrentWindow=%p (Type='%s' Name='%s')\n", Man->m_currentWindow,Type.data(), Name.data());
fwprintf(fp,L"\tCurrentWindow=%p (Type='%s' Name='%s')\n", Man->m_currentWindow.get(), Type.data(), Name.data());
fwprintf(fp,L"\n");
fflush(fp);
}
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4241)m4_dnl
m4_define(BUILD,4242)m4_dnl
14 changes: 7 additions & 7 deletions far/viewer.cpp
Expand Up @@ -2628,7 +2628,7 @@ struct Viewer::search_data
}
};

ENUM(Viewer::SEARCHER_RESULT)
ENUM(SEARCHER_RESULT)
{
Search_NotFound = 0,
Search_Continue = 1,
Expand All @@ -2645,7 +2645,7 @@ ENUM(SEARCH_WRAP_MODE)
SearchWrap_CYCLE = 2,
};

Viewer::SEARCHER_RESULT Viewer::search_hex_forward(search_data* sd)
SEARCHER_RESULT Viewer::search_hex_forward(search_data* sd)
{
char *buff = (char *)Search_buffer.data();
const char *search_str = sd->search_bytes;
Expand Down Expand Up @@ -2713,7 +2713,7 @@ Viewer::SEARCHER_RESULT Viewer::search_hex_forward(search_data* sd)
return Search_Continue;
}

Viewer::SEARCHER_RESULT Viewer::search_hex_backward(search_data* sd)
SEARCHER_RESULT Viewer::search_hex_backward(search_data* sd)
{
char *buff = (char *)Search_buffer.data();
const char *search_str = sd->search_bytes;
Expand Down Expand Up @@ -2779,7 +2779,7 @@ Viewer::SEARCHER_RESULT Viewer::search_hex_backward(search_data* sd)
return Search_Continue;
}

Viewer::SEARCHER_RESULT Viewer::search_text_forward(search_data* sd)
SEARCHER_RESULT Viewer::search_text_forward(search_data* sd)
{
int bsize = 8192, slen = sd->search_len, ww = (LastSearchWholeWords ? 1 : 0);
wchar_t prev_char = L'\0', *buff = Search_buffer.data(), *t_buff = (sd->ch_size < 0 ? buff + bsize : nullptr);
Expand Down Expand Up @@ -2862,7 +2862,7 @@ Viewer::SEARCHER_RESULT Viewer::search_text_forward(search_data* sd)
return Search_Continue;
}

Viewer::SEARCHER_RESULT Viewer::search_text_backward(search_data* sd)
SEARCHER_RESULT Viewer::search_text_backward(search_data* sd)
{
int bsize = 8192, slen = sd->search_len, ww = (LastSearchWholeWords ? 1 : 0);
wchar_t *buff = Search_buffer.data(), *t_buff = (sd->ch_size < 0 ? buff + bsize : nullptr);
Expand Down Expand Up @@ -2973,7 +2973,7 @@ int Viewer::read_line(wchar_t *buf, wchar_t *tbuf, INT64 cpos, int adjust, INT64
return llen;
}

Viewer::SEARCHER_RESULT Viewer::search_regex_forward(search_data* sd)
SEARCHER_RESULT Viewer::search_regex_forward(search_data* sd)
{
assert(sd->pRex);
assert(Search_buffer.size() >= static_cast<size_t>(2*MAX_VIEWLINEB));
Expand Down Expand Up @@ -3040,7 +3040,7 @@ Viewer::SEARCHER_RESULT Viewer::search_regex_forward(search_data* sd)
}
}

Viewer::SEARCHER_RESULT Viewer::search_regex_backward(search_data* sd)
SEARCHER_RESULT Viewer::search_regex_backward(search_data* sd)
{
assert(sd->pRex);
assert(Search_buffer.size() >= static_cast<size_t>(2*MAX_VIEWLINEB));
Expand Down
2 changes: 1 addition & 1 deletion far/viewer.hpp
Expand Up @@ -44,6 +44,7 @@ class FileViewer;
class KeyBar;
class Dialog;
class time_check;
ENUM(SEARCHER_RESULT);

class Viewer:public SimpleScreenObject
{
Expand Down Expand Up @@ -96,7 +97,6 @@ class Viewer:public SimpleScreenObject

private:
struct ViewerString;
ENUM(SEARCHER_RESULT);

virtual void DisplayObject() override;
void ShowPage(int nMode);
Expand Down

0 comments on commit 54dc1f5

Please sign in to comment.