Skip to content
Permalink
Browse files

more info in manually thrown exceptions, fixed exception handling in …

…gcc, refactoring
  • Loading branch information...
alabuzhev committed May 12, 2016
1 parent 9df0dfb commit d1a526b6ae83d1a1ecd252972c81d67fcb3b8d6a
Showing with 327 additions and 305 deletions.
  1. +1 −1 far/PluginA.cpp
  2. +2 −2 far/TPreRedrawFunc.hpp
  3. +9 −1 far/changelog
  4. +36 −36 far/clipboard.cpp
  5. +7 −9 far/clipboard.hpp
  6. +2 −1 far/common.hpp
  7. +3 −3 far/common/any.hpp
  8. +3 −3 far/common/enum_substrings.hpp
  9. +5 −5 far/common/enumerator.hpp
  10. +66 −0 far/common/exception.hpp
  11. +1 −1 far/common/scope_exit.hpp
  12. +3 −3 far/common/smart_ptr.hpp
  13. +2 −2 far/config.cpp
  14. +6 −14 far/config.hpp
  15. +6 −6 far/configdb.cpp
  16. +15 −15 far/configdb.hpp
  17. +1 −1 far/console.cpp
  18. +2 −2 far/console.hpp
  19. +1 −0 far/copy.cpp
  20. +2 −2 far/copy_progress.cpp
  21. +4 −14 far/dialog.cpp
  22. +1 −1 far/dialog.hpp
  23. +1 −0 far/disabled_warnings.hpp
  24. +1 −3 far/edit.hpp
  25. +1 −1 far/editor.cpp
  26. +1 −1 far/editor.hpp
  27. +18 −17 far/elevation.cpp
  28. +1 −0 far/far.vcxproj
  29. +3 −0 far/far.vcxproj.filters
  30. +12 −6 far/farexcpt.cpp
  31. +0 −12 far/farexcpt.hpp
  32. +2 −2 far/farrtl.cpp
  33. +8 −15 far/farwinapi.cpp
  34. +27 −22 far/farwinapi.hpp
  35. +1 −1 far/format.hpp
  36. +1 −0 far/headers.hpp
  37. +1 −1 far/keybar.hpp
  38. +2 −2 far/language.cpp
  39. +1 −1 far/menubar.hpp
  40. +0 −5 far/modal.cpp
  41. +5 −5 far/modal.hpp
  42. +1 −1 far/notification.hpp
  43. +1 −1 far/plclass.hpp
  44. +1 −2 far/plugsettings.hpp
  45. +2 −2 far/sqlitedb.cpp
  46. +3 −3 far/strmix.cpp
  47. +4 −18 far/synchro.hpp
  48. +1 −0 far/tracer.hpp
  49. +1 −2 far/transactional.hpp
  50. +40 −52 far/usermenu.cpp
  51. +3 −2 far/usermenu.hpp
  52. +1 −1 far/vbuild.m4
  53. +3 −3 far/viewer.cpp
  54. +1 −1 far/viewer.hpp
  55. +1 −1 far/vmenu.cpp
@@ -112,7 +112,7 @@ class oem_plugin_factory: public native_plugin_factory
oem_plugin_factory(PluginManager* Owner):
native_plugin_factory(Owner)
{
static const plugin_factory::export_name ExportsNames[] =
static const export_name ExportsNames[] =
{
WA(""), // GetGlobalInfo not used
WA("SetStartupInfo"),
@@ -41,7 +41,7 @@ struct PreRedrawItem: noncopyable
typedef std::function<void()> handler_type;

PreRedrawItem(const handler_type& PreRedrawFunc) : m_PreRedrawFunc(PreRedrawFunc) {}
virtual ~PreRedrawItem(){}
virtual ~PreRedrawItem() = default;

handler_type m_PreRedrawFunc;
};
@@ -57,7 +57,7 @@ class TPreRedrawFunc: noncopyable
private:
friend TPreRedrawFunc& PreRedrawStack();

TPreRedrawFunc() {}
TPreRedrawFunc() = default;
std::stack<std::unique_ptr<PreRedrawItem>> Items;
};

@@ -1,4 +1,12 @@
drkns 11.05.2016 23:59:21 +0200 - build 4670
drkns 13.05.2016 00:33:18 +0200 - build 4671

1. Уточнение обработки исключений для gcc.

2. Дополнительная информация в исключениях, брошенных вручную (function, file, line).

3. Рефакторинг.

drkns 11.05.2016 23:59:21 +0200 - build 4670

