Make a copy of the static registrar and the runtime headers for Xamarin.Mac/Classic. (#5945)

* [registrar] Make a copy of the static registrar for Xamarin.Mac/Classic.

Make a copy of the static registrar for Xamarin.Mac/Classic, one which is
compatible with the binary artifacts we ship for Xamarin.Mac/Classic
(libxammac, XamMac.dll).

This way the static registrar can evolve in the future, without breaking
Xamarin.Mac/Classic.

* [runtime] Make a copy of the runtime headers too.

* Update comment.

* [mmp] Delay creating a Target instance until we know if we're a Classic or Unified app.

Otherwise the wrong static registrar might be created.
This commit is contained in:
Rolf Bjarne Kvinge 2019-04-25 18:08:10 +02:00 коммит произвёл GitHub
Родитель 56ae1da5b9
Коммит aa4eaf7c92
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 6566 добавлений и 11 удалений

Просмотреть файл

@ -395,7 +395,7 @@ MAC_CLANG = DEVELOPER_DIR=$(XCODE_DEVELOPER_ROOT) $(MAC_CC) -mmacosx-version-min
MAC32_CLANG = DEVELOPER_DIR=$(XCODE94_DEVELOPER_ROOT) $(MAC32_CC) -mmacosx-version-min=$(MIN_OSX_SDK_VERSION)
MAC64_CLANG = DEVELOPER_DIR=$(XCODE_DEVELOPER_ROOT) $(MAC_CC) -mmacosx-version-min=$(MIN_OSX_SDK_VERSION)
MAC_SHIPPED_HEADERS = xamarin/launch.h
MAC_SHIPPED_HEADERS = xamarin/launch.h xamarin-classic/launch.h $(subst xamarin/,xamarin-classic/,$(SHIPPED_HEADERS))
MAC_OBJC_CFLAGS=-ObjC++ -std=c++0x -fno-exceptions -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\"
MAC_CFLAGS = -mmacosx-version-min=$(MIN_OSX_SDK_VERSION) -Wall -DMONOMAC -g -DMIN_XM_MONO_VERSION=\"$(MIN_XM_MONO_VERSION)\"
@ -526,6 +526,7 @@ RUNTIME_MAC_TARGETS_DIRS += \
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib \
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono \
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/include/xamarin \
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/include/xamarin-classic \
RUNTIME_MAC_TARGETS += \
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/XamMacLauncher \
@ -544,7 +545,7 @@ $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/%: .libs/mac/% | $(MAC_DESTDIR)$(
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono/XamMacLauncher: | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/lib/mono
$(Q) ln -sF ../XamMacLauncher $@
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/include/%.h: %.h | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/include/xamarin
$(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/include/%.h: %.h | $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/include/xamarin $(MAC_DESTDIR)$(MAC_FRAMEWORK_CURRENT_DIR)/include/xamarin-classic
$(Q) install -m 0644 $< $@
$(RUNTIME_MAC_TARGETS_DIRS):

Просмотреть файл

@ -0,0 +1,114 @@
//
// launch.h: Public launch code for Xamarin.Mac.
// This header describes the launch sequence of Xamarin.Mac apps.
// This header is public.
//
// Authors:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright 2014 Xamarin Inc.
//
#ifndef __XAMARIN_LAUNCH_H__
#define __XAMARIN_LAUNCH_H__
#include <Foundation/Foundation.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Xamarin.Mac will follow this startup logic:
*
* 1) If found, call the custom initialization function (xamarin_app_initialize). See later in this file how
* to declare this function.
*
* 2) (If not embedding Mono) Search for the system Mono in the following directories:
* a) As specified by the MONO_RUNTIME environment variable.
* b) Otherwise '/Library/Frameworks/Mono.framework/Versions/Current'
*
* 3) Ensure the following environment variables are set:
*
* appdir = /full/path/to/theapp.app ([[NSBundle mainBundle] bundlePath])
* resdir = $appdir/Contents/Resources
* bindir = $appdir/Contents/MacOS
* monodir = the path to the Mono runtime (as found in point 2 above)
*
* If not embedding Mono:
*
* DYLD_FALLBACK_LIBRARY_PATH=$resdir/lib:$monodir/lib:$DYLD_FALLBACK_LIBRARY_PATH
* PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/External/pkgconfig:$resdir/lib/pkgconfig:$resdir/share/pkgconfig:$PKG_CONFIG_PATH
* MONO_GAC_PREFIX=$resdir:$MONO_GAC_PREFIX
* PATH=$bindir:$PATH
*
* If embedding Mono:
*
* MONO_DISABLE_SHARED_AREA=1
* MONO_REGISTRY_PATH=~/Library/Application Support (NSApplicationSupportDirectory/$appid)
*
* The app does not need to set these variables. The app may end up relaunching in
* this process (some environment variables only take effect upon initial load, in
* particular any DYLD_* variables).
*
* 3b) (If embedding Mono) Change the current directory to $appdir/Contents/Resources
*
* 4) Ensure that the maximum number of open files is least 1024.
*
* 5) Verify the minimum Mono version. The minimum mono version is specified in:
* a) The bundle's Info.plist's MonoMinimumVersion field.
* b) The bundle's Info.plist's MonoMinVersion field.
* c) The minimum mono version Xamarin.Mac requires (currently 3.10)
*
* If the minimum Mono version requirement can't be met, a dialog will show an error
* and the app will exit.
*
* 6) Find the executable. The name is:
* a) The bundle's Info.plist's MonoBundleExecutable field.
* b) Otherwise the name of the executable + ".exe"
*
* The directory is by default the bundle's Contents/MonoBundle directory, but can be changed
* by calling xamarin_set_bundle_path.
*
* If the executable can't be found, a dialog will show an error and the app will exit.
*
* 7a) [If not embedding Mono] Don't parse any config files, leave it to the Mono runtime to load the defaults.
*
* 7b) [If embedding Mono] Parse $appdir/Contents/MonoBundle/machine.config and $appdir/Contents/MonoBundle/config
* (It is not an error to not find these files, but the app will most likely not work)
*
*/
/*
* To have a custom initialization method link a static library into the app,
* and include a function called 'xamarin_app_initialize'. The method will be
* called as described above.
*
* Example mmp command line:
* mmp --output pathToApp --name MyApp --no-root-assembly --profile=xammac --link_flags="-force_load custom-init.a" --use-system-mono --arch i386
*
* "-force_load" is required, because otherwise the native linker will see that
* it's not used, and remove it.
*/
typedef struct xamarin_initialize_data {
/* Input arguments */
int size; /* The size of this structure */
int argc;
char **argv;
bool is_relaunch; /* If we've been respawned or not */
const char *basename;
NSString *app_dir; /* The bundle directory */
/* Output arguments */
bool exit; // If initialization failed and the app should exit.
int exit_code; // The exit code to return if initialization failed.
bool requires_relaunch; // if the launcher should respawn itself (setting some environment variables require this, in particular DYLD_* variables). This is ignored if 'is_relaunch' is true.
enum XamarinLaunchMode launch_mode;
} xamarin_initialize_data;
typedef void (*xamarin_custom_initialize_func) (xamarin_initialize_data *data);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __XAMARIN_LAUNCH_H__ */

Просмотреть файл

