You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-23 15:16:17 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
@@ -44,7 +44,6 @@ typedef ShaderLanguage SL;
|
||||
namespace TestShaderLang {
|
||||
|
||||
static String _mktab(int p_level) {
|
||||
|
||||
String tb;
|
||||
for (int i = 0; i < p_level; i++) {
|
||||
tb += "\t";
|
||||
@@ -54,12 +53,10 @@ static String _mktab(int p_level) {
|
||||
}
|
||||
|
||||
static String _typestr(SL::DataType p_type) {
|
||||
|
||||
return ShaderLanguage::get_datatype_name(p_type);
|
||||
}
|
||||
|
||||
static String _prestr(SL::DataPrecision p_pres) {
|
||||
|
||||
switch (p_pres) {
|
||||
case SL::PRECISION_LOWP:
|
||||
return "lowp ";
|
||||
@@ -74,12 +71,10 @@ static String _prestr(SL::DataPrecision p_pres) {
|
||||
}
|
||||
|
||||
static String _opstr(SL::Operator p_op) {
|
||||
|
||||
return ShaderLanguage::get_operator_text(p_op);
|
||||
}
|
||||
|
||||
static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value> &p_values) {
|
||||
|
||||
switch (p_type) {
|
||||
case SL::TYPE_BOOL:
|
||||
return p_values[0].boolean ? "true" : "false";
|
||||
@@ -119,17 +114,13 @@ static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNo
|
||||
}
|
||||
|
||||
static String dump_node_code(SL::Node *p_node, int p_level) {
|
||||
|
||||
String code;
|
||||
|
||||
switch (p_node->type) {
|
||||
|
||||
case SL::Node::TYPE_SHADER: {
|
||||
|
||||
SL::ShaderNode *pnode = (SL::ShaderNode *)p_node;
|
||||
|
||||
for (Map<StringName, SL::ShaderNode::Uniform>::Element *E = pnode->uniforms.front(); E; E = E->next()) {
|
||||
|
||||
String ucode = "uniform ";
|
||||
ucode += _prestr(E->get().precision);
|
||||
ucode += _typestr(E->get().type);
|
||||
@@ -156,7 +147,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
|
||||
}
|
||||
|
||||
for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) {
|
||||
|
||||
String vcode = "varying ";
|
||||
vcode += _prestr(E->get().precision);
|
||||
vcode += _typestr(E->get().type);
|
||||
@@ -165,13 +155,11 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
|
||||
code += vcode + "\n";
|
||||
}
|
||||
for (int i = 0; i < pnode->functions.size(); i++) {
|
||||
|
||||
SL::FunctionNode *fnode = pnode->functions[i].function;
|
||||
|
||||
String header;
|
||||
header = _typestr(fnode->return_type) + " " + fnode->name + "(";
|
||||
for (int j = 0; j < fnode->arguments.size(); j++) {
|
||||
|
||||
if (j > 0)
|
||||
header += ", ";
|
||||
header += _prestr(fnode->arguments[j].precision) + _typestr(fnode->arguments[j].type) + " " + fnode->arguments[j].name;
|
||||
@@ -185,7 +173,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
|
||||
//code+=dump_node_code(pnode->body,p_level);
|
||||
} break;
|
||||
case SL::Node::TYPE_FUNCTION: {
|
||||
|
||||
} break;
|
||||
case SL::Node::TYPE_BLOCK: {
|
||||
SL::BlockNode *bnode = (SL::BlockNode *)p_node;
|
||||
@@ -193,12 +180,10 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
|
||||
//variables
|
||||
code += _mktab(p_level - 1) + "{\n";
|
||||
for (Map<StringName, SL::BlockNode::Variable>::Element *E = bnode->variables.front(); E; E = E->next()) {
|
||||
|
||||
code += _mktab(p_level) + _prestr(E->get().precision) + _typestr(E->get().type) + " " + E->key() + ";\n";
|
||||
}
|
||||
|
||||
for (int i = 0; i < bnode->statements.size(); i++) {
|
||||
|
||||
String scode = dump_node_code(bnode->statements[i], p_level);
|
||||
|
||||
if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW) {
|
||||
@@ -234,7 +219,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
|
||||
SL::OperatorNode *onode = (SL::OperatorNode *)p_node;
|
||||
|
||||
switch (onode->op) {
|
||||
|
||||
case SL::OP_ASSIGN:
|
||||
case SL::OP_ASSIGN_ADD:
|
||||
case SL::OP_ASSIGN_SUB:
|
||||
@@ -270,7 +254,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
|
||||
code += ")";
|
||||
break;
|
||||
default: {
|
||||
|
||||
code = "(" + dump_node_code(onode->arguments[0], p_level) + _opstr(onode->op) + dump_node_code(onode->arguments[1], p_level) + ")";
|
||||
break;
|
||||
}
|
||||
@@ -280,17 +263,14 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
|
||||
case SL::Node::TYPE_CONTROL_FLOW: {
|
||||
SL::ControlFlowNode *cfnode = (SL::ControlFlowNode *)p_node;
|
||||
if (cfnode->flow_op == SL::FLOW_OP_IF) {
|
||||
|
||||
code += _mktab(p_level) + "if (" + dump_node_code(cfnode->expressions[0], p_level) + ")\n";
|
||||
code += dump_node_code(cfnode->blocks[0], p_level + 1);
|
||||
if (cfnode->blocks.size() == 2) {
|
||||
|
||||
code += _mktab(p_level) + "else\n";
|
||||
code += dump_node_code(cfnode->blocks[1], p_level + 1);
|
||||
}
|
||||
|
||||
} else if (cfnode->flow_op == SL::FLOW_OP_RETURN) {
|
||||
|
||||
if (cfnode->blocks.size()) {
|
||||
code = "return " + dump_node_code(cfnode->blocks[0], p_level);
|
||||
} else {
|
||||
@@ -310,7 +290,6 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
|
||||
}
|
||||
|
||||
static Error recreate_code(void *p_str, SL::ShaderNode *p_program) {
|
||||
|
||||
String *str = (String *)p_str;
|
||||
|
||||
*str = dump_node_code(p_program, 0);
|
||||
@@ -319,7 +298,6 @@ static Error recreate_code(void *p_str, SL::ShaderNode *p_program) {
|
||||
}
|
||||
|
||||
MainLoop *test() {
|
||||
|
||||
List<String> cmdlargs = OS::get_singleton()->get_cmdline_args();
|
||||
|
||||
if (cmdlargs.empty()) {
|
||||
@@ -360,7 +338,6 @@ MainLoop *test() {
|
||||
Error err = sl.compile(code, dt, rm, types);
|
||||
|
||||
if (err) {
|
||||
|
||||
print_line("Error at line: " + rtos(sl.get_error_line()) + ": " + sl.get_error_text());
|
||||
return NULL;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user