Skip to content

Commit e82f9d2

Browse files
authored
Add .clang-format file. Reformat code. Use SPDX lincense refs (#235)
1 parent d1e9836 commit e82f9d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7479
-8245
lines changed

.clang-format

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
AccessModifierOffset: -4
3+
AlignConsecutiveAssignments: false
4+
AlignConsecutiveDeclarations: false
5+
AlignEscapedNewlines: DontAlign
6+
AlignOperands: true
7+
AlignTrailingComments: false
8+
AllowAllParametersOfDeclarationOnNextLine: true
9+
AllowShortBlocksOnASingleLine: false
10+
AllowShortCaseLabelsOnASingleLine: false
11+
AllowShortFunctionsOnASingleLine: InlineOnly
12+
AllowShortIfStatementsOnASingleLine: false
13+
AllowShortLoopsOnASingleLine: false
14+
AlwaysBreakAfterReturnType: None
15+
AlwaysBreakBeforeMultilineStrings: false
16+
AlwaysBreakTemplateDeclarations: true
17+
BinPackArguments: false
18+
BinPackParameters: false
19+
BraceWrapping:
20+
AfterClass: true
21+
AfterControlStatement: true
22+
AfterEnum: true
23+
AfterFunction: true
24+
AfterNamespace: false
25+
AfterStruct: true
26+
AfterUnion: true
27+
BeforeCatch: true
28+
BeforeElse: true
29+
IndentBraces: false
30+
SplitEmptyFunction: true
31+
BreakBeforeBinaryOperators: None
32+
BreakBeforeBraces: Custom
33+
BreakBeforeInheritanceComma: false
34+
BreakBeforeTernaryOperators: true
35+
BreakConstructorInitializers: BeforeComma
36+
BreakStringLiterals: true
37+
ColumnLimit: 100
38+
CompactNamespaces: false
39+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
40+
ConstructorInitializerIndentWidth: 4
41+
ContinuationIndentWidth: 4
42+
Cpp11BracedListStyle: true
43+
DerivePointerAlignment: false
44+
DisableFormat: false
45+
ExperimentalAutoDetectBinPacking: false
46+
FixNamespaceComments: true
47+
IndentCaseLabels: false
48+
IndentWidth: 4
49+
IndentWrappedFunctionNames: false
50+
KeepEmptyLinesAtTheStartOfBlocks: false
51+
Language: Cpp
52+
MaxEmptyLinesToKeep: 1
53+
NamespaceIndentation: None
54+
PointerAlignment: Left
55+
ReflowComments: true
56+
SortIncludes: true
57+
SortUsingDeclarations: true
58+
SpaceAfterCStyleCast: true
59+
SpaceAfterTemplateKeyword: false
60+
SpaceBeforeAssignmentOperators: true
61+
SpaceBeforeParens: ControlStatements
62+
SpaceInEmptyParentheses: false
63+
SpacesBeforeTrailingComments: 1
64+
SpacesInAngles: false
65+
SpacesInCStyleCastParentheses: false
66+
SpacesInContainerLiterals: false
67+
SpacesInParentheses: false
68+
SpacesInSquareBrackets: false
69+
Standard: Cpp11
70+
TabWidth: 4
71+
UseTab: Never
72+
73+
...

Source/LuaBridge/List.h

+29-32
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,42 @@
1010

1111
namespace luabridge {
1212

13-
template <class T>
14-
struct Stack <std::list <T>>
13+
template<class T>
14+
struct Stack<std::list<T>>
1515
{
16-
static void push (lua_State* L, std::list <T> const& list)
17-
{
18-
lua_createtable (L, static_cast <int> (list.size ()), 0);
19-
typename std::list <T>::const_iterator item = list.begin ();
20-
for (std::size_t i = 1; i <= list.size (); ++i)
16+
static void push(lua_State* L, std::list<T> const& list)
2117
{
22-
lua_pushinteger (L, static_cast <lua_Integer> (i));
23-
Stack <T>::push (L, *item);
24-
lua_settable (L, -3);
25-
++item;
18+
lua_createtable(L, static_cast<int>(list.size()), 0);
19+
typename std::list<T>::const_iterator item = list.begin();
20+
for (std::size_t i = 1; i <= list.size(); ++i)
21+
{
22+
lua_pushinteger(L, static_cast<lua_Integer>(i));
23+
Stack<T>::push(L, *item);
24+
lua_settable(L, -3);
25+
++item;
26+
}
2627
}
27-
}
2828

29-
static std::list <T> get (lua_State* L, int index)
30-
{
31-
if (!lua_istable (L, index))
29+
static std::list<T> get(lua_State* L, int index)
3230
{
33-
luaL_error (L, "#%d argument must be a table", index);
31+
if (!lua_istable(L, index))
32+
{
33+
luaL_error(L, "#%d argument must be a table", index);
34+
}
35+
36+
std::list<T> list;
37+
38+
int const absindex = lua_absindex(L, index);
39+
lua_pushnil(L);
40+
while (lua_next(L, absindex) != 0)
41+
{
42+
list.push_back(Stack<T>::get(L, -1));
43+
lua_pop(L, 1);
44+
}
45+
return list;
3446
}
3547

36-
std::list <T> list;
37-
38-
int const absindex = lua_absindex (L, index);
39-
lua_pushnil (L);
40-
while (lua_next (L, absindex) != 0)
41-
{
42-
list.push_back (Stack <T>::get (L, -1));
43-
lua_pop (L, 1);
44-
}
45-
return list;
46-
}
47-
48-
static bool isInstance (lua_State* L, int index)
49-
{
50-
return lua_istable (L, index);
51-
}
48+
static bool isInstance(lua_State* L, int index) { return lua_istable(L, index); }
5249
};
5350

5451
} // namespace luabridge

Source/LuaBridge/LuaBridge.h

+14-38
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,8 @@
1-
//------------------------------------------------------------------------------
2-
/*
3-
https://github.com/vinniefalco/LuaBridge
4-
5-
Copyright 2020, Dmitry Tarakanov
6-
Copyright 2012, Vinnie Falco <[email protected]>
7-
Copyright 2007, Nathan Reed
8-
9-
License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
10-
11-
Permission is hereby granted, free of charge, to any person obtaining a copy
12-
of this software and associated documentation files (the "Software"), to deal
13-
in the Software without restriction, including without limitation the rights
14-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15-
copies of the Software, and to permit persons to whom the Software is
16-
furnished to do so, subject to the following conditions:
17-
18-
The above copyright notice and this permission notice shall be included in all
19-
copies or substantial portions of the Software.
20-
21-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27-
SOFTWARE.
28-
*/
29-
//==============================================================================
1+
// https://github.com/vinniefalco/LuaBridge
2+
// Copyright 2020, Dmitry Tarakanov
3+
// Copyright 2012, Vinnie Falco <[email protected]>
4+
// Copyright 2007, Nathan Reed
5+
// SPDX-License-Identifier: MIT
306

317
#pragma once
328

@@ -42,17 +18,17 @@
4218
#error "Lua headers must be included prior to LuaBridge ones"
4319
#endif
4420

45-
#include <LuaBridge/detail/LuaHelpers.h>
46-
#include <LuaBridge/detail/TypeTraits.h>
47-
#include <LuaBridge/detail/TypeList.h>
48-
#include <LuaBridge/detail/FuncTraits.h>
49-
#include <LuaBridge/detail/Constructor.h>
21+
#include <LuaBridge/detail/CFunctions.h>
5022
#include <LuaBridge/detail/ClassInfo.h>
23+
#include <LuaBridge/detail/Constructor.h>
24+
#include <LuaBridge/detail/FuncTraits.h>
25+
#include <LuaBridge/detail/Iterator.h>
5126
#include <LuaBridge/detail/LuaException.h>
27+
#include <LuaBridge/detail/LuaHelpers.h>
5228
#include <LuaBridge/detail/LuaRef.h>
53-
#include <LuaBridge/detail/Iterator.h>
54-
#include <LuaBridge/detail/Userdata.h>
55-
#include <LuaBridge/detail/CFunctions.h>
29+
#include <LuaBridge/detail/Namespace.h>
5630
#include <LuaBridge/detail/Security.h>
5731
#include <LuaBridge/detail/Stack.h>
58-
#include <LuaBridge/detail/Namespace.h>
32+
#include <LuaBridge/detail/TypeList.h>
33+
#include <LuaBridge/detail/TypeTraits.h>
34+
#include <LuaBridge/detail/Userdata.h>

Source/LuaBridge/Map.h

+28-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// https://github.com/vinniefalco/LuaBridge
2-
//
32
// Copyright 2018, Dmitry Tarakanov
43
// SPDX-License-Identifier: MIT
54

@@ -12,45 +11,42 @@
1211

1312
namespace luabridge {
1413

15-
template <class K, class V>
16-
struct Stack <std::map <K, V>>
14+
template<class K, class V>
15+
struct Stack<std::map<K, V>>
1716
{
18-
typedef std::map <K, V> Map;
17+
typedef std::map<K, V> Map;
1918

20-
static void push (lua_State* L, const Map& map)
21-
{
22-
lua_createtable (L, 0, static_cast <int> (map.size ()));
23-
typedef typename Map::const_iterator ConstIter;
24-
for (ConstIter i = map.begin (); i != map.end (); ++i)
19+
static void push(lua_State* L, const Map& map)
2520
{
26-
Stack <K>::push (L, i->first);
27-
Stack <V>::push (L, i->second);
28-
lua_settable (L, -3);
21+
lua_createtable(L, 0, static_cast<int>(map.size()));
22+
typedef typename Map::const_iterator ConstIter;
23+
for (ConstIter i = map.begin(); i != map.end(); ++i)
24+
{
25+
Stack<K>::push(L, i->first);
26+
Stack<V>::push(L, i->second);
27+
lua_settable(L, -3);
28+
}
2929
}
30-
}
3130

32-
static Map get (lua_State* L, int index)
33-
{
34-
if (!lua_istable (L, index))
31+
static Map get(lua_State* L, int index)
3532
{
36-
luaL_error (L, "#%d argument must be a table", index);
33+
if (!lua_istable(L, index))
34+
{
35+
luaL_error(L, "#%d argument must be a table", index);
36+
}
37+
38+
Map map;
39+
int const absindex = lua_absindex(L, index);
40+
lua_pushnil(L);
41+
while (lua_next(L, absindex) != 0)
42+
{
43+
map.emplace(Stack<K>::get(L, -2), Stack<V>::get(L, -1));
44+
lua_pop(L, 1);
45+
}
46+
return map;
3747
}
3848

39-
Map map;
40-
int const absindex = lua_absindex (L, index);
41-
lua_pushnil (L);
42-
while (lua_next (L, absindex) != 0)
43-
{
44-
map.emplace (Stack <K>::get (L, -2), Stack <V>::get (L, -1));
45-
lua_pop (L, 1);
46-
}
47-
return map;
48-
}
49-
50-
static bool isInstance (lua_State* L, int index)
51-
{
52-
return lua_istable (L, index);
53-
}
49+
static bool isInstance(lua_State* L, int index) { return lua_istable(L, index); }
5450
};
5551

5652
} // namespace luabridge

0 commit comments

Comments
 (0)