pairs.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /* classes: h_files */
  2. #ifndef SCM_PAIRS_H
  3. #define SCM_PAIRS_H
  4. /* Copyright (C) 1995,1996,2000,2001, 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 3 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301 USA
  20. */
  21. #include "libguile/__scm.h"
  22. #if (SCM_DEBUG_PAIR_ACCESSES == 1)
  23. # define SCM_VALIDATE_PAIR(cell, expr) \
  24. ((!scm_is_pair (cell) ? scm_error_pair_access (cell), 0 : 0), (expr))
  25. #else
  26. # define SCM_VALIDATE_PAIR(cell, expr) (expr)
  27. #endif
  28. /*
  29. * Use scm_is_null_and_not_nil if it's important (for correctness)
  30. * that #nil must NOT be considered null.
  31. */
  32. #define scm_is_null_and_not_nil(x) (scm_is_eq ((x), SCM_EOL))
  33. /*
  34. * Use scm_is_null_assume_not_nil if
  35. #nil will never be tested,
  36. * for increased efficiency.
  37. */
  38. #define scm_is_null_assume_not_nil(x) (scm_is_eq ((x), SCM_EOL))
  39. /*
  40. * See the comments preceeding the definitions of SCM_BOOL_F and
  41. * SCM_MATCHES_BITS_IN_COMMON in tags.h for more information on
  42. * how the following macro works.
  43. */
  44. #define scm_is_null_or_nil(x) \
  45. (SCM_MATCHES_BITS_IN_COMMON ((x), SCM_ELISP_NIL, SCM_EOL))
  46. /* Older spellings for these null, nil, and pair predicates. */
  47. #define SCM_NILP(x) (scm_is_eq ((x), SCM_ELISP_NIL))
  48. #define SCM_NULL_OR_NIL_P(x) (scm_is_null_or_nil (x))
  49. #define SCM_NULLP(x) (scm_is_null (x))
  50. #define SCM_NNULLP(x) (!scm_is_null (x))
  51. #define SCM_CONSP(x) (scm_is_pair (x))
  52. #define SCM_NCONSP(x) (!SCM_CONSP (x))
  53. /* #nil is null. */
  54. #define scm_is_null(x) (scm_is_null_or_nil(x))
  55. #define SCM_CAR(x) (SCM_VALIDATE_PAIR (x, SCM_CELL_OBJECT_0 (x)))
  56. #define SCM_CDR(x) (SCM_VALIDATE_PAIR (x, SCM_CELL_OBJECT_1 (x)))
  57. #define SCM_SETCAR(x, v) (SCM_VALIDATE_PAIR (x, SCM_SET_CELL_OBJECT_0 ((x), (v))))
  58. #define SCM_SETCDR(x, v) (SCM_VALIDATE_PAIR (x, SCM_SET_CELL_OBJECT_1 ((x), (v))))
  59. #define SCM_CAAR(OBJ) SCM_CAR (SCM_CAR (OBJ))
  60. #define SCM_CDAR(OBJ) SCM_CDR (SCM_CAR (OBJ))
  61. #define SCM_CADR(OBJ) SCM_CAR (SCM_CDR (OBJ))
  62. #define SCM_CDDR(OBJ) SCM_CDR (SCM_CDR (OBJ))
  63. #define SCM_CAAAR(OBJ) SCM_CAR (SCM_CAR (SCM_CAR (OBJ)))
  64. #define SCM_CDAAR(OBJ) SCM_CDR (SCM_CAR (SCM_CAR (OBJ)))
  65. #define SCM_CADAR(OBJ) SCM_CAR (SCM_CDR (SCM_CAR (OBJ)))
  66. #define SCM_CDDAR(OBJ) SCM_CDR (SCM_CDR (SCM_CAR (OBJ)))
  67. #define SCM_CAADR(OBJ) SCM_CAR (SCM_CAR (SCM_CDR (OBJ)))
  68. #define SCM_CDADR(OBJ) SCM_CDR (SCM_CAR (SCM_CDR (OBJ)))
  69. #define SCM_CADDR(OBJ) SCM_CAR (SCM_CDR (SCM_CDR (OBJ)))
  70. #define SCM_CDDDR(OBJ) SCM_CDR (SCM_CDR (SCM_CDR (OBJ)))
  71. #define SCM_CAAAAR(OBJ) SCM_CAR (SCM_CAR (SCM_CAR (SCM_CAR (OBJ))))
  72. #define SCM_CDAAAR(OBJ) SCM_CDR (SCM_CAR (SCM_CAR (SCM_CAR (OBJ))))
  73. #define SCM_CADAAR(OBJ) SCM_CAR (SCM_CDR (SCM_CAR (SCM_CAR (OBJ))))
  74. #define SCM_CDDAAR(OBJ) SCM_CDR (SCM_CDR (SCM_CAR (SCM_CAR (OBJ))))
  75. #define SCM_CAADAR(OBJ) SCM_CAR (SCM_CAR (SCM_CDR (SCM_CAR (OBJ))))
  76. #define SCM_CDADAR(OBJ) SCM_CDR (SCM_CAR (SCM_CDR (SCM_CAR (OBJ))))
  77. #define SCM_CADDAR(OBJ) SCM_CAR (SCM_CDR (SCM_CDR (SCM_CAR (OBJ))))
  78. #define SCM_CDDDAR(OBJ) SCM_CDR (SCM_CDR (SCM_CDR (SCM_CAR (OBJ))))
  79. #define SCM_CAAADR(OBJ) SCM_CAR (SCM_CAR (SCM_CAR (SCM_CDR (OBJ))))
  80. #define SCM_CDAADR(OBJ) SCM_CDR (SCM_CAR (SCM_CAR (SCM_CDR (OBJ))))
  81. #define SCM_CADADR(OBJ) SCM_CAR (SCM_CDR (SCM_CAR (SCM_CDR (OBJ))))
  82. #define SCM_CDDADR(OBJ) SCM_CDR (SCM_CDR (SCM_CAR (SCM_CDR (OBJ))))
  83. #define SCM_CAADDR(OBJ) SCM_CAR (SCM_CAR (SCM_CDR (SCM_CDR (OBJ))))
  84. #define SCM_CDADDR(OBJ) SCM_CDR (SCM_CAR (SCM_CDR (SCM_CDR (OBJ))))
  85. #define SCM_CADDDR(OBJ) SCM_CAR (SCM_CDR (SCM_CDR (SCM_CDR (OBJ))))
  86. #define SCM_CDDDDR(OBJ) SCM_CDR (SCM_CDR (SCM_CDR (SCM_CDR (OBJ))))
  87. #if (SCM_DEBUG_PAIR_ACCESSES == 1)
  88. SCM_API void scm_error_pair_access (SCM);
  89. #endif
  90. SCM_API SCM scm_cons (SCM x, SCM y);
  91. SCM_API SCM scm_cons2 (SCM w, SCM x, SCM y);
  92. SCM_API SCM scm_pair_p (SCM x);
  93. SCM_API SCM scm_car (SCM x);
  94. SCM_API SCM scm_cdr (SCM x);
  95. SCM_API SCM scm_set_car_x (SCM pair, SCM value);
  96. SCM_API SCM scm_set_cdr_x (SCM pair, SCM value);
  97. SCM_API SCM scm_cddr (SCM x);
  98. SCM_API SCM scm_cdar (SCM x);
  99. SCM_API SCM scm_cadr (SCM x);
  100. SCM_API SCM scm_caar (SCM x);
  101. SCM_API SCM scm_cdddr (SCM x);
  102. SCM_API SCM scm_cddar (SCM x);
  103. SCM_API SCM scm_cdadr (SCM x);
  104. SCM_API SCM scm_cdaar (SCM x);
  105. SCM_API SCM scm_caddr (SCM x);
  106. SCM_API SCM scm_cadar (SCM x);
  107. SCM_API SCM scm_caadr (SCM x);
  108. SCM_API SCM scm_caaar (SCM x);
  109. SCM_API SCM scm_cddddr (SCM x);
  110. SCM_API SCM scm_cdddar (SCM x);
  111. SCM_API SCM scm_cddadr (SCM x);
  112. SCM_API SCM scm_cddaar (SCM x);
  113. SCM_API SCM scm_cdaddr (SCM x);
  114. SCM_API SCM scm_cdadar (SCM x);
  115. SCM_API SCM scm_cdaadr (SCM x);
  116. SCM_API SCM scm_cdaaar (SCM x);
  117. SCM_API SCM scm_cadddr (SCM x);
  118. SCM_API SCM scm_caddar (SCM x);
  119. SCM_API SCM scm_cadadr (SCM x);
  120. SCM_API SCM scm_cadaar (SCM x);
  121. SCM_API SCM scm_caaddr (SCM x);
  122. SCM_API SCM scm_caadar (SCM x);
  123. SCM_API SCM scm_caaadr (SCM x);
  124. SCM_API SCM scm_caaaar (SCM x);
  125. SCM_INTERNAL void scm_init_pairs (void);
  126. #endif /* SCM_PAIRS_H */
  127. /*
  128. Local Variables:
  129. c-file-style: "gnu"
  130. End:
  131. */