- Refactor on platform implementation. See comment in interface/platform.h for more info
This commit is contained in:
@@ -16,89 +16,24 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
// =====================================================================================================================
|
||||
|
||||
#include <fennec/fproc/filesystem/file.h>
|
||||
#include <fennec/platform/linux/platform.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifdef FENNEC_LIB_WAYLAND
|
||||
#include <fennec/platform/linux/wayland/lib/dyn.h>
|
||||
#include <fennec/platform/linux/wayland/displaydev.h>
|
||||
#endif
|
||||
#include <fennec/lang/startup.h>
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
|
||||
linux_platform::linux_platform()
|
||||
: platform()
|
||||
, _display_driver(display_none) {
|
||||
#if FENNEC_BUILD_SERVER
|
||||
_runtime_server_checks();
|
||||
#else
|
||||
_runtime_client_checks();
|
||||
#endif
|
||||
STATIC_CONSTRUCTOR(_init_linux) {
|
||||
static linux_platform* platform = new linux_platform();
|
||||
file::cout().write(platform, sizeof(platform), 1);
|
||||
}
|
||||
|
||||
linux_platform::~linux_platform() {
|
||||
if (_display) {
|
||||
delete _display;
|
||||
_display = nullptr;
|
||||
}
|
||||
void linux_platform::initialize() {
|
||||
platform::initialize();
|
||||
}
|
||||
|
||||
shared_object* linux_platform::load_object(const cstring& file) {
|
||||
void* handle = dlopen(file, RTLD_NOW | RTLD_LOCAL);
|
||||
const char* load_error = dlerror();
|
||||
assert(handle != nullptr, load_error);
|
||||
return static_cast<shared_object*>(handle);
|
||||
}
|
||||
|
||||
void linux_platform::unload_object(shared_object* obj) {
|
||||
if (obj) {
|
||||
dlclose(obj);
|
||||
}
|
||||
}
|
||||
|
||||
platform::function_pointer linux_platform::find_symbol(shared_object* hndl, const cstring& name) {
|
||||
string _name = name;
|
||||
void* symbol = dlsym(hndl, _name);
|
||||
if (symbol == nullptr) {
|
||||
_name = '_' + _name;
|
||||
symbol = dlsym(hndl, _name);
|
||||
}
|
||||
return (function_pointer)symbol;
|
||||
}
|
||||
|
||||
platform::global linux_platform::find_global(shared_object* hndl, const cstring& name) {
|
||||
string _name = name;
|
||||
void* symbol = dlsym(hndl, _name);
|
||||
if (symbol == nullptr) {
|
||||
_name = '_' + _name;
|
||||
symbol = dlsym(hndl, _name);
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
|
||||
displaydev* linux_platform::get_display() {
|
||||
return _display;
|
||||
}
|
||||
|
||||
void linux_platform::_runtime_client_checks() {
|
||||
#ifdef FENNEC_LIB_WAYLAND
|
||||
if (libwayland::load_symbols(this)) {
|
||||
_display_driver = display_wayland;
|
||||
_display = new wayland_display(this);
|
||||
libwayland::unload_symbols(this); // Doesn't actually unload symbols, just resets ref counter to only consider
|
||||
// the created display
|
||||
}
|
||||
#endif
|
||||
assertf(_display != nullptr, "failed to find suitable display driver");
|
||||
}
|
||||
|
||||
void linux_platform::_find_display_driver() {
|
||||
|
||||
}
|
||||
|
||||
void linux_platform::_runtime_server_checks() {
|
||||
void linux_platform::shutdown() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user