code format

This commit is contained in:
2022-12-14 14:13:52 +03:00
parent 430a41fefc
commit c2b8a8d6da
297 changed files with 27331 additions and 24162 deletions

View File

@@ -5,22 +5,22 @@
* \~russian Управление плагинами
*/
/*
PIP - Platform Independent Primitives
Plugin helpers
Ivan Pelipenko peri4ko@yandex.ru
PIP - Platform Independent Primitives
Plugin helpers
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PIPLUGIN_H
@@ -28,26 +28,26 @@
#ifndef MICRO_PIP
#include "pilibrary.h"
#include "pistringlist.h"
# include "pilibrary.h"
# include "pistringlist.h"
#ifdef DOXYGEN
# ifdef DOXYGEN
//! \~english Declare plugin, should be used before other PIP_PLUGIN_* macros
//! \~russian Объявляет плагин, должен быть использован перед любыми другими PIP_PLUGIN_* макросами
//! \~\relatesalso PIPluginLoader
#define PIP_PLUGIN
# define PIP_PLUGIN
//! \~english Set user version to check it while loading, "version" is quoted string
//! \~russian Устанавливает пользовательскую версию для проверки во время загрузки, "version" - строка в кавычках
//! \~\relatesalso PIPluginLoader
#define PIP_PLUGIN_SET_USER_VERSION(version)
# define PIP_PLUGIN_SET_USER_VERSION(version)
//! \~english Add pointer to future merge with plugin. Type is integer
//! \~russian Добавляет указатель для будущего слияния. Тип - целое число
//! \~\relatesalso PIPluginLoader
#define PIP_PLUGIN_ADD_STATIC_SECTION(type, ptr)
# define PIP_PLUGIN_ADD_STATIC_SECTION(type, ptr)
//! \~english Declare function to merge static sections
//! \~russian Объявляет метод для слияния статических секций
@@ -67,53 +67,54 @@
//! "to" - областью плагина. Таким образом, этот макрос позволяет провести
//! слияние статических данных приложения и плагина.
//! \~\relatesalso PIPluginLoader
#define PIP_PLUGIN_STATIC_SECTION_MERGE
# define PIP_PLUGIN_STATIC_SECTION_MERGE
//! \~english Mark method to export
//! \~russian Пометить метод на экспорт
//! \~\relatesalso PIPluginLoader
#define PIP_PLUGIN_EXPORT
# define PIP_PLUGIN_EXPORT
#else
# else
#ifdef WINDOWS
# define PIP_PLUGIN_EXPORT __declspec(dllexport)
#else
# define PIP_PLUGIN_EXPORT
#endif
# ifdef WINDOWS
# define PIP_PLUGIN_EXPORT __declspec(dllexport)
# else
# define PIP_PLUGIN_EXPORT
# endif
#define __PIP_PLUGIN_LOADER_VERSION_FUNC__ pip_loader_version
#define __PIP_PLUGIN_STATIC_MERGE_FUNC__ pip_merge_static
#define __PIP_PLUGIN_LOADER_VERSION__ 2
# define __PIP_PLUGIN_LOADER_VERSION_FUNC__ pip_loader_version
# define __PIP_PLUGIN_STATIC_MERGE_FUNC__ pip_merge_static
# define __PIP_PLUGIN_LOADER_VERSION__ 2
#define PIP_PLUGIN_SET_USER_VERSION(v) \
STATIC_INITIALIZER_BEGIN \
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
if (pi) pi->setUserVersion(v); \
STATIC_INITIALIZER_END
# define PIP_PLUGIN_SET_USER_VERSION(v) \
STATIC_INITIALIZER_BEGIN \
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
if (pi) pi->setUserVersion(v); \
STATIC_INITIALIZER_END
#define PIP_PLUGIN_ADD_STATIC_SECTION(type, ptr) \
STATIC_INITIALIZER_BEGIN \
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
if (pi) pi->setStaticSection(type, ptr); \
STATIC_INITIALIZER_END
# define PIP_PLUGIN_ADD_STATIC_SECTION(type, ptr) \
STATIC_INITIALIZER_BEGIN \
PIPluginInfo * pi = PIPluginInfoStorage::instance()->currentInfo(); \
if (pi) pi->setStaticSection(type, ptr); \
STATIC_INITIALIZER_END
#define PIP_PLUGIN \
extern "C" { \
PIP_PLUGIN_EXPORT int __PIP_PLUGIN_LOADER_VERSION_FUNC__() {return __PIP_PLUGIN_LOADER_VERSION__;} \
}
# define PIP_PLUGIN \
extern "C" { \
PIP_PLUGIN_EXPORT int __PIP_PLUGIN_LOADER_VERSION_FUNC__() { \
return __PIP_PLUGIN_LOADER_VERSION__; \
} \
}
#define PIP_PLUGIN_STATIC_SECTION_MERGE \
extern "C" { \
# define PIP_PLUGIN_STATIC_SECTION_MERGE \
extern "C" { \
PIP_PLUGIN_EXPORT void __PIP_PLUGIN_STATIC_MERGE_FUNC__(int type, void * from, void * to); \
} \
void __PIP_PLUGIN_STATIC_MERGE_FUNC__(int type, void * from, void * to)
} \
void __PIP_PLUGIN_STATIC_MERGE_FUNC__(int type, void * from, void * to)
#endif
# endif
class PIP_EXPORT PIPluginInfo {
@@ -123,16 +124,14 @@ public:
void setUserVersion(const PIString & v);
void setStaticSection(int type, void * ptr);
PIString userVersion() const;
PIMap<int, void*> staticSections() const;
PIMap<int, void *> staticSections() const;
private:
PIString user_version;
PIMap<int, void*> static_sections;
PIMap<int, void *> static_sections;
};
class PIP_EXPORT PIPluginInfoStorage {
public:
PIPluginInfoStorage();
@@ -149,32 +148,29 @@ private:
NO_COPY_CLASS(PIPluginInfoStorage);
void * current;
PIMap<void*, PIPluginInfo * > info;
PIMap<void *, PIPluginInfo *> info;
};
//! \ingroup System
//! \~\brief
//! \~english Plugin loader.
//! \~russian Загрузчик плагина.
class PIP_EXPORT PIPluginLoader {
public:
typedef int(*FunctionLoaderVersion)();
typedef void(*FunctionStaticMerge)(int, void *, void *);
typedef int (*FunctionLoaderVersion)();
typedef void (*FunctionStaticMerge)(int, void *, void *);
//! \~english Possible load plugin error
//! \~russian Возможные ошибки загрузки плагина
enum Error {
Unknown /** \~english No \a load() call yet \~russian Не было вызова \a load() */ ,
NoError /** \~english No error \~russian Нет ошибки */ ,
NoSuchFile /** \~english Can`t find library file \~russian Не найден файл библиотеки */ ,
LibraryLoadError /** \~english System can`t load library \~russian Система не смогла загрузить библиотеку */ ,
MissingSymbols /** \~english Can`t find necessary symbols \~russian Нет необходимых методов */ ,
InvalidLoaderVersion /** \~english Internal version mismatch \~russian Неверная внутренняя версия */ ,
InvalidUserVersion /** \~english User version mismatch \~russian Неверная пользовательская версия */ ,
Unknown /** \~english No \a load() call yet \~russian Не было вызова \a load() */,
NoError /** \~english No error \~russian Нет ошибки */,
NoSuchFile /** \~english Can`t find library file \~russian Не найден файл библиотеки */,
LibraryLoadError /** \~english System can`t load library \~russian Система не смогла загрузить библиотеку */,
MissingSymbols /** \~english Can`t find necessary symbols \~russian Нет необходимых методов */,
InvalidLoaderVersion /** \~english Internal version mismatch \~russian Неверная внутренняя версия */,
InvalidUserVersion /** \~english User version mismatch \~russian Неверная пользовательская версия */,
};
//! \~english Contruct loader with base filename "name" and call \a load() if "name" not empty
@@ -241,7 +237,6 @@ private:
PIString error_str;
Error error;
bool loaded, messages;
};