Fast IFS using RPN notation
python
c
x86-64
nasm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rpn_if_default.h 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2020 Weber Yann
  3. *
  4. * This file is part of pyrpn.
  5. *
  6. * pyrpn is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * pyrpn is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with pyrpn. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __rpn_if_default__h__
  20. #define __rpn_if_default__h__
  21. /**@file rpn_if_default.h Defines default IF
  22. * @ingroup ifs_if_default
  23. * @brief Default IF definitions
  24. */
  25. /**@defgroup ifs_if_default Default functions
  26. * @ingroup ifs_if
  27. * @brief Simple iterated functions functions
  28. *
  29. * Defines default @ref rpn_if_param_s.res_f and @ref rpn_if_param_s.arg_f
  30. * functions.
  31. */
  32. #include "config.h"
  33. #include "rpn_if.h"
  34. #define RPN_IF_POSITION_LINEAR 0 // One expr for position
  35. #define RPN_IF_POSITION_XY 1 // two expr for poisition
  36. #define RPN_IF_POSITION_XDIM 2 // X expr for position
  37. #define RPN_IF_POSITION_OF_LOOP 0 // Loop on position overflow
  38. #define RPN_IF_POSITION_OF_ERR 16 // Trigger error on position overflow
  39. #define RPN_IF_RES_BOOL 0 // Set to one when position occurs
  40. #define RPN_IF_RES_CONST 1 // Set to a constant value
  41. #define RPN_IF_RES_CONST_RGBA 2 // Set to a constant RGB using alpha channel
  42. #define RPN_IF_RES_COUNT 3 // Count number of time position occurs
  43. #define RPN_IF_RES_XFUN 4 // Set to result of rpn_expr
  44. #define RPN_IF_RES_RGB 5 // Set result to RGB color from rpn_expr
  45. #define RPN_IF_RES_RGBA 6 // Set result to RGB using alpha channel from rpn_expr
  46. typedef struct rpn_if_default_data_s rpn_if_default_data_t;
  47. /**@brief Stores default IF data
  48. *
  49. * Stores flags and size limit
  50. */
  51. struct rpn_if_default_data_s
  52. {
  53. short pos_flag;
  54. short res_flag;
  55. /**@brief Stores size limits given pos_flag
  56. *
  57. * @note If NULL no limit
  58. * - For @ref RPN_IF_POSITION_LINEAR size_lim is a single size_t
  59. * - For @ref RPN_IF_POSITION_XY size_lim is two size_t (height and width)
  60. * - For @ref RPN_IF_POSITION_XDIM *size_lim is the size of size_lim
  61. */
  62. size_t *size_lim;
  63. /**@brief Store constant values to set mem giver res_flag
  64. * - For @ref RPN_IF_RES_CONST_RGBA const_val points on a single value
  65. * - For @ref RPN_IF_RES_CONST_RGBA const_val points on 4 values
  66. */
  67. rpn_value_t *const_val;
  68. };
  69. int rpn_if_argf_default(rpn_if_t *rif, size_t pos, rpn_value_t *args);
  70. int rpn_if_resf_default(rpn_if_t *rif, size_t *pos, rpn_value_t *data);
  71. /**@brief Set the first expression argument from position
  72. * @param rif Expressions
  73. * @param pos Memory map offset
  74. * @param args pointer on expressions arguments
  75. * @note Other arguments are set using the generic @ref rpn_if_argf_default
  76. * function
  77. */
  78. int rpn_if_argf_linear(rpn_if_t *rif, size_t pos, rpn_value_t *args);
  79. /**@brief Transform 1st expression result to position
  80. * @param rif Expressions
  81. * @param pos Pointer on resulting position in memory map
  82. * @param data Pointer on resulting data
  83. * @note Data from position fecth is done by generic @ref rpn_if_resf_default
  84. * function
  85. */
  86. int rpn_if_resf_linear(rpn_if_t *rif, size_t *pos, rpn_value_t *data);
  87. /**@brief Set the 1st & 2nd argument from position
  88. * @param rif Expressions
  89. * @param pos Memory map offset
  90. * @param args pointer on expression arguments
  91. * @note Other arguments are set using the generic @ref rpn_if_argf_default
  92. * function
  93. */
  94. int rpn_if_argf_xy(rpn_if_t *rif, size_t pos, rpn_value_t *args);
  95. /**@brief Transform 1st and 2nd result into a memory map's offset
  96. * @param rif Expressions
  97. * @param pos Memory map offset pointer
  98. * @param data Pointer on resulting data
  99. * @note Data from position fetch is done by generic @ref rpn_if_resf_default
  100. * function
  101. */
  102. int rpn_if_resf_xy(rpn_if_t *rif, size_t *pos, rpn_value_t *data);
  103. /**@brief Set X first arguments from position
  104. * @param rif Expressions
  105. * @param pos Memory map offset
  106. * @param args Pointer on expression arguments
  107. * @note Other arguments are set using the generic @ref rpn_if_argf_default
  108. * function
  109. */
  110. int rpn_if_argf_xdim(rpn_if_t *rif, size_t pos, rpn_value_t *args);
  111. /**@brief Transform X arguments into a memory map's offset
  112. * @param rif Expressions
  113. * @param pos Memory map offset pointer
  114. * @param data Pointer on resulting data
  115. * @note Data from position fetch is done by generic @ref rpn_if_resf_default
  116. * function
  117. */
  118. int rpn_if_resf_xdim(rpn_if_t *rif, size_t *pos, rpn_value_t *data);
  119. #endif