(libm17n_core_la_LIBADD): Add THAI_WORDSEG_LD_FLAGS,
[m17n/m17n-lib.git] / src / internal.h
index 5352700..f518924 100644 (file)
     longer version of internal.h description 
 */
 
+extern int m17n__core_initialized;
+extern int m17n__shell_initialized;
+extern int m17n__gui_initialized;
+
 extern int mdebug_hook ();
 
 /** Return with code RET while setting merror_code to ERR.  */
@@ -241,19 +245,23 @@ typedef struct
 typedef struct
 {
   /**en Reference count of the object.  */
+  /**ja ¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¿ô.  */
   unsigned ref_count : 16;
 
   unsigned ref_count_extended : 1;
 
   /**en A flag bit used for various perpose.  */
+  /**ja ¤µ¤Þ¤¶¤Þ¤ÊÌÜŪ¤ËÍѤ¤¤é¤ì¤ë¥Õ¥é¥°¥Ó¥Ã¥È.  */
   unsigned flag : 15;
 
   union {
     /**en If <ref_count_extended> is zero, a function to free the
        object.  */
+    /**ja <ref_count_extended> ¤¬ 0 ¤Ê¤é¤Ð¥ª¥Ö¥¸¥§¥¯¥È¤ò²òÊü¤¹¤ë´Ø¿ô.  */
     void (*freer) (void *);
     /**en If <ref_count_extended> is nonzero, a pointer to the
        struct M17NObjectRecord.  */
+    /**ja <ref_count_extended> ¤¬ 0 ¤Ç¤Ê¤±¤ì¤Ð¹½Â¤ÂΠM17NObjectRecord ¤Ø¤Î¥Ý¥¤¥ó¥¿.  */
     M17NObjectRecord *record;
   } u;
 } M17NObject;
@@ -271,6 +279,7 @@ typedef struct
 
 /**en Increment the reference count of OBJECT if the count is not
    0.  */
+/**ja OBJECT ¤Î»²¾È¿ô¤¬ 0 ¤Ç¤Ê¤±¤ì¤Ð 1 Áý¤ä¤¹.  */
 
 #define M17N_OBJECT_REF(object)                                \
   do {                                                 \
@@ -311,7 +320,9 @@ typedef struct
 
 
 /**en Decrement the reference count of OBJECT if the count is greater
-    than 0.  In that case, if the count becomes 0, free OBJECT.  */
+      than 0.  In that case, if the count becomes 0, free OBJECT.  */
+/**ja OBJECT ¤Î»²¾È¿ô¤¬ 0 ¤è¤êÂ礭¤±¤ì¤Ð 1 ¸º¤é¤¹¡£¸º¤é¤·¤Æ 0 ¤Ë¤Ê¤ì¤Ð
+      OBJECT ¤ò²òÊü¤¹¤ë.  */
 
 #define M17N_OBJECT_UNREF(object)                              \
   do {                                                         \
@@ -329,6 +340,7 @@ typedef struct
              (((M17NObject *) (object))->u.freer) (object);    \
            else                                                \
              free (object);                                    \
+           (object) = NULL;                                    \
          }                                                     \
       }                                                                \
   } while (0)
@@ -341,36 +353,19 @@ typedef struct
   void **objects;
 } M17NObjectArray;
 
+extern void mdebug__register_object (M17NObjectArray *array, void *object);
 
-#define M17N_OBJECT_REGISTER(array, object)                    \
-  if (mdebug__flag & MDEBUG_FINI)                              \
-    {                                                          \
-      if ((array).used == 0)                                   \
-       MLIST_INIT1 (&(array), objects, 256);                   \
-      (array).count++;                                         \
-      MLIST_APPEND1 (&(array), objects, object, MERROR_OBJECT);        \
-    }                                                          \
+#define M17N_OBJECT_REGISTER(array, object)    \
+  if (mdebug__flag & MDEBUG_FINI)              \
+    mdebug__register_object (&array, object);  \
   else
 
-#define M17N_OBJECT_UNREGISTER(array, object)                          \
-  if (mdebug__flag & MDEBUG_FINI)                                      \
-    {                                                                  \
-      (array).count--;                                                 \
-      if ((array).count >= 0)                                          \
-       {                                                               \
-         int i = 0;                                                    \
-                                                                       \
-         while (i < (array).used && (array).objects[i] != object) i++; \
-         if (i < (array).used)                                         \
-           (array).objects[i] = NULL;                                  \
-         else                                                          \
-           mdebug_hook ();                                             \
-       }                                                               \
-      else                                                             \
-       mdebug_hook ();                                                 \
-    }                                                                  \
-  else
+extern void mdebug__unregister_object (M17NObjectArray *array, void *object);
 
+#define M17N_OBJECT_UNREGISTER(array, object)  \
+  if (mdebug__flag & MDEBUG_FINI)              \
+    mdebug__unregister_object (&array, object);        \
+  else
 
 extern void mdebug__report_object (char *name, M17NObjectArray *array);
 
@@ -455,6 +450,8 @@ struct MText
   } while (0)
 
 
+#define MTEXT_READ_ONLY_P(mt) ((mt)->allocated < 0)
+
 #define M_CHECK_READONLY(mt, ret)      \
   do {                                 \
     if ((mt)->allocated < 0)           \
@@ -520,6 +517,12 @@ extern void mdebug__print_time ();
       fprintf (stderr, (fmt), (arg1), (arg2), (arg3), (arg4)); \
   } while (0)
 
+#define MDEBUG_PRINT5(fmt, arg1, arg2, arg3, arg4, arg5)               \
+  do {                                                                 \
+    if (mdebug__flag & mdebug_mask)                                    \
+      fprintf (stderr, (fmt), (arg1), (arg2), (arg3), (arg4), (arg5)); \
+  } while (0)
+
 
 #define MDEBUG_PUSH_TIME()             \
   do {                                 \