diff options
| author | YAMAMOTO Mitsuharu | 2005-03-17 08:02:53 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2005-03-17 08:02:53 +0000 |
| commit | 48502d68e61cc00cca0206ad8e58544cf515bb15 (patch) | |
| tree | 2514906af7402e2d9c1fc9d8200f34108293bade /src | |
| parent | 11a646cddd651fec39eaa9dfefc0bfc55ddb7dc1 (diff) | |
| download | emacs-48502d68e61cc00cca0206ad8e58544cf515bb15.tar.gz emacs-48502d68e61cc00cca0206ad8e58544cf515bb15.zip | |
(HASHKEY_TERMINAL): Remove.
(HASHKEY_MAX_NID): New macro.
(xrm_q_get_resource_1): Rename from xrm_q_get_resource. Add extra
argument.
(xrm_q_get_resource): Call xrm_q_get_resource_1 with extra argument.
(xrm_create_database, xrm_q_put_resource)
(xrm_merge_string_database, xrm_q_get_resource_1)
(xrm_q_get_resource): Change resource database representation so that
it may not use multiple hash tables for a single database.
[TARGET_API_MAC_CARBON] (xrm_cfproperty_list_to_value): YAILOM.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 14 | ||||
| -rw-r--r-- | src/mac.c | 113 |
2 files changed, 79 insertions, 48 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 84c5b11a7ec..c2776756ce5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2005-03-17 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * mac.c (HASHKEY_TERMINAL): Remove. | ||
| 4 | (HASHKEY_MAX_NID): New macro. | ||
| 5 | (xrm_q_get_resource_1): Rename from xrm_q_get_resource. Add extra | ||
| 6 | argument. | ||
| 7 | (xrm_q_get_resource): Call xrm_q_get_resource_1 with extra | ||
| 8 | argument. | ||
| 9 | (xrm_create_database, xrm_q_put_resource) | ||
| 10 | (xrm_merge_string_database, xrm_q_get_resource_1) | ||
| 11 | (xrm_q_get_resource): Change resource database representation so | ||
| 12 | that it may not use multiple hash tables for a single database. | ||
| 13 | [TARGET_API_MAC_CARBON] (xrm_cfproperty_list_to_value): YAILOM. | ||
| 14 | |||
| 1 | 2005-03-16 Stefan Monnier <monnier@iro.umontreal.ca> | 15 | 2005-03-16 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 16 | ||
| 3 | * xmenu.c (ENCODE_MENU_STRING) [HAVE_X_I18N]: Use ENCODE_SYSTEM. | 17 | * xmenu.c (ENCODE_MENU_STRING) [HAVE_X_I18N]: Use ENCODE_SYSTEM. |
| @@ -344,7 +344,7 @@ cfnumber_to_lisp (number) | |||
| 344 | CFNumberRef number; | 344 | CFNumberRef number; |
| 345 | { | 345 | { |
| 346 | Lisp_Object result = Qnil; | 346 | Lisp_Object result = Qnil; |
| 347 | #if BITS_PER_EMACS_INT > 32 | 347 | #if BITS_PER_EMACS_INT > 32 |
| 348 | SInt64 int_val; | 348 | SInt64 int_val; |
| 349 | CFNumberType emacs_int_type = kCFNumberSInt64Type; | 349 | CFNumberType emacs_int_type = kCFNumberSInt64Type; |
| 350 | #else | 350 | #else |
| @@ -667,7 +667,7 @@ parse_resource_name (p) | |||
| 667 | if (NILP (component)) | 667 | if (NILP (component)) |
| 668 | return Qnil; | 668 | return Qnil; |
| 669 | 669 | ||
| 670 | result = Fcons (component, result); | 670 | result = Fcons (component, result); |
| 671 | while (binding = parse_binding (p)) | 671 | while (binding = parse_binding (p)) |
| 672 | { | 672 | { |
| 673 | if (binding == '*') | 673 | if (binding == '*') |
| @@ -678,7 +678,7 @@ parse_resource_name (p) | |||
| 678 | else | 678 | else |
| 679 | result = Fcons (component, result); | 679 | result = Fcons (component, result); |
| 680 | } | 680 | } |
| 681 | 681 | ||
| 682 | /* The final component should not be '?'. */ | 682 | /* The final component should not be '?'. */ |
| 683 | if (EQ (component, SINGLE_COMPONENT)) | 683 | if (EQ (component, SINGLE_COMPONENT)) |
| 684 | return Qnil; | 684 | return Qnil; |
| @@ -766,7 +766,7 @@ parse_value (p) | |||
| 766 | q = buf + total_len; | 766 | q = buf + total_len; |
| 767 | for (; CONSP (seq); seq = XCDR (seq)) | 767 | for (; CONSP (seq); seq = XCDR (seq)) |
| 768 | { | 768 | { |
| 769 | len = SBYTES (XCAR (seq)); | 769 | len = SBYTES (XCAR (seq)); |
| 770 | q -= len; | 770 | q -= len; |
| 771 | memcpy (q, SDATA (XCAR (seq)), len); | 771 | memcpy (q, SDATA (XCAR (seq)), len); |
| 772 | } | 772 | } |
| @@ -812,20 +812,27 @@ parse_resource_line (p) | |||
| 812 | An X Resource Database acts as a collection of resource names and | 812 | An X Resource Database acts as a collection of resource names and |
| 813 | associated values. It is implemented as a trie on quarks. Namely, | 813 | associated values. It is implemented as a trie on quarks. Namely, |
| 814 | each edge is labeled by either a string, LOOSE_BINDING, or | 814 | each edge is labeled by either a string, LOOSE_BINDING, or |
| 815 | SINGLE_COMPONENT. Nodes of the trie are implemented as Lisp hash | 815 | SINGLE_COMPONENT. Each node has a node id, which is a unique |
| 816 | tables, and a value associated with a resource name is recorded as | 816 | nonnegative integer, and the root node id is 0. A database is |
| 817 | a value for HASHKEY_TERMINAL at the hash table whose path from the | 817 | implemented as a hash table that maps a pair (SRC-NODE-ID . |
| 818 | root is the quarks of the resource name. */ | 818 | EDGE-LABEL) to DEST-NODE-ID. It also holds a maximum node id used |
| 819 | in the table as a value for HASHKEY_MAX_NID. A value associated to | ||
| 820 | a node is recorded as a value for the node id. */ | ||
| 819 | 821 | ||
| 820 | #define HASHKEY_TERMINAL Qt /* "T"erminal */ | 822 | #define HASHKEY_MAX_NID (make_number (0)) |
| 821 | 823 | ||
| 822 | static XrmDatabase | 824 | static XrmDatabase |
| 823 | xrm_create_database () | 825 | xrm_create_database () |
| 824 | { | 826 | { |
| 825 | return make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), | 827 | XrmDatabase database; |
| 826 | make_float (DEFAULT_REHASH_SIZE), | 828 | |
| 827 | make_float (DEFAULT_REHASH_THRESHOLD), | 829 | database = make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), |
| 828 | Qnil, Qnil, Qnil); | 830 | make_float (DEFAULT_REHASH_SIZE), |
| 831 | make_float (DEFAULT_REHASH_THRESHOLD), | ||
| 832 | Qnil, Qnil, Qnil); | ||
| 833 | Fputhash (HASHKEY_MAX_NID, make_number (0), database); | ||
| 834 | |||
| 835 | return database; | ||
| 829 | } | 836 | } |
| 830 | 837 | ||
| 831 | static void | 838 | static void |
| @@ -833,24 +840,30 @@ xrm_q_put_resource (database, quarks, value) | |||
| 833 | XrmDatabase database; | 840 | XrmDatabase database; |
| 834 | Lisp_Object quarks, value; | 841 | Lisp_Object quarks, value; |
| 835 | { | 842 | { |
| 836 | struct Lisp_Hash_Table *h; | 843 | struct Lisp_Hash_Table *h = XHASH_TABLE (database); |
| 837 | unsigned hash_code; | 844 | unsigned hash_code; |
| 838 | int i; | 845 | int max_nid, i; |
| 846 | Lisp_Object node_id, key; | ||
| 847 | |||
| 848 | max_nid = XINT (Fgethash (HASHKEY_MAX_NID, database, Qnil)); | ||
| 839 | 849 | ||
| 850 | XSETINT (node_id, 0); | ||
| 840 | for (; CONSP (quarks); quarks = XCDR (quarks)) | 851 | for (; CONSP (quarks); quarks = XCDR (quarks)) |
| 841 | { | 852 | { |
| 842 | h = XHASH_TABLE (database); | 853 | key = Fcons (node_id, XCAR (quarks)); |
| 843 | i = hash_lookup (h, XCAR (quarks), &hash_code); | 854 | i = hash_lookup (h, key, &hash_code); |
| 844 | if (i < 0) | 855 | if (i < 0) |
| 845 | { | 856 | { |
| 846 | database = xrm_create_database (); | 857 | max_nid++; |
| 847 | hash_put (h, XCAR (quarks), database, hash_code); | 858 | XSETINT (node_id, max_nid); |
| 859 | hash_put (h, key, node_id, hash_code); | ||
| 848 | } | 860 | } |
| 849 | else | 861 | else |
| 850 | database = HASH_VALUE (h, i); | 862 | node_id = HASH_VALUE (h, i); |
| 851 | } | 863 | } |
| 864 | Fputhash (node_id, value, database); | ||
| 852 | 865 | ||
| 853 | Fputhash (HASHKEY_TERMINAL, value, database); | 866 | Fputhash (HASHKEY_MAX_NID, make_number (max_nid), database); |
| 854 | } | 867 | } |
| 855 | 868 | ||
| 856 | /* Merge multiple resource entries specified by DATA into a resource | 869 | /* Merge multiple resource entries specified by DATA into a resource |
| @@ -875,49 +888,62 @@ xrm_merge_string_database (database, data) | |||
| 875 | } | 888 | } |
| 876 | 889 | ||
| 877 | static Lisp_Object | 890 | static Lisp_Object |
| 878 | xrm_q_get_resource (database, quark_name, quark_class) | 891 | xrm_q_get_resource_1 (database, node_id, quark_name, quark_class) |
| 879 | XrmDatabase database; | 892 | XrmDatabase database; |
| 880 | Lisp_Object quark_name, quark_class; | 893 | Lisp_Object node_id, quark_name, quark_class; |
| 881 | { | 894 | { |
| 882 | struct Lisp_Hash_Table *h = XHASH_TABLE (database); | 895 | struct Lisp_Hash_Table *h = XHASH_TABLE (database); |
| 883 | Lisp_Object keys[3], value; | 896 | Lisp_Object key, labels[3], value; |
| 884 | int i, k; | 897 | int i, k; |
| 885 | 898 | ||
| 886 | if (!CONSP (quark_name)) | 899 | if (!CONSP (quark_name)) |
| 887 | return Fgethash (HASHKEY_TERMINAL, database, Qnil); | 900 | return Fgethash (node_id, database, Qnil); |
| 888 | 901 | ||
| 889 | /* First, try tight bindings */ | 902 | /* First, try tight bindings */ |
| 890 | keys[0] = XCAR (quark_name); | 903 | labels[0] = XCAR (quark_name); |
| 891 | keys[1] = XCAR (quark_class); | 904 | labels[1] = XCAR (quark_class); |
| 892 | keys[2] = SINGLE_COMPONENT; | 905 | labels[2] = SINGLE_COMPONENT; |
| 893 | 906 | ||
| 894 | for (k = 0; k < sizeof (keys) / sizeof (*keys); k++) | 907 | key = Fcons (node_id, Qnil); |
| 908 | for (k = 0; k < sizeof (labels) / sizeof (*labels); k++) | ||
| 895 | { | 909 | { |
| 896 | i = hash_lookup (h, keys[k], NULL); | 910 | XSETCDR (key, labels[k]); |
| 911 | i = hash_lookup (h, key, NULL); | ||
| 897 | if (i >= 0) | 912 | if (i >= 0) |
| 898 | { | 913 | { |
| 899 | value = xrm_q_get_resource (HASH_VALUE (h, i), | 914 | value = xrm_q_get_resource_1 (database, HASH_VALUE (h, i), |
| 900 | XCDR (quark_name), XCDR (quark_class)); | 915 | XCDR (quark_name), XCDR (quark_class)); |
| 901 | if (!NILP (value)) | 916 | if (!NILP (value)) |
| 902 | return value; | 917 | return value; |
| 903 | } | 918 | } |
| 904 | } | 919 | } |
| 905 | 920 | ||
| 906 | /* Then, try loose bindings */ | 921 | /* Then, try loose bindings */ |
| 907 | i = hash_lookup (h, LOOSE_BINDING, NULL); | 922 | XSETCDR (key, LOOSE_BINDING); |
| 923 | i = hash_lookup (h, key, NULL); | ||
| 908 | if (i >= 0) | 924 | if (i >= 0) |
| 909 | { | 925 | { |
| 910 | value = xrm_q_get_resource (HASH_VALUE (h, i), quark_name, quark_class); | 926 | value = xrm_q_get_resource_1 (database, HASH_VALUE (h, i), |
| 927 | quark_name, quark_class); | ||
| 911 | if (!NILP (value)) | 928 | if (!NILP (value)) |
| 912 | return value; | 929 | return value; |
| 913 | else | 930 | else |
| 914 | return xrm_q_get_resource (database, | 931 | return xrm_q_get_resource_1 (database, node_id, |
| 915 | XCDR (quark_name), XCDR (quark_class)); | 932 | XCDR (quark_name), XCDR (quark_class)); |
| 916 | } | 933 | } |
| 917 | else | 934 | else |
| 918 | return Qnil; | 935 | return Qnil; |
| 919 | } | 936 | } |
| 920 | 937 | ||
| 938 | static Lisp_Object | ||
| 939 | xrm_q_get_resource (database, quark_name, quark_class) | ||
| 940 | XrmDatabase database; | ||
| 941 | Lisp_Object quark_name, quark_class; | ||
| 942 | { | ||
| 943 | return xrm_q_get_resource_1 (database, make_number (0), | ||
| 944 | quark_name, quark_class); | ||
| 945 | } | ||
| 946 | |||
| 921 | /* Retrieve a resource value for the specified NAME and CLASS from the | 947 | /* Retrieve a resource value for the specified NAME and CLASS from the |
| 922 | resource database DATABASE. It corresponds to XrmGetResource. */ | 948 | resource database DATABASE. It corresponds to XrmGetResource. */ |
| 923 | 949 | ||
| @@ -972,16 +998,7 @@ xrm_cfproperty_list_to_value (plist) | |||
| 972 | return result; | 998 | return result; |
| 973 | } | 999 | } |
| 974 | else if (type_id == CFBooleanGetTypeID ()) | 1000 | else if (type_id == CFBooleanGetTypeID ()) |
| 975 | { | 1001 | return build_string (CFBooleanGetValue (plist) ? "true" : "false"); |
| 976 | static value_true = NULL, value_false = NULL; | ||
| 977 | |||
| 978 | if (value_true == NULL) | ||
| 979 | { | ||
| 980 | value_true = build_string ("true"); | ||
| 981 | value_false = build_string ("false"); | ||
| 982 | } | ||
| 983 | return CFBooleanGetValue (plist) ? value_true : value_false; | ||
| 984 | } | ||
| 985 | else if (type_id == CFDataGetTypeID ()) | 1002 | else if (type_id == CFDataGetTypeID ()) |
| 986 | return cfdata_to_lisp (plist); | 1003 | return cfdata_to_lisp (plist); |
| 987 | else | 1004 | else |