ImguiEmbed

This commit is contained in:
2025-03-29 23:23:49 -05:00
parent e087ac70d1
commit 0c67caf827
6 changed files with 123 additions and 12 deletions

View File

@@ -21,19 +21,19 @@ namespace Archimedes {
for(auto it = modules.begin(); it != modules.end(); it++) {
void* handle = (*it)->getHandle();
delete *it;
dlclose(handle);
if(handle)
dlclose(handle);
it = modules.erase(it);
}
}
bool App::load(std::string lib, std::list<std::string> blacklist = {}) {
Module* App::dynamicLoad(std::string lib) {
void* h = dlopen(lib.c_str(), RTLD_NOW);
if(!h) {
std::cout << "could not open lib at: \"" << lib.c_str() << "\"\nError: " << dlerror() << std::endl;
return false;
return nullptr;
}
Module::create_t* create = (Module::create_t*) dlsym(h, "create");
@@ -41,15 +41,25 @@ namespace Archimedes {
if(err) {
std::cout << "error finding create function in file: " << lib << std::endl;
std::cout << "dlerror(): " << err << std::endl;
return nullptr;
}
Module* m = create(h, App::Get());
return create(h, Get());
}
bool App::load(Module* m, std::list<std::string> blacklist = {}) {
if(!m) {
return false;
}
void* h = m->getHandle();
for(auto it = blacklist.begin(); it != blacklist.end(); it++) {
if(*it == m->getName()) {
std::cout << "Module \"" << *it << "\" is already loaded!\n";
delete m;
dlclose(h);
if(h)
dlclose(h);
return false;
}
}
@@ -66,7 +76,7 @@ namespace Archimedes {
skip = false;
continue;
} else {
load(it->second, blacklist);
load(dynamicLoad(it->second), blacklist);
}
}
@@ -85,8 +95,9 @@ namespace Archimedes {
modules.erase(m->self);
delete m;
dlclose(h);
if(h)
dlclose(h);
}

View File

@@ -17,7 +17,9 @@ namespace Archimedes {
std::list<Module*> toClose;
std::list<std::string> toOpen;
virtual bool load(std::string, std::list<std::string>);
Module* dynamicLoad(std::string);
virtual bool load(Module*, std::list<std::string>);
virtual void unload(std::list<Module*>::iterator);
virtual void printHelp() = 0;