From 9d5ac7dd218b16b424b3bc9af323e2f4725978ce Mon Sep 17 00:00:00 2001 From: MORIOKA Tomohiko Date: Thu, 18 Apr 2013 11:15:12 +0900 Subject: [PATCH] (cos_cons_p): New function. (concord_object_get_feature_value): Use `cos_read_object'. --- cos.c | 51 +++++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/cos.c b/cos.c index 4a842b8..546078c 100644 --- a/cos.c +++ b/cos.c @@ -67,6 +67,12 @@ cos_make_int (COS_C_Int num) return (COS_object)((COS_INT)(num << 1) | 1); } +int +cos_int_p (COS_object obj) +{ + return COS_OBJECT_INT_P (obj); +} + COS_C_Int cos_int_value (COS_object obj) { @@ -75,12 +81,6 @@ cos_int_value (COS_object obj) return INTPTR_MIN; } -int -cos_int_p (COS_object obj) -{ - return COS_OBJECT_INT_P (obj); -} - COS_object cos_make_char (int code) @@ -89,17 +89,17 @@ cos_make_char (int code) } int -cos_char_id (COS_object obj) +cos_char_p (COS_object obj) { - if (COS_OBJECT_CHAR_P (obj)) - return ((COS_INT)obj) >> 2; - return -1; + return COS_OBJECT_CHAR_P (obj); } int -cos_char_p (COS_object obj) +cos_char_id (COS_object obj) { - return COS_OBJECT_CHAR_P (obj); + if (COS_OBJECT_CHAR_P (obj)) + return ((COS_INT)obj) >> 2; + return -1; } @@ -265,6 +265,12 @@ cos_release_cons (COS_Object obj) return 0; } +int +cos_cons_p (COS_object obj) +{ + return COS_OBJECT_CONS_P (obj); +} + COS_object cos_car (COS_Cons pair) { @@ -547,9 +553,6 @@ concord_object_get_feature_value (COS_object object, COS_object feature) CONCORD_String_Tank val_st; COS_String val_string; size_t end; - int val_cid; - COS_String val_str; - COS_object val_obj; if (COS_OBJECT_CHAR_P (object)) { @@ -574,23 +577,7 @@ concord_object_get_feature_value (COS_object object, COS_object feature) concord_feature_get_name (fobj), cos_string_data (val_string)); - val_obj = cos_read_int (CONCORD_String_data (&val_st), + return cos_read_object (CONCORD_String_data (&val_st), CONCORD_String_size (&val_st), 0, &end); - if ( val_obj != NULL ) - return val_obj; - - val_cid = cos_read_char (CONCORD_String_data (&val_st), - CONCORD_String_size (&val_st), - 0, &end); - if ( val_cid >= 0 ) - return cos_make_char (val_cid); - - val_str = cos_read_string (CONCORD_String_data (&val_st), - CONCORD_String_size (&val_st), - 0, &end); - if ( val_str != NULL ) - return val_str; - - return NULL; } -- 1.7.10.4