Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
AngelScriptBindings.cpp
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5 Copyright 2013-2022 Petr Ohlidal
6
7 For more information, see http://www.rigsofrods.org/
8
9 Rigs of Rods is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 3, as
11 published by the Free Software Foundation.
12
13 Rigs of Rods is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#pragma once
23
24#include "AngelScriptBindings.h"
25#include "Console.h"
26
27namespace RoR {
28
29void RegisterAngelScriptBinding(const char* bindingName, AngelScript::asIScriptEngine* engine, ASBindingRegisterFunc_t native, ASBindingRegisterFunc_t generic)
30{
31 // If diag_angelscript_generic_bind_test is true, we will try to register generic bindings, or fall back
32 // to native bindings if not available. For testing purposes only!
33 bool max_portability = strstr(AngelScript::asGetLibraryOptions(), "AS_MAX_PORTABILITY") || App::diag_angelscript_generic_bind_test->getBool();
34 ASBindingRegisterFunc_t register_func = max_portability ? generic : native;
35 if (max_portability && !generic && App::diag_angelscript_generic_bind_test->getBool())
36 {
37 max_portability = false;
38 register_func = native;
40 fmt::format("[AngelScriptBindings] Warning: Generic bindings not available for {}, falling back to native bindings", bindingName));
41 }
42
43 if (register_func)
44 {
45 register_func(engine);
46 }
47 else if (max_portability) // Max portability is enabled, no generic binding func specified
48 {
50 fmt::format("[AngelScriptBindings] Warning: Generic bindings not available for {}", bindingName));
51 }
52 else // Max portability is disabled, no native binding func specified
53 {
55 fmt::format("[AngelScriptBindings] Warning: Native bindings not available for {}", bindingName));
56 }
57}
58
59} // namespace RoR
bool getBool() const
Definition CVar.h:98
@ CONSOLE_MSGTYPE_LOG
Logfile echo.
Definition Console.h:61
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
Definition Console.cpp:103
@ CONSOLE_SYSTEM_WARNING
Definition Console.h:53
Console * GetConsole()
CVar * diag_angelscript_generic_bind_test
void RegisterAngelScriptBinding(const char *bindingName, AngelScript::asIScriptEngine *engine, ASBindingRegisterFunc_t native, ASBindingRegisterFunc_t generic)
void(* ASBindingRegisterFunc_t)(AngelScript::asIScriptEngine *)