nsi_core/
lib.rs

1#![cfg_attr(feature = "nightly", feature(doc_cfg))]
2#![allow(non_snake_case)]
3//#![warn(missing_docs)]
4//#![warn(missing_doc_code_examples)]
5
6use nsi_sys::*;
7
8pub mod node;
9pub use node::*;
10
11#[cfg(feature = "ustr_handles")]
12mod handle_ustr;
13#[cfg(feature = "ustr_handles")]
14use handle_ustr::HandleString;
15
16#[cfg(not(feature = "ustr_handles"))]
17mod handle_cstring;
18#[cfg(not(feature = "ustr_handles"))]
19use handle_cstring::HandleString;
20
21// Crate features -----------------------------------------------------
22
23#[cfg(not(feature = "link_lib3delight"))]
24mod dynamic;
25#[cfg(feature = "link_lib3delight")]
26mod linked;
27
28#[cfg(not(feature = "link_lib3delight"))]
29use self::dynamic as api;
30#[cfg(feature = "link_lib3delight")]
31use self::linked as api;
32
33// API initalization/on-demand loading of lib3delight -----------------
34
35#[macro_use]
36extern crate lazy_static;
37
38#[cfg(not(feature = "manual_init"))]
39lazy_static! {
40    static ref NSI_API: api::ApiImpl =
41        api::ApiImpl::new().expect("Could not load lib3delight");
42}
43
44// Default modules ----------------------------------------------------
45
46#[macro_use]
47pub mod argument;
48pub use argument::*;
49
50// Context should be in the crate root so we keep the module private.
51pub mod context;
52pub use context::*;
53
54#[cfg(feature = "output")]
55pub mod output;
56
57#[cfg(feature = "output")]
58pub use output::*;
59
60mod tests;
61
62trait Api {
63    fn NSIBegin(
64        &self,
65        nparams: ::std::os::raw::c_int,
66        params: *const NSIParam,
67    ) -> NSIContext;
68    fn NSIEnd(&self, ctx: NSIContext);
69    fn NSICreate(
70        &self,
71        ctx: NSIContext,
72        handle: NSIHandle,
73        type_: *const ::std::os::raw::c_char,
74        nparams: ::std::os::raw::c_int,
75        params: *const NSIParam,
76    );
77    fn NSIDelete(
78        &self,
79        ctx: NSIContext,
80        handle: NSIHandle,
81        nparams: ::std::os::raw::c_int,
82        params: *const NSIParam,
83    );
84    fn NSISetAttribute(
85        &self,
86        ctx: NSIContext,
87        object: NSIHandle,
88        nparams: ::std::os::raw::c_int,
89        params: *const NSIParam,
90    );
91    fn NSISetAttributeAtTime(
92        &self,
93        ctx: NSIContext,
94        object: NSIHandle,
95        time: f64,
96        nparams: ::std::os::raw::c_int,
97        params: *const NSIParam,
98    );
99    fn NSIDeleteAttribute(
100        &self,
101        ctx: NSIContext,
102        object: NSIHandle,
103        name: *const ::std::os::raw::c_char,
104    );
105    #[allow(clippy::too_many_arguments)]
106    fn NSIConnect(
107        &self,
108        ctx: NSIContext,
109        from: NSIHandle,
110        from_attr: *const ::std::os::raw::c_char,
111        to: NSIHandle,
112        to_attr: *const ::std::os::raw::c_char,
113        nparams: ::std::os::raw::c_int,
114        params: *const NSIParam,
115    );
116    fn NSIDisconnect(
117        &self,
118        ctx: NSIContext,
119        from: NSIHandle,
120        from_attr: *const ::std::os::raw::c_char,
121        to: NSIHandle,
122        to_attr: *const ::std::os::raw::c_char,
123    );
124    fn NSIEvaluate(
125        &self,
126        ctx: NSIContext,
127        nparams: ::std::os::raw::c_int,
128        params: *const NSIParam,
129    );
130    fn NSIRenderControl(
131        &self,
132        ctx: NSIContext,
133        nparams: ::std::os::raw::c_int,
134        params: *const NSIParam,
135    );
136
137    #[cfg(feature = "output")]
138    fn DspyRegisterDriver(
139        &self,
140        driver_name: *const ::std::os::raw::c_char,
141        p_open: ndspy_sys::PtDspyOpenFuncPtr,
142        p_write: ndspy_sys::PtDspyWriteFuncPtr,
143        p_close: ndspy_sys::PtDspyCloseFuncPtr,
144        p_query: ndspy_sys::PtDspyQueryFuncPtr,
145    ) -> ndspy_sys::PtDspyError;
146}