@ -0,0 +1,102 @@
//
// main.h: Basic startup code for Xamarin.iOS/Xamarin.Mac
// This header contains definitions used by Xamarin when building applications.
// Do not consider anything here stable API (unless otherwise specified),
// it will change between releases.
//
// Authors:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright 2012-2014 Xamarin Inc.
//
#include <Foundation/Foundation.h>
#ifndef __XAMARIN_MAIN_H__
#define __XAMARIN_MAIN_H__
#ifdef __cplusplus
extern "C" {
#endif
/* This enum must always match the identical enum in src/ObjCRuntime/ExceptionMode.cs */
enum MarshalObjectiveCExceptionMode : int {
MarshalObjectiveCExceptionModeDefault = 0,
MarshalObjectiveCExceptionModeUnwindManagedCode = 1,
MarshalObjectiveCExceptionModeThrowManagedException = 2,
MarshalObjectiveCExceptionModeAbort = 3,
MarshalObjectiveCExceptionModeDisable = 4,
};
/* This enum must always match the identical enum in src/ObjCRuntime/ExceptionMode.cs */
enum MarshalManagedExceptionMode : int {
MarshalManagedExceptionModeDefault = 0,
MarshalManagedExceptionModeUnwindNativeCode = 1,
MarshalManagedExceptionModeThrowObjectiveCException = 2,
MarshalManagedExceptionModeAbort = 3,
MarshalManagedExceptionModeDisable = 4,
};
/* This enum must always match the identical enum in src/ObjCRuntime/Runtime.cs */
enum XamarinLaunchMode {
XamarinLaunchModeApp = 0,
XamarinLaunchModeExtension = 1,
XamarinLaunchModeEmbedded = 2,
};
extern bool mono_use_llvm; // this is defined inside mono
#if MONOMAC
extern bool xamarin_use_new_assemblies;
#else
#define xamarin_use_new_assemblies 1
#endif
#if DEBUG
extern bool xamarin_gc_pump;
#endif
extern bool xamarin_debug_mode;
extern bool xamarin_disable_lldb_attach;
#if MONOMAC
extern bool xamarin_mac_hybrid_aot;
extern bool xamarin_mac_modern;
extern char *xamarin_entry_assembly_path;
#endif
extern bool xamarin_init_mono_debug;
extern int xamarin_log_level;
extern const char *xamarin_executable_name;
extern const char *xamarin_arch_name;
extern bool xamarin_is_gc_coop;
extern enum MarshalObjectiveCExceptionMode xamarin_marshal_objectivec_exception_mode;
extern enum MarshalManagedExceptionMode xamarin_marshal_managed_exception_mode;
extern enum XamarinLaunchMode xamarin_launch_mode;
extern bool xamarin_supports_dynamic_registration;
typedef void (*xamarin_setup_callback) ();
typedef int (*xamarin_extension_main_callback) (int argc, char** argv);
extern xamarin_setup_callback xamarin_setup;
extern xamarin_extension_main_callback xamarin_extension_main;
void xamarin_set_use_sgen (bool value); /* Public API, but a no-op (only SGen is supported, so it defaults to true) */
bool xamarin_get_use_sgen (); /* Public API, always returns true */
void xamarin_set_is_unified (bool value); /* Public API */
bool xamarin_get_is_unified (); /* Public API */
int xamarin_get_launch_mode ();
int xamarin_watchextension_main (int argc, char **argv);
#ifndef MONOTOUCH
void xamarin_set_is_mkbundle (bool value); /* Not Public API, exact semantics is not defined yet */
bool xamarin_get_is_mkbundle (); /* Not Public API, exact semantics is not defined yet */
#endif
void xamarin_set_is_debug (bool value); /* Public API */
bool xamarin_get_is_debug (); /* Public API */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __XAMARIN_MAIN_H__ */

Просмотреть файл

@ -0,0 +1,844 @@
// vim: set filetype=c :
//
// mono-runtime.h: Header file to allow dynamic loading of
// Mono to be transparent from code including this header.
//
// Authors:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
// Aaron Bockover <abock@xamarin.com>
//
// Copyright 2013-2014 Xamarin Inc.
//
#ifndef __MONO_RUNTIME__
#define __MONO_RUNTIME__
#ifdef __cplusplus
extern "C" {
#endif
/* This is copied from eglib's header files */
typedef unsigned int guint;
typedef int32_t gboolean;
typedef int32_t gint32;
typedef uint32_t guint32;
typedef char gchar;
typedef void * gpointer;
typedef const void * gconstpointer;
typedef guint (*GHashFunc) (gconstpointer key);
typedef gboolean (*GEqualFunc) (gconstpointer a, gconstpointer b);
#ifndef GPOINTER_TO_INT
#define GPOINTER_TO_INT(p) ((int) (long) (p))
#endif
#ifndef GINT_TO_POINTER
#define GINT_TO_POINTER(i) ((void *) (long) (i))
#endif
#include <stdint.h>
const char * xamarin_initialize_dynamic_runtime (const char *mono_runtime_prefix);
char *xamarin_get_mono_runtime_build_info (); // returns NULL if libmono couldn't be found (mono_get_runtime_build_info doesn't exist).
#ifdef DYNAMIC_MONO_RUNTIME
#define mono_class_from_name mono_class_from_name_impl
#define mono_class_get_method_from_name mono_class_get_method_from_name_impl
#define mono_class_get_field_from_name mono_class_get_field_from_name_impl
#define mono_class_is_assignable_from mono_class_is_assignable_from_impl
#define mono_class_from_mono_type mono_class_from_mono_type_impl
#define mono_class_is_delegate mono_class_is_delegate_impl
#define mono_class_get_element_class mono_class_get_element_class_impl
#define mono_class_get_namespace mono_class_get_namespace_impl
#define mono_class_get_name mono_class_get_name_impl
#define mono_class_get_parent mono_class_get_parent_impl
#define mono_class_is_subclass_of mono_class_is_subclass_of_impl
#define mono_class_is_valuetype mono_class_is_valuetype_impl
#define mono_class_is_enum mono_class_is_enum_impl
#define mono_class_enum_basetype mono_class_enum_basetype_impl
#define mono_class_value_size mono_class_value_size_impl
#define mono_class_get_type mono_class_get_type_impl
#define mono_class_is_nullable mono_class_is_nullable_impl
#define mono_class_get_nullable_param mono_class_get_nullable_param_impl
#define mono_method_full_name mono_method_full_name_impl
#define mono_runtime_invoke mono_runtime_invoke_impl
#define mono_gchandle_new mono_gchandle_new_impl
#define mono_gchandle_get_target mono_gchandle_get_target_impl
#define mono_gchandle_free mono_gchandle_free_impl
#define mono_gchandle_new_weakref mono_gchandle_new_weakref_impl
#define mono_raise_exception mono_raise_exception_impl
#define mono_array_addr_with_size mono_array_addr_with_size_impl
#define mono_string_new mono_string_new_impl
#define mono_array_new mono_array_new_impl
#define mono_object_unbox mono_object_unbox_impl
#define mono_string_to_utf8 mono_string_to_utf8_impl
#define mono_object_new mono_object_new_impl
#define mono_array_length mono_array_length_impl
#define mono_object_isinst mono_object_isinst_impl
#define mono_object_get_class mono_object_get_class_impl
#define mono_object_get_virtual_method mono_object_get_virtual_method_impl
#define mono_field_get_value mono_field_get_value_impl
#define mono_value_box mono_value_box_impl
#define mono_gc_wbarrier_set_arrayref mono_gc_wbarrier_set_arrayref_impl
#define mono_profiler_install mono_profiler_install_impl
#define mono_profiler_install_thread mono_profiler_install_thread_impl
#define mono_profiler_install_gc mono_profiler_install_gc_impl
#define mono_profiler_load mono_profiler_load_impl
#define mono_thread_is_foreign mono_thread_is_foreign_impl
#define mono_thread_current mono_thread_current_impl
#define mono_thread_attach mono_thread_attach_impl
#define mono_thread_detach_if_exiting mono_thread_detach_if_exiting_impl
#define mono_runtime_set_pending_exception mono_runtime_set_pending_exception_impl
#define mono_set_assemblies_path mono_set_assemblies_path_impl
#define mono_assembly_open mono_assembly_open_impl
#define mono_assembly_get_image mono_assembly_get_image_impl
#define mono_assembly_name_new mono_assembly_name_new_impl
#define mono_assembly_name_free mono_assembly_name_free_impl
#define mono_assembly_loaded mono_assembly_loaded_impl
#define mono_register_machine_config mono_register_machine_config_impl
#define mono_set_dirs mono_set_dirs_impl
#define mono_assembly_name_get_name mono_assembly_name_get_name_impl
#define mono_assembly_name_get_culture mono_assembly_name_get_culture_impl
#define mono_install_assembly_preload_hook mono_install_assembly_preload_hook_impl
#define mono_assembly_get_name mono_assembly_get_name_impl
#define mono_add_internal_call mono_add_internal_call_impl
#define mono_dangerous_add_raw_internal_call mono_dangerous_add_raw_internal_call_impl
#define mono_method_signature mono_method_signature_impl
#define mono_method_get_class mono_method_get_class_impl
#define mono_dllmap_insert mono_dllmap_insert_impl
#define mono_domain_get mono_domain_get_impl
#define mono_get_intptr_class mono_get_intptr_class_impl
#define mono_get_string_class mono_get_string_class_impl
#define mono_get_corlib mono_get_corlib_impl
#define mono_get_array_class mono_get_array_class_impl
#define mono_get_exception_class mono_get_exception_class_impl
#define mono_get_root_domain mono_get_root_domain_impl
#define mono_domain_set_config mono_domain_set_config_impl
#define mono_assembly_get_object mono_assembly_get_object_impl
#define mono_method_get_object mono_method_get_object_impl
#define mono_type_get_object mono_type_get_object_impl
#define mono_reflection_type_get_type mono_reflection_type_get_type_impl
#define mono_signature_get_params mono_signature_get_params_impl
#define mono_type_is_byref mono_type_is_byref_impl
#define mono_signature_get_return_type mono_signature_get_return_type_impl
#define mono_type_get_type mono_type_get_type_impl
#define mono_debug_init mono_debug_init_impl
#define mono_gc_collect mono_gc_collect_impl
#define mono_is_debugger_attached mono_is_debugger_attached_impl
#define mono_config_parse_memory mono_config_parse_memory_impl
#define mono_gc_max_generation mono_gc_max_generation_impl
#define mono_g_hash_table_new_type mono_g_hash_table_new_type_impl
#define mono_g_hash_table_lookup mono_g_hash_table_lookup_impl
#define mono_g_hash_table_insert mono_g_hash_table_insert_impl
#define mono_get_exception_execution_engine mono_get_exception_execution_engine_impl
#define mono_exception_from_name_msg mono_exception_from_name_msg_impl
#define mono_gc_reference_queue_new mono_gc_reference_queue_new_impl
#define mono_gc_reference_queue_free mono_gc_reference_queue_free_impl
#define mono_gc_reference_queue_add mono_gc_reference_queue_add_impl
#define mono_gc_register_finalizer_callbacks mono_gc_register_finalizer_callbacks_impl
#define mono_gc_toggleref_add mono_gc_toggleref_add_impl
#define mono_gc_toggleref_register_callback mono_gc_toggleref_register_callback_impl
#define mono_path_resolve_symlinks mono_path_resolve_symlinks_impl
#define mono_free mono_free_impl
#define mono_get_runtime_build_info mono_get_runtime_build_info_impl
#define mono_jit_init_version mono_jit_init_version_impl
#define mono_jit_init mono_jit_init_impl
#define mono_jit_exec mono_jit_exec_impl
#define mono_jit_parse_options mono_jit_parse_options_impl
#define mono_jit_set_aot_mode mono_jit_set_aot_mode_impl
#define mono_set_signal_chaining mono_set_signal_chaining_impl
#define mono_set_crash_chaining mono_set_crash_chaining_impl
#define mono_jit_set_trace_options mono_jit_set_trace_options_impl
#define mono_jit_thread_attach mono_jit_thread_attach_impl
#define mono_exception_walk_trace mono_exception_walk_trace_impl
#define mono_install_unhandled_exception_hook mono_install_unhandled_exception_hook_impl
#define mono_main mono_main_impl
#define mono_install_load_aot_data_hook mono_install_load_aot_data_hook_impl
#define mini_parse_debug_option mini_parse_debug_option_impl
#define mono_trace_set_log_handler mono_trace_set_log_handler_impl
#define mono_trace_set_print_handler mono_trace_set_print_handler_impl
#define mono_trace_set_printerr_handler mono_trace_set_printerr_handler_impl
#define mono_threads_enter_gc_unsafe_region mono_threads_enter_gc_unsafe_region_impl
#define mono_threads_exit_gc_unsafe_region mono_threads_exit_gc_unsafe_region_impl
#define mono_threads_enter_gc_safe_region mono_threads_enter_gc_safe_region_impl
#define mono_threads_exit_gc_safe_region mono_threads_exit_gc_safe_region_impl
#define mono_threads_assert_gc_safe_region mono_threads_assert_gc_safe_region_impl
#define mono_threads_assert_gc_unsafe_region mono_threads_assert_gc_unsafe_region_impl
#define mono_threads_assert_gc_starting_region mono_threads_assert_gc_starting_region_impl
#define mono_thread_info_current_unchecked mono_thread_info_current_unchecked_impl
#define mono_threads_attach_coop mono_threads_attach_coop_impl
#define mono_threads_detach_coop mono_threads_detach_coop_impl
#define mono_install_ftnptr_eh_callback mono_install_ftnptr_eh_callback_impl
#endif
/* This is copied from mono's header files */
/* utils/mono-publib.h */
#define MONO_API
typedef int32_t mono_bool;
/* metadata/image.h */
typedef struct _MonoAssembly MonoAssembly;
typedef struct _MonoAssemblyName MonoAssemblyName;
typedef struct _MonoImage MonoImage;
typedef enum {
MONO_IMAGE_OK,
MONO_IMAGE_ERROR_ERRNO,
MONO_IMAGE_MISSING_ASSEMBLYREF,
MONO_IMAGE_IMAGE_INVALID
} MonoImageOpenStatus;
/* metadata/metadata.h */
typedef struct _MonoClass MonoClass;
typedef struct _MonoDomain MonoDomain;
typedef struct _MonoMethod MonoMethod;
typedef struct _MonoMethodSignature MonoMethodSignature;
typedef struct _MonoType MonoType;
/* metadata/class.h */
typedef struct MonoVTable MonoVTable;
typedef struct _MonoClassField MonoClassField;
/* metadata/object.h */
typedef struct _MonoString MonoString;
typedef struct _MonoArray MonoArray;
typedef struct _MonoReflectionMethod MonoReflectionMethod;
typedef struct _MonoReflectionAssembly MonoReflectionAssembly;
typedef struct _MonoReflectionType MonoReflectionType;
typedef struct _MonoException MonoException;
typedef struct _MonoThread MonoThread;
typedef struct _MonoThreadsSync MonoThreadsSync;
typedef struct {
MonoVTable *vtable;
MonoThreadsSync *synchronisation;
} MonoObject;
typedef struct _MonoReferenceQueue MonoReferenceQueue;
typedef void (*mono_reference_queue_callback) (void *user_data);
#define mono_array_addr(array,type,index) ((type*)(void*) mono_array_addr_with_size (array, sizeof (type), index))
#define mono_array_get(array,type,index) ( *(type*)mono_array_addr ((array), type, (index)) )
#define mono_array_setref(array,index,value) \
do { \
void **__p = (void **) mono_array_addr ((array), void*, (index)); \
mono_gc_wbarrier_set_arrayref ((array), __p, (MonoObject*)(value)); \
/* *__p = (value);*/ \
} while (0)
/* metadata/assembly.h */
typedef MonoAssembly * (*MonoAssemblyPreLoadFunc) (MonoAssemblyName *aname, char **assemblies_path, void* user_data);
/* metadata/profiler.h */
typedef struct _MonoProfiler MonoProfiler;
typedef enum {
MONO_PROFILE_NONE = 0,
MONO_PROFILE_APPDOMAIN_EVENTS = 1 << 0,
MONO_PROFILE_ASSEMBLY_EVENTS = 1 << 1,
MONO_PROFILE_MODULE_EVENTS = 1 << 2,
MONO_PROFILE_CLASS_EVENTS = 1 << 3,
MONO_PROFILE_JIT_COMPILATION = 1 << 4,
MONO_PROFILE_INLINING = 1 << 5,
MONO_PROFILE_EXCEPTIONS = 1 << 6,
MONO_PROFILE_ALLOCATIONS = 1 << 7,
MONO_PROFILE_GC = 1 << 8,
MONO_PROFILE_THREADS = 1 << 9,
MONO_PROFILE_REMOTING = 1 << 10,
MONO_PROFILE_TRANSITIONS = 1 << 11,
MONO_PROFILE_ENTER_LEAVE = 1 << 12,
MONO_PROFILE_COVERAGE = 1 << 13,
MONO_PROFILE_INS_COVERAGE = 1 << 14,
MONO_PROFILE_STATISTICAL = 1 << 15,
MONO_PROFILE_METHOD_EVENTS = 1 << 16,
MONO_PROFILE_MONITOR_EVENTS = 1 << 17,
MONO_PROFILE_IOMAP_EVENTS = 1 << 18, /* this should likely be removed, too */
MONO_PROFILE_GC_MOVES = 1 << 19,
MONO_PROFILE_GC_ROOTS = 1 << 20
} MonoProfileFlags;
typedef enum {
MONO_GC_EVENT_START,
MONO_GC_EVENT_MARK_START,
MONO_GC_EVENT_MARK_END,
MONO_GC_EVENT_RECLAIM_START,
MONO_GC_EVENT_RECLAIM_END,
MONO_GC_EVENT_END,
MONO_GC_EVENT_PRE_STOP_WORLD,
MONO_GC_EVENT_POST_STOP_WORLD,
MONO_GC_EVENT_PRE_START_WORLD,
MONO_GC_EVENT_POST_START_WORLD
} MonoGCEvent;
typedef void (*MonoProfileFunc) (MonoProfiler *prof);
typedef void (*MonoProfileThreadFunc) (MonoProfiler *prof, uintptr_t tid);
typedef void (*MonoProfileGCFunc) (MonoProfiler *prof, MonoGCEvent event, int generation);
typedef void (*MonoProfileGCResizeFunc) (MonoProfiler *prof, int64_t new_size);
/* metadata/mono-debug.h */
typedef enum {
MONO_DEBUG_FORMAT_NONE,
MONO_DEBUG_FORMAT_MONO,
/* Deprecated, the mdb debugger is not longer supported. */
MONO_DEBUG_FORMAT_DEBUGGER
} MonoDebugFormat;
/* metadata/mini.h */
typedef gboolean (*MonoExceptionFrameWalk) (MonoMethod *method, gpointer ip, size_t native_offset, gboolean managed, gpointer user_data);
typedef void (*MonoUnhandledExceptionFunc) (MonoObject *exc, gpointer user_data);
typedef unsigned char* (*MonoLoadAotDataFunc) (MonoAssembly *assembly, int size, gpointer user_data, void **out_handle);
typedef void (*MonoFreeAotDataFunc) (MonoAssembly *assembly, int size, gpointer user_data, void *handle);
/* metadata/blob.h */
/*
* Encoding for type signatures used in the Metadata
*/
typedef enum {
MONO_TYPE_END = 0x00, /* End of List */
MONO_TYPE_VOID = 0x01,
MONO_TYPE_BOOLEAN = 0x02,
MONO_TYPE_CHAR = 0x03,
MONO_TYPE_I1 = 0x04,
MONO_TYPE_U1 = 0x05,
MONO_TYPE_I2 = 0x06,
MONO_TYPE_U2 = 0x07,
MONO_TYPE_I4 = 0x08,
MONO_TYPE_U4 = 0x09,
MONO_TYPE_I8 = 0x0a,
MONO_TYPE_U8 = 0x0b,
MONO_TYPE_R4 = 0x0c,
MONO_TYPE_R8 = 0x0d,
MONO_TYPE_STRING = 0x0e,
MONO_TYPE_PTR = 0x0f, /* arg: <type> token */
MONO_TYPE_BYREF = 0x10, /* arg: <type> token */
MONO_TYPE_VALUETYPE = 0x11, /* arg: <type> token */
MONO_TYPE_CLASS = 0x12, /* arg: <type> token */
MONO_TYPE_VAR = 0x13, /* number */
MONO_TYPE_ARRAY = 0x14, /* type, rank, boundsCount, bound1, loCount, lo1 */
MONO_TYPE_GENERICINST= 0x15, /* <type> <type-arg-count> <type-1> \x{2026} <type-n> */
MONO_TYPE_TYPEDBYREF = 0x16,
MONO_TYPE_I = 0x18,
MONO_TYPE_U = 0x19,
MONO_TYPE_FNPTR = 0x1b, /* arg: full method signature */
MONO_TYPE_OBJECT = 0x1c,
MONO_TYPE_SZARRAY = 0x1d, /* 0-based one-dim-array */
MONO_TYPE_MVAR = 0x1e, /* number */
MONO_TYPE_CMOD_REQD = 0x1f, /* arg: typedef or typeref token */
MONO_TYPE_CMOD_OPT = 0x20, /* optional arg: typedef or typref token */
MONO_TYPE_INTERNAL = 0x21, /* CLR internal type */
MONO_TYPE_MODIFIER = 0x40, /* Or with the following types */
MONO_TYPE_SENTINEL = 0x41, /* Sentinel for varargs method signature */
MONO_TYPE_PINNED = 0x45, /* Local var that points to pinned object */
MONO_TYPE_ENUM = 0x55 /* an enumeration */
} MonoTypeEnum;
/*
* From internal headers
*/
/* metadata/gc-internal.h */
enum {
MONO_GC_FINALIZER_EXTENSION_VERSION = 1,
};
typedef struct {
int version;
gboolean (*is_class_finalization_aware) (MonoClass *klass);
void (*object_queued_for_finalization) (MonoObject *object);
} MonoGCFinalizerCallbacks;
/* metadata/sgen-toggleref.h */
typedef enum {
MONO_TOGGLE_REF_DROP,
MONO_TOGGLE_REF_STRONG,
MONO_TOGGLE_REF_WEAK
} MonoToggleRefStatus;
typedef MonoToggleRefStatus (*MonoToggleRefCallback) (MonoObject *obj);
/* metadata/mono-hash.h */
typedef enum {
MONO_HASH_KEY_GC = 1,
MONO_HASH_VALUE_GC = 2,
MONO_HASH_KEY_VALUE_GC = MONO_HASH_KEY_GC | MONO_HASH_VALUE_GC,
} MonoGHashGCType;
typedef struct _MonoGHashTable MonoGHashTable;
/* utils/mono-logger.h */
typedef void (*MonoLogCallback) (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data);
typedef void (*MonoPrintCallback) (const char *string, mono_bool is_stdout);
/* mini/jit.h */
typedef enum {
MONO_AOT_MODE_NONE,
MONO_AOT_MODE_NORMAL,
MONO_AOT_MODE_HYBRID,
MONO_AOT_MODE_FULL,
MONO_AOT_MODE_LLVMONLY,
MONO_AOT_MODE_INTERP,
MONO_AOT_MODE_INTERP_LLVMONLY,
} MonoAotMode;
/* metadata/marshal.h */
typedef void (*MonoFtnPtrEHCallback) (guint32 gchandle);
/* not in any header */
void mono_gc_init_finalizer_thread ();
/*
* The functions we want to expose
*/
MONO_API MonoClass *
mono_class_from_name (MonoImage * image, const char * name_space, const char * name);
MONO_API MonoMethod *
mono_class_get_method_from_name (MonoClass * klass, const char * name, int param_count);
MONO_API MonoClassField *
mono_class_get_field_from_name (MonoClass * klass, const char * name);
MONO_API mono_bool
mono_class_is_assignable_from (MonoClass * klass, MonoClass * oklass);
MONO_API MonoClass *
mono_class_from_mono_type (MonoType * type);
MONO_API mono_bool
mono_class_is_delegate (MonoClass * klass);
MONO_API MonoClass *
mono_class_get_element_class (MonoClass * klass);
MONO_API const char *
mono_class_get_namespace (MonoClass * klass);
MONO_API const char *
mono_class_get_name (MonoClass * klass);
MONO_API MonoClass *
mono_class_get_parent (MonoClass * klass);
MONO_API mono_bool
mono_class_is_subclass_of (MonoClass * klass, MonoClass * klassc, mono_bool check_interfaces);
MONO_API mono_bool
mono_class_is_valuetype (MonoClass * klass);
MONO_API mono_bool
mono_class_is_enum (MonoClass * klass);
MONO_API MonoType *
mono_class_enum_basetype (MonoClass * klass);
MONO_API int32_t
mono_class_value_size (MonoClass * klass, uint32_t * align);
MONO_API MonoType *
mono_class_get_type (MonoClass * klass);
MONO_API gboolean
mono_class_is_nullable (MonoClass * klass);
MONO_API MonoClass *
mono_class_get_nullable_param (MonoClass * klass);
MONO_API char *
mono_method_full_name (MonoMethod * method, mono_bool signature);
MONO_API MonoObject *
mono_runtime_invoke (MonoMethod * method, void * obj, void ** params, MonoObject ** exc);
MONO_API uint32_t
mono_gchandle_new (MonoObject * obj, mono_bool pinned);
MONO_API MonoObject *
mono_gchandle_get_target (uint32_t gchandle);
MONO_API void
mono_gchandle_free (uint32_t gchandle);
MONO_API uint32_t
mono_gchandle_new_weakref (MonoObject * obj, mono_bool track_resurrection);
MONO_API void
mono_raise_exception (MonoException * ex);
MONO_API char*
mono_array_addr_with_size (MonoArray * array, int size, uintptr_t idx);
MONO_API MonoString *
mono_string_new (MonoDomain * domain, const char * text);
MONO_API MonoArray *
mono_array_new (MonoDomain * domain, MonoClass * eclass, uintptr_t n);
MONO_API void *
mono_object_unbox (MonoObject * obj);
MONO_API char *
mono_string_to_utf8 (MonoString * string_obj);
MONO_API MonoObject *
mono_object_new (MonoDomain * domain, MonoClass * klass);
MONO_API uintptr_t
mono_array_length (MonoArray * array);
MONO_API MonoObject *
mono_object_isinst (MonoObject * obj, MonoClass * klass);
MONO_API MonoClass *
mono_object_get_class (MonoObject * obj);
MONO_API MonoMethod *
mono_object_get_virtual_method (MonoObject * obj, MonoMethod * method);
MONO_API void
mono_field_get_value (MonoObject * obj, MonoClassField * field, void * value);
MONO_API MonoObject *
mono_value_box (MonoDomain * domain, MonoClass * klass, void * val);
MONO_API void
mono_gc_wbarrier_set_arrayref (MonoArray * arr, void * slot_ptr, MonoObject * value);
MONO_API void
mono_profiler_install (MonoProfiler * prof, MonoProfileFunc shutdown_callback);
MONO_API void
mono_profiler_install_thread (MonoProfileThreadFunc start, MonoProfileThreadFunc end);
MONO_API void
mono_profiler_install_gc (MonoProfileGCFunc callback, MonoProfileGCResizeFunc heap_resize_callback);
MONO_API void
mono_profiler_load (const char * desc);
MONO_API mono_bool
mono_thread_is_foreign (MonoThread * thread);
MONO_API MonoThread *
mono_thread_current (void);
MONO_API MonoThread *
mono_thread_attach (MonoDomain * domain);
MONO_API mono_bool
mono_thread_detach_if_exiting (void);
MONO_API void
mono_runtime_set_pending_exception (MonoException * exc, mono_bool overwrite);
MONO_API void
mono_set_assemblies_path (const char * path);
MONO_API MonoAssembly *
mono_assembly_open (const char * filename, MonoImageOpenStatus * status);
MONO_API MonoImage *
mono_assembly_get_image (MonoAssembly * assembly);
MONO_API MonoAssemblyName *
mono_assembly_name_new (const char * name);
MONO_API void
mono_assembly_name_free (MonoAssemblyName * aname);
MONO_API MonoAssembly *
mono_assembly_loaded (MonoAssemblyName * aname);
MONO_API void
mono_register_machine_config (const char * config_xml);
MONO_API void
mono_set_dirs (const char * assembly_dir, const char * config_dir);
MONO_API const char *
mono_assembly_name_get_name (MonoAssemblyName * aname);
MONO_API const char *
mono_assembly_name_get_culture (MonoAssemblyName * aname);
MONO_API void
mono_install_assembly_preload_hook (MonoAssemblyPreLoadFunc func, void * user_data);
MONO_API MonoAssemblyName *
mono_assembly_get_name (MonoAssembly * assembly);
MONO_API void
mono_add_internal_call (const char * name, const void * method);
MONO_API void
mono_dangerous_add_raw_internal_call (const char * name, const void * method);
MONO_API MonoMethodSignature *
mono_method_signature (MonoMethod * method);
MONO_API MonoClass *
mono_method_get_class (MonoMethod * method);
MONO_API void
mono_dllmap_insert (MonoImage * assembly, const char * dll, const char * func, const char * tdll, const char * tfunc);
MONO_API MonoDomain *
mono_domain_get (void);
MONO_API MonoClass *
mono_get_intptr_class (void);
MONO_API MonoClass *
mono_get_string_class (void);
MONO_API MonoImage *
mono_get_corlib (void);
MONO_API MonoClass *
mono_get_array_class (void);
MONO_API MonoClass *
mono_get_exception_class (void);
MONO_API MonoDomain *
mono_get_root_domain (void);
MONO_API void
mono_domain_set_config (MonoDomain * domain, const char * base_dir, const char * config_file_name);
MONO_API MonoReflectionAssembly *
mono_assembly_get_object (MonoDomain * domain, MonoAssembly * assembly);
MONO_API MonoReflectionMethod *
mono_method_get_object (MonoDomain * domain, MonoMethod * method, MonoClass * refclass);
MONO_API MonoReflectionType *
mono_type_get_object (MonoDomain * domain, MonoType * type);
MONO_API MonoType *
mono_reflection_type_get_type (MonoReflectionType * reftype);
MONO_API MonoType *
mono_signature_get_params (MonoMethodSignature * sig, void ** iter);
MONO_API mono_bool
mono_type_is_byref (MonoType * type);
MONO_API MonoType *
mono_signature_get_return_type (MonoMethodSignature * sig);
MONO_API int
mono_type_get_type (MonoType * type);
MONO_API void
mono_debug_init (MonoDebugFormat format);
MONO_API void
mono_gc_collect (int generation);
MONO_API mono_bool
mono_is_debugger_attached (void);
MONO_API void
mono_config_parse_memory (const char * buffer);
MONO_API int
mono_gc_max_generation (void);
MONO_API MonoGHashTable *
mono_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, MonoGHashGCType type);
MONO_API gpointer
mono_g_hash_table_lookup (MonoGHashTable * hash, gconstpointer key);
MONO_API void
mono_g_hash_table_insert (MonoGHashTable * hash, gpointer k, gpointer v);
MONO_API MonoException *
mono_get_exception_execution_engine (const char * msg);
MONO_API MonoException *
mono_exception_from_name_msg (MonoImage * image, const char * name_space, const char * name, const char * msg);
MONO_API MonoReferenceQueue *
mono_gc_reference_queue_new (mono_reference_queue_callback callback);
MONO_API void
mono_gc_reference_queue_free (MonoReferenceQueue * queue);
MONO_API gboolean
mono_gc_reference_queue_add (MonoReferenceQueue * queue, MonoObject * obj, void * user_data);
MONO_API void
mono_gc_register_finalizer_callbacks (MonoGCFinalizerCallbacks * callbacks);
MONO_API void
mono_gc_toggleref_add (MonoObject * object, mono_bool strong_ref);
MONO_API void
mono_gc_toggleref_register_callback (MonoToggleRefCallback process_toggleref);
MONO_API gchar *
mono_path_resolve_symlinks (const char * path);
MONO_API void
mono_free (void * ptr);
MONO_API char *
mono_get_runtime_build_info (void);
MONO_API MonoDomain *
mono_jit_init_version (const char * root_domain_name, const char * runtime_version);
MONO_API MonoDomain *
mono_jit_init (const char * file);
MONO_API int
mono_jit_exec (MonoDomain * domain, MonoAssembly * assembly, int argc, const char** argv);
MONO_API void
mono_jit_parse_options (int argc, char** argv);
MONO_API void
mono_jit_set_aot_mode (MonoAotMode mode);
MONO_API void
mono_set_signal_chaining (mono_bool chain_signals);
MONO_API void
mono_set_crash_chaining (mono_bool chain_signals);
MONO_API void
mono_jit_set_trace_options (const char * option);
MONO_API void*
mono_jit_thread_attach (MonoDomain * domain);
MONO_API gboolean
mono_exception_walk_trace (MonoException * exc, MonoExceptionFrameWalk func, gpointer user_data);
MONO_API void
mono_install_unhandled_exception_hook (MonoUnhandledExceptionFunc func, gpointer user_data);
MONO_API int
mono_main (int argc, char ** argv);
MONO_API void
mono_install_load_aot_data_hook (MonoLoadAotDataFunc load_func, MonoFreeAotDataFunc free_func, gpointer user_data);
MONO_API gboolean
mini_parse_debug_option (const char * option);
MONO_API void
mono_trace_set_log_handler (MonoLogCallback callback, void * user_data);
MONO_API void
mono_trace_set_print_handler (MonoPrintCallback callback);
MONO_API void
mono_trace_set_printerr_handler (MonoPrintCallback callback);
MONO_API void*
mono_threads_enter_gc_unsafe_region (void ** stackdata);
MONO_API void
mono_threads_exit_gc_unsafe_region (void * cookie, void ** stackdata);
MONO_API void*
mono_threads_enter_gc_safe_region (void ** stackdata);
MONO_API void
mono_threads_exit_gc_safe_region (void * cookie, void ** stackdata);
MONO_API void
mono_threads_assert_gc_safe_region (void);
MONO_API void
mono_threads_assert_gc_unsafe_region (void);
MONO_API void
mono_threads_assert_gc_starting_region (void);
MONO_API void*
mono_thread_info_current_unchecked (void);
MONO_API void *
mono_threads_attach_coop (MonoDomain * domain, gpointer* dummy);
MONO_API void *
mono_threads_detach_coop (gpointer cookie, gpointer* dummy);
MONO_API void
mono_install_ftnptr_eh_callback (MonoFtnPtrEHCallback callback);
bool
mono_class_is_nullable_exists ();
bool
mono_class_get_nullable_param_exists ();
bool
mono_runtime_set_pending_exception_exists ();
bool
mono_dangerous_add_raw_internal_call_exists ();
bool
mono_install_load_aot_data_hook_exists ();
bool
mini_parse_debug_option_exists ();
bool
mono_threads_enter_gc_unsafe_region_exists ();
bool
mono_threads_exit_gc_unsafe_region_exists ();
bool
mono_threads_enter_gc_safe_region_exists ();
bool
mono_threads_exit_gc_safe_region_exists ();
bool
mono_threads_assert_gc_safe_region_exists ();
bool
mono_threads_assert_gc_unsafe_region_exists ();
bool
mono_threads_assert_gc_starting_region_exists ();
bool
mono_thread_info_current_unchecked_exists ();
bool
mono_threads_attach_coop_exists ();
bool
mono_threads_detach_coop_exists ();
bool
mono_install_ftnptr_eh_callback_exists ();
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __MONO_RUNTIME__ */

Просмотреть файл

@ -0,0 +1,100 @@
// vim: set filetype=c :
//
// delegates.h:
//
// Authors:
// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright 2018 Microsoft Inc.
//
/* Functions calling into ObjCRuntime.Runtime */
#ifndef __RUNTIME_GENERATED_H__
#define __RUNTIME_GENERATED_H__
#include "xamarin.h"
#ifdef __cplusplus
extern "C" {
#endif
void
xamarin_throw_ns_exception (NSException * exc);
void
xamarin_rethrow_managed_exception (guint32 original_exception_gchandle, guint32 *exception_gchandle);
int
xamarin_create_ns_exception (NSException * exc, guint32 *exception_gchandle);
NSException *
xamarin_unwrap_ns_exception (int exc_handle, guint32 *exception_gchandle);
MonoObject *
xamarin_create_block_proxy (MonoObject * method, void * block, guint32 *exception_gchandle);
id
xamarin_create_delegate_proxy (MonoObject * method, MonoObject * block, const char * signature, unsigned int token_ref, guint32 *exception_gchandle);
MonoObject *
xamarin_get_class (Class ptr, guint32 *exception_gchandle);
MonoObject *
xamarin_get_selector (SEL ptr, guint32 *exception_gchandle);
bool
xamarin_has_nsobject (id obj, guint32 *exception_gchandle);
id
xamarin_get_handle_for_inativeobject (MonoObject * obj, guint32 *exception_gchandle);
void
xamarin_unregister_nsobject (id native_obj, MonoObject * managed_obj, guint32 *exception_gchandle);
MonoObject *
xamarin_try_get_or_construct_nsobject (id obj, guint32 *exception_gchandle);
MonoObject *
xamarin_get_inative_object_dynamic (id obj, bool owns, void * type, guint32 *exception_gchandle);
MonoReflectionMethod *
xamarin_get_method_from_token (unsigned int token_ref, guint32 *exception_gchandle);
MonoReflectionMethod *
xamarin_get_generic_method_from_token (MonoObject * obj, unsigned int token_ref, guint32 *exception_gchandle);
MonoObject *
xamarin_get_inative_object_static (id obj, bool owns, unsigned int iface_token_ref, unsigned int implementation_token_ref, guint32 *exception_gchandle);
MonoObject *
xamarin_get_nsobject_with_type (id obj, void * type, int32_t * created, SEL selector, MonoReflectionMethod * method, guint32 *exception_gchandle);
void
xamarin_dispose (MonoObject * mobj, guint32 *exception_gchandle);
guint32
xamarin_create_product_exception_for_error (int code, const char * message, guint32 *exception_gchandle);
char *
xamarin_reflection_type_get_full_name (MonoReflectionType * type, guint32 *exception_gchandle);
char *
xamarin_lookup_managed_type_name (Class klass, guint32 *exception_gchandle);
enum MarshalManagedExceptionMode
xamarin_on_marshal_managed_exception (int exception, guint32 *exception_gchandle);
enum MarshalObjectiveCExceptionMode
xamarin_on_marshal_objectivec_exception (id exception, bool throwManagedAsDefault, guint32 *exception_gchandle);
int32_t
xamarin_create_runtime_exception (int32_t code, const char * message, guint32 *exception_gchandle);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __RUNTIME_GENERATED_H__ */

Просмотреть файл

@ -0,0 +1,377 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* runtime.h: This header contains definitions used by Xamarin when building applications.
* Do not consider anything here stable API (unless otherwise specified),
* it will change between releases.
*
* Authors: Rolf Bjarne Kvinge
*
* Copyright (C) 2014 Xamarin Inc. (www.xamarin.com)
*
*/
#ifndef __XAMARIN_RUNTIME__
#define __XAMARIN_RUNTIME__
#include <stdbool.h>
#include <Foundation/Foundation.h>
#include "main.h"
#include "mono-runtime.h"
#include "runtime-generated.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
const char *name;
const char *type;
int size;
int align;
} MTIvar;
typedef struct {
const char *selector;
const char *signature;
int isstatic;
void *trampoline;
} MTMethod;
typedef struct {
const char *name;
const char *supername;
int ivar_count;
int method_count;
int prop_count;
} MTClass;
typedef struct {
const char *name;
const char *type;
const char *argument_semantic;
} MTProperty;
// This structure completely describes everything required to resolve a metadata token
typedef struct MTFullTokenReference {
const char *assembly_name; /* the name of the assembly */
uint32_t module_token;
uint32_t token;
} MTFullTokenReference;
// This structure is packed to be exactly 32 bits
// If 'is_full_reference' is 1, then the remaining bits are an index into a table of MTFullTokenReference.
typedef struct __attribute__((packed)) {
uint8_t is_full_reference:1;
uint8_t assembly_index:7; /* 0-based index into the '__xamarin_registration_assemblies' array. Max 127 (registered) assemblies before a full token reference has to be used */
uint32_t token:24; /* RID of the corresponding metadata token. The exact type of metadata token depends on the context where the token reference is used. */
} MTTokenReference;
static const uint32_t INVALID_TOKEN_REF = 0xFFFFFFFF;
enum MTTypeFlags {
MTTypeFlagsNone = 0,
MTTypeFlagsCustomType = 1, // not a platform type
MTTypeFlagsUserType = 2, // not a wrapped type
};
typedef struct __attribute__((packed)) {
void *handle;
uint32_t /* MTTokenReference */ type_reference;
uint32_t /* MTTypeFlags */ flags;
} MTClassMap;
typedef struct __attribute__((packed)) {
uint32_t /* MTTokenReference */ skipped_reference;
uint32_t /* MTTokenReference */ actual_reference;
} MTManagedClassMap;
typedef struct __attribute__((packed)) {
uint32_t protocol_token;
uint32_t wrapper_token;
} MTProtocolWrapperMap;
typedef struct __attribute__((packed)) {
const uint32_t *protocol_tokens; // an array of token references to managed interfaces that represent protocols
// __unsafe_unretained needed to prevent "error: pointer to non-const type 'const Protocol *' with no explicit ownership" in Embeddinator
const __unsafe_unretained Protocol * const * protocols; // the corresponding native protocols
} MTProtocolMap;
struct MTRegistrationMap;
struct MTRegistrationMap {
const char **assembly;
MTClassMap *map;
const MTFullTokenReference *full_token_references;
// There are some managed types that are not registered because their ObjC
// class is already registered for a different managed type. For instance:
// The managed type "Foundation.NSArray<T>"" is not registered, because
// its ObjC class would be NSArray, which is already registered to
// "Foundation.NSArray". In order to be able to map all managed types to
// ObjC types we need to know which other managed type is the main type
// for the ObjC type (an alternative would be to map it directly to the
// ObjC class, but this is not a constant known at compile time, which
// means it can't be stored in read-only memory).
const MTManagedClassMap *skipped_map;
const MTProtocolWrapperMap *protocol_wrappers; // array of MTProtocolWrapperMap, sorted ascending by protocol_token
const MTProtocolMap protocols;
int assembly_count;
int map_count;
int full_token_reference_count;
int skipped_map_count;
int protocol_wrapper_count;
int protocol_count;
};
typedef struct {
MonoReflectionType *original_type;
} BindAsData;
typedef struct {
MonoReflectionMethod *method;
int32_t semantic;
int32_t bindas_count; // The number of elements available in the bindas_types array.
// An array of BindAs original types. Element 0 is for the return value,
// the rest are for parameters (parameters start at 1 even for void methods).
// The array must contain space for the return value and all the parameters,
// even for those that don't have BindAs attributes (the original_type entry will be NULL).
BindAsData bindas[];
} MethodDescription;
// This has a managed equivalent in NSObject2.cs
enum NSObjectFlags {
NSObjectFlagsDisposed = 1,
NSObjectFlagsNativeRef = 2,
NSObjectFlagsIsDirectBinding = 4,
NSObjectFlagsRegisteredToggleRef = 8,
NSObjectFlagsInFinalizerQueue = 16,
NSObjectFlagsHasManagedRef = 32,
// 64, // Used by SoM
NSObjectFlagsIsCustomType = 128,
};
struct AssemblyLocation {
const char *assembly_name; // base name (without extension) of the assembly
const char *location; // the directory where the assembly is
};
struct AssemblyLocations {
int length;
struct AssemblyLocation *locations;
};
void xamarin_initialize ();
void xamarin_initialize_embedded (); /* Public API, must not change - this is used by the embeddinator */
void xamarin_assertion_message (const char *msg, ...) __attribute__((__noreturn__));
const char * xamarin_get_bundle_path (); /* Public API */
// Sets the bundle path (where the managed executable is). By default APP/Contents/MonoBundle.
void xamarin_set_bundle_path (const char *path); /* Public API */
MonoObject * xamarin_get_managed_object_for_ptr (id self, guint32 *exception_gchandle);
MonoObject * xamarin_get_managed_object_for_ptr_fast (id self, guint32 *exception_gchandle);
void xamarin_check_for_gced_object (MonoObject *obj, SEL sel, id self, MonoMethod *method, guint32 *exception_gchandle);
int xamarin_objc_type_size (const char *type);
bool xamarin_is_class_nsobject (MonoClass *cls);
bool xamarin_is_class_inativeobject (MonoClass *cls);
bool xamarin_is_class_array (MonoClass *cls);
bool xamarin_is_class_nsnumber (MonoClass *cls);
bool xamarin_is_class_nsvalue (MonoClass *cls);
bool xamarin_is_class_nsstring (MonoClass *cls);
bool xamarin_is_class_nullable (MonoClass *cls, MonoClass **element_type, guint32 *exception_gchandle);
MonoClass * xamarin_get_nullable_type (MonoClass *cls, guint32 *exception_gchandle);
MonoType * xamarin_get_parameter_type (MonoMethod *managed_method, int index);
MonoObject * xamarin_get_nsobject_with_type_for_ptr (id self, bool owns, MonoType* type, SEL selector, MonoMethod *managed_method, guint32 *exception_gchandle);
MonoObject * xamarin_get_nsobject_with_type_for_ptr_created (id self, bool owns, MonoType *type, int32_t *created, SEL selector, MonoMethod *managed_method, guint32 *exception_gchandle);
int * xamarin_get_delegate_for_block_parameter (MonoMethod *method, guint32 token_ref, int par, void *nativeBlock, guint32 *exception_gchandle);
id xamarin_get_block_for_delegate (MonoMethod *method, MonoObject *delegate, const char *signature /* NULL allowed, but requires the dynamic registrar at runtime to compute */, guint32 token_ref /* INVALID_TOKEN_REF allowed, but requires the dynamic registrar at runtime */, guint32 *exception_gchandle);
id xamarin_get_nsobject_handle (MonoObject *obj);
void xamarin_set_nsobject_handle (MonoObject *obj, id handle);
uint8_t xamarin_get_nsobject_flags (MonoObject *obj);
void xamarin_set_nsobject_flags (MonoObject *obj, uint8_t flags);
void xamarin_throw_nsexception (MonoException *exc);
void xamarin_rethrow_managed_exception (guint32 original_gchandle, guint32 *exception_gchandle);
MonoException * xamarin_create_exception (const char *msg);
id xamarin_get_handle (MonoObject *obj, guint32 *exception_gchandle);
char * xamarin_strdup_printf (const char *msg, ...);
void * xamarin_calloc (size_t size);
void xamarin_free (void *ptr);
MonoMethod * xamarin_get_reflection_method_method (MonoReflectionMethod *method);
MonoMethod * xamarin_get_managed_method_for_token (guint32 token_ref, guint32 *exception_gchandle);
void xamarin_framework_peer_lock ();
void xamarin_framework_peer_unlock ();
bool xamarin_file_exists (const char *path);
MonoAssembly * xamarin_open_and_register (const char *path, guint32 *exception_gchandle);
void xamarin_unhandled_exception_handler (MonoObject *exc, gpointer user_data);
void xamarin_ftnptr_exception_handler (guint32 gchandle);
void xamarin_create_classes ();
const char * xamarin_skip_encoding_flags (const char *encoding);
void xamarin_add_registration_map (struct MTRegistrationMap *map, bool partial);
uint32_t xamarin_find_protocol_wrapper_type (uint32_t token_ref);
void xamarin_release_block_on_main_thread (void *obj);
bool xamarin_has_managed_ref (id self);
bool xamarin_has_managed_ref_safe (id self);
void xamarin_switch_gchandle (id self, bool to_weak);
int xamarin_get_gchandle (id self);
void xamarin_free_gchandle (id self, int gchandle);
void xamarin_clear_gchandle (id self);
int xamarin_get_gchandle_with_flags (id self);
void xamarin_set_gchandle (id self, int gchandle);
void xamarin_create_gchandle (id self, void *managed_object, int flags, bool force_weak);
void xamarin_create_managed_ref (id self, void * managed_object, bool retain);
void xamarin_release_managed_ref (id self, MonoObject *managed_obj);
void xamarin_notify_dealloc (id self, int gchandle);
int xamarin_main (int argc, char *argv[], enum XamarinLaunchMode launch_mode);
char * xamarin_type_get_full_name (MonoType *type, guint32 *exception_gchandle); // return value must be freed with 'mono_free'
char * xamarin_class_get_full_name (MonoClass *klass, guint32 *exception_gchandle); // return value must be freed with 'mono_free'
#if DEBUG
void xamarin_verify_parameter (MonoObject *obj, SEL sel, id self, id arg, int index, MonoClass *expected, MonoMethod *method);
void xamarin_check_objc_type (id obj, Class expected_class, SEL sel, id self, int index, MonoMethod *method);
#endif
void xamarin_set_gc_pump_enabled (bool value);
typedef void (*XamarinUnhandledExceptionFunc) (MonoObject *exc, const char *type_name, const char *message, const char *trace);
void xamarin_install_unhandled_exception_hook (XamarinUnhandledExceptionFunc func);
void xamarin_process_nsexception (NSException *exc);
void xamarin_process_nsexception_using_mode (NSException *ns_exception, bool throwManagedAsDefault);
void xamarin_process_managed_exception (MonoObject *exc);
void xamarin_process_managed_exception_gchandle (guint32 gchandle);
void xamarin_throw_product_exception (int code, const char *message);
guint32 xamarin_create_product_exception (int code, const char *message);
NSString * xamarin_print_all_exceptions (MonoObject *exc);
id xamarin_invoke_objc_method_implementation (id self, SEL sel, IMP xamarin_impl);
MonoClass * xamarin_get_nsnumber_class ();
MonoClass * xamarin_get_nsvalue_class ();
bool xamarin_is_managed_exception_marshaling_disabled ();
const char * xamarin_find_assembly_directory (const char *assembly_name);
void xamarin_set_assembly_directories (struct AssemblyLocations *directories);
void xamarin_get_assembly_name_without_extension (const char *aname, char *name, int namelen);
bool xamarin_locate_assembly_resource_for_name (MonoAssemblyName *assembly_name, const char *resource, char *path, int pathlen);
bool xamarin_locate_assembly_resource (const char *assembly_name, const char *culture, const char *resource, char *path, int pathlen);
// this functions support NSLog/NSString-style format specifiers.
void xamarin_printf (const char *format, ...);
void xamarin_vprintf (const char *format, va_list args);
void xamarin_install_log_callbacks ();
/*
* Look for an assembly in the app and open it.
*
* Stable API.
*/
MonoAssembly * xamarin_open_assembly (const char *name);
#if defined(__arm__) || defined(__aarch64__)
void mono_aot_register_module (void *aot_info);
#endif
typedef void (*xamarin_register_module_callback) ();
typedef void (*xamarin_register_assemblies_callback) ();
extern xamarin_register_module_callback xamarin_register_modules;
extern xamarin_register_assemblies_callback xamarin_register_assemblies;
#ifdef __cplusplus
class XamarinObject {
public:
id native_object;
int gc_handle;
~XamarinObject ();
};
#endif
#ifdef __OBJC__
@interface XamarinAssociatedObject : NSObject {
@public
id native_object;
int gc_handle;
}
-(void) dealloc;
@end
@interface NSObject (NonXamarinObject)
-(int) xamarinGetGCHandle;
@end
#endif
// Coop GC helper API
#if !TARGET_OS_WATCH
#define MONO_ENTER_GC_UNSAFE
#define MONO_EXIT_GC_UNSAFE
#define MONO_ENTER_GC_SAFE
#define MONO_EXIT_GC_SAFE
#define MONO_ASSERT_GC_SAFE
#define MONO_ASSERT_GC_SAFE_OR_DETACHED
#define MONO_ASSERT_GC_UNSAFE
#define MONO_ASSERT_GC_STARTING
#else
#define MONO_ENTER_GC_UNSAFE \
do { \
gpointer __dummy; \
gpointer __gc_unsafe_cookie = mono_threads_enter_gc_unsafe_region (&__dummy) \
#define MONO_EXIT_GC_UNSAFE \
mono_threads_exit_gc_unsafe_region (__gc_unsafe_cookie, &__dummy); \
} while (0)
#define MONO_ENTER_GC_SAFE \
do { \
gpointer __dummy; \
gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__dummy) \
#define MONO_EXIT_GC_SAFE \
mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__dummy); \
} while (0)
//#if DEBUG
#define MONO_ASSERT_GC_SAFE mono_threads_assert_gc_safe_region ()
#define MONO_ASSERT_GC_SAFE_OR_DETACHED \
do { \
if (mono_thread_info_current_unchecked ()) \
mono_threads_assert_gc_safe_region (); \
} while (0)
#define MONO_ASSERT_GC_UNSAFE mono_threads_assert_gc_unsafe_region ()
#define MONO_ASSERT_GC_STARTING
// There's no way to assert STARTING, tls values inside mono aren't initialized so mono's API end up accessing random memory, and thus randomly asserting // mono_threads_assert_gc_starting_region ()
//#else
// #define MONO_ASSERT_GC_SAFE
// #define MONO_ASSERT_GC_UNSAFE
//#endif /* DEBUG */
#endif /* !TARGET_OS_WATCH */
// Once we have one mono clone again the TARGET_OS_WATCH
// condition should be removed (DYNAMIC_MONO_RUNTIME should still
// be here though).
#if TARGET_OS_WATCH && !defined (DYNAMIC_MONO_RUNTIME)
#define MONO_THREAD_ATTACH \
do { \
gpointer __thread_dummy; \
gpointer __thread_cookie = mono_threads_attach_coop (NULL, &__thread_dummy) \
#define MONO_THREAD_DETACH \
mono_threads_detach_coop (__thread_cookie, &__thread_dummy); \
} while (0)
#else
#define MONO_THREAD_ATTACH \
do { \
mono_jit_thread_attach (NULL) \
#define MONO_THREAD_DETACH \
} while (0)
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __XAMARIN_RUNTIME__ */

