25#include <simgear/nasal/cppbind/Ghost.hxx>
26#include <simgear/nasal/cppbind/NasalCallContext.hxx>
27#include <simgear/nasal/cppbind/NasalHash.hxx>
28#include <simgear/nasal/nasal.h>
29#include <simgear/structure/exception.hxx>
52 throw sg_exception(
"trying to access the AddonManager from Nasal, "
53 "however it is not initialized");
62 return ctx.to_nasal(addonMgr->registeredAddons());
68 std::string addonId = ctx.requireArg<std::string>(0);
69 return ctx.to_nasal(addonMgr->isAddonRegistered(addonId));
75 return ctx.to_nasal(addonMgr->loadedAddons());
81 std::string addonId = ctx.requireArg<std::string>(0);
82 return ctx.to_nasal(addonMgr->isAddonLoaded(addonId));
88 return ctx.to_nasal(addonMgr->getAddon(ctx.requireArg<std::string>(0)));
121 int major = 0, minor = 0, patchLevel = 0;
124 if (ctx.argc == 0 || ctx.argc > 4) {
126 "AddonVersion.new(versionString) or "
127 "AddonVersion.new(major[, minor[, patchLevel[, suffix]]])"
132 naRef arg1 = ctx.args[0];
134 if (naIsString(arg1)) {
136 }
else if (naIsNum(arg1)) {
139 return ctx.to_nasal(std::move(ref));
142 "AddonVersion.new(versionString) or "
143 "AddonVersion.new(major[, minor[, patchLevel[, suffix]]])"
148 assert(ctx.argc > 0);
149 if (!ctx.isNumeric(0)) {
151 "addons.AddonVersion.new() requires major number as an integer"
155 major = ctx.requireArg<
int>(0);
158 if (!ctx.isNumeric(1)) {
160 "addons.AddonVersion.new() requires minor number as an integer"
164 minor = ctx.requireArg<
int>(1);
168 if (!ctx.isNumeric(2)) {
170 "addons.AddonVersion.new() requires patch level as an integer"
174 patchLevel = ctx.requireArg<
int>(2);
178 if (!ctx.isString(3)) {
180 "addons.AddonVersion.new() requires suffix as a string"
184 suffix = ctx.requireArg<std::string>(3);
187 assert(ctx.argc <= 4);
196 nasal::Hash globalsModule(
globals, c);
197 nasal::Hash addonsModule = globalsModule.createHash(
"addons");
static const std::unique_ptr< AddonManager > & instance()
static void setupGhost(nasal::Hash &addonsModule)
static void setupGhost(nasal::Hash &addonsModule)
static void setupGhost(nasal::Hash &addonsModule)
static void setupGhost(nasal::Hash &addonsModule)
void initAddonClassesForNasal(naRef globals, naContext c)
static const std::unique_ptr< AddonManager > & getAddonMgrWithCheck()
static void wrapAddonManagerMethods(nasal::Hash &addonsModule)
static naRef f_loadedAddons(const nasal::CallContext &ctx)
naRef f_createAddonVersion(const nasal::CallContext &ctx)
static naRef f_getAddon(const nasal::CallContext &ctx)
static naRef f_isAddonRegistered(const nasal::CallContext &ctx)
static naRef f_registeredAddons(const nasal::CallContext &ctx)
SGSharedPtr< AddonVersion > AddonVersionRef
static naRef f_isAddonLoaded(const nasal::CallContext &ctx)
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...