dot operator makes for compound variables, i.e. "a.b=7"
Brought to you by:
johnston
|
From: <ivt...@li...> - 2000-02-17 17:54:40
|
Patch: ivtools-000213-johnston-020
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 the "." (dot) operator to comterp, to allow for compound
variables (i.e. "a.b"). They can be used on the right-hand or
left-hand side of an assignment operator, and used pretty much
anywhere a symbol can be used.
The first operand is either a symbol to assign an AttributeList to, or
an expression that evaluates to an AttributeList. The second operand
is always a symbol. They can be concatenated (i.e. "a.b.c").
Index: ComUtil/optable.c
diff -c ComUtil/optable.c:1.1 ComUtil/optable.c:1.2
*** ComUtil/optable.c:1.1 Tue Jan 18 03:06:51 2000
--- src/ComUtil/optable.c Sun Feb 13 21:43:31 2000
***************
*** 79,85 ****
BOOLEAN rtol;
unsigned optype;
} DefaultOperatorTable[] = {
! {".", "dot", 130, TRUE, OPTYPE_BINARY },
{"^", "power", 120, TRUE, OPTYPE_BINARY },
{"!", "negate", 110, TRUE, OPTYPE_UNARY_PREFIX },
{"++", "incr", 110, TRUE, OPTYPE_UNARY_PREFIX },
--- 79,85 ----
BOOLEAN rtol;
unsigned optype;
} DefaultOperatorTable[] = {
! {".", "dot", 130, FALSE, OPTYPE_BINARY },
{"^", "power", 120, TRUE, OPTYPE_BINARY },
{"!", "negate", 110, TRUE, OPTYPE_UNARY_PREFIX },
{"++", "incr", 110, TRUE, OPTYPE_UNARY_PREFIX },
Index: Attribute/attribute.c
diff -c Attribute/attribute.c:1.1 Attribute/attribute.c:1.2
*** Attribute/attribute.c:1.1 Tue Jan 18 03:06:54 2000
--- src/Attribute/attribute.c Sun Feb 13 21:43:33 2000
***************
*** 26,31 ****
--- 26,33 ----
/*****************************************************************************/
+ int Attribute::_symid = -1;
+
Attribute::Attribute(const char* name, AttributeValue* value) {
if (name)
symbolid = symbol_add((char *)name);
Index: Attribute/attribute.h
diff -c Attribute/attribute.h:1.1 Attribute/attribute.h:1.2
*** Attribute/attribute.h:1.1 Tue Jan 18 03:06:54 2000
--- src/Attribute/attribute.h Sun Feb 13 21:43:33 2000
***************
*** 24,29 ****
--- 24,41 ----
#ifndef _attribute_h
#define _attribute_h
+ //: define methods for a class name and class symbol id.
+ // adds ::class_name() and ::class_symid() based on 'name' to any
+ // class definition. For use in servers built on ComTerp for generating a
+ // unique id for a given type of component.
+ #define classid(name) \
+ public: \
+ static const char* class_name() {return name;}\
+ static int class_symid()\
+ { if (_symid<0) _symid=symbol_add((char*)class_name()); return _symid;} \
+ protected: \
+ static int _symid;
+
extern "C" {
int symbol_add(char*);
int symbol_del(int);
***************
*** 68,73 ****
--- 80,87 ----
AttributeValue* valueptr;
friend AttributeList;
+
+ classid("Attribute");
};
#endif
Index: Attribute/attrlist.c
diff -c Attribute/attrlist.c:1.1 Attribute/attrlist.c:1.2
*** Attribute/attrlist.c:1.1 Tue Jan 18 03:06:55 2000
--- src/Attribute/attrlist.c Sun Feb 13 21:43:33 2000
***************
*** 42,47 ****
--- 42,49 ----
/*****************************************************************************/
+ int AttributeList::_symid = -1;
+
AttributeList::AttributeList (AttributeList* s) {
_alist = new AList;
_count = 0;
***************
*** 113,118 ****
--- 115,130 ----
for (First(i); !Done(i); Next(i)) {
Attribute* attr = GetAttr(i);
if (strcmp(n, attr->Name()) == 0)
+ return attr;
+ }
+ return nil;
+ }
+
+ Attribute* AttributeList::GetAttr (int symid) {
+ ALIterator i;
+ for (First(i); !Done(i); Next(i)) {
+ Attribute* attr = GetAttr(i);
+ if (symid == attr->SymbolId())
return attr;
}
return nil;
Index: Attribute/attrlist.h
diff -c Attribute/attrlist.h:1.1 Attribute/attrlist.h:1.2
*** Attribute/attrlist.h:1.1 Tue Jan 18 03:06:55 2000
--- src/Attribute/attrlist.h Sun Feb 13 21:43:33 2000
***************
*** 36,41 ****
--- 36,53 ----
#define AList _lib_iv(UList)
#endif
+ //: define methods for a class name and class symbol id.
+ // adds ::class_name() and ::class_symid() based on 'name' to any
+ // class definition. For use in servers built on ComTerp for generating a
+ // unique id for a given type of component.
+ #define classid(name) \
+ public: \
+ static const char* class_name() {return name;}\
+ static int class_symid()\
+ { if (_symid<0) _symid=symbol_add((char*)class_name()); return _symid;} \
+ protected: \
+ static int _symid;
+
class ALIterator;
class AList;
class istream;
***************
*** 91,96 ****
--- 103,110 ----
Attribute* GetAttr(const char*);
// get attribute by name.
+ Attribute* GetAttr(int symid);
+ // get attribute by symbol id.
Attribute* GetAttr(ALIterator);
// get attribute pointed to by iterator.
void SetAttr(Attribute*, ALIterator&);
***************
*** 145,150 ****
--- 159,166 ----
AList* _alist;
unsigned int _count;
+
+ classid("AttributeList");
};
//: list of AttributeValue objects.
Index: Attribute/attrvalue.c
diff -c Attribute/attrvalue.c:1.1 Attribute/attrvalue.c:1.2
*** Attribute/attrvalue.c:1.1 Tue Jan 18 03:06:56 2000
--- src/Attribute/attrvalue.c Sun Feb 13 21:43:33 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1994-1997 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 22,27 ****
--- 23,29 ----
*/
#include <Attribute/aliterator.h>
+ #include <Attribute/attribute.h>
#include <Attribute/attrvalue.h>
#include <Attribute/attrlist.h>
***************
*** 539,544 ****
--- 541,550 ----
return _v.objval.type;
}
+ unsigned int AttributeValue::class_symid() {
+ return _v.objval.type;
+ }
+
AttributeValueList* AttributeValue::array_val() {
return array_ref();
}
***************
*** 754,759 ****
--- 760,769 ----
case AttributeValue::BlankType:
break;
+ case AttributeValue::ObjectType:
+ out << "<" << symbol_pntr(svp->class_symid()) << ">";
+ break;
+
default:
out << "Unknown type";
break;
***************
*** 830,834 ****
--- 840,868 ----
default:
return 0;
}
+ }
+
+ void AttributeValue::assignval (const AttributeValue& av) {
+ void* v1 = &_v;
+ const void* v2 = &av._v;
+ memcpy(v1, v2, sizeof(double));
+ _type = av._type;
+ _aggregate_type = av._aggregate_type;
+ #if 0 // this end of reference counting disabled as well
+ if (_type == StringType || _type == SymbolType)
+ symbol_add((char *)string_ptr());
+ else
+ #endif
+ if (_type == ArrayType && _v.arrayval.ptr)
+ Resource::ref(_v.arrayval.ptr);
+ }
+
+
+ boolean AttributeValue::is_attributelist() {
+ return is_object() && class_symid() == AttributeList::class_symid();
+ }
+
+ boolean AttributeValue::is_attribute() {
+ return is_object() && class_symid() == Attribute::class_symid();
}
Index: Attribute/attrvalue.h
diff -c Attribute/attrvalue.h:1.2 Attribute/attrvalue.h:1.3
*** Attribute/attrvalue.h:1.2 Tue Feb 1 23:08:39 2000
--- src/Attribute/attrvalue.h Sun Feb 13 21:43:33 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1994-1999 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 143,148 ****
--- 144,152 ----
static int type_size(ValueType);
// return sizeof of value of given type.
+ void assignval (const AttributeValue&);
+ // copy contents of AttributeValue
+
char& char_ref(); // char by reference.
unsigned char& uchar_ref(); // unsigned char by reference.
short& short_ref(); // short by reference.
***************
*** 178,183 ****
--- 182,188 ----
unsigned int symbol_val(); // symbol id by value.
void* obj_val(); // void* pointer to object by value.
unsigned int obj_type_val(); // classid of object by value.
+ unsigned int class_symid(); // classid of object by value.
AttributeValueList* array_val(); // values in list by value.
unsigned int array_type_val(); // type of values in list by value
unsigned int keyid_val(); // symbol id of keyword by value.
***************
*** 268,278 ****
static boolean is_num(ValueType t)
{ return is_integer(t) || is_floatingpoint(t); }
-
boolean is_blank() { return is_type(BlankType); }
// returns true if BlankType.
static boolean is_blank(ValueType t)
{ return t==BlankType; };
friend ostream& operator << (ostream& s, const AttributeValue&);
// output AttributeValue to ostream.
--- 273,287 ----
static boolean is_num(ValueType t)
{ return is_integer(t) || is_floatingpoint(t); }
boolean is_blank() { return is_type(BlankType); }
// returns true if BlankType.
static boolean is_blank(ValueType t)
{ return t==BlankType; };
+
+ boolean is_attributelist();
+ // returns true if ObjectType with an AttributeList object.
+ boolean is_attribute();
+ // returns true if ObjectType with an Attribute object.
friend ostream& operator << (ostream& s, const AttributeValue&);
// output AttributeValue to ostream.
Index: ComTerp/Imakefile
diff -c ComTerp/Imakefile:1.1 ComTerp/Imakefile:1.2
*** ComTerp/Imakefile:1.1 Tue Jan 18 03:07:02 2000
--- src/ComTerp/Imakefile Sun Feb 13 21:43:36 2000
***************
*** 24,29 ****
--- 24,30 ----
Obj(comvalue)
Obj(condfunc)
ObjA(ctrlfunc)
+ Obj(dotfunc)
Obj(helpfunc)
Obj(iofunc)
Obj(listfunc)
Index: ComTerp/assignfunc.c
diff -c ComTerp/assignfunc.c:1.1 ComTerp/assignfunc.c:1.2
*** ComTerp/assignfunc.c:1.1 Tue Jan 18 03:07:03 2000
--- src/ComTerp/assignfunc.c Sun Feb 13 21:43:36 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1997,1999 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 53,58 ****
--- 54,62 ----
Unref(attrlist);
} else
comterp()->localtable()->insert(operand1.symbol_val(), operand2);
+ } else if (operand1.type() == ComValue::ObjectType && operand1.class_symid() == Attribute::class_symid()) {
+ Attribute* attr = (Attribute*)operand1.obj_val();
+ attr->Value(operand2);
} else {
cerr << "assignment to something other than a symbol ignored\n";
// should say something about assignment from something other than a symbol as well.
Index: ComTerp/comterp.c
diff -c ComTerp/comterp.c:1.1 ComTerp/comterp.c:1.2
*** ComTerp/comterp.c:1.1 Tue Jan 18 03:07:03 2000
--- src/ComTerp/comterp.c Sun Feb 13 21:43:36 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1994-1998 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 31,36 ****
--- 32,38 ----
#include <ComTerp/comvalue.h>
#include <ComTerp/condfunc.h>
#include <ComTerp/ctrlfunc.h>
+ #include <ComTerp/dotfunc.h>
#include <ComTerp/helpfunc.h>
#include <ComTerp/iofunc.h>
#include <ComTerp/listfunc.h>
***************
*** 43,48 ****
--- 45,51 ----
#include <ComTerp/symbolfunc.h>
#include <ComTerp/xformfunc.h>
#include <Attribute/attrlist.h>
+ #include <Attribute/attribute.h>
#include <ctype.h>
#include <iostream.h>
***************
*** 189,194 ****
--- 192,201 ----
} else
push_stack(lookup_symval(sv));
+ } else if (sv.type() == ComValue::ObjectType && sv.class_symid() == Attribute::class_symid()) {
+
+ push_stack(*((Attribute*)sv.obj_val())->Value());
+
} else if (sv.type() == ComValue::BlankType) {
/* ignore it */
***************
*** 559,564 ****
--- 566,575 ----
} else
return ComValue::nullval();
}
+ } else if (comval.type() == ComValue::ObjectType && comval.class_symid() == Attribute::class_symid()) {
+
+ comval.assignval(*((Attribute*)comval.obj_val())->Value());
+
}
return comval;
}
***************
*** 709,714 ****
--- 720,729 ----
add_command("stream", new StreamFunc(this));
add_command("repeat", new RepeatFunc(this));
add_command("iterate", new IterateFunc(this));
+
+ add_command("dot", new DotFunc(this));
+ add_command("dname", new DotNameFunc(this));
+ add_command("dval", new DotValFunc(this));
add_command("at", new ListAtFunc(this));
add_command("size", new ListSizeFunc(this));
Index: ComTerp/comvalue.c
diff -c ComTerp/comvalue.c:1.1 ComTerp/comvalue.c:1.2
*** ComTerp/comvalue.c:1.1 Tue Jan 18 03:07:04 2000
--- src/ComTerp/comvalue.c Sun Feb 13 21:43:36 2000
***************
*** 1,4 ****
--- 1,5 ----
/*
+ * Copyright (c) 2000 IET Inc.
* Copyright (c) 1994-1998 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
***************
*** 24,29 ****
--- 25,31 ----
#include <ComTerp/comvalue.h>
#include <ComTerp/comterp.h>
#include <Attribute/attrlist.h>
+ #include <Attribute/attribute.h>
#include <Attribute/aliterator.h>
#include <Attribute/paramlist.h>
***************
*** 122,143 ****
return *this;
}
- void ComValue::assignval (const ComValue& sv) {
- void* v1 = &_v;
- const void* v2 = &sv._v;
- memcpy(v1, v2, sizeof(double));
- _type = sv._type;
- _aggregate_type = sv._aggregate_type;
- #if 0 // this end of reference counting disabled as well
- if (_type == StringType || _type == SymbolType)
- symbol_add((char *)string_ptr());
- else
- #endif
- if (_type == ArrayType && _v.arrayval.ptr)
- Resource::ref(_v.arrayval.ptr);
- }
-
-
int ComValue::narg() const { return _narg; }
int ComValue::nkey() const { return _nkey; }
int ComValue::nids() const { return _nids; }
--- 124,129 ----
***************
*** 301,312 ****
case ComValue::BlankType:
break;
case ComValue::UnknownType:
! out << "nil";
! break;
default:
! break;
}
return out;
}
--- 287,305 ----
case ComValue::BlankType:
break;
+ case ComValue::ObjectType:
+ if (svp->class_symid() == Attribute::class_symid())
+ out << "<" << *((Attribute*)svp->obj_val())->Value() << ">";
+ else
+ out << "<" << symbol_pntr(svp->class_symid()) << ">";
+ break;
+
case ComValue::UnknownType:
! out << "nil";
! break;
default:
! break;
}
return out;
}
Index: ComTerp/comvalue.h
diff -c ComTerp/comvalue.h:1.5 ComTerp/comvalue.h:1.6
*** ComTerp/comvalue.h:1.5 Wed Feb 2 03:19:57 2000
--- src/ComTerp/comvalue.h Sun Feb 13 21:43:36 2000
***************
*** 88,95 ****
ComValue& operator= (const ComValue&);
// assignment operator.
- void assignval (const ComValue&);
- // assign only the AttributeValue portion of a ComValue.
int narg() const;
// number of arguments associated with this command or keyword.
--- 88,93 ----
Index: ComTerp/ctrlfunc.c
diff -c ComTerp/ctrlfunc.c:1.1 ComTerp/ctrlfunc.c:1.2
*** ComTerp/ctrlfunc.c:1.1 Tue Jan 18 03:07:04 2000
--- src/ComTerp/ctrlfunc.c Sun Feb 13 21:43:36 2000
***************
*** 67,84 ****
/*****************************************************************************/
- DotFunc::DotFunc(ComTerp* comterp) : ComFunc(comterp) {
- }
-
- void DotFunc::execute() {
- ComValue thisval(stack_arg(0));
- ComValue methval(stack_arg(1));
- reset_stack();
- push_stack(methval);
- }
-
- /*****************************************************************************/
-
TimeExprFunc::TimeExprFunc(ComTerp* comterp) : ComFunc(comterp) {
}
--- 67,72 ----
Index: ComTerp/ctrlfunc.h
diff -c ComTerp/ctrlfunc.h:1.1 ComTerp/ctrlfunc.h:1.2
*** ComTerp/ctrlfunc.h:1.1 Tue Jan 18 03:07:04 2000
--- src/ComTerp/ctrlfunc.h Sun Feb 13 21:43:36 2000
***************
*** 63,77 ****
};
- //: . (dot) operator.
- class DotFunc : public ComFunc {
- public:
- DotFunc(ComTerp*);
-
- virtual void execute();
-
- };
-
//: timer expression command for ComTerp.
// timeexpr(comstr :sec n) -- command string to execute at intervals.
class TimeExprFunc : public ComFunc {
--- 63,68 ----
Index: ComTerp/dotfunc.c
diff -c /dev/null ComTerp/dotfunc.c:1.1
*** /dev/null Sun Feb 13 21:43:39 2000
--- src/ComTerp/dotfunc.c Sun Feb 13 21:43:36 2000
***************
*** 0 ****
--- 1,109 ----
+ /*
+ * Copyright (c) 2000 IET Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+ #include <ComTerp/dotfunc.h>
+ #include <ComTerp/comvalue.h>
+ #include <ComTerp/comterp.h>
+ #include <Attribute/attrlist.h>
+ #include <Attribute/attribute.h>
+
+ #define TITLE "DotFunc"
+
+ /*****************************************************************************/
+
+ DotFunc::DotFunc(ComTerp* comterp) : ComFunc(comterp) {
+ }
+
+ void DotFunc::execute() {
+ ComValue before_part(stack_arg(0, true));
+ ComValue after_part(stack_arg(1, true));
+ reset_stack();
+ if (!before_part.is_symbol() &&
+ !(before_part.is_attribute() &&
+ ((Attribute*)before_part.obj_val())->Value()->is_attributelist())) {
+ cerr << "expression before \".\" needs to evaluate to a symbol or <AttributeList>\n";
+ return;
+ }
+ if (!after_part.is_symbol()) {
+ cerr << "expression after \".\" needs to be a symbol\n";
+ return;
+ }
+
+
+ /* lookup value of before variable */
+ void* vptr = nil;
+ AttributeList* al = nil;
+ if (!before_part.is_attribute()) {
+ int before_symid = before_part.symbol_val();
+ comterp()->localtable()->find(vptr, before_symid);
+ if (vptr &&((ComValue*) vptr)->class_symid() == AttributeList::class_symid()) {
+ al = (AttributeList*) ((ComValue*) vptr)->obj_val();
+ } else {
+ al = new AttributeList();
+ ComValue* comval = new ComValue(AttributeList::class_symid(), al);
+ comterp()->localtable()->insert(before_symid, comval);
+ }
+ } else
+ al = (AttributeList*) ((Attribute*) before_part.obj_val())->Value()->obj_val();
+
+ int after_symid = after_part.symbol_val();
+ Attribute* attr = al->GetAttr(after_symid);
+ if (!attr) {
+ attr = new Attribute(after_symid, new AttributeValue());
+ al->add_attribute(attr);
+ }
+ ComValue retval(Attribute::class_symid(), attr);
+ push_stack(retval);
+ }
+
+ /*****************************************************************************/
+
+ DotNameFunc::DotNameFunc(ComTerp* comterp) : ComFunc(comterp) {
+ }
+
+ void DotNameFunc::execute() {
+ ComValue dotted_pair(stack_arg(0));
+ reset_stack();
+ if (dotted_pair.class_symid() != Attribute::class_symid()) return;
+ Attribute *attr = (Attribute*)dotted_pair.obj_val();
+ ComValue retval(attr->SymbolId(), ComValue::SymbolType);
+ push_stack(retval);
+ }
+
+ /*****************************************************************************/
+
+ DotValFunc::DotValFunc(ComTerp* comterp) : ComFunc(comterp) {
+ }
+
+ void DotValFunc::execute() {
+ ComValue dotted_pair(stack_arg(0));
+ reset_stack();
+ if (dotted_pair.class_symid() != Attribute::class_symid()) return;
+ Attribute *attr = (Attribute*)dotted_pair.obj_val();
+ push_stack(*attr->Value());
+ }
+
+
+
+
+
Index: ComTerp/dotfunc.h
diff -c /dev/null ComTerp/dotfunc.h:1.1
*** /dev/null Sun Feb 13 21:43:39 2000
--- src/ComTerp/dotfunc.h Sun Feb 13 21:43:36 2000
***************
*** 0 ****
--- 1,63 ----
+ /*
+ * Copyright (c) 2000 IET Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. The copyright holders make
+ * no representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+ /*
+ * dot func supports a compound variable
+ */
+
+ #if !defined(_dotfunc_h)
+ #define _dotfunc_h
+
+ #include <ComTerp/numfunc.h>
+
+ //: . (dot) operator, for compound variables.
+ class DotFunc : public ComFunc {
+ public:
+ DotFunc(ComTerp*);
+
+ virtual void execute();
+ virtual const char* docstring() {
+ return ". makes compound variables"; }
+ };
+
+ //: dname returns name field of a dotted pair
+ class DotNameFunc : public ComFunc {
+ public:
+ DotNameFunc(ComTerp*);
+
+ virtual void execute();
+ virtual const char* docstring() {
+ return "%s(attribute) returns name field of a dotted pair"; }
+ };
+
+ //: dval returns value field of a dotted pair
+ class DotValFunc : public ComFunc {
+ public:
+ DotValFunc(ComTerp*);
+
+ virtual void execute();
+ virtual const char* docstring() {
+ return "%s(attribute) returns value field of a dotted pair"; }
+ };
+ #endif /* !defined(_dotfunc_h) */
+
Index: ComTerp/helpfunc.c
diff -c ComTerp/helpfunc.c:1.1 ComTerp/helpfunc.c:1.2
*** ComTerp/helpfunc.c:1.1 Tue Jan 18 03:07:04 2000
--- src/ComTerp/helpfunc.c Sun Feb 13 21:43:36 2000
***************
*** 73,80 ****
} else if (val.is_type(AttributeValue::StringType)) {
void *vptr = nil;
comterp()->localtable()->find(vptr, val.string_val());
! if (vptr) {
! comfuncs[i] = (ComFunc*)((ComValue*)vptr)->obj_val();
} else
comfuncs[i] = nil;
command_ids[i] = val.string_val();
--- 73,80 ----
} else if (val.is_type(AttributeValue::StringType)) {
void *vptr = nil;
comterp()->localtable()->find(vptr, val.string_val());
! if (vptr && ((ComValue*)vptr)->is_command()) {
! comfuncs[i] = (ComFunc*)((ComValue*)vptr)->obj_val();
} else
comfuncs[i] = nil;
command_ids[i] = val.string_val();
***************
*** 104,110 ****
void* vptr;
comterp()->localtable()->find(vptr, command_id);
! if (vptr) {
comfuncs[j] = (ComFunc*)((ComValue*)vptr)->obj_val();
} else
comfuncs[j] = nil;
--- 104,110 ----
void* vptr;
comterp()->localtable()->find(vptr, command_id);
! if (vptr && ((ComValue*)vptr)->is_command()) {
comfuncs[j] = (ComFunc*)((ComValue*)vptr)->obj_val();
} else
comfuncs[j] = nil;
*** /dev/null Sun Feb 13 21:44:17 PST 2000
--- patches/ivtools-000213-johnston-020
*************** patches/ivtools-000213-johnston-020
*** 0 ****
--- 1 ----
+ ivtools-000213-johnston-020
|