• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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=5fb43e3f68ef5f431fe6d6f84d399dc0cd292d7d$
13 //
14 
15 #include "libcef_dll/cpptoc/v8context_cpptoc.h"
16 #include "libcef_dll/cpptoc/browser_cpptoc.h"
17 #include "libcef_dll/cpptoc/frame_cpptoc.h"
18 #include "libcef_dll/cpptoc/task_runner_cpptoc.h"
19 #include "libcef_dll/cpptoc/v8exception_cpptoc.h"
20 #include "libcef_dll/cpptoc/v8value_cpptoc.h"
21 
22 // GLOBAL FUNCTIONS - Body may be edited by hand.
23 
cef_v8context_get_current_context()24 CEF_EXPORT cef_v8context_t* cef_v8context_get_current_context() {
25   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
26 
27   // Execute
28   CefRefPtr<CefV8Context> _retval = CefV8Context::GetCurrentContext();
29 
30   // Return type: refptr_same
31   return CefV8ContextCppToC::Wrap(_retval);
32 }
33 
cef_v8context_get_entered_context()34 CEF_EXPORT cef_v8context_t* cef_v8context_get_entered_context() {
35   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
36 
37   // Execute
38   CefRefPtr<CefV8Context> _retval = CefV8Context::GetEnteredContext();
39 
40   // Return type: refptr_same
41   return CefV8ContextCppToC::Wrap(_retval);
42 }
43 
cef_v8context_in_context()44 CEF_EXPORT int cef_v8context_in_context() {
45   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
46 
47   // Execute
48   bool _retval = CefV8Context::InContext();
49 
50   // Return type: bool
51   return _retval;
52 }
53 
54 namespace {
55 
56 // MEMBER FUNCTIONS - Body may be edited by hand.
57 
58 cef_task_runner_t* CEF_CALLBACK
v8context_get_task_runner(struct _cef_v8context_t * self)59 v8context_get_task_runner(struct _cef_v8context_t* self) {
60   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
61 
62   DCHECK(self);
63   if (!self)
64     return NULL;
65 
66   // Execute
67   CefRefPtr<CefTaskRunner> _retval =
68       CefV8ContextCppToC::Get(self)->GetTaskRunner();
69 
70   // Return type: refptr_same
71   return CefTaskRunnerCppToC::Wrap(_retval);
72 }
73 
v8context_is_valid(struct _cef_v8context_t * self)74 int CEF_CALLBACK v8context_is_valid(struct _cef_v8context_t* self) {
75   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
76 
77   DCHECK(self);
78   if (!self)
79     return 0;
80 
81   // Execute
82   bool _retval = CefV8ContextCppToC::Get(self)->IsValid();
83 
84   // Return type: bool
85   return _retval;
86 }
87 
88 cef_browser_t* CEF_CALLBACK
v8context_get_browser(struct _cef_v8context_t * self)89 v8context_get_browser(struct _cef_v8context_t* self) {
90   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
91 
92   DCHECK(self);
93   if (!self)
94     return NULL;
95 
96   // Execute
97   CefRefPtr<CefBrowser> _retval = CefV8ContextCppToC::Get(self)->GetBrowser();
98 
99   // Return type: refptr_same
100   return CefBrowserCppToC::Wrap(_retval);
101 }
102 
v8context_get_frame(struct _cef_v8context_t * self)103 cef_frame_t* CEF_CALLBACK v8context_get_frame(struct _cef_v8context_t* self) {
104   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
105 
106   DCHECK(self);
107   if (!self)
108     return NULL;
109 
110   // Execute
111   CefRefPtr<CefFrame> _retval = CefV8ContextCppToC::Get(self)->GetFrame();
112 
113   // Return type: refptr_same
114   return CefFrameCppToC::Wrap(_retval);
115 }
116 
117 struct _cef_v8value_t* CEF_CALLBACK
v8context_get_global(struct _cef_v8context_t * self)118 v8context_get_global(struct _cef_v8context_t* self) {
119   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
120 
121   DCHECK(self);
122   if (!self)
123     return NULL;
124 
125   // Execute
126   CefRefPtr<CefV8Value> _retval = CefV8ContextCppToC::Get(self)->GetGlobal();
127 
128   // Return type: refptr_same
129   return CefV8ValueCppToC::Wrap(_retval);
130 }
131 
v8context_enter(struct _cef_v8context_t * self)132 int CEF_CALLBACK v8context_enter(struct _cef_v8context_t* self) {
133   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
134 
135   DCHECK(self);
136   if (!self)
137     return 0;
138 
139   // Execute
140   bool _retval = CefV8ContextCppToC::Get(self)->Enter();
141 
142   // Return type: bool
143   return _retval;
144 }
145 
v8context_exit(struct _cef_v8context_t * self)146 int CEF_CALLBACK v8context_exit(struct _cef_v8context_t* self) {
147   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
148 
149   DCHECK(self);
150   if (!self)
151     return 0;
152 
153   // Execute
154   bool _retval = CefV8ContextCppToC::Get(self)->Exit();
155 
156   // Return type: bool
157   return _retval;
158 }
159 
v8context_is_same(struct _cef_v8context_t * self,struct _cef_v8context_t * that)160 int CEF_CALLBACK v8context_is_same(struct _cef_v8context_t* self,
161                                    struct _cef_v8context_t* that) {
162   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
163 
164   DCHECK(self);
165   if (!self)
166     return 0;
167   // Verify param: that; type: refptr_same
168   DCHECK(that);
169   if (!that)
170     return 0;
171 
172   // Execute
173   bool _retval =
174       CefV8ContextCppToC::Get(self)->IsSame(CefV8ContextCppToC::Unwrap(that));
175 
176   // Return type: bool
177   return _retval;
178 }
179 
v8context_eval(struct _cef_v8context_t * self,const cef_string_t * code,const cef_string_t * script_url,int start_line,struct _cef_v8value_t ** retval,struct _cef_v8exception_t ** exception)180 int CEF_CALLBACK v8context_eval(struct _cef_v8context_t* self,
181                                 const cef_string_t* code,
182                                 const cef_string_t* script_url,
183                                 int start_line,
184                                 struct _cef_v8value_t** retval,
185                                 struct _cef_v8exception_t** exception) {
186   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
187 
188   DCHECK(self);
189   if (!self)
190     return 0;
191   // Verify param: code; type: string_byref_const
192   DCHECK(code);
193   if (!code)
194     return 0;
195   // Verify param: retval; type: refptr_same_byref
196   DCHECK(retval);
197   if (!retval)
198     return 0;
199   // Verify param: exception; type: refptr_same_byref
200   DCHECK(exception);
201   if (!exception)
202     return 0;
203   // Unverified params: script_url
204 
205   // Translate param: retval; type: refptr_same_byref
206   CefRefPtr<CefV8Value> retvalPtr;
207   if (retval && *retval)
208     retvalPtr = CefV8ValueCppToC::Unwrap(*retval);
209   CefV8Value* retvalOrig = retvalPtr.get();
210   // Translate param: exception; type: refptr_same_byref
211   CefRefPtr<CefV8Exception> exceptionPtr;
212   if (exception && *exception)
213     exceptionPtr = CefV8ExceptionCppToC::Unwrap(*exception);
214   CefV8Exception* exceptionOrig = exceptionPtr.get();
215 
216   // Execute
217   bool _retval = CefV8ContextCppToC::Get(self)->Eval(
218       CefString(code), CefString(script_url), start_line, retvalPtr,
219       exceptionPtr);
220 
221   // Restore param: retval; type: refptr_same_byref
222   if (retval) {
223     if (retvalPtr.get()) {
224       if (retvalPtr.get() != retvalOrig) {
225         *retval = CefV8ValueCppToC::Wrap(retvalPtr);
226       }
227     } else {
228       *retval = nullptr;
229     }
230   }
231   // Restore param: exception; type: refptr_same_byref
232   if (exception) {
233     if (exceptionPtr.get()) {
234       if (exceptionPtr.get() != exceptionOrig) {
235         *exception = CefV8ExceptionCppToC::Wrap(exceptionPtr);
236       }
237     } else {
238       *exception = nullptr;
239     }
240   }
241 
242   // Return type: bool
243   return _retval;
244 }
245 
246 }  // namespace
247 
248 // CONSTRUCTOR - Do not edit by hand.
249 
CefV8ContextCppToC()250 CefV8ContextCppToC::CefV8ContextCppToC() {
251   GetStruct()->get_task_runner = v8context_get_task_runner;
252   GetStruct()->is_valid = v8context_is_valid;
253   GetStruct()->get_browser = v8context_get_browser;
254   GetStruct()->get_frame = v8context_get_frame;
255   GetStruct()->get_global = v8context_get_global;
256   GetStruct()->enter = v8context_enter;
257   GetStruct()->exit = v8context_exit;
258   GetStruct()->is_same = v8context_is_same;
259   GetStruct()->eval = v8context_eval;
260 }
261 
262 // DESTRUCTOR - Do not edit by hand.
263 
~CefV8ContextCppToC()264 CefV8ContextCppToC::~CefV8ContextCppToC() {}
265 
266 template <>
267 CefRefPtr<CefV8Context>
268 CefCppToCRefCounted<CefV8ContextCppToC, CefV8Context, cef_v8context_t>::
UnwrapDerived(CefWrapperType type,cef_v8context_t * s)269     UnwrapDerived(CefWrapperType type, cef_v8context_t* s) {
270   NOTREACHED() << "Unexpected class type: " << type;
271   return nullptr;
272 }
273 
274 template <>
275 CefWrapperType CefCppToCRefCounted<CefV8ContextCppToC,
276                                    CefV8Context,
277                                    cef_v8context_t>::kWrapperType =
278     WT_V8CONTEXT;
279