home *** CD-ROM | disk | FTP | other *** search
- /*++
-
- Copyright (c) 1996-1997 Microsoft Corporation
-
- Module Name:
-
- nativcom.h
-
- Abstract:
-
- Public header for COM-marshaling facilities provided by msjava.dll.
-
- --*/
-
- #ifndef _NATIVCOM_
- #define _NATIVCOM_
-
- #include <windows.h>
- #include <native.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- //----------------------------------------------------------------------------
- // COM data wrapper helpers...
- //----------------------------------------------------------------------------
- void* __cdecl jcdwNewData(Hjava_lang_Object * phJCDW, unsigned int numBytes);
- void* __cdecl jcdwGetData(Hjava_lang_Object * phJCDW);
- unsigned int __cdecl jcdwSizeOf(Hjava_lang_Object * phJCDW);
- unsigned int __cdecl jcdwClassSizeOf(Hjava_lang_Object * phJavaClass);
- unsigned int __cdecl jcdwOffsetOf(Hjava_lang_Object * phJCDW, const char *pFieldName);
- unsigned int __cdecl jcdwClassOffsetOf(Hjava_lang_Object * phJCDWClass, const char *pFieldName);
- Hjava_lang_Object * __cdecl convert_IUnknown_to_Java_Object(IUnknown *punk,
- Hjava_lang_Object *phJavaClass,
- int fAssumeThreadSafe);
- Hjava_lang_Object * __cdecl convert_IUnknown_to_Java_Object2(IUnknown *punk,
- ClassClass *pClassClass,
- int fFreeThreaded);
-
- IUnknown * __cdecl convert_Java_Object_to_IUnknown(Hjava_lang_Object *phJavaObject, const IID *pIID);
-
-
- Hjava_lang_Object * __cdecl convert_ptr_to_jcdw(void *pExtData,
- Hjava_lang_Object *phJavaClass
- );
-
- int __cdecl jcdw_memory_freed_on_gc(Hjava_lang_Object *phJCDW);
-
-
- int __cdecl jcdwSetData(Hjava_lang_Object * phJCDW, LPVOID pv);
- int __cdecl jcdw_java_owned(Hjava_lang_Object *phJCDW);
-
- //----------------------------------------------------------------------------
- // Map HRESULT to ComException.
- //----------------------------------------------------------------------------
- void __cdecl SignalErrorHResult(HRESULT theHRESULT);
-
- //----------------------------------------------------------------------------
- // Map Java exception to HRESULT.
- //----------------------------------------------------------------------------
- HRESULT __cdecl HResultFromException(OBJECT* exception_object);
-
- typedef Hjava_lang_Object *JAVAARG;
-
- //----------------------------------------------------------------------------
- // Information structure for Java->COM Custom Method hook.
- //----------------------------------------------------------------------------
- typedef struct {
- DWORD cbSize; // size of structure in bytes
- IUnknown *punk; // pointer to interface being invoked
- const volatile JAVAARG *pJavaArgs; // pointer to Java argument stack
- } J2CMethodHookInfo;
-
- //----------------------------------------------------------------------------
- // Information structure for COM->Java Custom Method hook.
- //----------------------------------------------------------------------------
- typedef struct {
- DWORD cbSize; // size of structure in bytes
- struct methodblock *javaMethod; // java method to call
- LPVOID pComArgs; // pointer to COM method argument stack
- const volatile JAVAARG *ppThis; // pointer to pointer to Java this
-
- // Store the COM result here.
- union {
- HRESULT resHR;
- DWORD resDWORD;
- double resDouble;
- };
- } C2JMethodHookInfo;
-
- //----------------------------------------------------------------------------
- // Thread marshaling helpers
- //
- // The MarshalCall<> APIs will reexecute the RNI method on the supplied thread
- // id or on the apartment thread for the supplied Java object. The APIs will
- // return the following sets of HRESULTS:
- //
- // S_OK The call successfully was marshaled to the target thread.
- // The marshaled call may have generated an exception, which can
- // bechecked by calling exceptionOccurred.
- // S_FALSE The call did not require marshaling to the other thread--
- // the currently executing thread is the target thread.
- // E_<> An error occurred inside the MarshalCall<> API (invalid
- // arguments, out of memory, etc).
- //
- // The typical use of these APIs is to call the appropriate MarshalCall<> API
- // and if the HRESULT is S_FALSE, then execute the rest of the RNI method,
- // otherwise return with the value contained in pResult.
- //----------------------------------------------------------------------------
- typedef void * JAVATID;
-
- #define JAVATID_MAIN_APARTMENT ((JAVATID) 0x00000001)
- #define JAVATID_SERVER_APARTMENT ((JAVATID) 0x00000002)
-
- HRESULT __cdecl MarshalCallToJavaThreadId(JAVATID tid, int64_t *pResult);
- HRESULT __cdecl MarshalCallToJavaObjectHostThread(Hjava_lang_Object *phobj,
- int64_t *pResult);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-