mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-01 05:44:37 +02:00
Merge pull request #21 from Bagira80/additions_to_fix_for_issue11224
Addition to fix / workaround for issue #11224.
This commit is contained in:
@@ -2,14 +2,19 @@ Pre-processing of MPL-containers
|
|||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
Pre-processing of MPL-containers can be accomplished using the script
|
Pre-processing of MPL-containers can be accomplished using the script
|
||||||
"boost_mpl_preprocess.py". In the simplest case call it with a single
|
"boost_mpl_preprocess.py". In the simple case call it with a single
|
||||||
argument which is the path to the source-directory of Boost.
|
argument which is the path to the source-directory of Boost.
|
||||||
|
|
||||||
python boost_mpl_preprocess.py <path-to-boost-sourcedir>
|
python boost_mpl_preprocess.py <path-to-boost-sourcedir>
|
||||||
|
|
||||||
This will pre-process all four MPL-container types (vector, list, set,
|
If the Boost source-directory is the one this script resides in, you
|
||||||
map) and makes them able to hold up to 100 elements. They can be used
|
can just call it without any arguments.
|
||||||
either in their 'numbered' or their 'variadic' form.
|
|
||||||
|
python boost_mpl_preprocess.py
|
||||||
|
|
||||||
|
Either way, this will pre-process all four MPL-container types (vector,
|
||||||
|
list, set, map) and makes them able to hold up to 100 elements. They can
|
||||||
|
be used either in their 'numbered' or their 'variadic' form.
|
||||||
|
|
||||||
Additionally, the script also allows more fine-grained pre-processing.
|
Additionally, the script also allows more fine-grained pre-processing.
|
||||||
The maximal number of elements an MPL-container type is able to hold can
|
The maximal number of elements an MPL-container type is able to hold can
|
||||||
@@ -31,8 +36,8 @@ input source-files prior to pre-processing (by implicitly calling script
|
|||||||
"fix_boost_mpl_preprocess.py" with the chosen settings). It only patches
|
"fix_boost_mpl_preprocess.py" with the chosen settings). It only patches
|
||||||
the source-files needed for pre-processing the selected MPL-container
|
the source-files needed for pre-processing the selected MPL-container
|
||||||
types and their selected form ('numbered' or 'variadic').
|
types and their selected form ('numbered' or 'variadic').
|
||||||
If calling it with a single argument (as in the former section) all input
|
If calling it with a single (or no) argument (as in the former section)
|
||||||
source-files will be patched automatically.
|
all input source-files will be patched automatically.
|
||||||
|
|
||||||
Instead of fixing the input-files implicitly during pre-processing one
|
Instead of fixing the input-files implicitly during pre-processing one
|
||||||
can also fix them explicitly by calling "fix_boost_mpl_preprocess.py"
|
can also fix them explicitly by calling "fix_boost_mpl_preprocess.py"
|
||||||
|
@@ -72,6 +72,21 @@ def adjust_container_limits_for_variadic_sequences(headerDir, containers, maxEle
|
|||||||
print(line)
|
print(line)
|
||||||
|
|
||||||
|
|
||||||
|
def current_boost_dir():
|
||||||
|
"""Returns the (relative) path to the Boost source-directory this file is located in (if any)."""
|
||||||
|
# Path to directory containing this script.
|
||||||
|
path = os.path.dirname( os.path.realpath(__file__) )
|
||||||
|
# Making sure it is located in "${boost-dir}/libs/mpl/preprocessed".
|
||||||
|
for directory in reversed( ["libs", "mpl", "preprocessed"] ):
|
||||||
|
(head, tail) = os.path.split(path)
|
||||||
|
if tail == directory:
|
||||||
|
path = head
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
return os.path.relpath( path )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def to_positive_multiple_of_10(string):
|
def to_positive_multiple_of_10(string):
|
||||||
"""Converts a string into its encoded positive integer (greater zero) or throws an exception."""
|
"""Converts a string into its encoded positive integer (greater zero) or throws an exception."""
|
||||||
try:
|
try:
|
||||||
@@ -96,7 +111,12 @@ def to_existing_absolute_path(string):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""The main function."""
|
"""The main function."""
|
||||||
|
|
||||||
|
# Find the current Boost source-directory in which this script is located.
|
||||||
|
sourceDir = current_boost_dir()
|
||||||
|
if sourceDir == None:
|
||||||
|
sourceDir = ""
|
||||||
|
|
||||||
# Prepare and run cmdline-parser.
|
# Prepare and run cmdline-parser.
|
||||||
cmdlineParser = argparse.ArgumentParser(description="A generator-script for pre-processed Boost.MPL headers.")
|
cmdlineParser = argparse.ArgumentParser(description="A generator-script for pre-processed Boost.MPL headers.")
|
||||||
cmdlineParser.add_argument("-v", "--verbose", dest='verbose', action='store_true',
|
cmdlineParser.add_argument("-v", "--verbose", dest='verbose', action='store_true',
|
||||||
@@ -117,9 +137,9 @@ def main():
|
|||||||
cmdlineParser.add_argument("--num-elements", dest='numElements', metavar="<num-elements>",
|
cmdlineParser.add_argument("--num-elements", dest='numElements', metavar="<num-elements>",
|
||||||
type=to_positive_multiple_of_10, default=100,
|
type=to_positive_multiple_of_10, default=100,
|
||||||
help="The maximal number of elements per container sequence. (Default=100)")
|
help="The maximal number of elements per container sequence. (Default=100)")
|
||||||
cmdlineParser.add_argument(dest='sourceDir', metavar="<source-dir>",
|
cmdlineParser.add_argument(dest='sourceDir', metavar="<source-dir>", default=current_boost_dir(), nargs='?',
|
||||||
type=to_existing_absolute_path,
|
type=to_existing_absolute_path,
|
||||||
help="The source-directory of Boost.")
|
help="The source-directory of Boost. (Default=\"" + sourceDir + "\")")
|
||||||
args = cmdlineParser.parse_args()
|
args = cmdlineParser.parse_args()
|
||||||
|
|
||||||
# Some verbose debug output.
|
# Some verbose debug output.
|
||||||
@@ -134,7 +154,12 @@ def main():
|
|||||||
print " want: set = ", args.want_set
|
print " want: set = ", args.want_set
|
||||||
print " want: map = ", args.want_map
|
print " want: map = ", args.want_map
|
||||||
|
|
||||||
# The directories for header- and source files of Boost.MPL.
|
# Verify that we received any source-directory.
|
||||||
|
if args.sourceDir == None:
|
||||||
|
print "You should specify a valid path to the Boost source-directory."
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# The directories for header- and source files of Boost.MPL.
|
||||||
# NOTE: Assuming 'args.sourceDir' is the source-directory of the entire boost project.
|
# NOTE: Assuming 'args.sourceDir' is the source-directory of the entire boost project.
|
||||||
headerDir = os.path.join( args.sourceDir, "boost", "mpl" )
|
headerDir = os.path.join( args.sourceDir, "boost", "mpl" )
|
||||||
sourceDir = os.path.join( args.sourceDir, "libs", "mpl", "preprocessed" )
|
sourceDir = os.path.join( args.sourceDir, "libs", "mpl", "preprocessed" )
|
||||||
|
Reference in New Issue
Block a user