[uim-commit] r2946 - trunk/uim
yamaken at freedesktop.org
yamaken at freedesktop.org
Fri Jan 20 09:59:01 PST 2006
Author: yamaken
Date: 2006-01-20 09:58:51 -0800 (Fri, 20 Jan 2006)
New Revision: 2946
Modified:
trunk/uim/uim-custom.c
trunk/uim/uim-custom.h
Log:
* This commit change the custom API as said in bug
#5666. Corresponding Scheme part is not changed yet.
* uim/uim-custom.h
- (enum UCustomPathnameType, struct uim_custom_pathname): New type
- (union uim_custom_value): Change type of as_pathname to struct
uim_custom_pathname *
* uim/uim-custom.c
- (uim_custom_pathname_get, uim_custom_pathname_new,
uim_custom_pathname_free): New static function
- (uim_custom_value_internal, uim_custom_value_free,
uim_custom_set): Follow the changes
Modified: trunk/uim/uim-custom.c
===================================================================
--- trunk/uim/uim-custom.c 2006-01-20 15:09:07 UTC (rev 2945)
+++ trunk/uim/uim-custom.c 2006-01-20 17:58:51 UTC (rev 2946)
@@ -93,6 +93,9 @@
static char *uim_custom_label(const char *custom_sym);
static char *uim_custom_desc(const char *custom_sym);
+static struct uim_custom_pathname *uim_custom_pathname_get(const char *custom_sym, const char *getter_proc);
+static struct uim_custom_pathname *uim_custom_pathname_new(char *str, int type);
+static void uim_custom_pathname_free(struct uim_custom_pathname *custom_pathname);
static struct uim_custom_choice *uim_custom_choice_get(const char *custom_sym, const char *choice_sym);
static char *extract_choice_symbol(const struct uim_custom_choice *custom_choice);
static char *choice_list_to_str(const struct uim_custom_choice *const *list, const char *sep);
@@ -279,6 +282,55 @@
return uim_custom_get_str(custom_sym, "custom-desc");
}
+/* pathname */
+static struct uim_custom_pathname *
+uim_custom_pathname_get(const char *custom_sym, const char *getter_proc)
+{
+ struct uim_custom_pathname *custom_pathname;
+ char *str;
+ int type;
+
+ UIM_EVAL_FSTRING2(NULL, "(%s '%s)", getter_proc, custom_sym);
+ return_val = uim_scm_return_value();
+
+ str = uim_scm_c_str(return_val);
+ /* FIXME: retrieve custom attribute */
+ if (1)
+ type = UCustomPathnameType_RegularFile;
+ else
+ type = UCustomPathnameType_Directory;
+
+ custom_pathname = uim_custom_pathname_new(str, type);
+ if (!custom_pathname)
+ return NULL;
+
+ return custom_pathname;
+}
+
+static struct uim_custom_pathname *
+uim_custom_pathname_new(char *str, int type)
+{
+ struct uim_custom_pathname *custom_pathname;
+
+ custom_pathname = malloc(sizeof(struct uim_custom_pathname));
+ if (!custom_pathname)
+ return NULL;
+
+ custom_pathname->str = str;
+ custom_pathname->type = type;
+
+ return custom_pathname;
+}
+
+static void
+uim_custom_pathname_free(struct uim_custom_pathname *custom_pathname)
+{
+ if (!custom_pathname)
+ return;
+
+ free(custom_pathname->str);
+}
+
/* choice */
static struct uim_custom_choice *
uim_custom_choice_get(const char *custom_sym, const char *choice_sym)
@@ -568,7 +620,7 @@
value->as_str = uim_scm_c_str(return_val);
break;
case UCustom_Pathname:
- value->as_pathname = uim_scm_c_str(return_val);
+ value->as_pathname = uim_custom_pathname_get(custom_sym, getter_proc);
break;
case UCustom_Choice:
custom_value_symbol = uim_scm_c_symbol(return_val);
@@ -611,7 +663,7 @@
free(custom_value->as_str);
break;
case UCustom_Pathname:
- free(custom_value->as_pathname);
+ uim_custom_pathname_free(custom_value->as_pathname);
break;
case UCustom_Choice:
uim_custom_choice_free(custom_value->as_choice);
@@ -1155,7 +1207,7 @@
free(literal);
break;
case UCustom_Pathname:
- literal = literalize_string(custom->value->as_pathname);
+ literal = literalize_string(custom->value->as_pathname->str);
UIM_EVAL_FSTRING2(NULL, "(custom-set-value! '%s %s)",
custom->symbol, literal);
free(literal);
Modified: trunk/uim/uim-custom.h
===================================================================
--- trunk/uim/uim-custom.h 2006-01-20 15:09:07 UTC (rev 2945)
+++ trunk/uim/uim-custom.h 2006-01-20 17:58:51 UTC (rev 2946)
@@ -51,6 +51,11 @@
UCustom_Key
};
+enum UCustomPathnameType {
+ UCustomPathnameType_RegularFile,
+ UCustomPathnameType_Directory
+};
+
enum UCustomKeyType {
UCustomKey_Regular, /* "<Control>j" */
UCustomKey_Reference /* "generic-cancel-key" */
@@ -65,12 +70,17 @@
int as_bool;
int as_int;
char *as_str;
- char *as_pathname;
+ struct uim_custom_pathname *as_pathname;
struct uim_custom_choice *as_choice;
struct uim_custom_choice **as_olist;
struct uim_custom_key **as_key;
};
+struct uim_custom_pathname {
+ char *str;
+ int type; /* UCustomPathnameType */
+};
+
struct uim_custom_choice {
char *symbol;
char *label;
More information about the uim-commit
mailing list