summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorKarroffel <therzog@mail.de>2017-07-27 09:23:21 +0200
committerKarroffel <therzog@mail.de>2017-07-27 11:13:21 +0200
commit135c2112ad87265d35899dede34c3a7e06ec2f54 (patch)
tree87dc648f137a9d0d47766b281427766f621ad48f /drivers
parenta2795e95318f57747dbb86a2a12b3567838b8c7d (diff)
added an optional parameter to OS symbol lookup
When looking up a symbol from a library, previously an error was shown when the symbol did not exist. That caused confusion when the lookup was completely optional. This adds a new parameter to that method so that those errors can be handled manually if needed.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/unix/os_unix.cpp10
-rw-r--r--drivers/unix/os_unix.h2
2 files changed, 8 insertions, 4 deletions
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index d05529ef9a..e424590881 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -453,7 +453,7 @@ Error OS_Unix::close_dynamic_library(void *p_library_handle) {
return OK;
}
-Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle) {
+Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional) {
const char *error;
dlerror(); // Clear existing errors
@@ -461,8 +461,12 @@ Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const S
error = dlerror();
if (error != NULL) {
- ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + error);
- ERR_FAIL_V(ERR_CANT_RESOLVE);
+ if (!p_optional) {
+ ERR_EXPLAIN("Can't resolve symbol " + p_name + ". Error: " + error);
+ ERR_FAIL_V(ERR_CANT_RESOLVE);
+ } else {
+ return ERR_CANT_RESOLVE;
+ }
}
return OK;
}
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index 953b0f0431..fdc6d6e28f 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -85,7 +85,7 @@ public:
virtual Error open_dynamic_library(const String p_path, void *&p_library_handle);
virtual Error close_dynamic_library(void *p_library_handle);
- virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle);
+ virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false);
virtual Error set_cwd(const String &p_cwd);