summaryrefslogtreecommitdiff
path: root/fluid/Fl_Function_Type.cxx
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/Fl_Function_Type.cxx
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/Fl_Function_Type.cxx')
-rw-r--r--fluid/Fl_Function_Type.cxx55
1 files changed, 44 insertions, 11 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 $".
//