Add C# binding for GetWindows
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / src / application.cpp
index 72bd1f2..516a2bd 100755 (executable)
@@ -22,6 +22,7 @@
 #include "string"
 #include <dali/public-api/adaptor-framework/application.h>
 #include <dali/devel-api/adaptor-framework/application-devel.h>
+#include <dali/integration-api/adaptors/adaptor.h>
 
 /* Callback for returning strings to C# without leaking memory */
 typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *);
@@ -202,8 +203,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_2(int jarg1, cha
   }
   if (!jarg3) {
     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
-    delete []arg2[0];
-    delete []arg2;
+    delete []argV[0];
+    delete []argV;
     return 0;
   }
   std::string arg3_str(jarg3);
@@ -260,8 +261,8 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_3(int jarg1, cha
   }
   if (!jarg3) {
     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
-    delete []arg2[0];
-    delete []arg2;
+    delete []argV[0];
+    delete []argV;
     return 0;
   }
   std::string arg3_str(jarg3);
@@ -703,6 +704,63 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_GetWindow(void * jarg1) {
   return jresult;
 }
 
+SWIGEXPORT unsigned int SWIGSTDCALL CSharp_Dali_Application_GetWindowsListSize() {
+  unsigned int jresult ;
+  Dali::WindowContainer result;
+  {
+    try {
+      result = Dali::Adaptor::Get().GetWindows();
+      jresult = result.size();
+    } catch (std::out_of_range& e) {
+      {
+        SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
+      };
+    } catch (std::exception& e) {
+      {
+        SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return 0;
+      };
+    } catch (Dali::DaliException e) {
+      {
+        SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
+      };
+    } catch (...) {
+      {
+        SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
+      };
+    }
+  }
+  return jresult;
+}
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_GetWindowsFromList(uint jarg1) {
+  void * jresult ;
+  uint index = jarg1;
+  Dali::WindowContainer result;
+
+  {
+    try {
+      result = Dali::Adaptor::Get().GetWindows();
+    } catch (std::out_of_range& e) {
+      {
+        SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
+      };
+    } catch (std::exception& e) {
+      {
+        SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return 0;
+      };
+    } catch (Dali::DaliException e) {
+      {
+        SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
+      };
+    } catch (...) {
+      {
+        SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
+      };
+    }
+  }
+  jresult = new Dali::Window((const Dali::Window &)result[index]);
+  return jresult;
+}
 
 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Application_ReplaceWindow(void * jarg1, void * jarg2, char * jarg3) {
   Dali::Application *arg1 = (Dali::Application *) 0 ;
@@ -2237,6 +2295,10 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_4(int jarg1, cha
     int numStrings = 1;     // number of strings
     int stringLength = 30;      // max string length.
     array = (char **)malloc( (numStrings + 1 )* sizeof(char *) );
+    if(!array) {
+      SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "array is null", 0);
+      return 0;
+    }
     argV = array;
 
     // allocate the string data
@@ -2247,6 +2309,11 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_4(int jarg1, cha
     array[ numStrings ] =  NULL; // we allocated +1 for hold the NULL part
 
     std::string temp = "dali-csharp-app";
+
+    if(!array[0]) {
+      SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "array[0] is null", 0);
+      return 0;
+    }
     array[0][temp.copy(array[0], strlen(array[0])-1)] = '\0';
 
     arg1 = &argC;