From: handa Date: Thu, 29 Mar 2007 11:24:42 +0000 (+0000) Subject: (mplist_put_func, mplist_get_func): New functions. X-Git-Tag: FLT-base~108 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54420f1d20290a5d9f9a3eeb072aa6818b961618;p=m17n%2Fm17n-lib.git (mplist_put_func, mplist_get_func): New functions. --- diff --git a/src/plist.c b/src/plist.c index 0d30ee9..324608a 100644 --- a/src/plist.c +++ b/src/plist.c @@ -1166,10 +1166,10 @@ mplist_put (MPlist *plist, MSymbol key, void *val) /***en @brief Get the value of a property in a property list. - The mplist_get () function searches property list $PLIST - from the beginning for a property whose key is $KEY. If such a - property is found, a pointer to its value is returned as the type - of (void *). If not found, @c NULL is returned. + The mplist_get () function searches property list $PLIST from the + beginning for a property whose key is $KEY. If such a property is + found, its value is returned as the type of (void *). If + not found, @c NULL is returned. When @c NULL is returned, there are two possibilities: one is the case where no property is found (see above); the other is the case @@ -1179,8 +1179,8 @@ mplist_put (MPlist *plist, MSymbol key, void *val) /***ja @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë. - ´Ø¿ô mplist_get () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ò»Ï¤á¤«¤éõ¤·¤Æ¡¢¥­¡¼¤¬ - $KEY ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤ÎÃͤؤΥݥ¤¥ó¥¿¤ò + ´Ø¿ô mplist_get () ¤Ï¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ò»Ï¤á¤«¤éõ¤·¤Æ¡¢¥­¡¼ + ¤¬ $KEY ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ò¸«¤Ä¤±¤ë¡£¸«¤Ä¤«¤ì¤Ð¡¢¤½¤ÎÃͤò (void *) ·¿¤ÇÊÖ¤¹¡£¸«¤Ä¤«¤é¤Ê¤±¤ì¤Ð @c NULL ¤òÊÖ¤¹¡£ @c NULL ¤¬Ê֤俺ݤˤÏÆó¤Ä¤Î²ÄǽÀ­¤¬¤¢¤ë: @@ -1202,6 +1202,55 @@ mplist_get (MPlist *plist, MSymbol key) /*=*/ /***en + @brief Set the value (function pointer) of a property in a property list. + + The mplist_put_func () function is like mplist_put () but for + settting function pointer $FUNC in property list $PLIST for key + $KEY. */ + +/*** + @seealso + mplist_put (), M17N_FUNC () */ + +MPlist * +mplist_put_func (MPlist *plist, MSymbol key, M17NFunc func) +{ + if (key == Mnil) + MERROR (MERROR_PLIST, NULL); + do { + MPLIST_FIND (plist, key); + } while (! MPLIST_TAIL_P (plist) && ! MPLIST_VAL_FUNC_P (plist)); + + MPLIST_KEY (plist) = (key); + MPLIST_FUNC (plist) = func; + if (! plist->next) + MPLIST_NEW ((plist)->next); + return plist; +} + +/*=*/ + +/***en + @brief Get the value (function pointer) of a property in a property list. + + The mplist_get_func () funciont is like mplist_get () but for + getting a function pointer from property list $PLIST by key $KEY. */ + +/*** + @seealso + mplist_get () */ +M17NFunc +mplist_get_func (MPlist *plist, MSymbol key) +{ + do { + MPLIST_FIND (plist, key); + } while (! MPLIST_TAIL_P (plist) && ! MPLIST_VAL_FUNC_P (plist)); + return (MPLIST_TAIL_P (plist) ? NULL : MPLIST_FUNC (plist)); +} + +/*=*/ + +/***en @brief Add a property at the end of a property list. The mplist_add () function appends at the end of property list