swig/Doc/Manual
William S Fulton 959e627208 %template scope enforcement and class definition fixes
The scoping rules around %template have been specified and enforced.
The %template directive for a class template is the equivalent to an
explicit instantiation of a C++ class template. The scope for a valid
%template instantiation is now the same as the scope required for a
valid explicit instantiation of a C++ template. A definition of the
template for the explicit instantiation must be in scope where the
instantiation is declared and must not be enclosed within a different
namespace.

For example, a few %template and explicit instantiations of std::vector
are shown below:

  // valid
  namespace std {
    %template(vin) vector<int>;
    template class vector<int>;
  }

  // valid
  using namespace std;
  %template(vin) vector<int>;
  template class vector<int>;

  // valid
  using std::vector;
  %template(vin) vector<int>;
  template class vector<int>;

  // ill-formed
  namespace unrelated {
    using std::vector;
    %template(vin) vector<int>;
    template class vector<int>;
  }

  // ill-formed
  namespace unrelated {
    using namespace std;
    %template(vin) vector<int>;
    template class vector<int>;
  }

  // ill-formed
  namespace unrelated {
    namespace std {
      %template(vin) vector<int>;
      template class vector<int>;
    }
  }

  // ill-formed
  namespace unrelated {
    %template(vin) std::vector<int>;
    template class std::vector<int>;
  }

When the scope is incorrect, an error now occurs such as:

cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and
was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.

Previously SWIG accepted the ill-formed examples above but this led to
numerous subtle template scope problems especially in the presence of
using declarations and using directives as well as with %feature and %typemap.

Actually, a valid instantiation is one which conforms to the C++03
standard as C++11 made a change to disallow using declarations and
using directives to find a template.

  // valid C++03, ill-formed C++11
  using std::vector;
  template class vector<int>;

Similar fixes for defining classes using forward class references have
also been put in place. For example:

namespace Space1 {
  struct A;
}
namespace Space2 {
  struct Space1::A {
    void x();
  }
}

will now error out with:

cpp_class_definition.i:5: Error: 'Space1::A' resolves to 'Space1::A' and
was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'.
2017-08-16 00:24:25 +01:00
..
Allegrocl.html Correct some whitespace changes 2017-01-01 14:28:49 +00:00
android-class.png Add Android docs - supporting screenshots 2011-12-10 17:03:50 +00:00
android-simple.png Add Android docs - supporting screenshots 2011-12-10 17:03:50 +00:00
Android.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
Arguments.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
CCache.html HTML fixes for documentation - add meta tag and loose.dtd 2015-12-30 22:22:32 +00:00
ch2.1.png The great merge 2002-11-30 22:01:28 +00:00
chapters Add Scilab to html docs 2015-01-27 19:30:24 +00:00
Chicken.html Realign for some comments. 2016-12-31 23:29:45 +08:00
Contents.html %template scope enforcement and class definition fixes 2017-08-16 00:24:25 +01:00
Contract.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
CPlusPlus11.html C++11 hash tables documentation 2017-02-10 19:49:58 +00:00
CSharp.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
Customization.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
D.html Add %proxycode directive for adding code into proxy classes for C#, D and Java 2017-01-13 20:43:50 +00:00
Extending.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
fixstyle.py HTML pdf doc generation fixes 2015-12-30 22:22:33 +00:00
Go.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
Guile.html Realign for some comments. 2016-12-31 23:29:45 +08:00
index.html HTML fixes for documentation - add meta tag and loose.dtd 2015-12-30 22:22:32 +00:00
Introduction.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
Java.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
Javascript.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
Library.html Documentation corrections to use targetlang formatting 2017-08-16 00:24:25 +01:00
linkchecker.config html links updates 2015-12-18 21:14:44 +00:00
Lisp.html Formatting fixes in Lisp docs 2017-06-03 18:37:05 +01:00
Lua.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
makechap.py Correct html documentation linking generated by makechap.py script 2015-12-30 22:22:31 +00:00
Makefile Fix outdated info in Doc Makefile about pdf file generation 2016-11-25 07:39:06 +00:00
maketoc.py HTML fixes for documentation - add meta tag and loose.dtd 2015-12-30 22:22:32 +00:00
Modula3.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
Modules.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
Mzscheme.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
Ocaml.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
Octave.html Octave: add support for version 4.2 2017-01-22 11:53:12 +13:00
Perl5.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
Php.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
Pike.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
Preface.html html doc fixes 2016-04-02 13:47:23 +01:00
Preprocessor.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
Python.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
R.html Escape literal > in HTML 2017-03-02 08:45:45 +13:00
README subject/verb agreement 2013-04-30 22:49:12 -03:00
Ruby.html Ruby doc tweak 2017-01-20 19:53:47 +00:00
Scilab.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
Scripting.html Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
Sections.html Bump version to 4.0.0 2017-04-21 19:36:09 +01:00
style.css HTML pdf doc generation fixes 2015-12-30 22:22:33 +00:00
SWIG.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
swig16.png remove svn:executable property where applied incorrectly 2008-11-26 21:54:49 +00:00
SWIGPlus.html %template scope enforcement and class definition fixes 2017-08-16 00:24:25 +01:00
Tcl.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
Typemaps.html Fix %import and %fragment forced inclusion to not generate code. 2017-06-03 18:37:05 +01:00
Varargs.html More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
Warnings.html Correct some whitespace changes 2017-01-01 14:28:49 +00:00
Windows.html Replace tabs with spaces in html docs 2015-12-30 22:22:33 +00:00

This directory contains the HTML for the SWIG users manual.

All of this HTML is hand-written.  However, section numbering, indices,
and the table of contents are generated automatically by the 'maketoc.py'
script. The Makefile has further information on how the various alternative
forms of the documentation are generated from the hand-written HTML.

There are 4 types of boxes that code or whatever can be inside:
  - <div class="shell">...</div>
    This is for text that shows the output of running commands on the shell.
  - <div class="code">...</div>
    This is for either C, C++, or SWIG code
  - <div class="targetlang">...</div>
    This is for code in a target scripting language
  - <div class="diagram">...</div>
    This is for text that is not code or a shell

The general format is
<div class="foo"><pre>
whatever here
</pre></div>