NETHostUnix.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include "../../NETHost.h"
  3. #include <stdio.h>
  4. namespace Atomic
  5. {
  6. // Prototype of the coreclr_initialize function from the libcoreclr.so
  7. typedef int (*InitializeCoreCLRFunction)(
  8. const char* exePath,
  9. const char* appDomainFriendlyName,
  10. int propertyCount,
  11. const char** propertyKeys,
  12. const char** propertyValues,
  13. void** hostHandle,
  14. unsigned int* domainId);
  15. // Prototype of the coreclr_shutdown function from the libcoreclr.so
  16. typedef int (*ShutdownCoreCLRFunction)(
  17. void* hostHandle,
  18. unsigned int domainId);
  19. // Prototype of the coreclr_execute_assembly function from the libcoreclr.so
  20. typedef int (*ExecuteAssemblyFunction)(
  21. void* hostHandle,
  22. unsigned int domainId,
  23. int argc,
  24. const char** argv,
  25. const char* managedAssemblyPath,
  26. unsigned int* exitCode);
  27. typedef int (*CreateDelegateFunction)(
  28. void* hostHandle,
  29. unsigned int domainId,
  30. const char* entryPointAssemblyName,
  31. const char* entryPointTypeName,
  32. const char* entryPointMethodName,
  33. void** delegate);
  34. class ATOMIC_API NETHostUnix : public NETHost
  35. {
  36. OBJECT(NETHostUnix);
  37. public:
  38. /// Construct.
  39. NETHostUnix(Context* context);
  40. /// Destruct.
  41. virtual ~NETHostUnix();
  42. bool Initialize();
  43. bool CreateDelegate(const String& assemblyName, const String& qualifiedClassName, const String& methodName, void** funcOut);
  44. void WaitForDebuggerConnect();
  45. void Shutdown();
  46. private:
  47. bool LoadCLRDLL(String& errorMsg);
  48. bool CreateAppDomain(String &errorMsg);
  49. void AddFilesFromDirectoryToTPAList(const String& targetPath, Vector<String>& trustedAssemblies);
  50. void GenerateTPAList(String& tpaList);
  51. InitializeCoreCLRFunction InitializeCoreCLR_;
  52. ExecuteAssemblyFunction ExecuteAssembly_;
  53. CreateDelegateFunction CreateDelegate_;
  54. ShutdownCoreCLRFunction ShutdownCoreCLR_;
  55. void* coreCLRDLLHandle_;
  56. void* hostHandle_;
  57. unsigned domainId_;
  58. };
  59. }