diff options
| author | ruki <[email protected]> | 2025-11-10 06:35:04 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-10 06:35:04 +0800 |
| commit | 2b01e46fcf619aaecb8435b0fac975e3aff0587f (patch) | |
| tree | 8f005a8dfc3272e9f027560e5e1b5881a7a8bc70 /xmake | |
| parent | a1b0ec856e2c22aac84022feb05b6687912e3d6e (diff) | |
| parent | 2c387895657ae13cd717d7f42f5baed5eb028a8e (diff) | |
Merge pull request #7008 from xmake-io/format
format code
Diffstat (limited to 'xmake')
46 files changed, 109 insertions, 142 deletions
diff --git a/xmake/templates/c++/console/project/src/main.cpp b/xmake/templates/c++/console/project/src/main.cpp index 7c775d288..9b6abffea 100644 --- a/xmake/templates/c++/console/project/src/main.cpp +++ b/xmake/templates/c++/console/project/src/main.cpp @@ -1,6 +1,6 @@ #include <iostream> -int main(int argc, char** argv) { +int main(int argc, char **argv) { std::cout << "hello world!" << std::endl; return 0; } diff --git a/xmake/templates/c++/module.binary/project/modules/binary/bar/src/add.cpp b/xmake/templates/c++/module.binary/project/modules/binary/bar/src/add.cpp index e19d07e12..93fdf0ad8 100644 --- a/xmake/templates/c++/module.binary/project/modules/binary/bar/src/add.cpp +++ b/xmake/templates/c++/module.binary/project/modules/binary/bar/src/add.cpp @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdlib.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { int a = atoi(argv[1]); int b = atoi(argv[2]); printf("%d", a + b); diff --git a/xmake/templates/c++/module.binary/project/modules/binary/bar/src/sub.cpp b/xmake/templates/c++/module.binary/project/modules/binary/bar/src/sub.cpp index 980289d1a..ae7b6d1f2 100644 --- a/xmake/templates/c++/module.binary/project/modules/binary/bar/src/sub.cpp +++ b/xmake/templates/c++/module.binary/project/modules/binary/bar/src/sub.cpp @@ -1,10 +1,9 @@ #include <stdio.h> #include <stdlib.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { int a = atoi(argv[1]); int b = atoi(argv[2]); printf("%d", a - b); return 0; } - diff --git a/xmake/templates/c++/module.binary/project/src/main.cpp b/xmake/templates/c++/module.binary/project/src/main.cpp index 7c775d288..9b6abffea 100644 --- a/xmake/templates/c++/module.binary/project/src/main.cpp +++ b/xmake/templates/c++/module.binary/project/src/main.cpp @@ -1,6 +1,6 @@ #include <iostream> -int main(int argc, char** argv) { +int main(int argc, char **argv) { std::cout << "hello world!" << std::endl; return 0; } diff --git a/xmake/templates/c++/module.shared/project/modules/shared/foo/src/foo.cpp b/xmake/templates/c++/module.shared/project/modules/shared/foo/src/foo.cpp index a98baca02..adde214ca 100644 --- a/xmake/templates/c++/module.shared/project/modules/shared/foo/src/foo.cpp +++ b/xmake/templates/c++/module.shared/project/modules/shared/foo/src/foo.cpp @@ -1,27 +1,22 @@ #include <xmi.h> -static int add(lua_State* lua) { +static int add(lua_State *lua) { int a = lua_tointeger(lua, 1); int b = lua_tointeger(lua, 2); lua_pushinteger(lua, a + b); return 1; } -static int sub(lua_State* lua) { +static int sub(lua_State *lua) { int a = lua_tointeger(lua, 1); int b = lua_tointeger(lua, 2); lua_pushinteger(lua, a - b); return 1; } -int luaopen(foo, lua_State* lua) { - static const luaL_Reg funcs[] = { - {"add", add}, - {"sub", sub}, - {NULL, NULL} - }; +int luaopen(foo, lua_State *lua) { + static const luaL_Reg funcs[] = { { "add", add }, { "sub", sub }, { NULL, NULL } }; lua_newtable(lua); luaL_setfuncs(lua, funcs, 0); return 1; } - diff --git a/xmake/templates/c++/module.shared/project/src/main.cpp b/xmake/templates/c++/module.shared/project/src/main.cpp index 7c775d288..9b6abffea 100644 --- a/xmake/templates/c++/module.shared/project/src/main.cpp +++ b/xmake/templates/c++/module.shared/project/src/main.cpp @@ -1,6 +1,6 @@ #include <iostream> -int main(int argc, char** argv) { +int main(int argc, char **argv) { std::cout << "hello world!" << std::endl; return 0; } diff --git a/xmake/templates/c++/qt.quickapp_static/project/src/main.cpp b/xmake/templates/c++/qt.quickapp_static/project/src/main.cpp index 2ec4b880c..7d9cb80df 100644 --- a/xmake/templates/c++/qt.quickapp_static/project/src/main.cpp +++ b/xmake/templates/c++/qt.quickapp_static/project/src/main.cpp @@ -1,8 +1,7 @@ #include <QGuiApplication> #include <QQmlApplicationEngine> -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { #if QT_VERSION >= 0x50601 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif diff --git a/xmake/templates/c++/qt.shared/project/src/demo.cpp b/xmake/templates/c++/qt.shared/project/src/demo.cpp index bd791c271..576c861f0 100644 --- a/xmake/templates/c++/qt.shared/project/src/demo.cpp +++ b/xmake/templates/c++/qt.shared/project/src/demo.cpp @@ -1,6 +1,4 @@ #include "demo.h" - -QtDemo::QtDemo() -{ +QtDemo::QtDemo() { } diff --git a/xmake/templates/c++/qt.shared/project/src/demo.h b/xmake/templates/c++/qt.shared/project/src/demo.h index a0c8d28c6..89f29ec46 100644 --- a/xmake/templates/c++/qt.shared/project/src/demo.h +++ b/xmake/templates/c++/qt.shared/project/src/demo.h @@ -3,10 +3,8 @@ #include "demo_global.h" -class QT_DEMOSHARED_EXPORT QtDemo -{ - -public: +class QT_DEMOSHARED_EXPORT QtDemo { + public: QtDemo(); }; diff --git a/xmake/templates/c++/qt.shared/project/src/demo_global.h b/xmake/templates/c++/qt.shared/project/src/demo_global.h index a1daff02a..d6b1ddf0b 100644 --- a/xmake/templates/c++/qt.shared/project/src/demo_global.h +++ b/xmake/templates/c++/qt.shared/project/src/demo_global.h @@ -4,9 +4,9 @@ #include <QtCore/qglobal.h> #if defined(QT_DEMO_LIBRARY) -# define QT_DEMOSHARED_EXPORT Q_DECL_EXPORT +#define QT_DEMOSHARED_EXPORT Q_DECL_EXPORT #else -# define QT_DEMOSHARED_EXPORT Q_DECL_IMPORT +#define QT_DEMOSHARED_EXPORT Q_DECL_IMPORT #endif #endif // QT_DEMO_GLOBAL_H diff --git a/xmake/templates/c++/qt.static/project/src/demo.cpp b/xmake/templates/c++/qt.static/project/src/demo.cpp index a702ad253..576c861f0 100644 --- a/xmake/templates/c++/qt.static/project/src/demo.cpp +++ b/xmake/templates/c++/qt.static/project/src/demo.cpp @@ -1,5 +1,4 @@ #include "demo.h" -QtDemo::QtDemo() -{ +QtDemo::QtDemo() { } diff --git a/xmake/templates/c++/qt.static/project/src/demo.h b/xmake/templates/c++/qt.static/project/src/demo.h index 51eb9be55..24730c9d8 100644 --- a/xmake/templates/c++/qt.static/project/src/demo.h +++ b/xmake/templates/c++/qt.static/project/src/demo.h @@ -1,10 +1,8 @@ #ifndef QT_DEMO_H #define QT_DEMO_H -class QtDemo -{ - -public: +class QtDemo { + public: QtDemo(); }; diff --git a/xmake/templates/c++/qt.widgetapp/project/src/main.cpp b/xmake/templates/c++/qt.widgetapp/project/src/main.cpp index eb4e26c90..191ae18d2 100644 --- a/xmake/templates/c++/qt.widgetapp/project/src/main.cpp +++ b/xmake/templates/c++/qt.widgetapp/project/src/main.cpp @@ -3,7 +3,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - MainWindow w; + MainWindow w; w.show(); return a.exec(); } diff --git a/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.cpp b/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.cpp index 57ab27f7d..c9c6a0d98 100644 --- a/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.cpp +++ b/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.cpp @@ -1,9 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), - ui(new Ui::MainWindow) { +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } diff --git a/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.h b/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.h index a3948a917..a4245aa42 100644 --- a/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.h +++ b/xmake/templates/c++/qt.widgetapp/project/src/mainwindow.h @@ -7,15 +7,14 @@ namespace Ui { class MainWindow; } -class MainWindow : public QMainWindow -{ +class MainWindow : public QMainWindow { Q_OBJECT -public: + public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); -private: + private: Ui::MainWindow *ui; }; diff --git a/xmake/templates/c++/qt.widgetapp_static/project/src/main.cpp b/xmake/templates/c++/qt.widgetapp_static/project/src/main.cpp index b48f94ec8..db5b0cce8 100644 --- a/xmake/templates/c++/qt.widgetapp_static/project/src/main.cpp +++ b/xmake/templates/c++/qt.widgetapp_static/project/src/main.cpp @@ -1,10 +1,9 @@ #include "mainwindow.h" #include <QApplication> -int main(int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { QApplication a(argc, argv); - MainWindow w; + MainWindow w; w.show(); return a.exec(); diff --git a/xmake/templates/c++/qt.widgetapp_static/project/src/mainwindow.cpp b/xmake/templates/c++/qt.widgetapp_static/project/src/mainwindow.cpp index 49d64fce7..c9c6a0d98 100644 --- a/xmake/templates/c++/qt.widgetapp_static/project/src/mainwindow.cpp +++ b/xmake/templates/c++/qt.widgetapp_static/project/src/mainwindow.cpp @@ -1,14 +1,10 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } -MainWindow::~MainWindow() -{ +MainWindow::~MainWindow() { delete ui; } diff --git a/xmake/templates/c++/qt.widgetapp_static/project/src/mainwindow.h b/xmake/templates/c++/qt.widgetapp_static/project/src/mainwindow.h index a3948a917..a4245aa42 100644 --- a/xmake/templates/c++/qt.widgetapp_static/project/src/mainwindow.h +++ b/xmake/templates/c++/qt.widgetapp_static/project/src/mainwindow.h @@ -7,15 +7,14 @@ namespace Ui { class MainWindow; } -class MainWindow : public QMainWindow -{ +class MainWindow : public QMainWindow { Q_OBJECT -public: + public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); -private: + private: Ui::MainWindow *ui; }; diff --git a/xmake/templates/c++/shared/project/src/foo.h b/xmake/templates/c++/shared/project/src/foo.h index 20df0baa4..bd496c784 100644 --- a/xmake/templates/c++/shared/project/src/foo.h +++ b/xmake/templates/c++/shared/project/src/foo.h @@ -3,11 +3,11 @@ extern "C" { #endif #if defined(_WIN32) -# define __export __declspec(dllexport) +#define __export __declspec(dllexport) #elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) -# define __export __attribute__((visibility("default"))) +#define __export __attribute__((visibility("default"))) #else -# define __export +#define __export #endif __export int add(int a, int b); diff --git a/xmake/templates/c++/shared/project/src/main.cpp b/xmake/templates/c++/shared/project/src/main.cpp index d55d4d342..3834ee4d3 100644 --- a/xmake/templates/c++/shared/project/src/main.cpp +++ b/xmake/templates/c++/shared/project/src/main.cpp @@ -1,7 +1,7 @@ #include "foo.h" #include <iostream> -int main(int argc, char** argv) { +int main(int argc, char **argv) { std::cout << "add(1, 2) = " << add(1, 2) << std::endl; return 0; } diff --git a/xmake/templates/c++/static/project/src/main.cpp b/xmake/templates/c++/static/project/src/main.cpp index d55d4d342..3834ee4d3 100644 --- a/xmake/templates/c++/static/project/src/main.cpp +++ b/xmake/templates/c++/static/project/src/main.cpp @@ -1,7 +1,7 @@ #include "foo.h" #include <iostream> -int main(int argc, char** argv) { +int main(int argc, char **argv) { std::cout << "add(1, 2) = " << add(1, 2) << std::endl; return 0; } diff --git a/xmake/templates/c++/tbox.console/project/src/main.cpp b/xmake/templates/c++/tbox.console/project/src/main.cpp index 8cad00d22..2c7596b33 100644 --- a/xmake/templates/c++/tbox.console/project/src/main.cpp +++ b/xmake/templates/c++/tbox.console/project/src/main.cpp @@ -6,7 +6,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) { +tb_int_t main(tb_int_t argc, tb_char_t **argv) { if (tb_init(tb_null, tb_null)) { tb_trace_i("hello tbox!"); tb_exit(); diff --git a/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp b/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp index 84dad3f2b..b1e763989 100644 --- a/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp +++ b/xmake/templates/c++/tbox.shared/project/src/_demo/main.cpp @@ -6,7 +6,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) { +tb_int_t main(tb_int_t argc, tb_char_t **argv) { if (tb_init(tb_null, tb_null)) { tb_trace_i("hello tbox!"); tb_trace_i("add(1 + 1) = %d", add(1, 1)); diff --git a/xmake/templates/c++/tbox.shared/project/src/_library/interface.h b/xmake/templates/c++/tbox.shared/project/src/_library/interface.h index 398ad5d04..843ef1c98 100644 --- a/xmake/templates/c++/tbox.shared/project/src/_library/interface.h +++ b/xmake/templates/c++/tbox.shared/project/src/_library/interface.h @@ -11,7 +11,8 @@ */ __tb_extern_c_enter__ -__tb_export__ tb_int_t add(tb_int_t a, tb_int_t b); + __tb_export__ tb_int_t + add(tb_int_t a, tb_int_t b); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp b/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp index 84dad3f2b..b1e763989 100644 --- a/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp +++ b/xmake/templates/c++/tbox.static/project/src/_demo/main.cpp @@ -6,7 +6,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) { +tb_int_t main(tb_int_t argc, tb_char_t **argv) { if (tb_init(tb_null, tb_null)) { tb_trace_i("hello tbox!"); tb_trace_i("add(1 + 1) = %d", add(1, 1)); diff --git a/xmake/templates/c++/tbox.static/project/src/_library/interface.h b/xmake/templates/c++/tbox.static/project/src/_library/interface.h index 33d088314..caddb8394 100644 --- a/xmake/templates/c++/tbox.static/project/src/_library/interface.h +++ b/xmake/templates/c++/tbox.static/project/src/_library/interface.h @@ -11,7 +11,8 @@ */ __tb_extern_c_enter__ -tb_int_t add(tb_int_t a, tb_int_t b); + tb_int_t + add(tb_int_t a, tb_int_t b); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/xmake/templates/c++/wxwidgets/project/src/main.cpp b/xmake/templates/c++/wxwidgets/project/src/main.cpp index fbf187aa9..4b43fe6e3 100644 --- a/xmake/templates/c++/wxwidgets/project/src/main.cpp +++ b/xmake/templates/c++/wxwidgets/project/src/main.cpp @@ -1,44 +1,48 @@ #include <wx/wx.h> namespace Examples { - class Frame : public wxFrame { +class Frame : public wxFrame { enum wxOwnedID { - ID_Hello = 2 + ID_Hello = 2 }; public: - Frame(): wxFrame(nullptr, wxID_ANY, "Hello World") { - auto menuFile = new wxMenu(); - menuFile->Append(ID_Hello, "&Hello...\tCtrl-H", "Help string shown in status bar for this menu item"); - menuFile->AppendSeparator(); - menuFile->Append(wxID_EXIT); + Frame() : wxFrame(nullptr, wxID_ANY, "Hello World") { + auto menuFile = new wxMenu(); + menuFile->Append(ID_Hello, "&Hello...\tCtrl-H", "Help string shown in status bar for this menu item"); + menuFile->AppendSeparator(); + menuFile->Append(wxID_EXIT); - auto menuHelp = new wxMenu(); - menuHelp->Append(wxID_ABOUT); - auto menuBar = new wxMenuBar(); + auto menuHelp = new wxMenu(); + menuHelp->Append(wxID_ABOUT); + auto menuBar = new wxMenuBar(); - menuBar->Append(menuFile, "&File"); - menuBar->Append(menuHelp, "&Help"); - SetMenuBar(menuBar); + menuBar->Append(menuFile, "&File"); + menuBar->Append(menuHelp, "&Help"); + SetMenuBar(menuBar); - CreateStatusBar(); - SetStatusText("Welcome to wxWidgets!"); + CreateStatusBar(); + SetStatusText("Welcome to wxWidgets!"); - menuBar->Bind(wxEVT_MENU, [&](wxCommandEvent& event) { - if (event.GetId() == ID_Hello) wxLogMessage("Hello world from wxWidgets!"); - else if (event.GetId() == wxID_ABOUT) wxMessageBox("This is a wxWidgets Hello World example", "About Hello World", wxOK|wxICON_INFORMATION); - else if (event.GetId() == wxID_EXIT) Close(true); - else event.Skip(); - }); + menuBar->Bind(wxEVT_MENU, [&](wxCommandEvent &event) { + if (event.GetId() == ID_Hello) + wxLogMessage("Hello world from wxWidgets!"); + else if (event.GetId() == wxID_ABOUT) + wxMessageBox("This is a wxWidgets Hello World example", "About Hello World", wxOK | wxICON_INFORMATION); + else if (event.GetId() == wxID_EXIT) + Close(true); + else + event.Skip(); + }); } - }; +}; - class Application : public wxApp { +class Application : public wxApp { bool OnInit() override { - (new Frame())->Show(); - return true; + (new Frame())->Show(); + return true; } - }; -} +}; +} // namespace Examples wxIMPLEMENT_APP(Examples::Application);
\ No newline at end of file diff --git a/xmake/templates/c++/xmake.cli/project/src/lni/main.cpp b/xmake/templates/c++/xmake.cli/project/src/lni/main.cpp index 80237da16..e8955e074 100644 --- a/xmake/templates/c++/xmake.cli/project/src/lni/main.cpp +++ b/xmake/templates/c++/xmake.cli/project/src/lni/main.cpp @@ -3,26 +3,21 @@ extern "C" { } static tb_byte_t const g_luafiles_data[] = { - #include "luafiles.xmz.h" +#include "luafiles.xmz.h" }; -static tb_int_t lni_test_hello(lua_State* lua) { +static tb_int_t lni_test_hello(lua_State *lua) { lua_pushliteral(lua, "hello xmake!"); return 1; } -static tb_void_t lni_initalizer(xm_engine_ref_t engine, lua_State* lua) { - static luaL_Reg const lni_test_funcs[] = { - {"hello", lni_test_hello} - , {tb_null, tb_null} - }; +static tb_void_t lni_initalizer(xm_engine_ref_t engine, lua_State *lua) { + static luaL_Reg const lni_test_funcs[] = { { "hello", lni_test_hello }, { tb_null, tb_null } }; xm_engine_register(engine, "test", lni_test_funcs); xm_engine_add_embedfiles(engine, g_luafiles_data, sizeof(g_luafiles_data)); } -tb_int_t main(tb_int_t argc, tb_char_t** argv) { - tb_char_t* taskargv[] = {"lua", "-D", "lua.main", tb_null}; +tb_int_t main(tb_int_t argc, tb_char_t **argv) { + tb_char_t *taskargv[] = { "lua", "-D", "lua.main", tb_null }; return xm_engine_run("${TARGETNAME}", argc, argv, taskargv, lni_initalizer); } - - diff --git a/xmake/templates/c/console/project/src/main.c b/xmake/templates/c/console/project/src/main.c index 113930e1a..ccf4b2a77 100644 --- a/xmake/templates/c/console/project/src/main.c +++ b/xmake/templates/c/console/project/src/main.c @@ -1,6 +1,6 @@ #include <stdio.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { printf("hello world!\n"); return 0; } diff --git a/xmake/templates/c/module.binary/project/modules/binary/bar/src/add.c b/xmake/templates/c/module.binary/project/modules/binary/bar/src/add.c index e19d07e12..93fdf0ad8 100644 --- a/xmake/templates/c/module.binary/project/modules/binary/bar/src/add.c +++ b/xmake/templates/c/module.binary/project/modules/binary/bar/src/add.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdlib.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { int a = atoi(argv[1]); int b = atoi(argv[2]); printf("%d", a + b); diff --git a/xmake/templates/c/module.binary/project/modules/binary/bar/src/sub.c b/xmake/templates/c/module.binary/project/modules/binary/bar/src/sub.c index 980289d1a..ae7b6d1f2 100644 --- a/xmake/templates/c/module.binary/project/modules/binary/bar/src/sub.c +++ b/xmake/templates/c/module.binary/project/modules/binary/bar/src/sub.c @@ -1,10 +1,9 @@ #include <stdio.h> #include <stdlib.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { int a = atoi(argv[1]); int b = atoi(argv[2]); printf("%d", a - b); return 0; } - diff --git a/xmake/templates/c/module.binary/project/src/main.c b/xmake/templates/c/module.binary/project/src/main.c index 113930e1a..ccf4b2a77 100644 --- a/xmake/templates/c/module.binary/project/src/main.c +++ b/xmake/templates/c/module.binary/project/src/main.c @@ -1,6 +1,6 @@ #include <stdio.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { printf("hello world!\n"); return 0; } diff --git a/xmake/templates/c/module.shared/project/modules/shared/foo/src/foo.c b/xmake/templates/c/module.shared/project/modules/shared/foo/src/foo.c index a98baca02..adde214ca 100644 --- a/xmake/templates/c/module.shared/project/modules/shared/foo/src/foo.c +++ b/xmake/templates/c/module.shared/project/modules/shared/foo/src/foo.c @@ -1,27 +1,22 @@ #include <xmi.h> -static int add(lua_State* lua) { +static int add(lua_State *lua) { int a = lua_tointeger(lua, 1); int b = lua_tointeger(lua, 2); lua_pushinteger(lua, a + b); return 1; } -static int sub(lua_State* lua) { +static int sub(lua_State *lua) { int a = lua_tointeger(lua, 1); int b = lua_tointeger(lua, 2); lua_pushinteger(lua, a - b); return 1; } -int luaopen(foo, lua_State* lua) { - static const luaL_Reg funcs[] = { - {"add", add}, - {"sub", sub}, - {NULL, NULL} - }; +int luaopen(foo, lua_State *lua) { + static const luaL_Reg funcs[] = { { "add", add }, { "sub", sub }, { NULL, NULL } }; lua_newtable(lua); luaL_setfuncs(lua, funcs, 0); return 1; } - diff --git a/xmake/templates/c/module.shared/project/src/main.c b/xmake/templates/c/module.shared/project/src/main.c index 113930e1a..ccf4b2a77 100644 --- a/xmake/templates/c/module.shared/project/src/main.c +++ b/xmake/templates/c/module.shared/project/src/main.c @@ -1,6 +1,6 @@ #include <stdio.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { printf("hello world!\n"); return 0; } diff --git a/xmake/templates/c/shared/project/src/foo.h b/xmake/templates/c/shared/project/src/foo.h index b014f28e3..e15925829 100644 --- a/xmake/templates/c/shared/project/src/foo.h +++ b/xmake/templates/c/shared/project/src/foo.h @@ -1,11 +1,9 @@ #if defined(_WIN32) -# define __export __declspec(dllexport) +#define __export __declspec(dllexport) #elif defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) -# define __export __attribute__((visibility("default"))) +#define __export __attribute__((visibility("default"))) #else -# define __export +#define __export #endif __export int add(int a, int b); - - diff --git a/xmake/templates/c/shared/project/src/main.c b/xmake/templates/c/shared/project/src/main.c index a4c769408..f1c29d751 100644 --- a/xmake/templates/c/shared/project/src/main.c +++ b/xmake/templates/c/shared/project/src/main.c @@ -1,7 +1,7 @@ #include "foo.h" #include <stdio.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { printf("add(1, 2) = %d\n", add(1, 2)); return 0; } diff --git a/xmake/templates/c/static/project/src/main.c b/xmake/templates/c/static/project/src/main.c index a4c769408..f1c29d751 100644 --- a/xmake/templates/c/static/project/src/main.c +++ b/xmake/templates/c/static/project/src/main.c @@ -1,7 +1,7 @@ #include "foo.h" #include <stdio.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { printf("add(1, 2) = %d\n", add(1, 2)); return 0; } diff --git a/xmake/templates/c/tbox.console/project/src/main.c b/xmake/templates/c/tbox.console/project/src/main.c index 8cad00d22..2c7596b33 100644 --- a/xmake/templates/c/tbox.console/project/src/main.c +++ b/xmake/templates/c/tbox.console/project/src/main.c @@ -6,7 +6,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) { +tb_int_t main(tb_int_t argc, tb_char_t **argv) { if (tb_init(tb_null, tb_null)) { tb_trace_i("hello tbox!"); tb_exit(); diff --git a/xmake/templates/c/tbox.shared/project/src/_demo/main.c b/xmake/templates/c/tbox.shared/project/src/_demo/main.c index 84dad3f2b..b1e763989 100644 --- a/xmake/templates/c/tbox.shared/project/src/_demo/main.c +++ b/xmake/templates/c/tbox.shared/project/src/_demo/main.c @@ -6,7 +6,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) { +tb_int_t main(tb_int_t argc, tb_char_t **argv) { if (tb_init(tb_null, tb_null)) { tb_trace_i("hello tbox!"); tb_trace_i("add(1 + 1) = %d", add(1, 1)); diff --git a/xmake/templates/c/tbox.shared/project/src/_library/interface.h b/xmake/templates/c/tbox.shared/project/src/_library/interface.h index 398ad5d04..843ef1c98 100644 --- a/xmake/templates/c/tbox.shared/project/src/_library/interface.h +++ b/xmake/templates/c/tbox.shared/project/src/_library/interface.h @@ -11,7 +11,8 @@ */ __tb_extern_c_enter__ -__tb_export__ tb_int_t add(tb_int_t a, tb_int_t b); + __tb_export__ tb_int_t + add(tb_int_t a, tb_int_t b); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/xmake/templates/c/tbox.static/project/src/_demo/main.c b/xmake/templates/c/tbox.static/project/src/_demo/main.c index 84dad3f2b..b1e763989 100644 --- a/xmake/templates/c/tbox.static/project/src/_demo/main.c +++ b/xmake/templates/c/tbox.static/project/src/_demo/main.c @@ -6,7 +6,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * main */ -tb_int_t main(tb_int_t argc, tb_char_t** argv) { +tb_int_t main(tb_int_t argc, tb_char_t **argv) { if (tb_init(tb_null, tb_null)) { tb_trace_i("hello tbox!"); tb_trace_i("add(1 + 1) = %d", add(1, 1)); diff --git a/xmake/templates/c/tbox.static/project/src/_library/interface.c b/xmake/templates/c/tbox.static/project/src/_library/interface.c index a0ccb007b..ab0a826a6 100644 --- a/xmake/templates/c/tbox.static/project/src/_library/interface.c +++ b/xmake/templates/c/tbox.static/project/src/_library/interface.c @@ -6,7 +6,6 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t add(tb_int_t a, tb_int_t b) -{ +tb_int_t add(tb_int_t a, tb_int_t b) { return a + b; } diff --git a/xmake/templates/c/tbox.static/project/src/_library/interface.h b/xmake/templates/c/tbox.static/project/src/_library/interface.h index 33d088314..caddb8394 100644 --- a/xmake/templates/c/tbox.static/project/src/_library/interface.h +++ b/xmake/templates/c/tbox.static/project/src/_library/interface.h @@ -11,7 +11,8 @@ */ __tb_extern_c_enter__ -tb_int_t add(tb_int_t a, tb_int_t b); + tb_int_t + add(tb_int_t a, tb_int_t b); /* ////////////////////////////////////////////////////////////////////////////////////// * extern diff --git a/xmake/templates/c/xmake.cli/project/src/lni/main.c b/xmake/templates/c/xmake.cli/project/src/lni/main.c index 98a4c19ce..a4c6499ee 100644 --- a/xmake/templates/c/xmake.cli/project/src/lni/main.c +++ b/xmake/templates/c/xmake.cli/project/src/lni/main.c @@ -1,25 +1,21 @@ #include <xmake/xmake.h> static tb_byte_t const g_luafiles_data[] = { - #include "luafiles.xmz.h" +#include "luafiles.xmz.h" }; -static tb_int_t lni_test_hello(lua_State* lua) { +static tb_int_t lni_test_hello(lua_State *lua) { lua_pushliteral(lua, "hello xmake!"); return 1; } -static tb_void_t lni_initalizer(xm_engine_ref_t engine, lua_State* lua) { - static luaL_Reg const lni_test_funcs[] = { - {"hello", lni_test_hello} - , {tb_null, tb_null} - }; +static tb_void_t lni_initalizer(xm_engine_ref_t engine, lua_State *lua) { + static luaL_Reg const lni_test_funcs[] = { { "hello", lni_test_hello }, { tb_null, tb_null } }; xm_engine_register(engine, "test", lni_test_funcs); xm_engine_add_embedfiles(engine, g_luafiles_data, sizeof(g_luafiles_data)); } -tb_int_t main(tb_int_t argc, tb_char_t** argv) { - tb_char_t* taskargv[] = {"lua", "-D", "lua.main", tb_null}; +tb_int_t main(tb_int_t argc, tb_char_t **argv) { + tb_char_t *taskargv[] = { "lua", "-D", "lua.main", tb_null }; return xm_engine_run("${TARGETNAME}", argc, argv, taskargv, lni_initalizer); } - diff --git a/xmake/templates/kotlin/shared_library/project/src/main.c b/xmake/templates/kotlin/shared_library/project/src/main.c index 55e16305d..abb3f2c12 100644 --- a/xmake/templates/kotlin/shared_library/project/src/main.c +++ b/xmake/templates/kotlin/shared_library/project/src/main.c @@ -1,7 +1,7 @@ #include "libfoo_api.h" #include <stdio.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { printf("add(1, 2) = %d\n", kotlin_add(1, 2)); return 0; } diff --git a/xmake/templates/kotlin/static_library/project/src/main.c b/xmake/templates/kotlin/static_library/project/src/main.c index 55e16305d..abb3f2c12 100644 --- a/xmake/templates/kotlin/static_library/project/src/main.c +++ b/xmake/templates/kotlin/static_library/project/src/main.c @@ -1,7 +1,7 @@ #include "libfoo_api.h" #include <stdio.h> -int main(int argc, char** argv) { +int main(int argc, char **argv) { printf("add(1, 2) = %d\n", kotlin_add(1, 2)); return 0; } |
