Browse Source

Produces correct destructor for nested classes, patch from Alexandr Shevtsow

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@999 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
branch-1.0
Bill Spitzak 26 years ago
parent
commit
7482800177
  1. 13
      fluid/Fl_Function_Type.cxx
  2. 16
      fluid/Fl_Menu_Type.cxx
  3. 6
      fluid/Fl_Type.h
  4. 18
      fluid/Fl_Widget_Type.cxx

13
fluid/Fl_Function_Type.cxx

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Function_Type.cxx,v 1.15.2.11 2000/01/05 03:17:26 bill Exp $" // "$Id: Fl_Function_Type.cxx,v 1.15.2.12 2000/02/05 09:20:44 bill Exp $"
// //
// C function type code for the Fast Light Tool Kit (FLTK). // C function type code for the Fast Light Tool Kit (FLTK).
// //
@ -216,7 +216,7 @@ void Fl_Function_Type::write_code1() {
} else rtype = "void"; } else rtype = "void";
} }
const char* k = class_name(); const char* k = class_name(0);
if (k) { if (k) {
write_public(public_); write_public(public_);
if (name()[0] == '~') if (name()[0] == '~')
@ -468,7 +468,7 @@ void Fl_Decl_Type::write_code1() {
// lose all trailing semicolons so I can add one: // lose all trailing semicolons so I can add one:
const char* e = c+strlen(c); const char* e = c+strlen(c);
while (e>c && e[-1]==';') e--; while (e>c && e[-1]==';') e--;
if (class_name()) { if (class_name(1)) {
write_public(public_); write_public(public_);
write_h(" %.*s;\n", e-c, c); write_h(" %.*s;\n", e-c, c);
} else { } else {
@ -554,13 +554,14 @@ void Fl_DeclBlock_Type::write_code2() {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
const char* Fl_Type::class_name() const { const char* Fl_Type::class_name(const int need_nest) const {
Fl_Type* p = parent; Fl_Type* p = parent;
while (p) { while (p) {
if (p->is_class()) { if (p->is_class()) {
// see if we are nested in another class, we must fully-qualify name: // see if we are nested in another class, we must fully-qualify name:
// this is lame but works... // this is lame but works...
const char* q = p->class_name(); const char* q = 0;
if(need_nest) q=p->class_name(need_nest);
if (q) { if (q) {
static char buffer[256]; static char buffer[256];
if (q != buffer) strcpy(buffer, q); if (q != buffer) strcpy(buffer, q);
@ -664,5 +665,5 @@ void Fl_Class_Type::write_code2() {
} }
// //
// End of "$Id: Fl_Function_Type.cxx,v 1.15.2.11 2000/01/05 03:17:26 bill Exp $". // End of "$Id: Fl_Function_Type.cxx,v 1.15.2.12 2000/02/05 09:20:44 bill Exp $".
// //

16
fluid/Fl_Menu_Type.cxx

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Menu_Type.cxx,v 1.16.2.4 1999/08/09 13:53:54 mike Exp $" // "$Id: Fl_Menu_Type.cxx,v 1.16.2.5 2000/02/05 09:20:45 bill Exp $"
// //
// Menu item code for the Fast Light Tool Kit (FLTK). // Menu item code for the Fast Light Tool Kit (FLTK).
// //
@ -132,7 +132,7 @@ void Fl_Menu_Item_Type::write_static() {
while (*d && !is_id(*d)) d++; while (*d && !is_id(*d)) d++;
} }
const char* cn = callback_name(); const char* cn = callback_name();
const char* k = class_name(); const char* k = class_name(1);
if (k) { if (k) {
write_c("\ninline void %s::%s_i(Fl_Menu_*", k, cn); write_c("\ninline void %s::%s_i(Fl_Menu_*", k, cn);
} else { } else {
@ -163,7 +163,7 @@ void Fl_Menu_Item_Type::write_static() {
// okay, when we hit last item in the menu we have to write the // okay, when we hit last item in the menu we have to write the
// entire array out: // entire array out:
int level; int level;
const char* k = class_name(); const char* k = class_name(1);
if (k) { if (k) {
write_c("\nFl_Menu_Item %s::%s[] = {\n", k, menu_name(level)); write_c("\nFl_Menu_Item %s::%s[] = {\n", k, menu_name(level));
} else } else
@ -216,7 +216,7 @@ void Fl_Menu_Item_Type::write_item() {
else else
write_c(", 0, "); write_c(", 0, ");
if (callback()) { if (callback()) {
const char* k = is_name(callback()) ? 0 : class_name(); const char* k = is_name(callback()) ? 0 : class_name(1);
if (k) { if (k) {
write_c(" (Fl_Callback*)%s::%s,", k, callback_name()); write_c(" (Fl_Callback*)%s::%s,", k, callback_name());
} else { } else {
@ -237,7 +237,7 @@ void Fl_Menu_Item_Type::write_code1() {
int i; const char* name = menu_name(i); int i; const char* name = menu_name(i);
if (!prev->is_menu_item()) { if (!prev->is_menu_item()) {
// for first menu item, declare the array // for first menu item, declare the array
if (class_name()) if (class_name(1))
write_h(" static Fl_Menu_Item %s[];\n", name); write_h(" static Fl_Menu_Item %s[];\n", name);
else else
write_h("extern Fl_Menu_Item %s[];\n", name); write_h("extern Fl_Menu_Item %s[];\n", name);
@ -245,7 +245,7 @@ void Fl_Menu_Item_Type::write_code1() {
const char *c = array_name(this); const char *c = array_name(this);
if (c) { if (c) {
if (class_name()) { if (class_name(1)) {
write_public(public_); write_public(public_);
write_h(" static Fl_Menu_Item *%s;\n", c); write_h(" static Fl_Menu_Item *%s;\n", c);
} else } else
@ -253,7 +253,7 @@ void Fl_Menu_Item_Type::write_code1() {
} }
if (callback()) { if (callback()) {
if (!is_name(callback()) && class_name()) { if (!is_name(callback()) && class_name(1)) {
const char* cn = callback_name(); const char* cn = callback_name();
const char* ut = user_data_type() ? user_data_type() : "void*"; const char* ut = user_data_type() ? user_data_type() : "void*";
write_public(0); write_public(0);
@ -439,5 +439,5 @@ void shortcut_in_cb(Shortcut_Button* i, void* v) {
} }
// //
// End of "$Id: Fl_Menu_Type.cxx,v 1.16.2.4 1999/08/09 13:53:54 mike Exp $". // End of "$Id: Fl_Menu_Type.cxx,v 1.16.2.5 2000/02/05 09:20:45 bill Exp $".
// //

6
fluid/Fl_Type.h

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Type.h,v 1.5.2.5 1999/09/10 16:40:17 bill Exp $" // "$Id: Fl_Type.h,v 1.5.2.6 2000/02/05 09:20:46 bill Exp $"
// //
// Widget type header file for the Fast Light Tool Kit (FLTK). // Widget type header file for the Fast Light Tool Kit (FLTK).
// //
@ -123,7 +123,7 @@ public:
virtual int is_decl_block() const; virtual int is_decl_block() const;
virtual int is_class() const; virtual int is_class() const;
const char* class_name() const; const char* class_name(const int need_nest) const;
}; };
class Fl_Function_Type : public Fl_Type { class Fl_Function_Type : public Fl_Type {
@ -528,5 +528,5 @@ int storestring(const char *n, const char * & p, int nostrip=0);
extern int include_H_from_C; extern int include_H_from_C;
// //
// End of "$Id: Fl_Type.h,v 1.5.2.5 1999/09/10 16:40:17 bill Exp $". // End of "$Id: Fl_Type.h,v 1.5.2.6 2000/02/05 09:20:46 bill Exp $".
// //

18
fluid/Fl_Widget_Type.cxx

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Widget_Type.cxx,v 1.15.2.8 1999/12/17 18:34:56 bill Exp $" // "$Id: Fl_Widget_Type.cxx,v 1.15.2.9 2000/02/05 09:20:46 bill Exp $"
// //
// Widget type code for the Fast Light Tool Kit (FLTK). // Widget type code for the Fast Light Tool Kit (FLTK).
// //
@ -1198,9 +1198,9 @@ const char *array_name(Fl_Widget_Type *o) {
int sawthis = 0; int sawthis = 0;
Fl_Type *t = o->prev; Fl_Type *t = o->prev;
Fl_Type *tp = o; Fl_Type *tp = o;
const char *cn = o->class_name(); const char *cn = o->class_name(1);
for (; t && t->class_name() == cn; tp = t, t = t->prev); for (; t && t->class_name(1) == cn; tp = t, t = t->prev);
for (t = tp; t && t->class_name() == cn; t = t->next) { for (t = tp; t && t->class_name(1) == cn; t = t->next) {
if (t == o) {sawthis=1; continue;} if (t == o) {sawthis=1; continue;}
const char *e = t->name(); const char *e = t->name();
if (!e) continue; if (!e) continue;
@ -1234,7 +1234,7 @@ void Fl_Widget_Type::write_static() {
write_declare("extern void %s(%s*, %s);", callback(), t, write_declare("extern void %s(%s*, %s);", callback(), t,
user_data_type() ? user_data_type() : "void*"); user_data_type() ? user_data_type() : "void*");
const char* c = array_name(this); const char* c = array_name(this);
const char* k = class_name(); const char* k = class_name(1);
if (c && !k) { if (c && !k) {
write_c("\n"); write_c("\n");
if (!public_) write_c("static "); if (!public_) write_c("static ");
@ -1293,12 +1293,12 @@ void Fl_Widget_Type::write_code1() {
const char* t = subclassname(this); const char* t = subclassname(this);
const char *c = array_name(this); const char *c = array_name(this);
if (c) { if (c) {
if (class_name()) { if (class_name(1)) {
write_public(public_); write_public(public_);
write_h(" %s *%s;\n", t, c); write_h(" %s *%s;\n", t, c);
} }
} }
if (class_name() && callback() && !is_name(callback())) { if (class_name(1) && callback() && !is_name(callback())) {
const char* cn = callback_name(); const char* cn = callback_name();
const char* ut = user_data_type() ? user_data_type() : "void*"; const char* ut = user_data_type() ? user_data_type() : "void*";
write_public(0); write_public(0);
@ -1399,7 +1399,7 @@ void Fl_Widget_Type::write_widget_code() {
if (c != fc) write_c("%so->textcolor(%d);\n",indent(), c); if (c != fc) write_c("%so->textcolor(%d);\n",indent(), c);
}} }}
const char* ud = user_data(); const char* ud = user_data();
if (class_name() && !parent->is_widget()) ud = "this"; if (class_name(1) && !parent->is_widget()) ud = "this";
if (callback()) { if (callback()) {
write_c("%so->callback((Fl_Callback*)%s", indent(), callback_name()); write_c("%so->callback((Fl_Callback*)%s", indent(), callback_name());
if (ud) if (ud)
@ -1746,5 +1746,5 @@ int Fl_Widget_Type::read_fdesign(const char* name, const char* value) {
} }
// //
// End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.8 1999/12/17 18:34:56 bill Exp $". // End of "$Id: Fl_Widget_Type.cxx,v 1.15.2.9 2000/02/05 09:20:46 bill Exp $".
// //

Loading…
Cancel
Save