#include "globals.h" // Variables definitions G_varsType G_vars; // Functions addresses G_funcsType G_funcs; // List of objects to save G_toType G_tosave; // List of objects to print G_toType G_toprint; // Loaded modules G_libsType G_libs; void ClearGlobals() { for(auto& it:G_vars) delete it.second; for(auto& it:G_tosave) delete it; for(auto& it:G_toprint) delete it; for(auto& it:G_libs) dlclose(it); G_vars.clear(); G_tosave.clear(); G_toprint.clear(); } int LoadModule(const std::string& name, const void* p, const std::string& modname) { const std::string spath=*(reinterpret_cast(p)); // Load module void* handle; void* initfunc; std::string initname; if(0!=modname.size()) initname=modname; else { // Remove directory name, if present initname=name.substr((name.rfind('/')!=std::string::npos)?(name.rfind('/')+1):0,std::string::npos); // Remove ".so" on the end of string if(initname.rfind(".so")!=std::string::npos) initname.erase(initname.rfind(".so"),std::string::npos); } initname+="_module_init"; // Check if module is statically linked or already loaded: dlopen'ed the main program handle=dlopen(0,RTLD_LAZY|RTLD_GLOBAL); if(0==handle) { COUT(ERROR)<(initfunc))(p); if(0!=ret) COUT(ERROR)<Size(), i; if(sz<2 || sz%2==1 ) { COUT(ERROR)<<"Number of save arguments must not be "<At(i*2+1); if(!IS_OTYPE(arg1,ObjectString)) { COUT(ERROR)<<"Save format is save(object_1,file_1,...,object_n,file_n) where file_i is string"<At(i*2); arg2=dynamic_cast(input->At(i*2+1)); if(!arg1->Save(arg2->Value().c_str())) { COUT(ERROR)<<"Can't save object "<Dump()<<" to file "<Value()<Size(), i; if(sz==0) return true; // Print for(i=0;iAt(i)->Print()) { COUT(ERROR)<<"Unprintable object "<At(i)->Dump()<