home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / sdkjava.exe / SDKJava.cab / Include / nativcom.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-05  |  5.2 KB  |  125 lines

  1. /*++
  2.  
  3. Copyright (c) 1996-1997  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     nativcom.h
  8.  
  9. Abstract:
  10.  
  11.     Public header for COM-marshaling facilities provided by msjava.dll.
  12.  
  13. --*/
  14.  
  15. #ifndef _NATIVCOM_
  16. #define _NATIVCOM_
  17.  
  18. #include <windows.h>
  19. #include <native.h>
  20.  
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24.  
  25. //----------------------------------------------------------------------------
  26. // COM data wrapper helpers...
  27. //----------------------------------------------------------------------------
  28. void* __cdecl jcdwNewData(Hjava_lang_Object * phJCDW, unsigned int numBytes);
  29. void* __cdecl jcdwGetData(Hjava_lang_Object * phJCDW);
  30. unsigned int __cdecl jcdwSizeOf(Hjava_lang_Object * phJCDW);
  31. unsigned int __cdecl jcdwClassSizeOf(Hjava_lang_Object * phJavaClass);
  32. unsigned int __cdecl jcdwOffsetOf(Hjava_lang_Object * phJCDW, const char *pFieldName);
  33. unsigned int __cdecl jcdwClassOffsetOf(Hjava_lang_Object * phJCDWClass, const char *pFieldName);
  34. Hjava_lang_Object * __cdecl convert_IUnknown_to_Java_Object(IUnknown *punk,
  35.                                                             Hjava_lang_Object *phJavaClass,
  36.                                                             int       fAssumeThreadSafe);
  37. Hjava_lang_Object * __cdecl convert_IUnknown_to_Java_Object2(IUnknown    *punk,
  38.                                                              ClassClass  *pClassClass,
  39.                                                              int         fFreeThreaded);
  40.  
  41. IUnknown * __cdecl convert_Java_Object_to_IUnknown(Hjava_lang_Object *phJavaObject, const IID *pIID);
  42.  
  43.  
  44. Hjava_lang_Object * __cdecl convert_ptr_to_jcdw(void              *pExtData,
  45.                                                 Hjava_lang_Object *phJavaClass
  46.                                                 );
  47.  
  48. int __cdecl jcdw_memory_freed_on_gc(Hjava_lang_Object *phJCDW);
  49.  
  50.  
  51. int   __cdecl jcdwSetData(Hjava_lang_Object * phJCDW, LPVOID pv);
  52. int   __cdecl jcdw_java_owned(Hjava_lang_Object *phJCDW);
  53.  
  54. //----------------------------------------------------------------------------
  55. // Map HRESULT to ComException.
  56. //----------------------------------------------------------------------------
  57. void    __cdecl SignalErrorHResult(HRESULT theHRESULT);
  58.  
  59. //----------------------------------------------------------------------------
  60. // Map Java exception to HRESULT.
  61. //----------------------------------------------------------------------------
  62. HRESULT __cdecl HResultFromException(OBJECT* exception_object);
  63.  
  64. typedef Hjava_lang_Object *JAVAARG;
  65.  
  66. //----------------------------------------------------------------------------
  67. // Information structure for Java->COM Custom Method hook.
  68. //----------------------------------------------------------------------------
  69. typedef struct {
  70.     DWORD                   cbSize;         // size of structure in bytes
  71.     IUnknown               *punk;           // pointer to interface being invoked
  72.     const volatile JAVAARG *pJavaArgs;      // pointer to Java argument stack
  73. } J2CMethodHookInfo;
  74.  
  75. //----------------------------------------------------------------------------
  76. // Information structure for COM->Java Custom Method hook.
  77. //----------------------------------------------------------------------------
  78. typedef struct {
  79.     DWORD                      cbSize;         // size of structure in bytes
  80.     struct methodblock        *javaMethod;     // java method to call
  81.     LPVOID                     pComArgs;       // pointer to COM method argument stack
  82.     const volatile JAVAARG    *ppThis;         // pointer to pointer to Java this
  83.  
  84.     // Store the COM result here.
  85.     union {
  86.         HRESULT                         resHR;
  87.         DWORD                           resDWORD;
  88.         double                          resDouble;
  89.     };
  90. } C2JMethodHookInfo;
  91.  
  92. //----------------------------------------------------------------------------
  93. // Thread marshaling helpers
  94. //
  95. // The MarshalCall<> APIs will reexecute the RNI method on the supplied thread
  96. // id or on the apartment thread for the supplied Java object.  The APIs will
  97. // return the following sets of HRESULTS:
  98. //
  99. //      S_OK     The call successfully was marshaled to the target thread.
  100. //               The marshaled call may have generated an exception, which can
  101. //               bechecked by calling exceptionOccurred.
  102. //      S_FALSE  The call did not require marshaling to the other thread--
  103. //               the currently executing thread is the target thread.
  104. //      E_<>     An error occurred inside the MarshalCall<> API (invalid
  105. //               arguments, out of memory, etc).
  106. //
  107. // The typical use of these APIs is to call the appropriate MarshalCall<> API
  108. // and if the HRESULT is S_FALSE, then execute the rest of the RNI method,
  109. // otherwise return with the value contained in pResult.
  110. //----------------------------------------------------------------------------
  111. typedef void * JAVATID;
  112.  
  113. #define JAVATID_MAIN_APARTMENT          ((JAVATID) 0x00000001)
  114. #define JAVATID_SERVER_APARTMENT        ((JAVATID) 0x00000002)
  115.  
  116. HRESULT __cdecl MarshalCallToJavaThreadId(JAVATID tid, int64_t *pResult);
  117. HRESULT __cdecl MarshalCallToJavaObjectHostThread(Hjava_lang_Object *phobj,
  118.     int64_t *pResult);
  119.  
  120. #ifdef __cplusplus
  121. }
  122. #endif
  123.  
  124. #endif
  125.