Просмотреть файл

@ -0,0 +1,201 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors: Rolf Bjarne Kvinge
*
* Copyright (C) 2014 Xamarin Inc. (www.xamarin.com)
*
*/
#ifndef __TRAMPOLINES_H__
#define __TRAMPOLINES_H__
#ifdef __cplusplus
extern "C" {
#endif
void * xamarin_trampoline (id self, SEL sel, ...);
void xamarin_stret_trampoline (void *buffer, id self, SEL sel, ...);
float xamarin_fpret_single_trampoline (id self, SEL sel, ...);
double xamarin_fpret_double_trampoline (id self, SEL sel, ...);
void xamarin_release_trampoline (id self, SEL sel);
void xamarin_calayer_release_trampoline (id self, SEL sel);
id xamarin_retain_trampoline (id self, SEL sel);
void xamarin_dealloc_trampoline (id self, SEL sel);
void * xamarin_static_trampoline (id self, SEL sel, ...);
void * xamarin_ctor_trampoline (id self, SEL sel, ...);
void xamarin_x86_double_abi_stret_trampoline ();
float xamarin_static_fpret_single_trampoline (id self, SEL sel, ...);
double xamarin_static_fpret_double_trampoline (id self, SEL sel, ...);
void xamarin_static_stret_trampoline (void *buffer, id self, SEL sel, ...);
void xamarin_static_x86_double_abi_stret_trampoline ();
long long xamarin_longret_trampoline (id self, SEL sel, ...);
long long xamarin_static_longret_trampoline (id self, SEL sel, ...);
id xamarin_copyWithZone_trampoline1 (id self, SEL sel, NSZone *zone);
id xamarin_copyWithZone_trampoline2 (id self, SEL sel, NSZone *zone);
int xamarin_get_gchandle_trampoline (id self, SEL sel);
void xamarin_set_gchandle_trampoline (id self, SEL sel, int gc_handle);
int xamarin_get_frame_length (id self, SEL sel);
enum ArgumentSemantic /* Xcode 4.4 doesn't like this ': int' */ {
ArgumentSemanticNone = -1,
ArgumentSemanticAssign = 0,
ArgumentSemanticCopy = 1,
ArgumentSemanticRetain = 2,
ArgumentSemanticMask = ArgumentSemanticAssign | ArgumentSemanticCopy | ArgumentSemanticRetain,
ArgumentSemanticRetainReturnValue = 1 << 10,
ArgumentSemanticCategoryInstance = 1 << 11,
};
/* Conversion functions */
// The xamarin_id_to_managed_func and xamarin_managed_to_id_func typedefs
// represents functions to convert to/from id and managed types.
//
// The `value` parameter is the value to convert.
//
// The `ptr` parameter is optional, if passed the resulting value type will be
// stored here. If NULL, memory is allocated and returned, and the return
// value must be freed using `xamarin_free`.
//
// The `managedType` parameter is the managed type to convert to.
//
// The `context` parameter is a conversion-specific value that may or may not
// be provided:
// * Smart enum conversions: The `context` parameter represents a token ref to
// the conversion method. The static registrar bakes those token refs in to
// the generated code, thus avoiding the need for finding the conversion
// method at runtime).
// * Other conversions: The `context` parameter is not used in other
// conversions at the moment.
//
// The `exception_gchandle` parameter is required, and will contain a GCHandle
// to any exceptions that occur.
//
// The return value is:
// * xamarin_id_to_managed_func: a pointer to the resulting value type. If
// `ptr` was passed, this value is also returned, otherwise newly allocated
// memory is returned (which must be freed with `xamarin_free`). If an
// exception occurs, 'ptr' is returned (and no memory allocated).
// * xamarin_managed_to_id_func: the resulting Objective-C object.
typedef void * (*xamarin_id_to_managed_func) (id value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
typedef id (*xamarin_managed_to_id_func) (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_generate_conversion_to_native (MonoObject *value, MonoType *inputType, MonoType *outputType, MonoMethod *method, guint32 context, guint32 *exception_gchandle);
void * xamarin_generate_conversion_to_managed (id value, MonoType *inputType, MonoType *outputType, MonoMethod *method, guint32 *exception_gchandle, guint32 context, /*SList*/ void **free_list);
NSNumber * xamarin_convert_managed_to_nsnumber (MonoObject *value, MonoClass *managedType, MonoMethod *method, guint32 context, guint32 *exception_gchandle);
NSValue * xamarin_convert_managed_to_nsvalue (MonoObject *value, MonoClass *managedType, MonoMethod *method, guint32 context, guint32 *exception_gchandle);
NSString * xamarin_convert_managed_to_nsstring (MonoObject *value, MonoType *managedType, MonoType *nativeType, MonoMethod *method, guint32 *exception_gchandle);
MonoObject * xamarin_convert_nsnumber_to_managed (NSNumber *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle);
MonoObject * xamarin_convert_nsvalue_to_managed (NSValue *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle);
MonoObject * xamarin_convert_nsstring_to_managed (NSString *value, MonoType *nativeType, MonoType *managedType, MonoMethod *method, guint32 *exception_gchandle);
guint32 xamarin_create_bindas_exception (MonoType *inputType, MonoType *outputType, MonoMethod *method);
xamarin_id_to_managed_func xamarin_get_nsnumber_to_managed_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_managed_to_id_func xamarin_get_managed_to_nsnumber_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_id_to_managed_func xamarin_get_nsvalue_to_managed_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_managed_to_id_func xamarin_get_managed_to_nsvalue_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_id_to_managed_func xamarin_get_nsstring_to_smart_enum_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
xamarin_managed_to_id_func xamarin_get_smart_enum_to_nsstring_func (MonoClass *managedType, MonoMethod *method, guint32 *exception_gchandle);
NSArray * xamarin_convert_managed_to_nsarray_with_func (MonoArray *array, xamarin_managed_to_id_func convert, guint32 context, guint32 *exception_gchandle);
MonoArray * xamarin_convert_nsarray_to_managed_with_func (NSArray *array, MonoClass *managedElementType, xamarin_id_to_managed_func convert, guint32 context, guint32 *exception_gchandle);
void * xamarin_nsstring_to_smart_enum (id value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void * xamarin_smart_enum_to_nsstring (MonoObject *value, guint32 context /* token ref */, guint32 *exception_gchandle);
// Returns a pointer to the value type, which must be freed using xamarin_free.
void *xamarin_nsnumber_to_bool (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_sbyte (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_byte (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_short (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_ushort (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_int (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_uint (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_long (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_ulong (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_nint (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_nuint (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_float (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_double (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
void *xamarin_nsnumber_to_nfloat (NSNumber *number, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_gchandle);
// Returns a pointer to the value type, which must be freed using xamarin_free
void *xamarin_nsvalue_to_nsrange (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgaffinetransform (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgpoint (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgrect (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgsize (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cgvector (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_catransform3d (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cllocationcoordinate2d (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cmtime (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cmtimemapping (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_cmtimerange (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_mkcoordinatespan (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_scnmatrix4 (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_scnvector3 (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_scnvector4 (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_uiedgeinsets (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_uioffset (NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
void *xamarin_nsvalue_to_nsdirectionaledgeinsets(NSValue *value, void *ptr, MonoClass *managedType, guint32 context, guint32 *exception_ghandle);
id xamarin_bool_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_sbyte_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_byte_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_short_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_ushort_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_int_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_uint_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_long_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_ulong_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nint_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nuint_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_float_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_double_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nfloat_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nfloat_to_nsnumber (MonoObject *value, guint32 contxt, guint32 *exception_gchandle);
id xamarin_nsrange_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgaffinetransform_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgpoint_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgrect_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgsize_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cgvector_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_catransform3d_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cllocationcoordinate2d_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cmtime_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cmtimemapping_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_cmtimerange_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_mkcoordinatespan_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_scnmatrix4_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_scnvector3_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_scnvector4_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_uiedgeinsets_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_uioffset_to_nsvalue (MonoObject *value, guint32 context, guint32 *exception_gchandle);
id xamarin_nsdirectionaledgeinsets_to_nsvalue(MonoObject *value, guint32 context, guint32 *exception_gchandle);
/* Copied from SGen */
static inline void
mt_dummy_use (void *v) {
#if defined(__GNUC__)
__asm__ volatile ("" : "=r"(v) : "r"(v));
#elif defined(_MSC_VER)
__asm {
mov eax, v;
and eax, eax;
};
#else
#error "Implement mt_dummy_use for your compiler"
#endif
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __TRAMPOLINES_H__ */

Просмотреть файл

@ -0,0 +1,18 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors: Rolf Bjarne Kvinge
*
* Copyright (C) 2014 Xamarin Inc. (www.xamarin.com)
*
*/
#ifndef __XAMARIN_H__
#define __XAMARIN_H__
#include "main.h"
#include "mono-runtime.h"
#include "runtime.h"
#include "runtime-generated.h"
#include "trampolines.h"
#endif /* __XAMARIN_H__ */

Просмотреть файл

@ -1289,7 +1289,7 @@ namespace Registrar {
internal const string INativeObject = "INativeObject";
}
internal string PlatformAssembly {
public string PlatformAssembly {
get {
return IsDualBuild ? DualAssemblyName : CompatAssemblyName;
}

Просмотреть файл

@ -464,7 +464,16 @@ namespace Xamarin.Bundler {
#if MONOTOUCH
BuildTarget = BuildTarget.Simulator;
#endif
var registrar = new Registrar.StaticRegistrar (this);
Registrar.IStaticRegistrar registrar;
#if MMP
if (Driver.IsClassic) {
registrar = new Registrar.ClassicStaticRegistrar (this);
} else {
registrar = new Registrar.StaticRegistrar (this);
}
#else
registrar = new Registrar.StaticRegistrar (this);
#endif
if (RootAssemblies.Count == 1)
registrar.GenerateSingleAssembly (resolvedAssemblies.Values, Path.ChangeExtension (registrar_m, "h"), registrar_m, Path.GetFileNameWithoutExtension (RootAssembly));
else

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -13,7 +13,7 @@ namespace Xamarin.Tuner
{
public class DerivedLinkContext : LinkContext
{
internal StaticRegistrar StaticRegistrar;
internal IStaticRegistrar StaticRegistrar;
internal Target Target;
Symbols required_symbols;

Просмотреть файл

@ -42,7 +42,15 @@ namespace Xamarin.Bundler
hdr.WriteLine ("#define DEBUG 1");
hdr.WriteLine ("#include <stdarg.h>");
#if MMP
if (Driver.IsClassic) {
hdr.WriteLine ("#include <xamarin-classic/xamarin.h>");
} else {
hdr.WriteLine ("#include <xamarin/xamarin.h>");
}
#else
hdr.WriteLine ("#include <xamarin/xamarin.h>");
#endif
hdr.WriteLine ("#include <objc/objc.h>");
hdr.WriteLine ("#include <objc/runtime.h>");
hdr.WriteLine ("#include <objc/message.h>");

Просмотреть файл

@ -205,7 +205,23 @@ namespace Registrar {
}
}
class StaticRegistrar : Registrar
interface IStaticRegistrar
{
bool HasAttribute (ICustomAttributeProvider provider, string @namespace, string name, bool inherits = false);
bool HasProtocolAttribute (TypeReference type);
RegisterAttribute GetRegisterAttribute (TypeReference type);
ProtocolAttribute GetProtocolAttribute (TypeReference type);
string GetExportedTypeName (TypeReference type, RegisterAttribute register_attribute);
void GenerateSingleAssembly (IEnumerable<AssemblyDefinition> assemblies, string header_path, string source_path, string assembly);
void Generate (IEnumerable<AssemblyDefinition> assemblies, string header_path, string source_path);
string ComputeSignature (TypeReference DeclaringType, MethodDefinition Method, Registrar.ObjCMember member = null, bool isCategoryInstance = false, bool isBlockSignature = false);
string ComputeSignature (TypeReference declaring_type, bool is_ctor, TypeReference return_type, TypeReference [] parameters, MethodDefinition mi = null, Registrar.ObjCMember member = null, bool isCategoryInstance = false, bool isBlockSignature = false);
bool MapProtocolMember (MethodDefinition method, out MethodDefinition extensionMethod);
string PlatformAssembly { get; }
Dictionary<ICustomAttribute, MethodDefinition> ProtocolMemberMethodMap { get; }
}
class StaticRegistrar : Registrar, IStaticRegistrar
{
Dictionary<ICustomAttribute, MethodDefinition> protocol_member_method_map;

Просмотреть файл

@ -44,7 +44,7 @@ namespace Xamarin.Bundler {
public HashSet<string> Frameworks = new HashSet<string> ();
public HashSet<string> WeakFrameworks = new HashSet<string> ();
internal StaticRegistrar StaticRegistrar { get; set; }
internal IStaticRegistrar StaticRegistrar { get; set; }
// If we didn't link because the existing (cached) assemblyes are up-to-date.
bool cached_link = false;
@ -62,7 +62,15 @@ namespace Xamarin.Bundler {
public Target (Application app)
{
this.App = app;
#if MMP
if (Driver.IsClassic) {
this.StaticRegistrar = new ClassicStaticRegistrar (this);
} else {
this.StaticRegistrar = new StaticRegistrar (this);
}
#else
this.StaticRegistrar = new StaticRegistrar (this);
#endif
}
// This will find the link context, possibly looking in container targets.

Просмотреть файл

@ -70,7 +70,7 @@ namespace Xamarin.Bundler {
internal const string NAME = "mmp";
const string PRODUCT = "Xamarin.Mac";
internal static Application App = new Application (Environment.GetCommandLineArgs ());
static Target BuildTarget = new Target (App);
static Target BuildTarget;
static List<string> references = new List<string> ();
static List<string> resources = new List<string> ();
static List<string> resolved_assemblies = new List<string> ();
@ -500,6 +500,7 @@ namespace Xamarin.Bundler {
else
Profile.Current = new MacMobileProfile (arch == "x86_64" ? 64 : 32);
BuildTarget = new Target (App);
App.InitializeCommon ();
Log ("Xamarin.Mac {0}.{1}", Constants.Version, Constants.Revision);
@ -795,8 +796,6 @@ namespace Xamarin.Bundler {
ExtractNativeLinkInfo ();
BuildTarget.StaticRegistrar = new StaticRegistrar (BuildTarget);
BuildTarget.ValidateAssembliesBeforeLink ();
if (!no_executable) {
@ -1065,7 +1064,11 @@ namespace Xamarin.Bundler {
var sb = new StringBuilder ();
using (var sw = new StringWriter (sb)) {
sw.WriteLine ("#define MONOMAC 1");
sw.WriteLine ("#include <xamarin/xamarin.h>");
if (IsClassic) {
sw.WriteLine ("#include <xamarin-classic/xamarin.h>");
} else {
sw.WriteLine ("#include <xamarin/xamarin.h>");
}
sw.WriteLine ("#import <AppKit/NSAlert.h>");
sw.WriteLine ("#import <Foundation/NSDate.h>"); // 10.7 wants this even if not needed on 10.9
if (Driver.Registrar == RegistrarMode.PartialStatic)

Просмотреть файл

@ -385,6 +385,9 @@
<Compile Include="..\linker\CustomSymbolWriter.cs">
<Link>Xamarin.Linker\CustomSymbolWriter.cs</Link>
</Compile>
<Compile Include="..\common\ClassicStaticRegistrar.cs">
<Link>external\ClassicStaticRegistrar.cs</Link>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>