ready for 10.4.0

This commit is contained in:
Frank B. Brokken 2015-12-11 15:48:54 +01:00
parent a4cc07542c
commit 1b0272a5b9
15 changed files with 47 additions and 172 deletions

View file

@ -64,6 +64,7 @@ void htmldoc()
chdir("yo");
system("yodl2html --no-warnings -l3 cplusplus ");
system("mv *.html ../tmp/docs/html");
system("cp cplusplus.css ../tmp/docs/html");
chdir("..");
}

View file

@ -5,7 +5,7 @@ compilers explicitly mentioned, but fairly recent ones are assumed.
Required software for building the C++ Annotations 10.4.0
---------------------------------------------------------
icmake (>= 8.00.02), yodl (>= 3.06.00), libbobcat-dev (>= 4.01.03), flex, zip,
icmake (>= 8.00.03), yodl (>= 3.06.00), libbobcat-dev (>= 4.01.03), flex, zip,
texlive-latex-base, texlive-generic-recommended, texlive-latex-recommended,
texlive-fonts-recommended, ghostscript

View file

@ -34,9 +34,6 @@ string
sources, // sources to be used
wild, // wildcard of extension
current; // contains name of current dir.
/*
O B J F I L E S . I M
*/
list objfiles(list files)
{
@ -46,7 +43,7 @@ list objfiles(list files)
int
i;
for (i = 0; i < sizeof(files); i++)
for (i = 0; i < listlen(files); i++)
{
file = element(i, files); // determine element of the list
@ -60,64 +57,6 @@ list objfiles(list files)
}
return (files);
}
/*
parser.im
*/
void parser()
{
chdir("parser/gramspec");
system("grambuild");
chdir("..");
if
(
exists("grammar")
&&
"grammar" younger "parser.cc"
) // new parser needed
{
exec("bisonc++", "-d", "-o", "parser.cc", "grammar");
printf("Note: the compilation of parser.cc may produce "
"several compiler warnings.\n");
}
chdir("..");
}
/*
scanner.im
*/
void scanner()
{
chdir("scanner");
if
( // new lexer needed
exists("lexer")
&&
(
"lexer" younger "yylex.cc"
||
"../parser/parser.h" younger "yylex.cc"
)
)
{
exec("flex++",
#ifdef INTERACTIVE
"-I",
#endif
"-oyylex.cc", "lexer");
printf("Note: the compilation of yylex.cc may produce "
"several compiler warnings.\n");
}
chdir("..");
}
/*
A L T E R E D . I M
*/
list altered(list files, string target)
{
@ -126,7 +65,7 @@ list altered(list files, string target)
string
file;
for (i = 0; i < sizeof(files); i++) // try all elements of the list
for (i = 0; i < listlen(files); i++) // try all elements of the list
{
file = element(i, files); // use element i of the list
@ -138,9 +77,6 @@ list altered(list files, string target)
}
return (files); // return the new list
}
/*
F I L E L I S T . I M
*/
list file_list(string type, string library)
{
@ -153,9 +89,6 @@ list file_list(string type, string library)
return (files);
}
/*
L I N K . I M
*/
void link(string library, string exe)
{
@ -165,10 +98,6 @@ void link(string library, string exe)
);
}
/*
C C O M P I L E . I M
*/
void c_compile(list cfiles)
{
string nextfile;
@ -177,7 +106,7 @@ void c_compile(list cfiles)
if (!exists("o"))
system("mkdir o");
if (sizeof(cfiles)) // files to compile ?
if (listlen(cfiles)) // files to compile ?
{
printf(current, "\n");
@ -190,9 +119,6 @@ void c_compile(list cfiles)
}
}
}
/*
U P D A T E L I . I M
*/
void updatelib(string library)
{
@ -205,7 +131,7 @@ void updatelib(string library)
objlist = makelist("*.o");
if (!sizeof(objlist))
if (!listlen(objlist))
return;
printf("\n");
@ -230,9 +156,6 @@ void prefix_class(string class_id)
for (i = 0; o_file = element(i, o_files); i++)
exec("mv", o_file, class_id + o_file);
}
/*
S T D C P P . I M
*/
void std_cpp(string library)
{
@ -244,25 +167,6 @@ void std_cpp(string library)
c_compile(cfiles); // compile cpp-files
}
/*
C P P M A K E . C
CPP files are processed by stdmake.
Arguments of CPPMAKE:
cpp_make(
string mainfile, : name of the main .cpp file, or "" for library
maintenance
string library, : name of the local library to use/create
(without lib prefix, .a suffix
if main is given here, libmain.a is created)
string exe, : (path) name of the exe file to create
)
Both mainfile and library MUST be in the current directory
*/
void cpp_make(string mainfile, string library, string exe)
{
int
@ -273,18 +177,6 @@ void cpp_make(string mainfile, string library, string exe)
string
cwd;
#ifdef BISON++
CLASSES += "parser ";
if (exists("parser")) // subdir parser exists
parser();
#endif
#ifdef FLEX++
CLASSES += "scanner ";
if (exists("scanner")) // subdir scannerexists
scanner();
#endif
setClasses(); // remaining classes
cwd = chdir(".");
@ -293,7 +185,7 @@ void cpp_make(string mainfile, string library, string exe)
classes = strtok(CLASSES, " "); // list of classes
if (n = sizeof(classes))
if (n = listlen(classes))
ofiles += " */o/*.o"; // set ofiles for no LIBRARY use
wild = sources;
@ -327,9 +219,7 @@ void cpp_make(string mainfile, string library, string exe)
if (mainfile != "") // mainfile -> do link
link(library, exe);
}
/*
S E T L I B S . I M
*/
void setlibs()
{
int
@ -339,24 +229,18 @@ void setlibs()
cut;
cut = strtok(LIBS, " "); // cut op libraries
n = sizeof(cut);
n = listlen(cut);
for (index = 0; index < n; index++)
libs += " -l" + element(index, cut);
#ifdef FLEX++
libs += " -lfl";
#endif
cut = strtok(LIBPATH, " "); // cut up the paths
n = sizeof(cut);
n = listlen(cut);
for (index = 0; index < n; index++)
libpath += " -L" + element(index, cut);
}
void main()
{
echo(ECHO_REQUEST);
sources = "*.cc";

View file

@ -1,3 +1,5 @@
#define YY_NO_INPUT
#line 2 "flex.c"
#line 4 "flex.c"

View file

@ -26,7 +26,6 @@ this (regarding the members that are involved in their polymorphic behaviors):
int vmass() const override;
};
)
)
When converting dynamically polymorphic classes to statically polymorphic
classes we must realize that polymorphic classes show two important
@ -88,7 +87,7 @@ should it call tt(Class::vmass) or should it call tt(Truck::vmass)?
COMMENT(see examples/staticpolymorphism/multiple.cc)
)
To solve this problem (i.e., to ensure that tt(Truck{}.mass()) calls
tt(Truck::vmass) the redefinable interface must be separated
tt(Truck::vmass)) the redefinable interface must be separated
from the inheritable interface.
In derived classes the protected and public interfaces of (direct or indirect)
@ -125,12 +124,12 @@ to the right. E.g., tt(VehicleBase) declares tt(Vechicle) as its friend:
};
)
The top level class to the right (tt(VehicleBase) lays the foundation of
The top level class to the right (tt(VehicleBase)) lays the foundation of
static polymorphism, by defining that part of the interface that uses the
statically redefinable functions. E.g, using the curiously recurring template
pattern it defines a class member tt(mass) that calls the function tt(vmass)
of its derived class (at the same time it can use all members of its non-class
template base class. E.g,:
of its derived class (in addition it can use all members of its non-class
template base class). E.g,:
verb(
template <class Derived>
class Vehicle: public VehicleBase
@ -199,14 +198,14 @@ polymorphic base class (allowing for definitions like tt(Vehicle<> vehicle)).
it() Likewise the remaining classes have their members not involved in
static polymorphism moved to a base class. E.g.,
class tt(Car) moves these members to tt(CarBase) and
tt(Truck) moves those members to TruckBase).
tt(Truck) moves those members to tt(TruckBase).
it() A standard linear line of inheritance is used from tt(VehicleBase) to
tt(CarBase) and from there to tt(TruckBase).
it() Each of the remaining classes (here: tt(Car) and tt(Truck) is a class
template that derives from its base classes, and also, using the curiously
recurrent template pattern, from tt(Vehicle).
it() Each of the remaining classes (here: tt(Car) and tt(Truck)) is a
class template that derives from its base classes, and also, using the
curiously recurrent template pattern, from tt(Vehicle).
it() Each of these remaining classes can now implement its own version of
the redefinable interface, as used by the members of tt(Vehicle).
@ -248,6 +247,6 @@ template: two implementations, one for the tt(Car) type, and one for the
tt(Truck) type. The statically polumorphic program will be slightly faster,
though.
(An compilable example using static polymorphism is found in the
(A compilable example using static polymorphism is found in the
annotation()'s source distribution's file
tt(yo/classtemplates/examples/staticpolymorphism/polymorph.cc).
tt(yo/classtemplates/examples/staticpolymorphism/polymorph.cc).)

View file

@ -6,11 +6,11 @@ template <class Derived>
class Vehicle
{
public:
void mass()
void mass()
{
static_cast<Derived *>(this)->vmass();
}
// no need to implement vmass here, as it should be implemented
// by derived classes.
};
@ -20,7 +20,7 @@ class Car: public Vehicle<Car>
friend void Vehicle<Car>::mass();
private:
void vmass()
void vmass()
{
cout << "Car's vmass called\n";
}
@ -29,7 +29,7 @@ class Car: public Vehicle<Car>
class Truck: public Car
{
private:
void vmass()
void vmass()
{
cout << "Car's vmass called\n";
}

View file

@ -6,11 +6,11 @@ template <class Derived>
class Vehicle
{
public:
void mass()
void mass()
{
static_cast<Derived *>(this)->vmass();
}
// no need to implement vmass here, as it should be implemented
// by derived classes.
};
@ -20,7 +20,7 @@ class Car: public Vehicle<Car>
friend void Vehicle<Car>::mass();
private:
void vmass()
void vmass()
{
cout << "Car's vmass called\n";
}
@ -30,7 +30,7 @@ class Truck: public Car, public Vehicle<Truck>
{
friend void Vehicle<Car>::mass();
private:
void vmass()
void vmass()
{
cout << "Car's vmass called\n";
}

View file

@ -6,7 +6,7 @@ class VehicleBase
{
// original Vehicle members, not implementing the
// redefinable interface, but used as a implementable rather than
// instantiatable part of the corresponding class template.
// instantiatable part of the corresponding class template.
// That's why it declares its corresponding class template a friend.
template <class Derived>
@ -29,7 +29,7 @@ class Vehicle: public VehicleBase
class CarBase: public VehicleBase
{
// original Car members, not implementing the
// redefinable interface
// redefinable interface
int x = 1000;
friend class Car;
@ -48,7 +48,7 @@ class Car: public CarBase, public Vehicle<Car>
class TruckBase: public CarBase
{
// original Truck members, not implementing the
// redefinable interface
// redefinable interface
friend class Truck;
};

View file

@ -40,7 +40,7 @@ a tt(Derived) class object.
So, to call a tt(Derived) class member from inside tt(interface) we
can use the following implementation (remember that tt(Base) is a base class
of tt(Derived):
of tt(Derived)):
verb(
template<class Derived>
void Base<Derived>::interface()

View file

@ -23,11 +23,10 @@ includefile(overloading/increment.yo)
lsect(OVERLOADBINARY)(Overloading binary operators)
includefile(overloading/binary.yo)
subsect(Member function reference bindings (& and &&))
lsubsect(REFBIND)(Member function reference bindings (& and &&))
includefile(overloading/reference.yo)
COMMENT(13.3.3.2)
lsect(OVERLOADNEW)(Overloading `operator new(size_t)')
includefile(overloading/new)

View file

@ -49,9 +49,3 @@ int main()
cout << "========\n";
Demo{} + d1 + d1;
}

View file

@ -58,9 +58,3 @@ int main()
Demo{} + d1 + d1;
}

View file

@ -52,9 +52,3 @@ int main()
cout << "========\n";
Binary{} + Binary{} + Binary{};
}

View file

@ -21,8 +21,8 @@ Our implementation of tt(operator+=) thus far looks like this:
}
)
However, when implementing tt(operator+) we either already have a
temporary object (when using tt(operator+(Binary &&lhs, ...)), or just created
a temporary object (when using tt(operator+(Binary const &lhs, ...)). In our
temporary object (when using tt(operator+(Binary &&lhs, ...))), or just created
a temporary object (when using tt(operator+(Binary const &lhs, ...))). In our
current implementation lots of additional temporaries are being constructed,
each of them requiring a copy construction. E.g, in an expression like
verb(
@ -31,7 +31,7 @@ each of them requiring a copy construction. E.g, in an expression like
a temporary is constructed when computing tt(Binary{} + varB), then
another one for tt(Binary{} + varC), and yet one more for tt(Binary{} +
varD). In addition, each addition also performs a swap, even though we already
have a temporary (i.e., tt(Binary{}) in our hands.
have a temporary (i.e., tt(Binary{})) in our hands.
How to tell the compiler that we don't need these temporaries?
@ -97,7 +97,7 @@ expression tt(b1 + b2 + b3)
Move += = tmp += b3
)
It's even faster when the first operand already is a temporary (e.g.,
tt(Binary{} + b2 + b3):
tt(Binary{} + b2 + b3)):
verb(
Move += = Binary{} += b2
Move += = Binary{} += b3

View file

@ -1,6 +1,14 @@
This section is modified when the first or second part of the version number
changes (and sometimes for the third part as well).
itemization(
it() Version 10.4.0 adds the previously missing section about reference
bindings (section ref(REFBIND)). This section is a subsection of
section ref(OVERLOADBINARY), covering overloading binary operators,
and this latter section, as well as the section covering static
polymorphism (section ref(STATICPOLY)) was completely
rewritten. In addition, the appearance of the html-version of the
annotations() can now to some extent be fine-tuned by adding CSS
elements in the top-level file tt(cplusplus.css).
it() Version 10.3.0 contains new sections about expression templates,
about at tributes, about shared mutexes, about shared locks, about
heterogeneous lookups, about sized deallocation functions, and about