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=e32b4745b887e33f589cb04e8b46a7317686e4c2$
13 //
14
15 #include "libcef_dll/ctocpp/stream_writer_ctocpp.h"
16 #include "libcef_dll/cpptoc/write_handler_cpptoc.h"
17 #include "libcef_dll/shutdown_checker.h"
18
19 // STATIC METHODS - Body may be edited by hand.
20
21 NO_SANITIZE("cfi-icall")
CreateForFile(const CefString & fileName)22 CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForFile(
23 const CefString& fileName) {
24 shutdown_checker::AssertNotShutdown();
25
26 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
27
28 // Verify param: fileName; type: string_byref_const
29 DCHECK(!fileName.empty());
30 if (fileName.empty())
31 return nullptr;
32
33 // Execute
34 cef_stream_writer_t* _retval =
35 cef_stream_writer_create_for_file(fileName.GetStruct());
36
37 // Return type: refptr_same
38 return CefStreamWriterCToCpp::Wrap(_retval);
39 }
40
41 NO_SANITIZE("cfi-icall")
CreateForHandler(CefRefPtr<CefWriteHandler> handler)42 CefRefPtr<CefStreamWriter> CefStreamWriter::CreateForHandler(
43 CefRefPtr<CefWriteHandler> handler) {
44 shutdown_checker::AssertNotShutdown();
45
46 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
47
48 // Verify param: handler; type: refptr_diff
49 DCHECK(handler.get());
50 if (!handler.get())
51 return nullptr;
52
53 // Execute
54 cef_stream_writer_t* _retval = cef_stream_writer_create_for_handler(
55 CefWriteHandlerCppToC::Wrap(handler));
56
57 // Return type: refptr_same
58 return CefStreamWriterCToCpp::Wrap(_retval);
59 }
60
61 // VIRTUAL METHODS - Body may be edited by hand.
62
63 NO_SANITIZE("cfi-icall")
Write(const void * ptr,size_t size,size_t n)64 size_t CefStreamWriterCToCpp::Write(const void* ptr, size_t size, size_t n) {
65 shutdown_checker::AssertNotShutdown();
66
67 cef_stream_writer_t* _struct = GetStruct();
68 if (CEF_MEMBER_MISSING(_struct, write))
69 return 0;
70
71 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
72
73 // Verify param: ptr; type: simple_byaddr
74 DCHECK(ptr);
75 if (!ptr)
76 return 0;
77
78 // Execute
79 size_t _retval = _struct->write(_struct, ptr, size, n);
80
81 // Return type: simple
82 return _retval;
83 }
84
85 NO_SANITIZE("cfi-icall")
Seek(int64 offset,int whence)86 int CefStreamWriterCToCpp::Seek(int64 offset, int whence) {
87 shutdown_checker::AssertNotShutdown();
88
89 cef_stream_writer_t* _struct = GetStruct();
90 if (CEF_MEMBER_MISSING(_struct, seek))
91 return 0;
92
93 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
94
95 // Execute
96 int _retval = _struct->seek(_struct, offset, whence);
97
98 // Return type: simple
99 return _retval;
100 }
101
Tell()102 NO_SANITIZE("cfi-icall") int64 CefStreamWriterCToCpp::Tell() {
103 shutdown_checker::AssertNotShutdown();
104
105 cef_stream_writer_t* _struct = GetStruct();
106 if (CEF_MEMBER_MISSING(_struct, tell))
107 return 0;
108
109 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
110
111 // Execute
112 int64 _retval = _struct->tell(_struct);
113
114 // Return type: simple
115 return _retval;
116 }
117
Flush()118 NO_SANITIZE("cfi-icall") int CefStreamWriterCToCpp::Flush() {
119 shutdown_checker::AssertNotShutdown();
120
121 cef_stream_writer_t* _struct = GetStruct();
122 if (CEF_MEMBER_MISSING(_struct, flush))
123 return 0;
124
125 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
126
127 // Execute
128 int _retval = _struct->flush(_struct);
129
130 // Return type: simple
131 return _retval;
132 }
133
MayBlock()134 NO_SANITIZE("cfi-icall") bool CefStreamWriterCToCpp::MayBlock() {
135 shutdown_checker::AssertNotShutdown();
136
137 cef_stream_writer_t* _struct = GetStruct();
138 if (CEF_MEMBER_MISSING(_struct, may_block))
139 return false;
140
141 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
142
143 // Execute
144 int _retval = _struct->may_block(_struct);
145
146 // Return type: bool
147 return _retval ? true : false;
148 }
149
150 // CONSTRUCTOR - Do not edit by hand.
151
CefStreamWriterCToCpp()152 CefStreamWriterCToCpp::CefStreamWriterCToCpp() {}
153
154 // DESTRUCTOR - Do not edit by hand.
155
~CefStreamWriterCToCpp()156 CefStreamWriterCToCpp::~CefStreamWriterCToCpp() {
157 shutdown_checker::AssertNotShutdown();
158 }
159
160 template <>
161 cef_stream_writer_t*
162 CefCToCppRefCounted<CefStreamWriterCToCpp,
163 CefStreamWriter,
UnwrapDerived(CefWrapperType type,CefStreamWriter * c)164 cef_stream_writer_t>::UnwrapDerived(CefWrapperType type,
165 CefStreamWriter* c) {
166 NOTREACHED() << "Unexpected class type: " << type;
167 return nullptr;
168 }
169
170 template <>
171 CefWrapperType CefCToCppRefCounted<CefStreamWriterCToCpp,
172 CefStreamWriter,
173 cef_stream_writer_t>::kWrapperType =
174 WT_STREAM_WRITER;
175