RigsofRods
Soft-body Physics Simulation
ConsoleAngelscript.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 #include "Console.h"
23 #include "AngelScriptBindings.h"
24 #include <angelscript.h>
25 
26 using namespace AngelScript;
27 
28 void RoR::RegisterConsole(asIScriptEngine *engine)
29 {
30  int result;
31 
32  // class CVar
33  result = engine->RegisterObjectType("CVarClass", sizeof(Console), asOBJ_REF | asOBJ_NOCOUNT); ROR_ASSERT(result>=0);
34  result = engine->RegisterObjectMethod("CVarClass", "const string& getName()", asMETHOD(CVar,getName), asCALL_THISCALL); ROR_ASSERT(result>=0);
35  result = engine->RegisterObjectMethod("CVarClass", "const string& getStr()", asMETHOD(CVar,getStr), asCALL_THISCALL); ROR_ASSERT(result>=0);
36  result = engine->RegisterObjectMethod("CVarClass", "int getInt()", asMETHOD(CVar,getInt), asCALL_THISCALL); ROR_ASSERT(result>=0);
37  result = engine->RegisterObjectMethod("CVarClass", "float getFloat()", asMETHOD(CVar,getFloat), asCALL_THISCALL); ROR_ASSERT(result>=0);
38  result = engine->RegisterObjectMethod("CVarClass", "bool getBool()", asMETHOD(CVar,getBool), asCALL_THISCALL); ROR_ASSERT(result>=0);
39 
40  // enum CVarFlags
41  result = engine->RegisterEnum("CVarFlags"); ROR_ASSERT(result >= 0);
42  result = engine->RegisterEnumValue("CVarFlags", "CVAR_TYPE_BOOL", CVAR_TYPE_BOOL); ROR_ASSERT(result >= 0);
43  result = engine->RegisterEnumValue("CVarFlags", "CVAR_TYPE_INT", CVAR_TYPE_INT); ROR_ASSERT(result >= 0);
44  result = engine->RegisterEnumValue("CVarFlags", "CVAR_TYPE_FLOAT", CVAR_TYPE_FLOAT); ROR_ASSERT(result >= 0);
45  result = engine->RegisterEnumValue("CVarFlags", "CVAR_ARCHIVE", CVAR_ARCHIVE); ROR_ASSERT(result >= 0);
46  result = engine->RegisterEnumValue("CVarFlags", "CVAR_NO_LOG", CVAR_NO_LOG); ROR_ASSERT(result >= 0);
47 
48  // class Console
49  result = engine->RegisterObjectType("ConsoleClass", sizeof(Console), asOBJ_REF | asOBJ_NOCOUNT); ROR_ASSERT(result>=0);
50  result = engine->RegisterObjectMethod("ConsoleClass", "CVarClass @cVarCreate(const string &in, const string &in, int, const string &in)", asMETHOD(Console,cVarCreate), asCALL_THISCALL); ROR_ASSERT(result>=0);
51  result = engine->RegisterObjectMethod("ConsoleClass", "CVarClass @cVarFind(const string &in)", asMETHOD(Console,cVarFind), asCALL_THISCALL); ROR_ASSERT(result>=0);
52  result = engine->RegisterObjectMethod("ConsoleClass", "CVarClass @cVarGet(const string &in, int)", asMETHOD(Console,cVarGet), asCALL_THISCALL); ROR_ASSERT(result>=0);
53  result = engine->RegisterObjectMethod("ConsoleClass", "CVarClass @cVarSet(const string &in, const string &in)", asMETHOD(Console,cVarSet), asCALL_THISCALL); ROR_ASSERT(result>=0);
54  result = engine->RegisterObjectMethod("ConsoleClass", "void cVarAssign(CVarClass@, const string &in)", asMETHOD(Console,cVarAssign), asCALL_THISCALL); ROR_ASSERT(result>=0);
55 
56 }
ROR_ASSERT
#define ROR_ASSERT(_EXPR)
Definition: Application.h:40
RoR::CVAR_NO_LOG
@ CVAR_NO_LOG
Will not be written to RoR.log.
Definition: CVar.h:42
AngelScriptBindings.h
RoR::RegisterConsole
void RegisterConsole(AngelScript::asIScriptEngine *engine)
Registers RoR::Console, defined in ConsoleAngelscript.cpp.
Console.h
RoR::CVAR_ARCHIVE
@ CVAR_ARCHIVE
Will be written to RoR.cfg.
Definition: CVar.h:41
RoR::CVAR_TYPE_BOOL
@ CVAR_TYPE_BOOL
Definition: CVar.h:38
RoR::CVAR_TYPE_INT
@ CVAR_TYPE_INT
Definition: CVar.h:39
RoR::CVAR_TYPE_FLOAT
@ CVAR_TYPE_FLOAT
Definition: CVar.h:40