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=ac20659d83a6efb764f3b55756dbc8c686fc5363$
13 //
14
15 #include "libcef_dll/cpptoc/stream_writer_cpptoc.h"
16 #include "libcef_dll/ctocpp/write_handler_ctocpp.h"
17 #include "libcef_dll/shutdown_checker.h"
18
19 // GLOBAL FUNCTIONS - Body may be edited by hand.
20
cef_stream_writer_create_for_file(const cef_string_t * fileName)21 CEF_EXPORT cef_stream_writer_t* cef_stream_writer_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<CefStreamWriter> _retval =
34 CefStreamWriter::CreateForFile(CefString(fileName));
35
36 // Return type: refptr_same
37 return CefStreamWriterCppToC::Wrap(_retval);
38 }
39
cef_stream_writer_create_for_handler(cef_write_handler_t * handler)40 CEF_EXPORT cef_stream_writer_t* cef_stream_writer_create_for_handler(
41 cef_write_handler_t* handler) {
42 shutdown_checker::AssertNotShutdown();
43
44 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
45
46 // Verify param: handler; type: refptr_diff
47 DCHECK(handler);
48 if (!handler)
49 return NULL;
50
51 // Execute
52 CefRefPtr<CefStreamWriter> _retval =
53 CefStreamWriter::CreateForHandler(CefWriteHandlerCToCpp::Wrap(handler));
54
55 // Return type: refptr_same
56 return CefStreamWriterCppToC::Wrap(_retval);
57 }
58
59 namespace {
60
61 // MEMBER FUNCTIONS - Body may be edited by hand.
62
stream_writer_write(struct _cef_stream_writer_t * self,const void * ptr,size_t size,size_t n)63 size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* self,
64 const void* ptr,
65 size_t size,
66 size_t n) {
67 shutdown_checker::AssertNotShutdown();
68
69 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
70
71 DCHECK(self);
72 if (!self)
73 return 0;
74 // Verify param: ptr; type: simple_byaddr
75 DCHECK(ptr);
76 if (!ptr)
77 return 0;
78
79 // Execute
80 size_t _retval = CefStreamWriterCppToC::Get(self)->Write(ptr, size, n);
81
82 // Return type: simple
83 return _retval;
84 }
85
stream_writer_seek(struct _cef_stream_writer_t * self,int64 offset,int whence)86 int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* self,
87 int64 offset,
88 int whence) {
89 shutdown_checker::AssertNotShutdown();
90
91 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
92
93 DCHECK(self);
94 if (!self)
95 return 0;
96
97 // Execute
98 int _retval = CefStreamWriterCppToC::Get(self)->Seek(offset, whence);
99
100 // Return type: simple
101 return _retval;
102 }
103
stream_writer_tell(struct _cef_stream_writer_t * self)104 int64 CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* self) {
105 shutdown_checker::AssertNotShutdown();
106
107 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
108
109 DCHECK(self);
110 if (!self)
111 return 0;
112
113 // Execute
114 int64 _retval = CefStreamWriterCppToC::Get(self)->Tell();
115
116 // Return type: simple
117 return _retval;
118 }
119
stream_writer_flush(struct _cef_stream_writer_t * self)120 int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* self) {
121 shutdown_checker::AssertNotShutdown();
122
123 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
124
125 DCHECK(self);
126 if (!self)
127 return 0;
128
129 // Execute
130 int _retval = CefStreamWriterCppToC::Get(self)->Flush();
131
132 // Return type: simple
133 return _retval;
134 }
135
stream_writer_may_block(struct _cef_stream_writer_t * self)136 int CEF_CALLBACK stream_writer_may_block(struct _cef_stream_writer_t* self) {
137 shutdown_checker::AssertNotShutdown();
138
139 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
140
141 DCHECK(self);
142 if (!self)
143 return 0;
144
145 // Execute
146 bool _retval = CefStreamWriterCppToC::Get(self)->MayBlock();
147
148 // Return type: bool
149 return _retval;
150 }
151
152 } // namespace
153
154 // CONSTRUCTOR - Do not edit by hand.
155
CefStreamWriterCppToC()156 CefStreamWriterCppToC::CefStreamWriterCppToC() {
157 GetStruct()->write = stream_writer_write;
158 GetStruct()->seek = stream_writer_seek;
159 GetStruct()->tell = stream_writer_tell;
160 GetStruct()->flush = stream_writer_flush;
161 GetStruct()->may_block = stream_writer_may_block;
162 }
163
164 // DESTRUCTOR - Do not edit by hand.
165
~CefStreamWriterCppToC()166 CefStreamWriterCppToC::~CefStreamWriterCppToC() {
167 shutdown_checker::AssertNotShutdown();
168 }
169
170 template <>
171 CefRefPtr<CefStreamWriter> CefCppToCRefCounted<
172 CefStreamWriterCppToC,
173 CefStreamWriter,
UnwrapDerived(CefWrapperType type,cef_stream_writer_t * s)174 cef_stream_writer_t>::UnwrapDerived(CefWrapperType type,
175 cef_stream_writer_t* s) {
176 NOTREACHED() << "Unexpected class type: " << type;
177 return nullptr;
178 }
179
180 template <>
181 CefWrapperType CefCppToCRefCounted<CefStreamWriterCppToC,
182 CefStreamWriter,
183 cef_stream_writer_t>::kWrapperType =
184 WT_STREAM_WRITER;
185