lity(ComponentAnalyzerEvaluateSelfUpdate): Component: amd64_microsoft-windows-cryptsvc-dll_31bf3856ad364e35_6.1.7601.22948_none_d492bbeccaa14239, elevate: 2, applicable(true/false): 0
2015-04-26 13:48:13, Info                  CBS    Appl: Selfupdate, Component: amd64_microsoft-windows-wintrust-dll_31bf3856ad364e35_0.0.0.0_none_6fa6caf69a98926f (6.1.7601.22948), elevation:2, lower version revision holder: 6.1.7601.18741
2015-04-26 13:48:13, Info                  CBS    Applicability(ComponentAnalyzerEvaluateSelfUpdate): Component: amd64_microsoft-windows-wintrust-dll_31bf3856ad364e35_6.1.7601.22948_none_4e415c4dc9e2d953, elevate: 2, applicable(true/false): 0
2015-04-26 13:48:13, Info                  CBS    Appl: Selfupdate, Component: x86_microsoft-windows-capi2-instrumentation_31bf3856ad364e35_0.0.0.0_none_e18805f24e5bcbd6 (6.1.7601.22948), elevation:2, lower version revision holder: 6.1.7601.18741
2015-04-26 13:48:13, Info                  CBS    Applicability(ComponentAnalyzerEvaluateSelfUpdate): Component: x86_microsoft-windows-capi2-instrumentation_31bf3856ad364e35_6.1.7601.22948_none_c02297497da612ba, elevate: 2, applicable(true/false): 0
2015-04-26 13:48:13, Info                  CBS    Appl: Selfupdate, Component: x86_microsoft-windows-capi2-wintrust-reg_31bf3856ad364e35_0.0.0.0_none_acd64fc6dbb76a3d (6.1.7601.22948), elevation:2, lower version revision holder: 6.1.7601.18741
2015-04-26 13:48:13, Info                  CBS    Applicability(ComponentAnalyzerEvaluateSelfUpdate): Component: x86_microsoft-windows-capi2-wintrust-reg_31bf3856ad364e35_6.1.7601.22948_none_8b70e11e0b01b121, elevate: 2, applicable(true/false): 0
2015-04-26 13:48:13, Info                  CBS    Appl: Selfupdate, Component: x86_microsoft-windows-crypt32-dll.resources_31bf3856ad364e35_0.0.0.0_ar-sa_5d612fbc3d6e26f5 (6.1.7601.22948), elevation:2, lower version revision holder: 0.0.0.0
2015-04-26 13:48:13, Info                  CBS    Applicability(ComponentAnalyzerEvaluateSelfUpdate): Component: x86_microsoft-windows-crypt32-d<html>
<head>
<title>SWIG:Examples:perl5:class</title>
</head>

<body bgcolor="#ffffff">


<tt>SWIG/Examples/perl5/class/</tt>
<hr>

<H2>Wrapping a simple C++ class</H2>

<p>
This example illustrates the most primitive form of C++ class wrapping performed
by SWIG.  In this case, C++ classes are simply transformed into a collection of
C-style functions that provide access to class members.

<h2>The C++ Code</h2>

Suppose you have some C++ classes described by the following (and admittedly lame) 
header file:

<blockquote>
<pre>
/* File : example.h */

class Shape {
public:
  Shape() {
    nshapes++;
  }
  virtual ~Shape() {
    nshapes--;
  };
  double  x, y;   
  void    move(double dx, double dy);
  virtual double area() = 0;
  virtual double perimeter() = 0;
  static  int nshapes;
};

class Circle : public Shape {
private:
  double radius;
public:
  Circle(double r) : radius(r) { };
  virtual double area();
  virtual double perimeter();
};

class Square : public Shape {
private:
  double width;
public:
  Square(double w) : width(w) { };
  virtual double area();
  virtual double perimeter();
};
</pre>
</blockquote>

<h2>The SWIG interface</h2>

A simple SWIG interface for this can be built by simply grabbing the header file
like this:

<blockquote>
<pre>
/* File : example.i */
%module example

%{
#include "example.h"
%}

/* Let's just grab the original header file here */
%include "example.h"
</pre>
</blockquote>

Note: when creating a C++ extension, you must run SWIG with the <tt>-c++</tt> option like this:
<blockquote>
<pre>
% swig -c++ -python example.i
</pre>
</blockquote>

<h2>A sample Perl script</h2>

Click <a href="runme.pl">here</a> to see a script that calls the C++ functions from Perl.

<h2>Key points</h2>

<ul>
<li>To create a new object, you call a constructor like this:

<blockquote>
<pre>
$c = example::new_Circle(10.0);
</pre>
</blockquote>

<p>
<li>To access member data, a pair of accessor functions are used.
For example:

<blockquote>
<pre>
example::Shape_x_set($c,15);    # Set member data
$x = example::Shape_x_get($c);   # Get member data
</pre>
</blockquote>

Note: when accessing member data, the name of the class in which
the data member is defined is used.  For example <tt>Shape_x_get()</tt>.

<p>
<li>To invoke a member function, you simply do this

<blockquote>
<pre>
print "The area is ", example::Shape_area($c);
</pre>
</blockquote>

<p>
<li>Type checking knows about the inheritance structure of C++. For example:

<blockquote>
<pre>
example::Shape_area($c);       # Works (c is a Shape)
example::Circle_area($c);      # Works (c is a Circle)
example::Square_area($c);      # Fails (c is definitely not a Square)
</pre>
</blockquote>

<p>
<li>To invoke a destructor, simply do this

<blockquote>
<pre>
example::delete_Shape($c);     # Deletes a shape
</pre>
</blockquote>

<p>
<li>Static member variables are wrapped as C global variables.  For example:

<blockquote>
<pre>
$n = $example::Shape_nshapes;     # Get a static data member
$example::Shapes_nshapes = 13;   # Set a static data member
</pre>
</blockquote>

</ul>

<h2>General Comments</h2>

<ul>
<li>This low-level interface is not the only way to handle C++ code.  Proxy classes
provide a much higher-level interface.

<p>
<li>SWIG *does* know how to properly perform upcasting of objects in an inheritance
hierarchy (including multiple inheritance).  Therefore it is perfectly safe to pass
an object of a derived class to any function involving a base class.

<p>
<li>A wide variety of C++ features are not currently supported by SWIG.  Here is the
short and incomplete list:

<p>
<ul>
<li>Overloaded methods and functions.  SWIG wrappers don't know how to resolve name
conflicts so you must give an alternative name to any overloaded method name using the
%name directive like this:

<blockquote>
<pre>
void foo(int a);  
%name(foo2) void foo(double a, double b);
</pre>
</blockquote>

<p>
<li>Overloaded operators.  Not supported at all. The only workaround for this is
to write a helper function. For example:

<blockquote>
<pre>
%inline %{
    Vector *vector_add(Vector *a, Vector *b) {
          ... whatever ...
    }
%}
</pre>
</blockquote>

<p>
<li>Namespaces.  Not supported at all. Won't be supported until SWIG2.0 (if at all).

</ul>

<hr>
</body>
</html>
