Merge "Initialize coreclr in the candidate process and change ON_BOOT value to OFF...
[platform/core/dotnet/launcher.git] / NativeLauncher / launcher / dotnet / dotnet_launcher.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __DOTNET_LAUNCHER_H__
18 #define __DOTNET_LAUNCHER_H__
19
20 #include "launcher.h"
21
22 extern "C"
23 {
24         typedef int (*coreclr_initialize_ptr)(
25                         const char* exePath,
26                         const char* appDomainFriendlyName,
27                         int propertyCount,
28                         const char** propertyKeys,
29                         const char** propertyValues,
30                         void** hostHandle,
31                         unsigned int* domainId);
32
33         typedef int (*coreclr_execute_assembly_ptr)(
34                         void* hostHandle,
35                         unsigned int domainId,
36                         int argc,
37                         const char** argv,
38                         const char* managedAssemblyPath,
39                         unsigned int* exitCode);
40
41         typedef int (*coreclr_shutdown_ptr)(
42                         void* hostHandle,
43                         unsigned int domainId);
44
45         typedef int (*coreclr_create_delegate_ptr)(
46                         void* hostHandle,
47                         unsigned int domainId,
48                         const char* entryPointAssemblyName,
49                         const char* entryPointTypeName,
50                         const char* entryPointMethodName,
51                         void** delegate);
52
53         typedef void (*plugin_initialize_ptr)();
54
55         typedef void (*plugin_preload_ptr)();
56
57         typedef void (*plugin_set_app_info_ptr)(
58                         const char* appId,
59                         const char* managedAssemblyPath);
60
61         typedef void (*plugin_set_coreclr_info_ptr)(
62                         void* hostHandle,
63                         unsigned int domainId);
64
65         typedef char* (*plugin_get_dll_path_ptr)();
66
67         typedef void (*plugin_before_execute_ptr)();
68
69         typedef void (*plugin_finalize_ptr)();
70 }
71
72 namespace tizen {
73 namespace runtime {
74 namespace dotnetcore {
75
76 typedef void (*PreparedFunctionPtr)();
77 typedef bool (*LaunchFunctionPtr)(const char* root, const char* path, int argc, char* argv[]);
78
79 class CoreRuntime : public tizen::runtime::LauncherInterface
80 {
81         public:
82                 CoreRuntime();
83                 ~CoreRuntime();
84                 int initialize(bool standalone) override;
85                 void dispose() override;
86                 int launch(const char* appId, const char* root, const char* path, int argc, char* argv[]) override;
87
88         private:
89                 bool initializeCoreClr(const char* appId, const char* assemblyProbePaths, const char* pinvokeProbePaths, const char* tpaList);
90                 coreclr_initialize_ptr initializeClr;
91                 coreclr_execute_assembly_ptr executeAssembly;
92                 coreclr_shutdown_ptr shutdown;
93                 coreclr_create_delegate_ptr createDelegate;
94                 std::string __deviceAPIDirectory;
95                 std::string __runtimeDirectory;
96                 std::string __nativeLibDirectory;
97                 std::string __refAPIDirectory;
98                 void* __coreclrLib;
99                 void* __hostHandle;
100                 unsigned int __domainId;
101                 PreparedFunctionPtr preparedFunction;
102                 LaunchFunctionPtr launchFunction;
103                 // plugin function pointer
104                 void* __pluginLib;
105                 plugin_initialize_ptr pluginInitialize;
106                 plugin_preload_ptr      pluginPreload;
107                 plugin_set_app_info_ptr pluginSetAppInfo;
108                 plugin_set_coreclr_info_ptr     pluginSetCoreclrInfo;
109                 plugin_get_dll_path_ptr pluginGetDllPath;
110                 plugin_before_execute_ptr pluginBeforeExecute;
111                 plugin_finalize_ptr     pluginFinalize;
112                 int fd;
113 };
114
115 }  // dotnetcore
116 }  // namespace runtime
117 }  // namespace tizen
118
119 #endif /* __DOTNET_LAUNCHER_H__ */