1 // Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 //
5 // ---------------------------------------------------------------------------
6 //
7 // This file was generated by the CEF translator tool. If making changes by
8 // hand only do so within the body of existing method and function
9 // implementations. See the translator.README.txt file in the tools directory
10 // for more information.
11 //
12 // $hash=935efc8f333c6df95b783e1e80bb84aa26d55b9b$
13 //
14
15 #include "libcef_dll/cpptoc/post_data_cpptoc.h"
16 #include <algorithm>
17 #include "libcef_dll/cpptoc/post_data_element_cpptoc.h"
18
19 // GLOBAL FUNCTIONS - Body may be edited by hand.
20
cef_post_data_create()21 CEF_EXPORT cef_post_data_t* cef_post_data_create() {
22 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
23
24 // Execute
25 CefRefPtr<CefPostData> _retval = CefPostData::Create();
26
27 // Return type: refptr_same
28 return CefPostDataCppToC::Wrap(_retval);
29 }
30
31 namespace {
32
33 // MEMBER FUNCTIONS - Body may be edited by hand.
34
post_data_is_read_only(struct _cef_post_data_t * self)35 int CEF_CALLBACK post_data_is_read_only(struct _cef_post_data_t* self) {
36 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
37
38 DCHECK(self);
39 if (!self)
40 return 0;
41
42 // Execute
43 bool _retval = CefPostDataCppToC::Get(self)->IsReadOnly();
44
45 // Return type: bool
46 return _retval;
47 }
48
49 int CEF_CALLBACK
post_data_has_excluded_elements(struct _cef_post_data_t * self)50 post_data_has_excluded_elements(struct _cef_post_data_t* self) {
51 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
52
53 DCHECK(self);
54 if (!self)
55 return 0;
56
57 // Execute
58 bool _retval = CefPostDataCppToC::Get(self)->HasExcludedElements();
59
60 // Return type: bool
61 return _retval;
62 }
63
post_data_get_element_count(struct _cef_post_data_t * self)64 size_t CEF_CALLBACK post_data_get_element_count(struct _cef_post_data_t* self) {
65 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
66
67 DCHECK(self);
68 if (!self)
69 return 0;
70
71 // Execute
72 size_t _retval = CefPostDataCppToC::Get(self)->GetElementCount();
73
74 // Return type: simple
75 return _retval;
76 }
77
78 void CEF_CALLBACK
post_data_get_elements(struct _cef_post_data_t * self,size_t * elementsCount,struct _cef_post_data_element_t ** elements)79 post_data_get_elements(struct _cef_post_data_t* self,
80 size_t* elementsCount,
81 struct _cef_post_data_element_t** elements) {
82 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
83
84 DCHECK(self);
85 if (!self)
86 return;
87 // Verify param: elements; type: refptr_vec_same_byref
88 DCHECK(elementsCount && (*elementsCount == 0 || elements));
89 if (!elementsCount || (*elementsCount > 0 && !elements))
90 return;
91
92 // Translate param: elements; type: refptr_vec_same_byref
93 std::vector<CefRefPtr<CefPostDataElement>> elementsList;
94 if (elementsCount && *elementsCount > 0 && elements) {
95 for (size_t i = 0; i < *elementsCount; ++i) {
96 elementsList.push_back(CefPostDataElementCppToC::Unwrap(elements[i]));
97 }
98 }
99
100 // Execute
101 CefPostDataCppToC::Get(self)->GetElements(elementsList);
102
103 // Restore param: elements; type: refptr_vec_same_byref
104 if (elementsCount && elements) {
105 *elementsCount = std::min(elementsList.size(), *elementsCount);
106 if (*elementsCount > 0) {
107 for (size_t i = 0; i < *elementsCount; ++i) {
108 elements[i] = CefPostDataElementCppToC::Wrap(elementsList[i]);
109 }
110 }
111 }
112 }
113
114 int CEF_CALLBACK
post_data_remove_element(struct _cef_post_data_t * self,struct _cef_post_data_element_t * element)115 post_data_remove_element(struct _cef_post_data_t* self,
116 struct _cef_post_data_element_t* element) {
117 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
118
119 DCHECK(self);
120 if (!self)
121 return 0;
122 // Verify param: element; type: refptr_same
123 DCHECK(element);
124 if (!element)
125 return 0;
126
127 // Execute
128 bool _retval = CefPostDataCppToC::Get(self)->RemoveElement(
129 CefPostDataElementCppToC::Unwrap(element));
130
131 // Return type: bool
132 return _retval;
133 }
134
135 int CEF_CALLBACK
post_data_add_element(struct _cef_post_data_t * self,struct _cef_post_data_element_t * element)136 post_data_add_element(struct _cef_post_data_t* self,
137 struct _cef_post_data_element_t* element) {
138 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
139
140 DCHECK(self);
141 if (!self)
142 return 0;
143 // Verify param: element; type: refptr_same
144 DCHECK(element);
145 if (!element)
146 return 0;
147
148 // Execute
149 bool _retval = CefPostDataCppToC::Get(self)->AddElement(
150 CefPostDataElementCppToC::Unwrap(element));
151
152 // Return type: bool
153 return _retval;
154 }
155
post_data_remove_elements(struct _cef_post_data_t * self)156 void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* self) {
157 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
158
159 DCHECK(self);
160 if (!self)
161 return;
162
163 // Execute
164 CefPostDataCppToC::Get(self)->RemoveElements();
165 }
166
167 } // namespace
168
169 // CONSTRUCTOR - Do not edit by hand.
170
CefPostDataCppToC()171 CefPostDataCppToC::CefPostDataCppToC() {
172 GetStruct()->is_read_only = post_data_is_read_only;
173 GetStruct()->has_excluded_elements = post_data_has_excluded_elements;
174 GetStruct()->get_element_count = post_data_get_element_count;
175 GetStruct()->get_elements = post_data_get_elements;
176 GetStruct()->remove_element = post_data_remove_element;
177 GetStruct()->add_element = post_data_add_element;
178 GetStruct()->remove_elements = post_data_remove_elements;
179 }
180
181 // DESTRUCTOR - Do not edit by hand.
182
~CefPostDataCppToC()183 CefPostDataCppToC::~CefPostDataCppToC() {}
184
185 template <>
186 CefRefPtr<CefPostData>
187 CefCppToCRefCounted<CefPostDataCppToC, CefPostData, cef_post_data_t>::
UnwrapDerived(CefWrapperType type,cef_post_data_t * s)188 UnwrapDerived(CefWrapperType type, cef_post_data_t* s) {
189 NOTREACHED() << "Unexpected class type: " << type;
190 return nullptr;
191 }
192
193 template <>
194 CefWrapperType CefCppToCRefCounted<CefPostDataCppToC,
195 CefPostData,
196 cef_post_data_t>::kWrapperType =
197 WT_POST_DATA;
198