new virtual Unidraw method, ExecuteCmd
Brought to you by:
johnston
From: <ivt...@li...> - 2004-02-12 20:50:29
|
Patch: ivtools-040212-johnston-009 For: ivtools-1.1.2 Author: joh...@us... Subject: new virtual Unidraw method, ExecuteCmd Requires: This is an intermediate patch to ivtools-1.1.2. 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: - localize all Unidraw Command execution into a virtual Unidraw method, ::ExecuteCmd. Affects Command's executed by CommandDoer and CommandPusher as well as other places. Expects a copy of the original Command object, so it can decide whether or not to delete it or log it to the history. Index: Attribute/lexscan.c diff -c Attribute/lexscan.c:1.2 Attribute/lexscan.c:1.3 *** Attribute/lexscan.c:1.2 Wed Feb 11 12:03:28 2004 --- src/Attribute/lexscan.c Thu Feb 12 12:43:12 2004 *************** *** 87,93 **** { unsigned int toklen, tokstart; int status = lexscan (_inptr, _infunc, _eoffunc, _errfunc, NULL, NULL, ! _begcmt, _endcmt, '#", _buffer, _bufsiz, &_bufptr, _token, _toksiz, &toklen, &toktype, &tokstart, &_linenum); unsigned tok_buflen = _bufptr-tokstart; strncpy(_tokbuf, _buffer+tokstart, tok_buflen); --- 87,93 ---- { unsigned int toklen, tokstart; int status = lexscan (_inptr, _infunc, _eoffunc, _errfunc, NULL, NULL, ! _begcmt, _endcmt, '#', _buffer, _bufsiz, &_bufptr, _token, _toksiz, &toklen, &toktype, &tokstart, &_linenum); unsigned tok_buflen = _bufptr-tokstart; strncpy(_tokbuf, _buffer+tokstart, tok_buflen); Index: ComTerp/ctrlfunc.c diff -c ComTerp/ctrlfunc.c:1.3 ComTerp/ctrlfunc.c:1.4 *** ComTerp/ctrlfunc.c:1.3 Tue Feb 10 11:41:03 2004 --- src/ComTerp/ctrlfunc.c Thu Feb 12 12:43:15 2004 *************** *** 108,113 **** --- 108,115 ---- return; } + / ************************************************************************ *****/ + RemoteFunc::RemoteFunc(ComTerp* comterp) : ComFunc(comterp) { } *************** *** 123,128 **** --- 125,131 ---- #if __GNUC__==3&&__GNUC_MINOR__<1 fprintf(stderr, "Please upgrade to gcc-3.1 or greater\n"); + push_stack(ComValue::nullval()); return; #endif *************** *** 179,185 **** #else - reset_stack(); cerr << "for the remote command to work rebuild comterp with ACE\n"; return; --- 182,187 ---- Index: ComUnidraw/comeditor.c diff -c ComUnidraw/comeditor.c:1.1 ComUnidraw/comeditor.c:1.2 *** ComUnidraw/comeditor.c:1.1 Fri Jan 9 11:45:00 2004 --- src/ComUnidraw/comeditor.c Thu Feb 12 12:43:37 2004 *************** *** 229,236 **** --- 229,241 ---- /* virtual */ void ComEditor::ExecuteCmd(Command* cmd) { if(!whiteboard()) + + /* normal Unidraw command execution */ OverlayEditor::ExecuteCmd(cmd); + else { + + /* indirect command execution, all by script */ std::ostrstream sbuf; boolean oldflag = OverlayScript::ptlist_parens(); OverlayScript::ptlist_parens(false); *************** *** 262,268 **** if (!scripted) sbuf << "print(\"Failed attempt to generate script for a PASTE_CMD\\n\" :err)"; sbuf.put('\0'); ! cerr << sbuf.str() << "\n"; GetComTerp()->run(sbuf.str()); delete cmd; } --- 267,274 ---- if (!scripted) sbuf << "print(\"Failed attempt to generate script for a PASTE_CMD\\n\" :err)"; sbuf.put('\0'); ! cout << sbuf.str() << "\n"; ! cout.flush(); GetComTerp()->run(sbuf.str()); delete cmd; } Index: include_unidraw/unidraw.h diff -c include_unidraw/unidraw.h:1.1 include_unidraw/unidraw.h:1.2 *** include_unidraw/unidraw.h:1.1 Fri Jan 9 11:45:57 2004 --- src/include/Unidraw/unidraw.h Thu Feb 12 12:43:44 2004 *************** *** 1,4 **** --- 1,5 ---- /* + * Copyright (c) 2004 Scott E. Johnston * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its *************** *** 82,87 **** --- 83,92 ---- void Redo(Component*, int = 1); void ClearHistory(Component* = nil); void ClearHistory(Editor*); + + virtual void ExecuteCmd(Command*); + // indirection for command execution, will delete object + protected: virtual void Process(); Index: OverlayUnidraw/ovdoer.c diff -c OverlayUnidraw/ovdoer.c:1.1 OverlayUnidraw/ovdoer.c:1.2 *** OverlayUnidraw/ovdoer.c:1.1 Fri Jan 9 11:44:53 2004 --- src/OverlayUnidraw/ovdoer.c Thu Feb 12 12:43:34 2004 *************** *** 1,4 **** --- 1,5 ---- /* + * Copyright (c) 2004 Scott E. Johnston * Copyright (c) 1994 Vectaport Inc. * * Permission to use, copy, modify, distribute, and sell this software and *************** *** 33,38 **** --- 34,40 ---- } void CommandDoer::Do() { + #if 0 Command* command = cmd; if (command) { if (command->Reversible()) { *************** *** 52,57 **** --- 54,62 ---- } } } + #else + unidraw->ExecuteCmd(cmd); + #endif } CommandPusher::CommandPusher(Command* c) { Index: OverlayUnidraw/oved.c diff -c OverlayUnidraw/oved.c:1.1 OverlayUnidraw/oved.c:1.2 *** OverlayUnidraw/oved.c:1.1 Fri Jan 9 11:44:53 2004 --- src/OverlayUnidraw/oved.c Thu Feb 12 12:43:34 2004 *************** *** 389,400 **** } /* virtual */ void OverlayEditor::ExecuteCmd(Command* cmd) { ! cmd->Execute(); ! if (cmd->Reversible()) { ! cmd->Log(); ! } else { ! delete cmd; ! } } void OverlayEditor::SetText() { --- 389,395 ---- } /* virtual */ void OverlayEditor::ExecuteCmd(Command* cmd) { ! unidraw->ExecuteCmd(cmd); } void OverlayEditor::SetText() { Index: OverlayUnidraw/ovunidraw.c diff -c OverlayUnidraw/ovunidraw.c:1.1 OverlayUnidraw/ovunidraw.c:1.2 *** OverlayUnidraw/ovunidraw.c:1.1 Fri Jan 9 11:44:54 2004 --- src/OverlayUnidraw/ovunidraw.c Thu Feb 12 12:43:34 2004 *************** *** 134,141 **** } for (_cmdq->First(it); !_cmdq->Done(it); _cmdq->First(it)) { ! CommandDoer doer(_cmdq->GetCommand(it)); ! doer.Do(); _cmdq->Remove(_cmdq->GetCommand(it)); } --- 134,140 ---- } for (_cmdq->First(it); !_cmdq->Done(it); _cmdq->First(it)) { ! unidraw->ExecuteCmd(_cmdq->GetCommand(it)->Copy()); _cmdq->Remove(_cmdq->GetCommand(it)); } Index: Unidraw/uctrls.c diff -c Unidraw/uctrls.c:1.1 Unidraw/uctrls.c:1.2 *** Unidraw/uctrls.c:1.1 Fri Jan 9 11:44:39 2004 --- src/Unidraw/uctrls.c Thu Feb 12 12:43:31 2004 *************** *** 1,4 **** --- 1,5 ---- /* + * Copyright (c) 2004 Scott E. Johnston * Copyright (c) 1990, 1991 Stanford University * * Permission to use, copy, modify, distribute, and sell this software and its *************** *** 29,34 **** --- 30,36 ---- #include <Unidraw/globals.h> #include <Unidraw/iterator.h> #include <Unidraw/uctrls.h> + #include <Unidraw/unidraw.h> #include <Unidraw/Commands/command.h> #include <Unidraw/Graphic/ulabel.h> #include <Unidraw/Graphic/picture.h> *************** *** 71,76 **** --- 73,81 ---- if (cmd != nil) { Busy(); + #if 1 + unidraw->ExecuteCmd(cmd->Copy()); + #else if (cmd->Reversible()) { cmd = cmd->Copy(); cmd->Execute(); *************** *** 89,94 **** --- 94,100 ---- cmd->Log(); } } + #endif Done(); } Index: Unidraw/unidraw.c diff -c Unidraw/unidraw.c:1.1 Unidraw/unidraw.c:1.2 *** Unidraw/unidraw.c:1.1 Fri Jan 9 11:44:39 2004 --- src/Unidraw/unidraw.c Thu Feb 12 12:43:31 2004 *************** *** 504,506 **** --- 504,525 ---- past = history->_past; future = history->_future; } + + void Unidraw::ExecuteCmd(Command *command) { + if (command) { + if (command->Reversible()) { + command->Execute(); + if (command->Reversible()) { + command->Log(); + } else { + delete command; + } + } + else { + command->Execute(); + if (command->Reversible()) { + command->Log(); + } + } + } + } *** /dev/null Thu Feb 12 12:43:50 PST 2004 --- patches/ivtools-040212-johnston-009 *************** patches/ivtools-040212-johnston-009 *** 0 **** --- 1 ---- + ivtools-040212-johnston-009 |