[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
C++: issue a better CPP guard and Doxygen file command
From: |
Akim Demaille |
Subject: |
C++: issue a better CPP guard and Doxygen file command |
Date: |
Tue, 9 Oct 2018 19:11:29 +0200 |
commit b8351d06f1fd37abfc1a84d165c09a7b9a794695
Author: Akim Demaille <address@hidden>
Date: Tue Oct 9 18:58:50 2018 +0200
C++: issue a better CPP guard and Doxygen file command
Currently we use "<dir><api.location.file>" as \file argument, and as
base for the CPP guard. This is not nice when <dir> is absolute, in
which case it is expected that the user will use api.location.include
to get something nicer. If defined, use that name instead.
* data/location.cc (b4_location_path): New.
Use it.
* tests/c++.at (Shared locations): Check the guard and Doxygen doc.
diff --git a/data/location.cc b/data/location.cc
index 44a1f5ab..1b46055c 100644
--- a/data/location.cc
+++ b/data/location.cc
@@ -37,12 +37,27 @@ b4_percent_define_ifdef([[api.position.file]],
b4_percent_define_check_file([b4_location_file],
[[api.location.file]],
b4_defines_if([[location.hh]]))
+
+# b4_location_include
+# -------------------
# If location.hh is to be generated, the name under which should it be
# included.
+#
+# b4_location_path
+# ----------------
+# The path to use for the CPP guard.
m4_ifdef([b4_location_file],
- [m4_define([b4_location_include],
- [b4_percent_define_get([[api.location.include]],
- ["b4_location_file"])])])
+[m4_define([b4_location_include],
+ [b4_percent_define_get([[api.location.include]],
+ ["b4_location_file"])])
+ m4_define([b4_location_path],
+ b4_percent_define_get([[api.location.include]],
+ ["b4_dir_prefix[]b4_location_file"]))
+ m4_define([b4_location_path],
+ m4_substr(m4_defn([b4_location_path]), 1,
m4_eval(m4_len(m4_defn([b4_location_path])) - 2)))
+ ])
+
+
# b4_location_define
# ------------------
@@ -331,11 +346,11 @@ m4_ifdef([b4_location_file], [[
]b4_copyright([Locations for Bison parsers in C++])[
/**
- ** \file ]b4_dir_prefix[]b4_location_file[
+ ** \file ]b4_location_path[
** Define the ]b4_namespace_ref[::location class.
*/
-]b4_cpp_guard_open([b4_dir_prefix[]b4_location_file])[
+]b4_cpp_guard_open([b4_location_path])[
# include <algorithm> // std::max
# include <iostream>
@@ -346,7 +361,7 @@ m4_ifdef([b4_location_file], [[
]b4_namespace_open[
]b4_location_define[
]b4_namespace_close[
-]b4_cpp_guard_close([b4_dir_prefix[]b4_location_file])[
+]b4_cpp_guard_close([b4_location_path])[
]b4_output_end[
]])
diff --git a/tests/c++.at b/tests/c++.at
index 2b354c2d..33fbd52e 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -1324,6 +1324,8 @@ AT_FOR_EACH_CXX([AT_COMPILE_CXX([[input]])])
AT_CLEANUP
+
+
## ------------------ ##
## Shared locations. ##
## ------------------ ##
@@ -1368,6 +1370,15 @@ AT_TEST([x1],
%define api.location.file "include/ast/loc.hh"
%define api.location.include {<ast/loc.hh>}])
+# Check the CPP guard and Doxyen comments.
+AT_CHECK([sed -ne '/INCLUDED/p;/\\file/{p;n;p;}' include/ast/loc.hh], [],
+[[ ** \file ast/loc.hh
+ ** Define the x1::location class.
+#ifndef YY_YY_AST_LOC_HH_INCLUDED
+# define YY_YY_AST_LOC_HH_INCLUDED
+#endif // !YY_YY_AST_LOC_HH_INCLUDED
+]])
+
AT_TEST([x2],
[%defines
%locations
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- C++: issue a better CPP guard and Doxygen file command,
Akim Demaille <=