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
34
35
#![allow(non_snake_case)]
extern crate gdnative_core;
pub extern crate libc;
pub use gdnative_core::*;
use std::sync::{Once, ONCE_INIT};
use std::ops::*;
include!(concat!(env!("OUT_DIR"), "/common_types.rs"));
impl NativeScript {
pub fn to_rust_script<T: NativeClass>(&self) -> Option<NativeRef<T>> {
unsafe {
let class = self.get_class_name();
let gd_name = GodotString::from_str(T::class_name());
if class != gd_name {
return None;
}
return Some(NativeRef::from_sys(self.this));
}
}
pub fn from_rust_script<T: NativeClass>(script: NativeRef<T>) -> NativeScript {
unsafe {
NativeScript::from_sys(script.sys())
}
}
}