summaryrefslogtreecommitdiff
path: root/tests/src/Interop/PrimitiveMarshalling/Bool/BoolNative.cpp
blob: 79ab5c9a8f7257a36d65b426a254d4706acca097 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#include <xplatform.h>
#include <stdio.h>


BOOL boolManaged = true;
BOOL boolNative = false;

extern "C" DLL_EXPORT BOOL __stdcall Marshal_In(/*[in]*/BOOL boolValue)
{
	//Check the input
	if(boolValue != boolManaged)
	{
		printf("Error in Function Marshal_In(Native Client)\n");

		//Expected
		printf("Expected: %s", (boolManaged)?"true":"false");

		//Actual
		printf("Actual:  %s", (boolValue)?"true":"false");

		//Return the error value instead if verification failed
		return false;
	}

	return true;
}

extern "C" DLL_EXPORT BOOL __stdcall Marshal_InOut(/*[In,Out]*/BOOL boolValue)
{
	//Check the input
	if(boolValue != boolManaged)
	{
		printf("Error in Function Marshal_InOut(Native Client)\n");

		//Expected
		printf("Expected: %s", (boolManaged)?"true":"false");

		//Actual
		printf("Actual:  %s", (boolValue)?"true":"false");

		//Return the error value instead if verification failed
		return false;
	}

	//In-Place Change
	boolValue = boolNative;

	//Return
	return true;
}

extern "C" DLL_EXPORT BOOL __stdcall Marshal_Out(/*[Out]*/BOOL boolValue)
{
	//In-Place Change
	boolValue = boolNative;

	//Return
	return true;
}

extern "C" DLL_EXPORT BOOL __stdcall MarshalPointer_In(/*[in]*/BOOL *pboolValue)
{
	//Check the input
	if(*pboolValue != boolManaged)
	{
		printf("Error in Function MarshalPointer_In(Native Client)\n");

		//Expected
		printf("Expected: %s", (boolManaged)?"true":"false");

		//Actual
		printf("Actual:  %s", (*pboolValue)?"true":"false");

		//Return the error value instead if verification failed
		return false;
	}

	return true;
}

extern "C" DLL_EXPORT BOOL __stdcall MarshalPointer_InOut(/*[in,out]*/BOOL *pboolValue)
{
	//Check the input
	if(*pboolValue != boolManaged)
	{
		printf("Error in Function MarshalPointer_InOut(Native Client)\n");

		//Expected
		printf("Expected: %s", (boolManaged)?"true":"false");

		//Actual
		printf("Actual:  %s", (*pboolValue)?"true":"false");

		//Return the error value instead if verification failed
		return false;
	}

	//In-Place Change
	*pboolValue = boolNative;

	//Return
	return true;
}

extern "C" DLL_EXPORT BOOL __stdcall MarshalPointer_Out(/*[out]*/ BOOL *pboolValue)
{
	//In-Place Change
	*pboolValue = boolNative;

	//Return
	return true;
}

#pragma warning(push)
#if _MSC_VER <= 1900
// 'BOOL' forcing value to bool 'true' or 'false'
#pragma warning(disable: 4800)
#endif

extern "C" DLL_EXPORT bool __stdcall Marshal_As_In(/*[in]*/bool boolValue)
{
	//Check the input
	if(boolValue != (bool)boolManaged)
	{
		printf("Error in Function Marshal_As_In(Native Client)\n");

		//Expected
		printf("Expected: %s", (boolManaged)?"true":"false");

		//Actual
		printf("Actual:  %s", (boolValue)?"true":"false");

		//Return the error value instead if verification failed
		return false;
	}

	return true;
}

extern "C" DLL_EXPORT bool __stdcall Marshal_As_InOut(/*[In,Out]*/bool boolValue)
{
	//Check the input
	if(boolValue != (bool)boolManaged)
	{
		printf("Error in Function Marshal_As_InOut(Native Client)\n");

		//Expected
		printf("Expected: %s", (boolManaged)?"true":"false");

		//Actual
		printf("Actual:  %s", (boolValue)?"true":"false");

		//Return the error value instead if verification failed
		return false;
	}

	//In-Place Change
	boolValue = (bool)boolNative;

	//Return
	return true;
}

extern "C" DLL_EXPORT bool __stdcall Marshal_As_Out(/*[Out]*/bool boolValue)
{
	//In-Place Change
	boolValue = (bool)boolNative;

	//Return
	return true;
}
#pragma warning(pop)