Advertisement
chemoelectric

Untitled

May 20th, 2013
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.40 KB | None | 0 0
  1. diff --git a/auxiliary/guile_containers_rbmap.c b/auxiliary/guile_containers_rbmap.c
  2. index 0e696fc..33550ba 100644
  3. --- a/auxiliary/guile_containers_rbmap.c
  4. +++ b/auxiliary/guile_containers_rbmap.c
  5. @@ -32,7 +32,7 @@ INITIALIZED_CONSTANT (_FF_ATTRIBUTE_PURE static, SCM, _rbmapi_to_pointer,
  6.  
  7. //-------------------------------------------------------------------------
  8. //
  9. -// Maps with intmax_t as keys.
  10. +// Maps with size_t as keys.
  11.  
  12. typedef struct rbmapi_node_s rbmapi_node_t;
  13.  
  14. @@ -76,7 +76,7 @@ scm_to_c_rbmapi (SCM map)
  15. }
  16.  
  17. // Create instances of inline functions.
  18. -VISIBLE intmax_t scm_rbmapi_iter_key (scm_t_rbmapi_iter iter);
  19. +VISIBLE size_t scm_rbmapi_iter_key (scm_t_rbmapi_iter iter);
  20. VISIBLE SCM scm_rbmapi_iter_value (scm_t_rbmapi_iter iter);
  21. VISIBLE void scm_rbmapi_iter_set_value (scm_t_rbmapi_iter iter, SCM value);
  22.  
  23. @@ -101,7 +101,7 @@ scm_c_rbmapi_nsearch (SCM map, SCM key)
  24. iter = (scm_t_rbmapi_iter) rbmapi_first (tree);
  25. else
  26. {
  27. - const intmax_t i_key = scm_to_intmax (key);
  28. + const size_t i_key = scm_to_size_t (key);
  29. rbmapi_node_t key_node = {.key = i_key };
  30. iter = (scm_t_rbmapi_iter) rbmapi_nsearch (tree, &key_node);
  31. }
  32. @@ -117,7 +117,7 @@ scm_c_rbmapi_psearch (SCM map, SCM key)
  33. iter = (scm_t_rbmapi_iter) rbmapi_last (tree);
  34. else
  35. {
  36. - const intmax_t i_key = scm_to_intmax (key);
  37. + const size_t i_key = scm_to_size_t (key);
  38. rbmapi_node_t key_node = {.key = i_key };
  39. iter = (scm_t_rbmapi_iter) rbmapi_psearch (tree, &key_node);
  40. }
  41. @@ -147,7 +147,7 @@ scm_make_rbmapi (void)
  42. }
  43.  
  44. static inline void
  45. -internal_rbmapi_insert (rbmapi_t *tree, intmax_t i_key, SCM value)
  46. +internal_rbmapi_insert (rbmapi_t *tree, size_t i_key, SCM value)
  47. {
  48. rbmapi_node_t *node = scm_gc_malloc (sizeof (rbmapi_node_t), "rbmapi_node_t");
  49. node->key = i_key;
  50. @@ -159,7 +159,7 @@ VISIBLE SCM
  51. scm_rbmapi_set_x (SCM map, SCM key, SCM value)
  52. {
  53. rbmapi_t *tree = scm_to_c_rbmapi (map);
  54. - const intmax_t i_key = scm_to_intmax (key);
  55. + const size_t i_key = scm_to_size_t (key);
  56. rbmapi_node_t key_node = {.key = i_key };
  57.  
  58. rbmapi_node_t *node = rbmapi_search (tree, &key_node);
  59. @@ -175,7 +175,7 @@ VISIBLE SCM
  60. scm_rbmapi_delete_x (SCM map, SCM key)
  61. {
  62. rbmapi_t *tree = scm_to_c_rbmapi (map);
  63. - const intmax_t i_key = scm_to_intmax (key);
  64. + const size_t i_key = scm_to_size_t (key);
  65. rbmapi_node_t key_node = {.key = i_key };
  66.  
  67. rbmapi_node_t *node = rbmapi_search (tree, &key_node);
  68. @@ -192,7 +192,7 @@ scm_rbmapi_ref (SCM map, SCM key, SCM default_value)
  69. SCM dflt = SCM_UNBNDP (default_value) ? SCM_BOOL_F : default_value;
  70.  
  71. rbmapi_t *tree = scm_to_c_rbmapi (map);
  72. - const intmax_t i_key = scm_to_intmax (key);
  73. + const size_t i_key = scm_to_size_t (key);
  74. rbmapi_node_t key_node = {.key = i_key };
  75.  
  76. const rbmapi_node_t *node = rbmapi_search (tree, &key_node);
  77. @@ -206,7 +206,7 @@ scm_rbmapi_fold_left (SCM proc, SCM init, SCM map, SCM start_key)
  78. for (scm_t_rbmapi_iter p = scm_c_rbmapi_nsearch (map, start_key); p != NULL;
  79. p = scm_c_rbmapi_next (map, p))
  80. init =
  81. - scm_call_3 (proc, init, scm_from_intmax (scm_rbmapi_iter_key (p)),
  82. + scm_call_3 (proc, init, scm_from_size_t (scm_rbmapi_iter_key (p)),
  83. scm_rbmapi_iter_value (p));
  84. return init;
  85. }
  86. @@ -217,7 +217,7 @@ scm_rbmapi_fold_right (SCM proc, SCM init, SCM map, SCM start_key)
  87. for (scm_t_rbmapi_iter p = scm_c_rbmapi_psearch (map, start_key); p != NULL;
  88. p = scm_c_rbmapi_prev (map, p))
  89. init =
  90. - scm_call_3 (proc, scm_from_intmax (scm_rbmapi_iter_key (p)),
  91. + scm_call_3 (proc, scm_from_size_t (scm_rbmapi_iter_key (p)),
  92. scm_rbmapi_iter_value (p), init);
  93. return init;
  94. }
  95. @@ -242,7 +242,7 @@ scm_rbmapi_to_alist (SCM map)
  96. // Go backwards, so consing preserves the order.
  97. for (scm_t_rbmapi_iter p = scm_c_rbmapi_last (map); p != NULL;
  98. p = scm_c_rbmapi_prev (map, p))
  99. - alist = scm_acons (scm_from_intmax (scm_rbmapi_iter_key (p)),
  100. + alist = scm_acons (scm_from_size_t (scm_rbmapi_iter_key (p)),
  101. scm_rbmapi_iter_value (p), alist);
  102.  
  103. return alist;
  104. @@ -257,7 +257,7 @@ scm_rbmapi_map_to_list (SCM proc, SCM map)
  105. for (scm_t_rbmapi_iter p = scm_c_rbmapi_last (map); p != NULL;
  106. p = scm_c_rbmapi_prev (map, p))
  107. {
  108. - SCM element = scm_call_2 (proc, scm_from_intmax (scm_rbmapi_iter_key (p)),
  109. + SCM element = scm_call_2 (proc, scm_from_size_t (scm_rbmapi_iter_key (p)),
  110. scm_rbmapi_iter_value (p));
  111. lst = scm_cons (element, lst);
  112. }
  113. @@ -270,7 +270,7 @@ scm_rbmapi_for_each (SCM proc, SCM map)
  114. {
  115. for (scm_t_rbmapi_iter p = scm_c_rbmapi_last (map); p != NULL;
  116. p = scm_c_rbmapi_prev (map, p))
  117. - scm_call_2 (proc, scm_from_intmax (scm_rbmapi_iter_key (p)),
  118. + scm_call_2 (proc, scm_from_size_t (scm_rbmapi_iter_key (p)),
  119. scm_rbmapi_iter_value (p));
  120. return SCM_UNSPECIFIED;
  121. }
  122. @@ -282,7 +282,7 @@ scm_rbmapi_count (SCM pred, SCM map)
  123. for (scm_t_rbmapi_iter p = scm_c_rbmapi_first (map); p != NULL;
  124. p = scm_c_rbmapi_next (map, p))
  125. if (scm_is_true
  126. - (scm_call_2 (pred, scm_from_intmax (scm_rbmapi_iter_key (p)),
  127. + (scm_call_2 (pred, scm_from_size_t (scm_rbmapi_iter_key (p)),
  128. scm_rbmapi_iter_value (p))))
  129. count = scm_oneplus (count);
  130. return count;
  131. diff --git a/inc/sortsmill/guile/containers/rbmap.h b/inc/sortsmill/guile/containers/rbmap.h
  132. index 0c7ccd8..f479cec 100644
  133. --- a/inc/sortsmill/guile/containers/rbmap.h
  134. +++ b/inc/sortsmill/guile/containers/rbmap.h
  135. @@ -29,7 +29,7 @@ extern "C"
  136. }
  137. #endif
  138.  
  139. -#define SCM_RBMAPI_NODE_HEAD intmax_t key; SCM value
  140. +#define SCM_RBMAPI_NODE_HEAD size_t key; SCM value
  141.  
  142. typedef struct
  143. {
  144. @@ -38,7 +38,7 @@ typedef struct
  145.  
  146. typedef scm_t_rbmapi_node_data *scm_t_rbmapi_iter;
  147.  
  148. -inline intmax_t scm_rbmapi_iter_key (scm_t_rbmapi_iter iter);
  149. +inline size_t scm_rbmapi_iter_key (scm_t_rbmapi_iter iter);
  150. inline SCM scm_rbmapi_iter_value (scm_t_rbmapi_iter iter);
  151. inline void scm_rbmapi_iter_set_value (scm_t_rbmapi_iter iter, SCM value);
  152.  
  153. @@ -62,7 +62,7 @@ SCM scm_rbmapi_for_each (SCM proc, SCM map);
  154. SCM scm_rbmapi_count (SCM pred, SCM map);
  155. SCM scm_rbmapi_size (SCM map);
  156.  
  157. -inline intmax_t
  158. +inline size_t
  159. scm_rbmapi_iter_key (scm_t_rbmapi_iter iter)
  160. {
  161. return iter->key;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement