FLTK logo

STR #1954

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 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | SVN ⇄ GIT ]

STR #1954

Application:FLTK Library
Status:1 - Closed w/Resolution
Priority:1 - Request for Enhancement, e.g. asking for a feature
Scope:3 - Applies to all machines and operating systems
Subsystem:FLUID
Summary:de-obfuscate fluid enum values
Version:1.4-feature
Created By:ianmacarthur
Assigned To:ianmacarthur
Fix Version:1.3-current
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date Text  
 
#1 ianmacarthur
02:17 May 03, 2008
I often use fluid to auto-generate small bits of code that I then hand edit to add swoopy new functions... However, the code fluid generates is not easy to read, as it tends to use magic numbers rather than the enums to describe the widget attributes.

e.g.

      btn->color((Fl_Color)1);
      btn->selection_color((Fl_Color)4);

Is it possible to have fluid put these out as, say FL_RED or etc.?

OK, I accept that the fluid code is really intended to be read by the user, but it was just a thought...
 
 
#2 ianmacarthur
02:39 May 03, 2008
Having posted it, I notice my "example" only shows color enums... but of course the effect also applies to some other attributes too.  
 
#3 Harbour
03:20 May 03, 2008
It can be done, with gcc peprocessor extension (#x) and some header modification, so it may be not portable :

......color_data.H ....

_new_enum(FL_RED)
_new_enum(FL_GREEN)

..... Enumeration.H .......

#undef _new_enum
#define _new_enum(x)    x,
// or use #define _new_enum(x, y)    x = y,

enum Fl_Color {

#include <color_data.H>

};

#undef _new_enum

...................fluid gen code ...

#define _new_enum(x)    case x: return #x;

const char *color2str(unsigned int color)
{
  switch(cmd) {
#include <color_data.H>
    default:
      break;
 }
   return 0;
}

#undef _new_enum
 
 
#4 Harbour
03:33 May 03, 2008
Correct some typos:

const char *color2str(unsigned int color)
{
  switch(color) {
#include <color_data.H>
    default:
      break;
 }
   return 0; // or itoa(color)
}
 
 
#5 ianmacarthur
02:49 Sep 05, 2014
Fluid has evolved somewhat and this issue is now at least partly addressed.

Closing, as I am disinclined to make the effort to fix this properly!
 
     

Return to Bugs & Features ]

 
 

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'.