Skip to content

Commit c94f32a

Browse files
committed
in work
1 parent b4f746e commit c94f32a

File tree

5 files changed

+56
-2
lines changed

5 files changed

+56
-2
lines changed

rust/cubenativeutils/src/wrappers/neon/object/base_types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::{NeonObject, NeonTypeHandle};
2+
use super::primitive_root_holder::*;
23
use crate::wrappers::neon::inner_types::NeonInnerTypes;
34
use std::marker::PhantomData;
45

rust/cubenativeutils/src/wrappers/neon/object/neon_object.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::RootHolder;
22
use crate::wrappers::neon::context::{ContextHolder, SafeCallFn};
3+
use crate::wrappers::object::NativeObject;
34
use cubesql::CubeError;
45
use neon::prelude::*;
56
use std::rc::Rc;
@@ -21,3 +22,42 @@ impl<C: Context<'static> + 'static> NeonObject<C> {
2122
Self { root_holder: root }
2223
}
2324
}
25+
26+
/* impl<C: Context<'static> + 'static> NativeObject<NeonInnerTypes<C>> for NeonObject<C> {
27+
fn get_context(&self) -> ContextHolder<C> {
28+
self.root_holder.ge.clone()
29+
}
30+
31+
fn into_struct(self) -> Result<NeonStruct<C>, CubeError> {
32+
let obj = self.downcast_with_err_msg::<JsObject>("NeonObject is not the JsObject")?;
33+
Ok(NeonStruct::new(obj))
34+
}
35+
fn into_function(self) -> Result<NeonFunction<C>, CubeError> {
36+
let obj = self.downcast_with_err_msg::<JsFunction>("NeonObject is not the JsArray")?;
37+
Ok(NeonFunction::new(obj))
38+
}
39+
fn into_array(self) -> Result<NeonArray<C>, CubeError> {
40+
let obj = self.downcast_with_err_msg::<JsArray>("NeonObject is not the JsArray")?;
41+
Ok(NeonArray::new(obj))
42+
}
43+
fn into_string(self) -> Result<NeonString<C>, CubeError> {
44+
let obj = self.downcast_with_err_msg::<JsString>("NeonObject is not the JsString")?;
45+
Ok(NeonString::new(obj))
46+
}
47+
fn into_number(self) -> Result<NeonNumber<C>, CubeError> {
48+
let obj = self.downcast_with_err_msg::<JsNumber>("NeonObject is not the JsNumber")?;
49+
Ok(NeonNumber::new(obj))
50+
}
51+
fn into_boolean(self) -> Result<NeonBoolean<C>, CubeError> {
52+
let obj = self.downcast_with_err_msg::<JsBoolean>("NeonObject is not the JsBoolean")?;
53+
Ok(NeonBoolean::new(obj))
54+
}
55+
56+
fn is_null(&self) -> Result<bool, CubeError> {
57+
self.is_a::<JsNull>()
58+
}
59+
60+
fn is_undefined(&self) -> Result<bool, CubeError> {
61+
self.is_a::<JsUndefined>()
62+
}
63+
} */

rust/cubenativeutils/src/wrappers/neon/object/object_root_holder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<C: Context<'static> + 'static, V: Object + 'static> ObjectNeonTypeHolder<C,
1818
})
1919
}
2020

21-
fn get_context(&self) -> ContextHolder<C> {
21+
pub fn get_context(&self) -> ContextHolder<C> {
2222
self.context.clone()
2323
}
2424

rust/cubenativeutils/src/wrappers/neon/object/primitive_root_holder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<C: Context<'static> + 'static, V: Value + NeonPrimitiveMapping + 'static>
121121
Ok(Self { context, value })
122122
}
123123

124-
fn get_context(&self) -> ContextHolder<C> {
124+
pub fn get_context(&self) -> ContextHolder<C> {
125125
self.context.clone()
126126
}
127127

rust/cubenativeutils/src/wrappers/neon/object/root_holder.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ impl<C: Context<'static> + 'static> RootHolder<C> {
9595
T::upcast(typed_holder)
9696
}
9797

98+
pub fn get_context(&self) -> ContextHolder<C> {
99+
match self {
100+
Self::Null(v) => v.get_context(),
101+
Self::Undefined(v) => v.get_context(),
102+
Self::Boolean(v) => v.get_context(),
103+
Self::Number(v) => v.get_context(),
104+
Self::String(v) => v.get_context(),
105+
Self::Array(v) => v.get_context(),
106+
Self::Function(v) => v.get_context(),
107+
Self::Struct(v) => v.get_context(),
108+
}
109+
}
110+
98111
define_into_method!(into_null, Null, PrimitiveNeonTypeHolder<C, JsNull>, "Object is not the Null object");
99112
define_into_method!(into_undefined, Undefined, PrimitiveNeonTypeHolder<C, JsUndefined>, "Object is not the Undefined object");
100113
define_into_method!(into_boolean, Boolean, PrimitiveNeonTypeHolder<C, JsBoolean>, "Object is not the Boolean object");

0 commit comments

Comments
 (0)