"ComValue::object_compview() indicates use of ComponentView wrapper."
Brought to you by:
johnston
From: <ivt...@li...> - 2000-03-18 01:27:40
|
Patch: ivtools-000318-johnston-032 For: ivtools-0.8.1 Author: joh...@us... Subject: ComValue::object_compview() indicates use of ComponentView wrapper. Requires: This is an intermediate patch to ivtools-0.8.1. To apply, cd to the top-level directory of the ivtools source tree (the directory with src and config subdirs), and apply like this: patch -p0 <ThisFile Summary of Changes: - add a flag to ComValue (use space from one of two type-specific unions) to indicate the void* pointer stored in an ComValue of ObjectType is really a ComponentView, not the class indicated by the classid symbol associated with it. This allows derived ComFunc's to detect whether an object pointer is really a ComponentView indirection to some Component object. - fix bug in comterp telcat mode where a bad pathname segfaults. - extend OverlayComp::FindValue to support the "up" flag. - change all the derived ComFunc's that work with ComponentView's to set the ComValue::_object_compview flag, and provide a symbol for the classid that corresponds to the kind of component. This needs to become a virtual method on every component, which requires adding CLASS_SYMID to all the *comp(s).h in the OverlayUnidraw library. Index: top_ivtools/INSTALL diff -c top_ivtools/INSTALL:1.5 top_ivtools/INSTALL:1.6 *** top_ivtools/INSTALL:1.5 Thu Mar 9 02:16:29 2000 --- ./INSTALL Sat Mar 18 02:04:12 2000 *************** *** 15,22 **** egcs-1.0.3 and gcc-2.8.1. gcc-2.7.2 will still work, as probably would gcc-2.6.3. You will also need an equivalent copy of libstdc++. The libstdc++ version numbers stay roughly in synch with the gcc ! version numbers. If you have if you have gcc-2.8.1 you'd want ! libstdc++-2.8.1, etc.. 0.c. An installed copy of X11R6 as distributed by the Open Group, or an equivalent (XFree86 for Linux, or X11R5 from MIT). If you use a --- 15,22 ---- egcs-1.0.3 and gcc-2.8.1. gcc-2.7.2 will still work, as probably would gcc-2.6.3. You will also need an equivalent copy of libstdc++. The libstdc++ version numbers stay roughly in synch with the gcc ! version numbers. If you have gcc-2.8.1 you'd want libstdc++-2.8.1, ! etc.. 0.c. An installed copy of X11R6 as distributed by the Open Group, or an equivalent (XFree86 for Linux, or X11R5 from MIT). If you use a Index: Attribute/attrvalue.c diff -c Attribute/attrvalue.c:1.5 Attribute/attrvalue.c:1.6 *** Attribute/attrvalue.c:1.5 Wed Feb 23 04:27:30 2000 --- src/Attribute/attrvalue.c Sat Mar 18 02:04:14 2000 *************** *** 116,121 **** --- 116,122 ---- _type = AttributeValue::ObjectType; _v.objval.ptr = ptr; _v.objval.type = classid; + _object_compview = false; } AttributeValue::AttributeValue(AttributeValueList* ptr) { *************** *** 869,877 **** } void* AttributeValue::geta(int id) { ! if (is_object(id)) ! return obj_val(); else ! return nil; } --- 870,881 ---- } void* AttributeValue::geta(int id) { ! if (is_object(id)) { ! if (object_compview()) ! return nil; else ! return obj_val(); ! } else ! return nil; } Index: Attribute/attrvalue.h diff -c Attribute/attrvalue.h:1.7 Attribute/attrvalue.h:1.8 *** Attribute/attrvalue.h:1.7 Mon Feb 21 20:48:38 2000 --- src/Attribute/attrvalue.h Sat Mar 18 02:04:14 2000 *************** *** 203,208 **** --- 203,213 ---- boolean command_alias(); // returns true if command is an alias, not the first name. + boolean object_compview() { return _object_compview; } + // true if object is wrapped with a ComponentView + void object_compview(boolean flag) { _object_compview = flag; } + // true if object is wrapped with a ComponentView + void negate(); // negate numeric values. *************** *** 302,307 **** --- 307,313 ---- union { ValueType _aggregate_type; // used for ArrayType. unsigned int _command_symid; // used for CommandType. + boolean _object_compview; // used for ObjectType. }; }; Index: ComTerp/comvalue.c diff -c ComTerp/comvalue.c:1.8 ComTerp/comvalue.c:1.9 *** ComTerp/comvalue.c:1.8 Tue Mar 14 23:18:42 2000 --- src/ComTerp/comvalue.c Sat Mar 18 02:04:16 2000 *************** *** 267,273 **** avl->Next(i); if (!avl->Done(i)) out << ","; } ! if (!first) out << "}\n"; } else { out << "array of length " << svp->array_len(); ALIterator i; --- 267,273 ---- avl->Next(i); if (!avl->Done(i)) out << ","; } ! if (!first) out << "}"; } else { out << "array of length " << svp->array_len(); ALIterator i; *************** *** 298,304 **** if (svp->class_symid() == Attribute::class_symid()) out << *((Attribute*)svp->obj_val())->Value(); else ! out << "<" << symbol_pntr(svp->class_symid()) << ">"; break; case ComValue::UnknownType: --- 298,304 ---- if (svp->class_symid() == Attribute::class_symid()) out << *((Attribute*)svp->obj_val())->Value(); else ! out << "<" << symbol_pntr(svp->class_symid()) << ">"; break; case ComValue::UnknownType: Index: comterp/main.c diff -c comterp/main.c:1.1 comterp/main.c:1.2 *** comterp/main.c:1.1 Tue Jan 18 03:07:08 2000 --- src/comterp_/main.c Sat Mar 18 02:04:18 2000 *************** *** 145,151 **** } } ! } else { filebuf inbuf; inbuf.attach(fileno(inptr)); --- 145,151 ---- } } ! } else if (inptr) { filebuf inbuf; inbuf.attach(fileno(inptr)); *************** *** 155,209 **** obuf.attach(server.get_handle()); ostream out(&obuf); - #if 0 - for (;;) { - char ch; - in.get(ch); - if (!in.good()) break; - out << ch; - } - #else char buffer[BUFSIZ*BUFSIZ]; while(!in.eof() && in.good()) { in.read(buffer, BUFSIZ*BUFSIZ); if (!in.eof() || in.gcount()) out.write(buffer, in.gcount()); } - #endif out.flush(); ! ! #if 0 ! for (;;) { ! fgets(buffer, BUFSIZ*BUFSIZ, inptr); ! if (feof(inptr)) break; ! fputs(buffer, fptr); ! fflush(fptr); ! #if 0 ! fgets(buffer, BUFSIZ*BUFSIZ, fptr); ! fputs(buffer, stdout); ! #else ! char ch; ! ch = getc(fptr); ! if (ch == '>') { ! ch = getc(fptr); ! if (ch != ' ') { ! ungetc(ch, fptr); ! ungetc('>', fptr); ! fgets(buffer, BUFSIZ*BUFSIZ, fptr); ! fputs(buffer, stdout); ! } else { ! printf( "> " ); ! } ! } else { ! ungetc(ch, fptr); ! fgets(buffer, BUFSIZ*BUFSIZ, fptr); ! fputs(buffer, stdout); ! } ! #endif ! } ! #endif ! ! } if (argc<=4 && inptr) fclose(inptr); --- 155,169 ---- obuf.attach(server.get_handle()); ostream out(&obuf); char buffer[BUFSIZ*BUFSIZ]; while(!in.eof() && in.good()) { in.read(buffer, BUFSIZ*BUFSIZ); if (!in.eof() || in.gcount()) out.write(buffer, in.gcount()); } out.flush(); ! } else ! cerr << "comterp: unable to open file: " << argv[4] << "\n"; if (argc<=4 && inptr) fclose(inptr); *************** *** 213,219 **** return 0; } ! #endif if (server_flag || remote_flag) { ComTerpServ* terp = new ComTerpServ(BUFSIZ*BUFSIZ); --- 173,179 ---- return 0; } ! #endif /* defined(HAVE_ACE) */ if (server_flag || remote_flag) { ComTerpServ* terp = new ComTerpServ(BUFSIZ*BUFSIZ); Index: OverlayUnidraw/ovcomps.c diff -c OverlayUnidraw/ovcomps.c:1.1 OverlayUnidraw/ovcomps.c:1.2 *** OverlayUnidraw/ovcomps.c:1.1 Tue Jan 18 03:10:44 2000 --- src/OverlayUnidraw/ovcomps.c Sat Mar 18 02:04:36 2000 *************** *** 82,87 **** --- 82,89 ---- /*****************************************************************************/ + int OverlayComp::_symid = -1; + ParamList* OverlayComp::_overlay_comp_params = nil; OverlayComp::OverlayComp (Graphic* g, OverlayComp* parent) : GraphicComp(g) *************** *** 353,359 **** cerr << "breadth search not yet unsupported\n"; return nil; } else if (up) { ! cerr << "upward search not yet unsupported\n"; return nil; } else if (last) { cerr << "search for last value not yet unsupported\n"; --- 355,361 ---- cerr << "breadth search not yet unsupported\n"; return nil; } else if (up) { ! if (GetParent()) return ((OverlayComp*)GetParent())->FindValue(symid, last, breadth, down, up); return nil; } else if (last) { cerr << "search for last value not yet unsupported\n"; *************** *** 1125,1132 **** cerr << "breadth search not yet unsupported\n"; return nil; } else if (up) { ! cerr << "upward search not yet unsupported\n"; ! return nil; } else if (last) { cerr << "search for last value not yet unsupported\n"; return nil; --- 1127,1139 ---- cerr << "breadth search not yet unsupported\n"; return nil; } else if (up) { ! if (AttributeList* al = attrlist()) { ! AttributeValue* av = al->find(symid); ! if (av) return av; ! } ! return GetParent() ! ? ((OverlayComp*)GetParent())->FindValue(symid, last, breadth, down, up) ! : nil; } else if (last) { cerr << "search for last value not yet unsupported\n"; return nil; Index: OverlayUnidraw/ovcomps.h diff -c OverlayUnidraw/ovcomps.h:1.2 OverlayUnidraw/ovcomps.h:1.3 *** OverlayUnidraw/ovcomps.h:1.2 Tue Feb 15 04:57:49 2000 --- src/OverlayUnidraw/ovcomps.h Sat Mar 18 02:04:37 2000 *************** *** 171,176 **** --- 171,178 ---- friend OverlayScript; friend OverlaysScript; + + CLASS_SYMID("OverlayComp"); }; //: composite component, clone of GraphicComps derived from OverlayComp Index: OverlayUnidraw/ovkit.h diff -c OverlayUnidraw/ovkit.h:1.2 OverlayUnidraw/ovkit.h:1.3 *** OverlayUnidraw/ovkit.h:1.2 Tue Mar 14 23:18:59 2000 --- src/OverlayUnidraw/ovkit.h Sat Mar 18 02:04:37 2000 *************** *** 181,186 **** --- 181,190 ---- // set possible alternate X display string for constructing viewer. // Not yet working. + boolean& set_button_flag() { return _set_button_flag; } + // flag to add setr button to text editor + boolean& clr_button_flag() { return _clr_button_flag; } + // flag to add clear button to text editor protected: Glyph* MenuLine(PSBrush*); // create line to put in a pulldown menu. *************** *** 200,216 **** const char* otherdisplay(); // returns string that might specify an alternate X display. - boolean& set_button_flag() { return _set_button_flag; } - // flag to add setr button to text editor - boolean& clr_button_flag() { return _clr_button_flag; } - // flag to add clear button to text editor protected: OverlayEditor* _ed; Deck* _toolbars; Patch* _toolbar; char* _otherdisplay; - boolean _set_button_flag; boolean _clr_button_flag; --- 204,215 ---- Index: ComUnidraw/grfunc.c diff -c ComUnidraw/grfunc.c:1.4 ComUnidraw/grfunc.c:1.5 *** ComUnidraw/grfunc.c:1.4 Tue Mar 14 23:19:01 2000 --- src/ComUnidraw/grfunc.c Sat Mar 18 02:04:39 2000 *************** *** 118,124 **** Unref(rel); RectOvComp* comp = new RectOvComp(rect); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(_compview_id, new ComponentView(comp)); push_stack(compval); } else push_stack(ComValue::nullval()); --- 118,125 ---- Unref(rel); RectOvComp* comp = new RectOvComp(rect); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(symbol_add("RectComp"), new ComponentView(comp)); ! compval.object_compview(true); push_stack(compval); } else push_stack(ComValue::nullval()); *************** *** 180,186 **** Unref(rel); ArrowLineOvComp* comp = new ArrowLineOvComp(line); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(_compview_id, new ComponentView(comp)); push_stack(compval); } else push_stack(ComValue::nullval()); --- 181,188 ---- Unref(rel); ArrowLineOvComp* comp = new ArrowLineOvComp(line); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(symbol_add("ArrowLineComp"), new ComponentView(comp)); ! compval.object_compview(true); push_stack(compval); } else push_stack(ComValue::nullval()); *************** *** 241,247 **** Unref(rel); EllipseOvComp* comp = new EllipseOvComp(ellipse); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(_compview_id, new ComponentView(comp)); push_stack(compval); } else push_stack(ComValue::nullval()); --- 243,250 ---- Unref(rel); EllipseOvComp* comp = new EllipseOvComp(ellipse); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(symbol_add("EllipseComp"), new ComponentView(comp)); ! compval.object_compview(true); push_stack(compval); } else push_stack(ComValue::nullval()); *************** *** 303,309 **** text->Translate(args[x0], args[y0]); TextOvComp* comp = new TextOvComp(text); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(_compview_id, new ComponentView(comp)); push_stack(compval); } else push_stack(ComValue::nullval()); --- 306,313 ---- text->Translate(args[x0], args[y0]); TextOvComp* comp = new TextOvComp(text); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(symbol_add("TextComp"), new ComponentView(comp)); ! compval.object_compview(true); push_stack(compval); } else push_stack(ComValue::nullval()); *************** *** 366,372 **** Unref(rel); ArrowMultiLineOvComp* comp = new ArrowMultiLineOvComp(multiline); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(_compview_id, new ComponentView(comp)); push_stack(compval); } else push_stack(ComValue::nullval()); --- 370,377 ---- Unref(rel); ArrowMultiLineOvComp* comp = new ArrowMultiLineOvComp(multiline); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(symbol_add("ArrowMultiLineComp"), new ComponentView(comp)); ! compval.object_compview(true); push_stack(compval); } else push_stack(ComValue::nullval()); *************** *** 429,435 **** Unref(rel); ArrowSplineOvComp* comp = new ArrowSplineOvComp(openspline); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(_compview_id, new ComponentView(comp)); push_stack(compval); } else push_stack(ComValue::nullval()); --- 434,441 ---- Unref(rel); ArrowSplineOvComp* comp = new ArrowSplineOvComp(openspline); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(symbol_add("ArrowSplineComp"), new ComponentView(comp)); ! compval.object_compview(true); push_stack(compval); } else push_stack(ComValue::nullval()); *************** *** 490,496 **** Unref(rel); PolygonOvComp* comp = new PolygonOvComp(polygon); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(_compview_id, new ComponentView(comp)); push_stack(compval); } else push_stack(ComValue::nullval()); --- 496,503 ---- Unref(rel); PolygonOvComp* comp = new PolygonOvComp(polygon); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(symbol_add("PolygonComp"), new ComponentView(comp)); ! compval.object_compview(true); push_stack(compval); } else push_stack(ComValue::nullval()); *************** *** 552,558 **** Unref(rel); ClosedSplineOvComp* comp = new ClosedSplineOvComp(closedspline); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(_compview_id, new ComponentView(comp)); push_stack(compval); } else push_stack(ComValue::nullval()); --- 559,566 ---- Unref(rel); ClosedSplineOvComp* comp = new ClosedSplineOvComp(closedspline); cmd = new PasteCmd(_ed, new Clipboard(comp)); ! ComValue compval(symbol_add("ClosedSplineComp"), new ComponentView(comp)); ! compval.object_compview(true); push_stack(compval); } else push_stack(ComValue::nullval()); *************** *** 672,678 **** GraphicView* subgv = gv->GetView(i); newSel->Append(subgv); GraphicComp* comp = subgv->GetGraphicComp(); ! ComValue* compval = new ComValue(_compview_id, new ComponentView(comp)); avl->Append(compval); } --- 680,687 ---- GraphicView* subgv = gv->GetView(i); newSel->Append(subgv); GraphicComp* comp = subgv->GetGraphicComp(); ! ComValue* compval = new ComValue(symbol_add("Component"), new ComponentView(comp)); ! compval->object_compview(true); avl->Append(compval); } *************** *** 682,690 **** for (sel->First(i); !sel->Done(i); sel->Next(i)) { GraphicView* grview = sel->GetView(i); Component* comp = grview ? grview->GetSubject() : nil; ! ComValue* compval = comp ? new ComValue(_compview_id, new ComponentView(comp)) : nil; ! if (compval) avl->Append(compval); delete newSel; newSel = nil; } --- 691,702 ---- for (sel->First(i); !sel->Done(i); sel->Next(i)) { GraphicView* grview = sel->GetView(i); Component* comp = grview ? grview->GetSubject() : nil; ! ComValue* compval = comp ? new ComValue(symbol_add("Component"), new ComponentView(comp)) : nil; ! ! if (compval) { ! compval->object_compview(true); avl->Append(compval); + } delete newSel; newSel = nil; } *************** *** 698,704 **** OverlayComp* comp = (OverlayComp*)comview->GetSubject(); if (comp) { newSel->Append(comp->FindView(viewer)); ! ComValue* compval = new ComValue(_compview_id, new ComponentView(comp)); avl->Append(compval); } } --- 710,717 ---- OverlayComp* comp = (OverlayComp*)comview->GetSubject(); if (comp) { newSel->Append(comp->FindView(viewer)); ! ComValue* compval = new ComValue(symbol_add("Component"), new ComponentView(comp)); ! compval->object_compview(true); avl->Append(compval); } } Index: ComUnidraw/unifunc.c diff -c ComUnidraw/unifunc.c:1.2 ComUnidraw/unifunc.c:1.3 *** ComUnidraw/unifunc.c:1.2 Fri Mar 10 23:42:09 2000 --- src/ComUnidraw/unifunc.c Sat Mar 18 02:04:39 2000 *************** *** 1,5 **** /* ! * Copyright (c) 1994-1998 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided --- 1,5 ---- /* ! * Copyright (c) 1994-2000 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided *************** *** 207,223 **** if (!pathnamev.is_array()) { if (nargs()==1) { if (cmd = import(pathnamev.string_ptr())) { ! ComValue compval(_compview_id, new ComponentView(cmd->component())); push_stack(compval); } else push_stack(ComValue::nullval()); } else { for (int i=0; i<nargs(); i++) if (cmd = import(stack_arg(i).string_ptr())) { ! ComValue compval(_compview_id, new ComponentView(cmd->component())); push_stack(compval); } else push_stack(ComValue::nullval()); } --- 207,226 ---- if (!pathnamev.is_array()) { if (nargs()==1) { if (cmd = import(pathnamev.string_ptr())) { ! ComValue compval(symbol_add("Component"), new ComponentView(cmd->component())); + compval.object_compview(true); push_stack(compval); } else push_stack(ComValue::nullval()); } else { for (int i=0; i<nargs(); i++) if (cmd = import(stack_arg(i).string_ptr())) { ! ComValue compval(symbol_add("Component"), new ComponentView(cmd->component())); + compval.object_compview(true); push_stack(compval); + } else push_stack(ComValue::nullval()); } *************** *** 228,235 **** inlist->First(it); while(!inlist->Done(it)) { cmd = import(inlist->GetAttrVal(it)->string_ptr()); ! outlist->Append(new ComValue(_compview_id, ! new ComponentView(cmd->component()))); inlist->Next(it); } } --- 231,240 ---- inlist->First(it); while(!inlist->Done(it)) { cmd = import(inlist->GetAttrVal(it)->string_ptr()); ! ComValue* val = new ComValue(symbol_add("Component"), ! new ComponentView(cmd->component())); ! val->object_compview(true); ! outlist->Append(val); inlist->Next(it); } } *** /dev/null Sat Mar 18 02:04:54 PST 2000 --- patches/ivtools-000318-johnston-032 *************** patches/ivtools-000318-johnston-032 *** 0 **** --- 1 ---- + ivtools-000318-johnston-032 |