summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2009-09-23 20:08:30 +0000
committerMatthias Melcher <fltk@matthiasm.com>2009-09-23 20:08:30 +0000
commite0831b530fc2194eff166bb9437e068fd402cec5 (patch)
tree34be6387e0cc08e2f860f7e3d2ce7ef70266145a
parentbcd43ecb7d30039bb838542ed7643383c5b20a59 (diff)
Empty functions in Fluid no onger create an implementation (STR 2259)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6897 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES2
-rw-r--r--fluid/Fl_Function_Type.cxx47
2 files changed, 35 insertions, 14 deletions
diff --git a/CHANGES b/CHANGES
index e4c665472..9f211d7cf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
CHANGES IN FLTK 1.3.0
+ - Empty functions in Fluid no longer create an
+ implementation (STR #2259)
- Fixed Fluid dependency on X11 (STR #2261)
- Updated the bundled libpng to v1.2.40 (released Sep. 10, 2009)
- Fixed Fl_Choice contrast with light-on-dark settings (STR #2219)
diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx
index 94d3a9da3..d2e1f2c82 100644
--- a/fluid/Fl_Function_Type.cxx
+++ b/fluid/Fl_Function_Type.cxx
@@ -244,15 +244,23 @@ void Fl_Function_Type::write_code1() {
constructor=0;
havewidgets = 0;
Fl_Type *child;
- for (child = next; child && child->level > level; child = child->next)
+ // if the function has no children (hence no body), Fluid will not generate
+ // the function either. This is great if you decide to implement that function
+ // inside another module
+ char havechildren = 0;
+ for (child = next; child && child->level > level; child = child->next) {
+ havechildren = 1;
if (child->is_widget()) {
havewidgets = 1;
break;
}
- write_c("\n");
- if (ismain())
- write_c("int main(int argc, char **argv) {\n");
- else {
+ }
+ if (havechildren)
+ write_c("\n");
+ if (ismain()) {
+ if (havechildren)
+ write_c("int main(int argc, char **argv) {\n");
+ } else {
const char* rtype = return_type;
const char* star = "";
// from matt: let the user type "static " at the start of type
@@ -274,7 +282,8 @@ void Fl_Function_Type::write_code1() {
const char* k = class_name(0);
if (k) {
- write_comment_c();
+ if (havechildren)
+ write_comment_c();
write_public(public_);
if (name()[0] == '~')
constructor = 1;
@@ -287,7 +296,8 @@ void Fl_Function_Type::write_code1() {
if (is_virtual) write_h("virtual ");
if (!constructor) {
write_h("%s%s ", rtype, star);
- write_c("%s%s ", rtype, star);
+ if (havechildren)
+ write_c("%s%s ", rtype, star);
}
// if this is a subclass, only write_h() the part before the ':'
@@ -330,16 +340,20 @@ void Fl_Function_Type::write_code1() {
}
*sptr = '\0';
- write_c("%s::%s {\n", k, s);
+ if (havechildren)
+ write_c("%s::%s {\n", k, s);
} else {
- write_comment_c();
+ if (havechildren)
+ write_comment_c();
if (public_) {
if (cdecl_)
write_h("extern \"C\" { %s%s %s; }\n", rtype, star, name());
else
write_h("%s%s %s;\n", rtype, star, name());
+ } else {
+ if (havechildren)
+ write_c("static ");
}
- else write_c("static ");
// write everything but the default parameters (if any)
char s[1024], *sptr;
@@ -368,7 +382,8 @@ void Fl_Function_Type::write_code1() {
}
*sptr = '\0';
- write_c("%s%s %s {\n", rtype, star, s);
+ if (havechildren)
+ write_c("%s%s %s {\n", rtype, star, s);
}
}
@@ -379,16 +394,20 @@ void Fl_Function_Type::write_code1() {
void Fl_Function_Type::write_code2() {
Fl_Type *child;
const char *var = "w";
- for (child = next; child && child->level > level; child = child->next)
+ char havechildren = 0;
+ for (child = next; child && child->level > level; child = child->next) {
+ havechildren = 1;
if (child->is_window() && child->name()) var = child->name();
+ }
if (ismain()) {
if (havewidgets) write_c(" %s->show(argc, argv);\n", var);
- write_c(" return Fl::run();\n");
+ if (havechildren) write_c(" return Fl::run();\n");
} else if (havewidgets && !constructor && !return_type) {
write_c(" return %s;\n", var);
}
- write_c("}\n");
+ if (havechildren)
+ write_c("}\n");
indentation = 0;
}