symval command returns symbol without lookup, autonewframe command in flipbook interpreter
Brought to you by:
johnston
|
From: <ivt...@li...> - 2000-02-23 00:39:22
|
Patch: ivtools-000223-johnston-026
For: ivtools-0.8
Author: joh...@us...
This is an intermediate patch to ivtools-0.8. 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 new symval command to returns the symbol value instead of looking up the value of that symbol in the variable tables.
- documented acos, asin, and atan as returning radians, and cos, sin,
tan as taking radians.
- created autonewframe command in flipbook command interpreter, and
synched it with the "Auto New Frame" checkbox on the Frame pulldown
menu. So now you can set/reset this feature from either the GUI or
interpreter, and the GUI reflects the state.
Index: Attribute/attrvalue.c
diff -c Attribute/attrvalue.c:1.4 Attribute/attrvalue.c:1.5
*** Attribute/attrvalue.c:1.4 Mon Feb 21 20:48:38 2000
--- src/Attribute/attrvalue.c Wed Feb 23 04:27:30 2000
***************
*** 210,215 ****
--- 210,217 ----
return boolean_ref();
case AttributeValue::SymbolType:
return (boolean) int_val();
+ case AttributeValue::ObjectType:
+ return (boolean) obj_val();
default:
return 0;
}
Index: ComTerp/comterp.c
diff -c ComTerp/comterp.c:1.7 ComTerp/comterp.c:1.8
*** ComTerp/comterp.c:1.7 Mon Feb 21 20:48:41 2000
--- src/ComTerp/comterp.c Wed Feb 23 04:27:32 2000
***************
*** 808,813 ****
--- 808,814 ----
add_command("help", new HelpFunc(this));
add_command("symid", new SymIdFunc(this));
+ add_command("symval", new SymValFunc(this));
add_command("symbol", new SymbolFunc(this), "symval");
add_command("symvar", new SymVarFunc(this));
add_command("postfix", new PostFixFunc(this));
Index: ComTerp/mathfunc.h
diff -c ComTerp/mathfunc.h:1.1 ComTerp/mathfunc.h:1.2
*** ComTerp/mathfunc.h:1.1 Tue Jan 18 03:07:04 2000
--- src/ComTerp/mathfunc.h Wed Feb 23 04:27:32 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1998,1999 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 79,116 ****
};
//: arc-cosine command for ComTerp.
! // dbl=acos(x) -- returns the arc cosine of x.
class ACosFunc : public ComFunc {
public:
ACosFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the arc cosine of x"; }
};
//: arc-sine command for ComTerp.
! // dbl=asin(x) -- returns the arc sine of x.
class ASinFunc : public ComFunc {
public:
ASinFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the arc sine of x"; }
};
//: arc-tangent command for ComTerp.
! // dbl=atan(x) -- returns the arc tangent of x.
class ATanFunc : public ComFunc {
public:
ATanFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the arc tangent of x"; }
};
--- 80,117 ----
};
//: arc-cosine command for ComTerp.
! // dbl=acos(x) -- returns the arc cosine of x in radians.
class ACosFunc : public ComFunc {
public:
ACosFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the arc cosine of x in radians"; }
};
//: arc-sine command for ComTerp.
! // dbl=asin(x) -- returns the arc sine of x in radians.
class ASinFunc : public ComFunc {
public:
ASinFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the arc sine of x in radians"; }
};
//: arc-tangent command for ComTerp.
! // dbl=atan(x) -- returns the arc tangent of x in radians.
class ATanFunc : public ComFunc {
public:
ATanFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the arc tangent of x in radians"; }
};
***************
*** 127,164 ****
};
//: cosine command for ComTerp.
! // dbl=cos(x) -- returns the cosine of x.
class CosFunc : public ComFunc {
public:
CosFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the cosine of x"; }
};
//: sine command for ComTerp.
! // dbl=sin(x) -- returns the sine of x.
class SinFunc : public ComFunc {
public:
SinFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the sine of x"; }
};
//: tangent command for ComTerp.
! // dbl=tan(x) -- returns the tangent of x.
class TanFunc : public ComFunc {
public:
TanFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the tangent of x"; }
};
--- 128,165 ----
};
//: cosine command for ComTerp.
! // dbl=cos(x) -- returns the cosine of x radians.
class CosFunc : public ComFunc {
public:
CosFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the cosine of x radians"; }
};
//: sine command for ComTerp.
! // dbl=sin(x) -- returns the sine of x radians.
class SinFunc : public ComFunc {
public:
SinFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the sine of x radians"; }
};
//: tangent command for ComTerp.
! // dbl=tan(x) -- returns the tangent of x radians.
class TanFunc : public ComFunc {
public:
TanFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
! return "dbl=%s(x) -- returns the tangent of x radians"; }
};
Index: ComTerp/symbolfunc.c
diff -c ComTerp/symbolfunc.c:1.2 ComTerp/symbolfunc.c:1.3
*** ComTerp/symbolfunc.c:1.2 Tue Feb 15 04:56:31 2000
--- src/ComTerp/symbolfunc.c Wed Feb 23 04:27:32 2000
***************
*** 72,77 ****
--- 72,114 ----
/*****************************************************************************/
+ SymValFunc::SymValFunc(ComTerp* comterp) : ComFunc(comterp) {
+ }
+
+ void SymValFunc::execute() {
+ // return each symbol in the arguments as is
+ boolean noargs = !nargs() && !nkeys();
+ int numargs = nargs();
+ if (!numargs) return;
+ int symbol_ids[numargs];
+ for (int i=0; i<numargs; i++) {
+ ComValue& val = stack_arg(i, true);
+ if (val.is_type(AttributeValue::CommandType))
+ symbol_ids[i] = val.command_symid();
+ else if (val.is_type(AttributeValue::StringType))
+ symbol_ids[i] = val.string_val();
+ else if (val.is_type(AttributeValue::SymbolType))
+ symbol_ids[i] = val.symbol_val();
+ else
+ symbol_ids[i] = -1;
+ }
+ reset_stack();
+
+ if (numargs>1) {
+ AttributeValueList* avl = new AttributeValueList();
+ ComValue retval(avl);
+ for (int i=0; i<numargs; i++)
+ avl->Append(new AttributeValue(symbol_ids[i], AttributeValue::SymbolType));
+ push_stack(retval);
+ } else {
+ ComValue retval (symbol_ids[0], AttributeValue::SymbolType);
+ push_stack(retval);
+ }
+
+ }
+
+ /*****************************************************************************/
+
SymbolFunc::SymbolFunc(ComTerp* comterp) : ComFunc(comterp) {
}
Index: ComTerp/symbolfunc.h
diff -c ComTerp/symbolfunc.h:1.1 ComTerp/symbolfunc.h:1.2
*** ComTerp/symbolfunc.h:1.1 Tue Jan 18 03:07:06 2000
--- src/ComTerp/symbolfunc.h Wed Feb 23 04:27:32 2000
***************
*** 44,49 ****
--- 44,61 ----
return "%s(symbol [symbol...]) -- return id(s) associated with symbol(s)"; }
};
+ //: symbol value command for ComTerp.
+ // symval(symbol [symbol...]) -- preserve symbol(s) and return without lookup
+ class SymValFunc : public ComFunc {
+ public:
+ SymValFunc(ComTerp*);
+ virtual void execute();
+
+ virtual boolean post_eval() { return true; }
+ virtual const char* docstring() {
+ return "%s(symbol [symbol...]) -- preserve symbol(s) and return without lookup"; }
+ };
+
//: symbol command for ComTerp.
// symbol(symid [symid ...]) -- return symbol(s) associated with integer id(s)
class SymbolFunc : public ComFunc {
Index: comterp/README
diff -c comterp/README:1.2 comterp/README:1.3
*** comterp/README:1.2 Mon Feb 21 20:48:43 2000
--- src/comterp_/README Wed Feb 23 04:27:34 2000
***************
*** 115,133 ****
dbl=pow(x y) -- returns the value of x raised to the power of y
! dbl=acos(x) -- returns the arc cosine of x
! dbl=asin(x) -- returns the arc sine of x
! dbl=atan(x) -- returns the arc tangent of x
dbl=atan2(y x) -- returns the arc tangent of y over x
! dbl=cos(x) -- returns the cosine of x
! dbl=sin(x) -- returns the sine of x
! dbl=tan(x) -- returns the tangent of x
dbl=sqrt(x) -- returns square root of x
--- 115,133 ----
dbl=pow(x y) -- returns the value of x raised to the power of y
! dbl=acos(x) -- returns the arc cosine of x in radians
! dbl=asin(x) -- returns the arc sine of x in radians
! dbl=atan(x) -- returns the arc tangent of x in radians
dbl=atan2(y x) -- returns the arc tangent of y over x
! dbl=cos(x) -- returns the cosine of x radians
! dbl=sin(x) -- returns the sine of x radians
! dbl=tan(x) -- returns the tangent of x radians
dbl=sqrt(x) -- returns square root of x
***************
*** 179,184 ****
--- 179,186 ----
[str]=print(val :string|:str :err) -- print value with format string
symid(symbol [symbol...]) -- return integer id(s) associated with symbol(s)
+
+ symval(symbol [symbol...]) -- return symbols as is without lookup
symbol(symid [symid...]) -- return symbol(s) associated with integer id(s)
Index: OverlayUnidraw/oved.h
diff -c OverlayUnidraw/oved.h:1.1 OverlayUnidraw/oved.h:1.2
*** OverlayUnidraw/oved.h:1.1 Tue Jan 18 03:10:46 2000
--- src/OverlayUnidraw/oved.h Wed Feb 23 04:27:51 2000
***************
*** 32,38 ****
#include <UniIdraw/ided.h>
#include <OverlayUnidraw/ovkit.h>
#include <InterViews/action.h>
!
class AttributeList;
class ComTerpServ;
class Editor;
--- 32,40 ----
#include <UniIdraw/ided.h>
#include <OverlayUnidraw/ovkit.h>
#include <InterViews/action.h>
! extern "C" {
! #include <ComUtil/comutil.h>
! }
class AttributeList;
class ComTerpServ;
class Editor;
Index: FrameUnidraw/frameeditor.c
diff -c FrameUnidraw/frameeditor.c:1.1 FrameUnidraw/frameeditor.c:1.2
*** FrameUnidraw/frameeditor.c:1.1 Tue Jan 18 03:11:15 2000
--- src/FrameUnidraw/frameeditor.c Wed Feb 23 04:27:54 2000
***************
*** 50,55 ****
--- 50,56 ----
#include <InterViews/box.h>
#include <InterViews/border.h>
#include <InterViews/glue.h>
+ #include <InterViews/telltale.h>
#include <IV-2_6/InterViews/frame.h>
#include <IV-2_6/InterViews/panner.h>
***************
*** 97,109 ****
void FrameEditor::Init (OverlayComp* comp, const char* name) {
_curr_other = _prev_other = 0;
_texteditor = nil;
if (!comp) comp = new FrameIdrawComp;
_terp = new ComTerpServ();
AddCommands(_terp);
add_comterp("Flipbook", _terp);
_overlay_kit->Init(comp, name);
InitFrame();
- _autonewframe = false;
}
void FrameEditor::InitCommands() {
--- 98,111 ----
void FrameEditor::Init (OverlayComp* comp, const char* name) {
_curr_other = _prev_other = 0;
_texteditor = nil;
+ _autonewframe = false;
+ _autonewframe_tts = nil;
if (!comp) comp = new FrameIdrawComp;
_terp = new ComTerpServ();
AddCommands(_terp);
add_comterp("Flipbook", _terp);
_overlay_kit->Init(comp, name);
InitFrame();
}
void FrameEditor::InitCommands() {
***************
*** 205,210 ****
--- 207,213 ----
ComEditor::AddCommands(comterp);
comterp->add_command("moveframe", new MoveFrameFunc(comterp, this));
comterp->add_command("createframe", new CreateFrameFunc(comterp, this));
+ comterp->add_command("autonewframe", new AutoNewFrameFunc(comterp, this));
}
void FrameEditor::DoAutoNewFrame() {
***************
*** 213,216 ****
--- 216,224 ----
cmd->Execute();
cmd->Log();
}
+ }
+
+ void FrameEditor::ToggleAutoNewFrame() {
+ _autonewframe = !_autonewframe;
+ if (_autonewframe_tts) _autonewframe_tts->set(TelltaleState::is_chosen, _autonewframe);
}
Index: FrameUnidraw/frameeditor.h
diff -c FrameUnidraw/frameeditor.h:1.1 FrameUnidraw/frameeditor.h:1.2
*** FrameUnidraw/frameeditor.h:1.1 Tue Jan 18 03:11:15 2000
--- src/FrameUnidraw/frameeditor.h Wed Feb 23 04:27:54 2000
***************
*** 32,37 ****
--- 32,38 ----
class FrameNumberState;
class FrameListState;
class FrameView;
+ class TelltaleState;
//: ComEditor specialized for multi-frame use.
class FrameEditor : public ComEditor {
***************
*** 81,87 ****
FrameListState*& frameliststate() { return _frameliststate; }
// return reference to pointer to current-frame-count state variable
! void ToggleAutoNewFrame() { _autonewframe = !_autonewframe; }
// toggle flag which indicates a new frame should be automatically
// created whenever anything is imported.
boolean AutoNewFrame() { return _autonewframe; }
--- 82,88 ----
FrameListState*& frameliststate() { return _frameliststate; }
// return reference to pointer to current-frame-count state variable
! void ToggleAutoNewFrame();
// toggle flag which indicates a new frame should be automatically
// created whenever anything is imported.
boolean AutoNewFrame() { return _autonewframe; }
***************
*** 100,105 ****
--- 101,107 ----
int _curr_other;
int _prev_other;
boolean _autonewframe;
+ TelltaleState* _autonewframe_tts;
friend FrameKit;
};
Index: FrameUnidraw/framefunc.c
diff -c FrameUnidraw/framefunc.c:1.1 FrameUnidraw/framefunc.c:1.2
*** FrameUnidraw/framefunc.c:1.1 Tue Jan 18 03:11:16 2000
--- src/FrameUnidraw/framefunc.c Wed Feb 23 04:27:54 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1998 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 29,34 ****
--- 30,38 ----
#include <Unidraw/viewer.h>
#include <ComTerp/comvalue.h>
+ static int on_symid = symbol_add("on");
+ static int off_symid = symbol_add("off");
+
/*****************************************************************************/
MoveFrameFunc::MoveFrameFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) {
***************
*** 75,80 ****
--- 79,107 ----
execute_log(cmd);
ComValue retval(cmd->moveframecmd()->actualmotion(), ComValue::IntType);
push_stack(retval);
+ }
+ }
+
+ /*****************************************************************************/
+
+ AutoNewFrameFunc::AutoNewFrameFunc(ComTerp* comterp, Editor* ed) : UnidrawFunc(comterp, ed) {
+ }
+
+ void AutoNewFrameFunc::execute() {
+ ComValue onflagv(stack_key(on_symid));
+ ComValue offflagv(stack_key(off_symid));
+ reset_stack();
+
+ FrameEditor* ed = (FrameEditor*)GetEditor();
+
+ if (ed) {
+ if (onflagv.is_false() && offflagv.is_false()) {
+ ed->ToggleAutoNewFrame();
+ } else if (onflagv.is_true()) {
+ if (!ed->AutoNewFrame()) ed->ToggleAutoNewFrame();
+ } else if (offflagv.is_true()) {
+ if (ed->AutoNewFrame()) ed->ToggleAutoNewFrame();
+ }
}
}
Index: FrameUnidraw/framefunc.h
diff -c FrameUnidraw/framefunc.h:1.1 FrameUnidraw/framefunc.h:1.2
*** FrameUnidraw/framefunc.h:1.1 Tue Jan 18 03:11:16 2000
--- src/FrameUnidraw/framefunc.h Wed Feb 23 04:27:54 2000
***************
*** 46,49 ****
--- 46,59 ----
return "%s(:before) -- create and move to new frame"; }
};
+ //: interpreter command to toggle the autonewframe flag
+ // autonewframe(:on :off) -- command to toggle the autonewframe flag
+ class AutoNewFrameFunc : public UnidrawFunc {
+ public:
+ AutoNewFrameFunc(ComTerp*,Editor*);
+ virtual void execute();
+ virtual const char* docstring() {
+ return "%s(:on :off) -- command to toggle autonewframe"; }
+ };
+
#endif /* !defined(_framefunc_h) */
Index: FrameUnidraw/framekit.c
diff -c FrameUnidraw/framekit.c:1.1 FrameUnidraw/framekit.c:1.2
*** FrameUnidraw/framekit.c:1.1 Tue Jan 18 03:11:16 2000
--- src/FrameUnidraw/framekit.c Wed Feb 23 04:27:54 2000
***************
*** 317,322 ****
--- 317,323 ----
#else
menu_item = kit.check_menu_item(kit.label("Auto New Frame"));
menu_item->state()->set(TelltaleState::is_chosen, ((FrameEditor*)GetEditor())->AutoNewFrame());
+ ((FrameEditor*)GetEditor())->_autonewframe_tts = menu_item->state();
AutoNewFrameCmd::default_instance(new AutoNewFrameCmd(GetEditor()));
menu_item->action
(new ActionCallback(AutoNewFrameCmd)
Index: man1_ivtools/comterp.1
diff -c man1_ivtools/comterp.1:1.2 man1_ivtools/comterp.1:1.3
*** man1_ivtools/comterp.1:1.2 Mon Feb 21 20:49:14 2000
--- src/man/man1/comterp.1 Wed Feb 23 04:28:04 2000
***************
*** 125,143 ****
dbl=pow(x y) -- returns the value of x raised to the power of y
! dbl=acos(x) -- returns the arc cosine of x
! dbl=asin(x) -- returns the arc sine of x
! dbl=atan(x) -- returns the arc tangent of x
dbl=atan2(y x) -- returns the arc tangent of y over x
! dbl=cos(x) -- returns the cosine of x
! dbl=sin(x) -- returns the sine of x
! dbl=tan(x) -- returns the tangent of x
dbl=sqrt(x) -- returns square root of x
--- 125,143 ----
dbl=pow(x y) -- returns the value of x raised to the power of y
! dbl=acos(x) -- returns the arc cosine of x in radians
! dbl=asin(x) -- returns the arc sine of x in radians
! dbl=atan(x) -- returns the arc tangent of x in radians
dbl=atan2(y x) -- returns the arc tangent of y over x
! dbl=cos(x) -- returns the cosine of x radians
! dbl=sin(x) -- returns the sine of x radians
! dbl=tan(x) -- returns the tangent of x radians
dbl=sqrt(x) -- returns square root of x
***************
*** 187,192 ****
--- 187,194 ----
[str]=print(val :string|:str :err) -- print value
symid(symbol [symbol...]) -- return integer id(s) associated with symbol(s)
+
+ symval(symbol [symbol...]) -- return symbols as is without lookup
symbol(symid [symid...]) -- return symbol(s) associated with integer id(s)
*** /dev/null Wed Feb 23 04:28:09 PST 2000
--- patches/ivtools-000223-johnston-026
*************** patches/ivtools-000223-johnston-026
*** 0 ****
--- 1 ----
+ ivtools-000223-johnston-026
|