From 512b1d5aedd365cbbe6709ae70f29168ca6d0f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Sun, 30 Sep 2018 12:36:29 +0300 Subject: [PATCH] Scripting|libcore: Checking if a particular native module exists --- doomsday/sdk/libcore/include/de/scriptsys/scriptsystem.h | 2 ++ doomsday/sdk/libcore/src/scriptsys/scriptsystem.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/doomsday/sdk/libcore/include/de/scriptsys/scriptsystem.h b/doomsday/sdk/libcore/include/de/scriptsys/scriptsystem.h index a8c709f07a..a5f0d5e562 100644 --- a/doomsday/sdk/libcore/include/de/scriptsys/scriptsystem.h +++ b/doomsday/sdk/libcore/include/de/scriptsys/scriptsystem.h @@ -68,6 +68,8 @@ class DENG2_PUBLIC ScriptSystem : public System void removeNativeModule(String const &name); + bool nativeModuleExists(const String &name) const; + Record &nativeModule(String const &name); /** diff --git a/doomsday/sdk/libcore/src/scriptsys/scriptsystem.cpp b/doomsday/sdk/libcore/src/scriptsys/scriptsystem.cpp index 0ef9da1805..79c46f3d6f 100644 --- a/doomsday/sdk/libcore/src/scriptsys/scriptsystem.cpp +++ b/doomsday/sdk/libcore/src/scriptsys/scriptsystem.cpp @@ -216,6 +216,12 @@ Record &ScriptSystem::nativeModule(String const &name) return *foundNative.value(); } +bool ScriptSystem::nativeModuleExists(const String &name) const +{ + DENG2_GUARD_FOR(d->nativeModules, G); + return d->nativeModules.value.contains(name); +} + StringList ScriptSystem::nativeModules() const { DENG2_GUARD_FOR(d->nativeModules, G);