texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Patrice Dumas
Date: Thu, 14 Nov 2024 16:50:19 -0500 (EST)

branch: master
commit 21235b9b1a21ff684561f30bbe4a5de6f37f8a8d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Nov 14 22:35:09 2024 +0100

    * tp/Texinfo/XS/XSParagraph.xs (xspara_new), tp/Texinfo/XS/xspara.c
    (xspara_SET_CONF), tp/Texinfo/XS/xspara.h
    (XSPARA_CONF_VARIABLES_LIST): setup a list of XSParagraph
    configuration variables, XSPARA_CONF_VARIABLES_LIST applied to
    xspara_SET_CONF such that xspara_SET_CONF can be redefined in
    different codes to generate code for all the configuration variables.
    Use XSPARA_CONF_VARIABLES_LIST in xspara.c and XSParagraph.xs.
---
 ChangeLog                    | 10 ++++++++++
 tp/Texinfo/XS/XSParagraph.xs | 20 +++-----------------
 tp/Texinfo/XS/xspara.c       | 22 ++++------------------
 tp/Texinfo/XS/xspara.h       | 44 +++++++++++++++++++++++++-------------------
 4 files changed, 42 insertions(+), 54 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f1b02431f9..6a1c3441d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,16 @@
        in the sources which can cause problems on some unusual platforms.
        Report from Eli.
 
+2024-11-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/XSParagraph.xs (xspara_new), tp/Texinfo/XS/xspara.c
+       (xspara_SET_CONF), tp/Texinfo/XS/xspara.h
+       (XSPARA_CONF_VARIABLES_LIST): setup a list of XSParagraph
+       configuration variables, XSPARA_CONF_VARIABLES_LIST applied to
+       xspara_SET_CONF such that xspara_SET_CONF can be redefined in
+       different codes to generate code for all the configuration variables.
+       Use XSPARA_CONF_VARIABLES_LIST in xspara.c and XSParagraph.xs.
+
 2024-11-14  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/XSParagraph.xs (xspara_new), tp/Texinfo/XS/xspara.c
diff --git a/tp/Texinfo/XS/XSParagraph.xs b/tp/Texinfo/XS/XSParagraph.xs
index ea66c61b57..5a37cb9232 100644
--- a/tp/Texinfo/XS/XSParagraph.xs
+++ b/tp/Texinfo/XS/XSParagraph.xs
@@ -38,7 +38,7 @@ xspara_new (class, ...)
         int id;
         SV **val;
 #define FETCH(key) hv_fetch (conf, key, strlen (key), 0)
-#define FETCH_INT(variable) { val = FETCH(#variable); \
+#define xspara_SET_CONF(variable) { val = FETCH(#variable); \
                 if (val) { xspara_set_conf_##variable (SvIV (*val)); } }
     CODE:
         items--;
@@ -51,21 +51,7 @@ xspara_new (class, ...)
 
         if (conf)
           {
-            FETCH_INT(end_sentence)
-            FETCH_INT(max)
-            FETCH_INT(indent_length)
-            FETCH_INT(indent_length_next)
-            FETCH_INT(counter)
-            FETCH_INT(word_counter)
-            FETCH_INT(lines_counter)
-            FETCH_INT(end_line_count)
-            FETCH_INT(no_break)
-            FETCH_INT(ignore_columns)
-            FETCH_INT(keep_end_lines)
-            FETCH_INT(frenchspacing)
-            FETCH_INT(unfilled)
-            FETCH_INT(no_final_newline)
-            FETCH_INT(add_final_space)
+            XSPARA_CONF_VARIABLES_LIST 
           }
 
         /* Create an integer, which the other functions
@@ -74,8 +60,8 @@ xspara_new (class, ...)
     OUTPUT:
         RETVAL
     CLEANUP:
+#undef xspara_SET_CONF
 #undef FETCH
-#undef FETCH_INT
 
 
 int
diff --git a/tp/Texinfo/XS/xspara.c b/tp/Texinfo/XS/xspara.c
index 6041311dcb..318cbfd183 100644
--- a/tp/Texinfo/XS/xspara.c
+++ b/tp/Texinfo/XS/xspara.c
@@ -202,28 +202,14 @@ xspara_set_state (int paragraph)
 /* set a function to set the state for each of the possible configuration
    variables */
 
-#define SET_CONF(variable) \
+#define xspara_SET_CONF(variable) \
 void xspara_set_conf_##variable (int variable) { \
   state.variable = variable; \
 }
 
-SET_CONF(end_sentence)
-SET_CONF(max)
-SET_CONF(indent_length)
-SET_CONF(indent_length_next)
-SET_CONF(counter)
-SET_CONF(word_counter)
-SET_CONF(lines_counter)
-SET_CONF(end_line_count)
-SET_CONF(no_break)
-SET_CONF(ignore_columns)
-SET_CONF(keep_end_lines)
-SET_CONF(frenchspacing)
-SET_CONF(unfilled)
-SET_CONF(no_final_newline)
-SET_CONF(add_final_space)
-
-#undef SET_CONF
+XSPARA_CONF_VARIABLES_LIST
+
+#undef xspara_SET_CONF
 
 /************************************************************************/
 
diff --git a/tp/Texinfo/XS/xspara.h b/tp/Texinfo/XS/xspara.h
index 5e06ea40bb..2a1f370745 100644
--- a/tp/Texinfo/XS/xspara.h
+++ b/tp/Texinfo/XS/xspara.h
@@ -19,28 +19,34 @@
 
 #include "main/text.h"
 
-int xspara_new (void);
+/* list of XSParagraph configuration variables, to be reused in code
+   generation */
+#define XSPARA_CONF_VARIABLES_LIST \
+  xspara_SET_CONF(end_sentence) \
+  xspara_SET_CONF(max) \
+  xspara_SET_CONF(indent_length) \
+  xspara_SET_CONF(indent_length_next) \
+  xspara_SET_CONF(counter) \
+  xspara_SET_CONF(word_counter) \
+  xspara_SET_CONF(lines_counter) \
+  xspara_SET_CONF(end_line_count) \
+  xspara_SET_CONF(no_break) \
+  xspara_SET_CONF(ignore_columns) \
+  xspara_SET_CONF(keep_end_lines) \
+  xspara_SET_CONF(frenchspacing) \
+  xspara_SET_CONF(unfilled) \
+  xspara_SET_CONF(no_final_newline) \
+  xspara_SET_CONF(add_final_space) \
+
 
-#define SET_CONF(variable) \
+#define xspara_SET_CONF(variable) \
 void xspara_set_conf_##variable (int variable);
 
-SET_CONF(end_sentence)
-SET_CONF(max)
-SET_CONF(indent_length)
-SET_CONF(indent_length_next)
-SET_CONF(counter)
-SET_CONF(word_counter)
-SET_CONF(lines_counter)
-SET_CONF(end_line_count)
-SET_CONF(no_break)
-SET_CONF(ignore_columns)
-SET_CONF(keep_end_lines)
-SET_CONF(frenchspacing)
-SET_CONF(unfilled)
-SET_CONF(no_final_newline)
-SET_CONF(add_final_space)
-
-#undef SET_CONF
+ XSPARA_CONF_VARIABLES_LIST
+
+#undef xspara_SET_CONF
+
+int xspara_new (void);
 
 void xspara_set_state (int paragraph);
 TEXT xspara_add_next (char *, int, int transparent);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]