summaryrefslogtreecommitdiff
path: root/fluid/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'fluid/nodes')
-rw-r--r--fluid/nodes/Function_Node.cxx19
-rw-r--r--fluid/nodes/Function_Node.h10
-rw-r--r--fluid/nodes/Node.cxx6
3 files changed, 14 insertions, 21 deletions
diff --git a/fluid/nodes/Function_Node.cxx b/fluid/nodes/Function_Node.cxx
index 095b3fc5f..3e98a898f 100644
--- a/fluid/nodes/Function_Node.cxx
+++ b/fluid/nodes/Function_Node.cxx
@@ -1514,8 +1514,7 @@ Class_Node Class_Node::prototype;
Class_Node::Class_Node() :
Node(),
subclass_of(nullptr),
- public_(1),
- class_prefix(nullptr)
+ public_(1)
{ }
/**
@@ -1524,8 +1523,6 @@ Class_Node::Class_Node() :
Class_Node::~Class_Node() {
if (subclass_of)
free((void*)subclass_of);
- if (class_prefix)
- free((void*)class_prefix);
}
/**
@@ -1536,14 +1533,6 @@ int Class_Node::is_public() const {
}
/**
- Set the prefixx string.
- */
-void Class_Node::prefix(const char*p) {
- free((void*) class_prefix);
- class_prefix=fl_strdup(p ? p : "" );
-}
-
-/**
Make a new class node.
\param[in] strategy add after current or as last child
\return new Class node
@@ -1559,7 +1548,7 @@ Node *Class_Node::make(Strategy strategy) {
}
Class_Node *o = new Class_Node();
o->name("UserInterface");
- o->class_prefix = nullptr;
+ o->prefix("");
o->subclass_of = nullptr;
o->public_ = 1;
o->add(anchor, strategy);
@@ -1615,8 +1604,8 @@ void Class_Node::write_code1(fld::io::Code_Writer& f) {
write_public_state = 0;
f.write_h("\n");
write_comment_h(f);
- if (prefix() && strlen(prefix()))
- f.write_h("class %s %s ", prefix(), name());
+ if (!prefix().empty())
+ f.write_h("class %s %s ", prefix().c_str(), name());
else
f.write_h("class %s ", name());
if (subclass_of) f.write_h(": %s ", subclass_of);
diff --git a/fluid/nodes/Function_Node.h b/fluid/nodes/Function_Node.h
index 56a0046e0..282f33312 100644
--- a/fluid/nodes/Function_Node.h
+++ b/fluid/nodes/Function_Node.h
@@ -34,6 +34,8 @@
#include <stdarg.h>
#include <stdlib.h>
+#include <string>
+
extern class Class_Node *current_class;
int has_toplevel_function(const char *rtype, const char *sig);
@@ -271,7 +273,7 @@ public:
private:
const char* subclass_of;
char public_;
- const char* class_prefix;
+ std::string prefix_;
public:
Class_Node();
~Class_Node();
@@ -298,8 +300,10 @@ public:
void visibility(char v) { public_ = v; }
// class prefix attribute access
- void prefix(const char* p);
- const char* prefix() const {return class_prefix;}
+ /** Set the text between `class` and the class name */
+ void prefix(const std::string& p) { prefix_ = p; }
+ /** Get the text between `class` and the class name */
+ std::string prefix() const { return prefix_; }
};
#endif // FLUID_NODES_FUNCTION_NODE_H
diff --git a/fluid/nodes/Node.cxx b/fluid/nodes/Node.cxx
index 0b1cb2d4d..7557e61f4 100644
--- a/fluid/nodes/Node.cxx
+++ b/fluid/nodes/Node.cxx
@@ -889,9 +889,9 @@ void Node::write(fld::io::Project_Writer &f) {
f.write_word(type_name());
if (is_class()) {
- const char * p = ((Class_Node*)this)->prefix();
- if (p && strlen(p))
- f.write_word(p);
+ auto p = ((Class_Node*)this)->prefix();
+ if (!p.empty())
+ f.write_word(p.c_str());
}
f.write_word(name());