- Separated Platform and Compiler Dependent Behaviour into CMake scripts
- Implemented Basic Platform Interfaces
- Implemented partial Linux platform and Wayland Display.
- Implemented Dependencies for the above
- map
- set
- optional
- pair
TODO: threading
This commit is contained in:
69
source/platform/linux/wayland/lib/dyn.cpp
Normal file
69
source/platform/linux/wayland/lib/dyn.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
// =====================================================================================================================
|
||||
// fennec, a free and open source game engine
|
||||
// Copyright © 2025 Medusa Slockbower
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#include <fennec/platform/linux/wayland/lib/sym_def.h>
|
||||
#include <fennec/platform/linux/wayland/lib/dyn.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
namespace wayland
|
||||
{
|
||||
|
||||
using shared_lib = platform::shared_lib;
|
||||
|
||||
static int _load_count = 0;
|
||||
|
||||
// Create private variables
|
||||
#define FENNEC_LIB(lib) static shared_lib _FENNEC_LIB_##lib = { nullptr, FENNEC_LIB_##lib };
|
||||
#define FENNEC_SYMBOL(...)
|
||||
#include <fennec/platform/linux/wayland/lib/sym.h>
|
||||
|
||||
bool load_symbols(linux_platform* platform) {
|
||||
if (_load_count++ != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#define FENNEC_LIB(lib) _FENNEC_LIB_##lib._lib = platform->load_object(_FENNEC_LIB_##lib._name); \
|
||||
FENNEC_HAS_LIB_##lib = _FENNEC_LIB_##lib._lib != nullptr; \
|
||||
if(not FENNEC_HAS_LIB_##lib) { \
|
||||
unload_symbols(platform); \
|
||||
return false; \
|
||||
} \
|
||||
shared_lib& current_lib = _FENNEC_LIB_##lib;
|
||||
#define FENNEC_SYMBOL(ret, fn, ...) fn = (sym_##fn)(platform->find_symbol(current_lib._lib, #fn));
|
||||
#include <fennec/platform/linux/wayland/lib/sym.h>
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void unload_symbols(linux_platform* platform) {
|
||||
if (--_load_count != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
#define FENNEC_LIB(lib) platform->unload_object(_FENNEC_LIB_##lib._lib); \
|
||||
_FENNEC_LIB_##lib._lib = nullptr;
|
||||
#define FENNEC_SYMBOL(ret, fn, ...) fn = nullptr;
|
||||
#include <fennec/platform/linux/wayland/lib/sym.h>
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user