Commit graph

116 commits

Author SHA1 Message Date
William S Fulton
ff52610dc5 Move C++ 'Default arguments' section in manual 2017-09-14 18:51:36 +01:00
William S Fulton
330ef362f4 Add docs for C++11 ref-qualifiers 2017-08-30 18:17:04 +01:00
William S Fulton
32a454cfef Merge branch 'templates-scope-enforcement'
* templates-scope-enforcement:
  Test a few %template errors
  Add using declarations to templates into typedef table.
  Fix type lookup in the presence of using directives and using declarations
  More docs on %template
  Testcase fix for nameclash in php
  %template scope enforcement and class definition fixes
  Template documentation tweaks
  More consistent formatting of examples in documentation
  More consistent formatting of examples in documentation
  Documentation corrections to use targetlang formatting
  More consistent formatting of examples in documentation
  More consistent formatting of examples in documentation
  More consistent formatting of examples in documentation
  Namespace documentation minor corrections
  Improve description of template_parameters_resolve
  Minor code optimisation in template_parameters_resolve
  Fix scope lookup for template parameters containing unary scope operators
  Typemap change for templates
2017-08-16 21:44:51 +01:00
William S Fulton
8bf81b8718 More docs on %template 2017-08-16 00:24:25 +01:00
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
William S Fulton
97ae9d66bc Template documentation tweaks
Add subsections to the template documentation
Rewrite some of the template introduction
2017-08-16 00:24:25 +01:00
William S Fulton
5779aa8d79 More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
William S Fulton
04131a988f More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
William S Fulton
ba45861b46 More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
William S Fulton
8052211ac5 More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
William S Fulton
7ee76f93f9 More consistent formatting of examples in documentation 2017-08-16 00:24:25 +01:00
William S Fulton
8753f9652c Namespace documentation minor corrections 2017-08-16 00:24:24 +01:00
Olly Betts
90f9117e10 Fix various comment and documentation typos 2017-08-13 18:04:33 +12:00
William S Fulton
b538070016 Enhance %extend to extend a class with template methods 2017-01-22 10:36:46 +00:00
sunoru
8985c34809 Fix some typos in docs and examples and make the code look nicer. 2016-12-31 23:06:56 +08:00
William S Fulton
6310cdb28a html fix
[skip ci]
2016-11-03 19:26:38 +00:00
William S Fulton
0886fc6fe6 Edit operator[] additions 2016-10-30 14:52:35 +00:00
g
61061ff150 Added description of the operator[] caveats 2016-10-26 23:55:04 -07:00
William S Fulton
268b942865 Consistent formatting of example code in the docs 2016-10-23 20:16:35 +01:00
William S Fulton
3763beb489 Replace tabs with spaces in html docs
wkhtmltopdf is not expanding tabs within <pre> elements to 8 spaces as it
should. Workaround the problem by converting all tabs to an appropriate
number of spaces.
2015-12-30 22:22:33 +00:00
William S Fulton
4e67d5c7a8 Minor html fixes 2015-12-30 22:22:33 +00:00
William S Fulton
925b2a336f HTML fixes for documentation - add meta tag and loose.dtd 2015-12-30 22:22:32 +00:00
William S Fulton
8288ac15a0 Correct links in html documentation using new version of makechap.py
Corrects position of heading text within A and H1, H2, ... elements.
2015-12-30 22:22:32 +00:00
William S Fulton
55e7264d43 Clearer warning message for badly constructed typecheck typemaps 2015-04-14 07:34:40 +01:00
William S Fulton
f25f5cf635 Nested class template doc tweaks 2015-01-16 19:08:41 +00:00
Michael Schaller
007a75480a Updated C++ template documentation with respect to using a nested class as template parameter.
Fixes issue swig/swig#270.
2015-01-05 16:43:49 +01:00
Olly Betts
f541e604e8 Consistently put whitespace outside of <tt>...</tt> and not inside 2014-11-18 12:44:37 +13:00
Olly Betts
e047d2e2bd Remove bogus ; after } in documentation 2014-11-07 15:34:43 +13:00
William S Fulton
3dcc501ac0 Spelling fix 2014-10-21 07:55:07 +01:00
William S Fulton
bfde148887 The kwargs feature no longer turns on compactdefaultargs for languages that don't support kwargs.
Affects all languages except Python and Ruby.

Closes #242
2014-10-21 07:34:51 +01:00
William S Fulton
e982dc7e3b Correct documentation of special variable names
$parentname is really $parentclassname
$parentsymname is really $parentclasssymname
2014-07-01 20:07:19 +01:00
William S Fulton
785d93d9fb html fixes and section updates 2014-03-15 22:45:43 +00:00
Olly Betts
de7ed84f77 Recommend compiling with PIC consistently.
While shared objects with non-PIC code work on some architectures
(notably x86), unless code is always PIC on that arch (not true for x86)
doing so requires runtime relocations, which prevents the object
actually being shared, and means such segments can't be marked as
read-only.
2014-02-21 08:09:58 +13:00
William S Fulton
c34d7f6d23 %naturalvar feature fixes and documentation
Fix and document the naturalvar feature override behaviour - the naturalvar
feature attached to a variable name has precedence over the naturalvar
feature attached to the variable's type. The overriding was not working
when turning the feature off on the variable's name.

Fix so that any use of the naturalvar feature will override the global
setting. Previously when set globally by -naturalvar or %module(naturalvar=1),
use of the naturalvar feature was not always honoured.
2014-01-11 19:32:43 +00:00
William S Fulton
314fae460b Merge branch 'nested' - nested structs/classes support
* nested:
  Deprecation of the 'nestedworkaround' feature
  Ensure -c++out is not used with -c++
  Add missing header to new source file
  Nested C class setters restored in c++out mode for Octave
  Classprefix fixed after private nested classes some comments and spaces added
  Fix template partial specialization detection
  Minor tweaks in Swig_feature_set
  Swig_offset_string moved to misc.c
  nested private classes are discarded while parsing nested relate functions are moved to nested.cxx and renamed accordingly
  out-of-scope template definitions fixed nested_private test disabled again
  fixed out-of-scope nested class definitions, added a test enabled nested C structs assignment (still disabled for Octave), added Java runtime test fixed nested_private test case for Java & C#
  Testcase of private nested class usage causing segfault
  C nested struct passed by value example
  Add in Travis testing for nested branch
  Add C++ nested class example
  Minor code improvements
  Cosmetics/code beautification of nested class support
  Nested classes support
2013-12-14 15:12:07 +00:00
William S Fulton
0f4ceaf592 Deprecation of the 'nestedworkaround' feature
Also add in macros for the flatnested feature which can be used in place
of the nestedworkaround feature
2013-12-13 08:11:17 +00:00
Olly Betts
c6e4dea572 Fix a few typos in comments and docs 2013-12-12 11:45:30 +13:00
Vladimir Kalinin
b63c4839fe Nested classes support
Closes #89
Squash merge branch 'master' of https://github.com/wkalinin/swig into wkalinin-nested

