File tree 4 files changed +61
-4
lines changed 4 files changed +61
-4
lines changed Original file line number Diff line number Diff line change @@ -319,10 +319,10 @@ fn make_godot_properties_impl(
319
319
let variant_type = property_info. variant_type ;
320
320
quote ! {
321
321
let class_name = StringName :: from( #class_name:: CLASS_NAME ) ;
322
- let property_info = PropertyInfo :: new(
322
+ let property_info = :: godot :: builtin :: meta :: PropertyInfo :: new(
323
323
//#variant_type,
324
- :: godot_ffi :: VariantType :: Int ,
325
- :: godot_core :: builtin:: meta:: ClassName :: new:: <#class_name>( ) ,
324
+ :: godot :: sys :: VariantType :: Int ,
325
+ :: godot :: builtin:: meta:: ClassName :: new:: <#class_name>( ) ,
326
326
StringName :: from( #name) ,
327
327
) ;
328
328
let property_info_sys = property_info. property_sys( ) ;
Original file line number Diff line number Diff line change 4
4
5
5
extends Node
6
6
7
+
7
8
func run () -> bool :
8
9
print ("[GD] Test ManualFfi..." )
9
10
var ok = true
10
11
# ok = ok && test_missing_init()
11
12
ok = ok && test_to_string ()
13
+ ok = ok && test_property ()
12
14
13
15
print ("[GD] ManualFfi tested (passed=" , ok , ")" )
14
16
return ok
15
17
18
+
16
19
func test_missing_init () -> bool :
17
20
var obj = WithoutInit .new ()
18
21
print ("[GD] WithoutInit is: " , obj )
19
22
return true
20
23
24
+
25
+ func test_property () -> bool :
26
+ var obj = HasProperty .new ()
27
+ obj .val = 5
28
+ print ("[GD] HasProperty's property is: " , obj .val , " and should be 5" )
29
+ return obj .val == 5
30
+
31
+
21
32
func test_to_string () -> bool :
22
33
var ffi = VirtualMethodTest .new ()
23
34
var s = str (ffi )
24
35
25
36
print ("to_string: " , s )
26
37
print ("to_string: " , ffi )
27
- return true
38
+ return true
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ mod enum_test;
14
14
mod gdscript_ffi_test;
15
15
mod node_test;
16
16
mod object_test;
17
+ mod property_test;
17
18
mod singleton_test;
18
19
mod string_test;
19
20
mod utilities_test;
@@ -27,6 +28,7 @@ fn run_tests() -> bool {
27
28
ok &= node_test:: run ( ) ;
28
29
ok &= enum_test:: run ( ) ;
29
30
ok &= object_test:: run ( ) ;
31
+ ok &= property_test:: run ( ) ;
30
32
ok &= singleton_test:: run ( ) ;
31
33
ok &= string_test:: run ( ) ;
32
34
ok &= utilities_test:: run ( ) ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * This Source Code Form is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+
7
+ use crate :: itest;
8
+ use godot:: prelude:: * ;
9
+
10
+ pub ( crate ) fn run ( ) -> bool {
11
+ let mut ok = true ;
12
+ // No tests currently, tests using HasProperty are in Godot scripts.
13
+
14
+ ok
15
+ }
16
+
17
+ #[ derive( GodotClass ) ]
18
+ #[ class( base=Node ) ]
19
+ #[ property( name = "val" , getter = "get_val" , setter = "set_val" ) ]
20
+ struct HasProperty {
21
+ val : i32 ,
22
+ #[ base]
23
+ base : Base < Node > ,
24
+ }
25
+
26
+ #[ godot_api]
27
+ impl HasProperty {
28
+ #[ func]
29
+ pub fn get_val ( & self ) -> i32 {
30
+ return self . val ;
31
+ }
32
+
33
+ #[ func]
34
+ pub fn set_val ( & mut self , val : i32 ) {
35
+ self . val = val;
36
+ }
37
+ }
38
+
39
+ #[ godot_api]
40
+ impl GodotExt for HasProperty {
41
+ fn init ( base : Base < Node > ) -> Self {
42
+ HasProperty { val : 0 , base }
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments