NETHostUnix.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. int ExecAssembly(const String& assemblyName, const Vector<String>& args);
  47. private:
  48. bool LoadCLRDLL(String& errorMsg);
  49. bool CreateAppDomain(String &errorMsg);
  50. void AddFilesFromDirectoryToTPAList(const String& targetPath, Vector<String>& trustedAssemblies);
  51. void GenerateTPAList(String& tpaList);
  52. InitializeCoreCLRFunction InitializeCoreCLR_;
  53. ExecuteAssemblyFunction ExecuteAssembly_;
  54. CreateDelegateFunction CreateDelegate_;
  55. ShutdownCoreCLRFunction ShutdownCoreCLR_;
  56. void* coreCLRDLLHandle_;
  57. void* hostHandle_;
  58. unsigned domainId_;
  59. };
  60. }