From: handa Date: Thu, 29 Mar 2007 11:23:59 +0000 (+0000) Subject: (msymbol__fini): Use MPLIST_VAL. X-Git-Tag: FLT-base~109 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=7eaac4f52fe22d6fbed3dfbaa3db0bab48a3d5d4;p=m17n%2Fm17n-lib.git (msymbol__fini): Use MPLIST_VAL. (msymbol_put_func, msymbol_get_func): New functions. --- diff --git a/src/symbol.c b/src/symbol.c index 6999163..a9af1d7 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -155,7 +155,7 @@ msymbol__fini () 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; } @@ -660,6 +660,45 @@ msymbol_get (MSymbol symbol, MSymbol key) 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 like msymbol_put () but for + setting function pointer $FUNC as a property value of $SYMBOL for + key $KEY. */ + +/*** + @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 like msymbol_get () but for + getting a function pointer form the property of symbol $SYMBOL. */ + +/*** + @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