summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2003-01-28 20:51:17 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2003-01-28 20:51:17 +0000
commitfc22bc93a0b3724c759b9e28fb680d4f0b44376b (patch)
tree273ec97e80dad2f3860fe454a0b24f10b9012f63 /fluid
parent226715d978654145c1a011fe8ebf35431774c33d (diff)
Support type qualifiers before a class name; this allows for things like
"FL_EXPORT Fl_File_Chooser"... Update Fl_File_Chooser and Fl_Help_Dialog to use the new interface so that we don't have to add FL_EXPORT every time we make a change... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2934 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid')
-rw-r--r--fluid/Fl_Function_Type.cxx55
-rw-r--r--fluid/Fl_Type.cxx11
-rw-r--r--fluid/Fl_Type.h10
-rw-r--r--fluid/file.cxx10
4 files changed, 69 insertions, 17 deletions
diff --git a/fluid/Fl_Function_Type.cxx b/fluid/Fl_Function_Type.cxx
index ad0c2f387..af4797cc0 100644
--- a/fluid/Fl_Function_Type.cxx
+++ b/fluid/Fl_Function_Type.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.11 2002/11/07 03:34:49 easysw Exp $"
+// "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.12 2003/01/28 20:51:09 easysw Exp $"
//
// C function type code for the Fast Light Tool Kit (FLTK).
//
@@ -618,11 +618,17 @@ const char* Fl_Type::class_name(const int need_nest) const {
int Fl_Class_Type::is_public() const {return public_;}
+void Fl_Class_Type::prefix(const char*p) {
+ free((void*) class_prefix);
+ class_prefix=strdup(p ? p : "" );
+}
+
Fl_Type *Fl_Class_Type::make() {
Fl_Type *p = Fl_Type::current;
while (p && !p->is_decl_block()) p = p->parent;
Fl_Class_Type *o = new Fl_Class_Type();
o->name("UserInterface");
+ o->class_prefix=0;
o->subclass_of = 0;
o->public_ = 1;
o->add(p);
@@ -651,11 +657,19 @@ void Fl_Class_Type::read_property(const char *c) {
void Fl_Class_Type::open() {
if (!class_panel) make_class_panel();
- c_name_input->static_value(name());
+ char fullname[1024]="";
+ if (prefix() && strlen(prefix()))
+ sprintf(fullname,"%s %s",prefix(),name());
+ else
+ strcpy(fullname, name());
+ c_name_input->static_value(fullname);
c_subclass_input->static_value(subclass_of);
c_public_button->value(public_);
class_panel->show();
const char* message = 0;
+
+ char *na=0,*pr=0,*p=0; // name and prefix substrings
+
for (;;) { // repeat as long as there are errors
if (message) fl_alert(message);
for (;;) {
@@ -665,14 +679,30 @@ void Fl_Class_Type::open() {
else if (!w) Fl::wait();
}
const char*c = c_name_input->value();
- while (isspace(*c)) c++;
- if (!*c) goto OOPS;
- while (is_id(*c)) c++;
- while (isspace(*c)) c++;
- if (*c) {OOPS: message = "class name must be C++ identifier"; continue;}
+ char *s = strdup(c);
+ size_t len = strlen(s);
+ if (!*s) goto OOPS;
+ p = (char*) (s+len-1);
+ while (p>=s && isspace(*p)) *(p--)='\0';
+ if (p<s) goto OOPS;
+ while (p>=s && is_id(*p)) p--;
+ if ( (p<s && !is_id(*(p+1))) || !*(p+1) ) {
+ OOPS: message = "class name must be C++ identifier";
+ free((void*)s);
+ continue;
+ }
+ na=p+1; // now we have the name
+ if(p>s) *p--='\0';
+ while (p>=s && isspace(*p)) *(p--)='\0';
+ while (p>=s && is_id(*p)) p--;
+ if (p<s) p++;
+ if (is_id(*p) && p<na) pr=p; // prefix detected
c = c_subclass_input->value();
- message = c_check(c); if (message) continue;
- name(c_name_input->value());
+ message = c_check(c);
+ if (message) { free((void*)s);continue;}
+ name(na);
+ prefix(pr);
+ free((void*)s);
storestring(c, subclass_of);
public_ = c_public_button->value();
break;
@@ -696,7 +726,10 @@ void Fl_Class_Type::write_code1() {
parent_class = current_class;
current_class = this;
write_public_state = 0;
- write_h("\nclass %s ", name());
+ if (prefix() && strlen(prefix()))
+ write_h("\nclass %s %s ", prefix(), name());
+ else
+ write_h("\nclass %s ", name());
if (subclass_of) write_h(": %s ", subclass_of);
write_h("{\n");
}
@@ -707,5 +740,5 @@ void Fl_Class_Type::write_code2() {
}
//
-// End of "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.11 2002/11/07 03:34:49 easysw Exp $".
+// End of "$Id: Fl_Function_Type.cxx,v 1.15.2.16.2.12 2003/01/28 20:51:09 easysw Exp $".
//
diff --git a/fluid/Fl_Type.cxx b/fluid/Fl_Type.cxx
index e6be7c8de..eb29400fc 100644
--- a/fluid/Fl_Type.cxx
+++ b/fluid/Fl_Type.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Type.cxx,v 1.6.2.6.2.13 2002/11/19 18:41:15 easysw Exp $"
+// "$Id: Fl_Type.cxx,v 1.6.2.6.2.14 2003/01/28 20:51:10 easysw Exp $"
//
// Widget type code for the Fast Light Tool Kit (FLTK).
//
@@ -726,6 +726,13 @@ void later_cb(Fl_Widget*,void*) {
void Fl_Type::write() {
write_indent(level);
write_word(type_name());
+
+ if (is_class()) {
+ const char * p = ((Fl_Class_Type*)this)->prefix();
+ if (p && strlen(p))
+ write_word(p);
+ }
+
write_word(name());
write_open(level);
write_properties();
@@ -784,5 +791,5 @@ void Fl_Type::read_property(const char *c) {
int Fl_Type::read_fdesign(const char*, const char*) {return 0;}
//
-// End of "$Id: Fl_Type.cxx,v 1.6.2.6.2.13 2002/11/19 18:41:15 easysw Exp $".
+// End of "$Id: Fl_Type.cxx,v 1.6.2.6.2.14 2003/01/28 20:51:10 easysw Exp $".
//
diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h
index 2c4fa0540..3dcf27497 100644
--- a/fluid/Fl_Type.h
+++ b/fluid/Fl_Type.h
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Type.h,v 1.5.2.11.2.7 2002/10/30 21:06:14 matthiaswm Exp $"
+// "$Id: Fl_Type.h,v 1.5.2.11.2.8 2003/01/28 20:51:11 easysw Exp $"
//
// Widget type header file for the Fast Light Tool Kit (FLTK).
//
@@ -230,6 +230,12 @@ public:
int pixmapID() { return 12; }
void write_properties();
void read_property(const char *);
+
+ // class prefix attribute access
+ void prefix(const char* p);
+ const char* prefix() const {return class_prefix;}
+private:
+ const char* class_prefix;
};
#define NUM_EXTRA_CODE 4
@@ -587,5 +593,5 @@ int storestring(const char *n, const char * & p, int nostrip=0);
extern int include_H_from_C;
//
-// End of "$Id: Fl_Type.h,v 1.5.2.11.2.7 2002/10/30 21:06:14 matthiaswm Exp $".
+// End of "$Id: Fl_Type.h,v 1.5.2.11.2.8 2003/01/28 20:51:11 easysw Exp $".
//
diff --git a/fluid/file.cxx b/fluid/file.cxx
index 7cc2daac8..0e72e4315 100644
--- a/fluid/file.cxx
+++ b/fluid/file.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: file.cxx,v 1.7.2.6.2.7 2002/08/09 22:57:00 easysw Exp $"
+// "$Id: file.cxx,v 1.7.2.6.2.8 2003/01/28 20:51:13 easysw Exp $"
//
// Fluid file routines for the Fast Light Tool Kit (FLTK).
//
@@ -458,6 +458,12 @@ static void read_children(Fl_Type *p, int paste) {
t->name(read_word());
c = read_word(1);
+ if (strcmp(c,"{") && t->is_class()) { // <prefix> <name>
+ ((Fl_Class_Type*)t)->prefix(t->name());
+ t->name(c);
+ c = read_word(1);
+ }
+
if (strcmp(c,"{")) {
read_error("Missing property list for %s\n",t->title());
goto REUSE_C;
@@ -631,5 +637,5 @@ void read_fdesign() {
}
//
-// End of "$Id: file.cxx,v 1.7.2.6.2.7 2002/08/09 22:57:00 easysw Exp $".
+// End of "$Id: file.cxx,v 1.7.2.6.2.8 2003/01/28 20:51:13 easysw Exp $".
//