Update dependencies + move the code around a bit

This commit is contained in:
Demir Yerli
2022-11-25 20:26:25 +03:00
parent 693def0975
commit 6038c956d5
19 changed files with 81 additions and 89 deletions

View File

@@ -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"]

27
main/Cargo.toml Normal file
View File

@@ -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"]

View File

@@ -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::<Context>(&properties).expect("Failed to create an instance of Context")
glib::Object::new::<Context>(&properties)
}
pub fn virtual_machine(mut self, virtual_machine: &impl IsA<VirtualMachine>) -> Self {

View File

@@ -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::<Value>(&properties).expect("Failed to create an instance of Value")
glib::Object::new::<Value>(&properties)
}
pub fn context(mut self, context: &impl IsA<Context>) -> Self {

View File

@@ -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::<Self>(&[])
.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::<WeakValue>(&properties).expect("Failed to create an instance of WeakValue")
glib::Object::new::<WeakValue>(&properties)
}
pub fn value(mut self, value: &impl IsA<Value>) -> Self {

View File

@@ -1,6 +1,5 @@
use ffi::*;
use glib::translate::*;
use std::ptr;
pub struct GlobalContextRef {
raw: JSGlobalContextRef,

View File

@@ -3,10 +3,6 @@
// // Licensed under the MIT license, see the LICENSE file or <https://opensource.org/licenses/MIT>
#![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;

25
main/src/string_ref.rs Normal file
View File

@@ -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<ffi::JSStringRef>);
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) }
// // }
// }

View File

@@ -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<ffi::JSStringRef>);
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) }
// }
}

View File

@@ -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 = []

View File

@@ -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"),