From 6975de693575f64199524f23c676f21b27727ece Mon Sep 17 00:00:00 2001 From: DK Liao Date: Wed, 25 Oct 2023 20:25:02 +0800 Subject: [PATCH] Fix doc build --- Cargo.toml | 5 +- src/auto/class.rs | 84 ++-- src/auto/context.rs | 463 ++++++++--------- src/auto/enums.rs | 367 +++++++------- src/auto/exception.rs | 210 ++++---- src/auto/flags.rs | 21 +- src/auto/mod.rs | 14 +- src/auto/value.rs | 963 +++++++++++++++++------------------- src/auto/virtual_machine.rs | 23 +- src/auto/weak_value.rs | 134 +++-- sys/Cargo.toml | 35 +- sys/build.rs | 8 +- sys/src/lib.rs | 935 +++++++++++++--------------------- sys/tests/abi.rs | 488 ++++++++---------- 14 files changed, 1642 insertions(+), 2108 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cd2ae1c..6a2483e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,9 @@ repository = "https://github.com/tauri-apps/javascriptcore-rs" version = "1.1.1" [package.metadata.docs.rs] -features = [ "dox" ] +all-features = true +rustc-args = [ "--cfg", "docsrs" ] +rustdoc-args = [ "--cfg", "docsrs" ] [lib] name = "javascriptcore" @@ -24,6 +26,5 @@ glib = "^0.18.0" [features] default = [ "v2_38" ] -dox = [ "ffi/dox" ] v2_28 = [ "ffi/v2_28" ] v2_38 = [ "ffi/v2_38", "v2_28" ] diff --git a/src/auto/class.rs b/src/auto/class.rs index eac723c..1868c58 100644 --- a/src/auto/class.rs +++ b/src/auto/class.rs @@ -2,7 +2,7 @@ // from gir-files (https://github.com/tauri-apps/gir-files) // DO NOT EDIT -use glib::translate::*; +use glib::{translate::*}; glib::wrapper! { #[doc(alias = "JSCClass")] @@ -14,51 +14,55 @@ glib::wrapper! { } impl Class { - //#[doc(alias = "jsc_class_add_constructor")] - //pub fn add_constructor(&self, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_params: u32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { - // unsafe { TODO: call ffi:jsc_class_add_constructor() } - //} + //#[doc(alias = "jsc_class_add_constructor")] + //pub fn add_constructor(&self, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_params: u32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { + // unsafe { TODO: call ffi:jsc_class_add_constructor() } + //} - //#[doc(alias = "jsc_class_add_constructor_variadic")] - //pub fn add_constructor_variadic(&self, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type) -> Option { - // unsafe { TODO: call ffi:jsc_class_add_constructor_variadic() } - //} + //#[doc(alias = "jsc_class_add_constructor_variadic")] + //pub fn add_constructor_variadic(&self, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type) -> Option { + // unsafe { TODO: call ffi:jsc_class_add_constructor_variadic() } + //} - //#[doc(alias = "jsc_class_add_constructorv")] - //pub fn add_constructorv(&self, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_parameters: u32) -> Option { - // unsafe { TODO: call ffi:jsc_class_add_constructorv() } - //} + //#[doc(alias = "jsc_class_add_constructorv")] + //pub fn add_constructorv(&self, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_parameters: u32) -> Option { + // unsafe { TODO: call ffi:jsc_class_add_constructorv() } + //} - //#[doc(alias = "jsc_class_add_method")] - //pub fn add_method(&self, name: &str, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_params: u32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { - // unsafe { TODO: call ffi:jsc_class_add_method() } - //} + //#[doc(alias = "jsc_class_add_method")] + //pub fn add_method(&self, name: &str, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_params: u32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { + // unsafe { TODO: call ffi:jsc_class_add_method() } + //} - //#[doc(alias = "jsc_class_add_method_variadic")] - //pub fn add_method_variadic(&self, name: &str, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type) { - // unsafe { TODO: call ffi:jsc_class_add_method_variadic() } - //} + //#[doc(alias = "jsc_class_add_method_variadic")] + //pub fn add_method_variadic(&self, name: &str, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type) { + // unsafe { TODO: call ffi:jsc_class_add_method_variadic() } + //} - //#[doc(alias = "jsc_class_add_methodv")] - //pub fn add_methodv(&self, name: &str, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_parameters: u32) { - // unsafe { TODO: call ffi:jsc_class_add_methodv() } - //} + //#[doc(alias = "jsc_class_add_methodv")] + //pub fn add_methodv(&self, name: &str, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_parameters: u32) { + // unsafe { TODO: call ffi:jsc_class_add_methodv() } + //} - //#[doc(alias = "jsc_class_add_property")] - //pub fn add_property(&self, name: &str, property_type: glib::types::Type, getter: Option>, setter: Option>, user_data: /*Unimplemented*/Option) { - // unsafe { TODO: call ffi:jsc_class_add_property() } - //} + //#[doc(alias = "jsc_class_add_property")] + //pub fn add_property(&self, name: &str, property_type: glib::types::Type, getter: Option>, setter: Option>, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:jsc_class_add_property() } + //} - #[doc(alias = "jsc_class_get_name")] - #[doc(alias = "get_name")] - pub fn name(&self) -> Option { - unsafe { from_glib_none(ffi::jsc_class_get_name(self.to_glib_none().0)) } - } + #[doc(alias = "jsc_class_get_name")] + #[doc(alias = "get_name")] + pub fn name(&self) -> Option { + unsafe { + from_glib_none(ffi::jsc_class_get_name(self.to_glib_none().0)) + } + } - #[doc(alias = "jsc_class_get_parent")] - #[doc(alias = "get_parent")] - #[must_use] - pub fn parent(&self) -> Option { - unsafe { from_glib_none(ffi::jsc_class_get_parent(self.to_glib_none().0)) } - } + #[doc(alias = "jsc_class_get_parent")] + #[doc(alias = "get_parent")] +#[must_use] + pub fn parent(&self) -> Option { + unsafe { + from_glib_none(ffi::jsc_class_get_parent(self.to_glib_none().0)) + } + } } diff --git a/src/auto/context.rs b/src/auto/context.rs index 7a5278c..8e1e603 100644 --- a/src/auto/context.rs +++ b/src/auto/context.rs @@ -2,9 +2,9 @@ // from gir-files (https://github.com/tauri-apps/gir-files) // DO NOT EDIT -use crate::{CheckSyntaxMode, CheckSyntaxResult, Exception, Value, VirtualMachine}; -use glib::{prelude::*, translate::*}; -use std::boxed::Box as Box_; +use crate::{CheckSyntaxMode,CheckSyntaxResult,Exception,Value,VirtualMachine}; +use glib::{prelude::*,translate::*}; +use std::{boxed::Box as Box_}; glib::wrapper! { #[doc(alias = "JSCContext")] @@ -16,279 +16,218 @@ glib::wrapper! { } impl Context { - pub const NONE: Option<&'static Context> = None; - - #[doc(alias = "jsc_context_new")] - pub fn new() -> Context { - unsafe { from_glib_full(ffi::jsc_context_new()) } - } - - #[doc(alias = "jsc_context_new_with_virtual_machine")] - #[doc(alias = "new_with_virtual_machine")] - pub fn with_virtual_machine(vm: &impl IsA) -> Context { - unsafe { - from_glib_full(ffi::jsc_context_new_with_virtual_machine( - vm.as_ref().to_glib_none().0, - )) + pub const NONE: Option<&'static Context> = None; + + + #[doc(alias = "jsc_context_new")] + pub fn new() -> Context { + unsafe { + from_glib_full(ffi::jsc_context_new()) + } + } + + #[doc(alias = "jsc_context_new_with_virtual_machine")] + #[doc(alias = "new_with_virtual_machine")] + pub fn with_virtual_machine(vm: &impl IsA) -> Context { + unsafe { + from_glib_full(ffi::jsc_context_new_with_virtual_machine(vm.as_ref().to_glib_none().0)) + } + } + + // rustdoc-stripper-ignore-next + /// Creates a new builder-pattern struct instance to construct [`Context`] objects. + /// + /// This method returns an instance of [`ContextBuilder`](crate::builders::ContextBuilder) which can be used to create [`Context`] objects. + pub fn builder() -> ContextBuilder { + ContextBuilder::new() + } + + + #[doc(alias = "jsc_context_get_current")] + #[doc(alias = "get_current")] + pub fn current() -> Option { + unsafe { + from_glib_none(ffi::jsc_context_get_current()) + } } - } - - // rustdoc-stripper-ignore-next - /// Creates a new builder-pattern struct instance to construct [`Context`] objects. - /// - /// This method returns an instance of [`ContextBuilder`](crate::builders::ContextBuilder) which can be used to create [`Context`] objects. - pub fn builder() -> ContextBuilder { - ContextBuilder::new() - } - - #[doc(alias = "jsc_context_get_current")] - #[doc(alias = "get_current")] - pub fn current() -> Option { - unsafe { from_glib_none(ffi::jsc_context_get_current()) } - } } impl Default for Context { - fn default() -> Self { - Self::new() - } -} + fn default() -> Self { + Self::new() + } + } // rustdoc-stripper-ignore-next -/// A [builder-pattern] type to construct [`Context`] objects. -/// -/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html + /// A [builder-pattern] type to construct [`Context`] objects. + /// + /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct ContextBuilder { - builder: glib::object::ObjectBuilder<'static, Context>, -} - -impl ContextBuilder { - fn new() -> Self { - Self { - builder: glib::object::Object::builder(), - } - } - - pub fn virtual_machine(self, virtual_machine: &impl IsA) -> Self { - Self { - builder: self - .builder - .property("virtual-machine", virtual_machine.clone().upcast()), - } - } - - // rustdoc-stripper-ignore-next - /// Build the [`Context`]. - #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] - pub fn build(self) -> Context { - self.builder.build() - } + builder: glib::object::ObjectBuilder<'static, Context>, + } + + impl ContextBuilder { + fn new() -> Self { + Self { builder: glib::object::Object::builder() } + } + + pub fn virtual_machine(self, virtual_machine: &impl IsA) -> Self { + Self { builder: self.builder.property("virtual-machine", virtual_machine.clone().upcast()), } + } + + // rustdoc-stripper-ignore-next + /// Build the [`Context`]. + #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] + pub fn build(self) -> Context { + self.builder.build() } } mod sealed { - pub trait Sealed {} - impl> Sealed for T {} + pub trait Sealed {} + impl> Sealed for T {} } pub trait ContextExt: IsA + sealed::Sealed + 'static { - #[doc(alias = "jsc_context_check_syntax")] - fn check_syntax( - &self, - code: &str, - mode: CheckSyntaxMode, - uri: &str, - line_number: u32, - ) -> (CheckSyntaxResult, Exception) { - let length = code.len() as _; - unsafe { - let mut exception = std::ptr::null_mut(); - let ret = from_glib(ffi::jsc_context_check_syntax( - self.as_ref().to_glib_none().0, - code.to_glib_none().0, - length, - mode.into_glib(), - uri.to_glib_none().0, - line_number, - &mut exception, - )); - (ret, from_glib_full(exception)) - } - } - - #[doc(alias = "jsc_context_clear_exception")] - fn clear_exception(&self) { - unsafe { - ffi::jsc_context_clear_exception(self.as_ref().to_glib_none().0); - } - } - - #[doc(alias = "jsc_context_evaluate")] - fn evaluate(&self, code: &str) -> Option { - let length = code.len() as _; - unsafe { - from_glib_full(ffi::jsc_context_evaluate( - self.as_ref().to_glib_none().0, - code.to_glib_none().0, - length, - )) - } - } - - //#[doc(alias = "jsc_context_evaluate_in_object")] - //fn evaluate_in_object(&self, code: &str, object_instance: /*Unimplemented*/Option, object_class: Option<&Class>, uri: &str, line_number: u32) -> (Value, Value) { - // unsafe { TODO: call ffi:jsc_context_evaluate_in_object() } - //} - - #[doc(alias = "jsc_context_evaluate_with_source_uri")] - fn evaluate_with_source_uri(&self, code: &str, uri: &str, line_number: u32) -> Option { - let length = code.len() as _; - unsafe { - from_glib_full(ffi::jsc_context_evaluate_with_source_uri( - self.as_ref().to_glib_none().0, - code.to_glib_none().0, - length, - uri.to_glib_none().0, - line_number, - )) - } - } - - #[doc(alias = "jsc_context_get_exception")] - #[doc(alias = "get_exception")] - fn exception(&self) -> Option { - unsafe { - from_glib_none(ffi::jsc_context_get_exception( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_context_get_global_object")] - #[doc(alias = "get_global_object")] - fn global_object(&self) -> Option { - unsafe { - from_glib_full(ffi::jsc_context_get_global_object( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_context_get_value")] - #[doc(alias = "get_value")] - fn value(&self, name: &str) -> Option { - unsafe { - from_glib_full(ffi::jsc_context_get_value( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_context_get_virtual_machine")] - #[doc(alias = "get_virtual_machine")] - fn virtual_machine(&self) -> Option { - unsafe { - from_glib_none(ffi::jsc_context_get_virtual_machine( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_context_pop_exception_handler")] - fn pop_exception_handler(&self) { - unsafe { - ffi::jsc_context_pop_exception_handler(self.as_ref().to_glib_none().0); - } - } - - #[doc(alias = "jsc_context_push_exception_handler")] - fn push_exception_handler(&self, handler: P) { - let handler_data: Box_

= Box_::new(handler); - unsafe extern "C" fn handler_func( - context: *mut ffi::JSCContext, - exception: *mut ffi::JSCException, - user_data: glib::ffi::gpointer, - ) { - let context = from_glib_borrow(context); - let exception = from_glib_borrow(exception); - let callback: &P = &*(user_data as *mut _); - (*callback)(&context, &exception) - } - let handler = Some(handler_func::

as _); - unsafe extern "C" fn destroy_notify_func( - data: glib::ffi::gpointer, - ) { - let _callback: Box_

= Box_::from_raw(data as *mut _); - } - let destroy_call3 = Some(destroy_notify_func::

as _); - let super_callback0: Box_

= handler_data; - unsafe { - ffi::jsc_context_push_exception_handler( - self.as_ref().to_glib_none().0, - handler, - Box_::into_raw(super_callback0) as *mut _, - destroy_call3, - ); - } - } - - //#[doc(alias = "jsc_context_register_class")] - //fn register_class(&self, name: &str, parent_class: Option<&Class>, vtable: /*Ignored*/Option<&mut ClassVTable>) -> Option { - // unsafe { TODO: call ffi:jsc_context_register_class() } - //} - - #[doc(alias = "jsc_context_set_value")] - fn set_value(&self, name: &str, value: &impl IsA) { - unsafe { - ffi::jsc_context_set_value( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - value.as_ref().to_glib_none().0, - ); - } - } - - #[doc(alias = "jsc_context_throw")] - fn throw(&self, error_message: &str) { - unsafe { - ffi::jsc_context_throw( - self.as_ref().to_glib_none().0, - error_message.to_glib_none().0, - ); - } - } - - #[doc(alias = "jsc_context_throw_exception")] - fn throw_exception(&self, exception: &impl IsA) { - unsafe { - ffi::jsc_context_throw_exception( - self.as_ref().to_glib_none().0, - exception.as_ref().to_glib_none().0, - ); - } - } - - //#[doc(alias = "jsc_context_throw_printf")] - //fn throw_printf(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { - // unsafe { TODO: call ffi:jsc_context_throw_printf() } - //} - - #[doc(alias = "jsc_context_throw_with_name")] - fn throw_with_name(&self, error_name: &str, error_message: &str) { - unsafe { - ffi::jsc_context_throw_with_name( - self.as_ref().to_glib_none().0, - error_name.to_glib_none().0, - error_message.to_glib_none().0, - ); - } - } - - //#[doc(alias = "jsc_context_throw_with_name_printf")] - //fn throw_with_name_printf(&self, error_name: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { - // unsafe { TODO: call ffi:jsc_context_throw_with_name_printf() } - //} + #[doc(alias = "jsc_context_check_syntax")] + fn check_syntax(&self, code: &str, mode: CheckSyntaxMode, uri: &str, line_number: u32) -> (CheckSyntaxResult, Exception) { + let length = code.len() as _; + unsafe { + let mut exception = std::ptr::null_mut(); + let ret = from_glib(ffi::jsc_context_check_syntax(self.as_ref().to_glib_none().0, code.to_glib_none().0, length, mode.into_glib(), uri.to_glib_none().0, line_number, &mut exception)); + (ret, from_glib_full(exception)) + } + } + + #[doc(alias = "jsc_context_clear_exception")] + fn clear_exception(&self) { + unsafe { + ffi::jsc_context_clear_exception(self.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "jsc_context_evaluate")] + fn evaluate(&self, code: &str) -> Option { + let length = code.len() as _; + unsafe { + from_glib_full(ffi::jsc_context_evaluate(self.as_ref().to_glib_none().0, code.to_glib_none().0, length)) + } + } + + //#[doc(alias = "jsc_context_evaluate_in_object")] + //fn evaluate_in_object(&self, code: &str, object_instance: /*Unimplemented*/Option, object_class: Option<&Class>, uri: &str, line_number: u32) -> (Value, Value) { + // unsafe { TODO: call ffi:jsc_context_evaluate_in_object() } + //} + + #[doc(alias = "jsc_context_evaluate_with_source_uri")] + fn evaluate_with_source_uri(&self, code: &str, uri: &str, line_number: u32) -> Option { + let length = code.len() as _; + unsafe { + from_glib_full(ffi::jsc_context_evaluate_with_source_uri(self.as_ref().to_glib_none().0, code.to_glib_none().0, length, uri.to_glib_none().0, line_number)) + } + } + + #[doc(alias = "jsc_context_get_exception")] + #[doc(alias = "get_exception")] + fn exception(&self) -> Option { + unsafe { + from_glib_none(ffi::jsc_context_get_exception(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_context_get_global_object")] + #[doc(alias = "get_global_object")] + fn global_object(&self) -> Option { + unsafe { + from_glib_full(ffi::jsc_context_get_global_object(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_context_get_value")] + #[doc(alias = "get_value")] + fn value(&self, name: &str) -> Option { + unsafe { + from_glib_full(ffi::jsc_context_get_value(self.as_ref().to_glib_none().0, name.to_glib_none().0)) + } + } + + #[doc(alias = "jsc_context_get_virtual_machine")] + #[doc(alias = "get_virtual_machine")] + fn virtual_machine(&self) -> Option { + unsafe { + from_glib_none(ffi::jsc_context_get_virtual_machine(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_context_pop_exception_handler")] + fn pop_exception_handler(&self) { + unsafe { + ffi::jsc_context_pop_exception_handler(self.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "jsc_context_push_exception_handler")] + fn push_exception_handler(&self, handler: P) { + let handler_data: Box_

= Box_::new(handler); + unsafe extern "C" fn handler_func(context: *mut ffi::JSCContext, exception: *mut ffi::JSCException, user_data: glib::ffi::gpointer) { + let context = from_glib_borrow(context); + let exception = from_glib_borrow(exception); + let callback: &P = &*(user_data as *mut _); + (*callback)(&context, &exception) + } + let handler = Some(handler_func::

as _); + unsafe extern "C" fn destroy_notify_func(data: glib::ffi::gpointer) { + let _callback: Box_

= Box_::from_raw(data as *mut _); + } + let destroy_call3 = Some(destroy_notify_func::

as _); + let super_callback0: Box_

= handler_data; + unsafe { + ffi::jsc_context_push_exception_handler(self.as_ref().to_glib_none().0, handler, Box_::into_raw(super_callback0) as *mut _, destroy_call3); + } + } + + //#[doc(alias = "jsc_context_register_class")] + //fn register_class(&self, name: &str, parent_class: Option<&Class>, vtable: /*Ignored*/Option<&mut ClassVTable>) -> Option { + // unsafe { TODO: call ffi:jsc_context_register_class() } + //} + + #[doc(alias = "jsc_context_set_value")] + fn set_value(&self, name: &str, value: &impl IsA) { + unsafe { + ffi::jsc_context_set_value(self.as_ref().to_glib_none().0, name.to_glib_none().0, value.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "jsc_context_throw")] + fn throw(&self, error_message: &str) { + unsafe { + ffi::jsc_context_throw(self.as_ref().to_glib_none().0, error_message.to_glib_none().0); + } + } + + #[doc(alias = "jsc_context_throw_exception")] + fn throw_exception(&self, exception: &impl IsA) { + unsafe { + ffi::jsc_context_throw_exception(self.as_ref().to_glib_none().0, exception.as_ref().to_glib_none().0); + } + } + + //#[doc(alias = "jsc_context_throw_printf")] + //fn throw_printf(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { + // unsafe { TODO: call ffi:jsc_context_throw_printf() } + //} + + #[doc(alias = "jsc_context_throw_with_name")] + fn throw_with_name(&self, error_name: &str, error_message: &str) { + unsafe { + ffi::jsc_context_throw_with_name(self.as_ref().to_glib_none().0, error_name.to_glib_none().0, error_message.to_glib_none().0); + } + } + + //#[doc(alias = "jsc_context_throw_with_name_printf")] + //fn throw_with_name_printf(&self, error_name: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { + // unsafe { TODO: call ffi:jsc_context_throw_with_name_printf() } + //} } impl> ContextExt for O {} diff --git a/src/auto/enums.rs b/src/auto/enums.rs index 4f3a93b..9092e2f 100644 --- a/src/auto/enums.rs +++ b/src/auto/enums.rs @@ -2,238 +2,247 @@ // from gir-files (https://github.com/tauri-apps/gir-files) // DO NOT EDIT -use glib::translate::*; +use glib::{translate::*}; -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Clone, Copy)] #[non_exhaustive] #[doc(alias = "JSCCheckSyntaxMode")] pub enum CheckSyntaxMode { - #[doc(alias = "JSC_CHECK_SYNTAX_MODE_SCRIPT")] - Script, - #[doc(alias = "JSC_CHECK_SYNTAX_MODE_MODULE")] - Module, - #[doc(hidden)] - __Unknown(i32), + #[doc(alias = "JSC_CHECK_SYNTAX_MODE_SCRIPT")] + Script, + #[doc(alias = "JSC_CHECK_SYNTAX_MODE_MODULE")] + Module, +#[doc(hidden)] + __Unknown(i32), } #[doc(hidden)] impl IntoGlib for CheckSyntaxMode { - type GlibType = ffi::JSCCheckSyntaxMode; - - #[inline] - fn into_glib(self) -> ffi::JSCCheckSyntaxMode { - match self { - Self::Script => ffi::JSC_CHECK_SYNTAX_MODE_SCRIPT, - Self::Module => ffi::JSC_CHECK_SYNTAX_MODE_MODULE, - Self::__Unknown(value) => value, - } - } + type GlibType = ffi::JSCCheckSyntaxMode; + + #[inline] +fn into_glib(self) -> ffi::JSCCheckSyntaxMode { +match self { + Self::Script => ffi::JSC_CHECK_SYNTAX_MODE_SCRIPT, + Self::Module => ffi::JSC_CHECK_SYNTAX_MODE_MODULE, + Self::__Unknown(value) => value, +} +} } #[doc(hidden)] impl FromGlib for CheckSyntaxMode { - #[inline] - unsafe fn from_glib(value: ffi::JSCCheckSyntaxMode) -> Self { - match value { - ffi::JSC_CHECK_SYNTAX_MODE_SCRIPT => Self::Script, - ffi::JSC_CHECK_SYNTAX_MODE_MODULE => Self::Module, - value => Self::__Unknown(value), - } - } + #[inline] +unsafe fn from_glib(value: ffi::JSCCheckSyntaxMode) -> Self { + +match value { + ffi::JSC_CHECK_SYNTAX_MODE_SCRIPT => Self::Script, + ffi::JSC_CHECK_SYNTAX_MODE_MODULE => Self::Module, + value => Self::__Unknown(value), +} +} } -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Clone, Copy)] #[non_exhaustive] #[doc(alias = "JSCCheckSyntaxResult")] pub enum CheckSyntaxResult { - #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_SUCCESS")] - Success, - #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR")] - RecoverableError, - #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR")] - IrrecoverableError, - #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR")] - UnterminatedLiteralError, - #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR")] - OutOfMemoryError, - #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR")] - StackOverflowError, - #[doc(hidden)] - __Unknown(i32), + #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_SUCCESS")] + Success, + #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR")] + RecoverableError, + #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR")] + IrrecoverableError, + #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR")] + UnterminatedLiteralError, + #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR")] + OutOfMemoryError, + #[doc(alias = "JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR")] + StackOverflowError, +#[doc(hidden)] + __Unknown(i32), } #[doc(hidden)] impl IntoGlib for CheckSyntaxResult { - type GlibType = ffi::JSCCheckSyntaxResult; - - #[inline] - fn into_glib(self) -> ffi::JSCCheckSyntaxResult { - match self { - Self::Success => ffi::JSC_CHECK_SYNTAX_RESULT_SUCCESS, - Self::RecoverableError => ffi::JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR, - Self::IrrecoverableError => ffi::JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR, - Self::UnterminatedLiteralError => ffi::JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR, - Self::OutOfMemoryError => ffi::JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR, - Self::StackOverflowError => ffi::JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR, - Self::__Unknown(value) => value, - } - } + type GlibType = ffi::JSCCheckSyntaxResult; + + #[inline] +fn into_glib(self) -> ffi::JSCCheckSyntaxResult { +match self { + Self::Success => ffi::JSC_CHECK_SYNTAX_RESULT_SUCCESS, + Self::RecoverableError => ffi::JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR, + Self::IrrecoverableError => ffi::JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR, + Self::UnterminatedLiteralError => ffi::JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR, + Self::OutOfMemoryError => ffi::JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR, + Self::StackOverflowError => ffi::JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR, + Self::__Unknown(value) => value, +} +} } #[doc(hidden)] impl FromGlib for CheckSyntaxResult { - #[inline] - unsafe fn from_glib(value: ffi::JSCCheckSyntaxResult) -> Self { - match value { - ffi::JSC_CHECK_SYNTAX_RESULT_SUCCESS => Self::Success, - ffi::JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR => Self::RecoverableError, - ffi::JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR => Self::IrrecoverableError, - ffi::JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR => Self::UnterminatedLiteralError, - ffi::JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR => Self::OutOfMemoryError, - ffi::JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR => Self::StackOverflowError, - value => Self::__Unknown(value), - } - } -} - -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] + #[inline] +unsafe fn from_glib(value: ffi::JSCCheckSyntaxResult) -> Self { + +match value { + ffi::JSC_CHECK_SYNTAX_RESULT_SUCCESS => Self::Success, + ffi::JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR => Self::RecoverableError, + ffi::JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR => Self::IrrecoverableError, + ffi::JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR => Self::UnterminatedLiteralError, + ffi::JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR => Self::OutOfMemoryError, + ffi::JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR => Self::StackOverflowError, + value => Self::__Unknown(value), +} +} +} + +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Clone, Copy)] #[non_exhaustive] #[doc(alias = "JSCOptionType")] pub enum OptionType { - #[doc(alias = "JSC_OPTION_BOOLEAN")] - Boolean, - #[doc(alias = "JSC_OPTION_INT")] - Int, - #[doc(alias = "JSC_OPTION_UINT")] - Uint, - #[doc(alias = "JSC_OPTION_SIZE")] - Size, - #[doc(alias = "JSC_OPTION_DOUBLE")] - Double, - #[doc(alias = "JSC_OPTION_STRING")] - String, - #[doc(alias = "JSC_OPTION_RANGE_STRING")] - RangeString, - #[doc(hidden)] - __Unknown(i32), + #[doc(alias = "JSC_OPTION_BOOLEAN")] + Boolean, + #[doc(alias = "JSC_OPTION_INT")] + Int, + #[doc(alias = "JSC_OPTION_UINT")] + Uint, + #[doc(alias = "JSC_OPTION_SIZE")] + Size, + #[doc(alias = "JSC_OPTION_DOUBLE")] + Double, + #[doc(alias = "JSC_OPTION_STRING")] + String, + #[doc(alias = "JSC_OPTION_RANGE_STRING")] + RangeString, +#[doc(hidden)] + __Unknown(i32), } #[doc(hidden)] impl IntoGlib for OptionType { - type GlibType = ffi::JSCOptionType; - - #[inline] - fn into_glib(self) -> ffi::JSCOptionType { - match self { - Self::Boolean => ffi::JSC_OPTION_BOOLEAN, - Self::Int => ffi::JSC_OPTION_INT, - Self::Uint => ffi::JSC_OPTION_UINT, - Self::Size => ffi::JSC_OPTION_SIZE, - Self::Double => ffi::JSC_OPTION_DOUBLE, - Self::String => ffi::JSC_OPTION_STRING, - Self::RangeString => ffi::JSC_OPTION_RANGE_STRING, - Self::__Unknown(value) => value, - } - } + type GlibType = ffi::JSCOptionType; + + #[inline] +fn into_glib(self) -> ffi::JSCOptionType { +match self { + Self::Boolean => ffi::JSC_OPTION_BOOLEAN, + Self::Int => ffi::JSC_OPTION_INT, + Self::Uint => ffi::JSC_OPTION_UINT, + Self::Size => ffi::JSC_OPTION_SIZE, + Self::Double => ffi::JSC_OPTION_DOUBLE, + Self::String => ffi::JSC_OPTION_STRING, + Self::RangeString => ffi::JSC_OPTION_RANGE_STRING, + Self::__Unknown(value) => value, +} +} } #[doc(hidden)] impl FromGlib for OptionType { - #[inline] - unsafe fn from_glib(value: ffi::JSCOptionType) -> Self { - match value { - ffi::JSC_OPTION_BOOLEAN => Self::Boolean, - ffi::JSC_OPTION_INT => Self::Int, - ffi::JSC_OPTION_UINT => Self::Uint, - ffi::JSC_OPTION_SIZE => Self::Size, - ffi::JSC_OPTION_DOUBLE => Self::Double, - ffi::JSC_OPTION_STRING => Self::String, - ffi::JSC_OPTION_RANGE_STRING => Self::RangeString, - value => Self::__Unknown(value), - } - } + #[inline] +unsafe fn from_glib(value: ffi::JSCOptionType) -> Self { + +match value { + ffi::JSC_OPTION_BOOLEAN => Self::Boolean, + ffi::JSC_OPTION_INT => Self::Int, + ffi::JSC_OPTION_UINT => Self::Uint, + ffi::JSC_OPTION_SIZE => Self::Size, + ffi::JSC_OPTION_DOUBLE => Self::Double, + ffi::JSC_OPTION_STRING => Self::String, + ffi::JSC_OPTION_RANGE_STRING => Self::RangeString, + value => Self::__Unknown(value), +} +} } #[cfg(feature = "v2_38")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] -#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Clone, Copy)] #[non_exhaustive] #[doc(alias = "JSCTypedArrayType")] pub enum TypedArrayType { - #[doc(alias = "JSC_TYPED_ARRAY_NONE")] - None, - #[doc(alias = "JSC_TYPED_ARRAY_INT8")] - Int8, - #[doc(alias = "JSC_TYPED_ARRAY_INT16")] - Int16, - #[doc(alias = "JSC_TYPED_ARRAY_INT32")] - Int32, - #[doc(alias = "JSC_TYPED_ARRAY_INT64")] - Int64, - #[doc(alias = "JSC_TYPED_ARRAY_UINT8")] - Uint8, - #[doc(alias = "JSC_TYPED_ARRAY_UINT8_CLAMPED")] - Uint8Clamped, - #[doc(alias = "JSC_TYPED_ARRAY_UINT16")] - Uint16, - #[doc(alias = "JSC_TYPED_ARRAY_UINT32")] - Uint32, - #[doc(alias = "JSC_TYPED_ARRAY_UINT64")] - Uint64, - #[doc(alias = "JSC_TYPED_ARRAY_FLOAT32")] - Float32, - #[doc(alias = "JSC_TYPED_ARRAY_FLOAT64")] - Float64, - #[doc(hidden)] - __Unknown(i32), + #[doc(alias = "JSC_TYPED_ARRAY_NONE")] + None, + #[doc(alias = "JSC_TYPED_ARRAY_INT8")] + Int8, + #[doc(alias = "JSC_TYPED_ARRAY_INT16")] + Int16, + #[doc(alias = "JSC_TYPED_ARRAY_INT32")] + Int32, + #[doc(alias = "JSC_TYPED_ARRAY_INT64")] + Int64, + #[doc(alias = "JSC_TYPED_ARRAY_UINT8")] + Uint8, + #[doc(alias = "JSC_TYPED_ARRAY_UINT8_CLAMPED")] + Uint8Clamped, + #[doc(alias = "JSC_TYPED_ARRAY_UINT16")] + Uint16, + #[doc(alias = "JSC_TYPED_ARRAY_UINT32")] + Uint32, + #[doc(alias = "JSC_TYPED_ARRAY_UINT64")] + Uint64, + #[doc(alias = "JSC_TYPED_ARRAY_FLOAT32")] + Float32, + #[doc(alias = "JSC_TYPED_ARRAY_FLOAT64")] + Float64, +#[doc(hidden)] + __Unknown(i32), } #[cfg(feature = "v2_38")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] #[doc(hidden)] impl IntoGlib for TypedArrayType { - type GlibType = ffi::JSCTypedArrayType; - - #[inline] - fn into_glib(self) -> ffi::JSCTypedArrayType { - match self { - Self::None => ffi::JSC_TYPED_ARRAY_NONE, - Self::Int8 => ffi::JSC_TYPED_ARRAY_INT8, - Self::Int16 => ffi::JSC_TYPED_ARRAY_INT16, - Self::Int32 => ffi::JSC_TYPED_ARRAY_INT32, - Self::Int64 => ffi::JSC_TYPED_ARRAY_INT64, - Self::Uint8 => ffi::JSC_TYPED_ARRAY_UINT8, - Self::Uint8Clamped => ffi::JSC_TYPED_ARRAY_UINT8_CLAMPED, - Self::Uint16 => ffi::JSC_TYPED_ARRAY_UINT16, - Self::Uint32 => ffi::JSC_TYPED_ARRAY_UINT32, - Self::Uint64 => ffi::JSC_TYPED_ARRAY_UINT64, - Self::Float32 => ffi::JSC_TYPED_ARRAY_FLOAT32, - Self::Float64 => ffi::JSC_TYPED_ARRAY_FLOAT64, - Self::__Unknown(value) => value, - } - } + type GlibType = ffi::JSCTypedArrayType; + + #[inline] +fn into_glib(self) -> ffi::JSCTypedArrayType { +match self { + Self::None => ffi::JSC_TYPED_ARRAY_NONE, + Self::Int8 => ffi::JSC_TYPED_ARRAY_INT8, + Self::Int16 => ffi::JSC_TYPED_ARRAY_INT16, + Self::Int32 => ffi::JSC_TYPED_ARRAY_INT32, + Self::Int64 => ffi::JSC_TYPED_ARRAY_INT64, + Self::Uint8 => ffi::JSC_TYPED_ARRAY_UINT8, + Self::Uint8Clamped => ffi::JSC_TYPED_ARRAY_UINT8_CLAMPED, + Self::Uint16 => ffi::JSC_TYPED_ARRAY_UINT16, + Self::Uint32 => ffi::JSC_TYPED_ARRAY_UINT32, + Self::Uint64 => ffi::JSC_TYPED_ARRAY_UINT64, + Self::Float32 => ffi::JSC_TYPED_ARRAY_FLOAT32, + Self::Float64 => ffi::JSC_TYPED_ARRAY_FLOAT64, + Self::__Unknown(value) => value, +} +} } #[cfg(feature = "v2_38")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] #[doc(hidden)] impl FromGlib for TypedArrayType { - #[inline] - unsafe fn from_glib(value: ffi::JSCTypedArrayType) -> Self { - match value { - ffi::JSC_TYPED_ARRAY_NONE => Self::None, - ffi::JSC_TYPED_ARRAY_INT8 => Self::Int8, - ffi::JSC_TYPED_ARRAY_INT16 => Self::Int16, - ffi::JSC_TYPED_ARRAY_INT32 => Self::Int32, - ffi::JSC_TYPED_ARRAY_INT64 => Self::Int64, - ffi::JSC_TYPED_ARRAY_UINT8 => Self::Uint8, - ffi::JSC_TYPED_ARRAY_UINT8_CLAMPED => Self::Uint8Clamped, - ffi::JSC_TYPED_ARRAY_UINT16 => Self::Uint16, - ffi::JSC_TYPED_ARRAY_UINT32 => Self::Uint32, - ffi::JSC_TYPED_ARRAY_UINT64 => Self::Uint64, - ffi::JSC_TYPED_ARRAY_FLOAT32 => Self::Float32, - ffi::JSC_TYPED_ARRAY_FLOAT64 => Self::Float64, - value => Self::__Unknown(value), - } - } + #[inline] +unsafe fn from_glib(value: ffi::JSCTypedArrayType) -> Self { + +match value { + ffi::JSC_TYPED_ARRAY_NONE => Self::None, + ffi::JSC_TYPED_ARRAY_INT8 => Self::Int8, + ffi::JSC_TYPED_ARRAY_INT16 => Self::Int16, + ffi::JSC_TYPED_ARRAY_INT32 => Self::Int32, + ffi::JSC_TYPED_ARRAY_INT64 => Self::Int64, + ffi::JSC_TYPED_ARRAY_UINT8 => Self::Uint8, + ffi::JSC_TYPED_ARRAY_UINT8_CLAMPED => Self::Uint8Clamped, + ffi::JSC_TYPED_ARRAY_UINT16 => Self::Uint16, + ffi::JSC_TYPED_ARRAY_UINT32 => Self::Uint32, + ffi::JSC_TYPED_ARRAY_UINT64 => Self::Uint64, + ffi::JSC_TYPED_ARRAY_FLOAT32 => Self::Float32, + ffi::JSC_TYPED_ARRAY_FLOAT64 => Self::Float64, + value => Self::__Unknown(value), } +} +} + diff --git a/src/auto/exception.rs b/src/auto/exception.rs index a972cc0..7136e90 100644 --- a/src/auto/exception.rs +++ b/src/auto/exception.rs @@ -2,8 +2,8 @@ // from gir-files (https://github.com/tauri-apps/gir-files) // DO NOT EDIT -use crate::Context; -use glib::{prelude::*, translate::*}; +use crate::{Context}; +use glib::{prelude::*,translate::*}; glib::wrapper! { #[doc(alias = "JSCException")] @@ -15,124 +15,122 @@ glib::wrapper! { } impl Exception { - pub const NONE: Option<&'static Exception> = None; - - #[doc(alias = "jsc_exception_new")] - pub fn new(context: &impl IsA, message: &str) -> Exception { - unsafe { - from_glib_full(ffi::jsc_exception_new( - context.as_ref().to_glib_none().0, - message.to_glib_none().0, - )) + pub const NONE: Option<&'static Exception> = None; + + + #[doc(alias = "jsc_exception_new")] + pub fn new(context: &impl IsA, message: &str) -> Exception { + unsafe { + from_glib_full(ffi::jsc_exception_new(context.as_ref().to_glib_none().0, message.to_glib_none().0)) + } } - } - - //#[doc(alias = "jsc_exception_new_printf")] - //pub fn new_printf(context: &impl IsA, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Exception { - // unsafe { TODO: call ffi:jsc_exception_new_printf() } - //} - - //#[doc(alias = "jsc_exception_new_vprintf")] - //pub fn new_vprintf(context: &impl IsA, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Exception { - // unsafe { TODO: call ffi:jsc_exception_new_vprintf() } - //} - - #[doc(alias = "jsc_exception_new_with_name")] - #[doc(alias = "new_with_name")] - pub fn with_name(context: &impl IsA, name: &str, message: &str) -> Exception { - unsafe { - from_glib_full(ffi::jsc_exception_new_with_name( - context.as_ref().to_glib_none().0, - name.to_glib_none().0, - message.to_glib_none().0, - )) + + //#[doc(alias = "jsc_exception_new_printf")] + //pub fn new_printf(context: &impl IsA, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Exception { + // unsafe { TODO: call ffi:jsc_exception_new_printf() } + //} + + //#[doc(alias = "jsc_exception_new_vprintf")] + //pub fn new_vprintf(context: &impl IsA, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Exception { + // unsafe { TODO: call ffi:jsc_exception_new_vprintf() } + //} + + #[doc(alias = "jsc_exception_new_with_name")] + #[doc(alias = "new_with_name")] + pub fn with_name(context: &impl IsA, name: &str, message: &str) -> Exception { + unsafe { + from_glib_full(ffi::jsc_exception_new_with_name(context.as_ref().to_glib_none().0, name.to_glib_none().0, message.to_glib_none().0)) + } } - } - - //#[doc(alias = "jsc_exception_new_with_name_printf")] - //#[doc(alias = "new_with_name_printf")] - //pub fn with_name_printf(context: &impl IsA, name: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Exception { - // unsafe { TODO: call ffi:jsc_exception_new_with_name_printf() } - //} - - //#[doc(alias = "jsc_exception_new_with_name_vprintf")] - //#[doc(alias = "new_with_name_vprintf")] - //pub fn with_name_vprintf(context: &impl IsA, name: &str, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Exception { - // unsafe { TODO: call ffi:jsc_exception_new_with_name_vprintf() } - //} + + //#[doc(alias = "jsc_exception_new_with_name_printf")] + //#[doc(alias = "new_with_name_printf")] + //pub fn with_name_printf(context: &impl IsA, name: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Exception { + // unsafe { TODO: call ffi:jsc_exception_new_with_name_printf() } + //} + + //#[doc(alias = "jsc_exception_new_with_name_vprintf")] + //#[doc(alias = "new_with_name_vprintf")] + //pub fn with_name_vprintf(context: &impl IsA, name: &str, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Exception { + // unsafe { TODO: call ffi:jsc_exception_new_with_name_vprintf() } + //} } impl std::fmt::Display for Exception { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(&ExceptionExt::to_str(self)) - } + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(&ExceptionExt::to_str(self)) + } } mod sealed { - pub trait Sealed {} - impl> Sealed for T {} + pub trait Sealed {} + impl> Sealed for T {} } pub trait ExceptionExt: IsA + sealed::Sealed + 'static { - #[doc(alias = "jsc_exception_get_backtrace_string")] - #[doc(alias = "get_backtrace_string")] - fn backtrace_string(&self) -> Option { - unsafe { - from_glib_none(ffi::jsc_exception_get_backtrace_string( - self.as_ref().to_glib_none().0, - )) + #[doc(alias = "jsc_exception_get_backtrace_string")] + #[doc(alias = "get_backtrace_string")] + fn backtrace_string(&self) -> Option { + unsafe { + from_glib_none(ffi::jsc_exception_get_backtrace_string(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_exception_get_column_number")] + #[doc(alias = "get_column_number")] + fn column_number(&self) -> u32 { + unsafe { + ffi::jsc_exception_get_column_number(self.as_ref().to_glib_none().0) + } + } + + #[doc(alias = "jsc_exception_get_line_number")] + #[doc(alias = "get_line_number")] + fn line_number(&self) -> u32 { + unsafe { + ffi::jsc_exception_get_line_number(self.as_ref().to_glib_none().0) + } } - } - - #[doc(alias = "jsc_exception_get_column_number")] - #[doc(alias = "get_column_number")] - fn column_number(&self) -> u32 { - unsafe { ffi::jsc_exception_get_column_number(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "jsc_exception_get_line_number")] - #[doc(alias = "get_line_number")] - fn line_number(&self) -> u32 { - unsafe { ffi::jsc_exception_get_line_number(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "jsc_exception_get_message")] - #[doc(alias = "get_message")] - fn message(&self) -> Option { - unsafe { - from_glib_none(ffi::jsc_exception_get_message( - self.as_ref().to_glib_none().0, - )) + + #[doc(alias = "jsc_exception_get_message")] + #[doc(alias = "get_message")] + fn message(&self) -> Option { + unsafe { + from_glib_none(ffi::jsc_exception_get_message(self.as_ref().to_glib_none().0)) + } } - } - - #[doc(alias = "jsc_exception_get_name")] - #[doc(alias = "get_name")] - fn name(&self) -> Option { - unsafe { from_glib_none(ffi::jsc_exception_get_name(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_exception_get_source_uri")] - #[doc(alias = "get_source_uri")] - fn source_uri(&self) -> Option { - unsafe { - from_glib_none(ffi::jsc_exception_get_source_uri( - self.as_ref().to_glib_none().0, - )) + + #[doc(alias = "jsc_exception_get_name")] + #[doc(alias = "get_name")] + fn name(&self) -> Option { + unsafe { + from_glib_none(ffi::jsc_exception_get_name(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_exception_get_source_uri")] + #[doc(alias = "get_source_uri")] + fn source_uri(&self) -> Option { + unsafe { + from_glib_none(ffi::jsc_exception_get_source_uri(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_exception_report")] + fn report(&self) -> Option { + unsafe { + from_glib_full(ffi::jsc_exception_report(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_exception_to_string")] + #[doc(alias = "to_string")] + fn to_str(&self) -> glib::GString { + unsafe { + from_glib_full(ffi::jsc_exception_to_string(self.as_ref().to_glib_none().0)) + } } - } - - #[doc(alias = "jsc_exception_report")] - fn report(&self) -> Option { - unsafe { from_glib_full(ffi::jsc_exception_report(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_exception_to_string")] - #[doc(alias = "to_string")] - fn to_str(&self) -> glib::GString { - unsafe { from_glib_full(ffi::jsc_exception_to_string(self.as_ref().to_glib_none().0)) } - } } impl> ExceptionExt for O {} diff --git a/src/auto/flags.rs b/src/auto/flags.rs index a85f6ca..f684649 100644 --- a/src/auto/flags.rs +++ b/src/auto/flags.rs @@ -2,7 +2,7 @@ // from gir-files (https://github.com/tauri-apps/gir-files) // DO NOT EDIT -use glib::{bitflags::bitflags, translate::*}; +use glib::{bitflags::bitflags,translate::*}; bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -19,18 +19,19 @@ bitflags! { #[doc(hidden)] impl IntoGlib for ValuePropertyFlags { - type GlibType = ffi::JSCValuePropertyFlags; + type GlibType = ffi::JSCValuePropertyFlags; - #[inline] - fn into_glib(self) -> ffi::JSCValuePropertyFlags { - self.bits() - } + #[inline] + fn into_glib(self) -> ffi::JSCValuePropertyFlags { + self.bits() + } } #[doc(hidden)] impl FromGlib for ValuePropertyFlags { - #[inline] - unsafe fn from_glib(value: ffi::JSCValuePropertyFlags) -> Self { - Self::from_bits_truncate(value) - } + #[inline] + unsafe fn from_glib(value: ffi::JSCValuePropertyFlags) -> Self { + Self::from_bits_truncate(value) + } } + diff --git a/src/auto/mod.rs b/src/auto/mod.rs index 6f1dd6f..8791936 100644 --- a/src/auto/mod.rs +++ b/src/auto/mod.rs @@ -32,13 +32,13 @@ mod flags; pub use self::flags::ValuePropertyFlags; pub(crate) mod traits { - pub use super::context::ContextExt; - pub use super::exception::ExceptionExt; - pub use super::value::ValueExt; - pub use super::weak_value::WeakValueExt; + pub use super::context::ContextExt; + pub use super::exception::ExceptionExt; + pub use super::value::ValueExt; + pub use super::weak_value::WeakValueExt; } pub(crate) mod builders { - pub use super::context::ContextBuilder; - pub use super::value::ValueBuilder; - pub use super::weak_value::WeakValueBuilder; + pub use super::context::ContextBuilder; + pub use super::value::ValueBuilder; + pub use super::weak_value::WeakValueBuilder; } diff --git a/src/auto/value.rs b/src/auto/value.rs index cd5c976..0a23111 100644 --- a/src/auto/value.rs +++ b/src/auto/value.rs @@ -2,11 +2,11 @@ // from gir-files (https://github.com/tauri-apps/gir-files) // DO NOT EDIT +use crate::{Context,ValuePropertyFlags}; #[cfg(feature = "v2_38")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] -use crate::TypedArrayType; -use crate::{Context, ValuePropertyFlags}; -use glib::{prelude::*, translate::*}; +use crate::{TypedArrayType}; +use glib::{prelude::*,translate::*}; glib::wrapper! { #[doc(alias = "JSCValue")] @@ -18,536 +18,465 @@ glib::wrapper! { } impl Value { - pub const NONE: Option<&'static Value> = None; - - #[doc(alias = "jsc_value_new_array_from_garray")] - pub fn new_array_from_garray(context: &impl IsA, array: &[Value]) -> Value { - unsafe { - from_glib_full(ffi::jsc_value_new_array_from_garray( - context.as_ref().to_glib_none().0, - array.to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_new_array_from_strv")] - pub fn new_array_from_strv(context: &impl IsA, strv: &[&str]) -> Value { - unsafe { - from_glib_full(ffi::jsc_value_new_array_from_strv( - context.as_ref().to_glib_none().0, - strv.to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_new_boolean")] - pub fn new_boolean(context: &impl IsA, value: bool) -> Value { - unsafe { - from_glib_full(ffi::jsc_value_new_boolean( - context.as_ref().to_glib_none().0, - value.into_glib(), - )) - } - } - - #[cfg(feature = "v2_28")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] - #[doc(alias = "jsc_value_new_from_json")] - #[doc(alias = "new_from_json")] - pub fn from_json(context: &impl IsA, json: &str) -> Value { - unsafe { - from_glib_full(ffi::jsc_value_new_from_json( - context.as_ref().to_glib_none().0, - json.to_glib_none().0, - )) - } - } - - //#[doc(alias = "jsc_value_new_function")] - //pub fn new_function(context: &impl IsA, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, 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(context: &impl IsA, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, 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(context: &impl IsA, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_parameters: u32) -> Value { - // unsafe { TODO: call ffi:jsc_value_new_functionv() } - //} - - #[doc(alias = "jsc_value_new_null")] - pub fn new_null(context: &impl IsA) -> Value { - unsafe { from_glib_full(ffi::jsc_value_new_null(context.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_value_new_number")] - pub fn new_number(context: &impl IsA, number: f64) -> Value { - unsafe { - from_glib_full(ffi::jsc_value_new_number( - context.as_ref().to_glib_none().0, - number, - )) - } - } - - //#[doc(alias = "jsc_value_new_object")] - //pub fn new_object(context: &impl IsA, instance: /*Unimplemented*/Option, jsc_class: Option<&Class>) -> Value { - // unsafe { TODO: call ffi:jsc_value_new_object() } - //} - - #[doc(alias = "jsc_value_new_string")] - pub fn new_string(context: &impl IsA, string: Option<&str>) -> Value { - unsafe { - from_glib_full(ffi::jsc_value_new_string( - context.as_ref().to_glib_none().0, - string.to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_new_string_from_bytes")] - pub fn new_string_from_bytes(context: &impl IsA, bytes: Option<&glib::Bytes>) -> Value { - unsafe { - from_glib_full(ffi::jsc_value_new_string_from_bytes( - context.as_ref().to_glib_none().0, - bytes.to_glib_none().0, - )) - } - } - - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_new_typed_array")] - pub fn new_typed_array( - context: &impl IsA, - type_: TypedArrayType, - length: usize, - ) -> Value { - unsafe { - from_glib_full(ffi::jsc_value_new_typed_array( - context.as_ref().to_glib_none().0, - type_.into_glib(), - length, - )) - } - } - - #[doc(alias = "jsc_value_new_undefined")] - pub fn new_undefined(context: &impl IsA) -> Value { - unsafe { - from_glib_full(ffi::jsc_value_new_undefined( - context.as_ref().to_glib_none().0, - )) - } - } - - // rustdoc-stripper-ignore-next - /// Creates a new builder-pattern struct instance to construct [`Value`] objects. - /// - /// This method returns an instance of [`ValueBuilder`](crate::builders::ValueBuilder) which can be used to create [`Value`] objects. - pub fn builder() -> ValueBuilder { - ValueBuilder::new() - } + pub const NONE: Option<&'static Value> = None; + + + #[doc(alias = "jsc_value_new_array_from_garray")] + pub fn new_array_from_garray(context: &impl IsA, array: &[Value]) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_array_from_garray(context.as_ref().to_glib_none().0, array.to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_new_array_from_strv")] + pub fn new_array_from_strv(context: &impl IsA, strv: &[&str]) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_array_from_strv(context.as_ref().to_glib_none().0, strv.to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_new_boolean")] + pub fn new_boolean(context: &impl IsA, value: bool) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_boolean(context.as_ref().to_glib_none().0, value.into_glib())) + } + } + + #[cfg(feature = "v2_28")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] + #[doc(alias = "jsc_value_new_from_json")] + #[doc(alias = "new_from_json")] + pub fn from_json(context: &impl IsA, json: &str) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_from_json(context.as_ref().to_glib_none().0, json.to_glib_none().0)) + } + } + + //#[doc(alias = "jsc_value_new_function")] + //pub fn new_function(context: &impl IsA, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, 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(context: &impl IsA, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, 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(context: &impl IsA, name: Option<&str>, callback: P, user_data: /*Unimplemented*/Option, return_type: glib::types::Type, n_parameters: u32) -> Value { + // unsafe { TODO: call ffi:jsc_value_new_functionv() } + //} + + #[doc(alias = "jsc_value_new_null")] + pub fn new_null(context: &impl IsA) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_null(context.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_new_number")] + pub fn new_number(context: &impl IsA, number: f64) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_number(context.as_ref().to_glib_none().0, number)) + } + } + + //#[doc(alias = "jsc_value_new_object")] + //pub fn new_object(context: &impl IsA, instance: /*Unimplemented*/Option, jsc_class: Option<&Class>) -> Value { + // unsafe { TODO: call ffi:jsc_value_new_object() } + //} + + #[doc(alias = "jsc_value_new_string")] + pub fn new_string(context: &impl IsA, string: Option<&str>) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_string(context.as_ref().to_glib_none().0, string.to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_new_string_from_bytes")] + pub fn new_string_from_bytes(context: &impl IsA, bytes: Option<&glib::Bytes>) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_string_from_bytes(context.as_ref().to_glib_none().0, bytes.to_glib_none().0)) + } + } + + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_new_typed_array")] + pub fn new_typed_array(context: &impl IsA, type_: TypedArrayType, length: usize) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_typed_array(context.as_ref().to_glib_none().0, type_.into_glib(), length)) + } + } + + #[doc(alias = "jsc_value_new_undefined")] + pub fn new_undefined(context: &impl IsA) -> Value { + unsafe { + from_glib_full(ffi::jsc_value_new_undefined(context.as_ref().to_glib_none().0)) + } + } + + // rustdoc-stripper-ignore-next + /// Creates a new builder-pattern struct instance to construct [`Value`] objects. + /// + /// This method returns an instance of [`ValueBuilder`](crate::builders::ValueBuilder) which can be used to create [`Value`] objects. + pub fn builder() -> ValueBuilder { + ValueBuilder::new() + } + } impl std::fmt::Display for Value { - #[inline] - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(&ValueExt::to_str(self)) - } + #[inline] + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(&ValueExt::to_str(self)) + } } // rustdoc-stripper-ignore-next -/// A [builder-pattern] type to construct [`Value`] objects. -/// -/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html + /// A [builder-pattern] type to construct [`Value`] objects. + /// + /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct ValueBuilder { - builder: glib::object::ObjectBuilder<'static, Value>, + builder: glib::object::ObjectBuilder<'static, Value>, + } + + impl ValueBuilder { + fn new() -> Self { + Self { builder: glib::object::Object::builder() } + } + + pub fn context(self, context: &impl IsA) -> Self { + Self { builder: self.builder.property("context", context.clone().upcast()), } + } + + // rustdoc-stripper-ignore-next + /// Build the [`Value`]. + #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] + pub fn build(self) -> Value { + self.builder.build() } +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} } -impl ValueBuilder { - fn new() -> Self { - Self { - builder: glib::object::Object::builder(), +pub trait ValueExt: IsA + sealed::Sealed + 'static { + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_array_buffer_get_size")] + fn array_buffer_get_size(&self) -> usize { + unsafe { + ffi::jsc_value_array_buffer_get_size(self.as_ref().to_glib_none().0) + } + } + + //#[doc(alias = "jsc_value_constructor_call")] +//#[must_use] + //fn constructor_call(&self, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { + // unsafe { TODO: call ffi:jsc_value_constructor_call() } + //} + + #[doc(alias = "jsc_value_constructor_callv")] +#[must_use] + fn constructor_callv(&self, parameters: &[Value]) -> Option { + let n_parameters = parameters.len() as _; + unsafe { + from_glib_full(ffi::jsc_value_constructor_callv(self.as_ref().to_glib_none().0, n_parameters, parameters.to_glib_none().0)) + } } - } - pub fn context(self, context: &impl IsA) -> Self { - Self { - builder: self.builder.property("context", context.clone().upcast()), + //#[doc(alias = "jsc_value_function_call")] +//#[must_use] + //fn function_call(&self, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { + // unsafe { TODO: call ffi:jsc_value_function_call() } + //} + + #[doc(alias = "jsc_value_function_callv")] +#[must_use] + fn function_callv(&self, parameters: &[Value]) -> Option { + let n_parameters = parameters.len() as _; + unsafe { + from_glib_full(ffi::jsc_value_function_callv(self.as_ref().to_glib_none().0, n_parameters, parameters.to_glib_none().0)) + } } - } - // rustdoc-stripper-ignore-next - /// Build the [`Value`]. - #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] - pub fn build(self) -> Value { - self.builder.build() - } -} + #[doc(alias = "jsc_value_get_context")] + #[doc(alias = "get_context")] + fn context(&self) -> Option { + unsafe { + from_glib_none(ffi::jsc_value_get_context(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_is_array")] + fn is_array(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_array(self.as_ref().to_glib_none().0)) + } + } + + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_is_array_buffer")] + fn is_array_buffer(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_array_buffer(self.as_ref().to_glib_none().0)) + } + } -mod sealed { - pub trait Sealed {} - impl> Sealed for T {} -} + #[doc(alias = "jsc_value_is_boolean")] + fn is_boolean(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_boolean(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_is_constructor")] + fn is_constructor(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_constructor(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_is_function")] + fn is_function(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_function(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_is_null")] + fn is_null(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_null(self.as_ref().to_glib_none().0)) + } + } -pub trait ValueExt: IsA + sealed::Sealed + 'static { - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_array_buffer_get_size")] - fn array_buffer_get_size(&self) -> usize { - unsafe { ffi::jsc_value_array_buffer_get_size(self.as_ref().to_glib_none().0) } - } - - //#[doc(alias = "jsc_value_constructor_call")] - //#[must_use] - //fn constructor_call(&self, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { - // unsafe { TODO: call ffi:jsc_value_constructor_call() } - //} - - #[doc(alias = "jsc_value_constructor_callv")] - #[must_use] - fn constructor_callv(&self, parameters: &[Value]) -> Option { - let n_parameters = parameters.len() as _; - unsafe { - from_glib_full(ffi::jsc_value_constructor_callv( - self.as_ref().to_glib_none().0, - n_parameters, - parameters.to_glib_none().0, - )) - } - } - - //#[doc(alias = "jsc_value_function_call")] - //#[must_use] - //fn function_call(&self, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { - // unsafe { TODO: call ffi:jsc_value_function_call() } - //} - - #[doc(alias = "jsc_value_function_callv")] - #[must_use] - fn function_callv(&self, parameters: &[Value]) -> Option { - let n_parameters = parameters.len() as _; - unsafe { - from_glib_full(ffi::jsc_value_function_callv( - self.as_ref().to_glib_none().0, - n_parameters, - parameters.to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_get_context")] - #[doc(alias = "get_context")] - fn context(&self) -> Option { - unsafe { from_glib_none(ffi::jsc_value_get_context(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_value_is_array")] - fn is_array(&self) -> bool { - unsafe { from_glib(ffi::jsc_value_is_array(self.as_ref().to_glib_none().0)) } - } - - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_is_array_buffer")] - fn is_array_buffer(&self) -> bool { - unsafe { - from_glib(ffi::jsc_value_is_array_buffer( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_is_boolean")] - fn is_boolean(&self) -> bool { - unsafe { from_glib(ffi::jsc_value_is_boolean(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_value_is_constructor")] - fn is_constructor(&self) -> bool { - unsafe { - from_glib(ffi::jsc_value_is_constructor( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_is_function")] - fn is_function(&self) -> bool { - unsafe { from_glib(ffi::jsc_value_is_function(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_value_is_null")] - fn is_null(&self) -> bool { - unsafe { from_glib(ffi::jsc_value_is_null(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_value_is_number")] - fn is_number(&self) -> bool { - unsafe { from_glib(ffi::jsc_value_is_number(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_value_is_object")] - fn is_object(&self) -> bool { - unsafe { from_glib(ffi::jsc_value_is_object(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_value_is_string")] - fn is_string(&self) -> bool { - unsafe { from_glib(ffi::jsc_value_is_string(self.as_ref().to_glib_none().0)) } - } - - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_is_typed_array")] - fn is_typed_array(&self) -> bool { - unsafe { - from_glib(ffi::jsc_value_is_typed_array( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_is_undefined")] - fn is_undefined(&self) -> bool { - unsafe { from_glib(ffi::jsc_value_is_undefined(self.as_ref().to_glib_none().0)) } - } - - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_new_typed_array_with_buffer")] - #[must_use] - fn new_typed_array_with_buffer( - &self, - type_: TypedArrayType, - offset: usize, - length: isize, - ) -> Option { - unsafe { - from_glib_full(ffi::jsc_value_new_typed_array_with_buffer( - self.as_ref().to_glib_none().0, - type_.into_glib(), - offset, - length, - )) - } - } - - //#[doc(alias = "jsc_value_object_define_property_accessor")] - //fn object_define_property_accessor(&self, property_name: &str, flags: ValuePropertyFlags, property_type: glib::types::Type, getter: Option>, setter: Option>, user_data: /*Unimplemented*/Option) { - // unsafe { TODO: call ffi:jsc_value_object_define_property_accessor() } - //} - - #[doc(alias = "jsc_value_object_define_property_data")] - fn object_define_property_data( - &self, - property_name: &str, - flags: ValuePropertyFlags, - property_value: Option<&impl IsA>, - ) { - unsafe { - ffi::jsc_value_object_define_property_data( - self.as_ref().to_glib_none().0, - property_name.to_glib_none().0, - flags.into_glib(), - property_value.map(|p| p.as_ref()).to_glib_none().0, - ); - } - } - - #[doc(alias = "jsc_value_object_delete_property")] - fn object_delete_property(&self, name: &str) -> bool { - unsafe { - from_glib(ffi::jsc_value_object_delete_property( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_object_enumerate_properties")] - fn object_enumerate_properties(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_full(ffi::jsc_value_object_enumerate_properties( - self.as_ref().to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_object_get_property")] - #[must_use] - fn object_get_property(&self, name: &str) -> Option { - unsafe { - from_glib_full(ffi::jsc_value_object_get_property( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_object_get_property_at_index")] - #[must_use] - fn object_get_property_at_index(&self, index: u32) -> Option { - unsafe { - from_glib_full(ffi::jsc_value_object_get_property_at_index( - self.as_ref().to_glib_none().0, - index, - )) - } - } - - #[doc(alias = "jsc_value_object_has_property")] - fn object_has_property(&self, name: &str) -> bool { - unsafe { - from_glib(ffi::jsc_value_object_has_property( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - )) - } - } - - //#[doc(alias = "jsc_value_object_invoke_method")] - //#[must_use] - //fn object_invoke_method(&self, name: &str, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { - // unsafe { TODO: call ffi:jsc_value_object_invoke_method() } - //} - - #[doc(alias = "jsc_value_object_invoke_methodv")] - #[must_use] - fn object_invoke_methodv(&self, name: &str, parameters: &[Value]) -> Option { - let n_parameters = parameters.len() as _; - unsafe { - from_glib_full(ffi::jsc_value_object_invoke_methodv( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - n_parameters, - parameters.to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_object_is_instance_of")] - fn object_is_instance_of(&self, name: &str) -> bool { - unsafe { - from_glib(ffi::jsc_value_object_is_instance_of( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - )) - } - } - - #[doc(alias = "jsc_value_object_set_property")] - fn object_set_property(&self, name: &str, property: &impl IsA) { - unsafe { - ffi::jsc_value_object_set_property( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - property.as_ref().to_glib_none().0, - ); - } - } - - #[doc(alias = "jsc_value_object_set_property_at_index")] - fn object_set_property_at_index(&self, index: u32, property: &impl IsA) { - unsafe { - ffi::jsc_value_object_set_property_at_index( - self.as_ref().to_glib_none().0, - index, - property.as_ref().to_glib_none().0, - ); - } - } - - #[doc(alias = "jsc_value_to_boolean")] - fn to_boolean(&self) -> bool { - unsafe { from_glib(ffi::jsc_value_to_boolean(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_value_to_double")] - fn to_double(&self) -> f64 { - unsafe { ffi::jsc_value_to_double(self.as_ref().to_glib_none().0) } - } - - #[doc(alias = "jsc_value_to_int32")] - fn to_int32(&self) -> i32 { - unsafe { ffi::jsc_value_to_int32(self.as_ref().to_glib_none().0) } - } - - #[cfg(feature = "v2_28")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] - #[doc(alias = "jsc_value_to_json")] - fn to_json(&self, indent: u32) -> Option { - unsafe { - from_glib_full(ffi::jsc_value_to_json( - self.as_ref().to_glib_none().0, - indent, - )) - } - } - - #[doc(alias = "jsc_value_to_string")] - #[doc(alias = "to_string")] - fn to_str(&self) -> glib::GString { - unsafe { from_glib_full(ffi::jsc_value_to_string(self.as_ref().to_glib_none().0)) } - } - - #[doc(alias = "jsc_value_to_string_as_bytes")] - fn to_string_as_bytes(&self) -> Option { - unsafe { - from_glib_full(ffi::jsc_value_to_string_as_bytes( - self.as_ref().to_glib_none().0, - )) - } - } - - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_typed_array_get_buffer")] - #[must_use] - fn typed_array_get_buffer(&self) -> Option { - unsafe { - from_glib_full(ffi::jsc_value_typed_array_get_buffer( - self.as_ref().to_glib_none().0, - )) - } - } - - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_typed_array_get_length")] - fn typed_array_get_length(&self) -> usize { - unsafe { ffi::jsc_value_typed_array_get_length(self.as_ref().to_glib_none().0) } - } - - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_typed_array_get_offset")] - fn typed_array_get_offset(&self) -> usize { - unsafe { ffi::jsc_value_typed_array_get_offset(self.as_ref().to_glib_none().0) } - } - - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_typed_array_get_size")] - fn typed_array_get_size(&self) -> usize { - unsafe { ffi::jsc_value_typed_array_get_size(self.as_ref().to_glib_none().0) } - } - - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - #[doc(alias = "jsc_value_typed_array_get_type")] - fn typed_array_get_type(&self) -> TypedArrayType { - unsafe { - from_glib(ffi::jsc_value_typed_array_get_type( - self.as_ref().to_glib_none().0, - )) - } - } + #[doc(alias = "jsc_value_is_number")] + fn is_number(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_number(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_is_object")] + fn is_object(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_object(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_is_string")] + fn is_string(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_string(self.as_ref().to_glib_none().0)) + } + } + + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_is_typed_array")] + fn is_typed_array(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_typed_array(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_is_undefined")] + fn is_undefined(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_is_undefined(self.as_ref().to_glib_none().0)) + } + } + + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_new_typed_array_with_buffer")] +#[must_use] + fn new_typed_array_with_buffer(&self, type_: TypedArrayType, offset: usize, length: isize) -> Option { + unsafe { + from_glib_full(ffi::jsc_value_new_typed_array_with_buffer(self.as_ref().to_glib_none().0, type_.into_glib(), offset, length)) + } + } + + //#[doc(alias = "jsc_value_object_define_property_accessor")] + //fn object_define_property_accessor(&self, property_name: &str, flags: ValuePropertyFlags, property_type: glib::types::Type, getter: Option>, setter: Option>, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ffi:jsc_value_object_define_property_accessor() } + //} + + #[doc(alias = "jsc_value_object_define_property_data")] + fn object_define_property_data(&self, property_name: &str, flags: ValuePropertyFlags, property_value: Option<&impl IsA>) { + unsafe { + ffi::jsc_value_object_define_property_data(self.as_ref().to_glib_none().0, property_name.to_glib_none().0, flags.into_glib(), property_value.map(|p| p.as_ref()).to_glib_none().0); + } + } + + #[doc(alias = "jsc_value_object_delete_property")] + fn object_delete_property(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::jsc_value_object_delete_property(self.as_ref().to_glib_none().0, name.to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_object_enumerate_properties")] + fn object_enumerate_properties(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_full(ffi::jsc_value_object_enumerate_properties(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_object_get_property")] +#[must_use] + fn object_get_property(&self, name: &str) -> Option { + unsafe { + from_glib_full(ffi::jsc_value_object_get_property(self.as_ref().to_glib_none().0, name.to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_object_get_property_at_index")] +#[must_use] + fn object_get_property_at_index(&self, index: u32) -> Option { + unsafe { + from_glib_full(ffi::jsc_value_object_get_property_at_index(self.as_ref().to_glib_none().0, index)) + } + } + + #[doc(alias = "jsc_value_object_has_property")] + fn object_has_property(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::jsc_value_object_has_property(self.as_ref().to_glib_none().0, name.to_glib_none().0)) + } + } + + //#[doc(alias = "jsc_value_object_invoke_method")] +//#[must_use] + //fn object_invoke_method(&self, name: &str, first_parameter_type: glib::types::Type, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { + // unsafe { TODO: call ffi:jsc_value_object_invoke_method() } + //} + + #[doc(alias = "jsc_value_object_invoke_methodv")] +#[must_use] + fn object_invoke_methodv(&self, name: &str, parameters: &[Value]) -> Option { + let n_parameters = parameters.len() as _; + unsafe { + from_glib_full(ffi::jsc_value_object_invoke_methodv(self.as_ref().to_glib_none().0, name.to_glib_none().0, n_parameters, parameters.to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_object_is_instance_of")] + fn object_is_instance_of(&self, name: &str) -> bool { + unsafe { + from_glib(ffi::jsc_value_object_is_instance_of(self.as_ref().to_glib_none().0, name.to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_object_set_property")] + fn object_set_property(&self, name: &str, property: &impl IsA) { + unsafe { + ffi::jsc_value_object_set_property(self.as_ref().to_glib_none().0, name.to_glib_none().0, property.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "jsc_value_object_set_property_at_index")] + fn object_set_property_at_index(&self, index: u32, property: &impl IsA) { + unsafe { + ffi::jsc_value_object_set_property_at_index(self.as_ref().to_glib_none().0, index, property.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "jsc_value_to_boolean")] + fn to_boolean(&self) -> bool { + unsafe { + from_glib(ffi::jsc_value_to_boolean(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_to_double")] + fn to_double(&self) -> f64 { + unsafe { + ffi::jsc_value_to_double(self.as_ref().to_glib_none().0) + } + } + + #[doc(alias = "jsc_value_to_int32")] + fn to_int32(&self) -> i32 { + unsafe { + ffi::jsc_value_to_int32(self.as_ref().to_glib_none().0) + } + } + + #[cfg(feature = "v2_28")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] + #[doc(alias = "jsc_value_to_json")] + fn to_json(&self, indent: u32) -> Option { + unsafe { + from_glib_full(ffi::jsc_value_to_json(self.as_ref().to_glib_none().0, indent)) + } + } + + #[doc(alias = "jsc_value_to_string")] + #[doc(alias = "to_string")] + fn to_str(&self) -> glib::GString { + unsafe { + from_glib_full(ffi::jsc_value_to_string(self.as_ref().to_glib_none().0)) + } + } + + #[doc(alias = "jsc_value_to_string_as_bytes")] + fn to_string_as_bytes(&self) -> Option { + unsafe { + from_glib_full(ffi::jsc_value_to_string_as_bytes(self.as_ref().to_glib_none().0)) + } + } + + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_typed_array_get_buffer")] +#[must_use] + fn typed_array_get_buffer(&self) -> Option { + unsafe { + from_glib_full(ffi::jsc_value_typed_array_get_buffer(self.as_ref().to_glib_none().0)) + } + } + + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_typed_array_get_length")] + fn typed_array_get_length(&self) -> usize { + unsafe { + ffi::jsc_value_typed_array_get_length(self.as_ref().to_glib_none().0) + } + } + + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_typed_array_get_offset")] + fn typed_array_get_offset(&self) -> usize { + unsafe { + ffi::jsc_value_typed_array_get_offset(self.as_ref().to_glib_none().0) + } + } + + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_typed_array_get_size")] + fn typed_array_get_size(&self) -> usize { + unsafe { + ffi::jsc_value_typed_array_get_size(self.as_ref().to_glib_none().0) + } + } + + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + #[doc(alias = "jsc_value_typed_array_get_type")] + fn typed_array_get_type(&self) -> TypedArrayType { + unsafe { + from_glib(ffi::jsc_value_typed_array_get_type(self.as_ref().to_glib_none().0)) + } + } } impl> ValueExt for O {} diff --git a/src/auto/virtual_machine.rs b/src/auto/virtual_machine.rs index ed2a303..a3c72c0 100644 --- a/src/auto/virtual_machine.rs +++ b/src/auto/virtual_machine.rs @@ -2,7 +2,7 @@ // from gir-files (https://github.com/tauri-apps/gir-files) // DO NOT EDIT -use glib::translate::*; +use glib::{translate::*}; glib::wrapper! { #[doc(alias = "JSCVirtualMachine")] @@ -14,16 +14,19 @@ glib::wrapper! { } impl VirtualMachine { - pub const NONE: Option<&'static VirtualMachine> = None; + pub const NONE: Option<&'static VirtualMachine> = None; + - #[doc(alias = "jsc_virtual_machine_new")] - pub fn new() -> VirtualMachine { - unsafe { from_glib_full(ffi::jsc_virtual_machine_new()) } - } + #[doc(alias = "jsc_virtual_machine_new")] + pub fn new() -> VirtualMachine { + unsafe { + from_glib_full(ffi::jsc_virtual_machine_new()) + } + } } impl Default for VirtualMachine { - fn default() -> Self { - Self::new() - } -} + fn default() -> Self { + Self::new() + } + } diff --git a/src/auto/weak_value.rs b/src/auto/weak_value.rs index 52d7fc1..91f67ad 100644 --- a/src/auto/weak_value.rs +++ b/src/auto/weak_value.rs @@ -2,13 +2,9 @@ // from gir-files (https://github.com/tauri-apps/gir-files) // DO NOT EDIT -use crate::Value; -use glib::{ - prelude::*, - signal::{connect_raw, SignalHandlerId}, - translate::*, -}; -use std::boxed::Box as Box_; +use crate::{Value}; +use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*}; +use std::{boxed::Box as Box_}; glib::wrapper! { #[doc(alias = "JSCWeakValue")] @@ -20,95 +16,83 @@ glib::wrapper! { } impl WeakValue { - pub const NONE: Option<&'static WeakValue> = None; + pub const NONE: Option<&'static WeakValue> = None; + - #[doc(alias = "jsc_weak_value_new")] - pub fn new(value: &impl IsA) -> WeakValue { - unsafe { from_glib_full(ffi::jsc_weak_value_new(value.as_ref().to_glib_none().0)) } - } + #[doc(alias = "jsc_weak_value_new")] + pub fn new(value: &impl IsA) -> WeakValue { + unsafe { + from_glib_full(ffi::jsc_weak_value_new(value.as_ref().to_glib_none().0)) + } + } - // rustdoc-stripper-ignore-next - /// Creates a new builder-pattern struct instance to construct [`WeakValue`] objects. - /// - /// This method returns an instance of [`WeakValueBuilder`](crate::builders::WeakValueBuilder) which can be used to create [`WeakValue`] objects. - pub fn builder() -> WeakValueBuilder { - WeakValueBuilder::new() - } + // rustdoc-stripper-ignore-next + /// Creates a new builder-pattern struct instance to construct [`WeakValue`] objects. + /// + /// This method returns an instance of [`WeakValueBuilder`](crate::builders::WeakValueBuilder) which can be used to create [`WeakValue`] objects. + pub fn builder() -> WeakValueBuilder { + WeakValueBuilder::new() + } + } impl Default for WeakValue { - fn default() -> Self { - glib::object::Object::new::() - } -} + fn default() -> Self { + glib::object::Object::new::() + } + } // rustdoc-stripper-ignore-next -/// A [builder-pattern] type to construct [`WeakValue`] objects. -/// -/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html + /// A [builder-pattern] type to construct [`WeakValue`] objects. + /// + /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct WeakValueBuilder { - builder: glib::object::ObjectBuilder<'static, WeakValue>, -} + builder: glib::object::ObjectBuilder<'static, WeakValue>, + } -impl WeakValueBuilder { - fn new() -> Self { - Self { - builder: glib::object::Object::builder(), - } - } + impl WeakValueBuilder { + fn new() -> Self { + Self { builder: glib::object::Object::builder() } + } - pub fn value(self, value: &impl IsA) -> Self { - Self { - builder: self.builder.property("value", value.clone().upcast()), - } - } + pub fn value(self, value: &impl IsA) -> Self { + Self { builder: self.builder.property("value", value.clone().upcast()), } + } - // rustdoc-stripper-ignore-next - /// Build the [`WeakValue`]. - #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] - pub fn build(self) -> WeakValue { - self.builder.build() - } + // rustdoc-stripper-ignore-next + /// Build the [`WeakValue`]. + #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] + pub fn build(self) -> WeakValue { + self.builder.build() } } mod sealed { - pub trait Sealed {} - impl> Sealed for T {} + pub trait Sealed {} + impl> Sealed for T {} } pub trait WeakValueExt: IsA + sealed::Sealed + 'static { - #[doc(alias = "jsc_weak_value_get_value")] - #[doc(alias = "get_value")] - fn value(&self) -> Option { - unsafe { - from_glib_full(ffi::jsc_weak_value_get_value( - self.as_ref().to_glib_none().0, - )) + #[doc(alias = "jsc_weak_value_get_value")] + #[doc(alias = "get_value")] + fn value(&self) -> Option { + unsafe { + from_glib_full(ffi::jsc_weak_value_get_value(self.as_ref().to_glib_none().0)) + } } - } - #[doc(alias = "cleared")] - fn connect_cleared(&self, f: F) -> SignalHandlerId { - unsafe extern "C" fn cleared_trampoline, F: Fn(&P) + 'static>( - this: *mut ffi::JSCWeakValue, - f: glib::ffi::gpointer, - ) { - let f: &F = &*(f as *const F); - f(WeakValue::from_glib_borrow(this).unsafe_cast_ref()) - } - unsafe { - let f: Box_ = Box_::new(f); - connect_raw( - self.as_ptr() as *mut _, - b"cleared\0".as_ptr() as *const _, - Some(std::mem::transmute::<_, unsafe extern "C" fn()>( - cleared_trampoline:: as *const (), - )), - Box_::into_raw(f), - ) + #[doc(alias = "cleared")] + fn connect_cleared(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn cleared_trampoline, F: Fn(&P) + 'static>(this: *mut ffi::JSCWeakValue, f: glib::ffi::gpointer) { + let f: &F = &*(f as *const F); + f(WeakValue::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw(self.as_ptr() as *mut _, b"cleared\0".as_ptr() as *const _, + Some(std::mem::transmute::<_, unsafe extern "C" fn()>(cleared_trampoline:: as *const ())), Box_::into_raw(f)) + } } - } } impl> WeakValueExt for O {} diff --git a/sys/Cargo.toml b/sys/Cargo.toml index 96e0bfe..777c3ac 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -1,9 +1,9 @@ [package] -authors = [ "The Gtk-rs Project Developers" ] +authors = ["The Gtk-rs Project Developers"] build = "build.rs" description = "Sys functions for the Rust bindings of the javacriptcore library" edition = "2021" -keywords = [ "javascript", "gtk-rs", "gnome" ] +keywords = ["javascript", "gtk-rs", "gnome"] license = "MIT" name = "javascriptcore-rs-sys" repository = "https://github.com/tauri-apps/javascriptcore-rs" @@ -13,16 +13,16 @@ version = "1.1.0" name = "javascriptcoregtk-4.1" version = "2.24" - [package.metadata.system-deps.javascriptcoregtk_4_1.v2_28] - version = "2.28" +[package.metadata.system-deps.javascriptcoregtk_4_1.v2_28] +version = "2.28" - [package.metadata.system-deps.javascriptcoregtk_4_1.v2_38] - version = "2.38" +[package.metadata.system-deps.javascriptcoregtk_4_1.v2_38] +version = "2.38" [package.metadata.docs.rs] -features = [ "dox" ] -rustc-args = [ "--cfg", "docsrs" ] -rustdoc-args = [ "--cfg", "docsrs", "--generate-link-to-definition" ] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +all-features = true [lib] name = "javascriptcore_rs_sys" @@ -30,13 +30,13 @@ name = "javascriptcore_rs_sys" [dependencies] libc = "0.2" - [dependencies.glib] - package = "glib-sys" - version = "^0.18" +[dependencies.glib] +package = "glib-sys" +version = "^0.18" - [dependencies.gobject] - package = "gobject-sys" - version = "^0.18" +[dependencies.gobject] +package = "gobject-sys" +version = "^0.18" [build-dependencies] system-deps = "6" @@ -46,6 +46,5 @@ shell-words = "1.0.0" tempfile = "3" [features] -dox = [ ] -v2_28 = [ ] -v2_38 = [ "v2_28" ] +v2_28 = [] +v2_38 = ["v2_28"] diff --git a/sys/build.rs b/sys/build.rs index 7b45915..9d3c5d6 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -10,8 +10,8 @@ fn main() {} // prevent linking libraries to avoid documentation failure #[cfg(not(docsrs))] fn main() { - if let Err(s) = system_deps::Config::new().probe() { - println!("cargo:warning={s}"); - process::exit(1); - } + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + process::exit(1); + } } diff --git a/sys/src/lib.rs b/sys/src/lib.rs index b889e38..e639fb1 100644 --- a/sys/src/lib.rs +++ b/sys/src/lib.rs @@ -3,19 +3,14 @@ // DO NOT EDIT #![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] -#![allow( - clippy::approx_constant, - clippy::type_complexity, - clippy::unreadable_literal, - clippy::upper_case_acronyms -)] +#![allow(clippy::approx_constant, clippy::type_complexity, clippy::unreadable_literal, clippy::upper_case_acronyms)] #![cfg_attr(docsrs, feature(doc_cfg))] + #[allow(unused_imports)] -use libc::{ - c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, - intptr_t, size_t, ssize_t, uintptr_t, FILE, -}; +use libc::{c_int, c_char, c_uchar, c_float, c_uint, c_double, + c_short, c_ushort, c_long, c_ulong, + c_void, size_t, ssize_t, intptr_t, uintptr_t, FILE}; #[allow(unused_imports)] use glib::{gboolean, gconstpointer, gpointer, GType}; @@ -72,34 +67,19 @@ pub const JSC_VALUE_PROPERTY_ENUMERABLE: JSCValuePropertyFlags = 2; pub const JSC_VALUE_PROPERTY_WRITABLE: JSCValuePropertyFlags = 4; // Callbacks -pub type JSCClassDeletePropertyFunction = - Option gboolean>; -pub type JSCClassEnumeratePropertiesFunction = - Option *mut *mut c_char>; -pub type JSCClassGetPropertyFunction = Option< - unsafe extern "C" fn(*mut JSCClass, *mut JSCContext, gpointer, *const c_char) -> *mut JSCValue, ->; -pub type JSCClassHasPropertyFunction = - Option gboolean>; -pub type JSCClassSetPropertyFunction = Option< - unsafe extern "C" fn( - *mut JSCClass, - *mut JSCContext, - gpointer, - *const c_char, - *mut JSCValue, - ) -> gboolean, ->; -pub type JSCExceptionHandler = - Option; -pub type JSCOptionsFunc = - Option gboolean>; +pub type JSCClassDeletePropertyFunction = Option gboolean>; +pub type JSCClassEnumeratePropertiesFunction = Option *mut *mut c_char>; +pub type JSCClassGetPropertyFunction = Option *mut JSCValue>; +pub type JSCClassHasPropertyFunction = Option gboolean>; +pub type JSCClassSetPropertyFunction = Option gboolean>; +pub type JSCExceptionHandler = Option; +pub type JSCOptionsFunc = Option gboolean>; // Records #[repr(C)] pub struct _JSCClassClass { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, } pub type JSCClassClass = *mut _JSCClassClass; @@ -107,59 +87,59 @@ pub type JSCClassClass = *mut _JSCClassClass; #[derive(Copy, Clone)] #[repr(C)] pub struct JSCClassVTable { - pub get_property: JSCClassGetPropertyFunction, - pub set_property: JSCClassSetPropertyFunction, - pub has_property: JSCClassHasPropertyFunction, - pub delete_property: JSCClassDeletePropertyFunction, - pub enumerate_properties: JSCClassEnumeratePropertiesFunction, - pub _jsc_reserved0: Option, - pub _jsc_reserved1: Option, - pub _jsc_reserved2: Option, - pub _jsc_reserved3: Option, + pub get_property: JSCClassGetPropertyFunction, + pub set_property: JSCClassSetPropertyFunction, + pub has_property: JSCClassHasPropertyFunction, + pub delete_property: JSCClassDeletePropertyFunction, + pub enumerate_properties: JSCClassEnumeratePropertiesFunction, + pub _jsc_reserved0: Option, + pub _jsc_reserved1: Option, + pub _jsc_reserved2: Option, + pub _jsc_reserved3: Option, } impl ::std::fmt::Debug for JSCClassVTable { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCClassVTable @ {self:p}")) - .field("get_property", &self.get_property) - .field("set_property", &self.set_property) - .field("has_property", &self.has_property) - .field("delete_property", &self.delete_property) - .field("enumerate_properties", &self.enumerate_properties) - .field("_jsc_reserved0", &self._jsc_reserved0) - .field("_jsc_reserved1", &self._jsc_reserved1) - .field("_jsc_reserved2", &self._jsc_reserved2) - .field("_jsc_reserved3", &self._jsc_reserved3) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCClassVTable @ {self:p}")) + .field("get_property", &self.get_property) + .field("set_property", &self.set_property) + .field("has_property", &self.has_property) + .field("delete_property", &self.delete_property) + .field("enumerate_properties", &self.enumerate_properties) + .field("_jsc_reserved0", &self._jsc_reserved0) + .field("_jsc_reserved1", &self._jsc_reserved1) + .field("_jsc_reserved2", &self._jsc_reserved2) + .field("_jsc_reserved3", &self._jsc_reserved3) + .finish() + } } #[derive(Copy, Clone)] #[repr(C)] pub struct JSCContextClass { - pub parent_class: gobject::GObjectClass, - pub _jsc_reserved0: Option, - pub _jsc_reserved1: Option, - pub _jsc_reserved2: Option, - pub _jsc_reserved3: Option, + pub parent_class: gobject::GObjectClass, + pub _jsc_reserved0: Option, + pub _jsc_reserved1: Option, + pub _jsc_reserved2: Option, + pub _jsc_reserved3: Option, } impl ::std::fmt::Debug for JSCContextClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCContextClass @ {self:p}")) - .field("parent_class", &self.parent_class) - .field("_jsc_reserved0", &self._jsc_reserved0) - .field("_jsc_reserved1", &self._jsc_reserved1) - .field("_jsc_reserved2", &self._jsc_reserved2) - .field("_jsc_reserved3", &self._jsc_reserved3) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCContextClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_jsc_reserved0", &self._jsc_reserved0) + .field("_jsc_reserved1", &self._jsc_reserved1) + .field("_jsc_reserved2", &self._jsc_reserved2) + .field("_jsc_reserved3", &self._jsc_reserved3) + .finish() + } } #[repr(C)] pub struct _JSCContextPrivate { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, } pub type JSCContextPrivate = *mut _JSCContextPrivate; @@ -167,29 +147,29 @@ pub type JSCContextPrivate = *mut _JSCContextPrivate; #[derive(Copy, Clone)] #[repr(C)] pub struct JSCExceptionClass { - pub parent_class: gobject::GObjectClass, - pub _jsc_reserved0: Option, - pub _jsc_reserved1: Option, - pub _jsc_reserved2: Option, - pub _jsc_reserved3: Option, + pub parent_class: gobject::GObjectClass, + pub _jsc_reserved0: Option, + pub _jsc_reserved1: Option, + pub _jsc_reserved2: Option, + pub _jsc_reserved3: Option, } impl ::std::fmt::Debug for JSCExceptionClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCExceptionClass @ {self:p}")) - .field("parent_class", &self.parent_class) - .field("_jsc_reserved0", &self._jsc_reserved0) - .field("_jsc_reserved1", &self._jsc_reserved1) - .field("_jsc_reserved2", &self._jsc_reserved2) - .field("_jsc_reserved3", &self._jsc_reserved3) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCExceptionClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_jsc_reserved0", &self._jsc_reserved0) + .field("_jsc_reserved1", &self._jsc_reserved1) + .field("_jsc_reserved2", &self._jsc_reserved2) + .field("_jsc_reserved3", &self._jsc_reserved3) + .finish() + } } #[repr(C)] pub struct _JSCExceptionPrivate { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, } pub type JSCExceptionPrivate = *mut _JSCExceptionPrivate; @@ -197,29 +177,29 @@ pub type JSCExceptionPrivate = *mut _JSCExceptionPrivate; #[derive(Copy, Clone)] #[repr(C)] pub struct JSCValueClass { - pub parent_class: gobject::GObjectClass, - pub _jsc_reserved0: Option, - pub _jsc_reserved1: Option, - pub _jsc_reserved2: Option, - pub _jsc_reserved3: Option, + pub parent_class: gobject::GObjectClass, + pub _jsc_reserved0: Option, + pub _jsc_reserved1: Option, + pub _jsc_reserved2: Option, + pub _jsc_reserved3: Option, } impl ::std::fmt::Debug for JSCValueClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCValueClass @ {self:p}")) - .field("parent_class", &self.parent_class) - .field("_jsc_reserved0", &self._jsc_reserved0) - .field("_jsc_reserved1", &self._jsc_reserved1) - .field("_jsc_reserved2", &self._jsc_reserved2) - .field("_jsc_reserved3", &self._jsc_reserved3) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCValueClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_jsc_reserved0", &self._jsc_reserved0) + .field("_jsc_reserved1", &self._jsc_reserved1) + .field("_jsc_reserved2", &self._jsc_reserved2) + .field("_jsc_reserved3", &self._jsc_reserved3) + .finish() + } } #[repr(C)] pub struct _JSCValuePrivate { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, } pub type JSCValuePrivate = *mut _JSCValuePrivate; @@ -227,29 +207,29 @@ pub type JSCValuePrivate = *mut _JSCValuePrivate; #[derive(Copy, Clone)] #[repr(C)] pub struct JSCVirtualMachineClass { - pub parent_class: gobject::GObjectClass, - pub _jsc_reserved0: Option, - pub _jsc_reserved1: Option, - pub _jsc_reserved2: Option, - pub _jsc_reserved3: Option, + pub parent_class: gobject::GObjectClass, + pub _jsc_reserved0: Option, + pub _jsc_reserved1: Option, + pub _jsc_reserved2: Option, + pub _jsc_reserved3: Option, } impl ::std::fmt::Debug for JSCVirtualMachineClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCVirtualMachineClass @ {self:p}")) - .field("parent_class", &self.parent_class) - .field("_jsc_reserved0", &self._jsc_reserved0) - .field("_jsc_reserved1", &self._jsc_reserved1) - .field("_jsc_reserved2", &self._jsc_reserved2) - .field("_jsc_reserved3", &self._jsc_reserved3) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCVirtualMachineClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_jsc_reserved0", &self._jsc_reserved0) + .field("_jsc_reserved1", &self._jsc_reserved1) + .field("_jsc_reserved2", &self._jsc_reserved2) + .field("_jsc_reserved3", &self._jsc_reserved3) + .finish() + } } #[repr(C)] pub struct _JSCVirtualMachinePrivate { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, } pub type JSCVirtualMachinePrivate = *mut _JSCVirtualMachinePrivate; @@ -257,29 +237,29 @@ pub type JSCVirtualMachinePrivate = *mut _JSCVirtualMachinePrivate; #[derive(Copy, Clone)] #[repr(C)] pub struct JSCWeakValueClass { - pub parent_class: gobject::GObjectClass, - pub _jsc_reserved0: Option, - pub _jsc_reserved1: Option, - pub _jsc_reserved2: Option, - pub _jsc_reserved3: Option, + pub parent_class: gobject::GObjectClass, + pub _jsc_reserved0: Option, + pub _jsc_reserved1: Option, + pub _jsc_reserved2: Option, + pub _jsc_reserved3: Option, } impl ::std::fmt::Debug for JSCWeakValueClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCWeakValueClass @ {self:p}")) - .field("parent_class", &self.parent_class) - .field("_jsc_reserved0", &self._jsc_reserved0) - .field("_jsc_reserved1", &self._jsc_reserved1) - .field("_jsc_reserved2", &self._jsc_reserved2) - .field("_jsc_reserved3", &self._jsc_reserved3) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCWeakValueClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .field("_jsc_reserved0", &self._jsc_reserved0) + .field("_jsc_reserved1", &self._jsc_reserved1) + .field("_jsc_reserved2", &self._jsc_reserved2) + .field("_jsc_reserved3", &self._jsc_reserved3) + .finish() + } } #[repr(C)] pub struct _JSCWeakValuePrivate { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, } pub type JSCWeakValuePrivate = *mut _JSCWeakValuePrivate; @@ -287,507 +267,282 @@ pub type JSCWeakValuePrivate = *mut _JSCWeakValuePrivate; // Classes #[repr(C)] pub struct JSCClass { - _data: [u8; 0], - _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, } impl ::std::fmt::Debug for JSCClass { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCClass @ {self:p}")).finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCClass @ {self:p}")) + .finish() + } } #[derive(Copy, Clone)] #[repr(C)] pub struct JSCContext { - pub parent: gobject::GObject, - pub priv_: *mut JSCContextPrivate, + pub parent: gobject::GObject, + pub priv_: *mut JSCContextPrivate, } impl ::std::fmt::Debug for JSCContext { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCContext @ {self:p}")) - .field("parent", &self.parent) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCContext @ {self:p}")) + .field("parent", &self.parent) + .finish() + } } #[derive(Copy, Clone)] #[repr(C)] pub struct JSCException { - pub parent: gobject::GObject, - pub priv_: *mut JSCExceptionPrivate, + pub parent: gobject::GObject, + pub priv_: *mut JSCExceptionPrivate, } impl ::std::fmt::Debug for JSCException { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCException @ {self:p}")) - .field("parent", &self.parent) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCException @ {self:p}")) + .field("parent", &self.parent) + .finish() + } } #[derive(Copy, Clone)] #[repr(C)] pub struct JSCValue { - pub parent: gobject::GObject, - pub priv_: *mut JSCValuePrivate, + pub parent: gobject::GObject, + pub priv_: *mut JSCValuePrivate, } impl ::std::fmt::Debug for JSCValue { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCValue @ {self:p}")) - .field("parent", &self.parent) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCValue @ {self:p}")) + .field("parent", &self.parent) + .finish() + } } #[derive(Copy, Clone)] #[repr(C)] pub struct JSCVirtualMachine { - pub parent: gobject::GObject, - pub priv_: *mut JSCVirtualMachinePrivate, + pub parent: gobject::GObject, + pub priv_: *mut JSCVirtualMachinePrivate, } impl ::std::fmt::Debug for JSCVirtualMachine { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCVirtualMachine @ {self:p}")) - .field("parent", &self.parent) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCVirtualMachine @ {self:p}")) + .field("parent", &self.parent) + .finish() + } } #[derive(Copy, Clone)] #[repr(C)] pub struct JSCWeakValue { - pub parent: gobject::GObject, - pub priv_: *mut JSCWeakValuePrivate, + pub parent: gobject::GObject, + pub priv_: *mut JSCWeakValuePrivate, } impl ::std::fmt::Debug for JSCWeakValue { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("JSCWeakValue @ {self:p}")) - .field("parent", &self.parent) - .finish() - } + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("JSCWeakValue @ {self:p}")) + .field("parent", &self.parent) + .finish() + } } #[link(name = "javascriptcoregtk-4.1")] extern "C" { - //========================================================================= - // JSCClass - //========================================================================= - pub fn jsc_class_get_type() -> GType; - pub fn jsc_class_add_constructor( - jsc_class: *mut JSCClass, - name: *const c_char, - callback: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - return_type: GType, - n_params: c_uint, - ... - ) -> *mut JSCValue; - pub fn jsc_class_add_constructor_variadic( - jsc_class: *mut JSCClass, - name: *const c_char, - callback: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - return_type: GType, - ) -> *mut JSCValue; - pub fn jsc_class_add_constructorv( - jsc_class: *mut JSCClass, - name: *const c_char, - callback: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - return_type: GType, - n_parameters: c_uint, - parameter_types: *mut GType, - ) -> *mut JSCValue; - pub fn jsc_class_add_method( - jsc_class: *mut JSCClass, - name: *const c_char, - callback: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - return_type: GType, - n_params: c_uint, - ... - ); - pub fn jsc_class_add_method_variadic( - jsc_class: *mut JSCClass, - name: *const c_char, - callback: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - return_type: GType, - ); - pub fn jsc_class_add_methodv( - jsc_class: *mut JSCClass, - name: *const c_char, - callback: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - return_type: GType, - n_parameters: c_uint, - parameter_types: *mut GType, - ); - pub fn jsc_class_add_property( - jsc_class: *mut JSCClass, - name: *const c_char, - property_type: GType, - getter: gobject::GCallback, - setter: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - ); - pub fn jsc_class_get_name(jsc_class: *mut JSCClass) -> *const c_char; - pub fn jsc_class_get_parent(jsc_class: *mut JSCClass) -> *mut JSCClass; - - //========================================================================= - // JSCContext - //========================================================================= - pub fn jsc_context_get_type() -> GType; - pub fn jsc_context_new() -> *mut JSCContext; - pub fn jsc_context_new_with_virtual_machine(vm: *mut JSCVirtualMachine) -> *mut JSCContext; - pub fn jsc_context_get_current() -> *mut JSCContext; - pub fn jsc_context_check_syntax( - context: *mut JSCContext, - code: *const c_char, - length: ssize_t, - mode: JSCCheckSyntaxMode, - uri: *const c_char, - line_number: c_uint, - exception: *mut *mut JSCException, - ) -> JSCCheckSyntaxResult; - pub fn jsc_context_clear_exception(context: *mut JSCContext); - pub fn jsc_context_evaluate( - context: *mut JSCContext, - code: *const c_char, - length: ssize_t, - ) -> *mut JSCValue; - pub fn jsc_context_evaluate_in_object( - context: *mut JSCContext, - code: *const c_char, - length: ssize_t, - object_instance: gpointer, - object_class: *mut JSCClass, - uri: *const c_char, - line_number: c_uint, - object: *mut *mut JSCValue, - ) -> *mut JSCValue; - pub fn jsc_context_evaluate_with_source_uri( - context: *mut JSCContext, - code: *const c_char, - length: ssize_t, - uri: *const c_char, - line_number: c_uint, - ) -> *mut JSCValue; - pub fn jsc_context_get_exception(context: *mut JSCContext) -> *mut JSCException; - pub fn jsc_context_get_global_object(context: *mut JSCContext) -> *mut JSCValue; - pub fn jsc_context_get_value(context: *mut JSCContext, name: *const c_char) -> *mut JSCValue; - pub fn jsc_context_get_virtual_machine(context: *mut JSCContext) -> *mut JSCVirtualMachine; - pub fn jsc_context_pop_exception_handler(context: *mut JSCContext); - pub fn jsc_context_push_exception_handler( - context: *mut JSCContext, - handler: JSCExceptionHandler, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - ); - pub fn jsc_context_register_class( - context: *mut JSCContext, - name: *const c_char, - parent_class: *mut JSCClass, - vtable: *mut JSCClassVTable, - destroy_notify: glib::GDestroyNotify, - ) -> *mut JSCClass; - pub fn jsc_context_set_value(context: *mut JSCContext, name: *const c_char, value: *mut JSCValue); - pub fn jsc_context_throw(context: *mut JSCContext, error_message: *const c_char); - pub fn jsc_context_throw_exception(context: *mut JSCContext, exception: *mut JSCException); - pub fn jsc_context_throw_printf(context: *mut JSCContext, format: *const c_char, ...); - pub fn jsc_context_throw_with_name( - context: *mut JSCContext, - error_name: *const c_char, - error_message: *const c_char, - ); - pub fn jsc_context_throw_with_name_printf( - context: *mut JSCContext, - error_name: *const c_char, - format: *const c_char, - ... - ); - - //========================================================================= - // JSCException - //========================================================================= - pub fn jsc_exception_get_type() -> GType; - pub fn jsc_exception_new(context: *mut JSCContext, message: *const c_char) -> *mut JSCException; - pub fn jsc_exception_new_printf( - context: *mut JSCContext, - format: *const c_char, - ... - ) -> *mut JSCException; - //pub fn jsc_exception_new_vprintf(context: *mut JSCContext, format: *const c_char, args: /*Unimplemented*/va_list) -> *mut JSCException; - pub fn jsc_exception_new_with_name( - context: *mut JSCContext, - name: *const c_char, - message: *const c_char, - ) -> *mut JSCException; - pub fn jsc_exception_new_with_name_printf( - context: *mut JSCContext, - name: *const c_char, - format: *const c_char, - ... - ) -> *mut JSCException; - //pub fn jsc_exception_new_with_name_vprintf(context: *mut JSCContext, name: *const c_char, format: *const c_char, args: /*Unimplemented*/va_list) -> *mut JSCException; - pub fn jsc_exception_get_backtrace_string(exception: *mut JSCException) -> *const c_char; - pub fn jsc_exception_get_column_number(exception: *mut JSCException) -> c_uint; - pub fn jsc_exception_get_line_number(exception: *mut JSCException) -> c_uint; - pub fn jsc_exception_get_message(exception: *mut JSCException) -> *const c_char; - pub fn jsc_exception_get_name(exception: *mut JSCException) -> *const c_char; - pub fn jsc_exception_get_source_uri(exception: *mut JSCException) -> *const c_char; - pub fn jsc_exception_report(exception: *mut JSCException) -> *mut c_char; - pub fn jsc_exception_to_string(exception: *mut JSCException) -> *mut c_char; - - //========================================================================= - // JSCValue - //========================================================================= - pub fn jsc_value_get_type() -> GType; - pub fn jsc_value_new_array( - context: *mut JSCContext, - first_item_type: GType, - ... - ) -> *mut JSCValue; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_new_array_buffer( - context: *mut JSCContext, - data: gpointer, - size: size_t, - destroy_notify: glib::GDestroyNotify, - user_data: gpointer, - ) -> *mut JSCValue; - pub fn jsc_value_new_array_from_garray( - context: *mut JSCContext, - array: *mut glib::GPtrArray, - ) -> *mut JSCValue; - pub fn jsc_value_new_array_from_strv( - context: *mut JSCContext, - strv: *const *const c_char, - ) -> *mut JSCValue; - pub fn jsc_value_new_boolean(context: *mut JSCContext, value: gboolean) -> *mut JSCValue; - #[cfg(feature = "v2_28")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] - pub fn jsc_value_new_from_json(context: *mut JSCContext, json: *const c_char) -> *mut JSCValue; - pub fn jsc_value_new_function( - context: *mut JSCContext, - name: *const c_char, - callback: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - return_type: GType, - n_params: c_uint, - ... - ) -> *mut JSCValue; - pub fn jsc_value_new_function_variadic( - context: *mut JSCContext, - name: *const c_char, - callback: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - return_type: GType, - ) -> *mut JSCValue; - pub fn jsc_value_new_functionv( - context: *mut JSCContext, - name: *const c_char, - callback: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - return_type: GType, - n_parameters: c_uint, - parameter_types: *mut GType, - ) -> *mut JSCValue; - pub fn jsc_value_new_null(context: *mut JSCContext) -> *mut JSCValue; - pub fn jsc_value_new_number(context: *mut JSCContext, number: c_double) -> *mut JSCValue; - pub fn jsc_value_new_object( - context: *mut JSCContext, - instance: gpointer, - jsc_class: *mut JSCClass, - ) -> *mut JSCValue; - pub fn jsc_value_new_string(context: *mut JSCContext, string: *const c_char) -> *mut JSCValue; - pub fn jsc_value_new_string_from_bytes( - context: *mut JSCContext, - bytes: *mut glib::GBytes, - ) -> *mut JSCValue; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_new_typed_array( - context: *mut JSCContext, - type_: JSCTypedArrayType, - length: size_t, - ) -> *mut JSCValue; - pub fn jsc_value_new_undefined(context: *mut JSCContext) -> *mut JSCValue; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_array_buffer_get_data(value: *mut JSCValue, size: *mut size_t) -> gpointer; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_array_buffer_get_size(value: *mut JSCValue) -> size_t; - pub fn jsc_value_constructor_call( - value: *mut JSCValue, - first_parameter_type: GType, - ... - ) -> *mut JSCValue; - pub fn jsc_value_constructor_callv( - value: *mut JSCValue, - n_parameters: c_uint, - parameters: *mut *mut JSCValue, - ) -> *mut JSCValue; - pub fn jsc_value_function_call( - value: *mut JSCValue, - first_parameter_type: GType, - ... - ) -> *mut JSCValue; - pub fn jsc_value_function_callv( - value: *mut JSCValue, - n_parameters: c_uint, - parameters: *mut *mut JSCValue, - ) -> *mut JSCValue; - pub fn jsc_value_get_context(value: *mut JSCValue) -> *mut JSCContext; - pub fn jsc_value_is_array(value: *mut JSCValue) -> gboolean; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_is_array_buffer(value: *mut JSCValue) -> gboolean; - pub fn jsc_value_is_boolean(value: *mut JSCValue) -> gboolean; - pub fn jsc_value_is_constructor(value: *mut JSCValue) -> gboolean; - pub fn jsc_value_is_function(value: *mut JSCValue) -> gboolean; - pub fn jsc_value_is_null(value: *mut JSCValue) -> gboolean; - pub fn jsc_value_is_number(value: *mut JSCValue) -> gboolean; - pub fn jsc_value_is_object(value: *mut JSCValue) -> gboolean; - pub fn jsc_value_is_string(value: *mut JSCValue) -> gboolean; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_is_typed_array(value: *mut JSCValue) -> gboolean; - pub fn jsc_value_is_undefined(value: *mut JSCValue) -> gboolean; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_new_typed_array_with_buffer( - array_buffer: *mut JSCValue, - type_: JSCTypedArrayType, - offset: size_t, - length: ssize_t, - ) -> *mut JSCValue; - pub fn jsc_value_object_define_property_accessor( - value: *mut JSCValue, - property_name: *const c_char, - flags: JSCValuePropertyFlags, - property_type: GType, - getter: gobject::GCallback, - setter: gobject::GCallback, - user_data: gpointer, - destroy_notify: glib::GDestroyNotify, - ); - pub fn jsc_value_object_define_property_data( - value: *mut JSCValue, - property_name: *const c_char, - flags: JSCValuePropertyFlags, - property_value: *mut JSCValue, - ); - pub fn jsc_value_object_delete_property(value: *mut JSCValue, name: *const c_char) -> gboolean; - pub fn jsc_value_object_enumerate_properties(value: *mut JSCValue) -> *mut *mut c_char; - pub fn jsc_value_object_get_property(value: *mut JSCValue, name: *const c_char) -> *mut JSCValue; - pub fn jsc_value_object_get_property_at_index( - value: *mut JSCValue, - index: c_uint, - ) -> *mut JSCValue; - pub fn jsc_value_object_has_property(value: *mut JSCValue, name: *const c_char) -> gboolean; - pub fn jsc_value_object_invoke_method( - value: *mut JSCValue, - name: *const c_char, - first_parameter_type: GType, - ... - ) -> *mut JSCValue; - pub fn jsc_value_object_invoke_methodv( - value: *mut JSCValue, - name: *const c_char, - n_parameters: c_uint, - parameters: *mut *mut JSCValue, - ) -> *mut JSCValue; - pub fn jsc_value_object_is_instance_of(value: *mut JSCValue, name: *const c_char) -> gboolean; - pub fn jsc_value_object_set_property( - value: *mut JSCValue, - name: *const c_char, - property: *mut JSCValue, - ); - pub fn jsc_value_object_set_property_at_index( - value: *mut JSCValue, - index: c_uint, - property: *mut JSCValue, - ); - pub fn jsc_value_to_boolean(value: *mut JSCValue) -> gboolean; - pub fn jsc_value_to_double(value: *mut JSCValue) -> c_double; - pub fn jsc_value_to_int32(value: *mut JSCValue) -> i32; - #[cfg(feature = "v2_28")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] - pub fn jsc_value_to_json(value: *mut JSCValue, indent: c_uint) -> *mut c_char; - pub fn jsc_value_to_string(value: *mut JSCValue) -> *mut c_char; - pub fn jsc_value_to_string_as_bytes(value: *mut JSCValue) -> *mut glib::GBytes; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_typed_array_get_buffer(value: *mut JSCValue) -> *mut JSCValue; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_typed_array_get_data(value: *mut JSCValue, length: *mut size_t) -> gpointer; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_typed_array_get_length(value: *mut JSCValue) -> size_t; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_typed_array_get_offset(value: *mut JSCValue) -> size_t; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_typed_array_get_size(value: *mut JSCValue) -> size_t; - #[cfg(feature = "v2_38")] - #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] - pub fn jsc_value_typed_array_get_type(value: *mut JSCValue) -> JSCTypedArrayType; - - //========================================================================= - // JSCVirtualMachine - //========================================================================= - pub fn jsc_virtual_machine_get_type() -> GType; - pub fn jsc_virtual_machine_new() -> *mut JSCVirtualMachine; - - //========================================================================= - // JSCWeakValue - //========================================================================= - pub fn jsc_weak_value_get_type() -> GType; - pub fn jsc_weak_value_new(value: *mut JSCValue) -> *mut JSCWeakValue; - pub fn jsc_weak_value_get_value(weak_value: *mut JSCWeakValue) -> *mut JSCValue; - - //========================================================================= - // Other functions - //========================================================================= - pub fn jsc_get_major_version() -> c_uint; - pub fn jsc_get_micro_version() -> c_uint; - pub fn jsc_get_minor_version() -> c_uint; - pub fn jsc_options_foreach(function: JSCOptionsFunc, user_data: gpointer); - pub fn jsc_options_get_boolean(option: *const c_char, value: *mut gboolean) -> gboolean; - pub fn jsc_options_get_double(option: *const c_char, value: *mut c_double) -> gboolean; - pub fn jsc_options_get_int(option: *const c_char, value: *mut c_int) -> gboolean; - pub fn jsc_options_get_option_group() -> *mut glib::GOptionGroup; - pub fn jsc_options_get_range_string(option: *const c_char, value: *mut *mut c_char) -> gboolean; - pub fn jsc_options_get_size(option: *const c_char, value: *mut size_t) -> gboolean; - pub fn jsc_options_get_string(option: *const c_char, value: *mut *mut c_char) -> gboolean; - pub fn jsc_options_get_uint(option: *const c_char, value: *mut c_uint) -> gboolean; - pub fn jsc_options_set_boolean(option: *const c_char, value: gboolean) -> gboolean; - pub fn jsc_options_set_double(option: *const c_char, value: c_double) -> gboolean; - pub fn jsc_options_set_int(option: *const c_char, value: c_int) -> gboolean; - pub fn jsc_options_set_range_string(option: *const c_char, value: *const c_char) -> gboolean; - pub fn jsc_options_set_size(option: *const c_char, value: size_t) -> gboolean; - pub fn jsc_options_set_string(option: *const c_char, value: *const c_char) -> gboolean; - pub fn jsc_options_set_uint(option: *const c_char, value: c_uint) -> gboolean; + //========================================================================= + // JSCClass + //========================================================================= + pub fn jsc_class_get_type() -> GType; + pub fn jsc_class_add_constructor(jsc_class: *mut JSCClass, name: *const c_char, callback: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify, return_type: GType, n_params: c_uint, ...) -> *mut JSCValue; + pub fn jsc_class_add_constructor_variadic(jsc_class: *mut JSCClass, name: *const c_char, callback: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify, return_type: GType) -> *mut JSCValue; + pub fn jsc_class_add_constructorv(jsc_class: *mut JSCClass, name: *const c_char, callback: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify, return_type: GType, n_parameters: c_uint, parameter_types: *mut GType) -> *mut JSCValue; + pub fn jsc_class_add_method(jsc_class: *mut JSCClass, name: *const c_char, callback: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify, return_type: GType, n_params: c_uint, ...); + pub fn jsc_class_add_method_variadic(jsc_class: *mut JSCClass, name: *const c_char, callback: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify, return_type: GType); + pub fn jsc_class_add_methodv(jsc_class: *mut JSCClass, name: *const c_char, callback: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify, return_type: GType, n_parameters: c_uint, parameter_types: *mut GType); + pub fn jsc_class_add_property(jsc_class: *mut JSCClass, name: *const c_char, property_type: GType, getter: gobject::GCallback, setter: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify); + pub fn jsc_class_get_name(jsc_class: *mut JSCClass) -> *const c_char; + pub fn jsc_class_get_parent(jsc_class: *mut JSCClass) -> *mut JSCClass; + + //========================================================================= + // JSCContext + //========================================================================= + pub fn jsc_context_get_type() -> GType; + pub fn jsc_context_new() -> *mut JSCContext; + pub fn jsc_context_new_with_virtual_machine(vm: *mut JSCVirtualMachine) -> *mut JSCContext; + pub fn jsc_context_get_current() -> *mut JSCContext; + pub fn jsc_context_check_syntax(context: *mut JSCContext, code: *const c_char, length: ssize_t, mode: JSCCheckSyntaxMode, uri: *const c_char, line_number: c_uint, exception: *mut *mut JSCException) -> JSCCheckSyntaxResult; + pub fn jsc_context_clear_exception(context: *mut JSCContext); + pub fn jsc_context_evaluate(context: *mut JSCContext, code: *const c_char, length: ssize_t) -> *mut JSCValue; + pub fn jsc_context_evaluate_in_object(context: *mut JSCContext, code: *const c_char, length: ssize_t, object_instance: gpointer, object_class: *mut JSCClass, uri: *const c_char, line_number: c_uint, object: *mut *mut JSCValue) -> *mut JSCValue; + pub fn jsc_context_evaluate_with_source_uri(context: *mut JSCContext, code: *const c_char, length: ssize_t, uri: *const c_char, line_number: c_uint) -> *mut JSCValue; + pub fn jsc_context_get_exception(context: *mut JSCContext) -> *mut JSCException; + pub fn jsc_context_get_global_object(context: *mut JSCContext) -> *mut JSCValue; + pub fn jsc_context_get_value(context: *mut JSCContext, name: *const c_char) -> *mut JSCValue; + pub fn jsc_context_get_virtual_machine(context: *mut JSCContext) -> *mut JSCVirtualMachine; + pub fn jsc_context_pop_exception_handler(context: *mut JSCContext); + pub fn jsc_context_push_exception_handler(context: *mut JSCContext, handler: JSCExceptionHandler, user_data: gpointer, destroy_notify: glib::GDestroyNotify); + pub fn jsc_context_register_class(context: *mut JSCContext, name: *const c_char, parent_class: *mut JSCClass, vtable: *mut JSCClassVTable, destroy_notify: glib::GDestroyNotify) -> *mut JSCClass; + pub fn jsc_context_set_value(context: *mut JSCContext, name: *const c_char, value: *mut JSCValue); + pub fn jsc_context_throw(context: *mut JSCContext, error_message: *const c_char); + pub fn jsc_context_throw_exception(context: *mut JSCContext, exception: *mut JSCException); + pub fn jsc_context_throw_printf(context: *mut JSCContext, format: *const c_char, ...); + pub fn jsc_context_throw_with_name(context: *mut JSCContext, error_name: *const c_char, error_message: *const c_char); + pub fn jsc_context_throw_with_name_printf(context: *mut JSCContext, error_name: *const c_char, format: *const c_char, ...); + + //========================================================================= + // JSCException + //========================================================================= + pub fn jsc_exception_get_type() -> GType; + pub fn jsc_exception_new(context: *mut JSCContext, message: *const c_char) -> *mut JSCException; + pub fn jsc_exception_new_printf(context: *mut JSCContext, format: *const c_char, ...) -> *mut JSCException; + //pub fn jsc_exception_new_vprintf(context: *mut JSCContext, format: *const c_char, args: /*Unimplemented*/va_list) -> *mut JSCException; + pub fn jsc_exception_new_with_name(context: *mut JSCContext, name: *const c_char, message: *const c_char) -> *mut JSCException; + pub fn jsc_exception_new_with_name_printf(context: *mut JSCContext, name: *const c_char, format: *const c_char, ...) -> *mut JSCException; + //pub fn jsc_exception_new_with_name_vprintf(context: *mut JSCContext, name: *const c_char, format: *const c_char, args: /*Unimplemented*/va_list) -> *mut JSCException; + pub fn jsc_exception_get_backtrace_string(exception: *mut JSCException) -> *const c_char; + pub fn jsc_exception_get_column_number(exception: *mut JSCException) -> c_uint; + pub fn jsc_exception_get_line_number(exception: *mut JSCException) -> c_uint; + pub fn jsc_exception_get_message(exception: *mut JSCException) -> *const c_char; + pub fn jsc_exception_get_name(exception: *mut JSCException) -> *const c_char; + pub fn jsc_exception_get_source_uri(exception: *mut JSCException) -> *const c_char; + pub fn jsc_exception_report(exception: *mut JSCException) -> *mut c_char; + pub fn jsc_exception_to_string(exception: *mut JSCException) -> *mut c_char; + + //========================================================================= + // JSCValue + //========================================================================= + pub fn jsc_value_get_type() -> GType; + pub fn jsc_value_new_array(context: *mut JSCContext, first_item_type: GType, ...) -> *mut JSCValue; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_new_array_buffer(context: *mut JSCContext, data: gpointer, size: size_t, destroy_notify: glib::GDestroyNotify, user_data: gpointer) -> *mut JSCValue; + pub fn jsc_value_new_array_from_garray(context: *mut JSCContext, array: *mut glib::GPtrArray) -> *mut JSCValue; + pub fn jsc_value_new_array_from_strv(context: *mut JSCContext, strv: *const *const c_char) -> *mut JSCValue; + pub fn jsc_value_new_boolean(context: *mut JSCContext, value: gboolean) -> *mut JSCValue; + #[cfg(feature = "v2_28")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] + pub fn jsc_value_new_from_json(context: *mut JSCContext, json: *const c_char) -> *mut JSCValue; + pub fn jsc_value_new_function(context: *mut JSCContext, name: *const c_char, callback: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify, return_type: GType, n_params: c_uint, ...) -> *mut JSCValue; + pub fn jsc_value_new_function_variadic(context: *mut JSCContext, name: *const c_char, callback: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify, return_type: GType) -> *mut JSCValue; + pub fn jsc_value_new_functionv(context: *mut JSCContext, name: *const c_char, callback: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify, return_type: GType, n_parameters: c_uint, parameter_types: *mut GType) -> *mut JSCValue; + pub fn jsc_value_new_null(context: *mut JSCContext) -> *mut JSCValue; + pub fn jsc_value_new_number(context: *mut JSCContext, number: c_double) -> *mut JSCValue; + pub fn jsc_value_new_object(context: *mut JSCContext, instance: gpointer, jsc_class: *mut JSCClass) -> *mut JSCValue; + pub fn jsc_value_new_string(context: *mut JSCContext, string: *const c_char) -> *mut JSCValue; + pub fn jsc_value_new_string_from_bytes(context: *mut JSCContext, bytes: *mut glib::GBytes) -> *mut JSCValue; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_new_typed_array(context: *mut JSCContext, type_: JSCTypedArrayType, length: size_t) -> *mut JSCValue; + pub fn jsc_value_new_undefined(context: *mut JSCContext) -> *mut JSCValue; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_array_buffer_get_data(value: *mut JSCValue, size: *mut size_t) -> gpointer; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_array_buffer_get_size(value: *mut JSCValue) -> size_t; + pub fn jsc_value_constructor_call(value: *mut JSCValue, first_parameter_type: GType, ...) -> *mut JSCValue; + pub fn jsc_value_constructor_callv(value: *mut JSCValue, n_parameters: c_uint, parameters: *mut *mut JSCValue) -> *mut JSCValue; + pub fn jsc_value_function_call(value: *mut JSCValue, first_parameter_type: GType, ...) -> *mut JSCValue; + pub fn jsc_value_function_callv(value: *mut JSCValue, n_parameters: c_uint, parameters: *mut *mut JSCValue) -> *mut JSCValue; + pub fn jsc_value_get_context(value: *mut JSCValue) -> *mut JSCContext; + pub fn jsc_value_is_array(value: *mut JSCValue) -> gboolean; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_is_array_buffer(value: *mut JSCValue) -> gboolean; + pub fn jsc_value_is_boolean(value: *mut JSCValue) -> gboolean; + pub fn jsc_value_is_constructor(value: *mut JSCValue) -> gboolean; + pub fn jsc_value_is_function(value: *mut JSCValue) -> gboolean; + pub fn jsc_value_is_null(value: *mut JSCValue) -> gboolean; + pub fn jsc_value_is_number(value: *mut JSCValue) -> gboolean; + pub fn jsc_value_is_object(value: *mut JSCValue) -> gboolean; + pub fn jsc_value_is_string(value: *mut JSCValue) -> gboolean; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_is_typed_array(value: *mut JSCValue) -> gboolean; + pub fn jsc_value_is_undefined(value: *mut JSCValue) -> gboolean; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_new_typed_array_with_buffer(array_buffer: *mut JSCValue, type_: JSCTypedArrayType, offset: size_t, length: ssize_t) -> *mut JSCValue; + pub fn jsc_value_object_define_property_accessor(value: *mut JSCValue, property_name: *const c_char, flags: JSCValuePropertyFlags, property_type: GType, getter: gobject::GCallback, setter: gobject::GCallback, user_data: gpointer, destroy_notify: glib::GDestroyNotify); + pub fn jsc_value_object_define_property_data(value: *mut JSCValue, property_name: *const c_char, flags: JSCValuePropertyFlags, property_value: *mut JSCValue); + pub fn jsc_value_object_delete_property(value: *mut JSCValue, name: *const c_char) -> gboolean; + pub fn jsc_value_object_enumerate_properties(value: *mut JSCValue) -> *mut *mut c_char; + pub fn jsc_value_object_get_property(value: *mut JSCValue, name: *const c_char) -> *mut JSCValue; + pub fn jsc_value_object_get_property_at_index(value: *mut JSCValue, index: c_uint) -> *mut JSCValue; + pub fn jsc_value_object_has_property(value: *mut JSCValue, name: *const c_char) -> gboolean; + pub fn jsc_value_object_invoke_method(value: *mut JSCValue, name: *const c_char, first_parameter_type: GType, ...) -> *mut JSCValue; + pub fn jsc_value_object_invoke_methodv(value: *mut JSCValue, name: *const c_char, n_parameters: c_uint, parameters: *mut *mut JSCValue) -> *mut JSCValue; + pub fn jsc_value_object_is_instance_of(value: *mut JSCValue, name: *const c_char) -> gboolean; + pub fn jsc_value_object_set_property(value: *mut JSCValue, name: *const c_char, property: *mut JSCValue); + pub fn jsc_value_object_set_property_at_index(value: *mut JSCValue, index: c_uint, property: *mut JSCValue); + pub fn jsc_value_to_boolean(value: *mut JSCValue) -> gboolean; + pub fn jsc_value_to_double(value: *mut JSCValue) -> c_double; + pub fn jsc_value_to_int32(value: *mut JSCValue) -> i32; + #[cfg(feature = "v2_28")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_28")))] + pub fn jsc_value_to_json(value: *mut JSCValue, indent: c_uint) -> *mut c_char; + pub fn jsc_value_to_string(value: *mut JSCValue) -> *mut c_char; + pub fn jsc_value_to_string_as_bytes(value: *mut JSCValue) -> *mut glib::GBytes; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_typed_array_get_buffer(value: *mut JSCValue) -> *mut JSCValue; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_typed_array_get_data(value: *mut JSCValue, length: *mut size_t) -> gpointer; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_typed_array_get_length(value: *mut JSCValue) -> size_t; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_typed_array_get_offset(value: *mut JSCValue) -> size_t; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_typed_array_get_size(value: *mut JSCValue) -> size_t; + #[cfg(feature = "v2_38")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_38")))] + pub fn jsc_value_typed_array_get_type(value: *mut JSCValue) -> JSCTypedArrayType; + + //========================================================================= + // JSCVirtualMachine + //========================================================================= + pub fn jsc_virtual_machine_get_type() -> GType; + pub fn jsc_virtual_machine_new() -> *mut JSCVirtualMachine; + + //========================================================================= + // JSCWeakValue + //========================================================================= + pub fn jsc_weak_value_get_type() -> GType; + pub fn jsc_weak_value_new(value: *mut JSCValue) -> *mut JSCWeakValue; + pub fn jsc_weak_value_get_value(weak_value: *mut JSCWeakValue) -> *mut JSCValue; + + //========================================================================= + // Other functions + //========================================================================= + pub fn jsc_get_major_version() -> c_uint; + pub fn jsc_get_micro_version() -> c_uint; + pub fn jsc_get_minor_version() -> c_uint; + pub fn jsc_options_foreach(function: JSCOptionsFunc, user_data: gpointer); + pub fn jsc_options_get_boolean(option: *const c_char, value: *mut gboolean) -> gboolean; + pub fn jsc_options_get_double(option: *const c_char, value: *mut c_double) -> gboolean; + pub fn jsc_options_get_int(option: *const c_char, value: *mut c_int) -> gboolean; + pub fn jsc_options_get_option_group() -> *mut glib::GOptionGroup; + pub fn jsc_options_get_range_string(option: *const c_char, value: *mut *mut c_char) -> gboolean; + pub fn jsc_options_get_size(option: *const c_char, value: *mut size_t) -> gboolean; + pub fn jsc_options_get_string(option: *const c_char, value: *mut *mut c_char) -> gboolean; + pub fn jsc_options_get_uint(option: *const c_char, value: *mut c_uint) -> gboolean; + pub fn jsc_options_set_boolean(option: *const c_char, value: gboolean) -> gboolean; + pub fn jsc_options_set_double(option: *const c_char, value: c_double) -> gboolean; + pub fn jsc_options_set_int(option: *const c_char, value: c_int) -> gboolean; + pub fn jsc_options_set_range_string(option: *const c_char, value: *const c_char) -> gboolean; + pub fn jsc_options_set_size(option: *const c_char, value: size_t) -> gboolean; + pub fn jsc_options_set_string(option: *const c_char, value: *const c_char) -> gboolean; + pub fn jsc_options_set_uint(option: *const c_char, value: c_uint) -> gboolean; } diff --git a/sys/tests/abi.rs b/sys/tests/abi.rs index 77a47f6..b7326a4 100644 --- a/sys/tests/abi.rs +++ b/sys/tests/abi.rs @@ -5,10 +5,10 @@ #![cfg(unix)] use javascriptcore_rs_sys::*; +use std::mem::{align_of, size_of}; use std::env; use std::error::Error; use std::ffi::OsString; -use std::mem::{align_of, size_of}; use std::path::Path; use std::process::{Command, Stdio}; use std::str; @@ -18,338 +18,250 @@ static PACKAGES: &[&str] = &["javascriptcoregtk-4.1"]; #[derive(Clone, Debug)] struct Compiler { - pub args: Vec, + pub args: Vec, } impl Compiler { - pub fn new() -> Result> { - let mut args = get_var("CC", "cc")?; - args.push("-Wno-deprecated-declarations".to_owned()); - // For _Generic - args.push("-std=c11".to_owned()); - // For %z support in printf when using MinGW. - args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); - args.extend(get_var("CFLAGS", "")?); - args.extend(get_var("CPPFLAGS", "")?); - args.extend(pkg_config_cflags(PACKAGES)?); - Ok(Self { args }) - } - - pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { - let mut cmd = self.to_command(); - cmd.arg(src); - cmd.arg("-o"); - cmd.arg(out); - let status = cmd.spawn()?.wait()?; - if !status.success() { - return Err(format!("compilation command {cmd:?} failed, {status}").into()); + pub fn new() -> Result> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For _Generic + args.push("-std=c11".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Self { args }) + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {cmd:?} failed, {status}").into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd } - Ok(()) - } - - fn to_command(&self) -> Command { - let mut cmd = Command::new(&self.args[0]); - cmd.args(&self.args[1..]); - cmd - } } fn get_var(name: &str, default: &str) -> Result, Box> { - match env::var(name) { - Ok(value) => Ok(shell_words::split(&value)?), - Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), - Err(err) => Err(format!("{name} {err}").into()), - } + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{name} {err}").into()), + } } fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { - if packages.is_empty() { - return Ok(Vec::new()); - } - let pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); - let mut cmd = Command::new(pkg_config); - cmd.arg("--cflags"); - cmd.args(packages); - cmd.stderr(Stdio::inherit()); - let out = cmd.output()?; - if !out.status.success() { - let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); - return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); - } - let stdout = str::from_utf8(&out.stdout)?; - Ok(shell_words::split(stdout.trim())?) + if packages.is_empty() { + return Ok(Vec::new()); + } + let pkg_config = env::var_os("PKG_CONFIG") + .unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) } + #[derive(Copy, Clone, Debug, Eq, PartialEq)] struct Layout { - size: usize, - alignment: usize, + size: usize, + alignment: usize, } #[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] struct Results { - /// Number of successfully completed tests. - passed: usize, - /// Total number of failed tests (including those that failed to compile). - failed: usize, + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, } impl Results { - fn record_passed(&mut self) { - self.passed += 1; - } - fn record_failed(&mut self) { - self.failed += 1; - } - fn summary(&self) -> String { - format!("{} passed; {} failed", self.passed, self.failed) - } - fn expect_total_success(&self) { - if self.failed == 0 { - println!("OK: {}", self.summary()); - } else { - panic!("FAILED: {}", self.summary()); - }; - } + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } } #[test] fn cross_validate_constants_with_c() { - let mut c_constants: Vec<(String, String)> = Vec::new(); + let mut c_constants: Vec<(String, String)> = Vec::new(); - for l in get_c_output("constant").unwrap().lines() { - let (name, value) = l.split_once(';').expect("Missing ';' separator"); - c_constants.push((name.to_owned(), value.to_owned())); - } - - let mut results = Results::default(); - - for ((rust_name, rust_value), (c_name, c_value)) in RUST_CONSTANTS.iter().zip(c_constants.iter()) - { - if rust_name != c_name { - results.record_failed(); - eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); - continue; + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); } - if rust_value != c_value { - results.record_failed(); - eprintln!("Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}",); - continue; + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); } - results.record_passed(); - } - - results.expect_total_success(); + results.expect_total_success(); } #[test] fn cross_validate_layout_with_c() { - let mut c_layouts = Vec::new(); - - for l in get_c_output("layout").unwrap().lines() { - let (name, value) = l.split_once(';').expect("Missing first ';' separator"); - let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); - let size = size.parse().expect("Failed to parse size"); - let alignment = alignment.parse().expect("Failed to parse alignment"); - c_layouts.push((name.to_owned(), Layout { size, alignment })); - } - - let mut results = Results::default(); - - for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) { - if rust_name != c_name { - results.record_failed(); - eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); - continue; + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); } - if rust_layout != c_layout { - results.record_failed(); - eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); - continue; + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in + RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!( + "Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}", + ); + continue; + } + + results.record_passed(); } - results.record_passed(); - } - - results.expect_total_success(); + results.expect_total_success(); } fn get_c_output(name: &str) -> Result> { - let tmpdir = Builder::new().prefix("abi").tempdir()?; - let exe = tmpdir.path().join(name); - let c_file = Path::new("tests").join(name).with_extension("c"); - - let cc = Compiler::new().expect("configured compiler"); - cc.compile(&c_file, &exe)?; - - let mut cmd = Command::new(exe); - cmd.stderr(Stdio::inherit()); - let out = cmd.output()?; - if !out.status.success() { - let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); - return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); - } - - Ok(String::from_utf8(out.stdout)?) + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) } const RUST_LAYOUTS: &[(&str, Layout)] = &[ - ( - "JSCCheckSyntaxMode", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCCheckSyntaxResult", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCClassVTable", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCContext", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCContextClass", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCException", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCExceptionClass", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCOptionType", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCTypedArrayType", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCValue", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCValueClass", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCValuePropertyFlags", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCVirtualMachine", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCVirtualMachineClass", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCWeakValue", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), - ( - "JSCWeakValueClass", - Layout { - size: size_of::(), - alignment: align_of::(), - }, - ), + ("JSCCheckSyntaxMode", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCCheckSyntaxResult", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCClassVTable", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCContext", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCContextClass", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCException", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCExceptionClass", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCOptionType", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCTypedArrayType", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCValue", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCValueClass", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCValuePropertyFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCVirtualMachine", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCVirtualMachineClass", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCWeakValue", Layout {size: size_of::(), alignment: align_of::()}), + ("JSCWeakValueClass", Layout {size: size_of::(), alignment: align_of::()}), ]; const RUST_CONSTANTS: &[(&str, &str)] = &[ - ("(gint) JSC_CHECK_SYNTAX_MODE_MODULE", "1"), - ("(gint) JSC_CHECK_SYNTAX_MODE_SCRIPT", "0"), - ("(gint) JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR", "2"), - ("(gint) JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR", "4"), - ("(gint) JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR", "1"), - ("(gint) JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR", "5"), - ("(gint) JSC_CHECK_SYNTAX_RESULT_SUCCESS", "0"), - ( - "(gint) JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR", - "3", - ), - ("JSC_MAJOR_VERSION", "2"), - ("JSC_MICRO_VERSION", "1"), - ("JSC_MINOR_VERSION", "38"), - ("JSC_OPTIONS_USE_DFG", "useDFGJIT"), - ("JSC_OPTIONS_USE_FTL", "useFTLJIT"), - ("JSC_OPTIONS_USE_JIT", "useJIT"), - ("JSC_OPTIONS_USE_LLINT", "useLLInt"), - ("(gint) JSC_OPTION_BOOLEAN", "0"), - ("(gint) JSC_OPTION_DOUBLE", "4"), - ("(gint) JSC_OPTION_INT", "1"), - ("(gint) JSC_OPTION_RANGE_STRING", "6"), - ("(gint) JSC_OPTION_SIZE", "3"), - ("(gint) JSC_OPTION_STRING", "5"), - ("(gint) JSC_OPTION_UINT", "2"), - ("(gint) JSC_TYPED_ARRAY_FLOAT32", "10"), - ("(gint) JSC_TYPED_ARRAY_FLOAT64", "11"), - ("(gint) JSC_TYPED_ARRAY_INT16", "2"), - ("(gint) JSC_TYPED_ARRAY_INT32", "3"), - ("(gint) JSC_TYPED_ARRAY_INT64", "4"), - ("(gint) JSC_TYPED_ARRAY_INT8", "1"), - ("(gint) JSC_TYPED_ARRAY_NONE", "0"), - ("(gint) JSC_TYPED_ARRAY_UINT16", "7"), - ("(gint) JSC_TYPED_ARRAY_UINT32", "8"), - ("(gint) JSC_TYPED_ARRAY_UINT64", "9"), - ("(gint) JSC_TYPED_ARRAY_UINT8", "5"), - ("(gint) JSC_TYPED_ARRAY_UINT8_CLAMPED", "6"), - ("(guint) JSC_VALUE_PROPERTY_CONFIGURABLE", "1"), - ("(guint) JSC_VALUE_PROPERTY_ENUMERABLE", "2"), - ("(guint) JSC_VALUE_PROPERTY_WRITABLE", "4"), + ("(gint) JSC_CHECK_SYNTAX_MODE_MODULE", "1"), + ("(gint) JSC_CHECK_SYNTAX_MODE_SCRIPT", "0"), + ("(gint) JSC_CHECK_SYNTAX_RESULT_IRRECOVERABLE_ERROR", "2"), + ("(gint) JSC_CHECK_SYNTAX_RESULT_OUT_OF_MEMORY_ERROR", "4"), + ("(gint) JSC_CHECK_SYNTAX_RESULT_RECOVERABLE_ERROR", "1"), + ("(gint) JSC_CHECK_SYNTAX_RESULT_STACK_OVERFLOW_ERROR", "5"), + ("(gint) JSC_CHECK_SYNTAX_RESULT_SUCCESS", "0"), + ("(gint) JSC_CHECK_SYNTAX_RESULT_UNTERMINATED_LITERAL_ERROR", "3"), + ("JSC_MAJOR_VERSION", "2"), + ("JSC_MICRO_VERSION", "1"), + ("JSC_MINOR_VERSION", "38"), + ("JSC_OPTIONS_USE_DFG", "useDFGJIT"), + ("JSC_OPTIONS_USE_FTL", "useFTLJIT"), + ("JSC_OPTIONS_USE_JIT", "useJIT"), + ("JSC_OPTIONS_USE_LLINT", "useLLInt"), + ("(gint) JSC_OPTION_BOOLEAN", "0"), + ("(gint) JSC_OPTION_DOUBLE", "4"), + ("(gint) JSC_OPTION_INT", "1"), + ("(gint) JSC_OPTION_RANGE_STRING", "6"), + ("(gint) JSC_OPTION_SIZE", "3"), + ("(gint) JSC_OPTION_STRING", "5"), + ("(gint) JSC_OPTION_UINT", "2"), + ("(gint) JSC_TYPED_ARRAY_FLOAT32", "10"), + ("(gint) JSC_TYPED_ARRAY_FLOAT64", "11"), + ("(gint) JSC_TYPED_ARRAY_INT16", "2"), + ("(gint) JSC_TYPED_ARRAY_INT32", "3"), + ("(gint) JSC_TYPED_ARRAY_INT64", "4"), + ("(gint) JSC_TYPED_ARRAY_INT8", "1"), + ("(gint) JSC_TYPED_ARRAY_NONE", "0"), + ("(gint) JSC_TYPED_ARRAY_UINT16", "7"), + ("(gint) JSC_TYPED_ARRAY_UINT32", "8"), + ("(gint) JSC_TYPED_ARRAY_UINT64", "9"), + ("(gint) JSC_TYPED_ARRAY_UINT8", "5"), + ("(gint) JSC_TYPED_ARRAY_UINT8_CLAMPED", "6"), + ("(guint) JSC_VALUE_PROPERTY_CONFIGURABLE", "1"), + ("(guint) JSC_VALUE_PROPERTY_ENUMERABLE", "2"), + ("(guint) JSC_VALUE_PROPERTY_WRITABLE", "4"), ]; + +