sequence_common.hpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. // (C) Copyright Edward Diener 2011-2015
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. #if !defined(BOOST_VMD_DETAIL_SEQUENCE_COMMON_HPP)
  6. #define BOOST_VMD_DETAIL_SEQUENCE_COMMON_HPP
  7. #include <boost/preprocessor/arithmetic/inc.hpp>
  8. #include <boost/preprocessor/array/push_back.hpp>
  9. #include <boost/preprocessor/cat.hpp>
  10. #include <boost/preprocessor/comparison/equal.hpp>
  11. #include <boost/preprocessor/comparison/less_equal.hpp>
  12. #include <boost/preprocessor/comparison/not_equal.hpp>
  13. #include <boost/preprocessor/control/iif.hpp>
  14. #include <boost/preprocessor/control/while.hpp>
  15. #include <boost/preprocessor/list/append.hpp>
  16. #include <boost/preprocessor/logical/bitor.hpp>
  17. #include <boost/preprocessor/punctuation/is_begin_parens.hpp>
  18. #include <boost/preprocessor/seq/push_back.hpp>
  19. #include <boost/preprocessor/seq/size.hpp>
  20. #include <boost/preprocessor/tuple/elem.hpp>
  21. #include <boost/preprocessor/tuple/push_back.hpp>
  22. #include <boost/preprocessor/tuple/replace.hpp>
  23. #include <boost/preprocessor/tuple/size.hpp>
  24. #include <boost/vmd/empty.hpp>
  25. #include <boost/vmd/identity.hpp>
  26. #include <boost/vmd/is_empty.hpp>
  27. #include <boost/vmd/is_empty_list.hpp>
  28. #include <boost/vmd/detail/array.hpp>
  29. #include <boost/vmd/detail/equal_type.hpp>
  30. #include <boost/vmd/detail/identifier.hpp>
  31. #include <boost/vmd/detail/identifier_type.hpp>
  32. #include <boost/vmd/detail/list.hpp>
  33. #include <boost/vmd/detail/modifiers.hpp>
  34. #include <boost/vmd/detail/mods.hpp>
  35. #include <boost/vmd/detail/seq.hpp>
  36. #include <boost/vmd/detail/tuple.hpp>
  37. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT_ELEM 0
  38. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ELEM 1
  39. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM_ELEM 2
  40. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_OUTTYPE_ELEM 3
  41. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM_ELEM 4
  42. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES_ELEM 5
  43. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX_ELEM 6
  44. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state) \
  45. BOOST_PP_TUPLE_ELEM(BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT_ELEM,state) \
  46. /**/
  47. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state) \
  48. BOOST_PP_TUPLE_ELEM(BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ELEM,state) \
  49. /**/
  50. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state) \
  51. BOOST_PP_TUPLE_ELEM(BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM_ELEM,state) \
  52. /**/
  53. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_OUTTYPE(state) \
  54. BOOST_PP_TUPLE_ELEM(BOOST_VMD_DETAIL_SEQUENCE_STATE_OUTTYPE_ELEM,state) \
  55. /**/
  56. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM(state) \
  57. BOOST_PP_TUPLE_ELEM(BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM_ELEM,state) \
  58. /**/
  59. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_RETURN(d,from,number) \
  60. BOOST_PP_EQUAL_D \
  61. ( \
  62. d, \
  63. BOOST_PP_TUPLE_ELEM(0,from), \
  64. number \
  65. ) \
  66. /**/
  67. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_NO_RETURN(d,from) \
  68. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_RETURN(d,from,BOOST_VMD_DETAIL_MODS_NO_RETURN) \
  69. /**/
  70. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_EXACT_RETURN(d,from) \
  71. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_RETURN(d,from,BOOST_VMD_DETAIL_MODS_RETURN) \
  72. /**/
  73. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_GENERAL_RETURN(d,from) \
  74. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_RETURN(d,from,BOOST_VMD_DETAIL_MODS_RETURN_TUPLE) \
  75. /**/
  76. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_ARRAY_RETURN(d,from) \
  77. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_RETURN(d,from,BOOST_VMD_DETAIL_MODS_RETURN_ARRAY) \
  78. /**/
  79. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_LIST_RETURN(d,from) \
  80. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_RETURN(d,from,BOOST_VMD_DETAIL_MODS_RETURN_LIST) \
  81. /**/
  82. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_AFTER(from) \
  83. BOOST_PP_EQUAL \
  84. ( \
  85. BOOST_PP_TUPLE_ELEM(1,from), \
  86. BOOST_VMD_DETAIL_MODS_RETURN_AFTER \
  87. ) \
  88. /**/
  89. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_AFTER_D(d,from) \
  90. BOOST_PP_EQUAL_D \
  91. ( \
  92. d, \
  93. BOOST_PP_TUPLE_ELEM(1,from), \
  94. BOOST_VMD_DETAIL_MODS_RETURN_AFTER \
  95. ) \
  96. /**/
  97. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES(state) \
  98. BOOST_PP_TUPLE_ELEM(BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES_ELEM,state) \
  99. /**/
  100. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX(state) \
  101. BOOST_PP_TUPLE_ELEM(BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX_ELEM,state) \
  102. /**/
  103. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_IS_EMPTY(state) \
  104. BOOST_VMD_IS_EMPTY \
  105. ( \
  106. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state) \
  107. ) \
  108. /**/
  109. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_FROM_EMPTY(state,data) \
  110. (data) \
  111. /**/
  112. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_TO_SEQ(state,data) \
  113. BOOST_PP_SEQ_PUSH_BACK(BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state),data) \
  114. /**/
  115. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_TO_TUPLE(state,data) \
  116. BOOST_PP_TUPLE_PUSH_BACK(BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state),data) \
  117. /**/
  118. // Array
  119. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_BOOST_VMD_TYPE_ARRAY(d,state,data) \
  120. BOOST_PP_ARRAY_PUSH_BACK(BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state),data) \
  121. /**/
  122. // List
  123. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_BOOST_VMD_TYPE_LIST(d,state,data) \
  124. BOOST_PP_LIST_APPEND_D(d,BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state),(data,BOOST_PP_NIL)) \
  125. /**/
  126. // Seq
  127. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_BOOST_VMD_TYPE_SEQ(d,state,data) \
  128. BOOST_PP_IIF \
  129. ( \
  130. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_IS_EMPTY(state), \
  131. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_FROM_EMPTY, \
  132. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_TO_SEQ \
  133. ) \
  134. (state,data) \
  135. /**/
  136. // Tuple
  137. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_BOOST_VMD_TYPE_TUPLE(d,state,data) \
  138. BOOST_PP_IIF \
  139. ( \
  140. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_IS_EMPTY(state), \
  141. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_FROM_EMPTY, \
  142. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_TO_TUPLE \
  143. ) \
  144. (state,data) \
  145. /**/
  146. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_GET_NAME(state) \
  147. BOOST_PP_CAT \
  148. ( \
  149. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_, \
  150. BOOST_VMD_DETAIL_SEQUENCE_STATE_OUTTYPE(state) \
  151. ) \
  152. /**/
  153. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_PROCESS(d,name,state,data) \
  154. name(d,state,data) \
  155. /**/
  156. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_GET_DATA(d,state,tuple) \
  157. BOOST_VMD_IDENTITY_RESULT \
  158. ( \
  159. BOOST_PP_IIF \
  160. ( \
  161. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_NO_RETURN \
  162. ( \
  163. d, \
  164. BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM(state) \
  165. ), \
  166. BOOST_PP_TUPLE_ELEM, \
  167. BOOST_VMD_IDENTITY(tuple) \
  168. ) \
  169. (1,tuple) \
  170. ) \
  171. /**/
  172. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD(d,state,ttuple) \
  173. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_PROCESS \
  174. ( \
  175. d, \
  176. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_GET_NAME(state), \
  177. state, \
  178. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD_GET_DATA(d,state,ttuple) \
  179. ) \
  180. /**/
  181. #define BOOST_VMD_DETAIL_SEQUENCE_PROCESSING_ELEM_CHECK(d,state) \
  182. BOOST_PP_EQUAL_D \
  183. ( \
  184. d, \
  185. BOOST_PP_SEQ_SIZE(BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state)), \
  186. BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state) \
  187. ) \
  188. /**/
  189. #define BOOST_VMD_DETAIL_SEQUENCE_PROCESSING_ELEM(d,state) \
  190. BOOST_VMD_IDENTITY_RESULT \
  191. ( \
  192. BOOST_PP_IIF \
  193. ( \
  194. BOOST_VMD_IS_EMPTY(BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state)), \
  195. BOOST_VMD_IDENTITY(0), \
  196. BOOST_VMD_DETAIL_SEQUENCE_PROCESSING_ELEM_CHECK \
  197. ) \
  198. (d,state) \
  199. ) \
  200. /**/
  201. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_GET_TYPE(state) \
  202. BOOST_PP_TUPLE_ELEM \
  203. ( \
  204. 0, \
  205. BOOST_PP_TUPLE_ELEM(BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX(state),BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES(state)) \
  206. ) \
  207. /**/
  208. #define BOOST_VMD_DETAIL_SEQUENCE_STATE_GET_TYPE_REENTRANT(state) \
  209. BOOST_PP_TUPLE_ELEM \
  210. ( \
  211. 1, \
  212. BOOST_PP_TUPLE_ELEM(BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX(state),BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES(state)) \
  213. ) \
  214. /**/
  215. #define BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_UNKNOWN(d,state) \
  216. ( \
  217. , \
  218. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD(d,state,(BOOST_VMD_TYPE_UNKNOWN,BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state))), \
  219. BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state), \
  220. BOOST_VMD_DETAIL_SEQUENCE_STATE_OUTTYPE(state), \
  221. BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM(state), \
  222. BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES(state), \
  223. BOOST_PP_INC(BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX(state)) \
  224. ) \
  225. /**/
  226. #define BOOST_VMD_DETAIL_SEQUENCE_GET_FULL_TYPE_CHECK_ID(d,type,id) \
  227. BOOST_VMD_IDENTITY_RESULT \
  228. ( \
  229. BOOST_PP_IIF \
  230. ( \
  231. BOOST_VMD_DETAIL_EQUAL_TYPE_D(d,type,BOOST_VMD_TYPE_IDENTIFIER), \
  232. BOOST_VMD_DETAIL_IDENTIFIER_TYPE_D, \
  233. BOOST_VMD_IDENTITY(type) \
  234. ) \
  235. (d,id) \
  236. ) \
  237. /**/
  238. #define BOOST_VMD_DETAIL_SEQUENCE_GET_FULL_TYPE(d,state,tuple) \
  239. BOOST_VMD_DETAIL_SEQUENCE_GET_FULL_TYPE_CHECK_ID \
  240. ( \
  241. d, \
  242. BOOST_PP_CAT \
  243. ( \
  244. BOOST_VMD_TYPE_, \
  245. BOOST_VMD_DETAIL_SEQUENCE_STATE_GET_TYPE(state) \
  246. ), \
  247. BOOST_PP_TUPLE_ELEM(0,tuple) \
  248. ) \
  249. /**/
  250. #define BOOST_VMD_DETAIL_SEQUENCE_TYPE_FOUND_PROCESS(d,state,tuple) \
  251. ( \
  252. BOOST_PP_TUPLE_ELEM(1,tuple), \
  253. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD \
  254. ( \
  255. d, \
  256. state, \
  257. ( \
  258. BOOST_VMD_DETAIL_SEQUENCE_GET_FULL_TYPE(d,state,tuple), \
  259. BOOST_PP_TUPLE_ELEM(0,tuple) \
  260. ) \
  261. ), \
  262. BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state), \
  263. BOOST_VMD_DETAIL_SEQUENCE_STATE_OUTTYPE(state), \
  264. BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM(state), \
  265. BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES(state), \
  266. BOOST_PP_INC(BOOST_PP_TUPLE_SIZE(BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES(state))) \
  267. ) \
  268. /**/
  269. #define BOOST_VMD_DETAIL_SEQUENCE_TYPE_FOUND_SEQ_SINGLE(d,tuple) \
  270. BOOST_PP_EQUAL_D(d,BOOST_PP_SEQ_SIZE(BOOST_PP_TUPLE_ELEM(0,tuple)),1) \
  271. /**/
  272. #define BOOST_VMD_DETAIL_SEQUENCE_TYPE_FOUND_SEQ(d,state,tuple) \
  273. BOOST_VMD_IDENTITY_RESULT \
  274. ( \
  275. BOOST_PP_IIF \
  276. ( \
  277. BOOST_VMD_DETAIL_EQUAL_TYPE_D \
  278. ( \
  279. d, \
  280. BOOST_VMD_DETAIL_SEQUENCE_GET_FULL_TYPE(d,state,tuple), \
  281. BOOST_VMD_TYPE_SEQ \
  282. ), \
  283. BOOST_VMD_DETAIL_SEQUENCE_TYPE_FOUND_SEQ_SINGLE, \
  284. BOOST_VMD_IDENTITY(0) \
  285. ) \
  286. (d,tuple) \
  287. ) \
  288. /**/
  289. #define BOOST_VMD_DETAIL_SEQUENCE_TYPE_FOUND(d,state,tuple) \
  290. BOOST_PP_IIF \
  291. ( \
  292. BOOST_VMD_DETAIL_SEQUENCE_TYPE_FOUND_SEQ(d,state,tuple), \
  293. BOOST_VMD_DETAIL_SEQUENCE_INCREMENT_INDEX, \
  294. BOOST_VMD_DETAIL_SEQUENCE_TYPE_FOUND_PROCESS \
  295. ) \
  296. (d,state,tuple) \
  297. /**/
  298. #define BOOST_VMD_DETAIL_SEQUENCE_INCREMENT_INDEX(d,state,tuple) \
  299. BOOST_PP_TUPLE_REPLACE_D(d,state,BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX_ELEM,BOOST_PP_INC(BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX(state))) \
  300. /**/
  301. #define BOOST_VMD_DETAIL_SEQUENCE_TEST_TYPE_TUPLE(d,state,tuple) \
  302. BOOST_PP_IIF \
  303. ( \
  304. BOOST_VMD_IS_EMPTY \
  305. ( \
  306. BOOST_PP_TUPLE_ELEM(0,tuple) \
  307. ), \
  308. BOOST_VMD_DETAIL_SEQUENCE_INCREMENT_INDEX, \
  309. BOOST_VMD_DETAIL_SEQUENCE_TYPE_FOUND \
  310. ) \
  311. (d,state,tuple) \
  312. /**/
  313. #define BOOST_VMD_DETAIL_SEQUENCE_TEST_TYPE(d,call,state) \
  314. BOOST_VMD_DETAIL_SEQUENCE_TEST_TYPE_TUPLE \
  315. ( \
  316. d, \
  317. state, \
  318. call(BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state),BOOST_VMD_RETURN_AFTER) \
  319. ) \
  320. /**/
  321. #define BOOST_VMD_DETAIL_SEQUENCE_TEST_TYPE_D(d,call,state) \
  322. BOOST_VMD_DETAIL_SEQUENCE_TEST_TYPE_TUPLE \
  323. ( \
  324. d, \
  325. state, \
  326. call(d,BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state),BOOST_VMD_RETURN_AFTER) \
  327. ) \
  328. /**/
  329. #define BOOST_VMD_DETAIL_SEQUENCE_GCLRT(state) \
  330. BOOST_PP_CAT \
  331. ( \
  332. BOOST_VMD_DETAIL_, \
  333. BOOST_PP_CAT(BOOST_VMD_DETAIL_SEQUENCE_STATE_GET_TYPE(state),_D) \
  334. ) \
  335. /**/
  336. #define BOOST_VMD_DETAIL_SEQUENCE_GCLPL(state) \
  337. BOOST_PP_CAT \
  338. ( \
  339. BOOST_VMD_DETAIL_, \
  340. BOOST_VMD_DETAIL_SEQUENCE_STATE_GET_TYPE(state) \
  341. ) \
  342. /**/
  343. #define BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_TEST_GCL(state,rflag) \
  344. BOOST_PP_IIF \
  345. ( \
  346. rflag, \
  347. BOOST_VMD_DETAIL_SEQUENCE_GCLRT, \
  348. BOOST_VMD_DETAIL_SEQUENCE_GCLPL \
  349. ) \
  350. (state) \
  351. /**/
  352. #define BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_TEST_RT_CALL(d,call,state,rflag) \
  353. BOOST_PP_IIF \
  354. ( \
  355. rflag, \
  356. BOOST_VMD_DETAIL_SEQUENCE_TEST_TYPE_D, \
  357. BOOST_VMD_DETAIL_SEQUENCE_TEST_TYPE \
  358. ) \
  359. (d,call,state) \
  360. /**/
  361. #define BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_TEST_RT(d,state,rflag) \
  362. BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_TEST_RT_CALL \
  363. ( \
  364. d, \
  365. BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_TEST_GCL(state,rflag), \
  366. state, \
  367. rflag \
  368. ) \
  369. /**/
  370. #define BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_TEST(d,state) \
  371. BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_TEST_RT \
  372. ( \
  373. d, \
  374. state, \
  375. BOOST_VMD_DETAIL_SEQUENCE_STATE_GET_TYPE_REENTRANT(state) \
  376. ) \
  377. /**/
  378. #define BOOST_VMD_DETAIL_SEQUENCE_INNER_OP(d,state) \
  379. BOOST_PP_IIF \
  380. ( \
  381. BOOST_PP_EQUAL_D \
  382. ( \
  383. d, \
  384. BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX(state), \
  385. BOOST_PP_TUPLE_SIZE(BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES(state)) \
  386. ), \
  387. BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_UNKNOWN, \
  388. BOOST_VMD_DETAIL_SEQUENCE_INNER_OP_TEST \
  389. ) \
  390. (d,state) \
  391. /**/
  392. #define BOOST_VMD_DETAIL_SEQUENCE_INNER_PRED(d,state) \
  393. BOOST_PP_NOT_EQUAL_D \
  394. ( \
  395. d, \
  396. BOOST_VMD_DETAIL_SEQUENCE_STATE_INDEX(state), \
  397. BOOST_PP_INC(BOOST_PP_TUPLE_SIZE(BOOST_VMD_DETAIL_SEQUENCE_STATE_TYPES(state))) \
  398. ) \
  399. /**/
  400. #define BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN_TUPLE_TYPES_ELEM_FROM(d,from) \
  401. BOOST_PP_IIF \
  402. ( \
  403. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_GENERAL_RETURN(d,from), \
  404. ((SEQ,1),(TUPLE,1)), \
  405. BOOST_PP_IIF \
  406. ( \
  407. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_EXACT_RETURN(d,from), \
  408. ((SEQ,1),(LIST,1),(ARRAY,1),(TUPLE,1)), \
  409. BOOST_PP_IIF \
  410. ( \
  411. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_ARRAY_RETURN(d,from), \
  412. ((SEQ,1),(ARRAY,1),(TUPLE,1)), \
  413. BOOST_PP_IIF \
  414. ( \
  415. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_LIST_RETURN(d,from), \
  416. ((SEQ,1),(LIST,1),(TUPLE,1)), \
  417. ((SEQ,1),(TUPLE,1)) \
  418. ) \
  419. ) \
  420. ) \
  421. ) \
  422. /**/
  423. #define BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN_TUPLE_TYPES_ELEM(d,state) \
  424. BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN_TUPLE_TYPES_ELEM_FROM \
  425. ( \
  426. d, \
  427. BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM(state) \
  428. ) \
  429. /**/
  430. #define BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN_TUPLE_TYPES_ANY(d,state) \
  431. BOOST_VMD_IDENTITY_RESULT \
  432. ( \
  433. BOOST_PP_IIF \
  434. ( \
  435. BOOST_VMD_IS_EMPTY \
  436. ( \
  437. BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state) \
  438. ), \
  439. BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN_TUPLE_TYPES_ELEM, \
  440. BOOST_VMD_IDENTITY(((SEQ,1),(TUPLE,1))) \
  441. ) \
  442. (d,state) \
  443. ) \
  444. /**/
  445. #define BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN_TUPLE_TYPES(d,state) \
  446. BOOST_PP_IIF \
  447. ( \
  448. BOOST_VMD_DETAIL_SEQUENCE_PROCESSING_ELEM(d,state), \
  449. BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN_TUPLE_TYPES_ELEM, \
  450. BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN_TUPLE_TYPES_ANY \
  451. ) \
  452. (d,state) \
  453. /**/
  454. #define BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN(d,state) \
  455. BOOST_PP_WHILE_ ## d \
  456. ( \
  457. BOOST_VMD_DETAIL_SEQUENCE_INNER_PRED, \
  458. BOOST_VMD_DETAIL_SEQUENCE_INNER_OP, \
  459. BOOST_PP_TUPLE_PUSH_BACK \
  460. ( \
  461. BOOST_PP_TUPLE_PUSH_BACK \
  462. ( \
  463. state, \
  464. BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN_TUPLE_TYPES(d,state) \
  465. ), \
  466. 0 \
  467. ) \
  468. ) \
  469. /**/
  470. #define BOOST_VMD_DETAIL_SEQUENCE_OP_ID_LOOP(d,state) \
  471. BOOST_PP_WHILE_ ## d \
  472. ( \
  473. BOOST_VMD_DETAIL_SEQUENCE_INNER_PRED, \
  474. BOOST_VMD_DETAIL_SEQUENCE_INNER_OP, \
  475. BOOST_PP_TUPLE_PUSH_BACK(BOOST_PP_TUPLE_PUSH_BACK(state,((IDENTIFIER,1))),0) \
  476. ) \
  477. /**/
  478. #define BOOST_VMD_DETAIL_SEQUENCE_OP_ID_EL(d,state) \
  479. ( \
  480. BOOST_PP_TUPLE_ELEM(1,BOOST_VMD_DETAIL_LIST_D(d,BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state),BOOST_VMD_RETURN_AFTER)), \
  481. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT_ADD(d,state,(BOOST_VMD_TYPE_LIST,BOOST_PP_NIL)), \
  482. BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state), \
  483. BOOST_VMD_DETAIL_SEQUENCE_STATE_OUTTYPE(state), \
  484. BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM(state) \
  485. ) \
  486. /**/
  487. #define BOOST_VMD_DETAIL_SEQUENCE_OP_ID(d,state) \
  488. BOOST_PP_IIF \
  489. ( \
  490. BOOST_VMD_IS_EMPTY_LIST_D \
  491. ( \
  492. d, \
  493. BOOST_VMD_DETAIL_IDENTIFIER_D \
  494. ( \
  495. d, \
  496. BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state) \
  497. ) \
  498. ), \
  499. BOOST_VMD_DETAIL_SEQUENCE_OP_ID_EL, \
  500. BOOST_VMD_DETAIL_SEQUENCE_OP_ID_LOOP \
  501. ) \
  502. (d,state) \
  503. /**/
  504. #define BOOST_VMD_DETAIL_SEQUENCE_OP_REDUCE_STATE(state) \
  505. ( \
  506. BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state), \
  507. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state), \
  508. BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state), \
  509. BOOST_VMD_DETAIL_SEQUENCE_STATE_OUTTYPE(state), \
  510. BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM(state) \
  511. ) \
  512. /**/
  513. #define BOOST_VMD_DETAIL_SEQUENCE_OP(d,state) \
  514. BOOST_VMD_DETAIL_SEQUENCE_OP_REDUCE_STATE \
  515. ( \
  516. BOOST_PP_IIF \
  517. ( \
  518. BOOST_PP_IS_BEGIN_PARENS \
  519. ( \
  520. BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state) \
  521. ), \
  522. BOOST_VMD_DETAIL_SEQUENCE_OP_PAREN, \
  523. BOOST_VMD_DETAIL_SEQUENCE_OP_ID \
  524. ) \
  525. (d,state) \
  526. ) \
  527. /**/
  528. #define BOOST_VMD_DETAIL_SEQUENCE_PRED_CELEM_SZ(d,state) \
  529. BOOST_PP_LESS_EQUAL_D \
  530. ( \
  531. d, \
  532. BOOST_PP_SEQ_SIZE(BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state)), \
  533. BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state) \
  534. ) \
  535. /**/
  536. #define BOOST_VMD_DETAIL_SEQUENCE_PRED_CELEM(d,state) \
  537. BOOST_VMD_IDENTITY_RESULT \
  538. ( \
  539. BOOST_PP_IIF \
  540. ( \
  541. BOOST_PP_BITOR \
  542. ( \
  543. BOOST_VMD_IS_EMPTY \
  544. ( \
  545. BOOST_VMD_DETAIL_SEQUENCE_STATE_ELEM(state) \
  546. ), \
  547. BOOST_VMD_IS_EMPTY \
  548. ( \
  549. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state) \
  550. ) \
  551. ), \
  552. BOOST_VMD_IDENTITY(1), \
  553. BOOST_VMD_DETAIL_SEQUENCE_PRED_CELEM_SZ \
  554. ) \
  555. (d,state) \
  556. ) \
  557. /**/
  558. #define BOOST_VMD_DETAIL_SEQUENCE_PRED(d,state) \
  559. BOOST_VMD_IDENTITY_RESULT \
  560. ( \
  561. BOOST_PP_IIF \
  562. ( \
  563. BOOST_VMD_IS_EMPTY \
  564. ( \
  565. BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state) \
  566. ), \
  567. BOOST_VMD_IDENTITY(0), \
  568. BOOST_VMD_DETAIL_SEQUENCE_PRED_CELEM \
  569. ) \
  570. (d,state) \
  571. ) \
  572. /**/
  573. #define BOOST_VMD_DETAIL_SEQUENCE_EMPTY_TYPE_CHECK(output) \
  574. BOOST_PP_IIF \
  575. ( \
  576. BOOST_VMD_DETAIL_EQUAL_TYPE(output,BOOST_VMD_TYPE_ARRAY), \
  577. (0,()), \
  578. BOOST_PP_NIL \
  579. ) \
  580. /**/
  581. #define BOOST_VMD_DETAIL_SEQUENCE_EMPTY_TYPE_CHECK_D(d,output) \
  582. BOOST_PP_IIF \
  583. ( \
  584. BOOST_VMD_DETAIL_EQUAL_TYPE_D(d,output,BOOST_VMD_TYPE_ARRAY), \
  585. (0,()), \
  586. BOOST_PP_NIL \
  587. ) \
  588. /**/
  589. #define BOOST_VMD_DETAIL_SEQUENCE_EMPTY_TYPE(output) \
  590. BOOST_PP_IIF \
  591. ( \
  592. BOOST_PP_BITOR \
  593. ( \
  594. BOOST_VMD_DETAIL_EQUAL_TYPE(output,BOOST_VMD_TYPE_SEQ), \
  595. BOOST_VMD_DETAIL_EQUAL_TYPE(output,BOOST_VMD_TYPE_TUPLE) \
  596. ), \
  597. BOOST_VMD_EMPTY, \
  598. BOOST_VMD_DETAIL_SEQUENCE_EMPTY_TYPE_CHECK \
  599. ) \
  600. (output) \
  601. /**/
  602. #define BOOST_VMD_DETAIL_SEQUENCE_EMPTY_TYPE_D(d,output) \
  603. BOOST_PP_IIF \
  604. ( \
  605. BOOST_PP_BITOR \
  606. ( \
  607. BOOST_VMD_DETAIL_EQUAL_TYPE_D(d,output,BOOST_VMD_TYPE_SEQ), \
  608. BOOST_VMD_DETAIL_EQUAL_TYPE_D(d,output,BOOST_VMD_TYPE_TUPLE) \
  609. ), \
  610. BOOST_VMD_EMPTY, \
  611. BOOST_VMD_DETAIL_SEQUENCE_EMPTY_TYPE_CHECK_D \
  612. ) \
  613. (d,output) \
  614. /**/
  615. #define BOOST_VMD_DETAIL_SEQUENCE_ELEM_PROCESS_TUPLE_GET(state) \
  616. BOOST_PP_IIF \
  617. ( \
  618. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_AFTER \
  619. ( \
  620. BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM(state) \
  621. ), \
  622. ( \
  623. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state), \
  624. BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state) \
  625. ), \
  626. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state) \
  627. )
  628. /**/
  629. #define BOOST_VMD_DETAIL_SEQUENCE_ELEM_PROCESS_TUPLE_GET_D(d,state) \
  630. BOOST_PP_IIF \
  631. ( \
  632. BOOST_VMD_DETAIL_SEQUENCE_STATE_IS_AFTER_D \
  633. ( \
  634. d, \
  635. BOOST_VMD_DETAIL_SEQUENCE_STATE_FROM(state) \
  636. ), \
  637. ( \
  638. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state), \
  639. BOOST_VMD_DETAIL_SEQUENCE_STATE_INPUT(state) \
  640. ), \
  641. BOOST_VMD_DETAIL_SEQUENCE_STATE_RESULT(state) \
  642. )
  643. /**/
  644. #define BOOST_VMD_DETAIL_SEQUENCE_ELEM_PROCESS_TUPLE(vseq,elem,output,from) \
  645. BOOST_VMD_DETAIL_SEQUENCE_ELEM_PROCESS_TUPLE_GET \
  646. ( \
  647. BOOST_PP_WHILE \
  648. ( \
  649. BOOST_VMD_DETAIL_SEQUENCE_PRED, \
  650. BOOST_VMD_DETAIL_SEQUENCE_OP, \
  651. ( \
  652. vseq, \
  653. BOOST_VMD_DETAIL_SEQUENCE_EMPTY_TYPE \
  654. ( \
  655. output \
  656. ), \
  657. elem, \
  658. output, \
  659. from \
  660. ) \
  661. ) \
  662. ) \
  663. /**/
  664. #define BOOST_VMD_DETAIL_SEQUENCE_ELEM_PROCESS_TUPLE_D(d,vseq,elem,output,from) \
  665. BOOST_VMD_DETAIL_SEQUENCE_ELEM_PROCESS_TUPLE_GET_D \
  666. ( \
  667. d, \
  668. BOOST_PP_WHILE_ ## d \
  669. ( \
  670. BOOST_VMD_DETAIL_SEQUENCE_PRED, \
  671. BOOST_VMD_DETAIL_SEQUENCE_OP, \
  672. ( \
  673. vseq, \
  674. BOOST_VMD_DETAIL_SEQUENCE_EMPTY_TYPE_D \
  675. ( \
  676. d, \
  677. output \
  678. ), \
  679. elem, \
  680. output, \
  681. from \
  682. ) \
  683. ) \
  684. ) \
  685. /**/
  686. #endif /* BOOST_VMD_DETAIL_SEQUENCE_COMMON_HPP */