Fragments: additional testing and documentation enhancements
Add test for original syntax when using a single fragment key containing the list of dependent fragments. I couldn't find a test for this. Spaces in the fragment list don't seem to work - document it.
This commit is contained in:
parent
013be550ed
commit
d59cbf1c39
3 changed files with 54 additions and 19 deletions
|
|
@ -7,6 +7,15 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.1.0 (in progress)
|
||||
===========================
|
||||
|
||||
2022-02-07: sethrj
|
||||
#2196 Add alternative syntax for specifying fragments in typemaps.
|
||||
|
||||
New syntax:
|
||||
%typemap("in", fragment="frag1", fragment="frag2", fragment="frag3") {...}
|
||||
which is equivalent to:
|
||||
%typemap(in, fragment="frag1,frag2,frag3") {...}
|
||||
|
||||
|
||||
2022-02-07: olly
|
||||
#1806 Remove support for the "command" encoder, which was mostly
|
||||
intended for use in `%rename` - most uses can be achieved using
|
||||
|
|
|
|||
|
|
@ -3835,7 +3835,7 @@ To eliminate this, define a fragment that includes the common marshalling code:
|
|||
|
||||
<p>
|
||||
When the "in" or "varin" typemaps for MyClass are required, the
|
||||
contents of the fragment called "AsMyClass" is added to the "header" section within the generated code, and then the
|
||||
contents of the fragment called "AsMyClass" are added to the "header" section within the generated code, and then the
|
||||
typemap code is emitted. Hence, the method <tt>AsMyClass</tt> will be
|
||||
generated into the wrapper code before any typemap code that calls it.
|
||||
</p>
|
||||
|
|
@ -3983,29 +3983,34 @@ inclusion of the other fragments.
|
|||
|
||||
<li>
|
||||
<p>
|
||||
A typemap can also use more than one fragment with the same syntax:
|
||||
A typemap can also use more than one fragment:
|
||||
</p>
|
||||
<div class="code">
|
||||
<pre>
|
||||
%typemap("in", "header", fragment="frag1", fragment="frag2", fragment="frag3") "";
|
||||
</pre>
|
||||
</div>
|
||||
<p>
|
||||
<em>New in SWIG 4.1.</em>
|
||||
</p>
|
||||
|
||||
<p>An older syntax allows multiple fragments to be specified in a comma
|
||||
separated list inside a single keyword argument. Consider:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%typemap(in, fragment="frag1, frag2, frag3") {...}
|
||||
%typemap("in", fragment="frag1", fragment="frag2", fragment="frag3") {...}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
which is equivalent to:
|
||||
<b>Compatibility note: </b> The ability to use multiple
|
||||
<tt>fragment</tt> keys as shown above was introduced in SWIG-4.1.0.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Multiple fragments can alternatively be specified as a comma
|
||||
separated list value in a single <tt>fragment</tt> key.
|
||||
Note that no whitespace is allowed within this comma separated list.
|
||||
The following is the equivalent to the above:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%typemap(in, fragment="frag1,frag2,frag3") {...}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
which in turn is functionally equivalent to:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
|
|
|
|||
|
|
@ -35,15 +35,35 @@ int foo(int hola)
|
|||
|
||||
%}
|
||||
|
||||
/* Instantiate multiple fragments at once using fragments in comma separated list */
|
||||
typedef int comma_frag3;
|
||||
|
||||
%fragment("comma_frag1","header", noblock=1) {
|
||||
typedef int comma_frag1;
|
||||
}
|
||||
|
||||
%fragment("comma_frag2","header", noblock=1, noblock=1) {
|
||||
typedef comma_frag1 comma_frag2;
|
||||
}
|
||||
|
||||
%fragment("comma_frag3","header",
|
||||
fragment="comma_frag1,comma_frag2")
|
||||
%{typedef comma_frag2 comma_frag3;%}
|
||||
|
||||
%fragment("comma_frag3");
|
||||
%inline %{
|
||||
comma_frag3 my_comma_frag_int = 0;
|
||||
%}
|
||||
|
||||
|
||||
/* Instantiate multiple fragments at once using multiple keywords */
|
||||
typedef int int_infrag3;
|
||||
typedef int explicit_frag3;
|
||||
|
||||
%fragment("explicit_frag1","header", noblock=1) {
|
||||
typedef int explicit_frag1;
|
||||
}
|
||||
|
||||
%fragment("explicit_frag2","header", noblock=1, noblock=1) {
|
||||
%fragment("explicit_frag2","header", noblock=1) {
|
||||
typedef explicit_frag1 explicit_frag2;
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +91,7 @@ typedef int_infrag1 int_infrag2;
|
|||
typedef int int_infrag1;
|
||||
%}
|
||||
%fragment("infrag2","runtime") %{
|
||||
__second_infrag2_fragment_is_ignored_this_will_not_compile_if_emitted_
|
||||
typedef int_infrag1 int_infrag2;
|
||||
%}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue