mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-02 14:04:55 -04:00
Squashed 'boost/' content from commit b4feb19f2
git-subtree-dir: boost git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
class_template
|
||||
|
||||
class %class_name% {
|
||||
public:
|
||||
%class_name%() {}
|
||||
~%class_name%() {}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
// (C) Copyright Vladimir Prus, 2003
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Please see 'usage.verbatim' file for usage notes.
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
using std::cout;
|
||||
using std::string;
|
||||
using std::strlen;
|
||||
|
||||
extern const char class_template[];
|
||||
extern const char usage[];
|
||||
|
||||
int main(int ac, char* av[])
|
||||
{
|
||||
if (av[1]) {
|
||||
|
||||
string class_name = av[1];
|
||||
string s = class_template;
|
||||
|
||||
string::size_type n;
|
||||
while((n = s.find("%class_name%")) != string::npos) {
|
||||
s.replace(n, strlen("%class_name%"), class_name);
|
||||
}
|
||||
std::cout << "Output is:\n";
|
||||
std::cout << s << "\n";
|
||||
return 0;
|
||||
} else {
|
||||
std::cout << usage << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright 2003 Vladimir Prus
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import sys
|
||||
from string import strip
|
||||
|
||||
def quote_line(line):
|
||||
|
||||
result = ""
|
||||
|
||||
for i in line:
|
||||
if (i == '\\'):
|
||||
result = result + '\\\\'
|
||||
elif (i == '\"'):
|
||||
result = result + '\\\"'
|
||||
elif (i != '\r' and i != '\n'):
|
||||
result = result + i;
|
||||
|
||||
return '\"' + result + '\\n\"'
|
||||
|
||||
def quote_file(file):
|
||||
result = ""
|
||||
|
||||
for i in file.readlines():
|
||||
result = result + quote_line(i) + "\n"
|
||||
|
||||
return result
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print "Usage: inline_file.py output_c_file file_to_include"
|
||||
else:
|
||||
output_c_file = sys.argv[1]
|
||||
out_file = open(output_c_file, "w");
|
||||
|
||||
file_to_include = sys.argv[2]
|
||||
|
||||
in_file = open(file_to_include, "r");
|
||||
variable_name = strip(in_file.readline())
|
||||
out_file.write("extern const char %s[] = {\n%s};\n\n" % (variable_name, quote_file(in_file)))
|
||||
in_file.close()
|
||||
out_file.close()
|
||||
@@ -0,0 +1,9 @@
|
||||
# Copyright 2003 Vladimir Prus
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import verbatim ;
|
||||
|
||||
exe codegen : codegen.cpp class.verbatim usage.verbatim
|
||||
t1.verbatim ;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
Copyright 2003 Vladimir Prus
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
This example show how to add a new target type and a new tool support to
|
||||
Boost.Build. Please refer to extender manual for a complete description of this
|
||||
example.
|
||||
|
||||
Note that this example requires Python. If cygwin Python on Windows is to be
|
||||
used, please go to "verbatim.jam" and follow instructions there.
|
||||
@@ -0,0 +1,2 @@
|
||||
t1
|
||||
//###include "t2.verbatim"
|
||||
@@ -0,0 +1,5 @@
|
||||
usage
|
||||
Usage: codegen class_name
|
||||
|
||||
This program takes a template of C++ code and replaces of all occurrences of
|
||||
%class_name% with the passed 'class_name' parameter.
|
||||
@@ -0,0 +1,61 @@
|
||||
# Copyright 2003, 2004 Vladimir Prus
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# This file shows some of the primary customization mechanisms in Boost.Build V2
|
||||
# and should serve as a basic for your own customization.
|
||||
# Each part has a comment describing its purpose, and you can pick the parts
|
||||
# which are relevant to your case, remove everything else, and then change names
|
||||
# and actions to taste.
|
||||
|
||||
import os ;
|
||||
|
||||
# Declare a new target type. This allows Boost.Build to do something sensible
|
||||
# when targets with the .verbatim extension are found in sources.
|
||||
import type ;
|
||||
type.register VERBATIM : verbatim ;
|
||||
|
||||
# Declare a dependency scanner for the new target type. The
|
||||
# 'inline-file.py' script does not handle includes, so this is
|
||||
# only for illustraction.
|
||||
import scanner ;
|
||||
# First, define a new class, derived from 'common-scanner',
|
||||
# that class has all the interesting logic, and we only need
|
||||
# to override the 'pattern' method which return regular
|
||||
# expression to use when scanning.
|
||||
class verbatim-scanner : common-scanner
|
||||
{
|
||||
rule pattern ( )
|
||||
{
|
||||
return "//###include[ ]*\"([^\"]*)\"" ;
|
||||
}
|
||||
}
|
||||
|
||||
# Register the scanner class. The 'include' is
|
||||
# the property which specifies the search path
|
||||
# for includes.
|
||||
scanner.register verbatim-scanner : include ;
|
||||
# Assign the scanner class to the target type.
|
||||
# Now, all .verbatim sources will be scanned.
|
||||
# To test this, build the project, touch the
|
||||
# t2.verbatim file and build again.
|
||||
type.set-scanner VERBATIM : verbatim-scanner ;
|
||||
|
||||
import generators ;
|
||||
generators.register-standard verbatim.inline-file : VERBATIM : CPP ;
|
||||
|
||||
# Note: To use Cygwin Python on Windows change the following line
|
||||
# to "python inline_file.py $(<) $(>)"
|
||||
# Also, make sure that "python" in in PATH.
|
||||
actions inline-file
|
||||
{
|
||||
"./inline_file.py" $(<) $(>)
|
||||
}
|
||||
|
||||
if [ os.name ] = VMS
|
||||
{
|
||||
actions inline-file
|
||||
{
|
||||
python inline_file.py $(<:W) $(>:W)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
# Copyright 2010 Vladimir Prus
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# This file is only used with Python port of Boost.Build
|
||||
|
||||
# This file shows some of the primary customization mechanisms in Boost.Build V2
|
||||
# and should serve as a basic for your own customization.
|
||||
# Each part has a comment describing its purpose, and you can pick the parts
|
||||
# which are relevant to your case, remove everything else, and then change names
|
||||
# and actions to taste.
|
||||
|
||||
# Declare a new target type. This allows Boost.Build to do something sensible
|
||||
# when targets with the .verbatim extension are found in sources.
|
||||
import b2.build.type as type
|
||||
type.register("VERBATIM", ["verbatim"])
|
||||
|
||||
# Declare a dependency scanner for the new target type. The
|
||||
# 'inline-file.py' script does not handle includes, so this is
|
||||
# only for illustraction.
|
||||
import b2.build.scanner as scanner;
|
||||
# First, define a new class, derived from 'common-scanner',
|
||||
# that class has all the interesting logic, and we only need
|
||||
# to override the 'pattern' method which return regular
|
||||
# expression to use when scanning.
|
||||
class VerbatimScanner(scanner.CommonScanner):
|
||||
|
||||
def pattern(self):
|
||||
return "//###include[ ]*\"([^\"]*)\""
|
||||
|
||||
scanner.register(VerbatimScanner, ["include"])
|
||||
type.set_scanner("VERBATIM", VerbatimScanner)
|
||||
|
||||
import b2.build.generators as generators
|
||||
|
||||
generators.register_standard("verbatim.inline-file",
|
||||
["VERBATIM"], ["CPP"])
|
||||
|
||||
from b2.manager import get_manager
|
||||
|
||||
get_manager().engine().register_action("verbatim.inline-file",
|
||||
"""
|
||||
./inline_file.py $(<) $(>)
|
||||
""")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user