Add License file and comments to sources
[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 #include "launcher.h"
18
19 extern "C"
20 {
21   typedef int (*coreclr_initialize_ptr)(
22       const char* exePath,
23       const char* appDomainFriendlyName,
24       int propertyCount,
25       const char** propertyKeys,
26       const char** propertyValues,
27       void** hostHandle,
28       unsigned int* domainId);
29
30   typedef int (*coreclr_execute_assembly_ptr)(
31       void* hostHandle,
32       unsigned int domainId,
33       int argc,
34       const char** argv,
35       const char* managedAssemblyPath,
36       unsigned int* exitCode);
37
38   typedef int (*coreclr_shutdown_ptr)(
39       void* hostHandle,
40       unsigned int domainId);
41
42   typedef int (*coreclr_create_delegate_ptr)(
43       void* hostHandle,
44       unsigned int domainId,
45       const char* entryPointAssemblyName,
46       const char* entryPointTypeName,
47       const char* entryPointMethodName,
48       void** delegate);
49 }
50
51 namespace tizen {
52 namespace runtime {
53 namespace dotnetcore {
54
55 typedef void (*PreparedFunctionPtr)();
56 typedef bool (*LaunchFunctionPtr)(const char* root, const char* path, int argc, char* argv[]);
57
58 class CoreRuntime : public tizen::runtime::LauncherInterface
59 {
60   public:
61     CoreRuntime();
62     ~CoreRuntime();
63     int Initialize(bool standalone) override;
64     void Dispose() override;
65     int RunManagedLauncher() override;
66     int Launch(const char* root, const char* path, int argc, char* argv[]) override;
67
68   private:
69     bool InitializeCoreClr(const char* assembly_probe_paths, const char* pinvoke_probe_paths);
70     coreclr_initialize_ptr InitializeClr;
71     coreclr_execute_assembly_ptr ExecuteAssembly;
72     coreclr_shutdown_ptr Shutdown;
73     coreclr_create_delegate_ptr CreateDelegate;
74     std::string DeviceAPIDirectory;
75     std::string RuntimeDirectory;
76     std::string LauncherAssembly;
77     void* coreclrLib;
78     void* hostHandle;
79     unsigned int domainId;
80     PreparedFunctionPtr PreparedFunction;
81     LaunchFunctionPtr LaunchFunction;
82 };
83
84 }  // dotnetcore
85 }  // namespace runtime
86 }  // namespace tizen