mirror of
https://github.com/godotengine/godot.git
synced 2025-10-25 18:54:43 +00:00
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
This commit is contained in:
parent
45438e9918
commit
5dbf1809c6
1318 changed files with 140051 additions and 166004 deletions
|
|
@ -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<Variant::Type>(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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue