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=fcbdc299c4f34868f817a9b77777a9b88f3cf07b$
13 //
14
15 #include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
16 #include "libcef_dll/ctocpp/read_handler_ctocpp.h"
17 #include "libcef_dll/shutdown_checker.h"
18
19 // GLOBAL FUNCTIONS - Body may be edited by hand.
20
cef_stream_reader_create_for_file(const cef_string_t * fileName)21 CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_file(
22 const cef_string_t* fileName) {
23 shutdown_checker::AssertNotShutdown();
24
25 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
26
27 // Verify param: fileName; type: string_byref_const
28 DCHECK(fileName);
29 if (!fileName)
30 return NULL;
31
32 // Execute
33 CefRefPtr<CefStreamReader> _retval =
34 CefStreamReader::CreateForFile(CefString(fileName));
35
36 // Return type: refptr_same
37 return CefStreamReaderCppToC::Wrap(_retval);
38 }
39
cef_stream_reader_create_for_data(void * data,size_t size)40 CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_data(void* data,
41 size_t size) {
42 shutdown_checker::AssertNotShutdown();
43
44 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
45
46 // Verify param: data; type: simple_byaddr
47 DCHECK(data);
48 if (!data)
49 return NULL;
50
51 // Execute
52 CefRefPtr<CefStreamReader> _retval =
53 CefStreamReader::CreateForData(data, size);
54
55 // Return type: refptr_same
56 return CefStreamReaderCppToC::Wrap(_retval);
57 }
58
cef_stream_reader_create_for_handler(cef_read_handler_t * handler)59 CEF_EXPORT cef_stream_reader_t* cef_stream_reader_create_for_handler(
60 cef_read_handler_t* handler) {
61 shutdown_checker::AssertNotShutdown();
62
63 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
64
65 // Verify param: handler; type: refptr_diff
66 DCHECK(handler);
67 if (!handler)
68 return NULL;
69
70 // Execute
71 CefRefPtr<CefStreamReader> _retval =
72 CefStreamReader::CreateForHandler(CefReadHandlerCToCpp::Wrap(handler));
73
74 // Return type: refptr_same
75 return CefStreamReaderCppToC::Wrap(_retval);
76 }
77
78 namespace {
79
80 // MEMBER FUNCTIONS - Body may be edited by hand.
81
stream_reader_read(struct _cef_stream_reader_t * self,void * ptr,size_t size,size_t n)82 size_t CEF_CALLBACK stream_reader_read(struct _cef_stream_reader_t* self,
83 void* ptr,
84 size_t size,
85 size_t n) {
86 shutdown_checker::AssertNotShutdown();
87
88 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
89
90 DCHECK(self);
91 if (!self)
92 return 0;
93 // Verify param: ptr; type: simple_byaddr
94 DCHECK(ptr);
95 if (!ptr)
96 return 0;
97
98 // Execute
99 size_t _retval = CefStreamReaderCppToC::Get(self)->Read(ptr, size, n);
100
101 // Return type: simple
102 return _retval;
103 }
104
stream_reader_seek(struct _cef_stream_reader_t * self,int64 offset,int whence)105 int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* self,
106 int64 offset,
107 int whence) {
108 shutdown_checker::AssertNotShutdown();
109
110 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
111
112 DCHECK(self);
113 if (!self)
114 return 0;
115
116 // Execute
117 int _retval = CefStreamReaderCppToC::Get(self)->Seek(offset, whence);
118
119 // Return type: simple
120 return _retval;
121 }
122
stream_reader_tell(struct _cef_stream_reader_t * self)123 int64 CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* self) {
124 shutdown_checker::AssertNotShutdown();
125
126 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
127
128 DCHECK(self);
129 if (!self)
130 return 0;
131
132 // Execute
133 int64 _retval = CefStreamReaderCppToC::Get(self)->Tell();
134
135 // Return type: simple
136 return _retval;
137 }
138
stream_reader_eof(struct _cef_stream_reader_t * self)139 int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* self) {
140 shutdown_checker::AssertNotShutdown();
141
142 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
143
144 DCHECK(self);
145 if (!self)
146 return 0;
147
148 // Execute
149 int _retval = CefStreamReaderCppToC::Get(self)->Eof();
150
151 // Return type: simple
152 return _retval;
153 }
154
stream_reader_may_block(struct _cef_stream_reader_t * self)155 int CEF_CALLBACK stream_reader_may_block(struct _cef_stream_reader_t* self) {
156 shutdown_checker::AssertNotShutdown();
157
158 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
159
160 DCHECK(self);
161 if (!self)
162 return 0;
163
164 // Execute
165 bool _retval = CefStreamReaderCppToC::Get(self)->MayBlock();
166
167 // Return type: bool
168 return _retval;
169 }
170
171 } // namespace
172
173 // CONSTRUCTOR - Do not edit by hand.
174
CefStreamReaderCppToC()175 CefStreamReaderCppToC::CefStreamReaderCppToC() {
176 GetStruct()->read = stream_reader_read;
177 GetStruct()->seek = stream_reader_seek;
178 GetStruct()->tell = stream_reader_tell;
179 GetStruct()->eof = stream_reader_eof;
180 GetStruct()->may_block = stream_reader_may_block;
181 }
182
183 // DESTRUCTOR - Do not edit by hand.
184
~CefStreamReaderCppToC()185 CefStreamReaderCppToC::~CefStreamReaderCppToC() {
186 shutdown_checker::AssertNotShutdown();
187 }
188
189 template <>
190 CefRefPtr<CefStreamReader> CefCppToCRefCounted<
191 CefStreamReaderCppToC,
192 CefStreamReader,
UnwrapDerived(CefWrapperType type,cef_stream_reader_t * s)193 cef_stream_reader_t>::UnwrapDerived(CefWrapperType type,
194 cef_stream_reader_t* s) {
195 NOTREACHED() << "Unexpected class type: " << type;
196 return nullptr;
197 }
198
199 template <>
200 CefWrapperType CefCppToCRefCounted<CefStreamReaderCppToC,
201 CefStreamReader,
202 cef_stream_reader_t>::kWrapperType =
203 WT_STREAM_READER;
204