You should have received a copy of the GNU Lesser General Public
License along with the m17n library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
02111-1307, USA. */
/***en
msymbol__fini ()
{
int i;
- MSymbol sym, next;
- int freed_symbols = 0;
+ MSymbol sym;
for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
for (sym = symbol_table[i]; sym; sym = sym->next)
if (! MPLIST_TAIL_P (&sym->plist))
{
if (sym->plist.key->managing_key)
- M17N_OBJECT_UNREF (sym->plist.val);
+ M17N_OBJECT_UNREF (MPLIST_VAL (&sym->plist));
M17N_OBJECT_UNREF (sym->plist.next);
+ sym->plist.key = Mnil;
}
+}
+
+void
+msymbol__free_table ()
+{
+ int i;
+ MSymbol sym, next;
+ int freed_symbols = 0;
+
for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
{
for (sym = symbol_table[i]; sym; sym = next)
return msymbol (p);
}
+/** Return a plist of symbols that has non-NULL property PROP. If
+ PROP is Mnil, return a plist of all symbols. Values of the plist
+ is NULL. */
+
+MPlist *
+msymbol__list (MSymbol prop)
+{
+ MPlist *plist = mplist ();
+ int i;
+ MSymbol sym;
+
+ for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
+ for (sym = symbol_table[i]; sym; sym = sym->next)
+ if (prop == Mnil || msymbol_get (sym, prop))
+ mplist_push (plist, sym, NULL);
+ return plist;
+}
+
/** Canonicalize the name of SYM, and return a symbol of the
canonicalized name. Canonicalization is done by this rule:
/*=*/
/***en
+ @brief Check if a symbol is a managing key.
+
+ The msymbol_is_managing_key () function checks if the symbol
+ $SYMBOL is a managing key or not.
+
+ @return Return 1 if the symbol is a managing key. Otherwise,
+ return 0. */
+
+int
+msymbol_is_managing_key (MSymbol symbol)
+{
+ return (symbol->managing_key == 1);
+}
+
+/*=*/
+
+/***en
@brief Search for a symbol that has a specified name.
The msymbol_exist () function searches for the symbol whose name
return (MPLIST_TAIL_P (plist) ? NULL : MPLIST_VAL (plist));
}
+/*=*/
+/***en
+ @brief Set the value (function pointer) of a symbol property.
+
+ The msymbol_put_func () function is similar to msymbol_put () but for
+ setting function pointer $FUNC as the property value of $SYMBOL for
+ key $KEY. */
+
+/***ja
+ @brief ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ(´Ø¿ô¥Ý¥¤¥ó¥¿)¤òÀßÄꤹ¤ë.
+
+ ´Ø¿ô msymbol_put_func () ¤Ï¡¢´Ø¿ô msymbol_put () ¤ÈƱÍͤˡ¢¥·¥ó¥Ü¥ë
+ $SYMBOL ¤Î¥¡¼¤¬ $KEY ¤Ç¤¢¤ë¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë¡£Ã¢¤·
+ ¤½¤ÎÃͤϴؿô¥Ý¥¤¥ó¥¿ $FUNC ¤Ç¤¢¤ë¡£ */
+
+/***
+ @seealso msymbol_put (), M17N_FUNC () */
+int
+msymbol_put_func (MSymbol symbol, MSymbol key, M17NFunc func)
+{
+ if (symbol == Mnil || key == Mnil)
+ MERROR (MERROR_SYMBOL, -1);
+ mplist_put_func (&symbol->plist, key, func);
+ return 0;
+}
+
+/*=*/
+
+/***en
+ @brief Get the value (function pointer) of a symbol property.
+
+ The msymbol_get_func () function is similar to msymbol_get () but for
+ getting a function pointer form the property of symbol $SYMBOL. */
+
+/***ja
+ @brief ¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ (´Ø¿ô¥Ý¥¤¥ó¥¿) ¤òÆÀ¤ë.
+
+ ´Ø¿ô msymbol_get_func () ¤Ï¡¢´Ø¿ô msymbol_get () ¤ÈƱÍͤˡ¢¥·¥ó¥Ü¥ë
+ $SYMBOL ¤¬»ý¤Ä¥·¥ó¥Ü¥ë¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¡¢¥¡¼¤¬ $KEY ¤Ç¤¢¤ë¤â¤Î¤òÆÀ¤ë¡£Ã¢¤·
+ ¤½¤ÎÃͤϴؿô¥Ý¥¤¥ó¥¿¤ò¤Ç¤¢¤ë¡£ */
+
+/***
+ @seealso
+ msymbol_get () */
+
+M17NFunc
+msymbol_get_func (MSymbol symbol, MSymbol key)
+{
+ if (symbol == Mnil || key == Mnil)
+ return NULL;
+ return mplist_get_func (&symbol->plist, key);
+}
+
/*** @} */
#include <stdio.h>
mdebug_dump_all_symbols (int indent)
{
char *prefix;
- int i;
+ int i, n;
MSymbol sym;
if (indent < 0)
prefix[indent] = 0;
fprintf (stderr, "(symbol-list");
- for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
+ for (i = n = 0; i < SYMBOL_TABLE_SIZE; i++)
if ((sym = symbol_table[i]))
{
fprintf (stderr, "\n%s (%4d", prefix, i);
- for (; sym; sym = sym->next)
+ for (; sym; sym = sym->next, n++)
fprintf (stderr, " '%s'", sym->name);
fprintf (stderr, ")");
}
+ fprintf (stderr, "\n%s (total %d)", prefix, n);
fprintf (stderr, ")");
return Mnil;
}