Restrict the name used in %extend to be just the struct/class name and not a typedef to a class/struct. Typedefs were only partially working anyway. Anonymous struct typedefs excluded. Deprecate with a warning for now.

This commit is contained in:
William S Fulton 2013-02-18 19:53:37 +00:00
commit b80f4dc5e2
10 changed files with 134 additions and 20 deletions

View file

@ -2699,7 +2699,7 @@ the following declaration :</p>
<div class="code"><pre>
/* file : vector.h */
...
typedef struct {
typedef struct Vector {
double x,y,z;
} Vector;
@ -2772,7 +2772,7 @@ of the Vector structure. For example:</p>
#include "vector.h"
%}
typedef struct {
typedef struct Vector {
double x,y,z;
%extend {
Vector(double x, double y, double z) { ... }
@ -2783,7 +2783,7 @@ typedef struct {
</pre></div>
<p>
Finally, <tt>%extend</tt> can be used to access externally written
Note that <tt>%extend</tt> can be used to access externally written
functions provided they follow the naming convention used in this
example :</p>
@ -2814,7 +2814,7 @@ double Vector_magnitude(Vector *v) {
#include "vector.h"
%}
typedef struct {
typedef struct Vector {
double x,y,z;
%extend {
Vector(int,int,int); // This calls new_Vector()
@ -2826,6 +2826,37 @@ typedef struct {
</pre>
</div>
<p>
The name used for %extend should be the name of the struct and not the name of any typedef to the struct.
For example:
</p>
<div class="code"><pre>
typedef struct Integer {
int value;
} Int;
%extend Integer { ... } /* Correct name */
%extend Int { ... } /* Incorrect name */
struct Float {
float value;
};
typedef struct Float FloatValue;
%extend Float { ... } /* Correct name */
%extend FloatValue { ... } /* Incorrect name */
</pre></div>
<p>
There is one exception to this rule and that is when the struct is anonymously named such as:
</p>
<div class="code"><pre>
typedef struct {
double value;
} Double;
%extend Double { ... } /* Okay */
</pre></div>
<p>
A little known feature of the <tt>%extend</tt> directive is that
it can also be used to add synthesized attributes or to modify the
@ -2862,7 +2893,7 @@ For example, consider this interface:
<div class="code">
<pre>
typedef struct {
typedef struct Person {
char name[50];
...
} Person;
@ -2876,7 +2907,7 @@ the interface as follows to ensure this occurs whenever a name is read or writte
<div class="code">
<pre>
typedef struct {
typedef struct Person {
%extend {
char name[50];
}