Add docs about typemaps used by the C backend for proxy code generation.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13642 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Leif Middelschulte 2012-08-17 17:22:28 +00:00
commit beb9851f04

View file

@ -643,6 +643,51 @@ Finally, the return value variable is returned.
return result;
</pre></div>
<H4>The Proxy</H4>
Compared to the wrapper code generation, the proxy code is very simple.</br>
Basically it just casts types for the wrapper call. Let's have a look at the corresponding proxy header file code of the interface above.
<div class="targetlang"><pre>
//proxy header file
typedef struct SwigObj_SomeClass SomeClass;
SomeClass * new_SomeClass();
void delete_SomeClass(SomeClass * carg1);
SomeClass* someFunction(SomeIntTemplateClass* carg1, int carg2);
typedef struct SwigObj_SomeIntTemplateClass SomeIntTemplateClass;
SomeIntTemplateClass * new_SomeIntTemplateClass();
void delete_SomeIntTemplateClass(SomeIntTemplateClass * carg1);
</pre></div>
For shortness sake, we'll only examine one function that uses all proxy typemaps, as the other functions are analogous.
<div class="targetlang"><pre>
SomeClass* someFunction(SomeIntTemplateClass* carg1, int carg2) {
return (SomeClass*)_wrap_someFunction((SwigObj *)carg1, (int)carg2);
}
</pre></div>
Again, let's first examine the protype:
<div class="targetlang"><pre>
proxycouttype proxy proxy
---------- --------------------- ---
SomeClass* someFunction(SomeIntTemplateClass* carg1, int carg2);
</pre></div>
In the body of this function, we'll reuse the 'proxycouttype' and 'ctype' to cast the return value and arguments of the wrapper function.
<div class="targetlang"><pre>
proxycouttype ctype
---------- ---------
return (SomeClass*)_wrap_someFunction((SwigObj *)carg1, (int)carg2);
</pre></div>
<H2><a name="C_exceptions"></a>36.5 Exception handling</H2>