12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #include "gd_mono_internals.h"
- #include "../csharp_script.h"
- #include "../mono_gc_handle.h"
- #include "../utils/macros.h"
- #include "../utils/thread_local.h"
- #include "gd_mono_utils.h"
- #include <mono/metadata/exception.h>
- namespace GDMonoInternals {
- void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
-
- CRASH_COND(!unmanaged);
-
-
- Reference *ref = Object::cast_to<Reference>(unmanaged);
- GDMonoClass *klass = GDMonoUtils::get_object_class(managed);
- CRASH_COND(!klass);
- Ref<MonoGCHandle> gchandle = ref ? MonoGCHandle::create_weak(managed) :
- MonoGCHandle::create_strong(managed);
- Ref<CSharpScript> script = CSharpScript::create_for_managed_type(klass);
- CRASH_COND(script.is_null());
- ScriptInstance *si = CSharpInstance::create_for_managed_type(unmanaged, script.ptr(), gchandle);
- unmanaged->set_script_and_instance(script.get_ref_ptr(), si);
- return;
- }
- void unhandled_exception(MonoException *p_exc) {
- mono_unhandled_exception((MonoObject *)p_exc);
- abort();
- _UNREACHABLE_();
- }
- }
|