Skip to content

Commit

Permalink
Change code style
Browse files Browse the repository at this point in the history
  • Loading branch information
dargueta committed May 10, 2024
1 parent 6dcf292 commit 498efad
Show file tree
Hide file tree
Showing 34 changed files with 789 additions and 728 deletions.
69 changes: 35 additions & 34 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
Language: Cpp
BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
# BasedOnStyle: Microsoft
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: DontAlign
AlignTrailingComments: false
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortEnumsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
Expand All @@ -30,50 +30,51 @@ BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: WebKit
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
ColumnLimit: 90 # CHANGED from 120
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Leave
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: BinPack
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
Expand All @@ -100,7 +101,8 @@ IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
# Changed
IndentPPDirectives: AfterHash
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
Expand All @@ -113,11 +115,11 @@ LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
Expand All @@ -127,10 +129,10 @@ PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyReturnTypeOnItsOwnLine: 1000
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
PPIndentWidth: -1
PointerAlignment: Right
PPIndentWidth: 4
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
Expand All @@ -144,7 +146,7 @@ SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
Expand All @@ -158,7 +160,7 @@ SpaceBeforeParensOptions:
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
Expand All @@ -178,7 +180,7 @@ StatementAttributeLikeMacros:
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
Expand All @@ -188,4 +190,3 @@ WhitespaceSensitiveMacros:
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

44 changes: 22 additions & 22 deletions include/unicornlua/compat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,58 @@

#pragma once

extern "C" {
extern "C"
{
#include <lauxlib.h>
#include <lua.h>
#include <luaconf.h>
}

/* Compatibility stuff for Lua < 5.3 */
#if LUA_VERSION_NUM < 503
LUA_API void lua_seti(lua_State* L, int index, lua_Integer n);
LUA_API int lua_geti(lua_State* L, int index, lua_Integer i);
LUA_API void lua_seti(lua_State *L, int index, lua_Integer n);
LUA_API int lua_geti(lua_State *L, int index, lua_Integer i);
#endif

/* Compatibility stuff for Lua < 5.2 */
#if LUA_VERSION_NUM < 502
/* Copied and pasted from the 5.3 implementation. */
LUALIB_API void luaL_setmetatable(lua_State* L, const char* tname);
LUALIB_API void luaL_setmetatable(lua_State *L, const char *tname);

/**
* A partial replacement for Lua 5.2+ @e lua_len.
*
* @warning This DOES NOT invoke the `__len` metamethod, and as of right now
* this library doesn't need it so it won't be supported.
*/
LUA_API void lua_len(lua_State* L, int index);
LUA_API void lua_len(lua_State *L, int index);

LUA_API int luaL_len(lua_State* L, int index);
LUA_API int luaL_len(lua_State *L, int index);

/**
* Implementation of Lua 5.2+ `lua_absindex`.
*/
LUA_API int lua_absindex(lua_State* L, int index);
LUA_API int lua_absindex(lua_State *L, int index);

/* Copied and pasted from the 5.3 implementation. */
LUALIB_API void luaL_setfuncs(lua_State* L, const luaL_Reg* l, int nup);
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup);

LUALIB_API void lua_rawsetp(lua_State* L, int index, const void* p);
LUALIB_API void lua_rawsetp(lua_State *L, int index, const void *p);

#ifndef luaL_newlibtable
#define luaL_newlibtable(L, l) lua_createtable((L), 0, sizeof(l) / sizeof(*(l)))
#endif // luaL_newlibtable
# ifndef luaL_newlibtable
# define luaL_newlibtable(L, l) lua_createtable((L), 0, sizeof(l) / sizeof(*(l)))
# endif // luaL_newlibtable

#ifndef luaL_newlib
#define luaL_newlib(L, l) \
(luaL_newlibtable((L), (l)), luaL_setfuncs((L), (l), 0))
#endif // luaL_newlib
#endif // LUA_VERSION_NUM < 502
# ifndef luaL_newlib
# define luaL_newlib(L, l) (luaL_newlibtable((L), (l)), luaL_setfuncs((L), (l), 0))
# endif // luaL_newlib
#endif // LUA_VERSION_NUM < 502

// http://lua-users.org/lists/lua-l/2011-11/msg01149.html
#ifndef IS_LUAJIT
#ifdef LUA_JDIR
#define IS_LUAJIT 1
#else
#define IS_LUAJIT 0
#endif
# ifdef LUA_JDIR
# define IS_LUAJIT 1
# else
# define IS_LUAJIT 0
# endif
#endif
19 changes: 10 additions & 9 deletions include/unicornlua/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,31 @@
#include "unicornlua/engine.hpp"
#include "unicornlua/lua.hpp"

extern const char* const kContextMetatableName;
extern const char *const kContextMetatableName;
extern const luaL_Reg kContextMetamethods[];
extern const luaL_Reg kContextInstanceMethods[];

