add comment for header and fix some wrong return value 62/182762/1
authorWoongsuk Cho <ws77.cho@samsung.com>
Thu, 28 Jun 2018 01:03:20 +0000 (10:03 +0900)
committerWoongsuk Cho <ws77.cho@samsung.com>
Thu, 28 Jun 2018 01:03:20 +0000 (10:03 +0900)
Change-Id: I53c885ed0f3ffbd4c95321dca57a72e92632b387

NativeLauncher/inc/dotnet_launcher_plugin.h
NativeLauncher/inc/plugin_manager.h
NativeLauncher/inc/utils.h
NativeLauncher/util/utils.cc

index 4e75917..21967c4 100644 (file)
 
 extern "C"
 {
-       typedef void (*plugin_initialize_ptr)(const char* mode);
-       typedef void (*plugin_preload_ptr)();
-       typedef void (*plugin_set_app_info_ptr)(
-                       const char* appId,
-                       const char* managedAssemblyPath);
-       typedef void (*plugin_set_coreclr_info_ptr)(
-                       void* hostHandle,
-                       unsigned int domainId,
-                       coreclr_create_delegate_ptr delegateFunc);
-       typedef char* (*plugin_get_dll_path_ptr)();
-       typedef void (*plugin_before_execute_ptr)();
-       typedef void (*plugin_finalize_ptr)();
+       /**
+        * @brief initialize plugin code
+        * @param[in] mode mode of plugin ("default", "inhouse", etc)
+        */
+       void plugin_initialize(const char* mode);
+
+       /**
+        * @brief preload libraries. this fuction is called in the candidate process only
+        */
+       void plugin_preload();
+
+       /**
+        * @brief set appInfo to plugin
+        * @param[in] appID application ID to launch
+        * @param[in] assemblyPath assembly path which has entry point
+        */
+       void plugin_set_app_info(const char* appId,
+                                                        const char* assemblyPath);
+
+       /**
+        * @brief set coreclr info to plugin
+        * @param[in] hostHandle host handle of coreclr
+        * @param[in] domainId current domain ID
+        * @param[in] coreclr_create_delegate_ptr function pointer of coreclr_create_delegate
+        *            delegate function can be used to preload managed code
+        */
+       void plugin_set_coreclr_info(void* hostHandle,
+                                                                unsigned int domainId,
+                                                                coreclr_create_delegate_ptr delegateFunc);
+
+       /**
+        * @brief return additional pathes to find platform assembly.
+        * @return ":" seperated pathes
+        */
+       char* plugin_get_dll_path();
+
+       /**
+        * @brief function will be called before invoking managed code
+        */
+       void plugin_before_execute();
+
+       /**
+        * @brief function will be called when application is terminated
+        */
+       void plugin_finalize();
 }
 
 #endif /* __DOTNET_LAUNCHER_PLUGIN_H__ */
index 94e1798..0e8cacd 100644 (file)
 #ifndef __PLUGIN_MANAGER_H__
 #define __PLUGIN_MANAGER_H__
 
-#include "dotnet_launcher_plugin.h"
 #include "coreclr_host.h"
 
