1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | // See the LICENSE file in the project root for more information. |
4 | |
5 | #include <stdio.h> |
6 | #include <xplatform.h> |
7 | |
8 | int intManaged = 1000; |
9 | int intNative = 2000; |
10 | |
11 | int intReturn = 3000; |
12 | int intReturnA = 4000; |
13 | int intReturnW = 5000; |
14 | |
15 | int intErrReturn = 6000; |
16 | |
17 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_Int_InOut(/*[In,Out]*/int intValue) |
18 | { |
19 | //Check the input |
20 | if(intValue != intManaged) |
21 | { |
22 | printf("Error in Function Marshal_Int_InOut(Native Client)\n" ); |
23 | |
24 | //Expected |
25 | printf("Expected:%u\n" , intManaged); |
26 | |
27 | //Actual |
28 | printf("Actual:%u\n" ,intValue); |
29 | |
30 | //Return the error value instead if verification failed |
31 | return intErrReturn; |
32 | } |
33 | |
34 | //In-Place Change |
35 | intValue = intNative; |
36 | |
37 | //Return |
38 | return intReturn; |
39 | } |
40 | |
41 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_Int_InOutA(/*[In,Out]*/int intValue) |
42 | { |
43 | //Check the input |
44 | if(intValue != intManaged) |
45 | { |
46 | printf("Error in Function Marshal_Int_InOutA(Native Client)\n" ); |
47 | |
48 | //Expected |
49 | printf("Expected:%u\n" , intManaged); |
50 | |
51 | //Actual |
52 | printf("Actual:%u\n" ,intValue); |
53 | |
54 | //Return the error value instead if verification failed |
55 | return intErrReturn; |
56 | } |
57 | |
58 | //In-Place Change |
59 | intValue = intNative; |
60 | |
61 | //Return |
62 | return intReturnA; |
63 | } |
64 | |
65 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_Int_InOutW(/*[In,Out]*/int intValue) |
66 | { |
67 | //Check the input |
68 | if(intValue != intManaged) |
69 | { |
70 | printf("Error in Function Marshal_Int_InOutW(Native Client)\n" ); |
71 | |
72 | //Expected |
73 | printf("Expected:%u\n" , intManaged); |
74 | |
75 | //Actual |
76 | printf("Actual:%u\n" ,intValue); |
77 | |
78 | //Return the error value instead if verification failed |
79 | return intErrReturn; |
80 | } |
81 | |
82 | //In-Place Change |
83 | intValue = intNative; |
84 | |
85 | //Return |
86 | return intReturnW; |
87 | } |
88 | |
89 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE MarshalPointer_Int_InOut(/*[in,out]*/int *pintValue) |
90 | { |
91 | //Check the input |
92 | if(*pintValue != intManaged) |
93 | { |
94 | printf("Error in Function MarshalPointer_Int_InOut(Native Client)\n" ); |
95 | |
96 | //Expected |
97 | printf("Expected:%u\n" , intManaged); |
98 | |
99 | //Actual |
100 | printf("Actual:%u\n" ,*pintValue); |
101 | |
102 | //Return the error value instead if verification failed |
103 | return intErrReturn; |
104 | } |
105 | |
106 | //In-Place Change |
107 | *pintValue = intNative; |
108 | |
109 | //Return |
110 | return intReturn; |
111 | } |
112 | |
113 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE MarshalPointer_Int_InOutA(/*[in,out]*/int *pintValue) |
114 | { |
115 | //Check the input |
116 | if(*pintValue != intManaged) |
117 | { |
118 | printf("Error in Function MarshalPointer_Int_InOutA(Native Client)\n" ); |
119 | |
120 | //Expected |
121 | printf("Expected:%u\n" , intManaged); |
122 | |
123 | //Actual |
124 | printf("Actual:%u\n" ,*pintValue); |
125 | |
126 | //Return the error value instead if verification failed |
127 | return intErrReturn; |
128 | } |
129 | |
130 | //In-Place Change |
131 | *pintValue = intNative; |
132 | |
133 | //Return |
134 | return intReturnA; |
135 | } |
136 | |
137 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE MarshalPointer_Int_InOutW(/*[in,out]*/int *pintValue) |
138 | { |
139 | //Check the input |
140 | if(*pintValue != intManaged) |
141 | { |
142 | printf("Error in Function MarshalPointer_Int_InOutW(Native Client)\n" ); |
143 | |
144 | //Expected |
145 | printf("Expected:%u\n" , intManaged); |
146 | |
147 | //Actual |
148 | printf("Actual:%u\n" ,*pintValue); |
149 | |
150 | //Return the error value instead if verification failed |
151 | return intErrReturn; |
152 | } |
153 | |
154 | //In-Place Change |
155 | *pintValue = intNative; |
156 | |
157 | //Return |
158 | return intReturnW; |
159 | } |
160 | |
161 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_Int_InOut2A(/*[In,Out]*/int intValue) |
162 | { |
163 | return Marshal_Int_InOutA(intValue); |
164 | } |
165 | |
166 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE Marshal_Int_InOut2W(/*[In,Out]*/int intValue) |
167 | { |
168 | return Marshal_Int_InOutW(intValue); |
169 | } |
170 | |
171 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE MarshalPointer_Int_InOut2A(/*[in,out]*/int *pintValue) |
172 | { |
173 | return MarshalPointer_Int_InOutA(pintValue); |
174 | } |
175 | |
176 | extern "C" DLL_EXPORT int STDMETHODCALLTYPE MarshalPointer_Int_InOut2W(/*[in,out]*/int *pintValue) |
177 | { |
178 | return MarshalPointer_Int_InOutW(pintValue); |
179 | } |
180 | |