| 1 |
/* do not edit automatically generated by mc from SymbolKey. */ |
| 2 |
/* SymbolKey.def binary tree operations for storing symbols. |
| 3 |
|
| 4 |
Copyright (C) 2001-2025 Free Software Foundation, Inc. |
| 5 |
Contributed by Gaius Mulley <[email protected]>. |
| 6 |
|
| 7 |
This file is part of GNU Modula-2. |
| 8 |
|
| 9 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 10 |
it under the terms of the GNU General Public License as published by |
| 11 |
the Free Software Foundation; either version 3, or (at your option) |
| 12 |
any later version. |
| 13 |
|
| 14 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 15 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
General Public License for more details. |
| 18 |
|
| 19 |
You should have received a copy of the GNU General Public License |
| 20 |
along with GNU Modula-2; see the file COPYING3. If not see |
| 21 |
<http://www.gnu.org/licenses/>. */ |
| 22 |
|
| 23 |
|
| 24 |
#if !defined (_SymbolKey_H) |
| 25 |
# define _SymbolKey_H |
| 26 |
|
| 27 |
# ifdef __cplusplus |
| 28 |
extern "C" { |
| 29 |
# endif |
| 30 |
#include <stdbool.h> |
| 31 |
# if !defined (PROC_D) |
| 32 |
# define PROC_D |
| 33 |
typedef void (*PROC_t) (void); |
| 34 |
typedef struct { PROC_t proc; } PROC; |
| 35 |
# endif |
| 36 |
|
| 37 |
# include "GSYSTEM.h" |
| 38 |
# include "GNameKey.h" |
| 39 |
|
| 40 |
# if defined (_SymbolKey_C) |
| 41 |
# define EXTERN |
| 42 |
# else |
| 43 |
# define EXTERN extern |
| 44 |
# endif |
| 45 |
|
| 46 |
# define SymbolKey_NulKey 0 |
| 47 |
#if !defined (SymbolKey_SymbolTree_D) |
| 48 |
# define SymbolKey_SymbolTree_D |
| 49 |
typedef void *SymbolKey_SymbolTree; |
| 50 |
#endif |
| 51 |
|
| 52 |
typedef struct SymbolKey_IsSymbol_p SymbolKey_IsSymbol; |
| 53 |
|
| 54 |
typedef struct SymbolKey_PerformOperation_p SymbolKey_PerformOperation; |
| 55 |
|
| 56 |
typedef bool (*SymbolKey_IsSymbol_t) (unsigned int); |
| 57 |
struct SymbolKey_IsSymbol_p { SymbolKey_IsSymbol_t proc; }; |
| 58 |
|
| 59 |
typedef void (*SymbolKey_PerformOperation_t) (unsigned int); |
| 60 |
struct SymbolKey_PerformOperation_p { SymbolKey_PerformOperation_t proc; }; |
| 61 |
|
| 62 |
|
| 63 |
/* |
| 64 |
InitTree - Initializes a SymbolTree pointed to by t. |
| 65 |
*/ |
| 66 |
|
| 67 |
EXTERN void SymbolKey_InitTree (SymbolKey_SymbolTree *t); |
| 68 |
|
| 69 |
/* |
| 70 |
KillTree - Destroys the SymbolTree pointed to by t. |
| 71 |
*/ |
| 72 |
|
| 73 |
EXTERN void SymbolKey_KillTree (SymbolKey_SymbolTree *t); |
| 74 |
|
| 75 |
/* |
| 76 |
GetSymKey - Searches the SymbolTree t for an entry NameKey. If |
| 77 |
found then the SymKey is returned. NulKey = not found. |
| 78 |
*/ |
| 79 |
|
| 80 |
EXTERN unsigned int SymbolKey_GetSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey); |
| 81 |
|
| 82 |
/* |
| 83 |
PutSymKey - Puts an symbol entry NameKey in the SymbolTree t. |
| 84 |
SymKey is the value stored with NameKey. |
| 85 |
*/ |
| 86 |
|
| 87 |
EXTERN void SymbolKey_PutSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey, unsigned int SymKey); |
| 88 |
|
| 89 |
/* |
| 90 |
DelSymKey - Deletes a symbol entry NameKey in the SymbolTree t. |
| 91 |
*/ |
| 92 |
|
| 93 |
EXTERN void SymbolKey_DelSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey); |
| 94 |
|
| 95 |
/* |
| 96 |
IsEmptyTree - returns true if SymbolTree, t, is empty. |
| 97 |
*/ |
| 98 |
|
| 99 |
EXTERN bool SymbolKey_IsEmptyTree (SymbolKey_SymbolTree t); |
| 100 |
|
| 101 |
/* |
| 102 |
DoesTreeContainAny - returns true if SymbolTree, t, contains any |
| 103 |
symbols which in turn return true when procedure, |
| 104 |
P, is called with a symbol as its parameter. |
| 105 |
*/ |
| 106 |
|
| 107 |
EXTERN bool SymbolKey_DoesTreeContainAny (SymbolKey_SymbolTree t, SymbolKey_IsSymbol P); |
| 108 |
|
| 109 |
/* |
| 110 |
ForeachNodeDo - for each node in SymbolTree, t, a procedure, P, |
| 111 |
is called with the node symbol as its parameter. |
| 112 |
It traverse the tree in order. |
| 113 |
*/ |
| 114 |
|
| 115 |
EXTERN void SymbolKey_ForeachNodeDo (SymbolKey_SymbolTree t, SymbolKey_PerformOperation P); |
| 116 |
|
| 117 |
/* |
| 118 |
ContainsSymKey - return TRUE if tree, t, contains an entry for, NameKey. |
| 119 |
*/ |
| 120 |
|
| 121 |
EXTERN bool SymbolKey_ContainsSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey); |
| 122 |
|
| 123 |
/* |
| 124 |
NoOfNodes - returns the number of nodes in the tree t. |
| 125 |
*/ |
| 126 |
|
| 127 |
EXTERN unsigned int SymbolKey_NoOfNodes (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition); |
| 128 |
|
| 129 |
/* |
| 130 |
ForeachNodeConditionDo - traverse the tree t and for any node which satisfied |
| 131 |
condition call P. |
| 132 |
*/ |
| 133 |
|
| 134 |
EXTERN void SymbolKey_ForeachNodeConditionDo (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition, SymbolKey_PerformOperation P); |
| 135 |
# ifdef __cplusplus |
| 136 |
} |
| 137 |
# endif |
| 138 |
|
| 139 |
# undef EXTERN |
| 140 |
#endif |