FLTK logo

[master] c9b4406 - Fluid: adding feature: Functions can also be "local". (#390)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] c9b4406 - Fluid: adding feature: Functions can also be "local". (#390) "Matthias Melcher" Feb 12, 2022  
 
commit c9b44064d205a16790eed7e91ba81365b057c8f1
Author:     Matthias Melcher <github@matthiasm.com>
AuthorDate: Sun Feb 13 00:54:44 2022 +0100
Commit:     GitHub <noreply@github.com>
CommitDate: Sun Feb 13 00:54:44 2022 +0100

    Fluid: adding feature: Functions can also be "local". (#390)
    
    Before, Functions could only be "static" (keyword static is added)
    or "global" (prototype is added). This is harmful if the function or
    method was declared elsewhere. "local" solves that.

 fluid/Fl_Function_Type.cxx |  6 ++++--
 fluid/function_panel.cxx   |  1 +
 fluid/function_panel.fl    | 20 ++++++++++++--------
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git fluid/Fl_Function_Type.cxx fluid/Fl_Function_Type.cxx
index f51570d..8b15316 100644
--- fluid/Fl_Function_Type.cxx
+++ fluid/Fl_Function_Type.cxx
@@ -253,7 +253,7 @@ void Fl_Function_Type::open() {
     f_public_choice->hide();
     f_c_button->hide();
   } else {
-    f_public_choice->value(public_>0);
+    f_public_choice->value(public_);
     f_public_choice->show();
     f_public_member_choice->hide();
     f_c_button->show();
@@ -441,11 +441,13 @@ void Fl_Function_Type::write_code1() {
     } else {
       if (havechildren)
         write_comment_c();
-      if (public_) {
+      if (public_==1) {
         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 (public_==2) {
+        // write neither the prototype nor static, the function may be declared elsewhere
       } else {
         if (havechildren)
           write_c("static ");
diff --git fluid/function_panel.cxx fluid/function_panel.cxx
index 80762df..8e28df2 100644
--- fluid/function_panel.cxx
+++ fluid/function_panel.cxx
@@ -48,6 +48,7 @@ Fl_Choice *f_public_choice=(Fl_Choice *)0;
 Fl_Menu_Item menu_f_public_choice[] = {
  {"static", 0,  0, (void*)(0), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
  {"global", 0,  0, (void*)(1), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
+ {"local", 0,  0, (void*)(2), 0, (uchar)FL_NORMAL_LABEL, 0, 11, 0},
  {0,0,0,0,0,0,0,0,0}
 };
 
diff --git fluid/function_panel.fl fluid/function_panel.fl
index f66f603..831e8b9 100644
--- fluid/function_panel.fl
+++ fluid/function_panel.fl
@@ -51,7 +51,7 @@ Function {make_function_panel()} {open
 } {
   Fl_Window function_panel {
     label {Function/Method Properties} open
-    xywh {101 713 343 232} type Double hide resizable modal
+    xywh {540 418 343 232} type Double resizable modal visible
   } {
     Fl_Group {} {open
       xywh {10 10 270 20}
@@ -88,6 +88,11 @@ Function {make_function_panel()} {open
           user_data 1 user_data_type long
           xywh {15 15 100 20} labelsize 11
         }
+        MenuItem {} {
+          label local
+          user_data 2 user_data_type long
+          xywh {15 15 100 20} labelsize 11
+        }
       }
       Fl_Light_Button f_c_button {
         label {C declaration}
@@ -260,9 +265,9 @@ Function {make_decl_panel()} {open
 } {
   Fl_Window decl_panel {
     label {Declaration Properties}
-    xywh {445 609 343 237} type Double align 80 hide resizable size_range {343 237 0 0}
+    xywh {497 618 343 237} type Double align 80 hide resizable size_range {343 237 0 0}
   } {
-    Fl_Group {} {open
+    Fl_Group {} {
       xywh {10 10 270 20}
     } {
       Fl_Box {} {
@@ -337,7 +342,7 @@ Function {make_data_panel()} {open
 } {
   Fl_Window data_panel {
     label {Inline Data Properties}
-    xywh {449 337 343 237} type Double align 80 hide resizable size_range {343 237 0 0}
+    xywh {589 362 343 237} type Double align 80 hide resizable size_range {343 237 0 0}
   } {
     Fl_Group {} {open
       xywh {10 10 320 20}
@@ -529,18 +534,17 @@ Function {type_make_cb(Fl_Widget*,void*d)} {open return_type void
 if (Fl_Type::current && Fl_Type::current->is_group())
   add_new_widget_from_user(type_name, kAddAsLastChild);
 else
-  add_new_widget_from_user(type_name, kAddAfterCurrent);} {selected
-  }
+  add_new_widget_from_user(type_name, kAddAfterCurrent);} {}
 }
 
-Function {make_widgetbin()} {open
+Function {make_widgetbin()} {open selected
 } {
   Fl_Window widgetbin_panel {
     label {Widget Bin}
     callback {if (Fl::event()==FL_SHORTCUT && Fl::event_key()==FL_Escape)
   exit_cb((Fl_Widget*)o, v);
 else
-  toggle_widgetbin_cb((Fl_Widget*)o, v);} open
+  toggle_widgetbin_cb((Fl_Widget*)o, v);}
     xywh {449 206 600 102} type Single align 80 hide non_modal
   } {
     Fl_Group {} {
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.