1. Уточнение обработки DM_GETDIALOGINFО.

@@ -51,16 +51,16 @@ default_clipboard_mode::mode default_clipboard_mode::get()
}

//-----------------------------------------------------------------------------
enum FAR_CLIPBOARD_FORMAT: int
enum class Clipboard::clipboard_format: unsigned
{
FCF_VERTICALBLOCK_OEM,
FCF_VERTICALBLOCK_UNICODE,
FCF_CFSTR_PREFERREDDROPEFFECT,
FCF_MSDEVCOLUMNSELECT,
FCF_BORLANDIDEVBLOCK,
FCF_NOTEPADPLUSPLUS_BINARYTEXTLENGTH,

FCF_COUNT
vertical_block_oem,
vertical_block_unicode,
preferred_drop_effect,
ms_dev_column_select,
borland_ide_dev_block,
notepad_plusplus_binary_text_length,

count
};

//-----------------------------------------------------------------------------
@@ -75,7 +75,7 @@ class system_clipboard: noncopyable, public Clipboard

virtual ~system_clipboard()
{
Close();
system_clipboard::Close();
}

virtual bool Open() override
@@ -113,16 +113,16 @@ class system_clipboard: noncopyable, public Clipboard
}

private:
system_clipboard() {}
system_clipboard() = default;

virtual HANDLE GetData(UINT uFormat) const override
virtual HANDLE GetData(unsigned uFormat) const override
{
assert(m_Opened);

return GetClipboardData(uFormat);
}

virtual bool SetData(UINT uFormat, os::memory::global::ptr&& hMem) override
virtual bool SetData(unsigned uFormat, os::memory::global::ptr&& hMem) override
{
assert(m_Opened);

@@ -142,7 +142,7 @@ class system_clipboard: noncopyable, public Clipboard
return false;
}

virtual UINT RegisterFormat(FAR_CLIPBOARD_FORMAT Format) const override
virtual unsigned RegisterFormat(clipboard_format Format) const override
{
static const wchar_t* FormatNames[] =
{
@@ -154,12 +154,12 @@ class system_clipboard: noncopyable, public Clipboard
L"Notepad++ binary text length",
};

static_assert(std::size(FormatNames) == FCF_COUNT, "Wrong size of FormatNames");
assert(Format < FCF_COUNT);
return RegisterClipboardFormat(FormatNames[Format]);
static_assert(std::size(FormatNames) == static_cast<unsigned>(clipboard_format::count), "Wrong size of FormatNames");
assert(Format < clipboard_format::count);
return RegisterClipboardFormat(FormatNames[static_cast<unsigned>(Format)]);
}

virtual bool IsFormatAvailable(UINT Format) const override
virtual bool IsFormatAvailable(unsigned Format) const override
{
return IsClipboardFormatAvailable(Format) != FALSE;
}
@@ -177,7 +177,7 @@ class internal_clipboard: noncopyable, public Clipboard

virtual ~internal_clipboard()
{
Close();
internal_clipboard::Close();
}

virtual bool Open() override
@@ -212,9 +212,9 @@ class internal_clipboard: noncopyable, public Clipboard
}

private:
internal_clipboard() {}
internal_clipboard() = default;

virtual HANDLE GetData(UINT uFormat) const override
virtual HANDLE GetData(unsigned uFormat) const override
{
assert(m_Opened);

@@ -227,7 +227,7 @@ class internal_clipboard: noncopyable, public Clipboard
return nullptr;
}

virtual bool SetData(UINT uFormat, os::memory::global::ptr&& hMem) override
virtual bool SetData(unsigned uFormat, os::memory::global::ptr&& hMem) override
{
assert(m_Opened);

@@ -239,17 +239,17 @@ class internal_clipboard: noncopyable, public Clipboard
return false;
}

virtual UINT RegisterFormat(FAR_CLIPBOARD_FORMAT Format) const override
virtual unsigned RegisterFormat(clipboard_format Format) const override
{
return Format + 0xFC; // magic number stands for "Far Clipboard"
return static_cast<unsigned>(Format) + 0xFC; // magic number stands for "Far Clipboard"
}

virtual bool IsFormatAvailable(UINT Format) const override
virtual bool IsFormatAvailable(unsigned Format) const override
{
return Format && m_InternalData.count(Format);
}

std::unordered_map<UINT, os::memory::global::ptr> m_InternalData;
std::unordered_map<unsigned, os::memory::global::ptr> m_InternalData;
};

//-----------------------------------------------------------------------------
@@ -270,7 +270,7 @@ bool Clipboard::SetText(const wchar_t *Data, size_t Size)
{
// 'Notepad++ binary text length'
auto binary_length = static_cast<uint32_t>(Size);
SetData(RegisterFormat(FCF_NOTEPADPLUSPLUS_BINARYTEXTLENGTH), os::memory::global::copy(binary_length));
SetData(RegisterFormat(clipboard_format::notepad_plusplus_binary_text_length), os::memory::global::copy(binary_length));
}
}
else
@@ -287,7 +287,7 @@ bool Clipboard::SetVText(const wchar_t *Data, size_t Size)

if (Result && Data)
{
const auto FarVerticalBlock = RegisterFormat(FCF_VERTICALBLOCK_UNICODE);
const auto FarVerticalBlock = RegisterFormat(clipboard_format::vertical_block_unicode);

if (!FarVerticalBlock)
return false;
@@ -296,9 +296,9 @@ bool Clipboard::SetVText(const wchar_t *Data, size_t Size)

// 'Borland IDE Block Type'
char Cx02 = '\x02';
SetData(RegisterFormat(FCF_BORLANDIDEVBLOCK), os::memory::global::copy(Cx02));
SetData(RegisterFormat(clipboard_format::borland_ide_dev_block), os::memory::global::copy(Cx02));
// 'MSDEVColumnSelect'
SetData(RegisterFormat(FCF_MSDEVCOLUMNSELECT), nullptr);
SetData(RegisterFormat(clipboard_format::ms_dev_column_select), nullptr);
}
return Result;
}
@@ -326,7 +326,7 @@ bool Clipboard::SetHDROP(const string& NamesData, bool bMoved)
{
if (auto hMemoryMove = os::memory::global::copy<DWORD>(DROPEFFECT_MOVE))
{
if(SetData(RegisterFormat(FCF_CFSTR_PREFERREDDROPEFFECT), std::move(hMemoryMove)))
if(SetData(RegisterFormat(clipboard_format::preferred_drop_effect), std::move(hMemoryMove)))
{
Result = true;
}
@@ -352,7 +352,7 @@ bool Clipboard::GetText(string& data) const
Result = true;
data = ClipAddr.get();
size_t len = string::npos;
if (auto hClipDataLen = GetData(RegisterFormat(FCF_NOTEPADPLUSPLUS_BINARYTEXTLENGTH)))
if (auto hClipDataLen = GetData(RegisterFormat(clipboard_format::notepad_plusplus_binary_text_length)))
{
if (const auto ClipLength = os::memory::global::lock<const uint32_t*>(hClipDataLen))
len = static_cast<size_t>(ClipLength.get()[0]);
@@ -405,16 +405,16 @@ bool Clipboard::GetVText(string& data) const
{
bool Result = false;

bool ColumnSelect = IsFormatAvailable(RegisterFormat(FCF_VERTICALBLOCK_UNICODE));
bool ColumnSelect = IsFormatAvailable(RegisterFormat(clipboard_format::vertical_block_unicode));

if (!ColumnSelect)
{
ColumnSelect = IsFormatAvailable(RegisterFormat(FCF_MSDEVCOLUMNSELECT));
ColumnSelect = IsFormatAvailable(RegisterFormat(clipboard_format::ms_dev_column_select));
}

if (!ColumnSelect)
{
if (const auto hClipData = GetData(RegisterFormat(FCF_BORLANDIDEVBLOCK)))
if (const auto hClipData = GetData(RegisterFormat(clipboard_format::borland_ide_dev_block)))
if (const auto ClipAddr = os::memory::global::lock<const char*>(hClipData))
ColumnSelect = *ClipAddr == 0x02;
}
@@ -425,7 +425,7 @@ bool Clipboard::GetVText(string& data) const
}
else
{
const auto Far1xVerticalBlock = RegisterFormat(FCF_VERTICALBLOCK_OEM);
const auto Far1xVerticalBlock = RegisterFormat(clipboard_format::vertical_block_oem);
if (const auto hClipData = GetData(Far1xVerticalBlock))
{
if (const auto OemData = os::memory::global::lock<const char*>(hClipData))
@@ -46,13 +46,11 @@ class default_clipboard_mode
static mode m_Mode;
};

enum FAR_CLIPBOARD_FORMAT: int;

class Clipboard
{
public:
static Clipboard& GetInstance(default_clipboard_mode::mode Mode);
virtual ~Clipboard() {}
virtual ~Clipboard() = default;

virtual bool Open() = 0;
virtual bool Close() = 0;
@@ -72,15 +70,15 @@ class Clipboard
bool GetVText(string& data) const;

protected:
Clipboard(): m_Opened() {}
enum class clipboard_format: unsigned;

bool m_Opened;
bool m_Opened {};

private:
virtual bool SetData(UINT uFormat, os::memory::global::ptr&& hMem) = 0;
virtual HANDLE GetData(UINT uFormat) const = 0;
virtual UINT RegisterFormat(FAR_CLIPBOARD_FORMAT Format) const = 0;
virtual bool IsFormatAvailable(UINT Format) const = 0;
virtual bool SetData(unsigned uFormat, os::memory::global::ptr&& hMem) = 0;
virtual HANDLE GetData(unsigned uFormat) const = 0;
virtual unsigned RegisterFormat(clipboard_format Format) const = 0;
virtual bool IsFormatAvailable(unsigned Format) const = 0;

bool GetHDROPAsText(string& data) const;
};
@@ -39,6 +39,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "common/compiler.hpp"
#include "common/preprocessor.hpp"
#include "common/exception.hpp"
#include "common/noncopyable.hpp"
#include "common/swapable.hpp"
#include "common/rel_ops.hpp"
@@ -199,7 +200,7 @@ class writable_blob: public blob
if (m_Data)
{
if (size() != rhs.size())
throw std::runtime_error("incorrect blob size");
throw MAKE_FAR_EXCEPTION("incorrect blob size");
}
else
{
@@ -37,7 +37,7 @@ namespace detail
class any_base
{
public:
virtual ~any_base() {}
virtual ~any_base() = default;
virtual std::unique_ptr<any_base> clone() const = 0;
};

@@ -82,7 +82,7 @@ class any

any& operator=(const any& rhs)
{
any Tmp(rhs);
auto Tmp(rhs);
using std::swap;
swap(*this, Tmp);
return *this;
@@ -137,7 +137,7 @@ T& any_cast(any& Any)
const auto Result = any_cast<T>(&Any);
if (!Result)
{
throw std::bad_cast();
throw MAKE_FAR_EXCEPTION("bad any_cast");
}
return *Result;
}
@@ -60,15 +60,15 @@ class enum_substrings_t: public enumerator<enum_substrings_t<provider>, range<de
NONCOPYABLE(enum_substrings_t);
TRIVIALLY_MOVABLE(enum_substrings_t);

enum_substrings_t(const provider& Provider): m_Provider(&Provider), m_Offset() {}
explicit enum_substrings_t(const provider& Provider): m_Provider(&Provider), m_Offset() {}

bool get(size_t Index, typename enum_substrings_t<provider>::value_type& Value)
{
const auto Begin = detail::Begin(*m_Provider) + (Index? m_Offset : 0);
auto End = Begin;
bool IsEnd;
for (; (IsEnd = detail::IsEnd(*m_Provider, End)) == false && *End; ++End);

for (; (IsEnd = detail::IsEnd(*m_Provider, End)) == false && *End; ++End)
;
if (End != Begin)
{
const auto Ptr = &*Begin;
@@ -41,9 +41,10 @@ class enumerator
class const_iterator: public std::iterator<std::forward_iterator_tag, T>
{
public:
typedef const T value_type;
using value_type = const T;

const_iterator(Derived* collection = nullptr, size_t index = -1): m_collection(collection), m_index(index), m_value() {}
const_iterator(Derived* collection, size_t index): m_collection(collection), m_index(index), m_value() {}
const_iterator(): const_iterator(nullptr, -1) {}
const_iterator(const const_iterator& rhs): m_collection(rhs.m_collection), m_index(rhs.m_index), m_value(rhs.m_value) {}
const_iterator& operator =(const const_iterator& rhs) { m_collection = rhs.m_collection; m_index = rhs.m_index; m_value = rhs.m_value; return *this;}
value_type* operator ->() const { return &m_value; }
@@ -63,10 +64,9 @@ class enumerator
class iterator: public const_iterator
{
public:
typedef T value_type;
using value_type = T;
using const_iterator::const_iterator;

iterator(Derived* collection = nullptr, size_t index = -1): const_iterator(collection, index) {}
iterator(const iterator& rhs): const_iterator(rhs) {}
value_type* operator ->() { return const_cast<T*>(const_iterator::operator->()); }
value_type& operator *() { return const_cast<T&>(const_iterator::operator*()); }
iterator& operator ++() { const_iterator::operator++(); return *this; }
Oops, something went wrong.

0 comments on commit d1a526b

Please sign in to comment.
You can’t perform that action at this time.