DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2011
Version: 1.3-current





Link: http://www.fltk.org/str.php?L2011
Version: 1.3-current
Index: fluid/Fl_Menu_Type.cxx
===================================================================
--- fluid/Fl_Menu_Type.cxx      (revision 6148)
+++ fluid/Fl_Menu_Type.cxx      (working copy)
@@ -170,7 +170,7 @@
 #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++) {
Index: fluid/Fl_Type.h
===================================================================
--- fluid/Fl_Type.h     (revision 6148)
+++ fluid/Fl_Type.h     (working copy)
@@ -76,6 +76,9 @@
   int code_line, header_line;
   int code_line_end, header_line_end;
 
+protected:
+  int user_defined(const char* cbname) const;
+
 public:
 
   virtual ~Fl_Type();
Index: fluid/Fl_Type.cxx
===================================================================
--- fluid/Fl_Type.cxx   (revision 6148)
+++ fluid/Fl_Type.cxx   (working copy)
@@ -906,6 +906,24 @@
 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$".
 //
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to