7#include <mono/jit/jit.h>
8#include <mono/metadata/environment.h>
9#include <mono/metadata/mono-config.h>
10#include <mono/metadata/threads.h>
16#include "arcane/utils/PlatformUtils.h"
17#include "arcane/utils/String.h"
18#include "arcane/utils/CommandLineArguments.h"
19#include "arcane/Concurrency.h"
20#include "arcane/ObserverPool.h"
24bool dotnet_verbose =
false;
25bool global_is_running =
false;
32extern "C" int mono_main(
int argc,
char* argv[]);
42 m_observers.
addObserver(
this,&ArcaneMonoThreadAttachCallback::_callback,
48#ifndef ARCANE_MONO_NO_THREAD_ATTACH
50 std::cout <<
"MONO_THREAD_ATTACH CALLBACK !\n";
51 mono_thread_attach (mono_get_root_domain ());
62_arcane_mono_main_internal(
int argc,
char* argv[],
const char* assembly_name)
64 if (global_is_running)
66 global_is_running =
true;
67 int new_argc = argc+1;
68 char** new_argv =
new char*[new_argc+1];
69 new_argv[0] = strdup(argv[0]);
70 for(
int i=1; i<argc; ++i )
71 new_argv[i+1] = argv[i];
72 new_argv[1] = strdup(assembly_name);
73 Arcane::String verbose_str = Arcane::platform::getEnvironmentVariable(
"ARCANE_DEBUG_DOTNET");
74 dotnet_verbose = !verbose_str.
null();
77 std::cout <<
"ArcaneMono: ASSEMBLY NAME is '" << assembly_name <<
"' argc=" << argc <<
"\n";
78 for(
int i=0; i<new_argc; ++i )
79 std::cout<<
"ArcaneMono: Arg i=" << i <<
" V=" << new_argv[i] <<
'\n';
86 int retval = mono_main(new_argc,new_argv);
87 global_is_running =
false;
95extern "C" ARCANE_EXPORT
int
96arcane_mono_main(
int argc,
char* argv[],
const char* assembly_name)
98 if (!assembly_name || assembly_name[0]==
'\0')
99 assembly_name =
"Arcane.Main.dll";
100 return _arcane_mono_main_internal(argc,argv,assembly_name);
106extern "C" ARCANE_EXPORT
int
111 if (assembly_name.
empty())
112 assembly_name =
"Arcane.Main.dll";
114 int argc = *(cmd_args.commandLineArgc());
115 char** argv = *(cmd_args.commandLineArgv());
116 const char* assembly_name_str = assembly_name.
localstr();
117 return _arcane_mono_main_internal(argc,argv,assembly_name_str);
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Arguments de la ligne de commande.
void addObserver(T *obj, void(T::*func)(const IObservable &), IObservable *oba)
Ajoute un observateur.
static IObservable * createThreadObservable()
Observable appelé lors de la création d'un thread pour une tâche.
Chaîne de caractères unicode.
bool empty() const
Vrai si la chaîne est vide (nulle ou "")
const char * localstr() const
Retourne la conversion de l'instance dans l'encodage UTF-8.
bool null() const
Retourne true si la chaîne est nulle.