=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/Kclass/tree.c,v retrieving revision 1.3 retrieving revision 1.6 diff -u -p -r1.3 -r1.6 --- OpenXM/src/kan96xx/Kan/Kclass/tree.c 2003/11/24 06:50:16 1.3 +++ OpenXM/src/kan96xx/Kan/Kclass/tree.c 2003/12/05 23:14:14 1.6 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/Kclass/tree.c,v 1.2 2003/11/24 02:13:40 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/Kclass/tree.c,v 1.5 2003/12/05 13:51:32 takayama Exp $ */ #include #include "../datatype.h" #include "../stackm.h" @@ -56,7 +56,7 @@ int isTreeAdd(struct object ob) { if (name.tag != Sdollar) { errorKan1("%s\n","CLASSNAME_tree is broken. Should be string."); } - if (strcmp(KopString(name),"add") == 0) { + if (strcmp(KopString(name),"plus") == 0) { return(1); }else{ return(0); @@ -67,7 +67,11 @@ struct object addTree(struct object ob1, struct object { struct object rob,aob; struct object ob3,ob4; + struct object attr; + struct object keyValue; + struct object to; int i; + to = ob2; ob2=ob1; ob1=to; /* Exchange ob1 and ob2 */ if (isTreeAdd(ob1) && !isTreeAdd(ob2)) { ob1 = KopTree(ob1); ob3 = getoa(ob1,2); @@ -101,9 +105,14 @@ struct object addTree(struct object ob1, struct object putoa(aob,0,ob1); putoa(aob,1,ob2); } + attr = newObjectArray(1); + keyValue = newObjectArray(2); + putoa(keyValue,0,KpoString("cd")); + putoa(keyValue,1,KpoString("arith1")); + putoa(attr,0,keyValue); rob = newObjectArray(3); - putoa(rob,0,KpoString("add")); - putoa(rob,1,KpoString("basic")); + putoa(rob,0,KpoString("plus")); + putoa(rob,1,attr); putoa(rob,2,aob); return(KpoTree(rob)); } @@ -115,8 +124,11 @@ struct object KtreeGetDocumentElement(struct object to if (to.tag != Sclass) errorKan1("%s\n","KtreeGetDocumentElement"); if (ectag(to) != CLASSNAME_tree) errorKan1("%s\n","KtreeGetDocumentElement"); ob = KopTree(to); - if (ob.tag != Sdollar) errorKan1("%s\n","KtreeGetDocumentElement: element name is not a string."); - return getoa(ob,0); + if (ob.tag != Sarray) errorKan1("%s\n","KtreeGetDocumentElement: not an array."); + if (getoaSize(ob) != 3) errorKan1("%s\n","KtreeGetDocumentElement: array is broken."); + ob=getoa(ob,0); + if (ob.tag != Sdollar) errorKan1("%s\n","KtreeGetDocumentElement: element must be a string"); + return ob; } struct object KtreeGetAttributes(struct object to) { @@ -126,6 +138,7 @@ struct object KtreeGetAttributes(struct object to) { if (ectag(to) != CLASSNAME_tree) errorKan1("%s\n","KtreeGetAttributes:"); ob = KopTree(to); if (ob.tag != Sarray) errorKan1("%s\n","KtreeGetAttributes: not an array."); + if (getoaSize(ob) != 3) errorKan1("%s\n","KtreeGetAttributes: array is broken."); return getoa(ob,1); } @@ -136,6 +149,7 @@ struct object KtreeGetChildNodes(struct object to) { if (ectag(to) != CLASSNAME_tree) errorKan1("%s\n","KtreeGetChildNodes:"); ob = KopTree(to); if (ob.tag != Sarray) errorKan1("%s\n","KtreeGetChildNodes: not an array."); + if (getoaSize(ob) != 3) errorKan1("%s\n","KtreeGetChildNodes: array is broken."); return getoa(ob,2); }