From c9b44064d205a16790eed7e91ba81365b057c8f1 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 13 Feb 2022 00:54:44 +0100 Subject: [PATCH] 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 a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index f51570d92..8b15316cc 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/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 a/fluid/function_panel.cxx b/fluid/function_panel.cxx index 80762df28..8e28df2ad 100644 --- a/fluid/function_panel.cxx +++ b/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 a/fluid/function_panel.fl b/fluid/function_panel.fl index f66f60302..831e8b91b 100644 --- a/fluid/function_panel.fl +++ b/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 {} {