diff options
Diffstat (limited to 'fluid/nodes/Function_Node.cxx')
| -rw-r--r-- | fluid/nodes/Function_Node.cxx | 181 |
1 files changed, 56 insertions, 125 deletions
diff --git a/fluid/nodes/Function_Node.cxx b/fluid/nodes/Function_Node.cxx index daf5822c0..c5dcf7596 100644 --- a/fluid/nodes/Function_Node.cxx +++ b/fluid/nodes/Function_Node.cxx @@ -227,7 +227,7 @@ Node *Function_Node::make(Strategy strategy) { - "C" is written if we want a C signature instead of C++ - "return_type" is followed by the return type of the function */ -void Function_Node::write_properties(fld::io::Project_Writer &f) { +void Function_Node::write_properties(Project_Writer &f) { Node::write_properties(f); switch (public_) { case 0: f.write_string("private"); break; @@ -244,7 +244,7 @@ void Function_Node::write_properties(fld::io::Project_Writer &f) { Read function specific properties fron an .fl file. \param[in] c read from this string */ -void Function_Node::read_property(fld::io::Project_Reader &f, const char *c) { +void Function_Node::read_property(Project_Reader &f, const char *c) { if (!strcmp(c,"private")) { public_ = 0; } else if (!strcmp(c,"protected")) { @@ -321,9 +321,9 @@ static void clean_function_for_implementation(char *out, const char *function_na /** Write the code for the source and the header file. This writes the code that goes \b before all children of this class. - \see write_code2(fld::io::Code_Writer& f) + \see write_code2(Code_Writer& f) */ -void Function_Node::write_code1(fld::io::Code_Writer& f) { +void Function_Node::write_code1(Code_Writer& f) { constructor=0; havewidgets = 0; Node *child; @@ -457,9 +457,9 @@ void Function_Node::write_code1(fld::io::Code_Writer& f) { /** Write the code for the source and the header file. This writes the code that goes \b after all children of this class. - \see write_code1(fld::io::Code_Writer& f) + \see write_code1(Code_Writer& f) */ -void Function_Node::write_code2(fld::io::Code_Writer& f) { +void Function_Node::write_code2(Code_Writer& f) { Node *child; const char *var = "w"; char havechildren = 0; @@ -556,7 +556,7 @@ void Code_Node::open() { /** Grab changes from an external editor and write this node. */ -void Code_Node::write(fld::io::Project_Writer &f) { +void Code_Node::write(Project_Writer &f) { // External editor changes? If so, load changes into ram, update mtime/size if ( handle_editor_changes() == 1 ) { Fluid.main_window->redraw(); // tell fluid to redraw; edits may affect tree's contents @@ -567,7 +567,7 @@ void Code_Node::write(fld::io::Project_Writer &f) { /** Write the code block with the correct indentation. */ -void Code_Node::write_code1(fld::io::Code_Writer& f) { +void Code_Node::write_code1(Code_Writer& f) { // External editor changes? If so, load changes into ram, update mtime/size if ( handle_editor_changes() == 1 ) { Fluid.main_window->redraw(); // tell fluid to redraw; edits may affect tree's contents @@ -673,7 +673,7 @@ Node *CodeBlock_Node::make(Strategy strategy) { - "after" is followed by the code that comes after the children The "before" code is stored in the name() field. */ -void CodeBlock_Node::write_properties(fld::io::Project_Writer &f) { +void CodeBlock_Node::write_properties(Project_Writer &f) { Node::write_properties(f); if (end_code()[0]) { f.write_string("after"); @@ -684,7 +684,7 @@ void CodeBlock_Node::write_properties(fld::io::Project_Writer &f) { /** Read the node specific properties. */ -void CodeBlock_Node::read_property(fld::io::Project_Reader &f, const char *c) { +void CodeBlock_Node::read_property(Project_Reader &f, const char *c) { if (!strcmp(c,"after")) { end_code(f.read_word()); } else { @@ -702,7 +702,7 @@ void CodeBlock_Node::open() { /** Write the "before" code. */ -void CodeBlock_Node::write_code1(fld::io::Code_Writer& f) { +void CodeBlock_Node::write_code1(Code_Writer& f) { const char* c = name(); f.write_c("%s%s {\n", f.indent(), c ? c : ""); f.indentation++; @@ -711,7 +711,7 @@ void CodeBlock_Node::write_code1(fld::io::Code_Writer& f) { /** Write the "after" code. */ -void CodeBlock_Node::write_code2(fld::io::Code_Writer& f) { +void CodeBlock_Node::write_code2(Code_Writer& f) { f.indentation--; if (end_code()[0]) f.write_c("%s} %s\n", f.indent(), end_code()); @@ -775,7 +775,7 @@ Node *Decl_Node::make(Strategy strategy) { - "private"/"public"/"protected" - "local"/"global" if this is static or not */ -void Decl_Node::write_properties(fld::io::Project_Writer &f) { +void Decl_Node::write_properties(Project_Writer &f) { Node::write_properties(f); switch (public_) { case 0: f.write_string("private"); break; @@ -791,7 +791,7 @@ void Decl_Node::write_properties(fld::io::Project_Writer &f) { /** Read the specific properties. */ -void Decl_Node::read_property(fld::io::Project_Reader &f, const char *c) { +void Decl_Node::read_property(Project_Reader &f, const char *c) { if (!strcmp(c,"public")) { public_ = 1; } else if (!strcmp(c,"private")) { @@ -819,7 +819,7 @@ void Decl_Node::open() { \todo There are a lot of side effect in this node depending on the given text and the parent node. They need to be understood and documented. */ -void Decl_Node::write_code1(fld::io::Code_Writer& f) { +void Decl_Node::write_code1(Code_Writer& f) { const char* c = name(); if (!c) return; // handle a few keywords differently if inside a class @@ -934,7 +934,7 @@ Node *Data_Node::make(Strategy strategy) { - "filename" followed by the filename of the file to inline - "textmode" if data is written in ASCII vs. binary */ -void Data_Node::write_properties(fld::io::Project_Writer &f) { +void Data_Node::write_properties(Project_Writer &f) { Decl_Node::write_properties(f); if (filename()[0]) { f.write_string("filename"); @@ -943,28 +943,19 @@ void Data_Node::write_properties(fld::io::Project_Writer &f) { switch (output_format_) { case 1: f.write_string("textmode"); break; case 2: f.write_string("compressed"); break; - case 3: f.write_string("std_binary"); break; - case 4: f.write_string("std_textmode"); break; - case 5: f.write_string("std_compressed"); break; } } /** Read specific properties. */ -void Data_Node::read_property(fld::io::Project_Reader &f, const char *c) { +void Data_Node::read_property(Project_Reader &f, const char *c) { if (!strcmp(c,"filename")) { storestring(f.read_word(), filename_, 1); } else if (!strcmp(c,"textmode")) { output_format_ = 1; } else if (!strcmp(c,"compressed")) { output_format_ = 2; - } else if (!strcmp(c,"std_binary")) { - output_format_ = 3; - } else if (!strcmp(c,"std_textmode")) { - output_format_ = 4; - } else if (!strcmp(c,"std_compressed")) { - output_format_ = 5; } else { Decl_Node::read_property(f, c); } @@ -980,7 +971,7 @@ void Data_Node::open() { /** Write the content of the external file inline into the source code. */ -void Data_Node::write_code1(fld::io::Code_Writer& f) { +void Data_Node::write_code1(Code_Writer& f) { const char *message = 0; const char *c = name(); if (!c) return; @@ -1002,7 +993,7 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) { if (nData) { data = (char*)calloc(nData, 1); if (fread(data, nData, 1, f)==0) { /* use default */ } - if ((output_format_ == 2) || (output_format_ == 5)) { + if (output_format_ == 2) { uncompressedDataSize = nData; uLong nzData = compressBound(nData); Bytef *zdata = (Bytef*)::malloc(nzData); @@ -1020,47 +1011,27 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) { } if (is_in_class()) { f.write_public(public_); - if ((output_format_ == 1) || (output_format_ == 4)) { + if (output_format_ == 1) { f.write_c("\n"); write_comment_c(f); - if (output_format_ == 1) { - f.write_h("%sstatic const char *%s;\n", f.indent(1), c); - f.write_c("const char *%s::%s = /* text inlined from %s */\n", class_name(1), c, fn); - } else { - f.write_h_once("#include <string>"); - f.write_h("%sstatic const std::string %s;\n", f.indent(1), c); - f.write_c("const std::string %s::%s = /* text inlined from %s */\n", class_name(1), c, fn); - } + f.write_h("%sstatic const char *%s;\n", f.indent(1), c); + f.write_c("const char *%s::%s = /* text inlined from %s */\n", class_name(1), c, fn); if (message) f.write_c("#error %s %s\n", message, fn); f.write_cstring(data, nData); - } else if ((output_format_ == 2) || (output_format_ == 5)) { + } else if (output_format_ == 2) { f.write_h("%sstatic int %s_size;\n", f.indent(1), c); f.write_c("\n"); write_comment_c(f); f.write_c("int %s::%s_size = %d;\n", class_name(1), c, uncompressedDataSize); - if (output_format_ == 2) { - f.write_h("%sstatic unsigned char %s[%d];\n", f.indent(1), c, nData); - f.write_c("unsigned char %s::%s[%d] = /* data compressed and inlined from %s */\n", class_name(1), c, nData, fn); - } else { - f.write_h_once("#include <stdint.h>"); - f.write_h_once("#include <vector>"); - f.write_h("%sstatic std::vector<uint8_t> %s;\n", f.indent(1), c); - f.write_c("std::vector<uint8_t> %s::%s = /* data compressed and inlined from %s */\n", class_name(1), c, fn); - } + f.write_h("%sstatic unsigned char %s[%d];\n", f.indent(1), c, nData); + f.write_c("unsigned char %s::%s[%d] = /* data compressed and inlined from %s */\n", class_name(1), c, nData, fn); if (message) f.write_c("#error %s %s\n", message, fn); f.write_cdata(data, nData); } else { f.write_c("\n"); write_comment_c(f); - if (output_format_ == 0) { - f.write_h("%sstatic unsigned char %s[%d];\n", f.indent(1), c, nData); - f.write_c("unsigned char %s::%s[%d] = /* data inlined from %s */\n", class_name(1), c, nData, fn); - } else { - f.write_h_once("#include <stdint.h>"); - f.write_h_once("#include <vector>"); - f.write_h("%sstatic std::vector<uint8_t> %s;\n", f.indent(1), c); - f.write_c("std::vector<uint8_t> %s::%s = /* data inlined from %s */\n", class_name(1), c, fn); - } + f.write_h("%sstatic unsigned char %s[%d];\n", f.indent(1), c, nData); + f.write_c("unsigned char %s::%s[%d] = /* data inlined from %s */\n", class_name(1), c, nData, fn); if (message) f.write_c("#error %s %s\n", message, fn); f.write_cdata(data, nData); } @@ -1069,47 +1040,27 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) { // the "header only" option does not apply here! if (public_) { if (static_) { - if ((output_format_ == 1) || (output_format_ == 4)) { + if (output_format_ == 1) { f.write_c("\n"); write_comment_c(f); - if (output_format_ == 1) { - f.write_h("extern const char *%s;\n", c); - f.write_c("const char *%s = /* text inlined from %s */\n", c, fn); - } else { - f.write_h_once("#include <string>"); - f.write_h("extern const std::string %s;\n", c); - f.write_c("const std::string %s = /* text inlined from %s */\n", c, fn); - } + f.write_h("extern const char *%s;\n", c); + f.write_c("const char *%s = /* text inlined from %s */\n", c, fn); if (message) f.write_c("#error %s %s\n", message, fn); f.write_cstring(data, nData); - } else if ((output_format_ == 2) || (output_format_ == 5)) { + } else if (output_format_ == 2) { f.write_h("extern int %s_size;\n", c); f.write_c("\n"); write_comment_c(f); f.write_c("int %s_size = %d;\n", c, uncompressedDataSize); - if (output_format_ == 2) { - f.write_h("extern unsigned char %s[%d];\n", c, nData); - f.write_c("unsigned char %s[%d] = /* data compressed and inlined from %s */\n", c, nData, fn); - } else { - f.write_h_once("#include <stdint.h>"); - f.write_h_once("#include <vector>"); - f.write_h("extern std::vector<uint8_t> %s;\n", c); - f.write_c("std::vector<uint8_t> %s = /* data compressed and inlined from %s */\n", c, fn); - } + f.write_h("extern unsigned char %s[%d];\n", c, nData); + f.write_c("unsigned char %s[%d] = /* data compressed and inlined from %s */\n", c, nData, fn); if (message) f.write_c("#error %s %s\n", message, fn); f.write_cdata(data, nData); } else { f.write_c("\n"); write_comment_c(f); - if (output_format_ == 0) { - f.write_h("extern unsigned char %s[%d];\n", c, nData); - f.write_c("unsigned char %s[%d] = /* data inlined from %s */\n", c, nData, fn); - } else { - f.write_h_once("#include <stdint.h>"); - f.write_h_once("#include <vector>"); - f.write_h("extern std::vector<uint8_t> %s;\n", c); - f.write_c("std::vector<uint8_t> %s = /* data inlined from %s */\n", c, fn); - } + f.write_h("extern unsigned char %s[%d];\n", c, nData); + f.write_c("unsigned char %s[%d] = /* data inlined from %s */\n", c, nData, fn); if (message) f.write_c("#error %s %s\n", message, fn); f.write_cdata(data, nData); } @@ -1125,41 +1076,21 @@ void Data_Node::write_code1(fld::io::Code_Writer& f) { } else { f.write_c("\n"); write_comment_c(f); - if ((output_format_ == 1) || (output_format_ == 4)) { - if (output_format_ == 1) { - if (static_) f.write_c("static "); - f.write_c("const char *%s = /* text inlined from %s */\n", c, fn); - } else { - f.write_c_once("#include <string>"); - if (static_) f.write_c("static "); - f.write_c("const std::string %s = /* text inlined from %s */\n", c, fn); - } + if (output_format_ == 1) { + if (static_) f.write_c("static "); + f.write_c("const char *%s = /* text inlined from %s */\n", c, fn); if (message) f.write_c("#error %s %s\n", message, fn); f.write_cstring(data, nData); - } else if ((output_format_ == 2) || (output_format_ == 5)) { + } else if (output_format_ == 2) { if (static_) f.write_c("static "); f.write_c("int %s_size = %d;\n", c, uncompressedDataSize); - if (output_format_ == 2) { - if (static_) f.write_c("static "); - f.write_c("unsigned char %s[%d] = /* data compressed and inlined from %s */\n", c, nData, fn); - } else { - f.write_c_once("#include <stdint.h>"); - f.write_c_once("#include <vector>"); - if (static_) f.write_c("static "); - f.write_c("std::vector<uint8_t> %s = /* data compressed and inlined from %s */\n", c, fn); - } + if (static_) f.write_c("static "); + f.write_c("unsigned char %s[%d] = /* data compressed and inlined from %s */\n", c, nData, fn); if (message) f.write_c("#error %s %s\n", message, fn); f.write_cdata(data, nData); } else { - if (output_format_ == 0) { - if (static_) f.write_c("static "); - f.write_c("unsigned char %s[%d] = /* data inlined from %s */\n", c, nData, fn); - } else { - f.write_c_once("#include <stdint.h>"); - f.write_c_once("#include <vector>"); - if (static_) f.write_c("static "); - f.write_c("std::vector<uint8_t> %s = /* data inlined from %s */\n", c, fn); - } + if (static_) f.write_c("static "); + f.write_c("unsigned char %s[%d] = /* data inlined from %s */\n", c, nData, fn); if (message) f.write_c("#error %s %s\n", message, fn); f.write_cdata(data, nData); } @@ -1234,7 +1165,7 @@ Node *DeclBlock_Node::make(Strategy strategy) { - "public"/"protected" - "after" followed by the second code block. */ -void DeclBlock_Node::write_properties(fld::io::Project_Writer &f) { +void DeclBlock_Node::write_properties(Project_Writer &f) { Node::write_properties(f); // deprecated if (is_public()) f.write_string("public"); @@ -1248,7 +1179,7 @@ void DeclBlock_Node::write_properties(fld::io::Project_Writer &f) { /** Read the specific properties. */ -void DeclBlock_Node::read_property(fld::io::Project_Reader &f, const char *c) { +void DeclBlock_Node::read_property(Project_Reader &f, const char *c) { if(!strcmp(c,"public")) { write_map_ |= CODE_IN_HEADER; } else if(!strcmp(c,"protected")) { @@ -1273,7 +1204,7 @@ void DeclBlock_Node::open() { Write the \b before static code to the source file, and to the header file if declared public. The before code is stored in the name() field. */ -void DeclBlock_Node::write_static(fld::io::Code_Writer& f) { +void DeclBlock_Node::write_static(Code_Writer& f) { const char* c = name(); if (c && *c) { if (write_map_ & STATIC_IN_HEADER) @@ -1286,7 +1217,7 @@ void DeclBlock_Node::write_static(fld::io::Code_Writer& f) { /** Write the \b after static code to the source file, and to the header file if declared public. */ -void DeclBlock_Node::write_static_after(fld::io::Code_Writer& f) { +void DeclBlock_Node::write_static_after(Code_Writer& f) { if (end_code()[0]) { if (write_map_ & STATIC_IN_HEADER) f.write_h("%s\n", end_code()); @@ -1299,7 +1230,7 @@ void DeclBlock_Node::write_static_after(fld::io::Code_Writer& f) { Write the \b before code to the source file, and to the header file if declared public. The before code is stored in the name() field. */ -void DeclBlock_Node::write_code1(fld::io::Code_Writer& f) { +void DeclBlock_Node::write_code1(Code_Writer& f) { const char* c = name(); if (c && *c) { if (write_map_ & CODE_IN_HEADER) @@ -1312,7 +1243,7 @@ void DeclBlock_Node::write_code1(fld::io::Code_Writer& f) { /** Write the \b after code to the source file, and to the header file if declared public. */ -void DeclBlock_Node::write_code2(fld::io::Code_Writer& f) { +void DeclBlock_Node::write_code2(Code_Writer& f) { if (end_code()[0]) { if (write_map_ & CODE_IN_HEADER) f.write_h("%s\n", end_code()); @@ -1363,7 +1294,7 @@ Node *Comment_Node::make(Strategy strategy) { - "in_source"/"not_in_source" if the comment will be written to the source code - "in_header"/"not_in_header" if the comment will be written to the header file */ -void Comment_Node::write_properties(fld::io::Project_Writer &f) { +void Comment_Node::write_properties(Project_Writer &f) { Node::write_properties(f); if (in_c_) f.write_string("in_source"); else f.write_string("not_in_source"); if (in_h_) f.write_string("in_header"); else f.write_string("not_in_header"); @@ -1372,7 +1303,7 @@ void Comment_Node::write_properties(fld::io::Project_Writer &f) { /** Read extra properties. */ -void Comment_Node::read_property(fld::io::Project_Reader &f, const char *c) { +void Comment_Node::read_property(Project_Reader &f, const char *c) { if (!strcmp(c,"in_source")) { in_c_ = 1; } else if (!strcmp(c,"not_in_source")) { @@ -1418,7 +1349,7 @@ void Comment_Node::open() { /** Write the comment to the files. */ -void Comment_Node::write_code1(fld::io::Code_Writer& f) { +void Comment_Node::write_code1(Code_Writer& f) { const char* c = name(); if (!c) return; if (!in_c_ && !in_h_) return; @@ -1514,7 +1445,7 @@ Node *Class_Node::make(Strategy strategy) { - ":" followed by the super class - "private"/"protected" */ -void Class_Node::write_properties(fld::io::Project_Writer &f) { +void Class_Node::write_properties(Project_Writer &f) { Node::write_properties(f); if (base_class()[0]) { f.write_string(":"); @@ -1529,7 +1460,7 @@ void Class_Node::write_properties(fld::io::Project_Writer &f) { /** Read additional properties. */ -void Class_Node::read_property(fld::io::Project_Reader &f, const char *c) { +void Class_Node::read_property(Project_Reader &f, const char *c) { if (!strcmp(c,"private")) { public_ = 0; } else if (!strcmp(c,"protected")) { @@ -1551,7 +1482,7 @@ void Class_Node::open() { /** Write the header code that declares this class. */ -void Class_Node::write_code1(fld::io::Code_Writer& f) { +void Class_Node::write_code1(Code_Writer& f) { parent_class = current_class; current_class = this; write_public_state = 0; @@ -1570,7 +1501,7 @@ void Class_Node::write_code1(fld::io::Code_Writer& f) { /** Write the header code that ends the declaration of this class. */ -void Class_Node::write_code2(fld::io::Code_Writer& f) { +void Class_Node::write_code2(Code_Writer& f) { f.write_h("};\n"); current_class = parent_class; } |
