| 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 <xplatform.h> |
| 6 | #include <stdio.h> |
| 7 | #include <stdlib.h> |
| 8 | |
| 9 | const int iManaged = 10; |
| 10 | const int iNative = 11; |
| 11 | |
| 12 | |
| 13 | extern "C"BOOL DLL_EXPORT __cdecl MarshalRefInt_Cdcel(int * pint) |
| 14 | { |
| 15 | //Check the Input |
| 16 | if(iManaged != *pint) |
| 17 | { |
| 18 | printf("The parameter for MarshalRefCharArray is wrong!\n"); |
| 19 | return FALSE; |
| 20 | } |
| 21 | *pint = iNative; |
| 22 | return TRUE; |
| 23 | } |
| 24 | |
| 25 | extern "C"BOOL DLL_EXPORT __stdcall MarshalRefInt_Stdcall(int * pint) |
| 26 | { |
| 27 | //Check the Input |
| 28 | if(iManaged != *pint) |
| 29 | { |
| 30 | printf("The parameter for MarshalRefCharArray is wrong!\n"); |
| 31 | return FALSE; |
| 32 | } |
| 33 | *pint = iNative; |
| 34 | return TRUE; |
| 35 | } |
| 36 | |
| 37 | typedef BOOL (__cdecl *Cdeclcaller)(int* pint); |
| 38 | extern "C"BOOL DLL_EXPORT __cdecl DoCallBack_MarshalRefInt_Cdecl(Cdeclcaller caller) |
| 39 | { |
| 40 | //Check the Input |
| 41 | int itemp = iNative; |
| 42 | if(!caller(&itemp)) |
| 43 | { |
| 44 | printf("DoCallBack_MarshalRefInt_Cdecl:The Caller() return false!\n"); |
| 45 | return FALSE; |
| 46 | } |
| 47 | if(itemp!=iManaged) |
| 48 | { |
| 49 | printf("DoCallBack_MarshalRefInt_Cdecl:The Reference Parameter returns wrong value\n"); |
| 50 | return FALSE; |
| 51 | } |
| 52 | return TRUE; |
| 53 | } |
| 54 | |
| 55 | typedef BOOL (__stdcall *Stdcallcaller)(int* pint); |
| 56 | extern "C"BOOL DLL_EXPORT __stdcall DoCallBack_MarshalRefInt_Stdcall(Stdcallcaller caller) |
| 57 | { |
| 58 | //Check the Input |
| 59 | int itemp = iNative; |
| 60 | if(!caller(&itemp)) |
| 61 | { |
| 62 | printf("DoCallBack_MarshalRefInt_Stdcall:The Caller() return FALSE!\n"); |
| 63 | return FALSE; |
| 64 | } |
| 65 | if(itemp!=iManaged) |
| 66 | { |
| 67 | printf("DoCallBack_MarshalRefInt_Stdcall: The Reference Parameter returns wrong value\n"); |
| 68 | return FALSE; |
| 69 | } |
| 70 | return TRUE; |
| 71 | } |
| 72 | |
| 73 | typedef BOOL (__cdecl * DelegatePInvokeCdecl)(int * pint); |
| 74 | extern "C"DLL_EXPORT DelegatePInvokeCdecl __cdecl MarshalRefInt_DelegatePInvoke_Cdecl() |
| 75 | { |
| 76 | return MarshalRefInt_Cdcel; |
| 77 | } |
| 78 | |
| 79 | |
| 80 | typedef BOOL (__stdcall * DelegatePInvokeStdcall)(int *pint); |
| 81 | extern "C"DLL_EXPORT DelegatePInvokeStdcall __stdcall MarshalRefInt_DelegatePInvoke_StdCall() |
| 82 | { |
| 83 | return MarshalRefInt_Stdcall; |
| 84 | } |
| 85 |