FlightGear next
NasalTranslations.cxx
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Florent Rougon
2// SPDX-License-Identifier: GPL-2.0-or-later
3
8
9#include <memory>
10#include <string>
11
12#include <simgear/nasal/cppbind/Ghost.hxx>
13#include <simgear/nasal/cppbind/NasalCallContext.hxx>
14#include <simgear/nasal/cppbind/NasalHash.hxx>
15#include <simgear/nasal/nasal.h>
16
20
21namespace flightgear
22{
23
24static naRef f_new_FGTranslate(const nasal::CallContext& ctx)
25{
26 using FGTranslateRef = std::shared_ptr<FGTranslate>;
27 std::string domain;
28
29 switch (ctx.argc) {
30 case 0:
31 return ctx.to_nasal(FGTranslateRef(new FGTranslate()));
32 case 1:
33 domain = ctx.requireArg<std::string>(0);
34 return ctx.to_nasal(FGTranslateRef(new FGTranslate(std::move(domain))));
35 default:
36 ctx.runtimeError("FGTranslate.new() or FGTranslate.new(domain)");
37 }
38
39 return {}; // unreachable
40}
41
42void initNasalTranslations(naRef globals, naContext c)
43{
44 nasal::Hash globalsModule(globals, c);
45 nasal::Hash fgTranslateModule = globalsModule.createHash("FGTranslate");
46
47 fgTranslateModule.set("new", &f_new_FGTranslate);
48
52}
53
54} // of namespace flightgear
Class for retrieving translated strings.
Container class for related translation units.
Container class for a string and its translation.
Class for retrieving translated strings.
static void setupGhost()
Set up a Nasal type that wraps FGTranslate.
static void setupGhost()
Set up a Nasal type that wraps TranslationResource.
static void setupGhost()
Set up a Nasal type that wraps TranslationUnit.
FGGlobals * globals
Definition globals.cxx:142
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
void initNasalTranslations(naRef globals, naContext c)
static naRef f_new_FGTranslate(const nasal::CallContext &ctx)