home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_VC.50 / VC / MFC / SRC / OLECALL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-30  |  3.2 KB  |  109 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1997 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_OLE5_SEG
  14. #pragma code_seg(AFX_OLE5_SEG)
  15. #endif
  16.  
  17. // Note: because of the nature of these functions, it is not possible
  18. //  to create a 'C' or 'C++' version of them.  These functions are used
  19. //  for the lowest level of the OLE IDispatch implementation, and need
  20. //  to be ported to each supported platform.
  21.  
  22. extern "C" {
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Intel 386 version
  26.  
  27. #ifdef _X86_
  28.  
  29. __declspec(naked) void AFXAPI
  30. _AfxDispatchCall(AFX_PMSG /*pfn*/, void* /*pArgs*/, UINT /*nSizeArgs*/)
  31. {
  32.     _asm
  33.     {
  34.         pop     edx         // edx = return address
  35.         pop     eax         // eax = pfn
  36.         pop     ecx         // ecx = pArgs
  37.         add     ecx,[esp]   // ecx += nSizeArgs (=scratch area)
  38.         mov     [ecx],edx   // scratch[0] = return address
  39.         sub     ecx,[esp]   // ecx = pArgs (again)
  40.         mov     esp,ecx     // esp = pArgs (usually already correct)
  41.         pop     ecx         // ecx = this pointer (the CCmdTarget*)
  42.         call    eax         // call member function
  43.         ret                 // esp[0] should = scratch[0] = return address
  44.     }
  45. }
  46. #endif // _X86_
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // MIPS R4000 version
  50.  
  51. #ifdef _MIPS_
  52.  
  53. extern "C" void _asm(char *, ...);
  54. void AFXAPI
  55. _AfxDispatchCall(AFX_PMSG /*pfn*/, void* /*pArgs*/, UINT /*nSizeArgs*/)
  56. {
  57.     _asm("addiu     %sp,%a1,0x0");      // sp = pArgs
  58.     _asm("addiu     %t6,%a0,0x0");      // t6 = pfn (save it)
  59.     _asm("lw        %a0,0x0(%sp)");     // a0 = param0
  60.     _asm("lw        %a1,0x4(%sp)");     // a1 = param1
  61.     _asm("lw        %a2,0x8(%sp)");     // a2 = param2
  62.     _asm("lw        %a3,0xc(%sp)");     // a3 = param3
  63.     _asm("j         %t6");              // ip = pfn (jump to target function)
  64. }
  65.  
  66. #endif // _MIPS_
  67.  
  68. /////////////////////////////////////////////////////////////////////////////
  69. // DEC Alpha AXP version
  70.  
  71. #ifdef _ALPHA_
  72.  
  73. // Note: ALPHA version is in src\alpha\olecall_.s
  74.  
  75. // The ALPHA compiler does not support inline assembly, so it
  76. //  must be build separately with the ASAXP assembler.
  77.  
  78. #endif // _ALPHA_
  79.  
  80. /////////////////////////////////////////////////////////////////////////////
  81. // 680x0 version
  82.  
  83. #ifdef _68K_
  84.  
  85. // Note: Mac68k version is in src\m68k\olecall.obj
  86.  
  87. // The 68k compiler does not support inline assembly, so it
  88. //  has been build separate and included as an object
  89.  
  90.  
  91. #endif // _68K_
  92.  
  93. /////////////////////////////////////////////////////////////////////////////
  94. // PowerMac version
  95.  
  96. #ifdef _MPPC_
  97.  
  98. // Note: MacPPC version is in src\mppc\olecall.obj
  99.  
  100. // The Mac PowerPC compiler does not support inline assembly, so it
  101. //  has been build separate and included as an object
  102.  
  103. #endif // _MPPC_
  104.  
  105.  
  106. } // end extern "C" block
  107.  
  108. /////////////////////////////////////////////////////////////////////////////
  109.