Browse Source

Fix problems with new FLUID output, add common to closing braces to show

what widget is being closed, and bump the version number to 1.1.8 in the
repo...


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5271 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/168/head
Michael R Sweet 19 years ago
parent
commit
d9eecaf4ab
  1. 2
      FL/Enumerations.H
  2. 2
      configure.in
  3. 12
      fluid/Fl_Function_Type.cxx
  4. 47
      fluid/Fl_Widget_Type.cxx
  5. 2
      fluid/Fl_Window_Type.cxx
  6. 19
      fluid/code.cxx
  7. 38
      test/Makefile

2
FL/Enumerations.H

@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@
#define FL_MAJOR_VERSION 1
#define FL_MINOR_VERSION 1
#define FL_PATCH_VERSION 7
#define FL_PATCH_VERSION 8
#define FL_VERSION ((double)FL_MAJOR_VERSION + \
(double)FL_MINOR_VERSION * 0.01 + \
(double)FL_PATCH_VERSION * 0.0001)

2
configure.in

@ -36,7 +36,7 @@ AC_INIT(src/Fl.cxx) @@ -36,7 +36,7 @@ AC_INIT(src/Fl.cxx)
dnl FLTK library versions...
FL_MAJOR_VERSION=1
FL_MINOR_VERSION=1
FL_PATCH_VERSION=7
FL_PATCH_VERSION=8
FL_API_VERSION=${FL_MAJOR_VERSION}.${FL_MINOR_VERSION}
AC_SUBST(FL_MAJOR_VERSION)

12
fluid/Fl_Function_Type.cxx

