diff options
| author | engelsman <engelsman> | 2009-03-27 20:05:03 +0000 |
|---|---|---|
| committer | engelsman <engelsman> | 2009-03-27 20:05:03 +0000 |
| commit | 88a23466e32dfde5c7b58c1e79a817c5aacb70fe (patch) | |
| tree | 9cb19a740edcc93c940275174887c84626e8eea1 | |
| parent | f91d96253665065361519885ccfb72f31322e281 (diff) | |
fluid: fix erroneous declaration of user-defined static function (STR #2011)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6727 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | fluid/Fl_Menu_Type.cxx | 2 | ||||
| -rw-r--r-- | fluid/Fl_Type.cxx | 18 | ||||
| -rw-r--r-- | fluid/Fl_Type.h | 3 |
3 files changed, 22 insertions, 1 deletions
diff --git a/fluid/Fl_Menu_Type.cxx b/fluid/Fl_Menu_Type.cxx index 5bcdbf18a..d08de57ac 100644 --- a/fluid/Fl_Menu_Type.cxx +++ b/fluid/Fl_Menu_Type.cxx @@ -170,7 +170,7 @@ const char* Fl_Menu_Item_Type::menu_name(int& i) { #include "Fluid_Image.h" void Fl_Menu_Item_Type::write_static() { - if (callback() && is_name(callback())) + if (callback() && is_name(callback()) && !user_defined(callback())) write_declare("extern void %s(Fl_Menu_*, %s);", callback(), user_data_type() ? user_data_type() : "void*"); for (int n=0; n < NUM_EXTRA_CODE; n++) { diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx index 81ee7a277..af20bd9fd 100644 --- a/fluid/Fl_Type.cxx +++ b/fluid/Fl_Type.cxx @@ -994,6 +994,24 @@ void Fl_Type::leave_live_mode() { void Fl_Type::copy_properties() { } +/** + * Check whether callback name is declared anywhere else by the user + * + * \b Warning: this just checks that the name is declared somewhere, + * but it should probably also check that the name corresponds to a + * plain function or a member function within the same class and that + * the parameter types match. + */ +int Fl_Type::user_defined(const char* cbname) const { + for (Fl_Type* p = Fl_Type::first; p ; p = p->next) + if (strcmp(p->type_name(), "Function") == 0 && p->name() != 0) + if (strncmp(p->name(), cbname, strlen(cbname)) == 0) + if (p->name()[strlen(cbname)] == '(') + return 1; + return 0; +} + + // // End of "$Id$". // diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index 62984829e..88e0b2197 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -77,6 +77,9 @@ public: // things that should not be public: int code_line, header_line; int code_line_end, header_line_end; +protected: + int user_defined(const char* cbname) const; + public: virtual ~Fl_Type(); |
