Skip to content

Commit

Permalink
Implement a macro to help implement GstElements
Browse files Browse the repository at this point in the history
  • Loading branch information
thiblahute committed Jul 20, 2022
1 parent a784483 commit bc61518
Show file tree
Hide file tree
Showing 14 changed files with 722 additions and 13 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use_cairo = ["cairo"]
use_gdk4 = ["gdk4"]
use_gio = ["gio", "gobject-macros/gio"]
use_graphene = ["graphene"]
use_gst = ["gst", "once_cell", "gobject-macros/use_gst"]
use_gsk4 = ["gsk4"]
use_gtk4 = ["gtk4", "gobject-macros/gtk4"]
use_serde = ["serde", "gobject-macros/serde"]
Expand All @@ -23,8 +24,10 @@ glib = { git = "https://github.com/gtk-rs/gtk-rs-core", version = "0.16", featur
graphene = { git = "https://github.com/gtk-rs/gtk-rs-core", version = "0.16", package = "graphene-rs", optional = true }
gsk4 = { git = "https://github.com/gtk-rs/gtk4-rs", version = "0.5", optional = true }
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs", version = "0.5", optional = true }
gst = { git="https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", package = "gstreamer", optional = true }
gobject-macros = { path = "macros" }
serde = { version = "1", features = ["derive"], optional = true }
once_cell = { version = "1.0", optional = true }

[dev-dependencies]
futures-channel = "0.3"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod obj {
#[property(get, set)]
my_prop: std::cell::Cell<u64>,
}

impl MyObj {
#[signal]
fn abc(&self) {}
Expand Down
4 changes: 4 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ edition = "2021"
[lib]
path = "lib.rs"

[features]
use_gst = ["gst"]

[dependencies]
bitflags = "1.3.2"
darling = "0.13.1"
heck = "0.4.0"
proc-macro2 = "1.0.36"
quote = "1.0.16"
syn = { version = "1.0.89", features = ["full", "visit-mut"], default-features = false }
gst = { git="https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", package = "gstreamer", optional = true }
9 changes: 4 additions & 5 deletions core/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote, quote_spanned, ToTokens};
use syn::{parse_quote, parse_quote_spanned, spanned::Spanned};

#[derive(Debug, Default, FromMeta)]
#[derive(Debug, Default, FromMeta, Clone)]
#[darling(default)]
struct Attrs {
pub struct ClassAttrs {
pub name: Option<syn::Ident>,
pub ns: Option<syn::Ident>,
pub class: Option<syn::Ident>,
Expand All @@ -32,7 +32,7 @@ struct Attrs {
pub sync: Flag,
}

impl Attrs {
impl ClassAttrs {
fn validate(&self, errors: &Errors) {
use crate::validations::*;
let abstract_ = ("abstract", check_flag(&self.abstract_));
Expand All @@ -42,7 +42,7 @@ impl Attrs {
}

#[derive(Debug)]
pub struct ClassOptions(Attrs);
pub struct ClassOptions(pub ClassAttrs);

impl ClassOptions {
pub fn parse(tokens: TokenStream, errors: &Errors) -> Self {
Expand Down Expand Up @@ -380,7 +380,6 @@ impl ClassDefinition {
quote_spanned! { Span::mixed_site() =>
let generated_prop_id = id as i64;
}

}
}
#[inline]
Expand Down
1 change: 1 addition & 0 deletions core/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl Capture {
Some(match self {
Self::Strong { ident, from, .. } => {
let target = format_ident!("____strong{}", index, span = Span::mixed_site());

let input = from
.as_ref()
.map(|f| f.to_token_stream())
Expand Down
Loading

0 comments on commit bc61518

Please sign in to comment.