mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 18:53:04 +00:00
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.
This commit is contained in:
@@ -37,12 +37,27 @@ b4_percent_define_ifdef([[api.position.file]],
|
|||||||
b4_percent_define_check_file([b4_location_file],
|
b4_percent_define_check_file([b4_location_file],
|
||||||
[[api.location.file]],
|
[[api.location.file]],
|
||||||
b4_defines_if([[location.hh]]))
|
b4_defines_if([[location.hh]]))
|
||||||
|
|
||||||
|
# b4_location_include
|
||||||
|
# -------------------
|
||||||
# If location.hh is to be generated, the name under which should it be
|
# If location.hh is to be generated, the name under which should it be
|
||||||
# included.
|
# included.
|
||||||
|
#
|
||||||
|
# b4_location_path
|
||||||
|
# ----------------
|
||||||
|
# The path to use for the CPP guard.
|
||||||
m4_ifdef([b4_location_file],
|
m4_ifdef([b4_location_file],
|
||||||
[m4_define([b4_location_include],
|
[m4_define([b4_location_include],
|
||||||
[b4_percent_define_get([[api.location.include]],
|
[b4_percent_define_get([[api.location.include]],
|
||||||
["b4_location_file"])])])
|
["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
|
# b4_location_define
|
||||||
# ------------------
|
# ------------------
|
||||||
@@ -331,11 +346,11 @@ m4_ifdef([b4_location_file], [[
|
|||||||
]b4_copyright([Locations for Bison parsers in C++])[
|
]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.
|
** 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 <algorithm> // std::max
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
@@ -346,7 +361,7 @@ m4_ifdef([b4_location_file], [[
|
|||||||
]b4_namespace_open[
|
]b4_namespace_open[
|
||||||
]b4_location_define[
|
]b4_location_define[
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
]b4_cpp_guard_close([b4_dir_prefix[]b4_location_file])[
|
]b4_cpp_guard_close([b4_location_path])[
|
||||||
]b4_output_end[
|
]b4_output_end[
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
|||||||
11
tests/c++.at
11
tests/c++.at
@@ -1324,6 +1324,8 @@ AT_FOR_EACH_CXX([AT_COMPILE_CXX([[input]])])
|
|||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ------------------ ##
|
## ------------------ ##
|
||||||
## Shared locations. ##
|
## Shared locations. ##
|
||||||
## ------------------ ##
|
## ------------------ ##
|
||||||
@@ -1368,6 +1370,15 @@ AT_TEST([x1],
|
|||||||
%define api.location.file "include/ast/loc.hh"
|
%define api.location.file "include/ast/loc.hh"
|
||||||
%define api.location.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],
|
AT_TEST([x2],
|
||||||
[%defines
|
[%defines
|
||||||
%locations
|
%locations
|
||||||
|
|||||||
Reference in New Issue
Block a user