1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT
use crate::{ffi, Context, TypedArrayType, ValuePropertyFlags};
use glib::translate::*;
glib::wrapper! {
/// JSCValue represents a reference to a value in a #JSCContext. The JSCValue
/// protects the referenced value from being garbage collected.
///
/// ## Properties
///
///
/// #### `context`
/// The #JSCContext in which the value was created.
///
/// Readable | Writeable | Construct Only
#[doc(alias = "JSCValue")]
pub struct Value(Object<ffi::JSCValue, ffi::JSCValueClass>);
match fn {
type_ => || ffi::jsc_value_get_type(),
}
}
impl Value {
//#[doc(alias = "jsc_value_new_array")]
//pub fn new_array(context: &Context, first_item_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Value {
// unsafe { TODO: call ffi:jsc_value_new_array() }
//}
//#[doc(alias = "jsc_value_new_array_buffer")]
//pub fn new_array_buffer(context: &Context, data: /*Unimplemented*/Option<Basic: Pointer>, size: usize, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> Option<Value> {
// unsafe { TODO: call ffi:jsc_value_new_array_buffer() }
//}
/// Create a new #JSCValue referencing an array with the items from @array. If @array
/// is [`None`] or empty a new empty array will be created. Elements of @array should be
/// pointers to a #JSCValue.
/// ## `context`
/// a #JSCContext
/// ## `array`
/// a #GPtrArray
///
/// # Returns
///
/// a #JSCValue.
#[doc(alias = "jsc_value_new_array_from_garray")]
pub fn new_array_from_garray(context: &Context, array: &[Value]) -> Value {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::jsc_value_new_array_from_garray(
context.to_glib_none().0,
array.to_glib_none().0,
))
}
}
/// Create a new #JSCValue referencing an array of strings with the items from @strv. If @array
/// is [`None`] or empty a new empty array will be created.
/// ## `context`
/// a #JSCContext
/// ## `strv`
/// a [`None`]-terminated array of strings
///
/// # Returns
///
/// a #JSCValue.
#[doc(alias = "jsc_value_new_array_from_strv")]
pub fn new_array_from_strv(context: &Context, strv: &[&str]) -> Value {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::jsc_value_new_array_from_strv(
context.to_glib_none().0,
strv.to_glib_none().0,
))
}
}
/// Create a new #JSCValue from @value
/// ## `context`
/// a #JSCContext
/// ## `value`
/// a #gboolean
///
/// # Returns
///
/// a #JSCValue.
#[doc(alias = "jsc_value_new_boolean")]
pub fn new_boolean(context: &Context, value: bool) -> Value {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::jsc_value_new_boolean(
context.to_glib_none().0,
value.into_glib(),
))
}
}
/// Create a new #JSCValue referencing a new value created by parsing @json.
/// ## `context`
/// a #JSCContext
/// ## `json`
/// the JSON string to be parsed
///
/// # Returns
///
/// a #JSCValue.
#[doc(alias = "jsc_value_new_from_json")]
#[doc(alias = "new_from_json")]
pub fn from_json(context: &Context, json: &str) -> Value {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::jsc_value_new_from_json(
context.to_glib_none().0,
json.to_glib_none().0,
))
}
}
//#[doc(alias = "jsc_value_new_function")]
//pub fn new_function<P: Fn() + 'static>(context: &Context, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option<Basic: Pointer>, return_type: glib::types::Type, n_params: u32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Value {
// unsafe { TODO: call ffi:jsc_value_new_function() }
//}
//#[doc(alias = "jsc_value_new_function_variadic")]
//pub fn new_function_variadic<P: Fn() + 'static>(context: &Context, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option<Basic: Pointer>, return_type: glib::types::Type) -> Value {
// unsafe { TODO: call ffi:jsc_value_new_function_variadic() }
//}
//#[doc(alias = "jsc_value_new_functionv")]
//pub fn new_functionv<P: Fn() + 'static>(context: &Context, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option<Basic: Pointer>, return_type: glib::types::Type, n_parameters: u32) -> Value {
// unsafe { TODO: call ffi:jsc_value_new_functionv() }
//}
/// Create a new #JSCValue referencing <function>null</function> in @context.
/// ## `context`
/// a #JSCContext
///
/// # Returns
///
/// a #JSCValue.
#[doc(alias = "jsc_value_new_null")]
pub fn new_null(context: &Context) -> Value {
skip_assert_initialized!();
unsafe { from_glib_full(ffi::jsc_value_new_null(context.to_glib_none().0)) }
}
/// Create a new #JSCValue from @number.
/// ## `context`
/// a #JSCContext
/// ## `number`
/// a number
///
/// # Returns
///
/// a #JSCValue.
#[doc(alias = "jsc_value_new_number")]
pub fn new_number(context: &Context, number: f64) -> Value {
skip_assert_initialized!();
unsafe { from_glib_full(ffi::jsc_value_new_number(context.to_glib_none().0, number)) }
}
//#[doc(alias = "jsc_value_new_object")]
//pub fn new_object(context: &Context, instance: /*Unimplemented*/Option<Basic: Pointer>, jsc_class: Option<&Class>) -> Value {
// unsafe { TODO: call ffi:jsc_value_new_object() }
//}
/// Create a new #JSCValue from @string. If you need to create a #JSCValue from a
/// string containing null characters, use jsc_value_new_string_from_bytes() instead.
/// ## `context`
/// a #JSCContext
/// ## `string`
/// a null-terminated string
///
/// # Returns
///
/// a #JSCValue.
#[doc(alias = "jsc_value_new_string")]
pub fn new_string(context: &Context, string: Option<&str>) -> Value {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::jsc_value_new_string(
context.to_glib_none().0,
string.to_glib_none().0,
))
}
}
/// Create a new #JSCValue from @bytes.
/// ## `context`
/// a #JSCContext
/// ## `bytes`
/// a #GBytes
///
/// # Returns
///
/// a #JSCValue.
#[doc(alias = "jsc_value_new_string_from_bytes")]
pub fn new_string_from_bytes(context: &Context, bytes: Option<&glib::Bytes>) -> Value {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::jsc_value_new_string_from_bytes(
context.to_glib_none().0,
bytes.to_glib_none().0,
))
}
}
/// Create a new typed array containing a given amount of elements.
///
/// Create a #JSCValue referencing a new typed array with space for @length
/// elements of a given @type_. As all typed arrays must have an associated
/// `ArrayBuffer`, a new one of suitable size will be allocated to store
/// the elements, which will be initialized to zero.
///
/// The @type_ must *not* be [`TypedArrayType::None`][crate::TypedArrayType::None].
/// ## `context`
/// a #JSCContext
/// ## `type_`
/// the type of array elements
/// ## `length`
/// number of elements in the array
///
/// # Returns
///
/// a #JSCValue
#[doc(alias = "jsc_value_new_typed_array")]
pub fn new_typed_array(context: &Context, type_: TypedArrayType, length: usize) -> Value {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::jsc_value_new_typed_array(
context.to_glib_none().0,
type_.into_glib(),
length,
))
}
}
/// Create a new #JSCValue referencing <function>undefined</function> in @context.
/// ## `context`
/// a #JSCContext
///
/// # Returns
///
/// a #JSCValue.
#[doc(alias = "jsc_value_new_undefined")]
pub fn new_undefined(context: &Context) -> Value {
skip_assert_initialized!();
unsafe { from_glib_full(ffi::jsc_value_new_undefined(context.to_glib_none().0)) }
}
//#[doc(alias = "jsc_value_array_buffer_get_data")]
//pub fn array_buffer_get_data(&self, size: usize) -> /*Unimplemented*/Option<Basic: Pointer> {
// unsafe { TODO: call ffi:jsc_value_array_buffer_get_data() }
//}
/// Gets the size in bytes of the array buffer.
///
/// Obtains the size in bytes of the memory region that holds the contents of
/// an `ArrayBuffer`.
///
/// # Returns
///
/// size, in bytes.
#[doc(alias = "jsc_value_array_buffer_get_size")]
pub fn array_buffer_get_size(&self) -> usize {
unsafe { ffi::jsc_value_array_buffer_get_size(self.to_glib_none().0) }
}
//#[doc(alias = "jsc_value_constructor_call")]
//#[must_use]
//pub fn constructor_call(&self, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option<Value> {
// unsafe { TODO: call ffi:jsc_value_constructor_call() }
//}
/// Invoke <function>new</function> with constructor referenced by @self. If @n_parameters
/// is 0 no parameters will be passed to the constructor.
/// ## `parameters`
/// the #JSCValue<!-- -->s to pass as parameters to the constructor, or [`None`]
///
/// # Returns
///
/// a #JSCValue referencing the newly created object instance.
#[doc(alias = "jsc_value_constructor_callv")]
#[must_use]
pub fn constructor_callv(&self, parameters: &[Value]) -> Option<Value> {
let n_parameters = parameters.len() as _;
unsafe {
from_glib_full(ffi::jsc_value_constructor_callv(
self.to_glib_none().0,
n_parameters,
parameters.to_glib_none().0,
))
}
}
//#[doc(alias = "jsc_value_function_call")]
//#[must_use]
//pub fn function_call(&self, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option<Value> {
// unsafe { TODO: call ffi:jsc_value_function_call() }
//}
/// Call function referenced by @self, passing the given @parameters. If @n_parameters
/// is 0 no parameters will be passed to the function.
///
/// This function always returns a #JSCValue, in case of void functions a #JSCValue referencing
/// <function>undefined</function> is returned
/// ## `parameters`
/// the #JSCValue<!-- -->s to pass as parameters to the function, or [`None`]
///
/// # Returns
///
/// a #JSCValue with the return value of the function.
#[doc(alias = "jsc_value_function_callv")]
#[must_use]
pub fn function_callv(&self, parameters: &[Value]) -> Option<Value> {
let n_parameters = parameters.len() as _;
unsafe {
from_glib_full(ffi::jsc_value_function_callv(
self.to_glib_none().0,
n_parameters,
parameters.to_glib_none().0,
))
}
}
/// Get the #JSCContext in which @self was created.
///
/// # Returns
///
/// the #JSCValue context.
#[doc(alias = "jsc_value_get_context")]
#[doc(alias = "get_context")]
pub fn context(&self) -> Option<Context> {
unsafe { from_glib_none(ffi::jsc_value_get_context(self.to_glib_none().0)) }
}
/// Get whether the value referenced by @self is an array.
///
/// # Returns
///
/// whether the value is an array.
#[doc(alias = "jsc_value_is_array")]
pub fn is_array(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_array(self.to_glib_none().0)) }
}
/// Check whether the @self is an `ArrayBuffer`.
///
/// # Returns
///
/// whether the value is an `ArrayBuffer`
#[doc(alias = "jsc_value_is_array_buffer")]
pub fn is_array_buffer(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_array_buffer(self.to_glib_none().0)) }
}
/// Get whether the value referenced by @self is a boolean.
///
/// # Returns
///
/// whether the value is a boolean.
#[doc(alias = "jsc_value_is_boolean")]
pub fn is_boolean(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_boolean(self.to_glib_none().0)) }
}
/// Get whether the value referenced by @self is a constructor.
///
/// # Returns
///
/// whether the value is a constructor.
#[doc(alias = "jsc_value_is_constructor")]
pub fn is_constructor(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_constructor(self.to_glib_none().0)) }
}
/// Get whether the value referenced by @self is a function
///
/// # Returns
///
/// whether the value is a function.
#[doc(alias = "jsc_value_is_function")]
pub fn is_function(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_function(self.to_glib_none().0)) }
}
/// Get whether the value referenced by @self is <function>null</function>.
///
/// # Returns
///
/// whether the value is null.
#[doc(alias = "jsc_value_is_null")]
pub fn is_null(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_null(self.to_glib_none().0)) }
}
/// Get whether the value referenced by @self is a number.
///
/// # Returns
///
/// whether the value is a number.
#[doc(alias = "jsc_value_is_number")]
pub fn is_number(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_number(self.to_glib_none().0)) }
}
/// Get whether the value referenced by @self is an object.
///
/// # Returns
///
/// whether the value is an object.
#[doc(alias = "jsc_value_is_object")]
pub fn is_object(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_object(self.to_glib_none().0)) }
}
/// Get whether the value referenced by @self is a string
///
/// # Returns
///
/// whether the value is a string
#[doc(alias = "jsc_value_is_string")]
pub fn is_string(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_string(self.to_glib_none().0)) }
}
/// Determines whether a value is a typed array.
///
/// # Returns
///
/// Whether @self is a typed array.
#[doc(alias = "jsc_value_is_typed_array")]
pub fn is_typed_array(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_typed_array(self.to_glib_none().0)) }
}
/// Get whether the value referenced by @self is <function>undefined</function>.
///
/// # Returns
///
/// whether the value is undefined.
#[doc(alias = "jsc_value_is_undefined")]
pub fn is_undefined(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_is_undefined(self.to_glib_none().0)) }
}
/// Create a new typed array value with elements from an array buffer.
///
/// Create a #JSCValue referencing a new typed array value containing
/// elements of the given @type_, where the elements are stored at the memory
/// region represented by the @self.
///
/// The @type_ must *not* be [`TypedArrayType::None`][crate::TypedArrayType::None].
///
/// The @offset and @length parameters can be used to indicate which part of
/// the array buffer can be accessed through the typed array. If both are
/// omitted (passing zero as @offset, and `-1` as @length), the whole
/// @self is exposed through the typed array. Omitting the @length
/// with a non-zero @offset will expose the remainder of the @self
/// starting at the indicated offset.
/// ## `type_`
/// type of array elements.
/// ## `offset`
/// offset, in bytes.
/// ## `length`
/// number of array elements, or `-1`.
///
/// # Returns
///
/// a #JSCValue
#[doc(alias = "jsc_value_new_typed_array_with_buffer")]
#[must_use]
pub fn new_typed_array_with_buffer(
&self,
type_: TypedArrayType,
offset: usize,
length: isize,
) -> Option<Value> {
unsafe {
from_glib_full(ffi::jsc_value_new_typed_array_with_buffer(
self.to_glib_none().0,
type_.into_glib(),
offset,
length,
))
}
}
//#[doc(alias = "jsc_value_object_define_property_accessor")]
//pub fn object_define_property_accessor(&self, property_name: &str, flags: ValuePropertyFlags, property_type: glib::types::Type, getter: Option<Box_<dyn FnOnce() + 'static>>, setter: Option<Box_<dyn Fn() + 'static>>, user_data: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:jsc_value_object_define_property_accessor() }
//}
/// Define or modify a property with @property_name in object referenced by @self. This is equivalent to
/// JavaScript <function>Object.defineProperty()</function> when used with a data descriptor.
/// ## `property_name`
/// the name of the property to define
/// ## `flags`
/// #JSCValuePropertyFlags
/// ## `property_value`
/// the default property value
#[doc(alias = "jsc_value_object_define_property_data")]
pub fn object_define_property_data(
&self,
property_name: &str,
flags: ValuePropertyFlags,
property_value: Option<&Value>,
) {
unsafe {
ffi::jsc_value_object_define_property_data(
self.to_glib_none().0,
property_name.to_glib_none().0,
flags.into_glib(),
property_value.to_glib_none().0,
);
}
}
/// Try to delete property with @name from @self. This function will return [`false`] if
/// the property was defined without [`ValuePropertyFlags::CONFIGURABLE`][crate::ValuePropertyFlags::CONFIGURABLE] flag.
/// ## `name`
/// the property name
///
/// # Returns
///
/// [`true`] if the property was deleted, or [`false`] otherwise.
#[doc(alias = "jsc_value_object_delete_property")]
pub fn object_delete_property(&self, name: &str) -> bool {
unsafe {
from_glib(ffi::jsc_value_object_delete_property(
self.to_glib_none().0,
name.to_glib_none().0,
))
}
}
/// Get the list of property names of @self. Only properties defined with [`ValuePropertyFlags::ENUMERABLE`][crate::ValuePropertyFlags::ENUMERABLE]
/// flag will be collected.
///
/// # Returns
///
/// a [`None`]-terminated array of strings containing the
/// property names, or [`None`] if @self doesn't have enumerable properties. Use g_strfreev() to free.
#[doc(alias = "jsc_value_object_enumerate_properties")]
pub fn object_enumerate_properties(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::jsc_value_object_enumerate_properties(
self.to_glib_none().0,
))
}
}
/// Get property with @name from @self.
/// ## `name`
/// the property name
///
/// # Returns
///
/// the property #JSCValue.
#[doc(alias = "jsc_value_object_get_property")]
#[must_use]
pub fn object_get_property(&self, name: &str) -> Option<Value> {
unsafe {
from_glib_full(ffi::jsc_value_object_get_property(
self.to_glib_none().0,
name.to_glib_none().0,
))
}
}
/// Get property at @index from @self.
/// ## `index`
/// the property index
///
/// # Returns
///
/// the property #JSCValue.
#[doc(alias = "jsc_value_object_get_property_at_index")]
#[must_use]
pub fn object_get_property_at_index(&self, index: u32) -> Option<Value> {
unsafe {
from_glib_full(ffi::jsc_value_object_get_property_at_index(
self.to_glib_none().0,
index,
))
}
}
/// Get whether @self has property with @name.
/// ## `name`
/// the property name
///
/// # Returns
///
/// [`true`] if @self has a property with @name, or [`false`] otherwise
#[doc(alias = "jsc_value_object_has_property")]
pub fn object_has_property(&self, name: &str) -> bool {
unsafe {
from_glib(ffi::jsc_value_object_has_property(
self.to_glib_none().0,
name.to_glib_none().0,
))
}
}
//#[doc(alias = "jsc_value_object_invoke_method")]
//#[must_use]
//pub fn object_invoke_method(&self, name: &str, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option<Value> {
// unsafe { TODO: call ffi:jsc_value_object_invoke_method() }
//}
/// Invoke method with @name on object referenced by @self, passing the given @parameters. If
/// @n_parameters is 0 no parameters will be passed to the method.
/// The object instance will be handled automatically even when the method is a custom one
/// registered with jsc_class_add_method(), so it should never be passed explicitly as parameter
/// of this function.
///
/// This function always returns a #JSCValue, in case of void methods a #JSCValue referencing
/// <function>undefined</function> is returned.
/// ## `name`
/// the method name
/// ## `parameters`
/// the #JSCValue<!-- -->s to pass as parameters to the method, or [`None`]
///
/// # Returns
///
/// a #JSCValue with the return value of the method.
#[doc(alias = "jsc_value_object_invoke_methodv")]
#[must_use]
pub fn object_invoke_methodv(&self, name: &str, parameters: &[Value]) -> Option<Value> {
let n_parameters = parameters.len() as _;
unsafe {
from_glib_full(ffi::jsc_value_object_invoke_methodv(
self.to_glib_none().0,
name.to_glib_none().0,
n_parameters,
parameters.to_glib_none().0,
))
}
}
/// Get whether the value referenced by @self is an instance of class @name.
/// ## `name`
/// a class name
///
/// # Returns
///
/// whether the value is an object instance of class @name.
#[doc(alias = "jsc_value_object_is_instance_of")]
pub fn object_is_instance_of(&self, name: &str) -> bool {
unsafe {
from_glib(ffi::jsc_value_object_is_instance_of(
self.to_glib_none().0,
name.to_glib_none().0,
))
}
}
/// Set @property with @name on @self.
/// ## `name`
/// the property name
/// ## `property`
/// the #JSCValue to set
#[doc(alias = "jsc_value_object_set_property")]
pub fn object_set_property(&self, name: &str, property: &Value) {
unsafe {
ffi::jsc_value_object_set_property(
self.to_glib_none().0,
name.to_glib_none().0,
property.to_glib_none().0,
);
}
}
/// Set @property at @index on @self.
/// ## `index`
/// the property index
/// ## `property`
/// the #JSCValue to set
#[doc(alias = "jsc_value_object_set_property_at_index")]
pub fn object_set_property_at_index(&self, index: u32, property: &Value) {
unsafe {
ffi::jsc_value_object_set_property_at_index(
self.to_glib_none().0,
index,
property.to_glib_none().0,
);
}
}
/// Convert @self to a boolean.
///
/// # Returns
///
/// a #gboolean result of the conversion.
#[doc(alias = "jsc_value_to_boolean")]
pub fn to_boolean(&self) -> bool {
unsafe { from_glib(ffi::jsc_value_to_boolean(self.to_glib_none().0)) }
}
/// Convert @self to a double.
///
/// # Returns
///
/// a #gdouble result of the conversion.
#[doc(alias = "jsc_value_to_double")]
pub fn to_double(&self) -> f64 {
unsafe { ffi::jsc_value_to_double(self.to_glib_none().0) }
}
/// Convert @self to a #gint32.
///
/// # Returns
///
/// a #gint32 result of the conversion.
#[doc(alias = "jsc_value_to_int32")]
pub fn to_int32(&self) -> i32 {
unsafe { ffi::jsc_value_to_int32(self.to_glib_none().0) }
}
/// Create a JSON string of @self serialization. If @indent is 0, the resulting JSON will
/// not contain newlines. The size of the indent is clamped to 10 spaces.
/// ## `indent`
/// The number of spaces to indent when nesting.
///
/// # Returns
///
/// a null-terminated JSON string with serialization of @self
#[doc(alias = "jsc_value_to_json")]
pub fn to_json(&self, indent: u32) -> Option<glib::GString> {
unsafe { from_glib_full(ffi::jsc_value_to_json(self.to_glib_none().0, indent)) }
}
/// Convert @self to a string. Use jsc_value_to_string_as_bytes() instead, if you need to
/// handle strings containing null characters.
///
/// # Returns
///
/// a null-terminated string result of the conversion.
#[doc(alias = "jsc_value_to_string")]
#[doc(alias = "to_string")]
pub fn to_str(&self) -> glib::GString {
unsafe { from_glib_full(ffi::jsc_value_to_string(self.to_glib_none().0)) }
}
/// Convert @self to a string and return the results as #GBytes. This is needed
/// to handle strings with null characters.
///
/// # Returns
///
/// a #GBytes with the result of the conversion.
#[doc(alias = "jsc_value_to_string_as_bytes")]
pub fn to_string_as_bytes(&self) -> Option<glib::Bytes> {
unsafe { from_glib_full(ffi::jsc_value_to_string_as_bytes(self.to_glib_none().0)) }
}
/// Obtain the `ArrayBuffer` for the memory region of the typed array elements.
///
/// # Returns
///
/// A #JSCValue
#[doc(alias = "jsc_value_typed_array_get_buffer")]
#[must_use]
pub fn typed_array_get_buffer(&self) -> Option<Value> {
unsafe { from_glib_full(ffi::jsc_value_typed_array_get_buffer(self.to_glib_none().0)) }
}
//#[doc(alias = "jsc_value_typed_array_get_data")]
//pub fn typed_array_get_data(&self) -> (/*Unimplemented*/Option<Basic: Pointer>, usize) {
// unsafe { TODO: call ffi:jsc_value_typed_array_get_data() }
//}
/// Gets the number of elements in a typed array.
///
/// # Returns
///
/// number of elements.
#[doc(alias = "jsc_value_typed_array_get_length")]
pub fn typed_array_get_length(&self) -> usize {
unsafe { ffi::jsc_value_typed_array_get_length(self.to_glib_none().0) }
}
/// Gets the offset over the underlying array buffer data.
///
/// # Returns
///
/// offset, in bytes.
#[doc(alias = "jsc_value_typed_array_get_offset")]
pub fn typed_array_get_offset(&self) -> usize {
unsafe { ffi::jsc_value_typed_array_get_offset(self.to_glib_none().0) }
}
/// Gets the size of a typed array.
///
/// # Returns
///
/// size, in bytes.
#[doc(alias = "jsc_value_typed_array_get_size")]
pub fn typed_array_get_size(&self) -> usize {
unsafe { ffi::jsc_value_typed_array_get_size(self.to_glib_none().0) }
}
/// Gets the type of elements contained in a typed array.
///
/// # Returns
///
/// type of the elements, or [`TypedArrayType::None`][crate::TypedArrayType::None] if @self is not a typed array.
#[doc(alias = "jsc_value_typed_array_get_type")]
pub fn typed_array_get_type(&self) -> TypedArrayType {
unsafe { from_glib(ffi::jsc_value_typed_array_get_type(self.to_glib_none().0)) }
}
}
impl std::fmt::Display for Value {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&self.to_str())
}
}