1#![allow(non_snake_case)] extern crate gdnative_core;
4pub extern crate libc;
5
6pub use gdnative_core::*;
7
8use std::sync::{Once, ONCE_INIT};
9use std::ops::*;
10
11include!(concat!(env!("OUT_DIR"), "/common_types.rs"));
12
13impl NativeScript {
14 pub fn to_rust_script<T: NativeClass>(&self) -> Option<NativeRef<T>> {
16 unsafe {
17 let class = self.get_class_name();
19 let gd_name = GodotString::from_str(T::class_name());
20
21 if class != gd_name {
22 return None;
23 }
24
25 return Some(NativeRef::from_sys(self.this));
26 }
27 }
28
29 pub fn from_rust_script<T: NativeClass>(script: NativeRef<T>) -> NativeScript {
31 unsafe {
32 NativeScript::from_sys(script.sys())
33 }
34 }
35}