~ubuntu-branches/ubuntu/saucy/monodevelop/saucy

« back to all changes in this revision

Viewing changes to external/mono-tools/create-native-map/src/TestMap.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-05-27 18:08:20 UTC
  • mfrom: (1.8.5) (1.5.8 sid)
  • Revision ID: package-import@ubuntu.com-20120527180820-f1ub6lhg0s50wci1
Tags: 3.0.2+dfsg-3
* [fcecfe7] Fix monodevelop-core-addins.pc.in to point to actual 
  installed location of assemblies.
* [26e1a07] DebSrc 3.0 does not support Quilt's -p parameter, so 
  manually adjust the path in the patch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Test file for make-map.cs
 
2
using System;
 
3
using System.Runtime.InteropServices;
 
4
using System.Text;
 
5
 
 
6
// Make sure that a null namespace doesn't kill make-map
 
7
class GlobalClass {}
 
8
 
 
9
namespace MakeMap.Test {
 
10
        struct ForDelegate {int i;}
 
11
        [Map]
 
12
        delegate string MyDelegate (
 
13
                        bool b1, byte b2, sbyte b3, short s1, ushort us1, 
 
14
                        int i1, uint ui1, long l1, ulong ul1, 
 
15
                        IntPtr p1, UIntPtr p2, string s2, StringBuilder sb1,
 
16
                        HandleRef h, ForDelegate fd);
 
17
 
 
18
        [Map]
 
19
        enum TestEnum : long {
 
20
                Foo,
 
21
                Bar,
 
22
                Baz,
 
23
                Qux,
 
24
        }
 
25
 
 
26
        [Map, Flags]
 
27
        enum SimpleFlagsEnum {
 
28
                None  = 0,
 
29
                A     = 1,
 
30
                B     = 2,
 
31
                C     = 4,
 
32
                D     = 8,
 
33
        }
 
34
 
 
35
        [Map, Flags]
 
36
        enum FlagsEnum {
 
37
                None  = 0,
 
38
                A     = 1,
 
39
                B     = 2,
 
40
                C     = 4,
 
41
                D     = 8,
 
42
                All   = A | B | C | D,
 
43
                // Device types
 
44
                S_IFMT      = 0xF000, // Bits which determine file type
 
45
                [Map(SuppressFlags="S_IFMT")]
 
46
                S_IFDIR     = 0x4000, // Directory
 
47
                [Map(SuppressFlags="S_IFMT")]
 
48
                S_IFCHR     = 0x2000, // Character device
 
49
                [Map(SuppressFlags="S_IFMT")]
 
50
                S_IFBLK     = 0x6000, // Block device
 
51
                [Map(SuppressFlags="S_IFMT")]
 
52
                S_IFREG     = 0x8000, // Regular file
 
53
                [Map(SuppressFlags="S_IFMT")]
 
54
                S_IFIFO     = 0x1000, // FIFO
 
55
                [Map(SuppressFlags="S_IFMT")]
 
56
                S_IFLNK     = 0xA000, // Symbolic link
 
57
                [Map(SuppressFlags="S_IFMT")]
 
58
                S_IFSOCK    = 0xC000, // Socket
 
59
        }
 
60
 
 
61
        [Map ("struct foo")]
 
62
        struct Foo {
 
63
                public int foo;
 
64
 
 
65
                public IntPtr p;
 
66
 
 
67
                // this should be within a #ifdef HAVE_AUTOCONF_ME block, due to
 
68
                // --autoconf-member.
 
69
                public long autoconf_me;
 
70
        }
 
71
 
 
72
        [Map ("struct foo_holder")]
 
73
        struct FooHolder {
 
74
                public Foo      foo;
 
75
                public TestEnum mode;
 
76
        }
 
77
 
 
78
        delegate void DelFoo (int i, Foo f);
 
79
        delegate void DelRefFoo (int i, ref Foo f);
 
80
        delegate void DelArrayFoo (int i, Foo[] f);
 
81
        delegate void DelRefArrayFoo (int i, ref Foo[] f);
 
82
        delegate void DelBaz (int i, Baz b);
 
83
        delegate void DelRefBaz (int i, ref Baz b);
 
84
        delegate void DelArrayBaz (int i, Baz[] b);
 
85
        delegate void DelRefArrayBaz (int i, ref Baz[] b);
 
86
 
 
87
        [StructLayout (LayoutKind.Sequential)]
 
88
        class Baz {
 
89
                public DelFoo b1;
 
90
                public DelRefFoo b2;
 
91
                public DelArrayFoo b3;
 
92
                public DelRefArrayFoo b4;
 
93
                public DelBaz b5;
 
94
                public DelRefBaz b6;
 
95
                public DelArrayBaz b7;
 
96
                public DelRefArrayBaz b8;
 
97
        }
 
98
 
 
99
        [StructLayout (LayoutKind.Sequential)]
 
100
        class Qux {
 
101
                public int i;
 
102
                public Baz b;
 
103
        }
 
104
 
 
105
        class NativeMethods {
 
106
                [DllImport ("NativeLib")]
 
107
                private static extern void UseQux (DelFoo b, ref Qux q);
 
108
 
 
109
                // This shouldn't appear in test.h, due to --exclude-native-symbol
 
110
                [DllImport ("NativeLib")]
 
111
                private static extern void exclude_native_symbol ();
 
112
        }
 
113
}
 
114
 
 
115
// Testing namespace renaming; this should be NSTo within test.h
 
116
namespace MakeMap.ToBeRenamed {
 
117
        [Map]
 
118
        class Stat {
 
119
                // this should be st_atime_ in test.h due to --rename-member.
 
120
                [Map ("time_t")] public long st_atime;
 
121
        }
 
122
 
 
123
        [Map]
 
124
        enum Colors {
 
125
                Red, Blue, Green
 
126
        }
 
127
}
 
128