Change appfw callback functions to lamda
authorWonYoung Choi <wy80.choi@samsung.com>
Thu, 9 Apr 2015 06:08:28 +0000 (15:08 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Thu, 9 Apr 2015 06:08:28 +0000 (15:08 +0900)
Change-Id: Ie4214eb81f4c9602d676441450d394daf4b67156

src/runtime/runtime.cc
src/runtime/runtime.h

index 481a4dc..245a302 100755 (executable)
@@ -48,25 +48,8 @@ bool Runtime::OnCreate() {
   return true;
 }
 
-bool Runtime::onCreate(void* data) {
-  Runtime* runtime = reinterpret_cast<Runtime*>(data);
-  if (!runtime) {
-    LoggerE("Runtime has not been created.");
-    return false;
-  }
-  return runtime->OnCreate();
-}
-
 void Runtime::OnTerminate() {
 }
-void Runtime::onTerminate(void* data) {
-  Runtime* runtime = reinterpret_cast<Runtime*>(data);
-  if (!runtime) {
-    LoggerE("Runtime has not been created.");
-    return;
-  }
-  runtime->OnTerminate();
-}
 
 void Runtime::OnPause() {
   if (application_->initialized()) {
@@ -74,28 +57,11 @@ void Runtime::OnPause() {
   }
 }
 
-void Runtime::onPause(void* data) {
-  Runtime* runtime = reinterpret_cast<Runtime*>(data);
-  if (!runtime) {
-    LoggerE("Runtime has not been created.");
-    return;
-  }
-  runtime->OnPause();
-}
-
 void Runtime::OnResume() {
   if (application_->initialized()) {
     application_->Resume();
   }
 }
-void Runtime::onResume(void* data) {
-  Runtime* runtime = reinterpret_cast<Runtime*>(data);
-  if (!runtime) {
-    LoggerE("Runtime has not been created.");
-    return;
-  }
-  runtime->OnResume();
-}
 
 void Runtime::OnAppControl(app_control_h app_control) {
   if (application_->initialized()) {
@@ -106,23 +72,58 @@ void Runtime::OnAppControl(app_control_h app_control) {
   }
 }
 
-void Runtime::onAppControl(app_control_h app_control, void* data) {
-  Runtime* runtime = reinterpret_cast<Runtime*>(data);
-  if (!runtime) {
-    LoggerE("Runtime has not been created.");
-    return;
-  }
-  runtime->OnAppControl(app_control);
-}
-
 int Runtime::Exec(int argc, char* argv[]) {
   ui_app_lifecycle_callback_s ops = {0, };
 
-  ops.create = onCreate;
-  ops.terminate = onTerminate;
-  ops.pause = onPause;
-  ops.resume = onResume;
-  ops.app_control = onAppControl;
+  // onCreate
+  ops.create = [](void* data) -> bool {
+    Runtime* runtime = reinterpret_cast<Runtime*>(data);
+    if (!runtime) {
+      LoggerE("Runtime has not been created.");
+      return false;
+    }
+    return runtime->OnCreate();
+  };
+
+  // onTerminate
+  ops.terminate = [](void* data) -> void {
+    Runtime* runtime = reinterpret_cast<Runtime*>(data);
+    if (!runtime) {
+      LoggerE("Runtime has not been created.");
+      return;
+    }
+    runtime->OnTerminate();
+  };
+
+  // onPause
+  ops.pause = [](void* data) -> void {
+    Runtime* runtime = reinterpret_cast<Runtime*>(data);
+    if (!runtime) {
+      LoggerE("Runtime has not been created.");
+      return;
+    }
+    runtime->OnPause();
+  };
+
+  // onResume
+  ops.resume = [](void* data) -> void {
+    Runtime* runtime = reinterpret_cast<Runtime*>(data);
+    if (!runtime) {
+      LoggerE("Runtime has not been created.");
+      return;
+    }
+    runtime->OnResume();
+  };
+
+  // onAppControl
+  ops.app_control = [](app_control_h app_control, void* data) -> void {
+    Runtime* runtime = reinterpret_cast<Runtime*>(data);
+    if (!runtime) {
+      LoggerE("Runtime has not been created.");
+      return;
+    }
+    runtime->OnAppControl(app_control);
+  };
 
   return ui_app_main(argc, argv, &ops, this);
 }
index dc5751f..e988ce0 100755 (executable)
@@ -27,12 +27,6 @@ class Runtime {
   virtual void OnAppControl(app_control_h app_control);
 
  private:
-  static bool onCreate(void* data);
-  static void onTerminate(void* data);
-  static void onPause(void* data);
-  static void onResume(void* data);
-  static void onAppControl(app_control_h app_control, void* data);
-
   WebApplication* application_;
   NativeWindow* native_window_;
 };