Change style of C code to "targetlang"
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-c@13643 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
beb9851f04
commit
0db6a8c201
1 changed files with 9 additions and 9 deletions
|
|
@ -198,7 +198,7 @@ For each C function declared in the interface file a wrapper function is created
|
||||||
For example, for function declaration:
|
For example, for function declaration:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="targetlang"><pre>
|
||||||
int gcd(int x, int y);
|
int gcd(int x, int y);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ int gcd(int x, int y);
|
||||||
The output is simply:
|
The output is simply:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="targetlang"><pre>
|
||||||
int _wrap_gcd(int arg1, int arg2) {
|
int _wrap_gcd(int arg1, int arg2) {
|
||||||
int result;
|
int result;
|
||||||
result = gcd(arg1,arg2);
|
result = gcd(arg1,arg2);
|
||||||
|
|
@ -218,7 +218,7 @@ int _wrap_gcd(int arg1, int arg2) {
|
||||||
Then again, this wrapper function is usually called from C using helper function declared in proxy file, preserving the original name:
|
Then again, this wrapper function is usually called from C using helper function declared in proxy file, preserving the original name:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="targetlang"><pre>
|
||||||
int gcd(int arg1, int arg2) {
|
int gcd(int arg1, int arg2) {
|
||||||
return _wrap_gcd(arg1,arg2);
|
return _wrap_gcd(arg1,arg2);
|
||||||
}
|
}
|
||||||
|
|
@ -241,7 +241,7 @@ int gcd(int POSITIVE, int POSITIVE);
|
||||||
And now the generated result looks like:
|
And now the generated result looks like:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="targetlang"><pre>
|
||||||
int _wrap_gcd(int arg1, int arg2) {
|
int _wrap_gcd(int arg1, int arg2) {
|
||||||
{
|
{
|
||||||
if (arg1 <= 0)
|
if (arg1 <= 0)
|
||||||
|
|
@ -272,7 +272,7 @@ Wrapping variables comes also without any special issues. All global variables a
|
||||||
You can still apply some of the SWIG features when handling structs, e.g. <tt>%extend</tt> directive. Suppose, you have a C struct declaration:
|
You can still apply some of the SWIG features when handling structs, e.g. <tt>%extend</tt> directive. Suppose, you have a C struct declaration:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="targetlang"><pre>
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int x;
|
int x;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
@ -341,7 +341,7 @@ This section briefly covers the essential aspects of this wrapping.
|
||||||
Consider the following example. We have a C++ class, and want to use it from C code.
|
Consider the following example. We have a C++ class, and want to use it from C code.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="targetlang"><pre>
|
||||||
class Circle {
|
class Circle {
|
||||||
public:
|
public:
|
||||||
double radius;
|
double radius;
|
||||||
|
|
@ -367,7 +367,7 @@ Circle *circle;
|
||||||
The generated functions make calls to class' constructors and destructors, respectively. They also do all the necessary things required by the SWIG object management system in C.
|
The generated functions make calls to class' constructors and destructors, respectively. They also do all the necessary things required by the SWIG object management system in C.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="targetlang"><pre>
|
||||||
Circle * new_Circle(double r);
|
Circle * new_Circle(double r);
|
||||||
void delete_Circle(Circle * self);
|
void delete_Circle(Circle * self);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
@ -376,7 +376,7 @@ void delete_Circle(Circle * self);
|
||||||
The class <tt>Circle</tt> has a public variable called <tt>radius</tt>. SWIG generates a pair of setters and getters for each such variable:
|
The class <tt>Circle</tt> has a public variable called <tt>radius</tt>. SWIG generates a pair of setters and getters for each such variable:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="targetlang"><pre>
|
||||||
void Circle_radius_set(Circle * self, double radius);
|
void Circle_radius_set(Circle * self, double radius);
|
||||||
double Circle_radius_get(Circle * self);
|
double Circle_radius_get(Circle * self);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
@ -385,7 +385,7 @@ double Circle_radius_get(Circle * self);
|
||||||
For each public method, an appropriate function is generated:
|
For each public method, an appropriate function is generated:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="targetlang"><pre>
|
||||||
double Circle_area(Circle * self);
|
double Circle_area(Circle * self);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue