From 6038c956d55f0306a89d8fca8be3bcd2371e988c Mon Sep 17 00:00:00 2001 From: Demir Yerli Date: Fri, 25 Nov 2022 20:26:25 +0300 Subject: [PATCH] Update dependencies + move the code around a bit --- Cargo.toml | 29 ++----------------- main/Cargo.toml | 27 +++++++++++++++++ {src => main/src}/auto/class.rs | 0 {src => main/src}/auto/context.rs | 4 +-- {src => main/src}/auto/enums.rs | 0 {src => main/src}/auto/exception.rs | 0 {src => main/src}/auto/flags.rs | 0 {src => main/src}/auto/mod.rs | 0 {src => main/src}/auto/value.rs | 4 +-- {src => main/src}/auto/versions.txt | 0 {src => main/src}/auto/virtual_machine.rs | 0 {src => main/src}/auto/weak_value.rs | 5 ++-- {src => main/src}/global_context_ref.rs | 1 - {src => main/src}/lib.rs | 4 --- main/src/string_ref.rs | 25 ++++++++++++++++ {src => main/src}/value_ref.rs | 0 src/string_ref.rs | 27 ----------------- sys/Cargo.toml | 35 +++++++++++------------ sys/tests/abi.rs | 9 +++--- 19 files changed, 81 insertions(+), 89 deletions(-) create mode 100644 main/Cargo.toml rename {src => main/src}/auto/class.rs (100%) rename {src => main/src}/auto/context.rs (98%) rename {src => main/src}/auto/enums.rs (100%) rename {src => main/src}/auto/exception.rs (100%) rename {src => main/src}/auto/flags.rs (100%) rename {src => main/src}/auto/mod.rs (100%) rename {src => main/src}/auto/value.rs (99%) rename {src => main/src}/auto/versions.txt (100%) rename {src => main/src}/auto/virtual_machine.rs (100%) rename {src => main/src}/auto/weak_value.rs (94%) rename {src => main/src}/global_context_ref.rs (97%) rename {src => main/src}/lib.rs (84%) create mode 100644 main/src/string_ref.rs rename {src => main/src}/value_ref.rs (100%) delete mode 100644 src/string_ref.rs diff --git a/Cargo.toml b/Cargo.toml index 1cf6fe7..4f1b193 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,27 +1,2 @@ -[package] -name = "javascriptcore-rs" -version = "0.16.0" -edition = "2021" -description = "Rust bindings for the javacriptcore library" -repository = "https://github.com/tauri-apps/javascriptcore-rs" -license = "MIT" -keywords = [ "javascript", "gtk-rs", "gnome" ] - -[package.metadata.docs.rs] -features = [ "dox" ] - -[lib] -name = "javascriptcore" - -[dependencies] -glib = "^0.15.0" -bitflags = "^1.0" - - [dependencies.ffi] - package = "javascriptcore-rs-sys" - path = "./sys" - version = "0.4" - -[features] -v2_28 = [ "ffi/v2_28" ] -dox = [ "ffi/dox" ] +[workspace] +members = ["./sys", "./main"] diff --git a/main/Cargo.toml b/main/Cargo.toml new file mode 100644 index 0000000..eeb85e8 --- /dev/null +++ b/main/Cargo.toml @@ -0,0 +1,27 @@ +[package] +description = "Rust bindings for the javacriptcore library" +edition = "2021" +keywords = ["javascript", "gtk-rs", "gnome"] +license = "MIT" +name = "javascriptcore-rs" +repository = "https://github.com/tauri-apps/javascriptcore-rs" +version = "0.16.0" + +[package.metadata.docs.rs] +features = ["dox"] + +[lib] +name = "javascriptcore" + +[dependencies] +bitflags = "^1.0" +glib = "^0.16.0" + +[dependencies.ffi] +package = "javascriptcore-rs-sys" +path = "../sys" +version = "0.4" + +[features] +dox = ["ffi/dox"] +v2_28 = ["ffi/v2_28"] diff --git a/src/auto/class.rs b/main/src/auto/class.rs similarity index 100% rename from src/auto/class.rs rename to main/src/auto/class.rs diff --git a/src/auto/context.rs b/main/src/auto/context.rs similarity index 98% rename from src/auto/context.rs rename to main/src/auto/context.rs index a323d94..f7ecf28 100644 --- a/src/auto/context.rs +++ b/main/src/auto/context.rs @@ -6,7 +6,7 @@ use crate::{CheckSyntaxMode, CheckSyntaxResult, Exception, Value, VirtualMachine use glib::{ object::{Cast, IsA}, translate::*, - StaticType, ToValue, + ToValue, }; use std::{boxed::Box as Box_, fmt, ptr}; @@ -79,7 +79,7 @@ impl ContextBuilder { if let Some(ref virtual_machine) = self.virtual_machine { properties.push(("virtual-machine", virtual_machine)); } - glib::Object::new::(&properties).expect("Failed to create an instance of Context") + glib::Object::new::(&properties) } pub fn virtual_machine(mut self, virtual_machine: &impl IsA) -> Self { diff --git a/src/auto/enums.rs b/main/src/auto/enums.rs similarity index 100% rename from src/auto/enums.rs rename to main/src/auto/enums.rs diff --git a/src/auto/exception.rs b/main/src/auto/exception.rs similarity index 100% rename from src/auto/exception.rs rename to main/src/auto/exception.rs diff --git a/src/auto/flags.rs b/main/src/auto/flags.rs similarity index 100% rename from src/auto/flags.rs rename to main/src/auto/flags.rs diff --git a/src/auto/mod.rs b/main/src/auto/mod.rs similarity index 100% rename from src/auto/mod.rs rename to main/src/auto/mod.rs diff --git a/src/auto/value.rs b/main/src/auto/value.rs similarity index 99% rename from src/auto/value.rs rename to main/src/auto/value.rs index f4267b8..6edc7e5 100644 --- a/src/auto/value.rs +++ b/main/src/auto/value.rs @@ -6,7 +6,7 @@ use crate::{Context, ValuePropertyFlags}; use glib::{ object::{Cast, IsA}, translate::*, - StaticType, ToValue, + ToValue, }; use std::fmt; @@ -171,7 +171,7 @@ impl ValueBuilder { if let Some(ref context) = self.context { properties.push(("context", context)); } - glib::Object::new::(&properties).expect("Failed to create an instance of Value") + glib::Object::new::(&properties) } pub fn context(mut self, context: &impl IsA) -> Self { diff --git a/src/auto/versions.txt b/main/src/auto/versions.txt similarity index 100% rename from src/auto/versions.txt rename to main/src/auto/versions.txt diff --git a/src/auto/virtual_machine.rs b/main/src/auto/virtual_machine.rs similarity index 100% rename from src/auto/virtual_machine.rs rename to main/src/auto/virtual_machine.rs diff --git a/src/auto/weak_value.rs b/main/src/auto/weak_value.rs similarity index 94% rename from src/auto/weak_value.rs rename to main/src/auto/weak_value.rs index bdabf7d..62d2296 100644 --- a/src/auto/weak_value.rs +++ b/main/src/auto/weak_value.rs @@ -7,7 +7,7 @@ use glib::{ object::{Cast, IsA}, signal::{connect_raw, SignalHandlerId}, translate::*, - StaticType, ToValue, + ToValue, }; use std::{boxed::Box as Box_, fmt, mem::transmute}; @@ -38,7 +38,6 @@ impl WeakValue { impl Default for WeakValue { fn default() -> Self { glib::object::Object::new::(&[]) - .expect("Can't construct WeakValue object with default parameters") } } @@ -65,7 +64,7 @@ impl WeakValueBuilder { if let Some(ref value) = self.value { properties.push(("value", value)); } - glib::Object::new::(&properties).expect("Failed to create an instance of WeakValue") + glib::Object::new::(&properties) } pub fn value(mut self, value: &impl IsA) -> Self { diff --git a/src/global_context_ref.rs b/main/src/global_context_ref.rs similarity index 97% rename from src/global_context_ref.rs rename to main/src/global_context_ref.rs index d22cdb7..47a77e7 100644 --- a/src/global_context_ref.rs +++ b/main/src/global_context_ref.rs @@ -1,6 +1,5 @@ use ffi::*; use glib::translate::*; -use std::ptr; pub struct GlobalContextRef { raw: JSGlobalContextRef, diff --git a/src/lib.rs b/main/src/lib.rs similarity index 84% rename from src/lib.rs rename to main/src/lib.rs index f5925d9..8f01c3e 100644 --- a/src/lib.rs +++ b/main/src/lib.rs @@ -3,10 +3,6 @@ // // Licensed under the MIT license, see the LICENSE file or #![cfg_attr(feature = "dox", feature(doc_cfg))] -use ffi::*; -use glib::translate::{FromGlibPtrFull, FromGlibPtrNone}; -use std::ptr; - mod auto; pub use auto::{traits::*, *}; mod global_context_ref; diff --git a/main/src/string_ref.rs b/main/src/string_ref.rs new file mode 100644 index 0000000..322b2c8 --- /dev/null +++ b/main/src/string_ref.rs @@ -0,0 +1,25 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/vhdirk/gir-files) +// DO NOT EDIT + +glib::wrapper! { + #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] + pub struct StringRef(Shared); + + match fn { + ref => |ptr| ffi::JSStringRetain(*ptr), + unref => |ptr| ffi::JSStringRelease(*ptr), + } +} + +// impl StringRef { +// #[doc(alias = "JSStringGetMaximumUTF8CStringSize")] +// pub fn maximum_utf8_cstring_size(&self) -> usize { +// unsafe { ffi::JSStringGetMaximumUTF8CStringSize(*self.to_glib_none().0) } +// } + +// // #[doc(alias = "JSStringGetUTF8CString")] +// // pub fn getUTF8CString(&self, buffer: glib::GString, buffer_size: usize) -> usize { +// // unsafe { ffi::JSStringGetUTF8CString(*self.to_glib_none().0, buffer.to_glib_f) } +// // } +// } diff --git a/src/value_ref.rs b/main/src/value_ref.rs similarity index 100% rename from src/value_ref.rs rename to main/src/value_ref.rs diff --git a/src/string_ref.rs b/src/string_ref.rs deleted file mode 100644 index 8bfae89..0000000 --- a/src/string_ref.rs +++ /dev/null @@ -1,27 +0,0 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir) -// from gir-files (https://github.com/vhdirk/gir-files) -// DO NOT EDIT - -use glib::translate::*; - -glib::wrapper! { - #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct StringRef(Shared); - - match fn { - ref => |ptr| ffi::JSStringRetain(*ptr), - unref => |ptr| ffi::JSStringRelease(*ptr), - } -} - -impl StringRef { - #[doc(alias = "JSStringGetMaximumUTF8CStringSize")] - pub fn maximum_utf8_cstring_size(&self) -> usize { - unsafe { ffi::JSStringGetMaximumUTF8CStringSize(*self.to_glib_none().0) } - } - - // #[doc(alias = "JSStringGetUTF8CString")] - // pub fn getUTF8CString(&self, buffer: glib::GString, buffer_size: usize) -> usize { - // unsafe { ffi::JSStringGetUTF8CString(*self.to_glib_none().0, buffer.to_glib_f) } - // } -} diff --git a/sys/Cargo.toml b/sys/Cargo.toml index d85ed97..f2e01f9 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -1,39 +1,36 @@ [package] -name = "javascriptcore-rs-sys" -version = "0.4.0" -authors = [ "The Gtk-rs Project Developers" ] -description = "Sys functions for the Rust bindings of the javacriptcore library" -repository = "https://github.com/tauri-apps/javascriptcore-rs" -license = "MIT" -keywords = [ "javascript", "gtk-rs", "gnome" ] +authors = ["The Gtk-rs Project Developers"] build = "build.rs" -edition = "2018" +description = "Sys functions for the Rust bindings of the javacriptcore library" +edition = "2021" +keywords = ["javascript", "gtk-rs", "gnome"] +license = "MIT" +name = "javascriptcore-rs-sys" +repository = "https://github.com/tauri-apps/javascriptcore-rs" +version = "0.4.0" [package.metadata.system-deps.javascriptcoregtk_4_0] -name = "javascriptcoregtk-4.0" -version = "2.24" - - [package.metadata.system-deps.javascriptcoregtk_4_0.v2_28] - version = "2.28" +name = "javascriptcoregtk-4.1" +version = "2.38" [package.metadata.docs.rs] -features = [ "dox" ] +features = ["dox"] [lib] name = "javascriptcore_rs_sys" [dependencies] +glib-sys = "^0.16" +gobject-sys = "^0.16" libc = "0.2" -glib-sys = "^0.15" -gobject-sys = "^0.15" [build-dependencies] -system-deps = "5" +system-deps = "6" [dev-dependencies] shell-words = "1.0.0" tempfile = "3" [features] -v2_28 = [ ] -dox = [ ] +dox = [] +v2_28 = [] diff --git a/sys/tests/abi.rs b/sys/tests/abi.rs index 01f00c7..286f845 100644 --- a/sys/tests/abi.rs +++ b/sys/tests/abi.rs @@ -2,7 +2,7 @@ // from gir-files (https://github.com/vhdirk/gir-files @ 5c5c482b7f4a) // DO NOT EDIT -use javascriptcore_sys::*; +use javascriptcore_rs_sys::*; use std::{ env, error::Error, @@ -14,7 +14,7 @@ use std::{ }; use tempfile::Builder; -static PACKAGES: &[&str] = &["javascriptcoregtk-4.0"]; +static PACKAGES: &[&str] = &["javascriptcoregtk-4.1"]; #[derive(Clone, Debug)] struct Compiler { @@ -317,6 +317,7 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &[ ), ]; +// It'd be nice to have a bit more documentation on this const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) JSC_CHECK_SYNTAX_MODE_MODULE", "1"), ("(gint) JSC_CHECK_SYNTAX_MODE_SCRIPT", "0"), @@ -330,8 +331,8 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ "3", ), ("JSC_MAJOR_VERSION", "2"), - ("JSC_MICRO_VERSION", "1"), - ("JSC_MINOR_VERSION", "34"), + ("JSC_MICRO_VERSION", "2"), + ("JSC_MINOR_VERSION", "38"), ("JSC_OPTIONS_USE_DFG", "useDFGJIT"), ("JSC_OPTIONS_USE_FTL", "useFTLJIT"), ("JSC_OPTIONS_USE_JIT", "useJIT"),