struct Context {
uc_context* context_handle;
UCLuaEngine* engine;
struct Context
{
uc_context *context_handle;
UCLuaEngine *engine;
};

int ul_context_save(lua_State* L);
int ul_context_restore(lua_State* L);
int ul_context_save(lua_State *L);
int ul_context_restore(lua_State *L);

/** Deallocate a context object.
*
* This function calls `uc_free()` on versions of Unicorn before 1.0.2, and
* calls `uc_context_free()` on 1.0.2+. In either case, it will behave as
* expected.
*/
int ul_context_free(lua_State* L);
int ul_context_free(lua_State *L);

/**
* Like @ref ul_context_free, except if the context is closed, it does nothing
* instead of throwing an exception.
*/
int ul_context_maybe_free(lua_State* L);
int ul_context_maybe_free(lua_State *L);

Context* ul_toluacontext(lua_State* L, int index);
Context *ul_toluacontext(lua_State *L, int index);
62 changes: 31 additions & 31 deletions include/unicornlua/control_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@

#include "lua.hpp"

[[noreturn]] int ul_crash_unsupported_operation(lua_State* L);
[[noreturn]] int ul_crash_unsupported_operation(lua_State *L);

#if UC_API_MAJOR >= 2
int ul_ctl_exits_disable(lua_State* L);
int ul_ctl_exits_enable(lua_State* L);
int ul_ctl_flush_tlb(lua_State* L);
int ul_ctl_get_arch(lua_State* L);
int ul_ctl_get_cpu_model(lua_State* L);
int ul_ctl_get_exits(lua_State* L);
int ul_ctl_get_exits_cnt(lua_State* L);
int ul_ctl_get_mode(lua_State* L);
int ul_ctl_get_page_size(lua_State* L);
int ul_ctl_get_timeout(lua_State* L);
int ul_ctl_remove_cache(lua_State* L);
int ul_ctl_request_cache(lua_State* L);
int ul_ctl_set_cpu_model(lua_State* L);
int ul_ctl_set_exits(lua_State* L);
int ul_ctl_set_page_size(lua_State* L);
int ul_ctl_exits_disable(lua_State *L);
int ul_ctl_exits_enable(lua_State *L);
int ul_ctl_flush_tlb(lua_State *L);
int ul_ctl_get_arch(lua_State *L);
int ul_ctl_get_cpu_model(lua_State *L);
int ul_ctl_get_exits(lua_State *L);
int ul_ctl_get_exits_cnt(lua_State *L);
int ul_ctl_get_mode(lua_State *L);
int ul_ctl_get_page_size(lua_State *L);
int ul_ctl_get_timeout(lua_State *L);
int ul_ctl_remove_cache(lua_State *L);
int ul_ctl_request_cache(lua_State *L);
int ul_ctl_set_cpu_model(lua_State *L);
int ul_ctl_set_exits(lua_State *L);
int ul_ctl_set_page_size(lua_State *L);
#else
#define ul_ctl_exits_disable ul_crash_unsupported_operation
#define ul_ctl_exits_enable ul_crash_unsupported_operation
#define ul_ctl_flush_tlb ul_crash_unsupported_operation
#define ul_ctl_get_arch ul_crash_unsupported_operation
#define ul_ctl_get_cpu_model ul_crash_unsupported_operation
#define ul_ctl_get_exits ul_crash_unsupported_operation
#define ul_ctl_get_exits_cnt ul_crash_unsupported_operation
#define ul_ctl_get_mode ul_crash_unsupported_operation
#define ul_ctl_get_page_size ul_crash_unsupported_operation
#define ul_ctl_get_timeout ul_crash_unsupported_operation
#define ul_ctl_remove_cache ul_crash_unsupported_operation
#define ul_ctl_request_cache ul_crash_unsupported_operation
#define ul_ctl_set_cpu_model ul_crash_unsupported_operation
#define ul_ctl_set_exits ul_crash_unsupported_operation
#define ul_ctl_set_page_size ul_crash_unsupported_operation
# define ul_ctl_exits_disable ul_crash_unsupported_operation
# define ul_ctl_exits_enable ul_crash_unsupported_operation
# define ul_ctl_flush_tlb ul_crash_unsupported_operation
# define ul_ctl_get_arch ul_crash_unsupported_operation
# define ul_ctl_get_cpu_model ul_crash_unsupported_operation
# define ul_ctl_get_exits ul_crash_unsupported_operation
# define ul_ctl_get_exits_cnt ul_crash_unsupported_operation
# define ul_ctl_get_mode ul_crash_unsupported_operation
# define ul_ctl_get_page_size ul_crash_unsupported_operation
# define ul_ctl_get_timeout ul_crash_unsupported_operation
# define ul_ctl_remove_cache ul_crash_unsupported_operation
# define ul_ctl_request_cache ul_crash_unsupported_operation
# define ul_ctl_set_cpu_model ul_crash_unsupported_operation
# define ul_ctl_set_exits ul_crash_unsupported_operation
# define ul_ctl_set_page_size ul_crash_unsupported_operation
#endif
Loading

0 comments on commit 498efad

Please sign in to comment.