Browse Source

Merge pull request #9952 from endragor/pass-gdnative-library

Pass GDNativeLibrary pointer to library init
Thomas Herzog 8 năm trước cách đây
mục cha
commit
fc611f4b4c
2 tập tin đã thay đổi với 4 bổ sung0 xóa
  1. 3 0
      modules/gdnative/gdnative.cpp
  2. 1 0
      modules/gdnative/godot/gdnative.h

+ 3 - 0
modules/gdnative/gdnative.cpp

@@ -185,6 +185,8 @@ void GDNative::_bind_methods() {
 }
 
 void GDNative::set_library(Ref<GDNativeLibrary> p_library) {
+	ERR_EXPLAIN("Tried to change library of GDNative when it is already set");
+	ERR_FAIL_COND(library.is_valid());
 	library = p_library;
 }
 
@@ -229,6 +231,7 @@ bool GDNative::initialize() {
 	options.core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
 	options.editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR);
 	options.no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE);
+	options.gd_native_library = (godot_object *)(get_library().ptr());
 
 	library_init_fpointer(&options);
 

+ 1 - 0
modules/gdnative/godot/gdnative.h

@@ -265,6 +265,7 @@ typedef struct {
 	uint64_t core_api_hash;
 	uint64_t editor_api_hash;
 	uint64_t no_api_hash;
+	godot_object *gd_native_library; // pointer to GDNativeLibrary that is being initialized
 } godot_gdnative_init_options;
 
 typedef struct {