Run script test

This commit is contained in:
O01eg
2020-11-28 13:08:17 +03:00
parent c55ef5adcf
commit 279d63d6c5
8 changed files with 99 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ opts.Add(EnumVariable('platform', "Compilation platform", host_platform, ['', 'w
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", host_platform, ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(EnumVariable('bits', 'Target platform bits', '64', ('32', '64')))
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/bin/', PathVariable.PathAccept))
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'bin/', PathVariable.PathAccept))
opts.Add(PathVariable('target_name', 'The library name.', 'libgdexample', PathVariable.PathAccept))
# Local dependency paths, adapt them to your setup

View File

@@ -1,2 +0,0 @@
*
!.gitignore

20
test/gdexample.gdnlib Normal file
View File

@@ -0,0 +1,20 @@
[general]
singleton=false
load_once=true
symbol_prefix="godot_"
reloadable=false
[entry]
X11.64="res://bin/x11/libgdexample.so"
Server.64="res://bin/x11/libgdexample.so"
Windows.64="res://bin/win64/libgdexample.dll"
OSX.64="res://bin/osx/libgdexample.dylib"
[dependencies]
X11.64=[]
Server.64=[]
Windows.64=[]
OSX.64=[]

9
test/gdexample.gdns Normal file
View File

@@ -0,0 +1,9 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://gdexample.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "gdexample"
class_name = "SimpleClass"
library = ExtResource( 1 )

19
test/project.godot Normal file
View File

@@ -0,0 +1,19 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Test CI project"

30
test/script.gd Normal file
View File

@@ -0,0 +1,30 @@
extends MainLoop
func _initialize():
OS.exit_code = 1
var native_script = load("res://gdexample.gdns")
print("Native Script ", native_script)
if native_script == null || !is_instance_valid(native_script):
return
print("Library ", native_script.library)
if native_script.library == null || !is_instance_valid(native_script.library):
return
var ref = native_script.new()
print("Reference ", ref)
if ref == null || !is_instance_valid(ref):
return
print("Reference name ", ref.name)
if ref.name != "SimpleClass":
return
print("Reference value ", ref.value)
if ref.value != 0:
return
print("Call method ", ref.method(1))
if ref.method(1) != 1:
return
OS.exit_code = 0
func _idle(_delta):
return true

View File

@@ -10,7 +10,10 @@ public:
SimpleClass() {}
/** `_init` must exist as it is called by Godot. */
void _init() {}
void _init() {
_name = String("SimpleClass");
_value = 0;
}
void test_void_method() {
Godot::print("This is test");
@@ -30,10 +33,10 @@ public:
* The line below is equivalent to the following GDScript export:
* export var _name = "SimpleClass"
**/
register_property<SimpleClass, String>("base/name", &SimpleClass::_name, String("SimpleClass"));
register_property<SimpleClass, String>("name", &SimpleClass::_name, String("SimpleClass"));
/** Alternatively, with getter and setter methods: */
register_property<SimpleClass, int>("base/value", &SimpleClass::set_value, &SimpleClass::get_value, 0);
register_property<SimpleClass, int>("value", &SimpleClass::set_value, &SimpleClass::get_value, 0);
/** Registering a signal: **/
register_signal<SimpleClass>("signal_name0"); // windows: error C2668: 'godot::register_signal': ambiguous call to overloaded function