Generate C# interface

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Generate C# interface

Christophe Demez

Hi,

I have a problem to solve, I have look all around without finding any solution. I explain :

I have a C++ class and I wish to generate a C# interface for it, not a class. How can I do ?

Here is the class, IContext.hpp

class IContext
{
  public:
   
    virtual void process() = 0;

  protected:
    ~IContext() = default;
}; 

Here is the interface, IContext.i:

%module IContext
%{
  #include "IContext.hpp"
%}

%include <windows.i>

%nodefaultctor;

%interface(IContext)
{
public:
  IContext();
  ~IContext();
};

%clearnodefaultctor;

Thanks

--
Luciad Email Signature Christophe Demez
PROJECT LEADER  

LUCIAD  CONNECT  •  VISUALIZE   ANALYZE   ACT  

[hidden email]   T +32 16 23 95 91
Follow us on LinkedIn or @LUCIADconnect  

Luciad

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generate C# interface

William S Fulton


On 29 May 2017 at 13:06, Christophe Demez <[hidden email]> wrote:

Hi,

I have a problem to solve, I have look all around without finding any solution. I explain :

I have a C++ class and I wish to generate a C# interface for it, not a class. How can I do ?

Here is the class, IContext.hpp

class IContext
{
  public:
   
    virtual void process() = 0;

  protected:
    ~IContext() = default;
}; 

Here is the interface, IContext.i:

%module IContext
%{
  #include "IContext.hpp"
%}

%include <windows.i>

%nodefaultctor;

%interface(IContext)
{
public:
  IContext();
  ~IContext();
};

%clearnodefaultctor;


 

Here is a corrected version of the above (note that the module name should not be the same as one of your wrapped classes... you should get an error if you attempt to do this):

%module example

%{
  #include "IContext.hpp"
%}

%include <windows.i>
%include <swiginterface.i>

%nodefaultctor;

%interface(IContext)

class IContext
{
  public:
  
    virtual void process() = 0;

  protected:
    ~IContext() = default;
};

%clearnodefaultctor;

William

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...