MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / generate_code

Method generate_code

scene/resources/visual_shader.cpp:622–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

620}
621
622String VisualShaderNodeCustom::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
623 ERR_FAIL_COND_V(!GDVIRTUAL_IS_OVERRIDDEN(_get_code), "");
624 TypedArray<String> input_vars;
625 for (int i = 0; i < get_input_port_count(); i++) {
626 input_vars.push_back(p_input_vars[i]);
627 }
628 TypedArray<String> output_vars;
629 for (int i = 0; i < get_output_port_count(); i++) {
630 output_vars.push_back(p_output_vars[i]);
631 }
632
633 String _code;
634 GDVIRTUAL_CALL(_get_code, input_vars, output_vars, p_mode, p_type, _code);
635 if (_is_valid_code(_code)) {
636 String code = " {\n";
637 bool nend = _code.ends_with("\n");
638 _code = _code.insert(0, " ");
639 _code = _code.replace("\n", "\n ");
640 code += _code;
641 if (!nend) {
642 code += "\n }";
643 } else {
644 code.remove_at(code.size() - 1);
645 code += "}";
646 }
647 code += "\n";
648 return code;
649 }
650 return String();
651}
652
653String VisualShaderNodeCustom::generate_global_per_node(Shader::Mode p_mode, int p_id) const {
654 String _code;

Callers 1

_write_nodeMethod · 0.45

Calls 11

vformatFunction · 0.85
ends_withMethod · 0.80
contains_charMethod · 0.80
get_slicecMethod · 0.80
sizeMethod · 0.65
StringClass · 0.50
push_backMethod · 0.45
insertMethod · 0.45
replaceMethod · 0.45
remove_atMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected