2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/text/spanned.h>
21 #include <dali/dali.h>
24 #include <dali-csharp-binder/common/common.h>
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;
34 using namespace Dali::Toolkit::Text;
36 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_Spanned(void *refSpanned) {
37 Spanned *spannedPtr = (Spanned *)0;
38 spannedPtr = (Spanned *)refSpanned;
44 CALL_CATCH_EXCEPTION();
48 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_Spanned_GetAllSpans(void *refSpanned) {
51 void *result = nullptr;
53 spannedPtr = (Spanned *)refSpanned;
55 SWIG_CSharpSetPendingExceptionArgument(
56 SWIG_CSharpArgumentNullException, "Attempt to dereference null Spanned",
63 result = new std::vector<BaseSpan>(
64 (const std::vector<BaseSpan> &)(spannedPtr->GetAllSpans()));
66 CALL_CATCH_EXCEPTION(0);
72 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_Spanned_RetrieveAllSpansAndRanges(
73 void *refSpanned, void *refVectorSpans, void *refVectorRanges) {
75 std::vector<BaseSpan> *spanVectorPtr = (std::vector<BaseSpan> *)0;
76 spanVectorPtr = (std::vector<BaseSpan> *)refVectorSpans;
78 SWIG_CSharpSetPendingExceptionArgument(
79 SWIG_CSharpArgumentNullException,
80 "Attempt to dereference null vector<BaseSpan>", 0);
84 std::vector<Range> *rangeVectorPtr = (std::vector<Range> *)0;
85 rangeVectorPtr = (std::vector<Range> *)refVectorRanges;
86 if (!rangeVectorPtr) {
87 SWIG_CSharpSetPendingExceptionArgument(
88 SWIG_CSharpArgumentNullException,
89 "Attempt to dereference null vector<Range>", 0);
94 spannedPtr = (Spanned *)refSpanned;
96 SWIG_CSharpSetPendingExceptionArgument(
97 SWIG_CSharpArgumentNullException, "Attempt to dereference null Spanned",
104 spannedPtr->RetrieveAllSpansAndRanges(*spanVectorPtr, *rangeVectorPtr);
106 CALL_CATCH_EXCEPTION();
112 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_std_vector_BaseSpan_Create() {
114 std::vector<BaseSpan> *result = 0;
118 result = (std::vector<BaseSpan> *)new std::vector<BaseSpan>();
120 CALL_CATCH_EXCEPTION(0);
123 nuiResult = (void *)result;
127 SWIGEXPORT void SWIGSTDCALL
128 CSharp_Dali_std_vector_BaseSpan_Release(void *refVector) {
129 std::vector<BaseSpan> *spanPtr = (std::vector<BaseSpan> *)0;
131 spanPtr = (std::vector<BaseSpan> *)refVector;
136 CALL_CATCH_EXCEPTION();
140 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_std_vector_BaseSpan_ValueOfIndex(
141 void *refVector, unsigned long argIndex) {
143 std::vector<BaseSpan> *spanPtr = (std::vector<BaseSpan> *)0;
144 std::vector<BaseSpan>::size_type itemSize;
145 std::vector<BaseSpan>::value_type *result = 0;
147 spanPtr = (std::vector<BaseSpan> *)refVector;
148 itemSize = (std::vector<BaseSpan>::size_type)argIndex;
152 (std::vector<BaseSpan>::value_type *)&(spanPtr)->operator[](itemSize);
154 CALL_CATCH_EXCEPTION(0);
157 nuiResult = (void *)result;
161 SWIGEXPORT int SWIGSTDCALL CSharp_Dali_std_vector_BaseSpan_TypeOfIndex(
162 void *refVector, unsigned long argIndex) {
164 Dali::Toolkit::Text::SpanType::Value result;
165 std::vector<BaseSpan> *item = (std::vector<BaseSpan> *)0;
166 std::vector<BaseSpan>::size_type itemSize;
167 std::vector<BaseSpan>::value_type *spanPtr = 0;
169 item = (std::vector<BaseSpan> *)refVector;
170 itemSize = (std::vector<BaseSpan>::size_type)argIndex;
174 (std::vector<BaseSpan>::value_type *)&(item)->operator[](itemSize);
175 result = spanPtr->GetSpanType();
177 CALL_CATCH_EXCEPTION(0);
180 int nuiResult = (int)result;
184 SWIGEXPORT int SWIGSTDCALL
185 CSharp_Dali_std_vector_BaseSpan_Size(void *refVector) {
186 std::vector<BaseSpan> *spanVectorPtr = (std::vector<BaseSpan> *)0;
189 spanVectorPtr = (std::vector<BaseSpan> *)refVector;
192 size = (spanVectorPtr)->size();
194 CALL_CATCH_EXCEPTION(0);
200 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_std_vector_Range_Create() {
202 std::vector<Range> *result = 0;
206 result = (std::vector<Range> *)new std::vector<Range>();
208 CALL_CATCH_EXCEPTION(0);
211 nuiResult = (void *)result;
215 SWIGEXPORT void SWIGSTDCALL
216 CSharp_Dali_std_vector_Range_Release(void *refVector) {
217 std::vector<Range> *rangePtr = (std::vector<Range> *)0;
219 rangePtr = (std::vector<Range> *)refVector;
224 CALL_CATCH_EXCEPTION();
228 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_std_vector_Range_ValueOfIndex(
229 void *refVector, unsigned long argIndex) {
231 std::vector<Range> *rangePtr = (std::vector<Range> *)0;
232 std::vector<Range>::size_type itemSize;
233 std::vector<Range>::value_type *result = 0;
235 rangePtr = (std::vector<Range> *)refVector;
236 itemSize = (std::vector<Range>::size_type)argIndex;
240 (std::vector<Range>::value_type *)&(rangePtr)->operator[](itemSize);
242 CALL_CATCH_EXCEPTION(0);
245 nuiResult = (void *)result;
249 SWIGEXPORT int SWIGSTDCALL CSharp_Dali_std_vector_Range_Size(void *refVector) {
250 std::vector<Range> *rangePtr = (std::vector<Range> *)0;
253 rangePtr = (std::vector<Range> *)refVector;
256 size = (rangePtr)->size();
258 CALL_CATCH_EXCEPTION(0);