X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fplist.c;h=8cda7b9fb01131eb66f86218b3aeb7fbea29605d;hb=38c091dbfa19be7db173231b0b5101577de2098e;hp=8926952cb191b0180272a620c7de428a8967c344;hpb=7a7762460733818a5fc76a85627d24be49891d8d;p=m17n%2Fm17n-lib.git
diff --git a/src/plist.c b/src/plist.c
index 8926952..8cda7b9 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -17,7 +17,7 @@
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
@@ -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,74 @@ 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 similar to mplist_put () but for
+ setting function pointer $FUNC in property list $PLIST for key
+ $KEY. */
+
+/***ja
+ @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥ÈÃæ¤Î¥×¥í¥Ñ¥Æ¥£¤Ë´Ø¿ô¥Ý¥¤¥ó¥¿¤Ç¤¢¤ëÃͤòÀßÄꤹ¤ë.
+
+ ´Ø¿ô mplist_put_func () ¤Ï´Ø¿ô mplist_put () ƱÍÍ¡¢¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
+ Ãæ¤Ç¥¡¼¤¬ $KEY ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ËÃͤòÀßÄꤹ¤ë¡£Ã¢¤·¤½¤ÎÃͤϴؿô¥Ý¥¤¥ó¥¿
+ $FUNC ¤Ç¤¢¤ë¡£ */
+
+
+/***
+ @seealso
+ mplist_put (), M17N_FUNC () */
+
+MPlist *
+mplist_put_func (MPlist *plist, MSymbol key, M17NFunc func)
+{
+ if (key == Mnil)
+ MERROR (MERROR_PLIST, NULL);
+ while (1)
+ {
+ MPLIST_FIND (plist, key);
+ if (MPLIST_TAIL_P (plist) || MPLIST_VAL_FUNC_P (plist))
+ break;
+ plist = MPLIST_NEXT (plist);
+ };
+
+ MPLIST_KEY (plist) = (key);
+ MPLIST_FUNC (plist) = func;
+ MPLIST_SET_VAL_FUNC_P (plist);
+ 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 () function is similar to mplist_get () but for
+ getting a function pointer from property list $PLIST by key $KEY. */
+
+/***ja
+ @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤«¤é¥×¥í¥Ñ¥Æ¥£¤Î´Ø¿ô¥Ý¥¤¥ó¥¿¤Ç¤¢¤ëÃͤòÆÀ¤ë.
+
+ ´Ø¿ô mplist_get_func () ¤Ï´Ø¿ô mplist_get () ¤ÈƱÍͤˡ¢¥×¥í¥Ñ¥Æ¥£¥ê
+ ¥¹¥È $PLIST Ãæ¤Ç¥¡¼¤¬ $KEY ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ÎÃÍ¡¢Ã¢¤·´Ø¿ô¥Ý¥¤¥ó¥¿¡¢
+ ¤òÆÀ¤ë¡£ */
+
+
+/***
+ @seealso
+ mplist_get () */
+M17NFunc
+mplist_get_func (MPlist *plist, MSymbol key)
+{
+ MPLIST_FIND (plist, key);
+ 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
@@ -1295,7 +1363,7 @@ mplist_push (MPlist *plist, MSymbol key, void *val)
The mplist_pop () function removes a property at the beginning of
property list $PLIST. As a result, the second key and value of
- the original $PLIST become the first of those of the new $PLIST.
+ the $PLIST become the first ones.
@return
If the operation was successful, this function return the value of
@@ -1303,9 +1371,8 @@ mplist_push (MPlist *plist, MSymbol key, void *val)
/***ja
@brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ÎÀèƬ¤«¤é¥×¥í¥Ñ¥Æ¥£¤òºï½ü¤¹¤ë.
- ´Ø¿ô mplist_pop () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST
- ¤ÎÀèƬ¤Î¥×¥í¥Ñ¥Æ¥£¤òºï½ü¤¹¤ë¡£·ë²Ì¤È¤·¤Æ¡¢¸µ¤Î $PLIST ¤Î2ÈÖÌܤΥ¡¼¤ÈÃͤ¬¡¢¿·¤·¤¤
- $PLIST ¤ÎÀèƬ¤Î¥¡¼¤ÈÃͤˤʤ롣
+ ´Ø¿ô mplist_pop () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ÎÀèƬ¤Î¥×¥í¥Ñ¥Æ¥£¤òºï
+ ½ü¤¹¤ë¡£·ë²Ì¤È¤·¤Æ¡¢¸µ¤Î2ÈÖÌܤΥ¡¼¤ÈÃͤ¬ÀèƬ¤Î¥¡¼¤ÈÃͤˤʤ롣
@return
½èÍý¤ËÀ®¸ù¤¹¤ì¤Ð¡¢¤³¤Î´Ø¿ô¤Ïºï½ü¤µ¤ì¤¿¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÊÖ¤¹¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð