-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathpython_model.rs
33 lines (27 loc) · 957 Bytes
/
python_model.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use neon::prelude::*;
use crate::cross::{CLRepr, CLReprObject, CLReprObjectKind};
pub struct CubePythonModel {
functions: CLReprObject,
variables: CLReprObject,
filters: CLReprObject,
}
impl CubePythonModel {
pub fn new(functions: CLReprObject, variables: CLReprObject, filters: CLReprObject) -> Self {
Self {
functions,
variables,
filters,
}
}
}
impl Finalize for CubePythonModel {}
impl CubePythonModel {
#[allow(clippy::wrong_self_convention)]
pub fn to_object<'a, C: Context<'a>>(self, cx: &mut C) -> JsResult<'a, JsValue> {
let mut obj = CLReprObject::new(CLReprObjectKind::Object);
obj.insert("functions".to_string(), CLRepr::Object(self.functions));
obj.insert("variables".to_string(), CLRepr::Object(self.variables));
obj.insert("filters".to_string(), CLRepr::Object(self.filters));
CLRepr::Object(obj).into_js(cx)
}
}