-extern "C"
-{
-
+typedef void (*plugin_initialize_ptr)(const char* mode);
+typedef void (*plugin_preload_ptr)();
+typedef void (*plugin_set_app_info_ptr)(
+                       const char* appId,
+                       const char* managedAssemblyPath);
+typedef void (*plugin_set_coreclr_info_ptr)(
+                       void* hostHandle,
+                       unsigned int domainId,
+                       coreclr_create_delegate_ptr delegateFunc);
+typedef char* (*plugin_get_dll_path_ptr)();
+typedef void (*plugin_before_execute_ptr)();
+typedef void (*plugin_finalize_ptr)();
 
 typedef struct PluginFunc {
        plugin_initialize_ptr initialize;
@@ -45,6 +53,4 @@ void pluginBeforeExecute();
 int initializePluginManager(const char* mode);
 void finalizePluginManager();
 
-}
-
 #endif /* __PLUGIN_MANAGER_H__ */
index 534be8b..e43b63a 100644 (file)
 #include <string>
 #include <vector>
 #include <functional>
-#include <map>
 
 #ifndef PATH_SEPARATOR
 #define PATH_SEPARATOR '/'
 #endif
 
+/**
+ * @brief get current executable path
+ * return std::string path
+ */
 std::string readSelfPath();
 
+/**
+ * @brief concat path with PATH_SEPARATOR
+ * @param[in] destination path
+ * @param[in] source path
+ * return std::string result path
+ */
 std::string concatPath(const std::string& path1, const std::string& path2);
+
+/**
+ * @brief get absolute Path
+ * @param[in] source path
+ * return std::string result path
+ */
 std::string absolutePath(const std::string& path);
+
+/**
+ * @brief get the directory of file
+ * @param[in] source path
+ * return std::string result path
+ */
 std::string baseName(const std::string& path);
+
+/**
+ * @brief split path with ":" delimiter and put that in the vector
+ * @param[in] source path
+ * @param[out] string vector
+ */
 void splitPath(const std::string& path, std::vector<std::string>& out);
-void appendPath(std::string& path1, const std::string& path2);
 
+/**
+ * @brief check file is exist
+ * @param[in] source path
+ * @return bool
+ */
 bool isFileExist(const std::string& path);
 
-bool isManagedAssembly(const std::string& fileName);
-bool isNativeImage(const std::string& fileName);
+/**
+ * @brief check the file is managed assembly or not.
+ * @param[in] file path
+ * @return return true when the file is managed assembly.
+ *         otherwise return false including native image case.
+ */
+bool isManagedAssembly(const std::string& filePath);
+
+/**
+ * @brief check the file is native image or not.
+ * @param[in] file path
+ * @return return true when the file is native image.
+ */
+bool isNativeImage(const std::string& filePath);
 
+/**
+ * @brief find assembly files in the directories
+ * @param[in] directories
+ * @param[out] ":" seperated assembly path list
+ */
 void assembliesInDirectory(const std::vector<std::string>& directories, std::string& tpaList);
 
+/**
+ * @brief function pointer for file reader
+ */
 typedef std::function<void (const std::string&, const char*)> FileReader;
+
+/**
+ * @brief scan files in the given directory and run file reader function for that
+ * @param[in] directory
+ * @param[in] file reader function
+ * @param[in] scan depth
+ */
 void scanFilesInDir(const std::string& directory, FileReader reader, unsigned int depth);
 
+/**
+ * @brief start logging thread to bypass stderr and stdout to dlog
+ * @return return 0 when success, otherwise return negative value.
+ */
 int runLoggingThread();
 #endif /* __UTILS_H__ */
index 76ac831..62f7b9c 100644 (file)
@@ -29,6 +29,7 @@
 #include <vector>
 #include <iterator>
 #include <sstream>
+#include <map>
 
 #include "utils.h"
 #include "path_manager.h"
@@ -236,30 +237,30 @@ int runLoggingThread()
 {
     if (setvbuf(stdout, NULL, _IOLBF, 0) < 0) {
                _DBG("fail to make stdout line-buffered");
-               return 0;
+               return -1;
     }
 
     if (setvbuf(stderr, NULL, _IONBF, 0) < 0) {
                _DBG("make stderr unbuffered");
-               return 0;
+               return -1;
        }
 
     /* create the pipe and redirect stdout and stderr */
     if (pipe(__pfd) < 0) {
                _DBG("fail to create pipe for logging");
-               return 0;
+               return -1;
     }
 
     // stdout
     if (dup2(__pfd[1], 1) == -1) {
                _DBG("fail to duplicate fd to stdout");
-               return 0;
+               return -1;
     }
 
     // stderr
     if (dup2(__pfd[1], 2) == -1) {
                _DBG("fail to duplicate fd to stderr");
-               return 0;
+               return -1;
        }
 
        close(__pfd[1]);