@ -340,15 +340,15 @@ void Fl_Function_Type::write_code1() { @@ -340,15 +340,15 @@ void Fl_Function_Type::write_code1() {
}
void Fl_Function_Type::write_code2() {
Fl_Type *child;
const char *var = "w";
for (child = next; child && child->level > level; child = child->next)
if (child->is_window() && child->name()) var = child->name();
if (ismain()) {
if (havewidgets) write_c(" w->show(argc, argv);\n");
if (havewidgets) write_c(" %s->show(argc, argv);\n", var);
write_c(" return Fl::run();\n");
} else if (havewidgets && !constructor && !return_type) {
Fl_Type *child;
const char *var = "w";
for (child = next; child && child->level > level; child = child->next)
if (child->is_window() && child->name()) var = child->name();
write_c(" return %s;\n", var);
}
write_c("}\n");

47
fluid/Fl_Widget_Type.cxx

@ -1941,6 +1941,8 @@ const char *Fl_Type::callback_name() { @@ -1941,6 +1941,8 @@ const char *Fl_Type::callback_name() {
return unique_id(this, "cb", name(), label());
}
extern int varused_test, varused;
void Fl_Widget_Type::write_code1() {
const char* t = subclassname(this);
const char *c = array_name(this);
@ -1958,23 +1960,34 @@ void Fl_Widget_Type::write_code1() { @@ -1958,23 +1960,34 @@ void Fl_Widget_Type::write_code1() {
write_h(" static void %s(%s*, %s);\n", cn, t, ut);
}
// figure out if local variable will be used (prevent compiler warnings):
int oused = !name();
int wused = !name() && is_window();
const char *ptr;
if (!oused) {
varused = wused;
if (!name() && !varused) {
varused |= is_parent();
if (!varused) {
varused_test = 1;
write_widget_code();
varused_test = 0;
}
}
if (!varused) {
for (int n=0; n < NUM_EXTRA_CODE; n++)
if (extra_code(n) && !isdeclare(extra_code(n)) &&
(ptr = strstr(extra_code(n), "o->")) != NULL &&
(ptr == extra_code(n) ||
(!isalnum(ptr[-1] & 255) && ptr[-1] != '_'))) {
oused = 1;
varused = 1;
break;
}
}
write_c(indent());
if (oused) write_c("{ %s* o = ", t);
write_c("%s{ ", indent());
if (varused) write_c("%s* o = ", t);
if (name()) write_c("%s = ", name());
if (is_window()) {
// Handle special case where user is faking a Fl_Group type as a window,
@ -2007,10 +2020,10 @@ void Fl_Widget_Type::write_code1() { @@ -2007,10 +2020,10 @@ void Fl_Widget_Type::write_code1() {
}
write_c(");\n");
if (oused)
indentation += 2;
indentation += 2;
if (wused) write_c("%sw = o;\n", indent());
write_widget_code();
}
@ -2195,23 +2208,9 @@ void Fl_Widget_Type::write_extra_code() { @@ -2195,23 +2208,9 @@ void Fl_Widget_Type::write_extra_code() {
}
void Fl_Widget_Type::write_block_close() {
int oused = !name();
const char *ptr;
if (!oused) {
for (int n=0; n < NUM_EXTRA_CODE; n++)
if (extra_code(n) && !isdeclare(extra_code(n)) &&
(ptr = strstr(extra_code(n), "o->")) != NULL &&
(ptr == extra_code(n) ||
(!isalnum(ptr[-1] & 255) && ptr[-1] != '_'))) {
oused = 1;
break;
}
}
if (oused) {
indentation -= 2;
write_c("%s}\n", indent());
}
indentation -= 2;
write_c("%s} // %s* %s\n", indent(), subclassname(this),
name() ? name() : "o");
}
void Fl_Widget_Type::write_code2() {

2
fluid/Fl_Window_Type.cxx

@ -1299,7 +1299,7 @@ void Fl_Window_Type::write_code2() { @@ -1299,7 +1299,7 @@ void Fl_Window_Type::write_code2() {
}
write_c("%s%s->end();\n", indent(), var);
if (((Fl_Window*)o)->resizable() == o)
write_c("%s%s->resizable(o);\n", indent(), var);
write_c("%s%s->resizable(%s);\n", indent(), var, var);
write_block_close();
}

19
fluid/code.cxx

@ -153,8 +153,18 @@ int write_declare(const char *format, ...) { @@ -153,8 +153,18 @@ int write_declare(const char *format, ...) {
////////////////////////////////////////////////////////////////
// silly thing to prevent declaring unused variables:
// When this symbol is on, all attempts to write code don't write
// anything, but set a variable if it looks like the variable "o" is used:
int varused_test;
int varused;
// write an array of C characters (adds a null):
void write_cstring(const char *w, int length) {
if (varused_test) {
varused = 1;
return;
}
const char *e = w+length;
int linelength = 1;
putc('\"', code_file);
@ -221,6 +231,10 @@ void write_cstring(const char *w) {write_cstring(w,strlen(w));} @@ -221,6 +231,10 @@ void write_cstring(const char *w) {write_cstring(w,strlen(w));}
// write an array of C binary data (does not add a null):
void write_cdata(const char *s, int length) {
if (varused_test) {
varused = 1;
return;
}
const unsigned char *w = (const unsigned char *)s;
const unsigned char *e = w+length;
int linelength = 1;
@ -238,6 +252,10 @@ void write_cdata(const char *s, int length) { @@ -238,6 +252,10 @@ void write_cdata(const char *s, int length) {
}
void write_c(const char* format,...) {
if (varused_test) {
varused = 1;
return;
}
va_list args;
va_start(args, format);
vfprintf(code_file, format, args);
@ -245,6 +263,7 @@ void write_c(const char* format,...) { @@ -245,6 +263,7 @@ void write_c(const char* format,...) {
}
void write_h(const char* format,...) {
if (varused_test) return;
va_list args;
va_start(args, format);
vfprintf(header_file, format, args);

38
test/Makefile

@ -171,10 +171,20 @@ depend: $(CPPFILES) @@ -171,10 +171,20 @@ depend: $(CPPFILES)
include makedepend
clean:
-$(RM) $(ALL) $(GLALL) core
-$(RM) *.o core.* *~ *.bck *.bak
-$(RM) checkers.app/Contents/MacOS/checkers
-$(RM) sudoku.app/Contents/MacOS/sudoku
$(RM) $(ALL) $(GLALL) core
$(RM) *.o core.* *~ *.bck *.bak
$(RM) CubeViewUI.cxx
$(RM) fast_slow.cxx
$(RM) inactive.cxx
$(RM) keyboard_ui.cxx
$(RM) mandelbrot_ui.cxx
$(RM) preferences.cxx
$(RM) radio.cxx
$(RM) resize.cxx
$(RM) tabs.cxx
$(RM) valuators.cxx
$(RM) checkers.app/Contents/MacOS/checkers
$(RM) sudoku.app/Contents/MacOS/sudoku
install: all
echo "Installing example programs to $(DESTDIR)$(docdir)/examples..."
@ -288,7 +298,7 @@ editor$(EXEEXT): editor.o @@ -288,7 +298,7 @@ editor$(EXEEXT): editor.o
$(POSTBUILD) $@ ../FL/mac.r
fast_slow$(EXEEXT): fast_slow.o
fast_slow.cxx: fast_slow.fl
fast_slow.cxx: fast_slow.fl ../fluid/fluid$(EXEEXT)
file_chooser$(EXEEXT): file_chooser.o ../lib/$(IMGLIBNAME)
echo Linking $@...
@ -314,7 +324,7 @@ iconize$(EXEEXT): iconize.o @@ -314,7 +324,7 @@ iconize$(EXEEXT): iconize.o
image$(EXEEXT): image.o
inactive$(EXEEXT): inactive.o
inactive.cxx: inactive.fl
inactive.cxx: inactive.fl ../fluid/fluid$(EXEEXT)
input$(EXEEXT): input.o
@ -325,7 +335,7 @@ keyboard$(EXEEXT): keyboard_ui.o keyboard.o @@ -325,7 +335,7 @@ keyboard$(EXEEXT): keyboard_ui.o keyboard.o
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ keyboard.o keyboard_ui.o $(LINKFLTK) $(LDLIBS)
$(POSTBUILD) $@ ../FL/mac.r
keyboard_ui.o: keyboard_ui.h
keyboard_ui.cxx: keyboard_ui.fl
keyboard_ui.cxx: keyboard_ui.fl ../fluid/fluid$(EXEEXT)
label$(EXEEXT): label.o
echo Linking $@...
@ -341,7 +351,7 @@ mandelbrot$(EXEEXT): mandelbrot_ui.o mandelbrot.o @@ -341,7 +351,7 @@ mandelbrot$(EXEEXT): mandelbrot_ui.o mandelbrot.o
$(CXX) $(ARCHFLAGS) $(LDFLAGS) -o $@ mandelbrot.o mandelbrot_ui.o $(LINKFLTK) $(LDLIBS)
$(POSTBUILD) $@ ../FL/mac.r
mandelbrot_ui.o: mandelbrot_ui.h
mandelbrot_ui.cxx: mandelbrot_ui.fl
mandelbrot_ui.cxx: mandelbrot_ui.fl ../fluid/fluid$(EXEEXT)
menubar$(EXEEXT): menubar.o
@ -368,13 +378,13 @@ pixmap_browser$(EXEEXT): pixmap_browser.o ../lib/$(IMGLIBNAME) @@ -368,13 +378,13 @@ pixmap_browser$(EXEEXT): pixmap_browser.o ../lib/$(IMGLIBNAME)
$(POSTBUILD) $@ ../FL/mac.r
preferences$(EXEEXT): preferences.o
preferences.cxx: preferences.fl
preferences.cxx: preferences.fl ../fluid/fluid$(EXEEXT)
radio$(EXEEXT): radio.o
radio.cxx: radio.fl
radio.cxx: radio.fl ../fluid/fluid$(EXEEXT)
resize$(EXEEXT): resize.o
resize.cxx: resize.fl
resize.cxx: resize.fl ../fluid/fluid$(EXEEXT)
resizebox$(EXEEXT): resizebox.o
@ -396,7 +406,7 @@ sudoku.exe: sudoku.o sudoku.rc @@ -396,7 +406,7 @@ sudoku.exe: sudoku.o sudoku.rc
symbols$(EXEEXT): symbols.o
tabs$(EXEEXT): tabs.o
tabs.cxx: tabs.fl
tabs.cxx: tabs.fl ../fluid/fluid$(EXEEXT)
threads$(EXEEXT): threads.o
# This ensures that we have this dependency even if threads are not
@ -408,7 +418,7 @@ tile$(EXEEXT): tile.o @@ -408,7 +418,7 @@ tile$(EXEEXT): tile.o
tiled_image$(EXEEXT): tiled_image.o
valuators$(EXEEXT): valuators.o
valuators.cxx: valuators.fl
valuators.cxx: valuators.fl ../fluid/fluid$(EXEEXT)
# All OpenGL demos depend on the FLTK and FLTK_GL libraries...
$(GLALL): ../lib/$(LIBNAME) ../lib/$(GLLIBNAME)
@ -423,7 +433,7 @@ CubeView$(EXEEXT): CubeMain.o CubeView.o CubeViewUI.o @@ -423,7 +433,7 @@ CubeView$(EXEEXT): CubeMain.o CubeView.o CubeViewUI.o
CubeMain.o: CubeViewUI.h CubeView.h
CubeView.o: CubeView.h
CubeViewUI.o: CubeViewUI.h
CubeViewUI.cxx: CubeViewUI.fl
CubeViewUI.cxx: CubeViewUI.fl ../fluid/fluid$(EXEEXT)
cube$(EXEEXT): cube.o
echo Linking $@...

Loading…
Cancel
Save