By Vladimir Kalinin
* 'master' of https://github.com/wkalinin/swig:
  CPlusPlusOut mode for Octave
  nested class illustration
  fixed "Abstract" flag for nested classes added an example enabled anonymous nested structs runtime test
  porting
  warnings disabled
  porting fixes
  java runtime tests ported
  nested class closing bracket offset fixed
  removed double nested template (not supported by %template parsing)
  template_nested test extended
  parent field made public
  property access fixed
  replaced tabs with spaces
  warning W-reorder
  deprecated warnings removed, derived_nested runtime test added
  optimized string indenting
  Nested classes indenting
  nested classes docs
  fixed the order in which flattened inner classes are added after the outer
  Private nested classes were getting into the type table.
  Java getProxyName() fix for nested classes fixes the case when nested classes is forward declared
  Fix for a case when a nested class inherits from the same base as the outer. (Base class constructor declaration is found first in this case)
  merge fix
  nested C struct first immediate declaration incorrectly renamed sample fixed
  tests updated to reflect nested classes support
  Java nested classes support (1)
  flattening should remove the link to the outer class
  access mode correctly set/restored for nested classes
  nested templates should be skipped while flattening (template nodes themselves, not expanded versions) also non-public nested classes should be ignored
  If nested classes are not supported, default behaviour is flattening, not ignoring flag "nested" is preserved, so, the nested classes can be ignored by user
  nested workaround test updated
  template instantiated within a class is marked as nested for ignoring purposes
  %ignore not applied to the nested classed, because "nested" flag is set too late
  typedef name takes precedence over the real name (reason?)
  unnamed structs should be processed for all the languages
  nested C struct instances are wrapped as "immutable"
  tree building
  typedef declaration for unnamed C structures fixed
  nested classes "flattening"
  fixed %ignoring nested classes
  renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface
  renamed "nested" attribute to "nested:outer" added "nested" flag, to be used with $ignore (it is not removed while flattening) added nestedClassesSupported() function to the Language interface
  tree iteration fix
  dirclassname variable names unified memory issue fixed
  merge error
  ignore unnamed structs for C++
  unnamed nested C structs naming & unnesting
  class added to classes hash under typedef name
  private nested classes skipped
  test updated due to nested templates support
  anonymous structs with inheritance fixed nested_class test to allow anonymous structs w/o declarator
  tests updated: nested workaround removed from namespace_class.i propagated nested template declaration to the C++ file
  injected members scope
  nested tempplates fixes, nested structures in "C" mode parsing added utility function "appendSibling" (like "appendChild")
  nested unnamed structures parsing fixes, access mode restored on nested class end, tdname is properly patched with outer class name prefix
  memory management fixes
  nested templates (1)
  Nested unnamed structs
  Nested class support (1)
  Nested class support (1)
2013-11-29 07:02:34 +00:00
William S Fulton
f47075ec99 Smart pointer documentation improvement 2013-09-03 23:58:05 +01:00
William S Fulton
b17a77c6ea Support special variable expansion in %extend.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13871 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-10-11 19:28:02 +00:00
William S Fulton
bc43673a86 Add new warning if an empty template declaration is used on a base class, minor docs improvement for empty template declarations.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13840 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-09-14 22:25:35 +00:00
William S Fulton
d005a2cc3f New section numbering adding in Android chapter
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12869 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-12-10 16:53:04 +00:00
William S Fulton
5923117e81 HTML cosmetics
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12817 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-09-24 14:01:20 +00:00
William S Fulton
c794d08597 Fix %newobject when used in conjunction with %feature(ref). The code from the ref feature was not always being generated for the function specified by %newobject. Documentation for ref and unref moved from Python to the C++ chapter.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12783 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-08-23 19:29:10 +00:00
William S Fulton
3099911397 some doc typo fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12778 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-08-17 21:52:52 +00:00
William S Fulton
25c8689226 Use htmldoc's new --overflow option and fix overflow warnings in the pdf documentation generation
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12379 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-01-08 01:28:09 +00:00
William S Fulton
36c2e97a1c Add std_shared_ptr.i and document shared_ptr library
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12077 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-06-01 19:03:55 +00:00
William S Fulton
9006dc90ce Correctly mangle the html section names to prevent name clashes in the pdf document
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11921 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-03-06 19:35:25 +00:00
William S Fulton
b6b99bb148 Add nspace feature for C# and add documentation on nspace
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11920 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-03-06 19:11:32 +00:00
William S Fulton
6fe7287ad3 Update error message
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11856 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-13 00:09:24 +00:00