Skip to content

Commit

Permalink
gcc build fix, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Apr 19, 2016
1 parent e0b465d commit 3a78c33
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 137 deletions.
54 changes: 27 additions & 27 deletions far/PluginA.cpp
Expand Up @@ -5242,7 +5242,7 @@ bool PluginA::GetGlobalInfo(GlobalInfo* Info)
bool PluginA::SetStartupInfo(PluginStartupInfo* Info)
{
ExecuteStruct es = {iSetStartupInfo};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
auto InfoCopy = StartupInfo;
auto FsfCopy = StandardFunctions;
Expand Down Expand Up @@ -5270,7 +5270,7 @@ bool PluginA::SetStartupInfo(PluginStartupInfo* Info)
bool PluginA::CheckMinFarVersion()
{
ExecuteStruct es = {iGetMinFarVersion};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
EXECUTE_FUNCTION(es = FUNCTION(iGetMinFarVersion)());
if (bPendingRemove)
Expand Down Expand Up @@ -5298,7 +5298,7 @@ void* PluginA::Open(OpenInfo* Info)

ExecuteStruct es = {iOpen};

if (Load() && Exports[es.id] && !Global->ProcessException)
if (Load() && has(es.id) && !Global->ProcessException)
{
std::unique_ptr<char[]> Buffer;
intptr_t Ptr;
Expand Down Expand Up @@ -5385,7 +5385,7 @@ void* PluginA::Open(OpenInfo* Info)
void* PluginA::OpenFilePlugin(const wchar_t *Name, const unsigned char *Data, size_t DataSize, int OpMode)
{
ExecuteStruct es = {iOpenFilePlugin};
if (Load() && Exports[es.id] && !Global->ProcessException)
if (Load() && has(es.id) && !Global->ProcessException)
{
std::unique_ptr<char[]> NameA(Name? UnicodeToAnsi(Name) : nullptr);
EXECUTE_FUNCTION(es = FUNCTION(iOpenFilePlugin)(NameA.get(), Data, static_cast<int>(DataSize)));
Expand All @@ -5396,7 +5396,7 @@ void* PluginA::OpenFilePlugin(const wchar_t *Name, const unsigned char *Data, si
int PluginA::SetFindList(SetFindListInfo* Info)
{
ExecuteStruct es = {iSetFindList};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
oldfar::PluginPanelItem *PanelItemA = nullptr;
ConvertPanelItemsArrayToAnsi(Info->PanelItem, PanelItemA, Info->ItemsNumber);
Expand All @@ -5409,7 +5409,7 @@ int PluginA::SetFindList(SetFindListInfo* Info)
int PluginA::ProcessEditorInput(ProcessEditorInputInfo* Info)
{
ExecuteStruct es = {iProcessEditorInput};
if (Load() && Exports[es.id] && !Global->ProcessException)
if (Load() && has(es.id) && !Global->ProcessException)
{
const INPUT_RECORD *Ptr = &Info->Rec;
INPUT_RECORD OemRecord;
Expand All @@ -5427,7 +5427,7 @@ int PluginA::ProcessEditorInput(ProcessEditorInputInfo* Info)
int PluginA::ProcessEditorEvent(ProcessEditorEventInfo* Info)
{
ExecuteStruct es = {iProcessEditorEvent};
if (Load() && Exports[es.id] && !Global->ProcessException)
if (Load() && has(es.id) && !Global->ProcessException)
{
switch(Info->Event)
{
Expand All @@ -5448,7 +5448,7 @@ int PluginA::ProcessEditorEvent(ProcessEditorEventInfo* Info)
int PluginA::ProcessViewerEvent(ProcessViewerEventInfo* Info)
{
ExecuteStruct es = {iProcessViewerEvent};
if (Load() && Exports[es.id] && !Global->ProcessException)
if (Load() && has(es.id) && !Global->ProcessException)
{
switch(Info->Event)
{
Expand All @@ -5467,7 +5467,7 @@ int PluginA::ProcessViewerEvent(ProcessViewerEventInfo* Info)
int PluginA::ProcessDialogEvent(ProcessDialogEventInfo* Info)
{
ExecuteStruct es = {iProcessDialogEvent};
if (Load() && Exports[es.id] && !Global->ProcessException)
if (Load() && has(es.id) && !Global->ProcessException)
{
EXECUTE_FUNCTION(es = FUNCTION(iProcessDialogEvent)(Info->Event, Info->Param));
}
Expand All @@ -5477,7 +5477,7 @@ int PluginA::ProcessDialogEvent(ProcessDialogEventInfo* Info)
int PluginA::GetVirtualFindData(GetVirtualFindDataInfo* Info)
{
ExecuteStruct es = {iGetVirtualFindData};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
pVFDPanelItemA = nullptr;
size_t Size = wcslen(Info->Path) + 1;
Expand All @@ -5501,7 +5501,7 @@ void PluginA::FreeVirtualFindData(FreeFindDataInfo* Info)
FreeUnicodePanelItem(Info->PanelItem, Info->ItemsNumber);

ExecuteStruct es = {iFreeVirtualFindData};
if (Exports[es.id] && !Global->ProcessException && pVFDPanelItemA)
if (has(es.id) && !Global->ProcessException && pVFDPanelItemA)
{
EXECUTE_FUNCTION(FUNCTION(iFreeVirtualFindData)(Info->hPanel, pVFDPanelItemA, static_cast<int>(Info->ItemsNumber)));
pVFDPanelItemA = nullptr;
Expand All @@ -5511,7 +5511,7 @@ void PluginA::FreeVirtualFindData(FreeFindDataInfo* Info)
int PluginA::GetFiles(GetFilesInfo* Info)
{
ExecuteStruct es = {iGetFiles, -1};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
oldfar::PluginPanelItem *PanelItemA = nullptr;
ConvertPanelItemsArrayToAnsi(Info->PanelItem, PanelItemA, Info->ItemsNumber);
Expand All @@ -5529,7 +5529,7 @@ int PluginA::GetFiles(GetFilesInfo* Info)
int PluginA::PutFiles(PutFilesInfo* Info)
{
ExecuteStruct es = {iPutFiles, -1};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
oldfar::PluginPanelItem *PanelItemA = nullptr;
ConvertPanelItemsArrayToAnsi(Info->PanelItem, PanelItemA, Info->ItemsNumber);
Expand All @@ -5542,7 +5542,7 @@ int PluginA::PutFiles(PutFilesInfo* Info)
int PluginA::DeleteFiles(DeleteFilesInfo* Info)
{
ExecuteStruct es = {iDeleteFiles};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
oldfar::PluginPanelItem *PanelItemA = nullptr;
ConvertPanelItemsArrayToAnsi(Info->PanelItem, PanelItemA, Info->ItemsNumber);
Expand All @@ -5555,7 +5555,7 @@ int PluginA::DeleteFiles(DeleteFilesInfo* Info)
int PluginA::MakeDirectory(MakeDirectoryInfo* Info)
{
ExecuteStruct es = {iMakeDirectory, -1};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
char NameA[oldfar::NM];
UnicodeToOEM(Info->Name, NameA);
Expand All @@ -5570,7 +5570,7 @@ int PluginA::MakeDirectory(MakeDirectoryInfo* Info)
int PluginA::ProcessHostFile(ProcessHostFileInfo* Info)
{
ExecuteStruct es = {iProcessHostFile};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
oldfar::PluginPanelItem *PanelItemA = nullptr;
ConvertPanelItemsArrayToAnsi(Info->PanelItem, PanelItemA, Info->ItemsNumber);
Expand All @@ -5583,7 +5583,7 @@ int PluginA::ProcessHostFile(ProcessHostFileInfo* Info)
int PluginA::ProcessPanelEvent(ProcessPanelEventInfo* Info)
{
ExecuteStruct es = {iProcessPanelEvent};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
PVOID ParamA = Info->Param;

Expand All @@ -5601,7 +5601,7 @@ int PluginA::ProcessPanelEvent(ProcessPanelEventInfo* Info)
int PluginA::Compare(CompareInfo* Info)
{
ExecuteStruct es = {iCompare, -2};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
oldfar::PluginPanelItem *Item1A = nullptr;
oldfar::PluginPanelItem *Item2A = nullptr;
Expand All @@ -5617,7 +5617,7 @@ int PluginA::Compare(CompareInfo* Info)
int PluginA::GetFindData(GetFindDataInfo* Info)
{
ExecuteStruct es = {iGetFindData};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
pFDPanelItemA = nullptr;
int ItemsNumber = 0;
Expand All @@ -5638,7 +5638,7 @@ void PluginA::FreeFindData(FreeFindDataInfo* Info)
FreeUnicodePanelItem(Info->PanelItem, Info->ItemsNumber);

ExecuteStruct es = {iFreeFindData};
if (Exports[es.id] && !Global->ProcessException && pFDPanelItemA)
if (has(es.id) && !Global->ProcessException && pFDPanelItemA)
{
EXECUTE_FUNCTION(FUNCTION(iFreeFindData)(Info->hPanel, pFDPanelItemA, static_cast<int>(Info->ItemsNumber)));
pFDPanelItemA = nullptr;
Expand All @@ -5648,7 +5648,7 @@ void PluginA::FreeFindData(FreeFindDataInfo* Info)
int PluginA::ProcessPanelInput(ProcessPanelInputInfo* Info)
{
ExecuteStruct es = {iProcessPanelInput};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
int VirtKey;
int dwControlState;
Expand All @@ -5671,7 +5671,7 @@ int PluginA::ProcessPanelInput(ProcessPanelInputInfo* Info)
void PluginA::ClosePanel(ClosePanelInfo* Info)
{
ExecuteStruct es = {iClosePanel};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
EXECUTE_FUNCTION(FUNCTION(iClosePanel)(Info->hPanel));
}
Expand All @@ -5681,7 +5681,7 @@ void PluginA::ClosePanel(ClosePanelInfo* Info)
int PluginA::SetDirectory(SetDirectoryInfo* Info)
{
ExecuteStruct es = {iSetDirectory};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
char *DirA = UnicodeToAnsi(Info->Dir);
EXECUTE_FUNCTION(es = FUNCTION(iSetDirectory)(Info->hPanel, DirA, Info->OpMode));
Expand Down Expand Up @@ -5823,7 +5823,7 @@ void PluginA::GetOpenPanelInfo(OpenPanelInfo *pInfo)
pInfo->StructSize = sizeof(OpenPanelInfo);

ExecuteStruct es = {iGetOpenPanelInfo};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
oldfar::OpenPanelInfo InfoA={};
EXECUTE_FUNCTION(FUNCTION(iGetOpenPanelInfo)(pInfo->hPanel, &InfoA));
Expand All @@ -5834,7 +5834,7 @@ void PluginA::GetOpenPanelInfo(OpenPanelInfo *pInfo)
int PluginA::Configure(ConfigureInfo* Info)
{
ExecuteStruct es = {iConfigure};
if (Load() && Exports[es.id] && !Global->ProcessException)
if (Load() && has(es.id) && !Global->ProcessException)
{
EXECUTE_FUNCTION(es = FUNCTION(iConfigure)(Info->Guid->Data1));
}
Expand Down Expand Up @@ -5920,7 +5920,7 @@ bool PluginA::GetPluginInfo(PluginInfo *pi)
ClearStruct(*pi);

ExecuteStruct es = {iGetPluginInfo};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
oldfar::PluginInfo InfoA={sizeof(InfoA)};
EXECUTE_FUNCTION(FUNCTION(iGetPluginInfo)(&InfoA));
Expand All @@ -5938,7 +5938,7 @@ bool PluginA::GetPluginInfo(PluginInfo *pi)
void PluginA::ExitFAR(ExitInfo *Info)
{
ExecuteStruct es = {iExitFAR};
if (Exports[es.id] && !Global->ProcessException)
if (has(es.id) && !Global->ProcessException)
{
// ExitInfo ignored for ansi plugins
EXECUTE_FUNCTION(FUNCTION(iExitFAR)());
Expand Down
8 changes: 7 additions & 1 deletion far/changelog
@@ -1,4 +1,10 @@
svs 19.04.2016 18:18:01 +0300 - build 4625
drkns 19.04.2016 22:42:16 +0200 - build 4626

1. gcc build fix.

2. Refactoring.

svs 19.04.2016 18:18:01 +0300 - build 4625

1. SQLite 3.12.2

Expand Down
15 changes: 10 additions & 5 deletions far/configdb.cpp
Expand Up @@ -1271,13 +1271,18 @@ class PluginsCacheConfigDb: public PluginsCacheConfig, public SQLiteDb
return GetTextFromID(Statement(stmtGetSignature), id);
}

virtual void *GetExport(unsigned __int64 id, const string& ExportName) const override
virtual bool GetExportState(unsigned __int64 id, const wchar_t* ExportName) const override
{
if (!*ExportName)
{
return false;
}

auto& Stmt = Statement(stmtGetExportState);
void *enabled = nullptr;
bool enabled = false;
if (Stmt.Bind(id, ExportName).Step())
if (Stmt.GetColInt(0))
enabled = ToPtr(1);
enabled = true;
Stmt.Reset();
return enabled;
}
Expand Down Expand Up @@ -1397,9 +1402,9 @@ class PluginsCacheConfigDb: public PluginsCacheConfig, public SQLiteDb
return Statement(stmtSetFlags).Bind(id, Flags).StepAndReset();
}

virtual bool SetExport(unsigned __int64 id, const string& ExportName, bool Exists) override
virtual bool SetExportState(unsigned __int64 id, const wchar_t* ExportName, bool Exists) override
{
return Statement(stmtSetExportState).Bind(id, ExportName, Exists).StepAndReset();
return *ExportName && Statement(stmtSetExportState).Bind(id, ExportName, Exists).StepAndReset();
}

virtual bool SetMinFarVersion(unsigned __int64 id, const VersionInfo *Version) override
Expand Down
4 changes: 2 additions & 2 deletions far/configdb.hpp
Expand Up @@ -209,7 +209,7 @@ class PluginsCacheConfig: public representable, virtual public transactional
virtual bool DeleteCache(const string& CacheName) = 0;
virtual bool IsPreload(unsigned __int64 id) const = 0;
virtual string GetSignature(unsigned __int64 id) const = 0;
virtual void *GetExport(unsigned __int64 id, const string& ExportName) const = 0;
virtual bool GetExportState(unsigned __int64 id, const wchar_t* ExportName) const = 0;
virtual string GetGuid(unsigned __int64 id) const = 0;
virtual string GetTitle(unsigned __int64 id) const = 0;
virtual string GetAuthor(unsigned __int64 id) const = 0;
Expand All @@ -228,7 +228,7 @@ class PluginsCacheConfig: public representable, virtual public transactional
virtual bool SetPluginsConfigMenuItem(unsigned __int64 id, size_t index, const string& Text, const GUID& Guid) = 0;
virtual bool SetCommandPrefix(unsigned __int64 id, const string& Prefix) = 0;
virtual bool SetFlags(unsigned __int64 id, unsigned __int64 Flags) = 0;
virtual bool SetExport(unsigned __int64 id, const string& ExportName, bool Exists) = 0;
virtual bool SetExportState(unsigned __int64 id, const wchar_t* ExportName, bool Exists) = 0;
virtual bool SetMinFarVersion(unsigned __int64 id, const VersionInfo *Version) = 0;
virtual bool SetVersion(unsigned __int64 id, const VersionInfo *Version) = 0;
virtual bool SetGuid(unsigned __int64 id, const string& Guid) = 0;
Expand Down
2 changes: 1 addition & 1 deletion far/diskmenu.cpp
Expand Up @@ -1069,7 +1069,7 @@ static int ChangeDiskMenu(panel_ptr Owner, int Pos, bool FirstCall)
break;
case KEY_SHIFTF9:

if (item && item->bIsPlugin && item->pPlugin->has<iConfigure>())
if (item && item->bIsPlugin && item->pPlugin->has(iConfigure))
Global->CtrlObject->Plugins->ConfigureCurrent(item->pPlugin, item->Guid);

RetCode = SelPos;
Expand Down
2 changes: 1 addition & 1 deletion far/filelist.cpp
Expand Up @@ -813,7 +813,7 @@ void FileList::SortFileList(int KeepPosition)
strCurName = m_ListData[m_CurFile].strName;
}

hSortPlugin = (m_PanelMode == panel_mode::PLUGIN_PANEL && m_hPlugin && m_hPlugin->pPlugin->has<iCompare>())? m_hPlugin : nullptr;
hSortPlugin = (m_PanelMode == panel_mode::PLUGIN_PANEL && m_hPlugin && m_hPlugin->pPlugin->has(iCompare))? m_hPlugin : nullptr;

// ЭТО ЕСТЬ УЗКОЕ МЕСТО ДЛЯ СКОРОСТНЫХ ХАРАКТЕРИСТИК Far Manager
// при считывании директории
Expand Down
2 changes: 1 addition & 1 deletion far/findfile.cpp
Expand Up @@ -2730,7 +2730,7 @@ bool FindFiles::FindFilesProcess()

AnySetFindList = std::any_of(CONST_RANGE(*Global->CtrlObject->Plugins, i)
{
return i->has<iSetFindList>();
return i->has(iSetFindList);
});

if (!AnySetFindList)
Expand Down
2 changes: 1 addition & 1 deletion far/panel.cpp
Expand Up @@ -1365,7 +1365,7 @@ bool Panel::ExecShortcutFolder(string& strShortcutFolder, const GUID& PluginGuid

if (const auto pPlugin = Global->CtrlObject->Plugins->FindPlugin(PluginGuid))
{
if (pPlugin->has<iOpen>())
if (pPlugin->has(iOpen))
{
if (!strPluginFile.empty())
{
Expand Down

0 comments on commit 3a78c33

Please sign in to comment.