31 lines
863 B
C++
31 lines
863 B
C++
#include "mono.hpp"
|
|
#include <mono/jit/jit.h>
|
|
#include <mono/metadata/mono-config.h>
|
|
#include <mono/metadata/appdomain.h>
|
|
|
|
namespace Mono {
|
|
|
|
RuntimeJIT::RuntimeJIT(const std::string& domain_name){
|
|
mono_set_dirs("mono-libs", "mono-libs");
|
|
mono_set_assemblies_path("mono-libs");
|
|
mono_config_parse("mono-libs/config.xml");
|
|
|
|
domain = mono_jit_init(domain_name.c_str());
|
|
if(!domain)
|
|
throw UsefulException("can't initialize mono domain");
|
|
}
|
|
|
|
RuntimeJIT::~RuntimeJIT(){
|
|
// TODO: fix segfault on cleanup
|
|
// mono_jit_cleanup(domain);
|
|
}
|
|
|
|
std::shared_ptr<Assembly> RuntimeJIT::loadAssembly(const std::string &name){
|
|
MonoAssembly* ptr = mono_domain_assembly_open(domain, name.c_str());
|
|
if(!ptr)
|
|
throw UsefulException(ougge_format("can't load assembly '%s'", name.c_str()));
|
|
return std::make_shared<Assembly>(ptr);
|
|
}
|
|
|
|
}
|