From: MORIOKA Tomohiko Date: Tue, 16 Apr 2013 09:45:30 +0000 (+0900) Subject: (COS_Object_retain_function_table): New variable. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73a70ba1eb49f0a0d15089e2abc45d09a49452c6;p=chise%2Fconcord.git (COS_Object_retain_function_table): New variable. (cos_retain_object): Call a retain-function in `COS_Object_retain_function_table'. (cos_retain_string): New function. (cos_retain_cons): New function. (cos_retain_container): New function. (cos_retain_sexp): New function. (cos_retain_binary): New function. (cos_retain_ds): New function. (cos_retain_genre): New function. (cos_retain_feature): New function. (cos_retain_index): New function. (cos_retain_db_object): New function. --- diff --git a/cos.c b/cos.c index 299852b..4a842b8 100644 --- a/cos.c +++ b/cos.c @@ -28,6 +28,22 @@ const char concord_system_db_dir[] = CONCORD_SI_DB_DIR; CONCORD_DS concord_current_env = NULL; +int (*COS_Object_retain_function_table + [COS_OBJECT_TYPE_MAX - COS_Object_Type_char]) + (COS_Object) + = { cos_retain_string, + cos_retain_symbol, + cos_retain_cons, + cos_retain_container, + cos_retain_sexp, + cos_retain_binary, + cos_retain_ds, + cos_retain_genre, + cos_retain_feature, + cos_retain_index, + cos_retain_db_object +}; + int (*COS_Object_release_function_table [COS_OBJECT_TYPE_MAX - COS_Object_Type_char]) (COS_Object) @@ -106,7 +122,12 @@ COS_Object cos_retain_object (COS_Object obj) { if (COS_OBJECT_P (obj)) - obj->header.reference_count++; + { + obj->header.reference_count++; + (*COS_Object_retain_function_table + [((COS_Object)obj)->header.type + - COS_FAT_OBJECT_TYPE_MIN])(obj); + } return obj; } @@ -173,6 +194,12 @@ cos_build_string (char* str) } int +cos_retain_string (COS_Object obj) +{ + return 0; +} + +int cos_release_string (COS_Object obj) { if (obj == NULL) @@ -219,6 +246,14 @@ cos_cons (COS_object car, COS_object cdr) } int +cos_retain_cons (COS_Object obj) +{ + cos_retain_object (COS_CAR (obj)); + cos_retain_object (COS_CDR (obj)); + return 0; +} + +int cos_release_cons (COS_Object obj) { if (obj == NULL) @@ -250,6 +285,12 @@ cos_cdr (COS_Cons pair) int +cos_retain_container (COS_Object obj) +{ + return 0; +} + +int cos_release_container (COS_Object obj) { return 0; @@ -257,6 +298,12 @@ cos_release_container (COS_Object obj) int +cos_retain_sexp (COS_Object obj) +{ + return 0; +} + +int cos_release_sexp (COS_Object obj) { return 0; @@ -264,6 +311,12 @@ cos_release_sexp (COS_Object obj) int +cos_retain_binary (COS_Object obj) +{ + return 0; +} + +int cos_release_binary (COS_Object obj) { return 0; @@ -293,6 +346,12 @@ concord_open_env (COS_object ds) } int +cos_retain_ds (COS_Object obj) +{ + return 0; +} + +int cos_release_ds (COS_Object obj) { return concord_close_ds ((COS_DS)obj); @@ -312,6 +371,12 @@ concord_get_genre (COS_object ds, COS_object genre) } int +cos_retain_genre (COS_Object obj) +{ + return 0; +} + +int cos_release_genre (COS_Object obj) { return concord_close_genre ((COS_Genre)obj); @@ -343,6 +408,12 @@ concord_get_feature (COS_object ds, } int +cos_retain_feature (COS_Object obj) +{ + return 0; +} + +int cos_release_feature (COS_Object obj) { return concord_close_feature ((COS_Feature)obj); @@ -371,6 +442,12 @@ concord_get_feature_index (COS_object ds, } int +cos_retain_index (COS_Object obj) +{ + return concord_close_index ((COS_Feature_INDEX)obj); +} + +int cos_release_index (COS_Object obj) { return concord_close_index ((COS_Feature_INDEX)obj); @@ -378,6 +455,12 @@ cos_release_index (COS_Object obj) int +cos_retain_db_object (COS_Object obj) +{ + return 0; +} + +int cos_release_db_object (COS_Object obj) { return 0;