Rigs of Rods 2023.09
Soft-body Physics Simulation
Loading...
Searching...
No Matches
LocalStorageAngelscript.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 "LocalStorage.h"
23#include "AngelScriptBindings.h"
24
25#include <angelscript.h>
26
27using namespace AngelScript;
28using namespace RoR;
29
30static LocalStorage* LocalStorageFactory(std::string filename, const std::string& section_name, const std::string& rg_name)
31{
32 return new LocalStorage(filename, section_name, rg_name);
33}
34
35void RoR::RegisterLocalStorage(asIScriptEngine *engine)
36{
37 LocalStorage::RegisterRefCountingObject(engine, "LocalStorageClass");
38 LocalStoragePtr::RegisterRefCountingObjectPtr(engine, "LocalStorageClassPtr", "LocalStorageClass");
39
40 int r;
41 r = engine->RegisterObjectBehaviour("LocalStorageClass", asBEHAVE_FACTORY, "LocalStorageClass@+ f(string, const string&in = \"common\", const string&in = \"Cache\")", asFUNCTION(LocalStorageFactory), asCALL_CDECL); ROR_ASSERT(r >= 0);
42
43 r = engine->RegisterObjectMethod("LocalStorageClass", "void copyFrom(LocalStorageClassPtr@)", asMETHOD(LocalStorage,copyFrom), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
44 r = engine->RegisterObjectMethod("LocalStorageClass", "void changeSection(const string &in)", asMETHOD(LocalStorage,changeSection), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
45
46 r = engine->RegisterObjectMethod("LocalStorageClass", "string get(string)", asMETHODPR(LocalStorage,get,(std::string), std::string), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
47 r = engine->RegisterObjectMethod("LocalStorageClass", "string getString(string)", asMETHODPR(LocalStorage,get,(std::string), std::string), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
48 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const string &in)", asMETHODPR(LocalStorage,set,(std::string, const std::string&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
49 r = engine->RegisterObjectMethod("LocalStorageClass", "void setString(string, const string &in)", asMETHODPR(LocalStorage,set,(std::string, const std::string&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
50
51 r = engine->RegisterObjectMethod("LocalStorageClass", "float getFloat(string)", asMETHODPR(LocalStorage,getFloat,(std::string), float), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
52 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, float)", asMETHODPR(LocalStorage,set,(std::string, const float),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
53 r = engine->RegisterObjectMethod("LocalStorageClass", "void setFloat(string, float)", asMETHODPR(LocalStorage,set,(std::string, const float),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
54
55 r = engine->RegisterObjectMethod("LocalStorageClass", "vector3 getVector3(string)", asMETHODPR(LocalStorage,getVector3,(std::string), Ogre::Vector3), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
56 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const vector3 &in)", asMETHODPR(LocalStorage,set,(std::string, const Ogre::Vector3&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
57 r = engine->RegisterObjectMethod("LocalStorageClass", "void setVector3(string, const vector3 &in)", asMETHODPR(LocalStorage,set,(std::string, const Ogre::Vector3&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
58
59 r = engine->RegisterObjectMethod("LocalStorageClass", "radian getRadian(string)", asMETHODPR(LocalStorage,getRadian,(std::string), Ogre::Radian), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
60 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const radian &in)", asMETHODPR(LocalStorage,set,(std::string, const Ogre::Radian&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
61 r = engine->RegisterObjectMethod("LocalStorageClass", "void setRadian(string, const radian &in)", asMETHODPR(LocalStorage,set,(std::string, const Ogre::Radian&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
62
63 r = engine->RegisterObjectMethod("LocalStorageClass", "degree getDegree(string)", asMETHODPR(LocalStorage,getDegree,(std::string), Ogre::Degree), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
64 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const degree &in)", asMETHODPR(LocalStorage,set,(std::string, const Ogre::Degree&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
65 r = engine->RegisterObjectMethod("LocalStorageClass", "void setDegree(string, const degree &in)", asMETHODPR(LocalStorage,set,(std::string, const Ogre::Degree&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
66
67 r = engine->RegisterObjectMethod("LocalStorageClass", "quaternion getQuaternion(string)", asMETHODPR(LocalStorage,getQuaternion,(std::string), Ogre::Quaternion), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
68 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const quaternion &in)", asMETHODPR(LocalStorage,set,(std::string, const Ogre::Quaternion&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
69 r = engine->RegisterObjectMethod("LocalStorageClass", "void setQuaternion(string, const quaternion &in)", asMETHODPR(LocalStorage,set,(std::string, const Ogre::Quaternion&),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
70
71 r = engine->RegisterObjectMethod("LocalStorageClass", "bool getBool(string)", asMETHODPR(LocalStorage,getBool,(std::string), bool), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
72 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const bool &in)", asMETHODPR(LocalStorage,set,(std::string, const bool),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
73 r = engine->RegisterObjectMethod("LocalStorageClass", "void setBool(string, const bool &in)", asMETHODPR(LocalStorage,set,(std::string, const bool),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
74
75 r = engine->RegisterObjectMethod("LocalStorageClass", "int getInt(string)", asMETHODPR(LocalStorage,getInt,(std::string), int), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
76 r = engine->RegisterObjectMethod("LocalStorageClass", "int getInteger(string)", asMETHODPR(LocalStorage,getInt,(std::string), int), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
77 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, int)", asMETHODPR(LocalStorage,set,(std::string, const int),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
78 r = engine->RegisterObjectMethod("LocalStorageClass", "void setInt(string, int)", asMETHODPR(LocalStorage,set,(std::string, const int),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
79 r = engine->RegisterObjectMethod("LocalStorageClass", "void setInteger(string, int)", asMETHODPR(LocalStorage,set,(std::string, const int),void), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
80
81 r = engine->RegisterObjectMethod("LocalStorageClass", "void save()", asMETHOD(LocalStorage,saveDict), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
82 r = engine->RegisterObjectMethod("LocalStorageClass", "bool reload()", asMETHOD(LocalStorage,loadDict), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
83
84 r = engine->RegisterObjectMethod("LocalStorageClass", "bool exists(string &in) const", asMETHOD(LocalStorage,exists), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
85 r = engine->RegisterObjectMethod("LocalStorageClass", "void delete(string &in)", asMETHOD(LocalStorage,eraseKey), asCALL_THISCALL); ROR_ASSERT( r >= 0 );
86
87}
#define ROR_ASSERT(_EXPR)
Definition Application.h:40
static LocalStorage * LocalStorageFactory(std::string filename, const std::string &section_name, const std::string &rg_name)
static void RegisterRefCountingObjectPtr(AS_NAMESPACE_QUALIFIER asIScriptEngine *engine, const char *handle_name, const char *obj_name)
A class that allows scripts to store data persistently.
void RegisterLocalStorage(AngelScript::asIScriptEngine *engine)
Registers RoR::LocalStorage, defined in LocalStorageAngelscript.cpp.