[AT-SPI] Fix csharp_dali_accessibility_say() 25/299825/1
authorArtur Świgoń <a.swigon@samsung.com>
Tue, 10 Oct 2023 16:28:04 +0000 (18:28 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Tue, 10 Oct 2023 16:28:04 +0000 (18:28 +0200)
This is one of the oldest interops and was actually problematic for
multiple reasons; the return type didn't match and the third parameter
was expected to have exactly the same value in every invocation. While
fixing these issues, parsing the status string was moved from C++ to C#
for readability.

Change-Id: If039e47dd5725d840ebe8672947d4a1f2b5db2fc

dali-csharp-binder/dali-adaptor/atspi-wrap.cpp

index c7acd4d..6853555 100755 (executable)
 extern "C" {
 #endif
 
-using callbackFuncType = void(*)(int);
-callbackFuncType callBack;
+using SayCallbackType = void(*)(const char*);
 
-void sayTestCallback(std::string result)
+SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_say(const char* arg1_text, bool arg2_discardable, SayCallbackType arg3_callback)
 {
-  DALI_LOG_ERROR("sayTestCallback() result=%s ", result.c_str());
-
-  if(callBack)
-  {
-    if(result == "ReadingCancelled")
-    {
-      callBack(1);
-    }
-    else if(result == "ReadingStopped")
-    {
-      callBack(2);
-    }
-    else if(result == "ReadingSkipped")
-    {
-      callBack(3);
-    }
-    else if(result == "ReadingPaused")
-    {
-      callBack(4);
-    }
-    else if(result == "ReadingResumed")
-    {
-      callBack(5);
-    }
-    else
-    {
-      callBack(-1);
-    }
-  }
-}
-
-SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_say(char* arg1_text, bool arg2_discardable, void *arg3_callback)
-{
-  callBack = (callbackFuncType)arg3_callback;
-
-  Dali::AtspiAccessibility::Say(std::string{arg1_text}, arg2_discardable, sayTestCallback);
+  Dali::AtspiAccessibility::Say(std::string{arg1_text}, arg2_discardable, [arg3_callback](std::string status) {
+    arg3_callback(status.c_str());
+  });
 }
 
 SWIGEXPORT void SWIGSTDCALL csharp_dali_accessibility_pause_resume(bool arg1_pause)