Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
LocalStorageAngelscriptGeneric.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 "../../autowrapper/aswrappedcall.h"
23#include "LocalStorage.h"
24#include "AngelScriptBindings.h"
26
27#include <angelscript.h>
28
29using namespace AngelScript;
30using namespace RoR;
32
33void RoR::RegisterLocalStorageGeneric(asIScriptEngine *engine)
34{
35 LocalStorage::RegisterRefCountingObjectGeneric(engine, "LocalStorageClass");
36 LocalStoragePtr::RegisterRefCountingObjectPtrGeneric(engine, "LocalStorageClassPtr", "LocalStorageClass");
37
38 int r;
39 r = engine->RegisterObjectBehaviour("LocalStorageClass", asBEHAVE_FACTORY, "LocalStorageClass@+ f(string, const string&in = \"common\", const string&in = \"Cache\")", WRAP_FN(LocalStorageFactory), asCALL_GENERIC); ROR_ASSERT(r >= 0);
40
41 r = engine->RegisterObjectMethod("LocalStorageClass", "void copyFrom(LocalStorageClassPtr@)", WRAP_MFN(LocalStorage, copyFrom), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
42 r = engine->RegisterObjectMethod("LocalStorageClass", "void changeSection(const string &in)", WRAP_MFN(LocalStorage, changeSection), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
43
44 r = engine->RegisterObjectMethod("LocalStorageClass", "string get(string)", WRAP_MFN_PR(LocalStorage, get, (std::string), std::string), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
45 r = engine->RegisterObjectMethod("LocalStorageClass", "string getString(string)", WRAP_MFN_PR(LocalStorage, get, (std::string), std::string), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
46 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const string &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const std::string&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
47 r = engine->RegisterObjectMethod("LocalStorageClass", "void setString(string, const string &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const std::string&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
48
49 r = engine->RegisterObjectMethod("LocalStorageClass", "float getFloat(string)", WRAP_MFN_PR(LocalStorage, getFloat, (std::string), float), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
50 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, float)", WRAP_MFN_PR(LocalStorage, set, (std::string, const float), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
51 r = engine->RegisterObjectMethod("LocalStorageClass", "void setFloat(string, float)", WRAP_MFN_PR(LocalStorage, set, (std::string, const float), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
52
53 r = engine->RegisterObjectMethod("LocalStorageClass", "vector3 getVector3(string)", WRAP_MFN_PR(LocalStorage, getVector3, (std::string), Ogre::Vector3), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
54 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const vector3 &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const Ogre::Vector3&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
55 r = engine->RegisterObjectMethod("LocalStorageClass", "void setVector3(string, const vector3 &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const Ogre::Vector3&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
56
57 r = engine->RegisterObjectMethod("LocalStorageClass", "radian getRadian(string)", WRAP_MFN_PR(LocalStorage, getRadian, (std::string), Ogre::Radian), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
58 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const radian &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const Ogre::Radian&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
59 r = engine->RegisterObjectMethod("LocalStorageClass", "void setRadian(string, const radian &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const Ogre::Radian&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
60
61 r = engine->RegisterObjectMethod("LocalStorageClass", "degree getDegree(string)", WRAP_MFN_PR(LocalStorage, getDegree, (std::string), Ogre::Degree), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
62 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const degree &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const Ogre::Degree&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
63 r = engine->RegisterObjectMethod("LocalStorageClass", "void setDegree(string, const degree &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const Ogre::Degree&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
64
65 r = engine->RegisterObjectMethod("LocalStorageClass", "quaternion getQuaternion(string)", WRAP_MFN_PR(LocalStorage, getQuaternion, (std::string), Ogre::Quaternion), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
66 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const quaternion &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const Ogre::Quaternion&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
67 r = engine->RegisterObjectMethod("LocalStorageClass", "void setQuaternion(string, const quaternion &in)", WRAP_MFN_PR(LocalStorage, set, (std::string, const Ogre::Quaternion&), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
68
69 r = engine->RegisterObjectMethod("LocalStorageClass", "bool getBool(string)", WRAP_MFN_PR(LocalStorage, getBool, (std::string), bool), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
70 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, const bool &in)", WRAP_OBJ_FIRST(LocalStorage_setBool), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
71 r = engine->RegisterObjectMethod("LocalStorageClass", "void setBool(string, const bool &in)", WRAP_OBJ_FIRST(LocalStorage_setBool), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
72
73 r = engine->RegisterObjectMethod("LocalStorageClass", "int getInt(string)", WRAP_MFN_PR(LocalStorage, getInt, (std::string), int), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
74 r = engine->RegisterObjectMethod("LocalStorageClass", "int getInteger(string)", WRAP_MFN_PR(LocalStorage, getInt, (std::string), int), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
75 r = engine->RegisterObjectMethod("LocalStorageClass", "void set(string, int)", WRAP_MFN_PR(LocalStorage, set, (std::string, const int), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
76 r = engine->RegisterObjectMethod("LocalStorageClass", "void setInt(string, int)", WRAP_MFN_PR(LocalStorage, set, (std::string, const int), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
77 r = engine->RegisterObjectMethod("LocalStorageClass", "void setInteger(string, int)", WRAP_MFN_PR(LocalStorage, set, (std::string, const int), void), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
78
79 r = engine->RegisterObjectMethod("LocalStorageClass", "void save()", WRAP_MFN(LocalStorage, saveDict), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
80 r = engine->RegisterObjectMethod("LocalStorageClass", "bool reload()", WRAP_MFN(LocalStorage, loadDict), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
81
82 r = engine->RegisterObjectMethod("LocalStorageClass", "bool exists(string &in) const", WRAP_OBJ_FIRST(LocalStorage_exists), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
83 r = engine->RegisterObjectMethod("LocalStorageClass", "void delete(string &in)", WRAP_OBJ_FIRST(LocalStorage_eraseKey), asCALL_GENERIC); ROR_ASSERT( r >= 0 );
84
85}
#define ROR_ASSERT(_EXPR)
Definition Application.h:40
Helper/wrapper functions shared by native (LocalStorageAngelscript.cpp) and generic (LocalStorageAnge...
#define WRAP_MFN(ClassType, name)
#define WRAP_OBJ_FIRST(name)
#define WRAP_MFN_PR(ClassType, name, Parameters, ReturnType)
#define WRAP_FN(name)
static void RegisterRefCountingObjectPtrGeneric(AS_NAMESPACE_QUALIFIER asIScriptEngine *engine, const char *handle_name, const char *obj_name)
Same as RegisterRefCountingObjectPtr() but uses the generic calling convention (for platforms with AS...
A class that allows scripts to store data persistently.
void RegisterLocalStorageGeneric(AngelScript::asIScriptEngine *engine)
static void LocalStorage_setBool(LocalStorage *self, std::string key, const bool &value)
static void LocalStorage_eraseKey(LocalStorage *self, const std::string &key)
static LocalStorage * LocalStorageFactory(std::string filename, const std::string &section_name, const std::string &rg_name)
static bool LocalStorage_exists(LocalStorage *self, const std::string &key)