diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2006-05-18 14:40:10 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2006-05-18 14:40:10 +0000 |
| commit | 92d0163f407e89db078d58fb51b017458be6e412 (patch) | |
| tree | 9c5d5dc17ad9821453a0457d3da608378239835e /fluid | |
| parent | b0c7fc3ab72bf06f54dc917d6a3b318f6d7941e8 (diff) | |
Declarations in Fluid can now explicitly be made non-static or non-extern. This allows the declaration of types like 'enum'
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5130 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid')
| -rw-r--r-- | fluid/Fl_Function_Type.cxx | 33 | ||||
| -rw-r--r-- | fluid/Fl_Type.h | 1 | ||||
| -rw-r--r-- | fluid/function_panel.cxx | 10 | ||||
| -rw-r--r-- | fluid/function_panel.fl | 14 | ||||
| -rw-r--r-- | fluid/function_panel.h | 1 |
5 files changed, 50 insertions, 9 deletions
diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx index 77391abc1..b8a98ebc4 100644 --- a/fluid/Fl_Function_Type.cxx +++ b/fluid/Fl_Function_Type.cxx @@ -499,6 +499,7 @@ Fl_Type *Fl_Decl_Type::make() { while (p && !p->is_decl_block()) p = p->parent; Fl_Decl_Type *o = new Fl_Decl_Type(); o->public_ = 0; + o->static_ = 1; o->name("int x;"); o->add(p); o->factory = this; @@ -508,11 +509,14 @@ Fl_Type *Fl_Decl_Type::make() { void Fl_Decl_Type::write_properties() { Fl_Type::write_properties(); if (public_) write_string("public"); + if (!static_) write_string("global"); } void Fl_Decl_Type::read_property(const char *c) { if (!strcmp(c,"public")) { public_ = 1; + } else if (!strcmp(c,"global")) { + static_ = 0; } else { Fl_Type::read_property(c); } @@ -522,6 +526,12 @@ void Fl_Decl_Type::open() { if (!decl_panel) make_decl_panel(); decl_input->static_value(name()); decl_public_button->value(public_); + decl_static_button->value(static_); + if (public_) + decl_static_button->label("extern"); + else + decl_static_button->label("static"); + char pp = public_; decl_panel->show(); const char* message = 0; for (;;) { // repeat as long as there are errors @@ -531,6 +541,14 @@ void Fl_Decl_Type::open() { if (w == decl_panel_cancel) goto BREAK2; else if (w == decl_panel_ok) break; else if (!w) Fl::wait(); + if (pp != decl_public_button->value()) { + pp = decl_public_button->value(); + if (pp) + decl_static_button->label("extern"); + else + decl_static_button->label("static"); + decl_static_button->redraw(); + } } const char*c = decl_input->value(); while (isspace(*c)) c++; @@ -541,6 +559,10 @@ void Fl_Decl_Type::open() { set_modflag(1); public_ = decl_public_button->value(); } + if (static_!=decl_static_button->value()) { + set_modflag(1); + static_ = decl_static_button->value(); + } break; } BREAK2: @@ -575,10 +597,15 @@ void Fl_Decl_Type::write_code1() { write_h(" %.*s;\n", (int)(e-c), c); } else { if (public_) { - write_h("extern %.*s;\n", (int)(e-c), c); - write_c("%.*s;\n", (int)(e-c), c); + if (static_) + write_h("extern "); + write_h("%.*s;\n", (int)(e-c), c); + if (static_) + write_c("%.*s;\n", (int)(e-c), c); } else { - write_c("static %.*s;\n", (int)(e-c), c); + if (static_) + write_c("static "); + write_c("%.*s;\n", (int)(e-c), c); } } } diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index 728cae7a8..a6e9eebb5 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -200,6 +200,7 @@ public: class Fl_Decl_Type : public Fl_Type { char public_; + char static_; public: Fl_Type *make(); void write_code1(); diff --git a/fluid/function_panel.cxx b/fluid/function_panel.cxx index 64ba8b58e..7e8fec808 100644 --- a/fluid/function_panel.cxx +++ b/fluid/function_panel.cxx @@ -284,6 +284,8 @@ Fl_Double_Window *decl_panel=(Fl_Double_Window *)0; Fl_Light_Button *decl_public_button=(Fl_Light_Button *)0; +Fl_Light_Button *decl_static_button=(Fl_Light_Button *)0; + Fl_Input *decl_input=(Fl_Input *)0; Fl_Return_Button *decl_panel_ok=(Fl_Return_Button *)0; @@ -300,7 +302,13 @@ Fl_Double_Window* make_decl_panel() { o->labelsize(11); o->when(FL_WHEN_NEVER); } - { Fl_Box* o = new Fl_Box(80, 10, 200, 20); + { Fl_Light_Button* o = decl_static_button = new Fl_Light_Button(80, 10, 60, 20, "static"); + o->tooltip("Prepend \'static\' to private declarations in the source code, or \'extern\' \ +to public declarations in the header file."); + o->labelsize(11); + o->when(FL_WHEN_NEVER); + } + { Fl_Box* o = new Fl_Box(150, 10, 130, 20); Fl_Group::current()->resizable(o); } o->end(); diff --git a/fluid/function_panel.fl b/fluid/function_panel.fl index ae8b9fff2..40aa7b9d0 100644 --- a/fluid/function_panel.fl +++ b/fluid/function_panel.fl @@ -201,9 +201,9 @@ Function {make_declblock_panel()} {open Function {make_decl_panel()} {open } { Fl_Window decl_panel { - label {Declaration Properties} - xywh {412 206 290 150} type Double hide resizable - code0 {o->size_range(o->w(), o->h(), Fl::w(), o->h());} + label {Declaration Properties} open + xywh {412 206 290 150} type Double resizable + code0 {o->size_range(o->w(), o->h(), Fl::w(), o->h());} visible } { Fl_Group {} {open xywh {10 10 270 20} @@ -212,8 +212,12 @@ Function {make_decl_panel()} {open label public tooltip {Make the declaration publicly accessible.} xywh {10 10 60 20} labelsize 11 when 0 } + Fl_Light_Button decl_static_button { + label static selected + tooltip {Prepend 'static' to private declarations in the source code, or 'extern' to public declarations in the header file.} xywh {80 10 60 20} labelsize 11 when 0 + } Fl_Box {} { - xywh {80 10 200 20} resizable + xywh {150 10 130 20} resizable } } Fl_Input decl_input { @@ -706,7 +710,7 @@ Function {make_sourceview()} {open } } Fl_Group {} { - label Header open selected + label Header open xywh {10 35 500 415} labelsize 13 } { Fl_Text_Editor sv_header { diff --git a/fluid/function_panel.h b/fluid/function_panel.h index cd87a096b..0595cfad4 100644 --- a/fluid/function_panel.h +++ b/fluid/function_panel.h @@ -66,6 +66,7 @@ extern Fl_Light_Button *declblock_public_button; Fl_Double_Window* make_declblock_panel(); extern Fl_Double_Window *decl_panel; extern Fl_Light_Button *decl_public_button; +extern Fl_Light_Button *decl_static_button; extern Fl_Input *decl_input; extern Fl_Return_Button *decl_panel_ok; extern Fl_Button *decl_panel_cancel; |
