From d3421240981c52ab7130bb131432b508eb0820df Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 6 Sep 2012 16:42:38 +0800 Subject: remove duplicated defines --- utils/storage/import_interpolation.cpp | 18 ------------------ utils/training/import_k_mixture_model.cpp | 19 ------------------- utils/training/k_mixture_model_to_interpolation.cpp | 11 +---------- utils/utils_helper.h | 19 +++++++++++++++++++ 4 files changed, 20 insertions(+), 47 deletions(-) diff --git a/utils/storage/import_interpolation.cpp b/utils/storage/import_interpolation.cpp index 787f893..0974eb0 100644 --- a/utils/storage/import_interpolation.cpp +++ b/utils/storage/import_interpolation.cpp @@ -24,24 +24,6 @@ #include "pinyin_internal.h" #include "utils_helper.h" -#define TAGLIB_GET_VALUE(var, index) \ - phrase_token_t var = null_token; \ - { \ - const char * string = (const char *) g_ptr_array_index \ - (values, index); \ - var = taglib_string_to_token \ - (phrase_table, phrase_index, string); \ - } - -#define TAGLIB_GET_TAGVALUE(type, var, conv) \ - type var; \ - { \ - gpointer value = NULL; \ - assert(g_hash_table_lookup_extended \ - (required, #var, NULL, &value)); \ - var = conv((const char *)value); \ - } - enum LINE_TYPE{ BEGIN_LINE = 1, END_LINE, diff --git a/utils/training/import_k_mixture_model.cpp b/utils/training/import_k_mixture_model.cpp index 7af768e..b53be75 100644 --- a/utils/training/import_k_mixture_model.cpp +++ b/utils/training/import_k_mixture_model.cpp @@ -24,25 +24,6 @@ #include "utils_helper.h" #include "k_mixture_model.h" -#define TAGLIB_GET_VALUE(var, index) \ - phrase_token_t var = null_token; \ - { \ - const char * string = (const char *) g_ptr_array_index \ - (values, index); \ - var = taglib_string_to_token \ - (phrase_table, phrase_index, string); \ - } - -#define TAGLIB_GET_TAGVALUE(type, var, conv) \ - type var; \ - { \ - gpointer value = NULL; \ - assert(g_hash_table_lookup_extended \ - (required, #var, NULL, &value)); \ - var = conv((const char *)value); \ - } - - enum LINE_TYPE{ BEGIN_LINE = 1, END_LINE, diff --git a/utils/training/k_mixture_model_to_interpolation.cpp b/utils/training/k_mixture_model_to_interpolation.cpp index 7428e01..3a83f32 100644 --- a/utils/training/k_mixture_model_to_interpolation.cpp +++ b/utils/training/k_mixture_model_to_interpolation.cpp @@ -20,16 +20,7 @@ */ #include "pinyin_internal.h" - -#define TAGLIB_GET_TAGVALUE(type, var, conv) \ - type var; \ - { \ - gpointer value = NULL; \ - assert(g_hash_table_lookup_extended \ - (required, #var, NULL, &value)); \ - var = conv((const char *)value); \ - } - +#include "utils_helper.h" enum LINE_TYPE{ BEGIN_LINE = 1, diff --git a/utils/utils_helper.h b/utils/utils_helper.h index 152807b..db2a5c1 100644 --- a/utils/utils_helper.h +++ b/utils/utils_helper.h @@ -23,6 +23,25 @@ #ifndef UTILS_HELPER_H #define UTILS_HELPER_H +#define TAGLIB_GET_VALUE(var, index) \ + phrase_token_t var = null_token; \ + { \ + const char * string = (const char *) g_ptr_array_index \ + (values, index); \ + var = taglib_string_to_token \ + (phrase_table, phrase_index, string); \ + } + +#define TAGLIB_GET_TAGVALUE(type, var, conv) \ + type var; \ + { \ + gpointer value = NULL; \ + assert(g_hash_table_lookup_extended \ + (required, #var, NULL, &value)); \ + var = conv((const char *)value); \ + } + + static bool load_phrase_index(FacadePhraseIndex * phrase_index) { MemoryChunk * chunk = NULL; for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) { -- cgit