use crate::atomutils::*;
pub const LV2_ATOM_URI: &[u8] = b"http://lv2plug.in/ns/ext/atom\0";
pub const LV2_ATOM_URI_STR: &str = "http://lv2plug.in/ns/ext/atom";
pub const LV2_ATOM_PREFIX: &[u8] = b"http://lv2plug.in/ns/ext/atom#\0";
pub const LV2_ATOM_PREFIX_STR: &str = "http://lv2plug.in/ns/ext/atom#";
pub const LV2_ATOM__ATOM: &[u8] = b"http://lv2plug.in/ns/ext/atom#Atom\0";
pub const LV2_ATOM__ATOMPORT: &[u8] = b"http://lv2plug.in/ns/ext/atom#AtomPort\0";
pub const LV2_ATOM__BLANK: &[u8] = b"http://lv2plug.in/ns/ext/atom#Blank\0";
pub const LV2_ATOM__BOOL: &[u8] = b"http://lv2plug.in/ns/ext/atom#Bool\0";
pub const LV2_ATOM__CHUNK: &[u8] = b"http://lv2plug.in/ns/ext/atom#Chunk\0";
pub const LV2_ATOM__DOUBLE: &[u8] = b"http://lv2plug.in/ns/ext/atom#Double\0";
pub const LV2_ATOM__EVENT: &[u8] = b"http://lv2plug.in/ns/ext/atom#Event\0";
pub const LV2_ATOM__FLOAT: &[u8] = b"http://lv2plug.in/ns/ext/atom#Float\0";
pub const LV2_ATOM__INT: &[u8] = b"http://lv2plug.in/ns/ext/atom#Int\0";
pub const LV2_ATOM__LITERAL: &[u8] = b"http://lv2plug.in/ns/ext/atom#Literal\0";
pub const LV2_ATOM__LONG: &[u8] = b"http://lv2plug.in/ns/ext/atom#Long\0";
pub const LV2_ATOM__NUMBER: &[u8] = b"http://lv2plug.in/ns/ext/atom#Number\0";
pub const LV2_ATOM__OBJECT: &[u8] = b"http://lv2plug.in/ns/ext/atom#Object\0";
pub const LV2_ATOM__PATH: &[u8] = b"http://lv2plug.in/ns/ext/atom#Path\0";
pub const LV2_ATOM__PROPERTY: &[u8] = b"http://lv2plug.in/ns/ext/atom#Property\0";
pub const LV2_ATOM__RESOURCE: &[u8] = b"http://lv2plug.in/ns/ext/atom#Resource\0";
pub const LV2_ATOM__SEQUENCE: &[u8] = b"http://lv2plug.in/ns/ext/atom#Sequence\0";
pub const LV2_ATOM__SOUND: &[u8] = b"http://lv2plug.in/ns/ext/atom#Sound\0";
pub const LV2_ATOM__STRING: &[u8] = b"http://lv2plug.in/ns/ext/atom#String\0";
pub const LV2_ATOM__TUPLE: &[u8] = b"http://lv2plug.in/ns/ext/atom#Tuple\0";
pub const LV2_ATOM__URI: &[u8] = b"http://lv2plug.in/ns/ext/atom#URI\0";
pub const LV2_ATOM__URID: &[u8] = b"http://lv2plug.in/ns/ext/atom#URID\0";
pub const LV2_ATOM__VECTOR: &[u8] = b"http://lv2plug.in/ns/ext/atom#Vector\0";
pub const LV2_ATOM__ATOMTRANSFER: &[u8] = b"http://lv2plug.in/ns/ext/atom#atomTransfer\0";
pub const LV2_ATOM__BEATTIME: &[u8] = b"http://lv2plug.in/ns/ext/atom#beatTime\0";
pub const LV2_ATOM__BUFFERTYPE: &[u8] = b"http://lv2plug.in/ns/ext/atom#bufferType\0";
pub const LV2_ATOM__CHILDTYPE: &[u8] = b"http://lv2plug.in/ns/ext/atom#childType\0";
pub const LV2_ATOM__EVENTTRANSFER: &[u8] = b"http://lv2plug.in/ns/ext/atom#eventTransfer\0";
pub const LV2_ATOM__FRAMETIME: &[u8] = b"http://lv2plug.in/ns/ext/atom#frameTime\0";
pub const LV2_ATOM__SUPPORTS: &[u8] = b"http://lv2plug.in/ns/ext/atom#supports\0";
pub const LV2_ATOM__TIMEUNIT: &[u8] = b"http://lv2plug.in/ns/ext/atom#timeUnit\0";
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2Atom {
pub size: u32,
pub type_: u32,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomInt {
pub atom: LV2Atom,
pub body: i32,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomLong {
pub atom: LV2Atom,
pub body: i64,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomFloat {
pub atom: LV2Atom,
pub body: f32,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomDouble {
pub atom: LV2Atom,
pub body: f64,
}
pub type LV2AtomBool = LV2AtomInt;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomURID {
pub atom: LV2Atom,
pub body: u32,
}
#[repr(C)]
#[derive(Debug)]
pub struct LV2AtomString {
pub atom: LV2Atom,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomLiteralBody {
pub datatype: u32,
pub lang: u32,
}
#[repr(C)]
#[derive(Debug)]
pub struct LV2AtomLiteral {
pub atom: LV2Atom,
pub body: LV2AtomLiteralBody,
}
#[repr(C)]
#[derive(Debug)]
pub struct LV2AtomTuple {
pub atom: LV2Atom,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomVectorBody {
pub child_size: u32,
pub child_type: u32,
}
#[repr(C)]
#[derive(Debug)]
pub struct LV2AtomVector {
pub atom: LV2Atom,
pub body: LV2AtomVectorBody,
}
#[repr(C)]
#[derive(Debug)]
pub struct LV2AtomPropertyBody {
pub key: u32,
pub context: u32,
pub value: LV2Atom,
}
#[repr(C)]
#[derive(Debug)]
pub struct LV2AtomProperty {
pub atom: LV2Atom,
pub body: LV2AtomPropertyBody,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomObjectBody {
pub id: u32,
pub otype: u32,
}
#[repr(C)]
#[derive(Debug)]
pub struct LV2AtomObject {
pub atom: LV2Atom,
pub body: LV2AtomObjectBody,
}
impl LV2AtomObject {
pub unsafe fn foreach<F>(&mut self, mut closure: F)
where
F: FnMut(*mut LV2AtomPropertyBody) -> bool,
{
unsafe {
let body = &self.body;
let mut it = lv2_atom_object_begin(body);
while !lv2_atom_object_is_end(body, self.atom.size, it) {
if closure(it) {
break;
}
it = lv2_atom_object_next(it);
}
}
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomEvent {
pub time_in_frames: i64,
pub body: LV2Atom,
}
impl LV2AtomEvent {
#[inline]
#[must_use]
pub const fn time_as_frames(&self) -> i64 {
self.time_in_frames
}
#[inline]
#[must_use]
pub unsafe fn time_as_beats(&self) -> f64 {
f64::from_bits(i64::cast_unsigned(self.time_in_frames))
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct LV2AtomSequenceBody {
pub unit: u32,
pub pad: u32,
}
#[repr(C)]
#[derive(Debug)]
pub struct LV2AtomSequence {
pub atom: LV2Atom,
pub body: LV2AtomSequenceBody,
}
impl LV2AtomSequence {
pub unsafe fn foreach<F>(&mut self, mut closure: F)
where
F: FnMut(*const LV2AtomEvent),
{
unsafe {
let body = &self.body;
let mut it = lv2_atom_sequence_begin(body);
while !lv2_atom_sequence_is_end(body, self.atom.size, it) {
closure(it);
it = lv2_atom_sequence_next(it);
}
}
}
}