Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TestMap.cs « src « create-native-map - github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7d489ffb671e10835a7e5998af667bd23a7192ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Test file for make-map.cs
using System;
using System.Runtime.InteropServices;
using System.Text;

// Make sure that a null namespace doesn't kill make-map
class GlobalClass {}

namespace MakeMap.Test {
	struct ForDelegate {int i;}
	[Map]
	delegate string MyDelegate (
			bool b1, byte b2, sbyte b3, short s1, ushort us1, 
			int i1, uint ui1, long l1, ulong ul1, 
			IntPtr p1, UIntPtr p2, string s2, StringBuilder sb1,
			HandleRef h, ForDelegate fd);

	[Map]
	public enum TestEnum : long {
		Foo,
		Bar,
		Baz,
		Qux,
	}

	[Map, Flags]
	public enum SimpleFlagsEnum {
		None  = 0,
		A     = 1,
		B     = 2,
		C     = 4,
		D     = 8,
	}

	[Map, Flags]
	public enum FlagsEnum {
		None  = 0,
		A     = 1,
		B     = 2,
		C     = 4,
		D     = 8,
		All   = A | B | C | D,
		// Device types
		S_IFMT      = 0xF000, // Bits which determine file type
		[Map(SuppressFlags="S_IFMT")]
		S_IFDIR     = 0x4000, // Directory
		[Map(SuppressFlags="S_IFMT")]
		S_IFCHR     = 0x2000, // Character device
		[Map(SuppressFlags="S_IFMT")]
		S_IFBLK     = 0x6000, // Block device
		[Map(SuppressFlags="S_IFMT")]
		S_IFREG     = 0x8000, // Regular file
		[Map(SuppressFlags="S_IFMT")]
		S_IFIFO     = 0x1000, // FIFO
		[Map(SuppressFlags="S_IFMT")]
		S_IFLNK     = 0xA000, // Symbolic link
		[Map(SuppressFlags="S_IFMT")]
		S_IFSOCK    = 0xC000, // Socket
	}

	[Map ("struct foo")]
	struct Foo {
		public int foo;

		public IntPtr p;

		// this should be within a #ifdef HAVE_AUTOCONF_ME block, due to
		// --autoconf-member.
		public long autoconf_me;
	}

	[Map ("struct foo_holder")]
	struct FooHolder {
		public Foo      foo;
		public TestEnum mode;
	}

	delegate void DelFoo (int i, Foo f);
	delegate void DelRefFoo (int i, ref Foo f);
	delegate void DelArrayFoo (int i, Foo[] f);
	delegate void DelRefArrayFoo (int i, ref Foo[] f);
	delegate void DelBaz (int i, Baz b);
	delegate void DelRefBaz (int i, ref Baz b);
	delegate void DelArrayBaz (int i, Baz[] b);
	delegate void DelRefArrayBaz (int i, ref Baz[] b);

	[StructLayout (LayoutKind.Sequential)]
	class Baz {
		public DelFoo b1;
		public DelRefFoo b2;
		public DelArrayFoo b3;
		public DelRefArrayFoo b4;
		public DelBaz b5;
		public DelRefBaz b6;
		public DelArrayBaz b7;
		public DelRefArrayBaz b8;
	}

	[StructLayout (LayoutKind.Sequential)]
	class Qux {
		public int i;
		public Baz b;
	}

	class NativeMethods {
		[DllImport ("NativeLib")]
		private static extern void UseQux (DelFoo b, ref Qux q);

		// This shouldn't appear in test.h, due to --exclude-native-symbol
		[DllImport ("NativeLib")]
		private static extern void exclude_native_symbol ();
	}

	[Map]
	enum InternalEnum : long {
		Foo,
	}

	[Map ("struct parent")]
	[StructLayout (LayoutKind.Sequential)]
	public class Parent {
		public int i;
	}

	[Map ("struct child")]
	[StructLayout (LayoutKind.Sequential)]
	public class Child : Parent {
		public int j;
	}
}

// Testing namespace renaming; this should be NSTo within test.h
namespace MakeMap.ToBeRenamed {
	[Map]
	class Stat {
		// this should be st_atime_ in test.h due to --rename-member.
		[Map ("time_t")] public long st_atime;
	}

	[Map]
	public enum Colors {
		Red, Blue, Green
	}
}