X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-csharp-binder%2Fsrc%2Fapplication.cpp;h=516a2bdcb04d25ce39b3e4559d77d3ff85de3298;hb=0267927ddb0c3ffd940e7ca8e64d40ad1333b826;hp=7e8ee4e98740f0ab177cf04b6fbcdbbff7036ea1;hpb=2aab3b3dbf09fdd8516b0b9d1368f606e96005db;p=platform%2Fcore%2Fuifw%2Fdali-csharp-binder.git diff --git a/dali-csharp-binder/src/application.cpp b/dali-csharp-binder/src/application.cpp index 7e8ee4e..516a2bd 100755 --- a/dali-csharp-binder/src/application.cpp +++ b/dali-csharp-binder/src/application.cpp @@ -22,6 +22,7 @@ #include "string" #include #include +#include /* Callback for returning strings to C# without leaking memory */ typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *); @@ -137,34 +138,25 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_0() { SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_1(int jarg1) { void * jresult ; - int *arg1 = (int *) 0 ; - char ***arg2 ; - Dali::Application result; + int arg1 = 1; + char ***arg2; + Dali::Application result; { - // Todo generate argv data from the C# args - char **array; // two dimensional array - int numStrings = 1; // number of strings - int stringLength = 30; // max string length. - array = (char **)malloc( (numStrings + 1 )* sizeof(char *) ); - argV = array; - - // allocate the string data - for( int i=0; i < numStrings; i++) - { - array[i]=(char *)malloc( stringLength * sizeof(char) ); - } - array[ numStrings ] = NULL; // we allocated +1 for hold the NULL part + std::string app_name = "dali-csharp-app"; + int stringLength = app_name.length(); + argV = new char*[arg1 + 1]; + argV[0] = new char[stringLength + 1]; - std::string temp = "dali-csharp-app"; - array[0][temp.copy(array[0], strlen(array[0])-1)] = '\0'; + strncpy(argV[0], app_name.c_str(), stringLength); + argV[0][stringLength] = '\0'; + argV[1] = NULL; - arg1 = &argC; arg2 = &argV; } { try { - result = Dali::Application::New(arg1,arg2); + result = Dali::Application::New(&arg1, arg2); } catch (std::out_of_range& e) { { SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return 0; @@ -191,41 +183,35 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_1(int jarg1) { SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_2(int jarg1, char * jarg3) { void * jresult ; - int *arg1 = (int *) 0 ; - char ***arg2 ; - std::string *arg3 = 0 ; - Dali::Application result; + int arg1 = 1; + char ***arg2; + std::string *arg3 = 0; + Dali::Application result; { - // Todo generate argv data from the C# args - char **array; // two dimensional array - int numStrings = 1; // number of strings - int stringLength = 30; // max string length. - array = (char **)malloc( (numStrings + 1 )* sizeof(char *) ); - argV = array; + std::string app_name = "dali-csharp-app"; + int stringLength = app_name.length(); + argV = new char*[arg1 + 1]; + argV[0] = new char[stringLength + 1]; - // allocate the string data - for( int i=0; i < numStrings; i++) - { - array[i]=(char *)malloc( stringLength * sizeof(char) ); - } - array[ numStrings ] = NULL; // we allocated +1 for hold the NULL part + strncpy(argV[0], app_name.c_str(), stringLength); + argV[0][stringLength] = '\0'; + argV[1] = NULL; - std::string temp = "dali-csharp-app"; - array[0][temp.copy(array[0], strlen(array[0])-1)] = '\0'; - - arg1 = &argC; arg2 = &argV; + } if (!jarg3) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + delete []argV[0]; + delete []argV; return 0; } std::string arg3_str(jarg3); arg3 = &arg3_str; { try { - result = Dali::Application::New(arg1,arg2,(std::string const &)*arg3); + result = Dali::Application::New(&arg1, arg2,(std::string const &)*arg3); } catch (std::out_of_range& e) { { SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return 0; @@ -255,35 +241,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_2(int jarg1, cha SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_3(int jarg1, char * jarg3, int jarg4) { void * jresult ; - int *arg1 = (int *) 0 ; - char ***arg2 ; - std::string *arg3 = 0 ; - Dali::Application::WINDOW_MODE arg4 ; - Dali::Application result; + int arg1 = 1; + char ***arg2; + std::string *arg3 = 0; + Dali::Application::WINDOW_MODE arg4; + Dali::Application result; { - // Todo generate argv data from the C# args - char **array; // two dimensional array - int numStrings = 1; // number of strings - int stringLength = 30; // max string length. - array = (char **)malloc( (numStrings + 1 )* sizeof(char *) ); - argV = array; - - // allocate the string data - for( int i=0; i < numStrings; i++) - { - array[i]=(char *)malloc( stringLength * sizeof(char) ); - } - array[ numStrings ] = NULL; // we allocated +1 for hold the NULL part + std::string app_name = "dali-csharp-app"; + int stringLength = app_name.length(); + argV = new char*[arg1 + 1]; + argV[0] = new char[stringLength + 1]; - std::string temp = "dali-csharp-app"; - array[0][temp.copy(array[0], strlen(array[0])-1)] = '\0'; + strncpy(argV[0], app_name.c_str(), stringLength); + argV[0][stringLength] = '\0'; + argV[1] = NULL; - arg1 = &argC; arg2 = &argV; } if (!jarg3) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); + delete []argV[0]; + delete []argV; return 0; } std::string arg3_str(jarg3); @@ -291,7 +270,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__SWIG_3(int jarg1, cha arg4 = (Dali::Application::WINDOW_MODE)jarg4; { try { - result = Dali::Application::New(arg1,arg2,(std::string const &)*arg3,arg4); + result = Dali::Application::New(&arg1, arg2,(std::string const &)*arg3,arg4); } catch (std::out_of_range& e) { { SWIG_CSharpException(SWIG_IndexError, const_cast(e.what())); return 0; @@ -329,23 +308,28 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__MANUAL_4(int jarg1, c { // Todo generate argv data from the C# args int index = 0; - char *retPtr; + int length = 0; + char *retPtr = NULL; char *nextPtr; argV = new char*[jarg1 + 1]; - retPtr = strtok_r(jarg2," ", &nextPtr); - argV[index] = new char[strlen(retPtr)+1]; - strncpy( argV[index], retPtr, strlen(retPtr) ); - argV[index][strlen(retPtr)] = '\0'; - index++; + for(retPtr = strtok_r(jarg2, " ", &nextPtr); + retPtr != NULL && index < jarg1; + retPtr = strtok_r(NULL, " ", &nextPtr)) + { + length = 0; + length = strlen(retPtr); + argV[ index ] = new char[ length + 1 ]; + strncpy( argV[ index ], retPtr, length ); + argV[ index ][ length ] = '\0'; + index++; + } while( index < jarg1 ) { - retPtr = strtok_r(NULL," ", &nextPtr); - argV[index] = new char[strlen(retPtr)+1]; - strncpy( argV[index], retPtr, strlen(retPtr) ); - argV[index][strlen(retPtr)] = '\0'; + //if jarg1 - index >1, maybe cause error. + argV[index] = NULL; index++; } @@ -354,7 +338,6 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_Application_New__MANUAL_4(int jarg1, c arg1 = &argC; arg2 = &argV; - } std::string arg3_str(jarg3); @@ -721,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(e.what())); return 0; + }; + } catch (std::exception& e) { + { + SWIG_CSharpException(SWIG_RuntimeError, const_cast(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(e.what())); return 0; + }; + } catch (std::exception& e) { + { + SWIG_CSharpException(SWIG_RuntimeError, const_cast(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 ; @@ -2255,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 @@ -2265,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;