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.
This commit is contained in:
Matthias Melcher 2022-02-13 00:54:44 +01:00 committed by GitHub
parent 52bfbbc2fa
commit c9b44064d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 10 deletions

View File

@ -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 ");

View File

@ -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}
};

View File

@ -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 {} {