1 // Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // This file was generated by the CEF translator tool and should not edited 33 // by hand. See the translator.README.txt file in the tools directory for 34 // more information. 35 // 36 // $hash=2bdcad7f8e3c03285a5e5ddb9a02a5a2182f254c$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_base_capi.h" 44 #include "include/capi/cef_browser_capi.h" 45 #include "include/capi/cef_frame_capi.h" 46 #include "include/capi/cef_task_capi.h" 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 struct _cef_v8exception_t; 53 struct _cef_v8handler_t; 54 struct _cef_v8stack_frame_t; 55 struct _cef_v8value_t; 56 57 /// 58 // Structure representing a V8 context handle. V8 handles can only be accessed 59 // from the thread on which they are created. Valid threads for creating a V8 60 // handle include the render process main thread (TID_RENDERER) and WebWorker 61 // threads. A task runner for posting tasks on the associated thread can be 62 // retrieved via the cef_v8context_t::get_task_runner() function. 63 /// 64 typedef struct _cef_v8context_t { 65 /// 66 // Base structure. 67 /// 68 cef_base_ref_counted_t base; 69 70 /// 71 // Returns the task runner associated with this context. V8 handles can only 72 // be accessed from the thread on which they are created. This function can be 73 // called on any render process thread. 74 /// 75 struct _cef_task_runner_t*(CEF_CALLBACK* get_task_runner)( 76 struct _cef_v8context_t* self); 77 78 /// 79 // Returns true (1) if the underlying handle is valid and it can be accessed 80 // on the current thread. Do not call any other functions if this function 81 // returns false (0). 82 /// 83 int(CEF_CALLBACK* is_valid)(struct _cef_v8context_t* self); 84 85 /// 86 // Returns the browser for this context. This function will return an NULL 87 // reference for WebWorker contexts. 88 /// 89 struct _cef_browser_t*(CEF_CALLBACK* get_browser)( 90 struct _cef_v8context_t* self); 91 92 /// 93 // Returns the frame for this context. This function will return an NULL 94 // reference for WebWorker contexts. 95 /// 96 struct _cef_frame_t*(CEF_CALLBACK* get_frame)(struct _cef_v8context_t* self); 97 98 /// 99 // Returns the global object for this context. The context must be entered 100 // before calling this function. 101 /// 102 struct _cef_v8value_t*(CEF_CALLBACK* get_global)( 103 struct _cef_v8context_t* self); 104 105 /// 106 // Enter this context. A context must be explicitly entered before creating a 107 // V8 Object, Array, Function or Date asynchronously. exit() must be called 108 // the same number of times as enter() before releasing this context. V8 109 // objects belong to the context in which they are created. Returns true (1) 110 // if the scope was entered successfully. 111 /// 112 int(CEF_CALLBACK* enter)(struct _cef_v8context_t* self); 113 114 /// 115 // Exit this context. Call this function only after calling enter(). Returns 116 // true (1) if the scope was exited successfully. 117 /// 118 int(CEF_CALLBACK* exit)(struct _cef_v8context_t* self); 119 120 /// 121 // Returns true (1) if this object is pointing to the same handle as |that| 122 // object. 123 /// 124 int(CEF_CALLBACK* is_same)(struct _cef_v8context_t* self, 125 struct _cef_v8context_t* that); 126 127 /// 128 // Execute a string of JavaScript code in this V8 context. The |script_url| 129 // parameter is the URL where the script in question can be found, if any. The 130 // |start_line| parameter is the base line number to use for error reporting. 131 // On success |retval| will be set to the return value, if any, and the 132 // function will return true (1). On failure |exception| will be set to the 133 // exception, if any, and the function will return false (0). 134 /// 135 int(CEF_CALLBACK* eval)(struct _cef_v8context_t* self, 136 const cef_string_t* code, 137 const cef_string_t* script_url, 138 int start_line, 139 struct _cef_v8value_t** retval, 140 struct _cef_v8exception_t** exception); 141 } cef_v8context_t; 142 143 /// 144 // Returns the current (top) context object in the V8 context stack. 145 /// 146 CEF_EXPORT cef_v8context_t* cef_v8context_get_current_context(); 147 148 /// 149 // Returns the entered (bottom) context object in the V8 context stack. 150 /// 151 CEF_EXPORT cef_v8context_t* cef_v8context_get_entered_context(); 152 153 /// 154 // Returns true (1) if V8 is currently inside a context. 155 /// 156 CEF_EXPORT int cef_v8context_in_context(); 157 158 /// 159 // Structure that should be implemented to handle V8 function calls. The 160 // functions of this structure will be called on the thread associated with the 161 // V8 function. 162 /// 163 typedef struct _cef_v8handler_t { 164 /// 165 // Base structure. 166 /// 167 cef_base_ref_counted_t base; 168 169 /// 170 // Handle execution of the function identified by |name|. |object| is the 171 // receiver ('this' object) of the function. |arguments| is the list of 172 // arguments passed to the function. If execution succeeds set |retval| to the 173 // function return value. If execution fails set |exception| to the exception 174 // that will be thrown. Return true (1) if execution was handled. 175 /// 176 int(CEF_CALLBACK* execute)(struct _cef_v8handler_t* self, 177 const cef_string_t* name, 178 struct _cef_v8value_t* object, 179 size_t argumentsCount, 180 struct _cef_v8value_t* const* arguments, 181 struct _cef_v8value_t** retval, 182 cef_string_t* exception); 183 } cef_v8handler_t; 184 185 /// 186 // Structure that should be implemented to handle V8 accessor calls. Accessor 187 // identifiers are registered by calling cef_v8value_t::set_value(). The 188 // functions of this structure will be called on the thread associated with the 189 // V8 accessor. 190 /// 191 typedef struct _cef_v8accessor_t { 192 /// 193 // Base structure. 194 /// 195 cef_base_ref_counted_t base; 196 197 /// 198 // Handle retrieval the accessor value identified by |name|. |object| is the 199 // receiver ('this' object) of the accessor. If retrieval succeeds set 200 // |retval| to the return value. If retrieval fails set |exception| to the 201 // exception that will be thrown. Return true (1) if accessor retrieval was 202 // handled. 203 /// 204 int(CEF_CALLBACK* get)(struct _cef_v8accessor_t* self, 205 const cef_string_t* name, 206 struct _cef_v8value_t* object, 207 struct _cef_v8value_t** retval, 208 cef_string_t* exception); 209 210 /// 211 // Handle assignment of the accessor value identified by |name|. |object| is 212 // the receiver ('this' object) of the accessor. |value| is the new value 213 // being assigned to the accessor. If assignment fails set |exception| to the 214 // exception that will be thrown. Return true (1) if accessor assignment was 215 // handled. 216 /// 217 int(CEF_CALLBACK* set)(struct _cef_v8accessor_t* self, 218 const cef_string_t* name, 219 struct _cef_v8value_t* object, 220 struct _cef_v8value_t* value, 221 cef_string_t* exception); 222 } cef_v8accessor_t; 223 224 /// 225 // Structure that should be implemented to handle V8 interceptor calls. The 226 // functions of this structure will be called on the thread associated with the 227 // V8 interceptor. Interceptor's named property handlers (with first argument of 228 // type CefString) are called when object is indexed by string. Indexed property 229 // handlers (with first argument of type int) are called when object is indexed 230 // by integer. 231 /// 232 typedef struct _cef_v8interceptor_t { 233 /// 234 // Base structure. 235 /// 236 cef_base_ref_counted_t base; 237 238 /// 239 // Handle retrieval of the interceptor value identified by |name|. |object| is 240 // the receiver ('this' object) of the interceptor. If retrieval succeeds, set 241 // |retval| to the return value. If the requested value does not exist, don't 242 // set either |retval| or |exception|. If retrieval fails, set |exception| to 243 // the exception that will be thrown. If the property has an associated 244 // accessor, it will be called only if you don't set |retval|. Return true (1) 245 // if interceptor retrieval was handled, false (0) otherwise. 246 /// 247 int(CEF_CALLBACK* get_byname)(struct _cef_v8interceptor_t* self, 248 const cef_string_t* name, 249 struct _cef_v8value_t* object, 250 struct _cef_v8value_t** retval, 251 cef_string_t* exception); 252 253 /// 254 // Handle retrieval of the interceptor value identified by |index|. |object| 255 // is the receiver ('this' object) of the interceptor. If retrieval succeeds, 256 // set |retval| to the return value. If the requested value does not exist, 257 // don't set either |retval| or |exception|. If retrieval fails, set 258 // |exception| to the exception that will be thrown. Return true (1) if 259 // interceptor retrieval was handled, false (0) otherwise. 260 /// 261 int(CEF_CALLBACK* get_byindex)(struct _cef_v8interceptor_t* self, 262 int index, 263 struct _cef_v8value_t* object, 264 struct _cef_v8value_t** retval, 265 cef_string_t* exception); 266 267 /// 268 // Handle assignment of the interceptor value identified by |name|. |object| 269 // is the receiver ('this' object) of the interceptor. |value| is the new 270 // value being assigned to the interceptor. If assignment fails, set 271 // |exception| to the exception that will be thrown. This setter will always 272 // be called, even when the property has an associated accessor. Return true 273 // (1) if interceptor assignment was handled, false (0) otherwise. 274 /// 275 int(CEF_CALLBACK* set_byname)(struct _cef_v8interceptor_t* self, 276 const cef_string_t* name, 277 struct _cef_v8value_t* object, 278 struct _cef_v8value_t* value, 279 cef_string_t* exception); 280 281 /// 282 // Handle assignment of the interceptor value identified by |index|. |object| 283 // is the receiver ('this' object) of the interceptor. |value| is the new 284 // value being assigned to the interceptor. If assignment fails, set 285 // |exception| to the exception that will be thrown. Return true (1) if 286 // interceptor assignment was handled, false (0) otherwise. 287 /// 288 int(CEF_CALLBACK* set_byindex)(struct _cef_v8interceptor_t* self, 289 int index, 290 struct _cef_v8value_t* object, 291 struct _cef_v8value_t* value, 292 cef_string_t* exception); 293 } cef_v8interceptor_t; 294 295 /// 296 // Structure representing a V8 exception. The functions of this structure may be 297 // called on any render process thread. 298 /// 299 typedef struct _cef_v8exception_t { 300 /// 301 // Base structure. 302 /// 303 cef_base_ref_counted_t base; 304 305 /// 306 // Returns the exception message. 307 /// 308 // The resulting string must be freed by calling cef_string_userfree_free(). 309 cef_string_userfree_t(CEF_CALLBACK* get_message)( 310 struct _cef_v8exception_t* self); 311 312 /// 313 // Returns the line of source code that the exception occurred within. 314 /// 315 // The resulting string must be freed by calling cef_string_userfree_free(). 316 cef_string_userfree_t(CEF_CALLBACK* get_source_line)( 317 struct _cef_v8exception_t* self); 318 319 /// 320 // Returns the resource name for the script from where the function causing 321 // the error originates. 322 /// 323 // The resulting string must be freed by calling cef_string_userfree_free(). 324 cef_string_userfree_t(CEF_CALLBACK* get_script_resource_name)( 325 struct _cef_v8exception_t* self); 326 327 /// 328 // Returns the 1-based number of the line where the error occurred or 0 if the 329 // line number is unknown. 330 /// 331 int(CEF_CALLBACK* get_line_number)(struct _cef_v8exception_t* self); 332 333 /// 334 // Returns the index within the script of the first character where the error 335 // occurred. 336 /// 337 int(CEF_CALLBACK* get_start_position)(struct _cef_v8exception_t* self); 338 339 /// 340 // Returns the index within the script of the last character where the error 341 // occurred. 342 /// 343 int(CEF_CALLBACK* get_end_position)(struct _cef_v8exception_t* self); 344 345 /// 346 // Returns the index within the line of the first character where the error 347 // occurred. 348 /// 349 int(CEF_CALLBACK* get_start_column)(struct _cef_v8exception_t* self); 350 351 /// 352 // Returns the index within the line of the last character where the error 353 // occurred. 354 /// 355 int(CEF_CALLBACK* get_end_column)(struct _cef_v8exception_t* self); 356 } cef_v8exception_t; 357 358 /// 359 // Callback structure that is passed to cef_v8value_t::CreateArrayBuffer. 360 /// 361 typedef struct _cef_v8array_buffer_release_callback_t { 362 /// 363 // Base structure. 364 /// 365 cef_base_ref_counted_t base; 366 367 /// 368 // Called to release |buffer| when the ArrayBuffer JS object is garbage 369 // collected. |buffer| is the value that was passed to CreateArrayBuffer along 370 // with this object. 371 /// 372 void(CEF_CALLBACK* release_buffer)( 373 struct _cef_v8array_buffer_release_callback_t* self, 374 void* buffer); 375 } cef_v8array_buffer_release_callback_t; 376 377 /// 378 // Structure representing a V8 value handle. V8 handles can only be accessed 379 // from the thread on which they are created. Valid threads for creating a V8 380 // handle include the render process main thread (TID_RENDERER) and WebWorker 381 // threads. A task runner for posting tasks on the associated thread can be 382 // retrieved via the cef_v8context_t::get_task_runner() function. 383 /// 384 typedef struct _cef_v8value_t { 385 /// 386 // Base structure. 387 /// 388 cef_base_ref_counted_t base; 389 390 /// 391 // Returns true (1) if the underlying handle is valid and it can be accessed 392 // on the current thread. Do not call any other functions if this function 393 // returns false (0). 394 /// 395 int(CEF_CALLBACK* is_valid)(struct _cef_v8value_t* self); 396 397 /// 398 // True if the value type is undefined. 399 /// 400 int(CEF_CALLBACK* is_undefined)(struct _cef_v8value_t* self); 401 402 /// 403 // True if the value type is null. 404 /// 405 int(CEF_CALLBACK* is_null)(struct _cef_v8value_t* self); 406 407 /// 408 // True if the value type is bool. 409 /// 410 int(CEF_CALLBACK* is_bool)(struct _cef_v8value_t* self); 411 412 /// 413 // True if the value type is int. 414 /// 415 int(CEF_CALLBACK* is_int)(struct _cef_v8value_t* self); 416 417 /// 418 // True if the value type is unsigned int. 419 /// 420 int(CEF_CALLBACK* is_uint)(struct _cef_v8value_t* self); 421 422 /// 423 // True if the value type is double. 424 /// 425 int(CEF_CALLBACK* is_double)(struct _cef_v8value_t* self); 426 427 /// 428 // True if the value type is Date. 429 /// 430 int(CEF_CALLBACK* is_date)(struct _cef_v8value_t* self); 431 432 /// 433 // True if the value type is string. 434 /// 435 int(CEF_CALLBACK* is_string)(struct _cef_v8value_t* self); 436 437 /// 438 // True if the value type is object. 439 /// 440 int(CEF_CALLBACK* is_object)(struct _cef_v8value_t* self); 441 442 /// 443 // True if the value type is array. 444 /// 445 int(CEF_CALLBACK* is_array)(struct _cef_v8value_t* self); 446 447 /// 448 // True if the value type is an ArrayBuffer. 449 /// 450 int(CEF_CALLBACK* is_array_buffer)(struct _cef_v8value_t* self); 451 452 /// 453 // True if the value type is function. 454 /// 455 int(CEF_CALLBACK* is_function)(struct _cef_v8value_t* self); 456 457 /// 458 // Returns true (1) if this object is pointing to the same handle as |that| 459 // object. 460 /// 461 int(CEF_CALLBACK* is_same)(struct _cef_v8value_t* self, 462 struct _cef_v8value_t* that); 463 464 /// 465 // Return a bool value. 466 /// 467 int(CEF_CALLBACK* get_bool_value)(struct _cef_v8value_t* self); 468 469 /// 470 // Return an int value. 471 /// 472 int32(CEF_CALLBACK* get_int_value)(struct _cef_v8value_t* self); 473 474 /// 475 // Return an unsigned int value. 476 /// 477 uint32(CEF_CALLBACK* get_uint_value)(struct _cef_v8value_t* self); 478 479 /// 480 // Return a double value. 481 /// 482 double(CEF_CALLBACK* get_double_value)(struct _cef_v8value_t* self); 483 484 /// 485 // Return a Date value. 486 /// 487 cef_time_t(CEF_CALLBACK* get_date_value)(struct _cef_v8value_t* self); 488 489 /// 490 // Return a string value. 491 /// 492 // The resulting string must be freed by calling cef_string_userfree_free(). 493 cef_string_userfree_t(CEF_CALLBACK* get_string_value)( 494 struct _cef_v8value_t* self); 495 496 // OBJECT METHODS - These functions are only available on objects. Arrays and 497 // functions are also objects. String- and integer-based keys can be used 498 // interchangably with the framework converting between them as necessary. 499 500 /// 501 // Returns true (1) if this is a user created object. 502 /// 503 int(CEF_CALLBACK* is_user_created)(struct _cef_v8value_t* self); 504 505 /// 506 // Returns true (1) if the last function call resulted in an exception. This 507 // attribute exists only in the scope of the current CEF value object. 508 /// 509 int(CEF_CALLBACK* has_exception)(struct _cef_v8value_t* self); 510 511 /// 512 // Returns the exception resulting from the last function call. This attribute 513 // exists only in the scope of the current CEF value object. 514 /// 515 struct _cef_v8exception_t*(CEF_CALLBACK* get_exception)( 516 struct _cef_v8value_t* self); 517 518 /// 519 // Clears the last exception and returns true (1) on success. 520 /// 521 int(CEF_CALLBACK* clear_exception)(struct _cef_v8value_t* self); 522 523 /// 524 // Returns true (1) if this object will re-throw future exceptions. This 525 // attribute exists only in the scope of the current CEF value object. 526 /// 527 int(CEF_CALLBACK* will_rethrow_exceptions)(struct _cef_v8value_t* self); 528 529 /// 530 // Set whether this object will re-throw future exceptions. By default 531 // exceptions are not re-thrown. If a exception is re-thrown the current 532 // context should not be accessed again until after the exception has been 533 // caught and not re-thrown. Returns true (1) on success. This attribute 534 // exists only in the scope of the current CEF value object. 535 /// 536 int(CEF_CALLBACK* set_rethrow_exceptions)(struct _cef_v8value_t* self, 537 int rethrow); 538 539 /// 540 // Returns true (1) if the object has a value with the specified identifier. 541 /// 542 int(CEF_CALLBACK* has_value_bykey)(struct _cef_v8value_t* self, 543 const cef_string_t* key); 544 545 /// 546 // Returns true (1) if the object has a value with the specified identifier. 547 /// 548 int(CEF_CALLBACK* has_value_byindex)(struct _cef_v8value_t* self, int index); 549 550 /// 551 // Deletes the value with the specified identifier and returns true (1) on 552 // success. Returns false (0) if this function is called incorrectly or an 553 // exception is thrown. For read-only and don't-delete values this function 554 // will return true (1) even though deletion failed. 555 /// 556 int(CEF_CALLBACK* delete_value_bykey)(struct _cef_v8value_t* self, 557 const cef_string_t* key); 558 559 /// 560 // Deletes the value with the specified identifier and returns true (1) on 561 // success. Returns false (0) if this function is called incorrectly, deletion 562 // fails or an exception is thrown. For read-only and don't-delete values this 563 // function will return true (1) even though deletion failed. 564 /// 565 int(CEF_CALLBACK* delete_value_byindex)(struct _cef_v8value_t* self, 566 int index); 567 568 /// 569 // Returns the value with the specified identifier on success. Returns NULL if 570 // this function is called incorrectly or an exception is thrown. 571 /// 572 struct _cef_v8value_t*(CEF_CALLBACK* get_value_bykey)( 573 struct _cef_v8value_t* self, 574 const cef_string_t* key); 575 576 /// 577 // Returns the value with the specified identifier on success. Returns NULL if 578 // this function is called incorrectly or an exception is thrown. 579 /// 580 struct _cef_v8value_t*( 581 CEF_CALLBACK* get_value_byindex)(struct _cef_v8value_t* self, int index); 582 583 /// 584 // Associates a value with the specified identifier and returns true (1) on 585 // success. Returns false (0) if this function is called incorrectly or an 586 // exception is thrown. For read-only values this function will return true 587 // (1) even though assignment failed. 588 /// 589 int(CEF_CALLBACK* set_value_bykey)(struct _cef_v8value_t* self, 590 const cef_string_t* key, 591 struct _cef_v8value_t* value, 592 cef_v8_propertyattribute_t attribute); 593 594 /// 595 // Associates a value with the specified identifier and returns true (1) on 596 // success. Returns false (0) if this function is called incorrectly or an 597 // exception is thrown. For read-only values this function will return true 598 // (1) even though assignment failed. 599 /// 600 int(CEF_CALLBACK* set_value_byindex)(struct _cef_v8value_t* self, 601 int index, 602 struct _cef_v8value_t* value); 603 604 /// 605 // Registers an identifier and returns true (1) on success. Access to the 606 // identifier will be forwarded to the cef_v8accessor_t instance passed to 607 // cef_v8value_t::cef_v8value_create_object(). Returns false (0) if this 608 // function is called incorrectly or an exception is thrown. For read-only 609 // values this function will return true (1) even though assignment failed. 610 /// 611 int(CEF_CALLBACK* set_value_byaccessor)(struct _cef_v8value_t* self, 612 const cef_string_t* key, 613 cef_v8_accesscontrol_t settings, 614 cef_v8_propertyattribute_t attribute); 615 616 /// 617 // Read the keys for the object's values into the specified vector. Integer- 618 // based keys will also be returned as strings. 619 /// 620 int(CEF_CALLBACK* get_keys)(struct _cef_v8value_t* self, 621 cef_string_list_t keys); 622 623 /// 624 // Sets the user data for this object and returns true (1) on success. Returns 625 // false (0) if this function is called incorrectly. This function can only be 626 // called on user created objects. 627 /// 628 int(CEF_CALLBACK* set_user_data)(struct _cef_v8value_t* self, 629 struct _cef_base_ref_counted_t* user_data); 630 631 /// 632 // Returns the user data, if any, assigned to this object. 633 /// 634 struct _cef_base_ref_counted_t*(CEF_CALLBACK* get_user_data)( 635 struct _cef_v8value_t* self); 636 637 /// 638 // Returns the amount of externally allocated memory registered for the 639 // object. 640 /// 641 int(CEF_CALLBACK* get_externally_allocated_memory)( 642 struct _cef_v8value_t* self); 643 644 /// 645 // Adjusts the amount of registered external memory for the object. Used to 646 // give V8 an indication of the amount of externally allocated memory that is 647 // kept alive by JavaScript objects. V8 uses this information to decide when 648 // to perform global garbage collection. Each cef_v8value_t tracks the amount 649 // of external memory associated with it and automatically decreases the 650 // global total by the appropriate amount on its destruction. 651 // |change_in_bytes| specifies the number of bytes to adjust by. This function 652 // returns the number of bytes associated with the object after the 653 // adjustment. This function can only be called on user created objects. 654 /// 655 int(CEF_CALLBACK* adjust_externally_allocated_memory)( 656 struct _cef_v8value_t* self, 657 int change_in_bytes); 658 659 // ARRAY METHODS - These functions are only available on arrays. 660 661 /// 662 // Returns the number of elements in the array. 663 /// 664 int(CEF_CALLBACK* get_array_length)(struct _cef_v8value_t* self); 665 666 // ARRAY BUFFER METHODS - These functions are only available on ArrayBuffers. 667 668 /// 669 // Returns the ReleaseCallback object associated with the ArrayBuffer or NULL 670 // if the ArrayBuffer was not created with CreateArrayBuffer. 671 /// 672 struct _cef_v8array_buffer_release_callback_t*( 673 CEF_CALLBACK* get_array_buffer_release_callback)( 674 struct _cef_v8value_t* self); 675 676 /// 677 // Prevent the ArrayBuffer from using it's memory block by setting the length 678 // to zero. This operation cannot be undone. If the ArrayBuffer was created 679 // with CreateArrayBuffer then 680 // cef_v8array_buffer_release_callback_t::ReleaseBuffer will be called to 681 // release the underlying buffer. 682 /// 683 int(CEF_CALLBACK* neuter_array_buffer)(struct _cef_v8value_t* self); 684 685 // FUNCTION METHODS - These functions are only available on functions. 686 687 /// 688 // Returns the function name. 689 /// 690 // The resulting string must be freed by calling cef_string_userfree_free(). 691 cef_string_userfree_t(CEF_CALLBACK* get_function_name)( 692 struct _cef_v8value_t* self); 693 694 /// 695 // Returns the function handler or NULL if not a CEF-created function. 696 /// 697 struct _cef_v8handler_t*(CEF_CALLBACK* get_function_handler)( 698 struct _cef_v8value_t* self); 699 700 /// 701 // Execute the function using the current V8 context. This function should 702 // only be called from within the scope of a cef_v8handler_t or 703 // cef_v8accessor_t callback, or in combination with calling enter() and 704 // exit() on a stored cef_v8context_t reference. |object| is the receiver 705 // ('this' object) of the function. If |object| is NULL the current context's 706 // global object will be used. |arguments| is the list of arguments that will 707 // be passed to the function. Returns the function return value on success. 708 // Returns NULL if this function is called incorrectly or an exception is 709 // thrown. 710 /// 711 struct _cef_v8value_t*(CEF_CALLBACK* execute_function)( 712 struct _cef_v8value_t* self, 713 struct _cef_v8value_t* object, 714 size_t argumentsCount, 715 struct _cef_v8value_t* const* arguments); 716 717 /// 718 // Execute the function using the specified V8 context. |object| is the 719 // receiver ('this' object) of the function. If |object| is NULL the specified 720 // context's global object will be used. |arguments| is the list of arguments 721 // that will be passed to the function. Returns the function return value on 722 // success. Returns NULL if this function is called incorrectly or an 723 // exception is thrown. 724 /// 725 struct _cef_v8value_t*(CEF_CALLBACK* execute_function_with_context)( 726 struct _cef_v8value_t* self, 727 struct _cef_v8context_t* context, 728 struct _cef_v8value_t* object, 729 size_t argumentsCount, 730 struct _cef_v8value_t* const* arguments); 731 } cef_v8value_t; 732 733 /// 734 // Create a new cef_v8value_t object of type undefined. 735 /// 736 CEF_EXPORT cef_v8value_t* cef_v8value_create_undefined(); 737 738 /// 739 // Create a new cef_v8value_t object of type null. 740 /// 741 CEF_EXPORT cef_v8value_t* cef_v8value_create_null(); 742 743 /// 744 // Create a new cef_v8value_t object of type bool. 745 /// 746 CEF_EXPORT cef_v8value_t* cef_v8value_create_bool(int value); 747 748 /// 749 // Create a new cef_v8value_t object of type int. 750 /// 751 CEF_EXPORT cef_v8value_t* cef_v8value_create_int(int32 value); 752 753 /// 754 // Create a new cef_v8value_t object of type unsigned int. 755 /// 756 CEF_EXPORT cef_v8value_t* cef_v8value_create_uint(uint32 value); 757 758 /// 759 // Create a new cef_v8value_t object of type double. 760 /// 761 CEF_EXPORT cef_v8value_t* cef_v8value_create_double(double value); 762 763 /// 764 // Create a new cef_v8value_t object of type Date. This function should only be 765 // called from within the scope of a cef_render_process_handler_t, 766 // cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling 767 // enter() and exit() on a stored cef_v8context_t reference. 768 /// 769 CEF_EXPORT cef_v8value_t* cef_v8value_create_date(const cef_time_t* date); 770 771 /// 772 // Create a new cef_v8value_t object of type string. 773 /// 774 CEF_EXPORT cef_v8value_t* cef_v8value_create_string(const cef_string_t* value); 775 776 /// 777 // Create a new cef_v8value_t object of type object with optional accessor 778 // and/or interceptor. This function should only be called from within the scope 779 // of a cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t 780 // callback, or in combination with calling enter() and exit() on a stored 781 // cef_v8context_t reference. 782 /// 783 CEF_EXPORT cef_v8value_t* cef_v8value_create_object( 784 cef_v8accessor_t* accessor, 785 cef_v8interceptor_t* interceptor); 786 787 /// 788 // Create a new cef_v8value_t object of type array with the specified |length|. 789 // If |length| is negative the returned array will have length 0. This function 790 // should only be called from within the scope of a 791 // cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t callback, 792 // or in combination with calling enter() and exit() on a stored cef_v8context_t 793 // reference. 794 /// 795 CEF_EXPORT cef_v8value_t* cef_v8value_create_array(int length); 796 797 /// 798 // Create a new cef_v8value_t object of type ArrayBuffer which wraps the 799 // provided |buffer| of size |length| bytes. The ArrayBuffer is externalized, 800 // meaning that it does not own |buffer|. The caller is responsible for freeing 801 // |buffer| when requested via a call to cef_v8array_buffer_release_callback_t:: 802 // ReleaseBuffer. This function should only be called from within the scope of a 803 // cef_render_process_handler_t, cef_v8handler_t or cef_v8accessor_t callback, 804 // or in combination with calling enter() and exit() on a stored cef_v8context_t 805 // reference. 806 /// 807 CEF_EXPORT cef_v8value_t* cef_v8value_create_array_buffer( 808 void* buffer, 809 size_t length, 810 cef_v8array_buffer_release_callback_t* release_callback); 811 812 /// 813 // Create a new cef_v8value_t object of type function. This function should only 814 // be called from within the scope of a cef_render_process_handler_t, 815 // cef_v8handler_t or cef_v8accessor_t callback, or in combination with calling 816 // enter() and exit() on a stored cef_v8context_t reference. 817 /// 818 CEF_EXPORT cef_v8value_t* cef_v8value_create_function(const cef_string_t* name, 819 cef_v8handler_t* handler); 820 821 /// 822 // Structure representing a V8 stack trace handle. V8 handles can only be 823 // accessed from the thread on which they are created. Valid threads for 824 // creating a V8 handle include the render process main thread (TID_RENDERER) 825 // and WebWorker threads. A task runner for posting tasks on the associated 826 // thread can be retrieved via the cef_v8context_t::get_task_runner() function. 827 /// 828 typedef struct _cef_v8stack_trace_t { 829 /// 830 // Base structure. 831 /// 832 cef_base_ref_counted_t base; 833 834 /// 835 // Returns true (1) if the underlying handle is valid and it can be accessed 836 // on the current thread. Do not call any other functions if this function 837 // returns false (0). 838 /// 839 int(CEF_CALLBACK* is_valid)(struct _cef_v8stack_trace_t* self); 840 841 /// 842 // Returns the number of stack frames. 843 /// 844 int(CEF_CALLBACK* get_frame_count)(struct _cef_v8stack_trace_t* self); 845 846 /// 847 // Returns the stack frame at the specified 0-based index. 848 /// 849 struct _cef_v8stack_frame_t*( 850 CEF_CALLBACK* get_frame)(struct _cef_v8stack_trace_t* self, int index); 851 } cef_v8stack_trace_t; 852 853 /// 854 // Returns the stack trace for the currently active context. |frame_limit| is 855 // the maximum number of frames that will be captured. 856 /// 857 CEF_EXPORT cef_v8stack_trace_t* cef_v8stack_trace_get_current(int frame_limit); 858 859 /// 860 // Structure representing a V8 stack frame handle. V8 handles can only be 861 // accessed from the thread on which they are created. Valid threads for 862 // creating a V8 handle include the render process main thread (TID_RENDERER) 863 // and WebWorker threads. A task runner for posting tasks on the associated 864 // thread can be retrieved via the cef_v8context_t::get_task_runner() function. 865 /// 866 typedef struct _cef_v8stack_frame_t { 867 /// 868 // Base structure. 869 /// 870 cef_base_ref_counted_t base; 871 872 /// 873 // Returns true (1) if the underlying handle is valid and it can be accessed 874 // on the current thread. Do not call any other functions if this function 875 // returns false (0). 876 /// 877 int(CEF_CALLBACK* is_valid)(struct _cef_v8stack_frame_t* self); 878 879 /// 880 // Returns the name of the resource script that contains the function. 881 /// 882 // The resulting string must be freed by calling cef_string_userfree_free(). 883 cef_string_userfree_t(CEF_CALLBACK* get_script_name)( 884 struct _cef_v8stack_frame_t* self); 885 886 /// 887 // Returns the name of the resource script that contains the function or the 888 // sourceURL value if the script name is undefined and its source ends with a 889 // "//@ sourceURL=..." string. 890 /// 891 // The resulting string must be freed by calling cef_string_userfree_free(). 892 cef_string_userfree_t(CEF_CALLBACK* get_script_name_or_source_url)( 893 struct _cef_v8stack_frame_t* self); 894 895 /// 896 // Returns the name of the function. 897 /// 898 // The resulting string must be freed by calling cef_string_userfree_free(). 899 cef_string_userfree_t(CEF_CALLBACK* get_function_name)( 900 struct _cef_v8stack_frame_t* self); 901 902 /// 903 // Returns the 1-based line number for the function call or 0 if unknown. 904 /// 905 int(CEF_CALLBACK* get_line_number)(struct _cef_v8stack_frame_t* self); 906 907 /// 908 // Returns the 1-based column offset on the line for the function call or 0 if 909 // unknown. 910 /// 911 int(CEF_CALLBACK* get_column)(struct _cef_v8stack_frame_t* self); 912 913 /// 914 // Returns true (1) if the function was compiled using eval(). 915 /// 916 int(CEF_CALLBACK* is_eval)(struct _cef_v8stack_frame_t* self); 917 918 /// 919 // Returns true (1) if the function was called as a constructor via "new". 920 /// 921 int(CEF_CALLBACK* is_constructor)(struct _cef_v8stack_frame_t* self); 922 } cef_v8stack_frame_t; 923 924 /// 925 // Register a new V8 extension with the specified JavaScript extension code and 926 // handler. Functions implemented by the handler are prototyped using the 927 // keyword 'native'. The calling of a native function is restricted to the scope 928 // in which the prototype of the native function is defined. This function may 929 // only be called on the render process main thread. 930 // 931 // Example JavaScript extension code: <pre> 932 // // create the 'example' global object if it doesn't already exist. 933 // if (!example) 934 // example = {}; 935 // // create the 'example.test' global object if it doesn't already exist. 936 // if (!example.test) 937 // example.test = {}; 938 // (function() { 939 // // Define the function 'example.test.myfunction'. 940 // example.test.myfunction = function() { 941 // // Call CefV8Handler::Execute() with the function name 'MyFunction' 942 // // and no arguments. 943 // native function MyFunction(); 944 // return MyFunction(); 945 // }; 946 // // Define the getter function for parameter 'example.test.myparam'. 947 // example.test.__defineGetter__('myparam', function() { 948 // // Call CefV8Handler::Execute() with the function name 'GetMyParam' 949 // // and no arguments. 950 // native function GetMyParam(); 951 // return GetMyParam(); 952 // }); 953 // // Define the setter function for parameter 'example.test.myparam'. 954 // example.test.__defineSetter__('myparam', function(b) { 955 // // Call CefV8Handler::Execute() with the function name 'SetMyParam' 956 // // and a single argument. 957 // native function SetMyParam(); 958 // if(b) SetMyParam(b); 959 // }); 960 // 961 // // Extension definitions can also contain normal JavaScript variables 962 // // and functions. 963 // var myint = 0; 964 // example.test.increment = function() { 965 // myint += 1; 966 // return myint; 967 // }; 968 // })(); 969 // </pre> Example usage in the page: <pre> 970 // // Call the function. 971 // example.test.myfunction(); 972 // // Set the parameter. 973 // example.test.myparam = value; 974 // // Get the parameter. 975 // value = example.test.myparam; 976 // // Call another function. 977 // example.test.increment(); 978 // </pre> 979 /// 980 CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name, 981 const cef_string_t* javascript_code, 982 cef_v8handler_t* handler); 983 984 #ifdef __cplusplus 985 } 986 #endif 987 988 #endif // CEF_INCLUDE_CAPI_CEF_V8_CAPI_H_ 989