From 5dbf1809c6e3e905b94b8764e99491e608122261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 5 Mar 2017 16:44:50 +0100 Subject: A Whole New World (clang-format edition) I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code --- platform/javascript/javascript_eval.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'platform/javascript/javascript_eval.cpp') diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp index d84c8bf040..897c2276bb 100644 --- a/platform/javascript/javascript_eval.cpp +++ b/platform/javascript/javascript_eval.cpp @@ -31,16 +31,20 @@ #include "javascript_eval.h" #include "emscripten.h" -JavaScript *JavaScript::singleton=NULL; +JavaScript *JavaScript::singleton = NULL; JavaScript *JavaScript::get_singleton() { return singleton; } -Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) { +Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { - union { int i; double d; char* s; } js_data[4]; + union { + int i; + double d; + char *s; + } js_data[4]; /* clang-format off */ Variant::Type return_type = static_cast(EM_ASM_INT({ @@ -127,21 +131,20 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) { }, js_data, sizeof *js_data, p_code.utf8().get_data(), p_use_global_exec_context)); /* clang-format on */ - switch(return_type) { + switch (return_type) { case Variant::BOOL: return !!js_data->i; case Variant::INT: return js_data->i; case Variant::REAL: return js_data->d; - case Variant::STRING: - { - String str = String::utf8(js_data->s); - /* clang-format off */ + case Variant::STRING: { + String str = String::utf8(js_data->s); + /* clang-format off */ EM_ASM_({ _free($0); }, js_data->s); - /* clang-format on */ - return str; - } + /* clang-format on */ + return str; + } case Variant::VECTOR2: return Vector2(js_data[0].d, js_data[1].d); case Variant::VECTOR3: @@ -149,7 +152,7 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) { case Variant::RECT2: return Rect2(js_data[0].d, js_data[1].d, js_data[2].d, js_data[3].d); case Variant::COLOR: - return Color(js_data[0].d/255., js_data[1].d/255., js_data[2].d/255., js_data[3].d); + return Color(js_data[0].d / 255., js_data[1].d / 255., js_data[2].d / 255., js_data[3].d); } return Variant(); } @@ -166,7 +169,6 @@ JavaScript::JavaScript() { } JavaScript::~JavaScript() { - } #endif // JAVASCRIPT_EVAL_ENABLED -- cgit v1.2.3