[dali_2.3.33] Merge branch 'devel/master'
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / dali-toolkit / text-spannable-string-wrap.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // EXTERNAL INCLUDES
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/text/spannable-string.h>
21 #include <dali/dali.h>
22
23 // INTERNAL INCLUDES
24 #include <dali-csharp-binder/common/common.h>
25
26 /* Callback for returning strings to C# without leaking memory */
27 typedef char *(SWIGSTDCALL *SWIG_CSharpStringHelperCallback)(const char *);
28 extern SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback;
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 using namespace Dali::Toolkit::Text;
35
36 SWIGEXPORT void SWIGSTDCALL
37 CSharp_Dali_delete_SpannableString(void *refSpannableString) {
38   SpannableString *spannablePtr = (SpannableString *)0;
39   spannablePtr = (SpannableString *)refSpannableString;
40
41   {
42     try {
43       delete spannablePtr;
44     }
45     CALL_CATCH_EXCEPTION();
46   }
47 }
48
49 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_SpannableString_New(char *refText) {
50
51   std::string text = std::string(refText);
52   SpannableString *spannableStringPtr = 0;
53   {
54     try {
55       spannableStringPtr =
56           (SpannableString *)new SpannableString(SpannableString::New(text));
57     }
58     CALL_CATCH_EXCEPTION(0);
59   }
60
61   return (void *)spannableStringPtr;
62 }
63
64 #ifdef __cplusplus
65 }
66 #endif