1 2 /* 3 * bltTree.h -- 4 * 5 * Copyright 1998-1999 Lucent Technologies, Inc. 6 * 7 * Permission to use, copy, modify, and distribute this software and 8 * its documentation for any purpose and without fee is hereby 9 * granted, provided that the above copyright notice appear in all 10 * copies and that both that the copyright notice and warranty 11 * disclaimer appear in supporting documentation, and that the names 12 * of Lucent Technologies or any of their entities not be used in 13 * advertising or publicity pertaining to distribution of the software 14 * without specific, written prior permission. 15 * 16 * Lucent Technologies disclaims all warranties with regard to this 17 * software, including all implied warranties of merchantability and 18 * fitness. In no event shall Lucent Technologies be liable for any 19 * special, indirect or consequential damages or any damages 20 * whatsoever resulting from loss of use, data or profits, whether in 21 * an action of contract, negligence or other tortuous action, arising 22 * out of or in connection with the use or performance of this 23 * software. 24 * 25 * The "tree" data object was created by George A. Howlett. 26 */ 27 28 #ifndef _BLT_TREE_H 29 #define _BLT_TREE_H 30 31 #include <bltChain.h> 32 #include <bltHash.h> 33 #include <bltPool.h> 34 35 typedef struct Blt_TreeNodeStruct *Blt_TreeNode; 36 typedef struct Blt_TreeObjectStruct *Blt_TreeObject; 37 typedef struct Blt_TreeClientStruct *Blt_Tree; 38 typedef struct Blt_TreeTraceStruct *Blt_TreeTrace; 39 typedef struct Blt_TreeValueStruct *Blt_TreeValue; 40 typedef struct Blt_TreeTagEntryStruct Blt_TreeTagEntry; 41 typedef struct Blt_TreeTagTableStruct Blt_TreeTagTable; 42 43 typedef CONST char *Blt_TreeKey; 44 45 /* FindData->order flags. */ 46 #define TREE_PREORDER (1<<0) 47 #define TREE_POSTORDER (1<<1) 48 #define TREE_INORDER (1<<2) 49 #define TREE_BREADTHFIRST (1<<3) 50 51 /* Flags set in node->flags (a short) */ 52 #define TREE_TRACE_UNSET (1<<3) 53 #define TREE_TRACE_WRITE (1<<4) 54 #define TREE_TRACE_READ (1<<5) 55 #define TREE_TRACE_CREATE (1<<6) 56 #define TREE_TRACE_TAGMULTIPLE (1<<7) 57 #define TREE_TRACE_TAGADD (1<<8) 58 #define TREE_TRACE_TAGDELETE (1<<9) 59 #define TREE_TRACE_EXISTS (1<<0x0A) 60 #define TREE_TRACE_ALL \ 61 (TREE_TRACE_UNSET | TREE_TRACE_WRITE | TREE_TRACE_READ | TREE_TRACE_CREATE |TREE_TRACE_TAGMULTIPLE|TREE_TRACE_TAGADD|TREE_TRACE_TAGDELETE|TREE_TRACE_EXISTS) 62 #define TREE_TRACE_MASK (TREE_TRACE_ALL) 63 #define TREE_TRACE_ACTIVE (1<<0x0C) 64 #define TREE_NODE_UNMODIFIED (1<<0x0D) 65 #define TREE_NODE_INSERT_FAIL (1<<0x0E) 66 #define TREE_NODE_FIXED_FIELDS (1<<0x0F) 67 68 /* Flags set in tree->flags */ 69 #define TREE_TRACE_BGERROR (1<<0x10) 70 #define TREE_TRACE_FOREIGN_ONLY (1<<0x11) 71 #define TREE_FIXED_KEYS (1<<0x0F) 72 #define TREE_UNMODIFIED (1<<0x13) 73 #define TREE_DICT_KEYS (1<<0x14) 74 75 /* Flags set in tree->notifyFlags that used for tracing */ 76 #define TREE_NOTIFY_CREATE (1<<0) 77 #define TREE_NOTIFY_DELETE (1<<1) 78 #define TREE_NOTIFY_MOVE (1<<2) 79 #define TREE_NOTIFY_SORT (1<<3) 80 #define TREE_NOTIFY_RELABEL (1<<4) 81 #define TREE_NOTIFY_MOVEPOST (1<<5) 82 #define TREE_NOTIFY_RELABELPOST (1<<6) 83 #define TREE_NOTIFY_INSERT (1<<7) 84 #define TREE_NOTIFY_GET (1<<8) 85 #define TREE_NOTIFY_ALL \ 86 (TREE_NOTIFY_CREATE | TREE_NOTIFY_DELETE | TREE_NOTIFY_MOVE | \ 87 TREE_NOTIFY_MOVEPOST | TREE_NOTIFY_SORT | TREE_NOTIFY_RELABEL | \ 88 TREE_NOTIFY_RELABELPOST | TREE_NOTIFY_INSERT | TREE_NOTIFY_GET) 89 #define TREE_NOTIFY_MASK (TREE_NOTIFY_ALL) 90 #define TREE_NOTIFY_WHENIDLE (1<<0x10) 91 #define TREE_NOTIFY_FOREIGN_ONLY (1<<0x11) 92 #define TREE_NOTIFY_ACTIVE (1<<0x12) 93 #define TREE_NOTIFY_BGERROR (1<<0x13) 94 #define TREE_NOTIFY_TRACEACTIVE (1<<0x14) 95 96 typedef struct { 97 int type; 98 Blt_Tree tree; 99 unsigned int inode; /* Node of event */ 100 Tcl_Interp *interp; 101 } Blt_TreeNotifyEvent; 102 103 typedef struct { 104 Blt_TreeNode node; /* Node being searched. */ 105 unsigned long nextIndex; /* Index of next bucket to be 106 * enumerated after present one. */ 107 Blt_TreeValue nextValue; /* Next entry to be enumerated in the 108 * the current bucket. */ 109 int cnt; 110 } Blt_TreeKeySearch; 111 112 /* 113 * Blt_TreeObject -- 114 * 115 * Structure providing the internal representation of the tree 116 * object. A tree is uniquely identified by a combination of 117 * its name and originating namespace. Two trees in the same 118 * interpreter can have the same names but reside in different 119 * namespaces. 120 * 121 * The tree object represents a general-ordered tree of nodes. 122 * Each node may contain a heterogeneous collection of data 123 * values. Each value is identified by a field name and nodes 124 * do not need to contain the same data fields. Data field 125 * names are saved as reference counted strings and can be 126 * shared among nodes. 127 * 128 * The tree is threaded. A node contains both a pointer to 129 * back its parents and another to its siblings. Therefore 130 * the tree maybe traversed non-recursively. 131 * 132 * A tree object can be shared by several clients. When a 133 * client wants to use a tree object, it is given a token 134 * that represents the tree. The tree object uses the tokens 135 * to keep track of its clients. When all clients have 136 * released their tokens the tree is automatically destroyed. 137 */ 138 struct Blt_TreeObjectStruct { 139 Tcl_Interp *interp; /* Interpreter associated with this tree. */ 140 141 char *name; 142 143 Tcl_Namespace *nsPtr; 144 145 Blt_HashEntry *hashPtr; /* Pointer to this tree object in tree 146 * object hash table. */ 147 Blt_HashTable *tablePtr; 148 149 Blt_TreeNode root; /* Root of the entire tree. */ 150 151 char *sortNodesCmd; /* Tcl command to invoke to sort entries */ 152 153 Blt_Chain *clients; /* List of clients using this tree */ 154 155 Blt_Pool nodePool; 156 Blt_Pool valuePool; 157 158 Blt_HashTable nodeTable; /* Table of node identifiers. Used to 159 * search for a node pointer given an inode.*/ 160 unsigned int nextInode; 161 162 unsigned int nNodes; /* Always counts root node. */ 163 164 unsigned int depth; /* Maximum depth of the tree. */ 165 166 unsigned int flags; /* Internal flags. See definitions 167 * above. */ 168 unsigned int notifyFlags; /* Notification flags. See definitions 169 * above. */ 170 Blt_HashTable keyTable; /* Per-tree keys. */ 171 Blt_HashTable *interpKeyPtr; /* The local or interp-wide key table. */ 172 int delete; 173 int maxKeyList; /* Max key list length before hash (default 20). */ 174 }; 175 176 /* 177 * Blt_TreeNodeStruct -- 178 * 179 * Structure representing a node in a general ordered tree. 180 * Nodes are identified by their index, or inode. Nodes also 181 * have names, but nodes names are not unique and can be 182 * changed. Inodes are valid even if the node is moved. 183 * 184 * Each node can contain a list of data fields. Fields are 185 * name-value pairs. The values are represented by Tcl_Objs. 186 * 187 */ 188 struct Blt_TreeNodeStruct { 189 Blt_TreeNode parent; /* Parent node. If NULL, then this is 190 the root node. */ 191 Blt_TreeNode next; /* Next sibling node. */ 192 Blt_TreeNode prev; /* Previous sibling node. */ 193 Blt_TreeNode first; /* First child node. */ 194 Blt_TreeNode last; /* Last child node. */ 195 196 Blt_TreeKey label; /* Node label (doesn't have to be 197 * unique). */ 198 199 Blt_TreeObject treeObject; 200 201 Blt_TreeValue values; /* Depending upon the number of values 202 * stored, this is either a chain or 203 * hash table of Blt_TreeValue 204 * structures. (Note: if logSize is 205 * 0, then this is a list). Each 206 * value contains key/value data 207 * pair. The data is a Tcl_Obj. */ 208 209 unsigned short nValues; /* # of values for this node. */ 210 211 unsigned short logSize; /* Size of hash table indicated as a 212 * power of 2 (e.g. if logSize=3, then 213 * table size is 8). If 0, this 214 * indicates that the node's values 215 * are stored as a list. */ 216 217 unsigned int nChildren; /* # of children for this node. */ 218 unsigned int inode; /* Serial number of the node. */ 219 220 unsigned short depth; /* The depth of this node in the tree. */ 221 222 unsigned short flags; 223 }; 224 225 struct Blt_TreeTagEntryStruct { 226 char *tagName; 227 Blt_HashEntry *hashPtr; 228 Blt_HashTable nodeTable; 229 int refCount; /* Used to delay deletion while iterating. */ 230 }; 231 232 #define Blt_TreeTagRefDecr(tPtr) if (--(tPtr)->refCount > 0) ; else Blt_Free(tPtr) 233 #define Blt_TreeTagRefIncr(tPtr) ++(tPtr)->refCount 234 235 struct Blt_TreeTagTableStruct { 236 Blt_HashTable tagTable; 237 int refCount; 238 }; 239 240 /* 241 * Blt_TreeStruct -- 242 * 243 * A tree can be shared by several clients. Each client allocates 244 * this structure which acts as a ticket for using the tree. Clients 245 * can designate notifier routines that are automatically invoked 246 * by the tree object whenever the tree is changed is specific 247 * ways by other clients. 248 */ 249 250 struct Blt_TreeClientStruct { 251 unsigned int magic; /* Magic value indicating whether a 252 * generic pointer is really a tree 253 * token or not. */ 254 Blt_ChainLink *linkPtr; /* Pointer into the server's chain of 255 * clients. */ 256 Blt_TreeObject treeObject; /* Pointer to the structure containing 257 * the master information about the 258 * tree used by the client. If NULL, 259 * this indicates that the tree has 260 * been destroyed (but as of yet, this 261 * client hasn't recognized it). */ 262 263 Blt_Chain *events; /* Chain of node event handlers. */ 264 Blt_Chain *traces; /* Chain of data field callbacks. */ 265 Blt_TreeNode root; /* Designated root for this client */ 266 Blt_TreeTagTable *tagTablePtr; 267 Tcl_Obj *oldValue; /* Value before last update */ 268 }; 269 270 271 typedef int (Blt_TreeNotifyEventProc) _ANSI_ARGS_((ClientData clientData, 272 Blt_TreeNotifyEvent *eventPtr)); 273 274 typedef int (Blt_TreeTraceProc) _ANSI_ARGS_((ClientData clientData, 275 Tcl_Interp *interp, Blt_TreeNode node, Blt_TreeKey key, 276 unsigned int flags)); 277 278 typedef int (Blt_TreeEnumProc) _ANSI_ARGS_((Blt_TreeNode node, Blt_TreeKey key, 279 Tcl_Obj *valuePtr)); 280 281 typedef int (Blt_TreeCompareNodesProc) _ANSI_ARGS_((Blt_TreeNode *n1Ptr, 282 Blt_TreeNode *n2Ptr)); 283 284 typedef int (Blt_TreeApplyProc) _ANSI_ARGS_((Blt_TreeNode node, 285 ClientData clientData, int order)); 286 287 struct Blt_TreeTraceStruct { 288 ClientData clientData; 289 Blt_TreeKey key; 290 Blt_TreeNode node; 291 unsigned int mask; 292 Blt_TreeTraceProc *proc; 293 }; 294 295 /* 296 * Structure definition for information used to keep track of searches 297 * through hash tables:p 298 */ 299 struct Blt_TreeKeySearchStruct { 300 Blt_TreeNode node; /* Table being searched. */ 301 unsigned long nextIndex; /* Index of next bucket to be 302 * enumerated after present one. */ 303 Blt_TreeValue nextValue; /* Next entry to be enumerated in the 304 * the current bucket. */ 305 int cnt; 306 }; 307 308 #ifndef USE_BLT_STUBS 309 310 EXTERN void Blt_TreeOldValue _ANSI_ARGS_(( Tcl_Interp *interp, Blt_Tree tree, 311 Tcl_Obj **oldPtr, Tcl_Obj *newPtr)); 312 313 EXTERN Blt_TreeKey Blt_TreeGetKey _ANSI_ARGS_((CONST char *string)); 314 EXTERN Blt_TreeKey Blt_TreeKeyGet _ANSI_ARGS_((Tcl_Interp *interp, Blt_TreeObject treeObjPtr, CONST char *string)); 315 316 EXTERN Blt_TreeNode Blt_TreeInsertPost _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node)); 317 EXTERN int Blt_TreeNotifyGet _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node)); 318 EXTERN Blt_TreeNode Blt_TreeCreateNode _ANSI_ARGS_((Blt_Tree tree, 319 Blt_TreeNode parent, CONST char *name, int position)); 320 EXTERN Blt_TreeNode Blt_TreeCreateNodeWithId _ANSI_ARGS_((Blt_Tree tree, 321 Blt_TreeNode parent, CONST char *name, unsigned int inode, int position)); 322 323 EXTERN int Blt_TreeDeleteNode _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node)); 324 325 EXTERN int Blt_TreeMoveNode _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node, 326 Blt_TreeNode parent, Blt_TreeNode before)); 327 328 EXTERN Blt_TreeNode Blt_TreeGetNode _ANSI_ARGS_((Blt_Tree tree, 329 unsigned int inode)); 330 331 EXTERN Blt_TreeNode Blt_TreeFindChild _ANSI_ARGS_((Blt_TreeNode parent, 332 CONST char *name)); 333 334 EXTERN Blt_TreeNode Blt_TreeFindChildRev _ANSI_ARGS_((Blt_TreeNode parent, 335 CONST char *name, int firstN)); 336 337 EXTERN Blt_TreeNode Blt_TreeFirstChild _ANSI_ARGS_((Blt_TreeNode parent)); 338 339 EXTERN Blt_TreeNode Blt_TreeNextSibling _ANSI_ARGS_((Blt_TreeNode node)); 340 341 EXTERN Blt_TreeNode Blt_TreeLastChild _ANSI_ARGS_((Blt_TreeNode parent)); 342 343 EXTERN Blt_TreeNode Blt_TreePrevSibling _ANSI_ARGS_((Blt_TreeNode node)); 344 345 EXTERN Blt_TreeNode Blt_TreeNextNode _ANSI_ARGS_((Blt_TreeNode root, 346 Blt_TreeNode node)); 347 348 EXTERN Blt_TreeNode Blt_TreePrevNode _ANSI_ARGS_((Blt_TreeNode root, 349 Blt_TreeNode node)); 350 351 EXTERN Blt_TreeNode Blt_TreeChangeRoot _ANSI_ARGS_((Blt_Tree tree, 352 Blt_TreeNode node)); 353 354 EXTERN Blt_TreeNode Blt_TreeEndNode _ANSI_ARGS_((Blt_TreeNode node, 355 unsigned int nodeFlags)); 356 357 EXTERN int Blt_TreeIsBefore _ANSI_ARGS_((Blt_TreeNode node1, 358 Blt_TreeNode node2)); 359 360 EXTERN int Blt_TreeIsAncestor _ANSI_ARGS_((Blt_TreeNode node1, 361 Blt_TreeNode node2)); 362 363 EXTERN int Blt_TreePrivateValue _ANSI_ARGS_((Tcl_Interp *interp, Blt_Tree tree, 364 Blt_TreeNode node, Blt_TreeKey key)); 365 366 EXTERN int Blt_TreePublicValue _ANSI_ARGS_((Tcl_Interp *interp, Blt_Tree tree, 367 Blt_TreeNode node, Blt_TreeKey key)); 368 369 EXTERN int Blt_TreeGetValue _ANSI_ARGS_((Tcl_Interp *interp, Blt_Tree tree, 370 Blt_TreeNode node, CONST char *string, Tcl_Obj **valuePtr)); 371 372 EXTERN int Blt_TreeValueExists _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node, 373 CONST char *string)); 374 375 EXTERN int Blt_TreeSetValue _ANSI_ARGS_((Tcl_Interp *interp, Blt_Tree tree, 376 Blt_TreeNode node, CONST char *string, Tcl_Obj *valuePtr)); 377 378 EXTERN int Blt_TreeUpdateValue _ANSI_ARGS_((Tcl_Interp *interp, Blt_Tree tree, 379 Blt_TreeNode node, CONST char *string, Tcl_Obj *valuePtr)); 380 381 EXTERN int Blt_TreeUnsetValue _ANSI_ARGS_((Tcl_Interp *interp, Blt_Tree tree, 382 Blt_TreeNode node, CONST char *string)); 383 384 EXTERN int Blt_TreeGetArrayValue _ANSI_ARGS_((Tcl_Interp *interp, 385 Blt_Tree tree, Blt_TreeNode node, CONST char *arrayName, 386 CONST char *elemName, Tcl_Obj **valueObjPtrPtr)); 387 388 EXTERN int Blt_TreeSetArrayValue _ANSI_ARGS_((Tcl_Interp *interp, 389 Blt_Tree tree, Blt_TreeNode node, CONST char *arrayName, 390 CONST char *elemName, Tcl_Obj *valueObjPtr)); 391 392 EXTERN int Blt_TreeUpdateArrayValue _ANSI_ARGS_((Tcl_Interp *interp, 393 Blt_Tree tree, Blt_TreeNode node, CONST char *arrayName, 394 CONST char *elemName, Tcl_Obj *valueObjPtr)); 395 396 EXTERN int Blt_TreeUnsetArrayValue _ANSI_ARGS_((Tcl_Interp *interp, 397 Blt_Tree tree, Blt_TreeNode node, CONST char *arrayName, 398 CONST char *elemName)); 399 400 EXTERN int Blt_TreeArrayValueExists _ANSI_ARGS_((Blt_Tree tree, 401 Blt_TreeNode node, CONST char *arrayName, CONST char *elemName)); 402 403 EXTERN int Blt_TreeArrayNames _ANSI_ARGS_((Tcl_Interp *interp, Blt_Tree tree, 404 Blt_TreeNode node, CONST char *arrayName, Tcl_Obj *listObjPtr, CONST char *pattern)); 405 EXTERN int Blt_TreeArrayValues _ANSI_ARGS_((Tcl_Interp *interp, Blt_Tree tree, 406 Blt_TreeNode node, CONST char *arrayName, Tcl_Obj *listObjPtr, 407 int names)); 408 409 EXTERN int Blt_TreeGetValueByKey _ANSI_ARGS_((Tcl_Interp *interp, 410 Blt_Tree tree, Blt_TreeNode node, Blt_TreeKey key, 411 Tcl_Obj **valuePtr)); 412 413 EXTERN int Blt_TreeSetValueByKey _ANSI_ARGS_((Tcl_Interp *interp, 414 Blt_Tree tree, Blt_TreeNode node, Blt_TreeKey key, Tcl_Obj *valuePtr)); 415 416 EXTERN int Blt_TreeUnsetValueByKey _ANSI_ARGS_((Tcl_Interp *interp, 417 Blt_Tree tree, Blt_TreeNode node, Blt_TreeKey key)); 418 419 EXTERN int Blt_TreeValueExistsByKey _ANSI_ARGS_((Blt_Tree tree, 420 Blt_TreeNode node, Blt_TreeKey key)); 421 422 EXTERN Blt_TreeKey Blt_TreeFirstKey _ANSI_ARGS_((Blt_Tree tree, 423 Blt_TreeNode node, Blt_TreeKeySearch *cursorPtr)); 424 425 EXTERN Blt_TreeKey Blt_TreeNextKey _ANSI_ARGS_((Blt_Tree tree, 426 Blt_TreeKeySearch *cursorPtr)); 427 428 EXTERN int Blt_TreeCountKeys _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node)); 429 430 EXTERN int Blt_TreeApply _ANSI_ARGS_((Blt_TreeNode root, 431 Blt_TreeApplyProc *proc, ClientData clientData)); 432 433 EXTERN int Blt_TreeApplyDFS _ANSI_ARGS_((Blt_TreeNode root, 434 Blt_TreeApplyProc *proc, ClientData clientData, int order)); 435 436 EXTERN int Blt_TreeApplyBFS _ANSI_ARGS_((Blt_TreeNode root, 437 Blt_TreeApplyProc *proc, ClientData clientData)); 438 439 EXTERN int Blt_TreeSortNode _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node, 440 Blt_TreeCompareNodesProc *proc)); 441 442 EXTERN int Blt_TreeCreate _ANSI_ARGS_((Tcl_Interp *interp, CONST char *name, 443 Blt_Tree *treePtr)); 444 445 EXTERN int Blt_TreeExists _ANSI_ARGS_((Tcl_Interp *interp, CONST char *name)); 446 447 EXTERN int Blt_TreeGetToken _ANSI_ARGS_((Tcl_Interp *interp, CONST char *name, 448 Blt_Tree *treePtr)); 449 EXTERN int Blt_TreeGetTokenTag _ANSI_ARGS_((Tcl_Interp *interp, CONST char *name, 450 Blt_Tree *treePtr)); 451 452 EXTERN void Blt_TreeReleaseToken _ANSI_ARGS_((Blt_Tree tree)); 453 454 EXTERN int Blt_TreeSize _ANSI_ARGS_((Blt_TreeNode node)); 455 456 EXTERN Blt_TreeTrace Blt_TreeCreateTrace _ANSI_ARGS_((Blt_Tree tree, 457 Blt_TreeNode node, CONST char *keyPattern, CONST char *tagName, 458 unsigned int mask, Blt_TreeTraceProc *proc, ClientData clientData)); 459 460 EXTERN void Blt_TreeDeleteTrace _ANSI_ARGS_((Blt_TreeTrace token)); 461 462 EXTERN void Blt_TreeCreateEventHandler _ANSI_ARGS_((Blt_Tree tree, 463 unsigned int mask, Blt_TreeNotifyEventProc *proc, 464 ClientData clientData)); 465 466 EXTERN void Blt_TreeDeleteEventHandler _ANSI_ARGS_((Blt_Tree tree, 467 unsigned int mask, Blt_TreeNotifyEventProc *proc, 468 ClientData clientData)); 469 470 EXTERN int Blt_TreeRelabelNode _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node, 471 CONST char *string)); 472 EXTERN int Blt_TreeRelabelNode2 _ANSI_ARGS_((Blt_TreeNode node, 473 CONST char *string)); 474 EXTERN char *Blt_TreeNodePath _ANSI_ARGS_((Blt_TreeNode node, 475 Tcl_DString *resultPtr)); 476 EXTERN char *Blt_TreeNodePathStr _ANSI_ARGS_((Blt_TreeNode node, 477 Tcl_DString *resultPtr, char *prefix, char *delim)); 478 EXTERN int Blt_TreeNodePosition _ANSI_ARGS_((Blt_TreeNode node)); 479 480 EXTERN void Blt_TreeClearTags _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node)); 481 EXTERN int Blt_TreeHasTag _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node, 482 CONST char *tagName)); 483 EXTERN int Blt_TreeAddTag _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node, 484 CONST char *tagName)); 485 EXTERN int Blt_TreeTagDelTrace _ANSI_ARGS_((Blt_Tree tree, Blt_TreeNode node, 486 CONST char *tagName)); 487 EXTERN int Blt_TreeForgetTag _ANSI_ARGS_((Blt_Tree tree, CONST char *tagName)); 488 EXTERN Blt_HashTable *Blt_TreeTagHashTable _ANSI_ARGS_((Blt_Tree tree, 489 CONST char *tagName)); 490 EXTERN Blt_TreeTagEntry *Blt_TreeTagHashEntry _ANSI_ARGS_((Blt_Tree tree, 491 CONST char *tagName)); 492 EXTERN int Blt_TreeTagTableIsShared _ANSI_ARGS_((Blt_Tree tree)); 493 EXTERN int Blt_TreeShareTagTable _ANSI_ARGS_((Blt_Tree src, Blt_Tree target)); 494 EXTERN Blt_HashEntry *Blt_TreeFirstTag _ANSI_ARGS_((Blt_Tree tree, 495 Blt_HashSearch *searchPtr)); 496 EXTERN int Blt_TreeNotifyAttach _ANSI_ARGS_((Blt_Tree tree)); 497 498 #define Blt_TreeFirstChild(node) ((node)->first) 499 #define Blt_TreeLastChild(node) ((node)->last) 500 #define Blt_TreeNextSibling(node) (((node) == NULL) ? NULL : (node)->next) 501 #define Blt_TreePrevSibling(node) (((node) == NULL) ? NULL : (node)->prev) 502 #define Blt_TreeChangeRoot(token, node) ((token)->root = (node)) 503 504 #else 505 #include "bltDecls.h" 506 #endif /* USE_BLT_STUBS */ 507 508 #define Blt_TreeName(token) ((token)->treeObject->name) 509 #define Blt_TreeRootNode(token) ((token)->root) 510 511 #define Blt_TreeNodeDepth(token, node) ((node)->depth - (token)->root->depth) 512 #define Blt_TreeNodeLabel(node) ((node)->label) 513 #define Blt_TreeNodeId(node) ((node)->inode) 514 #define Blt_TreeNodeParent(node) ((node)->parent) 515 #define Blt_TreeNodeDegree(node) ((node)->nChildren) 516 #define Blt_TreeNodeDeleted(node) (((int)((node)->inode)) == -1) 517 518 #define Blt_TreeIsLeaf(node) ((node)->nChildren == 0) 519 #define Blt_TreeNextNodeId(token) ((token)->treeObject->nextInode) 520 521 522 #endif /* _BLT_TREE_H */ 523 524