PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/csharp_attributes.i

#
Swig | 62 lines | 53 code | 9 blank | 0 comment | 0 complexity | cd94b06e4bf7cba8923b8765328392be MD5 | raw file
 1%module(directors="1") csharp_attributes
 2
 3// Test the inattributes and outattributes typemaps
 4%typemap(cstype, outattributes="[IntOut]", inattributes="[IntIn]") int "int"
 5%typemap(imtype, outattributes="[IntegerOut]", inattributes="[IntegerIn]") int "int"
 6
 7%inline %{
 8class Stations {
 9public:
10  Stations(int myInt) { }
11  int Reading(int myInt) { return myInt; }
12  static int Swindon(int myInt) { return myInt; }
13};
14#define TESTMACRO 10
15int GlobalFunction(int myInt) { return myInt; }
16%}
17
18//%include "enumsimple.swg"
19//%include "enumtypesafe.swg"
20
21// Test the attributes feature
22%csattributes MoreStations::MoreStations()      "[InterCity1]"
23%csattributes MoreStations::Chippenham()        "[InterCity2]"
24%csattributes MoreStations::Bath()              "[InterCity3]"
25%csattributes Bristol                           "[InterCity4]"
26%csattributes WestonSuperMare                   "[InterCity5]"
27%csattributes Wales                             "[InterCity6]"
28%csattributes Paddington()                      "[InterCity7]"
29%csattributes DidcotParkway                     "[InterCity8]"
30%csattributes MoreStations::Cardiff             "[System.ComponentModel.Description(\"Cardiff city station\")]"
31%csattributes Swansea                           "[System.ComponentModel.Description(\"Swansea city station\")]"
32
33%typemap(csattributes) MoreStations "[Eurostar1]"
34%typemap(csattributes) MoreStations::Wales "[Eurostar2]"
35%typemap(csattributes) Cymru "[Eurostar3]"
36
37%inline %{
38struct MoreStations {
39  MoreStations() : Bristol(0) {}
40  void Chippenham() {}
41  static void Bath() {}
42  int Bristol;
43  static double WestonSuperMare;
44  enum Wales { Cardiff = 1, Swansea };
45};
46void Paddington() {}
47float DidcotParkway;
48enum Cymru { Llanelli };
49
50double MoreStations::WestonSuperMare = 0.0;
51%}
52
53// Test directorinattributes and directoroutattributes
54%typemap(imtype, directoroutattributes="[DirectorIntegerOut]", directorinattributes="[DirectorIntegerIn]") int "int"
55%feature("director") YetMoreStations;
56
57%inline %{
58struct YetMoreStations {
59  virtual int Slough(int x) { return x; }
60  virtual ~YetMoreStations() {}
61};
62%}