summaryrefslogtreecommitdiff
path: root/fluid/nodes
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2026-01-04 20:43:26 +0100
committerMatthias Melcher <github@matthiasm.com>2026-01-04 20:43:34 +0100
commit7306b66d99fb529d65ddda1ea8e093454d7005e1 (patch)
tree13803f53b2e921985abe54804b8d9131c46b9c3d /fluid/nodes
parent811a188bbf276841365f2ad4b11197f5820fe571 (diff)
Fluid: Add automated MergeBack
Diffstat (limited to 'fluid/nodes')
-rw-r--r--fluid/nodes/Function_Node.cxx22
-rw-r--r--fluid/nodes/Function_Node.h11
2 files changed, 16 insertions, 17 deletions
diff --git a/fluid/nodes/Function_Node.cxx b/fluid/nodes/Function_Node.cxx
index 42c3f3996..66e425533 100644
--- a/fluid/nodes/Function_Node.cxx
+++ b/fluid/nodes/Function_Node.cxx
@@ -1226,8 +1226,6 @@ DeclBlock_Node::DeclBlock_Node()
Destructor.
*/
DeclBlock_Node::~DeclBlock_Node() {
- if (after)
- ::free((void*)after);
}
/**
@@ -1253,7 +1251,7 @@ Node *DeclBlock_Node::make(Strategy strategy) {
DeclBlock_Node *o = new DeclBlock_Node();
o->name("#if 1");
o->write_map_ = CODE_IN_SOURCE;
- o->after = fl_strdup("#endif");
+ o->end_code_ = "#endif";
o->add(anchor, strategy);
o->factory = this;
return o;
@@ -1272,7 +1270,7 @@ void DeclBlock_Node::write_properties(fld::io::Project_Writer &f) {
if (write_map_ != CODE_IN_SOURCE)
f.write_string("map %d", write_map_);
f.write_string("after");
- f.write_word(after);
+ f.write_word(end_code().c_str());
}
/**
@@ -1286,7 +1284,7 @@ void DeclBlock_Node::read_property(fld::io::Project_Reader &f, const char *c) {
} else if(!strcmp(c,"map")) {
write_map_ = (int)atol(f.read_word());
} else if (!strcmp(c,"after")) {
- storestring(f.read_word(),after);
+ end_code(f.read_word());
} else {
Node::read_property(f, c);
}
@@ -1317,12 +1315,11 @@ 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) {
- const char* c = after;
- if (c && *c) {
+ if (!end_code().empty()) {
if (write_map_ & STATIC_IN_HEADER)
- f.write_h("%s\n", c);
+ f.write_h("%s\n", end_code().c_str());
if (write_map_ & STATIC_IN_SOURCE)
- f.write_c("%s\n", c);
+ f.write_c("%s\n", end_code().c_str());
}
}
@@ -1344,12 +1341,11 @@ 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) {
- const char* c = after;
- if (c && *c) {
+ if (!end_code().empty()) {
if (write_map_ & CODE_IN_HEADER)
- f.write_h("%s\n", c);
+ f.write_h("%s\n", end_code().c_str());
if (write_map_ & CODE_IN_SOURCE)
- f.write_c("%s\n", c);
+ f.write_c("%s\n", end_code().c_str());
}
}
diff --git a/fluid/nodes/Function_Node.h b/fluid/nodes/Function_Node.h
index 33bcc1849..c35a26705 100644
--- a/fluid/nodes/Function_Node.h
+++ b/fluid/nodes/Function_Node.h
@@ -208,8 +208,9 @@ public:
STATIC_IN_HEADER = 4,
STATIC_IN_SOURCE = 8
};
+
private:
- const char* after { nullptr }; ///< code after all children of this block
+ std::string end_code_; ///< code after all children of this block
int write_map_ { CODE_IN_SOURCE }; ///< see enum above
public:
@@ -229,8 +230,8 @@ public:
int is_public() const override;
Type type() const override { return Type::DeclBlock; }
bool is_a(Type inType) const override { return (inType==Type::DeclBlock) ? true : super::is_a(inType); }
- const char *end_code() { return after; }
- void end_code(const char *c) { storestring(c, after); }
+ std::string end_code() { return end_code_; }
+ void end_code(const std::string& p) { storestring(p, end_code_); }
int write_map() { return write_map_; }
void write_map(int v) { write_map_ = v; }
};
@@ -242,6 +243,7 @@ class Comment_Node : public Node
public:
typedef Node super;
static Comment_Node prototype;
+
private:
char in_c_, in_h_, style_;
@@ -270,17 +272,18 @@ class Class_Node : public Node
public:
typedef Node super;
static Class_Node prototype;
+
private:
std::string base_class_;
std::string prefix_;
char public_;
+
public:
Class_Node();
~Class_Node();
// state variables for output:
char write_public_state; // true when public: has been printed
Class_Node* parent_class; // save class if nested
-//
Node *make(Strategy strategy) override;
void write_code1(fld::io::Code_Writer& f) override;
void write_code2(fld::io::Code_Writer& f) override;