*** empty log message ***
[m17n/m17n-lib.git] / src / plist.h
index 37fbfa8..c6cf5aa 100644 (file)
@@ -1,5 +1,5 @@
 /* plist.h -- header file for the plist module.
-   Copyright (C) 2003, 2004
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H15PRO112
 
@@ -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.  */
 
 #ifndef _M17N_PLIST_H_
@@ -35,7 +35,10 @@ struct MPlist
   MSymbol key;
 
   /**en Value of the first element of the plist.  */
-  void *val;
+  union {
+    void *pointer;
+    M17NFunc func;
+  } val;
 
   /**en Plist for the next element. */
   MPlist *next;
@@ -44,8 +47,8 @@ struct MPlist
 /** Macros to access each member of PLIST.  */
 
 #define MPLIST_KEY(plist) ((plist)->key)
-#define MPLIST_VAL(plist) ((plist)->val)
-#define MPLIST_VAL_MANAGED_P(plist) ((plist)->control.flag)
+#define MPLIST_VAL(plist) ((plist)->val.pointer)
+#define MPLIST_FUNC(plist) ((plist)->val.func)
 #define MPLIST_NEXT(plist) ((plist)->next)
 #define MPLIST_TAIL_P(plist) ((plist)->key == Mnil)
 
@@ -55,6 +58,16 @@ struct MPlist
 #define MPLIST_INTEGER_P(plist) (MPLIST_KEY (plist) == Minteger)
 #define MPLIST_PLIST_P(plist) (MPLIST_KEY (plist) == Mplist)
 
+#define MPLIST_NESTED_P(plist) \
+  ((plist)->control.flag & 1)
+#define MPLIST_SET_NESTED_P(plist)     \
+  ((plist)->control.flag |= 1)
+
+#define MPLIST_VAL_FUNC_P(plist)       \
+  ((plist)->control.flag & 2)
+#define MPLIST_SET_VAL_FUNC_P(plist)   \
+  ((plist)->control.flag |= 2)
+
 #define MPLIST_SYMBOL(plist) ((MSymbol) MPLIST_VAL (plist))
 #define MPLIST_STRING(plist) ((char *) MPLIST_VAL (plist))
 #define MPLIST_MTEXT(plist) ((MText *) MPLIST_VAL (plist))
@@ -77,6 +90,13 @@ struct MPlist
    : MPLIST_TAIL_P ((plist)->next->next) ? 2   \
    : mplist_length (plist))
 
+#define MPLIST_ADD_PLIST(PLIST, KEY, VAL) \
+  MPLIST_SET_NESTED_P (mplist_add ((PLIST), (KEY), (VAL)))
+#define MPLIST_PUSH_PLIST(PLIST, KEY, VAL) \
+  MPLIST_SET_NESTED_P (mplist_push ((PLIST), (KEY), (VAL)))
+#define MPLIST_PUT_PLIST(PLIST, KEY, VAL) \
+  MPLIST_SET_NESTED_P (mplist_put ((PLIST), (KEY), (VAL)))
+
 
 extern unsigned char hex_mnemonic[256];
 extern unsigned char escape_mnemonic[256];
@@ -89,6 +109,12 @@ extern MPlist *mplist__from_alist (MPlist *plist);
 
 extern MPlist *mplist__from_string (unsigned char *str, int n);
 
-extern int mplist__serialize (MText *mt, MPlist *plist);
+extern int mplist__serialize (MText *mt, MPlist *plist, int pretty);
+
+extern MPlist *mplist__conc (MPlist *plist, MPlist *tail);
+
+extern void mplist__pop_unref (MPlist *plist);
+
+extern MPlist *mplist__assq (MPlist *plist, MSymbol key);
 
 #endif  /* _M17N_PLIST_H_ */