📄 fl_function_type.cxx
字号:
o->add(p); o->factory = this; return o;}void Fl_CodeBlock_Type::write_properties() { Fl_Type::write_properties(); if (after) { write_string("after"); write_word(after); }}void Fl_CodeBlock_Type::read_property(const char *c) { if (!strcmp(c,"after")) { storestring(read_word(),after); } else { Fl_Type::read_property(c); }}void Fl_CodeBlock_Type::open() { if (!codeblock_panel) make_codeblock_panel(); code_before_input->static_value(name()); code_after_input->static_value(after); codeblock_panel->show(); const char* message = 0; for (;;) { // repeat as long as there are errors if (message) fl_alert(message); for (;;) { Fl_Widget* w = Fl::readqueue(); if (w == codeblock_panel_cancel) goto BREAK2; else if (w == codeblock_panel_ok) break; else if (!w) Fl::wait(); } const char*c = code_before_input->value(); message = c_check(c); if (message) continue; name(c); c = code_after_input->value(); message = c_check(c); if (message) continue; storestring(c, after); break; } BREAK2: codeblock_panel->hide();}Fl_CodeBlock_Type Fl_CodeBlock_type;void Fl_CodeBlock_Type::write_code1() { const char* c = name(); write_c("%s%s {\n", indent(), c ? c : ""); indentation += 2;}void Fl_CodeBlock_Type::write_code2() { indentation += 2; if (after) write_c("%s} %s\n", indent(), after); else write_c("%s}\n", indent());}////////////////////////////////////////////////////////////////Fl_Type *Fl_Decl_Type::make() { Fl_Type *p = Fl_Type::current; while (p && !p->is_decl_block()) p = p->parent; Fl_Decl_Type *o = new Fl_Decl_Type(); o->public_ = 0; o->name("int x;"); o->add(p); o->factory = this; return o;}void Fl_Decl_Type::write_properties() { Fl_Type::write_properties(); if (public_) write_string("public");}void Fl_Decl_Type::read_property(const char *c) { if (!strcmp(c,"public")) { public_ = 1; } else { Fl_Type::read_property(c); }}void Fl_Decl_Type::open() { if (!decl_panel) make_decl_panel(); decl_input->static_value(name()); decl_public_button->value(public_); decl_panel->show(); const char* message = 0; for (;;) { // repeat as long as there are errors if (message) fl_alert(message); for (;;) { Fl_Widget* w = Fl::readqueue(); if (w == decl_panel_cancel) goto BREAK2; else if (w == decl_panel_ok) break; else if (!w) Fl::wait(); } const char*c = decl_input->value(); while (isspace(*c)) c++; message = c_check(c&&c[0]=='#' ? c+1 : c); if (message) continue; name(c); public_ = decl_public_button->value(); break; } BREAK2: decl_panel->hide();}Fl_Decl_Type Fl_Decl_type;void Fl_Decl_Type::write_code1() { const char* c = name(); if (!c) return; // handle putting #include or extern or typedef into decl: if (!isalpha(*c) && *c != '~' || !strncmp(c,"extern",6) && isspace(c[6]) || !strncmp(c,"class",5) && isspace(c[5]) || !strncmp(c,"typedef",7) && isspace(c[7])// || !strncmp(c,"struct",6) && isspace(c[6]) ) { if (public_) write_h("%s\n", c); else write_c("%s\n", c); return; } // lose all trailing semicolons so I can add one: const char* e = c+strlen(c); while (e>c && e[-1]==';') e--; if (class_name()) { write_public(public_); write_h(" %.*s;\n", e-c, c); } else { if (public_) { write_h("extern %.*s;\n", e-c, c); write_c("%.*s;\n", e-c, c); } else { write_c("static %.*s;\n", e-c, c); } }}void Fl_Decl_Type::write_code2() {}////////////////////////////////////////////////////////////////Fl_Type *Fl_DeclBlock_Type::make() { Fl_Type *p = Fl_Type::current; while (p && !p->is_decl_block()) p = p->parent; Fl_DeclBlock_Type *o = new Fl_DeclBlock_Type(); o->name("#if 1"); o->after = strdup("#endif"); o->add(p); o->factory = this; return o;}void Fl_DeclBlock_Type::write_properties() { Fl_Type::write_properties(); write_string("after"); write_word(after);}void Fl_DeclBlock_Type::read_property(const char *c) { if (!strcmp(c,"after")) { storestring(read_word(),after); } else { Fl_Type::read_property(c); }}void Fl_DeclBlock_Type::open() { if (!declblock_panel) make_declblock_panel(); decl_before_input->static_value(name()); decl_after_input->static_value(after); declblock_panel->show(); const char* message = 0; for (;;) { // repeat as long as there are errors if (message) fl_alert(message); for (;;) { Fl_Widget* w = Fl::readqueue(); if (w == declblock_panel_cancel) goto BREAK2; else if (w == declblock_panel_ok) break; else if (!w) Fl::wait(); } const char*c = decl_before_input->value(); while (isspace(*c)) c++; message = c_check(c&&c[0]=='#' ? c+1 : c); if (message) continue; name(c); c = decl_after_input->value(); while (isspace(*c)) c++; message = c_check(c&&c[0]=='#' ? c+1 : c); if (message) continue; storestring(c,after); break; } BREAK2: declblock_panel->hide();}Fl_DeclBlock_Type Fl_DeclBlock_type;void Fl_DeclBlock_Type::write_code1() { const char* c = name(); if (c) write_c("%s\n", c);}void Fl_DeclBlock_Type::write_code2() { const char* c = after; if (c) write_c("%s\n", c);}////////////////////////////////////////////////////////////////const char* Fl_Type::class_name() const { Fl_Type* p = parent; while (p) { if (p->is_class()) { // see if we are nested in another class, we must fully-qualify name: // this is lame but works... const char* q = p->class_name(); if (q) { static char buffer[256]; if (q != buffer) strcpy(buffer, q); strcat(buffer, "::"); strcat(buffer, p->name()); return buffer; } return p->name(); } p = p->parent; } return 0;}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->subclass_of = 0; o->public_ = 1; o->add(p); o->factory = this; return o;}void Fl_Class_Type::write_properties() { Fl_Type::write_properties(); if (subclass_of) { write_string(":"); write_word(subclass_of); } if (!public_) write_string("private");}void Fl_Class_Type::read_property(const char *c) { if (!strcmp(c,"private")) { public_ = 0; } else if (!strcmp(c,":")) { storestring(read_word(), subclass_of); } else { Fl_Type::read_property(c); }}void Fl_Class_Type::open() { if (!class_panel) make_class_panel(); c_name_input->static_value(name()); c_subclass_input->static_value(subclass_of); c_public_button->value(public_); class_panel->show(); const char* message = 0; for (;;) { // repeat as long as there are errors if (message) fl_alert(message); for (;;) { Fl_Widget* w = Fl::readqueue(); if (w == c_panel_cancel) goto BREAK2; else if (w == c_panel_ok) break; 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;} c = c_subclass_input->value(); message = c_check(c); if (message) continue; name(c_name_input->value()); storestring(c, subclass_of); public_ = c_public_button->value(); break; } BREAK2: class_panel->hide();}Fl_Class_Type Fl_Class_type;static Fl_Class_Type *current_class;extern int varused_test;void write_public(int state) { if (!current_class || varused_test) return; if (current_class->write_public_state == state) return; current_class->write_public_state = state; write_h(state ? "public:\n" : "private:\n");}void Fl_Class_Type::write_code1() { parent_class = current_class; current_class = this; write_public_state = 0; write_h("\nclass %s ", name()); if (subclass_of) write_h(": %s ", subclass_of); write_h("{\n");}void Fl_Class_Type::write_code2() { write_h("};\n"); current_class = parent_class;}//// End of "$Id: Fl_Function_Type.cxx,v 1.1.1.1 2003/08/07 21:18:39 jasonk Exp $".//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -