diff --git a/cpp/JXInput/JXInputManager.cpp b/cpp/JXInput/JXInputManager.cpp deleted file mode 100644 index 3718a7f..0000000 --- a/cpp/JXInput/JXInputManager.cpp +++ /dev/null @@ -1,175 +0,0 @@ - -#include "stdafx.h" -#include "JXInputManager.h" -#include "JXInput.h" - -// -// Globals -// -extern HINSTANCE g_hInst; - - -JXInputManager::JXInputManager( HWND hWnd ) : -mhWnd( hWnd ), -mDeviceCounter( 0 ) -{ - - for ( int i = 0; i < MAX_JXINPUTS; ++i ) - { - mDevices[ i ] = NULL; - } - - - if ( FAILED( InitDirectInput( hWnd ) ) ) - { - FreeDirectInput(); - } - -} - -JXInputManager::~JXInputManager() -{ - for ( int i = 0; i < getNumberOfJXInputs(); ++i ) - { - delete mDevices[ i ]; - mDevices[ i ] = NULL; - } - - FreeDirectInput(); -} - -int JXInputManager::getNumberOfJXInputs() const -{ - return mDeviceCounter; -} - -JXInput& JXInputManager::getJXInput( int idx ) const -{ - assert( idx < mDeviceCounter ); - return * mDevices[ idx ]; -} - - -int JXInputManager::getMaxNumberOfAxes() const -{ - return JXINPUT_MAX_AXES; -} - -int JXInputManager::getMaxNumberOfButtons() const -{ - return JXINPUT_MAX_BUTTONS; -} - -int JXInputManager::getMaxNumberOfDirectionals() const -{ - return JXINPUT_MAX_DIRECTIONALS; -} - - - -//----------------------------------------------------------------------------- -// Name: InitDirectInput() -// Desc: Initialize the DirectInput variables. -//----------------------------------------------------------------------------- -HRESULT JXInputManager::InitDirectInput( HWND hWnd ) -{ - HRESULT hr; - - // Register with the DirectInput subsystem and get a pointer - // to a IDirectInput interface we can use. - // Create a DInput object - if( FAILED( hr = DirectInput8Create( g_hInst, DIRECTINPUT_VERSION, - IID_IDirectInput8, (VOID**)&mpDI, NULL ) ) ) - return hr; - - // Look for a simple joystick we can use for this sample program. - if( FAILED( hr = mpDI->EnumDevices( DI8DEVCLASS_GAMECTRL, - EnumJoysticksCallback, - (VOID*)this, DIEDFL_ALLDEVICES /*| DIEDFL_INCLUDEPHANTOMS*/ ) ) ) - return hr; - - // Look for a other devices - if( FAILED( hr = mpDI->EnumDevices( DI8DEVCLASS_DEVICE, - EnumJoysticksCallback, - (VOID*)this, DIEDFL_ALLDEVICES /*| DIEDFL_INCLUDEPHANTOMS*/ ) ) ) - return hr; - - return S_OK; -} - - -//----------------------------------------------------------------------------- -// Name: FreeDirectInput() -// Desc: Initialize the DirectInput variables. -//----------------------------------------------------------------------------- -HRESULT JXInputManager::FreeDirectInput() -{ - - if ( NULL != mpDI ) - mpDI->Release(); - mpDI = NULL; - return S_OK; -} - - -//----------------------------------------------------------------------------- -// Name: EnumJoysticksCallback() -// Desc: Called once for each enumerated joystick. If we find one, create a -// device interface on it so we can play with it. -//----------------------------------------------------------------------------- -BOOL CALLBACK JXInputManager::EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, - VOID* pContext ) -{ - HRESULT hr; - LPDIRECTINPUTDEVICE8 pJoystick; - - JXInputManager* pThis = (JXInputManager*)pContext; - - // - // if the maximum number of devices is already registered, - // issue a warning and stop enumeration. - // - if( MAX_JXINPUTS == pThis->mDeviceCounter ) - { - OutputDebugString( "Max. number of devices exceeded!" ); - return DIENUM_STOP; - } - - - - // Obtain an interface to the enumerated joystick. - hr = pThis->mpDI->CreateDevice( pdidInstance->guidInstance, &pJoystick, NULL ); - - // If it failed, then we can't use this joystick. (Maybe the user unplugged - // it while we were in the middle of enumerating it.) - if( FAILED(hr) ) - return DIENUM_CONTINUE; - - JXInput* pJ = new JXInput( pJoystick, pThis->mhWnd ); - - // - // only register useful devices - // - if( pJ->getNumberOfAxes() + pJ->getNumberOfButtons() + pJ->getNumberOfDirectionals() > 0 ) - { - pThis->addJXInput( pJ ); - } - else - { - delete pJ; - } - - return DIENUM_CONTINUE; -} - - -/** - * Register a JXInput device. - */ -void JXInputManager::addJXInput( JXInput* pJ ) -{ - assert( mDeviceCounter < MAX_JXINPUTS ); - - if( mDeviceCounter < MAX_JXINPUTS ) - mDevices[ mDeviceCounter++ ] = pJ; -} diff --git a/cpp/JXInput/JXInputManager.h b/cpp/JXInput/JXInputManager.h deleted file mode 100644 index 41b9da4..0000000 --- a/cpp/JXInput/JXInputManager.h +++ /dev/null @@ -1,47 +0,0 @@ -// JXInputManager.h: Schnittstelle für die Klasse JXInputManager. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_JXINPUTMANAGER_H__24862402_14C9_407D_8532_A16A6E3A7D64__INCLUDED_) -#define AFX_JXINPUTMANAGER_H__24862402_14C9_407D_8532_A16A6E3A7D64__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -#define MAX_JXINPUTS 10 - -class JXInput; - -class JXINPUT_API JXInputManager -{ -public: - JXInputManager( HWND hWnd ); - virtual ~JXInputManager(); - - int getNumberOfJXInputs() const; - JXInput& getJXInput( int idx ) const; - - // - // Numbering methods - // - int getMaxNumberOfAxes() const; - int getMaxNumberOfButtons() const; - int getMaxNumberOfDirectionals() const; - -private: - LPDIRECTINPUT8 mpDI; - HWND mhWnd; - JXInput* mDevices[ MAX_JXINPUTS ]; - int mDeviceCounter; - - HRESULT InitDirectInput( HWND hWnd = NULL ); - HRESULT FreeDirectInput(); - - static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, - VOID* pContext ); - void addJXInput( JXInput* pJ ); -}; - -#endif // !defined(AFX_JXINPUTMANAGER_H__24862402_14C9_407D_8532_A16A6E3A7D64__INCLUDED_) diff --git a/cpp/JXInput/ReadMe.txt b/cpp/JXInput/ReadMe.txt deleted file mode 100644 index 5769d0b..0000000 --- a/cpp/JXInput/ReadMe.txt +++ /dev/null @@ -1,37 +0,0 @@ -======================================================================== - DYNAMIC LINK LIBRARY : jxinput -======================================================================== - - -Diese jxinput-DLL hat der Anwendungs-Assistent für Sie erstellt. - -Diese Datei enthält eine Zusammenfassung dessen, was Sie in jeder der Dateien -finden, die Ihre jxinput-Anwendung bilden. - -jxinput.dsp - Diese Datei (Projektdatei) enthält Informationen auf Projektebene und wird zur - Erstellung eines einzelnen Projekts oder Teilprojekts verwendet. Andere Benutzer können - die Projektdatei (.dsp) gemeinsam nutzen, sollten aber die Makefiles lokal exportieren. - -jxinput.cpp - Dies ist die Hauptquellcodedatei für die DLL. - -jxinput.h - Diese Datei enthält Ihre DLL-Exporte. - -///////////////////////////////////////////////////////////////////////////// -Weitere Standarddateien: - -StdAfx.h, StdAfx.cpp - Diese Dateien werden zum Erstellen einer vorkompilierten Header-Datei (PCH) namens - jxinput.pch und einer vorkompilierten Typdatei namens StdAfx.obj verwendet. - - -///////////////////////////////////////////////////////////////////////////// -Weitere Hinweise: - -Der Anwendungs-Assistent verwendet "ZU ERLEDIGEN:", um Bereiche des Quellcodes zu -kennzeichnen, die Sie hinzufügen oder anpassen sollten. - - -///////////////////////////////////////////////////////////////////////////// diff --git a/cpp/JXInput/StdAfx.cpp b/cpp/JXInput/StdAfx.cpp deleted file mode 100644 index a144a09..0000000 --- a/cpp/JXInput/StdAfx.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// stdafx.cpp : Quelltextdatei, die nur die Standard-Includes einbindet -// jxinput.pch ist die vorkompilierte Header-Datei -// stdafx.obj enthält die vorkompilierte Typinformation - -#include "stdafx.h" - -// ZU ERLEDIGEN: Verweis auf alle zusätzlichen Header-Dateien, die Sie in STDAFX.H -// und nicht in dieser Datei benötigen - diff --git a/cpp/JXInput/StdAfx.h b/cpp/JXInput/StdAfx.h deleted file mode 100644 index e139c4c..0000000 --- a/cpp/JXInput/StdAfx.h +++ /dev/null @@ -1,32 +0,0 @@ -// stdafx.h : Include-Datei für Standard-System-Include-Dateien, -// oder projektspezifische Include-Dateien, die häufig benutzt, aber -// in unregelmäßigen Abständen geändert werden. -// - -#if !defined(AFX_STDAFX_H__68E14C76_098F_47ED_932B_4C01E8E9EFFB__INCLUDED_) -#define AFX_STDAFX_H__68E14C76_098F_47ED_932B_4C01E8E9EFFB__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -// Fügen Sie hier Ihre Header-Dateien ein -#define WIN32_LEAN_AND_MEAN // Selten benutzte Teile der Windows-Header nicht einbinden -#define STRICT -#include - -// ZU ERLEDIGEN: Verweisen Sie hier auf zusätzliche Header-Dateien, die Ihr Programm benötigt -#ifdef JXINPUT_EXPORTS -#define JXINPUT_API __declspec(dllexport) -#else -#define JXINPUT_API __declspec(dllimport) -#endif - -#include -#include - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ fügt zusätzliche Deklarationen unmittelbar vor der vorherigen Zeile ein. - -#endif // !defined(AFX_STDAFX_H__68E14C76_098F_47ED_932B_4C01E8E9EFFB__INCLUDED_) diff --git a/cpp/JXInput/de_hardcode_jxinput_directinput_DirectInputDriver.cpp b/cpp/JXInput/de_hardcode_jxinput_directinput_DirectInputDriver.cpp deleted file mode 100644 index 077afe8..0000000 --- a/cpp/JXInput/de_hardcode_jxinput_directinput_DirectInputDriver.cpp +++ /dev/null @@ -1,279 +0,0 @@ -#include "stdafx.h" - -#include "de_hardcode_jxinput_directinput_DirectInputDriver.h" -#include "jxinput.h" -#include "JXInputManager.h" - - -// -// Globals -// -extern HINSTANCE g_hInst; - -static JXInputManager* pJXInputManager = NULL; -static JXInput* apJXInput[ MAX_JXINPUTS ]; -static HWND hWndJava; - -// -// IDs of the static Java arrays. -// -static jfieldID sAxesFieldID; -static jfieldID sButtonsFieldID; -static jfieldID sDirectionsFieldID; - - - -/** - * Remove all resources allocated by the Java binding. - */ -void shutdownJavaResources() -{ - if ( NULL != pJXInputManager ) - delete pJXInputManager; - - if ( NULL != hWndJava ) - DestroyWindow( hWndJava ); - - pJXInputManager = NULL; - - for( int i = 0; i < MAX_JXINPUTS; ++i ) - apJXInput[ i ] = NULL; - - hWndJava = NULL; -} - - - -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) -{ - return JNI_VERSION_1_2; -} - - -JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) -{ - shutdownJavaResources(); -} - - -JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeinit - (JNIEnv * penv, jclass pClazz ) -{ - - // - // Create a non-visible window as 'owner' of the DI device. - // - hWndJava = CreateWindowEx( - 0/*WS_EX_APPWINDOW*/, // DWORD dwExStyle, // extended window style - "STATIC", // LPCTSTR lpClassName, // pointer to registered class name - NULL, // LPCTSTR lpWindowName, // pointer to window name - 0/*WS_CAPTION*/, // DWORD dwStyle, // window style - 0, // int x, // horizontal position of window - 0, // int y, // vertical position of window - 0, // int nWidth, // window width - 0, // int nHeight, // window height - NULL, // HWND hWndParent, // handle to parent or owner window - NULL, // HMENU hMenu, // handle to menu, or child-window identifier - g_hInst, // HINSTANCE hInstance, // handle to application instance - NULL // LPVOID lpParam // pointer to window-creation data - ); - - - if ( NULL == pJXInputManager ) - { - pJXInputManager = new JXInputManager( hWndJava ); - - for( int i = 0; i < MAX_JXINPUTS; ++i ) - apJXInput[ i ] = NULL; - - for ( int i = 0; i < pJXInputManager->getNumberOfJXInputs(); ++i ) - { - apJXInput[ i ] = & pJXInputManager->getJXInput( i ); - } - } - - return true; -} - - - -JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeexit - (JNIEnv *, jclass ) -{ - shutdownJavaResources(); -} - - -/** - * Bind my field IDs to the Java variables. - */ -JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_bind - (JNIEnv * penv, jclass pClazz) -{ - // - // All fields are static. - // - sAxesFieldID = penv->GetStaticFieldID( pClazz, "sAxisValues", "[[D" ); - sButtonsFieldID = penv->GetStaticFieldID( pClazz, "sButtonStates", "[[Z" ); - sDirectionsFieldID = penv->GetStaticFieldID( pClazz, "sDirectionalValues", "[[I" ); -} - - -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfDevices - (JNIEnv *penv, jclass) -{ - return pJXInputManager->getNumberOfJXInputs(); -} - - -JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getName - (JNIEnv *penv, jclass, jint dev) -{ - return penv->NewStringUTF( apJXInput[ dev ]->getName() ); -} - -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfAxes - (JNIEnv *, jclass, jint dev) -{ - return apJXInput[ dev ]->getNumberOfAxes(); -} - -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfButtons - (JNIEnv *, jclass, jint dev) -{ - return apJXInput[ dev ]->getNumberOfButtons(); -} - -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfDirectionals - (JNIEnv *, jclass, jint dev) -{ - return apJXInput[ dev ]->getNumberOfDirectionals(); -} - -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfAxes - (JNIEnv *, jclass) -{ - return pJXInputManager->getMaxNumberOfAxes(); -} - -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfButtons - (JNIEnv *, jclass) -{ - return pJXInputManager->getMaxNumberOfButtons(); -} - -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfDirectionals - (JNIEnv *, jclass) -{ - return pJXInputManager->getMaxNumberOfDirectionals(); -} - -JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isAxisAvailable - (JNIEnv *, jclass, jint dev, jint idx ) -{ - return apJXInput[ dev ]->isAxisAvailable( idx ); -} - -JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getAxisName - (JNIEnv *penv, jclass, jint dev, jint idx ) -{ - return penv->NewStringUTF( apJXInput[ dev ]->getAxisName( idx ) ); -} - -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getAxisType - (JNIEnv *, jclass, jint dev, jint idx ) -{ - return apJXInput[ dev ]->getAxisType( idx ); -} - - -JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isButtonAvailable - (JNIEnv *, jclass, jint dev, jint idx ) -{ - return apJXInput[ dev ]->isButtonAvailable( idx ); -} - -JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getButtonName - (JNIEnv *penv, jclass, jint dev, jint idx ) -{ - return penv->NewStringUTF( apJXInput[ dev ]->getButtonName( idx ) ); -} - -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getButtonType - (JNIEnv *, jclass, jint dev, jint idx ) -{ - return apJXInput[ dev ]->getButtonType( idx ); -} - -JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isDirectionalAvailable - (JNIEnv *, jclass, jint dev, jint idx ) -{ - return apJXInput[ dev ]->isDirectionalAvailable( idx ); -} - -JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getDirectionalName - (JNIEnv *penv, jclass, jint dev, jint idx ) -{ - return penv->NewStringUTF( apJXInput[ dev ]->getDirectionalName( idx ) ); -} - - - -/** - * The main update method. - * Here, the actual work is done. - */ -JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeupdate - (JNIEnv * penv, jclass pClazz ) -{ - - static jdouble axes [ MAX_JXINPUTS ][ JXINPUT_MAX_AXES ]; - static jboolean buttons [ MAX_JXINPUTS ][ JXINPUT_MAX_BUTTONS ]; - static jint directions [ MAX_JXINPUTS ][ JXINPUT_MAX_DIRECTIONALS ]; - - static jobjectArray axisarrayarray; - static jobjectArray buttonarrayarray; - static jobjectArray directionarrayarray; - - static jdoubleArray axisarray; - static jbooleanArray buttonarray; - static jintArray directionarray; - - axisarrayarray = (jobjectArray)penv->GetStaticObjectField( pClazz, sAxesFieldID ); - buttonarrayarray = (jobjectArray)penv->GetStaticObjectField( pClazz, sButtonsFieldID ); - directionarrayarray = (jobjectArray)penv->GetStaticObjectField( pClazz, sDirectionsFieldID ); - - // - // For each device.... - // - for ( int dev = 0; dev < pJXInputManager->getNumberOfJXInputs(); ++dev ) - { - // Do the update of the device. - apJXInput[ dev ]->update(); - - // - // Copy all values into my arrays. - // - for ( int i = 0; i < JXINPUT_MAX_AXES; ++i ) - axes[ dev ][ i ] = apJXInput[ dev ]->getAxisValue( i ); - for ( int i = 0; i < JXINPUT_MAX_BUTTONS; ++i ) - buttons[ dev ][ i ] = apJXInput[ dev ]->isButtonDown( i ); - for ( int i = 0; i < JXINPUT_MAX_DIRECTIONALS; ++i ) - directions[ dev ][ i ] = apJXInput[ dev ]->getDirection( i ); - - - // - // Move my arrays to the Java arrays. - // - axisarray = (jdoubleArray)penv->GetObjectArrayElement( axisarrayarray, dev ); - penv->SetDoubleArrayRegion( axisarray, 0, JXINPUT_MAX_AXES, axes[ dev ] ); - - buttonarray = (jbooleanArray)penv->GetObjectArrayElement( buttonarrayarray, dev ); - penv->SetBooleanArrayRegion( buttonarray, 0, JXINPUT_MAX_BUTTONS, buttons[ dev ] ); - - directionarray = (jintArray)penv->GetObjectArrayElement( directionarrayarray, dev ); - penv->SetIntArrayRegion( directionarray, 0, JXINPUT_MAX_DIRECTIONALS, directions[ dev ] ); - } - -} - diff --git a/cpp/JXInput/de_hardcode_jxinput_directinput_DirectInputDriver.h b/cpp/JXInput/de_hardcode_jxinput_directinput_DirectInputDriver.h deleted file mode 100644 index bb93548..0000000 --- a/cpp/JXInput/de_hardcode_jxinput_directinput_DirectInputDriver.h +++ /dev/null @@ -1,183 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include - -/* Header for class de_hardcode_jxinput_directinput_DirectInputDriver */ - -#ifndef _Included_de_hardcode_jxinput_directinput_DirectInputDriver -#define _Included_de_hardcode_jxinput_directinput_DirectInputDriver - -#ifdef __cplusplus -extern "C" { -#endif - -/* Inaccessible static: sIsOperational */ -/* Inaccessible static: sAxisValues */ -/* Inaccessible static: sButtonStates */ -/* Inaccessible static: sDirectionalValues */ -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: nativeinit - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeinit - (JNIEnv *, jclass); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: nativeexit - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeexit - (JNIEnv *, jclass); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: bind - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_bind - (JNIEnv *, jclass); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getNumberOfDevices - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfDevices - (JNIEnv *, jclass); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getName - * Signature: (I)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getName - (JNIEnv *, jclass, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getNumberOfAxes - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfAxes - - (JNIEnv *, jclass, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getNumberOfButtons - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfButtons - (JNIEnv *, jclass, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getNumberOfDirectionals - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfDirectionals - (JNIEnv *, jclass, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getMaxNumberOfAxes - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfAxes - (JNIEnv *, jclass); - - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getMaxNumberOfButtons - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfButtons - (JNIEnv *, jclass); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getMaxNumberOfDirectionals - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfDirectionals - (JNIEnv *, jclass); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: isAxisAvailable - * Signature: (II)Z - */ -JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isAxisAvailable - (JNIEnv *, jclass, jint, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getAxisName - * Signature: (II)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getAxisName - (JNIEnv *, jclass, jint, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getAxisType - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getAxisType - (JNIEnv *, jclass, jint, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: isButtonAvailable - * Signature: (II)Z - */ -JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isButtonAvailable - (JNIEnv *, jclass, jint, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getButtonName - * Signature: (II)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getButtonName - (JNIEnv *, jclass, jint, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getButtonType - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getButtonType - (JNIEnv *, jclass, jint, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: isDirectionalAvailable - * Signature: (II)Z - */ -JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isDirectionalAvailable - (JNIEnv *, jclass, jint, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: getDirectionalName - * Signature: (II)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getDirectionalName - (JNIEnv *, jclass, jint, jint); - -/* - * Class: de_hardcode_jxinput_directinput_DirectInputDriver - * Method: nativeupdate - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeupdate - (JNIEnv *, jclass); - -#ifdef __cplusplus -} -#endif -#endif - diff --git a/cpp/JXInput/dllmain.cpp b/cpp/JXInput/dllmain.cpp deleted file mode 100644 index 567e8d4..0000000 --- a/cpp/JXInput/dllmain.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "stdafx.h" - -HINSTANCE g_hInst; - - -BOOL APIENTRY DllMain( HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - g_hInst = (HINSTANCE)hModule; - break; - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - break; - case DLL_PROCESS_DETACH: - g_hInst = NULL; - break; - } - return TRUE; -} diff --git a/cpp/JXInput/jxinput.cpp b/cpp/JXInput/jxinput.cpp deleted file mode 100644 index 890805b..0000000 --- a/cpp/JXInput/jxinput.cpp +++ /dev/null @@ -1,600 +0,0 @@ -// -// jxinput.cpp -// -#include "stdafx.h" -#include "jxinput.h" - - -// -// Globals -// -extern HINSTANCE g_hInst; - - -/** - * Ctor: Connect with DI - */ -JXInput::JXInput( LPDIRECTINPUTDEVICE8 pJoystick, HWND hWnd ) : - mpJoystick( pJoystick ), - mSliderCount( 0 ), - mPOVCount( 0 ), - mButtonCount( 0 ) -{ - initAxisConfig(); - initButtonsConfig(); - initDirectionalsConfig(); - - if ( FAILED( InitDirectInput( hWnd ) ) ) - { - FreeDirectInput(); - } -} - - - -/** - * Destructor: - * Free DirectInput. - */ -JXInput::~JXInput() -{ - FreeDirectInput(); -} - - -void JXInput::update() -{ - UpdateInputState(); -} - - -TCHAR * const JXInput::getName() const -{ - return (TCHAR*)mdiDevInfo.tszInstanceName; -} - - - -int JXInput::getNumberOfAxes() const -{ - return mdiDevCaps.dwAxes; -} - -int JXInput::getNumberOfButtons() const -{ - return mButtonCount; -} - -int JXInput::getNumberOfDirectionals() const -{ - return mPOVCount; -} - - -double JXInput::getAxisValueHelper( LONG val, int idx ) const -{ - const AxisConfig& cfg = mAxisConfig[ idx ]; - - double span = (double)( cfg.mMaxValue - cfg.mMinValue ); - double ret = (double)(val - cfg.mMinValue) / span; - - if ( TYPE_SLIDER != cfg.mType ) - return ret*2.0 - 1.0; - return ret; -} - -double JXInput::getX() const -{ - return getAxisValueHelper( mJS.lX, ID_X ); -} -double JXInput::getY() const -{ - return getAxisValueHelper( mJS.lY, ID_Y ); -} -double JXInput::getZ() const -{ - return getAxisValueHelper( mJS.lZ, ID_Z ); -} -double JXInput::getRotX() const -{ - return getAxisValueHelper( mJS.lRx, ID_ROTX ); -} -double JXInput::getRotY() const -{ - return getAxisValueHelper( mJS.lRy, ID_ROTY ); -} -double JXInput::getRotZ() const -{ - return getAxisValueHelper( mJS.lRz, ID_ROTZ ); -} -double JXInput::getSlider0() const -{ - return getAxisValueHelper( mJS.rglSlider[ 0 ], ID_SLIDER0 ); -} -double JXInput::getSlider1() const -{ - return getAxisValueHelper( mJS.rglSlider[ 1 ], ID_SLIDER1 ); -} - - - -bool JXInput::isAxisAvailable( int idx ) const -{ - assert( idx < JXINPUT_MAX_AXES ); - return mAxisConfig[ idx ].mIsAvailable; -} - -TCHAR * const JXInput::getAxisName( int idx ) const -{ - assert( idx < JXINPUT_MAX_AXES ); - return (char*const)mAxisConfig[ idx ].mName; -} - -int JXInput::getAxisType( int idx ) const -{ - assert( idx < JXINPUT_MAX_AXES ); - return mAxisConfig[ idx ].mType; -} - -double JXInput::getAxisValue( int idx ) const -{ - assert( idx < JXINPUT_MAX_AXES ); - - // Failsafe if called accidentally - if ( ! mAxisConfig[ idx ].mIsAvailable ) - return 0.0; - - return (this->*mAxisConfig[ idx ].mGetValueMethod)(); -} - - - - - -bool JXInput::isButtonAvailable( int idx ) const -{ - assert( idx < JXINPUT_MAX_BUTTONS ); - return mButtonConfig[ idx ].mIsAvailable; -} - -TCHAR * const JXInput::getButtonName( int idx ) const -{ - assert( idx < JXINPUT_MAX_BUTTONS ); - return (char*const)mButtonConfig[ idx ].mName; -} - -int JXInput::getButtonType( int idx ) const -{ - assert( idx < JXINPUT_MAX_BUTTONS ); - return mButtonConfig[ idx ].mType; -} - -bool JXInput::isButtonDown( int idx ) const -{ - assert( idx < JXINPUT_MAX_BUTTONS ); - return 0 != mJS.rgbButtons[ idx ] ; -} - - -bool JXInput::isDirectionalAvailable( int idx ) const -{ - assert( idx < JXINPUT_MAX_DIRECTIONALS ); - return mDirectionalConfig[ idx ].mIsAvailable; -} - -TCHAR * const JXInput::getDirectionalName( int idx ) const -{ - assert( idx < JXINPUT_MAX_DIRECTIONALS ); - return (char*const)mDirectionalConfig[ idx ].mName; -} - -int JXInput::getDirection( int idx ) const -{ - assert( idx < JXINPUT_MAX_DIRECTIONALS ); - return mJS.rgdwPOV[ idx ] ; -} - - -/** - * Initialize axis configuration array. - */ -void JXInput::initAxisConfig() -{ - mAxisConfig[ ID_X ].mIsAvailable = false; - mAxisConfig[ ID_X ].mType = TYPE_TRANSLATION; - mAxisConfig[ ID_X ].mGetValueMethod = &JXInput::getX; - - mAxisConfig[ ID_Y ].mIsAvailable = false; - mAxisConfig[ ID_Y ].mType = TYPE_TRANSLATION; - mAxisConfig[ ID_Y ].mGetValueMethod = &JXInput::getY; - - mAxisConfig[ ID_Z ].mIsAvailable = false; - mAxisConfig[ ID_Z ].mType = TYPE_TRANSLATION; - mAxisConfig[ ID_Z ].mGetValueMethod = &JXInput::getZ; - - mAxisConfig[ ID_ROTX ].mIsAvailable = false; - mAxisConfig[ ID_ROTX ].mType = TYPE_ROTATION; - mAxisConfig[ ID_ROTX ].mGetValueMethod = &JXInput::getRotX; - - mAxisConfig[ ID_ROTY ].mIsAvailable = false; - mAxisConfig[ ID_ROTY ].mType = TYPE_ROTATION; - mAxisConfig[ ID_ROTY ].mGetValueMethod = &JXInput::getRotY; - - mAxisConfig[ ID_ROTZ ].mIsAvailable = false; - mAxisConfig[ ID_ROTZ ].mType = TYPE_ROTATION; - mAxisConfig[ ID_ROTZ ].mGetValueMethod = &JXInput::getRotZ; - - mAxisConfig[ ID_SLIDER0 ].mIsAvailable = false; - mAxisConfig[ ID_SLIDER0 ].mType = TYPE_SLIDER; - mAxisConfig[ ID_SLIDER0 ].mGetValueMethod = &JXInput::getSlider0; - - mAxisConfig[ ID_SLIDER1 ].mIsAvailable = false; - mAxisConfig[ ID_SLIDER1 ].mType = TYPE_SLIDER; - mAxisConfig[ ID_SLIDER1 ].mGetValueMethod = &JXInput::getSlider1; -} - - -/** - * Initialize buttons configuration array. - */ -void JXInput::initButtonsConfig() -{ - for ( int i = 0; i < JXINPUT_MAX_BUTTONS; ++i ) - { - mButtonConfig[ i ].mIsAvailable = false; - mButtonConfig[ i ].mName[ 0 ] = '\0'; - mButtonConfig[ i ].mType = TYPE_PUSHBUTTON; - } - -} - - -/** - * Initialize directionals configuration array. - */ -void JXInput::initDirectionalsConfig() -{ - for ( int i = 0; i < JXINPUT_MAX_DIRECTIONALS; ++i ) - { - mDirectionalConfig[ i ].mIsAvailable = false; - mDirectionalConfig[ i ].mName[ 0 ] = '\0'; - } - -} - - - -//----------------------------------------------------------------------------- -// Name: EnumAxesCallback() -// Desc: Callback function for enumerating the axes on a joystick -//----------------------------------------------------------------------------- -BOOL CALLBACK JXInput::EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext ) -{ - JXInput* pThis = (JXInput*)pContext; - - AxisConfig* pAxCfg = NULL; - - // Set the UI to reflect what objects the joystick supports - // Code derived from M$ samples, really sucks, eh? - if (pdidoi->guidType == GUID_XAxis) - { - pAxCfg = & pThis->mAxisConfig[ ID_X ]; - } - if (pdidoi->guidType == GUID_YAxis) - { - pAxCfg = & pThis->mAxisConfig[ ID_Y ]; - } - if (pdidoi->guidType == GUID_ZAxis) - { - pAxCfg = & pThis->mAxisConfig[ ID_Z ]; - } - if (pdidoi->guidType == GUID_RxAxis) - { - pAxCfg = & pThis->mAxisConfig[ ID_ROTX ]; - } - if (pdidoi->guidType == GUID_RyAxis) - { - pAxCfg = & pThis->mAxisConfig[ ID_ROTY ]; - } - if (pdidoi->guidType == GUID_RzAxis) - { - pAxCfg = & pThis->mAxisConfig[ ID_ROTZ ]; - } - if (pdidoi->guidType == GUID_Slider) - { - switch( pThis->mSliderCount++ ) - { - case 0 : - pAxCfg = & pThis->mAxisConfig[ ID_SLIDER0 ]; - break; - - case 1 : - pAxCfg = & pThis->mAxisConfig[ ID_SLIDER1 ]; - break; - } - } - - // fail-safe - if( NULL == pAxCfg ) // e.g. GUID_Unknown - return DIENUM_CONTINUE; - - - // - // Perform config. - // - - DIPROPRANGE diprg; - diprg.diph.dwSize = sizeof(DIPROPRANGE); - diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); - diprg.diph.dwHow = DIPH_BYID; - diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis - - // Get the range for the axis - if( FAILED( pThis->mpJoystick->GetProperty( DIPROP_RANGE, &diprg.diph ) ) ) - return DIENUM_CONTINUE; - - pAxCfg->mMinValue = diprg.lMin; - pAxCfg->mMaxValue = diprg.lMax; - - strcpy( (char*)pAxCfg->mName, (char*)pdidoi->tszName ); - pAxCfg->mIsAvailable = true; - - return DIENUM_CONTINUE; -} - - - -//----------------------------------------------------------------------------- -// Name: EnumButtonsCallback() -// Desc: Callback function for enumerating the axes on a joystick -//----------------------------------------------------------------------------- -BOOL CALLBACK JXInput::EnumButtonsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext ) -{ - JXInput* pThis = (JXInput*)pContext; - - // - // if the maximum number of buttons is already registered, - // issue a warning and stop enumeration. - // - if( JXINPUT_MAX_BUTTONS == pThis->mButtonCount ) - { - OutputDebugString( "Max. number of buttons exceeded!" ); - return DIENUM_STOP; - } - - - ButtonConfig* pBtCfg = NULL; - - if ( pdidoi->guidType == GUID_Button ) - { - assert( JXINPUT_MAX_BUTTONS > pThis->mButtonCount ); - pBtCfg = & pThis->mButtonConfig[ pThis->mButtonCount++ ]; - } - - - // fail-safe - if( NULL == pBtCfg ) // e.g. unknown stuff - return DIENUM_CONTINUE; - assert( NULL != pBtCfg ); - - // - // Perform config. - // - - strcpy( (char*)pBtCfg->mName, (char*)pdidoi->tszName ); - pBtCfg->mIsAvailable = true; - - return DIENUM_CONTINUE; -} - - -//----------------------------------------------------------------------------- -// Name: EnumPOVsCallback() -// Desc: Callback function for enumerating the axes on a joystick -//----------------------------------------------------------------------------- -BOOL CALLBACK JXInput::EnumPOVsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext ) -{ - JXInput* pThis = (JXInput*)pContext; - - // - // if the maximum number of buttons is already registered, - // issue a warning and stop enumeration. - // - if( JXINPUT_MAX_DIRECTIONALS == pThis->mPOVCount ) - { - OutputDebugString( "Max. number of POVs exceeded!" ); - return DIENUM_STOP; - } - - DirectionalConfig* pDirCfg = NULL; - - - if (pdidoi->guidType == GUID_POV) - { - assert( JXINPUT_MAX_DIRECTIONALS > pThis->mPOVCount ); - pDirCfg = & pThis->mDirectionalConfig[ pThis->mPOVCount++ ]; - } - - // fail-safe - if( NULL == pDirCfg ) // e.g. unknown stuff - return DIENUM_CONTINUE; - assert( NULL != pDirCfg ); - - // - // Perform config. - // - - strcpy( (char*)pDirCfg->mName, (char*)pdidoi->tszName ); - pDirCfg->mIsAvailable = true; - - return DIENUM_CONTINUE; -} - - - -//----------------------------------------------------------------------------- -// Name: EnumEffectsCallback() -// Desc: Callback function for enumerating the effects of a joystick -//----------------------------------------------------------------------------- -BOOL CALLBACK JXInput::EnumEffectsCallback( const DIEFFECTINFO* pdidoi, - VOID* pContext ) -{ - JXInput* pThis = (JXInput*)pContext; - - // - // Work on that!! - // - - return DIENUM_CONTINUE; -} - - - -//----------------------------------------------------------------------------- -// Name: InitDirectInput() -// Desc: Initialize the DirectInput variables. -//----------------------------------------------------------------------------- -HRESULT JXInput::InitDirectInput( HWND hWnd ) -{ - HRESULT hr; - - // Make sure we got a joystick - if( NULL == mpJoystick ) - { - return E_FAIL; - } - - - // - // Ask the device for some useful information. - // - mdiDevInfo.dwSize = sizeof( DIDEVICEINSTANCE ); - hr = mpJoystick->GetDeviceInfo( &mdiDevInfo ); - if( FAILED(hr) ) - return hr; - - // Set the data format to "simple joystick" - a predefined data format - // - // A data format specifies which controls on a device we are interested in, - // and how they should be reported. This tells DInput that we will be - // passing a DIJOYSTATE structure to IDirectInputDevice::GetDeviceState(). - hr = mpJoystick->SetDataFormat( &c_dfDIJoystick2 ); - if( FAILED(hr) ) - return hr; - - // Set the cooperative level to let DInput know how this device should - // interact with the system and with other DInput applications. -// hr = g_pJoystick->SetCooperativeLevel( hDlg, DISCL_EXCLUSIVE|DISCL_FOREGROUND ); - DWORD mode = ( NULL == hWnd ? DISCL_NONEXCLUSIVE|DISCL_BACKGROUND : DISCL_EXCLUSIVE|DISCL_BACKGROUND ); - hr = mpJoystick->SetCooperativeLevel( hWnd, mode ); - if( FAILED(hr) ) - return hr; - - // Determine how many axis the joystick has (so we don't error out setting - // properties for unavailable axis) - mdiDevCaps.dwSize = sizeof(DIDEVCAPS); - hr = mpJoystick->GetCapabilities(&mdiDevCaps); - if ( FAILED(hr) ) - return hr; - - - // Enumerate the axes of the joyctick and set the range of each axis. Note: - // we could just use the defaults, but we're just trying to show an example - // of enumerating device objects (axes, buttons, etc.). - mpJoystick->EnumObjects( EnumAxesCallback, (VOID*)this, DIDFT_AXIS ); - mpJoystick->EnumObjects( EnumButtonsCallback, (VOID*)this, DIDFT_BUTTON ); - mpJoystick->EnumObjects( EnumPOVsCallback, (VOID*)this, DIDFT_POV ); - - mpJoystick->EnumEffects( EnumEffectsCallback, (VOID*)this, DIEFT_ALL ); - - // For FF sticks, switch on autocenter as long as we do not use real FF - SwitchAutoCenter( true ); - - return S_OK; -} - - - - - -//----------------------------------------------------------------------------- -// Name: UpdateInputState() -// Desc: Get the input device's state and display it. -//----------------------------------------------------------------------------- -HRESULT JXInput::UpdateInputState() -{ - HRESULT hr; - - if( mpJoystick ) - { - - // Poll the device to read the current state - hr = mpJoystick->Poll(); - if( FAILED(hr) ) - { - // DInput is telling us that the input stream has been - // interrupted. We aren't tracking any state between polls, so - // we don't have any special reset that needs to be done. We - // just re-acquire and try again. - hr = mpJoystick->Acquire(); - while( hr == DIERR_INPUTLOST ) - hr = mpJoystick->Acquire(); - - // hr may be DIERR_OTHERAPPHASPRIO or other errors. This - // may occur when the app is minimized or in the process of - // switching, so just try again later - return S_OK; - } - - // Get the input's device state - if( FAILED( hr = mpJoystick->GetDeviceState( sizeof(DIJOYSTATE2), &mJS ) ) ) - return hr; // The device should have been acquired during the Poll() - - } - - return S_OK; -} - - - - -//----------------------------------------------------------------------------- -// Name: FreeDirectInput() -// Desc: Initialize the DirectInput variables. -//----------------------------------------------------------------------------- -HRESULT JXInput::FreeDirectInput() -{ - // Unacquire and release any DirectInputDevice objects. - if( NULL != mpJoystick ) - { - // Unacquire the device one last time just in case - // the app tried to exit while the device is still acquired. - mpJoystick->Unacquire(); - - mpJoystick->Release(); - mpJoystick = NULL; - } - - return S_OK; -} - - - -HRESULT JXInput::SwitchAutoCenter( bool onoff ) -{ - HRESULT hr; - - DIPROPDWORD DIPropAutoCenter; - - DIPropAutoCenter.diph.dwSize = sizeof(DIPropAutoCenter); - DIPropAutoCenter.diph.dwHeaderSize = sizeof(DIPROPHEADER); - DIPropAutoCenter.diph.dwObj = 0; - DIPropAutoCenter.diph.dwHow = DIPH_DEVICE; - DIPropAutoCenter.dwData = ( onoff ? DIPROPAUTOCENTER_ON : DIPROPAUTOCENTER_OFF ); - - hr = mpJoystick->SetProperty( DIPROP_AUTOCENTER, &DIPropAutoCenter.diph ); - return hr; -} diff --git a/cpp/JXInput/jxinput.dsp b/cpp/JXInput/jxinput.dsp deleted file mode 100644 index 8bc8c66..0000000 --- a/cpp/JXInput/jxinput.dsp +++ /dev/null @@ -1,175 +0,0 @@ -# Microsoft Developer Studio Project File - Name="jxinput" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** NICHT BEARBEITEN ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=jxinput - Win32 Debug -!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE -!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl -!MESSAGE -!MESSAGE NMAKE /f "jxinput.mak". -!MESSAGE -!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben -!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: -!MESSAGE -!MESSAGE NMAKE /f "jxinput.mak" CFG="jxinput - Win32 Debug" -!MESSAGE -!MESSAGE Für die Konfiguration stehen zur Auswahl: -!MESSAGE -!MESSAGE "jxinput - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") -!MESSAGE "jxinput - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "jxinput - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JXINPUT_EXPORTS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "C:\j2sdk1.4.2\include" /I "C:\j2sdk1.4.2\include\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JXINPUT_EXPORTS" /FR /Yu"stdafx.h" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "NDEBUG" -# ADD RSC /l 0x407 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 dxguid.lib dinput8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\build\jxinput.dll" - -!ELSEIF "$(CFG)" == "jxinput - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JXINPUT_EXPORTS" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "C:\j2sdk1.4.2\include" /I "C:\j2sdk1.4.2\include\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JXINPUT_EXPORTS" /FR /Yu"stdafx.h" /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "_DEBUG" -# ADD RSC /l 0x407 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 dxguid.lib dinput8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\Classes\jxinput.dll" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "jxinput - Win32 Release" -# Name "jxinput - Win32 Debug" -# Begin Group "Quellcodedateien" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\de_hardcode_jxinput_directinput_DirectInputDriver.cpp -# End Source File -# Begin Source File - -SOURCE=.\dllmain.cpp -# End Source File -# Begin Source File - -SOURCE=.\jxinput.cpp -# End Source File -# Begin Source File - -SOURCE=.\JXInputManager.cpp -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.cpp -# ADD CPP /Yc"stdafx.h" -# End Source File -# End Group -# Begin Group "Header-Dateien" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\de_hardcode_jxinput_directinput_DirectInputDriver.h - -!IF "$(CFG)" == "jxinput - Win32 Release" - -# PROP Ignore_Default_Tool 1 -USERDEP__DE_HA="..\classes\de\hardcode\jxinput\directinput\DirectInputDriver.class" -# Begin Custom Build -InputPath=.\de_hardcode_jxinput_directinput_DirectInputDriver.h - -"de_hardcode_jxinput_directinput_DirectInputDriver.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - cd ..\Classes - C:\j2sdk1.4.2\bin\javah -classpath . -d ..\win32 de.hardcode.jxinput.directinput.DirectInputDriver - cd ..\win32 - -# End Custom Build - -!ELSEIF "$(CFG)" == "jxinput - Win32 Debug" - -# PROP Ignore_Default_Tool 1 -USERDEP__DE_HA="..\classes\de\hardcode\jxinput\directinput\DirectInputDriver.class" -# Begin Custom Build -InputPath=.\de_hardcode_jxinput_directinput_DirectInputDriver.h - -"de_hardcode_jxinput_directinput_DirectInputDriver.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - cd ..\Classes - C:\j2sdk1.4.2\bin\javah -classpath . -d ..\win32 de.hardcode.jxinput.directinput.DirectInputDriver - cd ..\win32 - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\jxinput.h -# End Source File -# Begin Source File - -SOURCE=.\JXInputManager.h -# End Source File -# Begin Source File - -SOURCE=.\StdAfx.h -# End Source File -# End Group -# Begin Group "Ressourcendateien" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# Begin Source File - -SOURCE=.\ReadMe.txt -# End Source File -# End Target -# End Project diff --git a/cpp/JXInput/jxinput.dsw b/cpp/JXInput/jxinput.dsw deleted file mode 100644 index b685e40..0000000 --- a/cpp/JXInput/jxinput.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! - -############################################################################### - -Project: "jxinput"=".\jxinput.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/cpp/JXInput/jxinput.h b/cpp/JXInput/jxinput.h deleted file mode 100644 index 6d47a31..0000000 --- a/cpp/JXInput/jxinput.h +++ /dev/null @@ -1,183 +0,0 @@ - -#define JXINPUT_MAX_AXES 8 -#define JXINPUT_MAX_BUTTONS 256 -#define JXINPUT_MAX_DIRECTIONALS 4 - - -/** - * This class will be exported by jxinput.dll. - */ -class JXINPUT_API JXInput -{ - -public: - - typedef enum AXISTYPE - { - TYPE_TRANSLATION, - TYPE_ROTATION, - TYPE_SLIDER - }; - - typedef enum BUTTONTYPE - { - TYPE_PUSHBUTTON, - TYPE_TOGGLEBUTTON - }; - - typedef enum AXISID - { - ID_X, ID_Y, ID_Z, - ID_ROTX, ID_ROTY, ID_ROTZ, - ID_SLIDER0, ID_SLIDER1 - }; - - - // - // Ctor - // - JXInput( LPDIRECTINPUTDEVICE8 pJoystick, HWND hWnd = NULL ); - - // - // Dtor - // - virtual ~JXInput(); - - // - // Operational methods - // - void update(); - - // Ask for the name - TCHAR * const getName() const; - - // - // Numbering methods - // - int getNumberOfAxes() const; - int getNumberOfButtons() const; - int getNumberOfDirectionals() const; - - - // - // Access axes - // - double getX() const; /** -1.0 .... 1.0 */ - double getY() const; /** -1.0 .... 1.0 */ - double getZ() const; /** -1.0 .... 1.0 */ - double getRotX() const; /** -1.0 .... 1.0 */ - double getRotY() const; /** -1.0 .... 1.0 */ - double getRotZ() const; /** -1.0 .... 1.0 */ - double getSlider0() const; /** 0.0 .... 1.0 */ - double getSlider1() const; /** 0.0 .... 1.0 */ - - - // - // Axis methods - // - bool isAxisAvailable( int idx ) const; - TCHAR* const getAxisName( int idx ) const; - int getAxisType( int idx ) const; - double getAxisValue( int idx ) const; - - // - // Button methods - // - bool isButtonAvailable( int idx ) const; - TCHAR* const getButtonName( int idx ) const; - int getButtonType( int idx ) const; - bool isButtonDown( int idx ) const; - - // - // Directional methods - // - bool isDirectionalAvailable( int idx ) const; - TCHAR* const getDirectionalName( int idx ) const; - int getDirection( int idx ) const; - -private://----------------------------------------------------------------------------------------- - LPDIRECTINPUTDEVICE8 mpJoystick; - - DIDEVICEINSTANCE mdiDevInfo; - DIDEVCAPS mdiDevCaps; - DIJOYSTATE2 mJS; // DInput joystick state - - int mSliderCount; - int mPOVCount; - int mButtonCount; - - double getAxisValueHelper( LONG val, int idx ) const; - - HRESULT SwitchAutoCenter( bool onoff = true ); - - HRESULT InitDirectInput( HWND hWnd = NULL ); - HRESULT FreeDirectInput(); - HRESULT UpdateInputState(); - - - static BOOL CALLBACK EnumAxesCallback - ( - const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext - ); - - static BOOL CALLBACK EnumButtonsCallback - ( - const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext - ); - - static BOOL CALLBACK EnumPOVsCallback - ( - const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext - ); - - static BOOL CALLBACK EnumEffectsCallback - ( - const DIEFFECTINFO* pdidoi, - VOID* pContext - ); - - - class JXINPUT_API AxisConfig - { - - public: - bool mIsAvailable; - CHAR mName[MAX_PATH]; - AXISTYPE mType; - LONG mMinValue; - LONG mMaxValue; - double (JXInput::*mGetValueMethod)() const; - - } mAxisConfig [ JXINPUT_MAX_AXES ]; - - void initAxisConfig(); - - - class JXINPUT_API ButtonConfig - { - - public: - bool mIsAvailable; - CHAR mName[MAX_PATH]; - BUTTONTYPE mType; - - } mButtonConfig[ JXINPUT_MAX_BUTTONS ]; - - void initButtonsConfig(); - - - class JXINPUT_API DirectionalConfig - { - - public: - bool mIsAvailable; - CHAR mName[MAX_PATH]; - - } mDirectionalConfig[ JXINPUT_MAX_DIRECTIONALS ]; - - void initDirectionalsConfig(); -}; - diff --git a/cpp/JXInput/jxinput.sln b/cpp/JXInput/jxinput.sln deleted file mode 100644 index 714fdc7..0000000 --- a/cpp/JXInput/jxinput.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jxinput", "jxinput.vcproj", "{8AEA84DC-D8F0-4425-BEBF-A84E91115F76}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8AEA84DC-D8F0-4425-BEBF-A84E91115F76}.Debug|Win32.ActiveCfg = Debug|Win32 - {8AEA84DC-D8F0-4425-BEBF-A84E91115F76}.Debug|Win32.Build.0 = Debug|Win32 - {8AEA84DC-D8F0-4425-BEBF-A84E91115F76}.Release|Win32.ActiveCfg = Release|Win32 - {8AEA84DC-D8F0-4425-BEBF-A84E91115F76}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/cpp/JXInput/jxinput.vcproj b/cpp/JXInput/jxinput.vcproj deleted file mode 100644 index c87fc0f..0000000 --- a/cpp/JXInput/jxinput.vcproj +++ /dev/null @@ -1,367 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cpp/JavaWinampApi/WINAMPCMD.H b/cpp/JavaWinampApi/WINAMPCMD.H deleted file mode 100644 index 9ba5de3..0000000 --- a/cpp/JavaWinampApi/WINAMPCMD.H +++ /dev/null @@ -1,62 +0,0 @@ -#define WINAMP_FILE_QUIT 40001 -#define WINAMP_OPTIONS_PREFS 40012 -#define WINAMP_OPTIONS_AOT 40019 -#define WINAMP_FILE_REPEAT 40022 -#define WINAMP_FILE_SHUFFLE 40023 -#define WINAMP_HIGH_PRIORITY 40025 -#define WINAMP_FILE_PLAY 40029 -#define WINAMP_OPTIONS_EQ 40036 -#define WINAMP_OPTIONS_ELAPSED 40037 -#define WINAMP_OPTIONS_REMAINING 40038 -#define WINAMP_OPTIONS_PLEDIT 40040 -#define WINAMP_HELP_ABOUT 40041 -#define WINAMP_MAINMENU 40043 -#define WINAMP_BUTTON1 40044 -#define WINAMP_BUTTON2 40045 -#define WINAMP_BUTTON3 40046 -#define WINAMP_BUTTON4 40047 -#define WINAMP_BUTTON5 40048 -#define WINAMP_VOLUMEUP 40058 -#define WINAMP_VOLUMEDOWN 40059 -#define WINAMP_FFWD5S 40060 -#define WINAMP_REW5S 40061 -#define WINAMP_NEXT_WINDOW 40063 -#define WINAMP_OPTIONS_WINDOWSHADE 40064 -#define WINAMP_BUTTON1_SHIFT 40144 -#define WINAMP_BUTTON2_SHIFT 40145 -#define WINAMP_BUTTON3_SHIFT 40146 -#define WINAMP_BUTTON4_SHIFT 40147 -#define WINAMP_BUTTON5_SHIFT 40148 -#define WINAMP_BUTTON1_CTRL 40154 -#define WINAMP_BUTTON2_CTRL 40155 -#define WINAMP_BUTTON3_CTRL 40156 -#define WINAMP_BUTTON4_CTRL 40157 -#define WINAMP_BUTTON5_CTRL 40158 -#define WINAMP_OPTIONS_DSIZE 40165 -#define IDC_SORT_FILENAME 40166 -#define IDC_SORT_FILETITLE 40167 -#define IDC_SORT_ENTIREFILENAME 40168 -#define IDC_SELECTALL 40169 -#define IDC_SELECTNONE 40170 -#define IDC_SELECTINV 40171 -#define IDM_EQ_LOADPRE 40172 -#define IDM_EQ_LOADMP3 40173 -#define IDM_EQ_LOADDEFAULT 40174 -#define IDM_EQ_SAVEPRE 40175 -#define IDM_EQ_SAVEMP3 40176 -#define IDM_EQ_SAVEDEFAULT 40177 -#define IDM_EQ_DELPRE 40178 -#define IDM_EQ_DELMP3 40180 -#define IDC_PLAYLIST_PLAY 40184 -#define WINAMP_FILE_LOC 40185 -#define WINAMP_OPTIONS_EASYMOVE 40186 -#define WINAMP_FILE_DIR 40187 -#define WINAMP_EDIT_ID3 40188 -#define WINAMP_TOGGLE_AUTOSCROLL 40189 -#define WINAMP_VISSETUP 40190 -#define WINAMP_PLGSETUP 40191 -#define WINAMP_VISPLUGIN 40192 -#define WINAMP_JUMP 40193 -#define WINAMP_JUMPFILE 40194 -#define WINAMP_JUMP10FWD 40195 -#define WINAMP_JUMP10BACK 40197 diff --git a/cpp/JavaWinampApi/WinampController.c b/cpp/JavaWinampApi/WinampController.c deleted file mode 100644 index 84b0db8..0000000 --- a/cpp/JavaWinampApi/WinampController.c +++ /dev/null @@ -1,587 +0,0 @@ -/* meu .h */ -#include "WinampController.h" - -/* mingw */ -#include -#include -#include - -/* winamp sdk */ -#include "wa_ipc.h" -#include "WINAMPCMD.H" - -const int WA_CLOSE = 40001 ; -const int WA_PLAY = WINAMP_BUTTON2; -const int WA_STOP = WINAMP_BUTTON4; -const int WA_PAUSE = WINAMP_BUTTON3; -const int WA_PREVTRACK = WINAMP_BUTTON1; -const int WA_NEXTTRACK = WINAMP_BUTTON5; -const int WA_FWD5SECS = WINAMP_FFWD5S; -const int WA_REW5SECS = WINAMP_REW5S; - -const int WA_PLAYLISTLEN = IPC_GETLISTLENGTH; -const int WA_SETVOLUME = IPC_SETVOLUME; -const int WA_SETPLAYLISTPOS = IPC_SETPLAYLISTPOS; -const int WA_WRITEPLAYLIST = IPC_WRITEPLAYLIST; -const int WA_ENQUEUEFILE = IPC_ENQUEUEFILE; - -const int WA_VOLUMEUP = WINAMP_VOLUMEUP; -const int WA_VOLUMEDOWN = WINAMP_VOLUMEDOWN; - -const int WA_CLEARPLAYLIST = IPC_DELETE; -const int WA_NOTHING = 0; -const int WA_TRACK_LENGTH = 1; - -const int WA_RESTART = IPC_RESTARTWINAMP; -const int WA_REFRESHPLCACHE = IPC_REFRESHPLCACHE; -const int WA_GETSHUFFLESTATUS = IPC_GET_SHUFFLE; -const int WA_GETREPEATSTATUS = IPC_GET_REPEAT; -const int WA_SETSHUFFLESTATUS = IPC_SET_SHUFFLE; -const int WA_SETREPEATSTATUS = IPC_SET_REPEAT; - -const int WA_GETSTATUS = IPC_ISPLAYING; - -const int WA_GETLISTPOS = IPC_GETLISTPOS; -const int WA_GETTITLE = IPC_GETPLAYLISTTITLE; - -const int WA_VERSION = IPC_GETVERSION; -const int WA_FILENAMEINLIST = IPC_GETPLAYLISTFILE; -const int WA_GETFILEINFO = IPC_GET_EXTENDED_FILE_INFO; - -HWND hwnd_winamp = NULL; -INT position = 0; -STARTUPINFO si; -PROCESS_INFORMATION pi; -char messageReturn[255]; -wchar_t* wMessageReturn; - -LPDWORD temp; - -void initWinampHandle() { - hwnd_winamp = NULL; - if (hwnd_winamp == NULL) { - hwnd_winamp = FindWindow("Winamp v1.x", NULL); - } - if (hwnd_winamp == NULL) { - hwnd_winamp = FindWindow("Winamp v2.x", NULL); - } - if (hwnd_winamp == NULL) { - hwnd_winamp = FindWindow("Winamp v3.x", NULL); - } -} - -jboolean runWinamp(unsigned char* pathWinamp) { - - /* STARTUPINFO si; - PROCESS_INFORMATION pi;*/ - - ZeroMemory( &si, sizeof(si) ); - si.cb = sizeof(si); - ZeroMemory( &pi, sizeof(pi) ); - - - // Start the child process. - if(!CreateProcess(pathWinamp, - NULL, - 0, - 0, - FALSE, - CREATE_NEW_CONSOLE, - 0, - 0, - &si, - &pi)) - { - return FALSE; - } - - DWORD dwResult = WaitForInputIdle(pi.hProcess,INFINITE); - if (dwResult != 0) return FALSE; - - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - - return TRUE; - - -} - -int getListPos() { - - initWinampHandle(); - if (hwnd_winamp != NULL) { - - return SendMessage(hwnd_winamp,WM_USER,WA_NOTHING,WA_GETLISTPOS); - - } - return -1; - -} - -void getPluginMessage(int param, int sendMessage) -{ - - LPCVOID message = (LPCVOID)SendMessageW(hwnd_winamp, WM_USER, param, sendMessage); - ZeroMemory( &pi, sizeof(pi)); - GetWindowThreadProcessId(hwnd_winamp, &pi.dwThreadId); - pi.hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pi.dwThreadId); - ReadProcessMemory(pi.hProcess, message, messageReturn,2056,temp); - free(temp); - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_run - (JNIEnv *env, jobject obj) { - - initWinampHandle(); - - if ( hwnd_winamp == NULL ) { - - unsigned char path[MAX_PATH]=""; - DWORD size = MAX_PATH; - - HKEY key; - DWORD tipo; - - if (!RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\Clients\\Media\\Winamp\\shell\\open\\command",&key)==ERROR_SUCCESS) - { - - printf("0"); - return FALSE; - - } - - if (!(RegQueryValueEx(key,"",NULL,&tipo,path,&size))==ERROR_SUCCESS) - { - - RegCloseKey(key); - return FALSE; - - } - - if (!runWinamp(path)) - { - - RegCloseKey(key); - return FALSE; - - } - return TRUE; - - } - - int version = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION); - return TRUE; - -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_exit - (JNIEnv *env, jobject obj) { - - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_CLOSE, WA_NOTHING); - return TRUE; - } - - return FALSE; - - -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_play - (JNIEnv *env, jobject obj) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - - SendMessageA(hwnd_winamp, WM_COMMAND, WA_PLAY, WA_NOTHING); - return TRUE; - - } - - return FALSE; -} - - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_stop - (JNIEnv *env, jobject obj) -{ - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_STOP, WA_NOTHING); - return TRUE; - } - - return FALSE; -} - - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_resume - (JNIEnv *env, jobject obj) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_PAUSE, WA_NOTHING); - return TRUE; - } - - return FALSE; -} - - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_pause - (JNIEnv *env, jobject obj) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_PAUSE, WA_NOTHING); - return TRUE; - } - - return FALSE; -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_previousTrack - (JNIEnv *env, jobject obj) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_PREVTRACK, WA_NOTHING); - return TRUE; - } - - return FALSE; - -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_nextTrack - (JNIEnv *env, jobject obj) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_NEXTTRACK, WA_NOTHING); - return TRUE; - } - - return FALSE; -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_fwd5Secs - (JNIEnv *env, jobject obj) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_FWD5SECS, WA_NOTHING); - return TRUE; - } - - return FALSE; -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_rew5Secs - (JNIEnv *env, jobject obj) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_REW5SECS, WA_NOTHING); - return TRUE; - } - - return FALSE; -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_increaseVolume - (JNIEnv *env, jobject obj) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_VOLUMEUP, WA_NOTHING); - return TRUE; - } - - return FALSE; - -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_decreaseVolume - (JNIEnv *env, jobject obj) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_COMMAND, WA_VOLUMEDOWN, WA_NOTHING); - return TRUE; - } - - return FALSE; - -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_increaseVolumePercent - (JNIEnv *env, jobject obj, jint percent) { - initWinampHandle(); - int i = 0; - if (hwnd_winamp != NULL) { - for(i=0;i0?1:0; -} - -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_isRepeatStatusOn - (JNIEnv *env, jobject obj) { - jint status = 0; - initWinampHandle(); - if (hwnd_winamp != NULL) { - status = (jint)SendMessageA(hwnd_winamp, WM_USER, WA_NOTHING, WA_GETREPEATSTATUS); - } else - return -1; - - return status>0?1:0; -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setRepeatStatusOn - (JNIEnv *env, jobject obj, jboolean status) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_USER, status, WA_SETREPEATSTATUS); - return TRUE; - } - - return FALSE; -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setShuffleStatusOn - (JNIEnv *env, jobject obj, jboolean status) { - initWinampHandle(); - if (hwnd_winamp != NULL) { - SendMessageA(hwnd_winamp, WM_USER, status, WA_SETSHUFFLESTATUS); - return TRUE; - } - - return FALSE; -} - -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_appendToPlayList - (JNIEnv *env, jobject obj, jstring mp3filename) { - initWinampHandle(); - jboolean iscopy; - if (hwnd_winamp != NULL) { - wMessageReturn = (wchar_t*)(*env)->GetStringChars(env, mp3filename, &iscopy); - int length = wcslen(wMessageReturn); - COPYDATASTRUCT cds; - cds.dwData = IPC_PLAYFILEW; - cds.lpData = (void*)wMessageReturn; - cds.cbData = length * 2 + 2 ; // it sums white space - - SendMessageW(hwnd_winamp, WM_COPYDATA, WA_NOTHING, (LPARAM)&cds); - return TRUE; - } - - return FALSE; - -} - -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getStatus - (JNIEnv *env, jobject obj) { - jint status = -1; - initWinampHandle(); - if (hwnd_winamp != NULL) { - status = SendMessageA(hwnd_winamp, WM_USER, WA_NOTHING, WA_GETSTATUS); - } - - return status; - - -} - -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getListPos - (JNIEnv *env, jobject obj) { - - return getListPos(); - -} - -JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getTitle - (JNIEnv *env, jobject obj) { - - initWinampHandle(); - if (hwnd_winamp != NULL) { - - char title[500] = ""; - GetWindowText(hwnd_winamp,title,500); - return (*env)->NewStringUTF(env,title); - - - } - - return NULL; - -} - -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getTime - (JNIEnv *env, jobject obj, jint mode) { - - initWinampHandle(); - if (hwnd_winamp != NULL) { - - return SendMessage(hwnd_winamp,WM_USER,mode,IPC_GETOUTPUTTIME); - - } - - return -2; - -} - -JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getFileNameInList - (JNIEnv *env, jobject obj, jint index) -{ - - initWinampHandle(); - - if (hwnd_winamp != NULL) { - - getPluginMessage(index, WA_FILENAMEINLIST); - char* filePath = messageReturn; - jstring strReturn = (*env)->NewStringUTF(env,filePath); - return strReturn; - - } - - return NULL; - -} - -JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getFileNamePlaying - (JNIEnv *env, jobject obj) -{ - - initWinampHandle(); - - if (hwnd_winamp != NULL) { - - getPluginMessage(WA_NOTHING, IPC_GET_PLAYING_FILENAME); - wchar_t* fileName = (wchar_t*)messageReturn; - int length = wcslen(fileName); - jstring strReturn = (*env)->NewString(env,fileName,length); - return strReturn; - - } - - return NULL; - -} diff --git a/cpp/JavaWinampApi/WinampController.h b/cpp/JavaWinampApi/WinampController.h deleted file mode 100644 index b9ec6be..0000000 --- a/cpp/JavaWinampApi/WinampController.h +++ /dev/null @@ -1,285 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class WinampController */ - - -#ifndef _Included_WinampController -#define _Included_WinampController -#ifdef __cplusplus -extern "C" { -#endif - -void initWinampHandle(); - -jboolean runWinamp(unsigned char* pathWinamp); - -int getListPos(); - -void getPluginMessage(int param, int sendMessage); - -/* - * Class: WinampController - * Method: run - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_run - (JNIEnv *, jclass); -/* - * Class: WinampController - * Method: exit - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_exit - (JNIEnv *, jclass); -/* - * Class: WinampController - * Method: play - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_play - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: stop - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_stop - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: resume - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_resume - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: pause - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_pause - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: previousTrack - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_previousTrack - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: nextTrack - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_nextTrack - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: fwd5Secs - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_fwd5Secs - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: fwd5Secs - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_rew5Secs - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: increaseVolume - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_increaseVolume - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: decreaseVolume - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_decreaseVolume - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: increaseVolumePercent - * Signature: (I)V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_increaseVolumePercent - (JNIEnv *, jclass, jint); - -/* - * Class: WinampController - * Method: decreaseVolumePercent - * Signature: (I)V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_decreaseVolumePercent - (JNIEnv *, jclass, jint); - -/* - * Class: WinampController - * Method: setVolume - * Signature: (I)V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setVolume - (JNIEnv *, jclass, jint); - -/* - * Class: WinampController - * Method: setVolume - * Signature: (I)V - */ -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getVolume - (JNIEnv *, jclass, jint); - -/* - * Class: WinampController - * Method: restart - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_restart - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: setPlaylistPosition - * Signature: (I)V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setPlaylistPosition - (JNIEnv *, jclass, jint); - -/* - * Class: WinampController - * Method: clearPlayList - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_clearPlayList - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: refreshPlayListCache - * Signature: ()V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_refreshPlayListCache - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: getPlayListLength - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getPlayListLength - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: writePlayListToFile - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_writePlayListToFile - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: isShuffleStatusOn - * Signature: ()Z - */ -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_isShuffleStatusOn - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: isRepeatStatusOn - * Signature: ()Z - */ -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_isRepeatStatusOn - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: setRepeatStatusOn - * Signature: (Z)V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setRepeatStatusOn - (JNIEnv *, jclass, jboolean); - -/* - * Class: WinampController - * Method: setShuffleStatusOn - * Signature: (Z)V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setShuffleStatusOn - (JNIEnv *, jclass, jboolean); - -/* - * Class: WinampController - * Method: appendToPlayList - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_appendToPlayList - (JNIEnv *, jclass, jstring); - -/* - * Class: WinampController - * Method: getStatus - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getStatus - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: getListPos - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getListPos - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: getTitle - * Signature: ()I - */ -JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getTitle - (JNIEnv *, jclass); - -/* - * Class: WinampController - * Method: getTime - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getTime - (JNIEnv *, jclass, jint); - -/* - * Class: WinampController - * Method: getFileNameInList - * Signature: ()I - */ -JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getFileNameInList - (JNIEnv *, jclass, jint); - -/* - * Class: WinampController - * Method: getFileNamePlaying - * Signature: ()I - */ -JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getFileNamePlaying - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/JavaWinampApi/dev/copy.bat b/cpp/JavaWinampApi/dev/copy.bat deleted file mode 100644 index 6045ddb..0000000 --- a/cpp/JavaWinampApi/dev/copy.bat +++ /dev/null @@ -1 +0,0 @@ -copy wpcom.dll ..\..\..\java\native\ \ No newline at end of file diff --git a/cpp/JavaWinampApi/dev/copy.mak b/cpp/JavaWinampApi/dev/copy.mak deleted file mode 100644 index 5459618..0000000 --- a/cpp/JavaWinampApi/dev/copy.mak +++ /dev/null @@ -1,2 +0,0 @@ -all-after: - copy.bat \ No newline at end of file diff --git a/cpp/JavaWinampApi/dev/wpcom.dev b/cpp/JavaWinampApi/dev/wpcom.dev deleted file mode 100644 index 8774d56..0000000 --- a/cpp/JavaWinampApi/dev/wpcom.dev +++ /dev/null @@ -1,69 +0,0 @@ -[Project] -FileName=wpcom.dev -Name=wpcom -UnitCount=2 -Type=3 -Ver=1 -ObjFiles= -Includes=..\include;..\include\win32 -Libs= -PrivateResource= -ResourceIncludes= -MakeIncludes=copy.mak -Compiler=-DBUILDING_DLL=1_@@_ -CppCompiler=-DBUILDING_DLL=1_@@_ -Linker=--no-export-all-symbols --add-stdcall-alias_@@_ -IsCpp=0 -Icon= -ExeOutput= -ObjectOutput= -OverrideOutput=0 -OverrideOutputName=wpcom.dll -HostApplication= -Folders= -CommandLine= -UseCustomMakefile=0 -CustomMakefile= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=0000000000000000000000 - -[Unit1] -FileName=..\WinampController.c -CompileCpp=0 -Folder=wpcom -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion= -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= -AutoIncBuildNr=0 - -[Unit2] -FileName=..\WinampController.h -CompileCpp=0 -Folder=wpcom -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - diff --git a/cpp/JavaWinampApi/include/classfile_constants.h b/cpp/JavaWinampApi/include/classfile_constants.h deleted file mode 100644 index 30e839e..0000000 --- a/cpp/JavaWinampApi/include/classfile_constants.h +++ /dev/null @@ -1,523 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - * - */ - -#ifndef CLASSFILE_CONSTANTS_H -#define CLASSFILE_CONSTANTS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Flags */ - -enum { - JVM_ACC_PUBLIC = 0x0001, - JVM_ACC_PRIVATE = 0x0002, - JVM_ACC_PROTECTED = 0x0004, - JVM_ACC_STATIC = 0x0008, - JVM_ACC_FINAL = 0x0010, - JVM_ACC_SYNCHRONIZED = 0x0020, - JVM_ACC_SUPER = 0x0020, - JVM_ACC_VOLATILE = 0x0040, - JVM_ACC_BRIDGE = 0x0040, - JVM_ACC_TRANSIENT = 0x0080, - JVM_ACC_VARARGS = 0x0080, - JVM_ACC_NATIVE = 0x0100, - JVM_ACC_INTERFACE = 0x0200, - JVM_ACC_ABSTRACT = 0x0400, - JVM_ACC_STRICT = 0x0800, - JVM_ACC_SYNTHETIC = 0x1000, - JVM_ACC_ANNOTATION = 0x2000, - JVM_ACC_ENUM = 0x4000 -}; - -/* Used in newarray instruction. */ - -enum { - JVM_T_BOOLEAN = 4, - JVM_T_CHAR = 5, - JVM_T_FLOAT = 6, - JVM_T_DOUBLE = 7, - JVM_T_BYTE = 8, - JVM_T_SHORT = 9, - JVM_T_INT = 10, - JVM_T_LONG = 11 -}; - -/* Constant Pool Entries */ - -enum { - JVM_CONSTANT_Utf8 = 1, - JVM_CONSTANT_Unicode = 2, /* unused */ - JVM_CONSTANT_Integer = 3, - JVM_CONSTANT_Float = 4, - JVM_CONSTANT_Long = 5, - JVM_CONSTANT_Double = 6, - JVM_CONSTANT_Class = 7, - JVM_CONSTANT_String = 8, - JVM_CONSTANT_Fieldref = 9, - JVM_CONSTANT_Methodref = 10, - JVM_CONSTANT_InterfaceMethodref = 11, - JVM_CONSTANT_NameAndType = 12 -}; - -/* StackMapTable type item numbers */ - -enum { - JVM_ITEM_Top = 0, - JVM_ITEM_Integer = 1, - JVM_ITEM_Float = 2, - JVM_ITEM_Double = 3, - JVM_ITEM_Long = 4, - JVM_ITEM_Null = 5, - JVM_ITEM_UninitializedThis = 6, - JVM_ITEM_Object = 7, - JVM_ITEM_Uninitialized = 8 -}; - -/* Type signatures */ - -enum { - JVM_SIGNATURE_ARRAY = '[', - JVM_SIGNATURE_BYTE = 'B', - JVM_SIGNATURE_CHAR = 'C', - JVM_SIGNATURE_CLASS = 'L', - JVM_SIGNATURE_ENDCLASS = ';', - JVM_SIGNATURE_ENUM = 'E', - JVM_SIGNATURE_FLOAT = 'F', - JVM_SIGNATURE_DOUBLE = 'D', - JVM_SIGNATURE_FUNC = '(', - JVM_SIGNATURE_ENDFUNC = ')', - JVM_SIGNATURE_INT = 'I', - JVM_SIGNATURE_LONG = 'J', - JVM_SIGNATURE_SHORT = 'S', - JVM_SIGNATURE_VOID = 'V', - JVM_SIGNATURE_BOOLEAN = 'Z' -}; - -/* Opcodes */ - -enum { - JVM_OPC_nop = 0, - JVM_OPC_aconst_null = 1, - JVM_OPC_iconst_m1 = 2, - JVM_OPC_iconst_0 = 3, - JVM_OPC_iconst_1 = 4, - JVM_OPC_iconst_2 = 5, - JVM_OPC_iconst_3 = 6, - JVM_OPC_iconst_4 = 7, - JVM_OPC_iconst_5 = 8, - JVM_OPC_lconst_0 = 9, - JVM_OPC_lconst_1 = 10, - JVM_OPC_fconst_0 = 11, - JVM_OPC_fconst_1 = 12, - JVM_OPC_fconst_2 = 13, - JVM_OPC_dconst_0 = 14, - JVM_OPC_dconst_1 = 15, - JVM_OPC_bipush = 16, - JVM_OPC_sipush = 17, - JVM_OPC_ldc = 18, - JVM_OPC_ldc_w = 19, - JVM_OPC_ldc2_w = 20, - JVM_OPC_iload = 21, - JVM_OPC_lload = 22, - JVM_OPC_fload = 23, - JVM_OPC_dload = 24, - JVM_OPC_aload = 25, - JVM_OPC_iload_0 = 26, - JVM_OPC_iload_1 = 27, - JVM_OPC_iload_2 = 28, - JVM_OPC_iload_3 = 29, - JVM_OPC_lload_0 = 30, - JVM_OPC_lload_1 = 31, - JVM_OPC_lload_2 = 32, - JVM_OPC_lload_3 = 33, - JVM_OPC_fload_0 = 34, - JVM_OPC_fload_1 = 35, - JVM_OPC_fload_2 = 36, - JVM_OPC_fload_3 = 37, - JVM_OPC_dload_0 = 38, - JVM_OPC_dload_1 = 39, - JVM_OPC_dload_2 = 40, - JVM_OPC_dload_3 = 41, - JVM_OPC_aload_0 = 42, - JVM_OPC_aload_1 = 43, - JVM_OPC_aload_2 = 44, - JVM_OPC_aload_3 = 45, - JVM_OPC_iaload = 46, - JVM_OPC_laload = 47, - JVM_OPC_faload = 48, - JVM_OPC_daload = 49, - JVM_OPC_aaload = 50, - JVM_OPC_baload = 51, - JVM_OPC_caload = 52, - JVM_OPC_saload = 53, - JVM_OPC_istore = 54, - JVM_OPC_lstore = 55, - JVM_OPC_fstore = 56, - JVM_OPC_dstore = 57, - JVM_OPC_astore = 58, - JVM_OPC_istore_0 = 59, - JVM_OPC_istore_1 = 60, - JVM_OPC_istore_2 = 61, - JVM_OPC_istore_3 = 62, - JVM_OPC_lstore_0 = 63, - JVM_OPC_lstore_1 = 64, - JVM_OPC_lstore_2 = 65, - JVM_OPC_lstore_3 = 66, - JVM_OPC_fstore_0 = 67, - JVM_OPC_fstore_1 = 68, - JVM_OPC_fstore_2 = 69, - JVM_OPC_fstore_3 = 70, - JVM_OPC_dstore_0 = 71, - JVM_OPC_dstore_1 = 72, - JVM_OPC_dstore_2 = 73, - JVM_OPC_dstore_3 = 74, - JVM_OPC_astore_0 = 75, - JVM_OPC_astore_1 = 76, - JVM_OPC_astore_2 = 77, - JVM_OPC_astore_3 = 78, - JVM_OPC_iastore = 79, - JVM_OPC_lastore = 80, - JVM_OPC_fastore = 81, - JVM_OPC_dastore = 82, - JVM_OPC_aastore = 83, - JVM_OPC_bastore = 84, - JVM_OPC_castore = 85, - JVM_OPC_sastore = 86, - JVM_OPC_pop = 87, - JVM_OPC_pop2 = 88, - JVM_OPC_dup = 89, - JVM_OPC_dup_x1 = 90, - JVM_OPC_dup_x2 = 91, - JVM_OPC_dup2 = 92, - JVM_OPC_dup2_x1 = 93, - JVM_OPC_dup2_x2 = 94, - JVM_OPC_swap = 95, - JVM_OPC_iadd = 96, - JVM_OPC_ladd = 97, - JVM_OPC_fadd = 98, - JVM_OPC_dadd = 99, - JVM_OPC_isub = 100, - JVM_OPC_lsub = 101, - JVM_OPC_fsub = 102, - JVM_OPC_dsub = 103, - JVM_OPC_imul = 104, - JVM_OPC_lmul = 105, - JVM_OPC_fmul = 106, - JVM_OPC_dmul = 107, - JVM_OPC_idiv = 108, - JVM_OPC_ldiv = 109, - JVM_OPC_fdiv = 110, - JVM_OPC_ddiv = 111, - JVM_OPC_irem = 112, - JVM_OPC_lrem = 113, - JVM_OPC_frem = 114, - JVM_OPC_drem = 115, - JVM_OPC_ineg = 116, - JVM_OPC_lneg = 117, - JVM_OPC_fneg = 118, - JVM_OPC_dneg = 119, - JVM_OPC_ishl = 120, - JVM_OPC_lshl = 121, - JVM_OPC_ishr = 122, - JVM_OPC_lshr = 123, - JVM_OPC_iushr = 124, - JVM_OPC_lushr = 125, - JVM_OPC_iand = 126, - JVM_OPC_land = 127, - JVM_OPC_ior = 128, - JVM_OPC_lor = 129, - JVM_OPC_ixor = 130, - JVM_OPC_lxor = 131, - JVM_OPC_iinc = 132, - JVM_OPC_i2l = 133, - JVM_OPC_i2f = 134, - JVM_OPC_i2d = 135, - JVM_OPC_l2i = 136, - JVM_OPC_l2f = 137, - JVM_OPC_l2d = 138, - JVM_OPC_f2i = 139, - JVM_OPC_f2l = 140, - JVM_OPC_f2d = 141, - JVM_OPC_d2i = 142, - JVM_OPC_d2l = 143, - JVM_OPC_d2f = 144, - JVM_OPC_i2b = 145, - JVM_OPC_i2c = 146, - JVM_OPC_i2s = 147, - JVM_OPC_lcmp = 148, - JVM_OPC_fcmpl = 149, - JVM_OPC_fcmpg = 150, - JVM_OPC_dcmpl = 151, - JVM_OPC_dcmpg = 152, - JVM_OPC_ifeq = 153, - JVM_OPC_ifne = 154, - JVM_OPC_iflt = 155, - JVM_OPC_ifge = 156, - JVM_OPC_ifgt = 157, - JVM_OPC_ifle = 158, - JVM_OPC_if_icmpeq = 159, - JVM_OPC_if_icmpne = 160, - JVM_OPC_if_icmplt = 161, - JVM_OPC_if_icmpge = 162, - JVM_OPC_if_icmpgt = 163, - JVM_OPC_if_icmple = 164, - JVM_OPC_if_acmpeq = 165, - JVM_OPC_if_acmpne = 166, - JVM_OPC_goto = 167, - JVM_OPC_jsr = 168, - JVM_OPC_ret = 169, - JVM_OPC_tableswitch = 170, - JVM_OPC_lookupswitch = 171, - JVM_OPC_ireturn = 172, - JVM_OPC_lreturn = 173, - JVM_OPC_freturn = 174, - JVM_OPC_dreturn = 175, - JVM_OPC_areturn = 176, - JVM_OPC_return = 177, - JVM_OPC_getstatic = 178, - JVM_OPC_putstatic = 179, - JVM_OPC_getfield = 180, - JVM_OPC_putfield = 181, - JVM_OPC_invokevirtual = 182, - JVM_OPC_invokespecial = 183, - JVM_OPC_invokestatic = 184, - JVM_OPC_invokeinterface = 185, - JVM_OPC_xxxunusedxxx = 186, - JVM_OPC_new = 187, - JVM_OPC_newarray = 188, - JVM_OPC_anewarray = 189, - JVM_OPC_arraylength = 190, - JVM_OPC_athrow = 191, - JVM_OPC_checkcast = 192, - JVM_OPC_instanceof = 193, - JVM_OPC_monitorenter = 194, - JVM_OPC_monitorexit = 195, - JVM_OPC_wide = 196, - JVM_OPC_multianewarray = 197, - JVM_OPC_ifnull = 198, - JVM_OPC_ifnonnull = 199, - JVM_OPC_goto_w = 200, - JVM_OPC_jsr_w = 201, - JVM_OPC_MAX = 201 -}; - -/* Opcode length initializer, use with something like: - * unsigned char opcode_length[JVM_OPC_MAX+1] = JVM_OPCODE_LENGTH_INITIALIZER; - */ -#define JVM_OPCODE_LENGTH_INITIALIZER { \ - 1, /* nop */ \ - 1, /* aconst_null */ \ - 1, /* iconst_m1 */ \ - 1, /* iconst_0 */ \ - 1, /* iconst_1 */ \ - 1, /* iconst_2 */ \ - 1, /* iconst_3 */ \ - 1, /* iconst_4 */ \ - 1, /* iconst_5 */ \ - 1, /* lconst_0 */ \ - 1, /* lconst_1 */ \ - 1, /* fconst_0 */ \ - 1, /* fconst_1 */ \ - 1, /* fconst_2 */ \ - 1, /* dconst_0 */ \ - 1, /* dconst_1 */ \ - 2, /* bipush */ \ - 3, /* sipush */ \ - 2, /* ldc */ \ - 3, /* ldc_w */ \ - 3, /* ldc2_w */ \ - 2, /* iload */ \ - 2, /* lload */ \ - 2, /* fload */ \ - 2, /* dload */ \ - 2, /* aload */ \ - 1, /* iload_0 */ \ - 1, /* iload_1 */ \ - 1, /* iload_2 */ \ - 1, /* iload_3 */ \ - 1, /* lload_0 */ \ - 1, /* lload_1 */ \ - 1, /* lload_2 */ \ - 1, /* lload_3 */ \ - 1, /* fload_0 */ \ - 1, /* fload_1 */ \ - 1, /* fload_2 */ \ - 1, /* fload_3 */ \ - 1, /* dload_0 */ \ - 1, /* dload_1 */ \ - 1, /* dload_2 */ \ - 1, /* dload_3 */ \ - 1, /* aload_0 */ \ - 1, /* aload_1 */ \ - 1, /* aload_2 */ \ - 1, /* aload_3 */ \ - 1, /* iaload */ \ - 1, /* laload */ \ - 1, /* faload */ \ - 1, /* daload */ \ - 1, /* aaload */ \ - 1, /* baload */ \ - 1, /* caload */ \ - 1, /* saload */ \ - 2, /* istore */ \ - 2, /* lstore */ \ - 2, /* fstore */ \ - 2, /* dstore */ \ - 2, /* astore */ \ - 1, /* istore_0 */ \ - 1, /* istore_1 */ \ - 1, /* istore_2 */ \ - 1, /* istore_3 */ \ - 1, /* lstore_0 */ \ - 1, /* lstore_1 */ \ - 1, /* lstore_2 */ \ - 1, /* lstore_3 */ \ - 1, /* fstore_0 */ \ - 1, /* fstore_1 */ \ - 1, /* fstore_2 */ \ - 1, /* fstore_3 */ \ - 1, /* dstore_0 */ \ - 1, /* dstore_1 */ \ - 1, /* dstore_2 */ \ - 1, /* dstore_3 */ \ - 1, /* astore_0 */ \ - 1, /* astore_1 */ \ - 1, /* astore_2 */ \ - 1, /* astore_3 */ \ - 1, /* iastore */ \ - 1, /* lastore */ \ - 1, /* fastore */ \ - 1, /* dastore */ \ - 1, /* aastore */ \ - 1, /* bastore */ \ - 1, /* castore */ \ - 1, /* sastore */ \ - 1, /* pop */ \ - 1, /* pop2 */ \ - 1, /* dup */ \ - 1, /* dup_x1 */ \ - 1, /* dup_x2 */ \ - 1, /* dup2 */ \ - 1, /* dup2_x1 */ \ - 1, /* dup2_x2 */ \ - 1, /* swap */ \ - 1, /* iadd */ \ - 1, /* ladd */ \ - 1, /* fadd */ \ - 1, /* dadd */ \ - 1, /* isub */ \ - 1, /* lsub */ \ - 1, /* fsub */ \ - 1, /* dsub */ \ - 1, /* imul */ \ - 1, /* lmul */ \ - 1, /* fmul */ \ - 1, /* dmul */ \ - 1, /* idiv */ \ - 1, /* ldiv */ \ - 1, /* fdiv */ \ - 1, /* ddiv */ \ - 1, /* irem */ \ - 1, /* lrem */ \ - 1, /* frem */ \ - 1, /* drem */ \ - 1, /* ineg */ \ - 1, /* lneg */ \ - 1, /* fneg */ \ - 1, /* dneg */ \ - 1, /* ishl */ \ - 1, /* lshl */ \ - 1, /* ishr */ \ - 1, /* lshr */ \ - 1, /* iushr */ \ - 1, /* lushr */ \ - 1, /* iand */ \ - 1, /* land */ \ - 1, /* ior */ \ - 1, /* lor */ \ - 1, /* ixor */ \ - 1, /* lxor */ \ - 3, /* iinc */ \ - 1, /* i2l */ \ - 1, /* i2f */ \ - 1, /* i2d */ \ - 1, /* l2i */ \ - 1, /* l2f */ \ - 1, /* l2d */ \ - 1, /* f2i */ \ - 1, /* f2l */ \ - 1, /* f2d */ \ - 1, /* d2i */ \ - 1, /* d2l */ \ - 1, /* d2f */ \ - 1, /* i2b */ \ - 1, /* i2c */ \ - 1, /* i2s */ \ - 1, /* lcmp */ \ - 1, /* fcmpl */ \ - 1, /* fcmpg */ \ - 1, /* dcmpl */ \ - 1, /* dcmpg */ \ - 3, /* ifeq */ \ - 3, /* ifne */ \ - 3, /* iflt */ \ - 3, /* ifge */ \ - 3, /* ifgt */ \ - 3, /* ifle */ \ - 3, /* if_icmpeq */ \ - 3, /* if_icmpne */ \ - 3, /* if_icmplt */ \ - 3, /* if_icmpge */ \ - 3, /* if_icmpgt */ \ - 3, /* if_icmple */ \ - 3, /* if_acmpeq */ \ - 3, /* if_acmpne */ \ - 3, /* goto */ \ - 3, /* jsr */ \ - 2, /* ret */ \ - 99, /* tableswitch */ \ - 99, /* lookupswitch */ \ - 1, /* ireturn */ \ - 1, /* lreturn */ \ - 1, /* freturn */ \ - 1, /* dreturn */ \ - 1, /* areturn */ \ - 1, /* return */ \ - 3, /* getstatic */ \ - 3, /* putstatic */ \ - 3, /* getfield */ \ - 3, /* putfield */ \ - 3, /* invokevirtual */ \ - 3, /* invokespecial */ \ - 3, /* invokestatic */ \ - 5, /* invokeinterface */ \ - 0, /* xxxunusedxxx */ \ - 3, /* new */ \ - 2, /* newarray */ \ - 3, /* anewarray */ \ - 1, /* arraylength */ \ - 1, /* athrow */ \ - 3, /* checkcast */ \ - 3, /* instanceof */ \ - 1, /* monitorenter */ \ - 1, /* monitorexit */ \ - 0, /* wide */ \ - 4, /* multianewarray */ \ - 3, /* ifnull */ \ - 3, /* ifnonnull */ \ - 5, /* goto_w */ \ - 5 /* jsr_w */ \ -} - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* CLASSFILE_CONSTANTS */ diff --git a/cpp/JavaWinampApi/include/jawt.h b/cpp/JavaWinampApi/include/jawt.h deleted file mode 100644 index 87e0b18..0000000 --- a/cpp/JavaWinampApi/include/jawt.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -#ifndef _JAVASOFT_JAWT_H_ -#define _JAVASOFT_JAWT_H_ - -#include "jni.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * AWT native interface (new in JDK 1.3) - * - * The AWT native interface allows a native C or C++ application a means - * by which to access native structures in AWT. This is to facilitate moving - * legacy C and C++ applications to Java and to target the needs of the - * community who, at present, wish to do their own native rendering to canvases - * for performance reasons. Standard extensions such as Java3D also require a - * means to access the underlying native data structures of AWT. - * - * There may be future extensions to this API depending on demand. - * - * A VM does not have to implement this API in order to pass the JCK. - * It is recommended, however, that this API is implemented on VMs that support - * standard extensions, such as Java3D. - * - * Since this is a native API, any program which uses it cannot be considered - * 100% pure java. - */ - -/* - * AWT Native Drawing Surface (JAWT_DrawingSurface). - * - * For each platform, there is a native drawing surface structure. This - * platform-specific structure can be found in jawt_md.h. It is recommended - * that additional platforms follow the same model. It is also recommended - * that VMs on Win32 and Solaris support the existing structures in jawt_md.h. - * - ******************* - * EXAMPLE OF USAGE: - ******************* - * - * In Win32, a programmer wishes to access the HWND of a canvas to perform - * native rendering into it. The programmer has declared the paint() method - * for their canvas subclass to be native: - * - * - * MyCanvas.java: - * - * import java.awt.*; - * - * public class MyCanvas extends Canvas { - * - * static { - * System.loadLibrary("mylib"); - * } - * - * public native void paint(Graphics g); - * } - * - * - * myfile.c: - * - * #include "jawt_md.h" - * #include - * - * JNIEXPORT void JNICALL - * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics) - * { - * JAWT awt; - * JAWT_DrawingSurface* ds; - * JAWT_DrawingSurfaceInfo* dsi; - * JAWT_Win32DrawingSurfaceInfo* dsi_win; - * jboolean result; - * jint lock; - * - * // Get the AWT - * awt.version = JAWT_VERSION_1_3; - * result = JAWT_GetAWT(env, &awt); - * assert(result != JNI_FALSE); - * - * // Get the drawing surface - * ds = awt.GetDrawingSurface(env, canvas); - * assert(ds != NULL); - * - * // Lock the drawing surface - * lock = ds->Lock(ds); - * assert((lock & JAWT_LOCK_ERROR) == 0); - * - * // Get the drawing surface info - * dsi = ds->GetDrawingSurfaceInfo(ds); - * - * // Get the platform-specific drawing info - * dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; - * - * ////////////////////////////// - * // !!! DO PAINTING HERE !!! // - * ////////////////////////////// - * - * // Free the drawing surface info - * ds->FreeDrawingSurfaceInfo(dsi); - * - * // Unlock the drawing surface - * ds->Unlock(ds); - * - * // Free the drawing surface - * awt.FreeDrawingSurface(ds); - * } - * - */ - -/* - * JAWT_Rectangle - * Structure for a native rectangle. - */ -typedef struct jawt_Rectangle { - jint x; - jint y; - jint width; - jint height; -} JAWT_Rectangle; - -struct jawt_DrawingSurface; - -/* - * JAWT_DrawingSurfaceInfo - * Structure for containing the underlying drawing information of a component. - */ -typedef struct jawt_DrawingSurfaceInfo { - /* - * Pointer to the platform-specific information. This can be safely - * cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a - * JAWT_X11DrawingSurfaceInfo on Solaris. See jawt_md.h for details. - */ - void* platformInfo; - /* Cached pointer to the underlying drawing surface */ - struct jawt_DrawingSurface* ds; - /* Bounding rectangle of the drawing surface */ - JAWT_Rectangle bounds; - /* Number of rectangles in the clip */ - jint clipSize; - /* Clip rectangle array */ - JAWT_Rectangle* clip; -} JAWT_DrawingSurfaceInfo; - -#define JAWT_LOCK_ERROR 0x00000001 -#define JAWT_LOCK_CLIP_CHANGED 0x00000002 -#define JAWT_LOCK_BOUNDS_CHANGED 0x00000004 -#define JAWT_LOCK_SURFACE_CHANGED 0x00000008 - -/* - * JAWT_DrawingSurface - * Structure for containing the underlying drawing information of a component. - * All operations on a JAWT_DrawingSurface MUST be performed from the same - * thread as the call to GetDrawingSurface. - */ -typedef struct jawt_DrawingSurface { - /* - * Cached reference to the Java environment of the calling thread. - * If Lock(), Unlock(), GetDrawingSurfaceInfo() or - * FreeDrawingSurfaceInfo() are called from a different thread, - * this data member should be set before calling those functions. - */ - JNIEnv* env; - /* Cached reference to the target object */ - jobject target; - /* - * Lock the surface of the target component for native rendering. - * When finished drawing, the surface must be unlocked with - * Unlock(). This function returns a bitmask with one or more of the - * following values: - * - * JAWT_LOCK_ERROR - When an error has occurred and the surface could not - * be locked. - * - * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed. - * - * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed. - * - * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed - */ - jint (JNICALL *Lock) - (struct jawt_DrawingSurface* ds); - /* - * Get the drawing surface info. - * The value returned may be cached, but the values may change if - * additional calls to Lock() or Unlock() are made. - * Lock() must be called before this can return a valid value. - * Returns NULL if an error has occurred. - * When finished with the returned value, FreeDrawingSurfaceInfo must be - * called. - */ - JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo) - (struct jawt_DrawingSurface* ds); - /* - * Free the drawing surface info. - */ - void (JNICALL *FreeDrawingSurfaceInfo) - (JAWT_DrawingSurfaceInfo* dsi); - /* - * Unlock the drawing surface of the target component for native rendering. - */ - void (JNICALL *Unlock) - (struct jawt_DrawingSurface* ds); -} JAWT_DrawingSurface; - -/* - * JAWT - * Structure for containing native AWT functions. - */ -typedef struct jawt { - /* - * Version of this structure. This must always be set before - * calling JAWT_GetAWT() - */ - jint version; - /* - * Return a drawing surface from a target jobject. This value - * may be cached. - * Returns NULL if an error has occurred. - * Target must be a java.awt.Component (should be a Canvas - * or Window for native rendering). - * FreeDrawingSurface() must be called when finished with the - * returned JAWT_DrawingSurface. - */ - JAWT_DrawingSurface* (JNICALL *GetDrawingSurface) - (JNIEnv* env, jobject target); - /* - * Free the drawing surface allocated in GetDrawingSurface. - */ - void (JNICALL *FreeDrawingSurface) - (JAWT_DrawingSurface* ds); - /* - * Since 1.4 - * Locks the entire AWT for synchronization purposes - */ - void (JNICALL *Lock)(JNIEnv* env); - /* - * Since 1.4 - * Unlocks the entire AWT for synchronization purposes - */ - void (JNICALL *Unlock)(JNIEnv* env); - /* - * Since 1.4 - * Returns a reference to a java.awt.Component from a native - * platform handle. On Windows, this corresponds to an HWND; - * on Solaris and Linux, this is a Drawable. For other platforms, - * see the appropriate machine-dependent header file for a description. - * The reference returned by this function is a local - * reference that is only valid in this environment. - * This function returns a NULL reference if no component could be - * found with matching platform information. - */ - jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo); - -} JAWT; - -/* - * Get the AWT native structure. This function returns JNI_FALSE if - * an error occurs. - */ -_JNI_IMPORT_OR_EXPORT_ -jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt); - -#define JAWT_VERSION_1_3 0x00010003 -#define JAWT_VERSION_1_4 0x00010004 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* !_JAVASOFT_JAWT_H_ */ diff --git a/cpp/JavaWinampApi/include/jdwpTransport.h b/cpp/JavaWinampApi/include/jdwpTransport.h deleted file mode 100644 index eae435a..0000000 --- a/cpp/JavaWinampApi/include/jdwpTransport.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -/* - * Java Debug Wire Protocol Transport Service Provider Interface. - */ - -#ifndef JDWPTRANSPORT_H -#define JDWPTRANSPORT_H - -#include "jni.h" - -enum { - JDWPTRANSPORT_VERSION_1_0 = 0x00010000 -}; - -#ifdef __cplusplus -extern "C" { -#endif - -struct jdwpTransportNativeInterface_; - -struct _jdwpTransportEnv; - -#ifdef __cplusplus -typedef _jdwpTransportEnv jdwpTransportEnv; -#else -typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv; -#endif /* __cplusplus */ - -/* - * Errors. Universal errors with JVMTI/JVMDI equivalents keep the - * values the same. - */ -typedef enum { - JDWPTRANSPORT_ERROR_NONE = 0, - JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103, - JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110, - JDWPTRANSPORT_ERROR_INTERNAL = 113, - JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201, - JDWPTRANSPORT_ERROR_IO_ERROR = 202, - JDWPTRANSPORT_ERROR_TIMEOUT = 203, - JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204 -} jdwpTransportError; - - -/* - * Structure to define capabilities - */ -typedef struct { - unsigned int can_timeout_attach :1; - unsigned int can_timeout_accept :1; - unsigned int can_timeout_handshake :1; - unsigned int reserved3 :1; - unsigned int reserved4 :1; - unsigned int reserved5 :1; - unsigned int reserved6 :1; - unsigned int reserved7 :1; - unsigned int reserved8 :1; - unsigned int reserved9 :1; - unsigned int reserved10 :1; - unsigned int reserved11 :1; - unsigned int reserved12 :1; - unsigned int reserved13 :1; - unsigned int reserved14 :1; - unsigned int reserved15 :1; -} JDWPTransportCapabilities; - - -/* - * Structures to define packet layout. - * - * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html - */ - -enum { - JDWPTRANSPORT_FLAGS_NONE = 0x0, - JDWPTRANSPORT_FLAGS_REPLY = 0x80 -}; - -typedef struct { - jint len; - jint id; - jbyte flags; - jbyte cmdSet; - jbyte cmd; - jbyte *data; -} jdwpCmdPacket; - -typedef struct { - jint len; - jint id; - jbyte flags; - jshort errorCode; - jbyte *data; -} jdwpReplyPacket; - -typedef struct { - union { - jdwpCmdPacket cmd; - jdwpReplyPacket reply; - } type; -} jdwpPacket; - -/* - * JDWP functions called by the transport. - */ -typedef struct jdwpTransportCallback { - void *(*alloc)(jint numBytes); /* Call this for all allocations */ - void (*free)(void *buffer); /* Call this for all deallocations */ -} jdwpTransportCallback; - -typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm, - jdwpTransportCallback *callback, - jint version, - jdwpTransportEnv** env); - - - -/* Function Interface */ - -struct jdwpTransportNativeInterface_ { - /* 1 : RESERVED */ - void *reserved1; - - /* 2 : Get Capabilities */ - jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env, - JDWPTransportCapabilities *capabilities_ptr); - - /* 3 : Attach */ - jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env, - const char* address, - jlong attach_timeout, - jlong handshake_timeout); - - /* 4: StartListening */ - jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env, - const char* address, - char** actual_address); - - /* 5: StopListening */ - jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env); - - /* 6: Accept */ - jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env, - jlong accept_timeout, - jlong handshake_timeout); - - /* 7: IsOpen */ - jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env); - - /* 8: Close */ - jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env); - - /* 9: ReadPacket */ - jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env, - jdwpPacket *pkt); - - /* 10: Write Packet */ - jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env, - const jdwpPacket* pkt); - - /* 11: GetLastError */ - jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env, - char** error); - -}; - - -/* - * Use inlined functions so that C++ code can use syntax such as - * env->Attach("mymachine:5000", 10*1000, 0); - * - * rather than using C's :- - * - * (*env)->Attach(env, "mymachine:5000", 10*1000, 0); - */ -struct _jdwpTransportEnv { - const struct jdwpTransportNativeInterface_ *functions; -#ifdef __cplusplus - - jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) { - return functions->GetCapabilities(this, capabilities_ptr); - } - - jdwpTransportError Attach(const char* address, jlong attach_timeout, - jlong handshake_timeout) { - return functions->Attach(this, address, attach_timeout, handshake_timeout); - } - - jdwpTransportError StartListening(const char* address, - char** actual_address) { - return functions->StartListening(this, address, actual_address); - } - - jdwpTransportError StopListening(void) { - return functions->StopListening(this); - } - - jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) { - return functions->Accept(this, accept_timeout, handshake_timeout); - } - - jboolean IsOpen(void) { - return functions->IsOpen(this); - } - - jdwpTransportError Close(void) { - return functions->Close(this); - } - - jdwpTransportError ReadPacket(jdwpPacket *pkt) { - return functions->ReadPacket(this, pkt); - } - - jdwpTransportError WritePacket(const jdwpPacket* pkt) { - return functions->WritePacket(this, pkt); - } - - jdwpTransportError GetLastError(char** error) { - return functions->GetLastError(this, error); - } - - -#endif /* __cplusplus */ -}; - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* JDWPTRANSPORT_H */ - diff --git a/cpp/JavaWinampApi/include/jni.h b/cpp/JavaWinampApi/include/jni.h deleted file mode 100644 index 8ed7366..0000000 --- a/cpp/JavaWinampApi/include/jni.h +++ /dev/null @@ -1,1944 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -/* - * We used part of Netscape's Java Runtime Interface (JRI) as the starting - * point of our design and implementation. - */ - -/****************************************************************************** - * Java Runtime Interface - * Copyright (c) 1996 Netscape Communications Corporation. All rights reserved. - *****************************************************************************/ - -#ifndef _JAVASOFT_JNI_H_ -#define _JAVASOFT_JNI_H_ - -#include -#include - -/* jni_md.h contains the machine-dependent typedefs for jbyte, jint - and jlong */ - -#include "jni_md.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * JNI Types - */ - -#ifndef JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H - -typedef unsigned char jboolean; -typedef unsigned short jchar; -typedef short jshort; -typedef float jfloat; -typedef double jdouble; - -typedef jint jsize; - -#ifdef __cplusplus - -class _jobject {}; -class _jclass : public _jobject {}; -class _jthrowable : public _jobject {}; -class _jstring : public _jobject {}; -class _jarray : public _jobject {}; -class _jbooleanArray : public _jarray {}; -class _jbyteArray : public _jarray {}; -class _jcharArray : public _jarray {}; -class _jshortArray : public _jarray {}; -class _jintArray : public _jarray {}; -class _jlongArray : public _jarray {}; -class _jfloatArray : public _jarray {}; -class _jdoubleArray : public _jarray {}; -class _jobjectArray : public _jarray {}; - -typedef _jobject *jobject; -typedef _jclass *jclass; -typedef _jthrowable *jthrowable; -typedef _jstring *jstring; -typedef _jarray *jarray; -typedef _jbooleanArray *jbooleanArray; -typedef _jbyteArray *jbyteArray; -typedef _jcharArray *jcharArray; -typedef _jshortArray *jshortArray; -typedef _jintArray *jintArray; -typedef _jlongArray *jlongArray; -typedef _jfloatArray *jfloatArray; -typedef _jdoubleArray *jdoubleArray; -typedef _jobjectArray *jobjectArray; - -#else - -struct _jobject; - -typedef struct _jobject *jobject; -typedef jobject jclass; -typedef jobject jthrowable; -typedef jobject jstring; -typedef jobject jarray; -typedef jarray jbooleanArray; -typedef jarray jbyteArray; -typedef jarray jcharArray; -typedef jarray jshortArray; -typedef jarray jintArray; -typedef jarray jlongArray; -typedef jarray jfloatArray; -typedef jarray jdoubleArray; -typedef jarray jobjectArray; - -#endif - -typedef jobject jweak; - -typedef union jvalue { - jboolean z; - jbyte b; - jchar c; - jshort s; - jint i; - jlong j; - jfloat f; - jdouble d; - jobject l; -} jvalue; - -struct _jfieldID; -typedef struct _jfieldID *jfieldID; - -struct _jmethodID; -typedef struct _jmethodID *jmethodID; - -/* Return values from jobjectRefType */ -typedef enum _jobjectType { - JNIInvalidRefType = 0, - JNILocalRefType = 1, - JNIGlobalRefType = 2, - JNIWeakGlobalRefType = 3 -} jobjectRefType; - - -#endif /* JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H */ - -/* - * jboolean constants - */ - -#define JNI_FALSE 0 -#define JNI_TRUE 1 - -/* - * possible return values for JNI functions. - */ - -#define JNI_OK 0 /* success */ -#define JNI_ERR (-1) /* unknown error */ -#define JNI_EDETACHED (-2) /* thread detached from the VM */ -#define JNI_EVERSION (-3) /* JNI version error */ -#define JNI_ENOMEM (-4) /* not enough memory */ -#define JNI_EEXIST (-5) /* VM already created */ -#define JNI_EINVAL (-6) /* invalid arguments */ - -/* - * used in ReleaseScalarArrayElements - */ - -#define JNI_COMMIT 1 -#define JNI_ABORT 2 - -/* - * used in RegisterNatives to describe native method name, signature, - * and function pointer. - */ - -typedef struct { - char *name; - char *signature; - void *fnPtr; -} JNINativeMethod; - -/* - * JNI Native Method Interface. - */ - -struct JNINativeInterface_; - -struct JNIEnv_; - -#ifdef __cplusplus -typedef JNIEnv_ JNIEnv; -#else -typedef const struct JNINativeInterface_ *JNIEnv; -#endif - -/* - * JNI Invocation Interface. - */ - -struct JNIInvokeInterface_; - -struct JavaVM_; - -#ifdef __cplusplus -typedef JavaVM_ JavaVM; -#else -typedef const struct JNIInvokeInterface_ *JavaVM; -#endif - -struct JNINativeInterface_ { - void *reserved0; - void *reserved1; - void *reserved2; - - void *reserved3; - jint (JNICALL *GetVersion)(JNIEnv *env); - - jclass (JNICALL *DefineClass) - (JNIEnv *env, const char *name, jobject loader, const jbyte *buf, - jsize len); - jclass (JNICALL *FindClass) - (JNIEnv *env, const char *name); - - jmethodID (JNICALL *FromReflectedMethod) - (JNIEnv *env, jobject method); - jfieldID (JNICALL *FromReflectedField) - (JNIEnv *env, jobject field); - - jobject (JNICALL *ToReflectedMethod) - (JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic); - - jclass (JNICALL *GetSuperclass) - (JNIEnv *env, jclass sub); - jboolean (JNICALL *IsAssignableFrom) - (JNIEnv *env, jclass sub, jclass sup); - - jobject (JNICALL *ToReflectedField) - (JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic); - - jint (JNICALL *Throw) - (JNIEnv *env, jthrowable obj); - jint (JNICALL *ThrowNew) - (JNIEnv *env, jclass clazz, const char *msg); - jthrowable (JNICALL *ExceptionOccurred) - (JNIEnv *env); - void (JNICALL *ExceptionDescribe) - (JNIEnv *env); - void (JNICALL *ExceptionClear) - (JNIEnv *env); - void (JNICALL *FatalError) - (JNIEnv *env, const char *msg); - - jint (JNICALL *PushLocalFrame) - (JNIEnv *env, jint capacity); - jobject (JNICALL *PopLocalFrame) - (JNIEnv *env, jobject result); - - jobject (JNICALL *NewGlobalRef) - (JNIEnv *env, jobject lobj); - void (JNICALL *DeleteGlobalRef) - (JNIEnv *env, jobject gref); - void (JNICALL *DeleteLocalRef) - (JNIEnv *env, jobject obj); - jboolean (JNICALL *IsSameObject) - (JNIEnv *env, jobject obj1, jobject obj2); - jobject (JNICALL *NewLocalRef) - (JNIEnv *env, jobject ref); - jint (JNICALL *EnsureLocalCapacity) - (JNIEnv *env, jint capacity); - - jobject (JNICALL *AllocObject) - (JNIEnv *env, jclass clazz); - jobject (JNICALL *NewObject) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jobject (JNICALL *NewObjectV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jobject (JNICALL *NewObjectA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jclass (JNICALL *GetObjectClass) - (JNIEnv *env, jobject obj); - jboolean (JNICALL *IsInstanceOf) - (JNIEnv *env, jobject obj, jclass clazz); - - jmethodID (JNICALL *GetMethodID) - (JNIEnv *env, jclass clazz, const char *name, const char *sig); - - jobject (JNICALL *CallObjectMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jobject (JNICALL *CallObjectMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jobject (JNICALL *CallObjectMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args); - - jboolean (JNICALL *CallBooleanMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jboolean (JNICALL *CallBooleanMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jboolean (JNICALL *CallBooleanMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args); - - jbyte (JNICALL *CallByteMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jbyte (JNICALL *CallByteMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jbyte (JNICALL *CallByteMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jchar (JNICALL *CallCharMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jchar (JNICALL *CallCharMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jchar (JNICALL *CallCharMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jshort (JNICALL *CallShortMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jshort (JNICALL *CallShortMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jshort (JNICALL *CallShortMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jint (JNICALL *CallIntMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jint (JNICALL *CallIntMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jint (JNICALL *CallIntMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jlong (JNICALL *CallLongMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jlong (JNICALL *CallLongMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jlong (JNICALL *CallLongMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jfloat (JNICALL *CallFloatMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jfloat (JNICALL *CallFloatMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jfloat (JNICALL *CallFloatMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jdouble (JNICALL *CallDoubleMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jdouble (JNICALL *CallDoubleMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jdouble (JNICALL *CallDoubleMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - void (JNICALL *CallVoidMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - void (JNICALL *CallVoidMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - void (JNICALL *CallVoidMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args); - - jobject (JNICALL *CallNonvirtualObjectMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jobject (JNICALL *CallNonvirtualObjectMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jobject (JNICALL *CallNonvirtualObjectMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue * args); - - jboolean (JNICALL *CallNonvirtualBooleanMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jboolean (JNICALL *CallNonvirtualBooleanMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jboolean (JNICALL *CallNonvirtualBooleanMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue * args); - - jbyte (JNICALL *CallNonvirtualByteMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jbyte (JNICALL *CallNonvirtualByteMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jbyte (JNICALL *CallNonvirtualByteMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jchar (JNICALL *CallNonvirtualCharMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jchar (JNICALL *CallNonvirtualCharMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jchar (JNICALL *CallNonvirtualCharMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jshort (JNICALL *CallNonvirtualShortMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jshort (JNICALL *CallNonvirtualShortMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jshort (JNICALL *CallNonvirtualShortMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jint (JNICALL *CallNonvirtualIntMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jint (JNICALL *CallNonvirtualIntMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jint (JNICALL *CallNonvirtualIntMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jlong (JNICALL *CallNonvirtualLongMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jlong (JNICALL *CallNonvirtualLongMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jlong (JNICALL *CallNonvirtualLongMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jfloat (JNICALL *CallNonvirtualFloatMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jfloat (JNICALL *CallNonvirtualFloatMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jfloat (JNICALL *CallNonvirtualFloatMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jdouble (JNICALL *CallNonvirtualDoubleMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jdouble (JNICALL *CallNonvirtualDoubleMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jdouble (JNICALL *CallNonvirtualDoubleMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - void (JNICALL *CallNonvirtualVoidMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - void (JNICALL *CallNonvirtualVoidMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - void (JNICALL *CallNonvirtualVoidMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue * args); - - jfieldID (JNICALL *GetFieldID) - (JNIEnv *env, jclass clazz, const char *name, const char *sig); - - jobject (JNICALL *GetObjectField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jboolean (JNICALL *GetBooleanField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jbyte (JNICALL *GetByteField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jchar (JNICALL *GetCharField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jshort (JNICALL *GetShortField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jint (JNICALL *GetIntField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jlong (JNICALL *GetLongField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jfloat (JNICALL *GetFloatField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jdouble (JNICALL *GetDoubleField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - - void (JNICALL *SetObjectField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val); - void (JNICALL *SetBooleanField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val); - void (JNICALL *SetByteField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val); - void (JNICALL *SetCharField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val); - void (JNICALL *SetShortField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val); - void (JNICALL *SetIntField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jint val); - void (JNICALL *SetLongField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val); - void (JNICALL *SetFloatField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val); - void (JNICALL *SetDoubleField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val); - - jmethodID (JNICALL *GetStaticMethodID) - (JNIEnv *env, jclass clazz, const char *name, const char *sig); - - jobject (JNICALL *CallStaticObjectMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jobject (JNICALL *CallStaticObjectMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jobject (JNICALL *CallStaticObjectMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jboolean (JNICALL *CallStaticBooleanMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jboolean (JNICALL *CallStaticBooleanMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jboolean (JNICALL *CallStaticBooleanMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jbyte (JNICALL *CallStaticByteMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jbyte (JNICALL *CallStaticByteMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jbyte (JNICALL *CallStaticByteMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jchar (JNICALL *CallStaticCharMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jchar (JNICALL *CallStaticCharMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jchar (JNICALL *CallStaticCharMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jshort (JNICALL *CallStaticShortMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jshort (JNICALL *CallStaticShortMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jshort (JNICALL *CallStaticShortMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jint (JNICALL *CallStaticIntMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jint (JNICALL *CallStaticIntMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jint (JNICALL *CallStaticIntMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jlong (JNICALL *CallStaticLongMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jlong (JNICALL *CallStaticLongMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jlong (JNICALL *CallStaticLongMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jfloat (JNICALL *CallStaticFloatMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jfloat (JNICALL *CallStaticFloatMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jfloat (JNICALL *CallStaticFloatMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jdouble (JNICALL *CallStaticDoubleMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jdouble (JNICALL *CallStaticDoubleMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jdouble (JNICALL *CallStaticDoubleMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - void (JNICALL *CallStaticVoidMethod) - (JNIEnv *env, jclass cls, jmethodID methodID, ...); - void (JNICALL *CallStaticVoidMethodV) - (JNIEnv *env, jclass cls, jmethodID methodID, va_list args); - void (JNICALL *CallStaticVoidMethodA) - (JNIEnv *env, jclass cls, jmethodID methodID, const jvalue * args); - - jfieldID (JNICALL *GetStaticFieldID) - (JNIEnv *env, jclass clazz, const char *name, const char *sig); - jobject (JNICALL *GetStaticObjectField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jboolean (JNICALL *GetStaticBooleanField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jbyte (JNICALL *GetStaticByteField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jchar (JNICALL *GetStaticCharField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jshort (JNICALL *GetStaticShortField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jint (JNICALL *GetStaticIntField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jlong (JNICALL *GetStaticLongField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jfloat (JNICALL *GetStaticFloatField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jdouble (JNICALL *GetStaticDoubleField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - - void (JNICALL *SetStaticObjectField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value); - void (JNICALL *SetStaticBooleanField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value); - void (JNICALL *SetStaticByteField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value); - void (JNICALL *SetStaticCharField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value); - void (JNICALL *SetStaticShortField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value); - void (JNICALL *SetStaticIntField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jint value); - void (JNICALL *SetStaticLongField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value); - void (JNICALL *SetStaticFloatField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value); - void (JNICALL *SetStaticDoubleField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value); - - jstring (JNICALL *NewString) - (JNIEnv *env, const jchar *unicode, jsize len); - jsize (JNICALL *GetStringLength) - (JNIEnv *env, jstring str); - const jchar *(JNICALL *GetStringChars) - (JNIEnv *env, jstring str, jboolean *isCopy); - void (JNICALL *ReleaseStringChars) - (JNIEnv *env, jstring str, const jchar *chars); - - jstring (JNICALL *NewStringUTF) - (JNIEnv *env, const char *utf); - jsize (JNICALL *GetStringUTFLength) - (JNIEnv *env, jstring str); - const char* (JNICALL *GetStringUTFChars) - (JNIEnv *env, jstring str, jboolean *isCopy); - void (JNICALL *ReleaseStringUTFChars) - (JNIEnv *env, jstring str, const char* chars); - - - jsize (JNICALL *GetArrayLength) - (JNIEnv *env, jarray array); - - jobjectArray (JNICALL *NewObjectArray) - (JNIEnv *env, jsize len, jclass clazz, jobject init); - jobject (JNICALL *GetObjectArrayElement) - (JNIEnv *env, jobjectArray array, jsize index); - void (JNICALL *SetObjectArrayElement) - (JNIEnv *env, jobjectArray array, jsize index, jobject val); - - jbooleanArray (JNICALL *NewBooleanArray) - (JNIEnv *env, jsize len); - jbyteArray (JNICALL *NewByteArray) - (JNIEnv *env, jsize len); - jcharArray (JNICALL *NewCharArray) - (JNIEnv *env, jsize len); - jshortArray (JNICALL *NewShortArray) - (JNIEnv *env, jsize len); - jintArray (JNICALL *NewIntArray) - (JNIEnv *env, jsize len); - jlongArray (JNICALL *NewLongArray) - (JNIEnv *env, jsize len); - jfloatArray (JNICALL *NewFloatArray) - (JNIEnv *env, jsize len); - jdoubleArray (JNICALL *NewDoubleArray) - (JNIEnv *env, jsize len); - - jboolean * (JNICALL *GetBooleanArrayElements) - (JNIEnv *env, jbooleanArray array, jboolean *isCopy); - jbyte * (JNICALL *GetByteArrayElements) - (JNIEnv *env, jbyteArray array, jboolean *isCopy); - jchar * (JNICALL *GetCharArrayElements) - (JNIEnv *env, jcharArray array, jboolean *isCopy); - jshort * (JNICALL *GetShortArrayElements) - (JNIEnv *env, jshortArray array, jboolean *isCopy); - jint * (JNICALL *GetIntArrayElements) - (JNIEnv *env, jintArray array, jboolean *isCopy); - jlong * (JNICALL *GetLongArrayElements) - (JNIEnv *env, jlongArray array, jboolean *isCopy); - jfloat * (JNICALL *GetFloatArrayElements) - (JNIEnv *env, jfloatArray array, jboolean *isCopy); - jdouble * (JNICALL *GetDoubleArrayElements) - (JNIEnv *env, jdoubleArray array, jboolean *isCopy); - - void (JNICALL *ReleaseBooleanArrayElements) - (JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode); - void (JNICALL *ReleaseByteArrayElements) - (JNIEnv *env, jbyteArray array, jbyte *elems, jint mode); - void (JNICALL *ReleaseCharArrayElements) - (JNIEnv *env, jcharArray array, jchar *elems, jint mode); - void (JNICALL *ReleaseShortArrayElements) - (JNIEnv *env, jshortArray array, jshort *elems, jint mode); - void (JNICALL *ReleaseIntArrayElements) - (JNIEnv *env, jintArray array, jint *elems, jint mode); - void (JNICALL *ReleaseLongArrayElements) - (JNIEnv *env, jlongArray array, jlong *elems, jint mode); - void (JNICALL *ReleaseFloatArrayElements) - (JNIEnv *env, jfloatArray array, jfloat *elems, jint mode); - void (JNICALL *ReleaseDoubleArrayElements) - (JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode); - - void (JNICALL *GetBooleanArrayRegion) - (JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf); - void (JNICALL *GetByteArrayRegion) - (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf); - void (JNICALL *GetCharArrayRegion) - (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf); - void (JNICALL *GetShortArrayRegion) - (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf); - void (JNICALL *GetIntArrayRegion) - (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf); - void (JNICALL *GetLongArrayRegion) - (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf); - void (JNICALL *GetFloatArrayRegion) - (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf); - void (JNICALL *GetDoubleArrayRegion) - (JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf); - - void (JNICALL *SetBooleanArrayRegion) - (JNIEnv *env, jbooleanArray array, jsize start, jsize l, const jboolean *buf); - void (JNICALL *SetByteArrayRegion) - (JNIEnv *env, jbyteArray array, jsize start, jsize len, const jbyte *buf); - void (JNICALL *SetCharArrayRegion) - (JNIEnv *env, jcharArray array, jsize start, jsize len, const jchar *buf); - void (JNICALL *SetShortArrayRegion) - (JNIEnv *env, jshortArray array, jsize start, jsize len, const jshort *buf); - void (JNICALL *SetIntArrayRegion) - (JNIEnv *env, jintArray array, jsize start, jsize len, const jint *buf); - void (JNICALL *SetLongArrayRegion) - (JNIEnv *env, jlongArray array, jsize start, jsize len, const jlong *buf); - void (JNICALL *SetFloatArrayRegion) - (JNIEnv *env, jfloatArray array, jsize start, jsize len, const jfloat *buf); - void (JNICALL *SetDoubleArrayRegion) - (JNIEnv *env, jdoubleArray array, jsize start, jsize len, const jdouble *buf); - - jint (JNICALL *RegisterNatives) - (JNIEnv *env, jclass clazz, const JNINativeMethod *methods, - jint nMethods); - jint (JNICALL *UnregisterNatives) - (JNIEnv *env, jclass clazz); - - jint (JNICALL *MonitorEnter) - (JNIEnv *env, jobject obj); - jint (JNICALL *MonitorExit) - (JNIEnv *env, jobject obj); - - jint (JNICALL *GetJavaVM) - (JNIEnv *env, JavaVM **vm); - - void (JNICALL *GetStringRegion) - (JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf); - void (JNICALL *GetStringUTFRegion) - (JNIEnv *env, jstring str, jsize start, jsize len, char *buf); - - void * (JNICALL *GetPrimitiveArrayCritical) - (JNIEnv *env, jarray array, jboolean *isCopy); - void (JNICALL *ReleasePrimitiveArrayCritical) - (JNIEnv *env, jarray array, void *carray, jint mode); - - const jchar * (JNICALL *GetStringCritical) - (JNIEnv *env, jstring string, jboolean *isCopy); - void (JNICALL *ReleaseStringCritical) - (JNIEnv *env, jstring string, const jchar *cstring); - - jweak (JNICALL *NewWeakGlobalRef) - (JNIEnv *env, jobject obj); - void (JNICALL *DeleteWeakGlobalRef) - (JNIEnv *env, jweak ref); - - jboolean (JNICALL *ExceptionCheck) - (JNIEnv *env); - - jobject (JNICALL *NewDirectByteBuffer) - (JNIEnv* env, void* address, jlong capacity); - void* (JNICALL *GetDirectBufferAddress) - (JNIEnv* env, jobject buf); - jlong (JNICALL *GetDirectBufferCapacity) - (JNIEnv* env, jobject buf); - - /* New JNI 1.6 Features */ - - jobjectRefType (JNICALL *GetObjectRefType) - (JNIEnv* env, jobject obj); -}; - -/* - * We use inlined functions for C++ so that programmers can write: - * - * env->FindClass("java/lang/String") - * - * in C++ rather than: - * - * (*env)->FindClass(env, "java/lang/String") - * - * in C. - */ - -struct JNIEnv_ { - const struct JNINativeInterface_ *functions; -#ifdef __cplusplus - - jint GetVersion() { - return functions->GetVersion(this); - } - jclass DefineClass(const char *name, jobject loader, const jbyte *buf, - jsize len) { - return functions->DefineClass(this, name, loader, buf, len); - } - jclass FindClass(const char *name) { - return functions->FindClass(this, name); - } - jmethodID FromReflectedMethod(jobject method) { - return functions->FromReflectedMethod(this,method); - } - jfieldID FromReflectedField(jobject field) { - return functions->FromReflectedField(this,field); - } - - jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) { - return functions->ToReflectedMethod(this, cls, methodID, isStatic); - } - - jclass GetSuperclass(jclass sub) { - return functions->GetSuperclass(this, sub); - } - jboolean IsAssignableFrom(jclass sub, jclass sup) { - return functions->IsAssignableFrom(this, sub, sup); - } - - jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) { - return functions->ToReflectedField(this,cls,fieldID,isStatic); - } - - jint Throw(jthrowable obj) { - return functions->Throw(this, obj); - } - jint ThrowNew(jclass clazz, const char *msg) { - return functions->ThrowNew(this, clazz, msg); - } - jthrowable ExceptionOccurred() { - return functions->ExceptionOccurred(this); - } - void ExceptionDescribe() { - functions->ExceptionDescribe(this); - } - void ExceptionClear() { - functions->ExceptionClear(this); - } - void FatalError(const char *msg) { - functions->FatalError(this, msg); - } - - jint PushLocalFrame(jint capacity) { - return functions->PushLocalFrame(this,capacity); - } - jobject PopLocalFrame(jobject result) { - return functions->PopLocalFrame(this,result); - } - - jobject NewGlobalRef(jobject lobj) { - return functions->NewGlobalRef(this,lobj); - } - void DeleteGlobalRef(jobject gref) { - functions->DeleteGlobalRef(this,gref); - } - void DeleteLocalRef(jobject obj) { - functions->DeleteLocalRef(this, obj); - } - - jboolean IsSameObject(jobject obj1, jobject obj2) { - return functions->IsSameObject(this,obj1,obj2); - } - - jobject NewLocalRef(jobject ref) { - return functions->NewLocalRef(this,ref); - } - jint EnsureLocalCapacity(jint capacity) { - return functions->EnsureLocalCapacity(this,capacity); - } - - jobject AllocObject(jclass clazz) { - return functions->AllocObject(this,clazz); - } - jobject NewObject(jclass clazz, jmethodID methodID, ...) { - va_list args; - jobject result; - va_start(args, methodID); - result = functions->NewObjectV(this,clazz,methodID,args); - va_end(args); - return result; - } - jobject NewObjectV(jclass clazz, jmethodID methodID, - va_list args) { - return functions->NewObjectV(this,clazz,methodID,args); - } - jobject NewObjectA(jclass clazz, jmethodID methodID, - const jvalue *args) { - return functions->NewObjectA(this,clazz,methodID,args); - } - - jclass GetObjectClass(jobject obj) { - return functions->GetObjectClass(this,obj); - } - jboolean IsInstanceOf(jobject obj, jclass clazz) { - return functions->IsInstanceOf(this,obj,clazz); - } - - jmethodID GetMethodID(jclass clazz, const char *name, - const char *sig) { - return functions->GetMethodID(this,clazz,name,sig); - } - - jobject CallObjectMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jobject result; - va_start(args,methodID); - result = functions->CallObjectMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jobject CallObjectMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallObjectMethodV(this,obj,methodID,args); - } - jobject CallObjectMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallObjectMethodA(this,obj,methodID,args); - } - - jboolean CallBooleanMethod(jobject obj, - jmethodID methodID, ...) { - va_list args; - jboolean result; - va_start(args,methodID); - result = functions->CallBooleanMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jboolean CallBooleanMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallBooleanMethodV(this,obj,methodID,args); - } - jboolean CallBooleanMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallBooleanMethodA(this,obj,methodID, args); - } - - jbyte CallByteMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jbyte result; - va_start(args,methodID); - result = functions->CallByteMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jbyte CallByteMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallByteMethodV(this,obj,methodID,args); - } - jbyte CallByteMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallByteMethodA(this,obj,methodID,args); - } - - jchar CallCharMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jchar result; - va_start(args,methodID); - result = functions->CallCharMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jchar CallCharMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallCharMethodV(this,obj,methodID,args); - } - jchar CallCharMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallCharMethodA(this,obj,methodID,args); - } - - jshort CallShortMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jshort result; - va_start(args,methodID); - result = functions->CallShortMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jshort CallShortMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallShortMethodV(this,obj,methodID,args); - } - jshort CallShortMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallShortMethodA(this,obj,methodID,args); - } - - jint CallIntMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jint result; - va_start(args,methodID); - result = functions->CallIntMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jint CallIntMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallIntMethodV(this,obj,methodID,args); - } - jint CallIntMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallIntMethodA(this,obj,methodID,args); - } - - jlong CallLongMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jlong result; - va_start(args,methodID); - result = functions->CallLongMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jlong CallLongMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallLongMethodV(this,obj,methodID,args); - } - jlong CallLongMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallLongMethodA(this,obj,methodID,args); - } - - jfloat CallFloatMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jfloat result; - va_start(args,methodID); - result = functions->CallFloatMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jfloat CallFloatMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallFloatMethodV(this,obj,methodID,args); - } - jfloat CallFloatMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallFloatMethodA(this,obj,methodID,args); - } - - jdouble CallDoubleMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jdouble result; - va_start(args,methodID); - result = functions->CallDoubleMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jdouble CallDoubleMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallDoubleMethodV(this,obj,methodID,args); - } - jdouble CallDoubleMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallDoubleMethodA(this,obj,methodID,args); - } - - void CallVoidMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - va_start(args,methodID); - functions->CallVoidMethodV(this,obj,methodID,args); - va_end(args); - } - void CallVoidMethodV(jobject obj, jmethodID methodID, - va_list args) { - functions->CallVoidMethodV(this,obj,methodID,args); - } - void CallVoidMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - functions->CallVoidMethodA(this,obj,methodID,args); - } - - jobject CallNonvirtualObjectMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jobject result; - va_start(args,methodID); - result = functions->CallNonvirtualObjectMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jobject CallNonvirtualObjectMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualObjectMethodV(this,obj,clazz, - methodID,args); - } - jobject CallNonvirtualObjectMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualObjectMethodA(this,obj,clazz, - methodID,args); - } - - jboolean CallNonvirtualBooleanMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jboolean result; - va_start(args,methodID); - result = functions->CallNonvirtualBooleanMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jboolean CallNonvirtualBooleanMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualBooleanMethodV(this,obj,clazz, - methodID,args); - } - jboolean CallNonvirtualBooleanMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualBooleanMethodA(this,obj,clazz, - methodID, args); - } - - jbyte CallNonvirtualByteMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jbyte result; - va_start(args,methodID); - result = functions->CallNonvirtualByteMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jbyte CallNonvirtualByteMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualByteMethodV(this,obj,clazz, - methodID,args); - } - jbyte CallNonvirtualByteMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualByteMethodA(this,obj,clazz, - methodID,args); - } - - jchar CallNonvirtualCharMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jchar result; - va_start(args,methodID); - result = functions->CallNonvirtualCharMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jchar CallNonvirtualCharMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualCharMethodV(this,obj,clazz, - methodID,args); - } - jchar CallNonvirtualCharMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualCharMethodA(this,obj,clazz, - methodID,args); - } - - jshort CallNonvirtualShortMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jshort result; - va_start(args,methodID); - result = functions->CallNonvirtualShortMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jshort CallNonvirtualShortMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualShortMethodV(this,obj,clazz, - methodID,args); - } - jshort CallNonvirtualShortMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualShortMethodA(this,obj,clazz, - methodID,args); - } - - jint CallNonvirtualIntMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jint result; - va_start(args,methodID); - result = functions->CallNonvirtualIntMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jint CallNonvirtualIntMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualIntMethodV(this,obj,clazz, - methodID,args); - } - jint CallNonvirtualIntMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualIntMethodA(this,obj,clazz, - methodID,args); - } - - jlong CallNonvirtualLongMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jlong result; - va_start(args,methodID); - result = functions->CallNonvirtualLongMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jlong CallNonvirtualLongMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualLongMethodV(this,obj,clazz, - methodID,args); - } - jlong CallNonvirtualLongMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualLongMethodA(this,obj,clazz, - methodID,args); - } - - jfloat CallNonvirtualFloatMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jfloat result; - va_start(args,methodID); - result = functions->CallNonvirtualFloatMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jfloat CallNonvirtualFloatMethodV(jobject obj, jclass clazz, - jmethodID methodID, - va_list args) { - return functions->CallNonvirtualFloatMethodV(this,obj,clazz, - methodID,args); - } - jfloat CallNonvirtualFloatMethodA(jobject obj, jclass clazz, - jmethodID methodID, - const jvalue * args) { - return functions->CallNonvirtualFloatMethodA(this,obj,clazz, - methodID,args); - } - - jdouble CallNonvirtualDoubleMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jdouble result; - va_start(args,methodID); - result = functions->CallNonvirtualDoubleMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jdouble CallNonvirtualDoubleMethodV(jobject obj, jclass clazz, - jmethodID methodID, - va_list args) { - return functions->CallNonvirtualDoubleMethodV(this,obj,clazz, - methodID,args); - } - jdouble CallNonvirtualDoubleMethodA(jobject obj, jclass clazz, - jmethodID methodID, - const jvalue * args) { - return functions->CallNonvirtualDoubleMethodA(this,obj,clazz, - methodID,args); - } - - void CallNonvirtualVoidMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - va_start(args,methodID); - functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args); - va_end(args); - } - void CallNonvirtualVoidMethodV(jobject obj, jclass clazz, - jmethodID methodID, - va_list args) { - functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args); - } - void CallNonvirtualVoidMethodA(jobject obj, jclass clazz, - jmethodID methodID, - const jvalue * args) { - functions->CallNonvirtualVoidMethodA(this,obj,clazz,methodID,args); - } - - jfieldID GetFieldID(jclass clazz, const char *name, - const char *sig) { - return functions->GetFieldID(this,clazz,name,sig); - } - - jobject GetObjectField(jobject obj, jfieldID fieldID) { - return functions->GetObjectField(this,obj,fieldID); - } - jboolean GetBooleanField(jobject obj, jfieldID fieldID) { - return functions->GetBooleanField(this,obj,fieldID); - } - jbyte GetByteField(jobject obj, jfieldID fieldID) { - return functions->GetByteField(this,obj,fieldID); - } - jchar GetCharField(jobject obj, jfieldID fieldID) { - return functions->GetCharField(this,obj,fieldID); - } - jshort GetShortField(jobject obj, jfieldID fieldID) { - return functions->GetShortField(this,obj,fieldID); - } - jint GetIntField(jobject obj, jfieldID fieldID) { - return functions->GetIntField(this,obj,fieldID); - } - jlong GetLongField(jobject obj, jfieldID fieldID) { - return functions->GetLongField(this,obj,fieldID); - } - jfloat GetFloatField(jobject obj, jfieldID fieldID) { - return functions->GetFloatField(this,obj,fieldID); - } - jdouble GetDoubleField(jobject obj, jfieldID fieldID) { - return functions->GetDoubleField(this,obj,fieldID); - } - - void SetObjectField(jobject obj, jfieldID fieldID, jobject val) { - functions->SetObjectField(this,obj,fieldID,val); - } - void SetBooleanField(jobject obj, jfieldID fieldID, - jboolean val) { - functions->SetBooleanField(this,obj,fieldID,val); - } - void SetByteField(jobject obj, jfieldID fieldID, - jbyte val) { - functions->SetByteField(this,obj,fieldID,val); - } - void SetCharField(jobject obj, jfieldID fieldID, - jchar val) { - functions->SetCharField(this,obj,fieldID,val); - } - void SetShortField(jobject obj, jfieldID fieldID, - jshort val) { - functions->SetShortField(this,obj,fieldID,val); - } - void SetIntField(jobject obj, jfieldID fieldID, - jint val) { - functions->SetIntField(this,obj,fieldID,val); - } - void SetLongField(jobject obj, jfieldID fieldID, - jlong val) { - functions->SetLongField(this,obj,fieldID,val); - } - void SetFloatField(jobject obj, jfieldID fieldID, - jfloat val) { - functions->SetFloatField(this,obj,fieldID,val); - } - void SetDoubleField(jobject obj, jfieldID fieldID, - jdouble val) { - functions->SetDoubleField(this,obj,fieldID,val); - } - - jmethodID GetStaticMethodID(jclass clazz, const char *name, - const char *sig) { - return functions->GetStaticMethodID(this,clazz,name,sig); - } - - jobject CallStaticObjectMethod(jclass clazz, jmethodID methodID, - ...) { - va_list args; - jobject result; - va_start(args,methodID); - result = functions->CallStaticObjectMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jobject CallStaticObjectMethodV(jclass clazz, jmethodID methodID, - va_list args) { - return functions->CallStaticObjectMethodV(this,clazz,methodID,args); - } - jobject CallStaticObjectMethodA(jclass clazz, jmethodID methodID, - const jvalue *args) { - return functions->CallStaticObjectMethodA(this,clazz,methodID,args); - } - - jboolean CallStaticBooleanMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jboolean result; - va_start(args,methodID); - result = functions->CallStaticBooleanMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jboolean CallStaticBooleanMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticBooleanMethodV(this,clazz,methodID,args); - } - jboolean CallStaticBooleanMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticBooleanMethodA(this,clazz,methodID,args); - } - - jbyte CallStaticByteMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jbyte result; - va_start(args,methodID); - result = functions->CallStaticByteMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jbyte CallStaticByteMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticByteMethodV(this,clazz,methodID,args); - } - jbyte CallStaticByteMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticByteMethodA(this,clazz,methodID,args); - } - - jchar CallStaticCharMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jchar result; - va_start(args,methodID); - result = functions->CallStaticCharMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jchar CallStaticCharMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticCharMethodV(this,clazz,methodID,args); - } - jchar CallStaticCharMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticCharMethodA(this,clazz,methodID,args); - } - - jshort CallStaticShortMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jshort result; - va_start(args,methodID); - result = functions->CallStaticShortMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jshort CallStaticShortMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticShortMethodV(this,clazz,methodID,args); - } - jshort CallStaticShortMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticShortMethodA(this,clazz,methodID,args); - } - - jint CallStaticIntMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jint result; - va_start(args,methodID); - result = functions->CallStaticIntMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jint CallStaticIntMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticIntMethodV(this,clazz,methodID,args); - } - jint CallStaticIntMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticIntMethodA(this,clazz,methodID,args); - } - - jlong CallStaticLongMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jlong result; - va_start(args,methodID); - result = functions->CallStaticLongMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jlong CallStaticLongMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticLongMethodV(this,clazz,methodID,args); - } - jlong CallStaticLongMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticLongMethodA(this,clazz,methodID,args); - } - - jfloat CallStaticFloatMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jfloat result; - va_start(args,methodID); - result = functions->CallStaticFloatMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jfloat CallStaticFloatMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticFloatMethodV(this,clazz,methodID,args); - } - jfloat CallStaticFloatMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticFloatMethodA(this,clazz,methodID,args); - } - - jdouble CallStaticDoubleMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jdouble result; - va_start(args,methodID); - result = functions->CallStaticDoubleMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jdouble CallStaticDoubleMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticDoubleMethodV(this,clazz,methodID,args); - } - jdouble CallStaticDoubleMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticDoubleMethodA(this,clazz,methodID,args); - } - - void CallStaticVoidMethod(jclass cls, jmethodID methodID, ...) { - va_list args; - va_start(args,methodID); - functions->CallStaticVoidMethodV(this,cls,methodID,args); - va_end(args); - } - void CallStaticVoidMethodV(jclass cls, jmethodID methodID, - va_list args) { - functions->CallStaticVoidMethodV(this,cls,methodID,args); - } - void CallStaticVoidMethodA(jclass cls, jmethodID methodID, - const jvalue * args) { - functions->CallStaticVoidMethodA(this,cls,methodID,args); - } - - jfieldID GetStaticFieldID(jclass clazz, const char *name, - const char *sig) { - return functions->GetStaticFieldID(this,clazz,name,sig); - } - jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticObjectField(this,clazz,fieldID); - } - jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticBooleanField(this,clazz,fieldID); - } - jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticByteField(this,clazz,fieldID); - } - jchar GetStaticCharField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticCharField(this,clazz,fieldID); - } - jshort GetStaticShortField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticShortField(this,clazz,fieldID); - } - jint GetStaticIntField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticIntField(this,clazz,fieldID); - } - jlong GetStaticLongField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticLongField(this,clazz,fieldID); - } - jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticFloatField(this,clazz,fieldID); - } - jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticDoubleField(this,clazz,fieldID); - } - - void SetStaticObjectField(jclass clazz, jfieldID fieldID, - jobject value) { - functions->SetStaticObjectField(this,clazz,fieldID,value); - } - void SetStaticBooleanField(jclass clazz, jfieldID fieldID, - jboolean value) { - functions->SetStaticBooleanField(this,clazz,fieldID,value); - } - void SetStaticByteField(jclass clazz, jfieldID fieldID, - jbyte value) { - functions->SetStaticByteField(this,clazz,fieldID,value); - } - void SetStaticCharField(jclass clazz, jfieldID fieldID, - jchar value) { - functions->SetStaticCharField(this,clazz,fieldID,value); - } - void SetStaticShortField(jclass clazz, jfieldID fieldID, - jshort value) { - functions->SetStaticShortField(this,clazz,fieldID,value); - } - void SetStaticIntField(jclass clazz, jfieldID fieldID, - jint value) { - functions->SetStaticIntField(this,clazz,fieldID,value); - } - void SetStaticLongField(jclass clazz, jfieldID fieldID, - jlong value) { - functions->SetStaticLongField(this,clazz,fieldID,value); - } - void SetStaticFloatField(jclass clazz, jfieldID fieldID, - jfloat value) { - functions->SetStaticFloatField(this,clazz,fieldID,value); - } - void SetStaticDoubleField(jclass clazz, jfieldID fieldID, - jdouble value) { - functions->SetStaticDoubleField(this,clazz,fieldID,value); - } - - jstring NewString(const jchar *unicode, jsize len) { - return functions->NewString(this,unicode,len); - } - jsize GetStringLength(jstring str) { - return functions->GetStringLength(this,str); - } - const jchar *GetStringChars(jstring str, jboolean *isCopy) { - return functions->GetStringChars(this,str,isCopy); - } - void ReleaseStringChars(jstring str, const jchar *chars) { - functions->ReleaseStringChars(this,str,chars); - } - - jstring NewStringUTF(const char *utf) { - return functions->NewStringUTF(this,utf); - } - jsize GetStringUTFLength(jstring str) { - return functions->GetStringUTFLength(this,str); - } - const char* GetStringUTFChars(jstring str, jboolean *isCopy) { - return functions->GetStringUTFChars(this,str,isCopy); - } - void ReleaseStringUTFChars(jstring str, const char* chars) { - functions->ReleaseStringUTFChars(this,str,chars); - } - - jsize GetArrayLength(jarray array) { - return functions->GetArrayLength(this,array); - } - - jobjectArray NewObjectArray(jsize len, jclass clazz, - jobject init) { - return functions->NewObjectArray(this,len,clazz,init); - } - jobject GetObjectArrayElement(jobjectArray array, jsize index) { - return functions->GetObjectArrayElement(this,array,index); - } - void SetObjectArrayElement(jobjectArray array, jsize index, - jobject val) { - functions->SetObjectArrayElement(this,array,index,val); - } - - jbooleanArray NewBooleanArray(jsize len) { - return functions->NewBooleanArray(this,len); - } - jbyteArray NewByteArray(jsize len) { - return functions->NewByteArray(this,len); - } - jcharArray NewCharArray(jsize len) { - return functions->NewCharArray(this,len); - } - jshortArray NewShortArray(jsize len) { - return functions->NewShortArray(this,len); - } - jintArray NewIntArray(jsize len) { - return functions->NewIntArray(this,len); - } - jlongArray NewLongArray(jsize len) { - return functions->NewLongArray(this,len); - } - jfloatArray NewFloatArray(jsize len) { - return functions->NewFloatArray(this,len); - } - jdoubleArray NewDoubleArray(jsize len) { - return functions->NewDoubleArray(this,len); - } - - jboolean * GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy) { - return functions->GetBooleanArrayElements(this,array,isCopy); - } - jbyte * GetByteArrayElements(jbyteArray array, jboolean *isCopy) { - return functions->GetByteArrayElements(this,array,isCopy); - } - jchar * GetCharArrayElements(jcharArray array, jboolean *isCopy) { - return functions->GetCharArrayElements(this,array,isCopy); - } - jshort * GetShortArrayElements(jshortArray array, jboolean *isCopy) { - return functions->GetShortArrayElements(this,array,isCopy); - } - jint * GetIntArrayElements(jintArray array, jboolean *isCopy) { - return functions->GetIntArrayElements(this,array,isCopy); - } - jlong * GetLongArrayElements(jlongArray array, jboolean *isCopy) { - return functions->GetLongArrayElements(this,array,isCopy); - } - jfloat * GetFloatArrayElements(jfloatArray array, jboolean *isCopy) { - return functions->GetFloatArrayElements(this,array,isCopy); - } - jdouble * GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy) { - return functions->GetDoubleArrayElements(this,array,isCopy); - } - - void ReleaseBooleanArrayElements(jbooleanArray array, - jboolean *elems, - jint mode) { - functions->ReleaseBooleanArrayElements(this,array,elems,mode); - } - void ReleaseByteArrayElements(jbyteArray array, - jbyte *elems, - jint mode) { - functions->ReleaseByteArrayElements(this,array,elems,mode); - } - void ReleaseCharArrayElements(jcharArray array, - jchar *elems, - jint mode) { - functions->ReleaseCharArrayElements(this,array,elems,mode); - } - void ReleaseShortArrayElements(jshortArray array, - jshort *elems, - jint mode) { - functions->ReleaseShortArrayElements(this,array,elems,mode); - } - void ReleaseIntArrayElements(jintArray array, - jint *elems, - jint mode) { - functions->ReleaseIntArrayElements(this,array,elems,mode); - } - void ReleaseLongArrayElements(jlongArray array, - jlong *elems, - jint mode) { - functions->ReleaseLongArrayElements(this,array,elems,mode); - } - void ReleaseFloatArrayElements(jfloatArray array, - jfloat *elems, - jint mode) { - functions->ReleaseFloatArrayElements(this,array,elems,mode); - } - void ReleaseDoubleArrayElements(jdoubleArray array, - jdouble *elems, - jint mode) { - functions->ReleaseDoubleArrayElements(this,array,elems,mode); - } - - void GetBooleanArrayRegion(jbooleanArray array, - jsize start, jsize len, jboolean *buf) { - functions->GetBooleanArrayRegion(this,array,start,len,buf); - } - void GetByteArrayRegion(jbyteArray array, - jsize start, jsize len, jbyte *buf) { - functions->GetByteArrayRegion(this,array,start,len,buf); - } - void GetCharArrayRegion(jcharArray array, - jsize start, jsize len, jchar *buf) { - functions->GetCharArrayRegion(this,array,start,len,buf); - } - void GetShortArrayRegion(jshortArray array, - jsize start, jsize len, jshort *buf) { - functions->GetShortArrayRegion(this,array,start,len,buf); - } - void GetIntArrayRegion(jintArray array, - jsize start, jsize len, jint *buf) { - functions->GetIntArrayRegion(this,array,start,len,buf); - } - void GetLongArrayRegion(jlongArray array, - jsize start, jsize len, jlong *buf) { - functions->GetLongArrayRegion(this,array,start,len,buf); - } - void GetFloatArrayRegion(jfloatArray array, - jsize start, jsize len, jfloat *buf) { - functions->GetFloatArrayRegion(this,array,start,len,buf); - } - void GetDoubleArrayRegion(jdoubleArray array, - jsize start, jsize len, jdouble *buf) { - functions->GetDoubleArrayRegion(this,array,start,len,buf); - } - - void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, - const jboolean *buf) { - functions->SetBooleanArrayRegion(this,array,start,len,buf); - } - void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, - const jbyte *buf) { - functions->SetByteArrayRegion(this,array,start,len,buf); - } - void SetCharArrayRegion(jcharArray array, jsize start, jsize len, - const jchar *buf) { - functions->SetCharArrayRegion(this,array,start,len,buf); - } - void SetShortArrayRegion(jshortArray array, jsize start, jsize len, - const jshort *buf) { - functions->SetShortArrayRegion(this,array,start,len,buf); - } - void SetIntArrayRegion(jintArray array, jsize start, jsize len, - const jint *buf) { - functions->SetIntArrayRegion(this,array,start,len,buf); - } - void SetLongArrayRegion(jlongArray array, jsize start, jsize len, - const jlong *buf) { - functions->SetLongArrayRegion(this,array,start,len,buf); - } - void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, - const jfloat *buf) { - functions->SetFloatArrayRegion(this,array,start,len,buf); - } - void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, - const jdouble *buf) { - functions->SetDoubleArrayRegion(this,array,start,len,buf); - } - - jint RegisterNatives(jclass clazz, const JNINativeMethod *methods, - jint nMethods) { - return functions->RegisterNatives(this,clazz,methods,nMethods); - } - jint UnregisterNatives(jclass clazz) { - return functions->UnregisterNatives(this,clazz); - } - - jint MonitorEnter(jobject obj) { - return functions->MonitorEnter(this,obj); - } - jint MonitorExit(jobject obj) { - return functions->MonitorExit(this,obj); - } - - jint GetJavaVM(JavaVM **vm) { - return functions->GetJavaVM(this,vm); - } - - void GetStringRegion(jstring str, jsize start, jsize len, jchar *buf) { - functions->GetStringRegion(this,str,start,len,buf); - } - void GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf) { - functions->GetStringUTFRegion(this,str,start,len,buf); - } - - void * GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) { - return functions->GetPrimitiveArrayCritical(this,array,isCopy); - } - void ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode) { - functions->ReleasePrimitiveArrayCritical(this,array,carray,mode); - } - - const jchar * GetStringCritical(jstring string, jboolean *isCopy) { - return functions->GetStringCritical(this,string,isCopy); - } - void ReleaseStringCritical(jstring string, const jchar *cstring) { - functions->ReleaseStringCritical(this,string,cstring); - } - - jweak NewWeakGlobalRef(jobject obj) { - return functions->NewWeakGlobalRef(this,obj); - } - void DeleteWeakGlobalRef(jweak ref) { - functions->DeleteWeakGlobalRef(this,ref); - } - - jboolean ExceptionCheck() { - return functions->ExceptionCheck(this); - } - - jobject NewDirectByteBuffer(void* address, jlong capacity) { - return functions->NewDirectByteBuffer(this, address, capacity); - } - void* GetDirectBufferAddress(jobject buf) { - return functions->GetDirectBufferAddress(this, buf); - } - jlong GetDirectBufferCapacity(jobject buf) { - return functions->GetDirectBufferCapacity(this, buf); - } - jobjectRefType GetObjectRefType(jobject obj) { - return functions->GetObjectRefType(this, obj); - } - -#endif /* __cplusplus */ -}; - -typedef struct JavaVMOption { - char *optionString; - void *extraInfo; -} JavaVMOption; - -typedef struct JavaVMInitArgs { - jint version; - - jint nOptions; - JavaVMOption *options; - jboolean ignoreUnrecognized; -} JavaVMInitArgs; - -typedef struct JavaVMAttachArgs { - jint version; - - char *name; - jobject group; -} JavaVMAttachArgs; - -/* These will be VM-specific. */ - -#define JDK1_2 -#define JDK1_4 - -/* End VM-specific. */ - -struct JNIInvokeInterface_ { - void *reserved0; - void *reserved1; - void *reserved2; - - jint (JNICALL *DestroyJavaVM)(JavaVM *vm); - - jint (JNICALL *AttachCurrentThread)(JavaVM *vm, void **penv, void *args); - - jint (JNICALL *DetachCurrentThread)(JavaVM *vm); - - jint (JNICALL *GetEnv)(JavaVM *vm, void **penv, jint version); - - jint (JNICALL *AttachCurrentThreadAsDaemon)(JavaVM *vm, void **penv, void *args); -}; - -struct JavaVM_ { - const struct JNIInvokeInterface_ *functions; -#ifdef __cplusplus - - jint DestroyJavaVM() { - return functions->DestroyJavaVM(this); - } - jint AttachCurrentThread(void **penv, void *args) { - return functions->AttachCurrentThread(this, penv, args); - } - jint DetachCurrentThread() { - return functions->DetachCurrentThread(this); - } - - jint GetEnv(void **penv, jint version) { - return functions->GetEnv(this, penv, version); - } - jint AttachCurrentThreadAsDaemon(void **penv, void *args) { - return functions->AttachCurrentThreadAsDaemon(this, penv, args); - } -#endif -}; - -#ifdef _JNI_IMPLEMENTATION_ -#define _JNI_IMPORT_OR_EXPORT_ JNIEXPORT -#else -#define _JNI_IMPORT_OR_EXPORT_ JNIIMPORT -#endif -_JNI_IMPORT_OR_EXPORT_ jint JNICALL -JNI_GetDefaultJavaVMInitArgs(void *args); - -_JNI_IMPORT_OR_EXPORT_ jint JNICALL -JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args); - -_JNI_IMPORT_OR_EXPORT_ jint JNICALL -JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *); - -/* Defined by native libraries. */ -JNIEXPORT jint JNICALL -JNI_OnLoad(JavaVM *vm, void *reserved); - -JNIEXPORT void JNICALL -JNI_OnUnload(JavaVM *vm, void *reserved); - -#define JNI_VERSION_1_1 0x00010001 -#define JNI_VERSION_1_2 0x00010002 -#define JNI_VERSION_1_4 0x00010004 -#define JNI_VERSION_1_6 0x00010006 - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* !_JAVASOFT_JNI_H_ */ - - - diff --git a/cpp/JavaWinampApi/include/jvmti.h b/cpp/JavaWinampApi/include/jvmti.h deleted file mode 100644 index 865f21e..0000000 --- a/cpp/JavaWinampApi/include/jvmti.h +++ /dev/null @@ -1,2504 +0,0 @@ -#ifdef USE_PRAGMA_IDENT_HDR -#pragma ident "@(#)jvmtiLib.xsl 1.38 06/08/02 23:22:31 JVM" -#endif -/* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - - /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */ - - - /* Include file for the Java(tm) Virtual Machine Tool Interface */ - -#ifndef _JAVA_JVMTI_H_ -#define _JAVA_JVMTI_H_ - -#include "jni.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - JVMTI_VERSION_1 = 0x30010000, - JVMTI_VERSION_1_0 = 0x30010000, - JVMTI_VERSION_1_1 = 0x30010100, - - JVMTI_VERSION = 0x30000000 + (1 * 0x10000) + (1 * 0x100) + 102 /* version: 1.1.102 */ -}; - -JNIEXPORT jint JNICALL -Agent_OnLoad(JavaVM *vm, char *options, void *reserved); - -JNIEXPORT jint JNICALL -Agent_OnAttach(JavaVM* vm, char* options, void* reserved); - -JNIEXPORT void JNICALL -Agent_OnUnload(JavaVM *vm); - - /* Forward declaration of the environment */ - -struct _jvmtiEnv; - -struct jvmtiInterface_1_; - -#ifdef __cplusplus -typedef _jvmtiEnv jvmtiEnv; -#else -typedef const struct jvmtiInterface_1_ *jvmtiEnv; -#endif /* __cplusplus */ - -/* Derived Base Types */ - -typedef jobject jthread; -typedef jobject jthreadGroup; -typedef jlong jlocation; -struct _jrawMonitorID; -typedef struct _jrawMonitorID *jrawMonitorID; -typedef struct JNINativeInterface_ jniNativeInterface; - - /* Constants */ - - - /* Thread State Flags */ - -enum { - JVMTI_THREAD_STATE_ALIVE = 0x0001, - JVMTI_THREAD_STATE_TERMINATED = 0x0002, - JVMTI_THREAD_STATE_RUNNABLE = 0x0004, - JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400, - JVMTI_THREAD_STATE_WAITING = 0x0080, - JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010, - JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020, - JVMTI_THREAD_STATE_SLEEPING = 0x0040, - JVMTI_THREAD_STATE_IN_OBJECT_WAIT = 0x0100, - JVMTI_THREAD_STATE_PARKED = 0x0200, - JVMTI_THREAD_STATE_SUSPENDED = 0x100000, - JVMTI_THREAD_STATE_INTERRUPTED = 0x200000, - JVMTI_THREAD_STATE_IN_NATIVE = 0x400000, - JVMTI_THREAD_STATE_VENDOR_1 = 0x10000000, - JVMTI_THREAD_STATE_VENDOR_2 = 0x20000000, - JVMTI_THREAD_STATE_VENDOR_3 = 0x40000000 -}; - - /* java.lang.Thread.State Conversion Masks */ - -enum { - JVMTI_JAVA_LANG_THREAD_STATE_MASK = JVMTI_THREAD_STATE_TERMINATED | JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT, - JVMTI_JAVA_LANG_THREAD_STATE_NEW = 0, - JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED = JVMTI_THREAD_STATE_TERMINATED, - JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE, - JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, - JVMTI_JAVA_LANG_THREAD_STATE_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY, - JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT -}; - - /* Thread Priority Constants */ - -enum { - JVMTI_THREAD_MIN_PRIORITY = 1, - JVMTI_THREAD_NORM_PRIORITY = 5, - JVMTI_THREAD_MAX_PRIORITY = 10 -}; - - /* Heap Filter Flags */ - -enum { - JVMTI_HEAP_FILTER_TAGGED = 0x4, - JVMTI_HEAP_FILTER_UNTAGGED = 0x8, - JVMTI_HEAP_FILTER_CLASS_TAGGED = 0x10, - JVMTI_HEAP_FILTER_CLASS_UNTAGGED = 0x20 -}; - - /* Heap Visit Control Flags */ - -enum { - JVMTI_VISIT_OBJECTS = 0x100, - JVMTI_VISIT_ABORT = 0x8000 -}; - - /* Heap Reference Enumeration */ - -typedef enum { - JVMTI_HEAP_REFERENCE_CLASS = 1, - JVMTI_HEAP_REFERENCE_FIELD = 2, - JVMTI_HEAP_REFERENCE_ARRAY_ELEMENT = 3, - JVMTI_HEAP_REFERENCE_CLASS_LOADER = 4, - JVMTI_HEAP_REFERENCE_SIGNERS = 5, - JVMTI_HEAP_REFERENCE_PROTECTION_DOMAIN = 6, - JVMTI_HEAP_REFERENCE_INTERFACE = 7, - JVMTI_HEAP_REFERENCE_STATIC_FIELD = 8, - JVMTI_HEAP_REFERENCE_CONSTANT_POOL = 9, - JVMTI_HEAP_REFERENCE_SUPERCLASS = 10, - JVMTI_HEAP_REFERENCE_JNI_GLOBAL = 21, - JVMTI_HEAP_REFERENCE_SYSTEM_CLASS = 22, - JVMTI_HEAP_REFERENCE_MONITOR = 23, - JVMTI_HEAP_REFERENCE_STACK_LOCAL = 24, - JVMTI_HEAP_REFERENCE_JNI_LOCAL = 25, - JVMTI_HEAP_REFERENCE_THREAD = 26, - JVMTI_HEAP_REFERENCE_OTHER = 27 -} jvmtiHeapReferenceKind; - - /* Primitive Type Enumeration */ - -typedef enum { - JVMTI_PRIMITIVE_TYPE_BOOLEAN = 90, - JVMTI_PRIMITIVE_TYPE_BYTE = 66, - JVMTI_PRIMITIVE_TYPE_CHAR = 67, - JVMTI_PRIMITIVE_TYPE_SHORT = 83, - JVMTI_PRIMITIVE_TYPE_INT = 73, - JVMTI_PRIMITIVE_TYPE_LONG = 74, - JVMTI_PRIMITIVE_TYPE_FLOAT = 70, - JVMTI_PRIMITIVE_TYPE_DOUBLE = 68 -} jvmtiPrimitiveType; - - /* Heap Object Filter Enumeration */ - -typedef enum { - JVMTI_HEAP_OBJECT_TAGGED = 1, - JVMTI_HEAP_OBJECT_UNTAGGED = 2, - JVMTI_HEAP_OBJECT_EITHER = 3 -} jvmtiHeapObjectFilter; - - /* Heap Root Kind Enumeration */ - -typedef enum { - JVMTI_HEAP_ROOT_JNI_GLOBAL = 1, - JVMTI_HEAP_ROOT_SYSTEM_CLASS = 2, - JVMTI_HEAP_ROOT_MONITOR = 3, - JVMTI_HEAP_ROOT_STACK_LOCAL = 4, - JVMTI_HEAP_ROOT_JNI_LOCAL = 5, - JVMTI_HEAP_ROOT_THREAD = 6, - JVMTI_HEAP_ROOT_OTHER = 7 -} jvmtiHeapRootKind; - - /* Object Reference Enumeration */ - -typedef enum { - JVMTI_REFERENCE_CLASS = 1, - JVMTI_REFERENCE_FIELD = 2, - JVMTI_REFERENCE_ARRAY_ELEMENT = 3, - JVMTI_REFERENCE_CLASS_LOADER = 4, - JVMTI_REFERENCE_SIGNERS = 5, - JVMTI_REFERENCE_PROTECTION_DOMAIN = 6, - JVMTI_REFERENCE_INTERFACE = 7, - JVMTI_REFERENCE_STATIC_FIELD = 8, - JVMTI_REFERENCE_CONSTANT_POOL = 9 -} jvmtiObjectReferenceKind; - - /* Iteration Control Enumeration */ - -typedef enum { - JVMTI_ITERATION_CONTINUE = 1, - JVMTI_ITERATION_IGNORE = 2, - JVMTI_ITERATION_ABORT = 0 -} jvmtiIterationControl; - - /* Class Status Flags */ - -enum { - JVMTI_CLASS_STATUS_VERIFIED = 1, - JVMTI_CLASS_STATUS_PREPARED = 2, - JVMTI_CLASS_STATUS_INITIALIZED = 4, - JVMTI_CLASS_STATUS_ERROR = 8, - JVMTI_CLASS_STATUS_ARRAY = 16, - JVMTI_CLASS_STATUS_PRIMITIVE = 32 -}; - - /* Event Enable/Disable */ - -typedef enum { - JVMTI_ENABLE = 1, - JVMTI_DISABLE = 0 -} jvmtiEventMode; - - /* Extension Function/Event Parameter Types */ - -typedef enum { - JVMTI_TYPE_JBYTE = 101, - JVMTI_TYPE_JCHAR = 102, - JVMTI_TYPE_JSHORT = 103, - JVMTI_TYPE_JINT = 104, - JVMTI_TYPE_JLONG = 105, - JVMTI_TYPE_JFLOAT = 106, - JVMTI_TYPE_JDOUBLE = 107, - JVMTI_TYPE_JBOOLEAN = 108, - JVMTI_TYPE_JOBJECT = 109, - JVMTI_TYPE_JTHREAD = 110, - JVMTI_TYPE_JCLASS = 111, - JVMTI_TYPE_JVALUE = 112, - JVMTI_TYPE_JFIELDID = 113, - JVMTI_TYPE_JMETHODID = 114, - JVMTI_TYPE_CCHAR = 115, - JVMTI_TYPE_CVOID = 116, - JVMTI_TYPE_JNIENV = 117 -} jvmtiParamTypes; - - /* Extension Function/Event Parameter Kinds */ - -typedef enum { - JVMTI_KIND_IN = 91, - JVMTI_KIND_IN_PTR = 92, - JVMTI_KIND_IN_BUF = 93, - JVMTI_KIND_ALLOC_BUF = 94, - JVMTI_KIND_ALLOC_ALLOC_BUF = 95, - JVMTI_KIND_OUT = 96, - JVMTI_KIND_OUT_BUF = 97 -} jvmtiParamKind; - - /* Timer Kinds */ - -typedef enum { - JVMTI_TIMER_USER_CPU = 30, - JVMTI_TIMER_TOTAL_CPU = 31, - JVMTI_TIMER_ELAPSED = 32 -} jvmtiTimerKind; - - /* Phases of execution */ - -typedef enum { - JVMTI_PHASE_ONLOAD = 1, - JVMTI_PHASE_PRIMORDIAL = 2, - JVMTI_PHASE_START = 6, - JVMTI_PHASE_LIVE = 4, - JVMTI_PHASE_DEAD = 8 -} jvmtiPhase; - - /* Version Interface Types */ - -enum { - JVMTI_VERSION_INTERFACE_JNI = 0x00000000, - JVMTI_VERSION_INTERFACE_JVMTI = 0x30000000 -}; - - /* Version Masks */ - -enum { - JVMTI_VERSION_MASK_INTERFACE_TYPE = 0x70000000, - JVMTI_VERSION_MASK_MAJOR = 0x0FFF0000, - JVMTI_VERSION_MASK_MINOR = 0x0000FF00, - JVMTI_VERSION_MASK_MICRO = 0x000000FF -}; - - /* Version Shifts */ - -enum { - JVMTI_VERSION_SHIFT_MAJOR = 16, - JVMTI_VERSION_SHIFT_MINOR = 8, - JVMTI_VERSION_SHIFT_MICRO = 0 -}; - - /* Verbose Flag Enumeration */ - -typedef enum { - JVMTI_VERBOSE_OTHER = 0, - JVMTI_VERBOSE_GC = 1, - JVMTI_VERBOSE_CLASS = 2, - JVMTI_VERBOSE_JNI = 4 -} jvmtiVerboseFlag; - - /* JLocation Format Enumeration */ - -typedef enum { - JVMTI_JLOCATION_JVMBCI = 1, - JVMTI_JLOCATION_MACHINEPC = 2, - JVMTI_JLOCATION_OTHER = 0 -} jvmtiJlocationFormat; - - /* Resource Exhaustion Flags */ - -enum { - JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR = 0x0001, - JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP = 0x0002, - JVMTI_RESOURCE_EXHAUSTED_THREADS = 0x0004 -}; - - /* Errors */ - -typedef enum { - JVMTI_ERROR_NONE = 0, - JVMTI_ERROR_INVALID_THREAD = 10, - JVMTI_ERROR_INVALID_THREAD_GROUP = 11, - JVMTI_ERROR_INVALID_PRIORITY = 12, - JVMTI_ERROR_THREAD_NOT_SUSPENDED = 13, - JVMTI_ERROR_THREAD_SUSPENDED = 14, - JVMTI_ERROR_THREAD_NOT_ALIVE = 15, - JVMTI_ERROR_INVALID_OBJECT = 20, - JVMTI_ERROR_INVALID_CLASS = 21, - JVMTI_ERROR_CLASS_NOT_PREPARED = 22, - JVMTI_ERROR_INVALID_METHODID = 23, - JVMTI_ERROR_INVALID_LOCATION = 24, - JVMTI_ERROR_INVALID_FIELDID = 25, - JVMTI_ERROR_NO_MORE_FRAMES = 31, - JVMTI_ERROR_OPAQUE_FRAME = 32, - JVMTI_ERROR_TYPE_MISMATCH = 34, - JVMTI_ERROR_INVALID_SLOT = 35, - JVMTI_ERROR_DUPLICATE = 40, - JVMTI_ERROR_NOT_FOUND = 41, - JVMTI_ERROR_INVALID_MONITOR = 50, - JVMTI_ERROR_NOT_MONITOR_OWNER = 51, - JVMTI_ERROR_INTERRUPT = 52, - JVMTI_ERROR_INVALID_CLASS_FORMAT = 60, - JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION = 61, - JVMTI_ERROR_FAILS_VERIFICATION = 62, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED = 63, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED = 64, - JVMTI_ERROR_INVALID_TYPESTATE = 65, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED = 66, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED = 67, - JVMTI_ERROR_UNSUPPORTED_VERSION = 68, - JVMTI_ERROR_NAMES_DONT_MATCH = 69, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED = 70, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71, - JVMTI_ERROR_UNMODIFIABLE_CLASS = 79, - JVMTI_ERROR_NOT_AVAILABLE = 98, - JVMTI_ERROR_MUST_POSSESS_CAPABILITY = 99, - JVMTI_ERROR_NULL_POINTER = 100, - JVMTI_ERROR_ABSENT_INFORMATION = 101, - JVMTI_ERROR_INVALID_EVENT_TYPE = 102, - JVMTI_ERROR_ILLEGAL_ARGUMENT = 103, - JVMTI_ERROR_NATIVE_METHOD = 104, - JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED = 106, - JVMTI_ERROR_OUT_OF_MEMORY = 110, - JVMTI_ERROR_ACCESS_DENIED = 111, - JVMTI_ERROR_WRONG_PHASE = 112, - JVMTI_ERROR_INTERNAL = 113, - JVMTI_ERROR_UNATTACHED_THREAD = 115, - JVMTI_ERROR_INVALID_ENVIRONMENT = 116, - JVMTI_ERROR_MAX = 116 -} jvmtiError; - - /* Event IDs */ - -typedef enum { - JVMTI_MIN_EVENT_TYPE_VAL = 50, - JVMTI_EVENT_VM_INIT = 50, - JVMTI_EVENT_VM_DEATH = 51, - JVMTI_EVENT_THREAD_START = 52, - JVMTI_EVENT_THREAD_END = 53, - JVMTI_EVENT_CLASS_FILE_LOAD_HOOK = 54, - JVMTI_EVENT_CLASS_LOAD = 55, - JVMTI_EVENT_CLASS_PREPARE = 56, - JVMTI_EVENT_VM_START = 57, - JVMTI_EVENT_EXCEPTION = 58, - JVMTI_EVENT_EXCEPTION_CATCH = 59, - JVMTI_EVENT_SINGLE_STEP = 60, - JVMTI_EVENT_FRAME_POP = 61, - JVMTI_EVENT_BREAKPOINT = 62, - JVMTI_EVENT_FIELD_ACCESS = 63, - JVMTI_EVENT_FIELD_MODIFICATION = 64, - JVMTI_EVENT_METHOD_ENTRY = 65, - JVMTI_EVENT_METHOD_EXIT = 66, - JVMTI_EVENT_NATIVE_METHOD_BIND = 67, - JVMTI_EVENT_COMPILED_METHOD_LOAD = 68, - JVMTI_EVENT_COMPILED_METHOD_UNLOAD = 69, - JVMTI_EVENT_DYNAMIC_CODE_GENERATED = 70, - JVMTI_EVENT_DATA_DUMP_REQUEST = 71, - JVMTI_EVENT_MONITOR_WAIT = 73, - JVMTI_EVENT_MONITOR_WAITED = 74, - JVMTI_EVENT_MONITOR_CONTENDED_ENTER = 75, - JVMTI_EVENT_MONITOR_CONTENDED_ENTERED = 76, - JVMTI_EVENT_RESOURCE_EXHAUSTED = 80, - JVMTI_EVENT_GARBAGE_COLLECTION_START = 81, - JVMTI_EVENT_GARBAGE_COLLECTION_FINISH = 82, - JVMTI_EVENT_OBJECT_FREE = 83, - JVMTI_EVENT_VM_OBJECT_ALLOC = 84, - JVMTI_MAX_EVENT_TYPE_VAL = 84 -} jvmtiEvent; - - - /* Pre-Declarations */ -struct _jvmtiThreadInfo; -typedef struct _jvmtiThreadInfo jvmtiThreadInfo; -struct _jvmtiMonitorStackDepthInfo; -typedef struct _jvmtiMonitorStackDepthInfo jvmtiMonitorStackDepthInfo; -struct _jvmtiThreadGroupInfo; -typedef struct _jvmtiThreadGroupInfo jvmtiThreadGroupInfo; -struct _jvmtiFrameInfo; -typedef struct _jvmtiFrameInfo jvmtiFrameInfo; -struct _jvmtiStackInfo; -typedef struct _jvmtiStackInfo jvmtiStackInfo; -struct _jvmtiHeapReferenceInfoField; -typedef struct _jvmtiHeapReferenceInfoField jvmtiHeapReferenceInfoField; -struct _jvmtiHeapReferenceInfoArray; -typedef struct _jvmtiHeapReferenceInfoArray jvmtiHeapReferenceInfoArray; -struct _jvmtiHeapReferenceInfoConstantPool; -typedef struct _jvmtiHeapReferenceInfoConstantPool jvmtiHeapReferenceInfoConstantPool; -struct _jvmtiHeapReferenceInfoStackLocal; -typedef struct _jvmtiHeapReferenceInfoStackLocal jvmtiHeapReferenceInfoStackLocal; -struct _jvmtiHeapReferenceInfoJniLocal; -typedef struct _jvmtiHeapReferenceInfoJniLocal jvmtiHeapReferenceInfoJniLocal; -struct _jvmtiHeapReferenceInfoReserved; -typedef struct _jvmtiHeapReferenceInfoReserved jvmtiHeapReferenceInfoReserved; -union _jvmtiHeapReferenceInfo; -typedef union _jvmtiHeapReferenceInfo jvmtiHeapReferenceInfo; -struct _jvmtiHeapCallbacks; -typedef struct _jvmtiHeapCallbacks jvmtiHeapCallbacks; -struct _jvmtiClassDefinition; -typedef struct _jvmtiClassDefinition jvmtiClassDefinition; -struct _jvmtiMonitorUsage; -typedef struct _jvmtiMonitorUsage jvmtiMonitorUsage; -struct _jvmtiLineNumberEntry; -typedef struct _jvmtiLineNumberEntry jvmtiLineNumberEntry; -struct _jvmtiLocalVariableEntry; -typedef struct _jvmtiLocalVariableEntry jvmtiLocalVariableEntry; -struct _jvmtiParamInfo; -typedef struct _jvmtiParamInfo jvmtiParamInfo; -struct _jvmtiExtensionFunctionInfo; -typedef struct _jvmtiExtensionFunctionInfo jvmtiExtensionFunctionInfo; -struct _jvmtiExtensionEventInfo; -typedef struct _jvmtiExtensionEventInfo jvmtiExtensionEventInfo; -struct _jvmtiTimerInfo; -typedef struct _jvmtiTimerInfo jvmtiTimerInfo; -struct _jvmtiAddrLocationMap; -typedef struct _jvmtiAddrLocationMap jvmtiAddrLocationMap; - - /* Function Types */ - -typedef void (JNICALL *jvmtiStartFunction) - (jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg); - -typedef jint (JNICALL *jvmtiHeapIterationCallback) - (jlong class_tag, jlong size, jlong* tag_ptr, jint length, void* user_data); - -typedef jint (JNICALL *jvmtiHeapReferenceCallback) - (jvmtiHeapReferenceKind reference_kind, const jvmtiHeapReferenceInfo* reference_info, jlong class_tag, jlong referrer_class_tag, jlong size, jlong* tag_ptr, jlong* referrer_tag_ptr, jint length, void* user_data); - -typedef jint (JNICALL *jvmtiPrimitiveFieldCallback) - (jvmtiHeapReferenceKind kind, const jvmtiHeapReferenceInfo* info, jlong object_class_tag, jlong* object_tag_ptr, jvalue value, jvmtiPrimitiveType value_type, void* user_data); - -typedef jint (JNICALL *jvmtiArrayPrimitiveValueCallback) - (jlong class_tag, jlong size, jlong* tag_ptr, jint element_count, jvmtiPrimitiveType element_type, const void* elements, void* user_data); - -typedef jint (JNICALL *jvmtiStringPrimitiveValueCallback) - (jlong class_tag, jlong size, jlong* tag_ptr, const jchar* value, jint value_length, void* user_data); - -typedef jint (JNICALL *jvmtiReservedCallback) - (); - -typedef jvmtiIterationControl (JNICALL *jvmtiHeapObjectCallback) - (jlong class_tag, jlong size, jlong* tag_ptr, void* user_data); - -typedef jvmtiIterationControl (JNICALL *jvmtiHeapRootCallback) - (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, void* user_data); - -typedef jvmtiIterationControl (JNICALL *jvmtiStackReferenceCallback) - (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong thread_tag, jint depth, jmethodID method, jint slot, void* user_data); - -typedef jvmtiIterationControl (JNICALL *jvmtiObjectReferenceCallback) - (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data); - -typedef jvmtiError (JNICALL *jvmtiExtensionFunction) - (jvmtiEnv* jvmti_env, ...); - -typedef void (JNICALL *jvmtiExtensionEvent) - (jvmtiEnv* jvmti_env, ...); - - - /* Structure Types */ -struct _jvmtiThreadInfo { - char* name; - jint priority; - jboolean is_daemon; - jthreadGroup thread_group; - jobject context_class_loader; -}; -struct _jvmtiMonitorStackDepthInfo { - jobject monitor; - jint stack_depth; -}; -struct _jvmtiThreadGroupInfo { - jthreadGroup parent; - char* name; - jint max_priority; - jboolean is_daemon; -}; -struct _jvmtiFrameInfo { - jmethodID method; - jlocation location; -}; -struct _jvmtiStackInfo { - jthread thread; - jint state; - jvmtiFrameInfo* frame_buffer; - jint frame_count; -}; -struct _jvmtiHeapReferenceInfoField { - jint index; -}; -struct _jvmtiHeapReferenceInfoArray { - jint index; -}; -struct _jvmtiHeapReferenceInfoConstantPool { - jint index; -}; -struct _jvmtiHeapReferenceInfoStackLocal { - jlong thread_tag; - jlong thread_id; - jint depth; - jmethodID method; - jlocation location; - jint slot; -}; -struct _jvmtiHeapReferenceInfoJniLocal { - jlong thread_tag; - jlong thread_id; - jint depth; - jmethodID method; -}; -struct _jvmtiHeapReferenceInfoReserved { - jlong reserved1; - jlong reserved2; - jlong reserved3; - jlong reserved4; - jlong reserved5; - jlong reserved6; - jlong reserved7; - jlong reserved8; -}; -union _jvmtiHeapReferenceInfo { - jvmtiHeapReferenceInfoField field; - jvmtiHeapReferenceInfoArray array; - jvmtiHeapReferenceInfoConstantPool constant_pool; - jvmtiHeapReferenceInfoStackLocal stack_local; - jvmtiHeapReferenceInfoJniLocal jni_local; - jvmtiHeapReferenceInfoReserved other; -}; -struct _jvmtiHeapCallbacks { - jvmtiHeapIterationCallback heap_iteration_callback; - jvmtiHeapReferenceCallback heap_reference_callback; - jvmtiPrimitiveFieldCallback primitive_field_callback; - jvmtiArrayPrimitiveValueCallback array_primitive_value_callback; - jvmtiStringPrimitiveValueCallback string_primitive_value_callback; - jvmtiReservedCallback reserved5; - jvmtiReservedCallback reserved6; - jvmtiReservedCallback reserved7; - jvmtiReservedCallback reserved8; - jvmtiReservedCallback reserved9; - jvmtiReservedCallback reserved10; - jvmtiReservedCallback reserved11; - jvmtiReservedCallback reserved12; - jvmtiReservedCallback reserved13; - jvmtiReservedCallback reserved14; - jvmtiReservedCallback reserved15; -}; -struct _jvmtiClassDefinition { - jclass klass; - jint class_byte_count; - const unsigned char* class_bytes; -}; -struct _jvmtiMonitorUsage { - jthread owner; - jint entry_count; - jint waiter_count; - jthread* waiters; - jint notify_waiter_count; - jthread* notify_waiters; -}; -struct _jvmtiLineNumberEntry { - jlocation start_location; - jint line_number; -}; -struct _jvmtiLocalVariableEntry { - jlocation start_location; - jint length; - char* name; - char* signature; - char* generic_signature; - jint slot; -}; -struct _jvmtiParamInfo { - char* name; - jvmtiParamKind kind; - jvmtiParamTypes base_type; - jboolean null_ok; -}; -struct _jvmtiExtensionFunctionInfo { - jvmtiExtensionFunction func; - char* id; - char* short_description; - jint param_count; - jvmtiParamInfo* params; - jint error_count; - jvmtiError* errors; -}; -struct _jvmtiExtensionEventInfo { - jint extension_event_index; - char* id; - char* short_description; - jint param_count; - jvmtiParamInfo* params; -}; -struct _jvmtiTimerInfo { - jlong max_value; - jboolean may_skip_forward; - jboolean may_skip_backward; - jvmtiTimerKind kind; - jlong reserved1; - jlong reserved2; -}; -struct _jvmtiAddrLocationMap { - const void* start_address; - jlocation location; -}; - -typedef struct { - unsigned int can_tag_objects : 1; - unsigned int can_generate_field_modification_events : 1; - unsigned int can_generate_field_access_events : 1; - unsigned int can_get_bytecodes : 1; - unsigned int can_get_synthetic_attribute : 1; - unsigned int can_get_owned_monitor_info : 1; - unsigned int can_get_current_contended_monitor : 1; - unsigned int can_get_monitor_info : 1; - unsigned int can_pop_frame : 1; - unsigned int can_redefine_classes : 1; - unsigned int can_signal_thread : 1; - unsigned int can_get_source_file_name : 1; - unsigned int can_get_line_numbers : 1; - unsigned int can_get_source_debug_extension : 1; - unsigned int can_access_local_variables : 1; - unsigned int can_maintain_original_method_order : 1; - unsigned int can_generate_single_step_events : 1; - unsigned int can_generate_exception_events : 1; - unsigned int can_generate_frame_pop_events : 1; - unsigned int can_generate_breakpoint_events : 1; - unsigned int can_suspend : 1; - unsigned int can_redefine_any_class : 1; - unsigned int can_get_current_thread_cpu_time : 1; - unsigned int can_get_thread_cpu_time : 1; - unsigned int can_generate_method_entry_events : 1; - unsigned int can_generate_method_exit_events : 1; - unsigned int can_generate_all_class_hook_events : 1; - unsigned int can_generate_compiled_method_load_events : 1; - unsigned int can_generate_monitor_events : 1; - unsigned int can_generate_vm_object_alloc_events : 1; - unsigned int can_generate_native_method_bind_events : 1; - unsigned int can_generate_garbage_collection_events : 1; - unsigned int can_generate_object_free_events : 1; - unsigned int can_force_early_return : 1; - unsigned int can_get_owned_monitor_stack_depth_info : 1; - unsigned int can_get_constant_pool : 1; - unsigned int can_set_native_method_prefix : 1; - unsigned int can_retransform_classes : 1; - unsigned int can_retransform_any_class : 1; - unsigned int can_generate_resource_exhaustion_heap_events : 1; - unsigned int can_generate_resource_exhaustion_threads_events : 1; - unsigned int : 7; - unsigned int : 16; - unsigned int : 16; - unsigned int : 16; - unsigned int : 16; - unsigned int : 16; -} jvmtiCapabilities; - - - /* Event Definitions */ - -typedef void (JNICALL *jvmtiEventReserved)(void); - - -typedef void (JNICALL *jvmtiEventBreakpoint) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location); - -typedef void (JNICALL *jvmtiEventClassFileLoadHook) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jclass class_being_redefined, - jobject loader, - const char* name, - jobject protection_domain, - jint class_data_len, - const unsigned char* class_data, - jint* new_class_data_len, - unsigned char** new_class_data); - -typedef void (JNICALL *jvmtiEventClassLoad) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jclass klass); - -typedef void (JNICALL *jvmtiEventClassPrepare) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jclass klass); - -typedef void (JNICALL *jvmtiEventCompiledMethodLoad) - (jvmtiEnv *jvmti_env, - jmethodID method, - jint code_size, - const void* code_addr, - jint map_length, - const jvmtiAddrLocationMap* map, - const void* compile_info); - -typedef void (JNICALL *jvmtiEventCompiledMethodUnload) - (jvmtiEnv *jvmti_env, - jmethodID method, - const void* code_addr); - -typedef void (JNICALL *jvmtiEventDataDumpRequest) - (jvmtiEnv *jvmti_env); - -typedef void (JNICALL *jvmtiEventDynamicCodeGenerated) - (jvmtiEnv *jvmti_env, - const char* name, - const void* address, - jint length); - -typedef void (JNICALL *jvmtiEventException) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location, - jobject exception, - jmethodID catch_method, - jlocation catch_location); - -typedef void (JNICALL *jvmtiEventExceptionCatch) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location, - jobject exception); - -typedef void (JNICALL *jvmtiEventFieldAccess) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location, - jclass field_klass, - jobject object, - jfieldID field); - -typedef void (JNICALL *jvmtiEventFieldModification) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location, - jclass field_klass, - jobject object, - jfieldID field, - char signature_type, - jvalue new_value); - -typedef void (JNICALL *jvmtiEventFramePop) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jboolean was_popped_by_exception); - -typedef void (JNICALL *jvmtiEventGarbageCollectionFinish) - (jvmtiEnv *jvmti_env); - -typedef void (JNICALL *jvmtiEventGarbageCollectionStart) - (jvmtiEnv *jvmti_env); - -typedef void (JNICALL *jvmtiEventMethodEntry) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method); - -typedef void (JNICALL *jvmtiEventMethodExit) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jboolean was_popped_by_exception, - jvalue return_value); - -typedef void (JNICALL *jvmtiEventMonitorContendedEnter) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object); - -typedef void (JNICALL *jvmtiEventMonitorContendedEntered) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object); - -typedef void (JNICALL *jvmtiEventMonitorWait) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object, - jlong timeout); - -typedef void (JNICALL *jvmtiEventMonitorWaited) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object, - jboolean timed_out); - -typedef void (JNICALL *jvmtiEventNativeMethodBind) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - void* address, - void** new_address_ptr); - -typedef void (JNICALL *jvmtiEventObjectFree) - (jvmtiEnv *jvmti_env, - jlong tag); - -typedef void (JNICALL *jvmtiEventResourceExhausted) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jint flags, - const void* reserved, - const char* description); - -typedef void (JNICALL *jvmtiEventSingleStep) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location); - -typedef void (JNICALL *jvmtiEventThreadEnd) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread); - -typedef void (JNICALL *jvmtiEventThreadStart) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread); - -typedef void (JNICALL *jvmtiEventVMDeath) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env); - -typedef void (JNICALL *jvmtiEventVMInit) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread); - -typedef void (JNICALL *jvmtiEventVMObjectAlloc) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object, - jclass object_klass, - jlong size); - -typedef void (JNICALL *jvmtiEventVMStart) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env); - - /* Event Callback Structure */ - -typedef struct { - /* 50 : VM Initialization Event */ - jvmtiEventVMInit VMInit; - /* 51 : VM Death Event */ - jvmtiEventVMDeath VMDeath; - /* 52 : Thread Start */ - jvmtiEventThreadStart ThreadStart; - /* 53 : Thread End */ - jvmtiEventThreadEnd ThreadEnd; - /* 54 : Class File Load Hook */ - jvmtiEventClassFileLoadHook ClassFileLoadHook; - /* 55 : Class Load */ - jvmtiEventClassLoad ClassLoad; - /* 56 : Class Prepare */ - jvmtiEventClassPrepare ClassPrepare; - /* 57 : VM Start Event */ - jvmtiEventVMStart VMStart; - /* 58 : Exception */ - jvmtiEventException Exception; - /* 59 : Exception Catch */ - jvmtiEventExceptionCatch ExceptionCatch; - /* 60 : Single Step */ - jvmtiEventSingleStep SingleStep; - /* 61 : Frame Pop */ - jvmtiEventFramePop FramePop; - /* 62 : Breakpoint */ - jvmtiEventBreakpoint Breakpoint; - /* 63 : Field Access */ - jvmtiEventFieldAccess FieldAccess; - /* 64 : Field Modification */ - jvmtiEventFieldModification FieldModification; - /* 65 : Method Entry */ - jvmtiEventMethodEntry MethodEntry; - /* 66 : Method Exit */ - jvmtiEventMethodExit MethodExit; - /* 67 : Native Method Bind */ - jvmtiEventNativeMethodBind NativeMethodBind; - /* 68 : Compiled Method Load */ - jvmtiEventCompiledMethodLoad CompiledMethodLoad; - /* 69 : Compiled Method Unload */ - jvmtiEventCompiledMethodUnload CompiledMethodUnload; - /* 70 : Dynamic Code Generated */ - jvmtiEventDynamicCodeGenerated DynamicCodeGenerated; - /* 71 : Data Dump Request */ - jvmtiEventDataDumpRequest DataDumpRequest; - /* 72 */ - jvmtiEventReserved reserved72; - /* 73 : Monitor Wait */ - jvmtiEventMonitorWait MonitorWait; - /* 74 : Monitor Waited */ - jvmtiEventMonitorWaited MonitorWaited; - /* 75 : Monitor Contended Enter */ - jvmtiEventMonitorContendedEnter MonitorContendedEnter; - /* 76 : Monitor Contended Entered */ - jvmtiEventMonitorContendedEntered MonitorContendedEntered; - /* 77 */ - jvmtiEventReserved reserved77; - /* 78 */ - jvmtiEventReserved reserved78; - /* 79 */ - jvmtiEventReserved reserved79; - /* 80 : Resource Exhausted */ - jvmtiEventResourceExhausted ResourceExhausted; - /* 81 : Garbage Collection Start */ - jvmtiEventGarbageCollectionStart GarbageCollectionStart; - /* 82 : Garbage Collection Finish */ - jvmtiEventGarbageCollectionFinish GarbageCollectionFinish; - /* 83 : Object Free */ - jvmtiEventObjectFree ObjectFree; - /* 84 : VM Object Allocation */ - jvmtiEventVMObjectAlloc VMObjectAlloc; -} jvmtiEventCallbacks; - - - /* Function Interface */ - -typedef struct jvmtiInterface_1_ { - - /* 1 : RESERVED */ - void *reserved1; - - /* 2 : Set Event Notification Mode */ - jvmtiError (JNICALL *SetEventNotificationMode) (jvmtiEnv* env, - jvmtiEventMode mode, - jvmtiEvent event_type, - jthread event_thread, - ...); - - /* 3 : RESERVED */ - void *reserved3; - - /* 4 : Get All Threads */ - jvmtiError (JNICALL *GetAllThreads) (jvmtiEnv* env, - jint* threads_count_ptr, - jthread** threads_ptr); - - /* 5 : Suspend Thread */ - jvmtiError (JNICALL *SuspendThread) (jvmtiEnv* env, - jthread thread); - - /* 6 : Resume Thread */ - jvmtiError (JNICALL *ResumeThread) (jvmtiEnv* env, - jthread thread); - - /* 7 : Stop Thread */ - jvmtiError (JNICALL *StopThread) (jvmtiEnv* env, - jthread thread, - jobject exception); - - /* 8 : Interrupt Thread */ - jvmtiError (JNICALL *InterruptThread) (jvmtiEnv* env, - jthread thread); - - /* 9 : Get Thread Info */ - jvmtiError (JNICALL *GetThreadInfo) (jvmtiEnv* env, - jthread thread, - jvmtiThreadInfo* info_ptr); - - /* 10 : Get Owned Monitor Info */ - jvmtiError (JNICALL *GetOwnedMonitorInfo) (jvmtiEnv* env, - jthread thread, - jint* owned_monitor_count_ptr, - jobject** owned_monitors_ptr); - - /* 11 : Get Current Contended Monitor */ - jvmtiError (JNICALL *GetCurrentContendedMonitor) (jvmtiEnv* env, - jthread thread, - jobject* monitor_ptr); - - /* 12 : Run Agent Thread */ - jvmtiError (JNICALL *RunAgentThread) (jvmtiEnv* env, - jthread thread, - jvmtiStartFunction proc, - const void* arg, - jint priority); - - /* 13 : Get Top Thread Groups */ - jvmtiError (JNICALL *GetTopThreadGroups) (jvmtiEnv* env, - jint* group_count_ptr, - jthreadGroup** groups_ptr); - - /* 14 : Get Thread Group Info */ - jvmtiError (JNICALL *GetThreadGroupInfo) (jvmtiEnv* env, - jthreadGroup group, - jvmtiThreadGroupInfo* info_ptr); - - /* 15 : Get Thread Group Children */ - jvmtiError (JNICALL *GetThreadGroupChildren) (jvmtiEnv* env, - jthreadGroup group, - jint* thread_count_ptr, - jthread** threads_ptr, - jint* group_count_ptr, - jthreadGroup** groups_ptr); - - /* 16 : Get Frame Count */ - jvmtiError (JNICALL *GetFrameCount) (jvmtiEnv* env, - jthread thread, - jint* count_ptr); - - /* 17 : Get Thread State */ - jvmtiError (JNICALL *GetThreadState) (jvmtiEnv* env, - jthread thread, - jint* thread_state_ptr); - - /* 18 : Get Current Thread */ - jvmtiError (JNICALL *GetCurrentThread) (jvmtiEnv* env, - jthread* thread_ptr); - - /* 19 : Get Frame Location */ - jvmtiError (JNICALL *GetFrameLocation) (jvmtiEnv* env, - jthread thread, - jint depth, - jmethodID* method_ptr, - jlocation* location_ptr); - - /* 20 : Notify Frame Pop */ - jvmtiError (JNICALL *NotifyFramePop) (jvmtiEnv* env, - jthread thread, - jint depth); - - /* 21 : Get Local Variable - Object */ - jvmtiError (JNICALL *GetLocalObject) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jobject* value_ptr); - - /* 22 : Get Local Variable - Int */ - jvmtiError (JNICALL *GetLocalInt) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jint* value_ptr); - - /* 23 : Get Local Variable - Long */ - jvmtiError (JNICALL *GetLocalLong) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jlong* value_ptr); - - /* 24 : Get Local Variable - Float */ - jvmtiError (JNICALL *GetLocalFloat) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jfloat* value_ptr); - - /* 25 : Get Local Variable - Double */ - jvmtiError (JNICALL *GetLocalDouble) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jdouble* value_ptr); - - /* 26 : Set Local Variable - Object */ - jvmtiError (JNICALL *SetLocalObject) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jobject value); - - /* 27 : Set Local Variable - Int */ - jvmtiError (JNICALL *SetLocalInt) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jint value); - - /* 28 : Set Local Variable - Long */ - jvmtiError (JNICALL *SetLocalLong) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jlong value); - - /* 29 : Set Local Variable - Float */ - jvmtiError (JNICALL *SetLocalFloat) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jfloat value); - - /* 30 : Set Local Variable - Double */ - jvmtiError (JNICALL *SetLocalDouble) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jdouble value); - - /* 31 : Create Raw Monitor */ - jvmtiError (JNICALL *CreateRawMonitor) (jvmtiEnv* env, - const char* name, - jrawMonitorID* monitor_ptr); - - /* 32 : Destroy Raw Monitor */ - jvmtiError (JNICALL *DestroyRawMonitor) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 33 : Raw Monitor Enter */ - jvmtiError (JNICALL *RawMonitorEnter) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 34 : Raw Monitor Exit */ - jvmtiError (JNICALL *RawMonitorExit) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 35 : Raw Monitor Wait */ - jvmtiError (JNICALL *RawMonitorWait) (jvmtiEnv* env, - jrawMonitorID monitor, - jlong millis); - - /* 36 : Raw Monitor Notify */ - jvmtiError (JNICALL *RawMonitorNotify) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 37 : Raw Monitor Notify All */ - jvmtiError (JNICALL *RawMonitorNotifyAll) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 38 : Set Breakpoint */ - jvmtiError (JNICALL *SetBreakpoint) (jvmtiEnv* env, - jmethodID method, - jlocation location); - - /* 39 : Clear Breakpoint */ - jvmtiError (JNICALL *ClearBreakpoint) (jvmtiEnv* env, - jmethodID method, - jlocation location); - - /* 40 : RESERVED */ - void *reserved40; - - /* 41 : Set Field Access Watch */ - jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv* env, - jclass klass, - jfieldID field); - - /* 42 : Clear Field Access Watch */ - jvmtiError (JNICALL *ClearFieldAccessWatch) (jvmtiEnv* env, - jclass klass, - jfieldID field); - - /* 43 : Set Field Modification Watch */ - jvmtiError (JNICALL *SetFieldModificationWatch) (jvmtiEnv* env, - jclass klass, - jfieldID field); - - /* 44 : Clear Field Modification Watch */ - jvmtiError (JNICALL *ClearFieldModificationWatch) (jvmtiEnv* env, - jclass klass, - jfieldID field); - - /* 45 : Is Modifiable Class */ - jvmtiError (JNICALL *IsModifiableClass) (jvmtiEnv* env, - jclass klass, - jboolean* is_modifiable_class_ptr); - - /* 46 : Allocate */ - jvmtiError (JNICALL *Allocate) (jvmtiEnv* env, - jlong size, - unsigned char** mem_ptr); - - /* 47 : Deallocate */ - jvmtiError (JNICALL *Deallocate) (jvmtiEnv* env, - unsigned char* mem); - - /* 48 : Get Class Signature */ - jvmtiError (JNICALL *GetClassSignature) (jvmtiEnv* env, - jclass klass, - char** signature_ptr, - char** generic_ptr); - - /* 49 : Get Class Status */ - jvmtiError (JNICALL *GetClassStatus) (jvmtiEnv* env, - jclass klass, - jint* status_ptr); - - /* 50 : Get Source File Name */ - jvmtiError (JNICALL *GetSourceFileName) (jvmtiEnv* env, - jclass klass, - char** source_name_ptr); - - /* 51 : Get Class Modifiers */ - jvmtiError (JNICALL *GetClassModifiers) (jvmtiEnv* env, - jclass klass, - jint* modifiers_ptr); - - /* 52 : Get Class Methods */ - jvmtiError (JNICALL *GetClassMethods) (jvmtiEnv* env, - jclass klass, - jint* method_count_ptr, - jmethodID** methods_ptr); - - /* 53 : Get Class Fields */ - jvmtiError (JNICALL *GetClassFields) (jvmtiEnv* env, - jclass klass, - jint* field_count_ptr, - jfieldID** fields_ptr); - - /* 54 : Get Implemented Interfaces */ - jvmtiError (JNICALL *GetImplementedInterfaces) (jvmtiEnv* env, - jclass klass, - jint* interface_count_ptr, - jclass** interfaces_ptr); - - /* 55 : Is Interface */ - jvmtiError (JNICALL *IsInterface) (jvmtiEnv* env, - jclass klass, - jboolean* is_interface_ptr); - - /* 56 : Is Array Class */ - jvmtiError (JNICALL *IsArrayClass) (jvmtiEnv* env, - jclass klass, - jboolean* is_array_class_ptr); - - /* 57 : Get Class Loader */ - jvmtiError (JNICALL *GetClassLoader) (jvmtiEnv* env, - jclass klass, - jobject* classloader_ptr); - - /* 58 : Get Object Hash Code */ - jvmtiError (JNICALL *GetObjectHashCode) (jvmtiEnv* env, - jobject object, - jint* hash_code_ptr); - - /* 59 : Get Object Monitor Usage */ - jvmtiError (JNICALL *GetObjectMonitorUsage) (jvmtiEnv* env, - jobject object, - jvmtiMonitorUsage* info_ptr); - - /* 60 : Get Field Name (and Signature) */ - jvmtiError (JNICALL *GetFieldName) (jvmtiEnv* env, - jclass klass, - jfieldID field, - char** name_ptr, - char** signature_ptr, - char** generic_ptr); - - /* 61 : Get Field Declaring Class */ - jvmtiError (JNICALL *GetFieldDeclaringClass) (jvmtiEnv* env, - jclass klass, - jfieldID field, - jclass* declaring_class_ptr); - - /* 62 : Get Field Modifiers */ - jvmtiError (JNICALL *GetFieldModifiers) (jvmtiEnv* env, - jclass klass, - jfieldID field, - jint* modifiers_ptr); - - /* 63 : Is Field Synthetic */ - jvmtiError (JNICALL *IsFieldSynthetic) (jvmtiEnv* env, - jclass klass, - jfieldID field, - jboolean* is_synthetic_ptr); - - /* 64 : Get Method Name (and Signature) */ - jvmtiError (JNICALL *GetMethodName) (jvmtiEnv* env, - jmethodID method, - char** name_ptr, - char** signature_ptr, - char** generic_ptr); - - /* 65 : Get Method Declaring Class */ - jvmtiError (JNICALL *GetMethodDeclaringClass) (jvmtiEnv* env, - jmethodID method, - jclass* declaring_class_ptr); - - /* 66 : Get Method Modifiers */ - jvmtiError (JNICALL *GetMethodModifiers) (jvmtiEnv* env, - jmethodID method, - jint* modifiers_ptr); - - /* 67 : RESERVED */ - void *reserved67; - - /* 68 : Get Max Locals */ - jvmtiError (JNICALL *GetMaxLocals) (jvmtiEnv* env, - jmethodID method, - jint* max_ptr); - - /* 69 : Get Arguments Size */ - jvmtiError (JNICALL *GetArgumentsSize) (jvmtiEnv* env, - jmethodID method, - jint* size_ptr); - - /* 70 : Get Line Number Table */ - jvmtiError (JNICALL *GetLineNumberTable) (jvmtiEnv* env, - jmethodID method, - jint* entry_count_ptr, - jvmtiLineNumberEntry** table_ptr); - - /* 71 : Get Method Location */ - jvmtiError (JNICALL *GetMethodLocation) (jvmtiEnv* env, - jmethodID method, - jlocation* start_location_ptr, - jlocation* end_location_ptr); - - /* 72 : Get Local Variable Table */ - jvmtiError (JNICALL *GetLocalVariableTable) (jvmtiEnv* env, - jmethodID method, - jint* entry_count_ptr, - jvmtiLocalVariableEntry** table_ptr); - - /* 73 : Set Native Method Prefix */ - jvmtiError (JNICALL *SetNativeMethodPrefix) (jvmtiEnv* env, - const char* prefix); - - /* 74 : Set Native Method Prefixes */ - jvmtiError (JNICALL *SetNativeMethodPrefixes) (jvmtiEnv* env, - jint prefix_count, - char** prefixes); - - /* 75 : Get Bytecodes */ - jvmtiError (JNICALL *GetBytecodes) (jvmtiEnv* env, - jmethodID method, - jint* bytecode_count_ptr, - unsigned char** bytecodes_ptr); - - /* 76 : Is Method Native */ - jvmtiError (JNICALL *IsMethodNative) (jvmtiEnv* env, - jmethodID method, - jboolean* is_native_ptr); - - /* 77 : Is Method Synthetic */ - jvmtiError (JNICALL *IsMethodSynthetic) (jvmtiEnv* env, - jmethodID method, - jboolean* is_synthetic_ptr); - - /* 78 : Get Loaded Classes */ - jvmtiError (JNICALL *GetLoadedClasses) (jvmtiEnv* env, - jint* class_count_ptr, - jclass** classes_ptr); - - /* 79 : Get Classloader Classes */ - jvmtiError (JNICALL *GetClassLoaderClasses) (jvmtiEnv* env, - jobject initiating_loader, - jint* class_count_ptr, - jclass** classes_ptr); - - /* 80 : Pop Frame */ - jvmtiError (JNICALL *PopFrame) (jvmtiEnv* env, - jthread thread); - - /* 81 : Force Early Return - Object */ - jvmtiError (JNICALL *ForceEarlyReturnObject) (jvmtiEnv* env, - jthread thread, - jobject value); - - /* 82 : Force Early Return - Int */ - jvmtiError (JNICALL *ForceEarlyReturnInt) (jvmtiEnv* env, - jthread thread, - jint value); - - /* 83 : Force Early Return - Long */ - jvmtiError (JNICALL *ForceEarlyReturnLong) (jvmtiEnv* env, - jthread thread, - jlong value); - - /* 84 : Force Early Return - Float */ - jvmtiError (JNICALL *ForceEarlyReturnFloat) (jvmtiEnv* env, - jthread thread, - jfloat value); - - /* 85 : Force Early Return - Double */ - jvmtiError (JNICALL *ForceEarlyReturnDouble) (jvmtiEnv* env, - jthread thread, - jdouble value); - - /* 86 : Force Early Return - Void */ - jvmtiError (JNICALL *ForceEarlyReturnVoid) (jvmtiEnv* env, - jthread thread); - - /* 87 : Redefine Classes */ - jvmtiError (JNICALL *RedefineClasses) (jvmtiEnv* env, - jint class_count, - const jvmtiClassDefinition* class_definitions); - - /* 88 : Get Version Number */ - jvmtiError (JNICALL *GetVersionNumber) (jvmtiEnv* env, - jint* version_ptr); - - /* 89 : Get Capabilities */ - jvmtiError (JNICALL *GetCapabilities) (jvmtiEnv* env, - jvmtiCapabilities* capabilities_ptr); - - /* 90 : Get Source Debug Extension */ - jvmtiError (JNICALL *GetSourceDebugExtension) (jvmtiEnv* env, - jclass klass, - char** source_debug_extension_ptr); - - /* 91 : Is Method Obsolete */ - jvmtiError (JNICALL *IsMethodObsolete) (jvmtiEnv* env, - jmethodID method, - jboolean* is_obsolete_ptr); - - /* 92 : Suspend Thread List */ - jvmtiError (JNICALL *SuspendThreadList) (jvmtiEnv* env, - jint request_count, - const jthread* request_list, - jvmtiError* results); - - /* 93 : Resume Thread List */ - jvmtiError (JNICALL *ResumeThreadList) (jvmtiEnv* env, - jint request_count, - const jthread* request_list, - jvmtiError* results); - - /* 94 : RESERVED */ - void *reserved94; - - /* 95 : RESERVED */ - void *reserved95; - - /* 96 : RESERVED */ - void *reserved96; - - /* 97 : RESERVED */ - void *reserved97; - - /* 98 : RESERVED */ - void *reserved98; - - /* 99 : RESERVED */ - void *reserved99; - - /* 100 : Get All Stack Traces */ - jvmtiError (JNICALL *GetAllStackTraces) (jvmtiEnv* env, - jint max_frame_count, - jvmtiStackInfo** stack_info_ptr, - jint* thread_count_ptr); - - /* 101 : Get Thread List Stack Traces */ - jvmtiError (JNICALL *GetThreadListStackTraces) (jvmtiEnv* env, - jint thread_count, - const jthread* thread_list, - jint max_frame_count, - jvmtiStackInfo** stack_info_ptr); - - /* 102 : Get Thread Local Storage */ - jvmtiError (JNICALL *GetThreadLocalStorage) (jvmtiEnv* env, - jthread thread, - void** data_ptr); - - /* 103 : Set Thread Local Storage */ - jvmtiError (JNICALL *SetThreadLocalStorage) (jvmtiEnv* env, - jthread thread, - const void* data); - - /* 104 : Get Stack Trace */ - jvmtiError (JNICALL *GetStackTrace) (jvmtiEnv* env, - jthread thread, - jint start_depth, - jint max_frame_count, - jvmtiFrameInfo* frame_buffer, - jint* count_ptr); - - /* 105 : RESERVED */ - void *reserved105; - - /* 106 : Get Tag */ - jvmtiError (JNICALL *GetTag) (jvmtiEnv* env, - jobject object, - jlong* tag_ptr); - - /* 107 : Set Tag */ - jvmtiError (JNICALL *SetTag) (jvmtiEnv* env, - jobject object, - jlong tag); - - /* 108 : Force Garbage Collection */ - jvmtiError (JNICALL *ForceGarbageCollection) (jvmtiEnv* env); - - /* 109 : Iterate Over Objects Reachable From Object */ - jvmtiError (JNICALL *IterateOverObjectsReachableFromObject) (jvmtiEnv* env, - jobject object, - jvmtiObjectReferenceCallback object_reference_callback, - const void* user_data); - - /* 110 : Iterate Over Reachable Objects */ - jvmtiError (JNICALL *IterateOverReachableObjects) (jvmtiEnv* env, - jvmtiHeapRootCallback heap_root_callback, - jvmtiStackReferenceCallback stack_ref_callback, - jvmtiObjectReferenceCallback object_ref_callback, - const void* user_data); - - /* 111 : Iterate Over Heap */ - jvmtiError (JNICALL *IterateOverHeap) (jvmtiEnv* env, - jvmtiHeapObjectFilter object_filter, - jvmtiHeapObjectCallback heap_object_callback, - const void* user_data); - - /* 112 : Iterate Over Instances Of Class */ - jvmtiError (JNICALL *IterateOverInstancesOfClass) (jvmtiEnv* env, - jclass klass, - jvmtiHeapObjectFilter object_filter, - jvmtiHeapObjectCallback heap_object_callback, - const void* user_data); - - /* 113 : RESERVED */ - void *reserved113; - - /* 114 : Get Objects With Tags */ - jvmtiError (JNICALL *GetObjectsWithTags) (jvmtiEnv* env, - jint tag_count, - const jlong* tags, - jint* count_ptr, - jobject** object_result_ptr, - jlong** tag_result_ptr); - - /* 115 : Follow References */ - jvmtiError (JNICALL *FollowReferences) (jvmtiEnv* env, - jint heap_filter, - jclass klass, - jobject initial_object, - const jvmtiHeapCallbacks* callbacks, - const void* user_data); - - /* 116 : Iterate Through Heap */ - jvmtiError (JNICALL *IterateThroughHeap) (jvmtiEnv* env, - jint heap_filter, - jclass klass, - const jvmtiHeapCallbacks* callbacks, - const void* user_data); - - /* 117 : RESERVED */ - void *reserved117; - - /* 118 : RESERVED */ - void *reserved118; - - /* 119 : RESERVED */ - void *reserved119; - - /* 120 : Set JNI Function Table */ - jvmtiError (JNICALL *SetJNIFunctionTable) (jvmtiEnv* env, - const jniNativeInterface* function_table); - - /* 121 : Get JNI Function Table */ - jvmtiError (JNICALL *GetJNIFunctionTable) (jvmtiEnv* env, - jniNativeInterface** function_table); - - /* 122 : Set Event Callbacks */ - jvmtiError (JNICALL *SetEventCallbacks) (jvmtiEnv* env, - const jvmtiEventCallbacks* callbacks, - jint size_of_callbacks); - - /* 123 : Generate Events */ - jvmtiError (JNICALL *GenerateEvents) (jvmtiEnv* env, - jvmtiEvent event_type); - - /* 124 : Get Extension Functions */ - jvmtiError (JNICALL *GetExtensionFunctions) (jvmtiEnv* env, - jint* extension_count_ptr, - jvmtiExtensionFunctionInfo** extensions); - - /* 125 : Get Extension Events */ - jvmtiError (JNICALL *GetExtensionEvents) (jvmtiEnv* env, - jint* extension_count_ptr, - jvmtiExtensionEventInfo** extensions); - - /* 126 : Set Extension Event Callback */ - jvmtiError (JNICALL *SetExtensionEventCallback) (jvmtiEnv* env, - jint extension_event_index, - jvmtiExtensionEvent callback); - - /* 127 : Dispose Environment */ - jvmtiError (JNICALL *DisposeEnvironment) (jvmtiEnv* env); - - /* 128 : Get Error Name */ - jvmtiError (JNICALL *GetErrorName) (jvmtiEnv* env, - jvmtiError error, - char** name_ptr); - - /* 129 : Get JLocation Format */ - jvmtiError (JNICALL *GetJLocationFormat) (jvmtiEnv* env, - jvmtiJlocationFormat* format_ptr); - - /* 130 : Get System Properties */ - jvmtiError (JNICALL *GetSystemProperties) (jvmtiEnv* env, - jint* count_ptr, - char*** property_ptr); - - /* 131 : Get System Property */ - jvmtiError (JNICALL *GetSystemProperty) (jvmtiEnv* env, - const char* property, - char** value_ptr); - - /* 132 : Set System Property */ - jvmtiError (JNICALL *SetSystemProperty) (jvmtiEnv* env, - const char* property, - const char* value); - - /* 133 : Get Phase */ - jvmtiError (JNICALL *GetPhase) (jvmtiEnv* env, - jvmtiPhase* phase_ptr); - - /* 134 : Get Current Thread CPU Timer Information */ - jvmtiError (JNICALL *GetCurrentThreadCpuTimerInfo) (jvmtiEnv* env, - jvmtiTimerInfo* info_ptr); - - /* 135 : Get Current Thread CPU Time */ - jvmtiError (JNICALL *GetCurrentThreadCpuTime) (jvmtiEnv* env, - jlong* nanos_ptr); - - /* 136 : Get Thread CPU Timer Information */ - jvmtiError (JNICALL *GetThreadCpuTimerInfo) (jvmtiEnv* env, - jvmtiTimerInfo* info_ptr); - - /* 137 : Get Thread CPU Time */ - jvmtiError (JNICALL *GetThreadCpuTime) (jvmtiEnv* env, - jthread thread, - jlong* nanos_ptr); - - /* 138 : Get Timer Information */ - jvmtiError (JNICALL *GetTimerInfo) (jvmtiEnv* env, - jvmtiTimerInfo* info_ptr); - - /* 139 : Get Time */ - jvmtiError (JNICALL *GetTime) (jvmtiEnv* env, - jlong* nanos_ptr); - - /* 140 : Get Potential Capabilities */ - jvmtiError (JNICALL *GetPotentialCapabilities) (jvmtiEnv* env, - jvmtiCapabilities* capabilities_ptr); - - /* 141 : RESERVED */ - void *reserved141; - - /* 142 : Add Capabilities */ - jvmtiError (JNICALL *AddCapabilities) (jvmtiEnv* env, - const jvmtiCapabilities* capabilities_ptr); - - /* 143 : Relinquish Capabilities */ - jvmtiError (JNICALL *RelinquishCapabilities) (jvmtiEnv* env, - const jvmtiCapabilities* capabilities_ptr); - - /* 144 : Get Available Processors */ - jvmtiError (JNICALL *GetAvailableProcessors) (jvmtiEnv* env, - jint* processor_count_ptr); - - /* 145 : Get Class Version Numbers */ - jvmtiError (JNICALL *GetClassVersionNumbers) (jvmtiEnv* env, - jclass klass, - jint* minor_version_ptr, - jint* major_version_ptr); - - /* 146 : Get Constant Pool */ - jvmtiError (JNICALL *GetConstantPool) (jvmtiEnv* env, - jclass klass, - jint* constant_pool_count_ptr, - jint* constant_pool_byte_count_ptr, - unsigned char** constant_pool_bytes_ptr); - - /* 147 : Get Environment Local Storage */ - jvmtiError (JNICALL *GetEnvironmentLocalStorage) (jvmtiEnv* env, - void** data_ptr); - - /* 148 : Set Environment Local Storage */ - jvmtiError (JNICALL *SetEnvironmentLocalStorage) (jvmtiEnv* env, - const void* data); - - /* 149 : Add To Bootstrap Class Loader Search */ - jvmtiError (JNICALL *AddToBootstrapClassLoaderSearch) (jvmtiEnv* env, - const char* segment); - - /* 150 : Set Verbose Flag */ - jvmtiError (JNICALL *SetVerboseFlag) (jvmtiEnv* env, - jvmtiVerboseFlag flag, - jboolean value); - - /* 151 : Add To System Class Loader Search */ - jvmtiError (JNICALL *AddToSystemClassLoaderSearch) (jvmtiEnv* env, - const char* segment); - - /* 152 : Retransform Classes */ - jvmtiError (JNICALL *RetransformClasses) (jvmtiEnv* env, - jint class_count, - const jclass* classes); - - /* 153 : Get Owned Monitor Stack Depth Info */ - jvmtiError (JNICALL *GetOwnedMonitorStackDepthInfo) (jvmtiEnv* env, - jthread thread, - jint* monitor_info_count_ptr, - jvmtiMonitorStackDepthInfo** monitor_info_ptr); - - /* 154 : Get Object Size */ - jvmtiError (JNICALL *GetObjectSize) (jvmtiEnv* env, - jobject object, - jlong* size_ptr); - -} jvmtiInterface_1; - -struct _jvmtiEnv { - const struct jvmtiInterface_1_ *functions; -#ifdef __cplusplus - - - jvmtiError Allocate(jlong size, - unsigned char** mem_ptr) { - return functions->Allocate(this, size, mem_ptr); - } - - jvmtiError Deallocate(unsigned char* mem) { - return functions->Deallocate(this, mem); - } - - jvmtiError GetThreadState(jthread thread, - jint* thread_state_ptr) { - return functions->GetThreadState(this, thread, thread_state_ptr); - } - - jvmtiError GetCurrentThread(jthread* thread_ptr) { - return functions->GetCurrentThread(this, thread_ptr); - } - - jvmtiError GetAllThreads(jint* threads_count_ptr, - jthread** threads_ptr) { - return functions->GetAllThreads(this, threads_count_ptr, threads_ptr); - } - - jvmtiError SuspendThread(jthread thread) { - return functions->SuspendThread(this, thread); - } - - jvmtiError SuspendThreadList(jint request_count, - const jthread* request_list, - jvmtiError* results) { - return functions->SuspendThreadList(this, request_count, request_list, results); - } - - jvmtiError ResumeThread(jthread thread) { - return functions->ResumeThread(this, thread); - } - - jvmtiError ResumeThreadList(jint request_count, - const jthread* request_list, - jvmtiError* results) { - return functions->ResumeThreadList(this, request_count, request_list, results); - } - - jvmtiError StopThread(jthread thread, - jobject exception) { - return functions->StopThread(this, thread, exception); - } - - jvmtiError InterruptThread(jthread thread) { - return functions->InterruptThread(this, thread); - } - - jvmtiError GetThreadInfo(jthread thread, - jvmtiThreadInfo* info_ptr) { - return functions->GetThreadInfo(this, thread, info_ptr); - } - - jvmtiError GetOwnedMonitorInfo(jthread thread, - jint* owned_monitor_count_ptr, - jobject** owned_monitors_ptr) { - return functions->GetOwnedMonitorInfo(this, thread, owned_monitor_count_ptr, owned_monitors_ptr); - } - - jvmtiError GetOwnedMonitorStackDepthInfo(jthread thread, - jint* monitor_info_count_ptr, - jvmtiMonitorStackDepthInfo** monitor_info_ptr) { - return functions->GetOwnedMonitorStackDepthInfo(this, thread, monitor_info_count_ptr, monitor_info_ptr); - } - - jvmtiError GetCurrentContendedMonitor(jthread thread, - jobject* monitor_ptr) { - return functions->GetCurrentContendedMonitor(this, thread, monitor_ptr); - } - - jvmtiError RunAgentThread(jthread thread, - jvmtiStartFunction proc, - const void* arg, - jint priority) { - return functions->RunAgentThread(this, thread, proc, arg, priority); - } - - jvmtiError SetThreadLocalStorage(jthread thread, - const void* data) { - return functions->SetThreadLocalStorage(this, thread, data); - } - - jvmtiError GetThreadLocalStorage(jthread thread, - void** data_ptr) { - return functions->GetThreadLocalStorage(this, thread, data_ptr); - } - - jvmtiError GetTopThreadGroups(jint* group_count_ptr, - jthreadGroup** groups_ptr) { - return functions->GetTopThreadGroups(this, group_count_ptr, groups_ptr); - } - - jvmtiError GetThreadGroupInfo(jthreadGroup group, - jvmtiThreadGroupInfo* info_ptr) { - return functions->GetThreadGroupInfo(this, group, info_ptr); - } - - jvmtiError GetThreadGroupChildren(jthreadGroup group, - jint* thread_count_ptr, - jthread** threads_ptr, - jint* group_count_ptr, - jthreadGroup** groups_ptr) { - return functions->GetThreadGroupChildren(this, group, thread_count_ptr, threads_ptr, group_count_ptr, groups_ptr); - } - - jvmtiError GetStackTrace(jthread thread, - jint start_depth, - jint max_frame_count, - jvmtiFrameInfo* frame_buffer, - jint* count_ptr) { - return functions->GetStackTrace(this, thread, start_depth, max_frame_count, frame_buffer, count_ptr); - } - - jvmtiError GetAllStackTraces(jint max_frame_count, - jvmtiStackInfo** stack_info_ptr, - jint* thread_count_ptr) { - return functions->GetAllStackTraces(this, max_frame_count, stack_info_ptr, thread_count_ptr); - } - - jvmtiError GetThreadListStackTraces(jint thread_count, - const jthread* thread_list, - jint max_frame_count, - jvmtiStackInfo** stack_info_ptr) { - return functions->GetThreadListStackTraces(this, thread_count, thread_list, max_frame_count, stack_info_ptr); - } - - jvmtiError GetFrameCount(jthread thread, - jint* count_ptr) { - return functions->GetFrameCount(this, thread, count_ptr); - } - - jvmtiError PopFrame(jthread thread) { - return functions->PopFrame(this, thread); - } - - jvmtiError GetFrameLocation(jthread thread, - jint depth, - jmethodID* method_ptr, - jlocation* location_ptr) { - return functions->GetFrameLocation(this, thread, depth, method_ptr, location_ptr); - } - - jvmtiError NotifyFramePop(jthread thread, - jint depth) { - return functions->NotifyFramePop(this, thread, depth); - } - - jvmtiError ForceEarlyReturnObject(jthread thread, - jobject value) { - return functions->ForceEarlyReturnObject(this, thread, value); - } - - jvmtiError ForceEarlyReturnInt(jthread thread, - jint value) { - return functions->ForceEarlyReturnInt(this, thread, value); - } - - jvmtiError ForceEarlyReturnLong(jthread thread, - jlong value) { - return functions->ForceEarlyReturnLong(this, thread, value); - } - - jvmtiError ForceEarlyReturnFloat(jthread thread, - jfloat value) { - return functions->ForceEarlyReturnFloat(this, thread, value); - } - - jvmtiError ForceEarlyReturnDouble(jthread thread, - jdouble value) { - return functions->ForceEarlyReturnDouble(this, thread, value); - } - - jvmtiError ForceEarlyReturnVoid(jthread thread) { - return functions->ForceEarlyReturnVoid(this, thread); - } - - jvmtiError FollowReferences(jint heap_filter, - jclass klass, - jobject initial_object, - const jvmtiHeapCallbacks* callbacks, - const void* user_data) { - return functions->FollowReferences(this, heap_filter, klass, initial_object, callbacks, user_data); - } - - jvmtiError IterateThroughHeap(jint heap_filter, - jclass klass, - const jvmtiHeapCallbacks* callbacks, - const void* user_data) { - return functions->IterateThroughHeap(this, heap_filter, klass, callbacks, user_data); - } - - jvmtiError GetTag(jobject object, - jlong* tag_ptr) { - return functions->GetTag(this, object, tag_ptr); - } - - jvmtiError SetTag(jobject object, - jlong tag) { - return functions->SetTag(this, object, tag); - } - - jvmtiError GetObjectsWithTags(jint tag_count, - const jlong* tags, - jint* count_ptr, - jobject** object_result_ptr, - jlong** tag_result_ptr) { - return functions->GetObjectsWithTags(this, tag_count, tags, count_ptr, object_result_ptr, tag_result_ptr); - } - - jvmtiError ForceGarbageCollection() { - return functions->ForceGarbageCollection(this); - } - - jvmtiError IterateOverObjectsReachableFromObject(jobject object, - jvmtiObjectReferenceCallback object_reference_callback, - const void* user_data) { - return functions->IterateOverObjectsReachableFromObject(this, object, object_reference_callback, user_data); - } - - jvmtiError IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback, - jvmtiStackReferenceCallback stack_ref_callback, - jvmtiObjectReferenceCallback object_ref_callback, - const void* user_data) { - return functions->IterateOverReachableObjects(this, heap_root_callback, stack_ref_callback, object_ref_callback, user_data); - } - - jvmtiError IterateOverHeap(jvmtiHeapObjectFilter object_filter, - jvmtiHeapObjectCallback heap_object_callback, - const void* user_data) { - return functions->IterateOverHeap(this, object_filter, heap_object_callback, user_data); - } - - jvmtiError IterateOverInstancesOfClass(jclass klass, - jvmtiHeapObjectFilter object_filter, - jvmtiHeapObjectCallback heap_object_callback, - const void* user_data) { - return functions->IterateOverInstancesOfClass(this, klass, object_filter, heap_object_callback, user_data); - } - - jvmtiError GetLocalObject(jthread thread, - jint depth, - jint slot, - jobject* value_ptr) { - return functions->GetLocalObject(this, thread, depth, slot, value_ptr); - } - - jvmtiError GetLocalInt(jthread thread, - jint depth, - jint slot, - jint* value_ptr) { - return functions->GetLocalInt(this, thread, depth, slot, value_ptr); - } - - jvmtiError GetLocalLong(jthread thread, - jint depth, - jint slot, - jlong* value_ptr) { - return functions->GetLocalLong(this, thread, depth, slot, value_ptr); - } - - jvmtiError GetLocalFloat(jthread thread, - jint depth, - jint slot, - jfloat* value_ptr) { - return functions->GetLocalFloat(this, thread, depth, slot, value_ptr); - } - - jvmtiError GetLocalDouble(jthread thread, - jint depth, - jint slot, - jdouble* value_ptr) { - return functions->GetLocalDouble(this, thread, depth, slot, value_ptr); - } - - jvmtiError SetLocalObject(jthread thread, - jint depth, - jint slot, - jobject value) { - return functions->SetLocalObject(this, thread, depth, slot, value); - } - - jvmtiError SetLocalInt(jthread thread, - jint depth, - jint slot, - jint value) { - return functions->SetLocalInt(this, thread, depth, slot, value); - } - - jvmtiError SetLocalLong(jthread thread, - jint depth, - jint slot, - jlong value) { - return functions->SetLocalLong(this, thread, depth, slot, value); - } - - jvmtiError SetLocalFloat(jthread thread, - jint depth, - jint slot, - jfloat value) { - return functions->SetLocalFloat(this, thread, depth, slot, value); - } - - jvmtiError SetLocalDouble(jthread thread, - jint depth, - jint slot, - jdouble value) { - return functions->SetLocalDouble(this, thread, depth, slot, value); - } - - jvmtiError SetBreakpoint(jmethodID method, - jlocation location) { - return functions->SetBreakpoint(this, method, location); - } - - jvmtiError ClearBreakpoint(jmethodID method, - jlocation location) { - return functions->ClearBreakpoint(this, method, location); - } - - jvmtiError SetFieldAccessWatch(jclass klass, - jfieldID field) { - return functions->SetFieldAccessWatch(this, klass, field); - } - - jvmtiError ClearFieldAccessWatch(jclass klass, - jfieldID field) { - return functions->ClearFieldAccessWatch(this, klass, field); - } - - jvmtiError SetFieldModificationWatch(jclass klass, - jfieldID field) { - return functions->SetFieldModificationWatch(this, klass, field); - } - - jvmtiError ClearFieldModificationWatch(jclass klass, - jfieldID field) { - return functions->ClearFieldModificationWatch(this, klass, field); - } - - jvmtiError GetLoadedClasses(jint* class_count_ptr, - jclass** classes_ptr) { - return functions->GetLoadedClasses(this, class_count_ptr, classes_ptr); - } - - jvmtiError GetClassLoaderClasses(jobject initiating_loader, - jint* class_count_ptr, - jclass** classes_ptr) { - return functions->GetClassLoaderClasses(this, initiating_loader, class_count_ptr, classes_ptr); - } - - jvmtiError GetClassSignature(jclass klass, - char** signature_ptr, - char** generic_ptr) { - return functions->GetClassSignature(this, klass, signature_ptr, generic_ptr); - } - - jvmtiError GetClassStatus(jclass klass, - jint* status_ptr) { - return functions->GetClassStatus(this, klass, status_ptr); - } - - jvmtiError GetSourceFileName(jclass klass, - char** source_name_ptr) { - return functions->GetSourceFileName(this, klass, source_name_ptr); - } - - jvmtiError GetClassModifiers(jclass klass, - jint* modifiers_ptr) { - return functions->GetClassModifiers(this, klass, modifiers_ptr); - } - - jvmtiError GetClassMethods(jclass klass, - jint* method_count_ptr, - jmethodID** methods_ptr) { - return functions->GetClassMethods(this, klass, method_count_ptr, methods_ptr); - } - - jvmtiError GetClassFields(jclass klass, - jint* field_count_ptr, - jfieldID** fields_ptr) { - return functions->GetClassFields(this, klass, field_count_ptr, fields_ptr); - } - - jvmtiError GetImplementedInterfaces(jclass klass, - jint* interface_count_ptr, - jclass** interfaces_ptr) { - return functions->GetImplementedInterfaces(this, klass, interface_count_ptr, interfaces_ptr); - } - - jvmtiError GetClassVersionNumbers(jclass klass, - jint* minor_version_ptr, - jint* major_version_ptr) { - return functions->GetClassVersionNumbers(this, klass, minor_version_ptr, major_version_ptr); - } - - jvmtiError GetConstantPool(jclass klass, - jint* constant_pool_count_ptr, - jint* constant_pool_byte_count_ptr, - unsigned char** constant_pool_bytes_ptr) { - return functions->GetConstantPool(this, klass, constant_pool_count_ptr, constant_pool_byte_count_ptr, constant_pool_bytes_ptr); - } - - jvmtiError IsInterface(jclass klass, - jboolean* is_interface_ptr) { - return functions->IsInterface(this, klass, is_interface_ptr); - } - - jvmtiError IsArrayClass(jclass klass, - jboolean* is_array_class_ptr) { - return functions->IsArrayClass(this, klass, is_array_class_ptr); - } - - jvmtiError IsModifiableClass(jclass klass, - jboolean* is_modifiable_class_ptr) { - return functions->IsModifiableClass(this, klass, is_modifiable_class_ptr); - } - - jvmtiError GetClassLoader(jclass klass, - jobject* classloader_ptr) { - return functions->GetClassLoader(this, klass, classloader_ptr); - } - - jvmtiError GetSourceDebugExtension(jclass klass, - char** source_debug_extension_ptr) { - return functions->GetSourceDebugExtension(this, klass, source_debug_extension_ptr); - } - - jvmtiError RetransformClasses(jint class_count, - const jclass* classes) { - return functions->RetransformClasses(this, class_count, classes); - } - - jvmtiError RedefineClasses(jint class_count, - const jvmtiClassDefinition* class_definitions) { - return functions->RedefineClasses(this, class_count, class_definitions); - } - - jvmtiError GetObjectSize(jobject object, - jlong* size_ptr) { - return functions->GetObjectSize(this, object, size_ptr); - } - - jvmtiError GetObjectHashCode(jobject object, - jint* hash_code_ptr) { - return functions->GetObjectHashCode(this, object, hash_code_ptr); - } - - jvmtiError GetObjectMonitorUsage(jobject object, - jvmtiMonitorUsage* info_ptr) { - return functions->GetObjectMonitorUsage(this, object, info_ptr); - } - - jvmtiError GetFieldName(jclass klass, - jfieldID field, - char** name_ptr, - char** signature_ptr, - char** generic_ptr) { - return functions->GetFieldName(this, klass, field, name_ptr, signature_ptr, generic_ptr); - } - - jvmtiError GetFieldDeclaringClass(jclass klass, - jfieldID field, - jclass* declaring_class_ptr) { - return functions->GetFieldDeclaringClass(this, klass, field, declaring_class_ptr); - } - - jvmtiError GetFieldModifiers(jclass klass, - jfieldID field, - jint* modifiers_ptr) { - return functions->GetFieldModifiers(this, klass, field, modifiers_ptr); - } - - jvmtiError IsFieldSynthetic(jclass klass, - jfieldID field, - jboolean* is_synthetic_ptr) { - return functions->IsFieldSynthetic(this, klass, field, is_synthetic_ptr); - } - - jvmtiError GetMethodName(jmethodID method, - char** name_ptr, - char** signature_ptr, - char** generic_ptr) { - return functions->GetMethodName(this, method, name_ptr, signature_ptr, generic_ptr); - } - - jvmtiError GetMethodDeclaringClass(jmethodID method, - jclass* declaring_class_ptr) { - return functions->GetMethodDeclaringClass(this, method, declaring_class_ptr); - } - - jvmtiError GetMethodModifiers(jmethodID method, - jint* modifiers_ptr) { - return functions->GetMethodModifiers(this, method, modifiers_ptr); - } - - jvmtiError GetMaxLocals(jmethodID method, - jint* max_ptr) { - return functions->GetMaxLocals(this, method, max_ptr); - } - - jvmtiError GetArgumentsSize(jmethodID method, - jint* size_ptr) { - return functions->GetArgumentsSize(this, method, size_ptr); - } - - jvmtiError GetLineNumberTable(jmethodID method, - jint* entry_count_ptr, - jvmtiLineNumberEntry** table_ptr) { - return functions->GetLineNumberTable(this, method, entry_count_ptr, table_ptr); - } - - jvmtiError GetMethodLocation(jmethodID method, - jlocation* start_location_ptr, - jlocation* end_location_ptr) { - return functions->GetMethodLocation(this, method, start_location_ptr, end_location_ptr); - } - - jvmtiError GetLocalVariableTable(jmethodID method, - jint* entry_count_ptr, - jvmtiLocalVariableEntry** table_ptr) { - return functions->GetLocalVariableTable(this, method, entry_count_ptr, table_ptr); - } - - jvmtiError GetBytecodes(jmethodID method, - jint* bytecode_count_ptr, - unsigned char** bytecodes_ptr) { - return functions->GetBytecodes(this, method, bytecode_count_ptr, bytecodes_ptr); - } - - jvmtiError IsMethodNative(jmethodID method, - jboolean* is_native_ptr) { - return functions->IsMethodNative(this, method, is_native_ptr); - } - - jvmtiError IsMethodSynthetic(jmethodID method, - jboolean* is_synthetic_ptr) { - return functions->IsMethodSynthetic(this, method, is_synthetic_ptr); - } - - jvmtiError IsMethodObsolete(jmethodID method, - jboolean* is_obsolete_ptr) { - return functions->IsMethodObsolete(this, method, is_obsolete_ptr); - } - - jvmtiError SetNativeMethodPrefix(const char* prefix) { - return functions->SetNativeMethodPrefix(this, prefix); - } - - jvmtiError SetNativeMethodPrefixes(jint prefix_count, - char** prefixes) { - return functions->SetNativeMethodPrefixes(this, prefix_count, prefixes); - } - - jvmtiError CreateRawMonitor(const char* name, - jrawMonitorID* monitor_ptr) { - return functions->CreateRawMonitor(this, name, monitor_ptr); - } - - jvmtiError DestroyRawMonitor(jrawMonitorID monitor) { - return functions->DestroyRawMonitor(this, monitor); - } - - jvmtiError RawMonitorEnter(jrawMonitorID monitor) { - return functions->RawMonitorEnter(this, monitor); - } - - jvmtiError RawMonitorExit(jrawMonitorID monitor) { - return functions->RawMonitorExit(this, monitor); - } - - jvmtiError RawMonitorWait(jrawMonitorID monitor, - jlong millis) { - return functions->RawMonitorWait(this, monitor, millis); - } - - jvmtiError RawMonitorNotify(jrawMonitorID monitor) { - return functions->RawMonitorNotify(this, monitor); - } - - jvmtiError RawMonitorNotifyAll(jrawMonitorID monitor) { - return functions->RawMonitorNotifyAll(this, monitor); - } - - jvmtiError SetJNIFunctionTable(const jniNativeInterface* function_table) { - return functions->SetJNIFunctionTable(this, function_table); - } - - jvmtiError GetJNIFunctionTable(jniNativeInterface** function_table) { - return functions->GetJNIFunctionTable(this, function_table); - } - - jvmtiError SetEventCallbacks(const jvmtiEventCallbacks* callbacks, - jint size_of_callbacks) { - return functions->SetEventCallbacks(this, callbacks, size_of_callbacks); - } - - jvmtiError SetEventNotificationMode(jvmtiEventMode mode, - jvmtiEvent event_type, - jthread event_thread, - ...) { - return functions->SetEventNotificationMode(this, mode, event_type, event_thread); - } - - jvmtiError GenerateEvents(jvmtiEvent event_type) { - return functions->GenerateEvents(this, event_type); - } - - jvmtiError GetExtensionFunctions(jint* extension_count_ptr, - jvmtiExtensionFunctionInfo** extensions) { - return functions->GetExtensionFunctions(this, extension_count_ptr, extensions); - } - - jvmtiError GetExtensionEvents(jint* extension_count_ptr, - jvmtiExtensionEventInfo** extensions) { - return functions->GetExtensionEvents(this, extension_count_ptr, extensions); - } - - jvmtiError SetExtensionEventCallback(jint extension_event_index, - jvmtiExtensionEvent callback) { - return functions->SetExtensionEventCallback(this, extension_event_index, callback); - } - - jvmtiError GetPotentialCapabilities(jvmtiCapabilities* capabilities_ptr) { - return functions->GetPotentialCapabilities(this, capabilities_ptr); - } - - jvmtiError AddCapabilities(const jvmtiCapabilities* capabilities_ptr) { - return functions->AddCapabilities(this, capabilities_ptr); - } - - jvmtiError RelinquishCapabilities(const jvmtiCapabilities* capabilities_ptr) { - return functions->RelinquishCapabilities(this, capabilities_ptr); - } - - jvmtiError GetCapabilities(jvmtiCapabilities* capabilities_ptr) { - return functions->GetCapabilities(this, capabilities_ptr); - } - - jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { - return functions->GetCurrentThreadCpuTimerInfo(this, info_ptr); - } - - jvmtiError GetCurrentThreadCpuTime(jlong* nanos_ptr) { - return functions->GetCurrentThreadCpuTime(this, nanos_ptr); - } - - jvmtiError GetThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { - return functions->GetThreadCpuTimerInfo(this, info_ptr); - } - - jvmtiError GetThreadCpuTime(jthread thread, - jlong* nanos_ptr) { - return functions->GetThreadCpuTime(this, thread, nanos_ptr); - } - - jvmtiError GetTimerInfo(jvmtiTimerInfo* info_ptr) { - return functions->GetTimerInfo(this, info_ptr); - } - - jvmtiError GetTime(jlong* nanos_ptr) { - return functions->GetTime(this, nanos_ptr); - } - - jvmtiError GetAvailableProcessors(jint* processor_count_ptr) { - return functions->GetAvailableProcessors(this, processor_count_ptr); - } - - jvmtiError AddToBootstrapClassLoaderSearch(const char* segment) { - return functions->AddToBootstrapClassLoaderSearch(this, segment); - } - - jvmtiError AddToSystemClassLoaderSearch(const char* segment) { - return functions->AddToSystemClassLoaderSearch(this, segment); - } - - jvmtiError GetSystemProperties(jint* count_ptr, - char*** property_ptr) { - return functions->GetSystemProperties(this, count_ptr, property_ptr); - } - - jvmtiError GetSystemProperty(const char* property, - char** value_ptr) { - return functions->GetSystemProperty(this, property, value_ptr); - } - - jvmtiError SetSystemProperty(const char* property, - const char* value) { - return functions->SetSystemProperty(this, property, value); - } - - jvmtiError GetPhase(jvmtiPhase* phase_ptr) { - return functions->GetPhase(this, phase_ptr); - } - - jvmtiError DisposeEnvironment() { - return functions->DisposeEnvironment(this); - } - - jvmtiError SetEnvironmentLocalStorage(const void* data) { - return functions->SetEnvironmentLocalStorage(this, data); - } - - jvmtiError GetEnvironmentLocalStorage(void** data_ptr) { - return functions->GetEnvironmentLocalStorage(this, data_ptr); - } - - jvmtiError GetVersionNumber(jint* version_ptr) { - return functions->GetVersionNumber(this, version_ptr); - } - - jvmtiError GetErrorName(jvmtiError error, - char** name_ptr) { - return functions->GetErrorName(this, error, name_ptr); - } - - jvmtiError SetVerboseFlag(jvmtiVerboseFlag flag, - jboolean value) { - return functions->SetVerboseFlag(this, flag, value); - } - - jvmtiError GetJLocationFormat(jvmtiJlocationFormat* format_ptr) { - return functions->GetJLocationFormat(this, format_ptr); - } - -#endif /* __cplusplus */ -}; - - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* !_JAVA_JVMTI_H_ */ - diff --git a/cpp/JavaWinampApi/include/win32/jawt_md.h b/cpp/JavaWinampApi/include/win32/jawt_md.h deleted file mode 100644 index 82ba034..0000000 --- a/cpp/JavaWinampApi/include/win32/jawt_md.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -#ifndef _JAVASOFT_JAWT_MD_H_ -#define _JAVASOFT_JAWT_MD_H_ - -#include -#include "jawt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Win32-specific declarations for AWT native interface. - * See notes in jawt.h for an example of use. - */ -typedef struct jawt_Win32DrawingSurfaceInfo { - /* Native window, DDB, or DIB handle */ - union { - HWND hwnd; - HBITMAP hbitmap; - void* pbits; - }; - /* - * This HDC should always be used instead of the HDC returned from - * BeginPaint() or any calls to GetDC(). - */ - HDC hdc; - HPALETTE hpalette; -} JAWT_Win32DrawingSurfaceInfo; - -#ifdef __cplusplus -} -#endif - -#endif /* !_JAVASOFT_JAWT_MD_H_ */ diff --git a/cpp/JavaWinampApi/include/win32/jni_md.h b/cpp/JavaWinampApi/include/win32/jni_md.h deleted file mode 100644 index 9ac4718..0000000 --- a/cpp/JavaWinampApi/include/win32/jni_md.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -#ifndef _JAVASOFT_JNI_MD_H_ -#define _JAVASOFT_JNI_MD_H_ - -#define JNIEXPORT __declspec(dllexport) -#define JNIIMPORT __declspec(dllimport) -#define JNICALL __stdcall - -typedef long jint; -typedef __int64 jlong; -typedef signed char jbyte; - -#endif /* !_JAVASOFT_JNI_MD_H_ */ diff --git a/cpp/JavaWinampApi/wa_ipc.h b/cpp/JavaWinampApi/wa_ipc.h deleted file mode 100644 index 2ff4275..0000000 --- a/cpp/JavaWinampApi/wa_ipc.h +++ /dev/null @@ -1,1620 +0,0 @@ -/* -** Copyright (C) 2006 Nullsoft, Inc. -** -** This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held -** liable for any damages arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, including commercial applications, and to -** alter it and redistribute it freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. -** If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -** -** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -** -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#ifndef _WA_IPC_H_ -#define _WA_IPC_H_ - -#include -#include -#if (_MSC_VER <= 1200) -typedef int intptr_t; -#endif -/* -** This is the modern replacement for the classic 'frontend.h'. Most of these -** updates are designed for in-process use, i.e. from a plugin. -** -*/ - -/* message used to sent many messages to winamp's main window. -** most all of the IPC_* messages involve sending the message in the form of: -** result = SendMessage(hwnd_winamp,WM_WA_IPC,(parameter),IPC_*); -** -** When you use SendMessage(hwnd_winamp,WM_WA_IPC,(parameter),IPC_*) and specify a IPC_* -** which is not currently implemented/supported by the Winamp version being used then it -** will return 1 for 'result'. This is a good way of helping to check if an api being -** used which returns a function pointer, etc is even going to be valid. -*/ -#define WM_WA_IPC WM_USER -/* but some of them use WM_COPYDATA. be afraid. -*/ - -#define WINAMP_VERSION_MAJOR(winampVersion) ((winampVersion & 0x0000FF00) >> 12) -#define WINAMP_VERSION_MINOR(winampVersion) (winampVersion & 0x000000FF) // returns, i.e. 0x12 for 5.12 and 0x10 for 5.1... - -#define IPC_GETVERSION 0 -/* int version = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION); -** -** The version returned will be 0x20yx for Winamp 2.yx. -** Versions previous to Winamp 2.0 typically (but not always) use 0x1zyx for 1.zx. -** Just a bit weird but that's the way it goes. -** -** For Winamp 5.x it uses the format 0x50yx for Winamp 5.yx -** e.g. 5.01 -> 0x5001 -** 5.09 -> 0x5009 -** 5.1 -> 0x5010 -** -** Notes: For 5.02 this api will return the same value as for a 5.01 build. -** For 5.07 this api will return the same value as for a 5.06 build. -*/ -#define IPC_GETVERSIONSTRING 1 - -#define IPC_GETREGISTEREDVERSION 770 - - -typedef struct { - const char *filename; - const char *title; - int length; -} enqueueFileWithMetaStruct; // send this to a IPC_PLAYFILE in a non WM_COPYDATA, -// and you get the nice desired result. if title is NULL, it is treated as a "thing", -// otherwise it's assumed to be a file (for speed) - -typedef struct { - const wchar_t *filename; - const wchar_t *title; - int length; -} enqueueFileWithMetaStructW; - -#define IPC_PLAYFILE 100 // dont be fooled, this is really the same as enqueufile -#define IPC_ENQUEUEFILE 100 -#define IPC_PLAYFILEW 1100 -/* This is sent as a WM_COPYDATA with IPC_PLAYFILE as the dwData member and the string -** of the file / playlist to be enqueued into the playlist editor as the lpData member. -** This will just enqueue the file or files since you can use this to enqueue a playlist. -** It will not clear the current playlist or change the playback state. -** -** COPYDATASTRUCT cds = {0}; -** cds.dwData = IPC_ENQUEUEFILE; -** cds.lpData = (void*)"c:\\test\\folder\\test.mp3"; -** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char -** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); -** -** -** With 2.9+ and all of the 5.x versions you can send this as a normal WM_WA_IPC -** (non WM_COPYDATA) with an enqueueFileWithMetaStruct as the param. -** If the title member is null then it is treated as a "thing" otherwise it will be -** assumed to be a file (for speed). -** -** enqueueFileWithMetaStruct eFWMS = {0}; -** eFWMS.filename = "c:\\test\\folder\\test.mp3"; -** eFWMS.title = "Whipping Good"; -** eFWMS.length = 300; // this is the number of seconds for the track -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&eFWMS,IPC_ENQUEUEFILE); -*/ - - -#define IPC_DELETE 101 -#define IPC_DELETE_INT 1101 -/* SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_DELETE); -** Use this api to clear Winamp's internal playlist. -** You should not need to use IPC_DELETE_INT since it is used internally by Winamp when -** it is dealing with some lame Windows Explorer issues (hard to believe that!). -*/ - - -#define IPC_STARTPLAY 102 -#define IPC_STARTPLAY_INT 1102 -/* SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_STARTPLAY); -** Sending this will start playback and is almost the same as hitting the play button. -** The IPC_STARTPLAY_INT version is used internally and you should not need to use it -** since it won't be any fun. -*/ - -#define IPC_CHDIR 103 -/* This is sent as a WM_COPYDATA type message with IPC_CHDIR as the dwData value and the -** directory you want to change to as the lpData member. -** -** COPYDATASTRUCT cds = {0}; -** cds.dwData = IPC_CHDIR; -** cds.lpData = (void*)"c:\\download"; -** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char -** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); -** -** The above example will make Winamp change to the directory 'C:\download'. -*/ - - -#define IPC_ISPLAYING 104 -/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING); -** This is sent to retrieve the current playback state of Winamp. -** If it returns 1, Winamp is playing. -** If it returns 3, Winamp is paused. -** If it returns 0, Winamp is not playing. -*/ - - -#define IPC_GETOUTPUTTIME 105 -/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETOUTPUTTIME); -** This api can return two different sets of information about current playback status. -** -** If mode = 0 then it will return the position (in ms) of the currently playing track. -** Will return -1 if Winamp is not playing. -** -** If mode = 1 then it will return the current track length (in seconds). -** Will return -1 if there are no tracks (or possibly if Winamp cannot get the length). -*/ - - - -#define IPC_JUMPTOTIME 106 -/* (requires Winamp 1.60+) -** SendMessage(hwnd_winamp,WM_WA_IPC,ms,IPC_JUMPTOTIME); -** This api sets the current position (in milliseconds) for the currently playing song. -** The resulting playback position may only be an approximate time since some playback -** formats do not provide exact seeking e.g. mp3 -** This returns -1 if Winamp is not playing, 1 on end of file, or 0 if it was successful. -*/ - -#define IPC_GETMODULENAME 109 -#define IPC_EX_ISRIGHTEXE 666 -/* usually shouldnt bother using these, but here goes: -** send a WM_COPYDATA with IPC_GETMODULENAME, and an internal -** flag gets set, which if you send a normal WM_WA_IPC message with -** IPC_EX_ISRIGHTEXE, it returns whether or not that filename -** matches. lame, I know. -*/ - -#define IPC_WRITEPLAYLIST 120 -/* (requires Winamp 1.666+) -** int cur = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_WRITEPLAYLIST); -** -** IPC_WRITEPLAYLIST will write the current playlist to '\\Winamp.m3u' and -** will also return the current playlist position (see IPC_GETLISTPOS). -** -** This is kinda obsoleted by some of the newer 2.x api items but it still is good for -** use with a front-end program (instead of a plug-in) and you want to see what is in the -** current playlist. -** -** This api will only save out extended file information in the #EXTINF entry if Winamp -** has already read the data such as if the file was played of scrolled into view. If -** Winamp has not read the data then you will only find the file with its filepath entry -** (as is the base requirements for a m3u playlist). -*/ - - -#define IPC_SETPLAYLISTPOS 121 -/* (requires Winamp 2.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,position,IPC_SETPLAYLISTPOS) -** IPC_SETPLAYLISTPOS sets the playlist position to the specified 'position'. -** It will not change playback status or anything else. It will just set the current -** position in the playlist and will update the playlist view if necessary. -** -** If you use SendMessage(hwnd_winamp,WM_COMMAND,MAKEWPARAM(WINAMP_BUTTON2,0),0); -** after using IPC_SETPLAYLISTPOS then Winamp will start playing the file at 'position'. -*/ - - -#define IPC_SETVOLUME 122 -/* (requires Winamp 2.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,volume,IPC_SETVOLUME); -** IPC_SETVOLUME sets the volume of Winamp (between the range of 0 to 255). -** -** If you pass 'volume' as -666 then the message will return the current volume. -** int curvol = SendMessage(hwnd_winamp,WM_WA_IPC,-666,IPC_SETVOLUME); -*/ - - -#define IPC_SETPANNING 123 -/* (requires Winamp 2.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,panning,IPC_SETPANNING); -** IPC_SETPANNING sets the panning of Winamp from 0 (left) to 255 (right). -** -** At least in 5.x+ this works from -127 (left) to 127 (right). -** -** If you pass 'panning' as -666 to this api then it will return the current panning. -** int curpan = SendMessage(hwnd_winamp,WM_WA_IPC,-666,IPC_SETPANNING); -*/ - - -#define IPC_GETLISTLENGTH 124 -/* (requires Winamp 2.0+) -** int length = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTLENGTH); -** IPC_GETLISTLENGTH returns the length of the current playlist as the number of tracks. -*/ - - -#define IPC_GETLISTPOS 125 -/* (requires Winamp 2.05+) -** int pos=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTPOS); -** IPC_GETLISTPOS returns the current playlist position (which is shown in the playlist -** editor as a differently coloured text entry e.g is yellow for the classic skin). -** -** This api is a lot like IPC_WRITEPLAYLIST but a lot faster since it does not have to -** write out the whole of the current playlist first. -*/ - - -#define IPC_GETINFO 126 -/* (requires Winamp 2.05+) -** int inf=SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETINFO); -** IPC_GETINFO returns info about the current playing song. The value -** it returns depends on the value of 'mode'. -** Mode Meaning -** ------------------ -** 0 Samplerate, in kilohertz (i.e. 44) -** 1 Bitrate (i.e. 128) -** 2 Channels (i.e. 2) -** 3 (5+) Video LOWORD=w HIWORD=h -** 4 (5+) > 65536, string (video description) -** 5 (5.25+) Samplerate, in hertz (i.e. 44100) -*/ - - -#define IPC_GETEQDATA 127 -/* (requires Winamp 2.05+) -** int data=SendMessage(hwnd_winamp,WM_WA_IPC,pos,IPC_GETEQDATA); -** IPC_GETEQDATA queries the status of the EQ. -** The value returned depends on what 'pos' is set to: -** Value Meaning -** ------------------ -** 0-9 The 10 bands of EQ data. 0-63 (+20db - -20db) -** 10 The preamp value. 0-63 (+20db - -20db) -** 11 Enabled. zero if disabled, nonzero if enabled. -** 12 Autoload. zero if disabled, nonzero if enabled. -*/ - - -#define IPC_SETEQDATA 128 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,pos,IPC_GETEQDATA); -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SETEQDATA); -** IPC_SETEQDATA sets the value of the last position retrieved -** by IPC_GETEQDATA. This is pretty lame, and we should provide -** an extended version that lets you do a MAKELPARAM(pos,value). -** someday... - - new (2.92+): - if the high byte is set to 0xDB, then the third byte specifies - which band, and the bottom word specifies the value. -*/ - -#define IPC_ADDBOOKMARK 129 -#define IPC_ADDBOOKMARKW 131 -/* (requires Winamp 2.4+) -** This is sent as a WM_COPYDATA using IPC_ADDBOOKMARK as the dwData value and the -** directory you want to change to as the lpData member. This will add the specified -** file / url to the Winamp bookmark list. -** -** COPYDATASTRUCT cds = {0}; -** cds.dwData = IPC_ADDBOOKMARK; -** cds.lpData = (void*)"http://www.blah.com/listen.pls"; -** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char -** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); -** -** -** In Winamp 5.0+ we use this as a normal WM_WA_IPC and the string is null separated as -** the filename and then the title of the entry. -** -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(char*)"filename\0title\0",IPC_ADDBOOKMARK); -** -** This will notify the library / bookmark editor that a bookmark was added. -** Note that using this message in this context does not actually add the bookmark. -** Do not use, it is essentially just a notification type message :) -*/ - - -#define IPC_INSTALLPLUGIN 130 -/* This is not implemented (and is very unlikely to be done due to safety concerns). -** If it was then you could do a WM_COPYDATA with a path to a .wpz and it would then -** install the plugin for you. -** -** COPYDATASTRUCT cds = {0}; -** cds.dwData = IPC_INSTALLPLUGIN; -** cds.lpData = (void*)"c:\\path\\to\\file.wpz"; -** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char -** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); -*/ - - -#define IPC_RESTARTWINAMP 135 -/* (requires Winamp 2.2+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_RESTARTWINAMP); -** IPC_RESTARTWINAMP will restart Winamp (isn't that obvious ? :) ) -** If this fails to make Winamp start after closing then there is a good chance one (or -** more) of the currently installed plugins caused Winamp to crash on exit (either as a -** silent crash or a full crash log report before it could call itself start again. -*/ - - -#define IPC_ISFULLSTOP 400 -/* (requires winamp 2.7+ I think) -** int ret=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISFULLSTOP); -** This is useful for when you're an output plugin and you want to see if the stop/close -** happening is a full stop or if you are just between tracks. This returns non zero if -** it is a full stop or zero if it is just a new track. -*/ - - -#define IPC_INETAVAILABLE 242 -/* (requires Winamp 2.05+) -** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_INETAVAILABLE); -** IPC_INETAVAILABLE will return 1 if an Internet connection is available for Winamp and -** relates to the internet connection type setting on the main general preferences page -** in the Winamp preferences. -*/ - - -#define IPC_UPDTITLE 243 -/* (requires Winamp 2.2+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_UPDTITLE); -** IPC_UPDTITLE will ask Winamp to update the information about the current title and -** causes GetFileInfo(..) in the input plugin associated with the current playlist entry -** to be called. This can be called such as when an input plugin is buffering a file so -** that it can cause the buffer percentage to appear in the playlist. -*/ - - -#define IPC_REFRESHPLCACHE 247 -/* (requires Winamp 2.2+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_REFRESHPLCACHE); -** IPC_REFRESHPLCACHE will flush the playlist cache buffer and you send this if you want -** Winamp to go refetch the titles for all of the entries in the current playlist. - -5.3+: pass a wchar_t * string in wParam, and it'll do a strnicmp() before clearing the cache -*/ - - -#define IPC_GET_SHUFFLE 250 -/* (requires Winamp 2.4+) -** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_SHUFFLE); -** IPC_GET_SHUFFLE returns the status of the shuffle option. -** If set then it will return 1 and if not set then it will return 0. -*/ - - -#define IPC_GET_REPEAT 251 -/* (requires Winamp 2.4+) -** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_REPEAT); -** IPC_GET_REPEAT returns the status of the repeat option. -** If set then it will return 1 and if not set then it will return 0. -*/ - - -#define IPC_SET_SHUFFLE 252 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_SHUFFLE); -** IPC_SET_SHUFFLE sets the status of the shuffle option. -** If 'value' is 1 then shuffle is turned on. -** If 'value' is 0 then shuffle is turned off. -*/ - - -#define IPC_SET_REPEAT 253 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_REPEAT); -** IPC_SET_REPEAT sets the status of the repeat option. -** If 'value' is 1 then shuffle is turned on. -** If 'value' is 0 then shuffle is turned off. -*/ - - -#define IPC_ENABLEDISABLE_ALL_WINDOWS 259 // 0xdeadbeef to disable -/* (requires Winamp 2.9+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(enable?0:0xdeadbeef),IPC_ENABLEDISABLE_ALL_WINDOWS); -** Sending this message with 0xdeadbeef as the param will disable all winamp windows and -** any other values will enable all of the Winamp windows again. When disabled you won't -** get any response on clicking or trying to do anything to the Winamp windows. If the -** taskbar icon is shown then you may still have control ;) -*/ - - -#define IPC_GETWND 260 -/* (requires Winamp 2.9+) -** HWND h=SendMessage(hwnd_winamp,WM_WA_IPC,IPC_GETWND_xxx,IPC_GETWND); -** returns the HWND of the window specified. -*/ - #define IPC_GETWND_EQ 0 // use one of these for the param - #define IPC_GETWND_PE 1 - #define IPC_GETWND_MB 2 - #define IPC_GETWND_VIDEO 3 -#define IPC_ISWNDVISIBLE 261 // same param as IPC_GETWND - - - - -/************************************************************************ -***************** in-process only (WE LOVE PLUGINS) -************************************************************************/ - -#define IPC_SETSKINW 199 -#define IPC_SETSKIN 200 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)"skinname",IPC_SETSKIN); -** IPC_SETSKIN sets the current skin to "skinname". Note that skinname -** can be the name of a skin, a skin .zip file, with or without path. -** If path isn't specified, the default search path is the winamp skins -** directory. -*/ - - -#define IPC_GETSKIN 201 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)skinname_buffer,IPC_GETSKIN); -** IPC_GETSKIN puts the directory where skin bitmaps can be found -** into skinname_buffer. -** skinname_buffer must be MAX_PATH characters in length. -** When using a .zip'd skin file, it'll return a temporary directory -** where the ZIP was decompressed. -*/ - - -#define IPC_EXECPLUG 202 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)"vis_file.dll",IPC_EXECPLUG); -** IPC_EXECPLUG executes a visualization plug-in pointed to by WPARAM. -** the format of this string can be: -** "vis_whatever.dll" -** "vis_whatever.dll,0" // (first mod, file in winamp plug-in dir) -** "C:\\dir\\vis_whatever.dll,1" -*/ - - -#define IPC_GETPLAYLISTFILE 211 -#define IPC_GETPLAYLISTFILEW 214 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTFILE); -** IPC_GETPLAYLISTFILE gets the filename of the playlist entry [index]. -** returns a pointer to it. returns NULL on error. -*/ - - -#define IPC_GETPLAYLISTTITLE 212 -#define IPC_GETPLAYLISTTITLEW 213 -/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) -** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTTITLE); -** -** IPC_GETPLAYLISTTITLE gets the title of the playlist entry [index]. -** returns a pointer to it. returns NULL on error. -*/ - - -#define IPC_GETHTTPGETTER 240 -/* retrieves a function pointer to a HTTP retrieval function. -** if this is unsupported, returns 1 or 0. -** the function should be: -** int (*httpRetrieveFile)(HWND hwnd, char *url, char *file, char *dlgtitle); -** if you call this function, with a parent window, a URL, an output file, and a dialog title, -** it will return 0 on successful download, 1 on error. -*/ - - -#define IPC_MBOPEN 241 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_MBOPEN); -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)url,IPC_MBOPEN); -** IPC_MBOPEN will open a new URL in the minibrowser. if url is NULL, it will open the Minibrowser window. -*/ - - - -#define IPC_CHANGECURRENTFILE 245 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)file,IPC_CHANGECURRENTFILE); -** IPC_CHANGECURRENTFILE will set the current playlist item. -*/ - -#define IPC_CHANGECURRENTFILEW 1245 -/* (requires Winamp 2.05+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)file,IPC_CHANGECURRENTFILEW); -** IPC_CHANGECURRENTFILEW will set the current playlist item. -*/ - - -#define IPC_GETMBURL 246 -/* (requires Winamp 2.2+) -** char buffer[4096]; // Urls can be VERY long -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)buffer,IPC_GETMBURL); -** IPC_GETMBURL will retrieve the current Minibrowser URL into buffer. -** buffer must be at least 4096 bytes long. -*/ - - -#define IPC_MBBLOCK 248 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_MBBLOCK); -** -** IPC_MBBLOCK will block the Minibrowser from updates if value is set to 1 -*/ - -#define IPC_MBOPENREAL 249 -/* (requires Winamp 2.4+) -** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)url,IPC_MBOPENREAL); -** -** IPC_MBOPENREAL works the same as IPC_MBOPEN except that it will works even if -** IPC_MBBLOCK has been set to 1 -*/ - -#define IPC_ADJUST_OPTIONSMENUPOS 280 -/* (requires Winamp 2.9+) -** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_OPTIONSMENUPOS); -** moves where winamp expects the Options menu in the main menu. Useful if you wish to insert a -** menu item above the options/skins/vis menus. -*/ - -#define IPC_GET_HMENU 281 -/* (requires Winamp 2.9+) -** HMENU hMenu=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GET_HMENU); -** values for data: -** 0 : main popup menu -** 1 : main menubar file menu -** 2 : main menubar options menu -** 3 : main menubar windows menu -** 4 : main menubar help menu -** other values will return NULL. -*/ - -#define IPC_GET_EXTENDED_FILE_INFO 290 //pass a pointer to the following struct in wParam -#define IPC_GET_EXTENDED_FILE_INFO_HOOKABLE 296 -/* (requires Winamp 2.9+) -** to use, create an extendedFileInfoStruct, point the values filename and metadata to the -** filename and metadata field you wish to query, and ret to a buffer, with retlen to the -** length of that buffer, and then SendMessage(hwnd_winamp,WM_WA_IPC,&struct,IPC_GET_EXTENDED_FILE_INFO); -** the results should be in the buffer pointed to by ret. -** returns 1 if the decoder supports a getExtendedFileInfo method -*/ -typedef struct { - const char *filename; - const char *metadata; - char *ret; - size_t retlen; -} extendedFileInfoStruct; - - -#define IPC_GET_BASIC_FILE_INFO 291 //pass a pointer to the following struct in wParam -typedef struct { - const char *filename; - - int quickCheck; // set to 0 to always get, 1 for quick, 2 for default (if 2, quickCheck will be set to 0 if quick wasnot used) - - // filled in by winamp - int length; - char *title; - int titlelen; -} basicFileInfoStruct; - -#define IPC_GET_BASIC_FILE_INFOW 1291 //pass a pointer to the following struct in wParam -typedef struct { - const wchar_t *filename; - - int quickCheck; // set to 0 to always get, 1 for quick, 2 for default (if 2, quickCheck will be set to 0 if quick wasnot used) - - // filled in by winamp - int length; - wchar_t *title; - int titlelen; -} basicFileInfoStructW; - - -#define IPC_GET_EXTLIST 292 //returns doublenull delimited. GlobalFree() it when done. if data is 0, returns raw extlist, if 1, returns something suitable for getopenfilename -#define IPC_GET_EXTLISTW 1292 // wide char version of above - -#define IPC_INFOBOX 293 -typedef struct { - HWND parent; - char *filename; -} infoBoxParam; - -#define IPC_INFOBOXW 1293 -typedef struct { - HWND parent; - const wchar_t *filename; -} infoBoxParamW; - -#define IPC_SET_EXTENDED_FILE_INFO 294 //pass a pointer to the a extendedFileInfoStruct in wParam -/* (requires Winamp 2.9+) -** to use, create an extendedFileInfoStruct, point the values filename and metadata to the -** filename and metadata field you wish to write in ret. (retlen is not used). and then -** SendMessage(hwnd_winamp,WM_WA_IPC,&struct,IPC_SET_EXTENDED_FILE_INFO); -** returns 1 if the metadata is supported -** Call IPC_WRITE_EXTENDED_FILE_INFO once you're done setting all the metadata you want to update -*/ - -#define IPC_WRITE_EXTENDED_FILE_INFO 295 -/* (requires Winamp 2.9+) -** writes all the metadata set thru IPC_SET_EXTENDED_FILE_INFO to the file -** returns 1 if the file has been successfully updated, 0 if error -*/ - -#define IPC_FORMAT_TITLE 297 -typedef struct -{ - char *spec; // NULL=default winamp spec - void *p; - - char *out; - int out_len; - - char * (*TAGFUNC)(const char * tag, void * p); //return 0 if not found - void (*TAGFREEFUNC)(char * tag,void * p); -} waFormatTitle; - -#define IPC_FORMAT_TITLE_EXTENDED 298 // similiar to IPC_FORMAT_TITLE, but falls back to Winamp's %tags% if your passed tag function doesn't handle it -typedef struct -{ - const wchar_t *filename; - int useExtendedInfo; // set to 1 if you want the Title Formatter to query the input plugins for any tags that your tag function fails on - const wchar_t *spec; // NULL=default winamp spec - void *p; - - wchar_t *out; - int out_len; - - wchar_t * (*TAGFUNC)(const wchar_t * tag, void * p); //return 0 if not found, -1 for empty tag - void (*TAGFREEFUNC)(wchar_t *tag, void *p); -} waFormatTitleExtended; - -#define IPC_COPY_EXTENDED_FILE_INFO 299 -typedef struct -{ - const char *source; - const char *dest; -} copyFileInfoStruct; - -#define IPC_COPY_EXTENDED_FILE_INFOW 1299 -typedef struct -{ - const wchar_t *source; - const wchar_t *dest; -} copyFileInfoStructW; - - -#define IPC_GETUNCOMPRESSINTERFACE 331 -/* returns a function pointer to uncompress(). -** int (*uncompress)(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen); -** right out of zlib, useful for decompressing zlibbed data. -** if you pass the parm of 0x10100000, it will return a wa_inflate_struct * to an inflate API. -*/ - -typedef struct { - int (*inflateReset)(void *strm); - int (*inflateInit_)(void *strm,const char *version, int stream_size); - int (*inflate)(void *strm, int flush); - int (*inflateEnd)(void *strm); - unsigned long (*crc32)(unsigned long crc, const unsigned char *buf, unsigned int len); -} wa_inflate_struct; - - -#define IPC_ADD_PREFS_DLG 332 -#define IPC_REMOVE_PREFS_DLG 333 -/* (requires Winamp 2.9+) -** to use, allocate a prefsDlgRec structure (either on the heap or some global -** data, but NOT on the stack), initialze the members: -** hInst to the DLL instance where the resource is located -** dlgID to the ID of the dialog, -** proc to the window procedure for the dialog -** name to the name of the prefs page in the prefs. -** where to 0 (eventually we may add more options) -** then, SendMessage(hwnd_winamp,WM_WA_IPC,&prefsRec,IPC_ADD_PREFS_DLG); -** -** you can also IPC_REMOVE_PREFS_DLG with the address of the same prefsRec, -** but you shouldn't really ever have to. -** -*/ -#define IPC_OPENPREFSTOPAGE 380 // pass an id of a builtin page, or a &prefsDlgRec of prefs page to open - -typedef struct _prefsDlgRec { - HINSTANCE hInst; - int dlgID; - void *proc; - - char *name; - intptr_t where; // 0 for options, 1 for plugins, 2 for skins, 3 for bookmarks, 4 for prefs - - intptr_t _id; - struct _prefsDlgRec *next; -} prefsDlgRec; - - -#define IPC_GETINIFILE 334 // returns a pointer to winamp.ini -#define IPC_GETINIDIRECTORY 335 // returns a pointer to the directory to put config files in (if you dont want to use winamp.ini) -#define IPC_GETPLUGINDIRECTORY 336 -#define IPC_GETM3UDIRECTORY 337 // returns a char pointer to the directory where winamp.m3u is stored in. -#define IPC_GETM3UDIRECTORYW 338 // returns a wchar_t pointer to the directory where winamp.m3u is stored in. - -#define IPC_SPAWNBUTTONPOPUP 361 // param = -// 0 = eject -// 1 = previous -// 2 = next -// 3 = pause -// 4 = play -// 5 = stop - -#define IPC_OPENURLBOX 360 // pass a HWND to a parent, returns a HGLOBAL that needs to be freed with GlobalFree(), if successful -#define IPC_OPENFILEBOX 362 // pass a HWND to a parent -#define IPC_OPENDIRBOX 363 // pass a HWND to a parent - -// pass an HWND to a parent. call this if you take over the whole UI so that the dialogs are not appearing on the -// bottom right of the screen since the main winamp window is at 3000x3000, call again with NULL to reset -#define IPC_SETDIALOGBOXPARENT 364 - - - -#define IPC_DRO_MIN 401 // reserved for DrO -#define IPC_SET_JTF_COMPARATOR 409 -/* pass me an int (__cdecl *)(const char *, const char *) in wParam */ -#define IPC_SET_JTF_COMPARATOR_W 410 -/* pass me an int (__cdecl *)(const wchar_t *, const wchar_t *) in wParam ... maybe someday :) */ -#define IPC_SET_JTF_DRAWTEXT 416 - -#define IPC_DRO_MAX 499 - - -// pass 0 for a copy of the skin HBITMAP -// pass 1 for name of font to use for playlist editor likeness -// pass 2 for font charset -// pass 3 for font size -#define IPC_GET_GENSKINBITMAP 503 - - -#define IPC_GET_EMBEDIF 505 // pass an embedWindowState -// returns an HWND embedWindow(embedWindowState *); if the data is NULL, otherwise returns the HWND directly -typedef struct -{ - HWND me; //hwnd of the window - - int flags; - - RECT r; - - void *user_ptr; // for application use - - intptr_t extra_data[64]; // for internal winamp use -} embedWindowState; - -#define EMBED_FLAGS_NORESIZE 0x1 // set this bit in embedWindowState.flags to keep window from being resizable -#define EMBED_FLAGS_NOTRANSPARENCY 0x2 // set this bit in embedWindowState.flags to make gen_ff turn transparency off for this wnd -#define EMBED_FLAGS_NOWINDOWMENU 0x4 // set this bit to prevent gen_ff from automatically adding your window to the right-click menu -#define EMBED_FLAGS_GUID 0x8 // call SET_EMBED_GUID(yourEmbedWindowStateStruct, GUID) to define a GUID for this window - -#define SET_EMBED_GUID(windowState, windowGUID) { windowState->flags |= EMBED_FLAGS_GUID; *((GUID *)&windowState->extra_data[4])=windowGUID; } -#define GET_EMBED_GUID(windowState) (*((GUID *)&windowState->extra_data[4])) - -#define IPC_EMBED_ENUM 532 -typedef struct embedEnumStruct -{ - int (*enumProc)(embedWindowState *ws, struct embedEnumStruct *param); // return 1 to abort - int user_data; // or more :) -} embedEnumStruct; - // pass - -#define IPC_EMBED_ISVALID 533 - -#define IPC_CONVERTFILE 506 -/* (requires Winamp 2.92+) -** Converts a given file to a different format (PCM, MP3, etc...) -** To use, pass a pointer to a waFileConvertStruct struct -** This struct can be either on the heap or some global -** data, but NOT on the stack. At least, until the conversion is done. -** -** eg: SendMessage(hwnd_winamp,WM_WA_IPC,&myConvertStruct,IPC_CONVERTFILE); -** -** Return value: -** 0: Can't start the conversion. Look at myConvertStruct->error for details. -** 1: Conversion started. Status messages will be sent to the specified callbackhwnd. -** Be sure to call IPC_CONVERTFILE_END when your callback window receives the -** IPC_CB_CONVERT_DONE message. -*/ -typedef struct -{ - char *sourcefile; // "c:\\source.mp3" - char *destfile; // "c:\\dest.pcm" - int destformat[8]; // like 'PCM ',srate,nch,bps. - //hack alert! you can set destformat[6]=mmioFOURCC('I','N','I',' '); and destformat[7]=(int)my_ini_file; (where my_ini_file is a char*) - HWND callbackhwnd; // window that will receive the IPC_CB_CONVERT notification messages - - //filled in by winamp.exe - char *error; //if IPC_CONVERTFILE returns 0, the reason will be here - - int bytes_done; //you can look at both of these values for speed statistics - int bytes_total; - int bytes_out; - - int killswitch; // don't set it manually, use IPC_CONVERTFILE_END - intptr_t extra_data[64]; // for internal winamp use -} convertFileStruct; - -#define IPC_CONVERTFILE_END 507 -/* (requires Winamp 2.92+) -** Stop/ends a convert process started from IPC_CONVERTFILE -** You need to call this when you receive the IPC_CB_CONVERTDONE message or when you -** want to abort a conversion process -** -** eg: SendMessage(hwnd_winamp,WM_WA_IPC,&myConvertStruct,IPC_CONVERTFILE_END); -** -** No return value -*/ - -typedef struct { - HWND hwndParent; - int format; - - //filled in by winamp.exe - HWND hwndConfig; - int extra_data[8]; - //hack alert! you can set extra_data[6]=mmioFOURCC('I','N','I',' '); and extra_data[7]=(int)my_ini_file; (where my_ini_file is a char*) -} convertConfigStruct; -#define IPC_CONVERT_CONFIG 508 -#define IPC_CONVERT_CONFIG_END 509 - -typedef struct -{ - void (*enumProc)(intptr_t user_data, const char *desc, int fourcc); - intptr_t user_data; -} converterEnumFmtStruct; -#define IPC_CONVERT_CONFIG_ENUMFMTS 510 -/* (requires Winamp 2.92+) -*/ - -typedef struct -{ - char cdletter; - char *playlist_file; - HWND callback_hwnd; - - //filled in by winamp.exe - char *error; -} burnCDStruct; -#define IPC_BURN_CD 511 -/* (requires Winamp 5.0+) -*/ - -typedef struct -{ - convertFileStruct *cfs; - int priority; -} convertSetPriority; -#define IPC_CONVERT_SET_PRIORITY 512 - -typedef struct -{ - unsigned int format; //fourcc value - char *item; // config item, eg "bitrate" - char *data; // buffer to recieve, or buffer that contains the data - int len; // length of the data buffer (only used when getting a config item) - char *configfile; // config file to read from -} convertConfigItem; - -#define IPC_CONVERT_CONFIG_SET_ITEM 513 // returns TRUE if successful -#define IPC_CONVERT_CONFIG_GET_ITEM 514 // returns TRUE if successful - -typedef struct -{ - const char *filename; - char *title; // 2048 bytes - int length; - int force_useformatting; // can set this to 1 if you want to force a url to use title formatting shit -} waHookTitleStruct; -// return TRUE if you hook this -#define IPC_HOOK_TITLES 850 - -typedef struct -{ - const wchar_t *filename; - wchar_t *title; // 2048 bytes - int length; - int force_useformatting; // can set this to 1 if you want to force a url to use title formatting shit -} waHookTitleStructW; -// return TRUE if you hook this -#define IPC_HOOK_TITLESW 851 - -#define IPC_GETSADATAFUNC 800 -// 0: returns a char *export_sa_get() that returns 150 bytes of data -// 1: returns a export_sa_setreq(int want); - -#define IPC_GETVUDATAFUNC 801 -// 0: returns a int export_vu_get(int channel) that returns 0-255 (or -1 for bad channel) - -#define IPC_ISMAINWNDVISIBLE 900 - - -#define IPC_SETPLEDITCOLORS 920 -typedef struct -{ - int numElems; - int *elems; - HBITMAP bm; // set if you want to override -} waSetPlColorsStruct; - - -// the following IPC use waSpawnMenuParms as parameter -#define IPC_SPAWNEQPRESETMENU 933 -#define IPC_SPAWNFILEMENU 934 //menubar -#define IPC_SPAWNOPTIONSMENU 935 //menubar -#define IPC_SPAWNWINDOWSMENU 936 //menubar -#define IPC_SPAWNHELPMENU 937 //menubar -#define IPC_SPAWNPLAYMENU 938 //menubar -#define IPC_SPAWNPEFILEMENU 939 //menubar -#define IPC_SPAWNPEPLAYLISTMENU 940 //menubar -#define IPC_SPAWNPESORTMENU 941 //menubar -#define IPC_SPAWNPEHELPMENU 942 //menubar -#define IPC_SPAWNMLFILEMENU 943 //menubar -#define IPC_SPAWNMLVIEWMENU 944 //menubar -#define IPC_SPAWNMLHELPMENU 945 //menubar -#define IPC_SPAWNPELISTOFPLAYLISTS 946 - -typedef struct -{ - HWND wnd; - int xpos; // in screen coordinates - int ypos; -} waSpawnMenuParms; - -// waSpawnMenuParms2 is used by the menubar submenus -typedef struct -{ - HWND wnd; - int xpos; // in screen coordinates - int ypos; - int width; - int height; -} waSpawnMenuParms2; - - -// system tray sends this (you might want to simulate it) -#define WM_WA_SYSTRAY WM_USER+1 - -// input plugins send this when they are done playing back -#define WM_WA_MPEG_EOF WM_USER+2 - - - -//// video stuff - -#define IPC_IS_PLAYING_VIDEO 501 // returns >1 if playing, 0 if not, 1 if old version (so who knows):) -#define IPC_GET_IVIDEOOUTPUT 500 // see below for IVideoOutput interface -#define VIDEO_MAKETYPE(A,B,C,D) ((A) | ((B)<<8) | ((C)<<16) | ((D)<<24)) -#define VIDUSER_SET_INFOSTRING 0x1000 -#define VIDUSER_GET_VIDEOHWND 0x1001 -#define VIDUSER_SET_VFLIP 0x1002 -#define VIDUSER_SET_TRACKSELINTERFACE 0x1003 // give your ITrackSelector interface as param2 -#define VIDUSER_OPENVIDEORENDERER 0x1004 -#define VIDUSER_CLOSEVIDEORENDERER 0x1005 -#define VIDUSER_GETPOPUPMENU 0x1006 - -typedef struct -{ - int w; - int h; - int vflip; - double aspectratio; - unsigned int fmt; -} VideoOpenStruct; - -#ifndef NO_IVIDEO_DECLARE -#ifdef __cplusplus - -class VideoOutput; -class SubsItem; - -#ifndef _NSV_DEC_IF_H_ -typedef struct { - unsigned char* baseAddr; - long rowBytes; -} YV12_PLANE; - -typedef struct { - YV12_PLANE y; - YV12_PLANE u; - YV12_PLANE v; -} YV12_PLANES; -#endif - -class IVideoOutput -{ - public: - virtual ~IVideoOutput() { } - virtual int open(int w, int h, int vflip, double aspectratio, unsigned int fmt)=0; - virtual void setcallback(LRESULT (*msgcallback)(void *token, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam), void *token) { (void)token; (void)msgcallback; /* to eliminate warning C4100 */ } - virtual void close()=0; - virtual void draw(void *frame)=0; - virtual void drawSubtitle(SubsItem *item) { } - virtual void showStatusMsg(const char *text) { } - virtual int get_latency() { return 0; } - virtual void notifyBufferState(int bufferstate) { } /* 0-255*/ - - virtual INT_PTR extended(INT_PTR param1, INT_PTR param2, INT_PTR param3) { return 0; } // Dispatchable, eat this! -}; - -class ITrackSelector -{ - public: - virtual int getNumAudioTracks()=0; - virtual void enumAudioTrackName(int n, const char *buf, int size)=0; - virtual int getCurAudioTrack()=0; - virtual int getNumVideoTracks()=0; - virtual void enumVideoTrackName(int n, const char *buf, int size)=0; - virtual int getCurVideoTrack()=0; - - virtual void setAudioTrack(int n)=0; - virtual void setVideoTrack(int n)=0; -}; - -#endif //cplusplus -#endif//NO_IVIDEO_DECLARE - -// these messages are callbacks that you can grab by subclassing the winamp window - -// wParam = -#define IPC_CB_WND_EQ 0 // use one of these for the param -#define IPC_CB_WND_PE 1 -#define IPC_CB_WND_MB 2 -#define IPC_CB_WND_VIDEO 3 -#define IPC_CB_WND_MAIN 4 - -#define IPC_CB_ONSHOWWND 600 -#define IPC_CB_ONHIDEWND 601 - -#define IPC_CB_GETTOOLTIP 602 - -#define IPC_CB_MISC 603 - #define IPC_CB_MISC_TITLE 0 - #define IPC_CB_MISC_VOLUME 1 // volume/pan - #define IPC_CB_MISC_STATUS 2 - #define IPC_CB_MISC_EQ 3 - #define IPC_CB_MISC_INFO 4 - #define IPC_CB_MISC_VIDEOINFO 5 - -#define IPC_CB_CONVERT_STATUS 604 // param value goes from 0 to 100 (percent) -#define IPC_CB_CONVERT_DONE 605 - -#define IPC_ADJUST_FFWINDOWSMENUPOS 606 -/* (requires Winamp 2.9+) -** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_FFWINDOWSMENUPOS); -** moves where winamp expects the freeform windows in the menubar windows main menu. Useful if you wish to insert a -** menu item above extra freeform windows. -*/ - -#define IPC_ISDOUBLESIZE 608 - -#define IPC_ADJUST_FFOPTIONSMENUPOS 609 -/* (requires Winamp 2.9+) -** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_FFOPTIONSMENUPOS); -** moves where winamp expects the freeform preferences item in the menubar windows main menu. Useful if you wish to insert a -** menu item above preferences item. -*/ - -#define IPC_GETTIMEDISPLAYMODE 610 // returns 0 if displaying elapsed time or 1 if displaying remaining time - -#define IPC_SETVISWND 611 // param is hwnd, setting this allows you to receive ID_VIS_NEXT/PREVOUS/RANDOM/FS wm_commands -#define ID_VIS_NEXT 40382 -#define ID_VIS_PREV 40383 -#define ID_VIS_RANDOM 40384 -#define ID_VIS_FS 40389 -#define ID_VIS_CFG 40390 -#define ID_VIS_MENU 40391 - -#define IPC_GETVISWND 612 // returns the vis cmd handler hwnd -#define IPC_ISVISRUNNING 613 -#define IPC_CB_VISRANDOM 628 // param is status of random - -#define IPC_SETIDEALVIDEOSIZE 614 // sent by winamp to winamp, trap it if you need it. width=HIWORD(param), height=LOWORD(param) - -#define IPC_GETSTOPONVIDEOCLOSE 615 -#define IPC_SETSTOPONVIDEOCLOSE 616 - -typedef struct { - HWND hwnd; - int uMsg; - WPARAM wParam; - LPARAM lParam; -} transAccelStruct; - -#define IPC_TRANSLATEACCELERATOR 617 - -typedef struct { - int cmd; - int x; - int y; - int align; -} windowCommand; // send this as param to an IPC_PLCMD, IPC_MBCMD, IPC_VIDCMD - -#define IPC_CB_ONTOGGLEAOT 618 - -#define IPC_GETPREFSWND 619 - -#define IPC_SET_PE_WIDTHHEIGHT 620 // data is a pointer to a POINT structure that holds width & height - -#define IPC_GETLANGUAGEPACKINSTANCE 621 - -#define IPC_CB_PEINFOTEXT 622 // data is a string, ie: "04:21/45:02" - -#define IPC_CB_OUTPUTCHANGED 623 // output plugin was changed in config - -#define IPC_GETOUTPUTPLUGIN 625 - -#define IPC_SETDRAWBORDERS 626 -#define IPC_DISABLESKINCURSORS 627 -#define IPC_CB_RESETFONT 629 - -#define IPC_IS_FULLSCREEN 630 // returns 1 if video or vis is in fullscreen mode -#define IPC_SET_VIS_FS_FLAG 631 // a vis should send this message with 1/as param to notify winamp that it has gone to or has come back from fullscreen mode - -#define IPC_SHOW_NOTIFICATION 632 - -#define IPC_GETSKININFO 633 - -#define IPC_GET_MANUALPLADVANCE 634 -/* (requires Winamp 5.03+) -** val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_MANUALPLADVANCE); -** -** IPC_GET_MANUALPLADVANCE returns the status of the Manual Playlist Advance (1 if set) -*/ - -#define IPC_SET_MANUALPLADVANCE 635 -/* (requires Winamp 5.03+) -** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_MANUALPLADVANCE); -** -** IPC_SET_MANUALPLADVANCE sets the status of the Manual Playlist Advance option (1 to turn it on) -*/ - -#define IPC_GET_NEXT_PLITEM 636 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_EOF_GET_NEXT_PLITEM); -** -** Sent to Winamp's main window when an item has just finished playback or the next button has been pressed and -** requesting the new playlist item number to go to. -** Mainly used by gen_jumpex. Subclass this message in your application to return the new item number. -** -1 for normal winamp operation (default) or the new item number in the playlist to play. -*/ - -#define IPC_GET_PREVIOUS_PLITEM 637 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_EOF_GET_PREVIOUS_PLITEM); -** -** Sent to Winamp's main window when the previous button has been pressed and Winamp is requesting the new playlist item number to go to. -** Mainly used by gen_jumpex. Subclass this message in your application to return the new item number. -** -1 for normal winamp operation (default) or the new item number in the playlist to play. -*/ - -#define IPC_IS_WNDSHADE 638 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,wnd,IPC_IS_WNDSHADE); -** -** 'wnd' is window id as defined for IPC_GETWND, or -1 for main window -** Returns 1 if wnd is set to winshade mode, or 0 if it is not -*/ - -#define IPC_SETRATING 639 -/* (requires Winamp 5.04+ with ML) -** SendMessage(hwnd_winamp,WM_WA_IPC,rating,IPC_SETRATING); -** 'rating' is an int value from 0 (no rating) to 5 -*/ - -#define IPC_GETRATING 640 -/* (requires Winamp 5.04+ with ML) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETRATING); -** returns the current item's rating -*/ - -#define IPC_GETNUMAUDIOTRACKS 641 -/* (requires Winamp 5.04+) -** int n = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETNUMAUDIOTRACKS); -** returns the number of audio tracks for the currently playing item -*/ - -#define IPC_GETNUMVIDEOTRACKS 642 -/* (requires Winamp 5.04+) -** int n = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETNUMVIDEOTRACKS); -** returns the number of video tracks for the currently playing item -*/ - -#define IPC_GETAUDIOTRACK 643 -/* (requires Winamp 5.04+) -** int cur = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETAUDIOTRACK); -** returns the id of the current audio track for the currently playing item -*/ - -#define IPC_GETVIDEOTRACK 644 -/* (requires Winamp 5.04+) -** int cur = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVIDEOTRACK); -** returns the id of the current video track for the currently playing item -*/ - -#define IPC_SETAUDIOTRACK 645 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,track,IPC_SETAUDIOTRACK); -** switch the currently playing item to a new audio track -*/ - -#define IPC_SETVIDEOTRACK 646 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,track,IPC_SETVIDEOTRACK); -** switch the currently playing item to a new video track -*/ - -#define IPC_PUSH_DISABLE_EXIT 647 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_PUSH_DISABLE_EXIT ); -** lets you disable or re-enable the UI exit functions (close button, -** context menu, alt-f4). -** call IPC_POP_DISABLE_EXIT when you are done doing whatever required -** preventing exit -*/ - -#define IPC_POP_DISABLE_EXIT 648 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_POP_DISABLE_EXIT ); -** see IPC_PUSH_DISABLE_EXIT -*/ - -#define IPC_IS_EXIT_ENABLED 649 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_IS_EXIT_ENABLED); -** returns 0 if exit is disabled, 1 otherwise -*/ - -#define IPC_IS_AOT 650 -/* (requires Winamp 5.04+) -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_IS_AOT); -** returns status of always on top flag. note: this may not match the actual -** TOPMOST window flag while another fullscreen application is focused -*/ - -#define IPC_USES_RECYCLEBIN 651 -/* -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_USES_RECYCLEBIN); -** returns 1 if deleted files should be sent to the recycle bin. -** returns 0 if deleted files should be deleted permanently. -** -** You should check for this option if your plugin deletes files -** so that your setting matches the winamp setting -*/ - -#define IPC_FLUSHAUDITS 652 -/* -** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_FLUSHAUDITS); -** -** Will flush any pending audits in the global audits que -** -*/ - -#define IPC_GETPLAYITEM_START 653 -#define IPC_GETPLAYITEM_END 654 - - -#define IPC_GETVIDEORESIZE 655 -#define IPC_SETVIDEORESIZE 656 - -// >>>>>>>>>>> Next is 657 - -#define IPC_PLCMD 1000 - -#define PLCMD_ADD 0 -#define PLCMD_REM 1 -#define PLCMD_SEL 2 -#define PLCMD_MISC 3 -#define PLCMD_LIST 4 - -//#define IPC_MBCMD 1001 - -#define MBCMD_BACK 0 -#define MBCMD_FORWARD 1 -#define MBCMD_STOP 2 -#define MBCMD_RELOAD 3 -#define MBCMD_MISC 4 - -#define IPC_VIDCMD 1002 - -#define VIDCMD_FULLSCREEN 0 -#define VIDCMD_1X 1 -#define VIDCMD_2X 2 -#define VIDCMD_LIB 3 -#define VIDPOPUP_MISC 4 - -//#define IPC_MBURL 1003 //sets the URL -//#define IPC_MBGETCURURL 1004 //copies the current URL into wParam (have a 4096 buffer ready) -//#define IPC_MBGETDESC 1005 //copies the current URL description into wParam (have a 4096 buffer ready) -//#define IPC_MBCHECKLOCFILE 1006 //checks that the link file is up to date (otherwise updates it). wParam=parent HWND -//#define IPC_MBREFRESH 1007 //refreshes the "now playing" view in the library -//#define IPC_MBGETDEFURL 1008 //copies the default URL into wParam (have a 4096 buffer ready) - -#define IPC_STATS_LIBRARY_ITEMCNT 1300 // updates library count status - -// IPC 2000-3000 reserved for freeform messages, see gen_ff/ff_ipc.h -#define IPC_FF_FIRST 2000 -#define IPC_FF_LAST 3000 - - -/* -** General IPC messages in Winamp -** -** All notification messages appear in the lParam of the main window message proceedure. -*/ - - -#define IPC_GETDROPTARGET 3001 -/* (requires Winamp 5.0+) -** IDropTarget* IDrop = (IDropTarget*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETDROPTARGET); -** -** You call this to retrieve a copy of the IDropTarget interface which Winamp created for -** handling external drag and drop operations on to it's Windows. This is only really -** useful if you're providing an alternate interface and want your Windows to provide the -** same drag and drop support as Winamp normally provides the user. Check out MSDN or -** your prefered search facility for more information about the IDropTarget interface and -** what's needed to handle it in your own instance. -*/ - -#define IPC_PLAYLIST_MODIFIED 3002 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window whenever the playlist is -** modified in any way e.g. the addition/removal of a playlist entry. -** -** It is not a good idea to do large amounts of processing in this notification since it -** will slow down Winamp as playlist entries are modified (especially when you're adding -** in a large playlist). -** -** if(uMsg == WM_WA_IPC && lParam == IPC_PLAYLIST_MODIFIED){ -** // do what you need to do here -** } -*/ - -#define IPC_PLAYING_FILE 3003 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window when playback begins for -** a file. This passes the full filepath in the wParam of the message received. -** -** if(uMsg == WM_WA_IPC && lParam == IPC_PLAYING_FILE){ -** // do what you need to do here, e.g. -** process_file((char*)wParam); -** } -*/ - -#define IPC_PLAYING_FILEW 13003 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window when playback begins for -** a file. This passes the full filepath in the wParam of the message received. -** -** if(uMsg == WM_WA_IPC && lParam == IPC_PLAYING_FILEW){ -** // do what you need to do here, e.g. -** process_file((wchar_t*)wParam); -** } -*/ - -#define IPC_FILE_TAG_MAY_HAVE_UPDATED 3004 // sent to main wnd with the file as parm (char *) whenever a file tag might be updated -#define IPC_FILE_TAG_MAY_HAVE_UPDATEDW 3005 // sent to main wnd with the file as parm (wchar_t *) whenever a file tag might be updated -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window when a file's tag -** (e.g. id3) may have been updated. This appears to be sent when the InfoBox(..) function -** of the associated input plugin returns a 1 (which is the file information dialog/editor -** call normally). -** -** if(uMsg == WM_WA_IPC && lParam == IPC_FILE_TAG_MAY_HAVE_UPDATED){ -** // do what you need to do here, e.g. -** update_info_on_file_update((char*)wParam); -** } -*/ - -#define IPC_ALLOW_PLAYTRACKING 3007 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,allow,IPC_ALLOW_PLAYTRACKING); -** Send allow as nonzero to allow play tracking and zero to disable the mode. -*/ - -#define IPC_HOOK_OKTOQUIT 3010 -/* (requires Winamp 5.0+) -** This is a notification message sent to the main Winamp window asking if it's okay to -** close or not. Return zero to prevent Winamp from closing or return anything non-zero -** to allow Winamp to close. -** -** The best implementation of this option is to let the message pass through to the -** original window proceedure since another plugin may want to have a say in the matter -** with regards to Winamp closing. -** -** if(uMsg == WM_WA_IPC && lParam == IPC_HOOK_OKTOQUIT){ -** // do what you need to do here, e.g. -** if(no_shut_down()){ -** return 1; -** } -** } -*/ - -#define IPC_WRITECONFIG 3011 -/* (requires Winamp 5.0+) -** SendMessage(hwnd_winamp,WM_WA_IPC,write_type,IPC_WRITECONFIG); -** -** Send write_type as 2 to write all config settings and the current playlist. -** -** Send write_type as 1 to write the playlist and common settings. -** This won't save the following ini settings:: -** -** defext, titlefmt, proxy, visplugin_name, dspplugin_name, check_ft_startup, -** visplugin_num, pe_fontsize, visplugin_priority, visplugin_autoexec, dspplugin_num, -** sticon, splash, taskbar, dropaotfs, ascb_new, ttips, riol, minst, whichicon, -** whichicon2, addtolist, snap, snaplen, parent, hilite, disvis, rofiob, shownumsinpl, -** keeponscreen, eqdsize, usecursors, fixtitles, priority, shuffle_morph_rate, -** useexttitles, bifont, inet_mode, ospb, embedwnd_freesize, no_visseh -** (the above was valid for 5.1) -** -** Send write_type as 0 to write the common and less common settings and no playlist. -*/ - -#define IPC_UPDATE_URL 3012 // pass the URL (char *) in lparam, will be free()'d on done. - -// pass a string to be the name to register, and returns a value > 65536, which is a unique value you can use -// for custom WM_WA_IPC messages. - -#define IPC_GET_RANDFUNC 3015 // returns a function to get a random number -/* (requires Winamp 5.1+) -** int (*randfunc)(void) = (int(*)(void))SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_GET_RANDFUNC); -** if(randfunc && randfunc != 1){ -** randfunc(); -** } -** -** This will return a positive 32-bit number (essentially 31-bit). -** The check for a returned value of 1 is because that's the default return value from -** SendMessage(..) when it is not handled so is good to check for it in this situation. -*/ - -#define IPC_METADATA_CHANGED 3017 -/* (requires Winamp 5.1+) -** int changed=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(char*)field,IPC_METADATA_CHANGED); -** a plugin can SendMessage this to winamp if internal metadata has changes. -** wParam should be a char * of what field changed -** -** Currently used for internal actions (and very few at that) the intent of this api is -** to allow a plugin to call it when metadata has changed in the current playlist entry -** e.g.a new id3v2 tag was found in a stream -** -** The wparam value can either be NULL or a pointer to an ansi string for the metadata -** which has changed. This can be thought of as an advanced version of IPC_UPDTITLE and -** could be used to allow for update of the current title when a specific tag changed. -** -** Not recommended to be used since there is not the complete handling implemented in -** Winamp for it at the moment. -*/ - -#define IPC_SKIN_CHANGED 3018 -/* (requires Winamp 5.1+) -** This is a notification message sent to the main Winamp window by itself whenever -** the skin in use is changed. There is no information sent by the wParam for this. -** -** if(message == WM_WA_IPC && lparam == IPC_SKIN_CHANGED){ -** // do what you need to do to handle skin changes, e.g. call WADlg_init(hwnd_winamp); -** } -*/ - -#define IPC_REGISTER_LOWORD_COMMAND 3019 -/* (requires Winamp 5.1+) -** WORD id = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_REGISTER_LOWORD_COMMAND); -** This will assign you a unique id for making your own commands such as for extra menu -** entries. The starting value returned by this message will potentially change as and -** when the main resource file of Winamp is updated with extra data so assumptions cannot -** be made on what will be returned and plugin loading order will affect things as well. - -** 5.33+ -** If you want to reserve more than one id, you can pass the number of ids required in wParam -*/ - -#define IPC_GET_DISPATCH_OBJECT 3020 // gets winamp main IDispatch * (for embedded webpages) -#define IPC_GET_UNIQUE_DISPATCH_ID 3021 // gives you a unique dispatch ID that won't conflict with anything in winamp's IDispatch * - -#define IPC_ADD_DISPATCH_OBJECT 3022 // add your own dispatch object into winamp's. This lets embedded webpages access your functions -// pass a pointer to DispatchInfo (see below). Winamp makes a copy of all this data so you can safely delete it later -typedef struct -{ - wchar_t *name; // filled in by plugin, make sure it's a unicode string!! (i.e. L"myObject" instead of "myObject). - struct IDispatch *dispatch; // filled in by plugin - DWORD id; // filled in by winamp on return -} DispatchInfo; - -#define IPC_GET_PROXY_STRING 3023 -/* (requires Winamp 5.11+) -** char* proxy_string=(char*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_PROXY_STRING); -** This will return the same string as is shown on the General Preferences page. -*/ - -#define IPC_USE_REGISTRY 3024 -/* (requires Winamp 5.11+) -** int reg_enabled=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_USE_REGISTRY); -** This will return 0 if you should leave your grubby hands off the registry (i.e. for -** lockdown mode). This is useful if Winamp is run from a USB drive and you can't alter -** system settings, etc. -*/ - -#define IPC_GET_API_SERVICE 3025 -/* (requires Winamp 5.12+) -** api_service* api_service = (api_service)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_API_SERVICE); -** This api will return Winamp's api_service pointer (which is what Winamp3 used, heh). -** If this api is not supported in the Winamp version that is being used at the time then -** the returned value from this api will be 1 which is a good version check. -** -** As of 5.12 there is support for .w5s plugins which reside in %WinampDir%\System and -** are intended for common code that can be shared amongst other plugins e.g. jnetlib.w5s -** which contains jnetlib in one instance instead of being duplicated multiple times in -** all of the plugins which need internet access. -** -** Details on the .w5s specifications will come at some stage (possibly). -*/ - - - -typedef struct { - const wchar_t *filename; - const wchar_t *metadata; - wchar_t *ret; - size_t retlen; -} extendedFileInfoStructW; - -#define IPC_GET_EXTENDED_FILE_INFOW 3026 -/* (requires Winamp 5.13+) -** Pass a pointer to the above struct in wParam -*/ -#define IPC_GET_EXTENDED_FILE_INFOW_HOOKABLE 3027 -#define IPC_SET_EXTENDED_FILE_INFOW 3028 -/* (requires Winamp 5.13+) -** Pass a pointer to the above struct in wParam -*/ - -#define IPC_PLAYLIST_GET_NEXT_SELECTED 3029 -/* (requires 5.2+) -** int pl_item = SendMessage(hwnd_winamp,WM_WA_IPC,start,IPC_PLAYLIST_GET_NEXT_SELECTED); -** -** This works just like the ListView_GetNextItem(..) macro for ListView controls. -** 'start' is the index of the playlist item that you want to begin the search after or -** set this as -1 for the search to begin with the first item of the current playlist. -** -** This will return the index of the selected playlist according to the 'start' value or -** it returns -1 if there is no selection or no more selected items according to 'start'. -** -** Quick example: -** -** int sel = -1; -** // keep incrementing the start of the search so we get all of the selected entries -** while((sel = SendMessage(hwnd_winamp,WM_WA_IPC,sel,IPC_PLAYLIST_GET_NEXT_SELECTED))!=-1){ -** // show the playlist file entry of the selected item(s) if there were any -** MessageBox(hwnd_winamp,(char*)SendMessage(hwnd_winamp,WM_WA_IPC,sel,IPC_GETPLAYLISTFILE),0,0); -** } -*/ - -#define IPC_PLAYLIST_GET_SELECTED_COUNT 3030 -/* (requires 5.2+) -** int selcnt = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_PLAYLIST_GET_SELECTED_COUNT); -** This will return the number of selected playlist entries. -*/ - -#define IPC_GET_PLAYING_FILENAME 3031 // returns wchar_t * of the currently playing filename - -#define IPC_OPEN_URL 3032 // send either ANSI or Unicode string (it'll figure it out, but it MUST start with "h"!, so don't send ftp:// or anything funny) - -#define IPC_REGISTER_WINAMP_IPCMESSAGE 65536 -/* (requires Winamp 5.0+) -** DWORD id = SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)name,IPC_REGISTER_WINAMP_IPCMESSAGE); -** The value 'id' returned is > 65536 and is incremented on subsequent calls for unique -** 'name' values passed to it. By using the same 'name' in different plugins will allow a -** common runtime api to be provided for the currently running instance of Winamp -** e.g. -** PostMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)my_param,registered_ipc); -** Have a look at wa_hotkeys.h for an example on how this api is used in practice for a -** custom WM_WA_IPC message. -** -** if(uMsg == WM_WA_IPC && lParam == id_from_register_winamp_ipcmessage){ -** // do things -** } -*/ - -#endif//_WA_IPC_H_ diff --git a/cpp/jacob/ComThread.cpp b/cpp/jacob/ComThread.cpp deleted file mode 100644 index 36b4a35..0000000 --- a/cpp/jacob/ComThread.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "stdafx.h" -#include -#include "ComThread.h" -// Win32 support for Ole Automation -#include -#include -#include -#include -#include -#include "util.h" - -extern "C" -{ - -JNIEXPORT void JNICALL Java_com_jacob_com_ComThread_doCoInitialize - (JNIEnv *env, jclass cls, jint mode) -{ - int threadModel = mode; - CoInitializeEx(NULL, threadModel); -} - -JNIEXPORT void JNICALL Java_com_jacob_com_ComThread_doCoUninitialize - (JNIEnv *env, jclass cls) -{ - CoUninitialize(); -} - -} diff --git a/cpp/jacob/ComThread.h b/cpp/jacob/ComThread.h deleted file mode 100644 index 84a1980..0000000 --- a/cpp/jacob/ComThread.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -/* Header for class com_jacob_com_ComThread */ - -#ifndef _Included_com_jacob_com_ComThread -#define _Included_com_jacob_com_ComThread -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_jacob_com_ComThread - * Method: doCoInitialize - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_ComThread_doCoInitialize - (JNIEnv *, jclass, jint); - -/* - * Class: com_jacob_com_ComThread - * Method: doCoUninitialize - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_ComThread_doCoUninitialize - (JNIEnv *, jclass); - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/jacob/Dispatch.cpp b/cpp/jacob/Dispatch.cpp deleted file mode 100644 index ff3a83d..0000000 --- a/cpp/jacob/Dispatch.cpp +++ /dev/null @@ -1,582 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "stdafx.h" -#include -#include "Dispatch.h" -// Win32 support for Ole Automation -#include -#include -#include -#include -#include -#include "util.h" - -extern "C" -{ - -#define DISP_FLD "m_pDispatch" - -// extract a IDispatch from a jobject -IDispatch *extractDispatch(JNIEnv *env, jobject arg) -{ - jclass argClass = env->GetObjectClass(arg); - jfieldID ajf = env->GetFieldID( argClass, DISP_FLD, "I"); - jint anum = env->GetIntField(arg, ajf); - IDispatch *v = (IDispatch *)anum; - return v; -} - -/** - * This method finds an interface rooted on the passed in dispatch object. - * This creates a new Dispatch object so it is NOT reliable - * in the event callback thread of a JWS client where the root class loader - * does not have com.jacob.com.Dispatch in its classpath - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Dispatch_QueryInterface - (JNIEnv *env, jobject _this, jstring _iid) -{ - // get the current IDispatch - IDispatch *pIDispatch = extractDispatch(env, _this); - if (!pIDispatch) return NULL; - // if we used env->GetStringChars() would that let us drop the conversion? - const char *siid = env->GetStringUTFChars(_iid, NULL); - USES_CONVERSION; - LPOLESTR bsIID = A2W(siid); - env->ReleaseStringUTFChars(_iid, siid); - IID iid; - HRESULT hr = IIDFromString(bsIID, &iid); - if (FAILED(hr)) { - ThrowComFail(env, "Can't get IID from String", hr); - return NULL; - } - - // try to call QI on the passed IID - IDispatch *disp; - hr = pIDispatch->QueryInterface(iid, (void **)&disp); - if (FAILED(hr)) { - ThrowComFail(env, "QI on IID from String Failed", hr); - return NULL; - } - - jclass autoClass = env->FindClass("com/jacob/com/Dispatch"); - jmethodID autoCons = env->GetMethodID(autoClass, "", "(I)V"); - // construct a Dispatch object to return - // I am copying the pointer to java - // jacob-msg 1817 - SF 1053871 : QueryInterface already called AddRef!! - //if (disp) disp->AddRef(); - jobject newAuto = env->NewObject(autoClass, autoCons, disp); - return newAuto; -} - -/** - * starts up a new instance of the requested program (progId) - * and connects to it. does special code if the progid - * is of the alternate format (with ":") - **/ -JNIEXPORT void JNICALL Java_com_jacob_com_Dispatch_createInstanceNative - (JNIEnv *env, jobject _this, jstring _progid) -{ - jclass clazz = env->GetObjectClass(_this); - jfieldID jf = env->GetFieldID( clazz, DISP_FLD, "I"); - - // if we used env->GetStringChars() would that let us drop the conversion? - const char *progid = env->GetStringUTFChars(_progid, NULL); - CLSID clsid; - HRESULT hr; - IUnknown *punk = NULL; - IDispatch *pIDispatch; - USES_CONVERSION; - LPOLESTR bsProgId = A2W(progid); - if (strchr(progid,':')) - { - env->ReleaseStringUTFChars(_progid, progid); - // it's a moniker - hr = CoGetObject(bsProgId, NULL, IID_IUnknown, (LPVOID *)&punk); - if (FAILED(hr)) { - ThrowComFail(env, "Can't find moniker", hr); - return; - } - IClassFactory *pIClass; - // if it was a clsid moniker, I may have a class factory - hr = punk->QueryInterface(IID_IClassFactory, (void **)&pIClass); - if (!SUCCEEDED(hr)) goto doDisp; - punk->Release(); - // try to create an instance - hr = pIClass->CreateInstance(NULL, IID_IUnknown, (void **)&punk); - if (FAILED(hr)) { - ThrowComFail(env, "Can't create moniker class instance", hr); - return; - } - pIClass->Release(); - goto doDisp; - } - env->ReleaseStringUTFChars(_progid, progid); - // Now, try to find an IDispatch interface for progid - hr = CLSIDFromProgID(bsProgId, &clsid); - if (FAILED(hr)) { - ThrowComFail(env, "Can't get object clsid from progid", hr); - return; - } - // standard creation - hr = CoCreateInstance(clsid,NULL,CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER,IID_IUnknown, (void **)&punk); - if (!SUCCEEDED(hr)) { - ThrowComFail(env, "Can't co-create object", hr); - return; - } -doDisp: - - // now get an IDispatch pointer from the IUnknown - hr = punk->QueryInterface(IID_IDispatch, (void **)&pIDispatch); - if (!SUCCEEDED(hr)) { - ThrowComFail(env, "Can't QI object for IDispatch", hr); - return; - } - // CoCreateInstance called AddRef - punk->Release(); - env->SetIntField(_this, jf, (unsigned int)pIDispatch); -} - -/** - * attempts to connect to an running instance of the requested program - * This exists solely for the factory method connectToActiveInstance. - **/ -JNIEXPORT void JNICALL Java_com_jacob_com_Dispatch_getActiveInstanceNative - (JNIEnv *env, jobject _this, jstring _progid) -{ - jclass clazz = env->GetObjectClass(_this); - jfieldID jf = env->GetFieldID( clazz, DISP_FLD, "I"); - - // if we used env->GetStringChars() would that let us drop the conversion? - const char *progid = env->GetStringUTFChars(_progid, NULL); - CLSID clsid; - HRESULT hr; - IUnknown *punk = NULL; - IDispatch *pIDispatch; - USES_CONVERSION; - LPOLESTR bsProgId = A2W(progid); - env->ReleaseStringUTFChars(_progid, progid); - // Now, try to find an IDispatch interface for progid - hr = CLSIDFromProgID(bsProgId, &clsid); - if (FAILED(hr)) { - ThrowComFail(env, "Can't get object clsid from progid", hr); - return; - } - // standard connection - //printf("trying to connect to running %ls\n",bsProgId); - hr = GetActiveObject(clsid,NULL, &punk); - if (!SUCCEEDED(hr)) { - ThrowComFail(env, "Can't get active object", hr); - return; - } - // now get an IDispatch pointer from the IUnknown - hr = punk->QueryInterface(IID_IDispatch, (void **)&pIDispatch); - if (!SUCCEEDED(hr)) { - ThrowComFail(env, "Can't QI object for IDispatch", hr); - return; - } - // GetActiveObject called AddRef - punk->Release(); - env->SetIntField(_this, jf, (unsigned int)pIDispatch); -} - -/** - * starts up a new instance of the requested program (progId). - * This exists solely for the factory method connectToActiveInstance. - **/ -JNIEXPORT void JNICALL Java_com_jacob_com_Dispatch_coCreateInstanceNative - (JNIEnv *env, jobject _this, jstring _progid) -{ - jclass clazz = env->GetObjectClass(_this); - jfieldID jf = env->GetFieldID( clazz, DISP_FLD, "I"); - - // if we used env->GetStringChars() would that let us drop the conversion? - const char *progid = env->GetStringUTFChars(_progid, NULL); - CLSID clsid; - HRESULT hr; - IUnknown *punk = NULL; - IDispatch *pIDispatch; - USES_CONVERSION; - LPOLESTR bsProgId = A2W(progid); - env->ReleaseStringUTFChars(_progid, progid); - // Now, try to find an IDispatch interface for progid - hr = CLSIDFromProgID(bsProgId, &clsid); - if (FAILED(hr)) { - ThrowComFail(env, "Can't get object clsid from progid", hr); - return; - } - // standard creation - hr = CoCreateInstance(clsid,NULL,CLSCTX_LOCAL_SERVER|CLSCTX_INPROC_SERVER,IID_IUnknown, (void **)&punk); - if (!SUCCEEDED(hr)) { - ThrowComFail(env, "Can't co-create object", hr); - return; - } - // now get an IDispatch pointer from the IUnknown - hr = punk->QueryInterface(IID_IDispatch, (void **)&pIDispatch); - if (!SUCCEEDED(hr)) { - ThrowComFail(env, "Can't QI object for IDispatch", hr); - return; - } - // CoCreateInstance called AddRef - punk->Release(); - env->SetIntField(_this, jf, (unsigned int)pIDispatch); -} - -/** - * release method - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Dispatch_release - (JNIEnv *env, jobject _this) -{ - jclass clazz = env->GetObjectClass(_this); - jfieldID jf = env->GetFieldID( clazz, DISP_FLD, "I"); - jint num = env->GetIntField(_this, jf); - - IDispatch *disp = (IDispatch *)num; - if (disp) { - disp->Release(); - env->SetIntField(_this, jf, (unsigned int)0); - } -} - -static HRESULT -name2ID(IDispatch *pIDispatch, const char *prop, DISPID *dispid, long lcid) -{ - HRESULT hresult; - USES_CONVERSION; - LPOLESTR propOle = A2W(prop); - hresult = pIDispatch->GetIDsOfNames(IID_NULL,(LPOLESTR*)&propOle,1,lcid,dispid); - return hresult; -} - -JNIEXPORT jintArray JNICALL Java_com_jacob_com_Dispatch_getIDsOfNames - (JNIEnv *env, jclass clazz, jobject disp, jint lcid, jobjectArray names) -{ - IDispatch *pIDispatch = extractDispatch(env, disp); - if (!pIDispatch) return NULL; - - int l = env->GetArrayLength(names); - int i; - LPOLESTR *lps = (LPOLESTR *)CoTaskMemAlloc(l * sizeof(LPOLESTR)); - DISPID *dispid = (DISPID *)CoTaskMemAlloc(l * sizeof(DISPID)); - for(i=0;iGetObjectArrayElement(names, i); - // if we used env->GetStringChars() would that let us drop the conversion? - const char *nm = env->GetStringUTFChars(s, NULL); - LPOLESTR nmos = A2W(nm); - env->ReleaseStringUTFChars(s, nm); - lps[i] = nmos; - env->DeleteLocalRef(s); - } - HRESULT hr = pIDispatch->GetIDsOfNames(IID_NULL,lps,l,lcid,dispid); - if (FAILED(hr)) { - CoTaskMemFree(lps); - CoTaskMemFree(dispid); - char buf[1024]; - strcpy_s(buf, "Can't map names to dispid:"); - for(i=0;iGetObjectArrayElement(names, i); - const char *nm = env->GetStringUTFChars(s, NULL); - strcat_s(buf, nm); - env->ReleaseStringUTFChars(s, nm); - env->DeleteLocalRef(s); - } - ThrowComFail(env, buf, hr); - return NULL; - } - jintArray iarr = env->NewIntArray(l); - // SF 1511033 -- the 2nd parameter should be 0 and not i! - env->SetIntArrayRegion(iarr, 0, l, dispid); - CoTaskMemFree(lps); - CoTaskMemFree(dispid); - return iarr; -} - -static char* BasicToCharString(const BSTR inBasicString) -{ - char* charString = NULL; - const size_t charStrSize = ::SysStringLen(inBasicString) + 1; - if (charStrSize > 1) - { - charString = new char[charStrSize]; - size_t convertedSize; - ::wcstombs_s(&convertedSize, charString, charStrSize, inBasicString, charStrSize); - } - else - { - charString = ::_strdup(""); - } - return charString; -} - -static wchar_t* CreateErrorMsgFromResult(HRESULT inResult) -{ - wchar_t* msg = NULL; - ::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, NULL, inResult,MAKELANGID(LANG_NEUTRAL, - SUBLANG_DEFAULT), (LPWSTR) &msg, 0, NULL); - if (msg == NULL) - { - const wchar_t* message_text = L"An unknown COM error has occured."; - size_t bufferLength = (wcslen(message_text) + 1) * sizeof(wchar_t); - msg = (wchar_t*) ::LocalAlloc(LPTR, bufferLength); - wcscpy_s(msg, bufferLength, message_text); - } - - return msg; -} - -static wchar_t* CreateErrorMsgFromInfo(HRESULT inResult, EXCEPINFO* ioInfo, - const char* methName) -{ - wchar_t* msg = NULL; - size_t methNameWSize = 0; - - mbstowcs_s(&methNameWSize, NULL, 0, methName, _TRUNCATE); - - wchar_t* methNameW = new wchar_t[methNameWSize]; - - mbstowcs_s(NULL, methNameW, methNameWSize, methName, _TRUNCATE); - - // If this is a dispatch exception (triggered by an Invoke message), - // then we have to take some additional steps to process the error - // message. - if (inResult == DISP_E_EXCEPTION) - { - // Check to see if the server deferred filling in the exception - // information. If so, make the call to populate the structure. - if (ioInfo->pfnDeferredFillIn != NULL) - (*(ioInfo->pfnDeferredFillIn))(ioInfo); - - // Build the error message from exception information content. - int sourceLen = SysStringLen(ioInfo->bstrSource); - int descLen = SysStringLen(ioInfo->bstrDescription); - const size_t MSG_LEN = ::wcslen(methNameW) + sourceLen + descLen + 128; - msg = new wchar_t[MSG_LEN]; - ::wcsncpy_s(msg, MSG_LEN, L"Invoke of: ", wcslen(L"Invoke of: ")); - ::wcsncat_s(msg, MSG_LEN, methNameW, wcslen(methNameW)); - ::wcsncat_s(msg, MSG_LEN, L"\nSource: ", wcslen(L"\nSource: ")); - ::wcsncat_s(msg, MSG_LEN, ioInfo->bstrSource, sourceLen); - ::wcsncat_s(msg, MSG_LEN, L"\nDescription: ", wcslen(L"\nDescription: ")); - ::wcsncat_s(msg, MSG_LEN, ioInfo->bstrDescription, descLen); - ::wcsncat_s(msg, MSG_LEN, L"\n", wcslen(L"\n")); - } - else - { - wchar_t* msg2 = CreateErrorMsgFromResult(inResult); - const size_t MSG_LEN = ::wcslen(methNameW) + ::wcslen(msg2) + 256; - msg = new wchar_t[MSG_LEN]; - ::wcsncpy_s(msg, MSG_LEN, - L"A COM exception has been encountered:\nAt Invoke of: ", - wcslen(L"A COM exception has been encountered:\nAt Invoke of: ")); - ::wcsncat_s(msg, MSG_LEN, methNameW, wcslen(methNameW)); - ::wcsncat_s(msg, MSG_LEN, L"\nDescription: ", wcslen(L"\nDescription: ")); - ::wcsncat_s(msg, MSG_LEN, msg2, wcslen(msg2)); - // jacob-msg 1075 - SF 1053872 : Documentation says "use LocalFree"!! - //delete msg2; - LocalFree(msg2); - } - delete methNameW; - return msg; -} - - -#define SETDISPPARAMS(dp, numArgs, pvArgs, numNamed, pNamed) \ - {\ - (dp).cArgs = numArgs; \ - (dp).rgvarg = pvArgs; \ - (dp).cNamedArgs = numNamed; \ - (dp).rgdispidNamedArgs = pNamed; \ - } - -#define SETNOPARAMS(dp) SETDISPPARAMS(dp, 0, NULL, 0, NULL) - -JNIEXPORT jobject JNICALL Java_com_jacob_com_Dispatch_invokev - (JNIEnv *env, jclass clazz, - jobject disp, jstring name, jint dispid, - jint lcid, jint wFlags, jobjectArray vArg, jintArray uArgErr) -{ - DISPPARAMS dispparams; - EXCEPINFO excepInfo; - // Sourceforge Bug Tracker 2935662 uninitialized data can be not NULL with bad results - excepInfo.pfnDeferredFillIn = NULL; - - IDispatch *pIDispatch = extractDispatch(env, disp); - if (!pIDispatch) return NULL; - - int dispID = dispid; - if (name != NULL) - { - const char *nm = env->GetStringUTFChars(name, NULL); - HRESULT hr; - if (FAILED(hr = name2ID(pIDispatch, nm, (long *)&dispID, lcid))) { - char buf[1024]; - sprintf_s(buf, 1024, "Can't map name to dispid: %s", nm); - ThrowComFail(env, buf, -1); - return NULL; - } - env->ReleaseStringUTFChars(name, nm); - } - - int num_args = env->GetArrayLength(vArg); - int i, j; - VARIANT *varr = NULL; - if (num_args) - { - varr = (VARIANT *)CoTaskMemAlloc(num_args*sizeof(VARIANT)); - /* reverse args for dispatch */ - for(i=num_args-1,j=0;0<=i;i--,j++) - { - VariantInit(&varr[j]); - jobject arg = env->GetObjectArrayElement(vArg, i); - VARIANT *v = extractVariant(env, arg); - // no escape from copy? - VariantCopy(&varr[j], v); - env->DeleteLocalRef(arg); - } - } - // prepare a new return value - jclass variantClass = env->FindClass("com/jacob/com/Variant"); - jmethodID variantCons = - env->GetMethodID(variantClass, "", "()V"); - // construct a variant to return - jobject newVariant = env->NewObject(variantClass, variantCons); - // get the VARIANT from the newVariant - VARIANT *v = extractVariant(env, newVariant); - DISPID dispidPropertyPut = DISPID_PROPERTYPUT; - - // determine how to dispatch - switch (wFlags) - { - case DISPATCH_PROPERTYGET: // GET - case DISPATCH_METHOD: // METHOD - case DISPATCH_METHOD|DISPATCH_PROPERTYGET: - { - SETDISPPARAMS(dispparams, num_args, varr, 0, NULL); - break; - } - case DISPATCH_PROPERTYPUT: - case DISPATCH_PROPERTYPUTREF: // jacob-msg 1075 - SF 1053872 - { - SETDISPPARAMS(dispparams, num_args, varr, 1, &dispidPropertyPut); - break; - } - } - - HRESULT hr = 0; - jint count = env->GetArrayLength(uArgErr); - if ( count != 0 ) - { - jint *uAE = env->GetIntArrayElements(uArgErr, NULL); - hr = pIDispatch->Invoke(dispID,IID_NULL, - lcid,(WORD)wFlags,&dispparams,v,&excepInfo,(unsigned int *)uAE); // SF 1689061 - env->ReleaseIntArrayElements(uArgErr, uAE, 0); - } - else - { - hr = pIDispatch->Invoke(dispID,IID_NULL, - lcid,(WORD)wFlags,&dispparams,v,&excepInfo, NULL); // SF 1689061 - } - if (num_args) - { - // to account for inouts, I need to copy the inputs back to - // the java array after the method returns - // this occurs, for example, in the ADO wrappers - for(i=num_args-1,j=0;0<=i;i--,j++) - { - jobject arg = env->GetObjectArrayElement(vArg, i); - VARIANT *v = extractVariant(env, arg); - // reverse copy - VariantCopy(v, &varr[j]); - // clear out the temporary variant - VariantClear(&varr[j]); - env->DeleteLocalRef(arg); - } - } - - if (varr) CoTaskMemFree(varr); - - // check for error and display a somewhat verbose error message - if (!SUCCEEDED(hr)) { - // two buffers that may have to be freed later - wchar_t *buf = NULL; - char *dispIdAsName = NULL; - // this method can get called with a name or a dispatch id - // we need to handle both SF 1114159 - if (name != NULL){ - const char *nm = env->GetStringUTFChars(name, NULL); - buf = CreateErrorMsgFromInfo(hr, &excepInfo, nm); - env->ReleaseStringUTFChars(name, nm); - } else { - dispIdAsName = new char[256]; - // get the id string - _itoa_s (dispID, dispIdAsName, 256,10); - //continue on mostly as before - buf = CreateErrorMsgFromInfo(hr,&excepInfo,dispIdAsName); - } - - // jacob-msg 3696 - SF 1053866 - if(hr == DISP_E_EXCEPTION) - { - if(excepInfo.scode != 0) - { - hr = excepInfo.scode; - } - else - { - hr = _com_error::WCodeToHRESULT(excepInfo.wCode); - } - } - - ThrowComFailUnicode(env, buf, hr); - if (buf) delete buf; - if (dispIdAsName) delete dispIdAsName; - return NULL; - } - - return newVariant; -} - -/* - * Wait method added so folks could wait until a com server terminated - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_Dispatch_hasExited - (JNIEnv *env,jclass clazz, jobject disp, jint dispid, jint lcid) { - IDispatch *pIDispatch = extractDispatch(env, disp); - if (!pIDispatch) { - // should we return 0? - return NULL; - } - ITypeInfo *v; - HRESULT hr = pIDispatch->GetTypeInfo(dispid, lcid, &v); - if (hr == RPC_E_SERVERCALL_RETRYLATER || hr == RPC_E_CALL_REJECTED || hr - == 0) { - return 0; - } else { - return 1; - } -} - -} - - diff --git a/cpp/jacob/Dispatch.h b/cpp/jacob/Dispatch.h deleted file mode 100644 index d8cda4e..0000000 --- a/cpp/jacob/Dispatch.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -/* Header for class Dispatch */ - -#ifndef _Included_Dispatch -#define _Included_Dispatch -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_jacob_com_Dispatch - * Method: QueryInterface - * Signature: (Ljava/lang/String;)Lcom/jacob/com/Dispatch; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Dispatch_QueryInterface - (JNIEnv *, jobject, jstring); - -/* - * Class: Dispatch - * Method: createInstance - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Dispatch_createInstanceNative - (JNIEnv *, jobject, jstring); - -/* - * Class: Dispatch - * Method: getActiveInstance - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Dispatch_getActiveInstanceNative - (JNIEnv *, jobject, jstring); - -/* - * Class: Dispatch - * Method: coCreateInstance - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Dispatch_coCreateInstanceNative - (JNIEnv *, jobject, jstring); - -/* - * Class: Dispatch - * Method: release - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Dispatch_release - (JNIEnv *, jobject); - -/* - * Class: Dispatch - * Method: getIDsOfNames - * Signature: (Ljava/lang/Object;I[Ljava/lang/String;)[I - */ -JNIEXPORT jintArray JNICALL Java_com_jacob_com_Dispatch_getIDsOfNames - (JNIEnv *, jclass, jobject, jint, jobjectArray); - -/* - * Class: Dispatch - * Method: invokev - * Signature: (Ljava/lang/Object;Ljava/lang/String;III[LVariant;[I)LVariant; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Dispatch_invokev - (JNIEnv *, jclass, jobject, jstring, jint, jint, jint, jobjectArray, jintArray); - -/* - * Class: Dispatch - * Method: wait - * Signature: (Ljava/lang/Object;I;)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_Dispatch_hasExited - (JNIEnv *, jclass, jobject, jint, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/jacob/DispatchEvents.cpp b/cpp/jacob/DispatchEvents.cpp deleted file mode 100644 index 3428749..0000000 --- a/cpp/jacob/DispatchEvents.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "DispatchEvents.h" -#include "EventProxy.h" -// Win32 support for Ole Automation -#include -#include -#include -#include -#include -#include - -#include "util.h" - -extern "C" -{ - -#define PROXY_FLD "m_pConnPtProxy" - -// defined below -BOOL GetEventIID(IUnknown*, IID*, CComBSTR **, DISPID **, int *,LPOLESTR); -BOOL GetEventIIDForTypeLib(BSTR, IID*, CComBSTR **, DISPID **, int *,LPOLESTR); -BOOL getClassInfoFromProgId(LPOLESTR bsProgId,LPTYPEINFO *pClassInfo); -BOOL MapEventIIDs(IID*, CComBSTR **, DISPID **, int *, LPOLESTR , LPTYPEINFO ); - -// extract a EventProxy* from a jobject -EventProxy *extractProxy(JNIEnv *env, jobject arg) -{ - jclass argClass = env->GetObjectClass(arg); - jfieldID ajf = env->GetFieldID( argClass, PROXY_FLD, "I"); - jint anum = env->GetIntField(arg, ajf); - EventProxy *v = (EventProxy *)anum; - return v; -} - -/* - * pushes the EventProxy (*ep) into tje jobject in the PROXY_FLD location - */ -void putProxy(JNIEnv *env, jobject arg, EventProxy *ep) -{ - jclass argClass = env->GetObjectClass(arg); - jfieldID ajf = env->GetFieldID( argClass, PROXY_FLD, "I"); - jint anum = env->GetIntField(arg, ajf); - env->SetIntField(arg, ajf, (jint)ep); -} - - -/* - * Class: com_jacob_com_DispatchEvents - * Method: init3 - * Signature: (Lcom/jacob/com/Dispatch;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init3 - (JNIEnv *env, - jobject _this, jobject src, - jobject sink, - jstring _progid, - jstring _typelib) -{ - USES_CONVERSION; - - if (_typelib != NULL && _progid == NULL){ - // both are required if typelib exists - ThrowComFail(env,"TypeLib was specified but no program id was",-1); - return; - } - - BSTR typeLib = NULL; - if (_typelib != NULL){ - // why is this UTF instead of unicode? Then we could probably drop the A2W - const char *typelib = env->GetStringUTFChars(_typelib, NULL); - typeLib = A2W(typelib); - // should we call env->ReleaseStringUTFChars(,) to free the memory like we do everywhere lese? - - //printf("we have a type lib %ls\n",typeLib); - } - - // find progid if any - LPOLESTR bsProgId = NULL; - if (_progid!=NULL) { - // why is this UTF instead of unicode? Then we could probably drop the A2W - const char *progid = env->GetStringUTFChars(_progid, NULL); - bsProgId = A2W(progid); - // should we call env->ReleaseStringUTFChars(,) to free the memory like we do everywhere lese? - //printf("we have an applicaton %ls\n",bsProgId); - } - - // get the IDispatch for the source object - IDispatch *pDisp = extractDispatch(env, src); - CComQIPtr pUnk(pDisp); - // see if it implements connection points - CComQIPtr pCPC(pUnk); - if (!pCPC) - { - // no events, throw something - ThrowComFail(env, "Can't find IConnectionPointContainer", -1); - return; - } - - IID eventIID; - CComBSTR *mNames; - DISPID *mIDs; - int n_EventMethods; - if (_typelib == NULL){ - if (!GetEventIID(pUnk, &eventIID, &mNames, &mIDs, &n_EventMethods,bsProgId)) { - ThrowComFail(env, "Can't find event iid", -1); - return; - } - } else { - if (!GetEventIIDForTypeLib(typeLib, &eventIID, &mNames, &mIDs, &n_EventMethods,bsProgId)) { - ThrowComFail(env, "Can't find event iid for type lib", -1); - return; - } - } - - // hook up to the default source iid - CComPtr pCP; - HRESULT hr = pCPC->FindConnectionPoint(eventIID, &pCP); - if (SUCCEEDED(hr)) - { - EventProxy *ep = new EventProxy(env, sink, pCP, eventIID, mNames, mIDs, n_EventMethods); - // need to store ep on _this, in case it gets collected - putProxy(env, _this, ep); - } else { - ThrowComFail(env, "Can't FindConnectionPoint", hr); - } -} - -/* - * Class: DispatchEvents - * Method: release - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_release - (JNIEnv *env, jobject _this) -{ - EventProxy *ep = extractProxy(env, _this); - if (ep) { - // this is the line that blows up in IETest - ep->Release(); - putProxy(env, _this, NULL); - } -} - -/* - * I need a reverse map from the event interface's dispids to - * function names so that we can reflect them to java - */ -void -LoadNameCache(LPTYPEINFO pTypeInfo, LPTYPEATTR pta, - CComBSTR **mNames, DISPID **mIDs, int *nmeth) -{ - CComBSTR *names = NULL; - DISPID *ids = NULL; - int m_nCount; - - m_nCount = pta->cFuncs; - *nmeth = m_nCount; - names = m_nCount == 0 ? NULL : new CComBSTR[m_nCount]; - ids = m_nCount == 0 ? NULL : new DISPID[m_nCount]; - for (int i=0; iGetFuncDesc(i, &pfd))) - { - CComBSTR bstrName; - if (SUCCEEDED(pTypeInfo->GetDocumentation(pfd->memid, &bstrName, NULL, NULL, NULL))) - { - names[i].Attach(bstrName.Detach()); - ids[i] = pfd->memid; - /* - USES_CONVERSION; - printf("map:%d -> %s\n", ids[i], W2A((OLECHAR *)names[i])); - */ - } - pTypeInfo->ReleaseFuncDesc(pfd); - } - } - *mNames = names; - *mIDs = ids; -} - -#define IMPLTYPE_MASK \ - (IMPLTYPEFLAG_FDEFAULT | IMPLTYPEFLAG_FSOURCE | IMPLTYPEFLAG_FRESTRICTED) - -#define IMPLTYPE_DEFAULTSOURCE \ - (IMPLTYPEFLAG_FDEFAULT | IMPLTYPEFLAG_FSOURCE) - -BOOL GetEventIID(IUnknown *m_pObject, IID* piid, - CComBSTR **mNames, DISPID **mIDs, int *nmeth,LPOLESTR bsProgId) -{ - *piid = GUID_NULL; - ATLASSERT(m_pObject != NULL); - // I Always use IProvideClassInfo rather than IProvideClassInfo2 - // since I also need to create a mapping from dispid to name - LPPROVIDECLASSINFO pPCI = NULL; - LPTYPEINFO pClassInfo = NULL; - if (SUCCEEDED(m_pObject->QueryInterface(IID_IProvideClassInfo, (LPVOID*)&pPCI))) - { - //printf("got IProvideClassInfo\n"); - ATLASSERT(pPCI != NULL); - HRESULT hr = pPCI->GetClassInfo(&pClassInfo); - pPCI->Release(); - if (!SUCCEEDED(hr)) return false; - } - else if (getClassInfoFromProgId(bsProgId,&pClassInfo)) { - } - else { - printf("GetEventIID: couldn't get IProvideClassInfo\n"); - return false; - } - - return MapEventIIDs(piid, mNames, mIDs, nmeth, bsProgId, pClassInfo); -} - -BOOL MapEventIIDs(IID* piid, - CComBSTR **mNames, DISPID **mIDs, int *nmeth, LPOLESTR bsProgId, LPTYPEINFO pClassInfo) -{ - ATLASSERT(pClassInfo != NULL); - //printf("MapEventIIDs: got past ClassInfo assert\n"); - LPTYPEATTR pClassAttr; - if (SUCCEEDED(pClassInfo->GetTypeAttr(&pClassAttr))) - { - //printf("MapEventIIDs: got TypeAttr\n"); - ATLASSERT(pClassAttr != NULL); - ATLASSERT(pClassAttr->typekind == TKIND_COCLASS); - - // Search for typeinfo of the default events interface. - int nFlags; - HREFTYPE hRefType; - - //printf("MapEventIIDs: looking at %d class attribute impl types \n"); - for (unsigned int i = 0; i < pClassAttr->cImplTypes; i++) - { - if (SUCCEEDED(pClassInfo->GetImplTypeFlags(i, &nFlags)) && - ((nFlags & IMPLTYPE_MASK) == IMPLTYPE_DEFAULTSOURCE)) - { - // Found it. Now look at its attributes to get IID. - LPTYPEINFO pEventInfo = NULL; - if (SUCCEEDED(pClassInfo->GetRefTypeOfImplType(i, - &hRefType)) && - SUCCEEDED(pClassInfo->GetRefTypeInfo(hRefType, - &pEventInfo))) - { - ATLASSERT(pEventInfo != NULL); - LPTYPEATTR pEventAttr; - if (SUCCEEDED(pEventInfo->GetTypeAttr(&pEventAttr))) - { - ATLASSERT(pEventAttr != NULL); - - // create a mapping from dispid to string - LoadNameCache(pEventInfo, pEventAttr, - mNames, mIDs, nmeth); - - *piid = pEventAttr->guid; - pEventInfo->ReleaseTypeAttr(pEventAttr); - } - pEventInfo->Release(); - } - break; - } - } - pClassInfo->ReleaseTypeAttr(pClassAttr); - } - pClassInfo->Release(); - - return (!IsEqualIID(*piid, GUID_NULL)); -} - -BOOL getClassInfoFromProgId(LPOLESTR bsProgId,LPTYPEINFO *pClassInfo) -{ - USES_CONVERSION; - CLSID clsid; - GUID libid; - if (FAILED(CLSIDFromProgID(bsProgId, &clsid))) return false; - if (FAILED(StringFromCLSID(clsid,&bsProgId))) return false; - HKEY keySoftware, keyClasses, keyCLSID, keyXXXX, keyTypeLib; - DWORD dwType, dwCountData=50; - BYTE abData[50]; - LONG lVal; - lVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE"),0,KEY_READ,&keySoftware); - if (lVal==ERROR_SUCCESS) { - lVal = RegOpenKeyEx(keySoftware,_T("Classes"),0,KEY_READ,&keyClasses); - if (lVal==ERROR_SUCCESS) { - lVal = RegOpenKeyEx(keyClasses,_T("CLSID"),0,KEY_READ,&keyCLSID); - if (lVal==ERROR_SUCCESS) { - _TCHAR *tsProgId = W2T(bsProgId); - lVal = RegOpenKeyEx(keyCLSID,tsProgId,0,KEY_READ,&keyXXXX); - if (lVal==ERROR_SUCCESS) { - lVal = RegOpenKeyEx(keyXXXX,_T("TypeLib"),0,KEY_READ,&keyTypeLib); - if (lVal==ERROR_SUCCESS) { - lVal = RegQueryValueExA(keyTypeLib,NULL,NULL,&dwType,abData,&dwCountData); - RegCloseKey(keyTypeLib); - } - RegCloseKey(keyXXXX); - } - RegCloseKey(keyCLSID); - } - RegCloseKey(keyClasses); - } - RegCloseKey(keySoftware); - } - if (lVal!=ERROR_SUCCESS) return false; - BSTR bsLibId = A2BSTR((char*)abData); - if (FAILED(CLSIDFromString(bsLibId,&libid))) return false; - //Try loading from registry information. - ITypeLib* pITypeLib; - if (FAILED(LoadRegTypeLib(libid,1,0, LANG_NEUTRAL, &pITypeLib))) return false; - //Find ITypeInfo for coclass. - pITypeLib->GetTypeInfoOfGuid(clsid, pClassInfo); - pITypeLib->Release(); - return true; -} - -/* - * Get the class info from the progId using the given typeLib. - */ -BOOL getClassInfoFromProgIdTypeLib(BSTR typeLib, LPOLESTR bsProgId, LPTYPEINFO *pClassInfo) -{ - USES_CONVERSION; - CLSID clsid; - - if (FAILED(CLSIDFromProgID(bsProgId, &clsid))) return false; - if (FAILED(StringFromCLSID(clsid,&bsProgId))) return false; - - ITypeLib* pITypeLib; - if (FAILED(LoadTypeLib(typeLib, &pITypeLib))) return false; - - //Find ITypeInfo for coclass. - pITypeLib->GetTypeInfoOfGuid(clsid, pClassInfo); - pITypeLib->Release(); - return true; -} - -BOOL GetEventIIDForTypeLib(BSTR typeLib, IID* piid, - CComBSTR **mNames, DISPID **mIDs, int *nmeth,LPOLESTR bsProgId) -{ - LPTYPEINFO pClassInfo = NULL; - if(getClassInfoFromProgIdTypeLib(typeLib, bsProgId,&pClassInfo)) - { - if (pClassInfo == NULL){ - printf("we had a successful return but pClassInfo is null\n"); - } - return MapEventIIDs(piid, mNames, mIDs, nmeth, bsProgId, pClassInfo); - } - else - { - printf("GetEventIIDForTypeLib: couldn't get IProvideClassInfo\n"); - return false; - } -} - -} diff --git a/cpp/jacob/DispatchEvents.h b/cpp/jacob/DispatchEvents.h deleted file mode 100644 index 82289ec..0000000 --- a/cpp/jacob/DispatchEvents.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -/* Header for class DispatchEvents */ - -#ifndef _Included_DispatchEvents -#define _Included_DispatchEvents -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Class: com_jacob_com_DispatchEvents - * Method: init3 - * Signature: (Lcom/jacob/com/Dispatch;Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init3 - (JNIEnv *, jobject, jobject, jobject, jstring, jstring); - -/* - * Class: DispatchEvents - * Method: release - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_release - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif - - diff --git a/cpp/jacob/DispatchProxy.cpp b/cpp/jacob/DispatchProxy.cpp deleted file mode 100644 index eb2dd46..0000000 --- a/cpp/jacob/DispatchProxy.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "stdafx.h" -#include -#include "ComThread.h" -// Win32 support for Ole Automation -#include -#include -#include -#include -#include -#include "util.h" - -extern "C" -{ - -// extract a IStream from a jobject -IStream *extractStream(JNIEnv *env, jobject arg) -{ - jclass argClass = env->GetObjectClass(arg); - jfieldID ajf = env->GetFieldID( argClass, "m_pStream", "I"); - jint anum = env->GetIntField(arg, ajf); - IStream *v = (IStream *)anum; - return v; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_DispatchProxy_MarshalIntoStream - (JNIEnv *env, jobject _this, jobject disp) -{ - IDispatch *pIDispatch = extractDispatch(env, disp); - if (!pIDispatch) return; - IStream *ps; // this is the stream we will marshall into - HRESULT hr = CoMarshalInterThreadInterfaceInStream( - IID_IDispatch, pIDispatch, &ps); - if (!SUCCEEDED(hr)) - { - ThrowComFail(env, "Could not Marshal Dispatch into IStream", hr); - return; - } - // store the stream pointer on the object - jclass argClass = env->GetObjectClass(_this); - jfieldID ajf = env->GetFieldID( argClass, "m_pStream", "I"); - env->SetIntField(_this, ajf, (jint)ps); -} - -JNIEXPORT jobject JNICALL Java_com_jacob_com_DispatchProxy_MarshalFromStream - (JNIEnv *env, jobject _this) -{ - IStream *ps = extractStream(env, _this); - if (!ps) - { - ThrowComFail(env, "Could not get IStream from DispatchProxy", -1); - return NULL; - } - IDispatch *pD; - HRESULT hr = CoGetInterfaceAndReleaseStream(ps, IID_IDispatch, (void **)&pD); - // zero out the stream pointer on the object - // since the stream can only be read once - jclass argClass = env->GetObjectClass(_this); - jfieldID ajf = env->GetFieldID( argClass, "m_pStream", "I"); - env->SetIntField(_this, ajf, (unsigned int)0); - - if (!SUCCEEDED(hr)) - { - ThrowComFail(env, "Could not Marshal Dispatch from IStream", hr); - return NULL; - } - jclass autoClass = env->FindClass("com/jacob/com/Dispatch"); - jmethodID autoCons = env->GetMethodID(autoClass, "", "(I)V"); - // construct a Dispatch object to return - // I am copying the pointer to java - if (pD) pD->AddRef(); - jobject newAuto = env->NewObject(autoClass, autoCons, pD); - return newAuto; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_DispatchProxy_release - (JNIEnv *env, jobject _this) -{ - IStream *ps = extractStream(env, _this); - if (ps) { - ps->Release(); - jclass argClass = env->GetObjectClass(_this); - jfieldID ajf = env->GetFieldID( argClass, "m_pStream", "I"); - env->SetIntField(_this, ajf, (unsigned int)0); - } -} - -} diff --git a/cpp/jacob/DispatchProxy.h b/cpp/jacob/DispatchProxy.h deleted file mode 100644 index aeabf43..0000000 --- a/cpp/jacob/DispatchProxy.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -/* Header for class com_jacob_com_DispatchProxy */ - -#ifndef _Included_com_jacob_com_DispatchProxy -#define _Included_com_jacob_com_DispatchProxy -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_jacob_com_DispatchProxy - * Method: MarshalIntoStream - * Signature: (Lcom/jacob/com/Dispatch;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_DispatchProxy_MarshalIntoStream - (JNIEnv *, jobject, jobject); - -/* - * Class: com_jacob_com_DispatchProxy - * Method: MarshalFromStream - * Signature: ()Lcom/jacob/com/Dispatch; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_DispatchProxy_MarshalFromStream - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_DispatchProxy - * Method: release - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_DispatchProxy_release - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/jacob/EnumVariant.cpp b/cpp/jacob/EnumVariant.cpp deleted file mode 100644 index 7ff9727..0000000 --- a/cpp/jacob/EnumVariant.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "stdafx.h" -#include -#include "Dispatch.h" -// Win32 support for Ole Automation -#include -#include -#include -#include -#include -#include "util.h" - -/** - * An implementation of IEnumVariant based on code submitted by - * Thomas Hallgren (mailto:Thomas.Hallgren@eoncompany.com) - */ -extern "C" -{ - -// extract a IDispatch from a jobject -IEnumVARIANT* extractEnumVariant(JNIEnv* env, jobject arg) -{ - jfieldID FID_pIEnumVARIANT = 0; - jclass clazz = env->GetObjectClass(arg); - FID_pIEnumVARIANT = env->GetFieldID(clazz, "m_pIEnumVARIANT", "I"); - return (IEnumVARIANT*)env->GetIntField(arg, FID_pIEnumVARIANT); -} - -JNIEXPORT jint JNICALL -Java_com_jacob_com_EnumVariant_Next(JNIEnv* env, jobject _this, jobjectArray vars) -{ - IEnumVARIANT* self = extractEnumVariant(env, _this); - //printf("self=%x\n", self); - if(self == NULL) - return 0; - - ULONG count = (ULONG)env->GetArrayLength(vars); - if(count == 0) - return 0; - - VARIANT* sink = (VARIANT*)CoTaskMemAlloc(count * sizeof(VARIANT)); - ULONG fetchCount = 0; - - HRESULT hr = self->Next(count, sink, &fetchCount); - if(FAILED(hr)) - { - CoTaskMemFree(sink); - ThrowComFail(env, "IEnumVARIANT::Next", hr); - return 0; - } - - // prepare a new return value array - // - jclass clazz = env->FindClass("com/jacob/com/Variant"); - jmethodID ctor = env->GetMethodID(clazz, "", "()V"); - - for(ULONG idx = 0; idx < fetchCount; ++idx) - { - // construct a variant to return - // - jobject newVariant = env->NewObject(clazz, ctor); - VARIANT* v = extractVariant(env, newVariant); - VariantCopy(v, sink + idx); - env->SetObjectArrayElement(vars, idx, newVariant); - env->DeleteLocalRef(newVariant); - //Sourceforge-1674179 fix memory leak - // Variants received while iterating IEnumVARIANT must be cleared when no longer needed - // The variant has been copied so no longer needed - VariantClear(sink); - } - CoTaskMemFree(sink); - return (jint)fetchCount; -} - -JNIEXPORT void JNICALL -Java_com_jacob_com_EnumVariant_release(JNIEnv* env, jobject _this) -{ - IEnumVARIANT* self = extractEnumVariant(env, _this); - if(self != NULL) - { - self->Release(); - jfieldID FID_pIEnumVARIANT = 0; - jclass clazz = env->GetObjectClass(_this); - FID_pIEnumVARIANT = env->GetFieldID(clazz, "m_pIEnumVARIANT", "I"); - env->SetIntField(_this, FID_pIEnumVARIANT, (unsigned int)0); - } -} - -JNIEXPORT void JNICALL -Java_com_jacob_com_EnumVariant_Reset(JNIEnv* env, jobject _this) -{ - IEnumVARIANT* self = extractEnumVariant(env, _this); - if(self == NULL) - return; - - HRESULT hr = self->Reset(); - if(FAILED(hr)) - ThrowComFail(env, "IEnumVARIANT::Reset", hr); -} - -JNIEXPORT void JNICALL -Java_com_jacob_com_EnumVariant_Skip(JNIEnv* env, jobject _this, jint count) -{ - IEnumVARIANT* self = extractEnumVariant(env, _this); - if(self == NULL) - return; - - HRESULT hr = self->Skip((ULONG)count); - if(FAILED(hr)) - ThrowComFail(env, "IEnumVARIANT::Skip", hr); -} - -} diff --git a/cpp/jacob/EnumVariant.h b/cpp/jacob/EnumVariant.h deleted file mode 100644 index 3465aae..0000000 --- a/cpp/jacob/EnumVariant.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef _Included_EnumVariant -#define _Included_EnumVariant - -#include - -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_jacob_com_EnumVariant - * Method: Next - * Signature: ([Lcom/jacob/com/Variant;)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_EnumVariant_Next - (JNIEnv *, jobject, jobjectArray); - -/* - * Class: com_jacob_com_EnumVariant - * Method: Release - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_EnumVariant_release - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_EnumVariant - * Method: Reset - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_EnumVariant_Reset - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_EnumVariant - * Method: Skip - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_EnumVariant_Skip - (JNIEnv *, jobject, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/jacob/EventProxy.cpp b/cpp/jacob/EventProxy.cpp deleted file mode 100644 index 6cdfa59..0000000 --- a/cpp/jacob/EventProxy.cpp +++ /dev/null @@ -1,870 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "EventProxy.h" -#include "Variant.h" - -// hook myself up as a listener for delegate -EventProxy::EventProxy(JNIEnv *env, - jobject aSinkObj, - CComPtr pConn, - IID eid, - CComBSTR mName[], - DISPID mID[], - int mNum) : - // initialize some variables - m_cRef(0), pCP(pConn), - eventIID(eid), MethNum(mNum), MethName(mName), - MethID(mID) -{ - // keep a pointer to the sink - javaSinkObj = env->NewGlobalRef(aSinkObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - - // we need this to attach to the event invocation thread - env->GetJavaVM(&jvm); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - AddRef(); - Connect(env); -} - -void EventProxy::Connect(JNIEnv *env) { - HRESULT hr = pCP->Advise(this, &dwEventCookie); - if (SUCCEEDED(hr)) { - connected = 1; - } else { - connected = 0; - ThrowComFail(env, "Advise failed", hr); - } -} - -// unhook myself up as a listener and get rid of delegate -EventProxy::~EventProxy() -{ - JNIEnv *env; - Disconnect(); - jint vmConnectionStatus = JNI_EVERSION ; - jint attachReturnStatus = -1; // AttachCurrentThread return status.. negative numbers are failure return codes. - - // attach to the current running thread -- JDK 1.4 jni.h has two param cover for 3 param call - vmConnectionStatus = jvm->GetEnv((void **)&env, JNI_VERSION_1_2); - if ((env != NULL)&& env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - if (vmConnectionStatus == JNI_EDETACHED){ - //printf("Unhook: Attaching to current thread using JNI Version 1.2 (%d)\n",vmConnectionStatus); - JavaVMAttachArgs attachmentArgs; - attachmentArgs.version = JNI_VERSION_1_2; - attachmentArgs.name = NULL; - attachmentArgs.group = NULL; - attachReturnStatus = jvm->AttachCurrentThread((void **)&env, &attachmentArgs); - if ((env != NULL) && env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - } else { - // should really look for JNI_OK versus an error because it could have been JNI_EVERSION - // started method with thread hooked to VM so no need to attach again - //printf("Unhook: No need to attach because already attached %d\n",vmConnectionStatus); - } - - // we should always have an env by this point but lets be paranoid and check - if (env != NULL){ - env->DeleteGlobalRef(javaSinkObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - } - if (MethNum) { - delete [] MethName; - delete [] MethID; - } - // detach from thread only if we attached to it in this function - if (attachReturnStatus == 0){ - jvm->DetachCurrentThread(); - //printf("Unhook: Detached\n"); - } else { - //printf("Unhook: No need to detatch because attached prior to method\n"); - } - //fflush(stdout); -} - -void EventProxy::Disconnect() { - if (connected) { - pCP->Unadvise(dwEventCookie); - } -} - -// I only support the eventIID interface which was passed in -// by the DispatchEvent wrapper who looked it up as the -// source object's default source interface -STDMETHODIMP EventProxy::QueryInterface(REFIID rid, void **ppv) -{ - if (rid == IID_IUnknown || rid == eventIID || rid == IID_IDispatch) - { - *ppv = this; - AddRef(); - return S_OK; - } - return E_NOINTERFACE; -} - -// This should never get called - the event source fires events -// by dispid's, not by name -STDMETHODIMP EventProxy::GetIDsOfNames(REFIID riid, - OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgDispID) -{ - return E_UNEXPECTED; -} - -// The actual callback from the connection point arrives here -STDMETHODIMP EventProxy::Invoke(DISPID dispID, REFIID riid, - LCID lcid, unsigned short wFlags, DISPPARAMS *pDispParams, - VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) -{ - const char *eventMethodName = NULL; //Sourceforge report 1394001 - JNIEnv *env = NULL; - - // map dispID to jmethodID - for(int i=0;iAttachCurrentThread((void **)&env, &attachmentArgs); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - - if (!eventMethodName) - { - // could not find this signature in list - // printf("Invoke: didn't find method name for dispatch id %d\n",dispID); - // this probably leaves a native thread attached to the vm when we don't want it - ThrowComFail(env, "Event method received was not defined as part of callback interface", -1); - - // should we detatch before returning?? We probably never get here if we ThrowComFail() - // jvm->DetachCurrentThread(); - return S_OK; - } - - // find the class of the InvocationHandler - jclass javaSinkClass = env->GetObjectClass(javaSinkObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - //printf("Invoke: Got sink class\n"); - jmethodID invokeMethod; - invokeMethod = env->GetMethodID(javaSinkClass, "invoke", "(Ljava/lang/String;[Lcom/jacob/com/Variant;)Lcom/jacob/com/Variant;"); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - jstring eventMethodNameAsString = env->NewStringUTF(eventMethodName); - //printf("Invoke: Got method name\n"); - // now do what we need for the variant - jmethodID getVariantMethod = env->GetMethodID(javaSinkClass, "getVariant", "()Lcom/jacob/com/Variant;"); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - //printf("Invoke: Found way too getVariant\n"); - jobject aVariantObj = env->CallObjectMethod(javaSinkObj, getVariantMethod); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - //printf("Invoke: Made Variant\n"); - jclass variantClass = env->GetObjectClass(aVariantObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - - // create the variant parameter array - // how many params - int numVariantParams = pDispParams->cArgs; - // make an array of them - jobjectArray varr = env->NewObjectArray(numVariantParams, variantClass, 0); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - //printf("Invoke: Created Array\n"); - int i,j; - for(i=numVariantParams-1,j=0;i>=0;i--,j++) - { - // construct a java variant holder - jobject arg = env->CallObjectMethod(javaSinkObj, getVariantMethod); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - // get the empty variant from it - VARIANT *va = extractVariant(env, arg); - // copy the value - VariantCopy(va, &pDispParams->rgvarg[i]); - // put it in the array - env->SetObjectArrayElement(varr, j, arg); - env->DeleteLocalRef(arg); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - } - //printf("Invoke: Filled Array\n"); - // Set up the return value - jobject ret; - - ret = env->CallObjectMethod(javaSinkObj, invokeMethod, - eventMethodNameAsString, varr); - //printf("Invoke: Invoked callback\n"); - if (!env->ExceptionOccurred() && ret != NULL) { - VariantCopy(pVarResult, extractVariant(env,ret)); - } - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - // don't need the first variant we created to get the class - // SF 1689061 change not accepted but put in as comment for later reminder - //Java_com_jacob_com_Variant_release(env, aVariantObj); - env->DeleteLocalRef(aVariantObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - - // Begin code from Jiffie team that copies parameters back from java to COM - for(i=numVariantParams-1,j=0;i>=0;i--,j++) - { - jobject arg = env->GetObjectArrayElement(varr, j); - VARIANT *java = extractVariant(env, arg); - VARIANT *com = &pDispParams->rgvarg[i]; - convertJavaVariant(java, com); - // SF 1689061 change not accepted but put in as comment for later reminder - //Java_com_jacob_com_Variant_release(env, arg); - zeroVariant(env, arg); - env->DeleteLocalRef(arg); - } - // End code from Jiffie team that copies parameters back from java to COM - // detach from thread - //printf("Invoke: Detatching\n"); - jvm->DetachCurrentThread(); - //fflush(stdout); - return S_OK; - } - return E_NOINTERFACE; -} - -void EventProxy::convertJavaVariant(VARIANT *java, VARIANT *com) { - - switch (com->vt) - { - case VT_DISPATCH: - { - switch (java->vt) - { - case VT_DISPATCH: - { - V_DISPATCH(com) = V_DISPATCH(java); - break; - } - - case VT_DISPATCH | VT_BYREF: - { - V_DISPATCH(com) = *V_DISPATCHREF(java); - break; - } - } - break; - } - - case VT_DISPATCH | VT_BYREF: - { - switch (java->vt) - { - case VT_DISPATCH: - { - *V_DISPATCHREF(com) = V_DISPATCH(java); - break; - } - - case VT_DISPATCH | VT_BYREF: - { - *V_DISPATCHREF(com) = *V_DISPATCHREF(java); - break; - } - } - break; - } - - case VT_BOOL: - { - switch (java->vt) - { - case VT_BOOL: - { - V_BOOL(com) = V_BOOL(java); - break; - } - - case VT_BOOL | VT_BYREF: - { - V_BOOL(com) = *V_BOOLREF(java); - break; - } - } - break; - } - - case VT_BOOL | VT_BYREF: - { - switch (java->vt) - { - case VT_BOOL: - { - *V_BOOLREF(com) = V_BOOL(java); - break; - } - - case VT_BOOL | VT_BYREF: - { - *V_BOOLREF(com) = *V_BOOLREF(java); - break; - } - } - break; - } - - case VT_UI1: - { - switch (java->vt) - { - case VT_UI1: - { - V_UI1(com) = V_UI1(java); - break; - } - - case VT_UI1 | VT_BYREF: - { - V_UI1(com) = *V_UI1REF(java); - break; - } - } - break; - } - - case VT_UI1 | VT_BYREF: - { - switch (java->vt) - { - case VT_UI1: - { - *V_UI1REF(com) = V_UI1(java); - break; - } - - case VT_UI1 | VT_BYREF: - { - *V_UI1REF(com) = *V_UI1REF(java); - break; - } - } - break; - } - - - case VT_I2: - { - switch (java->vt) - { - case VT_I2: - { - V_I2(com) = V_I2(java); - break; - } - - case VT_I2 | VT_BYREF: - { - V_I2(com) = *V_I2REF(java); - break; - } - } - break; - } - - case VT_I2 | VT_BYREF: - { - switch (java->vt) - { - case VT_I2: - { - *V_I2REF(com) = V_I2(java); - break; - } - - case VT_I2 | VT_BYREF: - { - *V_I2REF(com) = *V_I2REF(java); - break; - } - } - break; - } - - case VT_I4: - { - switch (java->vt) - { - case VT_I4: - { - V_I4(com) = V_I4(java); - break; - } - - case VT_I4 | VT_BYREF: - { - V_I4(com) = *V_I4REF(java); - break; - } - } - break; - } - - case VT_I4 | VT_BYREF: - { - switch (java->vt) - { - case VT_I4: - { - *V_I4REF(com) = V_I4(java); - break; - } - - case VT_I4 | VT_BYREF: - { - *V_I4REF(com) = *V_I4REF(java); - break; - } - } - break; - } - - case VT_R4: - { - switch (java->vt) - { - case VT_R4: - { - V_R4(com) = V_R4(java); - break; - } - - case VT_R4 | VT_BYREF: - { - V_R4(com) = *V_R4REF(java); - break; - } - } - break; - } - - case VT_R4 | VT_BYREF: - { - switch (java->vt) - { - case VT_R4: - { - *V_R4REF(com) = V_R4(java); - break; - } - - case VT_R4 | VT_BYREF: - { - *V_R4REF(com) = *V_R4REF(java); - break; - } - } - break; - } - - case VT_R8: - { - switch (java->vt) - { - case VT_R8: - { - V_R8(com) = V_R8(java); - break; - } - - case VT_R8 | VT_BYREF: - { - V_R8(com) = *V_R8REF(java); - break; - } - } - break; - } - - case VT_R8 | VT_BYREF: - { - switch (java->vt) - { - case VT_R8: - { - *V_R8REF(com) = V_R8(java); - break; - } - - case VT_R8 | VT_BYREF: - { - *V_R8REF(com) = *V_R8REF(java); - break; - } - } - break; - } - - case VT_I1: - { - switch (java->vt) - { - case VT_I1: - { - V_I1(com) = V_I1(java); - break; - } - - case VT_I1 | VT_BYREF: - { - V_I1(com) = *V_I1REF(java); - break; - } - } - break; - } - - case VT_I1 | VT_BYREF: - { - switch (java->vt) - { - case VT_I1: - { - *V_I1REF(com) = V_I1(java); - break; - } - - case VT_I1 | VT_BYREF: - { - *V_I1REF(com) = *V_I1REF(java); - break; - } - } - break; - } - - case VT_UI2: - { - switch (java->vt) - { - case VT_UI2: - { - V_UI2(com) = V_UI2(java); - break; - } - - case VT_UI2 | VT_BYREF: - { - V_UI2(com) = *V_UI2REF(java); - break; - } - } - break; - } - - case VT_UI2 | VT_BYREF: - { - switch (java->vt) - { - case VT_UI2: - { - *V_UI2REF(com) = V_UI2(java); - break; - } - - case VT_UI2 | VT_BYREF: - { - *V_UI2REF(com) = *V_UI2REF(java); - break; - } - } - break; - } - - case VT_UI4: - { - switch (java->vt) - { - case VT_UI4: - { - V_UI4(com) = V_UI4(java); - break; - } - - case VT_UI4 | VT_BYREF: - { - V_UI4(com) = *V_UI4REF(java); - break; - } - } - break; - } - - case VT_UI4 | VT_BYREF: - { - switch (java->vt) - { - case VT_UI4: - { - *V_UI4REF(com) = V_UI4(java); - break; - } - - case VT_UI4 | VT_BYREF: - { - *V_UI4REF(com) = *V_UI4REF(java); - break; - } - } - break; - } - - case VT_INT: - { - switch (java->vt) - { - case VT_INT: - { - V_INT(com) = V_INT(java); - break; - } - - case VT_INT | VT_BYREF: - { - V_INT(com) = *V_INTREF(java); - break; - } - } - break; - } - - case VT_INT | VT_BYREF: - { - switch (java->vt) - { - case VT_INT: - { - *V_INTREF(com) = V_INT(java); - break; - } - - case VT_INT | VT_BYREF: - { - *V_INTREF(com) = *V_INTREF(java); - break; - } - } - break; - } - - case VT_UINT: - { - switch (java->vt) - { - case VT_UINT: - { - V_UINT(com) = V_UINT(java); - break; - } - - case VT_UINT | VT_BYREF: - { - V_UINT(com) = *V_UINTREF(java); - break; - } - } - break; - } - - case VT_UINT | VT_BYREF: - { - switch (java->vt) - { - case VT_UINT: - { - *V_UINTREF(com) = V_UINT(java); - break; - } - - case VT_UINT | VT_BYREF: - { - *V_UINTREF(com) = *V_UINTREF(java); - break; - } - } - break; - } - - case VT_CY: - { - switch (java->vt) - { - case VT_CY: - { - V_CY(com) = V_CY(java); - break; - } - - case VT_CY | VT_BYREF: - { - V_CY(com) = *V_CYREF(java); - break; - } - } - break; - } - - case VT_CY | VT_BYREF: - { - switch (java->vt) - { - case VT_CY: - { - *V_CYREF(com) = V_CY(java); - break; - } - - case VT_CY | VT_BYREF: - { - *V_CYREF(com) = *V_CYREF(java); - break; - } - } - break; - } - - case VT_DATE: - { - switch (java->vt) - { - case VT_DATE: - { - V_DATE(com) = V_DATE(java); - break; - } - - case VT_DATE | VT_BYREF: - { - V_DATE(com) = *V_DATEREF(java); - break; - } - } - break; - } - - case VT_DATE | VT_BYREF: - { - switch (java->vt) - { - case VT_DATE: - { - *V_DATEREF(com) = V_DATE(java); - break; - } - - case VT_DATE | VT_BYREF: - { - *V_DATEREF(com) = *V_DATEREF(java); - break; - } - } - break; - } - - case VT_BSTR: - { - switch (java->vt) - { - case VT_BSTR: - { - V_BSTR(com) = V_BSTR(java); - break; - } - - case VT_BSTR | VT_BYREF: - { - V_BSTR(com) = *V_BSTRREF(java); - break; - } - } - break; - } - - case VT_BSTR | VT_BYREF: - { - switch (java->vt) - { - case VT_BSTR: - { - *V_BSTRREF(com) = V_BSTR(java); - break; - } - - case VT_BSTR | VT_BYREF: - { - *V_BSTRREF(com) = *V_BSTRREF(java); - break; - } - } - break; - } - - case VT_DECIMAL: - { - switch (java->vt) - { - case VT_DECIMAL: - { - V_DECIMAL(com) = V_DECIMAL(java); - break; - } - - case VT_DECIMAL | VT_BYREF: - { - V_DECIMAL(com) = *V_DECIMALREF(java); - break; - } - } - break; - } - - case VT_DECIMAL | VT_BYREF: - { - switch (java->vt) - { - case VT_DECIMAL: - { - *V_DECIMALREF(com) = V_DECIMAL(java); - break; - } - - case VT_DECIMAL | VT_BYREF: - { - *V_DECIMALREF(com) = *V_DECIMALREF(java); - break; - } - } - break; - } - - - } -} diff --git a/cpp/jacob/EventProxy.h b/cpp/jacob/EventProxy.h deleted file mode 100644 index 903fcb1..0000000 --- a/cpp/jacob/EventProxy.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -#include -#include -#include -#include -#include "stdafx.h" -#include "util.h" - -/* - * An instance of this class stands between a connection point - * and a java object. When it gets invoked from the cp, it reflects - * the call into the java object dynamically. The eventIID is passed - * in as are the valid dispids and the corresponding names. A map - * is created between the dispids and the java object's method in - * the constructor. For now, all the java event methods have to have - * the same signature: (Variant[]) - */ -class EventProxy : public IDispatch -{ -private: - int connected; - LONG m_cRef; // a reference counter - CComPtr pCP; // the connection point - DWORD dwEventCookie; // connection point cookie - jobject javaSinkObj; // the java object to delegate calls - - IID eventIID; // the interface iid passed in - int MethNum; // number of methods in the callback interface - CComBSTR *MethName; // Array of method names - DISPID *MethID; // Array of method ids, used to match invokations to method names - JavaVM *jvm; // The java vm we are running - void convertJavaVariant(VARIANT *java, VARIANT *com); - void Connect(JNIEnv *env); - void Disconnect(); -public: - // constuct with a global JNI ref to a sink object - // to which we will delegate event callbacks - EventProxy(JNIEnv *jenv, - jobject aSinkObj, - CComPtr pConn, - IID eventIID, - CComBSTR *mName, - DISPID *mID, - int mNum); - ~EventProxy(); - - // IUnknown methods - STDMETHODIMP_(ULONG) AddRef(void) - { - LONG res = InterlockedIncrement(&m_cRef); - return res; - } - - STDMETHODIMP_(ULONG) Release(void) - { - LONG res = InterlockedDecrement(&m_cRef); - if (res == 0) { - delete this; - } - return res; - - } - - STDMETHODIMP QueryInterface(REFIID rid, void **ppv); - - // IDispatch methods - STDMETHODIMP GetTypeInfoCount(UINT *num) - { - *num = 0; - return S_OK; - } - - STDMETHODIMP GetTypeInfo(UINT, LCID, ITypeInfo **pptInfo) - { - *pptInfo=NULL; - return E_NOTIMPL; - } - - // These are the actual supported methods - STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID , DISPID *); - STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *); -}; diff --git a/cpp/jacob/STA.cpp b/cpp/jacob/STA.cpp deleted file mode 100644 index 2da50b5..0000000 --- a/cpp/jacob/STA.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "stdafx.h" -#include -#include "ComThread.h" -// Win32 support for Ole Automation -#include -#include -#include -#include -#include -#include "util.h" - -extern "C" -{ - -JNIEXPORT void JNICALL Java_com_jacob_com_STA_doMessagePump - (JNIEnv *env, jobject obj) -{ - // store the current thread id so we can kill it - jclass argClass = env->GetObjectClass(obj); - jfieldID ajf = env->GetFieldID( argClass, "threadID", "I"); - jint threadID = (jint)GetCurrentThreadId(); - env->SetIntField(obj, ajf, threadID); - - MSG msg; - - ZeroMemory(&msg, sizeof(msg)); - msg.wParam = S_OK; - - while (GetMessage(&msg, NULL, 0, 0)) - { - DispatchMessage(&msg); - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_STA_quitMessagePump - (JNIEnv *env, jobject obj) -{ - jclass argClass = env->GetObjectClass(obj); - jfieldID ajf = env->GetFieldID( argClass, "threadID", "I"); - jint threadID = env->GetIntField(obj, ajf); - PostThreadMessage((DWORD)threadID, WM_QUIT, 0, 0); -} - -} diff --git a/cpp/jacob/STA.h b/cpp/jacob/STA.h deleted file mode 100644 index b575849..0000000 --- a/cpp/jacob/STA.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -/* Header for class STA */ - -#ifndef _Included_com_jacob_com_STA -#define _Included_com_jacob_com_STA -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_jacob_com_STA - * Method: doMessagePump - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_STA_doMessagePump - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_STA - * Method: quitMessagePump - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_STA_quitMessagePump - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/jacob/SafeArray.cpp b/cpp/jacob/SafeArray.cpp deleted file mode 100644 index 21a5939..0000000 --- a/cpp/jacob/SafeArray.cpp +++ /dev/null @@ -1,3177 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "SafeArray.h" -// Win32 support for Ole Automation -#include -#include -#include -#include -#include -#include -#include "util.h" - -extern "C" -{ - -#define V_FLD "m_pV" - -static SAFEARRAY *makeArray(int vt, int nDims, long *lb, long *cel) -{ - if (nDims == 1) { - // no need to alloc - SAFEARRAYBOUND sab; - sab.lLbound = lb[0]; - sab.cElements = cel[0]; - SAFEARRAY *sa = SafeArrayCreate(vt,1,&sab); - return sa; - } else { - SAFEARRAYBOUND* rgsaBounds = new SAFEARRAYBOUND[nDims]; - for(int i=0;iGetObjectClass(arg); - jfieldID vf = env->GetFieldID( argClass, V_FLD, "I"); - jint vnum = env->GetIntField(arg, vf); - if (vnum != NULL) - { - // if vnum is not NULL, then there is a Variant wrapper present - VARIANT *v = (VARIANT *)vnum; - return v; - } - return NULL; -} - -// extract a SAFEARRAY from a SafeArray object -SAFEARRAY *extractSA(JNIEnv *env, jobject arg) -{ - VARIANT *v = extractWrapper(env, arg); - if (v != NULL) - { - SAFEARRAY *sa = V_ARRAY(v); - return sa; - } - return NULL; -} - -// deep copy a SAFEARRAY -SAFEARRAY *copySA(SAFEARRAY *psa) -{ - // easiest way to make a deep copy is to use VariantCopy - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - VARIANT v1, v2; - - VariantInit(&v1); - VariantInit(&v2); - V_VT(&v1) = VT_ARRAY | vt; - V_ARRAY(&v1) = psa; - VariantCopy(&v2, &v1); - SAFEARRAY *sa = V_ARRAY(&v2); - VariantInit(&v2); // make sure it's not owned by this variant - VariantClear(&v2); - VariantInit(&v1); - VariantClear(&v1); - - return sa; -} - -// create a VARIANT wrapper for the safearray -void setSA(JNIEnv *env, jobject arg, SAFEARRAY *sa, int copy) -{ - // construct a variant to hold the result - // the variant then owns the array - jclass argClass = env->GetObjectClass(arg); - jfieldID ajf = env->GetFieldID( argClass, V_FLD, "I"); - jint vnum = env->GetIntField(arg, ajf); - VARIANT *v = (VARIANT *)vnum; - if (v == NULL) - { - v = new VARIANT(); - VariantInit(v); - } - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - V_VT(v) = VT_ARRAY | vt; - V_ARRAY(v) = copy ? copySA(sa) : sa; - env->SetIntField(arg, ajf, (unsigned int)v); -} - -/* - * Class: SafeArray - * Method: init - * Signature: (I[I[I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_init - (JNIEnv *env, jobject _this, jint vt, jintArray lb, jintArray cel) -{ - jint *lbounds = env->GetIntArrayElements(lb, NULL); - jint *celems = env->GetIntArrayElements(cel, NULL); - int nDims = env->GetArrayLength(lb); - // array lengths must match - if (nDims != env->GetArrayLength(cel)) return; - // build the sa according to params - if ( nDims > 0 ) - { - SAFEARRAY *sa = makeArray(vt, nDims, lbounds, celems); - env->ReleaseIntArrayElements(lb, lbounds, 0); - env->ReleaseIntArrayElements(cel, celems, 0); - jclass clazz = env->GetObjectClass(_this); - setSA(env, _this, sa, 0); - } -} - -/* - * Class: SafeArray - * Method: clone - * Signature: ()Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_SafeArray_clone - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (psa) - { - // prepare a new return value - jclass saClass = env->GetObjectClass(_this); - jmethodID saCons = env->GetMethodID(saClass, "", "()V"); - // construct an SA to return - jobject newSA = env->NewObject(saClass, saCons); - // wrap in a Variant - setSA(env, newSA, psa, 1); - return newSA; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: destroy - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_destroy - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractWrapper(env, _this); - if (v) { - // this is the case where a Variant wrapper exists, in that - // case free the variant, but if there is just a raw SA, then - // the owning variant will free it - jclass saClass = env->GetObjectClass(_this); - jfieldID jf = env->GetFieldID(saClass, V_FLD, "I"); - VariantClear(v); - delete v; - env->SetIntField(_this, jf, (unsigned int)0); - } -} - -/* - * Class: SafeArray - * Method: getvt - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getvt - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (psa) { - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - return (jint)vt; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: reinit - * Signature: (LSafeArray;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_reinit - (JNIEnv *env, jobject _this, jobject sa) -{ - // what to do here? -} - -/* - * Class: SafeArray - * Method: reinterpretType - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_reinterpretType - (JNIEnv *env, jobject _this, jint vt) -{ -} - -/* - * Class: SafeArray - * Method: getLBound - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getLBound__ - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (psa) { - jint lb; - SafeArrayGetLBound(psa, 1, &lb); - return lb; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: getLBound - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getLBound__I - (JNIEnv *env, jobject _this, jint dim) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (psa) { - jint lb; - SafeArrayGetLBound(psa, dim, &lb); - return lb; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: getUBound - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getUBound__ - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (psa) { - jint lb; - SafeArrayGetUBound(psa, 1, &lb); - return lb; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: getUBound - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getUBound__I - (JNIEnv *env, jobject _this, jint dim) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (psa) { - jint lb; - SafeArrayGetUBound(psa, dim, &lb); - return lb; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: getNumDim - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getNumDim - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (psa) { - return SafeArrayGetDim(psa); - } - return NULL; -} - -/* - * Class: SafeArray - * Method: getFeatures - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getFeatures - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (psa) { - SafeArrayLock(psa); - jint features = psa->fFeatures; - SafeArrayUnlock(psa); - return features; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: getElemSize - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getElemSize - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (psa) { - jint siz = SafeArrayGetElemsize(psa); - return siz; - } - return NULL; -} - -static int numElements(SAFEARRAY *psa) -{ - int nDims = SafeArrayGetDim(psa); - int elems = 0; - for(int i=1;i<=nDims;i++) { - long lb, ub; - SafeArrayGetLBound(psa, i, &lb); - SafeArrayGetUBound(psa, i, &ub); - elems += ub - lb + 1; - } - return elems; -} - -/* - * Class: SafeArray - * Method: fromCharArray - * Signature: ([C)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromCharArray - (JNIEnv *env, jobject _this, jcharArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - // get the double array - don't make a copy - jchar *arrayElements = env->GetCharArrayElements(a, 0); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_UI2; - for(int i=0;iReleaseCharArrayElements(a, arrayElements, 0); -} - -/* - * Class: SafeArray - * Method: fromIntArray - * Signature: ([I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromIntArray - (JNIEnv *env, jobject _this, jintArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - // get the int array - don't make a copy - jint *arrayElements = env->GetIntArrayElements(a, 0); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_I4; - for(int i=0;iReleaseIntArrayElements(a, arrayElements, 0); -} - -/* - * Class: SafeArray - * Method: fromLongArray - * Signature: ([L)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromLongArray - (JNIEnv *env, jobject _this, jlongArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - // get the long array - don't make a copy - jlong *arrayElements = env->GetLongArrayElements(a, 0); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_I8; - for(int i=0;iReleaseLongArrayElements(a, arrayElements, 0); -} - -/* - * Class: SafeArray - * Method: fromShortArray - * Signature: ([S)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromShortArray - (JNIEnv *env, jobject _this, jshortArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - // get the short array - don't make a copy - jshort *arrayElements = env->GetShortArrayElements(a, 0); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_I2; - for(int i=0;iReleaseShortArrayElements(a, arrayElements, 0); -} - -/* - * Class: SafeArray - * Method: fromDoubleArray - * Signature: ([D)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromDoubleArray - (JNIEnv *env, jobject _this, jdoubleArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - // get the double array - don't make a copy - jdouble *arrayElements = env->GetDoubleArrayElements(a, 0); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_R8; - for(int i=0;iReleaseDoubleArrayElements(a, arrayElements, 0); -} - -/* - * Class: SafeArray - * Method: fromStringArray - * Signature: ([Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromStringArray - (JNIEnv *env, jobject _this, jobjectArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_BSTR; - for(int i=0;iGetObjectArrayElement(a, i); - // jacob report 1224219 should use unicode and not UTF-8 - // GetStringUTFChars() replaced with GetStringChars() - // (Variant modified in previous report) - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); // SR cast SF 1689061 - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = bs.Copy(); - long x = i; - SafeArrayPutElement(psa,&x,&v); - env->ReleaseStringChars(s, str); - VariantClear(&v); - } - } else if (vt == VT_BSTR) { - for(int i=0;iGetObjectArrayElement(a, i); - // jacob report 1224219 should use unicode and not UTF-8 - // GetStringUTFChars() replaced with GetStringChars() - // (Variant modified in previous report) - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); // SR cast SF 1689061 - BSTR bstr = bs.Detach(); - long x = i; - SafeArrayPutElement(psa,&x,bstr); - env->ReleaseStringChars(s, str); - } - } else { - ThrowComFail(env, "safearray cannot be assigned from string\n", 0); - } -} - -/* - * Class: SafeArray - * Method: fromByteArray - * Signature: ([B)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromByteArray - (JNIEnv *env, jobject _this, jbyteArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - // get the byte array - don't make a copy - jbyte *arrayElements = env->GetByteArrayElements(a, 0); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_UI1; - for(int i=0;iReleaseByteArrayElements(a, arrayElements, 0); -} - -/* - * Class: SafeArray - * Method: fromFloatArray - * Signature: ([F)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromFloatArray - (JNIEnv *env, jobject _this, jfloatArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - // get the float array - don't make a copy - jfloat *arrayElements = env->GetFloatArrayElements(a, 0); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_R4; - for(int i=0;iReleaseFloatArrayElements(a, arrayElements, 0); -} - -/* - * Class: SafeArray - * Method: fromBooleanArray - * Signature: ([Z)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromBooleanArray - (JNIEnv *env, jobject _this, jbooleanArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - // get the boolean array - don't make a copy - jboolean *arrayElements = env->GetBooleanArrayElements(a, 0); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_BOOL; - for(int i=0;iReleaseBooleanArrayElements(a, arrayElements, 0); -} - -/* - * Class: SafeArray - * Method: fromVariantArray - * Signature: ([LVariant;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromVariantArray - (JNIEnv *env, jobject _this, jobjectArray a) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(a); - if (len > numElements(psa)) - { - // max size of memcpy - len = numElements(psa); - } - if (vt == VT_VARIANT) { - for(int i=0;iGetObjectArrayElement(a, i); - VARIANT *v = extractVariant(env, var); - long x = i; - if (v) SafeArrayPutElement(psa,&x,v); - } - } else { - ThrowComFail(env, "safearray cannot be assigned from variant", -1); - } -} - -/* - * Class: SafeArray - * Method: toCharArray - * Signature: ()[C - */ -JNIEXPORT jcharArray JNICALL Java_com_jacob_com_SafeArray_toCharArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_UI2 || vt == VT_I2) { - jcharArray arrayElements = env->NewCharArray(num); - void *pData; - SafeArrayAccessData(sa, &pData); - env->SetCharArrayRegion(arrayElements, 0, num, (jchar *)pData); - SafeArrayUnaccessData(sa); - return arrayElements; - } else if (vt == VT_VARIANT) { - jcharArray arrayElements = env->NewCharArray(num); - VARIANT v; - VariantInit(&v); - for(int i=lb;i<=ub;i++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_UI2))) { - return NULL; - } - jchar val = V_UI2(&v); - env->SetCharArrayRegion(arrayElements, i, 1, &val); - } - return arrayElements; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: toIntArray - * Signature: ()[I - */ -JNIEXPORT jintArray JNICALL Java_com_jacob_com_SafeArray_toIntArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_I4) { - jintArray arrayElements = env->NewIntArray(num); - void *pData; - SafeArrayAccessData(sa, &pData); - env->SetIntArrayRegion(arrayElements, 0, num, (jint *)pData); - SafeArrayUnaccessData(sa); - return arrayElements; - } else if (vt == VT_VARIANT) { - jintArray arrayElements = env->NewIntArray(num); - VARIANT v; - VariantInit(&v); - for(int i=lb;i<=ub;i++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_I4))) { - return NULL; - } - jint val = V_I4(&v); - env->SetIntArrayRegion(arrayElements, i, 1, &val); - } - return arrayElements; - } - return NULL; -} - - -/* - * Class: SafeArray - * Method: toLongArray - * Signature: ()[L - */ -JNIEXPORT jlongArray JNICALL Java_com_jacob_com_SafeArray_toLongArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_I8) { - jlongArray arrayElements = env->NewLongArray(num); - void *pData; - SafeArrayAccessData(sa, &pData); - env->SetLongArrayRegion(arrayElements, 0, num, (jlong *)pData); - SafeArrayUnaccessData(sa); - return arrayElements; - } else if (vt == VT_VARIANT) { - jlongArray arrayElements = env->NewLongArray(num); - VARIANT v; - VariantInit(&v); - for(int i=lb;i<=ub;i++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_I8))) { - return NULL; - } - jlong val = V_I8(&v); - env->SetLongArrayRegion(arrayElements, i, 1, &val); - } - return arrayElements; - } - return NULL; -} - - -/* - * Class: SafeArray - * Method: toShortArray - * Signature: ()[S - */ -JNIEXPORT jshortArray JNICALL Java_com_jacob_com_SafeArray_toShortArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_I2) { - jshortArray arrayElements = env->NewShortArray(num); - void *pData; - SafeArrayAccessData(sa, &pData); - env->SetShortArrayRegion(arrayElements, 0, num, (jshort *)pData); - SafeArrayUnaccessData(sa); - return arrayElements; - } else if (vt == VT_VARIANT) { - jshortArray arrayElements = env->NewShortArray(num); - VARIANT v; - VariantInit(&v); - for(int i=lb;i<=ub;i++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_I2))) { - return NULL; - } - jshort val = V_I2(&v); - env->SetShortArrayRegion(arrayElements, i, 1, &val); - } - return arrayElements; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: toDoubleArray - * Signature: ()[D - */ -JNIEXPORT jdoubleArray JNICALL Java_com_jacob_com_SafeArray_toDoubleArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_R8) { - jdoubleArray arrayElements = env->NewDoubleArray(num); - void *pData; - SafeArrayAccessData(sa, &pData); - env->SetDoubleArrayRegion(arrayElements, 0, num, (jdouble *)pData); - SafeArrayUnaccessData(sa); - return arrayElements; - } else if (vt == VT_VARIANT) { - jdoubleArray arrayElements = env->NewDoubleArray(num); - VARIANT v; - VariantInit(&v); - for(int i=lb;i<=ub;i++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_R8))) { - return NULL; - } - jdouble val = V_R8(&v); - env->SetDoubleArrayRegion(arrayElements, i, 1, &val); - } - return arrayElements; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: toStringArray - * Signature: ()[Ljava/lang/String; - */ -JNIEXPORT jobjectArray JNICALL Java_com_jacob_com_SafeArray_toStringArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) - { - jclass sClass = env->FindClass("java/lang/String"); - jobjectArray arrayElements = env->NewObjectArray(num, sClass, NULL); - VARIANT v; - VariantInit(&v); - for(int i=lb;i<=ub;i++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_BSTR))) { - return NULL; - } - BSTR bs = V_BSTR(&v); - jstring js = env->NewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - env->SetObjectArrayElement(arrayElements, i, js); - } - return arrayElements; - } else if (vt == VT_BSTR) { - jclass sClass = env->FindClass("java/lang/String"); - jobjectArray arrayElements = env->NewObjectArray(num, sClass, NULL); - for(int i=lb;i<=ub;i++) { - BSTR bs = NULL; - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &bs); - jstring js = env->NewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - env->SetObjectArrayElement(arrayElements, i, js); - } - return arrayElements; - } - ThrowComFail(env, "safearray cannot be converted to string[]", 0); - return NULL; -} - -/* - * Class: SafeArray - * Method: toByteArray - * Signature: ()[B - */ -JNIEXPORT jbyteArray JNICALL Java_com_jacob_com_SafeArray_toByteArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_I1 || vt == VT_UI1) { - jbyteArray arrayElements = env->NewByteArray(num); - jbyte *pData; - SafeArrayAccessData(sa, (void **)&pData); - env->SetByteArrayRegion(arrayElements, 0, num, pData); - SafeArrayUnaccessData(sa); - return arrayElements; - } else if (vt == VT_VARIANT) { - jbyteArray arrayElements = env->NewByteArray(num); - VARIANT v; - VariantInit(&v); - for(int i=lb,j=0;i<=ub;i++,j++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_UI1))) { - return NULL; - } - jbyte val = V_UI1(&v); - env->SetByteArrayRegion(arrayElements, j, 1, &val); - } - return arrayElements; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: toFloatArray - * Signature: ()[F - */ -JNIEXPORT jfloatArray JNICALL Java_com_jacob_com_SafeArray_toFloatArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_R4) { - jfloatArray arrayElements = env->NewFloatArray(num); - void *pData; - SafeArrayAccessData(sa, &pData); - env->SetFloatArrayRegion(arrayElements, 0, num, (jfloat *)pData); - SafeArrayUnaccessData(sa); - return arrayElements; - } else if (vt == VT_VARIANT) { - jfloatArray arrayElements = env->NewFloatArray(num); - VARIANT v; - VariantInit(&v); - for(int i=lb;i<=ub;i++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_R4))) { - return NULL; - } - jfloat val = V_R4(&v); - env->SetFloatArrayRegion(arrayElements, i, 1, &val); - } - return arrayElements; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: toBooleanArray - * Signature: ()[Z - */ -JNIEXPORT jbooleanArray JNICALL Java_com_jacob_com_SafeArray_toBooleanArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_BOOL) { - // need to loop because jboolean=1 byte and VARIANT_BOOL=2 bytes - jbooleanArray arrayElements = env->NewBooleanArray(num); - VARIANT_BOOL v; - for(int i=lb,j=0;i<=ub;i++,j++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - jboolean val = v == VARIANT_TRUE ? JNI_TRUE : JNI_FALSE; - env->SetBooleanArrayRegion(arrayElements, j, 1, &val); - } - return arrayElements; - } else if (vt == VT_VARIANT) { - jbooleanArray arrayElements = env->NewBooleanArray(num); - VARIANT v; - VariantInit(&v); - for(int i=lb;i<=ub;i++) { - long ix = i; - SafeArrayGetElement(sa, &ix, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_BOOL))) { - return NULL; - } - jboolean val = V_BOOL(&v) == VARIANT_TRUE ? JNI_TRUE : JNI_FALSE; - env->SetBooleanArrayRegion(arrayElements, i, 1, &val); - } - return arrayElements; - } - return NULL; -} - -/* - * Class: SafeArray - * Method: toVariantArray - * Signature: ()[LVariant; - */ -JNIEXPORT jobjectArray JNICALL Java_com_jacob_com_SafeArray_toVariantArray - (JNIEnv *env, jobject _this) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - int num = ub - lb + 1; - jclass vClass = env->FindClass("com/jacob/com/Variant"); - // create an array of Variant's - jobjectArray varr = env->NewObjectArray(num, vClass, 0); - // fill them in - jmethodID variantCons = - env->GetMethodID(vClass, "", "()V"); - for(int i=lb;i<=ub;i++) { - long ix = i; - // construct a variant to return - jobject newVariant = env->NewObject(vClass, variantCons); - // get the VARIANT from the newVariant - VARIANT *v = extractVariant(env, newVariant); - SafeArrayGetElement(sa, &ix, (void*) v); - // put in object array - env->SetObjectArrayElement(varr, i, newVariant); - } - return varr; -} - -// this is an ugly way to avoid copy/pasting the same code - -// returns a value extracted from a 1 dimensional SafeArray -// uses the idx variable in the object this macro is included in -#define GET1DCODE(varType, varAccess, jtyp) \ - SAFEARRAY *sa = extractSA(env, _this); \ - if (!sa) { \ - ThrowComFail(env, "safearray object corrupted", -1); \ - return NULL; \ - } \ - if (SafeArrayGetDim(sa) != 1) { \ - ThrowComFail(env, "safearray is not 1D", -1); \ - return NULL; \ - } \ - VARTYPE vt; \ - SafeArrayGetVartype(sa, &vt); \ - if (vt == VT_VARIANT) { \ - VARIANT v; \ - VariantInit(&v); \ - SafeArrayGetElement(sa, &idx, (void*) &v); \ - if (FAILED(VariantChangeType(&v, &v, 0, varType))) { \ - ThrowComFail(env, "VariantChangeType failed", -1); \ - return NULL; \ - } \ - return (jtyp)varAccess(&v); \ - } else if (vt == varType) { \ - jtyp jc; \ - SafeArrayGetElement(sa, &idx, (void*) &jc); \ - return jc; \ - } else { \ - return NULL; \ - } - -// returns a value extracted from a 2 dimensional SafeArray -// uses i and j from the method that this macro is included in as indexes -#define GET2DCODE(varType, varAccess, jtyp) \ - SAFEARRAY *sa = extractSA(env, _this); \ - if (!sa) { \ - ThrowComFail(env, "safearray object corrupted", -1); \ - return NULL; \ - } \ - if (SafeArrayGetDim(sa) != 2) { \ - ThrowComFail(env, "safearray is not 2D", -1); \ - return NULL; \ - } \ - long idx[2] = {i, j}; \ - VARTYPE vt; \ - SafeArrayGetVartype(sa, &vt); \ - if (vt == VT_VARIANT) { \ - VARIANT v; \ - VariantInit(&v); \ - SafeArrayGetElement(sa, idx, (void*) &v); \ - if (FAILED(VariantChangeType(&v, &v, 0, varType))) { \ - ThrowComFail(env, "VariantChangeType failed", -1); \ - return NULL; \ - } \ - return (jtyp)varAccess(&v); \ - } else if (vt == varType) { \ - jtyp jc; \ - SafeArrayGetElement(sa, idx, (void*) &jc); \ - return jc; \ - } else { \ - return NULL; \ - } - - -// sets the values on a one dimensional array -#define SET1DCODE(varType, varAccess) \ - SAFEARRAY *sa = extractSA(env, _this); \ - if (!sa) { \ - ThrowComFail(env, "safearray object corrupted", -1); \ - return; \ - } \ - if (SafeArrayGetDim(sa) != 1) { \ - ThrowComFail(env, "safearray is not 1D", -1); \ - return; \ - } \ - VARTYPE vt; \ - SafeArrayGetVartype(sa, &vt); \ - if (vt == VT_VARIANT) { \ - VARIANT v; \ - VariantInit(&v); \ - V_VT(&v) = varType; \ - varAccess(&v) = c; \ - SafeArrayPutElement(sa,&idx,&v); \ - } else if (vt == varType) { \ - SafeArrayPutElement(sa,&idx,&c); \ - } else { \ - ThrowComFail(env, "safearray type mismatch", -1); \ - } \ - -// sets the values into a 2 dimensional array -#define SET2DCODE(varType, varAccess) \ - SAFEARRAY *sa = extractSA(env, _this); \ - if (!sa) { \ - ThrowComFail(env, "safearray object corrupted", -1); \ - return; \ - } \ - if (SafeArrayGetDim(sa) != 2) { \ - ThrowComFail(env, "safearray is not 2D", -1); \ - return; \ - } \ - VARTYPE vt; \ - SafeArrayGetVartype(sa, &vt); \ - long idx[2] = {i,j}; \ - if (vt == VT_VARIANT) { \ - VARIANT v; \ - VariantInit(&v); \ - V_VT(&v) = varType; \ - varAccess(&v) = c; \ - SafeArrayPutElement(sa,idx,&v); \ - } else if (vt == varType) { \ - SafeArrayPutElement(sa,idx,&c); \ - } else { \ - ThrowComFail(env, "safearray type mismatch", -1); \ - } - -#define GETARRAYCODE(varType, varType2, varAccess, jtyp, jsetArr) \ - SAFEARRAY *sa = extractSA(env, _this); \ - if (!sa) { \ - ThrowComFail(env, "safearray object corrupted", -1); \ - return; \ - } \ - VARTYPE vt; \ - SafeArrayGetVartype(sa, &vt); \ - if (vt == varType || vt == varType2) { \ - jtyp *pData; \ - SafeArrayAccessData(sa, (void **)&pData); \ - env->jsetArr(ja, ja_start, nelem, &pData[idx]); \ - SafeArrayUnaccessData(sa); \ - return; \ - } else if (vt == VT_VARIANT) { \ - VARIANT v; \ - VariantInit(&v); \ - for(int i=idx, j=ja_start;ijsetArr(ja, j, 1, &val); \ - } \ - } - -#define SETARRAYCODE(varType, varType2, varAccess, jtyp, jgetArr, jrelArr) \ - SAFEARRAY *psa = extractSA(env, _this); \ - if (!psa) { \ - ThrowComFail(env, "safearray object corrupted", -1); \ - return; \ - } \ - VARTYPE vt; \ - SafeArrayGetVartype(psa, &vt); \ - jtyp *arrayElements = env->jgetArr(ja, 0); \ - if (vt == VT_VARIANT) { \ - VARIANT v; \ - VariantInit(&v); \ - V_VT(&v) = varType; \ - for(int i=ja_start,j=idx;ijrelArr(ja, arrayElements, 0); - -/* - * Class: SafeArray - * Method: getChar - * Signature: (I)C - */ -JNIEXPORT jchar JNICALL Java_com_jacob_com_SafeArray_getChar__I - (JNIEnv *env, jobject _this, jint idx) -{ - GET1DCODE(VT_UI2, V_UI2, jchar) -} - -/* - * Class: SafeArray - * Method: getChar - * Signature: (II)C - */ -JNIEXPORT jchar JNICALL Java_com_jacob_com_SafeArray_getChar__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - GET2DCODE(VT_UI2, V_UI2, jchar) -} - - -/* - * Class: SafeArray - * Method: setChar - * Signature: (IC)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setChar__IC - (JNIEnv *env, jobject _this, jint idx, jchar c) -{ - SET1DCODE(VT_UI2, V_UI2); -} - -/* - * Class: SafeArray - * Method: setChar - * Signature: (IIC)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setChar__IIC - (JNIEnv *env, jobject _this, jint i, jint j, jchar c) -{ - SET2DCODE(VT_UI2, V_UI2); -} - -/* - * Class: SafeArray - * Method: getChars - * Signature: (II[CI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getChars - (JNIEnv *env, jobject _this, jint idx, jint nelem, jcharArray ja, jint ja_start) -{ - GETARRAYCODE(VT_UI2, VT_I2, V_UI2, jchar, SetCharArrayRegion); -} - -/* - * Class: SafeArray - * Method: setChars - * Signature: (II[CI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setChars - (JNIEnv *env, jobject _this, jint idx, jint nelem, jcharArray ja, jint ja_start) -{ - SETARRAYCODE(VT_UI2, VT_I2, V_UI2, jchar, - GetCharArrayElements, ReleaseCharArrayElements); -} - -/*----------------------- INTS ----------------------------------*/ - -/* - * Class: SafeArray - * Method: getInt - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getInt__I - (JNIEnv *env, jobject _this, jint idx) -{ - GET1DCODE(VT_I4, V_I4, jint) -} - -/* - * Class: SafeArray - * Method: getInt - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getInt__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - GET2DCODE(VT_I4, V_I4, jint) -} - -/* - * Class: SafeArray - * Method: setInt - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setInt__II - (JNIEnv *env, jobject _this, jint idx, jint c) -{ - SET1DCODE(VT_I4, V_I4); -} - -/* - * Class: SafeArray - * Method: setInt - * Signature: (III)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setInt__III - (JNIEnv *env, jobject _this, jint i, jint j, jint c) -{ - SET2DCODE(VT_I4, V_I4); -} - -/* - * Class: SafeArray - * Method: getInts - * Signature: (II[II)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getInts - (JNIEnv *env, jobject _this, jint idx, jint nelem, jintArray ja, jint ja_start) -{ - GETARRAYCODE(VT_I4, VT_I4, V_I4, jint, SetIntArrayRegion); -} - -/* - * Class: SafeArray - * Method: setInts - * Signature: (II[II)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setInts - (JNIEnv *env, jobject _this, jint idx, jint nelem, jintArray ja, jint ja_start) -{ - SETARRAYCODE(VT_I4, VT_I4, V_I4, jint, - GetIntArrayElements, ReleaseIntArrayElements); -} - -/*----------------------- END INTS ----------------------------------*/ -/*----------------------- LONGS ----------------------------------*/ - -/* - * Class: SafeArray - * Method: getLong - * Signature: (I)J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_SafeArray_getLong__I - (JNIEnv *env, jobject _this, jint idx) -{ - GET1DCODE(VT_I8, V_I8, jlong) -} - -/* - * Class: SafeArray - * Method: getLong - * Signature: (II)J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_SafeArray_getLong__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - GET2DCODE(VT_I8, V_I8, jlong) -} - -/* - * Class: SafeArray - * Method: setLong - * Signature: (IJ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setLong__IJ - (JNIEnv *env, jobject _this, jint idx, jlong c) -{ - SET1DCODE(VT_I8, V_I8); -} - -/* - * Class: SafeArray - * Method: setLong - * Signature: (IIJ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setLong__IIJ - (JNIEnv *env, jobject _this, jint i, jint j, jlong c) -{ - SET2DCODE(VT_I8, V_I8); -} - -/* - * Class: SafeArray - * Method: getLongs - * Signature: (II[JI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getLongs - (JNIEnv *env, jobject _this, jint idx, jint nelem, jlongArray ja, jint ja_start) -{ - GETARRAYCODE(VT_I8, VT_I8, V_I8, jlong, SetLongArrayRegion); -} - -/* - * Class: SafeArray - * Method: setLongs - * Signature: (II[JI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setLongs - (JNIEnv *env, jobject _this, jint idx, jint nelem, jlongArray ja, jint ja_start) -{ - SETARRAYCODE(VT_I8, VT_I8, V_I8, jlong, - GetLongArrayElements, ReleaseLongArrayElements); -} - -/*------------------------ END LONGS -----------------------------*/ - - -/* - * Class: SafeArray - * Method: getShort - * Signature: (I)S - */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_SafeArray_getShort__I - (JNIEnv *env, jobject _this, jint idx) -{ - GET1DCODE(VT_I2, V_I2, jshort) -} - -/* - * Class: SafeArray - * Method: getShort - * Signature: (II)S - */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_SafeArray_getShort__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - GET2DCODE(VT_I2, V_I2, jshort) -} - -/* - * Class: SafeArray - * Method: setShort - * Signature: (IS)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setShort__IS - (JNIEnv *env, jobject _this, jint idx, jshort c) -{ - SET1DCODE(VT_I2, V_I2); -} - -/* - * Class: SafeArray - * Method: setShort - * Signature: (IIS)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setShort__IIS - (JNIEnv *env, jobject _this, jint i, jint j, jshort c) -{ - SET2DCODE(VT_I2, V_I2); -} - -/* - * Class: SafeArray - * Method: getShorts - * Signature: (II[SI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getShorts - (JNIEnv *env, jobject _this, jint idx, jint nelem, jshortArray ja, jint ja_start) -{ - GETARRAYCODE(VT_I2, VT_I2, V_I2, jshort, SetShortArrayRegion); -} - -/* - * Class: SafeArray - * Method: setShorts - * Signature: (II[SI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setShorts - (JNIEnv *env, jobject _this, jint idx, jint nelem, jshortArray ja, jint ja_start) -{ - SETARRAYCODE(VT_I2, VT_I2, V_I2, jshort, - GetShortArrayElements, ReleaseShortArrayElements); -} - -/* - * Class: SafeArray - * Method: getDouble - * Signature: (I)D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_SafeArray_getDouble__I - (JNIEnv *env, jobject _this, jint idx) -{ - GET1DCODE(VT_R8, V_R8, jdouble) -} - -/* - * Class: SafeArray - * Method: getDouble - * Signature: (II)D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_SafeArray_getDouble__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - GET2DCODE(VT_R8, V_R8, jdouble) -} - -/* - * Class: SafeArray - * Method: setDouble - * Signature: (ID)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setDouble__ID - (JNIEnv *env, jobject _this, jint idx, jdouble c) -{ - SET1DCODE(VT_R8, V_R8); -} - -/* - * Class: SafeArray - * Method: setDouble - * Signature: (IID)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setDouble__IID - (JNIEnv *env, jobject _this, jint i, jint j, jdouble c) -{ - SET2DCODE(VT_R8, V_R8); -} - -/* - * Class: SafeArray - * Method: getDoubles - * Signature: (II[DI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getDoubles - (JNIEnv *env, jobject _this, jint idx, jint nelem, jdoubleArray ja, jint ja_start) -{ - GETARRAYCODE(VT_R8, VT_R8, V_R8, jdouble, SetDoubleArrayRegion); -} - -/* - * Class: SafeArray - * Method: setDoubles - * Signature: (II[DI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setDoubles - (JNIEnv *env, jobject _this, jint idx, jint nelem, jdoubleArray ja, jint ja_start) -{ - SETARRAYCODE(VT_R8, VT_R8, V_R8, jdouble, - GetDoubleArrayElements, ReleaseDoubleArrayElements); -} - -/* - * Class: SafeArray - * Method: getString - * Signature: (I)Ljava/lang/String; - * - * There is supposed to be a leak in here, SourceForge 1224219 - * that should be fixed with a call to - * "StrFree, Release or VariantClear to release the memory" - * waiting on the actual patch the submitter used before modifying this - */ -JNIEXPORT jstring JNICALL Java_com_jacob_com_SafeArray_getString__I - (JNIEnv *env, jobject _this, jint idx) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); \ - return NULL; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - SafeArrayGetElement(psa, &idx, &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_BSTR))) { - return NULL; - } - BSTR bs = V_BSTR(&v); - jstring js = env->NewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - // jacob report 1224219 - // SafeArrayGetElement memory must be freed http://www.canaimasoft.com/f90VB/OnlineManuals/Reference/TH_31.htm - VariantClear(&v); - return js; - } else if (vt == VT_BSTR) { - BSTR bs = NULL; - SafeArrayGetElement(psa, &idx, &bs); - jstring js = env->NewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - // jacob report 1224219 - // SafeArrayGetElement memory must be freed http://www.canaimasoft.com/f90VB/OnlineManuals/Reference/TH_31.htm - if (bs) SysFreeString(bs); - return js; - } - ThrowComFail(env, "safearray cannot get string", 0); - return NULL; -} - -/* - * Class: SafeArray - * Method: getString - * Signature: (II)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_jacob_com_SafeArray_getString__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); \ - return NULL; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - long idx[2] = {i, j}; - SafeArrayGetElement(psa, idx, &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_BSTR))) { - return NULL; - } - BSTR bs = V_BSTR(&v); - jstring js = env->NewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - return js; - } else if (vt == VT_BSTR) { - long idx[2] = {i, j}; - BSTR bs = NULL; - SafeArrayGetElement(psa, idx, &bs); - jstring js = env->NewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - return js; - } - ThrowComFail(env, "safearray cannot get string", 0); - return NULL; -} - -/* - * Class: SafeArray - * Method: setString - * Signature: (ILjava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setString__ILjava_lang_String_2 - (JNIEnv *env, jobject _this, jint idx, jstring s) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); \ - return; - } - if (SafeArrayGetDim(sa) != 1) { - ThrowComFail(env, "safearray not 1D", -1); \ - return; - } - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = bs.Copy(); - SafeArrayPutElement(sa,&idx,&v); \ - env->ReleaseStringChars(s, str); - VariantClear(&v); - } else if (vt == VT_BSTR) { - // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); - SafeArrayPutElement(sa,&idx,bs.Detach()); - env->ReleaseStringChars(s, str); - } else { - ThrowComFail(env, "safearray cannot set string", 0); - } -} - -/* - * Class: SafeArray - * Method: setString - * Signature: (IILjava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setString__IILjava_lang_String_2 - (JNIEnv *env, jobject _this, jint i, jint j, jstring s) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - if (SafeArrayGetDim(sa) != 2) { - ThrowComFail(env, "safearray is not 2D", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = bs.Copy(); - long idx[2] = {i,j}; - SafeArrayPutElement(sa,idx,&v); - env->ReleaseStringChars(s, str); - VariantClear(&v); - } else if (vt == VT_BSTR) { - long idx[2] = {i,j}; - // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); - SafeArrayPutElement(sa,idx,bs.Detach()); - env->ReleaseStringChars(s, str); - } else { - ThrowComFail(env, "safearray cannot set string", 0); - } -} - -/* - * Class: SafeArray - * Method: getStrings - * Signature: (II[Ljava/lang/String;I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getStrings - (JNIEnv *env, jobject _this, jint idx, jint nelem, jobjectArray ja, jint ja_start) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) - { - VARIANT v; - for(int i=idx, j=ja_start;iNewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - env->SetObjectArrayElement(ja, j, js); - VariantClear(&v); - } - } - else if (vt == VT_BSTR) - { - BSTR bs = NULL; - for(int i=idx, j=ja_start;iNewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - env->SetObjectArrayElement(ja, j, js); - } - } else { - ThrowComFail(env, "safearray cannot get strings", 0); - } -} - -/* - * Class: SafeArray - * Method: setStrings - * Signature: (II[Ljava/lang/String;I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setStrings - (JNIEnv *env, jobject _this, jint idx, jint nelem, jobjectArray ja, jint ja_start) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(ja); - if (len > numElements(psa)) - { - len = numElements(psa); - } - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - for(int i=ja_start,j=idx;iGetObjectArrayElement(ja, i); - // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = bs.Copy(); - long x = j; - SafeArrayPutElement(psa,&x,&v); - VariantClear(&v); - env->ReleaseStringChars(s, str); - } - } else if (vt == VT_BSTR) { - for(int i=ja_start,j=idx;iGetObjectArrayElement(ja, i); - // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); - long x = j; - SafeArrayPutElement(psa,&x,bs.Detach()); - env->ReleaseStringChars(s, str); - } - } else { - ThrowComFail(env, "safearray cannot set strings", 0); - } -} - -/* - * Class: SafeArray - * Method: getByte - * Signature: (I)B - */ -JNIEXPORT jbyte JNICALL Java_com_jacob_com_SafeArray_getByte__I - (JNIEnv *env, jobject _this, jint idx) -{ - GET1DCODE(VT_UI1, V_UI1, jbyte) -} - -/* - * Class: SafeArray - * Method: getByte - * Signature: (II)B - */ -JNIEXPORT jbyte JNICALL Java_com_jacob_com_SafeArray_getByte__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - GET2DCODE(VT_UI1, V_UI1, jbyte) -} - -/* - * Class: SafeArray - * Method: setByte - * Signature: (IB)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setByte__IB - (JNIEnv *env, jobject _this, jint idx, jbyte c) -{ - SET1DCODE(VT_UI1, V_UI1); -} - -/* - * Class: SafeArray - * Method: setByte - * Signature: (IIB)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setByte__IIB - (JNIEnv *env, jobject _this, jint i, jint j, jbyte c) -{ - SET2DCODE(VT_UI1, V_UI1); -} - -/* - * Class: SafeArray - * Method: getBytes - * Signature: (II[BI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getBytes - (JNIEnv *env, jobject _this, jint idx, jint nelem, jbyteArray ja, jint ja_start) -{ - GETARRAYCODE(VT_UI1, VT_I1, V_UI1, jbyte, SetByteArrayRegion); -} - -/* - * Class: SafeArray - * Method: setBytes - * Signature: (II[BI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBytes - (JNIEnv *env, jobject _this, jint idx, jint nelem, jbyteArray ja, jint ja_start) -{ - SETARRAYCODE(VT_UI1, VT_I1, V_UI1, jbyte, - GetByteArrayElements, ReleaseByteArrayElements); -} - -/* - * Class: SafeArray - * Method: getFloat - * Signature: (I)F - */ -JNIEXPORT jfloat JNICALL Java_com_jacob_com_SafeArray_getFloat__I - (JNIEnv *env, jobject _this, jint idx) -{ - GET1DCODE(VT_R4, V_R4, jfloat) -} - -/* - * Class: SafeArray - * Method: getFloat - * Signature: (II)F - */ -JNIEXPORT jfloat JNICALL Java_com_jacob_com_SafeArray_getFloat__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - GET2DCODE(VT_R4, V_R4, jfloat) -} - -/* - * Class: SafeArray - * Method: setFloat - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setFloat__IF - (JNIEnv *env, jobject _this, jint idx, jfloat c) -{ - SET1DCODE(VT_R4, V_R4); -} - -/* - * Class: SafeArray - * Method: setFloat - * Signature: (IIF)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setFloat__IIF - (JNIEnv *env, jobject _this, jint i, jint j, jfloat c) -{ - SET2DCODE(VT_R4, V_R4); -} - -/* - * Class: SafeArray - * Method: getFloats - * Signature: (II[FI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getFloats - (JNIEnv *env, jobject _this, jint idx, jint nelem, jfloatArray ja, jint ja_start) -{ - GETARRAYCODE(VT_R4, VT_R4, V_R4, jfloat, SetFloatArrayRegion); -} - -/* - * Class: SafeArray - * Method: setFloats - * Signature: (II[FI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setFloats - (JNIEnv *env, jobject _this, jint idx, jint nelem, jfloatArray ja, jint ja_start) -{ - SETARRAYCODE(VT_R4, VT_R4, V_R4, jfloat, - GetFloatArrayElements, ReleaseFloatArrayElements); -} - -/* - * Class: SafeArray - * Method: getBoolean - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_SafeArray_getBoolean__I - (JNIEnv *env, jobject _this, jint idx) -{ - // code is inline because of size mismatch - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - if (SafeArrayGetDim(sa) != 1) { - ThrowComFail(env, "safearray not 1D", -1); \ - return NULL; - } - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - SafeArrayGetElement(sa, &idx, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_BOOL))) { - ThrowComFail(env, "safearray change type failed", -1); \ - return NULL; - } - jboolean jb = V_BOOL(&v) == VARIANT_TRUE ? JNI_TRUE: JNI_FALSE; - return jb; - } else if (vt == VT_BOOL) { - VARIANT_BOOL vb; - SafeArrayGetElement(sa, &idx, (void*) &vb); - jboolean jb = vb == VARIANT_TRUE ? JNI_TRUE: JNI_FALSE; - return jb; - } else { - return NULL; - } -} - -/* - * Class: SafeArray - * Method: getBoolean - * Signature: (II)Z - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_SafeArray_getBoolean__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - // code is inline because of size mismatch - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - if (SafeArrayGetDim(sa) != 2) { - ThrowComFail(env, "safearray is not 2D", -1); - return NULL; - } - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - long idx[2] = {i,j}; - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - SafeArrayGetElement(sa, idx, (void*) &v); - if (FAILED(VariantChangeType(&v, &v, 0, VT_BOOL))) { - ThrowComFail(env, "safearray change type failed", -1); - return NULL; - } - jboolean jb = V_BOOL(&v) == VARIANT_TRUE ? JNI_TRUE: JNI_FALSE; - return jb; - } else if (vt == VT_BOOL) { - VARIANT_BOOL vb; - SafeArrayGetElement(sa, idx, (void*) &vb); - jboolean jb = vb == VARIANT_TRUE ? JNI_TRUE: JNI_FALSE; - return jb; - } else { - return NULL; - } -} - -/* - * Class: SafeArray - * Method: setBoolean - * Signature: (IZ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBoolean__IZ - (JNIEnv *env, jobject _this, jint idx, jboolean c) -{ - // code is inline because of size mismatch - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - if (SafeArrayGetDim(sa) != 1) { - ThrowComFail(env, "safearray is not 1D", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_BOOL; - V_BOOL(&v) = c == JNI_TRUE ? VARIANT_TRUE : VARIANT_FALSE; - SafeArrayPutElement(sa,&idx,&v); - } else if (vt == VT_BOOL) { - VARIANT_BOOL vb = c == JNI_TRUE ? VARIANT_TRUE : VARIANT_FALSE; - SafeArrayPutElement(sa,&idx,&vb); - } else { - ThrowComFail(env, "safearray type mismatch", -1); - } -} - -/* - * Class: SafeArray - * Method: setBoolean - * Signature: (IIZ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBoolean__IIZ - (JNIEnv *env, jobject _this, jint i, jint j, jboolean c) -{ - // code is inline because of size mismatch - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - if (SafeArrayGetDim(sa) != 2) { - ThrowComFail(env, "safearray is not 2D", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - long idx[2] = {i,j}; - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_BOOL; - V_BOOL(&v) = c == JNI_TRUE ? VARIANT_TRUE : VARIANT_FALSE; - SafeArrayPutElement(sa,idx,&v); - } else if (vt == VT_BOOL) { - VARIANT_BOOL vb = c == JNI_TRUE ? VARIANT_TRUE : VARIANT_FALSE; - SafeArrayPutElement(sa,idx,&vb); - } else { - ThrowComFail(env, "safearray type mismatch", -1); - } -} - -/* - * Class: SafeArray - * Method: getBooleans - * Signature: (II[ZI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getBooleans - (JNIEnv *env, jobject _this, jint idx, jint nelem, jbooleanArray ja, jint ja_start) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_BOOL) { - VARIANT_BOOL v; - for(int i=idx, j=ja_start;iSetBooleanArrayRegion(ja, j, 1, &val); - } - } else if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - for(int i=idx, j=ja_start;iSetBooleanArrayRegion(ja, j, 1, &val); - } - } -} - -/* - * Class: SafeArray - * Method: setBooleans - * Signature: (II[ZI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBooleans - (JNIEnv *env, jobject _this, jint idx, jint nelem, jbooleanArray ja, jint ja_start) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(ja); - if (len > numElements(psa)) - { - len = numElements(psa); - } - jboolean *arrayElements = env->GetBooleanArrayElements(ja, 0); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_BOOL; - for(int i=ja_start,j=idx;iReleaseBooleanArrayElements(ja, arrayElements, 0); -} - -/* - * Class: SafeArray - * Method: getVariant - * Signature: (I)LVariant; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_SafeArray_getVariant__I - (JNIEnv *env, jobject _this, jint idx) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - // prepare a new return value - jclass variantClass = env->FindClass("com/jacob/com/Variant"); - jmethodID variantCons = - env->GetMethodID(variantClass, "", "()V"); - // construct a variant to return - jobject newVariant = env->NewObject(variantClass, variantCons); - // get the VARIANT from the newVariant - VARIANT *v = extractVariant(env, newVariant); - if (vt == VT_VARIANT) { - SafeArrayGetElement(psa, &idx, v); - } else if (vt == VT_DISPATCH || vt == VT_UNKNOWN) { - IDispatch *disp; - SafeArrayGetElement(psa, &idx, (void *)&disp); - VariantClear(v); // whatever was there before - V_VT(v) = VT_DISPATCH; - V_DISPATCH(v) = disp; - // I am handing the pointer to COM - disp->AddRef(); - } else { - ThrowComFail(env, "safearray type is not variant/dispatch", -1); - } - return newVariant; -} - -/* - * Class: SafeArray - * Method: getVariant - * Signature: (II)LVariant; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_SafeArray_getVariant__II - (JNIEnv *env, jobject _this, jint i, jint j) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - // prepare a new return value - jclass variantClass = env->FindClass("com/jacob/com/Variant"); - jmethodID variantCons = - env->GetMethodID(variantClass, "", "()V"); - // construct a variant to return - jobject newVariant = env->NewObject(variantClass, variantCons); - // get the VARIANT from the newVariant - VARIANT *v = extractVariant(env, newVariant); - long idx[2] = {i,j}; - if (vt == VT_VARIANT) { - SafeArrayGetElement(psa, idx, v); - } else if (vt == VT_DISPATCH || vt == VT_UNKNOWN) { - IDispatch *disp; - SafeArrayGetElement(psa, idx, (void *)&disp); - VariantClear(v); // whatever was there before - V_VT(v) = VT_DISPATCH; - V_DISPATCH(v) = disp; - // I am handing the pointer to COM - disp->AddRef(); - } else { - ThrowComFail(env, "safearray type is not variant/dispatch", -1); - } - return newVariant; -} - -/* - * Class: SafeArray - * Method: setVariant - * Signature: (ILVariant;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariant__ILcom_jacob_com_Variant_2 - (JNIEnv *env, jobject _this, jint idx, jobject s) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - if (SafeArrayGetDim(sa) != 1) { - ThrowComFail(env, "safearray is not 1D", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - VARIANT *v = extractVariant(env, s); - if (vt == VT_VARIANT) { - SafeArrayPutElement(sa,&idx,v); - } else if (vt == VT_DISPATCH || vt == VT_UNKNOWN) { - if (V_VT(v) != VT_DISPATCH) { - ThrowComFail(env, "variant is not dispatch", -1); - return; - } - IDispatch *disp = V_DISPATCH(v); - disp->AddRef(); - SafeArrayPutElement(sa,&idx,disp); - } else { - ThrowComFail(env, "safearray type is not variant/dispatch", -1); - } -} - -/* - * Class: SafeArray - * Method: setVariant - * Signature: (IILVariant;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariant__IILcom_jacob_com_Variant_2 - (JNIEnv *env, jobject _this, jint i, jint j, jobject s) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - if (SafeArrayGetDim(sa) != 2) { - ThrowComFail(env, "safearray is not 2D", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - long idx[2] = {i, j}; - if (vt == VT_VARIANT) { - VARIANT *v = extractVariant(env, s); - SafeArrayPutElement(sa,idx,v); - } else if (vt == VT_DISPATCH || vt == VT_UNKNOWN) { - VARIANT *v = extractVariant(env, s); - if (V_VT(v) != VT_DISPATCH) { - ThrowComFail(env, "variant is not dispatch", -1); - return; - } - IDispatch *disp = V_DISPATCH(v); - SafeArrayPutElement(sa,idx,disp); - } else { - ThrowComFail(env, "safearray type is not variant/dispatch", -1); - } -} - -/* - * Class: SafeArray - * Method: getVariants - * Signature: (II[LVariant;I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getVariants - (JNIEnv *env, jobject _this, jint idx, jint nelem, jobjectArray ja, jint ja_start) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - long lb, ub; - SafeArrayGetLBound(sa, 1, &lb); - SafeArrayGetUBound(sa, 1, &ub); - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) - { - jclass variantClass = env->FindClass("com/jacob/com/Variant"); - jmethodID variantCons = - env->GetMethodID(variantClass, "", "()V"); - for(int i=idx, j=ja_start;iNewObject(variantClass, variantCons); - // get the VARIANT from the newVariant - VARIANT *v = extractVariant(env, newVariant); - SafeArrayGetElement(sa, &ix, (void*) v); - env->SetObjectArrayElement(ja, j, newVariant); - } - } else { - ThrowComFail(env, "safearray type is not variant", -1); - } -} - -/* - * Class: SafeArray - * Method: setVariants - * Signature: (II[LVariant;I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariants - (JNIEnv *env, jobject _this, jint idx, jint nelem, jobjectArray ja, jint ja_start) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - int len = env->GetArrayLength(ja); - if (len > numElements(psa)) - { - len = numElements(psa); - } - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - for(int i=ja_start,j=idx;iGetObjectArrayElement(ja, i); - VARIANT *v = extractVariant(env, var); - long x = j; - SafeArrayPutElement(psa,&x,v); - } - } else { - ThrowComFail(env, "safearray type is not variant", -1); - } -} - -/* PLEASE NOTE THE LINE: - jint *jIndices = env->GetIntArrayElements(indices, NULL); - which I added to replace "long idx[2] = {i,j};" from the 2D case. - Not sure if this is correct. Also, check that I am doing the null test and - dimension test correctly. - Would really like to call env->ReleaseIntArrayElements(indices, jIndices, NULL); - in here but I can't get it to work -*/ - -#define GETNDCODE(varType, varAccess, jtyp) \ - SAFEARRAY *sa = extractSA(env, _this); \ - if (!sa) { \ - ThrowComFail(env, "safearray object corrupted", -1); \ - return NULL; \ - } \ - jint *jIndices = env->GetIntArrayElements(indices, NULL); \ - if (!jIndices) { \ - ThrowComFail(env, "null indices array", -1); \ - return NULL; \ - } \ - if (SafeArrayGetDim(sa) != env->GetArrayLength(indices)) { \ - ThrowComFail(env, "safearray and indices array have different dimensions", -1); \ - return NULL; \ - } \ - VARTYPE vt; \ - SafeArrayGetVartype(sa, &vt); \ - if (vt == VT_VARIANT) { \ - VARIANT v; \ - VariantInit(&v); \ - SafeArrayGetElement(sa, jIndices, (void*) &v); \ - if (FAILED(VariantChangeType(&v, &v, 0, varType))) { \ - ThrowComFail(env, "VariantChangeType failed", -1); \ - return NULL; \ - } \ - return (jtyp)varAccess(&v); \ - } else if (vt == varType) { \ - jtyp jc; \ - SafeArrayGetElement(sa, jIndices, (void*) &jc); \ - return jc; \ - } else { \ - return NULL; \ - } - - -//--------------------------------- - -/* PLEASE NOTE THE LINE: - jint *jIndices = env->GetIntArrayElements(indices, NULL); - which I added to replace "long idx[2] = {i,j};" from the 2D case. - Not sure if this is correct. Also, check that I am doing the null test and - dimension test correctly. - Would really like to call env->ReleaseIntArrayElements(indices, jIndices, NULL); - in here but I can't get it to work - */ - -#define SETNDCODE(varType, varAccess) \ - SAFEARRAY *sa = extractSA(env, _this); \ - if (!sa) { \ - ThrowComFail(env, "safearray object corrupted", -1); \ - return; \ - } \ - jint *jIndices = env->GetIntArrayElements(indices, NULL); \ - if (!jIndices) { \ - ThrowComFail(env, "null indices array", -1); \ - return; \ - } \ - if (SafeArrayGetDim(sa) != env->GetArrayLength(indices)) { \ - ThrowComFail(env, "safearray and indices array have different dimensions", -1); \ - return; \ - } \ - VARTYPE vt; \ - SafeArrayGetVartype(sa, &vt); \ - if (vt == VT_VARIANT) { \ - VARIANT v; \ - VariantInit(&v); \ - V_VT(&v) = varType; \ - varAccess(&v) = c; \ - SafeArrayPutElement(sa,jIndices,&v); \ - } else if (vt == varType) { \ - SafeArrayPutElement(sa, jIndices,&c); \ - } else { \ - ThrowComFail(env, "safearray type mismatch", -1); \ - } - -/* - * Class: com_jacob_com_SafeArray - * Method: getVariant - * Signature: ([I)Lcom/jacob/com/Variant; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_SafeArray_getVariant___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - - // ??? Not sure if this is correct type for call to SafeArrayGetElement() - jint *jIndices = env->GetIntArrayElements(indices, NULL); - - if (!jIndices) { - ThrowComFail(env, "null indices array", -1); - return NULL; - } - if (SafeArrayGetDim(psa) != env->GetArrayLength(indices)) { - ThrowComFail(env, "safearray and indices array have different dimensions", -1); - return NULL; - } - - - // prepare a new return value - jclass variantClass = env->FindClass("com/jacob/com/Variant"); - jmethodID variantCons = - env->GetMethodID(variantClass, "", "()V"); - // construct a variant to return - jobject newVariant = env->NewObject(variantClass, variantCons); - // get the VARIANT from the newVariant - VARIANT *v = extractVariant(env, newVariant); - if (vt == VT_VARIANT) { - SafeArrayGetElement(psa, jIndices, v); - } else if (vt == VT_DISPATCH || vt == VT_UNKNOWN) { - IDispatch *disp; - SafeArrayGetElement(psa, jIndices, (void *)&disp); - VariantClear(v); // whatever was there before - V_VT(v) = VT_DISPATCH; - V_DISPATCH(v) = disp; - // I am handing the pointer to COM - disp->AddRef(); - } else { - ThrowComFail(env, "safearray type is not variant/dispatch", -1); - } - env->ReleaseIntArrayElements(indices, jIndices, NULL); - return newVariant; -} - -/* - * Class: com_jacob_com_SafeArray - * Method: setVariant - * Signature: ([ILcom/jacob/com/Variant;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariant___3ILcom_jacob_com_Variant_2 - (JNIEnv *env, jobject _this, jintArray indices, jobject s) -{ - - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - - // ??? Not sure if this is correct type for call to SafeArrayGetElement() - jint *jIndices = env->GetIntArrayElements(indices, NULL); - - if (!jIndices) { - ThrowComFail(env, "null indices array", -1); - return; - } - if (SafeArrayGetDim(sa) != env->GetArrayLength(indices)) { - ThrowComFail(env, "safearray and indices array have different dimensions", -1); - return; - } - - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - - if (vt == VT_VARIANT) { - VARIANT *v = extractVariant(env, s); - SafeArrayPutElement(sa, jIndices, v); - } else if (vt == VT_DISPATCH || vt == VT_UNKNOWN) { - VARIANT *v = extractVariant(env, s); - if (V_VT(v) != VT_DISPATCH) { - ThrowComFail(env, "variant is not dispatch", -1); - return; - } - IDispatch *disp = V_DISPATCH(v); - SafeArrayPutElement(sa, jIndices, disp); - } else { - ThrowComFail(env, "safearray type is not variant/dispatch", -1); - } - env->ReleaseIntArrayElements(indices, jIndices, NULL); -} - -/* - * Class: com_jacob_com_SafeArray - * Method: getChar - * Signature: ([I)C - */ -JNIEXPORT jchar JNICALL Java_com_jacob_com_SafeArray_getChar___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - GETNDCODE(VT_UI2, V_UI2, jchar) -} - -/* - * Class: com_jacob_com_SafeArray - * Method: setChar - * Signature: ([IC)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setChar___3IC - (JNIEnv *env, jobject _this, jintArray indices, jchar c) -{ - SETNDCODE(VT_UI2, V_UI2); -} - -/*----------------------- INTS ----------------------------------*/ - -/* - * Class: com_jacob_com_SafeArray - * Method: getInt - * Signature: ([I)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getInt___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - GETNDCODE(VT_I4, V_I4, jint) -} - - -/* - * Class: com_jacob_com_SafeArray - * Method: setInt - * Signature: ([II)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setInt___3II - (JNIEnv *env, jobject _this, jintArray indices, jint c) -{ - SETNDCODE(VT_I4, V_I4); -} - -/*----------------------- END INTS ----------------------------------*/ -/*----------------------- LONGS ----------------------------------*/ - -/* - * Class: com_jacob_com_SafeArray - * Method: getLong - * Signature: ([I)J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_SafeArray_getLong___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - GETNDCODE(VT_I8, V_I8, jlong) -} - - -/* - * Class: com_jacob_com_SafeArray - * Method: setLong - * Signature: ([IJ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setLong___3IJ - (JNIEnv *env, jobject _this, jintArray indices, jlong c) -{ - SETNDCODE(VT_I8, V_I8); -} - -/*----------------------- END LONGS ----------------------------------*/ - -/* - * Class: com_jacob_com_SafeArray - * Method: getShort - * Signature: ([I)S - */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_SafeArray_getShort___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - GETNDCODE(VT_I2, V_I2, jshort) -} - -/* - * Class: com_jacob_com_SafeArray - * Method: setShort - * Signature: ([IS)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setShort___3IS - (JNIEnv *env, jobject _this, jintArray indices, jshort c) -{ - SETNDCODE(VT_I2, V_I2); -} - -/* - * Class: com_jacob_com_SafeArray - * Method: getDouble - * Signature: ([I)D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_SafeArray_getDouble___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - GETNDCODE(VT_R8, V_R8, jdouble) -} - -/* - * Class: com_jacob_com_SafeArray - * Method: setDouble - * Signature: ([ID)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setDouble___3ID - (JNIEnv *env, jobject _this, jintArray indices, jdouble c) -{ - SETNDCODE(VT_R8, V_R8); -} - -/* - * Class: com_jacob_com_SafeArray - * Method: getString - * Signature: ([I)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_jacob_com_SafeArray_getString___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - SAFEARRAY *psa = extractSA(env, _this); - if (!psa) { - ThrowComFail(env, "safearray object corrupted", -1); \ - return NULL; - } - - // ??? Not sure if this is correct type for call to SafeArrayGetElement() - jint *jIndices = env->GetIntArrayElements(indices, NULL); - - if (!jIndices) { - ThrowComFail(env, "null indices array", -1); - return NULL; - } - if (SafeArrayGetDim(psa) != env->GetArrayLength(indices)) { - ThrowComFail(env, "safearray and indices array have different dimensions", -1); - return NULL; - } - - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - SafeArrayGetElement(psa, jIndices, &v); - env->ReleaseIntArrayElements(indices, jIndices, NULL); - if (FAILED(VariantChangeType(&v, &v, 0, VT_BSTR))) { - return NULL; - } - BSTR bs = V_BSTR(&v); - jstring js = env->NewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - return js; - } else if (vt == VT_BSTR) { - BSTR bs = NULL; - SafeArrayGetElement(psa, jIndices, &bs); - env->ReleaseIntArrayElements(indices, jIndices, NULL); - jstring js = env->NewString((jchar*)bs, SysStringLen(bs)); // SR cast SF 1689061 - return js; - } else { - ThrowComFail(env, "safearray cannot get string", 0); - env->ReleaseIntArrayElements(indices, jIndices, NULL); - return NULL; - } -} - - -/* - * Class: com_jacob_com_SafeArray - * Method: setStringjIndices, NULL);ILjava/lang/String;)V - * - * This method has a leak in it somewhere. - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setString___3ILjava_lang_String_2 - (JNIEnv *env, jobject _this, jintArray indices, jstring s) -{ - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - - // ??? Not sure if this is correct type for call to SafeArrayGetElement() - // could have individually retrieved the indicies - jint *jIndices = env->GetIntArrayElements(indices, NULL); - - if (!jIndices) { - ThrowComFail(env, "null indices array", -1); - return; - } - if (SafeArrayGetDim(sa) != env->GetArrayLength(indices)) { - ThrowComFail(env, "safearray and indices array have different dimensions", -1); - return; - } - - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = bs.Copy(); - SafeArrayPutElement(sa, jIndices,&v); - env->ReleaseStringChars(s, str); - VariantClear(&v); - } else if (vt == VT_BSTR) { - // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() - const jchar *str = env->GetStringChars(s, NULL); - CComBSTR bs((LPCOLESTR)str); - SafeArrayPutElement(sa, jIndices,bs.Detach()); - env->ReleaseStringChars(s, str); - } else { - ThrowComFail(env, "safearray cannot set string", 0); - } - // need to unpin the copied array SF: 1775889 - env->ReleaseIntArrayElements(indices, jIndices, NULL); -} - -/* - * Class: com_jacob_com_SafeArray - * Method: getByte - * Signature: ([I)B - */ -JNIEXPORT jbyte JNICALL Java_com_jacob_com_SafeArray_getByte___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - GETNDCODE(VT_UI1, V_UI1, jbyte) -} - -/* - * Class: com_jacob_com_SafeArray - * Method: setByte - * Signature: ([IB)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setByte___3IB - (JNIEnv *env, jobject _this, jintArray indices, jbyte c) -{ - SETNDCODE(VT_UI1, V_UI1); -} - -/* - * Class: com_jacob_com_SafeArray - * Method: getFloat - * Signature: ([I)F - */ -JNIEXPORT jfloat JNICALL Java_com_jacob_com_SafeArray_getFloat___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - GETNDCODE(VT_R4, V_R4, jfloat) -} - - -/* - * Class: com_jacob_com_SafeArray - * Method: setFloat - * Signature: ([IF)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setFloat___3IF - (JNIEnv *env, jobject _this, jintArray indices, jfloat c) -{ - SETNDCODE(VT_R4, V_R4); -} - -/* - * Class: com_jacob_com_SafeArray - * Method: getBoolean - * Signature: ([I)Z - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_SafeArray_getBoolean___3I - (JNIEnv *env, jobject _this, jintArray indices) -{ - // code is inline because of size mismatch - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return NULL; - } - // ??? Not sure if this is correct type for call to SafeArrayGetElement() - jint *jIndices = env->GetIntArrayElements(indices, NULL); - - if (!jIndices) { - ThrowComFail(env, "null indices array", -1); - return NULL; - } - if (SafeArrayGetDim(sa) != env->GetArrayLength(indices)) { - ThrowComFail(env, "safearray and indices array have different dimensions", -1); - return NULL; - } - - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - SafeArrayGetElement(sa, jIndices, (void*) &v); - env->ReleaseIntArrayElements(indices, jIndices, NULL); - if (FAILED(VariantChangeType(&v, &v, 0, VT_BOOL))) { - ThrowComFail(env, "safearray change type failed", -1); - return NULL; - } - jboolean jb = V_BOOL(&v) == VARIANT_TRUE ? JNI_TRUE: JNI_FALSE; - return jb; - } else if (vt == VT_BOOL) { - VARIANT_BOOL vb; - SafeArrayGetElement(sa, jIndices, (void*) &vb); - env->ReleaseIntArrayElements(indices, jIndices, NULL); - jboolean jb = vb == VARIANT_TRUE ? JNI_TRUE: JNI_FALSE; - return jb; - } else { - env->ReleaseIntArrayElements(indices, jIndices, NULL); - return NULL; - } -} - -/* - * Class: com_jacob_com_SafeArray - * Method: setBoolean - * Signature: ([IZ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBoolean___3IZ - (JNIEnv *env, jobject _this, jintArray indices, jboolean c) -{ - // code is inline because of size mismatch - SAFEARRAY *sa = extractSA(env, _this); - if (!sa) { - ThrowComFail(env, "safearray object corrupted", -1); - return; - } - // ??? Not sure if this is correct type for call to SafeArrayGetElement() - jint *jIndices = env->GetIntArrayElements(indices, NULL); - - if (!jIndices) { - ThrowComFail(env, "null indices array", -1); - return; - } - if (SafeArrayGetDim(sa) != env->GetArrayLength(indices)) { - ThrowComFail(env, "safearray and indices array have different dimensions", -1); - return; - } - - VARTYPE vt; - SafeArrayGetVartype(sa, &vt); - if (vt == VT_VARIANT) { - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_BOOL; - V_BOOL(&v) = c == JNI_TRUE ? VARIANT_TRUE : VARIANT_FALSE; - SafeArrayPutElement(sa,jIndices,&v); - } else if (vt == VT_BOOL) { - VARIANT_BOOL vb = c == JNI_TRUE ? VARIANT_TRUE : VARIANT_FALSE; - SafeArrayPutElement(sa,jIndices,&vb); - } else { - ThrowComFail(env, "safearray type mismatch", -1); - } - env->ReleaseIntArrayElements(indices, jIndices, NULL); -} - - -} diff --git a/cpp/jacob/SafeArray.h b/cpp/jacob/SafeArray.h deleted file mode 100644 index 8695d56..0000000 --- a/cpp/jacob/SafeArray.h +++ /dev/null @@ -1,940 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -/* Header for class com_jacob_com_SafeArray */ - -#ifndef _Included_com_jacob_com_SafeArray -#define _Included_com_jacob_com_SafeArray -#ifdef __cplusplus -extern "C" { -#endif -/* Inaccessible static: buildVersion */ -/* Inaccessible static: buildDate */ -/* Inaccessible static: DEBUG */ -/* Inaccessible static: class_00024com_00024jacob_00024com_00024JacobObject */ -/* - * Class: com_jacob_com_SafeArray - * Method: init - * Signature: (I[I[I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_init - (JNIEnv *, jobject, jint, jintArray, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: clone - * Signature: ()Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_SafeArray_clone - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: destroy - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_destroy - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: getvt - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getvt - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: reinit - * Signature: (Lcom/jacob/com/SafeArray;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_reinit - (JNIEnv *, jobject, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: reinterpretType - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_reinterpretType - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getLBound - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getLBound__ - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: getLBound - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getLBound__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getUBound - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getUBound__ - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: getUBound - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getUBound__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getNumDim - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getNumDim - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: getFeatures - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getFeatures - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: getElemSize - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getElemSize - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromCharArray - * Signature: ([C)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromCharArray - (JNIEnv *, jobject, jcharArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromIntArray - * Signature: ([I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromIntArray - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromLongArray - * Signature: ([L)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromLongArray - (JNIEnv *, jobject, jlongArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromShortArray - * Signature: ([S)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromShortArray - (JNIEnv *, jobject, jshortArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromDoubleArray - * Signature: ([D)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromDoubleArray - (JNIEnv *, jobject, jdoubleArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromStringArray - * Signature: ([Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromStringArray - (JNIEnv *, jobject, jobjectArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromByteArray - * Signature: ([B)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromByteArray - (JNIEnv *, jobject, jbyteArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromFloatArray - * Signature: ([F)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromFloatArray - (JNIEnv *, jobject, jfloatArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromBooleanArray - * Signature: ([Z)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromBooleanArray - (JNIEnv *, jobject, jbooleanArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: fromVariantArray - * Signature: ([Lcom/jacob/com/Variant;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_fromVariantArray - (JNIEnv *, jobject, jobjectArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: toCharArray - * Signature: ()[C - */ -JNIEXPORT jcharArray JNICALL Java_com_jacob_com_SafeArray_toCharArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: toIntArray - * Signature: ()[I - */ -JNIEXPORT jintArray JNICALL Java_com_jacob_com_SafeArray_toIntArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: toLongArray - * Signature: ()[L - */ -JNIEXPORT jlongArray JNICALL Java_com_jacob_com_SafeArray_toLongArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: toShortArray - * Signature: ()[S - */ -JNIEXPORT jshortArray JNICALL Java_com_jacob_com_SafeArray_toShortArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: toDoubleArray - * Signature: ()[D - */ -JNIEXPORT jdoubleArray JNICALL Java_com_jacob_com_SafeArray_toDoubleArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: toStringArray - * Signature: ()[Ljava/lang/String; - */ -JNIEXPORT jobjectArray JNICALL Java_com_jacob_com_SafeArray_toStringArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: toByteArray - * Signature: ()[B - */ -JNIEXPORT jbyteArray JNICALL Java_com_jacob_com_SafeArray_toByteArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: toFloatArray - * Signature: ()[F - */ -JNIEXPORT jfloatArray JNICALL Java_com_jacob_com_SafeArray_toFloatArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: toBooleanArray - * Signature: ()[Z - */ -JNIEXPORT jbooleanArray JNICALL Java_com_jacob_com_SafeArray_toBooleanArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: toVariantArray - * Signature: ()[Lcom/jacob/com/Variant; - */ -JNIEXPORT jobjectArray JNICALL Java_com_jacob_com_SafeArray_toVariantArray - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: getChar - * Signature: (I)C - */ -JNIEXPORT jchar JNICALL Java_com_jacob_com_SafeArray_getChar__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getChar - * Signature: (II)C - */ -JNIEXPORT jchar JNICALL Java_com_jacob_com_SafeArray_getChar__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setChar - * Signature: (IC)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setChar__IC - (JNIEnv *, jobject, jint, jchar); - -/* - * Class: com_jacob_com_SafeArray - * Method: setChar - * Signature: (IIC)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setChar__IIC - (JNIEnv *, jobject, jint, jint, jchar); - -/* - * Class: com_jacob_com_SafeArray - * Method: getChars - * Signature: (II[CI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getChars - (JNIEnv *, jobject, jint, jint, jcharArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setChars - * Signature: (II[CI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setChars - (JNIEnv *, jobject, jint, jint, jcharArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getInt - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getInt__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getInt - * Signature: (II)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getInt__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setInt - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setInt__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setInt - * Signature: (III)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setInt__III - (JNIEnv *, jobject, jint, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getInts - * Signature: (II[II)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getInts - (JNIEnv *, jobject, jint, jint, jintArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setInts - * Signature: (II[II)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setInts - (JNIEnv *, jobject, jint, jint, jintArray, jint); - -/* - * Class: SafeArray - * Method: getLong - * Signature: (I)J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_SafeArray_getLong__I - (JNIEnv *env, jobject _this, jint idx); - -/* - * Class: SafeArray - * Method: getLong - * Signature: (II)J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_SafeArray_getLong__II - (JNIEnv *env, jobject _this, jint i, jint j); - -/* - * Class: SafeArray - * Method: setLong - * Signature: (IJ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setLong__IJ - (JNIEnv *env, jobject _this, jint idx, jlong c); - -/* - * Class: SafeArray - * Method: setLong - * Signature: (IIJ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setLong__IIJ - (JNIEnv *env, jobject _this, jint i, jint j, jlong c); - -/* - * Class: SafeArray - * Method: getLongs - * Signature: (II[JI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getLongs - (JNIEnv *env, jobject _this, jint idx, jint nelem, jlongArray ja, jint ja_start); - -/* - * Class: SafeArray - * Method: setLongs - * Signature: (II[JI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setLongs - (JNIEnv *env, jobject _this, jint idx, jint nelem, jlongArray ja, jint ja_start); - -/* - * Class: com_jacob_com_SafeArray - * Method: getShort - * Signature: (I)S - */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_SafeArray_getShort__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getShort - * Signature: (II)S - */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_SafeArray_getShort__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setShort - * Signature: (IS)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setShort__IS - (JNIEnv *, jobject, jint, jshort); - -/* - * Class: com_jacob_com_SafeArray - * Method: setShort - * Signature: (IIS)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setShort__IIS - (JNIEnv *, jobject, jint, jint, jshort); - -/* - * Class: com_jacob_com_SafeArray - * Method: getShorts - * Signature: (II[SI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getShorts - (JNIEnv *, jobject, jint, jint, jshortArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setShorts - * Signature: (II[SI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setShorts - (JNIEnv *, jobject, jint, jint, jshortArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getDouble - * Signature: (I)D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_SafeArray_getDouble__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getDouble - * Signature: (II)D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_SafeArray_getDouble__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setDouble - * Signature: (ID)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setDouble__ID - (JNIEnv *, jobject, jint, jdouble); - -/* - * Class: com_jacob_com_SafeArray - * Method: setDouble - * Signature: (IID)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setDouble__IID - (JNIEnv *, jobject, jint, jint, jdouble); - -/* - * Class: com_jacob_com_SafeArray - * Method: getDoubles - * Signature: (II[DI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getDoubles - (JNIEnv *, jobject, jint, jint, jdoubleArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setDoubles - * Signature: (II[DI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setDoubles - (JNIEnv *, jobject, jint, jint, jdoubleArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getString - * Signature: (I)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_jacob_com_SafeArray_getString__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getString - * Signature: (II)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_jacob_com_SafeArray_getString__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setString - * Signature: (ILjava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setString__ILjava_lang_String_2 - (JNIEnv *, jobject, jint, jstring); - -/* - * Class: com_jacob_com_SafeArray - * Method: setString - * Signature: (IILjava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setString__IILjava_lang_String_2 - (JNIEnv *, jobject, jint, jint, jstring); - -/* - * Class: com_jacob_com_SafeArray - * Method: getStrings - * Signature: (II[Ljava/lang/String;I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getStrings - (JNIEnv *, jobject, jint, jint, jobjectArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setStrings - * Signature: (II[Ljava/lang/String;I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setStrings - (JNIEnv *, jobject, jint, jint, jobjectArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getByte - * Signature: (I)B - */ -JNIEXPORT jbyte JNICALL Java_com_jacob_com_SafeArray_getByte__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getByte - * Signature: (II)B - */ -JNIEXPORT jbyte JNICALL Java_com_jacob_com_SafeArray_getByte__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setByte - * Signature: (IB)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setByte__IB - (JNIEnv *, jobject, jint, jbyte); - -/* - * Class: com_jacob_com_SafeArray - * Method: setByte - * Signature: (IIB)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setByte__IIB - (JNIEnv *, jobject, jint, jint, jbyte); - -/* - * Class: com_jacob_com_SafeArray - * Method: getBytes - * Signature: (II[BI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getBytes - (JNIEnv *, jobject, jint, jint, jbyteArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setBytes - * Signature: (II[BI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBytes - (JNIEnv *, jobject, jint, jint, jbyteArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getFloat - * Signature: (I)F - */ -JNIEXPORT jfloat JNICALL Java_com_jacob_com_SafeArray_getFloat__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getFloat - * Signature: (II)F - */ -JNIEXPORT jfloat JNICALL Java_com_jacob_com_SafeArray_getFloat__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setFloat - * Signature: (IF)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setFloat__IF - (JNIEnv *, jobject, jint, jfloat); - -/* - * Class: com_jacob_com_SafeArray - * Method: setFloat - * Signature: (IIF)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setFloat__IIF - (JNIEnv *, jobject, jint, jint, jfloat); - -/* - * Class: com_jacob_com_SafeArray - * Method: getFloats - * Signature: (II[FI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getFloats - (JNIEnv *, jobject, jint, jint, jfloatArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setFloats - * Signature: (II[FI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setFloats - (JNIEnv *, jobject, jint, jint, jfloatArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getBoolean - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_SafeArray_getBoolean__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getBoolean - * Signature: (II)Z - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_SafeArray_getBoolean__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setBoolean - * Signature: (IZ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBoolean__IZ - (JNIEnv *, jobject, jint, jboolean); - -/* - * Class: com_jacob_com_SafeArray - * Method: setBoolean - * Signature: (IIZ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBoolean__IIZ - (JNIEnv *, jobject, jint, jint, jboolean); - -/* - * Class: com_jacob_com_SafeArray - * Method: getBooleans - * Signature: (II[ZI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getBooleans - (JNIEnv *, jobject, jint, jint, jbooleanArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setBooleans - * Signature: (II[ZI)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBooleans - (JNIEnv *, jobject, jint, jint, jbooleanArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getVariant - * Signature: (I)Lcom/jacob/com/Variant; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_SafeArray_getVariant__I - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getVariant - * Signature: (II)Lcom/jacob/com/Variant; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_SafeArray_getVariant__II - (JNIEnv *, jobject, jint, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setVariant - * Signature: (ILcom/jacob/com/Variant;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariant__ILcom_jacob_com_Variant_2 - (JNIEnv *, jobject, jint, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: setVariant - * Signature: (IILcom/jacob/com/Variant;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariant__IILcom_jacob_com_Variant_2 - (JNIEnv *, jobject, jint, jint, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: getVariants - * Signature: (II[Lcom/jacob/com/Variant;I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_getVariants - (JNIEnv *, jobject, jint, jint, jobjectArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: setVariants - * Signature: (II[Lcom/jacob/com/Variant;I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariants - (JNIEnv *, jobject, jint, jint, jobjectArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getVariant - * Signature: ([I)Lcom/jacob/com/Variant; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_SafeArray_getVariant___3I - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: setVariant - * Signature: ([ILcom/jacob/com/Variant;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariant___3ILcom_jacob_com_Variant_2 - (JNIEnv *, jobject, jintArray, jobject); - -/* - * Class: com_jacob_com_SafeArray - * Method: getChar - * Signature: ([I)C - */ -JNIEXPORT jchar JNICALL Java_com_jacob_com_SafeArray_getChar___3I - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: setChar - * Signature: ([IC)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setChar___3IC - (JNIEnv *, jobject, jintArray, jchar); - -/* - * Class: com_jacob_com_SafeArray - * Method: getInt - * Signature: ([I)I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_SafeArray_getInt___3I - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: setInt - * Signature: ([II)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setInt___3II - (JNIEnv *, jobject, jintArray, jint); - -/* - * Class: com_jacob_com_SafeArray - * Method: getLong - * Signature: ([I)J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_SafeArray_getLong___3I - (JNIEnv *env, jobject _this, jintArray indices); - -/* - * Class: com_jacob_com_SafeArray - * Method: setLong - * Signature: ([IJ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setLong___3IJ - (JNIEnv *env, jobject _this, jintArray indices, jlong c); - - -/* - * Class: com_jacob_com_SafeArray - * Method: getShort - * Signature: ([I)S - */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_SafeArray_getShort___3I - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: setShort - * Signature: ([IS)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setShort___3IS - (JNIEnv *, jobject, jintArray, jshort); - -/* - * Class: com_jacob_com_SafeArray - * Method: getDouble - * Signature: ([I)D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_SafeArray_getDouble___3I - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: setDouble - * Signature: ([ID)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setDouble___3ID - (JNIEnv *, jobject, jintArray, jdouble); - -/* - * Class: com_jacob_com_SafeArray - * Method: getString - * Signature: ([I)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_jacob_com_SafeArray_getString___3I - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: setString - * Signature: ([ILjava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setString___3ILjava_lang_String_2 - (JNIEnv *, jobject, jintArray, jstring); - -/* - * Class: com_jacob_com_SafeArray - * Method: getByte - * Signature: ([I)B - */ -JNIEXPORT jbyte JNICALL Java_com_jacob_com_SafeArray_getByte___3I - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: setByte - * Signature: ([IB)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setByte___3IB - (JNIEnv *, jobject, jintArray, jbyte); - -/* - * Class: com_jacob_com_SafeArray - * Method: getFloat - * Signature: ([I)F - */ -JNIEXPORT jfloat JNICALL Java_com_jacob_com_SafeArray_getFloat___3I - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: setFloat - * Signature: ([IF)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setFloat___3IF - (JNIEnv *, jobject, jintArray, jfloat); - -/* - * Class: com_jacob_com_SafeArray - * Method: getBoolean - * Signature: ([I)Z - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_SafeArray_getBoolean___3I - (JNIEnv *, jobject, jintArray); - -/* - * Class: com_jacob_com_SafeArray - * Method: setBoolean - * Signature: ([IZ)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setBoolean___3IZ - (JNIEnv *, jobject, jintArray, jboolean); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/jacob/StdAfx.h b/cpp/jacob/StdAfx.h deleted file mode 100644 index 9d3d322..0000000 --- a/cpp/jacob/StdAfx.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, -// but are changed infrequently - -#if !defined(AFX_STDAFX_H__9988E984_6789_11D3_A646_000000000000__INCLUDED_) -#define AFX_STDAFX_H__9988E984_6789_11D3_A646_000000000000__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef STRICT -#define STRICT -#endif -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0400 -#endif -//#define _ATL_APARTMENT_THREADED -#include -#include -#include -#include -//You may derive a class from CComModule and use it if you want to override -//something, but do not change the name of _Module -extern CComModule _Module; -//#include - - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__9988E984_6789_11D3_A646_000000000000__INCLUDED) diff --git a/cpp/jacob/Variant.cpp b/cpp/jacob/Variant.cpp deleted file mode 100644 index 6b20d09..0000000 --- a/cpp/jacob/Variant.cpp +++ /dev/null @@ -1,1274 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "stdafx.h" -#include "Variant.h" -// Win32 support for Ole Automation -#include -#include -#include -#include -#include -#include -#include "util.h" - -extern "C" -{ - -#define VARIANT_FLD "m_pVariant" - -// extract a VARIANT from a Variant object -VARIANT *extractVariant(JNIEnv *env, jobject arg) -{ - jclass argClass = env->GetObjectClass(arg); - jfieldID ajf = env->GetFieldID( argClass, VARIANT_FLD, "I"); - jint anum = env->GetIntField(arg, ajf); - VARIANT *v = (VARIANT *)anum; - return v; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_release - (JNIEnv *env, jobject _this) -{ - jclass clazz = env->GetObjectClass(_this); - jfieldID jf = env->GetFieldID(clazz, VARIANT_FLD, "I"); - VARIANT *v = extractVariant(env, _this); - if (v) { - // fix byref leak - if (V_VT(v) & VT_BYREF) // is this a reference - { - void *pMem = V_BSTRREF(v); // get allocated memory - if (pMem) - { - if (V_VT(v) == (VT_BYREF|VT_BSTR)) - { - BSTR *pBstr = (BSTR*)pMem; - if (*pBstr) - SysFreeString(*pBstr);// release bstr - } - CoTaskMemFree(pMem); - } - } - VariantClear(v); - delete v; - env->SetIntField(_this, jf, (unsigned int)0); - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_init - (JNIEnv *env, jobject _this) -{ - jclass clazz = env->GetObjectClass(_this); - jfieldID jf = env->GetFieldID( clazz, VARIANT_FLD, "I"); - VARIANT *v = new VARIANT(); - VariantInit(v); - env->SetIntField(_this, jf, (unsigned int)v); -} - - -/* - * Class: com_jacob_com_Variant - * Method: zeroVariant - * Signature: ()V - * - * This should only be used on variant objects created by the - * com layer as part of a call through EventProxy. - * This zeros out the variant pointer in the Variant object - * so that the calling COM program can free the memory. - * instead of both the COM program and the Java GC doing it. - */ -void zeroVariant(JNIEnv *env, jobject _this) -{ - jclass clazz = env->GetObjectClass(_this); - jfieldID jf = env->GetFieldID(clazz, VARIANT_FLD, "I"); - env->SetIntField(_this, jf, (unsigned int)0); -} - - -/** - * This is the core of the old Save method. - * It copies this variant to a byte stream. - * The unmarshalling part of this doesn't work but it was left in - * with the hope that someone will want to fix this later - **/ -JNIEXPORT jbyteArray JNICALL Java_com_jacob_com_Variant_SerializationWriteToBytes - (JNIEnv *env, jobject _this){ - VARIANT *v = extractVariant(env, _this); - if (v) - { - DWORD flags = MSHCTX_LOCAL; - jint size = VARIANT_UserSize(&flags, 0L, v); - // allocate a byte array of the right length - jbyte* pBuf = new jbyte[size]; - // clear it out - ZeroMemory(pBuf, size); - // marshall the Variant into the buffer - VARIANT_UserMarshal(&flags, (unsigned char *)pBuf, v); - // need to convert the buffer to a java byte ba[] - jbyteArray ba = env->NewByteArray(size); - env->SetByteArrayRegion(ba, 0, size, pBuf); - // and delete the original memory - delete [] pBuf; - return ba; - } else { - jbyteArray ba = env->NewByteArray(0); - return ba; - } - } - -/** - * This is the core of the old Load method. It is broken because the - * unmarshalling code doesn't work under 2000/XP. - * - * It probably needs a custom handler. - **/ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_SerializationReadFromBytes - (JNIEnv *env, jobject _this, jbyteArray ba){ - - VARIANT *v = extractVariant(env, _this); - if (v){ - // get a buffer from it - jbyte *pBuf = env->GetByteArrayElements(ba, 0); - // unmarshall the Variant from the buffer - DWORD flags = MSHCTX_LOCAL; - printf("about to unmarshall array elements\n"); - VARIANT_UserUnmarshal(&flags, (unsigned char *)pBuf, v); - // release the byte array - printf("about to release array elements\n"); - env->ReleaseByteArrayElements(ba, pBuf, 0); - } - } - -/** - * Converts the data to a Enum Variant object and then returns it as a Dispatch - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_toEnumVariant - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) - { - HRESULT hr; - if (FAILED(hr = VariantChangeType(v, v, 0, VT_UNKNOWN))) { - ThrowComFail(env, "VariantChangeType failed", hr); - return NULL; - } - jclass autoClass = env->FindClass("com/jacob/com/EnumVariant"); - jmethodID autoCons = - env->GetMethodID(autoClass, "", "(I)V"); - // construct an Unknown object to return - IUnknown *unk = V_UNKNOWN(v); - IEnumVARIANT *ie; - hr = unk->QueryInterface(IID_IEnumVARIANT, (void **)&ie); - if (FAILED(hr)) { - ThrowComFail(env, "[toEnumVariant]: Object does not implement IEnumVariant", hr); - return NULL; - } - // I am copying the pointer to java - // SF-1674179 fix EnumVariants memory leak - // AJ: yes, but the QueryInterface call above already incremented the reference - //if (ie) ie->AddRef(); - jobject newAuto = env->NewObject(autoClass, autoCons, ie); - return newAuto; - } - return NULL; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantNull - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_NULL; - } -} - -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_cloneIndirect - (JNIEnv *env, jobject _this) -{ - return NULL; -} - - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantShortRef - (JNIEnv *env, jobject _this, jshort s) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - short *ps = (short *)CoTaskMemAlloc(sizeof(short)); - *ps = s; - V_VT(v) = VT_I2|VT_BYREF; - V_I2REF(v) = ps; - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantIntRef - (JNIEnv *env, jobject _this, jint s) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - long *ps = (long *)CoTaskMemAlloc(sizeof(long)); - *ps = s; - V_VT(v) = VT_I4|VT_BYREF; - V_I4REF(v) = ps; - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDoubleRef - (JNIEnv *env, jobject _this, jdouble s) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - double *ps = (double *)CoTaskMemAlloc(sizeof(double)); - *ps = s; - V_VT(v) = VT_R8|VT_BYREF; - V_R8REF(v) = ps; - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDateRef - (JNIEnv *env, jobject _this, jdouble s) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - double *ps = (double *)CoTaskMemAlloc(sizeof(double)); - *ps = s; - V_VT(v) = VT_DATE|VT_BYREF; - V_DATEREF(v) = ps; - } -} - -// SF 1065533 added unicode support -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantStringRef - (JNIEnv *env, jobject _this, jstring s) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - - const jchar *cStr = env->GetStringChars(s,NULL); - // SF 1314116 - // DBeck: 2005-09-23: changed CComBSTR c-tor to accept - // Unicode string (no terminating NULL) provided by GetStringChars - const jsize numChars = env->GetStringLength(s); - //CComBSTR bs(cStr); - CComBSTR bs( numChars, (LPCOLESTR)cStr ); // SR cast SF 1689061 - - BSTR *pbs = (BSTR *)CoTaskMemAlloc(sizeof(BSTR)); - bs.CopyTo(pbs); - V_VT(v) = VT_BSTR|VT_BYREF; - V_BSTRREF(v) = pbs; - - env->ReleaseStringChars(s,cStr); } -} - -JNIEXPORT jshort JNICALL Java_com_jacob_com_Variant_getVariantShortRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_I2|VT_BYREF)) { - return NULL; - } - return (jshort)*V_I2REF(v); - } - return NULL; -} - -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantIntRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_I4|VT_BYREF)) { - return NULL; - } - return (jint)*V_I4REF(v); - } - return NULL; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantShort - (JNIEnv *env, jobject _this, jshort s) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_I2; - V_I2(v) = (short)s; - } -} - -JNIEXPORT jshort JNICALL Java_com_jacob_com_Variant_getVariantShort - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != VT_I2) { - return NULL; - } - return (jshort)V_I2(v); - } - return NULL; -} - -JNIEXPORT jdouble JNICALL Java_com_jacob_com_Variant_getVariantDoubleRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_R8|VT_BYREF)) { - return NULL; - } - return (jdouble)*V_R8REF(v); - } - return NULL; -} - -JNIEXPORT jdouble JNICALL Java_com_jacob_com_Variant_getVariantDateRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_DATE|VT_BYREF)) { - return NULL; - } - return (jdouble)*V_DATEREF(v); - } - return NULL; -} - -JNIEXPORT jstring JNICALL Java_com_jacob_com_Variant_getVariantStringRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_BSTR|VT_BYREF)) { - return NULL; - } - BSTR *bs = V_BSTRREF(v); - jstring js = env->NewString((jchar*)*bs, SysStringLen(*bs)); // SR cast SF 1689061 - return js; - } - return NULL; -} - -/** - * cover for underlying C VariantClear function - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_VariantClear - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); - } -} - -/** - * Converts the data to a Dispatch object and then returns it as a Dispatch - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_toVariantDispatch - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - HRESULT hr; - if (FAILED(hr = VariantChangeType(v, v, 0, VT_DISPATCH))) { - ThrowComFail(env, "VariantChangeType failed", hr); - return NULL; - } - jclass autoClass = env->FindClass("com/jacob/com/Dispatch"); - jmethodID autoCons = - env->GetMethodID(autoClass, "", "(I)V"); - // construct a Dispatch object to return - IDispatch *disp = V_DISPATCH(v); - // I am copying the pointer to java - if (disp) disp->AddRef(); - jobject newAuto = env->NewObject(autoClass, autoCons, disp); - return newAuto; - } - return NULL; -} - -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_clone - (JNIEnv *env, jobject _this) -{ - return NULL; -} - -/** - * Returns the value of this int as a Boolea if it is of that type. - * Otherwise it will return null (no conversion done) - */ - -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantInt - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != VT_I4) { - return NULL; - } - return (jint)V_I4(v); - } - return NULL; -} - -/** - * Returns the value of this Date as a Boolea if it is of that type. - * Otherwise it will return null (no conversion done) - */ - -JNIEXPORT jdouble JNICALL Java_com_jacob_com_Variant_getVariantDate - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != VT_DATE) { - return NULL; - } - return (jdouble)V_DATE(v); - } - return NULL; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantInt - (JNIEnv *env, jobject _this, jint i) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_I4; - V_I4(v) = (int)i; - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDate - (JNIEnv *env, jobject _this, jdouble date) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_DATE; - V_DATE(v) = date; - } -} - -/** - * Returns the value of this Variant as a Boolea if it is of that type. - * Otherwise it will return null (no conversion done) - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_Variant_getVariantBoolean - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_BOOL)) { - return NULL; - } - return (jboolean)V_BOOL(v); - } - return NULL; -} - -/** - * Returns the value of this Variant as a Byte if it is of that type. - * Otherwise it will return null (no conversion done) - */ -JNIEXPORT jbyte JNICALL Java_com_jacob_com_Variant_getVariantByte - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_UI1)) { - return NULL; - } - return (jbyte)V_UI1(v); - } - return NULL; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantBoolean - (JNIEnv *env, jobject _this, jboolean b) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_BOOL; - V_BOOL(v) = b == JNI_TRUE ? VARIANT_TRUE : VARIANT_FALSE; - } - else ThrowComFail(env, "putVariantBoolean failed", -1); -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantByte - (JNIEnv *env, jobject _this, jbyte b) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_UI1; - V_UI1(v) = b; - } - else ThrowComFail(env, "putVariantByte failed", -1); -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantEmpty - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_EMPTY; - } -} - -/** - * Sets the variant type to dispatch with no value object - **/ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantNothing - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_DISPATCH; - } -} - -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantError - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != VT_ERROR) { - return NULL; - } - return (jint)V_ERROR(v); - } - return NULL; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantError - (JNIEnv *env, jobject _this, jint i) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_ERROR; - V_ERROR(v) = (int)i; - } -} - - -/** - * Returns the value of this Variant as a double if it is of that type. - * Otherwise it will return null (no conversion done) - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_Variant_getVariantDouble - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != VT_R8) { - return NULL; - } - return (jdouble)V_R8(v); - } - return NULL; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantCurrency - (JNIEnv *env, jobject _this, jlong cur) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - CY pf; - pf.int64 = (LONGLONG)cur; - V_VT(v) = VT_CY; - V_CY(v) = pf; - } else ThrowComFail(env, "putVariantCurrency failed", -1); -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantLong - (JNIEnv *env, jobject _this, jlong longValue) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_I8; - V_I8(v) = (LONGLONG)longValue; - } else ThrowComFail(env, "putVariantLong failed", -1); -} - -/** - * Accepts a dispatch object and sets the type to VT_DISPATCH. - * There is currently no way to pass NULL into this method - * to create something like "NOTHING" from VB - * */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDispatch - (JNIEnv *env, jobject _this, jobject _that) -{ - VARIANT *v = extractVariant(env, _this); - IDispatch *disp = extractDispatch(env, _that); - if (disp && v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_DISPATCH; - V_DISPATCH(v) = disp; - // I am handing the pointer to COM - disp->AddRef(); - } else ThrowComFail(env, "putObject failed", -1); -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDouble - (JNIEnv *env, jobject _this, jdouble d) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_R8; - V_R8(v) = (double)d; - } -} - -/** - * Returns the value of this Variant as a long if it is of that type. - * Otherwise it will return null (no conversion done) - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantCurrency - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != VT_CY) { - return NULL; - } - CY cy; - cy = V_CY(v); - jlong jl; - memcpy(&jl, &cy, sizeof(jl)); // was 64. should be sizeof(x) SF 1690420 - return jl; - } - return NULL; -} - -JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantLong - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != VT_I8) { - return NULL; - } - return (jlong)V_I8(v); - } - return NULL; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantFloatRef - (JNIEnv *env, jobject _this, jfloat val) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - float *pf = (float *)CoTaskMemAlloc(sizeof(float)); - *pf = val; - V_VT(v) = VT_R4|VT_BYREF; - V_R4REF(v) = pf; - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantCurrencyRef - (JNIEnv *env, jobject _this, jlong cur) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - CY *pf = (CY *)CoTaskMemAlloc(sizeof(CY)); - memcpy(pf, &cur, sizeof(*pf)); // was 64. should be sizeof(x) SF 1690420 - V_VT(v) = VT_BYREF|VT_CY; - V_CYREF(v) = pf; - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantLongRef - (JNIEnv *env, jobject _this, jlong longValue) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - LONGLONG *ps = (LONGLONG *)CoTaskMemAlloc(sizeof(LONGLONG)); - *ps = longValue; - V_VT(v) = VT_I8|VT_BYREF; - V_I8REF(v) = ps; - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantErrorRef - (JNIEnv *env, jobject _this, jint i) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_ERROR|VT_BYREF; - V_ERROR(v) = (int)i; - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantBooleanRef - (JNIEnv *env, jobject _this, jboolean b) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - VARIANT_BOOL *br = (VARIANT_BOOL *)CoTaskMemAlloc(sizeof(VARIANT_BOOL)); - *br = b ? VARIANT_TRUE : VARIANT_FALSE; - V_VT(v) = VT_BOOL|VT_BYREF; - V_BOOLREF(v) = br; - } -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantByteRef - (JNIEnv *env, jobject _this, jbyte b) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - unsigned char *br = (unsigned char *)CoTaskMemAlloc(sizeof(char)); - *br = b; - V_VT(v) = VT_UI1|VT_BYREF; - V_UI1REF(v) = br; - } -} - -/** - * Returns the value of this Variant as a String if it is of that type. - * Otherwise it will return null (no conversion done) - */ -JNIEXPORT jstring JNICALL Java_com_jacob_com_Variant_getVariantString - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != VT_BSTR) { - return NULL; - } - BSTR bs = V_BSTR(v); - jstring js = env->NewString((jchar*)bs, SysStringLen(bs));// SR cast SF 1689061 - return js; - } - return NULL; -} - -/** - * SF 1065533 added unicode support - * */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantString - (JNIEnv *env, jobject _this, jstring s) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_BSTR; - - const jchar *cStr = env->GetStringChars(s,NULL); - // SF 1314116 - // DBeck: 2005-09-23: changed CComBSTR c-tor to accept - // Unicode string (no terminating NULL) provided by GetStringChars - const jsize numChars = env->GetStringLength(s); - //CComBSTR bs(cStr); - CComBSTR bs( numChars, (LPCOLESTR)cStr ); // SR cast SF 1689061 - - V_VT(v) = VT_BSTR; - V_BSTR(v) = bs.Copy(); - - env->ReleaseStringChars(s,cStr); - } -} - -JNIEXPORT jfloat JNICALL Java_com_jacob_com_Variant_getVariantFloatRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_R4|VT_BYREF)) { - return NULL; - } - return (jfloat)*V_R4REF(v); - } - return NULL; -} - -JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantCurrencyRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_CY|VT_BYREF)) { - return NULL; - } - CY *cy; - cy = V_CYREF(v); - jlong jl; - memcpy(&jl, cy, sizeof(jl)); // was 64. should be sizeof(x) SF 1690420 - return jl; - } - return NULL; -} - -JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantLongRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_I8|VT_BYREF)) { - return NULL; - } - return (jlong)*V_I8REF(v); - } - return NULL; -} - -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantErrorRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_ERROR|VT_BYREF)) { - return NULL; - } - return (jint)V_ERROR(v); - } - return NULL; -} - -JNIEXPORT jboolean JNICALL Java_com_jacob_com_Variant_getVariantBooleanRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_BOOL|VT_BYREF)) { - return NULL; - } - return (jboolean)*V_BOOLREF(v); - } - return NULL; -} - - -JNIEXPORT jbyte JNICALL Java_com_jacob_com_Variant_getVariantByteRef - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_UI1|VT_BYREF)) { - return NULL; - } - return (jbyte)*V_UI1REF(v); - } - return NULL; -} - -/** - * Converts the data to a Safe Array object and then returns it as a Dispatch - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_toVariantSafeArray - (JNIEnv *env, jobject _this, jboolean deepCopy) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if ((V_VT(v) & VT_ARRAY) == 0) - { - ThrowComFail(env, "Variant not array", -1); - return NULL; - } - // prepare a new sa obj - jclass saClass = env->FindClass("com/jacob/com/SafeArray"); - jmethodID saCons = env->GetMethodID(saClass, "", "()V"); - // construct an SA to return - jobject newSA = env->NewObject(saClass, saCons); - // pass in the deep copy indicator - setSA(env, newSA, V_ARRAY(v), deepCopy == JNI_TRUE ? 1 : 0); - return newSA; - } - return NULL; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantSafeArrayRef - (JNIEnv *env, jobject _this, jobject sa) -{ - SAFEARRAY *psa = extractSA(env, sa); - if (psa) - { - VARIANT *v = extractVariant(env, _this); - if (v) { - VARTYPE vt; - SAFEARRAY **sa = (SAFEARRAY **)CoTaskMemAlloc(sizeof(SAFEARRAY*)); - *sa = psa; - SafeArrayGetVartype(psa, &vt); - V_VT(v) = VT_ARRAY | vt | VT_BYREF; - V_ARRAYREF(v) = sa; - return; - } - ThrowComFail(env, "Can't get variant pointer", -1); - return; - } - ThrowComFail(env, "Can't get sa pointer", -1); - return; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantSafeArray - (JNIEnv *env, jobject _this, jobject sa) -{ - SAFEARRAY *psa = extractSA(env, sa); - if (psa) - { - VARIANT *v = extractVariant(env, _this); - if (v) { - VARTYPE vt; - SafeArrayGetVartype(psa, &vt); - V_VT(v) = VT_ARRAY | vt; - V_ARRAY(v) = copySA(psa); - return; - } - ThrowComFail(env, "Can't get variant pointer", -1); - return; - } - ThrowComFail(env, "Can't get sa pointer", -1); - return; -} - -/** - * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND - * */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantNoParam - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - V_VT(v) = VT_ERROR; - V_ERROR(v) = DISP_E_PARAMNOTFOUND; - } -} - -/** - * Returns the value of this Variant as a Float if it is of that type. - * Otherwise it will return null (no conversion done) - */ -JNIEXPORT jfloat JNICALL Java_com_jacob_com_Variant_getVariantFloat - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_R4)) { - return NULL; - } - return (jfloat)V_R4(v); - } - return NULL; -} - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantFloat - (JNIEnv *env, jobject _this, jfloat val) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - V_VT(v) = VT_R4; - V_R4(v) = val; - } -} - -/** - * changes the type of the underlying variant data - * */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_changeVariantType - (JNIEnv *env, jobject _this, jshort t) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantChangeType(v, v, 0, t); - } -} - -/** - * returns the variant type if it is set, otherwise - * returns null - * */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_Variant_getVariantType - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (v) { - return (jshort)V_VT(v); - } - return NULL; -} - -// removed Java_com_jacob_com_Variant_putSafeArrayRefHelper - -/** - * this is a big cover method that returns TRUE if - * the variant type is - * VT_EMPTY, VT_NULL, VT_ERROR or VT_DISPATCH with no dispatch object - * */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_Variant_isVariantConsideredNull - (JNIEnv *env, jobject _this) -{ - VARIANT *v = extractVariant(env, _this); - if (!v) return JNI_TRUE; - if ((V_VT(v) & VT_ARRAY)) - { - // is it a null safearray - // prior to 4 Dec 2005 the squiggle brackets were missing - // so this did the wrong thing for the else statement - if ((V_VT(v) & VT_BYREF)) { - if (!V_ARRAYREF(v)) return JNI_TRUE; - } else { - if (!V_ARRAY(v)) return JNI_TRUE; - } - } - switch (V_VT(v)) - { - case VT_EMPTY: - case VT_NULL: - case VT_ERROR: - return JNI_TRUE; - // is it a null dispatch (Nothing in VB) - case VT_DISPATCH: - if (!V_DISPATCH(v)) return JNI_TRUE; - } - return JNI_FALSE; -} - -/** - * Puts a variant into a the Variant as its data and sets the type - * to VT_VARIANT|VT_BYREF. - * Added 1.12 pre 6 - * - * */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantVariant - (JNIEnv *env, jobject _this, jobject var) -{ - - VARIANT *vVar = extractVariant(env, var); - VARIANT *v = extractVariant(env, _this); - - if (v) { - VariantClear(v); // whatever was there before - - V_VT(v) = VT_VARIANT|VT_BYREF; - V_VARIANTREF(v) = vVar; - } - -} - -/** - * retrieves the enclosed variant when they are of type VT_VARIANT - * Added 1.12 pre 6 - * - * */ -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantVariant -(JNIEnv *env, jobject _this) -{ - - VARIANT *v = extractVariant(env, _this); - if (v) { - - if (V_VT(v) != (VT_VARIANT|VT_BYREF)) { - return NULL; - } - - VARIANT *refVar = V_VARIANTREF(v); - - // we could have made a copy of refV here but we aren't every going to free - // it outside of the scope of the enclosing context so we will just used the - // enclosed. This relies on the java layer to zero out its ref to this - // enclosed variant before the gc can come along and free the memory out from - // under this enclosing variant. - return (unsigned int)refVar; - } - - return NULL; -} - - /** - * puts a VT_DECIMAL by reference - * Added 1.13M4 - * */ - JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDecRef - (JNIEnv *env, jobject _this, jint signum, jbyte scale, jint lo, jint mid, jint hi) - { - VARIANT *v = extractVariant(env, _this); - if (v) { - VariantClear(v); // whatever was there before - DECIMAL *pd = (DECIMAL *)CoTaskMemAlloc(sizeof(DECIMAL)); - pd->scale = scale; - if (signum == 1 || signum == 0){ - pd->sign = 0; - } else { - pd->sign = 0x80; - } - pd->Hi32 = hi; - pd->Mid32 = mid; - pd->Lo32 = lo; - V_VT(v) = VT_DECIMAL | VT_BYREF; - V_DECIMALREF(v) = pd; - } - } - - - /** - * puts a VT_DECIMAL - * Added 1.13M4 - * */ - JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDec - (JNIEnv *env, jobject _this, jint signum, jbyte scale, jint lo, jint mid, jint hi) - { - VARIANT *v = extractVariant(env, _this); - DECIMAL *d; - if (v) { - VariantClear(v); // whatever was there before - d = (DECIMAL*)v; - d->scale = scale; - if (signum == 1 || signum == 0){ - d->sign = 0; - } else { - d->sign = 0x80; - } - d->Hi32 = hi; - d->Mid32 = mid; - d->Lo32 = lo; - V_VT(v) = VT_DECIMAL; - } - } - -/** - * utility method used by the getVariantXXX() methods to convert VT_DECIMAL to BigDecimal - * */ -jobject extractDecimal - (JNIEnv *env, DECIMAL* d) - { - jclass bigIntegerClass; - jclass bigDecimalClass; - jobject integer; - jmethodID bigIntegerConstructor; - jmethodID bigDecimalConstructor; - jbyteArray bArray; - jobject result = NULL; - jbyte* buffer; - - bigIntegerClass = env->FindClass("java/math/BigInteger"); - if (bigIntegerClass == NULL) - return NULL; - bigDecimalClass = env->FindClass("java/math/BigDecimal"); - if (bigDecimalClass == NULL) { - env->DeleteLocalRef(bigIntegerClass); - return NULL; - } - - bigIntegerConstructor = env->GetMethodID(bigIntegerClass, "", "(I[B)V"); - if (bigIntegerConstructor == NULL) { - env->DeleteLocalRef(bigIntegerClass); - env->DeleteLocalRef(bigDecimalClass); - return NULL; - } - bigDecimalConstructor = env->GetMethodID(bigDecimalClass, "", "(Ljava/math/BigInteger;I)V"); - if (bigIntegerConstructor == NULL) { - env->DeleteLocalRef(bigIntegerClass); - env->DeleteLocalRef(bigDecimalClass); - return NULL; - } - bArray = env->NewByteArray(12); - if (bArray == NULL) { - env->DeleteLocalRef(bigIntegerClass); - env->DeleteLocalRef(bigDecimalClass); - return NULL; - } - /* Unfortunately the byte ordering is completely wrong, so we remap it into buffer */ - buffer = (jbyte*)malloc(12); - buffer[11] = (byte)(d->Lo32 & 255); - buffer[10] = (byte)((d->Lo32 >> 8) & 255); - buffer[9] = (byte)((d->Lo32 >> 16) & 255); - buffer[8] = (byte)((d->Lo32 >> 24) & 255); - buffer[7] = (byte)((d->Mid32) & 255); - buffer[6] = (byte)((d->Mid32 >> 8) & 255); - buffer[5] = (byte)((d->Mid32 >> 16) & 255); - buffer[4] = (byte)((d->Mid32 >> 24) & 255); - buffer[3] = (byte)((d->Hi32) & 255); - buffer[2] = (byte)((d->Hi32 >> 8) & 255); - buffer[1] = (byte)((d->Hi32 >> 16) & 255); - buffer[0] = (byte)((d->Hi32 >> 24) & 255); - /* Load buffer into the actual array */ - env->SetByteArrayRegion(bArray, 0, 12, buffer); - /* then clean up the C array */ - free(buffer); - - /* instantiate the BigInteger */ - integer = env->NewObject(bigIntegerClass, bigIntegerConstructor, d->sign == 0x80?-1:1, bArray); - - result = env->NewObject(bigDecimalClass, bigDecimalConstructor, integer, (jint)(d->scale)); - - /* Clean up the Java global references */ - env->DeleteLocalRef(bArray); - env->DeleteLocalRef(integer); - env->DeleteLocalRef(bigIntegerClass); - return result; - } - -/** - * gets a VT_DECIMAL by ref as a BigDecimal - * Added 1.13M4 - * */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_getVariantDecRef - (JNIEnv *env, jobject _this) - { - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != (VT_DECIMAL|VT_BYREF)) { - return NULL; - } - return extractDecimal(env, v->pdecVal); - } - return NULL; - } - -/** - * gets a VT_DECIMAL as a BigDecimal - * Added 1.13M4 - * */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_getVariantDec - (JNIEnv *env, jobject _this) - { - VARIANT *v = extractVariant(env, _this); - if (v) { - if (V_VT(v) != VT_DECIMAL) { - return NULL; - } - return extractDecimal(env, (DECIMAL*)v); - } - return NULL; - } - -} diff --git a/cpp/jacob/Variant.h b/cpp/jacob/Variant.h deleted file mode 100644 index d2293c2..0000000 --- a/cpp/jacob/Variant.h +++ /dev/null @@ -1,605 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -/* Header for class com_jacob_com_Variant */ - -#ifndef _Included_com_jacob_com_Variant -#define _Included_com_jacob_com_Variant -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Class: com_jacob_com_Variant - * Method: toEnumVariant - * Signature: ()Lcom/jacob/com/EnumVariant; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_toEnumVariant - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantNull - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantNull - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: cloneIndirect - * Signature: ()Lcom_jacob_com_Variant; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_cloneIndirect - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantShortRef - * Signature: (S)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantShortRef - (JNIEnv *, jobject, jshort); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantIntRef - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantIntRef - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantDoubleRef - * Signature: (D)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDoubleRef - (JNIEnv *, jobject, jdouble); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantDateRef - * Signature: (D)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDateRef - (JNIEnv *, jobject, jdouble); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantStringRef - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantStringRef - (JNIEnv *, jobject, jstring); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantShortRef - * Signature: ()S - */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_Variant_getVariantShortRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantIntRef - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantIntRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantShort - * Signature: (S)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantShort - (JNIEnv *, jobject, jshort); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantShort - * Signature: ()S - */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_Variant_getVariantShort - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantDoubleRef - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_Variant_getVariantDoubleRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantDateRef - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_Variant_getVariantDateRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getStringRef - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_jacob_com_Variant_getVariantStringRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: com_jacob_com_VariantClear - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_VariantClear - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: toDispatch - * Signature: ()LDispatch; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_toVariantDispatch - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: clone - * Signature: ()Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_clone - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantInt - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantInt - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantDate - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_Variant_getVariantDate - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantInt - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantInt - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantDate - * Signature: (D)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDate - (JNIEnv *, jobject, jdouble); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantBoolean - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_Variant_getVariantBoolean - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantByte - * Signature: ()B - */ -JNIEXPORT jbyte JNICALL Java_com_jacob_com_Variant_getVariantByte - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantBoolean - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantBoolean - (JNIEnv *, jobject, jboolean); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantByte - * Signature: (B)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantByte - (JNIEnv *, jobject, jbyte); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantEmpty - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantEmpty - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantNothing - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantNothing - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantError - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantError - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantError - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantError - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantDouble - * Signature: ()D - */ -JNIEXPORT jdouble JNICALL Java_com_jacob_com_Variant_getVariantDouble - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantCurrency - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantCurrency - (JNIEnv *, jobject, jlong); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantLong - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantLong - (JNIEnv *, jobject, jlong); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantDispatch - * Signature: (Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDispatch - (JNIEnv *, jobject, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantDouble - * Signature: (D)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDouble - (JNIEnv *, jobject, jdouble); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantCurrency - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantCurrency - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantLong - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantLong - (JNIEnv *, jobject); -/* - * Class: com_jacob_com_Variant - * Method: putVariantFloatRef - * Signature: (F)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantFloatRef - (JNIEnv *, jobject, jfloat); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantCurrencyRef - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantCurrencyRef - (JNIEnv *, jobject, jlong); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantLongRef - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantLongRef - (JNIEnv *, jobject, jlong); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantErrorRef - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantErrorRef - (JNIEnv *, jobject, jint); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantBooleanRef - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantBooleanRef - (JNIEnv *, jobject, jboolean); - -/* - * Class: com_jacob_com_Variant - * Method: putObjectRef - * Signature: (Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putObjectRef - (JNIEnv *, jobject, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantByteRef - * Signature: (B)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantByteRef - (JNIEnv *, jobject, jbyte); - -/* - * Class: com_jacob_com_Variant - * Method: getString - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_jacob_com_Variant_getVariantString - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantString - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantString - (JNIEnv *, jobject, jstring); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantFloatRef - * Signature: ()F - */ -JNIEXPORT jfloat JNICALL Java_com_jacob_com_Variant_getVariantFloatRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantCurrencyRef - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantCurrencyRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantLongRef - * Signature: ()J - */ -JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantLongRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantErrorRef - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantErrorRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantBooleanRef - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_Variant_getVariantBooleanRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantByteRef - * Signature: ()B - */ -JNIEXPORT jbyte JNICALL Java_com_jacob_com_Variant_getVariantByteRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: toVariantSafeArray - * Signature: (Z)Lcom/jacob/com/SafeArray; - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_toVariantSafeArray - (JNIEnv *, jobject, jboolean); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantSafeArrayRef - * Signature: (LSafeArray;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantSafeArrayRef - (JNIEnv *, jobject, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantSafeArray - * Signature: (LSafeArray;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantSafeArray - (JNIEnv *, jobject, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantNoParam - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantNoParam - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantFloat - * Signature: ()F - */ -JNIEXPORT jfloat JNICALL Java_com_jacob_com_Variant_getVariantFloat - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantFloat - * Signature: (F)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantFloat - (JNIEnv *, jobject, jfloat); - -/* - * Class: com_jacob_com_Variant - * Method: changeVariantType - * Signature: (S)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_changeVariantType - (JNIEnv *, jobject, jshort); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantType - * Signature: ()S - */ -JNIEXPORT jshort JNICALL Java_com_jacob_com_Variant_getVariantType - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: release - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_release - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: init - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_init - (JNIEnv *, jobject); - -JNIEXPORT jbyteArray JNICALL Java_com_jacob_com_Variant_SerializationWriteToBytes - (JNIEnv *, jobject); - -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_SerializationReadFromBytes - (JNIEnv *, jobject, jbyteArray); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantVariant - * Signature: (Lcom/jacob/com/Variant;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantVariant - (JNIEnv *, jobject, jobject); - - -/* - * Class: com_jacob_com_Variant - * Method: getVariantVariant - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_jacob_com_Variant_getVariantVariant - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: putVariantDecRef - * Signature: (Ljava.math.BigDecimal;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDecRef - (JNIEnv *env, jobject _this, jint signum, jbyte scale, jint lo, jint mid, jint hi); - - -/* - * Class: com_jacob_com_Variant - * Method: putVariantDec - * Signature: (Ljava.math.BigDecimal;)V - */ -JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantDec - (JNIEnv *env, jobject _this, jint signum, jbyte scale, jint lo, jint mid, jint hi); - - -/* - * Class: com_jacob_com_Variant - * Method: getVariantDecRef - * Signature: ()Ljava.math.BigDecimal - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_getVariantDecRef - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: getVariantDec - * Signature: ()Ljava.math.BigDecimal - */ -JNIEXPORT jobject JNICALL Java_com_jacob_com_Variant_getVariantDec - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: isVariantConsideredNull - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_com_jacob_com_Variant_isVariantConsideredNull - (JNIEnv *, jobject); - -/* - * Class: com_jacob_com_Variant - * Method: zeroVariant - * Signature: ()V - * - * This should only be used on variant objects created by the - * com layer as part of a call through EventProxy. - * This zeros out the variant pointer in the Variant object - * so that the calling COM program can free the memory. - * instead of both the COM program and the Java GC doing it. - */ -void zeroVariant (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/jacob/include/atlalloc.h b/cpp/jacob/include/atlalloc.h deleted file mode 100644 index 8bd1006..0000000 --- a/cpp/jacob/include/atlalloc.h +++ /dev/null @@ -1,764 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#pragma once -#ifndef __ATLALLOC_H__ -#define __ATLALLOC_H__ -#endif - -#include -#include - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ - -/* -This is more than a little unsatisfying. /Wp64 warns when we convert a size_t to an int -because it knows such a conversion won't port. -But, when we have overloaded templates, there may well exist both conversions and we need -to fool the warning into not firing on 32 bit builds -*/ -#if !defined(_ATL_W64) -#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) -#define _ATL_W64 __w64 -#else -#define _ATL_W64 -#endif -#endif - -/* Can't use ::std::numeric_limits here because we don't want to introduce a new - deprendency of this code on SCL -*/ - -template -class AtlLimits; - -template<> -class AtlLimits -{ -public: - static const int _Min=INT_MIN; - static const int _Max=INT_MAX; -}; - -template<> -class AtlLimits -{ -public: - static const unsigned int _Min=0; - static const unsigned int _Max=UINT_MAX; -}; - -template<> -class AtlLimits -{ -public: - static const long _Min=LONG_MIN; - static const long _Max=LONG_MAX; -}; - -template<> -class AtlLimits -{ -public: - static const unsigned long _Min=0; - static const unsigned long _Max=ULONG_MAX; -}; - -template<> -class AtlLimits -{ -public: - static const long long _Min=LLONG_MIN; - static const long long _Max=LLONG_MAX; -}; - -template<> -class AtlLimits -{ -public: - static const unsigned long long _Min=0; - static const unsigned long long _Max=ULLONG_MAX; -}; - -/* generic version */ -template -inline HRESULT AtlAdd(T* ptResult, T tLeft, T tRight) -{ - if(::ATL::AtlLimits::_Max-tLeft < tRight) - { - return E_INVALIDARG; - } - *ptResult= tLeft + tRight; - return S_OK; -} - -/* generic but compariatively slow version */ -template -inline HRESULT AtlMultiply(T* ptResult, T tLeft, T tRight) -{ - /* avoid divide 0 */ - if(tLeft==0) - { - *ptResult=0; - return S_OK; - } - if(::ATL::AtlLimits::_Max/tLeft < tRight) - { - return E_INVALIDARG; - } - *ptResult= tLeft * tRight; - return S_OK; -} - -/* fast version for 32 bit integers */ -template<> -inline HRESULT AtlMultiply(int _ATL_W64 *piResult, int _ATL_W64 iLeft, int _ATL_W64 iRight) -{ - __int64 i64Result=static_cast<__int64>(iLeft) * static_cast<__int64>(iRight); - if(i64Result>INT_MAX || i64Result < INT_MIN) - { - return E_INVALIDARG; - } - *piResult=static_cast(i64Result); - return S_OK; -} - -template<> -inline HRESULT AtlMultiply(unsigned int _ATL_W64 *piResult, unsigned int _ATL_W64 iLeft, unsigned int _ATL_W64 iRight) -{ - unsigned __int64 i64Result=static_cast(iLeft) * static_cast(iRight); - if(i64Result>UINT_MAX) - { - return E_INVALIDARG; - } - *piResult=static_cast(i64Result); - return S_OK; -} - -template<> -inline HRESULT AtlMultiply(long _ATL_W64 *piResult, long _ATL_W64 iLeft, long _ATL_W64 iRight) -{ - __int64 i64Result=static_cast<__int64>(iLeft) * static_cast<__int64>(iRight); - if(i64Result>LONG_MAX || i64Result < LONG_MIN) - { - return E_INVALIDARG; - } - *piResult=static_cast(i64Result); - return S_OK; -} - -template<> -inline HRESULT AtlMultiply(unsigned long _ATL_W64 *piResult, unsigned long _ATL_W64 iLeft, unsigned long _ATL_W64 iRight) -{ - unsigned __int64 i64Result=static_cast(iLeft) * static_cast(iRight); - if(i64Result>ULONG_MAX) - { - return E_INVALIDARG; - } - *piResult=static_cast(i64Result); - return S_OK; -} - -template -inline T AtlMultiplyThrow(T tLeft, T tRight) -{ - T tResult; - HRESULT hr=AtlMultiply(&tResult, tLeft, tRight); - if(FAILED(hr)) - { - AtlThrow(hr); - } - return tResult; -} - -template -inline T AtlAddThrow(T tLeft, T tRight) -{ - T tResult; - HRESULT hr=AtlAdd(&tResult, tLeft, tRight); - if(FAILED(hr)) - { - AtlThrow(hr); - } - return tResult; -} - -inline LPVOID AtlCoTaskMemCAlloc(ULONG nCount, ULONG nSize) -{ - HRESULT hr; - ULONG nBytes=0; - if( FAILED(hr=::ATL::AtlMultiply(&nBytes, nCount, nSize))) - { - return NULL; - } - return ::CoTaskMemAlloc(nBytes); -} - -inline LPVOID AtlCoTaskMemRecalloc(void *pvMemory, ULONG nCount, ULONG nSize) -{ - HRESULT hr; - ULONG nBytes=0; - if( FAILED(hr=::ATL::AtlMultiply(&nBytes, nCount, nSize))) - { - return NULL; - } - return ::CoTaskMemRealloc(pvMemory, nBytes); -} - -} // namespace ATL -#pragma pack(pop) - -#pragma pack(push,8) -namespace ATL -{ -// forward declaration of Checked::memcpy_s - -namespace Checked -{ - void __cdecl memcpy_s(__out_bcount_part(s1max,n) void *s1, __in size_t s1max, __in_bcount(n) const void *s2, __in size_t n); -} - -///////////////////////////////////////////////////////////////////////////// -// Allocation helpers - -class CCRTAllocator -{ -public: - static void* Reallocate(void* p, size_t nBytes) throw() - { - return realloc(p, nBytes); - } - - static void* Allocate(size_t nBytes) throw() - { - return malloc(nBytes); - } - - static void Free(void* p) throw() - { - free(p); - } -}; - -class CLocalAllocator -{ -public: - static void* Allocate(size_t nBytes) throw() - { - return ::LocalAlloc(LMEM_FIXED, nBytes); - } - static void* Reallocate(void* p, size_t nBytes) throw() - { - if (p==NULL){ - return ( Allocate(nBytes) ); - - } - if (nBytes==0){ - Free(p); - return NULL; - } - return ::LocalReAlloc(p, nBytes, 0); - - } - static void Free(void* p) throw() - { - ::LocalFree(p); - } -}; - -class CGlobalAllocator -{ -public: - static void* Allocate(size_t nBytes) throw() - { - return ::GlobalAlloc(GMEM_FIXED, nBytes); - } - static void* Reallocate(void* p, size_t nBytes) throw() - { - if (p==NULL){ - return ( Allocate(nBytes) ); - - } - if (nBytes==0){ - Free(p); - return NULL; - } - return ( ::GlobalReAlloc(p, nBytes, 0) ); - } - static void Free(void* p) throw() - { - ::GlobalFree(p); - } -}; - -template -class CHeapPtrBase -{ -protected: - CHeapPtrBase() throw() : - m_pData(NULL) - { - } - CHeapPtrBase(CHeapPtrBase& p) throw() - { - m_pData = p.Detach(); // Transfer ownership - } - explicit CHeapPtrBase(T* pData) throw() : - m_pData(pData) - { - } - -public: - ~CHeapPtrBase() throw() - { - Free(); - } - -protected: - CHeapPtrBase& operator=(CHeapPtrBase& p) throw() - { - if(m_pData != p.m_pData) - Attach(p.Detach()); // Transfer ownership - return *this; - } - -public: - operator T*() const throw() - { - return m_pData; - } - - T* operator->() const throw() - { - ATLASSERT(m_pData != NULL); - return m_pData; - } - - T** operator&() throw() - { -#if defined(ATLASSUME) - ATLASSUME(m_pData == NULL); -#endif - return &m_pData; - } - - // Allocate a buffer with the given number of bytes - bool AllocateBytes(size_t nBytes) throw() - { - ATLASSERT(m_pData == NULL); - m_pData = static_cast(Allocator::Allocate(nBytes)); - if (m_pData == NULL) - return false; - - return true; - } - - // Attach to an existing pointer (takes ownership) - void Attach(T* pData) throw() - { - Allocator::Free(m_pData); - m_pData = pData; - } - - // Detach the pointer (releases ownership) - T* Detach() throw() - { - T* pTemp = m_pData; - m_pData = NULL; - return pTemp; - } - - // Free the memory pointed to, and set the pointer to NULL - void Free() throw() - { - Allocator::Free(m_pData); - m_pData = NULL; - } - - // Reallocate the buffer to hold a given number of bytes - bool ReallocateBytes(size_t nBytes) throw() - { - T* pNew; - - pNew = static_cast(Allocator::Reallocate(m_pData, nBytes)); - if (pNew == NULL) - return false; - m_pData = pNew; - - return true; - } - -public: - T* m_pData; -}; - -template -class CHeapPtr : - public CHeapPtrBase -{ -public: - CHeapPtr() throw() - { - } - CHeapPtr(CHeapPtr& p) throw() : - CHeapPtrBase(p) - { - } - explicit CHeapPtr(T* p) throw() : - CHeapPtrBase(p) - { - } - - CHeapPtr& operator=(CHeapPtr& p) throw() - { - CHeapPtrBase::operator=(p); - - return *this; - } - - // Allocate a buffer with the given number of elements - bool Allocate(size_t nElements = 1) throw() - { - size_t nBytes=0; - if(FAILED(::ATL::AtlMultiply(&nBytes, nElements, sizeof(T)))) - { - return false; - } - return AllocateBytes(nBytes); - } - - // Reallocate the buffer to hold a given number of elements - bool Reallocate(size_t nElements) throw() - { - size_t nBytes=0; - if(FAILED(::ATL::AtlMultiply(&nBytes, nElements, sizeof(T)))) - { - return false; - } - return ReallocateBytes(nBytes); - } -}; - -template< typename T, int t_nFixedBytes = 128, class Allocator = CCRTAllocator > -class CTempBuffer -{ -public: - CTempBuffer() throw() : - m_p( NULL ) - { - } - CTempBuffer( size_t nElements ) throw( ... ) : - m_p( NULL ) - { - Allocate( nElements ); - } - - ~CTempBuffer() throw() - { - if( m_p != reinterpret_cast< T* >( m_abFixedBuffer ) ) - { - FreeHeap(); - } - } - - operator T*() const throw() - { - return( m_p ); - } - T* operator->() const throw() - { - ATLASSERT( m_p != NULL ); - return( m_p ); - } - - T* Allocate( size_t nElements ) throw( ... ) - { - return( AllocateBytes( ::ATL::AtlMultiplyThrow(nElements,sizeof( T )) ) ); - } - - T* Reallocate( size_t nElements ) throw( ... ) - { - ATLENSURE(nElements < size_t(-1)/sizeof(T) ); - size_t nNewSize = nElements*sizeof( T ) ; - - if (m_p == NULL) - return AllocateBytes(nNewSize); - - if (nNewSize > t_nFixedBytes) - { - if( m_p == reinterpret_cast< T* >( m_abFixedBuffer ) ) - { - // We have to allocate from the heap and copy the contents into the new buffer - AllocateHeap(nNewSize); - Checked::memcpy_s(m_p, nNewSize, m_abFixedBuffer, t_nFixedBytes); - } - else - { - ReAllocateHeap( nNewSize ); - } - } - else - { - m_p = reinterpret_cast< T* >( m_abFixedBuffer ); - } - - return m_p; - } - - T* AllocateBytes( size_t nBytes ) - { - ATLASSERT( m_p == NULL ); - if( nBytes > t_nFixedBytes ) - { - AllocateHeap( nBytes ); - } - else - { - m_p = reinterpret_cast< T* >( m_abFixedBuffer ); - } - - return( m_p ); - } - -private: - ATL_NOINLINE void AllocateHeap( size_t nBytes ) - { - T* p = static_cast< T* >( Allocator::Allocate( nBytes ) ); - if( p == NULL ) - { - AtlThrow( E_OUTOFMEMORY ); - } - m_p = p; - } - - ATL_NOINLINE void ReAllocateHeap( size_t nNewSize) - { - T* p = static_cast< T* >( Allocator::Reallocate(m_p, nNewSize) ); - if ( p == NULL ) - { - AtlThrow( E_OUTOFMEMORY ); - } - m_p = p; - } - - ATL_NOINLINE void FreeHeap() throw() - { - Allocator::Free( m_p ); - } - -private: - T* m_p; - BYTE m_abFixedBuffer[t_nFixedBytes]; -}; - - -// Allocating memory on the stack without causing stack overflow. -// Only use these through the _ATL_SAFE_ALLOCA_* macros -namespace _ATL_SAFE_ALLOCA_IMPL -{ - -#ifndef _ATL_STACK_MARGIN -#if defined(_M_IX86) -#define _ATL_STACK_MARGIN 0x2000 // Minimum stack available after call to _ATL_SAFE_ALLOCA -#else //_M_AMD64 _M_IA64 -#define _ATL_STACK_MARGIN 0x4000 -#endif -#endif //_ATL_STACK_MARGIN - -//Verifies if sufficient space is available on the stack. -//Note: This function should never be inlined, because the stack allocation -//may not be freed until the end of the calling function (instead of the end of _AtlVerifyStackAvailable). -//The use of __try/__except preverts inlining in this case. -#if (_ATL_VER > 0x0301) -inline bool _AtlVerifyStackAvailable(SIZE_T Size) -{ - bool bStackAvailable = true; - - __try - { - SIZE_T size=0; - HRESULT hrAdd=::ATL::AtlAdd(&size, Size, static_cast(_ATL_STACK_MARGIN)); - if(FAILED(hrAdd)) - { - ATLASSERT(FALSE); - bStackAvailable = false; - } - else - { - PVOID p = _alloca(size); - if (p) - { - (p); - } - } - } - __except ((EXCEPTION_STACK_OVERFLOW == GetExceptionCode()) ? - EXCEPTION_EXECUTE_HANDLER : - EXCEPTION_CONTINUE_SEARCH) - { - bStackAvailable = false; - _resetstkoflw(); - } - return bStackAvailable; -} - - -// Helper Classes to manage heap buffers for _ATL_SAFE_ALLOCA -template < class Allocator> -class CAtlSafeAllocBufferManager -{ -private : - struct CAtlSafeAllocBufferNode - { - CAtlSafeAllocBufferNode* m_pNext; -#if defined(_M_IX86) - BYTE _pad[4]; -#elif defined(_M_IA64) - BYTE _pad[8]; -#elif defined(_M_AMD64) - BYTE _pad[8]; -#else - #error Only supported for X86, AMD64 and IA64 -#endif - void* GetData() - { - return (this + 1); - } - }; - - CAtlSafeAllocBufferNode* m_pHead; -public : - - CAtlSafeAllocBufferManager() : m_pHead(NULL) {}; - void* Allocate(SIZE_T nRequestedSize) - { - CAtlSafeAllocBufferNode *p = (CAtlSafeAllocBufferNode*)Allocator::Allocate(::ATL::AtlAddThrow(nRequestedSize, static_cast(sizeof(CAtlSafeAllocBufferNode)))); - if (p == NULL) - return NULL; - - // Add buffer to the list - p->m_pNext = m_pHead; - m_pHead = p; - - return p->GetData(); - } - ~CAtlSafeAllocBufferManager() - { - // Walk the list and free the buffers - while (m_pHead != NULL) - { - CAtlSafeAllocBufferNode* p = m_pHead; - m_pHead = m_pHead->m_pNext; - Allocator::Free(p); - } - } -}; -#endif - -} // namespace _ATL_SAFE_ALLOCA_IMPL - -} // namespace ATL - #pragma pack(pop) - -// Use one of the following macros before using _ATL_SAFE_ALLOCA -// EX version allows specifying a different heap allocator -#define USES_ATL_SAFE_ALLOCA_EX(x) ATL::_ATL_SAFE_ALLOCA_IMPL::CAtlSafeAllocBufferManager _AtlSafeAllocaManager - -#ifndef USES_ATL_SAFE_ALLOCA -#define USES_ATL_SAFE_ALLOCA USES_ATL_SAFE_ALLOCA_EX(ATL::CCRTAllocator) -#endif - -// nRequestedSize - requested size in bytes -// nThreshold - size in bytes beyond which memory is allocated from the heap. - -#if (_ATL_VER > 0x0301) - -// Defining _ATL_SAFE_ALLOCA_ALWAYS_ALLOCATE_THRESHOLD_SIZE always allocates the size specified -// for threshold if the stack space is available irrespective of requested size. -// This available for testing purposes. It will help determine the max stack usage due to _alloca's -// Disable _alloca not within try-except prefast warning since we verify stack space is available before. -#ifdef _ATL_SAFE_ALLOCA_ALWAYS_ALLOCATE_THRESHOLD_SIZE -#define _ATL_SAFE_ALLOCA(nRequestedSize, nThreshold) \ - __pragma(warning(push))\ - __pragma(warning(disable:4616))\ - __pragma(warning(disable:6255))\ - ((nRequestedSize <= nThreshold && ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nThreshold) ) ? \ - _alloca(nThreshold) : \ - ((ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nThreshold)) ? _alloca(nThreshold) : 0), \ - _AtlSafeAllocaManager.Allocate(nRequestedSize))\ - __pragma(warning(pop)) -#else -#define _ATL_SAFE_ALLOCA(nRequestedSize, nThreshold) \ - __pragma(warning(push))\ - __pragma(warning(disable:4616))\ - __pragma(warning(disable:6255))\ - ((nRequestedSize <= nThreshold && ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nRequestedSize) ) ? \ - _alloca(nRequestedSize) : \ - _AtlSafeAllocaManager.Allocate(nRequestedSize))\ - __pragma(warning(pop)) -#endif - -#endif - -// Use 1024 bytes as the default threshold in ATL -#ifndef _ATL_SAFE_ALLOCA_DEF_THRESHOLD -#define _ATL_SAFE_ALLOCA_DEF_THRESHOLD 1024 -#endif - -#if (_ATL_VER <= 0x0301) // from atlbase.h - -class CComAllocator -{ -public: - static void* Reallocate(void* p, size_t nBytes) throw() - { -#ifdef _WIN64 - if( nBytes > INT_MAX ) - { - return( NULL ); - } -#endif - return ::CoTaskMemRealloc(p, ULONG(nBytes)); - } - static void* Allocate(size_t nBytes) throw() - { -#ifdef _WIN64 - if( nBytes > INT_MAX ) - { - return( NULL ); - } -#endif - return ::CoTaskMemAlloc(ULONG(nBytes)); - } - static void Free(void* p) throw() - { - ::CoTaskMemFree(p); - } -}; - -template -class CComHeapPtr : - public CHeapPtr -{ -public: - CComHeapPtr() throw() - { - } - - explicit CComHeapPtr(T* pData) throw() : - CHeapPtr(pData) - { - } -}; - -#endif - diff --git a/cpp/jacob/include/atlbase.h b/cpp/jacob/include/atlbase.h deleted file mode 100644 index a0e61a0..0000000 --- a/cpp/jacob/include/atlbase.h +++ /dev/null @@ -1,7410 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLBASE_H__ -#define __ATLBASE_H__ - -#pragma once - -// Warnings outside of the push/pop sequence will be disabled for all user -// projects. The only warnings that should be disabled outside the push/pop -// are warnings that are a) benign and b) will show up in user projects -// without being directly caused by the user - -#pragma warning(disable: 4505) // unreferenced local function has been removed -#pragma warning(disable: 4710) // function couldn't be inlined -#pragma warning(disable: 4514) // unreferenced inlines are common - -// These two warnings will occur in any class that contains or derives from a -// class with a private copy constructor or copy assignment operator. -#pragma warning(disable: 4511) // copy constructor could not be generated -#pragma warning(disable: 4512) // assignment operator could not be generated - -// This is a very common pattern for us -#pragma warning(disable: 4355) // 'this' : used in base member initializer list - -// Warning 4702 is generated based on compiler backend data flow analysis. This means that for -// some specific instantiations of a template it can be generated even when the code branch is -// required for other instantiations. In future we should find a way to be more selective about this -#pragma warning(disable: 4702) // Unreachable code - -// -// [pfx_parse] - workaround for old PREfix/PREfast parser -// -#if (defined(_PREFIX_) || defined(_PREFAST_)) && (_MSC_VER < 1400) -#pragma warning (push) -#pragma warning(disable: 4081) // expected 'newline' -#endif // old PREfast parser - -#ifdef _ATL_ALL_WARNINGS -#pragma warning( push ) -#endif - -#pragma warning(disable : 4668) // is not defined as a preprocessor macro, replacing with '0' for '#if/#elif -#pragma warning(disable : 4820) // padding added after member -#pragma warning(disable : 4917) // a GUID can only be associated with a class, interface or namespace - -#pragma warning(disable : 4217) // member template functions cannot be used for copy-assignment or copy-construction - -#pragma warning(disable: 4127) // constant expression -#pragma warning(disable: 4097) // typedef name used as synonym for class-name -#pragma warning(disable: 4786) // identifier was truncated in the debug information -#pragma warning(disable: 4291) // allow placement new -#pragma warning(disable: 4201) // nameless unions are part of C++ -#pragma warning(disable: 4103) // pragma pack -#pragma warning(disable: 4268) // const static/global data initialized to zeros - -#pragma warning (push) -#pragma warning(disable: 4571) //catch(...) blocks compiled with /EHs do NOT catch or re-throw Structured Exceptions -#ifndef __cplusplus - #error ATL requires C++ compilation (use a .cpp suffix) -#endif -#ifndef ATL_NO_LEAN_AND_MEAN -#define ATL_NO_LEAN_AND_MEAN -#endif - -#include - -#ifndef _WINSOCKAPI_ -#include -#endif - -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -#if !defined(_ATL_MIN_CRT) & defined(_MT) -#include -#include // for _beginthreadex, _endthreadex -#endif - -#include -#include - -#include -#include -#include -#include -#include - -#define _ATL_TYPELIB_INDEX_LENGTH 10 -#define _ATL_QUOTES_SPACE 2 - -#pragma pack(push, _ATL_PACKING) - -#ifndef _ATL_NO_DEFAULT_LIBS - -#if defined(_ATL_DLL) - #pragma comment(lib, "atl.lib") - -#if !defined(_ATL_NOFORCE_MANIFEST) && !defined(_VC_NODEFAULTLIB) - -#include - -#endif // !defined(_ATL_NOFORCE_MANIFEST) && !defined(_VC_NODEFAULTLIB) - -#endif // _ATL_DLL - -#ifdef _DEBUG - #pragma comment(lib, "atlsd.lib") -#else - #pragma comment(lib, "atls.lib") -#ifdef _ATL_MIN_CRT - #pragma comment(lib, "atlmincrt.lib") -#endif -#endif - -#endif // !_ATL_NO_DEFAULT_LIBS - -#if defined(_ATL_DLL) - // Pull in obj file with manifest directive for ATL dll - #if defined(_M_IX86) - #pragma comment(linker, "/include:__forceAtlDllManifest") - #else - #pragma comment(linker, "/include:_forceAtlDllManifest") - #endif -#endif - -extern "C" const __declspec(selectany) GUID LIBID_ATLLib = {0x44EC0535,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}}; -extern "C" const __declspec(selectany) CLSID CLSID_Registrar = {0x44EC053A,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}}; -extern "C" const __declspec(selectany) IID IID_IRegistrar = {0x44EC053B,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}}; -extern "C" const __declspec(selectany) IID IID_IAxWinHostWindow = {0xb6ea2050,0x048a,0x11d1,{0x82,0xb9,0x00,0xc0,0x4f,0xb9,0x94,0x2e}}; -extern "C" const __declspec(selectany) IID IID_IAxWinAmbientDispatch = {0xb6ea2051,0x048a,0x11d1,{0x82,0xb9,0x00,0xc0,0x4f,0xb9,0x94,0x2e}}; -extern "C" const __declspec(selectany) IID IID_IInternalConnection = {0x72AD0770,0x6A9F,0x11d1,{0xBC,0xEC,0x00,0x60,0x08,0x8F,0x44,0x4E}}; -extern "C" const __declspec(selectany) IID IID_IDocHostUIHandlerDispatch = {0x425B5AF0,0x65F1,0x11d1,{0x96,0x11,0x00,0x00,0xF8,0x1E,0x0D,0x0D}}; -extern "C" const __declspec(selectany) IID IID_IAxWinHostWindowLic = {0x3935BDA8,0x4ED9,0x495c,{0x86,0x50,0xE0,0x1F,0xC1,0xE3,0x8A,0x4B}}; -extern "C" const __declspec(selectany) IID IID_IAxWinAmbientDispatchEx = {0xB2D0778B,0xAC99,0x4c58,{0xA5,0xC8,0xE7,0x72,0x4E,0x53,0x16,0xB5}}; - -// REVIEW: Temp until it gets back into UUID.LIB -extern "C" const __declspec(selectany) CLSID CLSID_StdGlobalInterfaceTable = {0x00000323,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}}; - -#ifndef _delayimp_h -extern "C" IMAGE_DOS_HEADER __ImageBase; -#endif - -#ifdef _AFX -void AFXAPI AfxOleLockApp(); -void AFXAPI AfxOleUnlockApp(); -#endif // _AFX - - - -namespace ATL -{ - -struct _ATL_CATMAP_ENTRY -{ - int iType; - const CATID* pcatid; -}; - -#define _ATL_CATMAP_ENTRY_END 0 -#define _ATL_CATMAP_ENTRY_IMPLEMENTED 1 -#define _ATL_CATMAP_ENTRY_REQUIRED 2 - -typedef HRESULT (WINAPI _ATL_CREATORFUNC)(void* pv, REFIID riid, LPVOID* ppv); -typedef HRESULT (WINAPI _ATL_CREATORARGFUNC)(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw); -typedef HRESULT (WINAPI _ATL_MODULEFUNC)(DWORD_PTR dw); -typedef LPCTSTR (WINAPI _ATL_DESCRIPTIONFUNC)(); -typedef const struct _ATL_CATMAP_ENTRY* (_ATL_CATMAPFUNC)(); -typedef void (__stdcall _ATL_TERMFUNC)(DWORD_PTR dw); - -struct _ATL_TERMFUNC_ELEM -{ - _ATL_TERMFUNC* pFunc; - DWORD_PTR dw; - _ATL_TERMFUNC_ELEM* pNext; -}; - -/* -struct _ATL_OBJMAP_ENTRY20 -{ - const CLSID* pclsid; - HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister); - _ATL_CREATORFUNC* pfnGetClassObject; - _ATL_CREATORFUNC* pfnCreateInstance; - IUnknown* pCF; - DWORD dwRegister; - _ATL_DESCRIPTIONFUNC* pfnGetObjectDescription; -}; -*/ - -// Can't inherit from _ATL_OBJMAP_ENTRY20 -// because it messes up the OBJECT_MAP macros -struct _ATL_OBJMAP_ENTRY30 -{ - const CLSID* pclsid; - HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister); - _ATL_CREATORFUNC* pfnGetClassObject; - _ATL_CREATORFUNC* pfnCreateInstance; - IUnknown* pCF; - DWORD dwRegister; - _ATL_DESCRIPTIONFUNC* pfnGetObjectDescription; - _ATL_CATMAPFUNC* pfnGetCategoryMap; - HRESULT WINAPI RevokeClassObject() - { - if (dwRegister == 0) - return S_OK; - return CoRevokeClassObject(dwRegister); - } - HRESULT WINAPI RegisterClassObject(DWORD dwClsContext, DWORD dwFlags) - { - IUnknown* p = NULL; - if (pfnGetClassObject == NULL) - return S_OK; - HRESULT hRes = pfnGetClassObject(pfnCreateInstance, __uuidof(IUnknown), (LPVOID*) &p); - if (SUCCEEDED(hRes)) - hRes = CoRegisterClassObject(*pclsid, p, dwClsContext, dwFlags, &dwRegister); - if (p != NULL) - p->Release(); - return hRes; - } -// Added in ATL 3.0 - void (WINAPI *pfnObjectMain)(bool bStarting); -}; - -typedef _ATL_OBJMAP_ENTRY30 _ATL_OBJMAP_ENTRY; - -// Auto Object Map - -#if defined(_M_IA64) || defined(_M_IX86) || defined (_M_AMD64) - -#pragma section("ATL$__a", read, shared) -#pragma section("ATL$__z", read, shared) -#pragma section("ATL$__m", read, shared) -extern "C" -{ -__declspec(selectany) __declspec(allocate("ATL$__a")) _ATL_OBJMAP_ENTRY* __pobjMapEntryFirst = NULL; -__declspec(selectany) __declspec(allocate("ATL$__z")) _ATL_OBJMAP_ENTRY* __pobjMapEntryLast = NULL; -} - -#if !defined(_M_IA64) -#pragma comment(linker, "/merge:ATL=.rdata") -#endif - -#else - -extern "C" -{ -__declspec(selectany) _ATL_OBJMAP_ENTRY* __pobjMapEntryFirst = NULL; -__declspec(selectany) _ATL_OBJMAP_ENTRY* __pobjMapEntryLast = NULL; -} - -#endif // defined(_M_IA64) || defined(_M_IX86) - -struct _ATL_REGMAP_ENTRY -{ - LPCOLESTR szKey; - LPCOLESTR szData; -}; - -struct _AtlCreateWndData -{ - void* m_pThis; - DWORD m_dwThreadID; - _AtlCreateWndData* m_pNext; -}; - - -// perfmon registration/unregistration function definitions -typedef HRESULT (*_ATL_PERFREGFUNC)(HINSTANCE hDllInstance); -typedef HRESULT (*_ATL_PERFUNREGFUNC)(); -__declspec(selectany) _ATL_PERFREGFUNC _pPerfRegFunc = NULL; -__declspec(selectany) _ATL_PERFUNREGFUNC _pPerfUnRegFunc = NULL; - -///////////////////////////////////////////////////////////////////////////// -// Threading Model Support - -template< class TLock > -class CComCritSecLock -{ -public: - CComCritSecLock( TLock& cs, bool bInitialLock = true ); - ~CComCritSecLock() throw(); - - HRESULT Lock() throw(); - void Unlock() throw(); - -// Implementation -private: - TLock& m_cs; - bool m_bLocked; - -// Private to avoid accidental use - CComCritSecLock( const CComCritSecLock& ) throw(); - CComCritSecLock& operator=( const CComCritSecLock& ) throw(); -}; - -template< class TLock > -inline CComCritSecLock< TLock >::CComCritSecLock( TLock& cs, bool bInitialLock ) : - m_cs( cs ), - m_bLocked( false ) -{ - if( bInitialLock ) - { - HRESULT hr; - - hr = Lock(); - if( FAILED( hr ) ) - { - AtlThrow( hr ); - } - } -} - -template< class TLock > -inline CComCritSecLock< TLock >::~CComCritSecLock() throw() -{ - if( m_bLocked ) - { - Unlock(); - } -} - -template< class TLock > -inline HRESULT CComCritSecLock< TLock >::Lock() throw() -{ - HRESULT hr; - - ATLASSERT( !m_bLocked ); - hr = m_cs.Lock(); - if( FAILED( hr ) ) - { - return( hr ); - } - m_bLocked = true; - - return( S_OK ); -} - -template< class TLock > -inline void CComCritSecLock< TLock >::Unlock() throw() -{ - ATLASSUME( m_bLocked ); - m_cs.Unlock(); - m_bLocked = false; -} - -class CComMultiThreadModelNoCS -{ -public: - static ULONG WINAPI Increment(LPLONG p) throw() {return InterlockedIncrement(p);} - static ULONG WINAPI Decrement(LPLONG p) throw() {return InterlockedDecrement(p);} - typedef CComFakeCriticalSection AutoCriticalSection; - typedef CComFakeCriticalSection AutoDeleteCriticalSection; - typedef CComFakeCriticalSection CriticalSection; - typedef CComMultiThreadModelNoCS ThreadModelNoCS; -}; - -class CComMultiThreadModel -{ -public: - static ULONG WINAPI Increment(LPLONG p) throw() {return InterlockedIncrement(p);} - static ULONG WINAPI Decrement(LPLONG p) throw() {return InterlockedDecrement(p);} - typedef CComAutoCriticalSection AutoCriticalSection; - typedef CComAutoDeleteCriticalSection AutoDeleteCriticalSection; - typedef CComCriticalSection CriticalSection; - typedef CComMultiThreadModelNoCS ThreadModelNoCS; -}; - -class CComSingleThreadModel -{ -public: - static ULONG WINAPI Increment(LPLONG p) throw() {return ++(*p);} - static ULONG WINAPI Decrement(LPLONG p) throw() {return --(*p);} - typedef CComFakeCriticalSection AutoCriticalSection; - typedef CComFakeCriticalSection AutoDeleteCriticalSection; - typedef CComFakeCriticalSection CriticalSection; - typedef CComSingleThreadModel ThreadModelNoCS; -}; - -#if defined(_ATL_SINGLE_THREADED) - -#if defined(_ATL_APARTMENT_THREADED) || defined(_ATL_FREE_THREADED) -#pragma message ("More than one global threading model defined.") -#endif - - typedef CComSingleThreadModel CComObjectThreadModel; - typedef CComSingleThreadModel CComGlobalsThreadModel; - -#elif defined(_ATL_APARTMENT_THREADED) - -#if defined(_ATL_SINGLE_THREADED) || defined(_ATL_FREE_THREADED) -#pragma message ("More than one global threading model defined.") -#endif - - typedef CComSingleThreadModel CComObjectThreadModel; - typedef CComMultiThreadModel CComGlobalsThreadModel; - -#elif defined(_ATL_FREE_THREADED) - -#if defined(_ATL_SINGLE_THREADED) || defined(_ATL_APARTMENT_THREADED) -#pragma message ("More than one global threading model defined.") -#endif - - typedef CComMultiThreadModel CComObjectThreadModel; - typedef CComMultiThreadModel CComGlobalsThreadModel; - -#else -#pragma message ("No global threading model defined") -#endif - -///////////////////////////////////////////////////////////////////////////// -// Module - - -// Used by COM related code in ATL -struct _ATL_COM_MODULE70 -{ - UINT cbSize; - HINSTANCE m_hInstTypeLib; - _ATL_OBJMAP_ENTRY** m_ppAutoObjMapFirst; - _ATL_OBJMAP_ENTRY** m_ppAutoObjMapLast; - CComCriticalSection m_csObjMap; -}; -typedef _ATL_COM_MODULE70 _ATL_COM_MODULE; - - -// Used by Windowing code in ATL -struct _ATL_WIN_MODULE70 -{ - UINT cbSize; - CComCriticalSection m_csWindowCreate; - _AtlCreateWndData* m_pCreateWndList; - CSimpleArray m_rgWindowClassAtoms; -}; -typedef _ATL_WIN_MODULE70 _ATL_WIN_MODULE; - - -struct _ATL_MODULE70 -{ - UINT cbSize; - LONG m_nLockCnt; - _ATL_TERMFUNC_ELEM* m_pTermFuncs; - CComCriticalSection m_csStaticDataInitAndTypeInfo; -}; -typedef _ATL_MODULE70 _ATL_MODULE; - - -///////////////////////////////////////////////////////////////////////////// -//This define makes debugging asserts easier. -#define _ATL_SIMPLEMAPENTRY ((ATL::_ATL_CREATORARGFUNC*)1) - -struct _ATL_INTMAP_ENTRY -{ - const IID* piid; // the interface id (IID) - DWORD_PTR dw; - _ATL_CREATORARGFUNC* pFunc; //NULL:end, 1:offset, n:ptr -}; - -///////////////////////////////////////////////////////////////////////////// -// Global Functions - -///////////////////////////////////////////////////////////////////////////// -// QI Support - -ATLAPI AtlInternalQueryInterface(void* pThis, - const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject); - -///////////////////////////////////////////////////////////////////////////// -// Inproc Marshaling helpers - -ATLAPI AtlFreeMarshalStream(IStream* pStream); -ATLAPI AtlMarshalPtrInProc(IUnknown* pUnk, const IID& iid, IStream** ppStream); -ATLAPI AtlUnmarshalPtr(IStream* pStream, const IID& iid, IUnknown** ppUnk); - -ATLAPI_(BOOL) AtlWaitWithMessageLoop(HANDLE hEvent); - -///////////////////////////////////////////////////////////////////////////// -// Connection Point Helpers - -ATLAPI AtlAdvise(IUnknown* pUnkCP, IUnknown* pUnk, const IID& iid, LPDWORD pdw); -ATLAPI AtlUnadvise(IUnknown* pUnkCP, const IID& iid, DWORD dw); - -///////////////////////////////////////////////////////////////////////////// -// IDispatch Error handling - -ATLAPI AtlSetErrorInfo(const CLSID& clsid, LPCOLESTR lpszDesc, - DWORD dwHelpID, LPCOLESTR lpszHelpFile, const IID& iid, HRESULT hRes, - HINSTANCE hInst); - -///////////////////////////////////////////////////////////////////////////// -// Module - -ATLAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE* pComModule, DWORD dwClsContext, DWORD dwFlags); -ATLAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE* pComModule); - -ATLAPI AtlComModuleGetClassObject(_ATL_COM_MODULE* pComModule, REFCLSID rclsid, REFIID riid, LPVOID* ppv); - -ATLAPI AtlComModuleRegisterServer(_ATL_COM_MODULE* pComModule, BOOL bRegTypeLib, const CLSID* pCLSID = NULL); -ATLAPI AtlComModuleUnregisterServer(_ATL_COM_MODULE* pComModule, BOOL bUnRegTypeLib, const CLSID* pCLSID = NULL); - -ATLAPI AtlRegisterClassCategoriesHelper( REFCLSID clsid, const struct _ATL_CATMAP_ENTRY* pCatMap, BOOL bRegister ); - -ATLAPI AtlUpdateRegistryFromResourceD(HINSTANCE hInst, LPCOLESTR lpszRes, - BOOL bRegister, struct _ATL_REGMAP_ENTRY* pMapEntries, IRegistrar* pReg = NULL); - -ATLAPI AtlRegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex); -ATLAPI AtlUnRegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex); -ATLAPI AtlLoadTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex, BSTR* pbstrPath, ITypeLib** ppTypeLib); - -ATLAPI_(DWORD) AtlGetVersion(void* pReserved); - -ATLAPI AtlModuleAddTermFunc(_ATL_MODULE* pModule, _ATL_TERMFUNC* pFunc, DWORD_PTR dw); -ATLAPI_(void) AtlCallTermFunc(_ATL_MODULE* pModule); - -ATLAPI AtlWinModuleInit(_ATL_WIN_MODULE* pWinModule); -ATLAPIINL AtlWinModuleTerm(_ATL_WIN_MODULE* pWinModule, HINSTANCE hInst); - -ATLAPI_(void) AtlWinModuleAddCreateWndData(_ATL_WIN_MODULE* pWinModule, _AtlCreateWndData* pData, void* pObject); -ATLAPI_(void*) AtlWinModuleExtractCreateWndData(_ATL_WIN_MODULE* pWinModule); - -///////////////////////////////////////////////////////////////////////////// -// Get Registrar object from ATL DLL. - -#if !defined(_ATL_STATIC_REGISTRY) -#ifdef _ATL_DLL_IMPL -extern "C" HRESULT __stdcall AtlCreateRegistrar(IRegistrar** ppReg); -#else -extern "C" __declspec(dllimport) HRESULT __stdcall AtlCreateRegistrar(IRegistrar** ppReg); -#endif -#endif - -///////////////////////////////////////////////////////////////////////////// -// GUID comparison -inline BOOL WINAPI InlineIsEqualUnknown(REFGUID rguid1) -{ - return ( - ((PLONG) &rguid1)[0] == 0 && - ((PLONG) &rguid1)[1] == 0 && -#ifdef _ATL_BYTESWAP - ((PLONG) &rguid1)[2] == 0xC0000000 && - ((PLONG) &rguid1)[3] == 0x00000046); -#else - ((PLONG) &rguid1)[2] == 0x000000C0 && - ((PLONG) &rguid1)[3] == 0x46000000); -#endif -} - - - -template -LPCTSTR AtlDebugGetClassName(T*) -{ -#ifdef _DEBUG - const _ATL_INTMAP_ENTRY* pEntries = T::_GetEntries(); - return (LPCTSTR)pEntries[-1].dw; -#else - return NULL; -#endif -} - -// Validation macro for OUT pointer -// Used in QI and CreateInstance -#define _ATL_VALIDATE_OUT_POINTER(x)\ - do { \ - ATLASSERT(x != NULL); \ - if (x == NULL) \ - return E_POINTER; \ - *x = NULL; \ - } while(0) - -///////////////////////////////////////////////////////////////////////////// -// Win32 libraries - -#ifndef _ATL_NO_DEFAULT_LIBS -#pragma comment(lib, "kernel32.lib") -#pragma comment(lib, "user32.lib") -#pragma comment(lib, "advapi32.lib") -#pragma comment(lib, "ole32.lib") -#pragma comment(lib, "shell32.lib") -#pragma comment(lib, "oleaut32.lib") -#pragma comment(lib, "uuid.lib") -#pragma comment(lib, "shlwapi.lib") -#endif // !_ATL_NO_DEFAULT_LIBS - -template< typename T > -class CAutoVectorPtr -{ -public: - CAutoVectorPtr() throw() : - m_p( NULL ) - { - } - CAutoVectorPtr( CAutoVectorPtr< T >& p ) throw() - { - m_p = p.Detach(); // Transfer ownership - } - explicit CAutoVectorPtr( T* p ) throw() : - m_p( p ) - { - } - ~CAutoVectorPtr() throw() - { - Free(); - } - - operator T*() const throw() - { - return( m_p ); - } - - CAutoVectorPtr< T >& operator=( CAutoVectorPtr< T >& p ) throw() - { - if(*this==p) - { - if(this!=&p) - { - // If this assert fires, it means you attempted to assign one CAutoVectorPtr to another when they both contained - // a pointer to the same underlying vector. This means a bug in your code, since your vector will get - // double-deleted. - ATLASSERT(FALSE); - - // For safety, we are going to detach the other CAutoVectorPtr to avoid a double-free. Your code still - // has a bug, though. - p.Detach(); - } - else - { - // Alternatively, this branch means that you are assigning a CAutoVectorPtr to itself, which is - // pointless but permissible - - // nothing to do - } - } - else - { - Free(); - Attach( p.Detach() ); // Transfer ownership - } - return( *this ); - } - - // basic comparison operators - bool operator!=(CAutoVectorPtr& p) const - { - return !operator==(p); - } - - bool operator==(CAutoVectorPtr& p) const - { - return m_p==p.m_p; - } - - // Allocate the vector - bool Allocate( size_t nElements ) throw() - { - ATLASSUME( m_p == NULL ); - ATLTRY( m_p = new T[nElements] ); - if( m_p == NULL ) - { - return( false ); - } - - return( true ); - } - // Attach to an existing pointer (takes ownership) - void Attach( T* p ) throw() - { - ATLASSUME( m_p == NULL ); - m_p = p; - } - // Detach the pointer (releases ownership) - T* Detach() throw() - { - T* p; - - p = m_p; - m_p = NULL; - - return( p ); - } - // Delete the vector pointed to, and set the pointer to NULL - void Free() throw() - { - delete[] m_p; - m_p = NULL; - } - -public: - T* m_p; -}; - -template< typename T > -class CAutoPtr -{ -public: - CAutoPtr() throw() : - m_p( NULL ) - { - } - template< typename TSrc > - CAutoPtr( CAutoPtr< TSrc >& p ) throw() - { - m_p = p.Detach(); // Transfer ownership - } -// -// [pfx_parse] - workaround for PREfix parse problems -// -#if (!defined(_PREFIX_)) && (!defined(_PREFAST_)) - CAutoPtr( CAutoPtr< T >& p ) throw() - { - m_p = p.Detach(); // Transfer ownership - } -#endif // !_PREFIX_ - explicit CAutoPtr( T* p ) throw() : - m_p( p ) - { - } - ~CAutoPtr() throw() - { - Free(); - } - - // Templated version to allow pBase = pDerived - template< typename TSrc > - CAutoPtr< T >& operator=( CAutoPtr< TSrc >& p ) throw() - { - if(m_p==p.m_p) - { - // This means that two CAutoPtrs of two different types had the same m_p in them - // which is never correct - ATLASSERT(FALSE); - } - else - { - Free(); - Attach( p.Detach() ); // Transfer ownership - } - return( *this ); - } - CAutoPtr< T >& operator=( CAutoPtr< T >& p ) throw() - { - if(*this==p) - { - if(this!=&p) - { - // If this assert fires, it means you attempted to assign one CAutoPtr to another when they both contained - // a pointer to the same underlying object. This means a bug in your code, since your object will get - // double-deleted. -#ifdef ATL_AUTOPTR_ASSIGNMENT_ASSERT - ATLASSERT(FALSE); -#endif - - // For safety, we are going to detach the other CAutoPtr to avoid a double-free. Your code still - // has a bug, though. - p.Detach(); - } - else - { - // Alternatively, this branch means that you are assigning a CAutoPtr to itself, which is - // pointless but permissible - - // nothing to do - } - } - else - { - Free(); - Attach( p.Detach() ); // Transfer ownership - } - return( *this ); - } - - // basic comparison operators - bool operator!=(CAutoPtr& p) const - { - return !operator==(p); - } - - bool operator==(CAutoPtr& p) const - { - return m_p==p.m_p; - } - - operator T*() const throw() - { - return( m_p ); - } - T* operator->() const throw() - { - ATLASSUME( m_p != NULL ); - return( m_p ); - } - - // Attach to an existing pointer (takes ownership) - void Attach( T* p ) throw() - { - ATLASSUME( m_p == NULL ); - m_p = p; - } - // Detach the pointer (releases ownership) - T* Detach() throw() - { - T* p; - - p = m_p; - m_p = NULL; - - return( p ); - } - // Delete the object pointed to, and set the pointer to NULL - void Free() throw() - { - delete m_p; - m_p = NULL; - } - -public: - T* m_p; -}; - -/* Automatic cleanup for _malloca objects */ -template< typename T > -class CAutoStackPtr -{ -public: - CAutoStackPtr() throw() : - m_p( NULL ) - { - } - template< typename TSrc > - CAutoStackPtr( CAutoStackPtr< TSrc >& p ) throw() - { - m_p = p.Detach(); // Transfer ownership - } - CAutoStackPtr( CAutoStackPtr< T >& p ) throw() - { - m_p = p.Detach(); // Transfer ownership - } - explicit CAutoStackPtr( T* p ) throw() : - m_p( p ) - { - } - ~CAutoStackPtr() throw() - { - Free(); - } - - // Templated version to allow pBase = pDerived - template< typename TSrc > - CAutoStackPtr< T >& operator=( CAutoStackPtr< TSrc >& p ) throw() - { - if(m_p==p.m_p) - { - // This means that two CAutoPtrs of two different types had the same m_p in them - // which is never correct - ATLASSERT(FALSE); - } - else - { - Free(); - Attach( p.Detach() ); // Transfer ownership - } - return( *this ); - } - CAutoStackPtr< T >& operator=( CAutoStackPtr< T >& p ) throw() - { - if(*this==p) - { - if(this!=&p) - { - // If this assert fires, it means you attempted to assign one CAutoPtr to another when they both contained - // a pointer to the same underlying object. This means a bug in your code, since your object will get - // double-deleted. - ATLASSERT(FALSE); - - // For safety, we are going to detach the other CAutoPtr to avoid a double-free. Your code still - // has a bug, though. - p.Detach(); - } - else - { - // Alternatively, this branch means that you are assigning a CAutoPtr to itself, which is - // pointless but permissible - - // nothing to do - } - } - else - { - Free(); - Attach( p.Detach() ); // Transfer ownership - } - return( *this ); - } - - // basic comparison operators - bool operator!=(CAutoStackPtr& p) const - { - return !operator==(p); - } - - bool operator==(CAutoStackPtr& p) const - { - return m_p==p.m_p; - } - - operator T*() const throw() - { - return( m_p ); - } - T* operator->() const throw() - { - ATLASSUME( m_p != NULL ); - return( m_p ); - } - - // Attach to an existing pointer (takes ownership) - void Attach( T* p ) throw() - { - ATLASSUME( m_p == NULL ); - m_p = p; - } - // Detach the pointer (releases ownership) - T* Detach() throw() - { - T* p; - - p = m_p; - m_p = NULL; - - return( p ); - } - // Delete the object pointed to, and set the pointer to NULL - void Free() throw() - { - /* Note: _freea only actually does anything if m_p was heap allocated - If m_p was from the stack, it wouldn't be possible to actually free it here - [wrong function] unless we got inlined. But really all we do if m_p is - stack-based is ignore it and let its alloca storage disappear at the end - of the outer function. - */ - _freea(m_p); - m_p = NULL; - } - -public: - T* m_p; -}; - -// static_cast_auto template functions. Used like static_cast, only they work on CAutoPtr objects -template< class Dest, class Src > -Dest* static_cast_auto( const CAutoPtr< Src >& pSrc ) throw() -{ - return( static_cast< Dest* >( static_cast< Src* >( pSrc ) ) ); -} - - -class CComAllocator -{ -public: - static void* Reallocate(void* p, size_t nBytes) throw() - { -#ifdef _WIN64 - if( nBytes > INT_MAX ) - { - return( NULL ); - } -#endif - return ::CoTaskMemRealloc(p, ULONG(nBytes)); - } - static void* Allocate(size_t nBytes) throw() - { -#ifdef _WIN64 - if( nBytes > INT_MAX ) - { - return( NULL ); - } -#endif - return ::CoTaskMemAlloc(ULONG(nBytes)); - } - static void Free(void* p) throw() - { - ::CoTaskMemFree(p); - } -}; - -template -class CComHeapPtr : - public CHeapPtr -{ -public: - CComHeapPtr() throw() - { - } - - explicit CComHeapPtr(T* pData) throw() : - CHeapPtr(pData) - { - } -}; - -template -T* AtlSafeRealloc(T* pT, size_t cEls) throw() -{ - T* pTemp; - - size_t nBytes=0; - if(FAILED(::ATL::AtlMultiply(&nBytes, cEls, sizeof(T)))) - { - return NULL; - } - pTemp = static_cast(Reallocator::Reallocate(pT, nBytes)); - if (pTemp == NULL) - { - Reallocator::Free(pT); - return NULL; - } - pT = pTemp; - return pTemp; -} - -class CHandle -{ -public: - CHandle() throw(); - CHandle( CHandle& h ) throw(); - explicit CHandle( HANDLE h ) throw(); - ~CHandle() throw(); - - CHandle& operator=( CHandle& h ) throw(); - - operator HANDLE() const throw(); - - // Attach to an existing handle (takes ownership). - void Attach( HANDLE h ) throw(); - // Detach the handle from the object (releases ownership). - HANDLE Detach() throw(); - - // Close the handle. - void Close() throw(); - -public: - HANDLE m_h; -}; - -inline CHandle::CHandle() throw() : - m_h( NULL ) -{ -} - -inline CHandle::CHandle( CHandle& h ) throw() : - m_h( NULL ) -{ - Attach( h.Detach() ); -} - -inline CHandle::CHandle( HANDLE h ) throw() : - m_h( h ) -{ -} - -inline CHandle::~CHandle() throw() -{ - if( m_h != NULL ) - { - Close(); - } -} - -inline CHandle& CHandle::operator=( CHandle& h ) throw() -{ - if( this != &h ) - { - if( m_h != NULL ) - { - Close(); - } - Attach( h.Detach() ); - } - - return( *this ); -} - -inline CHandle::operator HANDLE() const throw() -{ - return( m_h ); -} - -inline void CHandle::Attach( HANDLE h ) throw() -{ - ATLASSUME( m_h == NULL ); - m_h = h; // Take ownership -} - -inline HANDLE CHandle::Detach() throw() -{ - HANDLE h; - - h = m_h; // Release ownership - m_h = NULL; - - return( h ); -} - -inline void CHandle::Close() throw() -{ - if( m_h != NULL ) - { - ::CloseHandle( m_h ); - m_h = NULL; - } -} - -class CCritSecLock -{ -public: - CCritSecLock( CRITICAL_SECTION& cs, bool bInitialLock = true ); - ~CCritSecLock() throw(); - - void Lock(); - void Unlock() throw(); - -// Implementation -private: - CRITICAL_SECTION& m_cs; - bool m_bLocked; - -// Private to avoid accidental use - CCritSecLock( const CCritSecLock& ) throw(); - CCritSecLock& operator=( const CCritSecLock& ) throw(); -}; - -inline CCritSecLock::CCritSecLock( CRITICAL_SECTION& cs, bool bInitialLock ) : - m_cs( cs ), - m_bLocked( false ) -{ - if( bInitialLock ) - { - Lock(); - } -} - -inline CCritSecLock::~CCritSecLock() throw() -{ - if( m_bLocked ) - { - Unlock(); - } -} - -inline void CCritSecLock::Lock() -{ - ATLASSERT( !m_bLocked ); - __try - { - ::EnterCriticalSection( &m_cs ); - } - __except( STATUS_NO_MEMORY == GetExceptionCode() ) - { - AtlThrow( E_OUTOFMEMORY ); - } - m_bLocked = true; -} - -inline void CCritSecLock::Unlock() throw() -{ - ATLASSUME( m_bLocked ); - ::LeaveCriticalSection( &m_cs ); - m_bLocked = false; -} - -///////////////////////////////////////////////////////////////////////////// -// Interface debugging -#if defined(_ATL_DEBUG_INTERFACES) || defined(_ATL_DEBUG_QI) -HRESULT WINAPI AtlDumpIID(REFIID iid, LPCTSTR pszClassName, HRESULT hr) throw(); -#endif // _ATL_DEBUG_INTERFACES || _ATL_DEBUG_QI - -#ifdef _ATL_DEBUG_INTERFACES - -struct _QIThunk -{ - STDMETHOD(QueryInterface)(REFIID iid, void** pp) - { - ATLASSUME(m_dwRef >= 0); - ATLASSUME(m_pUnk != NULL); - return m_pUnk->QueryInterface(iid, pp); - } - STDMETHOD_(ULONG, AddRef)() - { - ATLASSUME(m_pUnk != NULL); - if (m_bBreak) - DebugBreak(); - m_pUnk->AddRef(); - return InternalAddRef(); - } - ULONG InternalAddRef() - { - ATLASSUME(m_pUnk != NULL); - if (m_bBreak) - DebugBreak(); - ATLASSUME(m_dwRef >= 0); - long l = InterlockedIncrement(&m_dwRef); - - TCHAR buf[512+1]; -#if _SECURE_ATL && !defined(_ATL_MIN_CRT) - _stprintf_s(buf, _countof(buf), _T("QIThunk - %-10d\tAddRef :\tObject = 0x%p\tRefcount = %d\t"), - m_nIndex, m_pUnk, m_dwRef); -#else -#pragma warning(push) -#pragma warning(disable:4995) // wsprintf is deprecated - wsprintf(buf, _T("QIThunk - %-10d\tAddRef :\tObject = 0x%p\tRefcount = %d\t"), m_nIndex, m_pUnk, m_dwRef); -#pragma warning(pop) -#endif - buf[_countof(buf)-1] = 0; - OutputDebugString(buf); - AtlDumpIID(m_iid, m_lpszClassName, S_OK); - - if (l > m_dwMaxRef) - m_dwMaxRef = l; - return l; - } - STDMETHOD_(ULONG, Release)(); - - STDMETHOD(f3)(); - STDMETHOD(f4)(); - STDMETHOD(f5)(); - STDMETHOD(f6)(); - STDMETHOD(f7)(); - STDMETHOD(f8)(); - STDMETHOD(f9)(); - STDMETHOD(f10)(); - STDMETHOD(f11)(); - STDMETHOD(f12)(); - STDMETHOD(f13)(); - STDMETHOD(f14)(); - STDMETHOD(f15)(); - STDMETHOD(f16)(); - STDMETHOD(f17)(); - STDMETHOD(f18)(); - STDMETHOD(f19)(); - STDMETHOD(f20)(); - STDMETHOD(f21)(); - STDMETHOD(f22)(); - STDMETHOD(f23)(); - STDMETHOD(f24)(); - STDMETHOD(f25)(); - STDMETHOD(f26)(); - STDMETHOD(f27)(); - STDMETHOD(f28)(); - STDMETHOD(f29)(); - STDMETHOD(f30)(); - STDMETHOD(f31)(); - STDMETHOD(f32)(); - STDMETHOD(f33)(); - STDMETHOD(f34)(); - STDMETHOD(f35)(); - STDMETHOD(f36)(); - STDMETHOD(f37)(); - STDMETHOD(f38)(); - STDMETHOD(f39)(); - STDMETHOD(f40)(); - STDMETHOD(f41)(); - STDMETHOD(f42)(); - STDMETHOD(f43)(); - STDMETHOD(f44)(); - STDMETHOD(f45)(); - STDMETHOD(f46)(); - STDMETHOD(f47)(); - STDMETHOD(f48)(); - STDMETHOD(f49)(); - STDMETHOD(f50)(); - STDMETHOD(f51)(); - STDMETHOD(f52)(); - STDMETHOD(f53)(); - STDMETHOD(f54)(); - STDMETHOD(f55)(); - STDMETHOD(f56)(); - STDMETHOD(f57)(); - STDMETHOD(f58)(); - STDMETHOD(f59)(); - STDMETHOD(f60)(); - STDMETHOD(f61)(); - STDMETHOD(f62)(); - STDMETHOD(f63)(); - STDMETHOD(f64)(); - STDMETHOD(f65)(); - STDMETHOD(f66)(); - STDMETHOD(f67)(); - STDMETHOD(f68)(); - STDMETHOD(f69)(); - STDMETHOD(f70)(); - STDMETHOD(f71)(); - STDMETHOD(f72)(); - STDMETHOD(f73)(); - STDMETHOD(f74)(); - STDMETHOD(f75)(); - STDMETHOD(f76)(); - STDMETHOD(f77)(); - STDMETHOD(f78)(); - STDMETHOD(f79)(); - STDMETHOD(f80)(); - STDMETHOD(f81)(); - STDMETHOD(f82)(); - STDMETHOD(f83)(); - STDMETHOD(f84)(); - STDMETHOD(f85)(); - STDMETHOD(f86)(); - STDMETHOD(f87)(); - STDMETHOD(f88)(); - STDMETHOD(f89)(); - STDMETHOD(f90)(); - STDMETHOD(f91)(); - STDMETHOD(f92)(); - STDMETHOD(f93)(); - STDMETHOD(f94)(); - STDMETHOD(f95)(); - STDMETHOD(f96)(); - STDMETHOD(f97)(); - STDMETHOD(f98)(); - STDMETHOD(f99)(); - STDMETHOD(f100)(); - STDMETHOD(f101)(); - STDMETHOD(f102)(); - STDMETHOD(f103)(); - STDMETHOD(f104)(); - STDMETHOD(f105)(); - STDMETHOD(f106)(); - STDMETHOD(f107)(); - STDMETHOD(f108)(); - STDMETHOD(f109)(); - STDMETHOD(f110)(); - STDMETHOD(f111)(); - STDMETHOD(f112)(); - STDMETHOD(f113)(); - STDMETHOD(f114)(); - STDMETHOD(f115)(); - STDMETHOD(f116)(); - STDMETHOD(f117)(); - STDMETHOD(f118)(); - STDMETHOD(f119)(); - STDMETHOD(f120)(); - STDMETHOD(f121)(); - STDMETHOD(f122)(); - STDMETHOD(f123)(); - STDMETHOD(f124)(); - STDMETHOD(f125)(); - STDMETHOD(f126)(); - STDMETHOD(f127)(); - STDMETHOD(f128)(); - STDMETHOD(f129)(); - STDMETHOD(f130)(); - STDMETHOD(f131)(); - STDMETHOD(f132)(); - STDMETHOD(f133)(); - STDMETHOD(f134)(); - STDMETHOD(f135)(); - STDMETHOD(f136)(); - STDMETHOD(f137)(); - STDMETHOD(f138)(); - STDMETHOD(f139)(); - STDMETHOD(f140)(); - STDMETHOD(f141)(); - STDMETHOD(f142)(); - STDMETHOD(f143)(); - STDMETHOD(f144)(); - STDMETHOD(f145)(); - STDMETHOD(f146)(); - STDMETHOD(f147)(); - STDMETHOD(f148)(); - STDMETHOD(f149)(); - STDMETHOD(f150)(); - STDMETHOD(f151)(); - STDMETHOD(f152)(); - STDMETHOD(f153)(); - STDMETHOD(f154)(); - STDMETHOD(f155)(); - STDMETHOD(f156)(); - STDMETHOD(f157)(); - STDMETHOD(f158)(); - STDMETHOD(f159)(); - STDMETHOD(f160)(); - STDMETHOD(f161)(); - STDMETHOD(f162)(); - STDMETHOD(f163)(); - STDMETHOD(f164)(); - STDMETHOD(f165)(); - STDMETHOD(f166)(); - STDMETHOD(f167)(); - STDMETHOD(f168)(); - STDMETHOD(f169)(); - STDMETHOD(f170)(); - STDMETHOD(f171)(); - STDMETHOD(f172)(); - STDMETHOD(f173)(); - STDMETHOD(f174)(); - STDMETHOD(f175)(); - STDMETHOD(f176)(); - STDMETHOD(f177)(); - STDMETHOD(f178)(); - STDMETHOD(f179)(); - STDMETHOD(f180)(); - STDMETHOD(f181)(); - STDMETHOD(f182)(); - STDMETHOD(f183)(); - STDMETHOD(f184)(); - STDMETHOD(f185)(); - STDMETHOD(f186)(); - STDMETHOD(f187)(); - STDMETHOD(f188)(); - STDMETHOD(f189)(); - STDMETHOD(f190)(); - STDMETHOD(f191)(); - STDMETHOD(f192)(); - STDMETHOD(f193)(); - STDMETHOD(f194)(); - STDMETHOD(f195)(); - STDMETHOD(f196)(); - STDMETHOD(f197)(); - STDMETHOD(f198)(); - STDMETHOD(f199)(); - STDMETHOD(f200)(); - STDMETHOD(f201)(); - STDMETHOD(f202)(); - STDMETHOD(f203)(); - STDMETHOD(f204)(); - STDMETHOD(f205)(); - STDMETHOD(f206)(); - STDMETHOD(f207)(); - STDMETHOD(f208)(); - STDMETHOD(f209)(); - STDMETHOD(f210)(); - STDMETHOD(f211)(); - STDMETHOD(f212)(); - STDMETHOD(f213)(); - STDMETHOD(f214)(); - STDMETHOD(f215)(); - STDMETHOD(f216)(); - STDMETHOD(f217)(); - STDMETHOD(f218)(); - STDMETHOD(f219)(); - STDMETHOD(f220)(); - STDMETHOD(f221)(); - STDMETHOD(f222)(); - STDMETHOD(f223)(); - STDMETHOD(f224)(); - STDMETHOD(f225)(); - STDMETHOD(f226)(); - STDMETHOD(f227)(); - STDMETHOD(f228)(); - STDMETHOD(f229)(); - STDMETHOD(f230)(); - STDMETHOD(f231)(); - STDMETHOD(f232)(); - STDMETHOD(f233)(); - STDMETHOD(f234)(); - STDMETHOD(f235)(); - STDMETHOD(f236)(); - STDMETHOD(f237)(); - STDMETHOD(f238)(); - STDMETHOD(f239)(); - STDMETHOD(f240)(); - STDMETHOD(f241)(); - STDMETHOD(f242)(); - STDMETHOD(f243)(); - STDMETHOD(f244)(); - STDMETHOD(f245)(); - STDMETHOD(f246)(); - STDMETHOD(f247)(); - STDMETHOD(f248)(); - STDMETHOD(f249)(); - STDMETHOD(f250)(); - STDMETHOD(f251)(); - STDMETHOD(f252)(); - STDMETHOD(f253)(); - STDMETHOD(f254)(); - STDMETHOD(f255)(); - STDMETHOD(f256)(); - STDMETHOD(f257)(); - STDMETHOD(f258)(); - STDMETHOD(f259)(); - STDMETHOD(f260)(); - STDMETHOD(f261)(); - STDMETHOD(f262)(); - STDMETHOD(f263)(); - STDMETHOD(f264)(); - STDMETHOD(f265)(); - STDMETHOD(f266)(); - STDMETHOD(f267)(); - STDMETHOD(f268)(); - STDMETHOD(f269)(); - STDMETHOD(f270)(); - STDMETHOD(f271)(); - STDMETHOD(f272)(); - STDMETHOD(f273)(); - STDMETHOD(f274)(); - STDMETHOD(f275)(); - STDMETHOD(f276)(); - STDMETHOD(f277)(); - STDMETHOD(f278)(); - STDMETHOD(f279)(); - STDMETHOD(f280)(); - STDMETHOD(f281)(); - STDMETHOD(f282)(); - STDMETHOD(f283)(); - STDMETHOD(f284)(); - STDMETHOD(f285)(); - STDMETHOD(f286)(); - STDMETHOD(f287)(); - STDMETHOD(f288)(); - STDMETHOD(f289)(); - STDMETHOD(f290)(); - STDMETHOD(f291)(); - STDMETHOD(f292)(); - STDMETHOD(f293)(); - STDMETHOD(f294)(); - STDMETHOD(f295)(); - STDMETHOD(f296)(); - STDMETHOD(f297)(); - STDMETHOD(f298)(); - STDMETHOD(f299)(); - STDMETHOD(f300)(); - STDMETHOD(f301)(); - STDMETHOD(f302)(); - STDMETHOD(f303)(); - STDMETHOD(f304)(); - STDMETHOD(f305)(); - STDMETHOD(f306)(); - STDMETHOD(f307)(); - STDMETHOD(f308)(); - STDMETHOD(f309)(); - STDMETHOD(f310)(); - STDMETHOD(f311)(); - STDMETHOD(f312)(); - STDMETHOD(f313)(); - STDMETHOD(f314)(); - STDMETHOD(f315)(); - STDMETHOD(f316)(); - STDMETHOD(f317)(); - STDMETHOD(f318)(); - STDMETHOD(f319)(); - STDMETHOD(f320)(); - STDMETHOD(f321)(); - STDMETHOD(f322)(); - STDMETHOD(f323)(); - STDMETHOD(f324)(); - STDMETHOD(f325)(); - STDMETHOD(f326)(); - STDMETHOD(f327)(); - STDMETHOD(f328)(); - STDMETHOD(f329)(); - STDMETHOD(f330)(); - STDMETHOD(f331)(); - STDMETHOD(f332)(); - STDMETHOD(f333)(); - STDMETHOD(f334)(); - STDMETHOD(f335)(); - STDMETHOD(f336)(); - STDMETHOD(f337)(); - STDMETHOD(f338)(); - STDMETHOD(f339)(); - STDMETHOD(f340)(); - STDMETHOD(f341)(); - STDMETHOD(f342)(); - STDMETHOD(f343)(); - STDMETHOD(f344)(); - STDMETHOD(f345)(); - STDMETHOD(f346)(); - STDMETHOD(f347)(); - STDMETHOD(f348)(); - STDMETHOD(f349)(); - STDMETHOD(f350)(); - STDMETHOD(f351)(); - STDMETHOD(f352)(); - STDMETHOD(f353)(); - STDMETHOD(f354)(); - STDMETHOD(f355)(); - STDMETHOD(f356)(); - STDMETHOD(f357)(); - STDMETHOD(f358)(); - STDMETHOD(f359)(); - STDMETHOD(f360)(); - STDMETHOD(f361)(); - STDMETHOD(f362)(); - STDMETHOD(f363)(); - STDMETHOD(f364)(); - STDMETHOD(f365)(); - STDMETHOD(f366)(); - STDMETHOD(f367)(); - STDMETHOD(f368)(); - STDMETHOD(f369)(); - STDMETHOD(f370)(); - STDMETHOD(f371)(); - STDMETHOD(f372)(); - STDMETHOD(f373)(); - STDMETHOD(f374)(); - STDMETHOD(f375)(); - STDMETHOD(f376)(); - STDMETHOD(f377)(); - STDMETHOD(f378)(); - STDMETHOD(f379)(); - STDMETHOD(f380)(); - STDMETHOD(f381)(); - STDMETHOD(f382)(); - STDMETHOD(f383)(); - STDMETHOD(f384)(); - STDMETHOD(f385)(); - STDMETHOD(f386)(); - STDMETHOD(f387)(); - STDMETHOD(f388)(); - STDMETHOD(f389)(); - STDMETHOD(f390)(); - STDMETHOD(f391)(); - STDMETHOD(f392)(); - STDMETHOD(f393)(); - STDMETHOD(f394)(); - STDMETHOD(f395)(); - STDMETHOD(f396)(); - STDMETHOD(f397)(); - STDMETHOD(f398)(); - STDMETHOD(f399)(); - STDMETHOD(f400)(); - STDMETHOD(f401)(); - STDMETHOD(f402)(); - STDMETHOD(f403)(); - STDMETHOD(f404)(); - STDMETHOD(f405)(); - STDMETHOD(f406)(); - STDMETHOD(f407)(); - STDMETHOD(f408)(); - STDMETHOD(f409)(); - STDMETHOD(f410)(); - STDMETHOD(f411)(); - STDMETHOD(f412)(); - STDMETHOD(f413)(); - STDMETHOD(f414)(); - STDMETHOD(f415)(); - STDMETHOD(f416)(); - STDMETHOD(f417)(); - STDMETHOD(f418)(); - STDMETHOD(f419)(); - STDMETHOD(f420)(); - STDMETHOD(f421)(); - STDMETHOD(f422)(); - STDMETHOD(f423)(); - STDMETHOD(f424)(); - STDMETHOD(f425)(); - STDMETHOD(f426)(); - STDMETHOD(f427)(); - STDMETHOD(f428)(); - STDMETHOD(f429)(); - STDMETHOD(f430)(); - STDMETHOD(f431)(); - STDMETHOD(f432)(); - STDMETHOD(f433)(); - STDMETHOD(f434)(); - STDMETHOD(f435)(); - STDMETHOD(f436)(); - STDMETHOD(f437)(); - STDMETHOD(f438)(); - STDMETHOD(f439)(); - STDMETHOD(f440)(); - STDMETHOD(f441)(); - STDMETHOD(f442)(); - STDMETHOD(f443)(); - STDMETHOD(f444)(); - STDMETHOD(f445)(); - STDMETHOD(f446)(); - STDMETHOD(f447)(); - STDMETHOD(f448)(); - STDMETHOD(f449)(); - STDMETHOD(f450)(); - STDMETHOD(f451)(); - STDMETHOD(f452)(); - STDMETHOD(f453)(); - STDMETHOD(f454)(); - STDMETHOD(f455)(); - STDMETHOD(f456)(); - STDMETHOD(f457)(); - STDMETHOD(f458)(); - STDMETHOD(f459)(); - STDMETHOD(f460)(); - STDMETHOD(f461)(); - STDMETHOD(f462)(); - STDMETHOD(f463)(); - STDMETHOD(f464)(); - STDMETHOD(f465)(); - STDMETHOD(f466)(); - STDMETHOD(f467)(); - STDMETHOD(f468)(); - STDMETHOD(f469)(); - STDMETHOD(f470)(); - STDMETHOD(f471)(); - STDMETHOD(f472)(); - STDMETHOD(f473)(); - STDMETHOD(f474)(); - STDMETHOD(f475)(); - STDMETHOD(f476)(); - STDMETHOD(f477)(); - STDMETHOD(f478)(); - STDMETHOD(f479)(); - STDMETHOD(f480)(); - STDMETHOD(f481)(); - STDMETHOD(f482)(); - STDMETHOD(f483)(); - STDMETHOD(f484)(); - STDMETHOD(f485)(); - STDMETHOD(f486)(); - STDMETHOD(f487)(); - STDMETHOD(f488)(); - STDMETHOD(f489)(); - STDMETHOD(f490)(); - STDMETHOD(f491)(); - STDMETHOD(f492)(); - STDMETHOD(f493)(); - STDMETHOD(f494)(); - STDMETHOD(f495)(); - STDMETHOD(f496)(); - STDMETHOD(f497)(); - STDMETHOD(f498)(); - STDMETHOD(f499)(); - STDMETHOD(f500)(); - STDMETHOD(f501)(); - STDMETHOD(f502)(); - STDMETHOD(f503)(); - STDMETHOD(f504)(); - STDMETHOD(f505)(); - STDMETHOD(f506)(); - STDMETHOD(f507)(); - STDMETHOD(f508)(); - STDMETHOD(f509)(); - STDMETHOD(f510)(); - STDMETHOD(f511)(); - STDMETHOD(f512)(); - STDMETHOD(f513)(); - STDMETHOD(f514)(); - STDMETHOD(f515)(); - STDMETHOD(f516)(); - STDMETHOD(f517)(); - STDMETHOD(f518)(); - STDMETHOD(f519)(); - STDMETHOD(f520)(); - STDMETHOD(f521)(); - STDMETHOD(f522)(); - STDMETHOD(f523)(); - STDMETHOD(f524)(); - STDMETHOD(f525)(); - STDMETHOD(f526)(); - STDMETHOD(f527)(); - STDMETHOD(f528)(); - STDMETHOD(f529)(); - STDMETHOD(f530)(); - STDMETHOD(f531)(); - STDMETHOD(f532)(); - STDMETHOD(f533)(); - STDMETHOD(f534)(); - STDMETHOD(f535)(); - STDMETHOD(f536)(); - STDMETHOD(f537)(); - STDMETHOD(f538)(); - STDMETHOD(f539)(); - STDMETHOD(f540)(); - STDMETHOD(f541)(); - STDMETHOD(f542)(); - STDMETHOD(f543)(); - STDMETHOD(f544)(); - STDMETHOD(f545)(); - STDMETHOD(f546)(); - STDMETHOD(f547)(); - STDMETHOD(f548)(); - STDMETHOD(f549)(); - STDMETHOD(f550)(); - STDMETHOD(f551)(); - STDMETHOD(f552)(); - STDMETHOD(f553)(); - STDMETHOD(f554)(); - STDMETHOD(f555)(); - STDMETHOD(f556)(); - STDMETHOD(f557)(); - STDMETHOD(f558)(); - STDMETHOD(f559)(); - STDMETHOD(f560)(); - STDMETHOD(f561)(); - STDMETHOD(f562)(); - STDMETHOD(f563)(); - STDMETHOD(f564)(); - STDMETHOD(f565)(); - STDMETHOD(f566)(); - STDMETHOD(f567)(); - STDMETHOD(f568)(); - STDMETHOD(f569)(); - STDMETHOD(f570)(); - STDMETHOD(f571)(); - STDMETHOD(f572)(); - STDMETHOD(f573)(); - STDMETHOD(f574)(); - STDMETHOD(f575)(); - STDMETHOD(f576)(); - STDMETHOD(f577)(); - STDMETHOD(f578)(); - STDMETHOD(f579)(); - STDMETHOD(f580)(); - STDMETHOD(f581)(); - STDMETHOD(f582)(); - STDMETHOD(f583)(); - STDMETHOD(f584)(); - STDMETHOD(f585)(); - STDMETHOD(f586)(); - STDMETHOD(f587)(); - STDMETHOD(f588)(); - STDMETHOD(f589)(); - STDMETHOD(f590)(); - STDMETHOD(f591)(); - STDMETHOD(f592)(); - STDMETHOD(f593)(); - STDMETHOD(f594)(); - STDMETHOD(f595)(); - STDMETHOD(f596)(); - STDMETHOD(f597)(); - STDMETHOD(f598)(); - STDMETHOD(f599)(); - STDMETHOD(f600)(); - STDMETHOD(f601)(); - STDMETHOD(f602)(); - STDMETHOD(f603)(); - STDMETHOD(f604)(); - STDMETHOD(f605)(); - STDMETHOD(f606)(); - STDMETHOD(f607)(); - STDMETHOD(f608)(); - STDMETHOD(f609)(); - STDMETHOD(f610)(); - STDMETHOD(f611)(); - STDMETHOD(f612)(); - STDMETHOD(f613)(); - STDMETHOD(f614)(); - STDMETHOD(f615)(); - STDMETHOD(f616)(); - STDMETHOD(f617)(); - STDMETHOD(f618)(); - STDMETHOD(f619)(); - STDMETHOD(f620)(); - STDMETHOD(f621)(); - STDMETHOD(f622)(); - STDMETHOD(f623)(); - STDMETHOD(f624)(); - STDMETHOD(f625)(); - STDMETHOD(f626)(); - STDMETHOD(f627)(); - STDMETHOD(f628)(); - STDMETHOD(f629)(); - STDMETHOD(f630)(); - STDMETHOD(f631)(); - STDMETHOD(f632)(); - STDMETHOD(f633)(); - STDMETHOD(f634)(); - STDMETHOD(f635)(); - STDMETHOD(f636)(); - STDMETHOD(f637)(); - STDMETHOD(f638)(); - STDMETHOD(f639)(); - STDMETHOD(f640)(); - STDMETHOD(f641)(); - STDMETHOD(f642)(); - STDMETHOD(f643)(); - STDMETHOD(f644)(); - STDMETHOD(f645)(); - STDMETHOD(f646)(); - STDMETHOD(f647)(); - STDMETHOD(f648)(); - STDMETHOD(f649)(); - STDMETHOD(f650)(); - STDMETHOD(f651)(); - STDMETHOD(f652)(); - STDMETHOD(f653)(); - STDMETHOD(f654)(); - STDMETHOD(f655)(); - STDMETHOD(f656)(); - STDMETHOD(f657)(); - STDMETHOD(f658)(); - STDMETHOD(f659)(); - STDMETHOD(f660)(); - STDMETHOD(f661)(); - STDMETHOD(f662)(); - STDMETHOD(f663)(); - STDMETHOD(f664)(); - STDMETHOD(f665)(); - STDMETHOD(f666)(); - STDMETHOD(f667)(); - STDMETHOD(f668)(); - STDMETHOD(f669)(); - STDMETHOD(f670)(); - STDMETHOD(f671)(); - STDMETHOD(f672)(); - STDMETHOD(f673)(); - STDMETHOD(f674)(); - STDMETHOD(f675)(); - STDMETHOD(f676)(); - STDMETHOD(f677)(); - STDMETHOD(f678)(); - STDMETHOD(f679)(); - STDMETHOD(f680)(); - STDMETHOD(f681)(); - STDMETHOD(f682)(); - STDMETHOD(f683)(); - STDMETHOD(f684)(); - STDMETHOD(f685)(); - STDMETHOD(f686)(); - STDMETHOD(f687)(); - STDMETHOD(f688)(); - STDMETHOD(f689)(); - STDMETHOD(f690)(); - STDMETHOD(f691)(); - STDMETHOD(f692)(); - STDMETHOD(f693)(); - STDMETHOD(f694)(); - STDMETHOD(f695)(); - STDMETHOD(f696)(); - STDMETHOD(f697)(); - STDMETHOD(f698)(); - STDMETHOD(f699)(); - STDMETHOD(f700)(); - STDMETHOD(f701)(); - STDMETHOD(f702)(); - STDMETHOD(f703)(); - STDMETHOD(f704)(); - STDMETHOD(f705)(); - STDMETHOD(f706)(); - STDMETHOD(f707)(); - STDMETHOD(f708)(); - STDMETHOD(f709)(); - STDMETHOD(f710)(); - STDMETHOD(f711)(); - STDMETHOD(f712)(); - STDMETHOD(f713)(); - STDMETHOD(f714)(); - STDMETHOD(f715)(); - STDMETHOD(f716)(); - STDMETHOD(f717)(); - STDMETHOD(f718)(); - STDMETHOD(f719)(); - STDMETHOD(f720)(); - STDMETHOD(f721)(); - STDMETHOD(f722)(); - STDMETHOD(f723)(); - STDMETHOD(f724)(); - STDMETHOD(f725)(); - STDMETHOD(f726)(); - STDMETHOD(f727)(); - STDMETHOD(f728)(); - STDMETHOD(f729)(); - STDMETHOD(f730)(); - STDMETHOD(f731)(); - STDMETHOD(f732)(); - STDMETHOD(f733)(); - STDMETHOD(f734)(); - STDMETHOD(f735)(); - STDMETHOD(f736)(); - STDMETHOD(f737)(); - STDMETHOD(f738)(); - STDMETHOD(f739)(); - STDMETHOD(f740)(); - STDMETHOD(f741)(); - STDMETHOD(f742)(); - STDMETHOD(f743)(); - STDMETHOD(f744)(); - STDMETHOD(f745)(); - STDMETHOD(f746)(); - STDMETHOD(f747)(); - STDMETHOD(f748)(); - STDMETHOD(f749)(); - STDMETHOD(f750)(); - STDMETHOD(f751)(); - STDMETHOD(f752)(); - STDMETHOD(f753)(); - STDMETHOD(f754)(); - STDMETHOD(f755)(); - STDMETHOD(f756)(); - STDMETHOD(f757)(); - STDMETHOD(f758)(); - STDMETHOD(f759)(); - STDMETHOD(f760)(); - STDMETHOD(f761)(); - STDMETHOD(f762)(); - STDMETHOD(f763)(); - STDMETHOD(f764)(); - STDMETHOD(f765)(); - STDMETHOD(f766)(); - STDMETHOD(f767)(); - STDMETHOD(f768)(); - STDMETHOD(f769)(); - STDMETHOD(f770)(); - STDMETHOD(f771)(); - STDMETHOD(f772)(); - STDMETHOD(f773)(); - STDMETHOD(f774)(); - STDMETHOD(f775)(); - STDMETHOD(f776)(); - STDMETHOD(f777)(); - STDMETHOD(f778)(); - STDMETHOD(f779)(); - STDMETHOD(f780)(); - STDMETHOD(f781)(); - STDMETHOD(f782)(); - STDMETHOD(f783)(); - STDMETHOD(f784)(); - STDMETHOD(f785)(); - STDMETHOD(f786)(); - STDMETHOD(f787)(); - STDMETHOD(f788)(); - STDMETHOD(f789)(); - STDMETHOD(f790)(); - STDMETHOD(f791)(); - STDMETHOD(f792)(); - STDMETHOD(f793)(); - STDMETHOD(f794)(); - STDMETHOD(f795)(); - STDMETHOD(f796)(); - STDMETHOD(f797)(); - STDMETHOD(f798)(); - STDMETHOD(f799)(); - STDMETHOD(f800)(); - STDMETHOD(f801)(); - STDMETHOD(f802)(); - STDMETHOD(f803)(); - STDMETHOD(f804)(); - STDMETHOD(f805)(); - STDMETHOD(f806)(); - STDMETHOD(f807)(); - STDMETHOD(f808)(); - STDMETHOD(f809)(); - STDMETHOD(f810)(); - STDMETHOD(f811)(); - STDMETHOD(f812)(); - STDMETHOD(f813)(); - STDMETHOD(f814)(); - STDMETHOD(f815)(); - STDMETHOD(f816)(); - STDMETHOD(f817)(); - STDMETHOD(f818)(); - STDMETHOD(f819)(); - STDMETHOD(f820)(); - STDMETHOD(f821)(); - STDMETHOD(f822)(); - STDMETHOD(f823)(); - STDMETHOD(f824)(); - STDMETHOD(f825)(); - STDMETHOD(f826)(); - STDMETHOD(f827)(); - STDMETHOD(f828)(); - STDMETHOD(f829)(); - STDMETHOD(f830)(); - STDMETHOD(f831)(); - STDMETHOD(f832)(); - STDMETHOD(f833)(); - STDMETHOD(f834)(); - STDMETHOD(f835)(); - STDMETHOD(f836)(); - STDMETHOD(f837)(); - STDMETHOD(f838)(); - STDMETHOD(f839)(); - STDMETHOD(f840)(); - STDMETHOD(f841)(); - STDMETHOD(f842)(); - STDMETHOD(f843)(); - STDMETHOD(f844)(); - STDMETHOD(f845)(); - STDMETHOD(f846)(); - STDMETHOD(f847)(); - STDMETHOD(f848)(); - STDMETHOD(f849)(); - STDMETHOD(f850)(); - STDMETHOD(f851)(); - STDMETHOD(f852)(); - STDMETHOD(f853)(); - STDMETHOD(f854)(); - STDMETHOD(f855)(); - STDMETHOD(f856)(); - STDMETHOD(f857)(); - STDMETHOD(f858)(); - STDMETHOD(f859)(); - STDMETHOD(f860)(); - STDMETHOD(f861)(); - STDMETHOD(f862)(); - STDMETHOD(f863)(); - STDMETHOD(f864)(); - STDMETHOD(f865)(); - STDMETHOD(f866)(); - STDMETHOD(f867)(); - STDMETHOD(f868)(); - STDMETHOD(f869)(); - STDMETHOD(f870)(); - STDMETHOD(f871)(); - STDMETHOD(f872)(); - STDMETHOD(f873)(); - STDMETHOD(f874)(); - STDMETHOD(f875)(); - STDMETHOD(f876)(); - STDMETHOD(f877)(); - STDMETHOD(f878)(); - STDMETHOD(f879)(); - STDMETHOD(f880)(); - STDMETHOD(f881)(); - STDMETHOD(f882)(); - STDMETHOD(f883)(); - STDMETHOD(f884)(); - STDMETHOD(f885)(); - STDMETHOD(f886)(); - STDMETHOD(f887)(); - STDMETHOD(f888)(); - STDMETHOD(f889)(); - STDMETHOD(f890)(); - STDMETHOD(f891)(); - STDMETHOD(f892)(); - STDMETHOD(f893)(); - STDMETHOD(f894)(); - STDMETHOD(f895)(); - STDMETHOD(f896)(); - STDMETHOD(f897)(); - STDMETHOD(f898)(); - STDMETHOD(f899)(); - STDMETHOD(f900)(); - STDMETHOD(f901)(); - STDMETHOD(f902)(); - STDMETHOD(f903)(); - STDMETHOD(f904)(); - STDMETHOD(f905)(); - STDMETHOD(f906)(); - STDMETHOD(f907)(); - STDMETHOD(f908)(); - STDMETHOD(f909)(); - STDMETHOD(f910)(); - STDMETHOD(f911)(); - STDMETHOD(f912)(); - STDMETHOD(f913)(); - STDMETHOD(f914)(); - STDMETHOD(f915)(); - STDMETHOD(f916)(); - STDMETHOD(f917)(); - STDMETHOD(f918)(); - STDMETHOD(f919)(); - STDMETHOD(f920)(); - STDMETHOD(f921)(); - STDMETHOD(f922)(); - STDMETHOD(f923)(); - STDMETHOD(f924)(); - STDMETHOD(f925)(); - STDMETHOD(f926)(); - STDMETHOD(f927)(); - STDMETHOD(f928)(); - STDMETHOD(f929)(); - STDMETHOD(f930)(); - STDMETHOD(f931)(); - STDMETHOD(f932)(); - STDMETHOD(f933)(); - STDMETHOD(f934)(); - STDMETHOD(f935)(); - STDMETHOD(f936)(); - STDMETHOD(f937)(); - STDMETHOD(f938)(); - STDMETHOD(f939)(); - STDMETHOD(f940)(); - STDMETHOD(f941)(); - STDMETHOD(f942)(); - STDMETHOD(f943)(); - STDMETHOD(f944)(); - STDMETHOD(f945)(); - STDMETHOD(f946)(); - STDMETHOD(f947)(); - STDMETHOD(f948)(); - STDMETHOD(f949)(); - STDMETHOD(f950)(); - STDMETHOD(f951)(); - STDMETHOD(f952)(); - STDMETHOD(f953)(); - STDMETHOD(f954)(); - STDMETHOD(f955)(); - STDMETHOD(f956)(); - STDMETHOD(f957)(); - STDMETHOD(f958)(); - STDMETHOD(f959)(); - STDMETHOD(f960)(); - STDMETHOD(f961)(); - STDMETHOD(f962)(); - STDMETHOD(f963)(); - STDMETHOD(f964)(); - STDMETHOD(f965)(); - STDMETHOD(f966)(); - STDMETHOD(f967)(); - STDMETHOD(f968)(); - STDMETHOD(f969)(); - STDMETHOD(f970)(); - STDMETHOD(f971)(); - STDMETHOD(f972)(); - STDMETHOD(f973)(); - STDMETHOD(f974)(); - STDMETHOD(f975)(); - STDMETHOD(f976)(); - STDMETHOD(f977)(); - STDMETHOD(f978)(); - STDMETHOD(f979)(); - STDMETHOD(f980)(); - STDMETHOD(f981)(); - STDMETHOD(f982)(); - STDMETHOD(f983)(); - STDMETHOD(f984)(); - STDMETHOD(f985)(); - STDMETHOD(f986)(); - STDMETHOD(f987)(); - STDMETHOD(f988)(); - STDMETHOD(f989)(); - STDMETHOD(f990)(); - STDMETHOD(f991)(); - STDMETHOD(f992)(); - STDMETHOD(f993)(); - STDMETHOD(f994)(); - STDMETHOD(f995)(); - STDMETHOD(f996)(); - STDMETHOD(f997)(); - STDMETHOD(f998)(); - STDMETHOD(f999)(); - STDMETHOD(f1000)(); - STDMETHOD(f1001)(); - STDMETHOD(f1002)(); - STDMETHOD(f1003)(); - STDMETHOD(f1004)(); - STDMETHOD(f1005)(); - STDMETHOD(f1006)(); - STDMETHOD(f1007)(); - STDMETHOD(f1008)(); - STDMETHOD(f1009)(); - STDMETHOD(f1010)(); - STDMETHOD(f1011)(); - STDMETHOD(f1012)(); - STDMETHOD(f1013)(); - STDMETHOD(f1014)(); - STDMETHOD(f1015)(); - STDMETHOD(f1016)(); - STDMETHOD(f1017)(); - STDMETHOD(f1018)(); - STDMETHOD(f1019)(); - STDMETHOD(f1020)(); - STDMETHOD(f1021)(); - STDMETHOD(f1022)(); - STDMETHOD(f1023)(); - _QIThunk(IUnknown* pOrig, LPCTSTR p, const IID& i, UINT n, bool b) - { - m_lpszClassName = p; - m_iid = i; - m_nIndex = n; - m_dwRef = 0; - m_dwMaxRef = 0; - ATLENSURE(pOrig); - m_pUnk = pOrig; - m_bBreak = b; - m_bNonAddRefThunk = false; - } - IUnknown* m_pUnk; - long m_dwRef; - long m_dwMaxRef; - LPCTSTR m_lpszClassName; - IID m_iid; - UINT m_nIndex; - bool m_bBreak; - bool m_bNonAddRefThunk; - void Dump() throw(); -}; - -#endif - -///////////////////////////////////////////////////////////////////////////// -// Module Classes - - -#ifdef _ATL_STATIC_REGISTRY -#define UpdateRegistryFromResource UpdateRegistryFromResourceS -#else -#define UpdateRegistryFromResource UpdateRegistryFromResourceD -#endif // _ATL_STATIC_REGISTRY - - -class CAtlComModule : public _ATL_COM_MODULE -{ -public: - - CAtlComModule() throw() - { - cbSize = 0; - - m_hInstTypeLib = reinterpret_cast(&__ImageBase); - - m_ppAutoObjMapFirst = &__pobjMapEntryFirst + 1; - m_ppAutoObjMapLast = &__pobjMapEntryLast; - - if (FAILED(m_csObjMap.Init())) - { - ATLTRACE(atlTraceCOM, 0, _T("ERROR : Unable to initialize critical section in CAtlComModule\n")); - ATLASSERT(0); - CAtlBaseModule::m_bInitFailed = true; - return; - } - // Set cbSize on success. - cbSize = sizeof(_ATL_COM_MODULE); - } - - ~CAtlComModule() - { - Term(); - } - - // Called from ~CAtlComModule or from ~CAtlExeModule. - void Term() - { - if (cbSize == 0) - return; - - for (_ATL_OBJMAP_ENTRY** ppEntry = m_ppAutoObjMapFirst; ppEntry < m_ppAutoObjMapLast; ppEntry++) - { - if (*ppEntry != NULL) - { - _ATL_OBJMAP_ENTRY* pEntry = *ppEntry; - if (pEntry->pCF != NULL) - pEntry->pCF->Release(); - pEntry->pCF = NULL; - } - } - m_csObjMap.Term(); - // Set to 0 to indicate that this function has been called - // At this point no one should be concerned about cbsize - // having the correct value - cbSize = 0; - } - - // Registry support (helpers) - HRESULT RegisterTypeLib() - { - return AtlRegisterTypeLib(m_hInstTypeLib, NULL); - } - HRESULT RegisterTypeLib(LPCTSTR lpszIndex) - { - USES_CONVERSION_EX; - LPCOLESTR pwszTemp = NULL; - if( lpszIndex != NULL ) - { - pwszTemp = T2COLE_EX(lpszIndex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if( pwszTemp == NULL ) - return E_OUTOFMEMORY; -#endif - } - return AtlRegisterTypeLib(m_hInstTypeLib, pwszTemp); - } - HRESULT UnRegisterTypeLib() - { - return AtlUnRegisterTypeLib(m_hInstTypeLib, NULL); - } - HRESULT UnRegisterTypeLib(LPCTSTR lpszIndex) - { - USES_CONVERSION_EX; - LPCOLESTR pwszTemp = NULL; - if( lpszIndex != NULL ) - { - pwszTemp = T2COLE_EX(lpszIndex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if( pwszTemp == NULL ) - return E_OUTOFMEMORY; -#endif - } - return AtlUnRegisterTypeLib(m_hInstTypeLib, pwszTemp); - } - - // RegisterServer walks the ATL Autogenerated object map and registers each object in the map - // If pCLSID is not NULL then only the object referred to by pCLSID is registered (The default case) - // otherwise all the objects are registered - HRESULT RegisterServer(BOOL bRegTypeLib = FALSE, const CLSID* pCLSID = NULL) - { - return AtlComModuleRegisterServer(this, bRegTypeLib, pCLSID); - } - - // UnregisterServer walks the ATL Autogenerated object map and unregisters each object in the map - // If pCLSID is not NULL then only the object referred to by pCLSID is unregistered (The default case) - // otherwise all the objects are unregistered. - HRESULT UnregisterServer(BOOL bRegTypeLib = FALSE, const CLSID* pCLSID = NULL) - { - return AtlComModuleUnregisterServer(this, bRegTypeLib, pCLSID); - } - - // Implementation - - // Call ObjectMain for all the objects. - void ExecuteObjectMain(bool bStarting) - { - for (_ATL_OBJMAP_ENTRY** ppEntry = m_ppAutoObjMapFirst; ppEntry < m_ppAutoObjMapLast; ppEntry++) - { - if (*ppEntry != NULL) - (*ppEntry)->pfnObjectMain(bStarting); - } - } -}; - -extern CAtlComModule _AtlComModule; - -#ifdef _ATL_DEBUG_INTERFACES - -class CAtlDebugInterfacesModule -{ -public: - CAtlDebugInterfacesModule() throw() : - m_nIndexQI( 0 ), - m_nIndexBreakAt( 0 ) - { - if (FAILED(m_cs.Init())) - { - ATLTRACE(atlTraceCOM, 0, _T("ERROR : Unable to initialize critical section in CAtlDebugInterfacesModule\n")); - ATLASSERT(0); - CAtlBaseModule::m_bInitFailed = true; - } - } - ~CAtlDebugInterfacesModule() throw() - { - // Release all class factories. - _AtlComModule.Term(); - DumpLeakedThunks(); - } - - HRESULT AddThunk(IUnknown** pp, LPCTSTR lpsz, REFIID iid) throw() - { - if ((pp == NULL) || (*pp == NULL)) - return E_POINTER; - IUnknown* p = *pp; - _QIThunk* pThunk = NULL; - CComCritSecLock lock(m_cs, false); - HRESULT hr = lock.Lock(); - if (FAILED(hr)) - { - ATLTRACE(atlTraceCOM, 0, _T("ERROR : Unable to lock critical section in CAtlDebugInterfacesModule\n")); - ATLASSERT(0); - return hr; - } - - // Check if exists for identity - if (InlineIsEqualUnknown(iid)) - { - for (int i = 0; i < m_aThunks.GetSize(); i++) - { - if (m_aThunks[i]->m_pUnk == p && InlineIsEqualGUID(m_aThunks[i]->m_iid, iid)) - { - m_aThunks[i]->InternalAddRef(); - pThunk = m_aThunks[i]; - break; - } - } - } - if (pThunk == NULL) - { - ++m_nIndexQI; - if (m_nIndexBreakAt == m_nIndexQI) - DebugBreak(); - ATLTRY(pThunk = new _QIThunk(p, lpsz, iid, m_nIndexQI, (m_nIndexBreakAt == m_nIndexQI))); - if (pThunk == NULL) - { - return E_OUTOFMEMORY; - } - pThunk->InternalAddRef(); - m_aThunks.Add(pThunk); - } - *pp = (IUnknown*)pThunk; - return S_OK; - } - HRESULT AddNonAddRefThunk(IUnknown* p, LPCTSTR lpsz, IUnknown** ppThunkRet) throw() - { - if (ppThunkRet == NULL) - return E_POINTER; - *ppThunkRet = NULL; - - _QIThunk* pThunk = NULL; - CComCritSecLock lock(m_cs, false); - HRESULT hr = lock.Lock(); - if (FAILED(hr)) - { - ATLTRACE(atlTraceCOM, 0, _T("ERROR : Unable to lock critical section in CAtlDebugInterfacesModule\n")); - ATLASSERT(0); - return hr; - } - - // Check if exists already for identity - for (int i = 0; i < m_aThunks.GetSize(); i++) - { - if (m_aThunks[i]->m_pUnk == p) - { - m_aThunks[i]->m_bNonAddRefThunk = true; - pThunk = m_aThunks[i]; - break; - } - } - if (pThunk == NULL) - { - ++m_nIndexQI; - if (m_nIndexBreakAt == m_nIndexQI) - DebugBreak(); - ATLTRY(pThunk = new _QIThunk(p, lpsz, __uuidof(IUnknown), m_nIndexQI, (m_nIndexBreakAt == m_nIndexQI))); - if (pThunk == NULL) - { - return E_OUTOFMEMORY; - } - pThunk->m_bNonAddRefThunk = true; - m_aThunks.Add(pThunk); - } - *ppThunkRet = (IUnknown*)pThunk; - return S_OK;; - } - void DeleteNonAddRefThunk(IUnknown* pUnk) throw() - { - CComCritSecLock lock(m_cs, false); - HRESULT hr = lock.Lock(); - if (FAILED(hr)) - { - ATLTRACE(atlTraceCOM, 0, _T("ERROR : Unable to lock critical section in CAtlDebugInterfacesModule\n")); - ATLASSERT(0); - return; - } - - for (int i = 0; i < m_aThunks.GetSize(); i++) - { - if (m_aThunks[i]->m_bNonAddRefThunk && m_aThunks[i]->m_pUnk == pUnk) - { - delete m_aThunks[i]; - m_aThunks.RemoveAt(i); - break; - } - } - } - void DeleteThunk(_QIThunk* p) throw() - { - CComCritSecLock lock(m_cs, false); - HRESULT hr = lock.Lock(); - if (FAILED(hr)) - { - ATLTRACE(atlTraceCOM, 0, _T("ERROR : Unable to lock critical section in CAtlDebugInterfacesModule\n")); - ATLASSERT(0); - return; - } - - int nIndex = m_aThunks.Find(p); - if (nIndex != -1) - { - m_aThunks[nIndex]->m_pUnk = NULL; - delete m_aThunks[nIndex]; - m_aThunks.RemoveAt(nIndex); - } - } - bool DumpLeakedThunks() - { - bool b = false; - for (int i = 0; i < m_aThunks.GetSize(); i++) - { - b = true; - m_aThunks[i]->Dump(); - delete m_aThunks[i]; - } - m_aThunks.RemoveAll(); - return b; - } - -public: - UINT m_nIndexQI; - UINT m_nIndexBreakAt; - CSimpleArray<_QIThunk*> m_aThunks; - CComAutoDeleteCriticalSection m_cs; -}; - -extern CAtlDebugInterfacesModule _AtlDebugInterfacesModule; - -#ifndef _ATL_STATIC_LIB_IMPL -// Should not be pulled into the static lib -__declspec (selectany) CAtlDebugInterfacesModule _AtlDebugInterfacesModule; -#endif - -inline ULONG _QIThunk::Release() -{ - ATLASSUME(m_pUnk != NULL); - if (m_bBreak) - DebugBreak(); - ATLASSUME(m_dwRef > 0); - - // save copies of member variables we wish to use after the InterlockedDecrement - UINT nIndex = m_nIndex; - IUnknown* pUnk = m_pUnk; - IID iid = m_iid; - LPCTSTR lpszClassName = m_lpszClassName; - bool bNonAddRefThunk = m_bNonAddRefThunk; - - ULONG l = InterlockedDecrement(&m_dwRef); - - TCHAR buf[512+1]; -#if _SECURE_ATL && !defined(_ATL_MIN_CRT) - _stprintf_s(buf, _countof(buf), _T("QIThunk - %-10d\tRelease :\tObject = 0x%p\tRefcount = %d\t"), nIndex, pUnk, l); -#else -#pragma warning(push) -#pragma warning(disable:4995) // wsprintf is deprecated - wsprintf(buf, _T("QIThunk - %-10d\tRelease :\tObject = 0x%p\tRefcount = %d\t"), nIndex, pUnk, l); -#pragma warning(pop) -#endif - buf[_countof(buf)-1] = 0; - OutputDebugString(buf); - AtlDumpIID(iid, lpszClassName, S_OK); - - bool bDeleteThunk = (l == 0 && !bNonAddRefThunk); - pUnk->Release(); - if (bDeleteThunk) - _AtlDebugInterfacesModule.DeleteThunk(this); - return l; -} - -#endif // _ATL_DEBUG_INTERFACES - - -class CAtlWinModule : public _ATL_WIN_MODULE -{ -public: - CAtlWinModule() - { - cbSize = sizeof(_ATL_WIN_MODULE); - HRESULT hr = AtlWinModuleInit(this); - if (FAILED(hr)) - { - ATLASSERT(0); - CAtlBaseModule::m_bInitFailed = true; - cbSize = 0; - return; - } - } - - ~CAtlWinModule() - { - Term(); - } - - void Term() - { - AtlWinModuleTerm(this, _AtlBaseModule.GetModuleInstance()); - } - - void AddCreateWndData(_AtlCreateWndData* pData, void* pObject) - { - AtlWinModuleAddCreateWndData(this, pData, pObject); - } - - void* ExtractCreateWndData() - { - return AtlWinModuleExtractCreateWndData(this); - } -}; - -extern CAtlWinModule _AtlWinModule; - -class CAtlModule; -__declspec(selectany) CAtlModule* _pAtlModule = NULL; - -#if defined(_M_CEE) && !defined(_ATL_MIXED) - -// This small class takes care of releasing the class factories at managed -// shutdown when we are compiling /clr. We can't wait to call _AtlComModule.Term() -// in _AtlComModule destructor, since _AtlComModule is a native global object, and it -// will be destructed after the managed runtime has been shutdown. - -// Notice that if the user defines _ATL_MIXED, he/she will need to take care -// of releasing the eventual managed class factories at the right time. - -class CAtlReleaseManagedClassFactories -{ -public: - CAtlReleaseManagedClassFactories() { } - ~CAtlReleaseManagedClassFactories() - { - _AtlComModule.Term(); - } -}; - -__declspec (selectany) CAtlReleaseManagedClassFactories _AtlReleaseManagedClassFactories; - -extern "C" -{ -__declspec (selectany) void *_pAtlReleaseManagedClassFactories = &_AtlReleaseManagedClassFactories; -} -#if defined(_M_IX86) - #pragma comment(linker, "/include:__pAtlReleaseManagedClassFactories") -#else - #pragma comment(linker, "/include:_pAtlReleaseManagedClassFactories") -#endif - -#endif - -class ATL_NO_VTABLE CAtlModule : public _ATL_MODULE -{ -public : - static GUID m_libid; - IGlobalInterfaceTable* m_pGIT; - - CAtlModule() throw() - { - // Should have only one instance of a class - // derived from CAtlModule in a project. - ATLASSERT(_pAtlModule == NULL); - cbSize = 0; - m_pTermFuncs = NULL; - - m_nLockCnt = 0; - _pAtlModule = this; - m_pGIT = NULL; - - if (FAILED(m_csStaticDataInitAndTypeInfo.Init())) - { - ATLTRACE(atlTraceGeneral, 0, _T("ERROR : Unable to initialize critical section in CAtlModule\n")); - ATLASSERT(0); - CAtlBaseModule::m_bInitFailed = true; - return; - } - - // Set cbSize on success. - cbSize = sizeof(_ATL_MODULE); - } - - void Term() throw() - { - // cbSize == 0 indicates that Term has already been called - if (cbSize == 0) - return; - - // Call term functions - if (m_pTermFuncs != NULL) - { - AtlCallTermFunc(this); - m_pTermFuncs = NULL; - } - - if (m_pGIT != NULL) - m_pGIT->Release(); - - m_csStaticDataInitAndTypeInfo.Term(); - - cbSize = 0; - } - - virtual ~CAtlModule() throw() - { - Term(); - } - - virtual LONG Lock() throw() - { - return CComGlobalsThreadModel::Increment(&m_nLockCnt); - } - - virtual LONG Unlock() throw() - { - return CComGlobalsThreadModel::Decrement(&m_nLockCnt); - } - - virtual LONG GetLockCount() throw() - { - return m_nLockCnt; - } - - HRESULT AddTermFunc(_ATL_TERMFUNC* pFunc, DWORD_PTR dw) throw() - { - return AtlModuleAddTermFunc(this, pFunc, dw); - } - - virtual HRESULT GetGITPtr(IGlobalInterfaceTable** ppGIT) throw() - { - ATLASSERT(ppGIT != NULL); - - if (ppGIT == NULL) - return E_POINTER; - - HRESULT hr = S_OK; - if (m_pGIT == NULL) - { - hr = ::CoCreateInstance(CLSID_StdGlobalInterfaceTable, NULL, CLSCTX_INPROC_SERVER, - __uuidof(IGlobalInterfaceTable), (void**)&m_pGIT); - } - - if (SUCCEEDED(hr)) - { - ATLASSUME(m_pGIT != NULL); - *ppGIT = m_pGIT; - m_pGIT->AddRef(); - } - return hr; - } - - virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* /*pRegistrar*/) throw() = 0; - - // Resource-based Registration -#ifdef _ATL_STATIC_REGISTRY - // Statically linking to Registry Ponent - HRESULT WINAPI UpdateRegistryFromResourceS(LPCTSTR lpszRes, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries = NULL) throw(); - HRESULT WINAPI UpdateRegistryFromResourceS(UINT nResID, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries = NULL) throw(); -#else - HRESULT WINAPI UpdateRegistryFromResourceD(LPCTSTR lpszRes, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries = NULL) throw() - { - if(lpszRes == NULL) - return E_INVALIDARG; - - USES_CONVERSION_EX; - LPCOLESTR pwszTemp = T2COLE_EX(lpszRes, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifdef _UNICODE - if(pwszTemp == NULL) - return E_OUTOFMEMORY; -#endif - return UpdateRegistryFromResourceDHelper(pwszTemp, bRegister, pMapEntries); - } - HRESULT WINAPI UpdateRegistryFromResourceD(UINT nResID, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries = NULL) throw() - { - return UpdateRegistryFromResourceDHelper((LPCOLESTR)MAKEINTRESOURCE(nResID), bRegister, pMapEntries); - } -#endif - - // Implementation -#if !defined(_ATL_STATIC_REGISTRY) - inline HRESULT WINAPI UpdateRegistryFromResourceDHelper(LPCOLESTR lpszRes, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries = NULL) throw() - { - CComPtr spRegistrar; - HRESULT hr = AtlCreateRegistrar(&spRegistrar); - if (FAILED(hr)) - return hr; - - if (NULL != pMapEntries) - { - while (NULL != pMapEntries->szKey) - { - ATLASSERT(NULL != pMapEntries->szData); - spRegistrar->AddReplacement(pMapEntries->szKey, pMapEntries->szData); - pMapEntries++; - } - } - - hr = AddCommonRGSReplacements(spRegistrar); - if (FAILED(hr)) - return hr; - - return AtlUpdateRegistryFromResourceD(_AtlBaseModule.GetModuleInstance(), lpszRes, bRegister, - NULL, spRegistrar); - } -#endif - - static void EscapeSingleQuote(__out_ecount_z(destSizeInChars) LPOLESTR lpDest,__in size_t destSizeInChars, __in_z LPCOLESTR lp) throw() - { - if (destSizeInChars == 0) - { - return; - } - UINT i = 0; - // copy charecters to the destination buffer but leave the last char to be NULL. - for (i=0; i < destSizeInChars-1 && *lp; i++) - { - lpDest[i] = *lp; - // make sure we won't promote lpDest behind the buffer limit. - if (*lp == '\'' && i < destSizeInChars-2) - lpDest[++i] = *lp; - lp++; - } - lpDest[i] = NULL; - } - - ATL_DEPRECATED("CAtlModule::EscapeSingleQuote(dest, src) is unsafe. Instead, use CAtlModule::EscapeSingleQuote(dest, size, src)") - static void EscapeSingleQuote(__out_z LPOLESTR lpDest, __in_z LPCOLESTR lp) throw() - { - EscapeSingleQuote(lpDest, SIZE_MAX/sizeof(OLECHAR), lp); - } - - // search for an occurence of string p2 in string p1 - static LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2) throw() - { - while (p1 != NULL && *p1 != NULL) - { - LPCTSTR p = p2; - while (p != NULL && *p != NULL) - { - if (*p1 == *p) - return CharNext(p1); - p = CharNext(p); - } - p1 = CharNext(p1); - } - return NULL; - } -#pragma warning(push) -#pragma warning(disable : 4302) // 'type cast' : truncation from 'LPSTR' to 'TCHAR' - - static int WordCmpI(LPCTSTR psz1, LPCTSTR psz2) throw() - { - TCHAR c1 = (TCHAR)CharUpper((LPTSTR)*psz1); - TCHAR c2 = (TCHAR)CharUpper((LPTSTR)*psz2); - while (c1 != NULL && c1 == c2 && c1 != ' ' && c1 != '\t') - { - psz1 = CharNext(psz1); - psz2 = CharNext(psz2); - c1 = (TCHAR)CharUpper((LPTSTR)*psz1); - c2 = (TCHAR)CharUpper((LPTSTR)*psz2); - } - if ((c1 == NULL || c1 == ' ' || c1 == '\t') && (c2 == NULL || c2 == ' ' || c2 == '\t')) - return 0; - - return (c1 < c2) ? -1 : 1; - } - -#pragma warning (pop) -}; - -__declspec(selectany) GUID CAtlModule::m_libid = {0x0, 0x0, 0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0} }; - -#define DECLARE_LIBID(libid) \ - static void InitLibId() throw() \ - { \ - ATL::CAtlModule::m_libid = libid; \ - } - -#define DECLARE_REGISTRY_APPID_RESOURCEID(resid, appid) \ - static LPCOLESTR GetAppId() throw() \ - { \ - return OLESTR(appid); \ - } \ - static TCHAR* GetAppIdT() throw() \ - { \ - return _T(appid); \ - } \ - static HRESULT WINAPI UpdateRegistryAppId(BOOL bRegister) throw() \ - { \ - ATL::_ATL_REGMAP_ENTRY aMapEntries [] = \ - { \ - { OLESTR("APPID"), GetAppId() }, \ - { NULL, NULL } \ - }; \ - return ATL::_pAtlModule->UpdateRegistryFromResource(resid, bRegister, aMapEntries); \ - } - -inline HRESULT AtlGetGITPtr(IGlobalInterfaceTable** ppGIT) throw() -{ - if (ppGIT == NULL) - return E_POINTER; - - if (_pAtlModule == NULL) - { - return CoCreateInstance(CLSID_StdGlobalInterfaceTable, NULL, CLSCTX_INPROC_SERVER, - __uuidof(IGlobalInterfaceTable), (void**)ppGIT); - } - else - { - return _pAtlModule->GetGITPtr(ppGIT); - } -} - -template -class ATL_NO_VTABLE CAtlModuleT : public CAtlModule -{ -public : - CAtlModuleT() throw() - { - T::InitLibId(); - } - - static void InitLibId() throw() - { - } - - HRESULT RegisterServer(BOOL bRegTypeLib = FALSE, const CLSID* pCLSID = NULL) throw() - { - (pCLSID); - (bRegTypeLib); - - HRESULT hr = S_OK; - -#ifndef _ATL_NO_COM_SUPPORT - - hr = _AtlComModule.RegisterServer(bRegTypeLib, pCLSID); - -#endif // _ATL_NO_COM_SUPPORT - - -#ifndef _ATL_NO_PERF_SUPPORT - - if (SUCCEEDED(hr) && _pPerfRegFunc != NULL) - hr = (*_pPerfRegFunc)(_AtlBaseModule.m_hInst); - -#endif - - return hr; - } - - HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID* pCLSID = NULL) throw() - { - (bUnRegTypeLib); - (pCLSID); - - HRESULT hr = S_OK; - -#ifndef _ATL_NO_PERF_SUPPORT - - if (_pPerfUnRegFunc != NULL) - hr = (*_pPerfUnRegFunc)(); - -#endif - -#ifndef _ATL_NO_COM_SUPPORT - - if (SUCCEEDED(hr)) - hr = _AtlComModule.UnregisterServer(bUnRegTypeLib, pCLSID); - -#endif // _ATL_NO_COM_SUPPORT - - return hr; - - } - - static HRESULT WINAPI UpdateRegistryAppId(BOOL /*bRegister*/) throw() - { - return S_OK; - } - HRESULT RegisterAppId() throw() - { - return T::UpdateRegistryAppId(TRUE); - } - - HRESULT UnregisterAppId() throw() - { - return T::UpdateRegistryAppId(FALSE); - } - - virtual HRESULT AddCommonRGSReplacements(IRegistrarBase* pRegistrar) throw() - { - return pRegistrar->AddReplacement(L"APPID", T::GetAppId()); - } - static LPCOLESTR GetAppId() throw() - { - return OLESTR(""); - } -}; - -#if !defined(_ATL_NATIVE_INITIALIZATION) -#pragma warning(push) -#pragma warning(disable:4483) -namespace __identifier("") -#pragma warning(pop) -{ - __declspec(selectany) bool DllModuleInitialized = false; -} - -#endif - -template -class ATL_NO_VTABLE CAtlDllModuleT : public CAtlModuleT -{ -public : - CAtlDllModuleT() throw() - { - _AtlComModule.ExecuteObjectMain(true); -#if !defined(_ATL_NATIVE_INITIALIZATION) -#pragma warning(push) -#pragma warning(disable:4483) - using namespace __identifier(""); -#pragma warning(pop) - ATLASSERT(DllModuleInitialized == false); - DllModuleInitialized = true; - _DllMain(DLL_PROCESS_ATTACH, NULL); -#endif - } - - ~CAtlDllModuleT() throw() - { -#if !defined(_ATL_NATIVE_INITIALIZATION) -#pragma warning(push) -#pragma warning(disable:4483) - using namespace __identifier(""); -#pragma warning(pop) - ATLASSERT(DllModuleInitialized == true); - _DllMain(DLL_PROCESS_DETACH, NULL); -#endif - _AtlComModule.ExecuteObjectMain(false); - } - - BOOL WINAPI DllMain(DWORD dwReason, LPVOID lpReserved) throw(); - - BOOL WINAPI _DllMain(DWORD dwReason, LPVOID /* lpReserved */) throw() - { - if (dwReason == DLL_PROCESS_ATTACH) - { - if (CAtlBaseModule::m_bInitFailed) - { - ATLASSERT(0); - return FALSE; - } - -#ifdef _ATL_MIN_CRT - DisableThreadLibraryCalls(_AtlBaseModule.GetModuleInstance()); -#endif - } -#ifdef _DEBUG - else if (dwReason == DLL_PROCESS_DETACH) - { - // Prevent false memory leak reporting. ~CAtlWinModule may be too late. - _AtlWinModule.Term(); - } -#endif // _DEBUG - return TRUE; // ok - } - - HRESULT DllCanUnloadNow() throw() - { - T* pT = static_cast(this); - return (pT->GetLockCount()==0) ? S_OK : S_FALSE; - } - - HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) throw() - { - T* pT = static_cast(this); - return pT->GetClassObject(rclsid, riid, ppv); - } - - HRESULT DllRegisterServer(BOOL bRegTypeLib = TRUE) throw() - { - LCID lcid = GetThreadLocale(); - SetThreadLocale(LOCALE_SYSTEM_DEFAULT); - // registers object, typelib and all interfaces in typelib - T* pT = static_cast(this); - HRESULT hr = pT->RegisterAppId(); - if (SUCCEEDED(hr)) - hr = pT->RegisterServer(bRegTypeLib); - SetThreadLocale(lcid); - return hr; - } - - HRESULT DllUnregisterServer(BOOL bUnRegTypeLib = TRUE) throw() - { - LCID lcid = GetThreadLocale(); - SetThreadLocale(LOCALE_SYSTEM_DEFAULT); - T* pT = static_cast(this); - HRESULT hr = pT->UnregisterServer(bUnRegTypeLib); - if (SUCCEEDED(hr)) - hr = pT->UnregisterAppId(); - SetThreadLocale(lcid); - return hr; - } - - // Obtain a Class Factory - HRESULT GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) throw() - { - -#ifndef _ATL_OLEDB_CONFORMANCE_TESTS - ATLASSERT(ppv != NULL); -#endif - - return AtlComModuleGetClassObject(&_AtlComModule, rclsid, riid, ppv); - } -}; - - -#if (_MSC_VER >= 1400) -#pragma managed(push, off) -#else -#pragma unmanaged -#endif - -template -inline BOOL WINAPI CAtlDllModuleT::DllMain(DWORD dwReason, LPVOID lpReserved) throw() -{ -#if !defined(_ATL_NATIVE_INITIALIZATION) - dwReason; lpReserved; -#pragma warning(push) -#pragma warning(disable:4483) - using namespace __identifier(""); -#pragma warning(pop) - if (dwReason == DLL_PROCESS_ATTACH) - { - ATLASSERT(DllModuleInitialized == false); - } - return TRUE; -#else - return _DllMain(dwReason, lpReserved); -#endif -} - - -#if (_MSC_VER >= 1400) -#pragma managed(pop) -#else -#pragma managed -#endif - -#ifndef _AFX - - -template -class ATL_NO_VTABLE CAtlExeModuleT : public CAtlModuleT -{ -public : -#ifndef _ATL_NO_COM_SUPPORT - - DWORD m_dwMainThreadID; - HANDLE m_hEventShutdown; - DWORD m_dwTimeOut; - DWORD m_dwPause; - bool m_bDelayShutdown; - bool m_bActivity; - bool m_bComInitialized; // Flag that indicates if ATL initialized COM - -#endif // _ATL_NO_COM_SUPPORT - - CAtlExeModuleT() throw() - -#ifndef _ATL_NO_COM_SUPPORT - - : m_dwMainThreadID(::GetCurrentThreadId()), - m_dwTimeOut(5000), - m_dwPause(1000), - m_hEventShutdown(NULL), - m_bDelayShutdown(true), - m_bComInitialized(false) - -#endif // _ATL_NO_COM_SUPPORT - - { -#if !defined(_ATL_NO_COM_SUPPORT) - HRESULT hr = T::InitializeCom(); - if (FAILED(hr)) - { - // Ignore RPC_E_CHANGED_MODE if CLR is loaded. Error is due to CLR initializing - // COM and InitializeCOM trying to initialize COM with different flags. - if (hr != RPC_E_CHANGED_MODE || GetModuleHandle(_T("Mscoree.dll")) == NULL) - { - ATLASSERT(0); - CAtlBaseModule::m_bInitFailed = true; - return; - } - } - else - { - m_bComInitialized = true; - } - - - _AtlComModule.ExecuteObjectMain(true); - -#endif // !defined(_ATL_NO_COM_SUPPORT) - - } - - ~CAtlExeModuleT() throw() - { -#ifndef _ATL_NO_COM_SUPPORT - - _AtlComModule.ExecuteObjectMain(false); - -#endif - - // Call term functions before COM is uninitialized - Term(); - -#ifndef _ATL_NO_COM_SUPPORT - - // Clean up AtlComModule before COM is uninitialized - _AtlComModule.Term(); - - if (m_bComInitialized) - T::UninitializeCom(); -#endif // _ATL_NO_COM_SUPPORT - } - - static HRESULT InitializeCom() throw() - { - -#if ((_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM)) & defined(_ATL_FREE_THREADED) - return CoInitializeEx(NULL, COINIT_MULTITHREADED); -#else - return CoInitialize(NULL); -#endif - } - - static void UninitializeCom() throw() - { - CoUninitialize(); - } - - LONG Unlock() throw() - { - LONG lRet = CComGlobalsThreadModel::Decrement(&m_nLockCnt); - -#ifndef _ATL_NO_COM_SUPPORT - - if (lRet == 0) - { - if (m_bDelayShutdown) - { - m_bActivity = true; - ::SetEvent(m_hEventShutdown); // tell monitor that we transitioned to zero - } - else - { - ::PostThreadMessage(m_dwMainThreadID, WM_QUIT, 0, 0); - } - } - -#endif // _ATL_NO_COM_SUPPORT - - return lRet; - } -#ifndef _ATL_NO_COM_SUPPORT - - void MonitorShutdown() throw() - { - while (1) - { - ::WaitForSingleObject(m_hEventShutdown, INFINITE); - DWORD dwWait = 0; - do - { - m_bActivity = false; - dwWait = ::WaitForSingleObject(m_hEventShutdown, m_dwTimeOut); - } while (dwWait == WAIT_OBJECT_0); - // timed out - if (!m_bActivity && m_nLockCnt == 0) // if no activity let's really bail - { -#if ((_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM)) & defined(_ATL_FREE_THREADED) - ::CoSuspendClassObjects(); - if (m_nLockCnt == 0) -#endif - break; - } - } - ::CloseHandle(m_hEventShutdown); - ::PostThreadMessage(m_dwMainThreadID, WM_QUIT, 0, 0); - } - - HANDLE StartMonitor() throw() - { - m_hEventShutdown = ::CreateEvent(NULL, false, false, NULL); - if (m_hEventShutdown == NULL) - { - return NULL; - } - DWORD dwThreadID; - HANDLE hThread = ::CreateThread(NULL, 0, MonitorProc, this, 0, &dwThreadID); - if(hThread==NULL) - { - ::CloseHandle(m_hEventShutdown); - } - return hThread; - } - - static DWORD WINAPI MonitorProc(void* pv) throw() - { - CAtlExeModuleT* p = static_cast*>(pv); - p->MonitorShutdown(); - return 0; - } -#endif // _ATL_NO_COM_SUPPORT - - int WinMain(int nShowCmd) throw() - { - if (CAtlBaseModule::m_bInitFailed) - { - ATLASSERT(0); - return -1; - } - T* pT = static_cast(this); - HRESULT hr = S_OK; - - LPTSTR lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT - if (pT->ParseCommandLine(lpCmdLine, &hr) == true) - hr = pT->Run(nShowCmd); - -#ifdef _DEBUG - // Prevent false memory leak reporting. ~CAtlWinModule may be too late. - _AtlWinModule.Term(); -#endif // _DEBUG - return hr; - } - - // Scan command line and perform registration - // Return value specifies if server should run - - // Parses the command line and registers/unregisters the rgs file if necessary - bool ParseCommandLine(LPCTSTR lpCmdLine, HRESULT* pnRetCode) throw() - { - *pnRetCode = S_OK; - - TCHAR szTokens[] = _T("-/"); - - T* pT = static_cast(this); - LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens); - while (lpszToken != NULL) - { - if (WordCmpI(lpszToken, _T("UnregServer"))==0) - { - *pnRetCode = pT->UnregisterServer(TRUE); - if (SUCCEEDED(*pnRetCode)) - *pnRetCode = pT->UnregisterAppId(); - return false; - } - - // Register as Local Server - if (WordCmpI(lpszToken, _T("RegServer"))==0) - { - *pnRetCode = pT->RegisterAppId(); - if (SUCCEEDED(*pnRetCode)) - *pnRetCode = pT->RegisterServer(TRUE); - return false; - } - - lpszToken = FindOneOf(lpszToken, szTokens); - } - - return true; - } - - HRESULT PreMessageLoop(int /*nShowCmd*/) throw() - { - HRESULT hr = S_OK; - T* pT = static_cast(this); - pT; - -#ifndef _ATL_NO_COM_SUPPORT - -#if ((_WIN32_WINNT >= 0x0400 ) || defined(_WIN32_DCOM)) & defined(_ATL_FREE_THREADED) - - hr = pT->RegisterClassObjects(CLSCTX_LOCAL_SERVER, - REGCLS_MULTIPLEUSE | REGCLS_SUSPENDED); - - if (FAILED(hr)) - return hr; - - if (hr == S_OK) - { - if (m_bDelayShutdown) - { - CHandle h(pT->StartMonitor()); - if (h.m_h == NULL) - { - hr = E_FAIL; - } - else - { - hr = CoResumeClassObjects(); - ATLASSERT(SUCCEEDED(hr)); - if (FAILED(hr)) - { - ::SetEvent(m_hEventShutdown); // tell monitor to shutdown - ::WaitForSingleObject(h, m_dwTimeOut * 2); - } - } - } - else - { - hr = CoResumeClassObjects(); - ATLASSERT(SUCCEEDED(hr)); - } - - if (FAILED(hr)) - pT->RevokeClassObjects(); - } - else - { - m_bDelayShutdown = false; - } - -#else - - hr = pT->RegisterClassObjects(CLSCTX_LOCAL_SERVER, - REGCLS_MULTIPLEUSE); - if (hr == S_OK) - { - if (m_bDelayShutdown && !pT->StartMonitor()) - { - hr = E_FAIL; - } - } - else - { - m_bDelayShutdown = false; - } - - -#endif - -#endif // _ATL_NO_COM_SUPPORT - - ATLASSERT(SUCCEEDED(hr)); - return hr; - } - - HRESULT PostMessageLoop() throw() - { - HRESULT hr = S_OK; - -#ifndef _ATL_NO_COM_SUPPORT - - T* pT = static_cast(this); - hr = pT->RevokeClassObjects(); - if (m_bDelayShutdown) - Sleep(m_dwPause); //wait for any threads to finish - -#endif // _ATL_NO_COM_SUPPORT - - return hr; - } - - void RunMessageLoop() throw() - { - MSG msg; - while (GetMessage(&msg, 0, 0, 0) > 0) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - HRESULT Run(int nShowCmd = SW_HIDE) throw() - { - HRESULT hr = S_OK; - - T* pT = static_cast(this); - hr = pT->PreMessageLoop(nShowCmd); - - // Call RunMessageLoop only if PreMessageLoop returns S_OK. - if (hr == S_OK) - { - pT->RunMessageLoop(); - } - - // Call PostMessageLoop if PreMessageLoop returns success. - if (SUCCEEDED(hr)) - { - hr = pT->PostMessageLoop(); - } - - ATLASSERT(SUCCEEDED(hr)); - return hr; - } - - // Register/Revoke All Class Factories with the OS (EXE only) - HRESULT RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags) throw() - { - return AtlComModuleRegisterClassObjects(&_AtlComModule, dwClsContext, dwFlags); - } - HRESULT RevokeClassObjects() throw() - { - return AtlComModuleRevokeClassObjects(&_AtlComModule); - } -}; - -#ifndef _ATL_NO_SERVICE -template -class ATL_NO_VTABLE CAtlServiceModuleT : public CAtlExeModuleT -{ -public : - - CAtlServiceModuleT() throw() - { - m_bService = TRUE; - LoadString(_AtlBaseModule.GetModuleInstance(), nServiceNameID, m_szServiceName, sizeof(m_szServiceName) / sizeof(TCHAR)); - - // set up the initial service status - m_hServiceStatus = NULL; - m_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; - m_status.dwCurrentState = SERVICE_STOPPED; - m_status.dwControlsAccepted = SERVICE_ACCEPT_STOP; - m_status.dwWin32ExitCode = 0; - m_status.dwServiceSpecificExitCode = 0; - m_status.dwCheckPoint = 0; - m_status.dwWaitHint = 0; - } - - int WinMain(int nShowCmd) throw() - { - if (CAtlBaseModule::m_bInitFailed) - { - ATLASSERT(0); - return -1; - } - - T* pT = static_cast(this); - HRESULT hr = S_OK; - - LPTSTR lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT - if (pT->ParseCommandLine(lpCmdLine, &hr) == true) - hr = pT->Start(nShowCmd); - -#ifdef _DEBUG - // Prevent false memory leak reporting. ~CAtlWinModule may be too late. - _AtlWinModule.Term(); -#endif // _DEBUG - return hr; - } - - HRESULT Start(int nShowCmd) throw() - { - T* pT = static_cast(this); - // Are we Service or Local Server - CRegKey keyAppID; - LONG lRes = keyAppID.Open(HKEY_CLASSES_ROOT, _T("AppID"), KEY_READ); - if (lRes != ERROR_SUCCESS) - { - m_status.dwWin32ExitCode = lRes; - return m_status.dwWin32ExitCode; - } - - CRegKey key; - lRes = key.Open(keyAppID, pT->GetAppIdT(), KEY_READ); - if (lRes != ERROR_SUCCESS) - { - m_status.dwWin32ExitCode = lRes; - return m_status.dwWin32ExitCode; - } - - TCHAR szValue[MAX_PATH]; - DWORD dwLen = MAX_PATH; - lRes = key.QueryStringValue(_T("LocalService"), szValue, &dwLen); - - m_bService = FALSE; - if (lRes == ERROR_SUCCESS) - m_bService = TRUE; - - if (m_bService) - { - SERVICE_TABLE_ENTRY st[] = - { - { m_szServiceName, _ServiceMain }, - { NULL, NULL } - }; - if (::StartServiceCtrlDispatcher(st) == 0) - m_status.dwWin32ExitCode = GetLastError(); - return m_status.dwWin32ExitCode; - } - // local server - call Run() directly, rather than - // from ServiceMain() - m_status.dwWin32ExitCode = pT->Run(nShowCmd); - return m_status.dwWin32ExitCode; - } - - inline HRESULT RegisterAppId(bool bService = false) throw() - { - if (IsInstalled()) - return E_FAIL; - - HRESULT hr = T::UpdateRegistryAppId(TRUE); - if (FAILED(hr)) - return hr; - - CRegKey keyAppID; - LONG lRes = keyAppID.Open(HKEY_CLASSES_ROOT, _T("AppID"), KEY_WRITE); - if (lRes != ERROR_SUCCESS) - return AtlHresultFromWin32(lRes); - - CRegKey key; - - lRes = key.Create(keyAppID, T::GetAppIdT()); - if (lRes != ERROR_SUCCESS) - return AtlHresultFromWin32(lRes); - - key.DeleteValue(_T("LocalService")); - - if (!bService) - return S_OK; - - key.SetStringValue(_T("LocalService"), m_szServiceName); - - // Create service - if (!Install()) - return E_FAIL; - return S_OK; - } - - HRESULT UnregisterAppId() throw() - { - if (!Uninstall()) - return E_FAIL; - // First remove entries not in the RGS file. - CRegKey keyAppID; - LONG lRes = keyAppID.Open(HKEY_CLASSES_ROOT, _T("AppID"), KEY_WRITE); - if (lRes != ERROR_SUCCESS) - return AtlHresultFromWin32(lRes); - - CRegKey key; - lRes = key.Open(keyAppID, T::GetAppIdT(), KEY_WRITE); - if (lRes != ERROR_SUCCESS) - return AtlHresultFromWin32(lRes); - key.DeleteValue(_T("LocalService")); - - return T::UpdateRegistryAppId(FALSE); - } - - // Parses the command line and registers/unregisters the rgs file if necessary - bool ParseCommandLine(LPCTSTR lpCmdLine, HRESULT* pnRetCode) throw() - { - if (!CAtlExeModuleT::ParseCommandLine(lpCmdLine, pnRetCode)) - return false; - - TCHAR szTokens[] = _T("-/"); - *pnRetCode = S_OK; - - T* pT = static_cast(this); - LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens); - while (lpszToken != NULL) - { - if (WordCmpI(lpszToken, _T("Service"))==0) - { - *pnRetCode = pT->RegisterAppId(true); - if (SUCCEEDED(*pnRetCode)) - *pnRetCode = pT->RegisterServer(TRUE); - return false; - } - lpszToken = FindOneOf(lpszToken, szTokens); - } - return true; - } - - void ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv) throw() - { - lpszArgv; - dwArgc; - // Register the control request handler - m_status.dwCurrentState = SERVICE_START_PENDING; - m_hServiceStatus = RegisterServiceCtrlHandler(m_szServiceName, _Handler); - if (m_hServiceStatus == NULL) - { - LogEvent(_T("Handler not installed")); - return; - } - SetServiceStatus(SERVICE_START_PENDING); - - m_status.dwWin32ExitCode = S_OK; - m_status.dwCheckPoint = 0; - m_status.dwWaitHint = 0; - - T* pT = static_cast(this); -#ifndef _ATL_NO_COM_SUPPORT - - HRESULT hr = E_FAIL; - hr = T::InitializeCom(); - if (FAILED(hr)) - { - // Ignore RPC_E_CHANGED_MODE if CLR is loaded. Error is due to CLR initializing - // COM and InitializeCOM trying to initialize COM with different flags. - if (hr != RPC_E_CHANGED_MODE || GetModuleHandle(_T("Mscoree.dll")) == NULL) - { - return; - } - } - else - { - m_bComInitialized = true; - } - - m_bDelayShutdown = false; -#endif //_ATL_NO_COM_SUPPORT - // When the Run function returns, the service has stopped. - m_status.dwWin32ExitCode = pT->Run(SW_HIDE); - -#ifndef _ATL_NO_COM_SUPPORT - if (m_bService && m_bComInitialized) - T::UninitializeCom(); -#endif - - SetServiceStatus(SERVICE_STOPPED); - LogEvent(_T("Service stopped")); - } - - HRESULT Run(int nShowCmd = SW_HIDE) throw() - { - HRESULT hr = S_OK; - T* pT = static_cast(this); - - hr = pT->PreMessageLoop(nShowCmd); - - if (hr == S_OK) - { - if (m_bService) - { - LogEvent(_T("Service started")); - SetServiceStatus(SERVICE_RUNNING); - } - - pT->RunMessageLoop(); - } - - if (SUCCEEDED(hr)) - { - hr = pT->PostMessageLoop(); - } - - return hr; - } - - HRESULT PreMessageLoop(int nShowCmd) throw() - { - HRESULT hr = S_OK; - if (m_bService) - { - m_dwThreadID = GetCurrentThreadId(); - - T* pT = static_cast(this); - hr = pT->InitializeSecurity(); - - if (FAILED(hr)) - return hr; - } - - hr = CAtlExeModuleT::PreMessageLoop(nShowCmd); - if (FAILED(hr)) - return hr; - - return hr; - } - - void OnStop() throw() - { - SetServiceStatus(SERVICE_STOP_PENDING); - PostThreadMessage(m_dwThreadID, WM_QUIT, 0, 0); - } - - void OnPause() throw() - { - } - - void OnContinue() throw() - { - } - - void OnInterrogate() throw() - { - } - - void OnShutdown() throw() - { - } - - void OnUnknownRequest(DWORD /*dwOpcode*/) throw() - { - LogEvent(_T("Bad service request")); - } - - void Handler(DWORD dwOpcode) throw() - { - T* pT = static_cast(this); - - switch (dwOpcode) - { - case SERVICE_CONTROL_STOP: - pT->OnStop(); - break; - case SERVICE_CONTROL_PAUSE: - pT->OnPause(); - break; - case SERVICE_CONTROL_CONTINUE: - pT->OnContinue(); - break; - case SERVICE_CONTROL_INTERROGATE: - pT->OnInterrogate(); - break; - case SERVICE_CONTROL_SHUTDOWN: - pT->OnShutdown(); - break; - default: - pT->OnUnknownRequest(dwOpcode); - } - } - - BOOL IsInstalled() throw() - { - BOOL bResult = FALSE; - - SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - - if (hSCM != NULL) - { - SC_HANDLE hService = ::OpenService(hSCM, m_szServiceName, SERVICE_QUERY_CONFIG); - if (hService != NULL) - { - bResult = TRUE; - ::CloseServiceHandle(hService); - } - ::CloseServiceHandle(hSCM); - } - return bResult; - } - BOOL Install() throw() - { - if (IsInstalled()) - return TRUE; - - // Get the executable file path - TCHAR szFilePath[MAX_PATH + _ATL_QUOTES_SPACE]; - DWORD dwFLen = ::GetModuleFileName(NULL, szFilePath + 1, MAX_PATH); - if( dwFLen == 0 || dwFLen == MAX_PATH ) - return FALSE; - - // Quote the FilePath before calling CreateService - szFilePath[0] = _T('\"'); - szFilePath[dwFLen + 1] = _T('\"'); - szFilePath[dwFLen + 2] = 0; - - SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if (hSCM == NULL) - { - TCHAR szBuf[1024]; - if (AtlLoadString(ATL_SERVICE_MANAGER_OPEN_ERROR, szBuf, 1024) == 0) -#ifdef UNICODE - Checked::wcscpy_s(szBuf, _countof(szBuf), _T("Could not open Service Manager")); -#else - Checked::strcpy_s(szBuf, _countof(szBuf), _T("Could not open Service Manager")); -#endif - MessageBox(NULL, szBuf, m_szServiceName, MB_OK); - return FALSE; - } - - SC_HANDLE hService = ::CreateService( - hSCM, m_szServiceName, m_szServiceName, - SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, - SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, - szFilePath, NULL, NULL, _T("RPCSS\0"), NULL, NULL); - - if (hService == NULL) - { - ::CloseServiceHandle(hSCM); - TCHAR szBuf[1024]; - if (AtlLoadString(ATL_SERVICE_START_ERROR, szBuf, 1024) == 0) -#ifdef UNICODE - Checked::wcscpy_s(szBuf, _countof(szBuf), _T("Could not start service")); -#else - Checked::strcpy_s(szBuf, _countof(szBuf), _T("Could not start service")); -#endif - MessageBox(NULL, szBuf, m_szServiceName, MB_OK); - return FALSE; - } - - ::CloseServiceHandle(hService); - ::CloseServiceHandle(hSCM); - return TRUE; - } - - BOOL Uninstall() throw() - { - if (!IsInstalled()) - return TRUE; - - SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - - if (hSCM == NULL) - { - TCHAR szBuf[1024]; - if (AtlLoadString(ATL_SERVICE_MANAGER_OPEN_ERROR, szBuf, 1024) == 0) -#ifdef UNICODE - Checked::wcscpy_s(szBuf, _countof(szBuf), _T("Could not open Service Manager")); -#else - Checked::strcpy_s(szBuf, _countof(szBuf), _T("Could not open Service Manager")); -#endif - MessageBox(NULL, szBuf, m_szServiceName, MB_OK); - return FALSE; - } - - SC_HANDLE hService = ::OpenService(hSCM, m_szServiceName, SERVICE_STOP | DELETE); - - if (hService == NULL) - { - ::CloseServiceHandle(hSCM); - TCHAR szBuf[1024]; - if (AtlLoadString(ATL_SERVICE_OPEN_ERROR, szBuf, 1024) == 0) -#ifdef UNICODE - Checked::wcscpy_s(szBuf, _countof(szBuf), _T("Could not open service")); -#else - Checked::strcpy_s(szBuf, _countof(szBuf), _T("Could not open service")); -#endif - MessageBox(NULL, szBuf, m_szServiceName, MB_OK); - return FALSE; - } - SERVICE_STATUS status; - BOOL bRet = ::ControlService(hService, SERVICE_CONTROL_STOP, &status); - if (!bRet) - { - DWORD dwError = GetLastError(); - if (!((dwError == ERROR_SERVICE_NOT_ACTIVE) || (dwError == ERROR_SERVICE_CANNOT_ACCEPT_CTRL && status.dwCurrentState == SERVICE_STOP_PENDING))) - { - TCHAR szBuf[1024]; - if (AtlLoadString(ATL_SERVICE_STOP_ERROR, szBuf, 1024) == 0) -#ifdef UNICODE - Checked::wcscpy_s(szBuf, _countof(szBuf), _T("Could not stop service")); -#else - Checked::strcpy_s(szBuf, _countof(szBuf), _T("Could not stop service")); -#endif - MessageBox(NULL, szBuf, m_szServiceName, MB_OK); - } - } - - - BOOL bDelete = ::DeleteService(hService); - ::CloseServiceHandle(hService); - ::CloseServiceHandle(hSCM); - - if (bDelete) - return TRUE; - - TCHAR szBuf[1024]; - if (AtlLoadString(ATL_SERVICE_DELETE_ERROR, szBuf, 1024) == 0) -#ifdef UNICODE - Checked::wcscpy_s(szBuf, _countof(szBuf), _T("Could not delete service")); -#else - Checked::strcpy_s(szBuf, _countof(szBuf), _T("Could not delete service")); -#endif - MessageBox(NULL, szBuf, m_szServiceName, MB_OK); - return FALSE; - } - - LONG Unlock() throw() - { - LONG lRet; - if (m_bService) - { - // We are running as a service, therefore transition to zero does not - // unload the process - lRet = CAtlModuleT::Unlock(); - } - else - { - // We are running as EXE, use MonitorShutdown logic provided by CExeModule - lRet = CAtlExeModuleT::Unlock(); - } - return lRet; - } - - void LogEventEx(int id, LPCTSTR pszMessage=NULL, WORD type = EVENTLOG_INFORMATION_TYPE) throw() - { - HANDLE hEventSource; - if (m_szServiceName) - { - /* Get a handle to use with ReportEvent(). */ - hEventSource = RegisterEventSource(NULL, m_szServiceName); - if (hEventSource != NULL) - { - /* Write to event log. */ - ReportEvent(hEventSource, - type, - (WORD)0, - id, - NULL, - (WORD)(pszMessage != NULL ? 1 : 0), - 0, - pszMessage != NULL ? &pszMessage : NULL, - NULL); - DeregisterEventSource(hEventSource); - } - } - } - -#pragma warning(push) -#pragma warning(disable : 4793) - void __cdecl LogEvent(LPCTSTR pszFormat, ...) throw() - { - const int LOG_EVENT_MSG_SIZE = 256; - - TCHAR chMsg[LOG_EVENT_MSG_SIZE]; - HANDLE hEventSource; - LPTSTR lpszStrings[1]; - va_list pArg; - - va_start(pArg, pszFormat); -#if _SECURE_ATL - _vsntprintf_s(chMsg, LOG_EVENT_MSG_SIZE, LOG_EVENT_MSG_SIZE-1, pszFormat, pArg); -#else - _vsntprintf(chMsg, LOG_EVENT_MSG_SIZE, pszFormat, pArg); -#endif - va_end(pArg); - - chMsg[LOG_EVENT_MSG_SIZE - 1] = 0; - - lpszStrings[0] = chMsg; - - if (!m_bService) - { - // Not running as a service, so print out the error message - // to the console if possible - _putts(chMsg); - } - - /* Get a handle to use with ReportEvent(). */ - hEventSource = RegisterEventSource(NULL, m_szServiceName); - if (hEventSource != NULL) - { - /* Write to event log. */ - ReportEvent(hEventSource, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (LPCTSTR*) &lpszStrings[0], NULL); - DeregisterEventSource(hEventSource); - } - } -#pragma warning(pop) - - void SetServiceStatus(DWORD dwState) throw() - { - m_status.dwCurrentState = dwState; - ::SetServiceStatus(m_hServiceStatus, &m_status); - } - -//Implementation -protected: - static void WINAPI _ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv) throw() - { - ((T*)_pAtlModule)->ServiceMain(dwArgc, lpszArgv); - } - static void WINAPI _Handler(DWORD dwOpcode) throw() - { - ((T*)_pAtlModule)->Handler(dwOpcode); - } - -// data members -public: - TCHAR m_szServiceName[256]; - SERVICE_STATUS_HANDLE m_hServiceStatus; - SERVICE_STATUS m_status; - BOOL m_bService; - DWORD m_dwThreadID; -}; - -#endif // _ATL_NO_SERVICE - -#endif // !_AFX - -#ifdef _AFX - -class CAtlMfcModule : public ATL::CAtlModuleT -{ -public : - virtual LONG Lock() throw() - { -#ifdef _USRDLL - AFX_MANAGE_STATE(AfxGetStaticModuleState()); -#endif - AfxOleLockApp(); - return AfxGetModuleState()->m_nObjectCount; - } - - virtual LONG Unlock() throw() - { -#ifdef _USRDLL - AFX_MANAGE_STATE(AfxGetStaticModuleState()); -#endif - AfxOleUnlockApp(); - return AfxGetModuleState()->m_nObjectCount; - } - - virtual LONG GetLockCount() throw() - { -#ifdef _USRDLL - AFX_MANAGE_STATE(AfxGetStaticModuleState()); -#endif - return AfxGetModuleState()->m_nObjectCount; - } - - // Obtain a Class Factory (DLL only) - HRESULT GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) - { - return ATL::AtlComModuleGetClassObject(&ATL::_AtlComModule, rclsid, riid, ppv); - } - - // Register/Revoke All Class Factories with the OS (EXE only) - HRESULT RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags) - { - return ATL::AtlComModuleRegisterClassObjects(&ATL::_AtlComModule, dwClsContext, dwFlags); - } - - HRESULT RevokeClassObjects() - { - return ATL::AtlComModuleRevokeClassObjects(&ATL::_AtlComModule); - } -}; - -#endif // _AFX - -///////////////////////////////////////////////////////////////////////////// -// CComModule - Uses the functionality provided by other modules - -#define THREADFLAGS_APARTMENT 0x1 -#define THREADFLAGS_BOTH 0x2 -#define AUTPRXFLAG 0x4 - -#ifndef _ATL_NO_COMMODULE - -class CComModule; - -#if !defined(_ATL_NATIVE_INITIALIZATION) - -#if (_MSC_VER >= 1400) -#pragma managed(push, off) -#else -#pragma unmanaged -#endif - -#pragma warning(push) -#pragma warning(disable:4483) -namespace __identifier("") -#pragma warning(pop) -{ - struct CComModuleHelper - { - CComModule* Module; - HINSTANCE Instance; - _ATL_OBJMAP_ENTRY* ObjectMap; - const GUID* LibraryId; - - // Must NOT have any constructors - // We initialize the object in DllMain *before* - // the constructors would run. - - void Initialize(CComModule* pModule, HINSTANCE hInstance, _ATL_OBJMAP_ENTRY* pObjMap, const GUID* pLibID) - { - Module = pModule; - Instance = hInstance; - ObjectMap = pObjMap; - LibraryId = pLibID; - } - }; - - __declspec(selectany) CComModuleHelper ComModuleHelper; - __declspec(selectany) bool ComModuleInitialized = false; -} - -#if (_MSC_VER >= 1400) -#pragma managed(pop) -#else -#pragma managed -#endif - -#endif - - -__declspec(selectany) CComModule* _pModule = NULL; -class CComModule : public CAtlModuleT -{ -public : - - CComModule() - { - // Should have only one instance of a class - // derived from CComModule in a project. - ATLASSERT(_pModule == NULL); - _pModule = this; -#if !defined(_ATL_NATIVE_INITIALIZATION) -#pragma warning(push) -#pragma warning(disable:4483) - using namespace __identifier(""); -#pragma warning(pop) - ATLASSERT(ComModuleInitialized == false); - // If ComModuleHelper.Module == NULL it mean that DllMain has not been called, so we assume CComModule lives in - // an exe and not in a dll - if (ComModuleHelper.Module != NULL) - { - ATLASSERT(ComModuleHelper.Module == this); - _DllMain(ComModuleHelper.Instance, DLL_PROCESS_ATTACH, NULL, ComModuleHelper.ObjectMap, ComModuleHelper.LibraryId); - } - ComModuleInitialized = true; -#endif - } - - ~CComModule() - { -#if !defined(_ATL_NATIVE_INITIALIZATION) -#pragma warning(push) -#pragma warning(disable:4483) - using namespace __identifier(""); -#pragma warning(pop) - ATLASSERT(ComModuleInitialized == true); - // If ComModuleHelper.Module == NULL it mean that DllMain has not been called, so we assume CComModule lives in - // an exe and not in a dll - if (ComModuleHelper.Module != NULL) - { - ATLASSERT(ComModuleHelper.Module == this); - _DllMain(ComModuleHelper.Instance, DLL_PROCESS_DETACH, NULL, ComModuleHelper.ObjectMap, ComModuleHelper.LibraryId); - } -#endif - } - - __declspec(property(get = get_m_hInst)) HINSTANCE m_hInst; - HINSTANCE& get_m_hInst() const throw() - { - return _AtlBaseModule.m_hInst; - } - - __declspec(property(get = get_m_hInstResource, put = put_m_hInstResource)) HINSTANCE m_hInstResource; - HINSTANCE& get_m_hInstResource() const throw() - { - return _AtlBaseModule.m_hInstResource; - } - void put_m_hInstResource(HINSTANCE h) throw() - { - _AtlBaseModule.SetResourceInstance(h); - } - HINSTANCE SetResourceInstance(HINSTANCE h) throw() - { - return _AtlBaseModule.SetResourceInstance(h); - } - - HINSTANCE GetModuleInstance() throw() - { - return _AtlBaseModule.m_hInst; - } - HINSTANCE GetResourceInstance() throw() - { - return _AtlBaseModule.m_hInstResource; - } - - __declspec(property(get = get_m_hInstTypeLib, put = put_m_hInstTypeLib)) HINSTANCE m_hInstTypeLib; - HINSTANCE& get_m_hInstTypeLib() const throw() - { - return _AtlComModule.m_hInstTypeLib; - } - void put_m_hInstTypeLib(HINSTANCE h) throw() - { - _AtlComModule.m_hInstTypeLib = h; - } - - HINSTANCE GetTypeLibInstance() const throw() - { - return _AtlComModule.m_hInstTypeLib; - } - - // For Backward compatibility - _ATL_OBJMAP_ENTRY* m_pObjMap; - - __declspec(property(get = get_m_csWindowCreate)) CRITICAL_SECTION m_csWindowCreate; - CRITICAL_SECTION& get_m_csWindowCreate() throw(); - - __declspec(property(get = get_m_csObjMap)) CRITICAL_SECTION m_csObjMap; - CRITICAL_SECTION& get_m_csObjMap() throw(); - - __declspec(property(get = get_m_csStaticDataInit)) CRITICAL_SECTION m_csTypeInfoHolder; - __declspec(property(get = get_m_csStaticDataInit)) CRITICAL_SECTION m_csStaticDataInit; - CRITICAL_SECTION& get_m_csStaticDataInit() throw(); - void EnterStaticDataCriticalSection() throw() - { - EnterCriticalSection(&m_csStaticDataInit); - } - - void LeaveStaticDataCriticalSection() throw() - { - LeaveCriticalSection(&m_csStaticDataInit); - } - - __declspec(property(get = get_dwAtlBuildVer)) DWORD dwAtlBuildVer; - DWORD& get_dwAtlBuildVer() throw() - { - return _AtlBaseModule.dwAtlBuildVer; - } - - __declspec(property(get = get_m_pCreateWndList, put = put_m_pCreateWndList)) _AtlCreateWndData* m_pCreateWndList; - _AtlCreateWndData*& get_m_pCreateWndList() throw(); - void put_m_pCreateWndList(_AtlCreateWndData* p) throw(); - - __declspec(property(get = get_pguidVer)) const GUID* pguidVer; - const GUID*& get_pguidVer() throw() - { - return _AtlBaseModule.pguidVer; - } - -#ifdef _ATL_DEBUG_INTERFACES - - __declspec(property(get = get_m_nIndexQI, put = put_m_nIndexQI)) UINT m_nIndexQI; - UINT& get_m_nIndexQI() throw(); - void put_m_nIndexQI(UINT nIndex) throw(); - - __declspec(property(get = get_m_nIndexBreakAt, put = put_m_nIndexBreakAt)) UINT m_nIndexBreakAt; - UINT& get_m_nIndexBreakAt() throw(); - void put_m_nIndexBreakAt(UINT nIndex) throw(); - - __declspec(property(get = get_m_paThunks)) CSimpleArray<_QIThunk*>* m_paThunks; - CSimpleArray<_QIThunk*>* get_m_paThunks() throw(); - HRESULT AddThunk(IUnknown** pp, LPCTSTR lpsz, REFIID iid) throw(); - - HRESULT AddNonAddRefThunk(IUnknown* p, LPCTSTR lpsz, IUnknown** ppThunkRet) throw(); - void DeleteNonAddRefThunk(IUnknown* pUnk) throw(); - void DeleteThunk(_QIThunk* p) throw(); - bool DumpLeakedThunks() throw(); -#endif // _ATL_DEBUG_INTERFACES - - HRESULT Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, const GUID* plibid = NULL) throw(); - void Term() throw(); - - HRESULT GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) throw(); - // Register/Revoke All Class Factories with the OS (EXE only) - HRESULT RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags) throw(); - HRESULT RevokeClassObjects() throw(); - // Registry support (helpers) - HRESULT RegisterTypeLib() throw(); - HRESULT RegisterTypeLib(LPCTSTR lpszIndex) throw(); - HRESULT UnRegisterTypeLib() throw(); - HRESULT UnRegisterTypeLib(LPCTSTR lpszIndex) throw(); - HRESULT RegisterServer(BOOL bRegTypeLib = FALSE, const CLSID* pCLSID = NULL) throw(); - HRESULT UnregisterServer(BOOL bUnRegTypeLib, const CLSID* pCLSID = NULL) throw(); - HRESULT UnregisterServer(const CLSID* pCLSID = NULL) throw(); - - void AddCreateWndData(_AtlCreateWndData* pData, void* pObject) throw() - { - _AtlWinModule.AddCreateWndData(pData, pObject); - } - - void* ExtractCreateWndData() throw() - { - return _AtlWinModule.ExtractCreateWndData(); - } - - // Only used in CComAutoThreadModule - HRESULT CreateInstance(void* /*pfnCreateInstance*/, REFIID /*riid*/, void** /*ppvObj*/) throw() - { - ATLASSERT(0); - ATLTRACENOTIMPL(_T("CComModule::CreateInstance")); - } - - HRESULT RegisterAppId(LPCTSTR pAppId); - HRESULT UnregisterAppId(LPCTSTR pAppId); - - // Resource-based Registration - virtual HRESULT WINAPI UpdateRegistryFromResourceD(LPCTSTR lpszRes, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries = NULL) throw() - { -#if defined(_ATL_STATIC_REGISTRY) - (lpszRes); - (bRegister); - (pMapEntries); - return E_FAIL; -#else - return CAtlModuleT::UpdateRegistryFromResourceD(lpszRes, bRegister, pMapEntries); -#endif - } - virtual HRESULT WINAPI UpdateRegistryFromResourceD(UINT nResID, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries = NULL) throw() - { -#if defined(_ATL_STATIC_REGISTRY) - (nResID); - (bRegister); - (pMapEntries); - return E_FAIL; -#else - return CAtlModuleT::UpdateRegistryFromResourceD(nResID, bRegister, pMapEntries); -#endif - } - - - // Statically linking to Registry Ponent - virtual HRESULT WINAPI UpdateRegistryFromResourceS(LPCTSTR lpszRes, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries = NULL) throw() - { -#ifdef _ATL_STATIC_REGISTRY - return CAtlModuleT::UpdateRegistryFromResourceS(lpszRes, bRegister, pMapEntries); -#else - (lpszRes); - (bRegister); - (pMapEntries); - return E_FAIL; -#endif - } - virtual HRESULT WINAPI UpdateRegistryFromResourceS(UINT nResID, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries = NULL) throw() - { -#ifdef _ATL_STATIC_REGISTRY - return CAtlModuleT::UpdateRegistryFromResourceS(nResID, bRegister, pMapEntries); -#else - (nResID); - (bRegister); - (pMapEntries); - return E_FAIL; -#endif - } - - - // Use RGS file for registration - - ATL_DEPRECATED("CComModule::RegisterProgID is no longer recommended. Instead, use an RGS file for registration.") - static HRESULT RegisterProgID(LPCTSTR lpszCLSID, LPCTSTR lpszProgID, LPCTSTR lpszUserDesc); - // Standard Registration - ATL_DEPRECATED("CComModule::UpdateRegistryClass is no longer recommended. Instead, use an RGS file for registration.") - HRESULT WINAPI UpdateRegistryClass(const CLSID& clsid, LPCTSTR lpszProgID, LPCTSTR lpszVerIndProgID, UINT nDescID, DWORD dwFlags, BOOL bRegister); - ATL_DEPRECATED("CComModule::UpdateRegistryClass is no longer recommended. Instead, use an RGS file for registration.") - HRESULT WINAPI UpdateRegistryClass(const CLSID& clsid, LPCTSTR lpszProgID, LPCTSTR lpszVerIndProgID, LPCTSTR szDesc, DWORD dwFlags, BOOL bRegister); - ATL_DEPRECATED("CComModule::RegisterClassHelper is no longer recommended. Instead, use an RGS file for registration.") - HRESULT WINAPI RegisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID, LPCTSTR lpszVerIndProgID, LPCTSTR szDesc, DWORD dwFlags); - ATL_DEPRECATED("CComModule::UnregisterClassHelper is no longer recommended. Instead, use an RGS file for registration.") - HRESULT WINAPI UnregisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID, LPCTSTR lpszVerIndProgID); - - BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReserved */, _ATL_OBJMAP_ENTRY* pObjMap, const GUID* pLibID); - - BOOL WINAPI _DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReserved */, _ATL_OBJMAP_ENTRY* pObjMap, const GUID* pLibID) - { - if (dwReason == DLL_PROCESS_ATTACH) - { - if (CAtlBaseModule::m_bInitFailed) - { - ATLASSERT(0); - return FALSE; - } - - if (FAILED(Init(pObjMap, hInstance, pLibID))) - { - Term(); - return FALSE; - } -#ifdef _ATL_MIN_CRT - DisableThreadLibraryCalls(hInstance); -#endif - } - else if (dwReason == DLL_PROCESS_DETACH) - Term(); - return TRUE; // ok - } - - HRESULT DllCanUnloadNow() throw() - { - return (GetLockCount()==0) ? S_OK : S_FALSE; - } - HRESULT DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) throw() - { - return GetClassObject(rclsid, riid, ppv); - } - - HRESULT DllRegisterServer(BOOL bRegTypeLib = TRUE) throw() - { - // registers object, typelib and all interfaces in typelib - return RegisterServer(bRegTypeLib); - } - - HRESULT DllUnregisterServer(BOOL bUnRegTypeLib = TRUE) throw() - { - return UnregisterServer(bUnRegTypeLib); - } - -}; - - -#if (_MSC_VER >= 1400) -#pragma managed(push, off) -#else -#pragma unmanaged -#endif - -inline BOOL WINAPI CComModule::DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved, _ATL_OBJMAP_ENTRY* pObjMap, const GUID* pLibID) -{ -#if !defined(_ATL_NATIVE_INITIALIZATION) -#pragma warning(push) -#pragma warning(disable:4483) - using namespace __identifier(""); -#pragma warning(pop) - lpReserved; - if (dwReason == DLL_PROCESS_ATTACH) - { - ATLASSERT(ComModuleInitialized == false); - ComModuleHelper.Initialize(this, hInstance, pObjMap, pLibID); - } - return TRUE; -#else - return _DllMain(hInstance, dwReason, lpReserved, pObjMap, pLibID); -#endif -} - - -#if (_MSC_VER >= 1400) -#pragma managed(pop) -#else -#pragma managed -#endif - -#endif // !_ATL_NO_COMMODULE - -///////////////////////////////////////////////////////////////////////////// -// Thread creation helpers - -#if !defined(_ATL_MIN_CRT) && defined(_MT) -// CRTThreadTraits -// This class is for use with CThreadPool or CWorkerThread -// It should be used if the worker class will use CRT -// functions. -class CRTThreadTraits -{ -public: - static HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpsa, DWORD dwStackSize, LPTHREAD_START_ROUTINE pfnThreadProc, void *pvParam, DWORD dwCreationFlags, DWORD *pdwThreadId) throw() - { - ATLASSERT(sizeof(DWORD) == sizeof(unsigned int)); // sanity check for pdwThreadId - - // _beginthreadex calls CreateThread which will set the last error value before it returns. - return (HANDLE) _beginthreadex(lpsa, dwStackSize, (unsigned int (__stdcall *)(void *)) pfnThreadProc, pvParam, dwCreationFlags, (unsigned int *) pdwThreadId); - } -}; - -#endif - -// Win32ThreadTraits -// This class is for use with CThreadPool or CWorkerThread -// It should be used if the worker class will not use CRT -// functions. -class Win32ThreadTraits -{ -public: - static HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpsa, DWORD dwStackSize, LPTHREAD_START_ROUTINE pfnThreadProc, void *pvParam, DWORD dwCreationFlags, DWORD *pdwThreadId) throw() - { - return ::CreateThread(lpsa, dwStackSize, pfnThreadProc, pvParam, dwCreationFlags, pdwThreadId); - } -}; - -#if !defined(_ATL_MIN_CRT) && defined(_MT) - typedef CRTThreadTraits DefaultThreadTraits; -#else - typedef Win32ThreadTraits DefaultThreadTraits; -#endif - -template -HANDLE CreateThreadT(LPSECURITY_ATTRIBUTES lpsa, DWORD dwStackSize, DWORD (WINAPI * pfn)(T *pparam), - T *pparam, DWORD dwCreationFlags, LPDWORD pdw) -{ - return DefaultThreadTraits::CreateThread(lpsa, - dwStackSize, - (LPTHREAD_START_ROUTINE)pfn, - pparam, - dwCreationFlags, - pdw); -} - -template -HANDLE AtlCreateThread(DWORD (WINAPI* pfn)(T *pparam), T *pparam) -{ - return CreateThreadT(0, 0, pfn, pparam, 0, 0); -} - -///////////////////////////////////////////////////////////////////////////////////////////// -// Thread Pooling classes - -class _AtlAptCreateObjData -{ -public: - _ATL_CREATORFUNC* pfnCreateInstance; - const IID* piid; - HANDLE hEvent; - LPSTREAM pStream; - HRESULT hRes; -}; - -class CComApartment -{ -public: - CComApartment() - { - m_nLockCnt = 0; - m_hThread = NULL; - } - static UINT ATL_CREATE_OBJECT; - static DWORD WINAPI _Apartment(__in void* pv) - { - ATLENSURE(pv != NULL); - return ((CComApartment*)pv)->Apartment(); - } - DWORD Apartment() - { - CoInitialize(NULL); - MSG msg; - while(GetMessage(&msg, 0, 0, 0) > 0) - { - if (msg.message == ATL_CREATE_OBJECT) - { - _AtlAptCreateObjData* pdata = (_AtlAptCreateObjData*)msg.lParam; - IUnknown* pUnk = NULL; - pdata->hRes = pdata->pfnCreateInstance(NULL, __uuidof(IUnknown), (void**)&pUnk); - if (SUCCEEDED(pdata->hRes)) - pdata->hRes = CoMarshalInterThreadInterfaceInStream(*pdata->piid, pUnk, &pdata->pStream); - if (SUCCEEDED(pdata->hRes)) - { - pUnk->Release(); - ATLTRACE(atlTraceCOM, 2, _T("Object created on thread = %d\n"), GetCurrentThreadId()); - } -#ifdef _DEBUG - else - { - ATLTRACE(atlTraceCOM, 2, _T("Failed to create Object on thread = %d\n"), GetCurrentThreadId()); - } -#endif - SetEvent(pdata->hEvent); - } - DispatchMessage(&msg); - } - CoUninitialize(); - - return 0; - } - LONG Lock() {return CComGlobalsThreadModel::Increment(&m_nLockCnt);} - LONG Unlock(){return CComGlobalsThreadModel::Decrement(&m_nLockCnt); - } - LONG GetLockCount() {return m_nLockCnt;} - - DWORD m_dwThreadID; - HANDLE m_hThread; - LONG m_nLockCnt; -}; - -__declspec(selectany) UINT CComApartment::ATL_CREATE_OBJECT = 0; - -class CComSimpleThreadAllocator -{ -public: - CComSimpleThreadAllocator() - { - m_nThread = 0; - } - int GetThread(CComApartment* /*pApt*/, int nThreads) - { - if (++m_nThread == nThreads) - m_nThread = 0; - return m_nThread; - } - int m_nThread; -}; - -__interface IAtlAutoThreadModule -{ - virtual HRESULT CreateInstance(void* pfnCreateInstance, REFIID riid, void** ppvObj); -}; - -__declspec(selectany) IAtlAutoThreadModule* _pAtlAutoThreadModule; - -template -class ATL_NO_VTABLE CAtlAutoThreadModuleT : public IAtlAutoThreadModule -{ -// This class is not for use in a DLL. -// If this class were used in a DLL, there will be a deadlock when the DLL is unloaded. -// because of dwWait's default value of INFINITE -public: - CAtlAutoThreadModuleT(int nThreads = T::GetDefaultThreads()) - { - ATLASSERT(_pAtlAutoThreadModule == NULL); - _pAtlAutoThreadModule = this; - m_pApartments = NULL; - m_nThreads= 0; - - ATLTRY(m_pApartments = new CComApartment[nThreads]); - ATLASSERT(m_pApartments != NULL); - if(m_pApartments == NULL) - { - CAtlBaseModule::m_bInitFailed = true; - ATLENSURE(0); - } - - memset(m_pApartments, 0, sizeof(CComApartment) * nThreads); - - m_nThreads = nThreads; - for (int i = 0; i < nThreads; i++) - { - -#if !defined(_ATL_MIN_CRT) && defined(_MT) - typedef unsigned ( __stdcall *pfnThread )( void * ); - m_pApartments[i].m_hThread = (HANDLE)_beginthreadex(NULL, 0, (pfnThread)CComApartment::_Apartment, &m_pApartments[i], 0, (UINT*)&m_pApartments[i].m_dwThreadID); - if (m_pApartments[i].m_hThread == NULL) - { - HRESULT hr = E_FAIL; - switch (Checked::get_errno()) - { - case EAGAIN: - hr = HRESULT_FROM_WIN32(ERROR_TOO_MANY_TCBS); - break; - case EINVAL: - hr = E_INVALIDARG; - break; - } - ATLASSERT(0); - CAtlBaseModule::m_bInitFailed = true; - break; - } - -#else - m_pApartments[i].m_hThread = ::CreateThread(NULL, 0, CComApartment::_Apartment, (void*)&m_pApartments[i], 0, &m_pApartments[i].m_dwThreadID); - // clean up allocated threads - if (m_pApartments[i].m_hThread == NULL) - { - ATLASSERT(0); - CAtlBaseModule::m_bInitFailed = true; - break; - } - -#endif - - } - if (!CAtlBaseModule::m_bInitFailed) - CComApartment::ATL_CREATE_OBJECT = RegisterWindowMessage(_T("ATL_CREATE_OBJECT")); - } - - virtual ~CAtlAutoThreadModuleT() - { - if (m_pApartments == NULL) - return; - - DWORD dwCurrentThreadId = GetCurrentThreadId(); - int nCurrentThread = -1; - for (int i=0; i < m_nThreads; i++) - { - if (m_pApartments[i].m_hThread == NULL) - continue; - if (m_pApartments[i].m_dwThreadID == dwCurrentThreadId) - { - nCurrentThread = i; - continue; - } - while (::PostThreadMessage(m_pApartments[i].m_dwThreadID, WM_QUIT, 0, 0) == 0) - { - if (GetLastError() == ERROR_INVALID_THREAD_ID) - { - ATLASSERT(FALSE); - break; - } - ::Sleep(100); - } - ::WaitForSingleObject(m_pApartments[i].m_hThread, dwWait); - CloseHandle(m_pApartments[i].m_hThread); - } - if (nCurrentThread != -1) - CloseHandle(m_pApartments[nCurrentThread].m_hThread); - - delete [] m_pApartments; - m_pApartments = NULL; - } - - HRESULT CreateInstance(void* pfnCreateInstance, REFIID riid, void** ppvObj) - { - ATLASSERT(ppvObj != NULL); - if (ppvObj == NULL) - return E_POINTER; - *ppvObj = NULL; - - _ATL_CREATORFUNC* pFunc = (_ATL_CREATORFUNC*) pfnCreateInstance; - _AtlAptCreateObjData data; - data.pfnCreateInstance = pFunc; - data.piid = &riid; - data.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - data.hRes = S_OK; - int nThread = m_Allocator.GetThread(m_pApartments, m_nThreads); - int nIterations = 0; - while(::PostThreadMessage(m_pApartments[nThread].m_dwThreadID, CComApartment::ATL_CREATE_OBJECT, 0, (LPARAM)&data) == 0 && ++nIterations < 100) - { - Sleep(100); - } - if (nIterations < 100) - { - AtlWaitWithMessageLoop(data.hEvent); - } - else - { - data.hRes = AtlHresultFromLastError(); - } - CloseHandle(data.hEvent); - if (SUCCEEDED(data.hRes)) - data.hRes = CoGetInterfaceAndReleaseStream(data.pStream, riid, ppvObj); - return data.hRes; - } - DWORD dwThreadID; - int m_nThreads; - CComApartment* m_pApartments; - ThreadAllocator m_Allocator; - static int GetDefaultThreads() - { - SYSTEM_INFO si; - GetSystemInfo(&si); - return si.dwNumberOfProcessors * 4; - } -}; - -class CAtlAutoThreadModule : public CAtlAutoThreadModuleT -{ -public : -}; - -#ifndef _ATL_NO_COMMODULE - -template -class CComAutoThreadModule : - public CComModule, - public CAtlAutoThreadModuleT, ThreadAllocator, dwWait> -{ -public: - CComAutoThreadModule(int nThreads = GetDefaultThreads()) : - CAtlAutoThreadModuleT, ThreadAllocator, dwWait>(nThreads) - { - } - HRESULT Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, const GUID* plibid = NULL, int nThreads = GetDefaultThreads()) - { - nThreads; - ATLASSERT(nThreads == GetDefaultThreads() && _T("Set number of threads through the constructor")); - return CComModule::Init(p, h, plibid); - } -}; - -#endif // !_ATL_NO_COMMODULE - -// Used in CThreadPool -class Win32WaitTraits -{ -public: - static DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwTimeout) - { - return ::WaitForSingleObject(hHandle, dwTimeout); - } -}; - -typedef Win32WaitTraits DefaultWaitTraits; - -///////////////////////////////////////////////////////////////////////////// -// GIT Pointer - -template -class CComGITPtr -{ -public: - CComGITPtr() throw() - { - m_dwCookie = 0; - } - CComGITPtr(T* p) - { - m_dwCookie = 0; - HRESULT hr = Attach(p); - - if (FAILED(hr)) - AtlThrow(hr); - } - CComGITPtr(const CComGITPtr& git) - { - m_dwCookie = 0; - CComPtr spT; - - HRESULT hr = git.CopyTo(&spT); - if (SUCCEEDED(hr)) - hr = Attach(spT); - - if (FAILED(hr)) - AtlThrow(hr); - } - explicit CComGITPtr(DWORD dwCookie) throw() - { - ATLASSUME(m_dwCookie != NULL); - m_dwCookie = dwCookie; - -#ifdef _DEBUG - CComPtr spT; - HRESULT hr = CopyTo(&spT); - ATLASSERT(SUCCEEDED(hr)); -#endif - } - - ~CComGITPtr() throw() - { - Revoke(); - } - CComGITPtr& operator=(const CComGITPtr& git) - { - if(*this!=git) - { - CComPtr spT; - - HRESULT hr = git.CopyTo(&spT); - if (SUCCEEDED(hr)) - { - hr = Attach(spT); - } - - if (FAILED(hr)) - { - AtlThrow(hr); - } - } - return *this; - } - CComGITPtr& operator=(T* p) - { - HRESULT hr = Attach(p); - if (FAILED(hr)) - AtlThrow(hr); - return *this; - } - CComGITPtr& operator=(DWORD dwCookie) - { - if(*this!=dwCookie) - { - HRESULT hr = Attach(dwCookie); - if (FAILED(hr)) - { - AtlThrow(hr); - } - - m_dwCookie = dwCookie; - -#ifdef _DEBUG - CComPtr spT; - hr = CopyTo(&spT); - ATLASSERT(SUCCEEDED(hr)); -#endif - } - return *this; - } - - // basic comparison operators - bool operator!=(CComGITPtr& git) const - { - return !operator==(git); - } - - bool operator!=(DWORD dwCookie) const - { - return !operator==(dwCookie); - } - - bool operator==(CComGITPtr& git) const - { - return m_dwCookie==git.GetCookie(); - } - - bool operator==(DWORD dwCookie) const - { - return m_dwCookie==dwCookie; - } - - // Get the cookie from the class - operator DWORD() const - { - return m_dwCookie; - } - // Get the cookie from the class - DWORD GetCookie() const - { - return m_dwCookie; - } - // Register the passed interface pointer in the GIT - HRESULT Attach(T* p) throw() - { - CComPtr spGIT; - HRESULT hr = E_FAIL; - hr = AtlGetGITPtr(&spGIT); - ATLASSERT(spGIT != NULL); - ATLASSERT(SUCCEEDED(hr)); - if (FAILED(hr)) - return hr; - - if (m_dwCookie != 0) - hr = spGIT->RevokeInterfaceFromGlobal(m_dwCookie); - if (FAILED(hr)) - return hr; - - return spGIT->RegisterInterfaceInGlobal(p, __uuidof(T), &m_dwCookie); - } - - HRESULT Attach(DWORD dwCookie) throw() - { - ATLASSERT(dwCookie != NULL); - HRESULT hr = Revoke(); - if (FAILED(hr)) - return hr; - m_dwCookie = dwCookie; - return S_OK; - } - - // Detach - DWORD Detach() throw() - { - DWORD dwCookie = m_dwCookie; - m_dwCookie = NULL; - return dwCookie; - } - - // Remove the interface from the GIT - HRESULT Revoke() throw() - { - HRESULT hr = S_OK; - if (m_dwCookie != 0) - { - CComPtr spGIT; - HRESULT hr = E_FAIL; - hr = AtlGetGITPtr(&spGIT); - - ATLASSERT(spGIT != NULL); - ATLASSERT(SUCCEEDED(hr)); - if (FAILED(hr)) - return hr; - - hr = spGIT->RevokeInterfaceFromGlobal(m_dwCookie); - if (SUCCEEDED(hr)) - m_dwCookie = 0; - } - return hr; - } - // Get's the interface from the GIT and copies it to the passed pointer. The pointer - // must be released by the caller when finished. - HRESULT CopyTo(T** pp) const throw() - { - CComPtr spGIT; - HRESULT hr = E_FAIL; - hr = AtlGetGITPtr(&spGIT); - - ATLASSERT(spGIT != NULL); - ATLASSERT(SUCCEEDED(hr)); - if (FAILED(hr)) - return hr; - - ATLASSUME(m_dwCookie!=NULL); - return spGIT->GetInterfaceFromGlobal(m_dwCookie, __uuidof(T), (void**)pp); - } - DWORD m_dwCookie; -}; - -///////////////////////////////////////////////////////////////////////////// -// CRegKey - -typedef LONG (WINAPI _ATL_DELETEKEYEXFUNC)(HKEY hKey, LPCTSTR lpSubKey, REGSAM samDesired, DWORD Reserved); -typedef LONG (WINAPI _ATL_DELETEKEYFUNC)(HKEY hKey, LPCTSTR lpSubKey); - -class CRegKey -{ -public: - CRegKey() throw(); - CRegKey( CRegKey& key ) throw(); - explicit CRegKey(HKEY hKey) throw(); - ~CRegKey() throw(); - - CRegKey& operator=( CRegKey& key ) throw(); - -// Attributes -public: - operator HKEY() const throw(); - HKEY m_hKey; - -private: - _ATL_DELETEKEYEXFUNC* pfnDeleteKeyEx; - _ATL_DELETEKEYFUNC* pfnDeleteKey; - -// Operations -public: - ATL_DEPRECATED("CRegKey::SetValue(DWORD, TCHAR *valueName) has been superseded by CRegKey::SetDWORDValue") - LONG SetValue(DWORD dwValue, LPCTSTR lpszValueName); - ATL_DEPRECATED("CRegKey::SetValue(TCHAR *value, TCHAR *valueName) has been superseded by CRegKey::SetStringValue and CRegKey::SetMultiStringValue") - LONG SetValue(LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL, bool bMulti = false, int nValueLen = -1); - LONG SetValue(LPCTSTR pszValueName, DWORD dwType, const void* pValue, ULONG nBytes) throw(); - LONG SetGUIDValue(LPCTSTR pszValueName, REFGUID guidValue) throw(); - LONG SetBinaryValue(LPCTSTR pszValueName, const void* pValue, ULONG nBytes) throw(); - LONG SetDWORDValue(LPCTSTR pszValueName, DWORD dwValue) throw(); - LONG SetQWORDValue(LPCTSTR pszValueName, ULONGLONG qwValue) throw(); - LONG SetStringValue(__in_z_opt LPCTSTR pszValueName, __in_z LPCTSTR pszValue, __in DWORD dwType = REG_SZ) throw(...); - LONG SetMultiStringValue(LPCTSTR pszValueName, LPCTSTR pszValue) throw(...); - - ATL_DEPRECATED("CRegKey::QueryValue(DWORD, TCHAR *valueName) has been superseded by CRegKey::QueryDWORDValue") - LONG QueryValue(__out DWORD& dwValue, __in_z_opt LPCTSTR lpszValueName); - ATL_DEPRECATED("CRegKey::QueryValue(TCHAR *value, TCHAR *valueName) has been superseded by CRegKey::QueryStringValue and CRegKey::QueryMultiStringValue") - LONG QueryValue(__out_ecount_part_z_opt(*pdwCount, *pdwCount) LPTSTR szValue, __in_z_opt LPCTSTR lpszValueName, __inout DWORD* pdwCount); - LONG QueryValue(__in_z_opt LPCTSTR pszValueName, DWORD* pdwType, void* pData, ULONG* pnBytes) throw(); - LONG QueryGUIDValue(__in_z_opt LPCTSTR pszValueName, GUID& guidValue) throw(); - LONG QueryBinaryValue(__in_z_opt LPCTSTR pszValueName, void* pValue, ULONG* pnBytes) throw(); - LONG QueryDWORDValue(__in_z_opt LPCTSTR pszValueName, DWORD& dwValue) throw(); - LONG QueryQWORDValue(__in_z_opt LPCTSTR pszValueName, ULONGLONG& qwValue) throw(); - LONG QueryStringValue(__in_z_opt LPCTSTR pszValueName, __out_ecount_part_z_opt(*pnChars, *pnChars) LPTSTR pszValue, __inout ULONG* pnChars) throw(); - - LONG QueryMultiStringValue(__in_z_opt LPCTSTR pszValueName, __out_ecount_part_z_opt(*pnChars, *pnChars) __out_z LPTSTR pszValue, __inout ULONG* pnChars) throw(); - - // Get the key's security attributes. - LONG GetKeySecurity(SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR psd, LPDWORD pnBytes) throw(); - // Set the key's security attributes. - LONG SetKeySecurity(SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR psd) throw(); - - LONG SetKeyValue(LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL) throw(); - static LONG WINAPI SetValue(HKEY hKeyParent, LPCTSTR lpszKeyName, - LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL); - - // Create a new registry key (or open an existing one). - LONG Create(__in HKEY hKeyParent, __in_z LPCTSTR lpszKeyName, - __in_z_opt LPTSTR lpszClass = REG_NONE, __in DWORD dwOptions = REG_OPTION_NON_VOLATILE, - __in REGSAM samDesired = KEY_READ | KEY_WRITE, - __in_opt LPSECURITY_ATTRIBUTES lpSecAttr = NULL, - __in_opt LPDWORD lpdwDisposition = NULL) throw(); - // Open an existing registry key. - LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, - REGSAM samDesired = KEY_READ | KEY_WRITE) throw(); - // Close the registry key. - LONG Close() throw(); - // Flush the key's data to disk. - LONG Flush() throw(); - - // Detach the CRegKey object from its HKEY. Releases ownership. - HKEY Detach() throw(); - // Attach the CRegKey object to an existing HKEY. Takes ownership. - void Attach(HKEY hKey) throw(); - - // Enumerate the subkeys of the key. - LONG EnumKey(__in DWORD iIndex, __out_ecount_part_z(*pnNameLength, *pnNameLength) LPTSTR pszName, __inout LPDWORD pnNameLength, __out_opt FILETIME* pftLastWriteTime = NULL) throw(); - LONG NotifyChangeKeyValue(BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent, BOOL bAsync = TRUE) throw(); - - LONG DeleteSubKey(LPCTSTR lpszSubKey) throw(); - LONG RecurseDeleteKey(LPCTSTR lpszKey) throw(); - LONG DeleteValue(LPCTSTR lpszValue) throw(); -}; - -inline CRegKey::CRegKey() throw() : - m_hKey( NULL ), - pfnDeleteKeyEx( NULL ), - pfnDeleteKey( NULL ) -{ -} - -inline CRegKey::CRegKey( CRegKey& key ) throw() : - m_hKey( NULL ), - pfnDeleteKeyEx( NULL ), - pfnDeleteKey( NULL ) -{ - Attach( key.Detach() ); -} - -inline CRegKey::CRegKey(HKEY hKey) throw() : - m_hKey(hKey), - pfnDeleteKeyEx( NULL ), - pfnDeleteKey( NULL ) -{ -} - -inline CRegKey::~CRegKey() throw() -{Close();} - -inline CRegKey& CRegKey::operator=( CRegKey& key ) throw() -{ - if(m_hKey!=key.m_hKey) - { - Close(); - Attach( key.Detach() ); - } - return( *this ); -} - -inline CRegKey::operator HKEY() const throw() -{return m_hKey;} - -inline HKEY CRegKey::Detach() throw() -{ - HKEY hKey = m_hKey; - m_hKey = NULL; - return hKey; -} - -inline void CRegKey::Attach(HKEY hKey) throw() -{ - ATLASSUME(m_hKey == NULL); - m_hKey = hKey; -} - -#pragma warning(push) -#pragma warning(disable : 4191) // 'type cast' : unsafe conversion from 'FARPROC' to 'ATL::_ATL_DELETEKEYEXFUNC' - -inline LONG CRegKey::DeleteSubKey(LPCTSTR lpszSubKey) throw() -{ - ATLASSUME(m_hKey != NULL); - - HINSTANCE hInstDLL = NULL; - - if (pfnDeleteKeyEx == NULL && pfnDeleteKey == NULL) - { - // No DLL loaded yet -- get the appropriate one for the current OS. - // Use GetModuleHandle rather than LoadLibrary for apiset dll - // for two reasons: - // - // 1. On Win7+, it will already be loaded into the process - // - // 2. It ensures that there is no opportunity to get a rogue - // "apiset dll" loaded on a down-level machine - - hInstDLL = ::GetModuleHandle(_T("API-MS-Win-Core-LocalRegistry-L1-1-0.dll")); - if (hInstDLL != NULL) - { -#ifdef UNICODE - pfnDeleteKeyEx = (_ATL_DELETEKEYEXFUNC*)GetProcAddress(hInstDLL, "RegDeleteKeyExW"); -#else - pfnDeleteKeyEx = (_ATL_DELETEKEYEXFUNC*)GetProcAddress(hInstDLL, "RegDeleteKeyExA"); -#endif - } - else - { - // No apiset dll, so load advapi32.dll instead. - // Note that this DLL is never unloaded for two reasons: - // - // 1. It is likely that the CRegKey destructor is called - // during DLL_PROCESS_ATTACH in multiple applications. - // - // 2. Whichever DLL is found (apiset dll or advapi32.dll) - // is almost guaranteed to be in use by other DLLs in the - // process, so the unload would have little (or no) effect. - - hInstDLL = ::LoadLibrary(_T("advapi32.dll")); - if (hInstDLL != NULL) - { -#ifdef UNICODE - pfnDeleteKey = (_ATL_DELETEKEYFUNC*)GetProcAddress(hInstDLL, "RegDeleteKeyW"); -#else - pfnDeleteKey = (_ATL_DELETEKEYFUNC*)GetProcAddress(hInstDLL, "RegDeleteKeyA"); -#endif - } - } - } - - if (pfnDeleteKeyEx != NULL) - { - return pfnDeleteKeyEx(m_hKey, lpszSubKey, 0, 0); - } - else if (pfnDeleteKey != NULL) - { - return pfnDeleteKey(m_hKey, lpszSubKey); - } - - // DLL loads failed - return GetLastError(); -} - -#pragma warning(pop) - -inline LONG CRegKey::DeleteValue(LPCTSTR lpszValue) throw() -{ - ATLASSUME(m_hKey != NULL); - return RegDeleteValue(m_hKey, (LPTSTR)lpszValue); -} - -inline LONG CRegKey::Close() throw() -{ - LONG lRes = ERROR_SUCCESS; - if (m_hKey != NULL) - { - lRes = RegCloseKey(m_hKey); - m_hKey = NULL; - } - return lRes; -} - -inline LONG CRegKey::Flush() throw() -{ - ATLASSUME(m_hKey != NULL); - - return ::RegFlushKey(m_hKey); -} - -inline LONG CRegKey::EnumKey(__in DWORD iIndex, __out_ecount_part_z(*pnNameLength, *pnNameLength) LPTSTR pszName, __inout LPDWORD pnNameLength, __out_opt FILETIME* pftLastWriteTime) throw() -{ - FILETIME ftLastWriteTime; - - ATLASSUME(m_hKey != NULL); - if (pftLastWriteTime == NULL) - { - pftLastWriteTime = &ftLastWriteTime; - } - - return ::RegEnumKeyEx(m_hKey, iIndex, pszName, pnNameLength, NULL, NULL, NULL, pftLastWriteTime); -} - -inline LONG CRegKey::NotifyChangeKeyValue(BOOL bWatchSubtree, DWORD dwNotifyFilter, HANDLE hEvent, BOOL bAsync) throw() -{ - ATLASSUME(m_hKey != NULL); - ATLASSERT((hEvent != NULL) || !bAsync); - - return ::RegNotifyChangeKeyValue(m_hKey, bWatchSubtree, dwNotifyFilter, hEvent, bAsync); -} - -inline LONG CRegKey::Create(__in HKEY hKeyParent, __in_z LPCTSTR lpszKeyName, - __in_z_opt LPTSTR lpszClass, __in DWORD dwOptions, __in REGSAM samDesired, - __in_opt LPSECURITY_ATTRIBUTES lpSecAttr, __in_opt LPDWORD lpdwDisposition) throw() -{ - ATLASSERT(hKeyParent != NULL); - DWORD dw; - HKEY hKey = NULL; - LONG lRes = RegCreateKeyEx(hKeyParent, lpszKeyName, 0, - lpszClass, dwOptions, samDesired, lpSecAttr, &hKey, &dw); - if (lpdwDisposition != NULL) - *lpdwDisposition = dw; - if (lRes == ERROR_SUCCESS) - { - lRes = Close(); - m_hKey = hKey; - } - return lRes; -} - -inline LONG CRegKey::Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired) throw() -{ - ATLASSERT(hKeyParent != NULL); - HKEY hKey = NULL; - LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyName, 0, samDesired, &hKey); - if (lRes == ERROR_SUCCESS) - { - lRes = Close(); - ATLASSERT(lRes == ERROR_SUCCESS); - m_hKey = hKey; - } - return lRes; -} - -#pragma warning(push) -#pragma warning(disable: 4996) -inline LONG CRegKey::QueryValue(DWORD& dwValue, LPCTSTR lpszValueName) -{ - DWORD dwType = NULL; - DWORD dwCount = sizeof(DWORD); - LONG lRes = RegQueryValueEx(m_hKey, lpszValueName, NULL, &dwType, - (LPBYTE)&dwValue, &dwCount); - ATLASSERT((lRes!=ERROR_SUCCESS) || (dwType == REG_DWORD)); - ATLASSERT((lRes!=ERROR_SUCCESS) || (dwCount == sizeof(DWORD))); - if (dwType != REG_DWORD) - return ERROR_INVALID_DATA; - return lRes; -} - -// -// [pfx_parse] - workaround for PREfix parse problem -// -#if ((defined(_PREFIX_)) || (defined(_PREFAST_))) && (_MSC_VER < 1400) - // do nothing, this pragma not understood by PREfix 5.1 -#else // !_PREFIX_ -#pragma warning(disable: 6053) -#endif //!_PREFIX_ - -inline LONG CRegKey::QueryValue(__out_ecount_part_z_opt(*pdwCount, *pdwCount) LPTSTR pszValue, __in_z_opt LPCTSTR lpszValueName, __inout DWORD* pdwCount) -{ - ATLENSURE(pdwCount != NULL); - DWORD dwType = NULL; - LONG lRes = RegQueryValueEx(m_hKey, lpszValueName, NULL, &dwType, (LPBYTE)pszValue, pdwCount); - ATLASSERT((lRes!=ERROR_SUCCESS) || (dwType == REG_SZ) || - (dwType == REG_MULTI_SZ) || (dwType == REG_EXPAND_SZ)); - if (pszValue != NULL) - { - if(*pdwCount>0) - { - switch(dwType) - { - case REG_SZ: - case REG_EXPAND_SZ: - if ((*pdwCount) % sizeof(TCHAR) != 0 || pszValue[(*pdwCount) / sizeof(TCHAR) - 1] != 0) - { - pszValue[0]=_T('\0'); - return ERROR_INVALID_DATA; - } - break; - case REG_MULTI_SZ: - if ((*pdwCount) % sizeof(TCHAR) != 0 || (*pdwCount) / sizeof(TCHAR) < 1 || pszValue[(*pdwCount) / sizeof(TCHAR) -1] != 0 || (((*pdwCount) / sizeof(TCHAR))>1 && pszValue[(*pdwCount) / sizeof(TCHAR) - 2] != 0) ) - { - pszValue[0]=_T('\0'); - return ERROR_INVALID_DATA; - } - break; - default: - // Ensure termination - pszValue[0]=_T('\0'); - return ERROR_INVALID_DATA; - } - } - else - { - // this is a blank one with no data yet - // Ensure termination - pszValue[0]=_T('\0'); - } - } - return lRes; -} -#pragma warning(pop) - -inline LONG CRegKey::QueryValue(LPCTSTR pszValueName, DWORD* pdwType, void* pData, ULONG* pnBytes) throw() -{ - ATLASSUME(m_hKey != NULL); - - return( ::RegQueryValueEx(m_hKey, pszValueName, NULL, pdwType, static_cast< LPBYTE >( pData ), pnBytes) ); -} - -inline LONG CRegKey::QueryDWORDValue(LPCTSTR pszValueName, DWORD& dwValue) throw() -{ - LONG lRes; - ULONG nBytes; - DWORD dwType; - - ATLASSUME(m_hKey != NULL); - - nBytes = sizeof(DWORD); - lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(&dwValue), - &nBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_DWORD) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; -} -inline LONG CRegKey::QueryQWORDValue(LPCTSTR pszValueName, ULONGLONG& qwValue) throw() -{ - LONG lRes; - ULONG nBytes; - DWORD dwType; - - ATLASSUME(m_hKey != NULL); - - nBytes = sizeof(ULONGLONG); - lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(&qwValue), - &nBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_QWORD) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; -} - -inline LONG CRegKey::QueryBinaryValue(LPCTSTR pszValueName, void* pValue, ULONG* pnBytes) throw() -{ - LONG lRes; - DWORD dwType; - - ATLASSERT(pnBytes != NULL); - ATLASSUME(m_hKey != NULL); - - lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pValue), - pnBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_BINARY) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; -} - -#pragma warning(push) - -// -// [pfx_parse] - workaround for PREfix parse problem -// -#if ((defined(_PREFIX_)) || (defined(_PREFAST_))) && (_MSC_VER < 1400) - // do nothing, this pragma not understood by PREfix 5.1 -#else // !_PREFIX_ -#pragma warning(disable: 6053) -#endif //!_PREFIX_ - -/* prefast noise VSW 496818 */ -inline LONG CRegKey::QueryStringValue(__in_z_opt LPCTSTR pszValueName, __out_ecount_part_z_opt(*pnChars, *pnChars) __out_z LPTSTR pszValue, __inout ULONG* pnChars) throw() -{ - LONG lRes; - DWORD dwType; - ULONG nBytes; - - ATLASSUME(m_hKey != NULL); - ATLASSERT(pnChars != NULL); - - nBytes = (*pnChars)*sizeof(TCHAR); - *pnChars = 0; - lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pszValue), - &nBytes); - - if (lRes != ERROR_SUCCESS) - { - return lRes; - } - - if(dwType != REG_SZ && dwType != REG_EXPAND_SZ) - { - return ERROR_INVALID_DATA; - } - - if (pszValue != NULL) - { - if(nBytes!=0) - { - if ((nBytes % sizeof(TCHAR) != 0) || (pszValue[nBytes / sizeof(TCHAR) -1] != 0)) - { - return ERROR_INVALID_DATA; - } - } - else - { - pszValue[0]=_T('\0'); - } - } - - *pnChars = nBytes/sizeof(TCHAR); - - return ERROR_SUCCESS; -} -#pragma warning(pop) - -#pragma warning(push) - -// -// [pfx_parse] - workaround for PREfix parse problem -// -#if ((defined(_PREFIX_)) || (defined(_PREFAST_))) && (_MSC_VER < 1400) - // do nothing, this pragma not understood by PREfix 5.1 -#else // !_PREFIX_ -#pragma warning(disable: 6053) -#endif // !_PREFIX_ - -/* prefast noise VSW 496818 */ -inline LONG CRegKey::QueryMultiStringValue(__in_z_opt LPCTSTR pszValueName, __out_ecount_part_z_opt(*pnChars, *pnChars) __out_z LPTSTR pszValue, __inout ULONG* pnChars) throw() -{ - LONG lRes; - DWORD dwType; - ULONG nBytes; - - ATLASSUME(m_hKey != NULL); - ATLASSERT(pnChars != NULL); - - if (pszValue != NULL && *pnChars < 2) - return ERROR_INSUFFICIENT_BUFFER; - - nBytes = (*pnChars)*sizeof(TCHAR); - *pnChars = 0; - - lRes = ::RegQueryValueEx(m_hKey, pszValueName, NULL, &dwType, reinterpret_cast(pszValue), - &nBytes); - if (lRes != ERROR_SUCCESS) - return lRes; - if (dwType != REG_MULTI_SZ) - return ERROR_INVALID_DATA; - if (pszValue != NULL && (nBytes % sizeof(TCHAR) != 0 || nBytes / sizeof(TCHAR) < 1 || pszValue[nBytes / sizeof(TCHAR) -1] != 0 || ((nBytes/sizeof(TCHAR))>1 && pszValue[nBytes / sizeof(TCHAR) - 2] != 0))) - return ERROR_INVALID_DATA; - - *pnChars = nBytes/sizeof(TCHAR); - - return ERROR_SUCCESS; -} -#pragma warning(pop) - -inline LONG CRegKey::QueryGUIDValue(LPCTSTR pszValueName, GUID& guidValue) throw() -{ - TCHAR szGUID[64]; - LONG lRes; - ULONG nCount; - HRESULT hr; - - ATLASSUME(m_hKey != NULL); - - guidValue = GUID_NULL; - - nCount = 64; - lRes = QueryStringValue(pszValueName, szGUID, &nCount); - - if (lRes != ERROR_SUCCESS) - return lRes; - - if(szGUID[0] != _T('{')) - return ERROR_INVALID_DATA; - - USES_CONVERSION_EX; - LPOLESTR lpstr = T2OLE_EX(szGUID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(lpstr == NULL) - return E_OUTOFMEMORY; -#endif - - hr = ::CLSIDFromString(lpstr, &guidValue); - if (FAILED(hr)) - return ERROR_INVALID_DATA; - - return ERROR_SUCCESS; -} - -inline LONG WINAPI CRegKey::SetValue(HKEY hKeyParent, LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName) -{ - ATLASSERT(lpszValue != NULL); - CRegKey key; - LONG lRes = key.Create(hKeyParent, lpszKeyName); - if (lRes == ERROR_SUCCESS) - lRes = key.SetStringValue(lpszValueName, lpszValue); - return lRes; -} - -inline LONG CRegKey::SetKeyValue(LPCTSTR lpszKeyName, LPCTSTR lpszValue, LPCTSTR lpszValueName) throw() -{ - ATLASSERT(lpszValue != NULL); - CRegKey key; - LONG lRes = key.Create(m_hKey, lpszKeyName); - if (lRes == ERROR_SUCCESS) - lRes = key.SetStringValue(lpszValueName, lpszValue); - return lRes; -} - -#pragma warning(push) -#pragma warning(disable: 4996) -inline LONG CRegKey::SetValue(DWORD dwValue, LPCTSTR pszValueName) -{ - ATLASSUME(m_hKey != NULL); - return SetDWORDValue(pszValueName, dwValue); -} - -inline LONG CRegKey::SetValue(LPCTSTR lpszValue, LPCTSTR lpszValueName, bool bMulti, int nValueLen) -{ - ATLENSURE(lpszValue != NULL); - ATLASSUME(m_hKey != NULL); - - if (bMulti && nValueLen == -1) - return ERROR_INVALID_PARAMETER; - - if (nValueLen == -1) - nValueLen = lstrlen(lpszValue) + 1; - - DWORD dwType = bMulti ? REG_MULTI_SZ : REG_SZ; - - return ::RegSetValueEx(m_hKey, lpszValueName, NULL, dwType, - reinterpret_cast(lpszValue), nValueLen*sizeof(TCHAR)); -} -#pragma warning(pop) - -inline LONG CRegKey::SetValue(LPCTSTR pszValueName, DWORD dwType, const void* pValue, ULONG nBytes) throw() -{ - ATLASSUME(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, dwType, static_cast(pValue), nBytes); -} - -inline LONG CRegKey::SetBinaryValue(LPCTSTR pszValueName, const void* pData, ULONG nBytes) throw() -{ - ATLASSUME(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_BINARY, reinterpret_cast(pData), nBytes); -} - -inline LONG CRegKey::SetDWORDValue(LPCTSTR pszValueName, DWORD dwValue) throw() -{ - ATLASSUME(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_DWORD, reinterpret_cast(&dwValue), sizeof(DWORD)); -} - -inline LONG CRegKey::SetQWORDValue(LPCTSTR pszValueName, ULONGLONG qwValue) throw() -{ - ATLASSUME(m_hKey != NULL); - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_QWORD, reinterpret_cast(&qwValue), sizeof(ULONGLONG)); -} - -inline LONG CRegKey::SetStringValue(__in_z_opt LPCTSTR pszValueName, __in_z LPCTSTR pszValue, __in DWORD dwType) throw(...) -{ - ATLASSUME(m_hKey != NULL); - ATLENSURE(pszValue != NULL); - ATLASSERT((dwType == REG_SZ) || (dwType == REG_EXPAND_SZ)); - - return ::RegSetValueEx(m_hKey, pszValueName, NULL, dwType, reinterpret_cast(pszValue), (lstrlen(pszValue)+1)*sizeof(TCHAR)); -} - -inline LONG CRegKey::SetMultiStringValue(LPCTSTR pszValueName, LPCTSTR pszValue) throw(...) -{ - LPCTSTR pszTemp; - ULONG nBytes; - ULONG nLength; - - ATLASSUME(m_hKey != NULL); - ATLENSURE(pszValue != NULL); - - // Find the total length (in bytes) of all of the strings, including the - // terminating '\0' of each string, and the second '\0' that terminates - // the list. - nBytes = 0; - pszTemp = pszValue; - do - { - nLength = lstrlen(pszTemp)+1; - pszTemp += nLength; - nBytes += nLength*sizeof(TCHAR); - } while (nLength != 1); - - return ::RegSetValueEx(m_hKey, pszValueName, NULL, REG_MULTI_SZ, reinterpret_cast(pszValue), - nBytes); -} - -inline LONG CRegKey::SetGUIDValue(LPCTSTR pszValueName, REFGUID guidValue) throw() -{ - OLECHAR szGUID[64]; - - ATLASSUME(m_hKey != NULL); - - ::StringFromGUID2(guidValue, szGUID, 64); - - USES_CONVERSION_EX; - LPCTSTR lpstr = OLE2CT_EX(szGUID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(lpstr == NULL) - return E_OUTOFMEMORY; -#endif - return SetStringValue(pszValueName, lpstr); -} - -inline LONG CRegKey::GetKeySecurity(SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR psd, LPDWORD pnBytes) throw() -{ - ATLASSUME(m_hKey != NULL); - ATLASSERT(pnBytes != NULL); - - return ::RegGetKeySecurity(m_hKey, si, psd, pnBytes); -} - -inline LONG CRegKey::SetKeySecurity(SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR psd) throw() -{ - ATLASSUME(m_hKey != NULL); - ATLASSERT(psd != NULL); - - return ::RegSetKeySecurity(m_hKey, si, psd); -} - -inline LONG CRegKey::RecurseDeleteKey(LPCTSTR lpszKey) throw() -{ - CRegKey key; - LONG lRes = key.Open(m_hKey, lpszKey, KEY_READ | KEY_WRITE); - if (lRes != ERROR_SUCCESS) - { - if (lRes != ERROR_FILE_NOT_FOUND && lRes != ERROR_PATH_NOT_FOUND) - { - ATLTRACE(atlTraceCOM, 0, _T("CRegKey::RecurseDeleteKey : Failed to Open Key %s(Error = %d)\n"), lpszKey, lRes); - } - return lRes; - } - FILETIME time; - DWORD dwSize = 256; - TCHAR szBuffer[256]; - while (RegEnumKeyEx(key.m_hKey, 0, szBuffer, &dwSize, NULL, NULL, NULL, - &time)==ERROR_SUCCESS) - { - lRes = key.RecurseDeleteKey(szBuffer); - if (lRes != ERROR_SUCCESS) - return lRes; - dwSize = 256; - } - key.Close(); - return DeleteSubKey(lpszKey); -} - -#ifndef _ATL_NO_COMMODULE - -inline HRESULT CComModule::RegisterProgID(LPCTSTR lpszCLSID, LPCTSTR lpszProgID, LPCTSTR lpszUserDesc) -{ - CRegKey keyProgID; - LONG lRes = keyProgID.Create(HKEY_CLASSES_ROOT, lpszProgID, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE); - if (lRes == ERROR_SUCCESS) - { - lRes = keyProgID.SetStringValue(NULL, lpszUserDesc); - if (lRes == ERROR_SUCCESS) - { - lRes = keyProgID.SetKeyValue(_T("CLSID"), lpszCLSID); - if (lRes == ERROR_SUCCESS) - return S_OK; - } - } - return AtlHresultFromWin32(lRes); -} - -inline HRESULT CComModule::RegisterAppId(LPCTSTR pAppId) -{ - CRegKey keyAppID; - HRESULT hr = S_OK; - LONG lRet; - - if ( (lRet = keyAppID.Open(HKEY_CLASSES_ROOT, _T("AppID"), KEY_WRITE)) == ERROR_SUCCESS) - { - TCHAR szModule1[MAX_PATH]; - TCHAR szModule2[MAX_PATH]; - TCHAR* pszFileName; - - DWORD dwFLen = ::GetModuleFileName(GetModuleInstance(), szModule1, MAX_PATH); - if ( dwFLen != 0 && dwFLen != MAX_PATH ) - { - if (::GetFullPathName(szModule1, MAX_PATH, szModule2, &pszFileName) != 0) - { - CRegKey keyAppIDEXE; - if ( (lRet = keyAppIDEXE.Create(keyAppID, pszFileName, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE)) == ERROR_SUCCESS) - { - lRet = keyAppIDEXE.SetStringValue(_T("AppID"), pAppId); - if (lRet != ERROR_SUCCESS) - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::RegisterAppId : Failed to set app id string value\n")); - hr = AtlHresultFromWin32(lRet); - return hr; - } - } - else - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::RegisterAppId : Failed to create file name key\n")); - hr = AtlHresultFromWin32(lRet); - return hr; - } - if ( (lRet = keyAppIDEXE.Create(keyAppID, pAppId, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE)) == ERROR_SUCCESS) - { - lRet = keyAppIDEXE.SetStringValue(NULL, pszFileName); - if (lRet != ERROR_SUCCESS) - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::RegisterAppId : Failed to set file name string value\n")); - hr = AtlHresultFromWin32(lRet); - return hr; - } - } - else - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::RegisterAppId : Failed to create app id key\n")); - hr = AtlHresultFromWin32(lRet); - return hr; - } - } - else - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::RegisterAppId : Failed to get full path name for file %s\n"), szModule1); - hr = AtlHresultFromLastError(); - } - } - else - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::RegisterAppId : Failed to get module name\n")); - if( dwFLen == 0 ) - hr = AtlHresultFromLastError(); - else if( dwFLen == MAX_PATH ) - hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } - } - else - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::RegisterAppId : Failed to open registry key\n")); - hr = AtlHresultFromWin32(lRet); - } - return hr; -} - -inline HRESULT CComModule::UnregisterAppId(LPCTSTR pAppId) -{ - CRegKey keyAppID; - HRESULT hr = S_OK; - LONG lRet = keyAppID.Open(HKEY_CLASSES_ROOT, _T("AppID"), KEY_READ | KEY_WRITE); - - if (lRet == ERROR_SUCCESS) - { - TCHAR szModule1[MAX_PATH]; - TCHAR szModule2[MAX_PATH]; - TCHAR* pszFileName; - - DWORD dwFLen = ::GetModuleFileName(GetModuleInstance(), szModule1, MAX_PATH); - if ( dwFLen != 0 && dwFLen != MAX_PATH ) - { - if (::GetFullPathName(szModule1, MAX_PATH, szModule2, &pszFileName) != 0) - { - if ((lRet = keyAppID.RecurseDeleteKey(pAppId)) != ERROR_SUCCESS) - { - if (lRet != ERROR_FILE_NOT_FOUND) - hr = AtlHresultFromWin32(lRet); - } - if ((lRet = keyAppID.RecurseDeleteKey(pszFileName)) != ERROR_SUCCESS) - { - if (lRet != ERROR_FILE_NOT_FOUND) - hr = AtlHresultFromWin32(lRet); - } - } - else - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::UnregisterAppId : Failed to get full path name for file %s\n"), szModule1); - hr = AtlHresultFromLastError(); - } - } - else - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::UnregisterAppId : Failed to get module name\n")); - if( dwFLen == 0 ) - hr = AtlHresultFromLastError(); - else if( dwFLen == MAX_PATH ) - hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } - } - else - { - if (lRet != ERROR_FILE_NOT_FOUND && lRet != ERROR_PATH_NOT_FOUND) - { - ATLTRACE(atlTraceCOM, 0, _T("CComModule::UnregisterAppId : Failed to open registry key\n")); - hr = AtlHresultFromWin32(lRet); - } - } - return hr; -} -#endif // !_ATL_NO_COMMODULE - -#ifdef _ATL_STATIC_REGISTRY -} // namespace ATL - - -#include - - - -namespace ATL -{ - -// Statically linking to Registry Ponent -inline HRESULT WINAPI CAtlModule::UpdateRegistryFromResourceS(LPCTSTR lpszRes, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries /*= NULL*/) throw() -{ - CRegObject ro; - HRESULT hr = ro.FinalConstruct(); - if (FAILED(hr)) - { - return hr; - } - - if (pMapEntries != NULL) - { - while (pMapEntries->szKey != NULL) - { - ATLASSERT(NULL != pMapEntries->szData); - ro.AddReplacement(pMapEntries->szKey, pMapEntries->szData); - pMapEntries++; - } - } - - hr = AddCommonRGSReplacements(&ro); - if (FAILED(hr)) - return hr; - - USES_CONVERSION_EX; - TCHAR szModule[MAX_PATH]; - HINSTANCE hInst = _AtlBaseModule.GetModuleInstance(); - DWORD dwFLen = GetModuleFileName(hInst, szModule, MAX_PATH); - if( dwFLen == 0 ) - return AtlHresultFromLastError(); - else if( dwFLen == MAX_PATH ) - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - - - LPOLESTR pszModule = NULL; - pszModule = T2OLE_EX(szModule, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(pszModule == NULL) - return E_OUTOFMEMORY; -#endif - - OLECHAR pszModuleUnquoted[_MAX_PATH * 2]; - EscapeSingleQuote(pszModuleUnquoted, _countof(pszModuleUnquoted), pszModule); - - HRESULT hRes; - if ((hInst == NULL) || (hInst == GetModuleHandle(NULL))) // register as EXE - { - // If Registering as an EXE, then we quote the resultant path. - // We don't do it for a DLL, because LoadLibrary fails if the path is - // quoted - OLECHAR pszModuleQuote[(_MAX_PATH + _ATL_QUOTES_SPACE)*2]; - pszModuleQuote[0] = OLESTR('\"'); - if(!ocscpy_s(pszModuleQuote + 1, (_MAX_PATH + _ATL_QUOTES_SPACE)*2 - 1, pszModuleUnquoted)) - { - return E_FAIL; - } - size_t nLen = ocslen(pszModuleQuote); - pszModuleQuote[nLen] = OLESTR('\"'); - pszModuleQuote[nLen + 1] = 0; - - hRes = ro.AddReplacement(OLESTR("Module"), pszModuleQuote); - } - else - { - hRes = ro.AddReplacement(OLESTR("Module"), pszModuleUnquoted); - } - - if(FAILED(hRes)) - return hRes; - - hRes = ro.AddReplacement(OLESTR("Module_Raw"), pszModuleUnquoted); - if(FAILED(hRes)) - return hRes; - - LPCOLESTR szType = OLESTR("REGISTRY"); - LPCOLESTR pszRes = T2COLE_EX(lpszRes, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(pszRes == NULL) - return E_OUTOFMEMORY; -#endif - hr = (bRegister) ? ro.ResourceRegisterSz(pszModule, pszRes, szType) : - ro.ResourceUnregisterSz(pszModule, pszRes, szType); - return hr; -} -inline HRESULT WINAPI CAtlModule::UpdateRegistryFromResourceS(UINT nResID, BOOL bRegister, - struct _ATL_REGMAP_ENTRY* pMapEntries /*= NULL*/) throw() -{ - CRegObject ro; - HRESULT hr = ro.FinalConstruct(); - if (FAILED(hr)) - { - return hr; - } - - if (pMapEntries != NULL) - { - while (pMapEntries->szKey != NULL) - { - ATLASSERT(NULL != pMapEntries->szData); - ro.AddReplacement(pMapEntries->szKey, pMapEntries->szData); - pMapEntries++; - } - } - - hr = AddCommonRGSReplacements(&ro); - if (FAILED(hr)) - return hr; - - USES_CONVERSION_EX; - TCHAR szModule[MAX_PATH]; - HINSTANCE hInst = _AtlBaseModule.GetModuleInstance(); - DWORD dwFLen = GetModuleFileName(hInst, szModule, MAX_PATH); - if( dwFLen == 0 ) - return AtlHresultFromLastError(); - else if( dwFLen == MAX_PATH ) - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - - LPOLESTR pszModule = NULL; - pszModule = T2OLE_EX(szModule, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(pszModule == NULL) - return E_OUTOFMEMORY; -#endif - - OLECHAR pszModuleUnquoted[_MAX_PATH * 2]; - EscapeSingleQuote(pszModuleUnquoted, _countof(pszModuleUnquoted), pszModule); - - HRESULT hRes; - if ((hInst == NULL) || (hInst == GetModuleHandle(NULL))) // register as EXE - { - // If Registering as an EXE, then we quote the resultant path. - // We don't do it for a DLL, because LoadLibrary fails if the path is - // quoted - OLECHAR pszModuleQuote[(_MAX_PATH + _ATL_QUOTES_SPACE)*2]; - pszModuleQuote[0] = OLESTR('\"'); - if(!ocscpy_s(pszModuleQuote + 1, (_MAX_PATH + _ATL_QUOTES_SPACE)*2 - 1, pszModuleUnquoted)) - { - return E_FAIL; - } - size_t nLen = ocslen(pszModuleQuote); - pszModuleQuote[nLen] = OLESTR('\"'); - pszModuleQuote[nLen + 1] = 0; - - hRes = ro.AddReplacement(OLESTR("Module"), pszModuleQuote); - } - else - { - hRes = ro.AddReplacement(OLESTR("Module"), pszModuleUnquoted); - } - - if(FAILED(hRes)) - return hRes; - - hRes = ro.AddReplacement(OLESTR("Module_Raw"), pszModuleUnquoted); - if(FAILED(hRes)) - return hRes; - - LPCOLESTR szType = OLESTR("REGISTRY"); - hr = (bRegister) ? ro.ResourceRegister(pszModule, nResID, szType) : - ro.ResourceUnregister(pszModule, nResID, szType); - return hr; -} -#endif //_ATL_STATIC_REGISTRY - -#ifndef _ATL_NO_COMMODULE - -#pragma warning( push ) -#pragma warning( disable: 4996 ) // Disable "deprecated symbol" warning - -inline HRESULT WINAPI CComModule::UpdateRegistryClass(const CLSID& clsid, LPCTSTR lpszProgID, - LPCTSTR lpszVerIndProgID, UINT nDescID, DWORD dwFlags, BOOL bRegister) -{ - if (bRegister) - { - TCHAR szDesc[256]; - LoadString(m_hInst, nDescID, szDesc, 256); - return RegisterClassHelper(clsid, lpszProgID, lpszVerIndProgID, szDesc, dwFlags); - } - return UnregisterClassHelper(clsid, lpszProgID, lpszVerIndProgID); -} - -inline HRESULT WINAPI CComModule::UpdateRegistryClass(const CLSID& clsid, LPCTSTR lpszProgID, - LPCTSTR lpszVerIndProgID, LPCTSTR szDesc, DWORD dwFlags, BOOL bRegister) -{ - if (bRegister) - return RegisterClassHelper(clsid, lpszProgID, lpszVerIndProgID, szDesc, dwFlags); - return UnregisterClassHelper(clsid, lpszProgID, lpszVerIndProgID); -} - -inline HRESULT WINAPI CComModule::RegisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID, - LPCTSTR lpszVerIndProgID, LPCTSTR szDesc, DWORD dwFlags) -{ - static const TCHAR szProgID[] = _T("ProgID"); - static const TCHAR szVIProgID[] = _T("VersionIndependentProgID"); - static const TCHAR szLS32[] = _T("LocalServer32"); - static const TCHAR szIPS32[] = _T("InprocServer32"); - static const TCHAR szThreadingModel[] = _T("ThreadingModel"); - static const TCHAR szAUTPRX32[] = _T("AUTPRX32.DLL"); - static const TCHAR szApartment[] = _T("Apartment"); - static const TCHAR szBoth[] = _T("both"); - USES_CONVERSION_EX; - TCHAR szModule[_MAX_PATH + _ATL_QUOTES_SPACE]; - - ATLENSURE(lpszProgID && lpszVerIndProgID || !lpszProgID && !lpszVerIndProgID); - - if (!szDesc) - { - szDesc = _T(""); - } - - // If the ModuleFileName's length is equal or greater than the 3rd parameter - // (length of the buffer passed),GetModuleFileName fills the buffer (truncates - // if neccessary), but doesn't null terminate it. It returns the same value as - // the 3rd parameter passed. So if the return value is the same as the 3rd param - // then you have a non null terminated buffer (which may or may not be truncated) - // We pass (szModule + 1) because in case it's an EXE we need to quote the PATH - // The quote is done later in this method before the SetKeyValue is called - DWORD dwLen = GetModuleFileName(m_hInst, szModule + 1, MAX_PATH); - if (dwLen == 0) - { - return AtlHresultFromLastError(); - } - else if( dwLen == MAX_PATH ) - { - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - } - - LPOLESTR lpOleStr; - HRESULT hRes = StringFromCLSID(clsid, &lpOleStr); - if (FAILED(hRes)) - return hRes; - - LPTSTR lpszCLSID = OLE2T_EX(lpOleStr, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(lpszCLSID == NULL) - { - CoTaskMemFree(lpOleStr); - return E_OUTOFMEMORY; - } -#endif - - hRes = lpszProgID ? RegisterProgID(lpszCLSID, lpszProgID, szDesc) : S_OK; - if (hRes == S_OK) - hRes = lpszVerIndProgID ? RegisterProgID(lpszCLSID, lpszVerIndProgID, szDesc) : S_OK; - LONG lRes = ERROR_SUCCESS; - if (hRes == S_OK) - { - CRegKey key; - lRes = key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ | KEY_WRITE); - if (lRes == ERROR_SUCCESS) - { - lRes = key.Create(key, lpszCLSID, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE); - if (lRes == ERROR_SUCCESS) - { - lRes = key.SetStringValue(NULL, szDesc); - if (lRes == ERROR_SUCCESS) - { - lRes = lpszProgID ? key.SetKeyValue(szProgID, lpszProgID) : ERROR_SUCCESS; - if (lRes == ERROR_SUCCESS) - { - lRes = lpszVerIndProgID ? key.SetKeyValue(szVIProgID, lpszVerIndProgID) : ERROR_SUCCESS; - if (lRes == ERROR_SUCCESS) - { - if ((m_hInst == NULL) || (m_hInst == GetModuleHandle(NULL))) // register as EXE - { - // If Registering as an EXE, then we quote the resultant path. - // We don't do it for a DLL, because LoadLibrary fails if the path is - // quoted - szModule[0] = _T('\"'); - szModule[dwLen + 1] = _T('\"'); - szModule[dwLen + 2] = 0; - - lRes = key.SetKeyValue(szLS32, szModule); - } - else - { - lRes = key.SetKeyValue(szIPS32, (dwFlags & AUTPRXFLAG) ? szAUTPRX32 : szModule + 1); - if (lRes == ERROR_SUCCESS) - { - LPCTSTR lpszModel = (dwFlags & THREADFLAGS_BOTH) ? szBoth : - (dwFlags & THREADFLAGS_APARTMENT) ? szApartment : NULL; - if (lpszModel != NULL) - lRes = key.SetKeyValue(szIPS32, lpszModel, szThreadingModel); - } - } - } - } - } - } - } - } - CoTaskMemFree(lpOleStr); - if (lRes != ERROR_SUCCESS) - hRes = AtlHresultFromWin32(lRes); - return hRes; -} - -inline HRESULT WINAPI CComModule::UnregisterClassHelper(const CLSID& clsid, LPCTSTR lpszProgID, - LPCTSTR lpszVerIndProgID) -{ - USES_CONVERSION_EX; - CRegKey key; - LONG lRet; - - key.Attach(HKEY_CLASSES_ROOT); - if (lpszProgID != NULL && lpszProgID[0]!=_T('\0')) - { - lRet = key.RecurseDeleteKey(lpszProgID); - if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND && lRet != ERROR_PATH_NOT_FOUND) - { - ATLTRACE(atlTraceCOM, 0, _T("Failed to Unregister ProgID : %s\n"), lpszProgID); - key.Detach(); - return AtlHresultFromWin32(lRet); - } - } - if (lpszVerIndProgID != NULL && lpszVerIndProgID[0]!=_T('\0')) - { - lRet = key.RecurseDeleteKey(lpszVerIndProgID); - if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND && lRet != ERROR_PATH_NOT_FOUND) - { - ATLTRACE(atlTraceCOM, 0, _T("Failed to Unregister Version Independent ProgID : %s\n"), lpszVerIndProgID); - key.Detach(); - return AtlHresultFromWin32(lRet); - } - } - LPOLESTR lpOleStr; - HRESULT hr = StringFromCLSID(clsid, &lpOleStr); - if (SUCCEEDED(hr)) - { - LPTSTR lpsz = OLE2T_EX(lpOleStr, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(lpsz == NULL) - { - CoTaskMemFree(lpOleStr); - return E_OUTOFMEMORY; - } -#endif - - lRet = key.Open(key, _T("CLSID"), KEY_READ | KEY_WRITE); - if (lRet == ERROR_SUCCESS) - lRet = key.RecurseDeleteKey(lpsz); - if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND && lRet != ERROR_PATH_NOT_FOUND) - { - ATLTRACE(atlTraceCOM, 0, _T("Failed to delete CLSID : %s\n"), lpsz); - hr = AtlHresultFromWin32(lRet); - } - CoTaskMemFree(lpOleStr); - } - else - { - ATLTRACE(atlTraceCOM, 0, _T("Failed to delete CLSID : {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), - clsid.Data1, - clsid.Data2, - clsid.Data3, - clsid.Data4[0], - clsid.Data4[1], - clsid.Data4[2], - clsid.Data4[3], - clsid.Data4[4], - clsid.Data4[5], - clsid.Data4[6], - clsid.Data4[7] - ); - } - key.Detach(); - return hr; -} - -#pragma warning( pop ) // Disable "deprecated symbol" warning - -#endif // !_ATL_NO_COMMODULE - -#ifdef _ATL_DEBUG_INTERFACES - -inline void _QIThunk::Dump() throw() -{ - TCHAR buf[512+1]; - if (m_dwRef != 0) - { -#if _SECURE_ATL && !defined(_ATL_MIN_CRT) - _stprintf_s(buf, _countof(buf), _T("ATL: QIThunk - %-10d\tLEAK :\tObject = 0x%p\tRefcount = %d\tMaxRefCount = %d\t"), - m_nIndex, m_pUnk, m_dwRef, m_dwMaxRef); -#else -#pragma warning(push) -#pragma warning(disable:4995) // wsprintf is deprecated - wsprintf(buf, _T("ATL: QIThunk - %-10d\tLEAK :\tObject = 0x%p\tRefcount = %d\tMaxRefCount = %d\t"), m_nIndex, m_pUnk, m_dwRef, m_dwMaxRef); -#pragma warning(pop) -#endif - buf[_countof(buf)-1] = 0; - OutputDebugString(buf); - AtlDumpIID(m_iid, m_lpszClassName, S_OK); - } - else - { -#if _SECURE_ATL && !defined(_ATL_MIN_CRT) - _stprintf_s(buf, _countof(buf), _T("ATL: QIThunk - %-10d\tNonAddRef LEAK :\tObject = 0x%p\t"), m_nIndex, m_pUnk); -#else -#pragma warning(push) -#pragma warning(disable:4995) // wsprintf is deprecated - wsprintf(buf, _T("ATL: QIThunk - %-10d\tNonAddRef LEAK :\tObject = 0x%p\t"), m_nIndex, m_pUnk); -#pragma warning(pop) -#endif - buf[_countof(buf)-1] = 0; - OutputDebugString(buf); - AtlDumpIID(m_iid, m_lpszClassName, S_OK); - } -} - -#endif // _ATL_DEBUG_INTERFACES - -#if defined(_ATL_DEBUG_INTERFACES) || defined(_ATL_DEBUG_QI) -__forceinline HRESULT WINAPI AtlDumpIID(REFIID iid, LPCTSTR pszClassName, HRESULT hr) throw() -{ - USES_CONVERSION_EX; - CRegKey key; - TCHAR szName[100]; - DWORD dwType; - DWORD dw = sizeof(szName); - - LPOLESTR pszGUID = NULL; - if (FAILED(StringFromCLSID(iid, &pszGUID))) - return hr; - - OutputDebugString(pszClassName); - OutputDebugString(_T(" - ")); - - LPTSTR lpszGUID = OLE2T_EX(pszGUID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(lpszGUID == NULL) - { - CoTaskMemFree(pszGUID); - return hr; - } -#endif - // Attempt to find it in the interfaces section - if (key.Open(HKEY_CLASSES_ROOT, _T("Interface"), KEY_READ) == ERROR_SUCCESS) - { - if (key.Open(key, lpszGUID, KEY_READ) == ERROR_SUCCESS) - { - *szName = 0; - if (RegQueryValueEx(key.m_hKey, (LPTSTR)NULL, NULL, &dwType, (LPBYTE)szName, &dw) == ERROR_SUCCESS) - { - OutputDebugString(szName); - } - } - } - // Attempt to find it in the clsid section - if (key.Open(HKEY_CLASSES_ROOT, _T("CLSID"), KEY_READ) == ERROR_SUCCESS) - { - if (key.Open(key, lpszGUID, KEY_READ) == ERROR_SUCCESS) - { - *szName = 0; - dw = sizeof(szName); - if (RegQueryValueEx(key.m_hKey, (LPTSTR)NULL, NULL, &dwType, (LPBYTE)szName, &dw) == ERROR_SUCCESS) - { - OutputDebugString(_T("(CLSID\?\?\?) ")); - OutputDebugString(szName); - } - } - } - else - OutputDebugString(lpszGUID); - - if (hr != S_OK) - OutputDebugString(_T(" - failed")); - OutputDebugString(_T("\n")); - CoTaskMemFree(pszGUID); - - return hr; -} -#endif // _ATL_DEBUG_INTERFACES || _ATL_DEBUG_QI - - - -// WM_FORWARDMSG - used to forward a message to another window for processing -// WPARAM - DWORD dwUserData - defined by user -// LPARAM - LPMSG pMsg - a pointer to the MSG structure -// return value - 0 if the message was not processed, nonzero if it was -#define WM_FORWARDMSG 0x037F - -}; //namespace ATL - - -#ifndef _ATL_NO_AUTOMATIC_NAMESPACE -using namespace ATL; -#endif //!_ATL_NO_AUTOMATIC_NAMESPACE - -#ifdef _ATL_ATTRIBUTES -#include -#endif - - - -namespace ATL -{ - -// All exports go here -// Pull in if building ATL DLL or not linking to ATL DLL -#ifndef _ATL_DLL - -///////////////////////////////////////////////////////////////////////////// -// statics - -static inline UINT WINAPI AtlGetDirLen(LPCOLESTR lpszPathName) throw() -{ - ATLASSERT(lpszPathName != NULL); - if(lpszPathName == NULL) - return 0; - - // always capture the complete file name including extension (if present) - LPCOLESTR lpszTemp = lpszPathName; - for (LPCOLESTR lpsz = lpszPathName; *lpsz != NULL; ) - { - LPCOLESTR lp = CharNextO(lpsz); - // remember last directory/drive separator - if (*lpsz == OLESTR('\\') || *lpsz == OLESTR('/') || *lpsz == OLESTR(':')) - lpszTemp = lp; - lpsz = lp; - } - - return UINT( lpszTemp-lpszPathName ); -} - -static inline LPTSTR AtlFindExtension(LPCTSTR psz) -{ - if (psz == NULL) - return NULL; - LPCTSTR pszRemember = NULL; - while (*psz != NULL) - { - switch(*psz) - { - case _T('\\'): - pszRemember = NULL; - break; - case _T('.'): - pszRemember = psz; - break; - default: - break; - } - psz = CharNext(psz); - } - return (LPTSTR)((pszRemember == NULL) ? psz : pszRemember); -} - - -///////////////////////////////////////////////////////////////////////////// -// TypeLib registration - -#define _ATL_MAX_PATH_PLUS_INDEX (_MAX_PATH + _ATL_TYPELIB_INDEX_LENGTH) - -ATLINLINE ATLAPI AtlLoadTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex, BSTR* pbstrPath, ITypeLib** ppTypeLib) -{ - ATLASSERT(pbstrPath != NULL && ppTypeLib != NULL); - if (pbstrPath == NULL || ppTypeLib == NULL) - return E_POINTER; - - *pbstrPath = NULL; - *ppTypeLib = NULL; - - USES_CONVERSION_EX; - ATLASSERT(hInstTypeLib != NULL); - TCHAR szModule[_ATL_MAX_PATH_PLUS_INDEX]; - - DWORD dwFLen = GetModuleFileName(hInstTypeLib, szModule, MAX_PATH); - if( dwFLen == 0 ) - return AtlHresultFromLastError(); - else if( dwFLen == MAX_PATH ) - return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); - - // get the extension pointer in case of fail - LPTSTR lpszExt = NULL; - - lpszExt = AtlFindExtension(szModule); - - if (lpszIndex != NULL) - { - LPCTSTR lpcszIndex = OLE2CT_EX(lpszIndex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - if(lpcszIndex == NULL) - { - return E_OUTOFMEMORY; - } - DWORD nIndexLen = lstrlen(lpcszIndex); - - DWORD newLen = dwFLen + nIndexLen; - if ((newLen < dwFLen) || (newLen < nIndexLen) || (newLen >= _ATL_MAX_PATH_PLUS_INDEX)) - return E_FAIL; -#ifdef UNICODE - Checked::wcscpy_s(szModule + dwFLen, _countof(szModule) - dwFLen, lpcszIndex); -#else - Checked::strcpy_s(szModule + dwFLen, _countof(szModule) - dwFLen, lpcszIndex); -#endif - } - LPOLESTR lpszModule = T2OLE_EX(szModule, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(lpszModule == NULL) - return E_OUTOFMEMORY; -#endif - HRESULT hr = LoadTypeLib(lpszModule, ppTypeLib); - if (!SUCCEEDED(hr)) - { - // typelib not in module, try .tlb instead - TCHAR szExt[] = _T(".tlb"); - if ((lpszExt - szModule + sizeof(szExt)/sizeof(TCHAR)) > _MAX_PATH) - return E_FAIL; - -#ifdef UNICODE - Checked::wcscpy_s(lpszExt, _countof(szModule) - (lpszExt - szModule), szExt); -#else - Checked::strcpy_s(lpszExt, _countof(szModule) - (lpszExt - szModule), szExt); -#endif - lpszModule = T2OLE_EX(szModule, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if(lpszModule == NULL) - return E_OUTOFMEMORY; -#endif - hr = LoadTypeLib(lpszModule, ppTypeLib); - } - if (SUCCEEDED(hr)) - { - *pbstrPath = ::SysAllocString(lpszModule); - if (*pbstrPath == NULL) - hr = E_OUTOFMEMORY; - } - return hr; -} - -ATLINLINE ATLAPI AtlUnRegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex) -{ - CComBSTR bstrPath; - CComPtr pTypeLib; - HRESULT hr = AtlLoadTypeLib(hInstTypeLib, lpszIndex, &bstrPath, &pTypeLib); - if (SUCCEEDED(hr)) - { - TLIBATTR* ptla; - hr = pTypeLib->GetLibAttr(&ptla); - if (SUCCEEDED(hr)) - { - hr = UnRegisterTypeLib(ptla->guid, ptla->wMajorVerNum, ptla->wMinorVerNum, ptla->lcid, ptla->syskind); - pTypeLib->ReleaseTLibAttr(ptla); - } - } - return hr; -} - -ATLINLINE ATLAPI AtlRegisterTypeLib(HINSTANCE hInstTypeLib, LPCOLESTR lpszIndex) -{ - CComBSTR bstrPath; - CComPtr pTypeLib; - HRESULT hr = AtlLoadTypeLib(hInstTypeLib, lpszIndex, &bstrPath, &pTypeLib); - if (SUCCEEDED(hr)) - { - CComBSTR bstrHelpFile; - hr = pTypeLib->GetDocumentation(-1, NULL, NULL, NULL, &bstrHelpFile); - if (SUCCEEDED(hr) && (bstrHelpFile.m_str != NULL)) - { - OLECHAR szDir[MAX_PATH]; - Checked::wcsncpy_s(szDir, MAX_PATH, bstrPath.m_str, bstrPath.Length()); - - szDir[MAX_PATH - 1] = 0; - - // If index is specified remove it from the path - if (lpszIndex != NULL) - { - size_t nLenPath = ocslen(szDir); - size_t nLenIndex = ocslen(lpszIndex); - if ((memcmp(szDir + nLenPath - nLenIndex, lpszIndex, nLenIndex) == 0) - && (nLenPath - nLenIndex < MAX_PATH)) - szDir[nLenPath - nLenIndex] = 0; - } - UINT nDirLen = AtlGetDirLen(szDir); - if (nDirLen < MAX_PATH) - szDir[nDirLen] = 0; - - hr = ::RegisterTypeLib(pTypeLib, bstrPath, szDir); - - } - else - { - hr = ::RegisterTypeLib(pTypeLib, bstrPath, NULL); - } - } - return hr; -} - -///////////////////////////////////////////////////////////////////////////// -// Registration - -// AtlComModuleRegisterServer walks the ATL Autogenerated Object Map and registers each object in the map -// If pCLSID is not NULL then only the object referred to by pCLSID is registered (The default case) -// otherwise all the objects are registered -ATLINLINE ATLAPI AtlComModuleRegisterServer(_ATL_COM_MODULE* pComModule, BOOL bRegTypeLib, const CLSID* pCLSID) -{ - ATLASSERT(pComModule != NULL); - if (pComModule == NULL) - return E_INVALIDARG; - ATLASSERT(pComModule->m_hInstTypeLib != NULL); - - HRESULT hr = S_OK; - - for (_ATL_OBJMAP_ENTRY** ppEntry = pComModule->m_ppAutoObjMapFirst; ppEntry < pComModule->m_ppAutoObjMapLast; ppEntry++) - { - if (*ppEntry != NULL) - { - _ATL_OBJMAP_ENTRY* pEntry = *ppEntry; - if (pCLSID != NULL) - { - if (!IsEqualGUID(*pCLSID, *pEntry->pclsid)) - continue; - } - hr = pEntry->pfnUpdateRegistry(TRUE); - if (FAILED(hr)) - break; - hr = AtlRegisterClassCategoriesHelper( *pEntry->pclsid, - pEntry->pfnGetCategoryMap(), TRUE ); - if (FAILED(hr)) - break; - } - } - - if (SUCCEEDED(hr) && bRegTypeLib) - hr = AtlRegisterTypeLib(pComModule->m_hInstTypeLib, 0); - - return hr; -} - -// AtlComUnregisterServer walks the ATL Object Map and unregisters each object in the map -// If pCLSID is not NULL then only the object referred to by pCLSID is unregistered (The default case) -// otherwise all the objects are unregistered. -ATLINLINE ATLAPI AtlComModuleUnregisterServer(_ATL_COM_MODULE* pComModule, BOOL bUnRegTypeLib, const CLSID* pCLSID) -{ - ATLASSERT(pComModule != NULL); - if (pComModule == NULL) - return E_INVALIDARG; - - HRESULT hr = S_OK; - - for (_ATL_OBJMAP_ENTRY** ppEntry = pComModule->m_ppAutoObjMapFirst; ppEntry < pComModule->m_ppAutoObjMapLast; ppEntry++) - { - if (*ppEntry != NULL) - { - _ATL_OBJMAP_ENTRY* pEntry = *ppEntry; - if (pCLSID != NULL) - { - if (!IsEqualGUID(*pCLSID, *pEntry->pclsid)) - continue; - } - hr = AtlRegisterClassCategoriesHelper( *pEntry->pclsid, pEntry->pfnGetCategoryMap(), FALSE ); - if (FAILED(hr)) - break; - hr = pEntry->pfnUpdateRegistry(FALSE); //unregister - if (FAILED(hr)) - break; - } - } - if (SUCCEEDED(hr) && bUnRegTypeLib) - hr = AtlUnRegisterTypeLib(pComModule->m_hInstTypeLib, 0); - - return hr; -} - -ATLINLINE ATLAPI AtlRegisterClassCategoriesHelper( REFCLSID clsid, - const struct _ATL_CATMAP_ENTRY* pCatMap, BOOL bRegister ) -{ - CComPtr< ICatRegister > pCatRegister; - HRESULT hResult; - const struct _ATL_CATMAP_ENTRY* pEntry; - CATID catid; - - if( pCatMap == NULL ) - { - return( S_OK ); - } - - if (InlineIsEqualGUID(clsid, GUID_NULL)) - { - ATLASSERT(0 && _T("Use OBJECT_ENTRY_NON_CREATEABLE_EX macro if you want to register class categories for non creatable objects.")); - return S_OK; - } - - hResult = CoCreateInstance( CLSID_StdComponentCategoriesMgr, NULL, - CLSCTX_INPROC_SERVER, __uuidof(ICatRegister), (void**)&pCatRegister ); - if( FAILED( hResult ) ) - { - // Since not all systems have the category manager installed, we'll allow - // the registration to succeed even though we didn't register our - // categories. If you really want to register categories on a system - // without the category manager, you can either manually add the - // appropriate entries to your registry script (.rgs), or you can - // redistribute comcat.dll. - return( S_OK ); - } - - hResult = S_OK; - pEntry = pCatMap; - while( pEntry->iType != _ATL_CATMAP_ENTRY_END ) - { - catid = *pEntry->pcatid; - if( bRegister ) - { - if( pEntry->iType == _ATL_CATMAP_ENTRY_IMPLEMENTED ) - { - hResult = pCatRegister->RegisterClassImplCategories( clsid, 1, - &catid ); - } - else - { - ATLASSERT( pEntry->iType == _ATL_CATMAP_ENTRY_REQUIRED ); - hResult = pCatRegister->RegisterClassReqCategories( clsid, 1, - &catid ); - } - if( FAILED( hResult ) ) - { - return( hResult ); - } - } - else - { - if( pEntry->iType == _ATL_CATMAP_ENTRY_IMPLEMENTED ) - { - pCatRegister->UnRegisterClassImplCategories( clsid, 1, &catid ); - } - else - { - ATLASSERT( pEntry->iType == _ATL_CATMAP_ENTRY_REQUIRED ); - pCatRegister->UnRegisterClassReqCategories( clsid, 1, &catid ); - } - } - pEntry++; - } - - // When unregistering remove "Implemented Categories" and "Required Categories" subkeys if they are empty. - if (!bRegister) - { - OLECHAR szGUID[64]; - ::StringFromGUID2(clsid, szGUID, 64); - USES_CONVERSION_EX; - TCHAR* pszGUID = OLE2T_EX(szGUID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - if (pszGUID != NULL) - { - TCHAR szKey[128]; -#ifdef UNICODE - Checked::wcscpy_s(szKey, _countof(szKey), _T("CLSID\\")); - Checked::wcscat_s(szKey, _countof(szKey), pszGUID); - Checked::wcscat_s(szKey, _countof(szKey), _T("\\Required Categories")); -#else - Checked::strcpy_s(szKey, _countof(szKey), _T("CLSID\\")); - Checked::strcat_s(szKey, _countof(szKey), pszGUID); - Checked::strcat_s(szKey, _countof(szKey), _T("\\Required Categories")); -#endif - - CRegKey root(HKEY_CLASSES_ROOT); - CRegKey key; - DWORD cbSubKeys = 0; - - LRESULT lRes = key.Open(root, szKey, KEY_READ); - if (lRes == ERROR_SUCCESS) - { - lRes = RegQueryInfoKey(key, NULL, NULL, NULL, &cbSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - key.Close(); - if (lRes == ERROR_SUCCESS && cbSubKeys == 0) - { - root.DeleteSubKey(szKey); - } - } - -#ifdef UNICODE - Checked::wcscpy_s(szKey, _countof(szKey), _T("CLSID\\")); - Checked::wcscat_s(szKey, _countof(szKey), pszGUID); - Checked::wcscat_s(szKey, _countof(szKey), _T("\\Implemented Categories")); -#else - Checked::strcpy_s(szKey, _countof(szKey), _T("CLSID\\")); - Checked::strcat_s(szKey, _countof(szKey), pszGUID); - Checked::strcat_s(szKey, _countof(szKey), _T("\\Implemented Categories")); -#endif - lRes = key.Open(root, szKey, KEY_READ); - if (lRes == ERROR_SUCCESS) - { - lRes = RegQueryInfoKey(key, NULL, NULL, NULL, &cbSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - key.Close(); - if (lRes == ERROR_SUCCESS && cbSubKeys == 0) - { - root.DeleteSubKey(szKey); - } - } - } - } - return( S_OK ); -} - -#endif // _ATL_DLL - -ATLINLINE ATLAPIINL -AtlWinModuleTerm(_ATL_WIN_MODULE* pWinModule, HINSTANCE hInst) -{ - if (pWinModule == NULL) - return E_INVALIDARG; - if (pWinModule->cbSize == 0) - return S_OK; - if (pWinModule->cbSize != sizeof(_ATL_WIN_MODULE)) - return E_INVALIDARG; - - for (int i = 0; i < pWinModule->m_rgWindowClassAtoms.GetSize(); i++) - UnregisterClass((LPCTSTR)pWinModule->m_rgWindowClassAtoms[i], hInst); - pWinModule->m_rgWindowClassAtoms.RemoveAll(); - pWinModule->m_csWindowCreate.Term(); - pWinModule->cbSize = 0; - return S_OK; -} - - - -///////////////////////////////////////////////////////////////////////////// -// General DLL Version Helpers - -#pragma warning(push) -#pragma warning(disable : 4191) // 'type cast' : unsafe conversion from 'FARPROC' to 'DLLGETVERSIONPROC' - -inline HRESULT AtlGetDllVersion(HINSTANCE hInstDLL, DLLVERSIONINFO* pDllVersionInfo) -{ - ATLENSURE(pDllVersionInfo != NULL); - - // We must get this function explicitly because some DLLs don't implement it. - DLLGETVERSIONPROC pfnDllGetVersion = (DLLGETVERSIONPROC)::GetProcAddress(hInstDLL, "DllGetVersion"); - - if(pfnDllGetVersion == NULL) - { - return E_NOTIMPL; - } - - return (*pfnDllGetVersion)(pDllVersionInfo); -} - -#pragma warning(pop) - -inline HRESULT AtlGetDllVersion(LPCTSTR lpstrDllName, DLLVERSIONINFO* pDllVersionInfo) -{ - HINSTANCE hInstDLL = ::LoadLibrary(lpstrDllName); - if(hInstDLL == NULL) - { - return AtlHresultFromLastError(); - } - HRESULT hRet = AtlGetDllVersion(hInstDLL, pDllVersionInfo); - ::FreeLibrary(hInstDLL); - return hRet; -} - -// Common Control Versions: -// Win95/WinNT 4.0 maj=4 min=00 -// IE 3.x maj=4 min=70 -// IE 4.0 maj=4 min=71 -// IE 5.0 maj=5 min=80 -// Win2000 maj=5 min=81 -inline HRESULT AtlGetCommCtrlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) -{ - ATLENSURE(( pdwMajor != NULL ) && ( pdwMinor != NULL )); - - DLLVERSIONINFO dvi; - memset(&dvi, 0, sizeof(dvi)); - dvi.cbSize = sizeof(dvi); - - HRESULT hRet = AtlGetDllVersion(_T("comctl32.dll"), &dvi); - - if(SUCCEEDED(hRet)) - { - *pdwMajor = dvi.dwMajorVersion; - *pdwMinor = dvi.dwMinorVersion; - } - else if(hRet == E_NOTIMPL) - { - // If DllGetVersion is not there, then the DLL is a version - // previous to the one shipped with IE 3.x - *pdwMajor = 4; - *pdwMinor = 0; - hRet = S_OK; - } - - return hRet; -} - -// Shell Versions: -// Win95/WinNT 4.0 maj=4 min=00 -// IE 3.x, IE 4.0 without Web Integrated Desktop maj=4 min=00 -// IE 4.0 with Web Integrated Desktop maj=4 min=71 -// IE 4.01 with Web Integrated Desktop maj=4 min=72 -// Win2000 maj=5 min=00 -inline HRESULT AtlGetShellVersion(LPDWORD pdwMajor, LPDWORD pdwMinor) -{ - ATLENSURE(( pdwMajor != NULL) && ( pdwMinor != NULL )); - - DLLVERSIONINFO dvi; - memset(&dvi, 0, sizeof(dvi)); - dvi.cbSize = sizeof(dvi); - HRESULT hRet = AtlGetDllVersion(_T("shell32.dll"), &dvi); - - if(SUCCEEDED(hRet)) - { - *pdwMajor = dvi.dwMajorVersion; - *pdwMinor = dvi.dwMinorVersion; - } - else if(hRet == E_NOTIMPL) - { - // If DllGetVersion is not there, then the DLL is a version - // previous to the one shipped with IE 4.x - *pdwMajor = 4; - *pdwMinor = 0; - hRet = S_OK; - } - - return hRet; -} - -inline ATL_DEPRECATED("AtlModuleRegisterClassObjects has been replaced by AtlComModuleRegisterClassObjects") -HRESULT AtlModuleRegisterClassObjects(_ATL_MODULE* /*pM*/, DWORD dwClsContext, DWORD dwFlags) -{ - return AtlComModuleRegisterClassObjects(&_AtlComModule, dwClsContext, dwFlags); -} - -inline ATL_DEPRECATED("AtlModuleRevokeClassObjects has been replaced by AtlComModuleRevokeClassObjects") -HRESULT AtlModuleRevokeClassObjects(_ATL_MODULE* /*pM*/) -{ - return AtlComModuleRevokeClassObjects(&_AtlComModule); -} - -inline ATL_DEPRECATED("AtlModuleGetClassObject has been replaced by AtlComModuleGetClassObject") -HRESULT AtlModuleGetClassObject(_ATL_MODULE* /*pM*/, REFCLSID rclsid, REFIID riid, LPVOID* ppv) -{ -#ifndef _ATL_OLEDB_CONFORMANCE_TESTS - ATLASSERT(ppv != NULL); -#endif - - return AtlComModuleGetClassObject(&_AtlComModule, rclsid, riid, ppv); -} - -inline ATL_DEPRECATED("AtlModuleRegisterServer has been replaced by AtlComModuleRegisterServer") -HRESULT AtlModuleRegisterServer(_ATL_MODULE* /*pM*/, BOOL bRegTypeLib, const CLSID* pCLSID = NULL) -{ - return AtlComModuleRegisterServer(&_AtlComModule, bRegTypeLib, pCLSID); -} - -inline ATL_DEPRECATED("AtlModuleUnregisterServer has been replaced by AtlComModuleUnregisterServer") -HRESULT AtlModuleUnregisterServer(_ATL_MODULE* /*pM*/, const CLSID* pCLSID = NULL) -{ - return AtlComModuleUnregisterServer(&_AtlComModule, FALSE, pCLSID); -} - -inline ATL_DEPRECATED("AtlModuleUnregisterServerEx has been replaced by AtlComModuleUnregisterServer") -HRESULT AtlModuleUnregisterServerEx(_ATL_MODULE* /*pM*/, BOOL bUnRegTypeLib, const CLSID* pCLSID = NULL) -{ - return AtlComModuleUnregisterServer(&_AtlComModule, bUnRegTypeLib, pCLSID); -} - -inline ATL_DEPRECATED("AtlModuleUpdateRegistryFromResourceD has been replaced by AtlUpdateRegistryFromResourceD") -HRESULT AtlModuleUpdateRegistryFromResourceD(_ATL_MODULE* /*pM*/, LPCOLESTR lpszRes, - BOOL bRegister, struct _ATL_REGMAP_ENTRY* pMapEntries, IRegistrar* pReg = NULL) -{ - return AtlUpdateRegistryFromResourceD(_AtlBaseModule.GetModuleInstance(), lpszRes, bRegister, pMapEntries, pReg); -} - -inline ATL_DEPRECATED("AtlModuleRegisterTypeLib has been replaced by AtlRegisterTypeLib") -HRESULT AtlModuleRegisterTypeLib(_ATL_MODULE* /*pM*/, LPCOLESTR lpszIndex) -{ - return AtlRegisterTypeLib(_AtlComModule.m_hInstTypeLib, lpszIndex); -} - -inline ATL_DEPRECATED("AtlModuleUnRegisterTypeLib has been replaced by AtlUnRegisterTypeLib") -HRESULT AtlModuleUnRegisterTypeLib(_ATL_MODULE* /*pM*/, LPCOLESTR lpszIndex) -{ - return AtlUnRegisterTypeLib(_AtlComModule.m_hInstTypeLib, lpszIndex); -} - -inline ATL_DEPRECATED("AtlModuleLoadTypeLib has been replaced by AtlLoadTypeLib") -HRESULT AtlModuleLoadTypeLib(_ATL_MODULE* /*pM*/, LPCOLESTR lpszIndex, BSTR* pbstrPath, ITypeLib** ppTypeLib) -{ - return AtlLoadTypeLib(_AtlComModule.m_hInstTypeLib, lpszIndex, pbstrPath, ppTypeLib); -} - -inline ATL_DEPRECATED("AtlModuleInit is no longer required") -HRESULT AtlModuleInit(_ATL_MODULE* /*pM*/, _ATL_OBJMAP_ENTRY* /*p*/, HINSTANCE /*h*/) -{ - return S_OK; -} - -inline ATL_DEPRECATED("AtlModuleTerm is no longer required") -HRESULT AtlModuleTerm(_ATL_MODULE* /*pM*/) -{ - return S_OK; -} - -inline ATL_DEPRECATED("AtlModuleAddCreateWndData has been replaced by AtlWinModuleAddCreateWndData") -void AtlModuleAddCreateWndData(_ATL_MODULE* /*pM*/, _AtlCreateWndData* pData, void* pObject) -{ - AtlWinModuleAddCreateWndData(&_AtlWinModule, pData, pObject); -} - -inline ATL_DEPRECATED("AtlModuleExtractCreateWndData has been replaced by AtlWinModuleExtractCreateWndData") -void* AtlModuleExtractCreateWndData(_ATL_MODULE* /*pM*/) -{ - return AtlWinModuleExtractCreateWndData(&_AtlWinModule); -} - -#ifndef _ATL_NO_COMMODULE - -inline CRITICAL_SECTION& CComModule::get_m_csWindowCreate() throw() -{ - return _AtlWinModule.m_csWindowCreate.m_sec; -} - -inline CRITICAL_SECTION& CComModule::get_m_csObjMap() throw() -{ - return _AtlComModule.m_csObjMap.m_sec; -} - -inline CRITICAL_SECTION& CComModule::get_m_csStaticDataInit() throw() -{ - return m_csStaticDataInitAndTypeInfo.m_sec; -} - -inline _AtlCreateWndData*& CComModule::get_m_pCreateWndList() throw() -{ - return _AtlWinModule.m_pCreateWndList; -} -inline void CComModule::put_m_pCreateWndList(_AtlCreateWndData* p) throw() -{ - _AtlWinModule.m_pCreateWndList = p; -} -#ifdef _ATL_DEBUG_INTERFACES -inline UINT& CComModule::get_m_nIndexQI() throw() -{ - return _AtlDebugInterfacesModule.m_nIndexQI; -} -inline void CComModule::put_m_nIndexQI(UINT nIndex) throw() -{ - _AtlDebugInterfacesModule.m_nIndexQI = nIndex; -} -inline UINT& CComModule::get_m_nIndexBreakAt() throw() -{ - return _AtlDebugInterfacesModule.m_nIndexBreakAt; -} -inline void CComModule::put_m_nIndexBreakAt(UINT nIndex) throw() -{ - _AtlDebugInterfacesModule.m_nIndexBreakAt = nIndex; -} -inline CSimpleArray<_QIThunk*>* CComModule::get_m_paThunks() throw() -{ - return &_AtlDebugInterfacesModule.m_aThunks; -} -inline HRESULT CComModule::AddThunk(IUnknown** pp, LPCTSTR lpsz, REFIID iid) throw() -{ - return _AtlDebugInterfacesModule.AddThunk(pp, lpsz, iid); -} -inline HRESULT CComModule::AddNonAddRefThunk(IUnknown* p, LPCTSTR lpsz, IUnknown** ppThunkRet) throw() -{ - return _AtlDebugInterfacesModule.AddNonAddRefThunk(p, lpsz, ppThunkRet); -} - -inline void CComModule::DeleteNonAddRefThunk(IUnknown* pUnk) throw() -{ - _AtlDebugInterfacesModule.DeleteNonAddRefThunk(pUnk); -} - -inline void CComModule::DeleteThunk(_QIThunk* p) throw() -{ - _AtlDebugInterfacesModule.DeleteThunk(p); -} - -inline bool CComModule::DumpLeakedThunks() throw() -{ - return _AtlDebugInterfacesModule.DumpLeakedThunks(); -} -#endif // _ATL_DEBUG_INTERFACES - -inline HRESULT CComModule::Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE /*h*/, const GUID* plibid) throw() -{ - if (plibid != NULL) - m_libid = *plibid; - - _ATL_OBJMAP_ENTRY* pEntry; - if (p != (_ATL_OBJMAP_ENTRY*)-1) - { - m_pObjMap = p; - if (m_pObjMap != NULL) - { - pEntry = m_pObjMap; - while (pEntry->pclsid != NULL) - { - pEntry->pfnObjectMain(true); //initialize class resources - pEntry++; - } - } - } - for (_ATL_OBJMAP_ENTRY** ppEntry = _AtlComModule.m_ppAutoObjMapFirst; ppEntry < _AtlComModule.m_ppAutoObjMapLast; ppEntry++) - { - if (*ppEntry != NULL) - (*ppEntry)->pfnObjectMain(true); //initialize class resources - } - return S_OK; -} - -inline void CComModule::Term() throw() -{ - _ATL_OBJMAP_ENTRY* pEntry; - if (m_pObjMap != NULL) - { - pEntry = m_pObjMap; - while (pEntry->pclsid != NULL) - { - if (pEntry->pCF != NULL) - pEntry->pCF->Release(); - pEntry->pCF = NULL; - pEntry->pfnObjectMain(false); //cleanup class resources - pEntry++; - } - } - - for (_ATL_OBJMAP_ENTRY** ppEntry = _AtlComModule.m_ppAutoObjMapFirst; ppEntry < _AtlComModule.m_ppAutoObjMapLast; ppEntry++) - { - if (*ppEntry != NULL) - (*ppEntry)->pfnObjectMain(false); //cleanup class resources - } -#ifdef _DEBUG - // Prevent false memory leak reporting. ~CAtlWinModule may be too late. - _AtlWinModule.Term(); -#endif // _DEBUG - - CAtlModuleT::Term(); -} - -inline HRESULT CComModule::GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) throw() -{ - if (ppv == NULL) - return E_POINTER; - HRESULT hr = S_OK; - _ATL_OBJMAP_ENTRY* pEntry; - if (m_pObjMap != NULL) - { - pEntry = m_pObjMap; - while (pEntry->pclsid != NULL) - { - if ((pEntry->pfnGetClassObject != NULL) && InlineIsEqualGUID(rclsid, *pEntry->pclsid)) - { - if (pEntry->pCF == NULL) - { - CComCritSecLock lock(_AtlComModule.m_csObjMap, false); - hr = lock.Lock(); - if (FAILED(hr)) - { - ATLTRACE(atlTraceCOM, 0, _T("ERROR : Unable to lock critical section in CComModule::GetClassObject\n")); - ATLASSERT(0); - break; - } - if (pEntry->pCF == NULL) - hr = pEntry->pfnGetClassObject(pEntry->pfnCreateInstance, __uuidof(IUnknown), (LPVOID*)&pEntry->pCF); - } - if (pEntry->pCF != NULL) - hr = pEntry->pCF->QueryInterface(riid, ppv); - break; - } - pEntry++; - } - } - if (*ppv == NULL && hr == S_OK) - hr = AtlComModuleGetClassObject(&_AtlComModule, rclsid, riid, ppv); - return hr; -} - -// Register/Revoke All Class Factories with the OS (EXE only) -inline HRESULT CComModule::RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags) throw() -{ - HRESULT hr = S_OK; - _ATL_OBJMAP_ENTRY* pEntry; - if (m_pObjMap != NULL) - { - pEntry = m_pObjMap; - while (pEntry->pclsid != NULL && hr == S_OK) - { - hr = pEntry->RegisterClassObject(dwClsContext, dwFlags); - pEntry++; - } - } - if (hr == S_OK) - hr = AtlComModuleRegisterClassObjects(&_AtlComModule, dwClsContext, dwFlags); - return hr; -} -inline HRESULT CComModule::RevokeClassObjects() throw() -{ - HRESULT hr = S_OK; - _ATL_OBJMAP_ENTRY* pEntry; - if (m_pObjMap != NULL) - { - pEntry = m_pObjMap; - while (pEntry->pclsid != NULL && hr == S_OK) - { - hr = pEntry->RevokeClassObject(); - pEntry++; - } - } - if (hr == S_OK) - hr = AtlComModuleRevokeClassObjects(&_AtlComModule); - return hr; -} - -// Registry support (helpers) -inline HRESULT CComModule::RegisterTypeLib() throw() -{ - return _AtlComModule.RegisterTypeLib(); -} -inline HRESULT CComModule::RegisterTypeLib(LPCTSTR lpszIndex) throw() -{ - return _AtlComModule.RegisterTypeLib(lpszIndex); -} -inline HRESULT CComModule::UnRegisterTypeLib() throw() -{ - return _AtlComModule.UnRegisterTypeLib(); -} -inline HRESULT CComModule::UnRegisterTypeLib(LPCTSTR lpszIndex) throw() -{ - return _AtlComModule.UnRegisterTypeLib(lpszIndex); -} - -inline HRESULT CComModule::RegisterServer(BOOL bRegTypeLib /*= FALSE*/, const CLSID* pCLSID /*= NULL*/) throw() -{ - HRESULT hr = S_OK; - _ATL_OBJMAP_ENTRY* pEntry = m_pObjMap; - if (pEntry != NULL) - { - for (;pEntry->pclsid != NULL; pEntry++) - { - if (pCLSID != NULL) - { - if (!IsEqualGUID(*pCLSID, *pEntry->pclsid)) - continue; - } - hr = pEntry->pfnUpdateRegistry(TRUE); - if (FAILED(hr)) - break; - hr = AtlRegisterClassCategoriesHelper( *pEntry->pclsid, - pEntry->pfnGetCategoryMap(), TRUE ); - if (FAILED(hr)) - break; - } - } - if (SUCCEEDED(hr)) - hr = CAtlModuleT::RegisterServer(bRegTypeLib, pCLSID); - return hr; -} - -inline HRESULT CComModule::UnregisterServer(BOOL bUnRegTypeLib, const CLSID* pCLSID /*= NULL*/) throw() -{ - HRESULT hr = S_OK; - _ATL_OBJMAP_ENTRY* pEntry = m_pObjMap; - if (pEntry != NULL) - { - for (;pEntry->pclsid != NULL; pEntry++) - { - if (pCLSID != NULL) - { - if (!IsEqualGUID(*pCLSID, *pEntry->pclsid)) - continue; - } - hr = AtlRegisterClassCategoriesHelper( *pEntry->pclsid, - pEntry->pfnGetCategoryMap(), FALSE ); - if (FAILED(hr)) - break; - hr = pEntry->pfnUpdateRegistry(FALSE); //unregister - if (FAILED(hr)) - break; - } - } - if (SUCCEEDED(hr)) - hr = CAtlModuleT::UnregisterServer(bUnRegTypeLib, pCLSID); - return hr; -} - -inline HRESULT CComModule::UnregisterServer(const CLSID* pCLSID /*= NULL*/) throw() -{ - return UnregisterServer(FALSE, pCLSID); -} - -#endif // !_ATL_NO_COMMODULE - -} // namespace ATL - - -#pragma warning( pop ) - -#if !defined(_ATL_DLL) && !defined(_DEBUG) - -#include - -#endif // !_ATL_DLL && !_DEBUG - -#pragma pack(pop) -#ifdef _ATL_ALL_WARNINGS -#pragma warning( pop ) -#endif - -// -// [pfx_parse] - workaround for old PREfix/PREfast parser -// -#if (defined(_PREFIX_) || defined(_PREFAST_)) && (_MSC_VER < 1400) -#pragma warning (pop) -#endif // old PREfast parser - -///////////////////////////////////////////////////////////////////////////// - -#endif // __ATLBASE_H__ - diff --git a/cpp/jacob/include/atlbase.inl b/cpp/jacob/include/atlbase.inl deleted file mode 100644 index 0d2534c..0000000 --- a/cpp/jacob/include/atlbase.inl +++ /dev/null @@ -1,428 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLBASE_INL__ -#define __ATLBASE_INL__ - -#pragma once - -#ifndef __ATLBASE_H__ - #error atlbase.inl requires atlbase.h to be included first -#endif -#pragma warning(push) -#pragma warning(disable:4571) //catch(...) blocks compiled with /EHs do NOT catch or re-throw Structured Exceptions -namespace ATL -{ - -///////////////////////////////////////////////////////////////////////////// -// Connection Point Helpers - -ATLINLINE ATLAPI AtlAdvise(IUnknown* pUnkCP, IUnknown* pUnk, const IID& iid, LPDWORD pdw) -{ - if(pUnkCP == NULL) - return E_INVALIDARG; - - CComPtr pCPC; - CComPtr pCP; - HRESULT hRes = pUnkCP->QueryInterface(__uuidof(IConnectionPointContainer), (void**)&pCPC); - if (SUCCEEDED(hRes)) - hRes = pCPC->FindConnectionPoint(iid, &pCP); - if (SUCCEEDED(hRes)) - hRes = pCP->Advise(pUnk, pdw); - return hRes; -} - -ATLINLINE ATLAPI AtlUnadvise(IUnknown* pUnkCP, const IID& iid, DWORD dw) -{ - if(pUnkCP == NULL) - return E_INVALIDARG; - - CComPtr pCPC; - CComPtr pCP; - HRESULT hRes = pUnkCP->QueryInterface(__uuidof(IConnectionPointContainer), (void**)&pCPC); - if (SUCCEEDED(hRes)) - hRes = pCPC->FindConnectionPoint(iid, &pCP); - if (SUCCEEDED(hRes)) - hRes = pCP->Unadvise(dw); - return hRes; -} - -///////////////////////////////////////////////////////////////////////////// -// Inproc Marshaling helpers - -//This API should be called from the same thread that called -//AtlMarshalPtrInProc -ATLINLINE ATLAPI AtlFreeMarshalStream(IStream* pStream) -{ - HRESULT hRes=S_OK; - if (pStream != NULL) - { - LARGE_INTEGER l; - l.QuadPart = 0; - pStream->Seek(l, STREAM_SEEK_SET, NULL); - hRes=CoReleaseMarshalData(pStream); - pStream->Release(); - } - return hRes; -} - -ATLINLINE ATLAPI AtlMarshalPtrInProc(IUnknown* pUnk, const IID& iid, IStream** ppStream) -{ - ATLASSERT(ppStream != NULL); - if (ppStream == NULL) - return E_POINTER; - - HRESULT hRes = CreateStreamOnHGlobal(NULL, TRUE, ppStream); - if (SUCCEEDED(hRes)) - { - hRes = CoMarshalInterface(*ppStream, iid, - pUnk, MSHCTX_INPROC, NULL, MSHLFLAGS_TABLESTRONG); - if (FAILED(hRes)) - { - (*ppStream)->Release(); - *ppStream = NULL; - } - } - return hRes; -} - -ATLINLINE ATLAPI AtlUnmarshalPtr(IStream* pStream, const IID& iid, IUnknown** ppUnk) -{ - ATLASSERT(ppUnk != NULL); - if (ppUnk == NULL) - return E_POINTER; - - *ppUnk = NULL; - HRESULT hRes = E_INVALIDARG; - if (pStream != NULL) - { - LARGE_INTEGER l; - l.QuadPart = 0; - pStream->Seek(l, STREAM_SEEK_SET, NULL); - hRes = CoUnmarshalInterface(pStream, iid, (void**)ppUnk); - } - return hRes; -} - -///////////////////////////////////////////////////////////////////////////// -// Module - -ATLINLINE ATLAPI AtlComModuleGetClassObject(_ATL_COM_MODULE* pComModule, REFCLSID rclsid, REFIID riid, LPVOID* ppv) -{ - ATLASSERT(pComModule != NULL); - if (pComModule == NULL) - return E_INVALIDARG; - if (pComModule->cbSize == 0) // Module hasn't been initialized - return E_UNEXPECTED; - - if (ppv == NULL) - return E_POINTER; - *ppv = NULL; - - HRESULT hr = S_OK; - - for (_ATL_OBJMAP_ENTRY** ppEntry = pComModule->m_ppAutoObjMapFirst; ppEntry < pComModule->m_ppAutoObjMapLast; ppEntry++) - { - if (*ppEntry != NULL) - { - _ATL_OBJMAP_ENTRY* pEntry = *ppEntry; - if ((pEntry->pfnGetClassObject != NULL) && InlineIsEqualGUID(rclsid, *pEntry->pclsid)) - { - if (pEntry->pCF == NULL) - { - CComCritSecLock lock(pComModule->m_csObjMap, false); - hr = lock.Lock(); - if (FAILED(hr)) - { - ATLTRACE(atlTraceCOM, 0, _T("ERROR : Unable to lock critical section in AtlComModuleGetClassObject\n")); - ATLASSERT(0); - break; - } - if (pEntry->pCF == NULL) - hr = pEntry->pfnGetClassObject(pEntry->pfnCreateInstance, __uuidof(IUnknown), (LPVOID*)&pEntry->pCF); - } - if (pEntry->pCF != NULL) - hr = pEntry->pCF->QueryInterface(riid, ppv); - break; - } - } - } - - if (*ppv == NULL && hr == S_OK) - hr = CLASS_E_CLASSNOTAVAILABLE; - return hr; -} - -ATLINLINE ATLAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE* pComModule, DWORD dwClsContext, DWORD dwFlags) -{ - ATLASSERT(pComModule != NULL); - if (pComModule == NULL) - return E_INVALIDARG; - - HRESULT hr = S_FALSE; - for (_ATL_OBJMAP_ENTRY** ppEntry = pComModule->m_ppAutoObjMapFirst; ppEntry < pComModule->m_ppAutoObjMapLast && SUCCEEDED(hr); ppEntry++) - { - if (*ppEntry != NULL) - hr = (*ppEntry)->RegisterClassObject(dwClsContext, dwFlags); - } - return hr; -} - -ATLINLINE ATLAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE* pComModule) -{ - ATLASSERT(pComModule != NULL); - if (pComModule == NULL) - return E_INVALIDARG; - - HRESULT hr = S_OK; - for (_ATL_OBJMAP_ENTRY** ppEntry = pComModule->m_ppAutoObjMapFirst; ppEntry < pComModule->m_ppAutoObjMapLast && hr == S_OK; ppEntry++) - { - if (*ppEntry != NULL) - hr = (*ppEntry)->RevokeClassObject(); - } - return hr; -} - -ATLINLINE ATLAPI_(BOOL) AtlWaitWithMessageLoop(HANDLE hEvent) -{ - DWORD dwRet; - MSG msg; - - while(1) - { - dwRet = MsgWaitForMultipleObjects(1, &hEvent, FALSE, INFINITE, QS_ALLINPUT); - - if (dwRet == WAIT_OBJECT_0) - return TRUE; // The event was signaled - - if (dwRet != WAIT_OBJECT_0 + 1) - break; // Something else happened - - // There is one or more window message available. Dispatch them - while(PeekMessage(&msg,0,0,0,PM_NOREMOVE)) - { - // check for unicode window so we call the appropriate functions - BOOL bUnicode = ::IsWindowUnicode(msg.hwnd); - BOOL bRet; - - if (bUnicode) - bRet = ::GetMessageW(&msg, NULL, 0, 0); - else - bRet = ::GetMessageA(&msg, NULL, 0, 0); - - if (bRet > 0) - { - ::TranslateMessage(&msg); - - if (bUnicode) - ::DispatchMessageW(&msg); - else - ::DispatchMessageA(&msg); - } - - if (WaitForSingleObject(hEvent, 0) == WAIT_OBJECT_0) - return TRUE; // Event is now signaled. - } - } - return FALSE; -} - -///////////////////////////////////////////////////////////////////////////// -// QI support - -ATLINLINE ATLAPI AtlInternalQueryInterface(void* pThis, - const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject) -{ - ATLASSERT(pThis != NULL); - ATLASSERT(pEntries!= NULL); - - if(pThis == NULL || pEntries == NULL) - return E_INVALIDARG ; - - // First entry in the com map should be a simple map entry - ATLASSERT(pEntries->pFunc == _ATL_SIMPLEMAPENTRY); - if (ppvObject == NULL) - return E_POINTER; - *ppvObject = NULL; - if (InlineIsEqualUnknown(iid)) // use first interface - { - IUnknown* pUnk = (IUnknown*)((INT_PTR)pThis+pEntries->dw); - pUnk->AddRef(); - *ppvObject = pUnk; - return S_OK; - } - while (pEntries->pFunc != NULL) - { - BOOL bBlind = (pEntries->piid == NULL); - if (bBlind || InlineIsEqualGUID(*(pEntries->piid), iid)) - { - if (pEntries->pFunc == _ATL_SIMPLEMAPENTRY) //offset - { - ATLASSERT(!bBlind); - IUnknown* pUnk = (IUnknown*)((INT_PTR)pThis+pEntries->dw); - pUnk->AddRef(); - *ppvObject = pUnk; - return S_OK; - } - else //actual function call - { - HRESULT hRes = pEntries->pFunc(pThis, - iid, ppvObject, pEntries->dw); - if (hRes == S_OK || (!bBlind && FAILED(hRes))) - return hRes; - } - } - pEntries++; - } - return E_NOINTERFACE; -} - -ATLINLINE ATLAPI_(DWORD) AtlGetVersion(void* /* pReserved */) -{ - return _ATL_VER; -} - -///////////////////////////////////////////////////////////////////////////// -// Windowing - -ATLINLINE ATLAPI_(void) AtlWinModuleAddCreateWndData(_ATL_WIN_MODULE* pWinModule, _AtlCreateWndData* pData, void* pObject) -{ - if (pWinModule == NULL) - _AtlRaiseException((DWORD)EXCEPTION_ACCESS_VIOLATION); - - ATLASSERT(pData != NULL && pObject != NULL); - if(pData == NULL || pObject == NULL) - _AtlRaiseException((DWORD)EXCEPTION_ACCESS_VIOLATION); - - pData->m_pThis = pObject; - pData->m_dwThreadID = ::GetCurrentThreadId(); - CComCritSecLock lock(pWinModule->m_csWindowCreate, false); - if (FAILED(lock.Lock())) - { - ATLTRACE(atlTraceWindowing, 0, _T("ERROR : Unable to lock critical section in AtlWinModuleAddCreateWndData\n")); - ATLASSERT(0); - return; - } - pData->m_pNext = pWinModule->m_pCreateWndList; - pWinModule->m_pCreateWndList = pData; -} - -ATLINLINE ATLAPI_(void*) AtlWinModuleExtractCreateWndData(_ATL_WIN_MODULE* pWinModule) -{ - if (pWinModule == NULL) - return NULL; - - void* pv = NULL; - CComCritSecLock lock(pWinModule->m_csWindowCreate, false); - if (FAILED(lock.Lock())) - { - ATLTRACE(atlTraceWindowing, 0, _T("ERROR : Unable to lock critical section in AtlWinModuleExtractCreateWndData\n")); - ATLASSERT(0); - return pv; - } - _AtlCreateWndData* pEntry = pWinModule->m_pCreateWndList; - if(pEntry != NULL) - { - DWORD dwThreadID = ::GetCurrentThreadId(); - _AtlCreateWndData* pPrev = NULL; - while(pEntry != NULL) - { - if(pEntry->m_dwThreadID == dwThreadID) - { - if(pPrev == NULL) - pWinModule->m_pCreateWndList = pEntry->m_pNext; - else - pPrev->m_pNext = pEntry->m_pNext; - pv = pEntry->m_pThis; - break; - } - pPrev = pEntry; - pEntry = pEntry->m_pNext; - } - } - return pv; -} - - -ATLINLINE ATLAPI AtlWinModuleInit(_ATL_WIN_MODULE* pWinModule) -{ - if (pWinModule == NULL) - return E_INVALIDARG; - - // check only in the DLL - if (pWinModule->cbSize != sizeof(_ATL_WIN_MODULE)) - return E_INVALIDARG; - - pWinModule->m_pCreateWndList = NULL; - - HRESULT hr = pWinModule->m_csWindowCreate.Init(); - if (FAILED(hr)) - { - ATLTRACE(atlTraceWindowing, 0, _T("ERROR : Unable to initialize critical section in AtlWinModuleInit\n")); - ATLASSERT(0); - } - return hr; -} - -///////////////////////////////////////////////////////////////////////////// -// Module - -ATLINLINE ATLAPI AtlModuleAddTermFunc(_ATL_MODULE* pModule, _ATL_TERMFUNC* pFunc, DWORD_PTR dw) -{ - if (pModule == NULL) - return E_INVALIDARG; - - HRESULT hr = S_OK; - _ATL_TERMFUNC_ELEM* pNew = NULL; - ATLTRY(pNew = new _ATL_TERMFUNC_ELEM); - if (pNew == NULL) - hr = E_OUTOFMEMORY; - else - { - pNew->pFunc = pFunc; - pNew->dw = dw; - CComCritSecLock lock(pModule->m_csStaticDataInitAndTypeInfo, false); - hr = lock.Lock(); - if (SUCCEEDED(hr)) - { - pNew->pNext = pModule->m_pTermFuncs; - pModule->m_pTermFuncs = pNew; - } - else - { - delete pNew; - ATLTRACE(atlTraceGeneral, 0, _T("ERROR : Unable to lock critical section in AtlModuleAddTermFunc\n")); - ATLASSERT(0); - } - } - return hr; -} - -ATLINLINE ATLAPI_(void) AtlCallTermFunc(_ATL_MODULE* pModule) -{ - if (pModule == NULL) - _AtlRaiseException((DWORD)EXCEPTION_ACCESS_VIOLATION); - - _ATL_TERMFUNC_ELEM* pElem = pModule->m_pTermFuncs; - _ATL_TERMFUNC_ELEM* pNext = NULL; - while (pElem != NULL) - { - pElem->pFunc(pElem->dw); - pNext = pElem->pNext; - delete pElem; - pElem = pNext; - } - pModule->m_pTermFuncs = NULL; -} - -} // namespace ATL -#pragma warning(pop) -#endif // __ATLBASE_INL__ - diff --git a/cpp/jacob/include/atlchecked.h b/cpp/jacob/include/atlchecked.h deleted file mode 100644 index aadb522..0000000 --- a/cpp/jacob/include/atlchecked.h +++ /dev/null @@ -1,605 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLCHECKED_H__ -#define __ATLCHECKED_H__ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#pragma warning(push) -#pragma warning(disable:4127) - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ - -inline errno_t AtlCrtErrorCheck(errno_t nError) -{ - switch(nError) - { - case ENOMEM: - AtlThrow(E_OUTOFMEMORY); - break; - case EINVAL: - case ERANGE: - AtlThrow(E_INVALIDARG); - break; - case 0: - case STRUNCATE: - break; - default: - AtlThrow(E_FAIL); - break; - } - return nError; -} - -///////////////////////////////////////////////////////////////////////////// -// Secure (Checked) CRT functions - -namespace Checked -{ - -#if _SECURE_ATL - -#ifdef _AFX -#define ATLMFC_CRT_ERRORCHECK(expr) AFX_CRT_ERRORCHECK(expr) -#else -#define ATLMFC_CRT_ERRORCHECK(expr) ATL_CRT_ERRORCHECK(expr) -#endif - -inline void __cdecl memcpy_s(__out_bcount_part(_S1max,_N) void *_S1, __in size_t _S1max, __in_bcount(_N) const void *_S2, __in size_t _N) -{ - ATLMFC_CRT_ERRORCHECK(::memcpy_s(_S1, _S1max, _S2, _N)); -} - -inline void __cdecl wmemcpy_s(__out_ecount_part(_N1,_N) wchar_t *_S1, __in size_t _N1, __in_ecount(_N) const wchar_t *_S2, __in size_t _N) -{ - ATLMFC_CRT_ERRORCHECK(::wmemcpy_s(_S1, _N1, _S2, _N)); -} - -inline void __cdecl memmove_s(__out_bcount_part(_S1max,_N) void *_S1, __in size_t _S1max, __in_bcount(_N) const void *_S2, size_t _N) -{ - ATLMFC_CRT_ERRORCHECK(::memmove_s(_S1, _S1max, _S2, _N)); -} - -inline void __cdecl strcpy_s(__out_ecount(_S1max) char *_S1, __in size_t _S1max, __in_z const char *_S2) -{ - ATLMFC_CRT_ERRORCHECK(::strcpy_s(_S1, _S1max, _S2)); -} - -inline void __cdecl wcscpy_s(__out_ecount(_S1max) wchar_t *_S1, __in size_t _S1max, __in_z const wchar_t *_S2) -{ - ATLMFC_CRT_ERRORCHECK(::wcscpy_s(_S1, _S1max, _S2)); -} - -inline void __cdecl tcscpy_s(__out_ecount(_SizeInChars) TCHAR * _Dst, __in size_t _SizeInChars, __in_z const TCHAR * _Src) -{ -#ifndef _ATL_MIN_CRT - ATLMFC_CRT_ERRORCHECK(::_tcscpy_s(_Dst, _SizeInChars, _Src)); -#else -#ifdef UNICODE - ATLMFC_CRT_ERRORCHECK(::wcscpy_s(_Dst, _SizeInChars, _Src)); -#else - ATLMFC_CRT_ERRORCHECK(::strcpy_s(_Dst, _SizeInChars, _Src)); -#endif -#endif -} - -inline errno_t __cdecl strncpy_s(__out_ecount(_SizeInChars) char *_Dest, __in size_t _SizeInChars, __in_z const char *_Source, __in size_t _Count) -{ - return ATLMFC_CRT_ERRORCHECK(::strncpy_s(_Dest, _SizeInChars, _Source,_Count)); -} - -inline errno_t __cdecl wcsncpy_s(__out_ecount(_SizeInChars) wchar_t *_Dest, __in size_t _SizeInChars, __in_z const wchar_t *_Source, __in size_t _Count) -{ - return ATLMFC_CRT_ERRORCHECK(::wcsncpy_s(_Dest, _SizeInChars, _Source,_Count)); -} - -inline errno_t __cdecl tcsncpy_s(__out_ecount(_SizeInChars) TCHAR *_Dest, __in size_t _SizeInChars, __in_z const TCHAR *_Source, __in size_t _Count) -{ -#ifndef _ATL_MIN_CRT - return ATLMFC_CRT_ERRORCHECK(::_tcsncpy_s(_Dest, _SizeInChars, _Source,_Count)); -#else -#ifdef UNICODE - return ATLMFC_CRT_ERRORCHECK(::wcsncpy_s(_Dest, _SizeInChars, _Source,_Count)); -#else - return ATLMFC_CRT_ERRORCHECK(::strncpy_s(_Dest, _SizeInChars, _Source,_Count)); -#endif -#endif -} - -inline void __cdecl strcat_s(__inout_ecount_z(_SizeInChars) char * _Dst, __in size_t _SizeInChars, __in_z const char * _Src) -{ - ATLMFC_CRT_ERRORCHECK(::strcat_s(_Dst, _SizeInChars, _Src)); -} - -inline void __cdecl wcscat_s(__inout_ecount_z(_SizeInChars) wchar_t * _Dst, __in size_t _SizeInChars, __in_z const wchar_t * _Src) -{ - ATLMFC_CRT_ERRORCHECK(::wcscat_s(_Dst, _SizeInChars, _Src)); -} - -inline void __cdecl tcscat_s(__inout_ecount_z(_SizeInChars) TCHAR * _Dst, __in size_t _SizeInChars, __in_z const TCHAR * _Src) -{ -#ifndef _ATL_MIN_CRT - ATLMFC_CRT_ERRORCHECK(::_tcscat_s(_Dst, _SizeInChars, _Src)); -#else -#ifdef UNICODE - ATLMFC_CRT_ERRORCHECK(::wcscat_s(_Dst, _SizeInChars, _Src)); -#else - ATLMFC_CRT_ERRORCHECK(::strcat_s(_Dst, _SizeInChars, _Src)); -#endif -#endif -} - -inline void __cdecl strlwr_s(__inout_ecount_z(_SizeInChars) char * _Str, __in size_t _SizeInChars) -{ - ATLMFC_CRT_ERRORCHECK(::_strlwr_s(_Str, _SizeInChars)); -} - -inline void __cdecl wcslwr_s(__inout_ecount_z(_SizeInChars) wchar_t * _Str, __in size_t _SizeInChars) -{ - ATLMFC_CRT_ERRORCHECK(::_wcslwr_s(_Str, _SizeInChars)); -} - -#if !defined(_MANAGED) -inline void __cdecl mbslwr_s(__inout_bcount_z(_SizeInChars) unsigned char * _Str, __in size_t _SizeInChars) -{ - ATLMFC_CRT_ERRORCHECK(::_mbslwr_s(_Str, _SizeInChars)); -} -#endif - -inline void __cdecl tcslwr_s(__inout_ecount_z(_SizeInChars) TCHAR * _Str, __in size_t _SizeInChars) -{ -#ifndef _ATL_MIN_CRT - ATLMFC_CRT_ERRORCHECK(::_tcslwr_s(_Str, _SizeInChars)); -#else -#ifdef UNICODE - ATLMFC_CRT_ERRORCHECK(::_wcslwr_s(_Str, _SizeInChars)); -#else - ATLMFC_CRT_ERRORCHECK(::_strlwr_s(_Str, _SizeInChars)); -#endif -#endif -} - -inline void __cdecl strupr_s(__inout_ecount_z(_SizeInChars) char * _Str, __in size_t _SizeInChars) -{ - ATLMFC_CRT_ERRORCHECK(::_strupr_s(_Str, _SizeInChars)); -} - -inline void __cdecl wcsupr_s(__inout_ecount_z(_SizeInChars) wchar_t * _Str, __in size_t _SizeInChars) -{ - ATLMFC_CRT_ERRORCHECK(::_wcsupr_s(_Str, _SizeInChars)); -} - -#if !defined(_MANAGED) -inline void __cdecl mbsupr_s(__inout_bcount_z(_SizeInChars) unsigned char * _Str, __in size_t _SizeInChars) -{ - ATLMFC_CRT_ERRORCHECK(::_mbsupr_s(_Str, _SizeInChars)); -} -#endif - -inline void __cdecl tcsupr_s(__inout_ecount_z(_SizeInChars) TCHAR * _Str, __in size_t _SizeInChars) -{ - ATLMFC_CRT_ERRORCHECK(::_tcsupr_s(_Str, _SizeInChars)); -} - -inline void __cdecl itoa_s(__in int _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_itoa_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl itot_s(__in int _Val, __out_ecount_z(_SizeInChars) TCHAR *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_itot_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl ltoa_s(__in long _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_ltoa_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl ltot_s(__in long _Val, __out_ecount_z(_SizeInChars) TCHAR *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_ltot_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl ultoa_s(__in unsigned long _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_ultoa_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl ultow_s(__in unsigned long _Val, __out_ecount_z(_SizeInChars) wchar_t *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_ultow_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl ultot_s(__in unsigned long _Val, __out_ecount_z(_SizeInChars) TCHAR *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_ultot_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl i64toa_s(__in __int64 _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_i64toa_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl i64tow_s(__in __int64 _Val, __out_ecount_z(_SizeInChars) wchar_t *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_i64tow_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl ui64toa_s(__in unsigned __int64 _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_ui64toa_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl ui64tow_s(__in unsigned __int64 _Val, __out_ecount_z(_SizeInChars) wchar_t *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - ATLMFC_CRT_ERRORCHECK(::_ui64tow_s(_Val, _Buf, _SizeInChars, _Radix)); -} - -inline void __cdecl gcvt_s(__out_ecount_z(_SizeInChars) char *_Buffer, __in size_t _SizeInChars, __in double _Value, __in int _Ndec) -{ - ATLMFC_CRT_ERRORCHECK(::_gcvt_s(_Buffer, _SizeInChars, _Value, _Ndec)); -} - -inline void __cdecl tsplitpath_s(__in_z const TCHAR *_Path, __out_ecount_z_opt(_Drive_len) TCHAR *_Drive, __in size_t _Drive_len, - __out_ecount_z_opt(_Dir_len) TCHAR *_Dir, __in size_t _Dir_len, - __out_ecount_z_opt(_Fname_len) TCHAR *_Fname, __in size_t _Fname_len, - __out_ecount_z_opt(_Ext_len) TCHAR *_Ext, __in size_t _Ext_len) -{ - ATLMFC_CRT_ERRORCHECK(::_tsplitpath_s(_Path, _Drive, _Drive_len, _Dir, _Dir_len, _Fname, _Fname_len, _Ext, _Ext_len)); -} - -inline void __cdecl tmakepath_s(__out_ecount_z(_SizeInChars) TCHAR *_Path, __in size_t _SizeInChars, __in_z const TCHAR *_Drive, - __in_z const TCHAR *_Dir, __in_z const TCHAR *_Fname, __in_z const TCHAR *_Ext) -{ - ATLMFC_CRT_ERRORCHECK(::_tmakepath_s(_Path, _SizeInChars, _Drive, _Dir, _Fname, _Ext)); -} - -inline size_t __cdecl strnlen(__in_ecount(_Maxsize) const char *_Str, __in size_t _Maxsize) -{ - return ::strnlen(_Str, _Maxsize); -} - -inline size_t __cdecl wcsnlen(__in_ecount(_Maxsize) const wchar_t *_Wcs, __in size_t _Maxsize) -{ - return ::wcsnlen(_Wcs, _Maxsize); -} - -inline size_t __cdecl tcsnlen(__in_ecount(_Maxsize) const TCHAR *_Str, __in size_t _Maxsize) -{ - return ::_tcsnlen(_Str, _Maxsize); -} - -inline int get_errno() -{ - int nErrNo; - ATLMFC_CRT_ERRORCHECK(::_get_errno(&nErrNo)); - return nErrNo; -} - -inline void set_errno(__in int _Value) -{ - ATLMFC_CRT_ERRORCHECK(::_set_errno(_Value)); -} - -#else // !_SECURE_ATL - -#define ATLMFC_CRT_ERRORCHECK(expr) do { expr; } while (0) - -inline void __cdecl memcpy_s(__out_bcount(_S1max) void *_S1, __in size_t _S1max, __in_bcount(_N) const void *_S2, size_t _N) -{ - (_S1max); - memcpy(_S1, _S2, _N); -} - -inline void __cdecl wmemcpy_s(__out_ecount(_N1) wchar_t *_S1, __in size_t _N1, __in_ecount(_N) const wchar_t *_S2, __in size_t _N) -{ - (_N1); - ::wmemcpy(_S1, _S2, _N); -} - -inline void __cdecl memmove_s(__out_bcount(_S1max) void *_S1, __in size_t _S1max, __in_bcount(_N) const void *_S2, __in size_t _N) -{ - (_S1max); - memmove(_S1, _S2, _N); -} - -inline void __cdecl strcpy_s(__out_ecount_z(_S1max) char *_S1, __in size_t _S1max, __in_z const char *_S2) -{ - (_S1max); - ::strcpy(_S1, _S2); -} - -inline void __cdecl wcscpy_s(__out_ecount_z(_S1max) wchar_t *_S1, __in size_t _S1max, __in_z const wchar_t *_S2) -{ - (_S1max); - ::wcscpy(_S1, _S2); -} - -inline void __cdecl tcscpy_s(__out_ecount_z(_SizeInChars) TCHAR * _Dst, __in size_t _SizeInChars, __in_z const TCHAR * _Src) -{ - (_SizeInChars); -#ifndef _ATL_MIN_CRT - ::_tcscpy(_Dst, _Src); -#else -#ifdef UNICODE - ::wcscpy(_Dst, _Src); -#else - ::strcpy(_Dst, _Src); -#endif -#endif -} - -/* ensure that strncpy_s null-terminate the dest string */ -inline errno_t __cdecl strncpy_s(__out_ecount_z(_SizeInChars) char *_Dest, __in size_t _SizeInChars, __in_z const char *_Source,__in size_t _Count) -{ - if (_Count == _TRUNCATE) - { - _Count = _SizeInChars - 1; - } - while (_Count > 0 && *_Source != 0) - { - *_Dest++ = *_Source++; - --_Count; - } - *_Dest = 0; - - return (*_Source!=0) ? STRUNCATE : 0; -} - -inline errno_t __cdecl wcsncpy_s(__out_ecount_z(_SizeInChars) wchar_t *_Dest, __in size_t _SizeInChars, __in_z const wchar_t *_Source, __in size_t _Count) -{ - if (_Count == _TRUNCATE) - { - _Count = _SizeInChars - 1; - } - while (_Count > 0 && *_Source != 0) - { - *_Dest++ = *_Source++; - --_Count; - } - *_Dest = 0; - - return (*_Source!=0) ? STRUNCATE : 0; -} - -inline errno_t __cdecl tcsncpy_s(__out_ecount_z(_SizeInChars) TCHAR *_Dest, __in size_t _SizeInChars, __in_z const TCHAR *_Source,__in size_t _Count) -{ - if (_Count == _TRUNCATE) - { - if(_SizeInChars>0) - { - _Count = _SizeInChars - 1; - } - else - { - _Count =0; - } - } - -#ifndef _ATL_MIN_CRT -#pragma warning(push) -#pragma warning(disable: 6535) - ::_tcsncpy(_Dest,_Source,_Count); -#pragma warning(pop) - if(_SizeInChars>0) - { - size_t nulCount = __min(_SizeInChars-1, _Count); - _Dest[nulCount] = 0; - } -#else - while (_Count > 0 && *_Source != 0) - { - *_Dest++ = *_Source++; - --_Count; - } - *_Dest = 0; -#endif - - return (*_Source!=0) ? STRUNCATE : 0; -} - -inline void __cdecl strcat_s(__inout_ecount_z(_SizeInChars) char * _Dst, __in size_t _SizeInChars, __in_z const char * _Src) -{ - (_SizeInChars); - ::strcat(_Dst, _Src); -} - -inline void __cdecl wcscat_s(__inout_ecount_z(_SizeInChars) wchar_t * _Dst, __in size_t _SizeInChars, __in_z const wchar_t * _Src) -{ - (_SizeInChars); - ::wcscat(_Dst, _Src); -} - -inline void __cdecl tcscat_s(__inout_ecount_z(_SizeInChars) TCHAR * _Dst, __in size_t _SizeInChars, __in_z const TCHAR * _Src) -{ - (_SizeInChars); -#ifndef _ATL_MIN_CRT - ::_tcscat(_Dst, _Src); -#else -#ifdef UNICODE - ::wcscat(_Dst, _Src); -#else - ::strcat(_Dst, _Src); -#endif -#endif -} - -inline void __cdecl strlwr_s(__inout_ecount_z(_SizeInChars) char * _Str, size_t _SizeInChars) -{ - (_SizeInChars); - ::_strlwr(_Str); -} - -inline void __cdecl wcslwr_s(__inout_ecount_z(_SizeInChars) wchar_t * _Str, size_t _SizeInChars) -{ - (_SizeInChars); - ::_wcslwr(_Str); -} - -inline void __cdecl mbslwr_s(__inout_bcount_z(_SizeInChars) unsigned char * _Str, size_t _SizeInChars) -{ - (_SizeInChars); - ::_mbslwr(_Str); -} - -inline void __cdecl tcslwr_s(__inout_ecount_z(_SizeInChars) TCHAR * _Str, size_t _SizeInChars) -{ - (_SizeInChars); -#ifndef _ATL_MIN_CRT - ::_tcslwr(_Str); -#else -#ifdef UNICODE - ::_wcslwr(_Str); -#else - ::_strlwr(_Str); -#endif -#endif -} - -inline void __cdecl itoa_s(__in int _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_itoa_s(_Val, _Buf, _SizeInChars, _Radix); -} - -inline void __cdecl itot_s(__in int _Val, __out_ecount_z(_SizeInChars) TCHAR *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_itot(_Val, _Buf, _Radix); -} - -inline void __cdecl ltoa_s(__in long _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_ltoa(_Val, _Buf, _Radix); -} - -inline void __cdecl ltot_s(__in long _Val, __out_ecount_z(_SizeInChars) TCHAR *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_ltot(_Val, _Buf, _Radix); -} - -inline void __cdecl ultoa_s(__in unsigned long _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_ultoa(_Val, _Buf, _Radix); -} - -inline void __cdecl ultow_s(__in unsigned long _Val, __out_ecount_z(_SizeInChars) wchar_t *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_ultow(_Val, _Buf, _Radix); -} - -inline void __cdecl ultot_s(__in unsigned long _Val, __out_ecount_z(_SizeInChars) TCHAR *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_ultot(_Val, _Buf, _Radix); -} - -inline void __cdecl i64toa_s(__in __int64 _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_i64toa(_Val, _Buf, _Radix); -} - -inline void __cdecl i64tow_s(__in __int64 _Val, __out_ecount_z(_SizeInChars) wchar_t *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_i64tow(_Val, _Buf, _Radix); -} - -inline void __cdecl ui64toa_s(__in unsigned __int64 _Val, __out_ecount_z(_SizeInChars) char *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_ui64toa(_Val, _Buf, _Radix); -} - -inline void __cdecl ui64tow_s(__in unsigned __int64 _Val, __out_ecount_z(_SizeInChars) wchar_t *_Buf, __in size_t _SizeInChars, __in int _Radix) -{ - (_SizeInChars); - ::_ui64tow(_Val, _Buf, _Radix); -} - -inline void __cdecl gcvt_s(__out_ecount_z(_SizeInChars) char *_Buffer, __in size_t _SizeInChars, __in double _Value, __in int _Ndec) -{ - (_SizeInChars); - ::_gcvt(_Value, _Ndec, _Buffer); -} - -inline void __cdecl tsplitpath_s(__in_z const TCHAR *_Path, __out_ecount_z_opt(_Drive_len) TCHAR *_Drive, __in size_t _Drive_len, - __out_ecount_z_opt(_Dir_len) TCHAR *_Dir, __in size_t _Dir_len, - __out_ecount_z_opt(_Fname_ext) TCHAR *_Fname, __in size_t _Fname_len, - __out_ecount_z_opt(_Ext_len) TCHAR *_Ext, __in size_t _Ext_len) -{ - (_Drive_len, _Dir_len, _Fname_len, _Ext_len); - ::_tsplitpath(_Path, _Drive, _Dir, _Fname, _Ext); -} - -inline void __cdecl tmakepath_s(__out_ecount_z(_SizeInChars) TCHAR *_Path, __in size_t _SizeInChars, __in_z const TCHAR *_Drive, - __in_z const TCHAR *_Dir, __in_z const TCHAR *_Fname, __in_z const TCHAR *_Ext) -{ - (_SizeInChars); - ::_tmakepath(_Path, _Drive, _Dir, _Fname, _Ext); -} - -inline size_t __cdecl strnlen(__in_ecount(_Maxsize) const char *_Str, __in size_t _Maxsize) -{ - (_Maxsize); - return ::strlen(_Str); -} - -inline size_t __cdecl wcsnlen(__in_ecount(_Maxsize) const wchar_t *_Wcs, __in size_t _Maxsize) -{ - (_Maxsize); - return ::wcslen(_Wcs); -} - -inline size_t __cdecl tcsnlen(__in_ecount(_Maxsize) const TCHAR *_Str, __in size_t _Maxsize) -{ - (_Maxsize); - return ::_tcslen(_Str); -} - -inline int get_errno() -{ - return errno; -} - -inline void set_errno(__in int _Value) -{ - errno = _Value; -} - -#endif // _SECURE_ATL - -} // namespace Checked - -} // namespace ATL -#pragma warning(pop) -#pragma pack(pop) - -#endif // __ATLCHECKED_H__ - -///////////////////////////////////////////////////////////////////////////// - diff --git a/cpp/jacob/include/atlcomcli.h b/cpp/jacob/include/atlcomcli.h deleted file mode 100644 index f0d71cd..0000000 --- a/cpp/jacob/include/atlcomcli.h +++ /dev/null @@ -1,2874 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLCOMCLI_H__ -#define __ATLCOMCLI_H__ - -#pragma once - -#include -#include -#include - -#pragma warning (push) -#pragma warning (disable: 4127) // conditional expression constant -#pragma warning (disable: 4571) //catch(...) blocks compiled with /EHs do NOT catch or re-throw Structured Exceptions - - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ -///////////////////////////////////////////////////////////////////////////// -// Error to HRESULT helpers - -ATL_NOINLINE inline HRESULT AtlHresultFromLastError() throw() -{ - DWORD dwErr = ::GetLastError(); - return HRESULT_FROM_WIN32(dwErr); -} - -ATL_NOINLINE inline HRESULT AtlHresultFromWin32(__in DWORD nError) throw() -{ - return( HRESULT_FROM_WIN32( nError ) ); -} - -///////////////////////////////////////////////////////////////////////////// -// Smart Pointer helpers - -ATLAPI_(IUnknown*) AtlComPtrAssign(__deref_out_opt IUnknown** pp, __in_opt IUnknown* lp); -ATLAPI_(IUnknown*) AtlComQIPtrAssign(__deref_out_opt IUnknown** pp, __in_opt IUnknown* lp, REFIID riid); - -#ifndef _ATL_DLL - -ATLINLINE ATLAPI_(IUnknown*) AtlComPtrAssign(__deref_out_opt IUnknown** pp, __in_opt IUnknown* lp) -{ - if (pp == NULL) - return NULL; - - if (lp != NULL) - lp->AddRef(); - if (*pp) - (*pp)->Release(); - *pp = lp; - return lp; -} - -ATLINLINE ATLAPI_(IUnknown*) AtlComQIPtrAssign(__deref_out_opt IUnknown** pp, __in_opt IUnknown* lp, REFIID riid) -{ - if (pp == NULL) - return NULL; - - IUnknown* pTemp = *pp; - *pp = NULL; - if (lp != NULL) - lp->QueryInterface(riid, (void**)pp); - if (pTemp) - pTemp->Release(); - return *pp; -} - -#endif // _ATL_DLL - -///////////////////////////////////////////////////////////////////////////// -// COM Smart pointers - -template -class _NoAddRefReleaseOnCComPtr : public T -{ - private: - STDMETHOD_(ULONG, AddRef)()=0; - STDMETHOD_(ULONG, Release)()=0; -}; - -inline __checkReturn HRESULT AtlSetChildSite(__inout IUnknown* punkChild, __in_opt IUnknown* punkParent) -{ - if (punkChild == NULL) - return E_POINTER; - - HRESULT hr; - IObjectWithSite* pChildSite = NULL; - hr = punkChild->QueryInterface(__uuidof(IObjectWithSite), (void**)&pChildSite); - if (SUCCEEDED(hr) && pChildSite != NULL) - { - hr = pChildSite->SetSite(punkParent); - pChildSite->Release(); - } - return hr; -} - - -//CComPtrBase provides the basis for all other smart pointers -//The other smartpointers add their own constructors and operators -template -class CComPtrBase -{ -protected: - CComPtrBase() throw() - { - p = NULL; - } - CComPtrBase(__in int nNull) throw() - { - ATLASSERT(nNull == 0); - (void)nNull; - p = NULL; - } - CComPtrBase(__in_opt T* lp) throw() - { - p = lp; - if (p != NULL) - p->AddRef(); - } -public: - typedef T _PtrClass; - ~CComPtrBase() throw() - { - if (p) - p->Release(); - } - operator T*() const throw() - { - return p; - } - T& operator*() const - { - ATLENSURE(p!=NULL); - return *p; - } - //The assert on operator& usually indicates a bug. If this is really - //what is needed, however, take the address of the p member explicitly. - T** operator&() throw() - { - ATLASSERT(p==NULL); - return &p; - } - _NoAddRefReleaseOnCComPtr* operator->() const throw() - { - ATLASSERT(p!=NULL); - return (_NoAddRefReleaseOnCComPtr*)p; - } - bool operator!() const throw() - { - return (p == NULL); - } - bool operator<(__in_opt T* pT) const throw() - { - return p < pT; - } - bool operator!=(__in_opt T* pT) const - { - return !operator==(pT); - } - bool operator==(__in_opt T* pT) const throw() - { - return p == pT; - } - - // Release the interface and set to NULL - void Release() throw() - { - T* pTemp = p; - if (pTemp) - { - p = NULL; - pTemp->Release(); - } - } - // Compare two objects for equivalence - bool IsEqualObject(__in_opt IUnknown* pOther) throw() - { - if (p == NULL && pOther == NULL) - return true; // They are both NULL objects - - if (p == NULL || pOther == NULL) - return false; // One is NULL the other is not - - CComPtr punk1; - CComPtr punk2; - p->QueryInterface(__uuidof(IUnknown), (void**)&punk1); - pOther->QueryInterface(__uuidof(IUnknown), (void**)&punk2); - return punk1 == punk2; - } - // Attach to an existing interface (does not AddRef) - void Attach(__in T* p2) throw() - { - if (p) - p->Release(); - p = p2; - } - // Detach the interface (does not Release) - T* Detach() throw() - { - T* pt = p; - p = NULL; - return pt; - } - __checkReturn HRESULT CopyTo(__deref_out_opt T** ppT) throw() - { - ATLASSERT(ppT != NULL); - if (ppT == NULL) - return E_POINTER; - *ppT = p; - if (p) - p->AddRef(); - return S_OK; - } - __checkReturn HRESULT SetSite(__in_opt IUnknown* punkParent) throw() - { - return AtlSetChildSite(p, punkParent); - } - __checkReturn HRESULT Advise(__in IUnknown* pUnk, __in const IID& iid, __out LPDWORD pdw) throw() - { - return AtlAdvise(p, pUnk, iid, pdw); - } - __checkReturn HRESULT CoCreateInstance(__in REFCLSID rclsid, __in_opt LPUNKNOWN pUnkOuter = NULL, __in DWORD dwClsContext = CLSCTX_ALL) throw() - { - ATLASSERT(p == NULL); - return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p); - } - __checkReturn HRESULT CoCreateInstance(__in LPCOLESTR szProgID, __in_opt LPUNKNOWN pUnkOuter = NULL, __in DWORD dwClsContext = CLSCTX_ALL) throw() - { - CLSID clsid; - HRESULT hr = CLSIDFromProgID(szProgID, &clsid); - ATLASSERT(p == NULL); - if (SUCCEEDED(hr)) - hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p); - return hr; - } - template - __checkReturn HRESULT QueryInterface(__deref_out_opt Q** pp) const throw() - { - ATLASSERT(pp != NULL); - return p->QueryInterface(__uuidof(Q), (void**)pp); - } - T* p; -}; - -template -class CComPtr : public CComPtrBase -{ -public: - CComPtr() throw() - { - } - CComPtr(int nNull) throw() : - CComPtrBase(nNull) - { - } - CComPtr(T* lp) throw() : - CComPtrBase(lp) - - { - } - CComPtr(__in const CComPtr& lp) throw() : - CComPtrBase(lp.p) - { - } - T* operator=(__in_opt T* lp) throw() - { - if(*this!=lp) - { - return static_cast(AtlComPtrAssign((IUnknown**)&p, lp)); - } - return *this; - } - template - T* operator=(__in const CComPtr& lp) throw() - { - if( !IsEqualObject(lp) ) - { - return static_cast(AtlComQIPtrAssign((IUnknown**)&p, lp, __uuidof(T))); - } - return *this; - } - T* operator=(__in const CComPtr& lp) throw() - { - if(*this!=lp) - { - return static_cast(AtlComPtrAssign((IUnknown**)&p, lp)); - } - return *this; - } -}; - -//specialization for IDispatch -template <> -class CComPtr : public CComPtrBase -{ -public: - CComPtr() throw() - { - } - CComPtr(IDispatch* lp) throw() : - CComPtrBase(lp) - { - } - CComPtr(const CComPtr& lp) throw() : - CComPtrBase(lp.p) - { - } - IDispatch* operator=(IDispatch* lp) throw() - { - if(*this!=lp) - { - return static_cast(AtlComPtrAssign((IUnknown**)&p, lp)); - } - return *this; - } - IDispatch* operator=(const CComPtr& lp) throw() - { - if(*this!=lp) - { - return static_cast(AtlComPtrAssign((IUnknown**)&p, lp.p)); - } - return *this; - } - -// IDispatch specific stuff - __checkReturn HRESULT GetPropertyByName(__in LPCOLESTR lpsz, __out VARIANT* pVar) throw() - { - ATLASSERT(p); - ATLASSERT(pVar); - DISPID dwDispID; - HRESULT hr = GetIDOfName(lpsz, &dwDispID); - if (SUCCEEDED(hr)) - hr = GetProperty(dwDispID, pVar); - return hr; - } - __checkReturn HRESULT GetProperty(__in DISPID dwDispID, __out VARIANT* pVar) throw() - { - return GetProperty(p, dwDispID, pVar); - } - __checkReturn HRESULT PutPropertyByName(__in LPCOLESTR lpsz, __in VARIANT* pVar) throw() - { - ATLASSERT(p); - ATLASSERT(pVar); - DISPID dwDispID; - HRESULT hr = GetIDOfName(lpsz, &dwDispID); - if (SUCCEEDED(hr)) - hr = PutProperty(dwDispID, pVar); - return hr; - } - __checkReturn HRESULT PutProperty(__in DISPID dwDispID, __in VARIANT* pVar) throw() - { - return PutProperty(p, dwDispID, pVar); - } - __checkReturn HRESULT GetIDOfName(__in LPCOLESTR lpsz, __out DISPID* pdispid) throw() - { - return p->GetIDsOfNames(IID_NULL, const_cast(&lpsz), 1, LOCALE_USER_DEFAULT, pdispid); - } - // Invoke a method by DISPID with no parameters - __checkReturn HRESULT Invoke0(__in DISPID dispid, __out_opt VARIANT* pvarRet = NULL) throw() - { - DISPPARAMS dispparams = { NULL, NULL, 0, 0}; - return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); - } - // Invoke a method by name with no parameters - __checkReturn HRESULT Invoke0(__in LPCOLESTR lpszName, __out_opt VARIANT* pvarRet = NULL) throw() - { - HRESULT hr; - DISPID dispid; - hr = GetIDOfName(lpszName, &dispid); - if (SUCCEEDED(hr)) - hr = Invoke0(dispid, pvarRet); - return hr; - } - // Invoke a method by DISPID with a single parameter - __checkReturn HRESULT Invoke1(__in DISPID dispid, VARIANT* pvarParam1, __out_opt VARIANT* pvarRet = NULL) throw() - { - DISPPARAMS dispparams = { pvarParam1, NULL, 1, 0}; - return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); - } - // Invoke a method by name with a single parameter - __checkReturn HRESULT Invoke1(__in LPCOLESTR lpszName, VARIANT* pvarParam1, __out_opt VARIANT* pvarRet = NULL) throw() - { - HRESULT hr; - DISPID dispid; - hr = GetIDOfName(lpszName, &dispid); - if (SUCCEEDED(hr)) - hr = Invoke1(dispid, pvarParam1, pvarRet); - return hr; - } - // Invoke a method by DISPID with two parameters - __checkReturn HRESULT Invoke2(__in DISPID dispid, __in VARIANT* pvarParam1, __in VARIANT* pvarParam2, __out_opt VARIANT* pvarRet = NULL) throw(); - // Invoke a method by name with two parameters - __checkReturn HRESULT Invoke2(__in LPCOLESTR lpszName, __in VARIANT* pvarParam1, __in VARIANT* pvarParam2, __out_opt VARIANT* pvarRet = NULL) throw() - { - HRESULT hr; - DISPID dispid; - hr = GetIDOfName(lpszName, &dispid); - if (SUCCEEDED(hr)) - hr = Invoke2(dispid, pvarParam1, pvarParam2, pvarRet); - return hr; - } - // Invoke a method by DISPID with N parameters - __checkReturn HRESULT InvokeN(DISPID dispid, VARIANT* pvarParams, int nParams, VARIANT* pvarRet = NULL) throw() - { - DISPPARAMS dispparams = { pvarParams, NULL, nParams, 0}; - return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); - } - // Invoke a method by name with Nparameters - __checkReturn HRESULT InvokeN(LPCOLESTR lpszName, VARIANT* pvarParams, int nParams, VARIANT* pvarRet = NULL) throw() - { - HRESULT hr; - DISPID dispid; - hr = GetIDOfName(lpszName, &dispid); - if (SUCCEEDED(hr)) - hr = InvokeN(dispid, pvarParams, nParams, pvarRet); - return hr; - } - static __checkReturn HRESULT PutProperty(__inout IDispatch* p, __in DISPID dwDispID, __in VARIANT* pVar) throw() - { - ATLASSERT(p); - ATLASSERT(pVar != NULL); - if (pVar == NULL) - return E_POINTER; - - if(p == NULL) - return E_INVALIDARG; - - ATLTRACE(atlTraceCOM, 2, _T("CPropertyHelper::PutProperty\n")); - DISPPARAMS dispparams = {NULL, NULL, 1, 1}; - dispparams.rgvarg = pVar; - DISPID dispidPut = DISPID_PROPERTYPUT; - dispparams.rgdispidNamedArgs = &dispidPut; - - if (pVar->vt == VT_UNKNOWN || pVar->vt == VT_DISPATCH || - (pVar->vt & VT_ARRAY) || (pVar->vt & VT_BYREF)) - { - HRESULT hr = p->Invoke(dwDispID, IID_NULL, - LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUTREF, - &dispparams, NULL, NULL, NULL); - if (SUCCEEDED(hr)) - return hr; - } - return p->Invoke(dwDispID, IID_NULL, - LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, - &dispparams, NULL, NULL, NULL); - } - static __checkReturn HRESULT GetProperty(__in IDispatch* p, __in DISPID dwDispID, __out VARIANT* pVar) throw() - { - ATLASSERT(p); - ATLASSERT(pVar != NULL); - if (pVar == NULL) - return E_POINTER; - - if(p == NULL) - return E_INVALIDARG; - - ATLTRACE(atlTraceCOM, 2, _T("CPropertyHelper::GetProperty\n")); - DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; - return p->Invoke(dwDispID, IID_NULL, - LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, - &dispparamsNoArgs, pVar, NULL, NULL); - } -}; - -template -class CComQIPtr : public CComPtr -{ -public: - CComQIPtr() throw() - { - } - CComQIPtr(__in T* lp) throw() : - CComPtr(lp) - { - } - CComQIPtr(__in const CComQIPtr& lp) throw() : - CComPtr(lp.p) - { - } - CComQIPtr(__in_opt IUnknown* lp) throw() - { - if (lp != NULL) - lp->QueryInterface(*piid, (void **)&p); - } - T* operator=(__in T* lp) throw() - { - if(*this!=lp) - { - return static_cast(AtlComPtrAssign((IUnknown**)&p, lp)); - } - return *this; - } - T* operator=(__in const CComQIPtr& lp) throw() - { - if(*this!=lp) - { - return static_cast(AtlComPtrAssign((IUnknown**)&p, lp.p)); - } - return *this; - } - T* operator=(__in IUnknown* lp) throw() - { - if(*this!=lp) - { - return static_cast(AtlComQIPtrAssign((IUnknown**)&p, lp, *piid)); - } - return *this; - } -}; - -//Specialization to make it work -template<> -class CComQIPtr : public CComPtr -{ -public: - CComQIPtr() throw() - { - } - CComQIPtr(__in IUnknown* lp) throw() - { - //Actually do a QI to get identity - if (lp != NULL) - lp->QueryInterface(__uuidof(IUnknown), (void **)&p); - } - CComQIPtr(__in const CComQIPtr& lp) throw() : - CComPtr(lp.p) - { - } - IUnknown* operator=(__in IUnknown* lp) throw() - { - if(*this!=lp) - { - //Actually do a QI to get identity - return AtlComQIPtrAssign((IUnknown**)&p, lp, __uuidof(IUnknown)); - } - return *this; - } - - IUnknown* operator=(__in const CComQIPtr& lp) throw() - { - if(*this!=lp) - { - return AtlComPtrAssign((IUnknown**)&p, lp.p); - } - return *this; - } -}; - -typedef CComQIPtr CComDispatchDriver; - -#define com_cast ATL::CComQIPtr -#ifndef _ATL_STREAM_MAX_SIZE -#define _ATL_STREAM_MAX_SIZE 0x100000 -#endif - - -///////////////////////////////////////////////////////////////////////////// -// CComBSTR - -class CComBSTR -{ -public: - BSTR m_str; - - CComBSTR() throw() - { - m_str = NULL; - } - - CComBSTR(__in int nSize) - { - if (nSize == 0) - m_str = NULL; - else - { - m_str = ::SysAllocStringLen(NULL, nSize); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - } - - CComBSTR(__in int nSize, __in_ecount_opt(nSize) LPCOLESTR sz) - { - if (nSize == 0) - { - m_str = NULL; - } - else - { - m_str = ::SysAllocStringLen(sz, nSize); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - } - - CComBSTR(__in_opt LPCOLESTR pSrc) - { - if (pSrc == NULL) - { - m_str = NULL; - } - else - { - m_str = ::SysAllocString(pSrc); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - } - - CComBSTR(__in const CComBSTR& src) - { - m_str = src.Copy(); - if (!!src && !*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - - CComBSTR(__in REFGUID guid) - { - OLECHAR szGUID[64]; - ::StringFromGUID2(guid, szGUID, 64); - m_str = ::SysAllocString(szGUID); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - - CComBSTR& operator=(__in const CComBSTR& src) - { - if (m_str != src.m_str) - { - ::SysFreeString(m_str); - m_str = src.Copy(); - if (!!src && !*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - return *this; - } - - CComBSTR& operator=(__in_opt LPCOLESTR pSrc) - { - if (pSrc != m_str) - { - ::SysFreeString(m_str); - if (pSrc != NULL) - { - m_str = ::SysAllocString(pSrc); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - else - { - m_str = NULL; - } - } - return *this; - } - - ~CComBSTR() throw(); - - unsigned int Length() const throw() - { - return ::SysStringLen(m_str); - } - - unsigned int ByteLength() const throw() - { - return ::SysStringByteLen(m_str); - } - - operator BSTR() const throw() - { - return m_str; - } - - -#ifndef ATL_CCOMBSTR_ADDRESS_OF_ASSERT -// Temp disable CComBSTR::operator& Assert -#define ATL_NO_CCOMBSTR_ADDRESS_OF_ASSERT -#endif - - - BSTR* operator&() throw() - { -#ifndef ATL_NO_CCOMBSTR_ADDRESS_OF_ASSERT -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "We are deliberately checking if this has already been allocated") - ATLASSERT(!*this); -#pragma prefast(pop) -#pragma warning(pop) -#endif - return &m_str; - } - - BSTR Copy() const throw() - { - if (!*this) - { - return NULL; - } - return ::SysAllocStringByteLen((char*)m_str, ::SysStringByteLen(m_str)); - } - - __checkReturn HRESULT CopyTo(__inout_opt BSTR* pbstr) throw() - { - ATLASSERT(pbstr != NULL); - if (pbstr == NULL) - { - return E_POINTER; - } - *pbstr = Copy(); -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "We are checking allocation semantics here") - if ((*pbstr == NULL) && (m_str != NULL)) - { - return E_OUTOFMEMORY; - } -#pragma prefast(pop) -#pragma warning(pop) - return S_OK; - } - - // copy BSTR to VARIANT - __checkReturn HRESULT CopyTo(__out_opt VARIANT *pvarDest) throw() - { - ATLASSERT(pvarDest != NULL); - HRESULT hRes = E_POINTER; - if (pvarDest != NULL) - { - pvarDest->vt = VT_BSTR; - pvarDest->bstrVal = Copy(); -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "We are checking allocation semantics here") - if (pvarDest->bstrVal == NULL && m_str != NULL) - { - hRes = E_OUTOFMEMORY; - } -#pragma prefast(pop) -#pragma warning(pop) - else - { - hRes = S_OK; - } - } - return hRes; - } - - void Attach(__in BSTR src) throw() - { - if (m_str != src) - { - ::SysFreeString(m_str); - m_str = src; - } - } - - BSTR Detach() throw() - { - BSTR s = m_str; - m_str = NULL; - return s; - } - - void Empty() throw() - { - ::SysFreeString(m_str); - m_str = NULL; - } - - bool operator!() const throw() - { -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - return (m_str == NULL); -#pragma prefast(pop) -#pragma warning(pop) - } - - __checkReturn HRESULT Append(__in const CComBSTR& bstrSrc) throw() - { - return AppendBSTR(bstrSrc.m_str); - } - - __checkReturn HRESULT Append(__in_opt LPCOLESTR lpsz) throw() - { - return Append(lpsz, UINT(ocslen(lpsz))); - } - - // a BSTR is just a LPCOLESTR so we need a special version to signify - // that we are appending a BSTR - __checkReturn HRESULT AppendBSTR(__in_opt BSTR p) throw() - { - if (::SysStringLen(p) == 0) - { - return S_OK; - } - BSTR bstrNew = NULL; - HRESULT hr; - hr = VarBstrCat(m_str, p, &bstrNew); - if (SUCCEEDED(hr)) - { - ::SysFreeString(m_str); - m_str = bstrNew; - } - return hr; - } - - __checkReturn HRESULT Append(__in_ecount_opt(nLen) LPCOLESTR lpsz, __in int nLen) throw() - { -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - if (lpsz == NULL || (m_str != NULL && nLen == 0)) -#pragma prefast(pop) -#pragma warning(pop) - return S_OK; - int n1 = Length(); - if (n1+nLen < n1) - return E_OUTOFMEMORY; - BSTR b; - b = ::SysAllocStringLen(NULL, n1+nLen); -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - if (b == NULL) -#pragma prefast(pop) -#pragma warning(pop) - return E_OUTOFMEMORY; - if(::SysStringLen(m_str) > 0) - { - Checked::memcpy_s(b, (n1+nLen)*sizeof(OLECHAR), m_str, n1*sizeof(OLECHAR)); - } - Checked::memcpy_s(b+n1, nLen*sizeof(OLECHAR), lpsz, nLen*sizeof(OLECHAR)); - b[n1+nLen] = NULL; - SysFreeString(m_str); - m_str = b; - return S_OK; - } - - __checkReturn HRESULT Append(__in char ch) throw() - { - OLECHAR chO = ch; - - return( Append( &chO, 1 ) ); - } - - __checkReturn HRESULT Append(__in wchar_t ch) throw() - { - return( Append( &ch, 1 ) ); - } - - __checkReturn HRESULT AppendBytes(__in_ecount_opt(nLen) const char* lpsz, __in int nLen) throw() - { - if (lpsz == NULL || nLen == 0) - return S_OK; - int n1 = ByteLength(); - if (n1+nLen < n1) - return E_OUTOFMEMORY; - BSTR b; - b = ::SysAllocStringByteLen(NULL, n1+nLen); - if (b == NULL) - { - return E_OUTOFMEMORY; - } - Checked::memcpy_s(b, n1+nLen, m_str, n1); - Checked::memcpy_s(((char*)b)+n1, nLen, lpsz, nLen); - *((OLECHAR*)(((char*)b)+n1+nLen)) = NULL; - SysFreeString(m_str); - m_str = b; - return S_OK; - } - - __checkReturn HRESULT AssignBSTR(const BSTR bstrSrc) throw() - { - HRESULT hr = S_OK; - if (m_str != bstrSrc) - { - ::SysFreeString(m_str); -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - if (bstrSrc != NULL) -#pragma prefast(pop) -#pragma warning(pop) - { - m_str = ::SysAllocStringByteLen((char*)bstrSrc, ::SysStringByteLen(bstrSrc)); - if (!*this) - { - hr = E_OUTOFMEMORY; - } - } - else - { - m_str = NULL; - } - } - - return hr; - } - - __checkReturn HRESULT ToLower() throw() - { - if (::SysStringLen(m_str) > 0) - { -#ifdef _UNICODE - // Convert in place - CharLowerBuff(m_str, Length()); -#else - // Cannot use conversion macros due to possible embedded NULLs - UINT _acp = _AtlGetConversionACP(); - int _convert = WideCharToMultiByte(_acp, 0, m_str, Length(), NULL, 0, NULL, NULL); - CTempBuffer pszA; - ATLTRY(pszA.Allocate(_convert)); - if (pszA == NULL) - return E_OUTOFMEMORY; - - int nRet = WideCharToMultiByte(_acp, 0, m_str, Length(), pszA, _convert, NULL, NULL); - if (nRet == 0) - { - ATLASSERT(0); - return AtlHresultFromLastError(); - } - - CharLowerBuff(pszA, nRet); - - _convert = MultiByteToWideChar(_acp, 0, pszA, nRet, NULL, 0); - - CTempBuffer pszW; - ATLTRY(pszW.Allocate(_convert)); - if (pszW == NULL) - return E_OUTOFMEMORY; - - nRet = MultiByteToWideChar(_acp, 0, pszA, nRet, pszW, _convert); - if (nRet <= 0) - { - ATLASSERT(0); - return AtlHresultFromLastError(); - } - - UINT nBytes=0; - HRESULT hr=S_OK; - if( FAILED(hr=::ATL::AtlMultiply(&nBytes, static_cast(nRet), static_cast(sizeof(OLECHAR))))) - { - return hr; - } - BSTR b = ::SysAllocStringByteLen((LPCSTR) (LPWSTR) pszW, nBytes); - if (b == NULL) - return E_OUTOFMEMORY; - SysFreeString(m_str); - m_str = b; -#endif - } - return S_OK; - } - __checkReturn HRESULT ToUpper() throw() - { - if (::SysStringLen(m_str) > 0) - { -#ifdef _UNICODE - // Convert in place - CharUpperBuff(m_str, Length()); -#else - // Cannot use conversion macros due to possible embedded NULLs - UINT _acp = _AtlGetConversionACP(); - int _convert = WideCharToMultiByte(_acp, 0, m_str, Length(), NULL, 0, NULL, NULL); - CTempBuffer pszA; - ATLTRY(pszA.Allocate(_convert)); - if (pszA == NULL) - return E_OUTOFMEMORY; - - int nRet = WideCharToMultiByte(_acp, 0, m_str, Length(), pszA, _convert, NULL, NULL); - if (nRet == 0) - { - ATLASSERT(0); - return AtlHresultFromLastError(); - } - - CharUpperBuff(pszA, nRet); - - _convert = MultiByteToWideChar(_acp, 0, pszA, nRet, NULL, 0); - - CTempBuffer pszW; - ATLTRY(pszW.Allocate(_convert)); - if (pszW == NULL) - return E_OUTOFMEMORY; - - nRet = MultiByteToWideChar(_acp, 0, pszA, nRet, pszW, _convert); - if (nRet <= 0) - { - ATLASSERT(0); - return AtlHresultFromLastError(); - } - - UINT nBytes=0; - HRESULT hr=S_OK; - if( FAILED(hr=::ATL::AtlMultiply(&nBytes, static_cast(nRet), static_cast(sizeof(OLECHAR))))) - { - return hr; - } - BSTR b = ::SysAllocStringByteLen((LPCSTR) (LPWSTR) pszW, nBytes); - if (b == NULL) - return E_OUTOFMEMORY; - SysFreeString(m_str); - m_str = b; -#endif - } - return S_OK; - } - - bool LoadString(__in HINSTANCE hInst, __in UINT nID) throw() - { - ::SysFreeString(m_str); - m_str = NULL; - return LoadStringResource(hInst, nID, m_str); - } - - bool LoadString(__in UINT nID) throw() - { - ::SysFreeString(m_str); - m_str = NULL; - return LoadStringResource(nID, m_str); - } - - CComBSTR& operator+=(__in const CComBSTR& bstrSrc) - { - HRESULT hr; - hr = AppendBSTR(bstrSrc.m_str); - if (FAILED(hr)) - AtlThrow(hr); - return *this; - } - - CComBSTR& operator+=(__in_opt LPCOLESTR pszSrc) - { - HRESULT hr; - hr = Append(pszSrc); - if (FAILED(hr)) - AtlThrow(hr); - return *this; - } - - bool operator<(const CComBSTR& bstrSrc) const throw() - { - return VarBstrCmp(m_str, bstrSrc.m_str, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_LT); - } - bool operator<(__in_z LPCOLESTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator<(bstr2); - } - bool operator<(__in_z LPOLESTR pszSrc) const - { - return operator<((LPCOLESTR)pszSrc); - } - - bool operator>(const CComBSTR& bstrSrc) const throw() - { - return VarBstrCmp(m_str, bstrSrc.m_str, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_GT); - } - bool operator>(__in_z LPCOLESTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator>(bstr2); - } - bool operator>(__in_z LPOLESTR pszSrc) const - { - return operator>((LPCOLESTR)pszSrc); - } - - bool operator!=(const CComBSTR& bstrSrc) const throw() - { - return !operator==(bstrSrc); - } - bool operator!=(__in_z LPCOLESTR pszSrc) const - { - return !operator==(pszSrc); - } - bool operator!=(int nNull) const throw() - { - return !operator==(nNull); - } - bool operator!=(__in_z LPOLESTR pszSrc) const - { - return operator!=((LPCOLESTR)pszSrc); - } - - bool operator==(const CComBSTR& bstrSrc) const throw() - { - return VarBstrCmp(m_str, bstrSrc.m_str, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_EQ); - } - bool operator==(__in_z LPCOLESTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator==(bstr2); - } - bool operator==(__in_z LPOLESTR pszSrc) const - { - return operator==((LPCOLESTR)pszSrc); - } - - bool operator==(int nNull) const throw() - { - ATLASSERT(nNull == NULL); - (void)nNull; - return (!*this); - } - - CComBSTR(__in LPCSTR pSrc) - { - if (pSrc != NULL) - { - m_str = A2WBSTR(pSrc); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - else - { - m_str = NULL; - } - } - - CComBSTR(__in int nSize, __in_ecount_opt(nSize) LPCSTR sz) - { - if (nSize != 0 && sz == NULL) - { - m_str = ::SysAllocStringLen(NULL, nSize); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - return; - } - - m_str = A2WBSTR(sz, nSize); - if (!*this && nSize != 0) - { - AtlThrow(E_OUTOFMEMORY); - } - } - - __checkReturn HRESULT Append(__in LPCSTR lpsz) throw() - { - if (lpsz == NULL) - return S_OK; - - CComBSTR bstrTemp; - ATLTRY(bstrTemp = lpsz); - if (!bstrTemp) - { - return E_OUTOFMEMORY; - } - return Append(bstrTemp); - } - - CComBSTR& operator=(__in LPCSTR pSrc) - { - ::SysFreeString(m_str); - m_str = A2WBSTR(pSrc); - if (!*this && pSrc != NULL) - { - AtlThrow(E_OUTOFMEMORY); - } - return *this; - } - - bool operator<(__in_z LPCSTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator<(bstr2); - } - bool operator>(__in_z LPCSTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator>(bstr2); - } - bool operator!=(__in_z LPCSTR pszSrc) const - { - return !operator==(pszSrc); - } - bool operator==(__in_z LPCSTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator==(bstr2); - } - - __checkReturn HRESULT WriteToStream(__inout IStream* pStream) throw() - { - ATLASSERT(pStream != NULL); - if(pStream == NULL) - return E_INVALIDARG; - - ULONG cb; - ULONG cbStrLen = CComBSTR::GetStreamSize(m_str) - sizeof(ULONG); - HRESULT hr = pStream->Write((void*) &cbStrLen, sizeof(cbStrLen), &cb); - if (FAILED(hr)) - return hr; - return cbStrLen ? pStream->Write((void*) m_str, cbStrLen, &cb) : S_OK; - } - - __checkReturn HRESULT ReadFromStream(__inout IStream* pStream) throw() - { - ATLASSERT(pStream != NULL); - if(pStream == NULL) - { - return E_INVALIDARG; - } - - ATLASSERT(!*this); // should be empty - Empty(); - - HRESULT hrSeek; - ULARGE_INTEGER nBegOffset; - { - LARGE_INTEGER nZeroOffset; - nZeroOffset.QuadPart = 0L; - hrSeek = pStream->Seek(nZeroOffset, STREAM_SEEK_CUR, &nBegOffset); - } - - ULONG cbRead = 0; - ULONG cbStrLen = 0; - HRESULT hr = pStream->Read(reinterpret_cast(&cbStrLen), sizeof(cbStrLen), &cbRead); - - if (SUCCEEDED(hr)) - { - // invalid data sizes - if (sizeof(cbStrLen) != cbRead) - { - ATLTRACE(atlTraceCOM, 0, _T("Input stream is corrupted.")); - hr = E_FAIL; - } - // check for NULL bstr - else if (cbStrLen == 0) - { - } - // security checks when system hang for huge stream of data - else if (cbStrLen > _ATL_STREAM_MAX_SIZE) - { - ATLTRACE(atlTraceCOM, 0, _T("String exceeded the maximum allowed size see _ATL_STREAM_MAX_SIZE.")); - hr = E_ACCESSDENIED; - } - else - { - //subtract size for terminating NULL which we wrote out - cbStrLen -= sizeof(OLECHAR); - - m_str = ::SysAllocStringByteLen(NULL, cbStrLen); - if (!*this) - { - hr = E_OUTOFMEMORY; - } - else - { - hr = pStream->Read(reinterpret_cast(m_str), cbStrLen, &cbRead); - - if (SUCCEEDED(hr)) - { - if (cbRead != cbStrLen) - { - ATLTRACE(atlTraceCOM, 0, _T("Length of string data is different than expected.")); - hr = E_FAIL; - } - else - { - OLECHAR ch; - hr = pStream->Read(reinterpret_cast(&ch), sizeof(OLECHAR), &cbRead); - - if (SUCCEEDED(hr)) - { - if (cbRead != sizeof(OLECHAR)) - { - ATLTRACE(atlTraceCOM, 0, _T("Cannot read NULL terminator from stream.")); - hr = E_FAIL; - } - else - { - //check if string is properly terminated with NULL - ATLASSERT(ch == L'\0'); - } - } - } - } - - if (FAILED(hr)) - { - ::SysFreeString(m_str); - m_str = NULL; - } - } - } - } - - // If SysAllocStringByteLen or IStream::Read failed, reset seek - // pointer to start of BSTR size. - if (FAILED(hr) && SUCCEEDED(hrSeek)) - { - LARGE_INTEGER nOffset; - nOffset.QuadPart = static_cast(nBegOffset.QuadPart); - pStream->Seek(nOffset, STREAM_SEEK_SET, NULL); - } - - return hr; - } - - static bool LoadStringResource(__in HINSTANCE hInstance, __in UINT uID, __deref_out_opt BSTR& bstrText) throw() - { - const ATLSTRINGRESOURCEIMAGE* pImage; - -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - ATLASSERT(bstrText == NULL); -#pragma prefast(pop) -#pragma warning(pop) - - pImage = AtlGetStringResourceImage(hInstance, uID); - if (pImage != NULL) - { - bstrText = ::SysAllocStringLen(pImage->achString, pImage->nLength); - } -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - return (bstrText != NULL) ? true : false; -#pragma prefast(pop) -#pragma warning(pop) - } - - static bool LoadStringResource(__in UINT uID, __deref_out_opt BSTR& bstrText) throw() - { - const ATLSTRINGRESOURCEIMAGE* pImage; - -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - ATLASSERT(bstrText == NULL); -#pragma prefast(pop) -#pragma warning(pop) - - pImage = AtlGetStringResourceImage(uID); - if (pImage != NULL) - { - bstrText = ::SysAllocStringLen(pImage->achString, pImage->nLength); - } - -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - return (bstrText != NULL) ? true : false; -#pragma prefast(pop) -#pragma warning(pop) - } - - // each character in BSTR is copied to each element in SAFEARRAY - __success(return>=0) HRESULT BSTRToArray(__deref_out LPSAFEARRAY *ppArray) throw() - { - return VectorFromBstr(m_str, ppArray); - } - - // first character of each element in SAFEARRAY is copied to BSTR - __checkReturn HRESULT ArrayToBSTR(__in const SAFEARRAY *pSrc) throw() - { - ::SysFreeString(m_str); - return BstrFromVector((LPSAFEARRAY)pSrc, &m_str); - } - static ULONG GetStreamSize(BSTR bstr) - { - ULONG ulSize=sizeof(ULONG); -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - if (bstr != NULL) -#pragma prefast(pop) -#pragma warning(pop) - { - ulSize += SysStringByteLen(bstr) + sizeof(OLECHAR); - } - return ulSize; - } -}; - -inline CComBSTR::~CComBSTR() throw() - { - ::SysFreeString(m_str); - } - -inline void SysFreeStringHelper(__in CComBSTR& bstr) -{ - bstr.Empty(); -} - -inline void SysFreeStringHelper(BSTR bstr) -{ - ::SysFreeString(bstr); -} - -inline __checkReturn HRESULT SysAllocStringHelper(__out_opt CComBSTR& bstrDest,BSTR bstrSrc) -{ - bstrDest=bstrSrc; - return !bstrDest ? E_OUTOFMEMORY : S_OK; -} - -inline __checkReturn HRESULT SysAllocStringHelper(__out_opt BSTR& bstrDest,BSTR bstrSrc) -{ - bstrDest=::SysAllocString(bstrSrc); -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "The semantics of this function are about allocation, not content") - return bstrDest==NULL ? E_OUTOFMEMORY : S_OK; -#pragma prefast(pop) -#pragma warning(pop) -} - -///////////////////////////////////////////////////////////// -// Class to Adapt CComBSTR and CComPtr for use with STL containers -// the syntax to use it is -// std::vector< CAdapt > vect; - -template -class CAdapt -{ -public: - CAdapt() - { - } - CAdapt(__in const T& rSrc) : - m_T( rSrc ) - { - } - - CAdapt(__in const CAdapt& rSrCA) : - m_T( rSrCA.m_T ) - { - } - - CAdapt& operator=(__in const T& rSrc) - { - m_T = rSrc; - return *this; - } - bool operator<(__in const T& rSrc) const - { - return m_T < rSrc; - } - bool operator==(__in const T& rSrc) const - { - return m_T == rSrc; - } - operator T&() - { - return m_T; - } - - operator const T&() const - { - return m_T; - } - - T m_T; -}; - -///////////////////////////////////////////////////////////////////////////// -// CComVariant - - -#define ATL_VARIANT_TRUE VARIANT_BOOL( -1 ) -#define ATL_VARIANT_FALSE VARIANT_BOOL( 0 ) - -template< typename T > -class CVarTypeInfo -{ -// static const VARTYPE VT; // VARTYPE corresponding to type T -// static T VARIANT::* const pmField; // Pointer-to-member of corresponding field in VARIANT struct -}; - -template<> -class CVarTypeInfo< char > -{ -public: - static const VARTYPE VT = VT_I1; - static char VARIANT::* const pmField; -}; - -__declspec( selectany ) char VARIANT::* const CVarTypeInfo< char >::pmField = &VARIANT::cVal; - -template<> -class CVarTypeInfo< unsigned char > -{ -public: - static const VARTYPE VT = VT_UI1; - static unsigned char VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned char VARIANT::* const CVarTypeInfo< unsigned char >::pmField = &VARIANT::bVal; - -template<> -class CVarTypeInfo< char* > -{ -public: - static const VARTYPE VT = VT_I1|VT_BYREF; - static char* VARIANT::* const pmField; -}; - -__declspec( selectany ) char* VARIANT::* const CVarTypeInfo< char* >::pmField = &VARIANT::pcVal; - -template<> -class CVarTypeInfo< unsigned char* > -{ -public: - static const VARTYPE VT = VT_UI1|VT_BYREF; - static unsigned char* VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned char* VARIANT::* const CVarTypeInfo< unsigned char* >::pmField = &VARIANT::pbVal; - -template<> -class CVarTypeInfo< short > -{ -public: - static const VARTYPE VT = VT_I2; - static short VARIANT::* const pmField; -}; - -__declspec( selectany ) short VARIANT::* const CVarTypeInfo< short >::pmField = &VARIANT::iVal; - -template<> -class CVarTypeInfo< short* > -{ -public: - static const VARTYPE VT = VT_I2|VT_BYREF; - static short* VARIANT::* const pmField; -}; - -__declspec( selectany ) short* VARIANT::* const CVarTypeInfo< short* >::pmField = &VARIANT::piVal; - -template<> -class CVarTypeInfo< unsigned short > -{ -public: - static const VARTYPE VT = VT_UI2; - static unsigned short VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned short VARIANT::* const CVarTypeInfo< unsigned short >::pmField = &VARIANT::uiVal; - -#ifdef _NATIVE_WCHAR_T_DEFINED // Only treat unsigned short* as VT_UI2|VT_BYREF if BSTR isn't the same as unsigned short* -template<> -class CVarTypeInfo< unsigned short* > -{ -public: - static const VARTYPE VT = VT_UI2|VT_BYREF; - static unsigned short* VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned short* VARIANT::* const CVarTypeInfo< unsigned short* >::pmField = &VARIANT::puiVal; -#endif // _NATIVE_WCHAR_T_DEFINED - -template<> -class CVarTypeInfo< int > -{ -public: - static const VARTYPE VT = VT_I4; - static int VARIANT::* const pmField; -}; - -__declspec( selectany ) int VARIANT::* const CVarTypeInfo< int >::pmField = &VARIANT::intVal; - -template<> -class CVarTypeInfo< int* > -{ -public: - static const VARTYPE VT = VT_I4|VT_BYREF; - static int* VARIANT::* const pmField; -}; - -__declspec( selectany ) int* VARIANT::* const CVarTypeInfo< int* >::pmField = &VARIANT::pintVal; - -template<> -class CVarTypeInfo< unsigned int > -{ -public: - static const VARTYPE VT = VT_UI4; - static unsigned int VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned int VARIANT::* const CVarTypeInfo< unsigned int >::pmField = &VARIANT::uintVal; - -template<> -class CVarTypeInfo< unsigned int* > -{ -public: - static const VARTYPE VT = VT_UI4|VT_BYREF; - static unsigned int* VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned int* VARIANT::* const CVarTypeInfo< unsigned int* >::pmField = &VARIANT::puintVal; - -template<> -class CVarTypeInfo< long > -{ -public: - static const VARTYPE VT = VT_I4; - static long VARIANT::* const pmField; -}; - -__declspec( selectany ) long VARIANT::* const CVarTypeInfo< long >::pmField = &VARIANT::lVal; - -template<> -class CVarTypeInfo< long* > -{ -public: - static const VARTYPE VT = VT_I4|VT_BYREF; - static long* VARIANT::* const pmField; -}; - -__declspec( selectany ) long* VARIANT::* const CVarTypeInfo< long* >::pmField = &VARIANT::plVal; - -template<> -class CVarTypeInfo< unsigned long > -{ -public: - static const VARTYPE VT = VT_UI4; - static unsigned long VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned long VARIANT::* const CVarTypeInfo< unsigned long >::pmField = &VARIANT::ulVal; - -template<> -class CVarTypeInfo< unsigned long* > -{ -public: - static const VARTYPE VT = VT_UI4|VT_BYREF; - static unsigned long* VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned long* VARIANT::* const CVarTypeInfo< unsigned long* >::pmField = &VARIANT::pulVal; - -template<> -class CVarTypeInfo< __int64 > -{ -public: - static const VARTYPE VT = VT_I8; - static __int64 VARIANT::* const pmField; -}; - -__declspec( selectany ) __int64 VARIANT::* const CVarTypeInfo< __int64 >::pmField = &VARIANT::llVal; - -template<> -class CVarTypeInfo< __int64* > -{ -public: - static const VARTYPE VT = VT_I8|VT_BYREF; - static __int64* VARIANT::* const pmField; -}; - -__declspec( selectany ) __int64* VARIANT::* const CVarTypeInfo< __int64* >::pmField = &VARIANT::pllVal; - -template<> -class CVarTypeInfo< unsigned __int64 > -{ -public: - static const VARTYPE VT = VT_UI8; - static unsigned __int64 VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned __int64 VARIANT::* const CVarTypeInfo< unsigned __int64 >::pmField = &VARIANT::ullVal; - -template<> -class CVarTypeInfo< unsigned __int64* > -{ -public: - static const VARTYPE VT = VT_UI8|VT_BYREF; - static unsigned __int64* VARIANT::* const pmField; -}; - -__declspec( selectany ) unsigned __int64* VARIANT::* const CVarTypeInfo< unsigned __int64* >::pmField = &VARIANT::pullVal; - -template<> -class CVarTypeInfo< float > -{ -public: - static const VARTYPE VT = VT_R4; - static float VARIANT::* const pmField; -}; - -__declspec( selectany ) float VARIANT::* const CVarTypeInfo< float >::pmField = &VARIANT::fltVal; - -template<> -class CVarTypeInfo< float* > -{ -public: - static const VARTYPE VT = VT_R4|VT_BYREF; - static float* VARIANT::* const pmField; -}; - -__declspec( selectany ) float* VARIANT::* const CVarTypeInfo< float* >::pmField = &VARIANT::pfltVal; - -template<> -class CVarTypeInfo< double > -{ -public: - static const VARTYPE VT = VT_R8; - static double VARIANT::* const pmField; -}; - -__declspec( selectany ) double VARIANT::* const CVarTypeInfo< double >::pmField = &VARIANT::dblVal; - -template<> -class CVarTypeInfo< double* > -{ -public: - static const VARTYPE VT = VT_R8|VT_BYREF; - static double* VARIANT::* const pmField; -}; - -__declspec( selectany ) double* VARIANT::* const CVarTypeInfo< double* >::pmField = &VARIANT::pdblVal; - -template<> -class CVarTypeInfo< VARIANT > -{ -public: - static const VARTYPE VT = VT_VARIANT; -}; - -template<> -class CVarTypeInfo< BSTR > -{ -public: - static const VARTYPE VT = VT_BSTR; - static BSTR VARIANT::* const pmField; -}; - -__declspec( selectany ) BSTR VARIANT::* const CVarTypeInfo< BSTR >::pmField = &VARIANT::bstrVal; - -template<> -class CVarTypeInfo< BSTR* > -{ -public: - static const VARTYPE VT = VT_BSTR|VT_BYREF; - static BSTR* VARIANT::* const pmField; -}; - -__declspec( selectany ) BSTR* VARIANT::* const CVarTypeInfo< BSTR* >::pmField = &VARIANT::pbstrVal; - -template<> -class CVarTypeInfo< IUnknown* > -{ -public: - static const VARTYPE VT = VT_UNKNOWN; - static IUnknown* VARIANT::* const pmField; -}; - -__declspec( selectany ) IUnknown* VARIANT::* const CVarTypeInfo< IUnknown* >::pmField = &VARIANT::punkVal; - -template<> -class CVarTypeInfo< IUnknown** > -{ -public: - static const VARTYPE VT = VT_UNKNOWN|VT_BYREF; - static IUnknown** VARIANT::* const pmField; -}; - -__declspec( selectany ) IUnknown** VARIANT::* const CVarTypeInfo< IUnknown** >::pmField = &VARIANT::ppunkVal; - -template<> -class CVarTypeInfo< IDispatch* > -{ -public: - static const VARTYPE VT = VT_DISPATCH; - static IDispatch* VARIANT::* const pmField; -}; - -__declspec( selectany ) IDispatch* VARIANT::* const CVarTypeInfo< IDispatch* >::pmField = &VARIANT::pdispVal; - -template<> -class CVarTypeInfo< IDispatch** > -{ -public: - static const VARTYPE VT = VT_DISPATCH|VT_BYREF; - static IDispatch** VARIANT::* const pmField; -}; - -__declspec( selectany ) IDispatch** VARIANT::* const CVarTypeInfo< IDispatch** >::pmField = &VARIANT::ppdispVal; - -template<> -class CVarTypeInfo< CY > -{ -public: - static const VARTYPE VT = VT_CY; - static CY VARIANT::* const pmField; -}; - -__declspec( selectany ) CY VARIANT::* const CVarTypeInfo< CY >::pmField = &VARIANT::cyVal; - -template<> -class CVarTypeInfo< CY* > -{ -public: - static const VARTYPE VT = VT_CY|VT_BYREF; - static CY* VARIANT::* const pmField; -}; - -__declspec( selectany ) CY* VARIANT::* const CVarTypeInfo< CY* >::pmField = &VARIANT::pcyVal; - -class CComVariant : public tagVARIANT -{ -// Constructors -public: - CComVariant() throw() - { - ::VariantInit(this); - } - ~CComVariant() throw() - { - Clear(); - } - - CComVariant(__in const VARIANT& varSrc) - { - vt = VT_EMPTY; - InternalCopy(&varSrc); - } - - CComVariant(__in const CComVariant& varSrc) - { - vt = VT_EMPTY; - InternalCopy(&varSrc); - } - CComVariant(__in LPCOLESTR lpszSrc) - { - vt = VT_EMPTY; - *this = lpszSrc; - } - - CComVariant(__in LPCSTR lpszSrc) - { - vt = VT_EMPTY; - *this = lpszSrc; - } - - CComVariant(__in bool bSrc) - { - vt = VT_BOOL; - boolVal = bSrc ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE; - } - - CComVariant(__in int nSrc, __in VARTYPE vtSrc = VT_I4) throw() - { - ATLASSERT(vtSrc == VT_I4 || vtSrc == VT_INT); - vt = vtSrc; - intVal = nSrc; - } - CComVariant(__in BYTE nSrc) throw() - { - vt = VT_UI1; - bVal = nSrc; - } - CComVariant(__in short nSrc) throw() - { - vt = VT_I2; - iVal = nSrc; - } - CComVariant(__in long nSrc, __in VARTYPE vtSrc = VT_I4) throw() - { - ATLASSERT(vtSrc == VT_I4 || vtSrc == VT_ERROR); - vt = vtSrc; - lVal = nSrc; - } - CComVariant(__in float fltSrc) throw() - { - vt = VT_R4; - fltVal = fltSrc; - } - CComVariant(__in double dblSrc, __in VARTYPE vtSrc = VT_R8) throw() - { - ATLASSERT(vtSrc == VT_R8 || vtSrc == VT_DATE); - vt = vtSrc; - dblVal = dblSrc; - } -#if (_WIN32_WINNT >= 0x0501) || defined(_ATL_SUPPORT_VT_I8) - CComVariant(__in LONGLONG nSrc) throw() - { - vt = VT_I8; - llVal = nSrc; - } - CComVariant(__in ULONGLONG nSrc) throw() - { - vt = VT_UI8; - ullVal = nSrc; - } -#endif - CComVariant(CY __in cySrc) throw() - { - vt = VT_CY; - cyVal.Hi = cySrc.Hi; - cyVal.Lo = cySrc.Lo; - } - CComVariant(__in_opt IDispatch* pSrc) throw() - { - vt = VT_DISPATCH; - pdispVal = pSrc; - // Need to AddRef as VariantClear will Release - if (pdispVal != NULL) - pdispVal->AddRef(); - } - CComVariant(__in_opt IUnknown* pSrc) throw() - { - vt = VT_UNKNOWN; - punkVal = pSrc; - // Need to AddRef as VariantClear will Release - if (punkVal != NULL) - punkVal->AddRef(); - } - CComVariant(__in char cSrc) throw() - { - vt = VT_I1; - cVal = cSrc; - } - CComVariant(__in unsigned short nSrc) throw() - { - vt = VT_UI2; - uiVal = nSrc; - } - CComVariant(__in unsigned long nSrc) throw() - { - vt = VT_UI4; - ulVal = nSrc; - } - CComVariant(__in unsigned int nSrc, __in VARTYPE vtSrc = VT_UI4) throw() - { - ATLASSERT(vtSrc == VT_UI4 || vtSrc == VT_UINT); - vt = vtSrc; - uintVal= nSrc; - } - CComVariant(__in const CComBSTR& bstrSrc) - { - vt = VT_EMPTY; - *this = bstrSrc; - } - CComVariant(__in_opt const SAFEARRAY *pSrc) - { - LPSAFEARRAY pCopy; - if (pSrc != NULL) - { - HRESULT hRes = ::SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); - if (SUCCEEDED(hRes) && pCopy != NULL) - { - ::ATL::AtlSafeArrayGetActualVartype((LPSAFEARRAY)pSrc, &vt); - vt |= VT_ARRAY; - parray = pCopy; - } - else - { - vt = VT_ERROR; - scode = hRes; -#ifndef _ATL_NO_VARIANT_THROW - ATLENSURE_THROW(FALSE, E_OUTOFMEMORY); -#endif - } - } - else - { - vt = VT_EMPTY; - } - } -// Assignment Operators -public: - CComVariant& operator=(__in const CComVariant& varSrc) - { - if(this!=&varSrc) - { - InternalCopy(&varSrc); - } - return *this; - } - CComVariant& operator=(__in const VARIANT& varSrc) - { - if(static_cast(this)!=&varSrc) - { - InternalCopy(&varSrc); - } - return *this; - } - - CComVariant& operator=(__in const CComBSTR& bstrSrc) - { - Clear(); - vt = VT_BSTR; - bstrVal = bstrSrc.Copy(); -#pragma warning(push) -#pragma warning(disable:4068) -#pragma prefast(push) -#pragma prefast(disable:325, "We are checking allocation semantics here") - if (bstrVal == NULL && bstrSrc.m_str != NULL) - { - vt = VT_ERROR; - scode = E_OUTOFMEMORY; -#ifndef _ATL_NO_VARIANT_THROW - ATLENSURE_THROW(FALSE, E_OUTOFMEMORY); -#endif - } -#pragma prefast(pop) -#pragma warning(pop) - return *this; - } - - CComVariant& operator=(__in LPCOLESTR lpszSrc) - { - Clear(); - vt = VT_BSTR; - bstrVal = ::SysAllocString(lpszSrc); - - if (bstrVal == NULL && lpszSrc != NULL) - { - vt = VT_ERROR; - scode = E_OUTOFMEMORY; -#ifndef _ATL_NO_VARIANT_THROW - ATLENSURE_THROW(FALSE, E_OUTOFMEMORY); -#endif - - } - return *this; - } - - CComVariant& operator=(__in LPCSTR lpszSrc) - { - USES_CONVERSION_EX; - Clear(); - vt = VT_BSTR; - bstrVal = ::SysAllocString(A2COLE_EX(lpszSrc, _ATL_SAFE_ALLOCA_DEF_THRESHOLD)); - - if (bstrVal == NULL && lpszSrc != NULL) - { - vt = VT_ERROR; - scode = E_OUTOFMEMORY; -#ifndef _ATL_NO_VARIANT_THROW - ATLENSURE_THROW(FALSE, E_OUTOFMEMORY); -#endif - } - return *this; - } - - CComVariant& operator=(__in bool bSrc) - { - if (vt != VT_BOOL) - { - Clear(); - vt = VT_BOOL; - } - boolVal = bSrc ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE; - return *this; - } - - CComVariant& operator=(__in int nSrc) throw() - { - if (vt != VT_I4) - { - Clear(); - vt = VT_I4; - } - intVal = nSrc; - - return *this; - } - - CComVariant& operator=(__in BYTE nSrc) throw() - { - if (vt != VT_UI1) - { - Clear(); - vt = VT_UI1; - } - bVal = nSrc; - return *this; - } - - CComVariant& operator=(__in short nSrc) throw() - { - if (vt != VT_I2) - { - Clear(); - vt = VT_I2; - } - iVal = nSrc; - return *this; - } - - CComVariant& operator=(__in long nSrc) throw() - { - if (vt != VT_I4) - { - Clear(); - vt = VT_I4; - } - lVal = nSrc; - return *this; - } - - CComVariant& operator=(__in float fltSrc) throw() - { - if (vt != VT_R4) - { - Clear(); - vt = VT_R4; - } - fltVal = fltSrc; - return *this; - } - - CComVariant& operator=(__in double dblSrc) throw() - { - if (vt != VT_R8) - { - Clear(); - vt = VT_R8; - } - dblVal = dblSrc; - return *this; - } - - CComVariant& operator=(__in CY cySrc) throw() - { - if (vt != VT_CY) - { - Clear(); - vt = VT_CY; - } - cyVal.Hi = cySrc.Hi; - cyVal.Lo = cySrc.Lo; - return *this; - } - - CComVariant& operator=(__in_opt IDispatch* pSrc) throw() - { - Clear(); - vt = VT_DISPATCH; - pdispVal = pSrc; - // Need to AddRef as VariantClear will Release - if (pdispVal != NULL) - pdispVal->AddRef(); - return *this; - } - - CComVariant& operator=(__in_opt IUnknown* pSrc) throw() - { - Clear(); - vt = VT_UNKNOWN; - punkVal = pSrc; - - // Need to AddRef as VariantClear will Release - if (punkVal != NULL) - punkVal->AddRef(); - return *this; - } - - CComVariant& operator=(__in char cSrc) throw() - { - if (vt != VT_I1) - { - Clear(); - vt = VT_I1; - } - cVal = cSrc; - return *this; - } - - CComVariant& operator=(__in unsigned short nSrc) throw() - { - if (vt != VT_UI2) - { - Clear(); - vt = VT_UI2; - } - uiVal = nSrc; - return *this; - } - - CComVariant& operator=(__in unsigned long nSrc) throw() - { - if (vt != VT_UI4) - { - Clear(); - vt = VT_UI4; - } - ulVal = nSrc; - return *this; - } - - CComVariant& operator=(__in unsigned int nSrc) throw() - { - if (vt != VT_UI4) - { - Clear(); - vt = VT_UI4; - } - uintVal= nSrc; - return *this; - } - - CComVariant& operator=(__in_opt BYTE* pbSrc) throw() - { - if (vt != (VT_UI1|VT_BYREF)) - { - Clear(); - vt = VT_UI1|VT_BYREF; - } - pbVal = pbSrc; - return *this; - } - - CComVariant& operator=(__in_opt short* pnSrc) throw() - { - if (vt != (VT_I2|VT_BYREF)) - { - Clear(); - vt = VT_I2|VT_BYREF; - } - piVal = pnSrc; - return *this; - } - -#ifdef _NATIVE_WCHAR_T_DEFINED - CComVariant& operator=(__in_opt USHORT* pnSrc) throw() - { - if (vt != (VT_UI2|VT_BYREF)) - { - Clear(); - vt = VT_UI2|VT_BYREF; - } - puiVal = pnSrc; - return *this; - } -#endif - - CComVariant& operator=(__in_opt int* pnSrc) throw() - { - if (vt != (VT_I4|VT_BYREF)) - { - Clear(); - vt = VT_I4|VT_BYREF; - } - pintVal = pnSrc; - return *this; - } - - CComVariant& operator=(__in_opt UINT* pnSrc) throw() - { - if (vt != (VT_UI4|VT_BYREF)) - { - Clear(); - vt = VT_UI4|VT_BYREF; - } - puintVal = pnSrc; - return *this; - } - - CComVariant& operator=(__in_opt long* pnSrc) throw() - { - if (vt != (VT_I4|VT_BYREF)) - { - Clear(); - vt = VT_I4|VT_BYREF; - } - plVal = pnSrc; - return *this; - } - - CComVariant& operator=(__in_opt ULONG* pnSrc) throw() - { - if (vt != (VT_UI4|VT_BYREF)) - { - Clear(); - vt = VT_UI4|VT_BYREF; - } - pulVal = pnSrc; - return *this; - } - -#if (_WIN32_WINNT >= 0x0501) || defined(_ATL_SUPPORT_VT_I8) - CComVariant& operator=(__in LONGLONG nSrc) throw() - { - if (vt != VT_I8) - { - Clear(); - vt = VT_I8; - } - llVal = nSrc; - - return *this; - } - - CComVariant& operator=(__in_opt LONGLONG* pnSrc) throw() - { - if (vt != (VT_I8|VT_BYREF)) - { - Clear(); - vt = VT_I8|VT_BYREF; - } - pllVal = pnSrc; - return *this; - } - - CComVariant& operator=(__in ULONGLONG nSrc) throw() - { - if (vt != VT_UI8) - { - Clear(); - vt = VT_UI8; - } - ullVal = nSrc; - - return *this; - } - - CComVariant& operator=(__in_opt ULONGLONG* pnSrc) throw() - { - if (vt != (VT_UI8|VT_BYREF)) - { - Clear(); - vt = VT_UI8|VT_BYREF; - } - pullVal = pnSrc; - return *this; - } -#endif - -#pragma warning(push) -#pragma warning(disable: 28110) - - CComVariant& operator=(__in_opt float* pfSrc) throw() - { - if (vt != (VT_R4|VT_BYREF)) - { - Clear(); - vt = VT_R4|VT_BYREF; - } - pfltVal = pfSrc; - return *this; - } - - CComVariant& operator=(__in_opt double* pfSrc) throw() - { - if (vt != (VT_R8|VT_BYREF)) - { - Clear(); - vt = VT_R8|VT_BYREF; - } - pdblVal = pfSrc; - return *this; - } - -#pragma warning(pop) - - CComVariant& operator=(__in_opt const SAFEARRAY *pSrc) - { - Clear(); - LPSAFEARRAY pCopy; - if (pSrc != NULL) - { - HRESULT hRes = ::SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); - if (SUCCEEDED(hRes) && pCopy != NULL) - { - ::ATL::AtlSafeArrayGetActualVartype((LPSAFEARRAY)pSrc, &vt); - vt |= VT_ARRAY; - parray = pCopy; - } - else - { - vt = VT_ERROR; - scode = hRes; -#ifndef _ATL_NO_VARIANT_THROW - ATLENSURE_THROW(FALSE, E_OUTOFMEMORY); -#endif - } - } - return *this; - } - -// Comparison Operators -public: - bool operator==(__in const VARIANT& varSrc) const throw() - { - // For backwards compatibility - if (vt == VT_NULL && varSrc.vt == VT_NULL) - { - return true; - } - // Variants not equal if types don't match - if (vt != varSrc.vt) - { - return false; - } - return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_EQ); - } - - bool operator!=(__in const VARIANT& varSrc) const throw() - { - return !operator==(varSrc); - } - - bool operator<(__in const VARIANT& varSrc) const throw() - { - if (vt == VT_NULL && varSrc.vt == VT_NULL) - return false; - return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)== static_cast(VARCMP_LT); - } - - bool operator>(__in const VARIANT& varSrc) const throw() - { - if (vt == VT_NULL && varSrc.vt == VT_NULL) - return false; - return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)== static_cast(VARCMP_GT); - } - -// Operations -public: - HRESULT Clear() { return ::VariantClear(this); } - HRESULT ClearToZero() - { - HRESULT hr = ::VariantClear(this); - if( FAILED(hr) ) - { - return hr; - } - memset(this ,0 ,sizeof(tagVARIANT)); - vt = VT_EMPTY; - return hr; - } - - HRESULT Copy(__in const VARIANT* pSrc) { return ::VariantCopy(this, const_cast(pSrc)); } - // copy VARIANT to BSTR - HRESULT CopyTo(__out BSTR *pstrDest) - { - ATLASSERT(pstrDest != NULL && vt == VT_BSTR); - HRESULT hRes = E_POINTER; - if (pstrDest != NULL && vt == VT_BSTR) - { - *pstrDest = ::SysAllocStringByteLen((char*)bstrVal, ::SysStringByteLen(bstrVal)); - if (*pstrDest == NULL) - hRes = E_OUTOFMEMORY; - else - hRes = S_OK; - } - else if (vt != VT_BSTR) - hRes = DISP_E_TYPEMISMATCH; - return hRes; - } - HRESULT Attach(__in VARIANT* pSrc) - { - if(pSrc == NULL) - return E_INVALIDARG; - - // Clear out the variant - HRESULT hr = Clear(); - if (!FAILED(hr)) - { - // Copy the contents and give control to CComVariant - Checked::memcpy_s(this, sizeof(CComVariant), pSrc, sizeof(VARIANT)); - pSrc->vt = VT_EMPTY; - hr = S_OK; - } - return hr; - } - - HRESULT Detach(__out VARIANT* pDest) - { - ATLASSERT(pDest != NULL); - if(pDest == NULL) - return E_POINTER; - - // Clear out the variant - HRESULT hr = ::VariantClear(pDest); - if (!FAILED(hr)) - { - // Copy the contents and remove control from CComVariant - Checked::memcpy_s(pDest, sizeof(VARIANT), this, sizeof(VARIANT)); - vt = VT_EMPTY; - hr = S_OK; - } - return hr; - } - - HRESULT ChangeType(__in VARTYPE vtNew, __in_opt const VARIANT* pSrc = NULL) - { - VARIANT* pVar = const_cast(pSrc); - // Convert in place if pSrc is NULL - if (pVar == NULL) - pVar = this; - // Do nothing if doing in place convert and vts not different - return ::VariantChangeType(this, pVar, 0, vtNew); - } - - template< typename T > - void SetByRef( __in T* pT ) throw() - { - Clear(); - vt = CVarTypeInfo< T >::VT|VT_BYREF; - byref = pT; - } - - HRESULT WriteToStream(__inout IStream* pStream); - HRESULT WriteToStream(__inout IStream* pStream, VARTYPE vtWrite) - { - if (vtWrite != VT_EMPTY && vtWrite != vt) - { - CComVariant varConv; - HRESULT hr = varConv.ChangeType(vtWrite, this); - if (FAILED(hr)) - { - return hr; - } - return varConv.WriteToStream(pStream); - } - return WriteToStream(pStream); - } - HRESULT ReadFromStream(__inout IStream* pStream, VARTYPE vtExpected = VT_EMPTY); - - // Return the size in bytes of the current contents - ULONG GetSize() const; - -// Implementation -public: - HRESULT InternalClear() - { - HRESULT hr = Clear(); - ATLASSERT(SUCCEEDED(hr)); - if (FAILED(hr)) - { - vt = VT_ERROR; - scode = hr; -#ifndef _ATL_NO_VARIANT_THROW - AtlThrow(hr); -#endif - } - return hr; - } - - void InternalCopy(__in const VARIANT* pSrc) - { - HRESULT hr = Copy(pSrc); - if (FAILED(hr)) - { - vt = VT_ERROR; - scode = hr; -#ifndef _ATL_NO_VARIANT_THROW - AtlThrow(hr); -#endif - } - } -}; - -#pragma warning(push) -#pragma warning(disable: 4702) -inline HRESULT CComVariant::WriteToStream(__inout IStream* pStream) -{ - if(pStream == NULL) - return E_INVALIDARG; - - HRESULT hr = pStream->Write(&vt, sizeof(VARTYPE), NULL); - if (FAILED(hr)) - return hr; - - int cbWrite = 0; - switch (vt) - { - case VT_UNKNOWN: - case VT_DISPATCH: - { - CComPtr spStream; - if (punkVal != NULL) - { - hr = punkVal->QueryInterface(__uuidof(IPersistStream), (void**)&spStream); - if (FAILED(hr)) - { - hr = punkVal->QueryInterface(__uuidof(IPersistStreamInit), (void**)&spStream); - if (FAILED(hr)) - return hr; - } - } - if (spStream != NULL) - return OleSaveToStream(spStream, pStream); - return WriteClassStm(pStream, CLSID_NULL); - } - case VT_UI1: - case VT_I1: - cbWrite = sizeof(BYTE); - break; - case VT_I2: - case VT_UI2: - case VT_BOOL: - cbWrite = sizeof(short); - break; - case VT_I4: - case VT_UI4: - case VT_R4: - case VT_INT: - case VT_UINT: - case VT_ERROR: - cbWrite = sizeof(long); - break; - case VT_I8: - case VT_UI8: - cbWrite = sizeof(LONGLONG); - break; - case VT_R8: - case VT_CY: - case VT_DATE: - cbWrite = sizeof(double); - break; - default: - break; - } - if (cbWrite != 0) - return pStream->Write((void*) &bVal, cbWrite, NULL); - - CComBSTR bstrWrite; - CComVariant varBSTR; - if (vt != VT_BSTR) - { - hr = VariantChangeType(&varBSTR, this, VARIANT_NOVALUEPROP, VT_BSTR); - if (FAILED(hr)) - return hr; - bstrWrite.Attach(varBSTR.bstrVal); - } - else - bstrWrite.Attach(bstrVal); - - hr = bstrWrite.WriteToStream(pStream); - bstrWrite.Detach(); - return hr; -} -#pragma warning(pop) // C4702 - -inline HRESULT CComVariant::ReadFromStream(__inout IStream* pStream, VARTYPE vtExpected /* = VT_EMPTY */ ) -{ - ATLASSERT(pStream != NULL); - if(pStream == NULL) - return E_INVALIDARG; - - HRESULT hr; - hr = VariantClear(this); - if (FAILED(hr)) - return hr; - VARTYPE vtRead = VT_EMPTY; - ULONG cbRead = 0; - hr = pStream->Read(&vtRead, sizeof(VARTYPE), &cbRead); - if (hr == S_FALSE || (cbRead != sizeof(VARTYPE) && hr == S_OK)) - hr = E_FAIL; - if (FAILED(hr)) - return hr; - if (vtExpected != VT_EMPTY && vtRead != vtExpected) - return E_FAIL; - - vt = vtRead; - cbRead = 0; - switch (vtRead) - { - case VT_UNKNOWN: - case VT_DISPATCH: - { - punkVal = NULL; - hr = OleLoadFromStream(pStream, - (vtRead == VT_UNKNOWN) ? __uuidof(IUnknown) : __uuidof(IDispatch), - (void**)&punkVal); - // If IPictureDisp or IFontDisp property is not set, - // OleLoadFromStream() will return REGDB_E_CLASSNOTREG. - if (hr == REGDB_E_CLASSNOTREG) - hr = S_OK; - return hr; - } - case VT_UI1: - case VT_I1: - cbRead = sizeof(BYTE); - break; - case VT_I2: - case VT_UI2: - case VT_BOOL: - cbRead = sizeof(short); - break; - case VT_I4: - case VT_UI4: - case VT_R4: - case VT_INT: - case VT_UINT: - case VT_ERROR: - cbRead = sizeof(long); - break; - case VT_I8: - case VT_UI8: - cbRead = sizeof(LONGLONG); - break; - case VT_R8: - case VT_CY: - case VT_DATE: - cbRead = sizeof(double); - break; - default: - break; - } - if (cbRead != 0) - { - hr = pStream->Read((void*) &bVal, cbRead, NULL); - if (hr == S_FALSE) - hr = E_FAIL; - return hr; - } - CComBSTR bstrRead; - - hr = bstrRead.ReadFromStream(pStream); - if (FAILED(hr)) - { - // If CComBSTR::ReadFromStream failed, reset seek pointer to start of - // variant type. - LARGE_INTEGER nOffset; - nOffset.QuadPart = -(static_cast(sizeof(VARTYPE))); - pStream->Seek(nOffset, STREAM_SEEK_CUR, NULL); - vt = VT_EMPTY; - return hr; - } - vt = VT_BSTR; - bstrVal = bstrRead.Detach(); - if (vtRead != VT_BSTR) - hr = ChangeType(vtRead); - return hr; -} - -inline ULONG CComVariant::GetSize() const -{ - ULONG nSize = sizeof(VARTYPE); - HRESULT hr; - - switch (vt) - { - case VT_UNKNOWN: - case VT_DISPATCH: - { - CComPtr spStream; - if (punkVal != NULL) - { - hr = punkVal->QueryInterface(__uuidof(IPersistStream), (void**)&spStream); - if (FAILED(hr)) - { - hr = punkVal->QueryInterface(__uuidof(IPersistStreamInit), (void**)&spStream); - if (FAILED(hr)) - break; - } - } - if (spStream != NULL) - { - ULARGE_INTEGER nPersistSize; - nPersistSize.QuadPart = 0; - spStream->GetSizeMax(&nPersistSize); - nSize += nPersistSize.LowPart + sizeof(CLSID); - } - else - nSize += sizeof(CLSID); - } - break; - case VT_UI1: - case VT_I1: - nSize += sizeof(BYTE); - break; - case VT_I2: - case VT_UI2: - case VT_BOOL: - nSize += sizeof(short); - break; - case VT_I4: - case VT_UI4: - case VT_R4: - case VT_INT: - case VT_UINT: - case VT_ERROR: - nSize += sizeof(long); - break; - case VT_I8: - case VT_UI8: - nSize += sizeof(LONGLONG); - break; - case VT_R8: - case VT_CY: - case VT_DATE: - nSize += sizeof(double); - break; - default: - break; - } - if (nSize == sizeof(VARTYPE)) - { - VARTYPE vtTmp = vt; - BSTR bstr = NULL; - CComVariant varBSTR; - if (vtTmp != VT_BSTR) - { - hr = VariantChangeType(&varBSTR, const_cast((const VARIANT*)this), VARIANT_NOVALUEPROP, VT_BSTR); - if (SUCCEEDED(hr)) - { - bstr = varBSTR.bstrVal; - vtTmp = VT_BSTR; - } - } else - { - bstr = bstrVal; - } - - if (vtTmp == VT_BSTR) - { - // Add the size of the length + string (in bytes) + NULL terminator. - nSize += CComBSTR::GetStreamSize(bstr); - } - } - return nSize; -} - -__checkReturn inline HRESULT CComPtr::Invoke2(__in DISPID dispid, __in VARIANT* pvarParam1, __in VARIANT* pvarParam2, __out_opt VARIANT* pvarRet) throw() -{ - if(pvarParam1 == NULL || pvarParam2 == NULL) - return E_INVALIDARG; - - CComVariant varArgs[2] = { *pvarParam2, *pvarParam1 }; - DISPPARAMS dispparams = { &varArgs[0], NULL, 2, 0}; - return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); -} - -} // namespace ATL -#pragma pack(pop) - -#pragma warning (pop) - -#ifndef _ATL_NO_AUTOMATIC_NAMESPACE -using namespace ATL; -#endif //!_ATL_NO_AUTOMATIC_NAMESPACE - -#endif // __ATLCOMCLI_H__ - diff --git a/cpp/jacob/include/atlconv.h b/cpp/jacob/include/atlconv.h deleted file mode 100644 index 338109d..0000000 --- a/cpp/jacob/include/atlconv.h +++ /dev/null @@ -1,1302 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLCONV_H__ -#define __ATLCONV_H__ - -#pragma once - -#ifndef _ATL_NO_PRAGMA_WARNINGS -#pragma warning (push) -#pragma warning(disable: 4127) // unreachable code -#endif //!_ATL_NO_PRAGMA_WARNINGS - -// -// [pfx_parse] - workaround for old PREfix/PREfast parser -// -#if (defined(_PREFIX_) || defined(_PREFAST_)) && (_MSC_VER < 1400) -#pragma warning (push) -#pragma warning(disable: 4081) // expected 'newline' -#endif // old PREfast parser - -#ifndef __cplusplus - #error ATL requires C++ compilation (use a .cpp suffix) -#endif - -#include -#include -#include - -#ifndef __wtypes_h__ - -#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86) -#define _X86_ -#endif - -#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_AMD64) -#define _AMD64_ -#endif - -#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_M68K) -#define _68K_ -#endif - -#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_MPPC) -#define _MPPC_ -#endif - -#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_M_IX86) && !defined(_AMD64_) && defined(_M_IA64) -#if !defined(_IA64_) -#define _IA64_ -#endif // !_IA64_ -#endif - -#include -#include -#include -#include - -#if defined(_WIN32) && !defined(OLE2ANSI) - -typedef WCHAR OLECHAR; -typedef OLECHAR *LPOLESTR; -typedef const OLECHAR *LPCOLESTR; -#define OLESTR(str) L##str - -#else - -typedef char OLECHAR; -typedef LPSTR LPOLESTR; -typedef LPCSTR LPCOLESTR; -#define OLESTR(str) str - -#endif // _WIN32 && !OLE2ANSI -#endif // __wtypes_h__ - -#ifndef _OLEAUTO_H_ -typedef LPWSTR BSTR;// must (semantically) match typedef in oleauto.h - -extern "C" -{ -__declspec(dllimport) BSTR __stdcall SysAllocString(const OLECHAR *); -__declspec(dllimport) BSTR __stdcall SysAllocStringLen(const OLECHAR *, UINT); -__declspec(dllimport) INT __stdcall SysReAllocStringLen(BSTR *, const OLECHAR *, UINT); -__declspec(dllimport) void __stdcall SysFreeString(BSTR); -} -#endif - -// we use our own implementation of InterlockedExchangePointer because of problems with the one in system headers -#ifdef _M_IX86 -#undef InterlockedExchangePointer -inline void* WINAPI InterlockedExchangePointer(void** pp, void* pNew) throw() -{ - return( reinterpret_cast(static_cast(::InterlockedExchange(reinterpret_cast(pp), static_cast(reinterpret_cast(pNew))))) ); -} -#endif - -#ifndef _SECURECRT_FILL_BUFFER_PATTERN -#define _SECURECRT_FILL_BUFFER_PATTERN 0xFD -#endif - -#define ATLCONV_DEADLAND_FILL _SECURECRT_FILL_BUFFER_PATTERN - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ -#ifndef _CONVERSION_DONT_USE_THREAD_LOCALE -inline UINT WINAPI _AtlGetConversionACP() throw() -{ - return( CP_THREAD_ACP ); -} - -#else - -inline UINT WINAPI _AtlGetConversionACP() throw() -{ - return( CP_ACP ); -} - -#endif // _CONVERSION_DONT_USE_THREAD_LOCALE -template -inline void AtlConvAllocMemory(__deref_ecount_opt(nLength) _CharType** ppBuff,__in int nLength,__inout_ecount(nFixedBufferLength) _CharType* pszFixedBuffer,__in int nFixedBufferLength) -{ - ATLENSURE_THROW(ppBuff != NULL, E_INVALIDARG); - ATLENSURE_THROW(nLength >= 0, E_INVALIDARG); - ATLENSURE_THROW(pszFixedBuffer != NULL, E_INVALIDARG); - - //if buffer malloced, try to realloc. - if (*ppBuff != pszFixedBuffer) - { - if( nLength > nFixedBufferLength ) - { - _CharType* ppReallocBuf = static_cast< _CharType* >( _recalloc(*ppBuff, nLength,sizeof( _CharType ) ) ); - if (ppReallocBuf == NULL) - { - AtlThrow( E_OUTOFMEMORY ); - } - *ppBuff = ppReallocBuf; - } else - { - free(*ppBuff); - *ppBuff=pszFixedBuffer; - } - - } else //Buffer is not currently malloced. - { - if( nLength > nFixedBufferLength ) - { - *ppBuff = static_cast< _CharType* >( calloc(nLength,sizeof( _CharType ) ) ); - } else - { - *ppBuff=pszFixedBuffer; - } - } - - if (*ppBuff == NULL) - { - AtlThrow( E_OUTOFMEMORY ); - } - -} - -template -inline void AtlConvFreeMemory(_CharType* pBuff,_CharType* pszFixedBuffer,int nFixedBufferLength) -{ - (nFixedBufferLength); - if( pBuff != pszFixedBuffer ) - { - free( pBuff ); - } -#ifdef _DEBUG - else - { - memset(pszFixedBuffer,ATLCONV_DEADLAND_FILL,nFixedBufferLength*sizeof(_CharType)); - } -#endif - -} - -template< int t_nBufferLength = 128 > -class CW2WEX -{ -public: - CW2WEX( __in_opt LPCWSTR psz ) throw(...) : - m_psz( m_szBuffer ) - { - Init( psz ); - } - CW2WEX( __in_opt LPCWSTR psz, UINT nCodePage ) throw(...) : - m_psz( m_szBuffer ) - { - (void)nCodePage; // Code page doesn't matter - - Init( psz ); - } - ~CW2WEX() throw() - { - AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); - } - - operator LPWSTR() const throw() - { - return( m_psz ); - } - -private: - void Init( __in_opt LPCWSTR psz ) throw(...) - { - if (psz == NULL) - { - m_psz = NULL; - return; - } - int nLength = lstrlenW( psz )+1; - AtlConvAllocMemory(&m_psz,nLength,m_szBuffer,t_nBufferLength); - Checked::memcpy_s( m_psz, nLength*sizeof( wchar_t ), psz, nLength*sizeof( wchar_t )); - } - -public: - LPWSTR m_psz; - wchar_t m_szBuffer[t_nBufferLength]; - -private: - CW2WEX( const CW2WEX& ) throw(); - CW2WEX& operator=( const CW2WEX& ) throw(); -}; -typedef CW2WEX<> CW2W; - -template< int t_nBufferLength = 128 > -class CA2AEX -{ -public: - CA2AEX( __in_opt LPCSTR psz ) throw(...) : - m_psz( m_szBuffer ) - { - Init( psz ); - } - CA2AEX( __in_opt LPCSTR psz, UINT nCodePage ) throw(...) : - m_psz( m_szBuffer ) - { - (void)nCodePage; // Code page doesn't matter - - Init( psz ); - } - ~CA2AEX() throw() - { - AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); - } - - operator LPSTR() const throw() - { - return( m_psz ); - } - -private: - void Init( __in_opt LPCSTR psz ) throw(...) - { - if (psz == NULL) - { - m_psz = NULL; - return; - } - int nLength = lstrlenA( psz )+1; - AtlConvAllocMemory(&m_psz,nLength,m_szBuffer,t_nBufferLength); - Checked::memcpy_s( m_psz, nLength*sizeof( char ), psz, nLength*sizeof( char )); - } - -public: - LPSTR m_psz; - char m_szBuffer[t_nBufferLength]; - -private: - CA2AEX( const CA2AEX& ) throw(); - CA2AEX& operator=( const CA2AEX& ) throw(); -}; -typedef CA2AEX<> CA2A; - -template< int t_nBufferLength = 128 > -class CA2CAEX -{ -public: - CA2CAEX( __in LPCSTR psz ) throw(...) : - m_psz( psz ) - { - } - CA2CAEX( __in LPCSTR psz, UINT nCodePage ) throw(...) : - m_psz( psz ) - { - (void)nCodePage; - } - ~CA2CAEX() throw() - { - } - - operator LPCSTR() const throw() - { - return( m_psz ); - } - -public: - LPCSTR m_psz; - -private: - CA2CAEX( const CA2CAEX& ) throw(); - CA2CAEX& operator=( const CA2CAEX& ) throw(); -}; -typedef CA2CAEX<> CA2CA; - -template< int t_nBufferLength = 128 > -class CW2CWEX -{ -public: - CW2CWEX( __in LPCWSTR psz ) throw(...) : - m_psz( psz ) - { - } - CW2CWEX( __in LPCWSTR psz, UINT nCodePage ) throw(...) : - m_psz( psz ) - { - (void)nCodePage; - } - ~CW2CWEX() throw() - { - } - - operator LPCWSTR() const throw() - { - return( m_psz ); - } - -public: - LPCWSTR m_psz; - -private: - CW2CWEX( const CW2CWEX& ) throw(); - CW2CWEX& operator=( const CW2CWEX& ) throw(); -}; -typedef CW2CWEX<> CW2CW; - -template< int t_nBufferLength = 128 > -class CA2WEX -{ -public: - CA2WEX( __in_opt LPCSTR psz ) throw(...) : - m_psz( m_szBuffer ) - { - Init( psz, _AtlGetConversionACP() ); - } - CA2WEX( __in_opt LPCSTR psz, UINT nCodePage ) throw(...) : - m_psz( m_szBuffer ) - { - Init( psz, nCodePage ); - } - ~CA2WEX() throw() - { - AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); - } - - operator LPWSTR() const throw() - { - return( m_psz ); - } - -private: - void Init( __in_opt LPCSTR psz, UINT nCodePage ) throw(...) - { - if (psz == NULL) - { - m_psz = NULL; - return; - } - int nLengthA = lstrlenA( psz )+1; - int nLengthW = nLengthA; - - AtlConvAllocMemory(&m_psz,nLengthW,m_szBuffer,t_nBufferLength); - - BOOL bFailed=(0 == ::MultiByteToWideChar( nCodePage, 0, psz, nLengthA, m_psz, nLengthW ) ); - if (bFailed) - { - if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) - { - nLengthW = ::MultiByteToWideChar( nCodePage, 0, psz, nLengthA, NULL, 0); - AtlConvAllocMemory(&m_psz,nLengthW,m_szBuffer,t_nBufferLength); - bFailed=(0 == ::MultiByteToWideChar( nCodePage, 0, psz, nLengthA, m_psz, nLengthW ) ); - } - } - if (bFailed) - { - AtlThrowLastWin32(); - } - } - -public: - LPWSTR m_psz; - wchar_t m_szBuffer[t_nBufferLength]; - -private: - CA2WEX( const CA2WEX& ) throw(); - CA2WEX& operator=( const CA2WEX& ) throw(); -}; -typedef CA2WEX<> CA2W; - -template< int t_nBufferLength = 128 > -class CW2AEX -{ -public: - CW2AEX( __in_opt LPCWSTR psz ) throw(...) : - m_psz( m_szBuffer ) - { - Init( psz, _AtlGetConversionACP() ); - } - CW2AEX( __in_opt LPCWSTR psz, UINT nCodePage ) throw(...) : - m_psz( m_szBuffer ) - { - Init( psz, nCodePage ); - } - ~CW2AEX() throw() - { - AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); - } - - operator LPSTR() const throw() - { - return( m_psz ); - } - -private: - void Init( __in_opt LPCWSTR psz, __in UINT nConvertCodePage ) throw(...) - { - if (psz == NULL) - { - m_psz = NULL; - return; - } - int nLengthW = lstrlenW( psz )+1; - int nLengthA = nLengthW*4; - - AtlConvAllocMemory(&m_psz,nLengthA,m_szBuffer,t_nBufferLength); - - BOOL bFailed=(0 == ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, m_psz, nLengthA, NULL, NULL )); - if (bFailed) - { - if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) - { - nLengthA = ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, NULL, 0, NULL, NULL ); - AtlConvAllocMemory(&m_psz,nLengthA,m_szBuffer,t_nBufferLength); - bFailed=(0 == ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, m_psz, nLengthA, NULL, NULL )); - } - } - if (bFailed) - { - AtlThrowLastWin32(); - } - } - -public: - LPSTR m_psz; - char m_szBuffer[t_nBufferLength]; - -private: - CW2AEX( const CW2AEX& ) throw(); - CW2AEX& operator=( const CW2AEX& ) throw(); -}; -typedef CW2AEX<> CW2A; - -#ifdef _UNICODE - - #define CW2T CW2W - #define CW2TEX CW2WEX - #define CW2CT CW2CW - #define CW2CTEX CW2CWEX - #define CT2W CW2W - #define CT2WEX CW2WEX - #define CT2CW CW2CW - #define CT2CWEX CW2CWEX - - #define CA2T CA2W - #define CA2TEX CA2WEX - #define CA2CT CA2W - #define CA2CTEX CA2WEX - #define CT2A CW2A - #define CT2AEX CW2AEX - #define CT2CA CW2A - #define CT2CAEX CW2AEX - -#else // !_UNICODE - - #define CW2T CW2A - #define CW2TEX CW2AEX - #define CW2CT CW2A - #define CW2CTEX CW2AEX - #define CT2W CA2W - #define CT2WEX CA2WEX - #define CT2CW CA2W - #define CT2CWEX CA2WEX - - #define CA2T CA2A - #define CA2TEX CA2AEX - #define CA2CT CA2CA - #define CA2CTEX CA2CAEX - #define CT2A CA2A - #define CT2AEX CA2AEX - #define CT2CA CA2CA - #define CT2CAEX CA2CAEX - -#endif // !_UNICODE - -#define COLE2T CW2T -#define COLE2TEX CW2TEX -#define COLE2CT CW2CT -#define COLE2CTEX CW2CTEX -#define CT2OLE CT2W -#define CT2OLEEX CT2WEX -#define CT2COLE CT2CW -#define CT2COLEEX CT2CWEX - -}; // namespace ATL -#pragma pack(pop) - -#pragma pack(push,8) - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - -#ifndef _DEBUG - #define USES_CONVERSION int _convert; (_convert); UINT _acp = ATL::_AtlGetConversionACP() /*CP_THREAD_ACP*/; (_acp); LPCWSTR _lpw; (_lpw); LPCSTR _lpa; (_lpa) -#else - #define USES_CONVERSION int _convert = 0; (_convert); UINT _acp = ATL::_AtlGetConversionACP() /*CP_THREAD_ACP*/; (_acp); LPCWSTR _lpw = NULL; (_lpw); LPCSTR _lpa = NULL; (_lpa) -#endif - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#ifndef _DEBUG - #define USES_CONVERSION_EX int _convert_ex; (_convert_ex); UINT _acp_ex = ATL::_AtlGetConversionACP(); (_acp_ex); LPCWSTR _lpw_ex; (_lpw_ex); LPCSTR _lpa_ex; (_lpa_ex); USES_ATL_SAFE_ALLOCA -#else - #define USES_CONVERSION_EX int _convert_ex = 0; (_convert_ex); UINT _acp_ex = ATL::_AtlGetConversionACP(); (_acp_ex); LPCWSTR _lpw_ex = NULL; (_lpw_ex); LPCSTR _lpa_ex = NULL; (_lpa_ex); USES_ATL_SAFE_ALLOCA -#endif - -#ifdef _WINGDI_ - ATLAPI_(LPDEVMODEA) AtlDevModeW2A(__out LPDEVMODEA lpDevModeA, __in const DEVMODEW* lpDevModeW); -#endif - -///////////////////////////////////////////////////////////////////////////// -// Global UNICODE<>ANSI translation helpers -inline __out_ecount_z_opt(nChars) LPWSTR WINAPI AtlA2WHelper(__out_ecount_z(nChars) LPWSTR lpw, __in_z LPCSTR lpa, __in int nChars, __in UINT acp) throw() -{ - ATLASSERT(lpa != NULL); - ATLASSERT(lpw != NULL); - if (lpw == NULL || lpa == NULL) - return NULL; - // verify that no illegal character present - // since lpw was allocated based on the size of lpa - // don't worry about the number of chars - lpw[0] = '\0'; - int ret = MultiByteToWideChar(acp, 0, lpa, -1, lpw, nChars); - if(ret == 0) - { - ATLASSERT(FALSE); - return NULL; - } - return lpw; -} - -inline __out_ecount_z_opt(nChars) LPSTR WINAPI AtlW2AHelper(__out_ecount_z(nChars) LPSTR lpa, __in_z LPCWSTR lpw, __in int nChars, __in UINT acp) throw() -{ - ATLASSERT(lpw != NULL); - ATLASSERT(lpa != NULL); - if (lpa == NULL || lpw == NULL) - return NULL; - // verify that no illegal character present - // since lpa was allocated based on the size of lpw - // don't worry about the number of chars - lpa[0] = '\0'; - int ret = WideCharToMultiByte(acp, 0, lpw, -1, lpa, nChars, NULL, NULL); - if(ret == 0) - { - ATLASSERT(FALSE); - return NULL; - } - return lpa; -} -inline __out_ecount_z_opt(nChars) LPWSTR WINAPI AtlA2WHelper(__out_ecount_z(nChars) LPWSTR lpw, __in_z LPCSTR lpa, __in int nChars) throw() -{ - return AtlA2WHelper(lpw, lpa, nChars, CP_ACP); -} - -inline __out_ecount_z_opt(nChars) LPSTR WINAPI AtlW2AHelper(__out_ecount_z(nChars) LPSTR lpa, __in_z LPCWSTR lpw, __in int nChars) throw() -{ - return AtlW2AHelper(lpa, lpw, nChars, CP_ACP); -} - -#ifndef _CONVERSION_DONT_USE_THREAD_LOCALE - #ifdef ATLA2WHELPER - #undef ATLA2WHELPER - #undef ATLW2AHELPER - #endif - #define ATLA2WHELPER AtlA2WHelper - #define ATLW2AHELPER AtlW2AHelper -#else - #ifndef ATLA2WHELPER - #define ATLA2WHELPER AtlA2WHelper - #define ATLW2AHELPER AtlW2AHelper - #endif -#endif - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - -#define A2W(lpa) (\ - ((_lpa = lpa) == NULL) ? NULL : (\ - _convert = (lstrlenA(_lpa)+1),\ - (INT_MAX/2<_convert)? NULL : \ - ATLA2WHELPER((LPWSTR) alloca(_convert*sizeof(WCHAR)), _lpa, _convert, _acp))) - -#define W2A(lpw) (\ - ((_lpw = lpw) == NULL) ? NULL : (\ - (_convert = (lstrlenW(_lpw)+1), \ - (_convert>INT_MAX/2) ? NULL : \ - ATLW2AHELPER((LPSTR) alloca(_convert*sizeof(WCHAR)), _lpw, _convert*sizeof(WCHAR), _acp)))) - -#define A2W_CP(lpa, cp) (\ - ((_lpa = lpa) == NULL) ? NULL : (\ - _convert = (lstrlenA(_lpa)+1),\ - (INT_MAX/2<_convert)? NULL : \ - ATLA2WHELPER((LPWSTR) alloca(_convert*sizeof(WCHAR)), _lpa, _convert, (cp)))) - -#define W2A_CP(lpw, cp) (\ - ((_lpw = lpw) == NULL) ? NULL : (\ - (_convert = (lstrlenW(_lpw)+1), \ - (_convert>INT_MAX/2) ? NULL : \ - ATLW2AHELPER((LPSTR) alloca(_convert*sizeof(WCHAR)), _lpw, _convert*sizeof(WCHAR), (cp))))) - -#endif - -// The call to _alloca will not cause stack overflow if _AtlVerifyStackAvailable returns TRUE. -// Notice that nChars is never used in these conversion functions. We cannot change the behavior of -// these functions to actually use nChars because we could potentially break a lot of legacy code. -#define A2W_EX(lpa, nChars) (\ - ((_lpa_ex = lpa) == NULL) ? NULL : (\ - _convert_ex = (lstrlenA(_lpa_ex)+1),\ - FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ - ATLA2WHELPER( \ - (LPWSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ - _lpa_ex, \ - _convert_ex / sizeof(WCHAR), \ - _acp_ex))) - -#define A2W_EX_DEF(lpa) A2W_EX(lpa, _ATL_SAFE_ALLOCA_DEF_THRESHOLD) - -#define W2A_EX(lpw, nChars) (\ - ((_lpw_ex = lpw) == NULL) ? NULL : (\ - _convert_ex = (lstrlenW(_lpw_ex)+1),\ - FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ - ATLW2AHELPER( \ - (LPSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ - _lpw_ex, \ - _convert_ex, \ - _acp_ex))) - -#define W2A_EX_DEF(lpa) W2A_EX(lpa, _ATL_SAFE_ALLOCA_DEF_THRESHOLD) - -#define A2W_CP_EX(lpa, nChars, cp) (\ - ((_lpa_ex = lpa) == NULL) ? NULL : (\ - _convert_ex = (lstrlenA(_lpa_ex)+1),\ - FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ - ATLA2WHELPER( \ - (LPWSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ - _lpa_ex, \ - _convert_ex / sizeof(WCHAR), \ - (cp)))) - -#define W2A_CP_EX(lpw, nChars, cp) (\ - ((_lpw_ex = lpw) == NULL) ? NULL : (\ - _convert_ex = (lstrlenW(_lpw_ex)+1),\ - FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ - ATLW2AHELPER( \ - (LPSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ - _lpw_ex, \ - _convert_ex, \ - (cp)))) - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - -#define A2CW(lpa) ((LPCWSTR)A2W(lpa)) -#define W2CA(lpw) ((LPCSTR)W2A(lpw)) - -#define A2CW_CP(lpa, cp) ((LPCWSTR)A2W_CP(lpa, (cp))) -#define W2CA_CP(lpw, cp) ((LPCSTR)W2A_CP(lpw, (cp))) - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#define A2CW_EX(lpa, nChar) ((LPCWSTR)A2W_EX(lpa, nChar)) -#define A2CW_EX_DEF(lpa) ((LPCWSTR)A2W_EX_DEF(lpa)) -#define W2CA_EX(lpw, nChar) ((LPCSTR)W2A_EX(lpw, nChar)) -#define W2CA_EX_DEF(lpw) ((LPCSTR)W2A_EX_DEF(lpw)) - -#define A2CW_CP_EX(lpa, nChar, cp) ((LPCWSTR)A2W_CP_EX(lpa, nChar, (cp))) -#define W2CA_CP_EX(lpw, nChar, cp) ((LPCSTR)W2A_CP_EX(lpw, nChar, (cp))) - - inline int ocslen(__in_z LPCOLESTR x) throw() { return lstrlenW(x); } - -#if _SECURE_ATL - inline bool ocscpy_s(__out_ecount_z(maxSize) LPOLESTR dest, __in size_t maxSize, __in_z LPCOLESTR src) throw() - { return 0 == memcpy_s(dest, maxSize*sizeof(WCHAR), src, (ocslen(src)+1)*sizeof(WCHAR)); } - inline bool ocscat_s(__out_ecount_z(maxSize) LPOLESTR dest, __in size_t maxSize, __in_z LPCOLESTR src) throw() - { return 0 == wcscat_s(dest, maxSize,src); } -#else - inline bool ocscpy_s(__out_ecount_z(maxSize) LPOLESTR dest, __in size_t maxSize, __in_z LPCOLESTR src) throw() - { (void)maxSize; memcpy(dest, src, (ocslen(src)+1)*sizeof(WCHAR)); return true; } - inline bool ocscat_s(__out_ecount_z(maxSize) LPOLESTR dest, __in size_t maxSize, __in_z LPCOLESTR src) throw() - { (void)maxSize; wcscat(dest, src); } -#endif - -#if defined(_UNICODE) - -// in these cases the default (TCHAR) is the same as OLECHAR - -#if _SECURE_ATL - _ATL_INSECURE_DEPRECATE("ocscpy is not safe. Intead, use ocscpy_s") - inline OLECHAR* ocscpy(__out_z LPOLESTR dest, __in_z LPCOLESTR src) throw() - { -#pragma warning(push) -#pragma warning(disable:4995) // use of deprecated function -#pragma warning(disable:4996) -#pragma warning(disable:28719) // use of Banned API - return wcscpy(dest, src); -#pragma warning(pop) - } - _ATL_INSECURE_DEPRECATE("ocscat is not safe. Intead, use ocscat_s") - inline OLECHAR* ocscat(__out_z LPOLESTR dest, __in_z LPCOLESTR src) throw() - { -#pragma warning(push) -#pragma warning(disable:4995) // use of deprecated function -#pragma warning(disable:4996) -#pragma warning(disable:28719) // use of Banned API - return wcscat(dest, src); -#pragma warning(pop) - } -#else -#pragma warning(push) -#pragma warning(disable:4995) // use of deprecated function - inline OLECHAR* ocscpy(__out_z LPOLESTR dest, __in_z LPCOLESTR src) throw() { return lstrcpyW(dest, src); } - inline OLECHAR* ocscat(__out_z LPOLESTR dest, __in_z LPCOLESTR src) throw() { return lstrcatW(dest, src); } -#pragma warning(pop) -#endif - - inline LPCOLESTR T2COLE_EX(__in_opt LPCTSTR lp, UINT) { return lp; } - inline LPCOLESTR T2COLE_EX_DEF(__in_opt LPCTSTR lp) { return lp; } - inline LPCTSTR OLE2CT_EX(__in_opt LPCOLESTR lp, UINT) { return lp; } - inline LPCTSTR OLE2CT_EX_DEF(__in_opt LPCOLESTR lp) { return lp; } - inline LPOLESTR T2OLE_EX(__in_opt LPTSTR lp, UINT) { return lp; } - inline LPOLESTR T2OLE_EX_DEF(__in_opt LPTSTR lp) { return lp; } - inline LPTSTR OLE2T_EX(__in_opt LPOLESTR lp, UINT) { return lp; } - inline LPTSTR OLE2T_EX_DEF(__in_opt LPOLESTR lp) { return lp; } - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - - inline LPCOLESTR T2COLE(__in_opt LPCTSTR lp) { return lp; } - inline LPCTSTR OLE2CT(__in_opt LPCOLESTR lp) { return lp; } - inline LPOLESTR T2OLE(__in_opt LPTSTR lp) { return lp; } - inline LPTSTR OLE2T(__in_opt LPOLESTR lp) { return lp; } - inline LPOLESTR CharNextO(__in LPCOLESTR lp) throw() {return CharNextW(lp);} - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#else // !defined(_UNICODE) - -#if _SECURE_ATL - - _ATL_INSECURE_DEPRECATE("ocscpy is not safe. Intead, use ocscpy_s") - inline OLECHAR* ocscpy(__out_z LPOLESTR dest, __in_z LPCOLESTR src) throw() - { -#pragma warning(push) -#pragma warning(disable:4995) // use of deprecated function -#pragma warning(disable:4996) - return (LPOLESTR) memcpy(dest, src, (lstrlenW(src)+1)*sizeof(WCHAR)); -#pragma warning(pop) - } - _ATL_INSECURE_DEPRECATE("ocscat is not safe. Intead, use ocscat_s") - inline OLECHAR* ocscat(__inout_z LPOLESTR dest, __in_z LPCOLESTR src) throw() - { -#pragma warning(push) -#pragma warning(disable:4995) // use of deprecated function -#pragma warning(disable:4996) - return ocscpy(dest+ocslen(dest), src); -#pragma warning(pop) - } - -#else - - //lstrcpyW doesn't work on Win95, so we do this - inline OLECHAR* ocscpy(__out_z LPOLESTR dest, __in_z LPCOLESTR src) throw() - { - return (LPOLESTR) memcpy(dest, src, (lstrlenW(src)+1)*sizeof(WCHAR)); - } - inline OLECHAR* ocscat(__out_z LPOLESTR dest, __in_z LPCOLESTR src) throw() - { - return ocscpy(dest+ocslen(dest), src); - } - -#endif - - //CharNextW doesn't work on Win95 so we use this - #define T2COLE_EX(lpa, nChar) A2CW_EX(lpa, nChar) - #define T2COLE_EX_DEF(lpa) A2CW_EX_DEF(lpa) - #define T2OLE_EX(lpa, nChar) A2W_EX(lpa, nChar) - #define T2OLE_EX_DEF(lpa) A2W_EX_DEF(lpa) - #define OLE2CT_EX(lpo, nChar) W2CA_EX(lpo, nChar) - #define OLE2CT_EX_DEF(lpo) W2CA_EX_DEF(lpo) - #define OLE2T_EX(lpo, nChar) W2A_EX(lpo, nChar) - #define OLE2T_EX_DEF(lpo) W2A_EX_DEF(lpo) - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - - #define T2COLE(lpa) A2CW(lpa) - #define T2OLE(lpa) A2W(lpa) - #define OLE2CT(lpo) W2CA(lpo) - #define OLE2T(lpo) W2A(lpo) - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - - inline LPOLESTR CharNextO(LPCOLESTR lp) throw() {return (LPOLESTR) ((*lp) ? (lp+1) : lp);} - -#endif // defined(_UNICODE) - - inline LPOLESTR W2OLE_EX(__in_opt LPWSTR lp, UINT) { return lp; } - inline LPOLESTR W2OLE_EX_DEF(__in_opt LPWSTR lp) { return lp; } - inline LPWSTR OLE2W_EX(__in_opt LPOLESTR lp, UINT) { return lp; } - inline LPWSTR OLE2W_EX_DEF(__in_opt LPOLESTR lp) { return lp; } - #define A2OLE_EX A2W_EX - #define A2OLE_EX_DEF A2W_EX_DEF - #define OLE2A_EX W2A_EX - #define OLE2A_EX_DEF W2A_EX_DEF - inline LPCOLESTR W2COLE_EX(__in_opt LPCWSTR lp, UINT) { return lp; } - inline LPCOLESTR W2COLE_EX_DEF(__in_opt LPCWSTR lp) { return lp; } - inline LPCWSTR OLE2CW_EX(__in_opt LPCOLESTR lp, UINT) { return lp; } - inline LPCWSTR OLE2CW_EX_DEF(__in_opt LPCOLESTR lp) { return lp; } - #define A2COLE_EX A2CW_EX - #define A2COLE_EX_DEF A2CW_EX_DEF - #define OLE2CA_EX W2CA_EX - #define OLE2CA_EX_DEF W2CA_EX_DEF - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - - inline LPOLESTR W2OLE(__in_opt LPWSTR lp) { return lp; } - inline LPWSTR OLE2W(__in_opt LPOLESTR lp) { return lp; } - #define A2OLE A2W - #define OLE2A W2A - inline LPCOLESTR W2COLE(__in_opt LPCWSTR lp) { return lp; } - inline LPCWSTR OLE2CW(__in_opt LPCOLESTR lp) { return lp; } - #define A2COLE A2CW - #define OLE2CA W2CA - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#if defined(_UNICODE) - - #define T2A_EX W2A_EX - #define T2A_EX_DEF W2A_EX_DEF - #define A2T_EX A2W_EX - #define A2T_EX_DEF A2W_EX_DEF - inline LPWSTR T2W_EX(__in_opt LPTSTR lp, UINT) { return lp; } - inline LPWSTR T2W_EX_DEF(__in_opt LPTSTR lp) { return lp; } - inline LPTSTR W2T_EX(__in_opt LPWSTR lp, UINT) { return lp; } - inline LPTSTR W2T_DEF(__in_opt LPWSTR lp) { return lp; } - #define T2CA_EX W2CA_EX - #define T2CA_EX_DEF W2CA_EX_DEF - #define A2CT_EX A2CW_EX - #define A2CT_EX_DEF A2CW_EX_DEF - inline LPCWSTR T2CW_EX(__in_opt LPCTSTR lp, UINT) { return lp; } - inline LPCWSTR T2CW_EX_DEF(__in_opt LPCTSTR lp) { return lp; } - inline LPCTSTR W2CT_EX(__in_opt LPCWSTR lp, UINT) { return lp; } - inline LPCTSTR W2CT_EX_DEF(__in_opt LPCWSTR lp) { return lp; } - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - - #define T2A W2A - #define A2T A2W - inline LPWSTR T2W(__in_opt LPTSTR lp) { return lp; } - inline LPTSTR W2T(__in_opt LPWSTR lp) { return lp; } - #define T2CA W2CA - #define A2CT A2CW - inline LPCWSTR T2CW(__in_opt LPCTSTR lp) { return lp; } - inline LPCTSTR W2CT(__in_opt LPCWSTR lp) { return lp; } - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#else // !defined(_UNICODE) - - #define T2W_EX A2W_EX - #define T2W_EX_DEF A2W_EX_DEF - #define W2T_EX W2A_EX - #define W2T_EX_DEF W2A_EX_DEF - inline LPSTR T2A_EX(__in_opt LPTSTR lp, UINT) { return lp; } - inline LPSTR T2A_EX_DEF(__in_opt LPTSTR lp) { return lp; } - inline LPTSTR A2T_EX(__in_opt LPSTR lp, UINT) { return lp; } - inline LPTSTR A2T_EX_DEF(__in_opt LPSTR lp) { return lp; } - #define T2CW_EX A2CW_EX - #define T2CW_EX_DEF A2CW_EX_DEF - #define W2CT_EX W2CA_EX - #define W2CT_EX_DEF W2CA_EX_DEF - inline LPCSTR T2CA_EX(__in_opt LPCTSTR lp, UINT) { return lp; } - inline LPCSTR T2CA_EX_DEF(__in_opt LPCTSTR lp) { return lp; } - inline LPCTSTR A2CT_EX(__in_opt LPCSTR lp, UINT) { return lp; } - inline LPCTSTR A2CT_EX_DEF(__in_opt LPCSTR lp) { return lp; } - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - - #define T2W A2W - #define W2T W2A - inline LPSTR T2A(__in_opt LPTSTR lp) { return lp; } - inline LPTSTR A2T(__in_opt LPSTR lp) { return lp; } - #define T2CW A2CW - #define W2CT W2CA - inline LPCSTR T2CA(__in_opt LPCTSTR lp) { return lp; } - inline LPCTSTR A2CT(__in_opt LPCSTR lp) { return lp; } - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#endif // defined(_UNICODE) - -inline __checkReturn BSTR A2WBSTR(__in_opt LPCSTR lp, int nLen = -1) -{ - if (lp == NULL || nLen == 0) - return NULL; - USES_CONVERSION_EX; - BSTR str = NULL; - int nConvertedLen = MultiByteToWideChar(_acp_ex, 0, lp, - nLen, NULL, NULL); - int nAllocLen = nConvertedLen; - if (nLen == -1) - nAllocLen -= 1; // Don't allocate terminating '\0' - str = ::SysAllocStringLen(NULL, nAllocLen); - - if (str != NULL) - { - int nResult; - nResult = MultiByteToWideChar(_acp_ex, 0, lp, nLen, str, nConvertedLen); - ATLASSERT(nResult == nConvertedLen); - if(nResult != nConvertedLen) - { - SysFreeString(str); - return NULL; - } - - } - return str; -} - -inline BSTR OLE2BSTR(__in_opt LPCOLESTR lp) {return ::SysAllocString(lp);} -#if defined(_UNICODE) -// in these cases the default (TCHAR) is the same as OLECHAR - inline BSTR T2BSTR_EX(__in_opt LPCTSTR lp) {return ::SysAllocString(lp);} - inline BSTR A2BSTR_EX(__in_opt LPCSTR lp) {return A2WBSTR(lp);} - inline BSTR W2BSTR_EX(__in_opt LPCWSTR lp) {return ::SysAllocString(lp);} - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - - inline BSTR T2BSTR(__in_opt LPCTSTR lp) {return ::SysAllocString(lp);} - inline BSTR A2BSTR(__in_opt LPCSTR lp) {return A2WBSTR(lp);} - inline BSTR W2BSTR(__in_opt LPCWSTR lp) {return ::SysAllocString(lp);} - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#else // !defined(_UNICODE) - inline BSTR T2BSTR_EX(__in_opt LPCTSTR lp) {return A2WBSTR(lp);} - inline BSTR A2BSTR_EX(__in_opt LPCSTR lp) {return A2WBSTR(lp);} - inline BSTR W2BSTR_EX(__in_opt LPCWSTR lp) {return ::SysAllocString(lp);} - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - - inline BSTR T2BSTR(__in_opt LPCTSTR lp) {return A2WBSTR(lp);} - inline BSTR A2BSTR(__in_opt LPCSTR lp) {return A2WBSTR(lp);} - inline BSTR W2BSTR(__in_opt LPCWSTR lp) {return ::SysAllocString(lp);} - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#endif // defined(_UNICODE) - -#ifdef _WINGDI_ -///////////////////////////////////////////////////////////////////////////// -// Global UNICODE<>ANSI translation helpers -inline LPDEVMODEW AtlDevModeA2W(__out LPDEVMODEW lpDevModeW, __in const DEVMODEA* lpDevModeA) -{ - USES_CONVERSION_EX; - ATLASSERT(lpDevModeW != NULL); - if (lpDevModeA == NULL || lpDevModeW == NULL) - { - return NULL; - } - - AtlA2WHelper(lpDevModeW->dmDeviceName, (LPCSTR)lpDevModeA->dmDeviceName, 32, _acp_ex); - -#if _SECURE_ATL - if(0 != memcpy_s(&lpDevModeW->dmSpecVersion, offsetof(DEVMODEW, dmFormName) - offsetof(DEVMODEW, dmSpecVersion), - &lpDevModeA->dmSpecVersion, offsetof(DEVMODEW, dmFormName) - offsetof(DEVMODEW, dmSpecVersion))) - { - return NULL; - } -#else - memcpy(&lpDevModeW->dmSpecVersion, &lpDevModeA->dmSpecVersion, - offsetof(DEVMODEW, dmFormName) - offsetof(DEVMODEW, dmSpecVersion)); -#endif - - AtlA2WHelper(lpDevModeW->dmFormName, (LPCSTR)lpDevModeA->dmFormName, 32, _acp_ex); - -#if _SECURE_ATL - if(0 != memcpy_s(&lpDevModeW->dmLogPixels, sizeof(DEVMODEW) - offsetof(DEVMODEW, dmLogPixels), - &lpDevModeA->dmLogPixels, sizeof(DEVMODEW) - offsetof(DEVMODEW, dmLogPixels))) - { - return NULL; - } -#else - memcpy(&lpDevModeW->dmLogPixels, &lpDevModeA->dmLogPixels, - sizeof(DEVMODEW) - offsetof(DEVMODEW, dmLogPixels)); -#endif - - if (lpDevModeA->dmDriverExtra != 0) - { - // lpDevModeW holds more info -#pragma warning(push) -// -// [pfx_parse] - workaround for PREfix parse problem -// -#if ((defined(_PREFIX_)) || (defined(_PREFAST_))) && (_MSC_VER < 1400) - // do nothing, this pragma not understood by PREfix 5.1 -#else // !_PREFIX_ -#pragma warning(disable:26000) -#endif -#if _SECURE_ATL - if(0 != memcpy_s(lpDevModeW+1, lpDevModeA->dmDriverExtra, lpDevModeA+1, lpDevModeA->dmDriverExtra)) - { - return NULL; - } -#else - memcpy(lpDevModeW+1, lpDevModeA+1, lpDevModeA->dmDriverExtra); -#endif -#pragma warning(pop) - } - lpDevModeW->dmSize = sizeof(DEVMODEW); - return lpDevModeW; -} - -inline LPTEXTMETRICW AtlTextMetricA2W(__out LPTEXTMETRICW lptmW, __in LPTEXTMETRICA lptmA) -{ - USES_CONVERSION_EX; - ATLASSERT(lptmW != NULL); - if (lptmA == NULL || lptmW == NULL) - return NULL; - -#if _SECURE_ATL - if(0 != memcpy_s(lptmW, sizeof(LONG) * 11, lptmA, sizeof(LONG) * 11)) - { - return NULL; - } -#else - memcpy(lptmW, lptmA, sizeof(LONG) * 11); -#endif - -#if _SECURE_ATL - if(0 != memcpy_s(&lptmW->tmItalic, sizeof(BYTE) * 5, &lptmA->tmItalic, sizeof(BYTE) * 5)) - { - return NULL; - } -#else - memcpy(&lptmW->tmItalic, &lptmA->tmItalic, sizeof(BYTE) * 5); -#endif - - if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmFirstChar, 1, &lptmW->tmFirstChar, 1) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmLastChar, 1, &lptmW->tmLastChar, 1) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmDefaultChar, 1, &lptmW->tmDefaultChar, 1)== 0) - { - ATLASSERT(FALSE); - return NULL; - } - - if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmBreakChar, 1, &lptmW->tmBreakChar, 1) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - return lptmW; -} - -inline LPTEXTMETRICA AtlTextMetricW2A(__out LPTEXTMETRICA lptmA, __in LPTEXTMETRICW lptmW) -{ - USES_CONVERSION_EX; - ATLASSERT(lptmA != NULL); - if (lptmW == NULL || lptmA == NULL) - { - return NULL; - } - -#if _SECURE_ATL - if(0 != memcpy_s(lptmA, sizeof(LONG) * 11, lptmW, sizeof(LONG) * 11)) - { - return NULL; - } -#else - memcpy(lptmA, lptmW, sizeof(LONG) * 11); -#endif - -#if _SECURE_ATL - if(0 != memcpy_s(&lptmA->tmItalic, sizeof(BYTE) * 5, &lptmW->tmItalic, sizeof(BYTE) * 5)) - { - return NULL; - } -#else - memcpy(&lptmA->tmItalic, &lptmW->tmItalic, sizeof(BYTE) * 5); -#endif - - if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmFirstChar, 1, (LPSTR)&lptmA->tmFirstChar, 1, NULL, NULL) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmLastChar, 1, (LPSTR)&lptmA->tmLastChar, 1, NULL, NULL) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmDefaultChar, 1, (LPSTR)&lptmA->tmDefaultChar, 1, NULL, NULL) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmBreakChar, 1, (LPSTR)&lptmA->tmBreakChar, 1, NULL, NULL) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - return lptmA; -} - -#ifndef ATLDEVMODEA2W -#define ATLDEVMODEA2W AtlDevModeA2W -#define ATLDEVMODEW2A AtlDevModeW2A -#define ATLTEXTMETRICA2W AtlTextMetricA2W -#define ATLTEXTMETRICW2A AtlTextMetricW2A -#endif - -// Requires USES_CONVERSION_EX or USES_ATL_SAFE_ALLOCA macro before using the _EX versions of the macros -#define DEVMODEW2A_EX(lpw)\ - (((lpw) == NULL) ? NULL : ATLDEVMODEW2A((LPDEVMODEA)_ATL_SAFE_ALLOCA(sizeof(DEVMODEA)+(lpw)->dmDriverExtra, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lpw))) -#define DEVMODEA2W_EX(lpa)\ - (((lpa) == NULL) ? NULL : ATLDEVMODEA2W((LPDEVMODEW)_ATL_SAFE_ALLOCA(sizeof(DEVMODEW)+(lpa)->dmDriverExtra, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lpa))) -#define TEXTMETRICW2A_EX(lptmw)\ - (((lptmw) == NULL) ? NULL : ATLTEXTMETRICW2A((LPTEXTMETRICA)_ATL_SAFE_ALLOCA(sizeof(TEXTMETRICA), _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lptmw))) -#define TEXTMETRICA2W_EX(lptma)\ - (((lptma) == NULL) ? NULL : ATLTEXTMETRICA2W((LPTEXTMETRICW)_ATL_SAFE_ALLOCA(sizeof(TEXTMETRICW), _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lptma))) - -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - -#define DEVMODEW2A(lpw)\ - ((lpw == NULL) ? NULL : ATLDEVMODEW2A((LPDEVMODEA)alloca(sizeof(DEVMODEA)+lpw->dmDriverExtra), lpw)) -#define DEVMODEA2W(lpa)\ - ((lpa == NULL) ? NULL : ATLDEVMODEA2W((LPDEVMODEW)alloca(sizeof(DEVMODEW)+lpa->dmDriverExtra), lpa)) -#define TEXTMETRICW2A(lptmw)\ - ((lptmw == NULL) ? NULL : ATLTEXTMETRICW2A((LPTEXTMETRICA)alloca(sizeof(TEXTMETRICA)), lptmw)) -#define TEXTMETRICA2W(lptma)\ - ((lptma == NULL) ? NULL : ATLTEXTMETRICA2W((LPTEXTMETRICW)alloca(sizeof(TEXTMETRICW)), lptma)) - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#define DEVMODEOLE DEVMODEW -#define LPDEVMODEOLE LPDEVMODEW -#define TEXTMETRICOLE TEXTMETRICW -#define LPTEXTMETRICOLE LPTEXTMETRICW - -#if defined(_UNICODE) -// in these cases the default (TCHAR) is the same as OLECHAR - inline LPDEVMODEW DEVMODEOLE2T_EX(LPDEVMODEOLE lp) { return lp; } - inline LPDEVMODEOLE DEVMODET2OLE_EX(LPDEVMODEW lp) { return lp; } - inline LPTEXTMETRICW TEXTMETRICOLE2T_EX(LPTEXTMETRICOLE lp) { return lp; } - inline LPTEXTMETRICOLE TEXTMETRICT2OLE_EX(LPTEXTMETRICW lp) { return lp; } -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - inline LPDEVMODEW DEVMODEOLE2T(LPDEVMODEOLE lp) { return lp; } - inline LPDEVMODEOLE DEVMODET2OLE(LPDEVMODEW lp) { return lp; } - inline LPTEXTMETRICW TEXTMETRICOLE2T(LPTEXTMETRICOLE lp) { return lp; } - inline LPTEXTMETRICOLE TEXTMETRICT2OLE(LPTEXTMETRICW lp) { return lp; } -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#else // !defined(_UNICODE) - #define DEVMODEOLE2T_EX(lpo) DEVMODEW2A_EX(lpo) - #define DEVMODET2OLE_EX(lpa) DEVMODEA2W_EX(lpa) - #define TEXTMETRICOLE2T_EX(lptmw) TEXTMETRICW2A_EX(lptmw) - #define TEXTMETRICT2OLE_EX(lptma) TEXTMETRICA2W_EX(lptma) -#ifndef _ATL_EX_CONVERSION_MACROS_ONLY - #define DEVMODEOLE2T(lpo) DEVMODEW2A(lpo) - #define DEVMODET2OLE(lpa) DEVMODEA2W(lpa) - #define TEXTMETRICOLE2T(lptmw) TEXTMETRICW2A(lptmw) - #define TEXTMETRICT2OLE(lptma) TEXTMETRICA2W(lptma) -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - -#endif // defined(_UNICODE) - -#endif //_WINGDI_ - -#pragma pack(pop) - -///////////////////////////////////////////////////////////////////////////// - -#ifndef _ATL_DLL - -#ifdef _WINGDI_ - -ATLINLINE ATLAPI_(LPDEVMODEA) AtlDevModeW2A(__out LPDEVMODEA lpDevModeA, __in const DEVMODEW* lpDevModeW) -{ - USES_CONVERSION_EX; - ATLASSERT(lpDevModeA != NULL); - if (lpDevModeW == NULL || lpDevModeA == NULL) - return NULL; - - AtlW2AHelper((LPSTR)lpDevModeA->dmDeviceName, lpDevModeW->dmDeviceName, 32, _acp_ex); - -#if _SECURE_ATL - if(0 != memcpy_s(&lpDevModeA->dmSpecVersion, offsetof(DEVMODEA, dmFormName) - offsetof(DEVMODEA, dmSpecVersion), - &lpDevModeW->dmSpecVersion, offsetof(DEVMODEA, dmFormName) - offsetof(DEVMODEA, dmSpecVersion))) - { - return NULL; - } -#else - memcpy(&lpDevModeA->dmSpecVersion, &lpDevModeW->dmSpecVersion, - offsetof(DEVMODEA, dmFormName) - offsetof(DEVMODEA, dmSpecVersion)); -#endif - - AtlW2AHelper((LPSTR)lpDevModeA->dmFormName, lpDevModeW->dmFormName, 32, _acp_ex); - -#if _SECURE_ATL - if(0 != memcpy_s(&lpDevModeA->dmLogPixels, sizeof(DEVMODEA) - offsetof(DEVMODEA, dmLogPixels), - &lpDevModeW->dmLogPixels, sizeof(DEVMODEA) - offsetof(DEVMODEA, dmLogPixels))) - { - return NULL; - } -#else - memcpy(&lpDevModeA->dmLogPixels, &lpDevModeW->dmLogPixels, - sizeof(DEVMODEA) - offsetof(DEVMODEA, dmLogPixels)); -#endif - - if (lpDevModeW->dmDriverExtra != 0) - { - // lpDevModeW holds more info -#pragma warning(push) -// -// [pfx_parse] - workaround for PREfix parse problem -// -#if ((defined(_PREFIX_)) || (defined(_PREFAST_))) && (_MSC_VER < 1400) - // do nothing, this pragma not understood by PREfix 5.1 -#else // !_PREFIX_ -#pragma warning(disable:26000) -#endif -#if _SECURE_ATL - if(0 != memcpy_s(lpDevModeA+1, lpDevModeW->dmDriverExtra, lpDevModeW+1, lpDevModeW->dmDriverExtra)) - { - return NULL; - } -#else - memcpy(lpDevModeA+1, lpDevModeW+1, lpDevModeW->dmDriverExtra); -#endif -#pragma warning(pop) - } - - lpDevModeA->dmSize = sizeof(DEVMODEA); - return lpDevModeA; -} - -#endif //_WINGDI - -#endif // !_ATL_DLL - -// -// [pfx_parse] - workaround for old PREfix/PREfast parser -// -#if (defined(_PREFIX_) || defined(_PREFAST_)) && (_MSC_VER < 1400) -#pragma warning (pop) -#endif // old PREfast parser - -#ifndef _ATL_NO_PRAGMA_WARNINGS -#pragma warning (pop) -#endif //!_ATL_NO_PRAGMA_WARNINGS - -#endif // __ATLCONV_H__ - diff --git a/cpp/jacob/include/atlcore.h b/cpp/jacob/include/atlcore.h deleted file mode 100644 index 2313070..0000000 --- a/cpp/jacob/include/atlcore.h +++ /dev/null @@ -1,554 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLCORE_H__ -#define __ATLCORE_H__ - -#pragma once - -#ifdef _ATL_ALL_WARNINGS -#pragma warning( push ) -#endif - -#pragma warning(disable: 4786) // identifier was truncated in the debug information -#pragma warning(disable: 4127) // constant expression - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ -///////////////////////////////////////////////////////////////////////////// -// Verify that a null-terminated string points to valid memory -inline BOOL AtlIsValidString(LPCWSTR psz, size_t nMaxLength = INT_MAX) -{ - (nMaxLength); - return (psz != NULL); -} - -// Verify that a null-terminated string points to valid memory -inline BOOL AtlIsValidString(LPCSTR psz, size_t nMaxLength = UINT_MAX) -{ - (nMaxLength); - return (psz != NULL); -} - -// Verify that a pointer points to valid memory -inline BOOL AtlIsValidAddress(const void* p, size_t nBytes, - BOOL bReadWrite = TRUE) -{ - (bReadWrite); - (nBytes); - return (p != NULL); -} - -template -inline void AtlAssertValidObject(const T *pOb) -{ - ATLASSERT(pOb); - ATLASSERT(AtlIsValidAddress(pOb, sizeof(T))); - if(pOb) - pOb->AssertValid(); -} -#ifdef _DEBUG -#define ATLASSERT_VALID(x) ATL::AtlAssertValidObject(x) -#else -#define ATLASSERT_VALID(x) __noop; -#endif - -// COM Sync Classes -class CComCriticalSection -{ -public: - CComCriticalSection() throw() - { - memset(&m_sec, 0, sizeof(CRITICAL_SECTION)); - } - ~CComCriticalSection() - { - } - HRESULT Lock() throw() - { - EnterCriticalSection(&m_sec); - return S_OK; - } - HRESULT Unlock() throw() - { - LeaveCriticalSection(&m_sec); - return S_OK; - } - HRESULT Init() throw() - { - HRESULT hRes = E_FAIL; - __try - { - InitializeCriticalSection(&m_sec); - hRes = S_OK; - } - // structured exception may be raised in low memory situations - __except(STATUS_NO_MEMORY == GetExceptionCode()) - { - hRes = E_OUTOFMEMORY; - } - return hRes; - } - - HRESULT Term() throw() - { - DeleteCriticalSection(&m_sec); - return S_OK; - } - CRITICAL_SECTION m_sec; -}; - -class CComAutoCriticalSection : public CComCriticalSection -{ -public: - CComAutoCriticalSection() - { - HRESULT hr = CComCriticalSection::Init(); - if (FAILED(hr)) - AtlThrow(hr); - } - ~CComAutoCriticalSection() throw() - { - CComCriticalSection::Term(); - } -private : - HRESULT Init(); // Not implemented. CComAutoCriticalSection::Init should never be called - HRESULT Term(); // Not implemented. CComAutoCriticalSection::Term should never be called -}; - -class CComSafeDeleteCriticalSection : public CComCriticalSection -{ -public: - CComSafeDeleteCriticalSection(): m_bInitialized(false) - { - } - - ~CComSafeDeleteCriticalSection() throw() - { - if (!m_bInitialized) - { - return; - } - m_bInitialized = false; - CComCriticalSection::Term(); - } - - HRESULT Init() throw() - { - ATLASSERT( !m_bInitialized ); - HRESULT hr = CComCriticalSection::Init(); - if (SUCCEEDED(hr)) - { - m_bInitialized = true; - } - return hr; - } - - HRESULT Term() throw() - { - if (!m_bInitialized) - { - return S_OK; - } - m_bInitialized = false; - return CComCriticalSection::Term(); - } - - HRESULT Lock() - { - // CComSafeDeleteCriticalSection::Init or CComAutoDeleteCriticalSection::Init - // not called or failed. - // m_critsec member of CComObjectRootEx is now of type - // CComAutoDeleteCriticalSection. It has to be initialized - // by calling CComObjectRootEx::_AtlInitialConstruct - ATLASSUME(m_bInitialized); - return CComCriticalSection::Lock(); - } - -private: - bool m_bInitialized; -}; - -class CComAutoDeleteCriticalSection : public CComSafeDeleteCriticalSection -{ -private: - // CComAutoDeleteCriticalSection::Term should never be called - HRESULT Term() throw(); -}; - -class CComFakeCriticalSection -{ -public: - HRESULT Lock() throw() { return S_OK; } - HRESULT Unlock() throw() { return S_OK; } - HRESULT Init() throw() { return S_OK; } - HRESULT Term() throw() { return S_OK; } -}; - -///////////////////////////////////////////////////////////////////////////// -// Module - -// Used by any project that uses ATL -struct _ATL_BASE_MODULE70 -{ - UINT cbSize; - HINSTANCE m_hInst; - HINSTANCE m_hInstResource; - bool m_bNT5orWin98; - DWORD dwAtlBuildVer; - const GUID* pguidVer; - CComCriticalSection m_csResource; - CSimpleArray m_rgResourceInstance; -}; -typedef _ATL_BASE_MODULE70 _ATL_BASE_MODULE; - -class CAtlBaseModule : public _ATL_BASE_MODULE -{ -public : - static bool m_bInitFailed; - CAtlBaseModule() throw(); - ~CAtlBaseModule() throw (); - - HINSTANCE GetModuleInstance() throw() - { - return m_hInst; - } - HINSTANCE GetResourceInstance() throw() - { - return m_hInstResource; - } - HINSTANCE SetResourceInstance(HINSTANCE hInst) throw() - { - return static_cast< HINSTANCE >(InterlockedExchangePointer((void**)&m_hInstResource, hInst)); - } - - bool AddResourceInstance(HINSTANCE hInst) throw(); - bool RemoveResourceInstance(HINSTANCE hInst) throw(); - HINSTANCE GetHInstanceAt(int i) throw(); -}; - -__declspec(selectany) bool CAtlBaseModule::m_bInitFailed = false; -extern CAtlBaseModule _AtlBaseModule; - -///////////////////////////////////////////////////////////////////////////// -// String resource helpers - -#pragma warning(push) -#pragma warning(disable: 4200) - struct ATLSTRINGRESOURCEIMAGE - { - WORD nLength; - __field_ecount(nLength) WCHAR achString[]; - }; -#pragma warning(pop) // C4200 - -inline const ATLSTRINGRESOURCEIMAGE* _AtlGetStringResourceImage( HINSTANCE hInstance, HRSRC hResource, UINT id ) throw() -{ - const ATLSTRINGRESOURCEIMAGE* pImage; - const ATLSTRINGRESOURCEIMAGE* pImageEnd; - ULONG nResourceSize; - HGLOBAL hGlobal; - UINT iIndex; - - hGlobal = ::LoadResource( hInstance, hResource ); - if( hGlobal == NULL ) - { - return( NULL ); - } - - pImage = (const ATLSTRINGRESOURCEIMAGE*)::LockResource( hGlobal ); - if( pImage == NULL ) - { - return( NULL ); - } - - nResourceSize = ::SizeofResource( hInstance, hResource ); - pImageEnd = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE( pImage )+nResourceSize); - iIndex = id&0x000f; - - while( (iIndex > 0) && (pImage < pImageEnd) ) - { - pImage = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE( pImage )+(sizeof( ATLSTRINGRESOURCEIMAGE )+(pImage->nLength*sizeof( WCHAR )))); - iIndex--; - } - if( pImage >= pImageEnd ) - { - return( NULL ); - } - if( pImage->nLength == 0 ) - { - return( NULL ); - } - - return( pImage ); -} - -inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage( HINSTANCE hInstance, UINT id ) throw() -{ - HRSRC hResource; - - hResource = ::FindResource( hInstance, MAKEINTRESOURCE( ((id>>4)+1) ), RT_STRING ); - if( hResource == NULL ) - { - return( NULL ); - } - - return _AtlGetStringResourceImage( hInstance, hResource, id ); -} - -inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage( HINSTANCE hInstance, UINT id, WORD wLanguage ) throw() -{ - HRSRC hResource; - - hResource = ::FindResourceEx( hInstance, RT_STRING, MAKEINTRESOURCE( ((id>>4)+1) ), wLanguage ); - if( hResource == NULL ) - { - return( NULL ); - } - - return _AtlGetStringResourceImage( hInstance, hResource, id ); -} - -inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage( UINT id ) throw() -{ - const ATLSTRINGRESOURCEIMAGE* p = NULL; - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - - for (int i = 1; hInst != NULL && p == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - p = AtlGetStringResourceImage(hInst, id); - } - return p; -} - -inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage( UINT id, WORD wLanguage ) throw() -{ - const ATLSTRINGRESOURCEIMAGE* p = NULL; - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - - for (int i = 1; hInst != NULL && p == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - p = AtlGetStringResourceImage(hInst, id, wLanguage); - } - return p; -} - -inline int AtlLoadString(__in UINT nID, __out_ecount_part_z(nBufferMax, return + 1) LPTSTR lpBuffer, __in int nBufferMax) throw() -{ - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - int nRet = 0; - - for (int i = 1; hInst != NULL && nRet == 0; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - nRet = LoadString(hInst, nID, lpBuffer, nBufferMax); - } - return nRet; -} - -inline HINSTANCE AtlFindResourceInstance(LPCTSTR lpName, LPCTSTR lpType, WORD wLanguage = 0) throw() -{ - ATLASSERT(lpType != RT_STRING); // Call AtlFindStringResourceInstance to find the string - if (lpType == RT_STRING) - return NULL; - - if (ATL_IS_INTRESOURCE(lpType)) - { - /* Prefast false warnings caused by bad-shaped definition of MAKEINTRESOURCE macro from PSDK */ - if (lpType == ATL_RT_ICON) - { - lpType = ATL_RT_GROUP_ICON; - } - else if (lpType == ATL_RT_CURSOR) - { - lpType = ATL_RT_GROUP_CURSOR; - } - } - - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - HRSRC hResource = NULL; - - for (int i = 1; hInst != NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - hResource = ::FindResourceEx(hInst, lpType, lpName, wLanguage); - if (hResource != NULL) - { - return hInst; - } - } - - return NULL; -} - -inline HINSTANCE AtlFindResourceInstance(UINT nID, LPCTSTR lpType, WORD wLanguage = 0) throw() -{ - return AtlFindResourceInstance(MAKEINTRESOURCE(nID), lpType, wLanguage); -} - -inline HINSTANCE AtlFindStringResourceInstance(UINT nID, WORD wLanguage = 0) throw() -{ - const ATLSTRINGRESOURCEIMAGE* p = NULL; - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - - for (int i = 1; hInst != NULL && p == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - p = AtlGetStringResourceImage(hInst, nID, wLanguage); - if (p != NULL) - return hInst; - } - - return NULL; -} - -/* -Needed by both atlcomcli and atlsafe, so needs to be in here -*/ -inline HRESULT AtlSafeArrayGetActualVartype -( - SAFEARRAY *psaArray, - VARTYPE *pvtType -) -{ - HRESULT hrSystem=::SafeArrayGetVartype(psaArray, pvtType); - - if(FAILED(hrSystem)) - { - return hrSystem; - } - - /* - When Windows has a SAFEARRAY of type VT_DISPATCH with FADF_HAVEIID, - it returns VT_UNKNOWN instead of VT_DISPATCH. We patch the value to be correct - */ - if(pvtType && *pvtType==VT_UNKNOWN) - { - if(psaArray && ((psaArray->fFeatures & FADF_HAVEIID)!=0)) - { - if(psaArray->fFeatures & FADF_DISPATCH) - { - *pvtType=VT_DISPATCH; - } - } - } - - return hrSystem; -} -template -inline _CharType* AtlCharNext(const _CharType* p) throw() -{ - ATLASSUME(p != NULL); // Too expensive to check separately here - if (*p == '\0') // ::CharNextA won't increment if we're at a \0 already - return const_cast<_CharType*>(p+1); - else - return ::CharNextA(p); -} - -template <> -inline wchar_t* AtlCharNext(const wchar_t* p) throw() -{ - return const_cast< wchar_t* >( p+1 ); -} -template -inline const CharType* AtlstrchrT(const CharType* p, CharType ch) throw() -{ - ATLASSERT(p != NULL); - if(p==NULL) - { - return NULL; - } - while( *p != 0 ) - { - if (*p == ch) - { - return p; - } - p = AtlCharNext(p); - } - //strchr for '\0' should succeed - the while loop terminates - //*p == 0, but ch also == 0, so NULL terminator address is returned - return (*p == ch) ? p : NULL; -} -//Ansi and Unicode versions of printf, used with templated CharType trait classes. -#pragma warning(push) -#pragma warning(disable : 4793) -template -inline int AtlprintfT(const CharType* pszFormat,... ) throw() -{ - int retval=0; - va_list argList; - va_start( argList, pszFormat ); - retval=vprintf(pszFormat,argList); - va_end( argList ); - return retval; -} -#pragma warning(pop) - -#pragma warning(push) -#pragma warning(disable : 4793) -template<> -inline int AtlprintfT(const wchar_t* pszFormat,... ) throw() -{ - int retval=0; - va_list argList; - va_start( argList, pszFormat ); - retval=vwprintf(pszFormat, argList); - va_end( argList ); - return retval; -} -#pragma warning(pop) - -#pragma warning(push) -#pragma warning(disable : 4068 28110) - -inline BOOL AtlConvertSystemTimeToVariantTime(const SYSTEMTIME& systimeSrc,double* pVarDtTm) -{ - ATLENSURE(pVarDtTm!=NULL); - //Convert using ::SystemTimeToVariantTime and store the result in pVarDtTm then - //convert variant time back to system time and compare to original system time. - - BOOL ok = ::SystemTimeToVariantTime(const_cast(&systimeSrc), pVarDtTm); - - SYSTEMTIME sysTime; - ::ZeroMemory(&sysTime, sizeof(SYSTEMTIME)); - - ok = ok && ::VariantTimeToSystemTime(*pVarDtTm, &sysTime); - ok = ok && (systimeSrc.wYear == sysTime.wYear && - systimeSrc.wMonth == sysTime.wMonth && - systimeSrc.wDay == sysTime.wDay && - systimeSrc.wHour == sysTime.wHour && - systimeSrc.wMinute == sysTime.wMinute && - systimeSrc.wSecond == sysTime.wSecond); - - return ok; -} -#pragma warning(pop) - -///////////////////////////////////////////////////////////////////////////// - -} // namespace ATL -#pragma pack(pop) - -#ifdef _ATL_ALL_WARNINGS -#pragma warning( pop ) -#endif - -#endif // __ATLCORE_H__ - diff --git a/cpp/jacob/include/atldef.h b/cpp/jacob/include/atldef.h deleted file mode 100644 index bfd2bce..0000000 --- a/cpp/jacob/include/atldef.h +++ /dev/null @@ -1,668 +0,0 @@ - -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLDEF_H__ -#define __ATLDEF_H__ - -#pragma once - -#pragma warning(disable : 4619) // there is no warning number - -#include -#include -#include - -#ifndef RC_INVOKED - -#ifndef __cplusplus - #error ATL requires C++ compilation (use a .cpp suffix) -#endif - -#ifdef UNDER_CE - #error This version of ATL is not currently supported for CE. Look for the CE specific version. -#endif - -// If you are mixing compilation units that are built as -// native code with those that are built /clr, you must define -// the symbol '_ATL_MIXED'. _ATL_MIXED must be defined for all -// compilation units in an executable or it must be defined for none of them. -#if !defined(_ATL_MIXED) -namespace Inconsistent_definition_of_symbol__ATL_MIXED -{ - struct _Please_define_it_the_same_throughout_your_project { }; -} -#else -namespace Inconsistent_definition_of_symbol__ATL_MIXED -{ -#ifdef _M_IX86 -#pragma comment(linker, "/include:??3@YAXPAX@Z") -#else -#pragma comment(linker, "/include:??3@YAXPEAX@Z") -#endif - struct _Please_define_it_the_same_throughout_your_project { virtual void one(){} }; -} -#endif -namespace Inconsistent_definition_of_symbol__ATL_MIXED -{ - __declspec(selectany) _Please_define_it_the_same_throughout_your_project clash = _Please_define_it_the_same_throughout_your_project (); -} - -#if !defined(_ATL_MIXED) -namespace Define_the_symbol__ATL_MIXED -{ -#if defined(_M_CEE) - struct Thank_you { }; -#else -#ifdef _M_IX86 -#pragma comment(linker, "/include:??3@YAXPAX@Z") -#else -#pragma comment(linker, "/include:??3@YAXPEAX@Z") -#endif - struct Thank_you { virtual void one(){} }; -#endif - __declspec(selectany) Thank_you clash = Thank_you(); -} -#endif - -#if defined(_ATL_MIXED) -#define _ATL_NATIVE_INITIALIZATION -#endif - -#if !defined(_M_CEE) -#define _ATL_NATIVE_INITIALIZATION -#endif - -#ifdef _UNICODE -#ifndef UNICODE -#define UNICODE // UNICODE is used by Windows headers -#endif -#endif - -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE // _UNICODE is used by C-runtime/MFC headers -#endif -#endif - -#ifdef _DEBUG -#ifndef DEBUG -#define DEBUG -#endif -#endif - -#ifdef _WIN64 -#define _ATL_SUPPORT_VT_I8 // Always support VT_I8 on Win64. -#endif - -#if !defined(UNALIGNED) -#if defined(_M_IA64) || defined(_M_AMD64) -#define UNALIGNED __unaligned -#else -#define UNALIGNED -#endif -#endif - -#if !defined(_countof) -#if !defined(__cplusplus) -#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0])) -#else -extern "C++" -{ -template -char (*__countof_helper(UNALIGNED _CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray]; -#define _countof(_Array) sizeof(*__countof_helper(_Array)) -} -#endif -#endif - -#ifndef AtlThrow -#ifndef _ATL_CUSTOM_THROW -#define AtlThrow ATL::AtlThrowImpl -#endif -#endif // AtlThrow - -#ifndef ATLASSERT -#define ATLASSERT(expr) _ASSERTE(expr) -#endif // ATLASSERT - -/* -Why does ATLASSUME exist? - -ATL 8 has two existing validation models - -ATLASSERT/ATLVERIFY - These are used to make sure a debug build reports a problem with the expression/invariant -ATLENSURE - Debug is the same as ATLVERIFY, retail throws a C++ exception - -We added ATLENSURE because there were too many unreported error paths in ATL and we wanted to bail out of more -error conditions rather than just trying to continue in retail. - -There might be a case for changing 'lots' of ATLASSERT to ATLENSURE, but we chose an incremental approach and only -changed over where we saw a problem with code reported from a customer or test case. This reduces code churn in our -code for this version. - -In general, our approach is to try to make sure that when something goes wrong -- the client does not continue to run, because we report an error condition -- debug builds see an assertion about the problem - -Sometimes we have code like - -HRESULT ComMethod(void) -{ - ATLASSUME(m_pFoo); - return m_pFoo->Method(); -} - -We could add - if(!m_pFoo) return E_POINTER; - -But this is very unlikely to help, since it removes the ability of the developer to debug this problem if it's seen in a retail -build of the application. - -We could try something more severe - - if(!m_pFoo) terminate(); // or your favourite shutdown function - -This would ensure good reporting (because VC8 terminate generates a Windows Error Report and crash dump), but hardly seems a big win -over the previous crash. - -ATLENSURE might seem slightly better. It is debuggable and consistent with ATL in general. In fact, many parts of ATL do just this. -But in this specific context, it doesn't look like a great choice. COM methods should not in general be emitting native C++ exceptions -as an error reporting strategy. - -So we find ourselves in a quandry. For these kinds of methods, the traditional code (ATLASSERT followed by a crash), seems be the most -debuggable thing to do in this situation. At least for VS8, we have decided to stick with this shape. - ---- - -Now consider the impact of cl /analyze. We want cl /analyze to not warn about our potential dereferences when they refer to member variables -whose state was previously validated by another method. But we do want to see the impact of function contracts on the parameters of the -function. - -So we've done a broad replace of all the member-related ATLASSERT to ATLASSUME. - -*/ - -#ifndef ATLASSUME -#define ATLASSUME(expr) do { ATLASSERT(expr); __analysis_assume(!!(expr)); } while(0) -#endif // ATLASSERT - -#ifndef ATLVERIFY -#ifdef _DEBUG -#define ATLVERIFY(expr) ATLASSERT(expr) -#else -#define ATLVERIFY(expr) (expr) -#endif // DEBUG -#endif // ATLVERIFY - -#ifndef ATLENSURE_THROW -#define ATLENSURE_THROW(expr, hr) \ -do { \ - int __atl_condVal=!!(expr); \ - ATLASSERT(__atl_condVal); \ - if(!(__atl_condVal)) AtlThrow(hr); \ -} while (0) -#endif // ATLENSURE - -#ifndef ATLENSURE -#define ATLENSURE(expr) ATLENSURE_THROW(expr, E_FAIL) -#endif // ATLENSURE - -#ifndef ATLENSURE_SUCCEEDED -#define ATLENSURE_SUCCEEDED(hr) ATLENSURE_THROW(SUCCEEDED(hr), hr) -#endif // ATLENSURE - -/* Used inside COM methods that do not want to throw */ -#ifndef ATLENSURE_RETURN_HR -#define ATLENSURE_RETURN_HR(expr, hr) \ -do { \ - int __atl_condVal=!!(expr); \ - ATLASSERT(__atl_condVal); \ - if(!(__atl_condVal)) return hr; \ -} while (0) -#endif - -/* Used inside COM methods that do not want to throw */ -#ifndef ATLENSURE_RETURN -#define ATLENSURE_RETURN(expr) ATLENSURE_RETURN_HR(expr, E_FAIL) -#endif - -/* generic version that returns 2nd expr if 1st is false; no implication of HRESULT */ -#ifndef ATLENSURE_RETURN_VAL -#define ATLENSURE_RETURN_VAL ATLENSURE_RETURN_HR -#endif - -#if defined(_SECURE_ATL) -#error Do not define _SECURE_ATL. -#undef _SECURE_ATL -#endif -#define _SECURE_ATL 1 - -#if _SECURE_ATL - -#ifndef ATL_CRT_ERRORCHECK -#define ATL_CRT_ERRORCHECK(expr) AtlCrtErrorCheck(expr) -#endif // ATL_CRT_ERRORCHECK - -#ifndef ATL_CRT_ERRORCHECK_SPRINTF -#define ATL_CRT_ERRORCHECK_SPRINTF(expr) \ -do { \ - errno_t _saveErrno = errno; \ - errno = 0; \ - (expr); \ - if(0 != errno) \ - { \ - AtlCrtErrorCheck(errno); \ - } \ - else \ - { \ - errno = _saveErrno; \ - } \ -} while (0) -#endif // ATL_CRT_ERRORCHECK_SPRINTF - -#else // !_SECURE_ATL - -#define ATL_CRT_ERRORCHECK(expr) do { expr; } while (0) -#define ATL_CRT_ERRORCHECK_SPRINTF(expr) do { expr; } while (0) - -#endif // _SECURE_ATL - -/////////////////////////////////////////////////////////////////////////////// -// __declspec(novtable) is used on a class declaration to prevent the vtable -// pointer from being initialized in the constructor and destructor for the -// class. This has many benefits because the linker can now eliminate the -// vtable and all the functions pointed to by the vtable. Also, the actual -// constructor and destructor code are now smaller. -/////////////////////////////////////////////////////////////////////////////// -// This should only be used on a class that is not directly createable but is -// rather only used as a base class. Additionally, the constructor and -// destructor (if provided by the user) should not call anything that may cause -// a virtual function call to occur back on the object. -/////////////////////////////////////////////////////////////////////////////// -// By default, the wizards will generate new ATL object classes with this -// attribute (through the ATL_NO_VTABLE macro). This is normally safe as long -// the restriction mentioned above is followed. It is always safe to remove -// this macro from your class, so if in doubt, remove it. -/////////////////////////////////////////////////////////////////////////////// - -#ifdef _ATL_DISABLE_NO_VTABLE -#define ATL_NO_VTABLE -#else -#define ATL_NO_VTABLE __declspec(novtable) -#endif - -#ifdef _ATL_DISABLE_NOTHROW -#define ATL_NOTHROW -#else -#define ATL_NOTHROW __declspec(nothrow) -#endif - -#ifdef _ATL_DISABLE_FORCEINLINE -#define ATL_FORCEINLINE -#else -#define ATL_FORCEINLINE __forceinline -#endif - -#ifdef _ATL_DISABLE_NOINLINE -#define ATL_NOINLINE -#else -#define ATL_NOINLINE __declspec( noinline ) -#endif - -#if defined(_ATL_DISABLE_DEPRECATED) || (defined(_PREFAST_) && (_MSC_VER < 1400)) -#define ATL_DEPRECATED(_Message) -#else -#define ATL_DEPRECATED(_Message) __declspec( deprecated(_Message) ) -#endif - -// If ATL80.DLL is being used then _ATL_STATIC_REGISTRY doesn't really make sense -#ifdef _ATL_DLL -#undef _ATL_STATIC_REGISTRY -#else -// If not linking to ATL80.DLL, use the static registrar and not building atl.dll -#ifndef _ATL_DLL_IMPL -#ifndef _ATL_STATIC_REGISTRY -#define _ATL_STATIC_REGISTRY -#endif -#endif -#endif - -#ifdef _ATL_DEBUG_REFCOUNT -#ifndef _ATL_DEBUG_INTERFACES -#define _ATL_DEBUG_INTERFACES -#endif -#endif - -#ifdef _DEBUG -#ifndef _ATL_DEBUG -#define _ATL_DEBUG -#endif // _ATL_DEBUG -#endif // _DEBUG - -#ifdef _ATL_DEBUG_INTERFACES -#ifndef _ATL_DEBUG -#define _ATL_DEBUG -#endif // _ATL_DEBUG -#endif // _ATL_DEBUG_INTERFACES - -#ifndef _ATL_HEAPFLAGS -#ifdef _MALLOC_ZEROINIT -#define _ATL_HEAPFLAGS HEAP_ZERO_MEMORY -#else -#define _ATL_HEAPFLAGS 0 -#endif -#endif - -#ifndef _ATL_PACKING -#define _ATL_PACKING 8 -#endif - -#if defined(_ATL_DLL) - #define ATLAPI extern "C" HRESULT __declspec(dllimport) __stdcall - #define ATLAPI_(x) extern "C" __declspec(dllimport) x __stdcall - #define ATLINLINE - #define ATLAPIINL extern "C" inline HRESULT __stdcall - #define ATLAPIINL_(x) extern "C" inline x __stdcall -#elif defined(_ATL_DLL_IMPL) - #define ATLAPI extern "C" inline HRESULT __stdcall - #define ATLAPI_(x) extern "C" inline x __stdcall - #define ATLAPIINL ATLAPI - #define ATLAPIINL_(x) ATLAPI_(x) - #define ATLINLINE -#else - #define ATLAPI __declspec(nothrow) HRESULT __stdcall - #define ATLAPI_(x) __declspec(nothrow) x __stdcall - #define ATLAPIINL ATLAPI - #define ATLAPIINL_(x) ATLAPI_(x) - #define ATLINLINE inline -#endif - -#ifdef _ATL_NO_EXCEPTIONS - #ifdef _AFX - #error MFC projects cannot define _ATL_NO_EXCEPTIONS - #endif -#else - #ifndef _CPPUNWIND - #define _ATL_NO_EXCEPTIONS - #endif -#endif - -#ifdef _CPPUNWIND - -#ifndef ATLTRYALLOC - -#ifdef _AFX -#define ATLTRYALLOC(x) try{x;} catch(CException* e){e->Delete();} -#else -/* prefast noise VSW 489981 */ -#define ATLTRYALLOC(x) __pragma(warning(push)) __pragma(warning(disable: 4571)) try{x;} catch(...) {} __pragma(warning(pop)) -#endif //__AFX - -#endif //ATLTRYALLOC - -// If you define _ATLTRY before including this file, then -// you should define _ATLCATCH and _ATLRETHROW as well. -#ifndef _ATLTRY -#define _ATLTRY try -#ifdef _AFX -#define _ATLCATCH( e ) catch( CException* e ) -#else -#define _ATLCATCH( e ) catch( CAtlException e ) -#endif - -#define _ATLCATCHALL() __pragma(warning(push)) __pragma(warning(disable: 4571)) catch( ... ) __pragma(warning(pop)) - -#ifdef _AFX -#define _ATLDELETEEXCEPTION(e) e->Delete(); -#else -#define _ATLDELETEEXCEPTION(e) e; -#endif - -#define _ATLRETHROW throw -#endif // _ATLTRY - -/* -COM functions should not throw. Which means we should protect their callers from C++ exceptions leaking out. These macros -can help with that, though they have not yet been applied to the whole of ATL, which uses a variety of patterns to achieve -this end -*/ - -#ifndef _ATL_COM_BEGIN -#define _ATL_COM_BEGIN \ - HRESULT __hrAtlComMethod=S_OK; \ - try \ - { -#endif - -#ifdef _AFX -/* Nice to do something more complex here in future to translate an MFC exception to a better HR */ -#define _AFX_COM_END_PART \ - catch(CException *e) \ - { \ - if(e) \ - { \ - e->Delete(); \ - } \ - __hrAtlComMethod=E_FAIL; \ - } -#else -#define _AFX_COM_END_PART \ - catch(CAtlException e) \ - { \ - __hrAtlComMethod=e.m_hr; \ - } -#endif - -#ifndef _ATL_COM_END -#define _ATL_COM_END \ - _AFX_COM_END_PART \ - catch(...) \ - { \ - __hrAtlComMethod=E_FAIL; \ - } \ - return hr; -#endif - - - -#else //_CPPUNWIND - -#ifndef ATLTRYALLOC -#define ATLTRYALLOC(x) x; -#endif //ATLTRYALLOC - -// if _ATLTRY is defined before including this file then -// _ATLCATCH and _ATLRETHROW should be defined as well. -#ifndef _ATLTRY -#define _ATLTRY -#define _ATLCATCH( e ) __pragma(warning(push)) __pragma(warning(disable: 4127)) if( false ) __pragma(warning(pop)) -#define _ATLCATCHALL() __pragma(warning(push)) __pragma(warning(disable: 4127)) if( false ) __pragma(warning(pop)) -#define _ATLDELETEEXCEPTION(e) -#define _ATLRETHROW -#endif // _ATLTRY - -#endif //_CPPUNWIND - -#ifndef ATLTRY -#define ATLTRY(x) ATLTRYALLOC(x) -#endif //ATLTRY - -#define offsetofclass(base, derived) ((DWORD_PTR)(static_cast((derived*)_ATL_PACKING))-_ATL_PACKING) - -///////////////////////////////////////////////////////////////////////////// -// Master version numbers - -#define _ATL 1 // Active Template Library -#define _ATL_VER 0x0800 // Active Template Library version 8.00 - -///////////////////////////////////////////////////////////////////////////// -// Threading - -#ifndef _ATL_SINGLE_THREADED -#ifndef _ATL_APARTMENT_THREADED -#ifndef _ATL_FREE_THREADED -#define _ATL_FREE_THREADED -#endif -#endif -#endif - -// UUIDOF -#ifndef _ATL_NO_UUIDOF -#define _ATL_IIDOF(x) __uuidof(x) -#else -#define _ATL_IIDOF(x) IID_##x -#endif - -// Lean and mean -#ifndef ATL_NO_LEAN_AND_MEAN -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMCX -#define NOMCX -#endif -#endif // ATL_NO_LEAN_AND_MEAN - -#ifdef NOSERVICE -#ifndef _ATL_NO_SERVICE -#define _ATL_NO_SERVICE -#endif // _ATL_NO_SERVICE -#else -#ifdef _ATL_NO_SERVICE -#ifndef NOSERVICE -#define NOSERVICE -#endif // NOSERVICE -#endif // _ATL_NO_SERVICE -#endif // NOSERVICE - -#include -#ifdef _DEBUG -#include -#endif -#ifndef _ATL_NO_DEBUG_CRT -// Warning: if you define the above symbol, you will have -// to provide your own definition of the ATLASSERT(x) macro -// in order to compile ATL - #include -#endif - -#endif // RC_INVOKED - -#define ATLAXWIN_CLASS "AtlAxWin80" -#define ATLAXWINLIC_CLASS "AtlAxWinLic80" - -// _ATL_INSECURE_DEPRECATE define -#ifndef _ATL_INSECURE_DEPRECATE -#if defined(_ATL_SECURE_NO_DEPRECATE) || (defined(_PREFAST_) && (_MSC_VER < 1400)) -#define _ATL_INSECURE_DEPRECATE(_Message) -#else -#define _ATL_INSECURE_DEPRECATE(_Message) __declspec(deprecated(_Message)) -#endif // _ATL_SECURE_NO_DEPRECATE -#endif // _ATL_INSECURE_DEPRECATE - -/* -This is called when something really bad happens -- so bad -that we consider it dangerous to even throw an exception -*/ -#ifndef _ATL_FATAL_SHUTDOWN -#define _ATL_FATAL_SHUTDOWN do { ::TerminateProcess(::GetCurrentProcess(), 0); } while(0); -#endif - -//ATL/MFC code should use standard pointer to member standard syntax &MyClass::MyMethod, instead -//of the legacy non-standard syntax - MyMethod. -#ifdef _ATL_ENABLE_PTM_WARNING -#define PTM_WARNING_DISABLE -#define PTM_WARNING_RESTORE -#else -#define PTM_WARNING_DISABLE \ - __pragma(warning( push )) \ - __pragma(warning( disable : 4867 )) -#define PTM_WARNING_RESTORE \ - __pragma(warning( pop )) -#endif //_ATL_ENABLE_PTM_WARNING - -/* we have to define our own versions of MAKEINTRESOURCE and IS_INTRESOURCE to - * fix warning 6268. At least until those macros are not cleanend in PSDK. - Same comes true for those definitions of constants which use the above macros -*/ -#define ATL_MAKEINTRESOURCEA(i) ((LPSTR)((ULONG_PTR)((WORD)(i)))) -#define ATL_MAKEINTRESOURCEW(i) ((LPWSTR)((ULONG_PTR)((WORD)(i)))) -#ifdef UNICODE -#define ATL_MAKEINTRESOURCE ATL_MAKEINTRESOURCEW -#else -#define ATL_MAKEINTRESOURCE ATL_MAKEINTRESOURCEA -#endif // !UNICODE -#define ATL_IS_INTRESOURCE(_r) ((((ULONG_PTR)(_r)) >> 16) == 0) - -/* - * Predefined Resource Types - */ -#define ATL_RT_CURSOR ATL_MAKEINTRESOURCE(1) -#define ATL_RT_BITMAP ATL_MAKEINTRESOURCE(2) -#define ATL_RT_ICON ATL_MAKEINTRESOURCE(3) -#define ATL_RT_MENU ATL_MAKEINTRESOURCE(4) -#define ATL_RT_DIALOG ATL_MAKEINTRESOURCE(5) -#define ATL_RT_STRING ATL_MAKEINTRESOURCE(6) -#define ATL_RT_FONTDIR ATL_MAKEINTRESOURCE(7) -#define ATL_RT_FONT ATL_MAKEINTRESOURCE(8) -#define ATL_RT_ACCELERATOR ATL_MAKEINTRESOURCE(9) -#define ATL_RT_RCDATA ATL_MAKEINTRESOURCE(10) -#define ATL_RT_MESSAGETABLE ATL_MAKEINTRESOURCE(11) - -#define ATL_DIFFERENCE 11 -#define ATL_RT_GROUP_CURSOR ATL_MAKEINTRESOURCE((ULONG_PTR)ATL_RT_CURSOR + ATL_DIFFERENCE) -#define ATL_RT_GROUP_ICON ATL_MAKEINTRESOURCE((ULONG_PTR)ATL_RT_ICON + ATL_DIFFERENCE) -#define ATL_RT_VERSION ATL_MAKEINTRESOURCE(16) -#define ATL_RT_DLGINCLUDE ATL_MAKEINTRESOURCE(17) -#if(WINVER >= 0x0400) -#define ATL_RT_PLUGPLAY ATL_MAKEINTRESOURCE(19) -#define ATL_RT_VXD ATL_MAKEINTRESOURCE(20) -#define ATL_RT_ANICURSOR ATL_MAKEINTRESOURCE(21) -#define ATL_RT_ANIICON ATL_MAKEINTRESOURCE(22) -#endif /* WINVER >= 0x0400 */ -#define ATL_RT_HTML ATL_MAKEINTRESOURCE(23) -#ifdef RC_INVOKED -#define ATL_RT_MANIFEST 24 -#define ATL_CREATEPROCESS_MANIFEST_RESOURCE_ID 1 -#define ATL_ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2 -#define ATL_ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3 -#define ATL_MINIMUM_RESERVED_MANIFEST_RESOURCE_ID 1 /* inclusive */ -#define ATL_MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID 16 /* inclusive */ -#else /* RC_INVOKED */ -#define ATL_RT_MANIFEST ATL_MAKEINTRESOURCE(24) -#define ATL_CREATEPROCESS_MANIFEST_RESOURCE_ID ATL_MAKEINTRESOURCE( 1) -#define ATL_ISOLATIONAWARE_MANIFEST_RESOURCE_ID ATL_MAKEINTRESOURCE(2) -#define ATL_ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID ATL_MAKEINTRESOURCE(3) -#define ATL_MINIMUM_RESERVED_MANIFEST_RESOURCE_ID ATL_MAKEINTRESOURCE( 1 /*inclusive*/) -#define ATL_MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID ATL_MAKEINTRESOURCE(16 /*inclusive*/) -#endif /* RC_INVOKED */ - -/* sal.h stuff that is not in the current LKG */ -#ifndef __out_ecount_part_z -#define __out_ecount_part_z(size,length) __out_ecount_part(size,length) __post __nullterminated -#endif - -#ifndef __out_ecount_part_z_opt -#define __out_ecount_part_z_opt(size,length) __out_ecount_part_opt(size,length) __post __nullterminated -#endif - -#ifndef __deref_opt_out_z -#define __deref_opt_out_z __deref_opt_out __post __deref __nullterminated -#endif - -#ifndef __out_bcount_part_z -#define __out_bcount_part_z(size,length) __out_bcount_part(size,length) __post __nullterminated -#endif - -#endif // __ATLDEF_H__ - -///////////////////////////////////////////////////////////////////////////// - diff --git a/cpp/jacob/include/atlexcept.h b/cpp/jacob/include/atlexcept.h deleted file mode 100644 index 119208b..0000000 --- a/cpp/jacob/include/atlexcept.h +++ /dev/null @@ -1,123 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLEXCEPT_H__ -#define __ATLEXCEPT_H__ - -#pragma once - -#include -#include - - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ - -///////////////////////////////////////////////////////////////////////////// -// Exception raise (for functions that cannot return an error code) - -inline void __declspec(noreturn) _AtlRaiseException( DWORD dwExceptionCode, DWORD dwExceptionFlags = EXCEPTION_NONCONTINUABLE ) -{ - RaiseException( dwExceptionCode, dwExceptionFlags, 0, NULL ); -} - -class CAtlException -{ -public: - CAtlException() throw() : - m_hr( E_FAIL ) - { - } - - CAtlException( HRESULT hr ) throw() : - m_hr( hr ) - { - } - - operator HRESULT() const throw() - { - return( m_hr ); - } - -public: - HRESULT m_hr; -}; - -#ifndef _ATL_NO_EXCEPTIONS - -// Throw a CAtlException with the given HRESULT -#if defined( _ATL_CUSTOM_THROW ) // You can define your own AtlThrow to throw a custom exception. -#ifdef _AFX -#error MFC projects must use default implementation of AtlThrow() -#endif -#else -ATL_NOINLINE __declspec(noreturn) inline void WINAPI AtlThrowImpl( HRESULT hr ) -{ - ATLTRACE(atlTraceException, 0, _T("AtlThrow: hr = 0x%x\n"), hr ); -#ifdef _AFX - if( hr == E_OUTOFMEMORY ) - { - AfxThrowMemoryException(); - } - else - { - AfxThrowOleException( hr ); - } -#else - throw CAtlException( hr ); -#endif -}; -#endif - -// Throw a CAtlException corresponding to the result of ::GetLastError -ATL_NOINLINE __declspec(noreturn) inline void WINAPI AtlThrowLastWin32() -{ - DWORD dwError = ::GetLastError(); - AtlThrow( HRESULT_FROM_WIN32( dwError ) ); -} - -#else // no exception handling - -// Throw a CAtlException with the given HRESULT -#if !defined( _ATL_CUSTOM_THROW ) // You can define your own AtlThrow - -ATL_NOINLINE inline void WINAPI AtlThrowImpl( HRESULT hr ) -{ - ATLTRACE(atlTraceException, 0, _T("AtlThrow: hr = 0x%x\n"), hr ); - ATLASSERT( false ); - DWORD dwExceptionCode; - switch(hr) - { - case E_OUTOFMEMORY: - dwExceptionCode = DWORD(STATUS_NO_MEMORY); - break; - default: - dwExceptionCode = DWORD(EXCEPTION_ILLEGAL_INSTRUCTION); - break; - } - _AtlRaiseException(dwExceptionCode); -} -#endif - -// Throw a CAtlException corresponding to the result of ::GetLastError -ATL_NOINLINE inline void WINAPI AtlThrowLastWin32() -{ - DWORD dwError = ::GetLastError(); - AtlThrow( HRESULT_FROM_WIN32( dwError ) ); -} - -#endif // no exception handling - -}; // namespace ATL -#pragma pack(pop) - -#endif // __ATLEXCEPT_H__ - diff --git a/cpp/jacob/include/atliface.h b/cpp/jacob/include/atliface.h deleted file mode 100644 index 3736c90..0000000 --- a/cpp/jacob/include/atliface.h +++ /dev/null @@ -1,2956 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#pragma warning( disable: 4049 ) /* more than 64k source lines */ - -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - - /* File created by MIDL compiler version 6.00.0342 */ -/* at Mon Feb 12 21:31:09 2001 - */ -/* Compiler settings for atliface.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() -*/ -//@@MIDL_FILE_HEADING( ) - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 440 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - -#ifndef __atliface_h__ -#define __atliface_h__ - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma once -#endif - -/* Forward Declarations */ - -#ifndef __IRegistrarBase_FWD_DEFINED__ -#define __IRegistrarBase_FWD_DEFINED__ -typedef interface IRegistrarBase IRegistrarBase; -#endif /* __IRegistrarBase_FWD_DEFINED__ */ - - -#ifndef __IRegistrar_FWD_DEFINED__ -#define __IRegistrar_FWD_DEFINED__ -typedef interface IRegistrar IRegistrar; -#endif /* __IRegistrar_FWD_DEFINED__ */ - - -#ifndef __IDocHostUIHandlerDispatch_FWD_DEFINED__ -#define __IDocHostUIHandlerDispatch_FWD_DEFINED__ -typedef interface IDocHostUIHandlerDispatch IDocHostUIHandlerDispatch; -#endif /* __IDocHostUIHandlerDispatch_FWD_DEFINED__ */ - - -#ifndef __IAxWinHostWindow_FWD_DEFINED__ -#define __IAxWinHostWindow_FWD_DEFINED__ -typedef interface IAxWinHostWindow IAxWinHostWindow; -#endif /* __IAxWinHostWindow_FWD_DEFINED__ */ - - -#ifndef __IAxWinHostWindowLic_FWD_DEFINED__ -#define __IAxWinHostWindowLic_FWD_DEFINED__ -typedef interface IAxWinHostWindowLic IAxWinHostWindowLic; -#endif /* __IAxWinHostWindowLic_FWD_DEFINED__ */ - - -#ifndef __IAxWinAmbientDispatch_FWD_DEFINED__ -#define __IAxWinAmbientDispatch_FWD_DEFINED__ -typedef interface IAxWinAmbientDispatch IAxWinAmbientDispatch; -#endif /* __IAxWinAmbientDispatch_FWD_DEFINED__ */ - - -#ifndef __IAxWinAmbientDispatchEx_FWD_DEFINED__ -#define __IAxWinAmbientDispatchEx_FWD_DEFINED__ -typedef interface IAxWinAmbientDispatchEx IAxWinAmbientDispatchEx; -#endif /* __IAxWinAmbientDispatchEx_FWD_DEFINED__ */ - - -#ifndef __IInternalConnection_FWD_DEFINED__ -#define __IInternalConnection_FWD_DEFINED__ -typedef interface IInternalConnection IInternalConnection; -#endif /* __IInternalConnection_FWD_DEFINED__ */ - - -#ifndef __IAccessibleProxy_FWD_DEFINED__ -#define __IAccessibleProxy_FWD_DEFINED__ -typedef interface IAccessibleProxy IAccessibleProxy; -#endif /* __IAccessibleProxy_FWD_DEFINED__ */ - - -#ifndef __IAccessibleServer_FWD_DEFINED__ -#define __IAccessibleServer_FWD_DEFINED__ -typedef interface IAccessibleServer IAccessibleServer; -#endif /* __IAccessibleServer_FWD_DEFINED__ */ - - -/* header files for imported files */ -#include "oaidl.h" -#include "ocidl.h" -#include "oleacc.h" - -#ifdef __cplusplus -extern "C"{ -#endif - -void * __RPC_USER MIDL_user_allocate(size_t size); -void __RPC_USER MIDL_user_free(__inout void * ); - -/* interface __MIDL_itf_atliface_0000 */ -/* [local] */ - -EXTERN_C const CLSID CLSID_Registrar; - - -extern RPC_IF_HANDLE __MIDL_itf_atliface_0000_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_atliface_0000_v0_0_s_ifspec; - -#ifndef __IRegistrarBase_INTERFACE_DEFINED__ -#define __IRegistrarBase_INTERFACE_DEFINED__ - -/* interface IRegistrarBase */ -/* [unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IRegistrarBase; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("e21f8a85-b05d-4243-8183-c7cb405588f7") - IRegistrarBase : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE AddReplacement( - /* [in] */ LPCOLESTR key, - /* [in] */ LPCOLESTR item) = 0; - - virtual HRESULT STDMETHODCALLTYPE ClearReplacements( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct IRegistrarBaseVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IRegistrarBase * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IRegistrarBase * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IRegistrarBase * This); - - HRESULT ( STDMETHODCALLTYPE *AddReplacement )( - IRegistrarBase * This, - /* [in] */ LPCOLESTR key, - /* [in] */ LPCOLESTR item); - - HRESULT ( STDMETHODCALLTYPE *ClearReplacements )( - IRegistrarBase * This); - - END_INTERFACE - } IRegistrarBaseVtbl; - - interface IRegistrarBase - { - CONST_VTBL struct IRegistrarBaseVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IRegistrarBase_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IRegistrarBase_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IRegistrarBase_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IRegistrarBase_AddReplacement(This,key,item) \ - (This)->lpVtbl -> AddReplacement(This,key,item) - -#define IRegistrarBase_ClearReplacements(This) \ - (This)->lpVtbl -> ClearReplacements(This) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IRegistrarBase_AddReplacement_Proxy( - IRegistrarBase * This, - /* [in] */ LPCOLESTR key, - /* [in] */ LPCOLESTR item); - - -void __RPC_STUB IRegistrarBase_AddReplacement_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IRegistrarBase_ClearReplacements_Proxy( - IRegistrarBase * This); - - -void __RPC_STUB IRegistrarBase_ClearReplacements_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IRegistrarBase_INTERFACE_DEFINED__ */ - - -#ifndef __IRegistrar_INTERFACE_DEFINED__ -#define __IRegistrar_INTERFACE_DEFINED__ - -/* interface IRegistrar */ -/* [unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IRegistrar; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("44EC053B-400F-11D0-9DCD-00A0C90391D3") - IRegistrar : public IRegistrarBase - { - public: - virtual HRESULT STDMETHODCALLTYPE ResourceRegisterSz( - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResourceUnregisterSz( - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType) = 0; - - virtual HRESULT STDMETHODCALLTYPE FileRegister( - /* [in] */ LPCOLESTR fileName) = 0; - - virtual HRESULT STDMETHODCALLTYPE FileUnregister( - /* [in] */ LPCOLESTR fileName) = 0; - - virtual HRESULT STDMETHODCALLTYPE StringRegister( - /* [in] */ LPCOLESTR data) = 0; - - virtual HRESULT STDMETHODCALLTYPE StringUnregister( - /* [in] */ LPCOLESTR data) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResourceRegister( - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResourceUnregister( - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType) = 0; - - }; - -#else /* C style interface */ - - typedef struct IRegistrarVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IRegistrar * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IRegistrar * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IRegistrar * This); - - HRESULT ( STDMETHODCALLTYPE *AddReplacement )( - IRegistrar * This, - /* [in] */ LPCOLESTR key, - /* [in] */ LPCOLESTR item); - - HRESULT ( STDMETHODCALLTYPE *ClearReplacements )( - IRegistrar * This); - - HRESULT ( STDMETHODCALLTYPE *ResourceRegisterSz )( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType); - - HRESULT ( STDMETHODCALLTYPE *ResourceUnregisterSz )( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType); - - HRESULT ( STDMETHODCALLTYPE *FileRegister )( - IRegistrar * This, - /* [in] */ LPCOLESTR fileName); - - HRESULT ( STDMETHODCALLTYPE *FileUnregister )( - IRegistrar * This, - /* [in] */ LPCOLESTR fileName); - - HRESULT ( STDMETHODCALLTYPE *StringRegister )( - IRegistrar * This, - /* [in] */ LPCOLESTR data); - - HRESULT ( STDMETHODCALLTYPE *StringUnregister )( - IRegistrar * This, - /* [in] */ LPCOLESTR data); - - HRESULT ( STDMETHODCALLTYPE *ResourceRegister )( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType); - - HRESULT ( STDMETHODCALLTYPE *ResourceUnregister )( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType); - - END_INTERFACE - } IRegistrarVtbl; - - interface IRegistrar - { - CONST_VTBL struct IRegistrarVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IRegistrar_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IRegistrar_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IRegistrar_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IRegistrar_AddReplacement(This,key,item) \ - (This)->lpVtbl -> AddReplacement(This,key,item) - -#define IRegistrar_ClearReplacements(This) \ - (This)->lpVtbl -> ClearReplacements(This) - - -#define IRegistrar_ResourceRegisterSz(This,resFileName,szID,szType) \ - (This)->lpVtbl -> ResourceRegisterSz(This,resFileName,szID,szType) - -#define IRegistrar_ResourceUnregisterSz(This,resFileName,szID,szType) \ - (This)->lpVtbl -> ResourceUnregisterSz(This,resFileName,szID,szType) - -#define IRegistrar_FileRegister(This,fileName) \ - (This)->lpVtbl -> FileRegister(This,fileName) - -#define IRegistrar_FileUnregister(This,fileName) \ - (This)->lpVtbl -> FileUnregister(This,fileName) - -#define IRegistrar_StringRegister(This,data) \ - (This)->lpVtbl -> StringRegister(This,data) - -#define IRegistrar_StringUnregister(This,data) \ - (This)->lpVtbl -> StringUnregister(This,data) - -#define IRegistrar_ResourceRegister(This,resFileName,nID,szType) \ - (This)->lpVtbl -> ResourceRegister(This,resFileName,nID,szType) - -#define IRegistrar_ResourceUnregister(This,resFileName,nID,szType) \ - (This)->lpVtbl -> ResourceUnregister(This,resFileName,nID,szType) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IRegistrar_ResourceRegisterSz_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType); - - -void __RPC_STUB IRegistrar_ResourceRegisterSz_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IRegistrar_ResourceUnregisterSz_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType); - - -void __RPC_STUB IRegistrar_ResourceUnregisterSz_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IRegistrar_FileRegister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR fileName); - - -void __RPC_STUB IRegistrar_FileRegister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IRegistrar_FileUnregister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR fileName); - - -void __RPC_STUB IRegistrar_FileUnregister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IRegistrar_StringRegister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR data); - - -void __RPC_STUB IRegistrar_StringRegister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IRegistrar_StringUnregister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR data); - - -void __RPC_STUB IRegistrar_StringUnregister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IRegistrar_ResourceRegister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType); - - -void __RPC_STUB IRegistrar_ResourceRegister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IRegistrar_ResourceUnregister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType); - - -void __RPC_STUB IRegistrar_ResourceUnregister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IRegistrar_INTERFACE_DEFINED__ */ - - -#ifndef __IDocHostUIHandlerDispatch_INTERFACE_DEFINED__ -#define __IDocHostUIHandlerDispatch_INTERFACE_DEFINED__ - -/* interface IDocHostUIHandlerDispatch */ -/* [object][unique][helpstring][uuid][local] */ - -typedef -enum tagDOCHOSTUIDBLCLKDispatch - { docHostUIDblClkDEFAULT = 0, - docHostUIDblClkSHOWPROPERTIES = 1, - docHostUIDblClkSHOWCODE = 2 - } DOCHOSTUIDBLCLKDispatch; - -typedef -enum tagDocHostUIFlagDispatch - { docHostUIFlagDIALOG = 1, - docHostUIFlagDISABLE_HELP_MENU = 2, - docHostUIFlagNO3DBORDER = 4, - docHostUIFlagSCROLL_NO = 8, - docHostUIFlagDISABLE_SCRIPT_INACTIVE = 16, - docHostUIFlagOPENNEWWIN = 32, - docHostUIFlagDISABLE_OFFSCREEN = 64, - docHostUIFlagFLAT_SCROLLBAR = 128, - docHostUIFlagDIV_BLOCKDEFAULT = 256, - docHostUIFlagACTIVATE_CLIENTHIT_ONLY = 512 - } DocHostUIFlagDispatch; - - -EXTERN_C const IID IID_IDocHostUIHandlerDispatch; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("425B5AF0-65F1-11d1-9611-0000F81E0D0D") - IDocHostUIHandlerDispatch : public IDispatch - { - public: - virtual HRESULT STDMETHODCALLTYPE ShowContextMenu( - /* [in] */ DWORD dwID, - /* [in] */ DWORD x, - /* [in] */ DWORD y, - /* [in] */ IUnknown *pcmdtReserved, - /* [in] */ IDispatch *pdispReserved, - /* [retval][out] */ HRESULT *dwRetVal) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetHostInfo( - /* [out][in] */ DWORD *pdwFlags, - /* [out][in] */ DWORD *pdwDoubleClick) = 0; - - virtual HRESULT STDMETHODCALLTYPE ShowUI( - /* [in] */ DWORD dwID, - /* [in] */ IUnknown *pActiveObject, - /* [in] */ IUnknown *pCommandTarget, - /* [in] */ IUnknown *pFrame, - /* [in] */ IUnknown *pDoc, - /* [retval][out] */ HRESULT *dwRetVal) = 0; - - virtual HRESULT STDMETHODCALLTYPE HideUI( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE UpdateUI( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE EnableModeless( - /* [in] */ VARIANT_BOOL fEnable) = 0; - - virtual HRESULT STDMETHODCALLTYPE OnDocWindowActivate( - /* [in] */ VARIANT_BOOL fActivate) = 0; - - virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivate( - /* [in] */ VARIANT_BOOL fActivate) = 0; - - virtual HRESULT STDMETHODCALLTYPE ResizeBorder( - /* [in] */ long left, - /* [in] */ long top, - /* [in] */ long right, - /* [in] */ long bottom, - /* [in] */ IUnknown *pUIWindow, - /* [in] */ VARIANT_BOOL fFrameWindow) = 0; - - virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator( - /* [in] */ DWORD_PTR hWnd, - /* [in] */ DWORD nMessage, - /* [in] */ DWORD_PTR wParam, - /* [in] */ DWORD_PTR lParam, - /* [in] */ BSTR bstrGuidCmdGroup, - /* [in] */ DWORD nCmdID, - /* [retval][out] */ HRESULT *dwRetVal) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetOptionKeyPath( - /* [out] */ BSTR *pbstrKey, - /* [in] */ DWORD dw) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetDropTarget( - /* [in] */ IUnknown *pDropTarget, - /* [out] */ IUnknown **ppDropTarget) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetExternal( - /* [out] */ IDispatch **ppDispatch) = 0; - - virtual HRESULT STDMETHODCALLTYPE TranslateUrl( - /* [in] */ DWORD dwTranslate, - /* [in] */ BSTR bstrURLIn, - /* [out] */ BSTR *pbstrURLOut) = 0; - - virtual HRESULT STDMETHODCALLTYPE FilterDataObject( - /* [in] */ IUnknown *pDO, - /* [out] */ IUnknown **ppDORet) = 0; - - }; - -#else /* C style interface */ - - typedef struct IDocHostUIHandlerDispatchVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDocHostUIHandlerDispatch * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDocHostUIHandlerDispatch * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IDocHostUIHandlerDispatch * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - IDocHostUIHandlerDispatch * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - IDocHostUIHandlerDispatch * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - IDocHostUIHandlerDispatch * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - HRESULT ( STDMETHODCALLTYPE *ShowContextMenu )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwID, - /* [in] */ DWORD x, - /* [in] */ DWORD y, - /* [in] */ IUnknown *pcmdtReserved, - /* [in] */ IDispatch *pdispReserved, - /* [retval][out] */ HRESULT *dwRetVal); - - HRESULT ( STDMETHODCALLTYPE *GetHostInfo )( - IDocHostUIHandlerDispatch * This, - /* [out][in] */ DWORD *pdwFlags, - /* [out][in] */ DWORD *pdwDoubleClick); - - HRESULT ( STDMETHODCALLTYPE *ShowUI )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwID, - /* [in] */ IUnknown *pActiveObject, - /* [in] */ IUnknown *pCommandTarget, - /* [in] */ IUnknown *pFrame, - /* [in] */ IUnknown *pDoc, - /* [retval][out] */ HRESULT *dwRetVal); - - HRESULT ( STDMETHODCALLTYPE *HideUI )( - IDocHostUIHandlerDispatch * This); - - HRESULT ( STDMETHODCALLTYPE *UpdateUI )( - IDocHostUIHandlerDispatch * This); - - HRESULT ( STDMETHODCALLTYPE *EnableModeless )( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fEnable); - - HRESULT ( STDMETHODCALLTYPE *OnDocWindowActivate )( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fActivate); - - HRESULT ( STDMETHODCALLTYPE *OnFrameWindowActivate )( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fActivate); - - HRESULT ( STDMETHODCALLTYPE *ResizeBorder )( - IDocHostUIHandlerDispatch * This, - /* [in] */ long left, - /* [in] */ long top, - /* [in] */ long right, - /* [in] */ long bottom, - /* [in] */ IUnknown *pUIWindow, - /* [in] */ VARIANT_BOOL fFrameWindow); - - HRESULT ( STDMETHODCALLTYPE *TranslateAccelerator )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD_PTR hWnd, - /* [in] */ DWORD nMessage, - /* [in] */ DWORD_PTR wParam, - /* [in] */ DWORD_PTR lParam, - /* [in] */ BSTR bstrGuidCmdGroup, - /* [in] */ DWORD nCmdID, - /* [retval][out] */ HRESULT *dwRetVal); - - HRESULT ( STDMETHODCALLTYPE *GetOptionKeyPath )( - IDocHostUIHandlerDispatch * This, - /* [out] */ BSTR *pbstrKey, - /* [in] */ DWORD dw); - - HRESULT ( STDMETHODCALLTYPE *GetDropTarget )( - IDocHostUIHandlerDispatch * This, - /* [in] */ IUnknown *pDropTarget, - /* [out] */ IUnknown **ppDropTarget); - - HRESULT ( STDMETHODCALLTYPE *GetExternal )( - IDocHostUIHandlerDispatch * This, - /* [out] */ IDispatch **ppDispatch); - - HRESULT ( STDMETHODCALLTYPE *TranslateUrl )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwTranslate, - /* [in] */ BSTR bstrURLIn, - /* [out] */ BSTR *pbstrURLOut); - - HRESULT ( STDMETHODCALLTYPE *FilterDataObject )( - IDocHostUIHandlerDispatch * This, - /* [in] */ IUnknown *pDO, - /* [out] */ IUnknown **ppDORet); - - END_INTERFACE - } IDocHostUIHandlerDispatchVtbl; - - interface IDocHostUIHandlerDispatch - { - CONST_VTBL struct IDocHostUIHandlerDispatchVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IDocHostUIHandlerDispatch_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IDocHostUIHandlerDispatch_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IDocHostUIHandlerDispatch_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IDocHostUIHandlerDispatch_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define IDocHostUIHandlerDispatch_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define IDocHostUIHandlerDispatch_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define IDocHostUIHandlerDispatch_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define IDocHostUIHandlerDispatch_ShowContextMenu(This,dwID,x,y,pcmdtReserved,pdispReserved,dwRetVal) \ - (This)->lpVtbl -> ShowContextMenu(This,dwID,x,y,pcmdtReserved,pdispReserved,dwRetVal) - -#define IDocHostUIHandlerDispatch_GetHostInfo(This,pdwFlags,pdwDoubleClick) \ - (This)->lpVtbl -> GetHostInfo(This,pdwFlags,pdwDoubleClick) - -#define IDocHostUIHandlerDispatch_ShowUI(This,dwID,pActiveObject,pCommandTarget,pFrame,pDoc,dwRetVal) \ - (This)->lpVtbl -> ShowUI(This,dwID,pActiveObject,pCommandTarget,pFrame,pDoc,dwRetVal) - -#define IDocHostUIHandlerDispatch_HideUI(This) \ - (This)->lpVtbl -> HideUI(This) - -#define IDocHostUIHandlerDispatch_UpdateUI(This) \ - (This)->lpVtbl -> UpdateUI(This) - -#define IDocHostUIHandlerDispatch_EnableModeless(This,fEnable) \ - (This)->lpVtbl -> EnableModeless(This,fEnable) - -#define IDocHostUIHandlerDispatch_OnDocWindowActivate(This,fActivate) \ - (This)->lpVtbl -> OnDocWindowActivate(This,fActivate) - -#define IDocHostUIHandlerDispatch_OnFrameWindowActivate(This,fActivate) \ - (This)->lpVtbl -> OnFrameWindowActivate(This,fActivate) - -#define IDocHostUIHandlerDispatch_ResizeBorder(This,left,top,right,bottom,pUIWindow,fFrameWindow) \ - (This)->lpVtbl -> ResizeBorder(This,left,top,right,bottom,pUIWindow,fFrameWindow) - -#define IDocHostUIHandlerDispatch_TranslateAccelerator(This,hWnd,nMessage,wParam,lParam,bstrGuidCmdGroup,nCmdID,dwRetVal) \ - (This)->lpVtbl -> TranslateAccelerator(This,hWnd,nMessage,wParam,lParam,bstrGuidCmdGroup,nCmdID,dwRetVal) - -#define IDocHostUIHandlerDispatch_GetOptionKeyPath(This,pbstrKey,dw) \ - (This)->lpVtbl -> GetOptionKeyPath(This,pbstrKey,dw) - -#define IDocHostUIHandlerDispatch_GetDropTarget(This,pDropTarget,ppDropTarget) \ - (This)->lpVtbl -> GetDropTarget(This,pDropTarget,ppDropTarget) - -#define IDocHostUIHandlerDispatch_GetExternal(This,ppDispatch) \ - (This)->lpVtbl -> GetExternal(This,ppDispatch) - -#define IDocHostUIHandlerDispatch_TranslateUrl(This,dwTranslate,bstrURLIn,pbstrURLOut) \ - (This)->lpVtbl -> TranslateUrl(This,dwTranslate,bstrURLIn,pbstrURLOut) - -#define IDocHostUIHandlerDispatch_FilterDataObject(This,pDO,ppDORet) \ - (This)->lpVtbl -> FilterDataObject(This,pDO,ppDORet) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_ShowContextMenu_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwID, - /* [in] */ DWORD x, - /* [in] */ DWORD y, - /* [in] */ IUnknown *pcmdtReserved, - /* [in] */ IDispatch *pdispReserved, - /* [retval][out] */ HRESULT *dwRetVal); - - -void __RPC_STUB IDocHostUIHandlerDispatch_ShowContextMenu_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_GetHostInfo_Proxy( - IDocHostUIHandlerDispatch * This, - /* [out][in] */ DWORD *pdwFlags, - /* [out][in] */ DWORD *pdwDoubleClick); - - -void __RPC_STUB IDocHostUIHandlerDispatch_GetHostInfo_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_ShowUI_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwID, - /* [in] */ IUnknown *pActiveObject, - /* [in] */ IUnknown *pCommandTarget, - /* [in] */ IUnknown *pFrame, - /* [in] */ IUnknown *pDoc, - /* [retval][out] */ HRESULT *dwRetVal); - - -void __RPC_STUB IDocHostUIHandlerDispatch_ShowUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_HideUI_Proxy( - IDocHostUIHandlerDispatch * This); - - -void __RPC_STUB IDocHostUIHandlerDispatch_HideUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_UpdateUI_Proxy( - IDocHostUIHandlerDispatch * This); - - -void __RPC_STUB IDocHostUIHandlerDispatch_UpdateUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_EnableModeless_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fEnable); - - -void __RPC_STUB IDocHostUIHandlerDispatch_EnableModeless_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_OnDocWindowActivate_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fActivate); - - -void __RPC_STUB IDocHostUIHandlerDispatch_OnDocWindowActivate_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_OnFrameWindowActivate_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fActivate); - - -void __RPC_STUB IDocHostUIHandlerDispatch_OnFrameWindowActivate_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_ResizeBorder_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ long left, - /* [in] */ long top, - /* [in] */ long right, - /* [in] */ long bottom, - /* [in] */ IUnknown *pUIWindow, - /* [in] */ VARIANT_BOOL fFrameWindow); - - -void __RPC_STUB IDocHostUIHandlerDispatch_ResizeBorder_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_TranslateAccelerator_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD_PTR hWnd, - /* [in] */ DWORD nMessage, - /* [in] */ DWORD_PTR wParam, - /* [in] */ DWORD_PTR lParam, - /* [in] */ BSTR bstrGuidCmdGroup, - /* [in] */ DWORD nCmdID, - /* [retval][out] */ HRESULT *dwRetVal); - - -void __RPC_STUB IDocHostUIHandlerDispatch_TranslateAccelerator_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_GetOptionKeyPath_Proxy( - IDocHostUIHandlerDispatch * This, - /* [out] */ BSTR *pbstrKey, - /* [in] */ DWORD dw); - - -void __RPC_STUB IDocHostUIHandlerDispatch_GetOptionKeyPath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_GetDropTarget_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ IUnknown *pDropTarget, - /* [out] */ IUnknown **ppDropTarget); - - -void __RPC_STUB IDocHostUIHandlerDispatch_GetDropTarget_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_GetExternal_Proxy( - IDocHostUIHandlerDispatch * This, - /* [out] */ IDispatch **ppDispatch); - - -void __RPC_STUB IDocHostUIHandlerDispatch_GetExternal_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_TranslateUrl_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwTranslate, - /* [in] */ BSTR bstrURLIn, - /* [out] */ BSTR *pbstrURLOut); - - -void __RPC_STUB IDocHostUIHandlerDispatch_TranslateUrl_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_FilterDataObject_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ IUnknown *pDO, - /* [out] */ IUnknown **ppDORet); - - -void __RPC_STUB IDocHostUIHandlerDispatch_FilterDataObject_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IDocHostUIHandlerDispatch_INTERFACE_DEFINED__ */ - - -#ifndef __IAxWinHostWindow_INTERFACE_DEFINED__ -#define __IAxWinHostWindow_INTERFACE_DEFINED__ - -/* interface IAxWinHostWindow */ -/* [object][unique][helpstring][uuid] */ - - -EXTERN_C const IID IID_IAxWinHostWindow; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("B6EA2050-048A-11d1-82B9-00C04FB9942E") - IAxWinHostWindow : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE CreateControl( - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateControlEx( - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise) = 0; - - virtual HRESULT STDMETHODCALLTYPE AttachControl( - /* [in] */ IUnknown *pUnkControl, - /* [in] */ HWND hWnd) = 0; - - virtual HRESULT STDMETHODCALLTYPE QueryControl( - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetExternalDispatch( - /* [in] */ IDispatch *pDisp) = 0; - - virtual HRESULT STDMETHODCALLTYPE SetExternalUIHandler( - /* [in] */ IDocHostUIHandlerDispatch *pDisp) = 0; - - }; - -#else /* C style interface */ - - typedef struct IAxWinHostWindowVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAxWinHostWindow * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAxWinHostWindow * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IAxWinHostWindow * This); - - HRESULT ( STDMETHODCALLTYPE *CreateControl )( - IAxWinHostWindow * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream); - - HRESULT ( STDMETHODCALLTYPE *CreateControlEx )( - IAxWinHostWindow * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise); - - HRESULT ( STDMETHODCALLTYPE *AttachControl )( - IAxWinHostWindow * This, - /* [in] */ IUnknown *pUnkControl, - /* [in] */ HWND hWnd); - - HRESULT ( STDMETHODCALLTYPE *QueryControl )( - IAxWinHostWindow * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - HRESULT ( STDMETHODCALLTYPE *SetExternalDispatch )( - IAxWinHostWindow * This, - /* [in] */ IDispatch *pDisp); - - HRESULT ( STDMETHODCALLTYPE *SetExternalUIHandler )( - IAxWinHostWindow * This, - /* [in] */ IDocHostUIHandlerDispatch *pDisp); - - END_INTERFACE - } IAxWinHostWindowVtbl; - - interface IAxWinHostWindow - { - CONST_VTBL struct IAxWinHostWindowVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IAxWinHostWindow_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IAxWinHostWindow_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IAxWinHostWindow_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IAxWinHostWindow_CreateControl(This,lpTricsData,hWnd,pStream) \ - (This)->lpVtbl -> CreateControl(This,lpTricsData,hWnd,pStream) - -#define IAxWinHostWindow_CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) \ - (This)->lpVtbl -> CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) - -#define IAxWinHostWindow_AttachControl(This,pUnkControl,hWnd) \ - (This)->lpVtbl -> AttachControl(This,pUnkControl,hWnd) - -#define IAxWinHostWindow_QueryControl(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryControl(This,riid,ppvObject) - -#define IAxWinHostWindow_SetExternalDispatch(This,pDisp) \ - (This)->lpVtbl -> SetExternalDispatch(This,pDisp) - -#define IAxWinHostWindow_SetExternalUIHandler(This,pDisp) \ - (This)->lpVtbl -> SetExternalUIHandler(This,pDisp) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IAxWinHostWindow_CreateControl_Proxy( - IAxWinHostWindow * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream); - - -void __RPC_STUB IAxWinHostWindow_CreateControl_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IAxWinHostWindow_CreateControlEx_Proxy( - IAxWinHostWindow * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise); - - -void __RPC_STUB IAxWinHostWindow_CreateControlEx_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IAxWinHostWindow_AttachControl_Proxy( - IAxWinHostWindow * This, - /* [in] */ IUnknown *pUnkControl, - /* [in] */ HWND hWnd); - - -void __RPC_STUB IAxWinHostWindow_AttachControl_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IAxWinHostWindow_QueryControl_Proxy( - IAxWinHostWindow * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - -void __RPC_STUB IAxWinHostWindow_QueryControl_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IAxWinHostWindow_SetExternalDispatch_Proxy( - IAxWinHostWindow * This, - /* [in] */ IDispatch *pDisp); - - -void __RPC_STUB IAxWinHostWindow_SetExternalDispatch_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IAxWinHostWindow_SetExternalUIHandler_Proxy( - IAxWinHostWindow * This, - /* [in] */ IDocHostUIHandlerDispatch *pDisp); - - -void __RPC_STUB IAxWinHostWindow_SetExternalUIHandler_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IAxWinHostWindow_INTERFACE_DEFINED__ */ - - -#ifndef __IAxWinHostWindowLic_INTERFACE_DEFINED__ -#define __IAxWinHostWindowLic_INTERFACE_DEFINED__ - -/* interface IAxWinHostWindowLic */ -/* [object][unique][helpstring][uuid] */ - - -EXTERN_C const IID IID_IAxWinHostWindowLic; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("3935BDA8-4ED9-495c-8650-E01FC1E38A4B") - IAxWinHostWindowLic : public IAxWinHostWindow - { - public: - virtual HRESULT STDMETHODCALLTYPE CreateControlLic( - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [in] */ BSTR bstrLic) = 0; - - virtual HRESULT STDMETHODCALLTYPE CreateControlLicEx( - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise, - /* [in] */ BSTR bstrLic) = 0; - - }; - -#else /* C style interface */ - - typedef struct IAxWinHostWindowLicVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAxWinHostWindowLic * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAxWinHostWindowLic * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IAxWinHostWindowLic * This); - - HRESULT ( STDMETHODCALLTYPE *CreateControl )( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream); - - HRESULT ( STDMETHODCALLTYPE *CreateControlEx )( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise); - - HRESULT ( STDMETHODCALLTYPE *AttachControl )( - IAxWinHostWindowLic * This, - /* [in] */ IUnknown *pUnkControl, - /* [in] */ HWND hWnd); - - HRESULT ( STDMETHODCALLTYPE *QueryControl )( - IAxWinHostWindowLic * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - HRESULT ( STDMETHODCALLTYPE *SetExternalDispatch )( - IAxWinHostWindowLic * This, - /* [in] */ IDispatch *pDisp); - - HRESULT ( STDMETHODCALLTYPE *SetExternalUIHandler )( - IAxWinHostWindowLic * This, - /* [in] */ IDocHostUIHandlerDispatch *pDisp); - - HRESULT ( STDMETHODCALLTYPE *CreateControlLic )( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [in] */ BSTR bstrLic); - - HRESULT ( STDMETHODCALLTYPE *CreateControlLicEx )( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise, - /* [in] */ BSTR bstrLic); - - END_INTERFACE - } IAxWinHostWindowLicVtbl; - - interface IAxWinHostWindowLic - { - CONST_VTBL struct IAxWinHostWindowLicVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IAxWinHostWindowLic_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IAxWinHostWindowLic_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IAxWinHostWindowLic_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IAxWinHostWindowLic_CreateControl(This,lpTricsData,hWnd,pStream) \ - (This)->lpVtbl -> CreateControl(This,lpTricsData,hWnd,pStream) - -#define IAxWinHostWindowLic_CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) \ - (This)->lpVtbl -> CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) - -#define IAxWinHostWindowLic_AttachControl(This,pUnkControl,hWnd) \ - (This)->lpVtbl -> AttachControl(This,pUnkControl,hWnd) - -#define IAxWinHostWindowLic_QueryControl(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryControl(This,riid,ppvObject) - -#define IAxWinHostWindowLic_SetExternalDispatch(This,pDisp) \ - (This)->lpVtbl -> SetExternalDispatch(This,pDisp) - -#define IAxWinHostWindowLic_SetExternalUIHandler(This,pDisp) \ - (This)->lpVtbl -> SetExternalUIHandler(This,pDisp) - - -#define IAxWinHostWindowLic_CreateControlLic(This,lpTricsData,hWnd,pStream,bstrLic) \ - (This)->lpVtbl -> CreateControlLic(This,lpTricsData,hWnd,pStream,bstrLic) - -#define IAxWinHostWindowLic_CreateControlLicEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise,bstrLic) \ - (This)->lpVtbl -> CreateControlLicEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise,bstrLic) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IAxWinHostWindowLic_CreateControlLic_Proxy( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [in] */ BSTR bstrLic); - - -void __RPC_STUB IAxWinHostWindowLic_CreateControlLic_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IAxWinHostWindowLic_CreateControlLicEx_Proxy( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise, - /* [in] */ BSTR bstrLic); - - -void __RPC_STUB IAxWinHostWindowLic_CreateControlLicEx_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IAxWinHostWindowLic_INTERFACE_DEFINED__ */ - - -#ifndef __IAxWinAmbientDispatch_INTERFACE_DEFINED__ -#define __IAxWinAmbientDispatch_INTERFACE_DEFINED__ - -/* interface IAxWinAmbientDispatch */ -/* [unique][helpstring][uuid][dual][object] */ - - -EXTERN_C const IID IID_IAxWinAmbientDispatch; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("B6EA2051-048A-11d1-82B9-00C04FB9942E") - IAxWinAmbientDispatch : public IDispatch - { - public: - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_AllowWindowlessActivation( - /* [in] */ VARIANT_BOOL bCanWindowlessActivate) = 0; - - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_AllowWindowlessActivation( - /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate) = 0; - - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_BackColor( - /* [in] */ OLE_COLOR clrBackground) = 0; - - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_BackColor( - /* [retval][out] */ OLE_COLOR *pclrBackground) = 0; - - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_ForeColor( - /* [in] */ OLE_COLOR clrForeground) = 0; - - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ForeColor( - /* [retval][out] */ OLE_COLOR *pclrForeground) = 0; - - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_LocaleID( - /* [in] */ LCID lcidLocaleID) = 0; - - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_LocaleID( - /* [retval][out] */ LCID *plcidLocaleID) = 0; - - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_UserMode( - /* [in] */ VARIANT_BOOL bUserMode) = 0; - - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_UserMode( - /* [retval][out] */ VARIANT_BOOL *pbUserMode) = 0; - - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_DisplayAsDefault( - /* [in] */ VARIANT_BOOL bDisplayAsDefault) = 0; - - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_DisplayAsDefault( - /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault) = 0; - - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_Font( - /* [in] */ IFontDisp *pFont) = 0; - - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_Font( - /* [retval][out] */ IFontDisp **pFont) = 0; - - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_MessageReflect( - /* [in] */ VARIANT_BOOL bMsgReflect) = 0; - - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_MessageReflect( - /* [retval][out] */ VARIANT_BOOL *pbMsgReflect) = 0; - - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ShowGrabHandles( - /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles) = 0; - - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ShowHatching( - /* [retval][out] */ VARIANT_BOOL *pbShowHatching) = 0; - - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_DocHostFlags( - /* [in] */ DWORD dwDocHostFlags) = 0; - - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_DocHostFlags( - /* [retval][out] */ DWORD *pdwDocHostFlags) = 0; - - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_DocHostDoubleClickFlags( - /* [in] */ DWORD dwDocHostDoubleClickFlags) = 0; - - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_DocHostDoubleClickFlags( - /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags) = 0; - - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_AllowContextMenu( - /* [in] */ VARIANT_BOOL bAllowContextMenu) = 0; - - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_AllowContextMenu( - /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu) = 0; - - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_AllowShowUI( - /* [in] */ VARIANT_BOOL bAllowShowUI) = 0; - - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_AllowShowUI( - /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI) = 0; - - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_OptionKeyPath( - /* [in] */ BSTR bstrOptionKeyPath) = 0; - - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_OptionKeyPath( - /* [retval][out] */ BSTR *pbstrOptionKeyPath) = 0; - - }; - -#else /* C style interface */ - - typedef struct IAxWinAmbientDispatchVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAxWinAmbientDispatch * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAxWinAmbientDispatch * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IAxWinAmbientDispatch * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - IAxWinAmbientDispatch * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - IAxWinAmbientDispatch * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - IAxWinAmbientDispatch * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - IAxWinAmbientDispatch * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowWindowlessActivation )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bCanWindowlessActivate); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowWindowlessActivation )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_BackColor )( - IAxWinAmbientDispatch * This, - /* [in] */ OLE_COLOR clrBackground); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_BackColor )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ OLE_COLOR *pclrBackground); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_ForeColor )( - IAxWinAmbientDispatch * This, - /* [in] */ OLE_COLOR clrForeground); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ForeColor )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ OLE_COLOR *pclrForeground); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_LocaleID )( - IAxWinAmbientDispatch * This, - /* [in] */ LCID lcidLocaleID); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_LocaleID )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ LCID *plcidLocaleID); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_UserMode )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bUserMode); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_UserMode )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbUserMode); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DisplayAsDefault )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bDisplayAsDefault); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DisplayAsDefault )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Font )( - IAxWinAmbientDispatch * This, - /* [in] */ IFontDisp *pFont); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Font )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ IFontDisp **pFont); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_MessageReflect )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bMsgReflect); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_MessageReflect )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbMsgReflect); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowGrabHandles )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowHatching )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbShowHatching); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostFlags )( - IAxWinAmbientDispatch * This, - /* [in] */ DWORD dwDocHostFlags); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostFlags )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ DWORD *pdwDocHostFlags); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostDoubleClickFlags )( - IAxWinAmbientDispatch * This, - /* [in] */ DWORD dwDocHostDoubleClickFlags); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostDoubleClickFlags )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowContextMenu )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bAllowContextMenu); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowContextMenu )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowShowUI )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bAllowShowUI); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowShowUI )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_OptionKeyPath )( - IAxWinAmbientDispatch * This, - /* [in] */ BSTR bstrOptionKeyPath); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_OptionKeyPath )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ BSTR *pbstrOptionKeyPath); - - END_INTERFACE - } IAxWinAmbientDispatchVtbl; - - interface IAxWinAmbientDispatch - { - CONST_VTBL struct IAxWinAmbientDispatchVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IAxWinAmbientDispatch_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IAxWinAmbientDispatch_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IAxWinAmbientDispatch_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IAxWinAmbientDispatch_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define IAxWinAmbientDispatch_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define IAxWinAmbientDispatch_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define IAxWinAmbientDispatch_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define IAxWinAmbientDispatch_put_AllowWindowlessActivation(This,bCanWindowlessActivate) \ - (This)->lpVtbl -> put_AllowWindowlessActivation(This,bCanWindowlessActivate) - -#define IAxWinAmbientDispatch_get_AllowWindowlessActivation(This,pbCanWindowlessActivate) \ - (This)->lpVtbl -> get_AllowWindowlessActivation(This,pbCanWindowlessActivate) - -#define IAxWinAmbientDispatch_put_BackColor(This,clrBackground) \ - (This)->lpVtbl -> put_BackColor(This,clrBackground) - -#define IAxWinAmbientDispatch_get_BackColor(This,pclrBackground) \ - (This)->lpVtbl -> get_BackColor(This,pclrBackground) - -#define IAxWinAmbientDispatch_put_ForeColor(This,clrForeground) \ - (This)->lpVtbl -> put_ForeColor(This,clrForeground) - -#define IAxWinAmbientDispatch_get_ForeColor(This,pclrForeground) \ - (This)->lpVtbl -> get_ForeColor(This,pclrForeground) - -#define IAxWinAmbientDispatch_put_LocaleID(This,lcidLocaleID) \ - (This)->lpVtbl -> put_LocaleID(This,lcidLocaleID) - -#define IAxWinAmbientDispatch_get_LocaleID(This,plcidLocaleID) \ - (This)->lpVtbl -> get_LocaleID(This,plcidLocaleID) - -#define IAxWinAmbientDispatch_put_UserMode(This,bUserMode) \ - (This)->lpVtbl -> put_UserMode(This,bUserMode) - -#define IAxWinAmbientDispatch_get_UserMode(This,pbUserMode) \ - (This)->lpVtbl -> get_UserMode(This,pbUserMode) - -#define IAxWinAmbientDispatch_put_DisplayAsDefault(This,bDisplayAsDefault) \ - (This)->lpVtbl -> put_DisplayAsDefault(This,bDisplayAsDefault) - -#define IAxWinAmbientDispatch_get_DisplayAsDefault(This,pbDisplayAsDefault) \ - (This)->lpVtbl -> get_DisplayAsDefault(This,pbDisplayAsDefault) - -#define IAxWinAmbientDispatch_put_Font(This,pFont) \ - (This)->lpVtbl -> put_Font(This,pFont) - -#define IAxWinAmbientDispatch_get_Font(This,pFont) \ - (This)->lpVtbl -> get_Font(This,pFont) - -#define IAxWinAmbientDispatch_put_MessageReflect(This,bMsgReflect) \ - (This)->lpVtbl -> put_MessageReflect(This,bMsgReflect) - -#define IAxWinAmbientDispatch_get_MessageReflect(This,pbMsgReflect) \ - (This)->lpVtbl -> get_MessageReflect(This,pbMsgReflect) - -#define IAxWinAmbientDispatch_get_ShowGrabHandles(This,pbShowGrabHandles) \ - (This)->lpVtbl -> get_ShowGrabHandles(This,pbShowGrabHandles) - -#define IAxWinAmbientDispatch_get_ShowHatching(This,pbShowHatching) \ - (This)->lpVtbl -> get_ShowHatching(This,pbShowHatching) - -#define IAxWinAmbientDispatch_put_DocHostFlags(This,dwDocHostFlags) \ - (This)->lpVtbl -> put_DocHostFlags(This,dwDocHostFlags) - -#define IAxWinAmbientDispatch_get_DocHostFlags(This,pdwDocHostFlags) \ - (This)->lpVtbl -> get_DocHostFlags(This,pdwDocHostFlags) - -#define IAxWinAmbientDispatch_put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) \ - (This)->lpVtbl -> put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) - -#define IAxWinAmbientDispatch_get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) \ - (This)->lpVtbl -> get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) - -#define IAxWinAmbientDispatch_put_AllowContextMenu(This,bAllowContextMenu) \ - (This)->lpVtbl -> put_AllowContextMenu(This,bAllowContextMenu) - -#define IAxWinAmbientDispatch_get_AllowContextMenu(This,pbAllowContextMenu) \ - (This)->lpVtbl -> get_AllowContextMenu(This,pbAllowContextMenu) - -#define IAxWinAmbientDispatch_put_AllowShowUI(This,bAllowShowUI) \ - (This)->lpVtbl -> put_AllowShowUI(This,bAllowShowUI) - -#define IAxWinAmbientDispatch_get_AllowShowUI(This,pbAllowShowUI) \ - (This)->lpVtbl -> get_AllowShowUI(This,pbAllowShowUI) - -#define IAxWinAmbientDispatch_put_OptionKeyPath(This,bstrOptionKeyPath) \ - (This)->lpVtbl -> put_OptionKeyPath(This,bstrOptionKeyPath) - -#define IAxWinAmbientDispatch_get_OptionKeyPath(This,pbstrOptionKeyPath) \ - (This)->lpVtbl -> get_OptionKeyPath(This,pbstrOptionKeyPath) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_AllowWindowlessActivation_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bCanWindowlessActivate); - - -void __RPC_STUB IAxWinAmbientDispatch_put_AllowWindowlessActivation_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_AllowWindowlessActivation_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate); - - -void __RPC_STUB IAxWinAmbientDispatch_get_AllowWindowlessActivation_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_BackColor_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ OLE_COLOR clrBackground); - - -void __RPC_STUB IAxWinAmbientDispatch_put_BackColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_BackColor_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ OLE_COLOR *pclrBackground); - - -void __RPC_STUB IAxWinAmbientDispatch_get_BackColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_ForeColor_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ OLE_COLOR clrForeground); - - -void __RPC_STUB IAxWinAmbientDispatch_put_ForeColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_ForeColor_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ OLE_COLOR *pclrForeground); - - -void __RPC_STUB IAxWinAmbientDispatch_get_ForeColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_LocaleID_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ LCID lcidLocaleID); - - -void __RPC_STUB IAxWinAmbientDispatch_put_LocaleID_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_LocaleID_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ LCID *plcidLocaleID); - - -void __RPC_STUB IAxWinAmbientDispatch_get_LocaleID_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_UserMode_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bUserMode); - - -void __RPC_STUB IAxWinAmbientDispatch_put_UserMode_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_UserMode_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbUserMode); - - -void __RPC_STUB IAxWinAmbientDispatch_get_UserMode_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_DisplayAsDefault_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bDisplayAsDefault); - - -void __RPC_STUB IAxWinAmbientDispatch_put_DisplayAsDefault_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_DisplayAsDefault_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault); - - -void __RPC_STUB IAxWinAmbientDispatch_get_DisplayAsDefault_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_Font_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ IFontDisp *pFont); - - -void __RPC_STUB IAxWinAmbientDispatch_put_Font_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_Font_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ IFontDisp **pFont); - - -void __RPC_STUB IAxWinAmbientDispatch_get_Font_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_MessageReflect_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bMsgReflect); - - -void __RPC_STUB IAxWinAmbientDispatch_put_MessageReflect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_MessageReflect_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbMsgReflect); - - -void __RPC_STUB IAxWinAmbientDispatch_get_MessageReflect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_ShowGrabHandles_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles); - - -void __RPC_STUB IAxWinAmbientDispatch_get_ShowGrabHandles_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_ShowHatching_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbShowHatching); - - -void __RPC_STUB IAxWinAmbientDispatch_get_ShowHatching_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_DocHostFlags_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ DWORD dwDocHostFlags); - - -void __RPC_STUB IAxWinAmbientDispatch_put_DocHostFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_DocHostFlags_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ DWORD *pdwDocHostFlags); - - -void __RPC_STUB IAxWinAmbientDispatch_get_DocHostFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_DocHostDoubleClickFlags_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ DWORD dwDocHostDoubleClickFlags); - - -void __RPC_STUB IAxWinAmbientDispatch_put_DocHostDoubleClickFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_DocHostDoubleClickFlags_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags); - - -void __RPC_STUB IAxWinAmbientDispatch_get_DocHostDoubleClickFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_AllowContextMenu_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bAllowContextMenu); - - -void __RPC_STUB IAxWinAmbientDispatch_put_AllowContextMenu_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_AllowContextMenu_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu); - - -void __RPC_STUB IAxWinAmbientDispatch_get_AllowContextMenu_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_AllowShowUI_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bAllowShowUI); - - -void __RPC_STUB IAxWinAmbientDispatch_put_AllowShowUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_AllowShowUI_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI); - - -void __RPC_STUB IAxWinAmbientDispatch_get_AllowShowUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_OptionKeyPath_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ BSTR bstrOptionKeyPath); - - -void __RPC_STUB IAxWinAmbientDispatch_put_OptionKeyPath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_OptionKeyPath_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ BSTR *pbstrOptionKeyPath); - - -void __RPC_STUB IAxWinAmbientDispatch_get_OptionKeyPath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IAxWinAmbientDispatch_INTERFACE_DEFINED__ */ - - -#ifndef __IAxWinAmbientDispatchEx_INTERFACE_DEFINED__ -#define __IAxWinAmbientDispatchEx_INTERFACE_DEFINED__ - -/* interface IAxWinAmbientDispatchEx */ -/* [unique][helpstring][uuid][dual][object] */ - - -EXTERN_C const IID IID_IAxWinAmbientDispatchEx; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("B2D0778B-AC99-4c58-A5C8-E7724E5316B5") - IAxWinAmbientDispatchEx : public IAxWinAmbientDispatch - { - public: - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetAmbientDispatch( - /* [in] */ IDispatch *pDispatch) = 0; - - }; - -#else /* C style interface */ - - typedef struct IAxWinAmbientDispatchExVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAxWinAmbientDispatchEx * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAxWinAmbientDispatchEx * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IAxWinAmbientDispatchEx * This); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - IAxWinAmbientDispatchEx * This, - /* [out] */ UINT *pctinfo); - - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - IAxWinAmbientDispatchEx * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); - - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - IAxWinAmbientDispatchEx * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - IAxWinAmbientDispatchEx * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowWindowlessActivation )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bCanWindowlessActivate); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowWindowlessActivation )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_BackColor )( - IAxWinAmbientDispatchEx * This, - /* [in] */ OLE_COLOR clrBackground); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_BackColor )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ OLE_COLOR *pclrBackground); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_ForeColor )( - IAxWinAmbientDispatchEx * This, - /* [in] */ OLE_COLOR clrForeground); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ForeColor )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ OLE_COLOR *pclrForeground); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_LocaleID )( - IAxWinAmbientDispatchEx * This, - /* [in] */ LCID lcidLocaleID); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_LocaleID )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ LCID *plcidLocaleID); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_UserMode )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bUserMode); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_UserMode )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbUserMode); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DisplayAsDefault )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bDisplayAsDefault); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DisplayAsDefault )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Font )( - IAxWinAmbientDispatchEx * This, - /* [in] */ IFontDisp *pFont); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Font )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ IFontDisp **pFont); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_MessageReflect )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bMsgReflect); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_MessageReflect )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbMsgReflect); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowGrabHandles )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowHatching )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbShowHatching); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostFlags )( - IAxWinAmbientDispatchEx * This, - /* [in] */ DWORD dwDocHostFlags); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostFlags )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ DWORD *pdwDocHostFlags); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostDoubleClickFlags )( - IAxWinAmbientDispatchEx * This, - /* [in] */ DWORD dwDocHostDoubleClickFlags); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostDoubleClickFlags )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowContextMenu )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bAllowContextMenu); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowContextMenu )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowShowUI )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bAllowShowUI); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowShowUI )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_OptionKeyPath )( - IAxWinAmbientDispatchEx * This, - /* [in] */ BSTR bstrOptionKeyPath); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_OptionKeyPath )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ BSTR *pbstrOptionKeyPath); - - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetAmbientDispatch )( - IAxWinAmbientDispatchEx * This, - /* [in] */ IDispatch *pDispatch); - - END_INTERFACE - } IAxWinAmbientDispatchExVtbl; - - interface IAxWinAmbientDispatchEx - { - CONST_VTBL struct IAxWinAmbientDispatchExVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IAxWinAmbientDispatchEx_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IAxWinAmbientDispatchEx_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IAxWinAmbientDispatchEx_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IAxWinAmbientDispatchEx_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define IAxWinAmbientDispatchEx_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define IAxWinAmbientDispatchEx_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define IAxWinAmbientDispatchEx_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define IAxWinAmbientDispatchEx_put_AllowWindowlessActivation(This,bCanWindowlessActivate) \ - (This)->lpVtbl -> put_AllowWindowlessActivation(This,bCanWindowlessActivate) - -#define IAxWinAmbientDispatchEx_get_AllowWindowlessActivation(This,pbCanWindowlessActivate) \ - (This)->lpVtbl -> get_AllowWindowlessActivation(This,pbCanWindowlessActivate) - -#define IAxWinAmbientDispatchEx_put_BackColor(This,clrBackground) \ - (This)->lpVtbl -> put_BackColor(This,clrBackground) - -#define IAxWinAmbientDispatchEx_get_BackColor(This,pclrBackground) \ - (This)->lpVtbl -> get_BackColor(This,pclrBackground) - -#define IAxWinAmbientDispatchEx_put_ForeColor(This,clrForeground) \ - (This)->lpVtbl -> put_ForeColor(This,clrForeground) - -#define IAxWinAmbientDispatchEx_get_ForeColor(This,pclrForeground) \ - (This)->lpVtbl -> get_ForeColor(This,pclrForeground) - -#define IAxWinAmbientDispatchEx_put_LocaleID(This,lcidLocaleID) \ - (This)->lpVtbl -> put_LocaleID(This,lcidLocaleID) - -#define IAxWinAmbientDispatchEx_get_LocaleID(This,plcidLocaleID) \ - (This)->lpVtbl -> get_LocaleID(This,plcidLocaleID) - -#define IAxWinAmbientDispatchEx_put_UserMode(This,bUserMode) \ - (This)->lpVtbl -> put_UserMode(This,bUserMode) - -#define IAxWinAmbientDispatchEx_get_UserMode(This,pbUserMode) \ - (This)->lpVtbl -> get_UserMode(This,pbUserMode) - -#define IAxWinAmbientDispatchEx_put_DisplayAsDefault(This,bDisplayAsDefault) \ - (This)->lpVtbl -> put_DisplayAsDefault(This,bDisplayAsDefault) - -#define IAxWinAmbientDispatchEx_get_DisplayAsDefault(This,pbDisplayAsDefault) \ - (This)->lpVtbl -> get_DisplayAsDefault(This,pbDisplayAsDefault) - -#define IAxWinAmbientDispatchEx_put_Font(This,pFont) \ - (This)->lpVtbl -> put_Font(This,pFont) - -#define IAxWinAmbientDispatchEx_get_Font(This,pFont) \ - (This)->lpVtbl -> get_Font(This,pFont) - -#define IAxWinAmbientDispatchEx_put_MessageReflect(This,bMsgReflect) \ - (This)->lpVtbl -> put_MessageReflect(This,bMsgReflect) - -#define IAxWinAmbientDispatchEx_get_MessageReflect(This,pbMsgReflect) \ - (This)->lpVtbl -> get_MessageReflect(This,pbMsgReflect) - -#define IAxWinAmbientDispatchEx_get_ShowGrabHandles(This,pbShowGrabHandles) \ - (This)->lpVtbl -> get_ShowGrabHandles(This,pbShowGrabHandles) - -#define IAxWinAmbientDispatchEx_get_ShowHatching(This,pbShowHatching) \ - (This)->lpVtbl -> get_ShowHatching(This,pbShowHatching) - -#define IAxWinAmbientDispatchEx_put_DocHostFlags(This,dwDocHostFlags) \ - (This)->lpVtbl -> put_DocHostFlags(This,dwDocHostFlags) - -#define IAxWinAmbientDispatchEx_get_DocHostFlags(This,pdwDocHostFlags) \ - (This)->lpVtbl -> get_DocHostFlags(This,pdwDocHostFlags) - -#define IAxWinAmbientDispatchEx_put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) \ - (This)->lpVtbl -> put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) - -#define IAxWinAmbientDispatchEx_get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) \ - (This)->lpVtbl -> get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) - -#define IAxWinAmbientDispatchEx_put_AllowContextMenu(This,bAllowContextMenu) \ - (This)->lpVtbl -> put_AllowContextMenu(This,bAllowContextMenu) - -#define IAxWinAmbientDispatchEx_get_AllowContextMenu(This,pbAllowContextMenu) \ - (This)->lpVtbl -> get_AllowContextMenu(This,pbAllowContextMenu) - -#define IAxWinAmbientDispatchEx_put_AllowShowUI(This,bAllowShowUI) \ - (This)->lpVtbl -> put_AllowShowUI(This,bAllowShowUI) - -#define IAxWinAmbientDispatchEx_get_AllowShowUI(This,pbAllowShowUI) \ - (This)->lpVtbl -> get_AllowShowUI(This,pbAllowShowUI) - -#define IAxWinAmbientDispatchEx_put_OptionKeyPath(This,bstrOptionKeyPath) \ - (This)->lpVtbl -> put_OptionKeyPath(This,bstrOptionKeyPath) - -#define IAxWinAmbientDispatchEx_get_OptionKeyPath(This,pbstrOptionKeyPath) \ - (This)->lpVtbl -> get_OptionKeyPath(This,pbstrOptionKeyPath) - - -#define IAxWinAmbientDispatchEx_SetAmbientDispatch(This,pDispatch) \ - (This)->lpVtbl -> SetAmbientDispatch(This,pDispatch) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [id] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatchEx_SetAmbientDispatch_Proxy( - IAxWinAmbientDispatchEx * This, - /* [in] */ IDispatch *pDispatch); - - -void __RPC_STUB IAxWinAmbientDispatchEx_SetAmbientDispatch_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IAxWinAmbientDispatchEx_INTERFACE_DEFINED__ */ - - -#ifndef __IInternalConnection_INTERFACE_DEFINED__ -#define __IInternalConnection_INTERFACE_DEFINED__ - -/* interface IInternalConnection */ -/* [object][unique][helpstring][uuid] */ - - -EXTERN_C const IID IID_IInternalConnection; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("72AD0770-6A9F-11d1-BCEC-0060088F444E") - IInternalConnection : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE AddConnection( void) = 0; - - virtual HRESULT STDMETHODCALLTYPE ReleaseConnection( void) = 0; - - }; - -#else /* C style interface */ - - typedef struct IInternalConnectionVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IInternalConnection * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IInternalConnection * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IInternalConnection * This); - - HRESULT ( STDMETHODCALLTYPE *AddConnection )( - IInternalConnection * This); - - HRESULT ( STDMETHODCALLTYPE *ReleaseConnection )( - IInternalConnection * This); - - END_INTERFACE - } IInternalConnectionVtbl; - - interface IInternalConnection - { - CONST_VTBL struct IInternalConnectionVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IInternalConnection_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IInternalConnection_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IInternalConnection_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IInternalConnection_AddConnection(This) \ - (This)->lpVtbl -> AddConnection(This) - -#define IInternalConnection_ReleaseConnection(This) \ - (This)->lpVtbl -> ReleaseConnection(This) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IInternalConnection_AddConnection_Proxy( - IInternalConnection * This); - - -void __RPC_STUB IInternalConnection_AddConnection_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IInternalConnection_ReleaseConnection_Proxy( - IInternalConnection * This); - - -void __RPC_STUB IInternalConnection_ReleaseConnection_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IInternalConnection_INTERFACE_DEFINED__ */ - - -/* interface __MIDL_itf_atliface_0257 */ -/* [local] */ - - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ -#ifdef __cplusplus -#include -#else -#define ATLAPI EXTERN_C HRESULT __declspec(dllimport) __stdcall -#define ATLAPI_(x) EXTERN_C __declspec(dllimport) x __stdcall -#define ATLINLINE -#endif // __cplusplus - -ATLAPI_(INT_PTR) AtlAxDialogBoxW(HINSTANCE hInstance, LPCWSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogProc, LPARAM dwInitParam); -ATLAPI_(INT_PTR) AtlAxDialogBoxA(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogProc, LPARAM dwInitParam); -#ifdef UNICODE -#define AtlAxDialogBox AtlAxDialogBoxW -#else -#define AtlAxDialogBox AtlAxDialogBoxA -#endif - -ATLAPI_(HWND) AtlAxCreateDialogW(HINSTANCE hInstance, LPCWSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogProc, LPARAM dwInitParam); -ATLAPI_(HWND) AtlAxCreateDialogA(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogProc, LPARAM dwInitParam); -#ifdef UNICODE -#define AtlAxCreateDialog AtlAxCreateDialogW -#else -#define AtlAxCreateDialog AtlAxCreateDialogA -#endif - -ATLAPI AtlAxCreateControl(LPCOLESTR lpszName, HWND hWnd, IStream* pStream, IUnknown** ppUnkContainer); -#ifdef __cplusplus -ATLAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd, IStream* pStream, - IUnknown** ppUnkContainer, IUnknown** ppUnkControl, - REFIID iidSink=IID_NULL, IUnknown* punkSink=NULL); -ATLAPI AtlAxCreateControlLic(LPCOLESTR lpszName, HWND hWnd, IStream* pStream, IUnknown** ppUnkContainer, BSTR bstrLic = NULL); -ATLAPI AtlAxCreateControlLicEx(LPCOLESTR lpszName, HWND hWnd, IStream* pStream, - IUnknown** ppUnkContainer, IUnknown** ppUnkControl, - REFIID iidSink=IID_NULL, IUnknown* punkSink=NULL, BSTR bstrLic = NULL); -#else -ATLAPI AtlAxCreateControlEx(LPCOLESTR lpszName, HWND hWnd, IStream* pStream, - IUnknown** ppUnkContainer, IUnknown** ppUnkControl, - REFIID iidSink, IUnknown* punkSink); -ATLAPI AtlAxCreateControlLic(LPCOLESTR lpszName, HWND hWnd, IStream* pStream, IUnknown** ppUnkContainer, BSTR bstrLic); -ATLAPI AtlAxCreateControlLicEx(LPCOLESTR lpszName, HWND hWnd, IStream* pStream, - IUnknown** ppUnkContainer, IUnknown** ppUnkControl, - REFIID iidSink, IUnknown* punkSink, BSTR bstrLic); -#endif // __cplusplus -ATLAPI AtlAxAttachControl(IUnknown* pControl, HWND hWnd, IUnknown** ppUnkContainer); -ATLAPI_(BOOL) AtlAxWinInit(); - -ATLAPI AtlAxGetHost(HWND h, IUnknown** pp); -ATLAPI AtlAxGetControl(HWND h, IUnknown** pp); - -}; //namespace ATL -#pragma pack(pop) - -extern RPC_IF_HANDLE __MIDL_itf_atliface_0257_v0_0_c_ifspec; -extern RPC_IF_HANDLE __MIDL_itf_atliface_0257_v0_0_s_ifspec; - -#ifndef __IAccessibleProxy_INTERFACE_DEFINED__ -#define __IAccessibleProxy_INTERFACE_DEFINED__ - -/* interface IAccessibleProxy */ -/* [unique][helpstring][dual][uuid][object] */ - - -EXTERN_C const IID IID_IAccessibleProxy; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("7A7D9DCF-B7A1-4019-9031-258268846980") - IAccessibleProxy : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetServer( - /* [in] */ IAccessible *pAccessible, - /* [in] */ IAccessibleServer *pServer) = 0; - - }; - -#else /* C style interface */ - - typedef struct IAccessibleProxyVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAccessibleProxy * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAccessibleProxy * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IAccessibleProxy * This); - - HRESULT ( STDMETHODCALLTYPE *SetServer )( - IAccessibleProxy * This, - /* [in] */ IAccessible *pAccessible, - /* [in] */ IAccessibleServer *pServer); - - END_INTERFACE - } IAccessibleProxyVtbl; - - interface IAccessibleProxy - { - CONST_VTBL struct IAccessibleProxyVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IAccessibleProxy_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IAccessibleProxy_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IAccessibleProxy_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IAccessibleProxy_SetServer(This,pAccessible,pServer) \ - (This)->lpVtbl -> SetServer(This,pAccessible,pServer) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IAccessibleProxy_SetServer_Proxy( - IAccessibleProxy * This, - /* [in] */ IAccessible *pAccessible, - /* [in] */ IAccessibleServer *pServer); - - -void __RPC_STUB IAccessibleProxy_SetServer_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IAccessibleProxy_INTERFACE_DEFINED__ */ - - -#ifndef __IAccessibleServer_INTERFACE_DEFINED__ -#define __IAccessibleServer_INTERFACE_DEFINED__ - -/* interface IAccessibleServer */ -/* [unique][helpstring][uuid][object] */ - - -EXTERN_C const IID IID_IAccessibleServer; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("52C8FB5E-D779-4e77-AE9F-F611FA7E9D7A") - IAccessibleServer : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE SetProxy( - /* [in] */ IAccessibleProxy *pUnknown) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetHWND( - /* [out] */ HWND *phWnd) = 0; - - virtual HRESULT STDMETHODCALLTYPE GetEnumVariant( - /* [out] */ IEnumVARIANT **ppEnumVariant) = 0; - - }; - -#else /* C style interface */ - - typedef struct IAccessibleServerVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAccessibleServer * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); - - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAccessibleServer * This); - - ULONG ( STDMETHODCALLTYPE *Release )( - IAccessibleServer * This); - - HRESULT ( STDMETHODCALLTYPE *SetProxy )( - IAccessibleServer * This, - /* [in] */ IAccessibleProxy *pUnknown); - - HRESULT ( STDMETHODCALLTYPE *GetHWND )( - IAccessibleServer * This, - /* [out] */ HWND *phWnd); - - HRESULT ( STDMETHODCALLTYPE *GetEnumVariant )( - IAccessibleServer * This, - /* [out] */ IEnumVARIANT **ppEnumVariant); - - END_INTERFACE - } IAccessibleServerVtbl; - - interface IAccessibleServer - { - CONST_VTBL struct IAccessibleServerVtbl *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IAccessibleServer_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IAccessibleServer_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IAccessibleServer_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IAccessibleServer_SetProxy(This,pUnknown) \ - (This)->lpVtbl -> SetProxy(This,pUnknown) - -#define IAccessibleServer_GetHWND(This,phWnd) \ - (This)->lpVtbl -> GetHWND(This,phWnd) - -#define IAccessibleServer_GetEnumVariant(This,ppEnumVariant) \ - (This)->lpVtbl -> GetEnumVariant(This,ppEnumVariant) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -HRESULT STDMETHODCALLTYPE IAccessibleServer_SetProxy_Proxy( - IAccessibleServer * This, - /* [in] */ IAccessibleProxy *pUnknown); - - -void __RPC_STUB IAccessibleServer_SetProxy_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IAccessibleServer_GetHWND_Proxy( - IAccessibleServer * This, - /* [out] */ HWND *phWnd); - - -void __RPC_STUB IAccessibleServer_GetHWND_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -HRESULT STDMETHODCALLTYPE IAccessibleServer_GetEnumVariant_Proxy( - IAccessibleServer * This, - /* [out] */ IEnumVARIANT **ppEnumVariant); - - -void __RPC_STUB IAccessibleServer_GetEnumVariant_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IAccessibleServer_INTERFACE_DEFINED__ */ - - -/* Additional Prototypes for ALL interfaces */ - -unsigned long __RPC_USER BSTR_UserSize( unsigned long *, unsigned long , BSTR * ); -unsigned char * __RPC_USER BSTR_UserMarshal( unsigned long *, unsigned char *, BSTR * ); -unsigned char * __RPC_USER BSTR_UserUnmarshal(unsigned long *, unsigned char *, BSTR * ); -void __RPC_USER BSTR_UserFree( unsigned long *, BSTR * ); - -unsigned long __RPC_USER HWND_UserSize( unsigned long *, unsigned long , HWND * ); -unsigned char * __RPC_USER HWND_UserMarshal( unsigned long *, unsigned char *, HWND * ); -unsigned char * __RPC_USER HWND_UserUnmarshal(unsigned long *, unsigned char *, HWND * ); -void __RPC_USER HWND_UserFree( unsigned long *, HWND * ); - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif - - - diff --git a/cpp/jacob/include/atlrc.h b/cpp/jacob/include/atlrc.h deleted file mode 100644 index a231b99..0000000 --- a/cpp/jacob/include/atlrc.h +++ /dev/null @@ -1,28 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#pragma once - -#ifndef __ATLRC_H__ - -#define ATL_RESID_BASE 0xD800 -#define ATL_STRING_BASE ATL_RESID_BASE - -#define ATL_IDS_DATETIME_INVALID (ATL_STRING_BASE + 0) -#define ATL_IDS_DATETIMESPAN_INVALID (ATL_STRING_BASE + 1) - -#define ATL_SERVICE_MANAGER_OPEN_ERROR (ATL_STRING_BASE + 10) -#define ATL_SERVICE_START_ERROR (ATL_STRING_BASE + 11) -#define ATL_SERVICE_OPEN_ERROR (ATL_STRING_BASE + 12) -#define ATL_SERVICE_DELETE_ERROR (ATL_STRING_BASE + 13) -#define ATL_SERVICE_STOP_ERROR (ATL_STRING_BASE + 14) - -#endif // __ATLRC_H__ - diff --git a/cpp/jacob/include/atlsimpcoll.h b/cpp/jacob/include/atlsimpcoll.h deleted file mode 100644 index 8a5277d..0000000 --- a/cpp/jacob/include/atlsimpcoll.h +++ /dev/null @@ -1,489 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLSIMPCOLL_H__ -#define __ATLSIMPCOLL_H__ - -#pragma once - -#include -#include -#include - -#pragma push_macro("malloc") -#undef malloc -#pragma push_macro("calloc") -#undef calloc -#pragma push_macro("realloc") -#undef realloc -#pragma push_macro("_recalloc") -#undef _recalloc -#pragma push_macro("free") -#undef free - -#pragma warning(push) -#pragma warning(disable: 4800) // forcing 'int' value to bool - - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ - -#pragma push_macro("new") -#undef new - -///////////////////////////////////////////////////////////////////////////// -// Collection helpers - CSimpleArray & CSimpleMap - -// template class helpers with functions for comparing elements -// override if using complex types without operator== -template -class CSimpleArrayEqualHelper -{ -public: - static bool IsEqual(const T& t1, const T& t2) - { - return (t1 == t2); - } -}; - -template -class CSimpleArrayEqualHelperFalse -{ -public: - static bool IsEqual(const T&, const T&) - { - ATLASSERT(false); - return false; - } -}; - -template -class CSimpleMapEqualHelper -{ -public: - static bool IsEqualKey(const TKey& k1, const TKey& k2) - { - return CSimpleArrayEqualHelper::IsEqual(k1, k2); - } - - static bool IsEqualValue(const TVal& v1, const TVal& v2) - { - return CSimpleArrayEqualHelper::IsEqual(v1, v2); - } -}; - -template -class CSimpleMapEqualHelperFalse -{ -public: - static bool IsEqualKey(const TKey& k1, const TKey& k2) - { - return CSimpleArrayEqualHelper::IsEqual(k1, k2); - } - - static bool IsEqualValue(const TVal&, const TVal&) - { - ATLASSERT(FALSE); - return false; - } -}; - -template > -class CSimpleArray -{ -public: -// Construction/destruction - CSimpleArray() : m_aT(NULL), m_nSize(0), m_nAllocSize(0) - { } - - ~CSimpleArray(); - - CSimpleArray(const CSimpleArray< T, TEqual >& src) : m_aT(NULL), m_nSize(0), m_nAllocSize(0) - { - if (src.GetSize()) - { - m_aT = (T*)calloc(src.GetSize(), sizeof(T)); - if (m_aT != NULL) - { - m_nAllocSize = src.GetSize(); - for (int i=0; i& operator=(const CSimpleArray< T, TEqual >& src) - { - if (GetSize() != src.GetSize()) - { - RemoveAll(); - m_aT = (T*)calloc(src.GetSize(), sizeof(T)); - if (m_aT != NULL) - m_nAllocSize = src.GetSize(); - } - else - { - for (int i = GetSize(); i > 0; i--) - RemoveAt(i - 1); - } - for (int i=0; iINT_MAX/sizeof(T)) - { - - - return FALSE; - - } - - - - aT = (T*)_recalloc(m_aT, nNewAllocSize, sizeof(T)); - if(aT == NULL) - return FALSE; - m_nAllocSize = nNewAllocSize; - m_aT = aT; - - } - InternalSetAtIndex(m_nSize, t); - m_nSize++; - return TRUE; - } - BOOL Remove(const T& t) - { - int nIndex = Find(t); - if(nIndex == -1) - return FALSE; - return RemoveAt(nIndex); - } - BOOL RemoveAt(int nIndex) - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if (nIndex < 0 || nIndex >= m_nSize) - return FALSE; - m_aT[nIndex].~T(); - if(nIndex != (m_nSize - 1)) - Checked::memmove_s((void*)(m_aT + nIndex), (m_nSize - nIndex) * sizeof(T), (void*)(m_aT + nIndex + 1), (m_nSize - (nIndex + 1)) * sizeof(T)); - m_nSize--; - return TRUE; - } - void RemoveAll() - { - if(m_aT != NULL) - { - for(int i = 0; i < m_nSize; i++) - m_aT[i].~T(); - free(m_aT); - m_aT = NULL; - } - m_nSize = 0; - m_nAllocSize = 0; - } - const T& operator[] (int nIndex) const - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if(nIndex < 0 || nIndex >= m_nSize) - { - _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); - } - return m_aT[nIndex]; - } - T& operator[] (int nIndex) - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if(nIndex < 0 || nIndex >= m_nSize) - { - _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); - } - return m_aT[nIndex]; - } - T* GetData() const - { - return m_aT; - } - - int Find(const T& t) const - { - for(int i = 0; i < m_nSize; i++) - { - if(TEqual::IsEqual(m_aT[i], t)) - return i; - } - return -1; // not found - } - - BOOL SetAtIndex(int nIndex, const T& t) - { - if (nIndex < 0 || nIndex >= m_nSize) - return FALSE; - InternalSetAtIndex(nIndex, t); - return TRUE; - } - -// Implementation - class Wrapper - { - public: - Wrapper(const T& _t) : t(_t) - { - } - template - void * __cdecl operator new(size_t, _Ty* p) - { - return p; - } - template - void __cdecl operator delete(void* /* pv */, _Ty* /* p */) - { - } - T t; - }; - -// Implementation - void InternalSetAtIndex(int nIndex, const T& t) - { - new(m_aT + nIndex) Wrapper(t); - } - - typedef T _ArrayElementType; - T* m_aT; - int m_nSize; - int m_nAllocSize; - -}; - -#define CSimpleValArray CSimpleArray - - template inline CSimpleArray::~CSimpleArray() - { - RemoveAll(); - } - -// intended for small number of simple types or pointers -template > -class CSimpleMap -{ -public: - TKey* m_aKey; - TVal* m_aVal; - int m_nSize; - - typedef TKey _ArrayKeyType; - typedef TVal _ArrayElementType; - -// Construction/destruction - CSimpleMap() : m_aKey(NULL), m_aVal(NULL), m_nSize(0) - { } - - ~CSimpleMap() - { - RemoveAll(); - } - -// Operations - int GetSize() const - { - return m_nSize; - } - BOOL Add(const TKey& key, const TVal& val) - { - TKey* pKey; - pKey = (TKey*)_recalloc(m_aKey, (m_nSize + 1), sizeof(TKey)); - if(pKey == NULL) - return FALSE; - m_aKey = pKey; - TVal* pVal; - pVal = (TVal*)_recalloc(m_aVal, (m_nSize + 1), sizeof(TVal)); - if(pVal == NULL) - return FALSE; - m_aVal = pVal; - InternalSetAtIndex(m_nSize, key, val); - m_nSize++; - return TRUE; - } - BOOL Remove(const TKey& key) - { - int nIndex = FindKey(key); - if(nIndex == -1) - return FALSE; - return RemoveAt(nIndex); - } - BOOL RemoveAt(int nIndex) - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if (nIndex < 0 || nIndex >= m_nSize) - return FALSE; - m_aKey[nIndex].~TKey(); - m_aVal[nIndex].~TVal(); - if(nIndex != (m_nSize - 1)) - { - Checked::memmove_s((void*)(m_aKey + nIndex), (m_nSize - nIndex) * sizeof(TKey), (void*)(m_aKey + nIndex + 1), (m_nSize - (nIndex + 1)) * sizeof(TKey)); - Checked::memmove_s((void*)(m_aVal + nIndex), (m_nSize - nIndex) * sizeof(TVal), (void*)(m_aVal + nIndex + 1), (m_nSize - (nIndex + 1)) * sizeof(TVal)); - } - TKey* pKey; - pKey = (TKey*)_recalloc(m_aKey, (m_nSize - 1), sizeof(TKey)); - if(pKey != NULL || m_nSize == 1) - m_aKey = pKey; - TVal* pVal; - pVal = (TVal*)_recalloc(m_aVal, (m_nSize - 1), sizeof(TVal)); - if(pVal != NULL || m_nSize == 1) - m_aVal = pVal; - m_nSize--; - return TRUE; - } - void RemoveAll() - { - if(m_aKey != NULL) - { - for(int i = 0; i < m_nSize; i++) - { - m_aKey[i].~TKey(); - m_aVal[i].~TVal(); - } - free(m_aKey); - m_aKey = NULL; - } - if(m_aVal != NULL) - { - free(m_aVal); - m_aVal = NULL; - } - - m_nSize = 0; - } - BOOL SetAt(const TKey& key, const TVal& val) - { - int nIndex = FindKey(key); - if(nIndex == -1) - return FALSE; - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - m_aKey[nIndex].~TKey(); - m_aVal[nIndex].~TVal(); - InternalSetAtIndex(nIndex, key, val); - return TRUE; - } - TVal Lookup(const TKey& key) const - { - int nIndex = FindKey(key); - if(nIndex == -1) - return NULL; // must be able to convert - return GetValueAt(nIndex); - } - TKey ReverseLookup(const TVal& val) const - { - int nIndex = FindVal(val); - if(nIndex == -1) - return NULL; // must be able to convert - return GetKeyAt(nIndex); - } - TKey& GetKeyAt(int nIndex) const - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if(nIndex < 0 || nIndex >= m_nSize) - _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); - - return m_aKey[nIndex]; - } - TVal& GetValueAt(int nIndex) const - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if(nIndex < 0 || nIndex >= m_nSize) - _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); - - return m_aVal[nIndex]; - } - - int FindKey(const TKey& key) const - { - for(int i = 0; i < m_nSize; i++) - { - if(TEqual::IsEqualKey(m_aKey[i], key)) - return i; - } - return -1; // not found - } - int FindVal(const TVal& val) const - { - for(int i = 0; i < m_nSize; i++) - { - if(TEqual::IsEqualValue(m_aVal[i], val)) - return i; - } - return -1; // not found - } - - BOOL SetAtIndex(int nIndex, const TKey& key, const TVal& val) - { - if (nIndex < 0 || nIndex >= m_nSize) - return FALSE; - InternalSetAtIndex(nIndex, key, val); - return TRUE; - } - - -// Implementation - - template - class Wrapper - { - public: - Wrapper(const T& _t) : t(_t) - { - } - template - void *operator new(size_t, _Ty* p) - { - return p; - } - template - void operator delete(void* /* pv */, _Ty* /* p */) - { - } - T t; - }; - void InternalSetAtIndex(int nIndex, const TKey& key, const TVal& val) - { - new(m_aKey + nIndex) Wrapper(key); - new(m_aVal + nIndex) Wrapper(val); - } -}; - -#pragma pop_macro("new") - -}; // namespace ATL -#pragma pack(pop) - -#pragma warning(pop) - -#pragma pop_macro("free") -#pragma pop_macro("realloc") -#pragma pop_macro("_recalloc") -#pragma pop_macro("malloc") -#pragma pop_macro("calloc") - - -#endif // __ATLSIMPCOLL_H__ - diff --git a/cpp/jacob/include/atltrace.h b/cpp/jacob/include/atltrace.h deleted file mode 100644 index bcd05b3..0000000 --- a/cpp/jacob/include/atltrace.h +++ /dev/null @@ -1,450 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __ATLTRACE_H__ -#define __ATLTRACE_H__ - -#pragma once - -#include -#include - -#ifdef _DEBUG -#include -#include -#endif - -#ifdef _DEBUG -#include - -extern "C" IMAGE_DOS_HEADER __ImageBase; -#endif // _DEBUG - - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ - -// Declare a global instance of this class to automatically register a custom trace category at startup -class CTraceCategory -{ -public: - explicit CTraceCategory( LPCTSTR pszCategoryName, UINT nStartingLevel = 0 ) throw(); - -#ifdef _DEBUG - UINT GetLevel() const throw(); - void SetLevel( UINT nLevel ) throw(); - ATLTRACESTATUS GetStatus() const throw(); - void SetStatus( ATLTRACESTATUS eStatus) throw(); -#endif - - operator DWORD_PTR() const throw(); - -public: -#ifdef _DEBUG - DWORD_PTR m_dwCategory; -#endif -}; - -#ifdef _DEBUG - -class CTrace -{ -public: - typedef int (__cdecl *fnCrtDbgReport_t)(int,const char *,int,const char *,const char *,...); - -private: - CTrace( -#ifdef _ATL_NO_DEBUG_CRT - fnCrtDbgReport_t pfnCrtDbgReport = NULL) -#else - fnCrtDbgReport_t pfnCrtDbgReport = _CrtDbgReport) -#endif - : m_hInst(reinterpret_cast(&__ImageBase)), - m_dwModule( 0 ) - { - m_dwModule = AtlTraceRegister(m_hInst, pfnCrtDbgReport); - } - - ~CTrace() - { - AtlTraceUnregister(m_dwModule); - } - -public: - bool ChangeCategory(DWORD_PTR dwCategory, UINT nLevel, ATLTRACESTATUS eStatus) - { - return 0 != - AtlTraceModifyCategory(0, dwCategory, nLevel, eStatus); - } - - bool GetCategory(DWORD_PTR dwCategory, UINT *pnLevel, ATLTRACESTATUS *peStatus) - { - ATLASSERT(pnLevel && peStatus); - return 0 != AtlTraceGetCategory(0, dwCategory, pnLevel, peStatus); - } - UINT GetLevel() - { - ATLTRACESTATUS eStatus; - UINT nLevel; - AtlTraceGetModule(0, m_dwModule, &nLevel, &eStatus); - - return nLevel; - } - void SetLevel(UINT nLevel) - { - AtlTraceModifyModule(0, m_dwModule, nLevel, ATLTRACESTATUS_ENABLED); - } - ATLTRACESTATUS GetStatus() - { - ATLTRACESTATUS eStatus; - UINT nLevel; - AtlTraceGetModule(0, m_dwModule, &nLevel, &eStatus); - - return eStatus; - } - void SetStatus(ATLTRACESTATUS eStatus) - { - ATLTRACESTATUS eOldStatus; - UINT nLevel; - AtlTraceGetModule(0, m_dwModule, &nLevel, &eOldStatus); - AtlTraceModifyModule(0, m_dwModule, nLevel, eStatus); - } - void __cdecl TraceV(const char *pszFileName, int nLine, - DWORD_PTR dwCategory, UINT nLevel, LPCSTR pszFmt, va_list args) const; - void __cdecl TraceV(const char *pszFileName, int nLine, - DWORD_PTR dwCategory, UINT nLevel, LPCWSTR pszFmt, va_list args) const; - - DWORD_PTR RegisterCategory(LPCSTR pszCategory) - {return(AtlTraceRegisterCategoryA(m_dwModule, pszCategory));} -#ifdef _UNICODE - DWORD_PTR RegisterCategory(LPCWSTR pszCategory) - {return(AtlTraceRegisterCategoryU(m_dwModule, pszCategory));} -#endif - - bool LoadSettings(LPCTSTR pszFileName = NULL) const - {return 0 != AtlTraceLoadSettings(pszFileName);} - void SaveSettings(LPCTSTR pszFileName = NULL) const - {AtlTraceSaveSettings(pszFileName);} - -public: - static CTrace s_trace; - -protected: - HINSTANCE m_hInst; - DWORD_PTR m_dwModule; -}; - - inline void __cdecl CTrace::TraceV(const char *pszFileName, int nLine, - DWORD_PTR dwCategory, UINT nLevel, LPCSTR pszFmt, va_list args) const - { - AtlTraceVA(m_dwModule, pszFileName, nLine, dwCategory, nLevel, pszFmt, args); - } - inline void __cdecl CTrace::TraceV(const char *pszFileName, int nLine, - DWORD_PTR dwCategory, UINT nLevel, LPCWSTR pszFmt, va_list args) const - { - AtlTraceVU(m_dwModule, pszFileName, nLine, dwCategory, nLevel, pszFmt, args); - } - -extern CTraceCategory atlTraceGeneral; - -class CTraceFileAndLineInfo -{ -public: - CTraceFileAndLineInfo(const char *pszFileName, int nLineNo) - : m_pszFileName(pszFileName), m_nLineNo(nLineNo) - {} - -#pragma warning(push) -#pragma warning(disable : 4793) - void __cdecl operator()(DWORD_PTR dwCategory, UINT nLevel, const char *pszFmt, ...) const - { - va_list ptr; va_start(ptr, pszFmt); - ATL::CTrace::s_trace.TraceV(m_pszFileName, m_nLineNo, dwCategory, nLevel, pszFmt, ptr); - va_end(ptr); - } -#pragma warning(pop) - -#pragma warning(push) -#pragma warning(disable : 4793) - void __cdecl operator()(DWORD_PTR dwCategory, UINT nLevel, const wchar_t *pszFmt, ...) const - { - va_list ptr; va_start(ptr, pszFmt); - ATL::CTrace::s_trace.TraceV(m_pszFileName, m_nLineNo, dwCategory, nLevel, pszFmt, ptr); - va_end(ptr); - } -#pragma warning(pop) - -#pragma warning(push) -#pragma warning(disable : 4793) - void __cdecl operator()(const char *pszFmt, ...) const - { - va_list ptr; va_start(ptr, pszFmt); - ATL::CTrace::s_trace.TraceV(m_pszFileName, m_nLineNo, atlTraceGeneral, 0, pszFmt, ptr); - va_end(ptr); - } -#pragma warning(pop) - -#pragma warning(push) -#pragma warning(disable : 4793) - void __cdecl operator()(const wchar_t *pszFmt, ...) const - { - va_list ptr; va_start(ptr, pszFmt); - ATL::CTrace::s_trace.TraceV(m_pszFileName, m_nLineNo, atlTraceGeneral, 0, pszFmt, ptr); - va_end(ptr); - } -#pragma warning(pop) - -private: - /* unimplemented */ - CTraceFileAndLineInfo &__cdecl operator=(const CTraceFileAndLineInfo &right); - - const char *const m_pszFileName; - const int m_nLineNo; -}; - -#endif // _DEBUG - -#ifdef _DEBUG - -inline CTraceCategory::CTraceCategory( LPCTSTR pszCategoryName, UINT nStartingLevel ) throw() : - m_dwCategory( 0 ) -{ - m_dwCategory = ATL::CTrace::s_trace.RegisterCategory( pszCategoryName ); - ATL::CTrace::s_trace.ChangeCategory( m_dwCategory, nStartingLevel, ATLTRACESTATUS_INHERIT); -} - -inline CTraceCategory::operator DWORD_PTR() const throw() -{ - return( m_dwCategory ); -} - -inline UINT CTraceCategory::GetLevel() const throw() -{ - UINT nLevel; - ATLTRACESTATUS eStatus; - ATL::CTrace::s_trace.GetCategory( m_dwCategory, &nLevel, &eStatus ); - - return( nLevel ); -} - -inline void CTraceCategory::SetLevel( UINT nLevel ) throw() -{ - ATL::CTrace::s_trace.ChangeCategory( m_dwCategory, nLevel, ATLTRACESTATUS_ENABLED ); -} - -inline ATLTRACESTATUS CTraceCategory::GetStatus() const throw() -{ - UINT nLevel; - ATLTRACESTATUS eStatus; - ATL::CTrace::s_trace.GetCategory( m_dwCategory, &nLevel, &eStatus ); - - return( eStatus ); -} - -inline void CTraceCategory::SetStatus( ATLTRACESTATUS eStatus ) throw() -{ - UINT nLevel; - ATLTRACESTATUS eOldStatus; - ATL::CTrace::s_trace.GetCategory( m_dwCategory, &nLevel, &eOldStatus ); - ATL::CTrace::s_trace.ChangeCategory( m_dwCategory, nLevel, eStatus ); -} - -#else // !_DEBUG - -inline CTraceCategory::CTraceCategory( LPCTSTR pszCategoryName, UINT nStartingLevel ) throw() -{ - (void)pszCategoryName; - (void)nStartingLevel; -} - -inline CTraceCategory::operator DWORD_PTR() const throw() -{ - return( 0 ); -} - -#endif // _DEBUG - -} // namespace ATL - -namespace ATL -{ - -#ifdef _DEBUG -#define DECLARE_TRACE_CATEGORY( name ) extern ATL::CTraceCategory name; -#else -#define DECLARE_TRACE_CATEGORY( name ) const DWORD_PTR name = 0; -#endif - -DECLARE_TRACE_CATEGORY( atlTraceGeneral ) -DECLARE_TRACE_CATEGORY( atlTraceCOM ) -DECLARE_TRACE_CATEGORY( atlTraceQI ) -DECLARE_TRACE_CATEGORY( atlTraceRegistrar ) -DECLARE_TRACE_CATEGORY( atlTraceRefcount ) -DECLARE_TRACE_CATEGORY( atlTraceWindowing ) -DECLARE_TRACE_CATEGORY( atlTraceControls ) -DECLARE_TRACE_CATEGORY( atlTraceHosting ) -DECLARE_TRACE_CATEGORY( atlTraceDBClient ) -DECLARE_TRACE_CATEGORY( atlTraceDBProvider ) -DECLARE_TRACE_CATEGORY( atlTraceSnapin ) -DECLARE_TRACE_CATEGORY( atlTraceNotImpl ) -DECLARE_TRACE_CATEGORY( atlTraceAllocation ) -DECLARE_TRACE_CATEGORY( atlTraceException ) -DECLARE_TRACE_CATEGORY( atlTraceTime ) -DECLARE_TRACE_CATEGORY( atlTraceCache ) -DECLARE_TRACE_CATEGORY( atlTraceStencil ) -DECLARE_TRACE_CATEGORY( atlTraceString ) -DECLARE_TRACE_CATEGORY( atlTraceMap ) -DECLARE_TRACE_CATEGORY( atlTraceUtil ) -DECLARE_TRACE_CATEGORY( atlTraceSecurity ) -DECLARE_TRACE_CATEGORY( atlTraceSync ) -DECLARE_TRACE_CATEGORY( atlTraceISAPI ) - -// atlTraceUser categories are no longer needed. Just declare your own trace category using CTraceCategory. -DECLARE_TRACE_CATEGORY( atlTraceUser ) -DECLARE_TRACE_CATEGORY( atlTraceUser2 ) -DECLARE_TRACE_CATEGORY( atlTraceUser3 ) -DECLARE_TRACE_CATEGORY( atlTraceUser4 ) - -#pragma deprecated( atlTraceUser ) -#pragma deprecated( atlTraceUser2 ) -#pragma deprecated( atlTraceUser3 ) -#pragma deprecated( atlTraceUser4 ) - -#ifdef _DEBUG - -#ifndef _ATL_NO_DEBUG_CRT -class CNoUIAssertHook -{ -public: - CNoUIAssertHook() - { - ATLASSERT( s_pfnPrevHook == NULL ); - s_pfnPrevHook = _CrtSetReportHook(CrtHookProc); - } - ~CNoUIAssertHook() - { - _CrtSetReportHook(s_pfnPrevHook); - s_pfnPrevHook = NULL; - } - -private: - static int __cdecl CrtHookProc(__in int eReportType, __in_z char* pszMessage, __out int* pnRetVal) - { - - if (eReportType == _CRT_ASSERT) - { - ::OutputDebugStringA( "ASSERTION FAILED\n" ); - ::OutputDebugStringA( pszMessage ); - //If caller doesn't want retVal, so be it. - if (pnRetVal != NULL) - { - *pnRetVal = 1; - } - return TRUE; - } - - if (s_pfnPrevHook != NULL) - { - return s_pfnPrevHook(eReportType, pszMessage, pnRetVal); - } - else - { - return FALSE; - } - } - -private: - static _CRT_REPORT_HOOK s_pfnPrevHook; -}; - -__declspec( selectany ) _CRT_REPORT_HOOK CNoUIAssertHook::s_pfnPrevHook = NULL; - -#define DECLARE_NOUIASSERT() ATL::CNoUIAssertHook _g_NoUIAssertHook; - -#endif // _ATL_NO_DEBUG_CRT - -#ifndef ATLTRACE -#define ATLTRACE ATL::CTraceFileAndLineInfo(__FILE__, __LINE__) -#define ATLTRACE2 ATLTRACE -#endif - -#pragma warning(push) -#pragma warning(disable : 4793) -inline void __cdecl AtlTrace(LPCSTR pszFormat, ...) -{ - va_list ptr; - va_start(ptr, pszFormat); - ATL::CTrace::s_trace.TraceV(NULL, -1, atlTraceGeneral, 0, pszFormat, ptr); - va_end(ptr); -} -#pragma warning(pop) - -#pragma warning(push) -#pragma warning(disable : 4793) -inline void __cdecl AtlTrace(LPCWSTR pszFormat, ...) -{ - va_list ptr; - va_start(ptr, pszFormat); - ATL::CTrace::s_trace.TraceV(NULL, -1, atlTraceGeneral, 0, pszFormat, ptr); - va_end(ptr); -} -#pragma warning(pop) - -#pragma warning(push) -#pragma warning(disable : 4793) -inline void __cdecl AtlTrace2(DWORD_PTR dwCategory, UINT nLevel, LPCSTR pszFormat, ...) -{ - va_list ptr; - va_start(ptr, pszFormat); - ATL::CTrace::s_trace.TraceV(NULL, -1, dwCategory, nLevel, pszFormat, ptr); - va_end(ptr); -} -#pragma warning(pop) - -#pragma warning(push) -#pragma warning(disable : 4793) -inline void __cdecl AtlTrace2(DWORD_PTR dwCategory, UINT nLevel, LPCWSTR pszFormat, ...) -{ - va_list ptr; - va_start(ptr, pszFormat); - ATL::CTrace::s_trace.TraceV(NULL, -1, dwCategory, nLevel, pszFormat, ptr); - va_end(ptr); -} -#pragma warning(pop) - -#define ATLTRACENOTIMPL(funcname) do { ATLTRACE(ATL::atlTraceNotImpl, 0, _T("ATL: %s not implemented.\n"), funcname); return E_NOTIMPL; } while(0) - -#else // !DEBUG - -#pragma warning(push) -#pragma warning(disable : 4793) -inline void __cdecl AtlTraceNull(...){} -inline void __cdecl AtlTrace(LPCSTR , ...){} -inline void __cdecl AtlTrace2(DWORD_PTR, UINT, LPCSTR , ...){} -inline void __cdecl AtlTrace(LPCWSTR , ...){} -inline void __cdecl AtlTrace2(DWORD_PTR, UINT, LPCWSTR , ...){} -#pragma warning(pop) - -#ifndef ATLTRACE - -#define ATLTRACE __noop -#define ATLTRACE2 __noop -#endif //ATLTRACE -#define ATLTRACENOTIMPL(funcname) return E_NOTIMPL -#define DECLARE_NOUIASSERT() - -#endif //!_DEBUG - -}; // namespace ATL -#pragma pack(pop) - -#endif // __ATLTRACE_H__ - diff --git a/cpp/jacob/include/statreg.h b/cpp/jacob/include/statreg.h deleted file mode 100644 index 2dc76aa..0000000 --- a/cpp/jacob/include/statreg.h +++ /dev/null @@ -1,1509 +0,0 @@ -// This is a part of the Active Template Library. -// Copyright (C) Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Active Template Library Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Active Template Library product. - -#ifndef __STATREG_H__ -#define __STATREG_H__ - -#pragma once - -#ifndef __cplusplus - #error ATL requires C++ compilation (use a .cpp suffix) -#endif - -#ifndef __ATLBASE_H__ - #error statreg.h requires atlbase.h to be included first -#endif - -#pragma warning(push) -#pragma warning(disable:4571) //catch(...) blocks compiled with /EHs do NOT catch or re-throw Structured Exceptions - -// SAL requires macro definition -#define MAX_VALUE_VALUE 4096 - -#define E_ATL_REGISTRAR_DESC 0x0201 -#define E_ATL_NOT_IN_MAP 0x0202 -#define E_ATL_UNEXPECTED_EOS 0x0203 -#define E_ATL_VALUE_SET_FAILED 0x0204 -#define E_ATL_RECURSE_DELETE_FAILED 0x0205 -#define E_ATL_EXPECTING_EQUAL 0x0206 -#define E_ATL_CREATE_KEY_FAILED 0x0207 -#define E_ATL_DELETE_KEY_FAILED 0x0208 -#define E_ATL_OPEN_KEY_FAILED 0x0209 -#define E_ATL_CLOSE_KEY_FAILED 0x020A -#define E_ATL_UNABLE_TO_COERCE 0x020B -#define E_ATL_BAD_HKEY 0x020C -#define E_ATL_MISSING_OPENKEY_TOKEN 0x020D -#define E_ATL_CONVERT_FAILED 0x020E -#define E_ATL_TYPE_NOT_SUPPORTED 0x020F -#define E_ATL_COULD_NOT_CONCAT 0x0210 -#define E_ATL_COMPOUND_KEY 0x0211 -#define E_ATL_INVALID_MAPKEY 0x0212 -#define E_ATL_UNSUPPORTED_VT 0x0213 -#define E_ATL_VALUE_GET_FAILED 0x0214 -#define E_ATL_VALUE_TOO_LARGE 0x0215 -#define E_ATL_MISSING_VALUE_DELIMETER 0x0216 -#define E_ATL_DATA_NOT_BYTE_ALIGNED 0x0217 - -#pragma pack(push,_ATL_PACKING) -namespace ATL -{ -const TCHAR chDirSep = _T('\\'); -const TCHAR chRightBracket = _T('}'); -const TCHAR chLeftBracket = _T('{'); -const TCHAR chQuote = _T('\''); -const TCHAR chEquals = _T('='); -const LPCTSTR szStringVal = _T("S"); -const LPCTSTR multiszStringVal = _T("M"); -const LPCTSTR szDwordVal = _T("D"); -const LPCTSTR szBinaryVal = _T("B"); -const LPCTSTR szValToken = _T("Val"); -const LPCTSTR szForceRemove = _T("ForceRemove"); -const LPCTSTR szNoRemove = _T("NoRemove"); -const LPCTSTR szDelete = _T("Delete"); - - -// Implementation helper -class CExpansionVectorEqualHelper -{ -public: - static bool IsEqualKey(__in_z const LPTSTR k1, __in_z const LPTSTR k2) - { - if (lstrcmpi(k1, k2) == 0) - return true; - return false; - } - - // Not used - static bool IsEqualValue(const LPCOLESTR /*v1*/, const LPCOLESTR /*v2*/) - { - return false; - } -}; - -// Implementation helper -class CExpansionVector : public CSimpleMap -{ -public: - ~CExpansionVector() - { - ClearReplacements(); - } - - BOOL Add(LPCTSTR lpszKey, LPCOLESTR lpszValue) - { - ATLASSERT(lpszKey != NULL && lpszValue != NULL); - if (lpszKey == NULL || lpszValue == NULL) - return FALSE; - - HRESULT hRes = S_OK; - - size_t cbKey = (lstrlen(lpszKey)+1)*sizeof(TCHAR); - TCHAR* szKey = NULL; - -#pragma warning(push) -#pragma warning(disable: 28197 28198) - - ATLTRY(szKey = new TCHAR[cbKey];) - -#pragma warning(pop) - - CAutoVectorPtr spKey; - spKey.Attach(szKey); - - size_t cbValue = (ocslen(lpszValue)+1)*sizeof(OLECHAR); - LPOLESTR szValue = NULL; - -#pragma warning(push) -#pragma warning(disable: 28197) - - ATLTRY(szValue = new OLECHAR[cbValue];) - -#pragma warning(pop) - - CAutoVectorPtr spValue; - spValue.Attach(szValue); - - if (szKey == NULL || szValue == NULL) - hRes = E_OUTOFMEMORY; - else - { - Checked::memcpy_s(szKey, cbKey, lpszKey, cbKey); - Checked::memcpy_s(szValue, cbValue, lpszValue, cbValue); - if (!CSimpleMap::Add(szKey, szValue)) - hRes = E_OUTOFMEMORY; - } - if (SUCCEEDED(hRes)) - { - spKey.Detach(); - spValue.Detach(); - } - return SUCCEEDED(hRes); - } - HRESULT ClearReplacements() - { - for (int i = 0; i < GetSize(); i++) - { - delete []GetKeyAt(i); - delete []GetValueAt(i); - } - RemoveAll(); - return S_OK; - } -}; - -class CRegObject; - -class CRegParser -{ -public: - CRegParser(CRegObject* pRegObj); - - HRESULT PreProcessBuffer(__in_z LPTSTR lpszReg, __deref_out_z LPTSTR* ppszReg); - HRESULT RegisterBuffer(__in_z LPTSTR szReg, BOOL bRegister); - -protected: - - void SkipWhiteSpace(); - HRESULT NextToken(__out_ecount_z(MAX_VALUE_VALUE) LPTSTR szToken); - HRESULT AddValue(__in CRegKey& rkParent, __in_z_opt LPCTSTR szValueName, __out_ecount_z(MAX_VALUE_VALUE) LPTSTR szToken); - BOOL CanForceRemoveKey(LPCTSTR szKey); - BOOL HasSubKeys(HKEY hkey); - BOOL HasValues(HKEY hkey); - HRESULT RegisterSubkeys(__out_ecount_z(MAX_VALUE_VALUE) LPTSTR szToken, __in HKEY hkParent, __in BOOL bRegister, __in BOOL bInRecovery = FALSE); - BOOL IsSpace(TCHAR ch); - LPTSTR m_pchCur; - - CRegObject* m_pRegObj; - - HRESULT GenerateError(UINT) {return DISP_E_EXCEPTION;} - //HRESULT HandleReplacements(LPTSTR& szToken); - HRESULT SkipAssignment(__inout_ecount_z(MAX_VALUE_VALUE) LPTSTR szToken); - - BOOL EndOfVar() { return chQuote == *m_pchCur && chQuote != *CharNext(m_pchCur); } - static LPTSTR StrChr(__in_z LPTSTR lpsz, __in TCHAR ch); - static HKEY HKeyFromString(__in_z LPTSTR szToken); - static BYTE ChToByte(const TCHAR ch); - static BOOL VTFromRegType(LPCTSTR szValueType, VARTYPE& vt); - static const TCHAR* const rgszNeverDelete[]; - static const int cbNeverDelete; - static const int MAX_VALUE = MAX_VALUE_VALUE; - static const int MAX_TYPE = 4096; - - - // Implementation Helper - class CParseBuffer - { - public: - int nPos; - int nSize; - __field_ecount(nSize) LPTSTR p; - CParseBuffer(int nInitial) - { - if (nInitial < 100) - nInitial = 1000; - nPos = 0; - nSize = nInitial; - p = (LPTSTR) ::ATL::AtlCoTaskMemCAlloc(nSize,static_cast(sizeof(TCHAR))); - if (p != NULL) - *p = NULL; - } - ~CParseBuffer() - { - CoTaskMemFree(p); - } - BOOL Append(const TCHAR* pch, int nChars) - { - ATLASSERT(p != NULL); - int newSize = nPos + nChars + 1; - if ((newSize <= nPos) || (newSize <= nChars)) - return FALSE; - - if (newSize >= nSize) - { - int nTempSize = nSize; - while (newSize >= nTempSize) { - if (nTempSize > INT_MAX / 2) - return FALSE; - nTempSize *= 2; - } - LPTSTR pTemp = (LPTSTR)::ATL::AtlCoTaskMemRecalloc(p, nTempSize, sizeof(TCHAR)); - if (pTemp == NULL) - return FALSE; - p = pTemp; - nSize = nTempSize; - } - if ((nPos < 0) || (nPos >= nSize) || nSize - nPos > nSize) - return FALSE; - -#pragma warning(push) -// -// [pfx_parse] - workaround for PREfix parse problem -// -#if ((defined(_PREFIX_)) || (defined(_PREFAST_))) && (_MSC_VER < 1400) - // do nothing, this pragma not understood by PREfix 5.1 -#else // !_PREFIX_ -#pragma warning(disable: 22008) -#endif - /* Prefast false warning is fired here despite the all above checks */ - Checked::memcpy_s(p + nPos, (nSize-nPos) * sizeof(TCHAR), pch, int(nChars * sizeof(TCHAR))); - nPos += nChars; - *(p + nPos) = NULL; -#pragma warning(pop) - return TRUE; - } - - BOOL AddChar(const TCHAR* pch) - { -#ifndef _UNICODE - int nChars = int(CharNext(pch) - pch); -#else - int nChars = 1; -#endif - return Append(pch, nChars); - - } - BOOL AddString(LPCOLESTR lpsz) - { - if (lpsz == NULL) - { - return FALSE; - } - USES_CONVERSION_EX; - LPCTSTR lpszT = OLE2CT_EX(lpsz, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - if (lpszT == NULL) - { - return FALSE; - } - return Append(lpszT, (int)lstrlen(lpszT)); - } - LPTSTR Detach() - { - LPTSTR lp = p; - p = NULL; - nSize = nPos = 0; - return lp; - } - - }; -}; - -#if defined(_ATL_DLL) || defined(_ATL_DLL_IMPL) -class ATL_NO_VTABLE CRegObject - : public IRegistrar -#else -class CRegObject : public IRegistrarBase -#endif -{ -public: - -#if defined(_ATL_DLL) || defined(_ATL_DLL_IMPL) - -#else - STDMETHOD(QueryInterface)(const IID &,void **ppv) - { - ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function")); - if (ppv) *ppv = NULL; - return E_NOTIMPL; - } - - STDMETHOD_(ULONG, AddRef)(void) - { - ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function")); - return 1; - } - STDMETHOD_(ULONG, Release)(void) - { - ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function")); - return 0; - } -#endif - virtual ~CRegObject(){ClearReplacements();} - HRESULT FinalConstruct() { return m_csMap.Init(); } - void FinalRelease() {} - - - // Map based methods - HRESULT STDMETHODCALLTYPE AddReplacement(LPCOLESTR lpszKey, LPCOLESTR lpszItem); - HRESULT STDMETHODCALLTYPE ClearReplacements(); - LPCOLESTR StrFromMap(__in_z LPTSTR lpszKey); - - // Register via a given mechanism - HRESULT STDMETHODCALLTYPE ResourceRegister(LPCOLESTR pszFileName, UINT nID, LPCOLESTR pszType); - HRESULT STDMETHODCALLTYPE ResourceRegisterSz(LPCOLESTR pszFileName, LPCOLESTR pszID, LPCOLESTR pszType); - HRESULT STDMETHODCALLTYPE ResourceUnregister(LPCOLESTR pszFileName, UINT nID, LPCOLESTR pszType); - HRESULT STDMETHODCALLTYPE ResourceUnregisterSz(LPCOLESTR pszFileName, LPCOLESTR pszID, LPCOLESTR pszType); - HRESULT STDMETHODCALLTYPE FileRegister(LPCOLESTR bstrFileName) - { - return CommonFileRegister(bstrFileName, TRUE); - } - - HRESULT STDMETHODCALLTYPE FileUnregister(LPCOLESTR bstrFileName) - { - return CommonFileRegister(bstrFileName, FALSE); - } - - HRESULT STDMETHODCALLTYPE StringRegister(LPCOLESTR bstrData) - { - return RegisterWithString(bstrData, TRUE); - } - - HRESULT STDMETHODCALLTYPE StringUnregister(LPCOLESTR bstrData) - { - return RegisterWithString(bstrData, FALSE); - } - -protected: - - HRESULT CommonFileRegister(LPCOLESTR pszFileName, BOOL bRegister); - HRESULT RegisterFromResource(LPCOLESTR pszFileName, LPCTSTR pszID, LPCTSTR pszType, BOOL bRegister); - HRESULT RegisterWithString(LPCOLESTR pszData, BOOL bRegister); - - static HRESULT GenerateError(UINT) {return DISP_E_EXCEPTION;} - - CExpansionVector m_RepMap; - CComObjectThreadModel::AutoDeleteCriticalSection m_csMap; -}; - -inline HRESULT STDMETHODCALLTYPE CRegObject::AddReplacement(LPCOLESTR lpszKey, LPCOLESTR lpszItem) -{ - if (lpszKey == NULL || lpszItem == NULL) - return E_INVALIDARG; - m_csMap.Lock(); - USES_CONVERSION_EX; - - LPCTSTR lpszT = OLE2CT_EX(lpszKey, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - -#ifndef _UNICODE - if(lpszT == NULL) { - m_csMap.Unlock(); - return E_OUTOFMEMORY; - } -#endif - - BOOL bRet = m_RepMap.Add(lpszT, lpszItem); - m_csMap.Unlock(); - return bRet ? S_OK : E_OUTOFMEMORY; -} - -inline HRESULT CRegObject::RegisterFromResource(LPCOLESTR bstrFileName, LPCTSTR szID, - LPCTSTR szType, BOOL bRegister) -{ - USES_CONVERSION_EX; - - HRESULT hr; - CRegParser parser(this); - HINSTANCE hInstResDll; - HRSRC hrscReg; - HGLOBAL hReg; - DWORD dwSize; - LPSTR szRegA; - CTempBuffer szReg; - - LPCTSTR lpszBSTRFileName = OLE2CT_EX(bstrFileName, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if (lpszBSTRFileName == NULL) - { - return E_OUTOFMEMORY; - } -#endif // _UNICODE - - hInstResDll = LoadLibraryEx(lpszBSTRFileName, NULL, LOAD_LIBRARY_AS_DATAFILE); - - if (NULL == hInstResDll) - { - ATLTRACE(atlTraceRegistrar, 0, _T("Failed to LoadLibrary on %s\n"), bstrFileName); - hr = AtlHresultFromLastError(); - goto ReturnHR; - } - - hrscReg =FindResource((HMODULE)hInstResDll, szID, szType); - - if (NULL == hrscReg) - { - ATLTRACE(atlTraceRegistrar, 0, (HIWORD(szID) == NULL) ? - _T("Failed to FindResource on ID:%d TYPE:%s\n") : - _T("Failed to FindResource on ID:%s TYPE:%s\n"), - szID, szType); - hr = AtlHresultFromLastError(); - goto ReturnHR; - } - hReg = LoadResource((HMODULE)hInstResDll, hrscReg); - - if (NULL == hReg) - { - ATLTRACE(atlTraceRegistrar, 0, _T("Failed to LoadResource\n")); - hr = AtlHresultFromLastError(); - goto ReturnHR; - } - - dwSize = SizeofResource((HMODULE)hInstResDll, hrscReg); - szRegA = (LPSTR)hReg; - - // Allocate extra space for NULL. - if (dwSize + 1 < dwSize) - return E_OUTOFMEMORY; - ATLTRY(szReg.Allocate(dwSize + 1)); - if (szReg == NULL) - { - hr = E_OUTOFMEMORY; - goto ReturnHR; - } - -#ifdef _UNICODE - DWORD uniSize = ::MultiByteToWideChar(_AtlGetConversionACP(), 0, szRegA, dwSize, szReg, dwSize); - if (uniSize == 0) - { - hr = AtlHresultFromLastError(); - goto ReturnHR; - } - // Append a NULL at the end. - szReg[uniSize] = NULL; -#else - Checked::memcpy_s(szReg, dwSize, szRegA, dwSize); - // Append a NULL at the end. - szReg[dwSize] = NULL; -#endif - - - - hr = parser.RegisterBuffer(szReg, bRegister); - -ReturnHR: - - if (NULL != hInstResDll) - FreeLibrary((HMODULE)hInstResDll); - return hr; -} - -inline HRESULT STDMETHODCALLTYPE CRegObject::ResourceRegister(LPCOLESTR szFileName, UINT nID, LPCOLESTR szType) -{ - USES_CONVERSION_EX; - - LPCTSTR lpszT = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if (lpszT == NULL) - { - return E_OUTOFMEMORY; - } -#endif // _UNICODE - - return RegisterFromResource(szFileName, MAKEINTRESOURCE(nID), lpszT, TRUE); -} - -inline HRESULT STDMETHODCALLTYPE CRegObject::ResourceRegisterSz(LPCOLESTR szFileName, LPCOLESTR szID, LPCOLESTR szType) -{ - USES_CONVERSION_EX; - if (szID == NULL || szType == NULL) - return E_INVALIDARG; - - LPCTSTR lpszID = OLE2CT_EX(szID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - LPCTSTR lpszType = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if (lpszID == NULL || lpszType==NULL) - { - return E_OUTOFMEMORY; - } -#endif // _UNICODE - return RegisterFromResource(szFileName, lpszID, lpszType, TRUE); -} - -inline HRESULT STDMETHODCALLTYPE CRegObject::ResourceUnregister(LPCOLESTR szFileName, UINT nID, LPCOLESTR szType) -{ - USES_CONVERSION_EX; - - LPCTSTR lpszT = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if (lpszT == NULL) - { - return E_OUTOFMEMORY; - } -#endif // _UNICODE - return RegisterFromResource(szFileName, MAKEINTRESOURCE(nID), lpszT, FALSE); -} - -inline HRESULT STDMETHODCALLTYPE CRegObject::ResourceUnregisterSz(LPCOLESTR szFileName, LPCOLESTR szID, LPCOLESTR szType) -{ - USES_CONVERSION_EX; - if (szID == NULL || szType == NULL) - return E_INVALIDARG; - - LPCTSTR lpszID = OLE2CT_EX(szID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - LPCTSTR lpszType = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if (lpszID == NULL || lpszType == NULL) - { - return E_OUTOFMEMORY; - } -#endif // _UNICODE - - return RegisterFromResource(szFileName, lpszID, lpszType, FALSE); -} - -inline HRESULT CRegObject::RegisterWithString(LPCOLESTR bstrData, BOOL bRegister) -{ - USES_CONVERSION_EX; - CRegParser parser(this); - - LPCTSTR szReg = OLE2CT_EX(bstrData, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if (szReg == NULL) - { - return E_OUTOFMEMORY; - } -#endif // _UNICODE - - HRESULT hr = parser.RegisterBuffer((LPTSTR)szReg, bRegister); - - return hr; -} - -inline HRESULT CRegObject::ClearReplacements() -{ - m_csMap.Lock(); - HRESULT hr = m_RepMap.ClearReplacements(); - m_csMap.Unlock(); - return hr; -} - - -inline LPCOLESTR CRegObject::StrFromMap(__in_z LPTSTR lpszKey) -{ - m_csMap.Lock(); - LPCOLESTR lpsz = m_RepMap.Lookup(lpszKey); - if (lpsz == NULL) // not found!! - ATLTRACE(atlTraceRegistrar, 0, _T("Map Entry not found\n")); - m_csMap.Unlock(); - return lpsz; -} - -inline HRESULT CRegObject::CommonFileRegister(LPCOLESTR bstrFileName, BOOL bRegister) -{ - USES_CONVERSION_EX; - - CRegParser parser(this); - - LPCTSTR lpszBSTRFileName = OLE2CT_EX(bstrFileName, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); -#ifndef _UNICODE - if (lpszBSTRFileName == NULL) - { - return E_OUTOFMEMORY; - } -#endif // _UNICODE - - HANDLE hFile = CreateFile(lpszBSTRFileName, GENERIC_READ, 0, NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_READONLY, - NULL); - if (INVALID_HANDLE_VALUE == hFile) - { - ATLTRACE2(atlTraceRegistrar, 0, _T("Failed to CreateFile on %s\n"), lpszBSTRFileName); - return AtlHresultFromLastError(); - } - - HRESULT hRes = S_OK; - DWORD cbRead; - DWORD cbFile = GetFileSize(hFile, NULL); // No HiOrder DWORD required - - CTempBuffer szReg; - // Extra space for NULL. - ATLTRY(szReg.Allocate(cbFile + 1)); - if (szReg == NULL) - { - hRes = E_OUTOFMEMORY; - goto ReturnHR; - } - - if (ReadFile(hFile, szReg, cbFile, &cbRead, NULL) == 0) - { - ATLTRACE2(atlTraceRegistrar, 0, "Read Failed on file%s\n", lpszBSTRFileName); - hRes = AtlHresultFromLastError(); - } - if (SUCCEEDED(hRes)) - { - szReg[cbRead] = NULL; - -#ifdef _UNICODE - CTempBuffer szConverted; - ATLTRY(szConverted.Allocate(cbFile + 1)); - if (szConverted == NULL) - { - hRes = E_OUTOFMEMORY; - goto ReturnHR; - - } - if (::MultiByteToWideChar(_AtlGetConversionACP(), 0, szReg, cbFile + 1, szConverted, cbFile + 1) == 0) - { - hRes = AtlHresultFromLastError(); - goto ReturnHR; - } - - - - -#else - LPTSTR szConverted = szReg; -#endif - hRes = parser.RegisterBuffer(szConverted, bRegister); - } -ReturnHR: - CloseHandle(hFile); - return hRes; -} - -__declspec(selectany) const TCHAR* const CRegParser::rgszNeverDelete[] = -{ - _T("AppID"), - _T("CLSID"), - _T("Component Categories"), - _T("FileType"), - _T("Interface"), - _T("Hardware"), - _T("Mime"), - _T("SAM"), - _T("SECURITY"), - _T("SYSTEM"), - _T("Software"), - _T("TypeLib") -}; - -__declspec(selectany) const int CRegParser::cbNeverDelete = sizeof(rgszNeverDelete) / sizeof(LPCTSTR*); - - -inline BOOL CRegParser::VTFromRegType(LPCTSTR szValueType, VARTYPE& vt) -{ -// -// [pfx_parse] - workaround for PREfix parse problem -// -#if defined(_PREFIX_) || defined(_PREFAST_) - UNREFERENCED_PARAMETER(szValueType); - UNREFERENCED_PARAMETER(vt); - return FALSE; -#else - - struct typemap - { - LPCTSTR lpsz; - VARTYPE vt; - }; -#pragma warning (push) -#pragma warning (disable : 4640) // construction of local static object is not thread-safe - - static const typemap map[] = { - {szStringVal, VT_BSTR}, - {multiszStringVal, VT_BSTR | VT_BYREF}, - {szDwordVal, VT_UI4}, - {szBinaryVal, VT_UI1} - }; - -#pragma warning (pop) - - for (int i=0;i= szOrig + MAX_VALUE) - return GenerateError(E_ATL_VALUE_TOO_LARGE); - - for (int i = 0; i < (int)nChars; i++, szToken++, pchPrev++) - *szToken = *pchPrev; - } - - if (NULL == *m_pchCur) - { - ATLTRACE(atlTraceRegistrar, 0, _T("NextToken : Unexpected End of File\n")); - return GenerateError(E_ATL_UNEXPECTED_EOS); - } - - *szToken = NULL; - m_pchCur = CharNext(m_pchCur); - } - - else - { - // Handle non-quoted ie parse up till first "White Space" - while (NULL != *m_pchCur && !IsSpace(*m_pchCur)) - { - LPTSTR pchPrev = m_pchCur; - m_pchCur = CharNext(m_pchCur); - - INT_PTR nChars = m_pchCur - pchPrev; - - // Make sure we have room for nChars plus terminating NULL - if ((szToken + nChars + 1) >= szOrig + MAX_VALUE) - return GenerateError(E_ATL_VALUE_TOO_LARGE); - - for (int i = 0; i < (int)nChars; i++, szToken++, pchPrev++) - *szToken = *pchPrev; - } - - *szToken = NULL; - } - return S_OK; -} - -inline HRESULT CRegParser::AddValue(__in CRegKey& rkParent, __in_z_opt LPCTSTR szValueName, __out_ecount_z(MAX_VALUE_VALUE) LPTSTR szToken) -{ - HRESULT hr; - - TCHAR szValue[MAX_VALUE]; - VARTYPE vt = VT_EMPTY; - LONG lRes = ERROR_SUCCESS; - UINT nIDRes = 0; - - if (FAILED(hr = NextToken(szValue))) - return hr; - if (!VTFromRegType(szValue, vt)) - { - ATLTRACE(atlTraceRegistrar, 0, _T("%s Type not supported\n"), szValue); - return GenerateError(E_ATL_TYPE_NOT_SUPPORTED); - } - - SkipWhiteSpace(); - if (FAILED(hr = NextToken(szValue))) - return hr; - - switch (vt) - { - case VT_BSTR: - { - lRes = rkParent.SetStringValue(szValueName, szValue); - ATLTRACE(atlTraceRegistrar, 2, _T("Setting Value %s at %s\n"), szValue, !szValueName ? _T("default") : szValueName); - break; - } - case VT_BSTR | VT_BYREF: - { - ATLTRACE(atlTraceRegistrar, 2, _T("Setting Value %s at %s\n"), szValue, !szValueName ? _T("default") : szValueName); - int nLen = lstrlen(szValue) + 2; //Allocate space for double null termination. - CTempBuffer pszDestValue; - //nLen should be >= the max size of the target buffer. - ATLTRY(pszDestValue.Allocate(nLen)); - if (pszDestValue != NULL) - { - TCHAR* p = pszDestValue; - TCHAR* q = szValue; - nLen = 0; - while (*q != _T('\0')) - { - TCHAR* r = CharNext(q); - if (*q == _T('\\') && *r == _T('0')) - { - *p++ = NULL; - q = CharNext(r); - } - else - { - *p = *q; -#ifndef _UNICODE - if (IsDBCSLeadByte(*q)) - { - p++; - q++; - //Protect from Lead byte followed by the zero terminator.May skip beyond the end of the string. - if (*q == _T('\0')) { break; } - *p = *q; - } -#endif - p++; - q++; - } - nLen ++; - } - //Always terminate with 2 NULLs. - *p = NULL; - p++; - *p = NULL; - lRes = rkParent.SetMultiStringValue(szValueName, pszDestValue); - } - else - { - lRes = ERROR_OUTOFMEMORY; - } - } - break; - case VT_UI4: - { - ULONG ulVal; - USES_CONVERSION_EX; - - LPOLESTR lpszV = T2OLE_EX(szValue, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - #ifndef _UNICODE - if(lpszV == NULL) - return E_OUTOFMEMORY; - #endif - VarUI4FromStr(lpszV, 0, 0, &ulVal); - - lRes = rkParent.SetDWORDValue(szValueName, ulVal); - ATLTRACE(atlTraceRegistrar, 2, _T("Setting Value %d at %s\n"), ulVal, !szValueName ? _T("default") : szValueName); - break; - } - case VT_UI1: - { - int cbValue = lstrlen(szValue); - if (cbValue & 0x00000001) - { - ATLTRACE(atlTraceRegistrar, 0, _T("Binary Data does not fall on BYTE boundries\n")); - return E_FAIL; - } - int cbValDiv2 = cbValue/2; - CTempBuffer rgBinary; - ATLTRY(rgBinary.Allocate(cbValDiv2)); - if (rgBinary == NULL) - return E_FAIL; - memset(rgBinary, 0, cbValDiv2); - for (int irg = 0; irg < cbValue; irg++) - rgBinary[(irg/2)] |= (ChToByte(szValue[irg])) << (4*(1 - (irg & 0x00000001))); - lRes = RegSetValueEx(rkParent, szValueName, 0, REG_BINARY, rgBinary, cbValDiv2); - break; - } - } - - if (ERROR_SUCCESS != lRes) - { - nIDRes = E_ATL_VALUE_SET_FAILED; - return AtlHresultFromWin32(lRes); - } - - if (FAILED(hr = NextToken(szToken))) - return hr; - - return S_OK; -} - -inline BOOL CRegParser::CanForceRemoveKey(LPCTSTR szKey) -{ - for (int iNoDel = 0; iNoDel < cbNeverDelete; iNoDel++) - if (!lstrcmpi(szKey, rgszNeverDelete[iNoDel])) - return FALSE; // We cannot delete it - - return TRUE; -} - -inline BOOL CRegParser::HasSubKeys(HKEY hkey) -{ - DWORD cbSubKeys = 0; - - if (RegQueryInfoKey(hkey, NULL, NULL, NULL, - &cbSubKeys, NULL, NULL, - NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) - { - ATLTRACE(atlTraceRegistrar, 0, _T("Should not be here!!\n")); - ATLASSERT(FALSE); - return FALSE; - } - - return cbSubKeys > 0; -} - -inline BOOL CRegParser::HasValues(HKEY hkey) -{ - DWORD cbValues = 0; - - LONG lResult = RegQueryInfoKey(hkey, NULL, NULL, NULL, - NULL, NULL, NULL, - &cbValues, NULL, NULL, NULL, NULL); - if (ERROR_SUCCESS != lResult) - { - ATLTRACE(atlTraceRegistrar, 0, _T("RegQueryInfoKey Failed ")); - ATLASSERT(FALSE); - return FALSE; - } - - if (1 == cbValues) - { - DWORD cbMaxName= MAX_VALUE; - TCHAR szValueName[MAX_VALUE]; - // Check to see if the Value is default or named - lResult = RegEnumValue(hkey, 0, szValueName, &cbMaxName, NULL, NULL, NULL, NULL); - if (ERROR_SUCCESS == lResult && (szValueName[0] != NULL)) - return TRUE; // Named Value means we have a value - return FALSE; - } - - return cbValues > 0; // More than 1 means we have a non-default value -} - -inline HRESULT CRegParser::SkipAssignment(__inout_ecount_z(MAX_VALUE_VALUE) LPTSTR szToken) -{ - HRESULT hr; - TCHAR szValue[MAX_VALUE]; - - if (*szToken == chEquals) - { - if (FAILED(hr = NextToken(szToken))) - return hr; - // Skip assignment - SkipWhiteSpace(); - if (FAILED(hr = NextToken(szValue))) - return hr; - if (FAILED(hr = NextToken(szToken))) - return hr; - } - - return S_OK; -} - -inline HRESULT CRegParser::PreProcessBuffer(__in_z LPTSTR lpszReg, __deref_out_z LPTSTR* ppszReg) -{ - ATLASSERT(lpszReg != NULL); - ATLASSERT(ppszReg != NULL); - - if (lpszReg == NULL || ppszReg == NULL) - return E_POINTER; - - *ppszReg = NULL; - int nSize = lstrlen(lpszReg)*2; - CParseBuffer pb(nSize); - if (pb.p == NULL) - return E_OUTOFMEMORY; - m_pchCur = lpszReg; - HRESULT hr = S_OK; - - while (*m_pchCur != NULL) // look for end - { - if (*m_pchCur == _T('%')) - { - m_pchCur = CharNext(m_pchCur); - if (*m_pchCur == _T('%')) - { - if (!pb.AddChar(m_pchCur)) - { - hr = E_OUTOFMEMORY; - break; - } - } - else - { - LPTSTR lpszNext = StrChr(m_pchCur, _T('%')); - if (lpszNext == NULL) - { - ATLTRACE(atlTraceRegistrar, 0, _T("Error no closing %% found\n")); - hr = GenerateError(E_ATL_UNEXPECTED_EOS); - break; - } - if ((lpszNext-m_pchCur) > 31) - { - hr = E_FAIL; - break; - } - int nLength = int(lpszNext - m_pchCur); - TCHAR buf[32]; - Checked::tcsncpy_s(buf, _countof(buf), m_pchCur, nLength); - LPCOLESTR lpszVar = m_pRegObj->StrFromMap(buf); - if (lpszVar == NULL) - { - hr = GenerateError(E_ATL_NOT_IN_MAP); - break; - } - if (!pb.AddString(lpszVar)) - { - hr = E_OUTOFMEMORY; - break; - } - - while (m_pchCur != lpszNext) - m_pchCur = CharNext(m_pchCur); - } - } - else - { - if (!pb.AddChar(m_pchCur)) - { - hr = E_OUTOFMEMORY; - break; - } - } - - m_pchCur = CharNext(m_pchCur); - } - if (SUCCEEDED(hr)) - *ppszReg = pb.Detach(); - return hr; -} - -inline HRESULT CRegParser::RegisterBuffer(__in_z LPTSTR szBuffer, __in BOOL bRegister) -{ - TCHAR szToken[MAX_VALUE]; - HRESULT hr = S_OK; - - LPTSTR szReg = NULL; - hr = PreProcessBuffer(szBuffer, &szReg); - if (FAILED(hr)) - return hr; - - ATLTRACE(atlTraceRegistrar, 0, _T("%s\n"), szReg); - - m_pchCur = szReg; - - // Preprocess szReg - - while (NULL != *m_pchCur) - { - if (FAILED(hr = NextToken(szToken))) - break; - HKEY hkBase; - if ((hkBase = HKeyFromString(szToken)) == NULL) - { - ATLTRACE(atlTraceRegistrar, 0, _T("HKeyFromString failed on %s\n"), szToken); - hr = GenerateError(E_ATL_BAD_HKEY); - break; - } - - if (FAILED(hr = NextToken(szToken))) - break; - - if (chLeftBracket != *szToken) - { - ATLTRACE(atlTraceRegistrar, 0, _T("Syntax error, expecting a {, found a %s\n"), szToken); - hr = GenerateError(E_ATL_MISSING_OPENKEY_TOKEN); - break; - } - if (bRegister) - { - LPTSTR szRegAtRegister = m_pchCur; - hr = RegisterSubkeys(szToken, hkBase, bRegister); - if (FAILED(hr)) - { - ATLTRACE(atlTraceRegistrar, 0, _T("Failed to register, cleaning up!\n")); - m_pchCur = szRegAtRegister; - RegisterSubkeys(szToken, hkBase, FALSE); - break; - } - } - else - { - if (FAILED(hr = RegisterSubkeys(szToken, hkBase, bRegister))) - break; - } - - SkipWhiteSpace(); - } - CoTaskMemFree(szReg); - return hr; -} - -inline HRESULT CRegParser::RegisterSubkeys(__out_ecount_z(MAX_VALUE_VALUE) LPTSTR szToken, __in HKEY hkParent, __in BOOL bRegister, __in BOOL bRecover) -{ - CRegKey keyCur; - LONG lRes; - TCHAR szKey[_MAX_PATH]; - BOOL bDelete = TRUE; - BOOL bInRecovery = bRecover; - HRESULT hr = S_OK; - - ATLTRACE(atlTraceRegistrar, 2, _T("Num Els = %d\n"), cbNeverDelete); - if (FAILED(hr = NextToken(szToken))) - return hr; - - - while (*szToken != chRightBracket) // Continue till we see a } - { - - - bDelete = TRUE; - BOOL bTokenDelete = !lstrcmpi(szToken, szDelete); - - if (!lstrcmpi(szToken, szForceRemove) || bTokenDelete) - { - if (FAILED(hr = NextToken(szToken))) - break; - - if (bRegister) - { - CRegKey rkForceRemove; - - if (StrChr(szToken, chDirSep) != NULL) - return GenerateError(E_ATL_COMPOUND_KEY); - - if (CanForceRemoveKey(szToken)) - { - rkForceRemove.Attach(hkParent); - // Error not returned. We will overwrite the values any way. - rkForceRemove.RecurseDeleteKey(szToken); - rkForceRemove.Detach(); - } - if (bTokenDelete) - { - if (FAILED(hr = NextToken(szToken))) - break; - if (FAILED(hr = SkipAssignment(szToken))) - break; - goto EndCheck; - } - } - - } - - if (!lstrcmpi(szToken, szNoRemove)) - { - bDelete = FALSE; // set even for register - if (FAILED(hr = NextToken(szToken))) - break; - } - - if (!lstrcmpi(szToken, szValToken)) // need to add a value to hkParent - { - TCHAR szValueName[MAX_VALUE]; - - if (FAILED(hr = NextToken(szValueName))) - break; - if (FAILED(hr = NextToken(szToken))) - break; - - if (*szToken != chEquals) - return GenerateError(E_ATL_EXPECTING_EQUAL); - - if (bRegister) - { - CRegKey rk; - - rk.Attach(hkParent); - hr = AddValue(rk, szValueName, szToken); - rk.Detach(); - - if (FAILED(hr)) - return hr; - - goto EndCheck; - } - else - { - if (!bRecover && bDelete) - { - ATLTRACE(atlTraceRegistrar, 1, _T("Deleting %s\n"), szValueName); - // We have to open the key for write to be able to delete. - CRegKey rkParent; - lRes = rkParent.Open(hkParent, NULL, KEY_WRITE); - if (lRes == ERROR_SUCCESS) - { - lRes = rkParent.DeleteValue(szValueName); - if (lRes != ERROR_SUCCESS && lRes != ERROR_FILE_NOT_FOUND) - { - // Key not present is not an error - hr = AtlHresultFromWin32(lRes); - break; - } - } - else - { - hr = AtlHresultFromWin32(lRes); - break; - } - } - if (FAILED(hr = SkipAssignment(szToken))) - break; - continue; // can never have a subkey - } - } - - if (StrChr(szToken, chDirSep) != NULL) - return GenerateError(E_ATL_COMPOUND_KEY); - - if (bRegister) - { - lRes = keyCur.Open(hkParent, szToken, KEY_READ | KEY_WRITE); - if (ERROR_SUCCESS != lRes) - { - // Failed all access try read only - lRes = keyCur.Open(hkParent, szToken, KEY_READ); - if (ERROR_SUCCESS != lRes) - { - // Finally try creating it - ATLTRACE(atlTraceRegistrar, 2, _T("Creating key %s\n"), szToken); - lRes = keyCur.Create(hkParent, szToken, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE); - if (lRes != ERROR_SUCCESS) - return AtlHresultFromWin32(lRes); - } - } - - if (FAILED(hr = NextToken(szToken))) - break; - - - if (*szToken == chEquals) - { - if (FAILED(hr = AddValue(keyCur, NULL, szToken))) // NULL == default - break; - } - } - else //Unregister - { - if (!bRecover) - { - lRes = keyCur.Open(hkParent, szToken, KEY_READ); - - } - else - lRes = ERROR_FILE_NOT_FOUND; - - - // Open failed set recovery mode - if (lRes != ERROR_SUCCESS) - bRecover = true; - - // TRACE out Key open status and if in recovery mode -#ifdef _DEBUG - if (!bRecover) - ATLTRACE(atlTraceRegistrar, 1, _T("Opened Key %s\n"), szToken); - else - ATLTRACE(atlTraceRegistrar, 0, _T("Ignoring Open key on %s : In Recovery mode\n"), szToken); -#endif //_DEBUG - - // Remember Subkey - Checked::tcsncpy_s(szKey, _countof(szKey), szToken, _TRUNCATE); - - if (FAILED(hr = NextToken(szToken))) - break; - if (FAILED(hr = SkipAssignment(szToken))) - break; - - if (*szToken == chLeftBracket && lstrlen(szToken) == 1) - { - hr = RegisterSubkeys(szToken, keyCur.m_hKey, bRegister, bRecover); - // In recover mode ignore error - if (FAILED(hr) && !bRecover) - break; - // Skip the } - if (FAILED(hr = NextToken(szToken))) - break; - } - -#ifdef _DEBUG - if (bRecover != bInRecovery) - ATLTRACE(atlTraceRegistrar, 0, _T("Ending Recovery Mode\n")); -#endif - bRecover = bInRecovery; - - if (lRes == ERROR_FILE_NOT_FOUND) - // Key already not present so not an error. - continue; - - if (lRes != ERROR_SUCCESS) - { - // We are recovery mode continue on errors else break - if (bRecover) - continue; - else - { - hr = AtlHresultFromWin32(lRes); - break; - } - } - - // If in recovery mode - if (bRecover && HasSubKeys(keyCur)) - { - // See if the KEY is in the NeverDelete list and if so, don't - if (CanForceRemoveKey(szKey) && bDelete) - { - ATLTRACE(atlTraceRegistrar, 0, _T("Deleting non-empty subkey %s by force\n"), szKey); - // Error not returned since we are in recovery mode. The error that caused recovery mode is returned - keyCur.RecurseDeleteKey(szKey); - } - continue; - } - - BOOL bHasSubKeys=HasSubKeys(keyCur); - lRes = keyCur.Close(); - if (lRes != ERROR_SUCCESS) - return AtlHresultFromWin32(lRes); - - if (bDelete&& !bHasSubKeys) - { - ATLTRACE(atlTraceRegistrar, 0, _T("Deleting Key %s\n"), szKey); - CRegKey rkParent; - rkParent.Attach(hkParent); - lRes = rkParent.DeleteSubKey(szKey); - rkParent.Detach(); - if (lRes != ERROR_SUCCESS) - { - - hr = AtlHresultFromWin32(lRes); - break; - } - } - - - - - } - -EndCheck: - - if (bRegister) - { - if (*szToken == chLeftBracket && lstrlen(szToken) == 1) - { - if (FAILED(hr = RegisterSubkeys(szToken, keyCur.m_hKey, bRegister, FALSE))) - break; - if (FAILED(hr = NextToken(szToken))) - break; - } - } - } - - return hr; -} - -}; //namespace ATL - -#pragma pack(pop) -#pragma warning(pop) - -#endif //__STATREG_H__ - diff --git a/cpp/jacob/lib/atls.lib b/cpp/jacob/lib/atls.lib deleted file mode 100644 index 48cd9c0..0000000 Binary files a/cpp/jacob/lib/atls.lib and /dev/null differ diff --git a/cpp/jacob/msvc/copy.bat b/cpp/jacob/msvc/copy.bat deleted file mode 100644 index b10047c..0000000 --- a/cpp/jacob/msvc/copy.bat +++ /dev/null @@ -1 +0,0 @@ -copy Release\jacob.dll ..\..\..\java\native\ \ No newline at end of file diff --git a/cpp/jacob/msvc/jacob.sln b/cpp/jacob/msvc/jacob.sln deleted file mode 100644 index 50ae3e2..0000000 --- a/cpp/jacob/msvc/jacob.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jacob", "jacob.vcxproj", "{745CA8EA-176E-46A7-B2A5-55260DF5639B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {745CA8EA-176E-46A7-B2A5-55260DF5639B}.Debug|Win32.ActiveCfg = Debug|Win32 - {745CA8EA-176E-46A7-B2A5-55260DF5639B}.Debug|Win32.Build.0 = Debug|Win32 - {745CA8EA-176E-46A7-B2A5-55260DF5639B}.Release|Win32.ActiveCfg = Release|Win32 - {745CA8EA-176E-46A7-B2A5-55260DF5639B}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/cpp/jacob/msvc/jacob.suo b/cpp/jacob/msvc/jacob.suo deleted file mode 100644 index 706c50c..0000000 Binary files a/cpp/jacob/msvc/jacob.suo and /dev/null differ diff --git a/cpp/jacob/msvc/jacob.vcxproj b/cpp/jacob/msvc/jacob.vcxproj deleted file mode 100644 index 8c3a22c..0000000 --- a/cpp/jacob/msvc/jacob.vcxproj +++ /dev/null @@ -1,105 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {745CA8EA-176E-46A7-B2A5-55260DF5639B} - Win32Proj - jacob - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - true - - - false - ..\include;C:\Program Files %28x86%29\Java\jdk1.6.0_23\include;C:\Program Files %28x86%29\Java\jdk1.6.0_23\include\win32;$(IncludePath) - ..\lib;$(LibraryPath) - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;JACOB_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;JACOB_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cpp/jacob/msvc/jacob.vcxproj.filters b/cpp/jacob/msvc/jacob.vcxproj.filters deleted file mode 100644 index 5729cab..0000000 --- a/cpp/jacob/msvc/jacob.vcxproj.filters +++ /dev/null @@ -1,87 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/cpp/jacob/msvc/jacob.vcxproj.user b/cpp/jacob/msvc/jacob.vcxproj.user deleted file mode 100644 index 695b5c7..0000000 --- a/cpp/jacob/msvc/jacob.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/cpp/jacob/util.cpp b/cpp/jacob/util.cpp deleted file mode 100644 index b0f6c19..0000000 --- a/cpp/jacob/util.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "Dispatch.h" -// Win32 support for Ole Automation -#include -#include -#include -#include -#include -#include -#include "util.h" - -extern "C" -{ - -void ThrowComFail(JNIEnv *env, const char* desc, jint hr) -{ - jclass failClass = env->FindClass("com/jacob/com/ComFailException"); - // call the constructor that takes hr and message - jmethodID failCons = - env->GetMethodID(failClass, "", "(ILjava/lang/String;)V"); - if (!desc) { - desc = "Java/COM Error"; - } - jstring js = env->NewStringUTF(desc); - jthrowable fail = (jthrowable)env->NewObject(failClass, failCons, hr, js); - env->Throw(fail); -} - -void ThrowComFailUnicode(JNIEnv *env, const wchar_t* desc, jint hr) -{ - if (!desc) { - ThrowComFail(env, "Java/COM Error", hr); - } - jclass failClass = env->FindClass("com/jacob/com/ComFailException"); - // call the constructor that takes hr and message - jmethodID failCons = - env->GetMethodID(failClass, "", "(ILjava/lang/String;)V"); - jstring js = env->NewString((const jchar *) desc, wcslen(desc)); - jthrowable fail = (jthrowable)env->NewObject(failClass, failCons, hr, js); - env->Throw(fail); -} - -// if env's are different throw on the 1st env -int CheckEnv(JNIEnv *env1, JNIEnv *env2) -{ - if (env1 != env2) { - jclass failClass = env1->FindClass("com/jacob/com/WrongThreadException"); - // call the constructor that takes hr and message - jmethodID failCons = - env1->GetMethodID(failClass, "", "()V"); - env1->ThrowNew(failClass, "Wrong Thread"); - return 0; - } - return 1; -} - -} diff --git a/cpp/jacob/util.h b/cpp/jacob/util.h deleted file mode 100644 index 5835154..0000000 --- a/cpp/jacob/util.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -extern "C" { - VARIANT *extractVariant(JNIEnv *env, jobject arg); - void ThrowComFail(JNIEnv *env, const char* desc, jint hr); - void ThrowComFailUnicode(JNIEnv *env, const wchar_t* desc, jint hr); - IDispatch *extractDispatch(JNIEnv *env, jobject arg); - SAFEARRAY *extractSA(JNIEnv *env, jobject arg); - void setSA(JNIEnv *env, jobject arg, SAFEARRAY *sa, int copy); - SAFEARRAY *copySA(SAFEARRAY *psa); -} diff --git a/cpp/jintellitype/JIntellitype.cpp b/cpp/jintellitype/JIntellitype.cpp deleted file mode 100644 index 3481412..0000000 --- a/cpp/jintellitype/JIntellitype.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - JIntellitype (http://www.melloware.com/) - Java JNI API for Windows Intellitype commands and global keystrokes. - - Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - Compiled with Mingw port of GCC, - Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) -*/ -#include "stdafx.h" -#include "com_melloware_jintellitype_JIntellitype.h" -#include "JIntellitypeHandler.h" - -HINSTANCE g_instance = NULL; - - -BOOL WINAPI DllMain -( - HINSTANCE hinstDLL, // handle to DLL module - DWORD fdwReason, // reason for calling function - LPVOID lpvReserved // reserved -) -{ - switch( fdwReason ) - { - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - - case DLL_PROCESS_ATTACH: - g_instance = hinstDLL; - - break; - } - return TRUE; -} - - -extern "C" -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: initializeLibrary - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_initializeLibrary - (JNIEnv *env, jobject object) -{ - // Get handler - JIntellitypeHandler *l_handler = JIntellitypeHandler::extract( env, object ); - - // Create our handler - l_handler = new JIntellitypeHandler( env, object ); - - // Enable it - if( l_handler ) - l_handler->initialize(env, g_instance); -} - -extern "C" -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: regHotKey - * Signature: (III)V - */ -JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_regHotKey - (JNIEnv *env, jobject object, jint identifier, jint modifier, jint keycode) -{ - // Get handler - JIntellitypeHandler *l_handler = JIntellitypeHandler::extract( env, object ); - - if( l_handler ) - { - l_handler->regHotKey(identifier, modifier, keycode); - } - else - { - // throw exception - jclass JIntellitypeException = env->FindClass("com/melloware/jintellitype/JIntellitypeException"); - env->ThrowNew(JIntellitypeException,"JIntellitype was not initialized properly."); - } -} - -extern "C" -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: unregHotKey - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_unregHotKey - (JNIEnv *env, jobject object, jint identifier) -{ - // Get handler - JIntellitypeHandler *l_handler = JIntellitypeHandler::extract( env, object ); - - if( l_handler ) - { - l_handler->unregHotKey(identifier); - } - else - { - // throw exception - jclass JIntellitypeException = env->FindClass("com/melloware/jintellitype/JIntellitypeException"); - env->ThrowNew(JIntellitypeException,"JIntellitype was not initialized properly."); - } - -} - -extern "C" -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: terminate - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_terminate - (JNIEnv *env, jobject object) -{ - // Get handler - JIntellitypeHandler *l_handler = JIntellitypeHandler::extract( env, object ); - - // Clean up all resources allocated by this API - if( l_handler ) - l_handler->terminate(); - -} - -extern "C" -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: isRunning - * Signature: (Ljava/lang/String;)Z - */ -JNIEXPORT jboolean JNICALL Java_com_melloware_jintellitype_JIntellitype_isRunning - (JNIEnv *env, jclass, jstring wndName) -{ - // App name for the hidden window's registered class - CHAR szAppName[] = "SunAwtFrame"; - const char *cWndName = env->GetStringUTFChars(wndName, 0); - // Find out if there's a hidden window with the given title - HWND mHwnd = FindWindow((LPCWSTR)szAppName, (LPCWSTR)cWndName); - env->ReleaseStringUTFChars(wndName, cWndName); - // If there is, another instance of our app is already running - return mHwnd != NULL; -} - diff --git a/cpp/jintellitype/JIntellitypeHandler.cpp b/cpp/jintellitype/JIntellitypeHandler.cpp deleted file mode 100644 index b937c10..0000000 --- a/cpp/jintellitype/JIntellitypeHandler.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* - JIntellitype (http://www.melloware.com/) - Java JNI API for Windows Intellitype commands and global keystrokes. - - Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - Compiled with Mingw port of GCC, - Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) -*/ -#include "stdafx.h" -#include "JIntellitypeHandler.h" -#include "JIntellitypeThread.h" -#include - - -UINT WM_SHELLHOOK = 0; - -/* - * Extract the unique handlerID from the java object - */ -JIntellitypeHandler *JIntellitypeHandler::extract( JNIEnv *env, jobject object ) -{ - // Get field ID - jfieldID l_handlerId = env->GetFieldID( env->GetObjectClass( object ), "handler", "I" ); - - // Get field - JIntellitypeHandler *l_handler = (JIntellitypeHandler *) env->GetIntField( object, l_handlerId ); - - return l_handler; -} - -/* - * Constructor - */ -JIntellitypeHandler::JIntellitypeHandler( JNIEnv *env, jobject object ) -{ - m_window = NULL; - - // Reference object - m_object = env->NewGlobalRef(object ); - - // Get method IDs - m_fireHotKey = env->GetMethodID( env->GetObjectClass( m_object ) , "onHotKey", "(I)V" ); - m_fireIntellitype = env->GetMethodID( env->GetObjectClass( m_object ) , "onIntellitype", "(I)V" ); - - // Get field ID - jfieldID l_handlerId = env->GetFieldID( env->GetObjectClass( m_object ) , "handler", "I" ); - - // Set field - env->SetIntField( m_object, l_handlerId, (jint) this ); -} - -/* - * Destructor - */ -JIntellitypeHandler::~JIntellitypeHandler() -{ - // Get field ID - jfieldID l_handlerId = g_JIntellitypeThread.m_env->GetFieldID( g_JIntellitypeThread.m_env->GetObjectClass( m_object ), "handler", "I" ); - - // Set field - g_JIntellitypeThread.m_env->SetIntField( m_object, l_handlerId, 0 ); - - // Release our reference - g_JIntellitypeThread.m_env->DeleteGlobalRef( m_object ); - - // unregister the shell hook - DeregisterShellHookWindow( m_window ); - - // Destroy window - DestroyWindow( m_window ); -} - - -/* - * Perform initialization of the object and thread. - */ -void JIntellitypeHandler::initialize( JNIEnv *env, HINSTANCE instance ) -{ - m_instance = instance; - g_JIntellitypeThread.MakeSureThreadIsUp( env ); - while( !PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, INITIALIZE_CODE, (LPARAM) this ) ) - Sleep( 0 ); -} - -/* - * Callback method that creates the hidden window on initialization to receive - * any WM_HOTKEY messages and process them. - */ -void JIntellitypeHandler::doInitialize() -{ - // Register window class - WNDCLASSEX l_Class; - l_Class.cbSize = sizeof( l_Class ); - l_Class.style = CS_HREDRAW | CS_VREDRAW; - l_Class.lpszClassName = TEXT( "JIntellitypeHandlerClass" ); - l_Class.lpfnWndProc = WndProc; - l_Class.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - l_Class.hCursor = NULL; - l_Class.hIcon = NULL; - l_Class.hIconSm = NULL; - l_Class.lpszMenuName = NULL; - l_Class.cbClsExtra = 0; - l_Class.cbWndExtra = 0; - l_Class.hInstance = m_instance; - - if( !RegisterClassEx( &l_Class ) ) - return; - - // Create window - m_window = CreateWindow - ( - TEXT( "JIntellitypeHandlerClass" ), - TEXT( "JIntellitypeHandler" ), - WS_OVERLAPPEDWINDOW, - 0, 0, 0, 0, - NULL, - NULL, - m_instance, - NULL - ); - - if( !m_window ) - return; - - //Set pointer to this object inside the Window's USERDATA section - SetWindowLong( m_window, GWL_USERDATA, (LONG) this ); - - // hide the window - ShowWindow(m_window, SW_HIDE); - UpdateWindow(m_window); - - //register this window as a shell hook to intercept WM_APPCOMMAND messages - WM_SHELLHOOK = RegisterWindowMessage(TEXT("SHELLHOOK")); - BOOL (__stdcall *RegisterShellHookWindow)(HWND) = NULL; - RegisterShellHookWindow = (BOOL (__stdcall *)(HWND))GetProcAddress(GetModuleHandle((LPCWSTR)"USER32.DLL"), "RegisterShellHookWindow"); - - //make sure it worked - if (!RegisterShellHookWindow(m_window)) { - // throw exception - jclass JIntellitypeException = g_JIntellitypeThread.m_env->FindClass("com/melloware/jintellitype/JIntellitypeException"); - g_JIntellitypeThread.m_env->ThrowNew(JIntellitypeException,"Could not register window as a shell hook window."); - } -} - -/* - * Registers a hotkey. - * identifier - unique identifier assigned to this key comination - * modifier - ALT, SHIFT, CTRL, WIN or combination of - * keycode- Ascii keycode, 65 for A, 66 for B etc - */ -void JIntellitypeHandler::regHotKey( jint identifier, jint modifier, jint keycode ) -{ - JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) malloc(sizeof(JIntellitypeHandlerCallback)); - callback->identifier = identifier; - callback->modifier = modifier; - callback->keycode = keycode; - callback->handler = this; - PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, REGISTER_HOTKEY_CODE, (LPARAM) callback ); -} - -/* - * Actually registers the hotkey using the Win32API RegisterHotKey call. - */ -void JIntellitypeHandler::doRegHotKey(LPARAM callback_) -{ - JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) callback_; - RegisterHotKey(m_window, callback->identifier, callback->modifier, callback->keycode); - free(callback); -} - -/* - * Unregisters a previously assigned hotkey. - * identifier - unique identifier assigned to this key comination - */ -void JIntellitypeHandler::unregHotKey( jint identifier ) -{ - JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) malloc(sizeof(JIntellitypeHandlerCallback)); - callback->identifier = identifier; - callback->handler = this; - PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, UNREGISTER_HOTKEY_CODE, (LPARAM) callback ); -} - -/* - * Actually unregisters the hotkey using the Win32API UnregisterHotKey call. - */ -void JIntellitypeHandler::doUnregisterHotKey(LPARAM callback_) -{ - JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) callback_; - UnregisterHotKey(m_window, callback->identifier); - free(callback); -} - -/* - * When an intellitype command is recieved by the JFrame this method is called - * to perform a callback to the Intellitype java listeners. - * commandId - the unique command Id from the WM_APPCOMMAND listings - */ -void JIntellitypeHandler::intellitype( jint commandId ) -{ - JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) malloc(sizeof(JIntellitypeHandlerCallback)); - callback->command = commandId; - callback->handler = this; - PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, INTELLITYPE_CODE, (LPARAM) callback ); -} - -/* - * Call the correct JVM with the intellitype command for the listeners listening. - */ -void JIntellitypeHandler::doIntellitype(LPARAM callback_) -{ - JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) callback_; - g_JIntellitypeThread.m_env->CallVoidMethod(m_object, m_fireIntellitype, callback->command); - free(callback); -} - -/* - * Cleans up resources allocated by JIntellitype. - */ -void JIntellitypeHandler::terminate() -{ - PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, TERMINATE_CODE, (LPARAM) this ); -} - -/* - * Callback method to send hotkey to the Java HotKeyListeners registered. - */ -void JIntellitypeHandler::fireHotKey(jint hotkeyId) -{ - g_JIntellitypeThread.m_env->CallVoidMethod(m_object, m_fireHotKey, hotkeyId); -} - - -/* - * WndProc method registered to the hidden window to listen for WM_HOTKEY - * messages and send them back to the Java listeners. - */ -LRESULT CALLBACK JIntellitypeHandler::WndProc( HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam ) -{ - - // check for Intellitype messages and if found send them to Intellitype listeners - if (uMessage == WM_SHELLHOOK) { - if (wParam == HSHELL_APPCOMMAND) { - jint cmd = GET_APPCOMMAND_LPARAM(lParam); - JIntellitypeHandler *l_this = (JIntellitypeHandler *) GetWindowLong( hWnd, GWL_USERDATA ); - l_this->intellitype(cmd); - } - return TRUE; - } - - // check for registered hotkey messages and send them to HotKeyListeners - switch( uMessage ) { - case WM_HOTKEY: { - JIntellitypeHandler *l_this = (JIntellitypeHandler *) GetWindowLong( hWnd, GWL_USERDATA ); - l_this->fireHotKey(wParam); - return TRUE; - break; - } - default: - return DefWindowProc( hWnd, uMessage, wParam, lParam ); - } - -} - - - diff --git a/cpp/jintellitype/JIntellitypeHandler.h b/cpp/jintellitype/JIntellitypeHandler.h deleted file mode 100644 index d003ff9..0000000 --- a/cpp/jintellitype/JIntellitypeHandler.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - JIntellitype (http://www.melloware.com/) - Java JNI API for Windows Intellitype commands and global keystrokes. - - Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - Compiled with Mingw port of GCC, - Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) -*/ -#ifndef __JIntellitypeHandler_h__ -#define __JIntellitypeHandler_h__ - -#include "JIntellitypeThread.h" - -class JIntellitypeHandler -{ - friend DWORD WINAPI JIntellitypeThread::ThreadProc( LPVOID lpParameter ); - -public: - - static JIntellitypeHandler *extract( JNIEnv *env, jobject object ); - - JIntellitypeHandler( JNIEnv *env, jobject object ); - - void initialize( JNIEnv *env, HINSTANCE instance ); - void regHotKey( jint identifier, jint modifier, jint keycode ); - void unregHotKey( jint identifier ); - void intellitype( jint commandId ); - void terminate(); - -private: - - enum - { - INITIALIZE_CODE = 1, - REGISTER_HOTKEY_CODE = 2, - UNREGISTER_HOTKEY_CODE = 3, - TERMINATE_CODE = 4, - INTELLITYPE_CODE = 5 - }; - - ~JIntellitypeHandler(); - - void createHiddenWindow(); - void doInitialize(); - void doRegHotKey(LPARAM callback); - void doUnregisterHotKey(LPARAM callback); - void doIntellitype(LPARAM callback); - void fireHotKey(jint hotkeyId); - void fireIntellitype(jint commandId); - - HINSTANCE m_instance; - HWND m_window; - jobject m_object; - jmethodID m_fireHotKey; - jmethodID m_fireIntellitype; - - static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam ); - static DWORD WINAPI ThreadProc( LPVOID lpParameter ); -}; - -typedef struct { - JIntellitypeHandler *handler; - jint identifier; - jint modifier; - jint keycode; - jint command; -} JIntellitypeHandlerCallback; - - -#ifndef WM_APPCOMMAND -#define WM_APPCOMMAND 0x319 -#define FAPPCOMMAND_MASK 0x8000 -#define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK)) -#define HSHELL_APPCOMMAND 12 - -#endif - - -#endif diff --git a/cpp/jintellitype/JIntellitypeThread.cpp b/cpp/jintellitype/JIntellitypeThread.cpp deleted file mode 100644 index dc55048..0000000 --- a/cpp/jintellitype/JIntellitypeThread.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - JIntellitype (http://www.melloware.com/) - Java JNI API for Windows Intellitype commands and global keystrokes. - - Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - Compiled with Mingw port of GCC, - Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) -*/ -#include "stdafx.h" -#include "JIntellitypeThread.h" -#include "JIntellitypeHandler.h" - -JIntellitypeThread g_JIntellitypeThread; - - -JIntellitypeThread::JIntellitypeThread() -{ - m_env = NULL; - m_thread = 0; - m_vm = NULL; - m_handlerCount = 0; -} - - -void JIntellitypeThread::MakeSureThreadIsUp( JNIEnv *env ) -{ - if( !m_thread ) - { - // Get VM - env->GetJavaVM( &m_vm ); - - // Start "native" thread - CreateThread - ( - NULL, - 0, - ThreadProc, - this, - 0, - &m_thread - ); - } -} - - -JIntellitypeThread::operator DWORD () -{ - return m_thread; -} - - -DWORD WINAPI JIntellitypeThread::ThreadProc( LPVOID lpParameter ) -{ - JIntellitypeThread *l_this = (JIntellitypeThread *) lpParameter; - - // Attach the thread to the VM - l_this->m_vm->AttachCurrentThread( (void**) &l_this->m_env, NULL ); - - MSG msg; - while( GetMessage( &msg, NULL, 0, 0 ) ) - { - if( msg.message == WM_JINTELLITYPE ) - { - // Extract handler - JIntellitypeHandler *l_handler; - - switch( msg.wParam ) - { - case JIntellitypeHandler::INITIALIZE_CODE: - l_handler = (JIntellitypeHandler*) msg.lParam; - l_this->m_handlerCount++; - l_handler->doInitialize(); - break; - case JIntellitypeHandler::REGISTER_HOTKEY_CODE: - l_handler = ((JIntellitypeHandlerCallback*) msg.lParam)->handler; - l_handler->doRegHotKey(msg.lParam); - break; - - case JIntellitypeHandler::UNREGISTER_HOTKEY_CODE: - l_handler = ((JIntellitypeHandlerCallback*) msg.lParam)->handler; - l_handler->doUnregisterHotKey(msg.lParam); - break; - case JIntellitypeHandler::INTELLITYPE_CODE: - l_handler = ((JIntellitypeHandlerCallback*) msg.lParam)->handler; - l_handler->doIntellitype(msg.lParam); - break; - - case JIntellitypeHandler::TERMINATE_CODE: - l_handler = (JIntellitypeHandler*) msg.lParam; - - // Destroy it! - delete l_handler; - - // No more handlers? - if( !--l_this->m_handlerCount ) - { - l_this->m_thread = 0; - - // Detach thread from VM - l_this->m_vm->DetachCurrentThread(); - - // Time to die - ExitThread( 0 ); - } - break; - } - } - else - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - - // Detach thread from VM - l_this->m_vm->DetachCurrentThread(); - - return 0; -} diff --git a/cpp/jintellitype/JIntellitypeThread.h b/cpp/jintellitype/JIntellitypeThread.h deleted file mode 100644 index 10b09f9..0000000 --- a/cpp/jintellitype/JIntellitypeThread.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - JIntellitype (http://www.melloware.com/) - Java JNI API for Windows Intellitype commands and global keystrokes. - - Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - Compiled with Mingw port of GCC, - Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) -*/ -#ifndef __JIntellitypeThread_h__ -#define __JIntellitypeThread_h__ - - -class JIntellitypeThread -{ -public: - - JIntellitypeThread(); - - void MakeSureThreadIsUp( JNIEnv *env ); - - JNIEnv *m_env; - static DWORD WINAPI ThreadProc( LPVOID lpParameter ); - - operator DWORD (); - -private: - - DWORD m_thread; - JavaVM *m_vm; - int m_handlerCount; - - -}; - -extern JIntellitypeThread g_JIntellitypeThread; - - -#define WM_JINTELLITYPE (WM_USER+1) - - -#endif diff --git a/cpp/jintellitype/JIntellitype_private.h b/cpp/jintellitype/JIntellitype_private.h deleted file mode 100644 index 1c7f45e..0000000 --- a/cpp/jintellitype/JIntellitype_private.h +++ /dev/null @@ -1,23 +0,0 @@ -/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ -/* DO NOT EDIT ! */ - -#ifndef JINTELLITYPE_PRIVATE_H -#define JINTELLITYPE_PRIVATE_H - -/* VERSION DEFINITIONS */ -#define VER_STRING "1.0.0.465" -#define VER_MAJOR 1 -#define VER_MINOR 0 -#define VER_RELEASE 0 -#define VER_BUILD 465 -#define COMPANY_NAME "Melloware Inc (www.melloware.com)" -#define FILE_VERSION "1.0" -#define FILE_DESCRIPTION "Java JNI bridge to MS Intellitype commands" -#define INTERNAL_NAME "" -#define LEGAL_COPYRIGHT "Copyright 2006 Melloware Inc" -#define LEGAL_TRADEMARKS "Copyright 2006 Melloware Inc" -#define ORIGINAL_FILENAME "" -#define PRODUCT_NAME "JIntellitype" -#define PRODUCT_VERSION "1.0" - -#endif /*JINTELLITYPE_PRIVATE_H*/ diff --git a/cpp/jintellitype/StdAfx.cpp b/cpp/jintellitype/StdAfx.cpp deleted file mode 100644 index a10ee7b..0000000 --- a/cpp/jintellitype/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// win32.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/cpp/jintellitype/StdAfx.h b/cpp/jintellitype/StdAfx.h deleted file mode 100644 index 7203ae8..0000000 --- a/cpp/jintellitype/StdAfx.h +++ /dev/null @@ -1,24 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__1F571525_24C2_11D3_B0CF_0000E85D9A83__INCLUDED_) -#define AFX_STDAFX_H__1F571525_24C2_11D3_B0CF_0000E85D9A83__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -// Insert your headers here -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include -#include - -#include - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__1F571525_24C2_11D3_B0CF_0000E85D9A83__INCLUDED_) diff --git a/cpp/jintellitype/com_melloware_jintellitype_JIntellitype.h b/cpp/jintellitype/com_melloware_jintellitype_JIntellitype.h deleted file mode 100644 index 2394ca6..0000000 --- a/cpp/jintellitype/com_melloware_jintellitype_JIntellitype.h +++ /dev/null @@ -1,53 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class com_melloware_jintellitype_JIntellitype */ - -#ifndef _Included_com_melloware_jintellitype_JIntellitype -#define _Included_com_melloware_jintellitype_JIntellitype -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: initializeLibrary - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_initializeLibrary - (JNIEnv *, jobject); - -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: regHotKey - * Signature: (III)V - */ -JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_regHotKey - (JNIEnv *, jobject, jint, jint, jint); - -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: terminate - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_terminate - (JNIEnv *, jobject); - -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: unregHotKey - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_unregHotKey - (JNIEnv *, jobject, jint); - -/* - * Class: com_melloware_jintellitype_JIntellitype - * Method: isRunning - * Signature: (Ljava/lang/String;)Z - */ -JNIEXPORT jboolean JNICALL Java_com_melloware_jintellitype_JIntellitype_isRunning - (JNIEnv *, jclass, jstring); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/jintellitype/msvc/copy.bat b/cpp/jintellitype/msvc/copy.bat deleted file mode 100644 index 3f521b0..0000000 --- a/cpp/jintellitype/msvc/copy.bat +++ /dev/null @@ -1 +0,0 @@ -copy Release\jintellitype.dll ..\..\..\java\native\ \ No newline at end of file diff --git a/cpp/jintellitype/msvc/jintellitype.sln b/cpp/jintellitype/msvc/jintellitype.sln deleted file mode 100644 index 8acae3c..0000000 --- a/cpp/jintellitype/msvc/jintellitype.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jintellitype", "jintellitype.vcxproj", "{29297EB4-DE7D-4F2B-9FD7-FEB53409AA7D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {29297EB4-DE7D-4F2B-9FD7-FEB53409AA7D}.Debug|Win32.ActiveCfg = Debug|Win32 - {29297EB4-DE7D-4F2B-9FD7-FEB53409AA7D}.Debug|Win32.Build.0 = Debug|Win32 - {29297EB4-DE7D-4F2B-9FD7-FEB53409AA7D}.Release|Win32.ActiveCfg = Release|Win32 - {29297EB4-DE7D-4F2B-9FD7-FEB53409AA7D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/cpp/jintellitype/msvc/jintellitype.suo b/cpp/jintellitype/msvc/jintellitype.suo deleted file mode 100644 index 13fcffd..0000000 Binary files a/cpp/jintellitype/msvc/jintellitype.suo and /dev/null differ diff --git a/cpp/jintellitype/msvc/jintellitype.vcxproj b/cpp/jintellitype/msvc/jintellitype.vcxproj deleted file mode 100644 index f5334da..0000000 --- a/cpp/jintellitype/msvc/jintellitype.vcxproj +++ /dev/null @@ -1,96 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {29297EB4-DE7D-4F2B-9FD7-FEB53409AA7D} - Win32Proj - jintellitype - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - true - C:\Program Files %28x86%29\Java\jdk1.6.0_23\include;C:\Program Files %28x86%29\Java\jdk1.6.0_23\include\win32;$(IncludePath) - - - false - C:\Program Files %28x86%29\Java\jdk1.6.0_23\include;C:\Program Files %28x86%29\Java\jdk1.6.0_23\include\win32;$(IncludePath) - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;JINTELLITYPE_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;JINTELLITYPE_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - copy.bat - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cpp/jintellitype/msvc/jintellitype.vcxproj.filters b/cpp/jintellitype/msvc/jintellitype.vcxproj.filters deleted file mode 100644 index 4374356..0000000 --- a/cpp/jintellitype/msvc/jintellitype.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/cpp/jintellitype/msvc/jintellitype.vcxproj.user b/cpp/jintellitype/msvc/jintellitype.vcxproj.user deleted file mode 100644 index 695b5c7..0000000 --- a/cpp/jintellitype/msvc/jintellitype.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/cpp/list/dev/copy.bat b/cpp/list/dev/copy.bat deleted file mode 100644 index cbff225..0000000 --- a/cpp/list/dev/copy.bat +++ /dev/null @@ -1 +0,0 @@ -copy list.exe ..\..\..\java\native\ \ No newline at end of file diff --git a/cpp/list/dev/copy.mak b/cpp/list/dev/copy.mak deleted file mode 100644 index 5459618..0000000 --- a/cpp/list/dev/copy.mak +++ /dev/null @@ -1,2 +0,0 @@ -all-after: - copy.bat \ No newline at end of file diff --git a/cpp/list/dev/list.dev b/cpp/list/dev/list.dev deleted file mode 100644 index b9b5046..0000000 --- a/cpp/list/dev/list.dev +++ /dev/null @@ -1,59 +0,0 @@ -[Project] -FileName=list.dev -Name=list -UnitCount=1 -Type=1 -Ver=1 -ObjFiles= -Includes= -Libs= -PrivateResource= -ResourceIncludes= -MakeIncludes=copy.mak -Compiler= -CppCompiler= -Linker= -IsCpp=1 -Icon= -ExeOutput= -ObjectOutput= -OverrideOutput=0 -OverrideOutputName=List.exe -HostApplication= -Folders= -CommandLine= -UseCustomMakefile=0 -CustomMakefile= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=0000000000000000000000 - -[Unit1] -FileName=..\main.cpp -CompileCpp=1 -Folder= -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion= -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= -AutoIncBuildNr=0 - diff --git a/cpp/list/main.cpp b/cpp/list/main.cpp deleted file mode 100644 index 95b444a..0000000 --- a/cpp/list/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include -#include - -BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam); -BOOL GetProcessList(); - -using namespace std; - -int main(int argc, char **argv) { - if (argc == 2) { - if (*argv[1] == 'w') { - printf("handle\tpid\ttitle\n"); - EnumWindows(EnumProc, 0); - return 0; - } else if (*argv[1] == 'p') { - printf("pid\tname\n"); - GetProcessList(); - return 0; - } - } - return 1; -} - -BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam) { - DWORD processId; - GetWindowThreadProcessId(hWnd, &processId); - TCHAR title[500]; - ZeroMemory(title, sizeof(title)); - GetWindowText(hWnd, title, sizeof(title) / sizeof(title[0])); - printf("%d\t%d\t%s\n", hWnd, processId, title); - return TRUE; -} - -BOOL GetProcessList() { - HANDLE hProcessSnap; - HANDLE hProcess; - PROCESSENTRY32 pe32; - - hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (hProcessSnap == INVALID_HANDLE_VALUE) { - return FALSE; - } - - pe32.dwSize = sizeof(PROCESSENTRY32); - if(!Process32First( hProcessSnap, &pe32 ) ) { - CloseHandle(hProcessSnap); - return FALSE; - } - - do { - hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID); - if( hProcess != NULL ) { - CloseHandle( hProcess ); - } - printf("%d\t%s\n", pe32.th32ProcessID, pe32.szExeFile); - } while (Process32Next(hProcessSnap, &pe32)); - - CloseHandle( hProcessSnap ); - return TRUE; -} diff --git a/cpp/nativecall/IntCall.cpp b/cpp/nativecall/IntCall.cpp deleted file mode 100644 index ba49558..0000000 --- a/cpp/nativecall/IntCall.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* - * IntCall.cpp - * - * Created on 11.09.2004. - * - * $Id: IntCall.cpp,v 1.3 2006/04/19 20:54:55 grnull Exp $ - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include -#include "com_eaio_nativecall_IntCall.h" - -#ifdef _WINDOWS -#include -#include -#endif - -#ifdef _WINDOWS -#ifdef _X86_ - -#define _push(x) __asm { push x }; - -#endif -#endif - -// NativeCall fields - -extern jfieldID fieldFunction, fieldModule, fieldFunctionHandle, - fieldModuleHandle, fieldLastErrorCode; - -// Holder fields - -extern jfieldID fieldHolderO; - -// Classes - -extern jclass classBoolean,/* classByte, classCharacter, classShort,*/ - classInteger, /* classLong, classFloat, classDouble,*/ classString, - classByteArray, classCharArray, /*classIntArray,*/ classHolder; - -// Wrapper class methods - -extern jmethodID methodBooleanValue,/* methodByteValue, methodCharValue, -methodShortValue,*/ methodIntValue/*, methodLongValue, methodFloatValue, -methodDoubleValue*/; - -// Constructors - -extern jmethodID newIntegerInt, newBooleanBoolean; - -/* - * Class: com_eaio_nativecall_IntCall - * Method: executeCall - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_eaio_nativecall_IntCall_executeCall -(JNIEnv *env, jobject obj) { - - jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); - jint outVal; - -#ifdef _WINDOWS -#ifdef _X86_ - - __asm { - - call functionHandle - mov outVal, eax - - } - -#endif -#endif - - env->SetIntField(obj, fieldLastErrorCode, GetLastError()); - - return outVal; - -} - -/* - * Class: com_eaio_nativecall_IntCall - * Method: executeCall0 - * Signature: ([Ljava/lang/Object;)I - */ -JNIEXPORT jint JNICALL Java_com_eaio_nativecall_IntCall_executeCall0 -(JNIEnv *env, jobject obj, jobjectArray params) { - - const int len = env->GetArrayLength(params); - - int* arrays = NULL; - if (!(arrays = new int[len])) { - env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), NULL); - return 0; - } - memset(arrays, 0, (sizeof(int) * len)); - - jobject param; - - for (int i = len - 1; i >= 0; i--) { - - param = env->GetObjectArrayElement(params, i); - - if (param == NULL) { - _push(0); - } - else if (env->IsInstanceOf(param, classInteger)) { - int intArg = env->CallIntMethod(param, methodIntValue); - _push(intArg) - } - else if (env->IsInstanceOf(param, classByteArray)) { - char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) param, 0); - arrays[i] = (int) &byteArrayArg; - _push(byteArrayArg) - } - else if (env->IsInstanceOf(param, classCharArray)) { - unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( - (jarray) param, 0); - arrays[i] = (int) &charArrayArg; - _push(charArrayArg) - } - else if (env->IsInstanceOf(param, classBoolean)) { - jboolean booleanArg = env->CallBooleanMethod(param, methodBooleanValue); - int tempArg = (booleanArg == JNI_FALSE ? 0 : 1); - _push(tempArg) - } - else if (env->IsInstanceOf(param, classHolder)) { - - /* Holder */ - - jobject o = env->GetObjectField(param, fieldHolderO); - - if (env->IsInstanceOf(o, classInteger)) { - int *intPtr = new int; - *intPtr = env->CallIntMethod(o, methodIntValue); - arrays[i] = (int) intPtr; - _push(intPtr); - } - else if (env->IsInstanceOf(o, classByteArray)) { - char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) o, 0); - arrays[i] = (int) &byteArrayArg; - _push(byteArrayArg) - } - else if (env->IsInstanceOf(o, classCharArray)) { - unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( - (jarray) o, 0); - arrays[i] = (int) &charArrayArg; - _push(charArrayArg) - } - else if (env->IsInstanceOf(o, classBoolean)) { - jboolean booleanArg = env->CallBooleanMethod(o, methodBooleanValue); - int *tempPtr = new int; - *tempPtr = (booleanArg == JNI_FALSE ? 0 : 1); - arrays[i] = (int) tempPtr; - _push(tempPtr); - } - - /* end Holder */ - - } - - } - - jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); - jint outVal; - -#ifdef _WINDOWS -#ifdef _X86_ - - __asm { - - call functionHandle - mov outVal, eax - - } - -#endif -#endif - - for (int j = 0; j < len; ++j) { - param = env->GetObjectArrayElement(params, j); - if (param == NULL) {} - else if (env->IsInstanceOf(param, classByteArray) || env->IsInstanceOf(param, classCharArray)) { - env->ReleasePrimitiveArrayCritical((jarray) param, (void*) arrays[j], 0); - } - else if (env->IsInstanceOf(param, classHolder)) { - - jobject o = env->GetObjectField(param, fieldHolderO); - - if (env->IsInstanceOf(o, classInteger)) { - int* out = (int*) arrays[j]; - env->SetObjectField(param, fieldHolderO, env->NewObject(classInteger, newIntegerInt, *out)); - delete out; - } - else if (env->IsInstanceOf(o, classByteArray) || env->IsInstanceOf(o, classCharArray)) { - env->ReleasePrimitiveArrayCritical((jarray) o, (void*) arrays[j], 0); - } - else if (env->IsInstanceOf(o, classBoolean)) { - int* out = (int*) arrays[j]; - env->SetObjectField(param, fieldHolderO, env->NewObject(classBoolean, newBooleanBoolean, (*out == 0 ? JNI_FALSE : JNI_TRUE))); - delete out; - } - - } - - } - - delete [] arrays; - - env->SetIntField(obj, fieldLastErrorCode, GetLastError()); - - return outVal; - -} diff --git a/cpp/nativecall/NativeCall.cpp b/cpp/nativecall/NativeCall.cpp deleted file mode 100644 index 5ab390c..0000000 --- a/cpp/nativecall/NativeCall.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* - * NativeCall.cpp - * - * Created on 11.09.2004. - * - * $Id: NativeCall.cpp,v 1.4 2006/04/19 20:54:55 grnull Exp $ - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include -#include "com_eaio_nativecall_NativeCall.h" - -#ifdef _WINDOWS -#include -#include -#endif - -// NativeCall fields - -jfieldID fieldFunction, fieldModule, fieldFunctionHandle, - fieldModuleHandle, fieldLastErrorCode; - -// Holder fields - -jfieldID fieldHolderO; - -// Classes - -jclass classBoolean,/* classByte, classCharacter, classShort,*/ - classInteger, /* classLong, classFloat, classDouble,*/ classString, - classByteArray, classCharArray, /*classIntArray,*/ classHolder; - -// Wrapper class methods - -jmethodID methodBooleanValue,/* methodByteValue, methodCharValue, -methodShortValue,*/ methodIntValue/*, methodLongValue, methodFloatValue, -methodDoubleValue*/; - -// Constructors - -jmethodID newIntegerInt, newBooleanBoolean; - -/* - * Class: com_eaio_nativecall_NativeCall - * Method: initIDs - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_eaio_nativecall_NativeCall_initIDs -(JNIEnv *env, jclass cls) { - - // NativeCall fields - - fieldFunction = env->GetFieldID(cls, "function", "Ljava/lang/String;"); - fieldModule = env->GetFieldID(cls, "module", "Ljava/lang/String;"); - - fieldFunctionHandle = env->GetFieldID(cls, "functionHandle", "I"); - fieldModuleHandle = env-> GetFieldID(cls, "moduleHandle", "I"); - - fieldLastErrorCode = env->GetFieldID(cls, "lastErrorCode", "I"); - - // Holder fields - - classHolder = (jclass) env->NewGlobalRef(env->FindClass("com/eaio/nativecall/Holder")); - fieldHolderO = env->GetFieldID(classHolder, "o", "Ljava/lang/Object;"); - - // Other classes - - classBoolean = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Boolean")); - /*classByte = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Byte")); - classCharacter = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Character")); - classShort = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Short"));*/ - classInteger = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Integer")); - /*classLong = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Long")); - classFloat = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Float")); - classDouble = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Double"));*/ - classString = (jclass) env->NewGlobalRef(env->FindClass("java/lang/String")); - classByteArray = (jclass) env->NewGlobalRef(env->FindClass("[B")); - classCharArray = (jclass) env->NewGlobalRef(env->FindClass("[C")); - /*classIntArray = (jclass) env->NewGlobalRef(env->FindClass("[I"));*/ - - // Wrapper class methods - - methodBooleanValue = env->GetMethodID(classBoolean, - "booleanValue", "()Z"); - /*methodByteValue = env->GetMethodID(classByte, - "byteValue", "()B"); - methodCharValue = env->GetMethodID(classCharacter, - "charValue", "()C"); - methodShortValue = env->GetMethodID(classShort, - "shortValue", "()S");*/ - methodIntValue = env->GetMethodID(classInteger, - "intValue", "()I"); - /*methodLongValue = env->GetMethodID(classLong, - "longValue", "()J"); - methodFloatValue = env->GetMethodID(classFloat, - "floatValue", "()F"); - methodDoubleValue = env->GetMethodID(classDouble, - "doubleValue", "()D");*/ - - // Constructors - - newIntegerInt = env->GetMethodID(classInteger, "", "(I)V"); - newBooleanBoolean = env->GetMethodID(classBoolean, "", "(Z)V"); - -} - -/* - * Class: com_eaio_nativecall_NativeCall - * Method: initHandles - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_com_eaio_nativecall_NativeCall_initHandles -(JNIEnv *env, jobject obj) { - - bool out = JNI_TRUE; - - jstring moduleNameS = (jstring) env->GetObjectField(obj, fieldModule); - jstring functionNameS = (jstring) env->GetObjectField(obj, fieldFunction); - - const char* moduleName = env->GetStringUTFChars(moduleNameS, 0); - const char* functionName = env->GetStringUTFChars(functionNameS, 0); - -#ifdef _WINDOWS - - HMODULE mod = LoadLibrary((LPCWSTR) moduleName); - - if (mod == NULL) { - /* no such module or DllMain returned FALSE */ - env->SetIntField(obj, fieldLastErrorCode, GetLastError()); - out = JNI_FALSE; - } - else { - FARPROC addr = GetProcAddress(mod, functionName); - if (addr == NULL) { - /* function not found */ - FreeLibrary(mod); - env->SetIntField(obj, fieldLastErrorCode, GetLastError()); - out = JNI_FALSE; - } - else { - /* all ok */ - env->SetIntField(obj, fieldModuleHandle, (jint) mod); - env->SetIntField(obj, fieldFunctionHandle, (jint) addr); - } - } - -#endif - - env->ReleaseStringUTFChars(moduleNameS, moduleName); - env->ReleaseStringUTFChars(functionNameS, functionName); - - return out; - -} - -/* - * Class: com_eaio_nativecall_NativeCall - * Method: getLastError - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_eaio_nativecall_NativeCall_getLastError -(JNIEnv *env, jobject obj) { - - jint lastError = env->GetIntField(obj, fieldLastErrorCode); - - if (lastError == 0) return NULL; - - jstring out = NULL; - -#ifdef _WINDOWS - - LPVOID msgBufPtr = NULL; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM, NULL, lastError, 0, - (LPWSTR) &msgBufPtr, 0, NULL); - - out = env->NewStringUTF((char*) msgBufPtr); - - LocalFree(msgBufPtr); - -#endif - - return out; - -} - -/* - * Class: com_eaio_nativecall_NativeCall - * Method: destroy - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_eaio_nativecall_NativeCall_destroy -(JNIEnv *env, jobject obj) { - - jint module = env->GetIntField(obj, fieldModuleHandle); - - if (module == 0) return; - -#ifdef _WINDOWS - - if (FreeLibrary((HMODULE) module) == 0) { - env->SetIntField(obj, fieldLastErrorCode, GetLastError()); - } - -#endif - - env->SetIntField(obj, fieldModuleHandle, 0); - env->SetIntField(obj, fieldFunctionHandle, 0); - - return; - -} \ No newline at end of file diff --git a/cpp/nativecall/VoidCall.cpp b/cpp/nativecall/VoidCall.cpp deleted file mode 100644 index 8c9a1b9..0000000 --- a/cpp/nativecall/VoidCall.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * VoidCall.cpp - * - * Created on 16.09.2004. - * - * $Id: VoidCall.cpp,v 1.4 2006/04/20 05:50:15 grnull Exp $ - * - * eaio: NativeCall - calling operating system methods from Java - * Copyright (c) 2004-2006 Johann Burkard () - * - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include -#include "com_eaio_nativecall_VoidCall.h" - -#ifdef _WINDOWS -#include -#include -#endif - -#ifdef _WINDOWS -#ifdef _X86_ - -#define _push(x) __asm { push x }; - -#endif -#endif - -// NativeCall fields - -extern jfieldID fieldFunction, fieldModule, fieldFunctionHandle, - fieldModuleHandle, fieldLastErrorCode; - -// Holder fields - -extern jfieldID fieldHolderO; - -// Classes - -extern jclass classBoolean,/* classByte, classCharacter, classShort,*/ - classInteger, /* classLong, classFloat, classDouble,*/ classString, - classByteArray, classCharArray, /*classIntArray,*/ classHolder; - -// Wrapper class methods - -extern jmethodID methodBooleanValue,/* methodByteValue, methodCharValue, -methodShortValue,*/ methodIntValue/*, methodLongValue, methodFloatValue, -methodDoubleValue*/; - -// Constructors - -extern jmethodID newIntegerInt, newBooleanBoolean; - -/* - * Class: com_eaio_nativecall_VoidCall - * Method: executeCall - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_eaio_nativecall_VoidCall_executeCall -(JNIEnv *env, jobject obj) { - - jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); - -#ifdef _WINDOWS -#ifdef _X86_ - - __asm { - - call functionHandle - - } - -#endif -#endif - - env->SetIntField(obj, fieldLastErrorCode, GetLastError()); - -} - -/* - * Class: com_eaio_nativecall_VoidCall - * Method: executeCall0 - * Signature: ([Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_com_eaio_nativecall_VoidCall_executeCall0 -(JNIEnv *env, jobject obj, jobjectArray params) { - - const int len = env->GetArrayLength(params); - - int* arrays = NULL; - if (!(arrays = new int[len])) { - env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), NULL); - return; - } - memset(arrays, 0, (sizeof(int) * len)); - - jobject param; - - for (int i = len - 1; i >= 0; i--) { - - param = env->GetObjectArrayElement(params, i); - - if (param == NULL) { - _push(0); - } - else if (env->IsInstanceOf(param, classInteger)) { - int intArg = env->CallIntMethod(param, methodIntValue); - _push(intArg) - } - else if (env->IsInstanceOf(param, classByteArray)) { - char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) param, 0); - arrays[i] = (int) &byteArrayArg; - _push(byteArrayArg) - } - else if (env->IsInstanceOf(param, classCharArray)) { - unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( - (jarray) param, 0); - arrays[i] = (int) &charArrayArg; - _push(charArrayArg) - } - else if (env->IsInstanceOf(param, classBoolean)) { - jboolean booleanArg = env->CallBooleanMethod(param, methodBooleanValue); - int tempArg = (booleanArg == JNI_FALSE ? 0 : 1); - _push(tempArg) - } - else if (env->IsInstanceOf(param, classHolder)) { - - /* Holder */ - - jobject o = env->GetObjectField(param, fieldHolderO); - - if (env->IsInstanceOf(o, classInteger)) { - int *intPtr = new int; - *intPtr = env->CallIntMethod(o, methodIntValue); - arrays[i] = (int) intPtr; - _push(intPtr); - } - else if (env->IsInstanceOf(o, classByteArray)) { - char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) o, 0); - arrays[i] = (int) &byteArrayArg; - _push(byteArrayArg) - } - else if (env->IsInstanceOf(o, classCharArray)) { - unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( - (jarray) o, 0); - arrays[i] = (int) &charArrayArg; - _push(charArrayArg) - } - else if (env->IsInstanceOf(o, classBoolean)) { - jboolean booleanArg = env->CallBooleanMethod(o, methodBooleanValue); - int *tempPtr = new int; - *tempPtr = (booleanArg == JNI_FALSE ? 0 : 1); - arrays[i] = (int) tempPtr; - _push(tempPtr); - } - - /* end Holder */ - - } - - } - - jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); - -#ifdef _WINDOWS -#ifdef _X86_ - - __asm { - - call functionHandle - - } - -#endif -#endif - - for (int j = 0; j < len; ++j) { - param = env->GetObjectArrayElement(params, j); - if (param == NULL) {} - else if (env->IsInstanceOf(param, classByteArray) || env->IsInstanceOf(param, classCharArray)) { - env->ReleasePrimitiveArrayCritical((jarray) param, (void*) arrays[j], 0); - } - else if (env->IsInstanceOf(param, classHolder)) { - - jobject o = env->GetObjectField(param, fieldHolderO); - - if (env->IsInstanceOf(o, classInteger)) { - int* out = (int*) arrays[j]; - env->SetObjectField(param, fieldHolderO, env->NewObject(classInteger, newIntegerInt, *out)); - delete out; - } - else if (env->IsInstanceOf(o, classByteArray) || env->IsInstanceOf(o, classCharArray)) { - env->ReleasePrimitiveArrayCritical((jarray) o, (void*) arrays[j], 0); - } - else if (env->IsInstanceOf(o, classBoolean)) { - int* out = (int*) arrays[j]; - env->SetObjectField(param, fieldHolderO, env->NewObject(classBoolean, newBooleanBoolean, (*out == 0 ? JNI_FALSE : JNI_TRUE))); - delete out; - } - - } - - } - - delete [] arrays; - - env->SetIntField(obj, fieldLastErrorCode, GetLastError()); - -} \ No newline at end of file diff --git a/cpp/nativecall/com_eaio_nativecall_IntCall.h b/cpp/nativecall/com_eaio_nativecall_IntCall.h deleted file mode 100644 index 3940b16..0000000 --- a/cpp/nativecall/com_eaio_nativecall_IntCall.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class com_eaio_nativecall_IntCall */ - -#ifndef _Included_com_eaio_nativecall_IntCall -#define _Included_com_eaio_nativecall_IntCall -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_eaio_nativecall_IntCall - * Method: executeCall - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_com_eaio_nativecall_IntCall_executeCall - (JNIEnv *, jobject); - -/* - * Class: com_eaio_nativecall_IntCall - * Method: executeCall0 - * Signature: ([Ljava/lang/Object;)I - */ -JNIEXPORT jint JNICALL Java_com_eaio_nativecall_IntCall_executeCall0 - (JNIEnv *, jobject, jobjectArray); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/nativecall/com_eaio_nativecall_NativeCall.h b/cpp/nativecall/com_eaio_nativecall_NativeCall.h deleted file mode 100644 index 2e92b91..0000000 --- a/cpp/nativecall/com_eaio_nativecall_NativeCall.h +++ /dev/null @@ -1,45 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class com_eaio_nativecall_NativeCall */ - -#ifndef _Included_com_eaio_nativecall_NativeCall -#define _Included_com_eaio_nativecall_NativeCall -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_eaio_nativecall_NativeCall - * Method: initIDs - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_eaio_nativecall_NativeCall_initIDs - (JNIEnv *, jclass); - -/* - * Class: com_eaio_nativecall_NativeCall - * Method: initHandles - * Signature: ()Z - */ -JNIEXPORT jboolean JNICALL Java_com_eaio_nativecall_NativeCall_initHandles - (JNIEnv *, jobject); - -/* - * Class: com_eaio_nativecall_NativeCall - * Method: getLastError - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_eaio_nativecall_NativeCall_getLastError - (JNIEnv *, jobject); - -/* - * Class: com_eaio_nativecall_NativeCall - * Method: destroy - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_eaio_nativecall_NativeCall_destroy - (JNIEnv *, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/nativecall/com_eaio_nativecall_VoidCall.h b/cpp/nativecall/com_eaio_nativecall_VoidCall.h deleted file mode 100644 index e72afb9..0000000 --- a/cpp/nativecall/com_eaio_nativecall_VoidCall.h +++ /dev/null @@ -1,29 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class com_eaio_nativecall_VoidCall */ - -#ifndef _Included_com_eaio_nativecall_VoidCall -#define _Included_com_eaio_nativecall_VoidCall -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: com_eaio_nativecall_VoidCall - * Method: executeCall - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_com_eaio_nativecall_VoidCall_executeCall - (JNIEnv *, jobject); - -/* - * Class: com_eaio_nativecall_VoidCall - * Method: executeCall0 - * Signature: ([Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_com_eaio_nativecall_VoidCall_executeCall0 - (JNIEnv *, jobject, jobjectArray); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/cpp/nativecall/include/classfile_constants.h b/cpp/nativecall/include/classfile_constants.h deleted file mode 100644 index 30e839e..0000000 --- a/cpp/nativecall/include/classfile_constants.h +++ /dev/null @@ -1,523 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - * - */ - -#ifndef CLASSFILE_CONSTANTS_H -#define CLASSFILE_CONSTANTS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Flags */ - -enum { - JVM_ACC_PUBLIC = 0x0001, - JVM_ACC_PRIVATE = 0x0002, - JVM_ACC_PROTECTED = 0x0004, - JVM_ACC_STATIC = 0x0008, - JVM_ACC_FINAL = 0x0010, - JVM_ACC_SYNCHRONIZED = 0x0020, - JVM_ACC_SUPER = 0x0020, - JVM_ACC_VOLATILE = 0x0040, - JVM_ACC_BRIDGE = 0x0040, - JVM_ACC_TRANSIENT = 0x0080, - JVM_ACC_VARARGS = 0x0080, - JVM_ACC_NATIVE = 0x0100, - JVM_ACC_INTERFACE = 0x0200, - JVM_ACC_ABSTRACT = 0x0400, - JVM_ACC_STRICT = 0x0800, - JVM_ACC_SYNTHETIC = 0x1000, - JVM_ACC_ANNOTATION = 0x2000, - JVM_ACC_ENUM = 0x4000 -}; - -/* Used in newarray instruction. */ - -enum { - JVM_T_BOOLEAN = 4, - JVM_T_CHAR = 5, - JVM_T_FLOAT = 6, - JVM_T_DOUBLE = 7, - JVM_T_BYTE = 8, - JVM_T_SHORT = 9, - JVM_T_INT = 10, - JVM_T_LONG = 11 -}; - -/* Constant Pool Entries */ - -enum { - JVM_CONSTANT_Utf8 = 1, - JVM_CONSTANT_Unicode = 2, /* unused */ - JVM_CONSTANT_Integer = 3, - JVM_CONSTANT_Float = 4, - JVM_CONSTANT_Long = 5, - JVM_CONSTANT_Double = 6, - JVM_CONSTANT_Class = 7, - JVM_CONSTANT_String = 8, - JVM_CONSTANT_Fieldref = 9, - JVM_CONSTANT_Methodref = 10, - JVM_CONSTANT_InterfaceMethodref = 11, - JVM_CONSTANT_NameAndType = 12 -}; - -/* StackMapTable type item numbers */ - -enum { - JVM_ITEM_Top = 0, - JVM_ITEM_Integer = 1, - JVM_ITEM_Float = 2, - JVM_ITEM_Double = 3, - JVM_ITEM_Long = 4, - JVM_ITEM_Null = 5, - JVM_ITEM_UninitializedThis = 6, - JVM_ITEM_Object = 7, - JVM_ITEM_Uninitialized = 8 -}; - -/* Type signatures */ - -enum { - JVM_SIGNATURE_ARRAY = '[', - JVM_SIGNATURE_BYTE = 'B', - JVM_SIGNATURE_CHAR = 'C', - JVM_SIGNATURE_CLASS = 'L', - JVM_SIGNATURE_ENDCLASS = ';', - JVM_SIGNATURE_ENUM = 'E', - JVM_SIGNATURE_FLOAT = 'F', - JVM_SIGNATURE_DOUBLE = 'D', - JVM_SIGNATURE_FUNC = '(', - JVM_SIGNATURE_ENDFUNC = ')', - JVM_SIGNATURE_INT = 'I', - JVM_SIGNATURE_LONG = 'J', - JVM_SIGNATURE_SHORT = 'S', - JVM_SIGNATURE_VOID = 'V', - JVM_SIGNATURE_BOOLEAN = 'Z' -}; - -/* Opcodes */ - -enum { - JVM_OPC_nop = 0, - JVM_OPC_aconst_null = 1, - JVM_OPC_iconst_m1 = 2, - JVM_OPC_iconst_0 = 3, - JVM_OPC_iconst_1 = 4, - JVM_OPC_iconst_2 = 5, - JVM_OPC_iconst_3 = 6, - JVM_OPC_iconst_4 = 7, - JVM_OPC_iconst_5 = 8, - JVM_OPC_lconst_0 = 9, - JVM_OPC_lconst_1 = 10, - JVM_OPC_fconst_0 = 11, - JVM_OPC_fconst_1 = 12, - JVM_OPC_fconst_2 = 13, - JVM_OPC_dconst_0 = 14, - JVM_OPC_dconst_1 = 15, - JVM_OPC_bipush = 16, - JVM_OPC_sipush = 17, - JVM_OPC_ldc = 18, - JVM_OPC_ldc_w = 19, - JVM_OPC_ldc2_w = 20, - JVM_OPC_iload = 21, - JVM_OPC_lload = 22, - JVM_OPC_fload = 23, - JVM_OPC_dload = 24, - JVM_OPC_aload = 25, - JVM_OPC_iload_0 = 26, - JVM_OPC_iload_1 = 27, - JVM_OPC_iload_2 = 28, - JVM_OPC_iload_3 = 29, - JVM_OPC_lload_0 = 30, - JVM_OPC_lload_1 = 31, - JVM_OPC_lload_2 = 32, - JVM_OPC_lload_3 = 33, - JVM_OPC_fload_0 = 34, - JVM_OPC_fload_1 = 35, - JVM_OPC_fload_2 = 36, - JVM_OPC_fload_3 = 37, - JVM_OPC_dload_0 = 38, - JVM_OPC_dload_1 = 39, - JVM_OPC_dload_2 = 40, - JVM_OPC_dload_3 = 41, - JVM_OPC_aload_0 = 42, - JVM_OPC_aload_1 = 43, - JVM_OPC_aload_2 = 44, - JVM_OPC_aload_3 = 45, - JVM_OPC_iaload = 46, - JVM_OPC_laload = 47, - JVM_OPC_faload = 48, - JVM_OPC_daload = 49, - JVM_OPC_aaload = 50, - JVM_OPC_baload = 51, - JVM_OPC_caload = 52, - JVM_OPC_saload = 53, - JVM_OPC_istore = 54, - JVM_OPC_lstore = 55, - JVM_OPC_fstore = 56, - JVM_OPC_dstore = 57, - JVM_OPC_astore = 58, - JVM_OPC_istore_0 = 59, - JVM_OPC_istore_1 = 60, - JVM_OPC_istore_2 = 61, - JVM_OPC_istore_3 = 62, - JVM_OPC_lstore_0 = 63, - JVM_OPC_lstore_1 = 64, - JVM_OPC_lstore_2 = 65, - JVM_OPC_lstore_3 = 66, - JVM_OPC_fstore_0 = 67, - JVM_OPC_fstore_1 = 68, - JVM_OPC_fstore_2 = 69, - JVM_OPC_fstore_3 = 70, - JVM_OPC_dstore_0 = 71, - JVM_OPC_dstore_1 = 72, - JVM_OPC_dstore_2 = 73, - JVM_OPC_dstore_3 = 74, - JVM_OPC_astore_0 = 75, - JVM_OPC_astore_1 = 76, - JVM_OPC_astore_2 = 77, - JVM_OPC_astore_3 = 78, - JVM_OPC_iastore = 79, - JVM_OPC_lastore = 80, - JVM_OPC_fastore = 81, - JVM_OPC_dastore = 82, - JVM_OPC_aastore = 83, - JVM_OPC_bastore = 84, - JVM_OPC_castore = 85, - JVM_OPC_sastore = 86, - JVM_OPC_pop = 87, - JVM_OPC_pop2 = 88, - JVM_OPC_dup = 89, - JVM_OPC_dup_x1 = 90, - JVM_OPC_dup_x2 = 91, - JVM_OPC_dup2 = 92, - JVM_OPC_dup2_x1 = 93, - JVM_OPC_dup2_x2 = 94, - JVM_OPC_swap = 95, - JVM_OPC_iadd = 96, - JVM_OPC_ladd = 97, - JVM_OPC_fadd = 98, - JVM_OPC_dadd = 99, - JVM_OPC_isub = 100, - JVM_OPC_lsub = 101, - JVM_OPC_fsub = 102, - JVM_OPC_dsub = 103, - JVM_OPC_imul = 104, - JVM_OPC_lmul = 105, - JVM_OPC_fmul = 106, - JVM_OPC_dmul = 107, - JVM_OPC_idiv = 108, - JVM_OPC_ldiv = 109, - JVM_OPC_fdiv = 110, - JVM_OPC_ddiv = 111, - JVM_OPC_irem = 112, - JVM_OPC_lrem = 113, - JVM_OPC_frem = 114, - JVM_OPC_drem = 115, - JVM_OPC_ineg = 116, - JVM_OPC_lneg = 117, - JVM_OPC_fneg = 118, - JVM_OPC_dneg = 119, - JVM_OPC_ishl = 120, - JVM_OPC_lshl = 121, - JVM_OPC_ishr = 122, - JVM_OPC_lshr = 123, - JVM_OPC_iushr = 124, - JVM_OPC_lushr = 125, - JVM_OPC_iand = 126, - JVM_OPC_land = 127, - JVM_OPC_ior = 128, - JVM_OPC_lor = 129, - JVM_OPC_ixor = 130, - JVM_OPC_lxor = 131, - JVM_OPC_iinc = 132, - JVM_OPC_i2l = 133, - JVM_OPC_i2f = 134, - JVM_OPC_i2d = 135, - JVM_OPC_l2i = 136, - JVM_OPC_l2f = 137, - JVM_OPC_l2d = 138, - JVM_OPC_f2i = 139, - JVM_OPC_f2l = 140, - JVM_OPC_f2d = 141, - JVM_OPC_d2i = 142, - JVM_OPC_d2l = 143, - JVM_OPC_d2f = 144, - JVM_OPC_i2b = 145, - JVM_OPC_i2c = 146, - JVM_OPC_i2s = 147, - JVM_OPC_lcmp = 148, - JVM_OPC_fcmpl = 149, - JVM_OPC_fcmpg = 150, - JVM_OPC_dcmpl = 151, - JVM_OPC_dcmpg = 152, - JVM_OPC_ifeq = 153, - JVM_OPC_ifne = 154, - JVM_OPC_iflt = 155, - JVM_OPC_ifge = 156, - JVM_OPC_ifgt = 157, - JVM_OPC_ifle = 158, - JVM_OPC_if_icmpeq = 159, - JVM_OPC_if_icmpne = 160, - JVM_OPC_if_icmplt = 161, - JVM_OPC_if_icmpge = 162, - JVM_OPC_if_icmpgt = 163, - JVM_OPC_if_icmple = 164, - JVM_OPC_if_acmpeq = 165, - JVM_OPC_if_acmpne = 166, - JVM_OPC_goto = 167, - JVM_OPC_jsr = 168, - JVM_OPC_ret = 169, - JVM_OPC_tableswitch = 170, - JVM_OPC_lookupswitch = 171, - JVM_OPC_ireturn = 172, - JVM_OPC_lreturn = 173, - JVM_OPC_freturn = 174, - JVM_OPC_dreturn = 175, - JVM_OPC_areturn = 176, - JVM_OPC_return = 177, - JVM_OPC_getstatic = 178, - JVM_OPC_putstatic = 179, - JVM_OPC_getfield = 180, - JVM_OPC_putfield = 181, - JVM_OPC_invokevirtual = 182, - JVM_OPC_invokespecial = 183, - JVM_OPC_invokestatic = 184, - JVM_OPC_invokeinterface = 185, - JVM_OPC_xxxunusedxxx = 186, - JVM_OPC_new = 187, - JVM_OPC_newarray = 188, - JVM_OPC_anewarray = 189, - JVM_OPC_arraylength = 190, - JVM_OPC_athrow = 191, - JVM_OPC_checkcast = 192, - JVM_OPC_instanceof = 193, - JVM_OPC_monitorenter = 194, - JVM_OPC_monitorexit = 195, - JVM_OPC_wide = 196, - JVM_OPC_multianewarray = 197, - JVM_OPC_ifnull = 198, - JVM_OPC_ifnonnull = 199, - JVM_OPC_goto_w = 200, - JVM_OPC_jsr_w = 201, - JVM_OPC_MAX = 201 -}; - -/* Opcode length initializer, use with something like: - * unsigned char opcode_length[JVM_OPC_MAX+1] = JVM_OPCODE_LENGTH_INITIALIZER; - */ -#define JVM_OPCODE_LENGTH_INITIALIZER { \ - 1, /* nop */ \ - 1, /* aconst_null */ \ - 1, /* iconst_m1 */ \ - 1, /* iconst_0 */ \ - 1, /* iconst_1 */ \ - 1, /* iconst_2 */ \ - 1, /* iconst_3 */ \ - 1, /* iconst_4 */ \ - 1, /* iconst_5 */ \ - 1, /* lconst_0 */ \ - 1, /* lconst_1 */ \ - 1, /* fconst_0 */ \ - 1, /* fconst_1 */ \ - 1, /* fconst_2 */ \ - 1, /* dconst_0 */ \ - 1, /* dconst_1 */ \ - 2, /* bipush */ \ - 3, /* sipush */ \ - 2, /* ldc */ \ - 3, /* ldc_w */ \ - 3, /* ldc2_w */ \ - 2, /* iload */ \ - 2, /* lload */ \ - 2, /* fload */ \ - 2, /* dload */ \ - 2, /* aload */ \ - 1, /* iload_0 */ \ - 1, /* iload_1 */ \ - 1, /* iload_2 */ \ - 1, /* iload_3 */ \ - 1, /* lload_0 */ \ - 1, /* lload_1 */ \ - 1, /* lload_2 */ \ - 1, /* lload_3 */ \ - 1, /* fload_0 */ \ - 1, /* fload_1 */ \ - 1, /* fload_2 */ \ - 1, /* fload_3 */ \ - 1, /* dload_0 */ \ - 1, /* dload_1 */ \ - 1, /* dload_2 */ \ - 1, /* dload_3 */ \ - 1, /* aload_0 */ \ - 1, /* aload_1 */ \ - 1, /* aload_2 */ \ - 1, /* aload_3 */ \ - 1, /* iaload */ \ - 1, /* laload */ \ - 1, /* faload */ \ - 1, /* daload */ \ - 1, /* aaload */ \ - 1, /* baload */ \ - 1, /* caload */ \ - 1, /* saload */ \ - 2, /* istore */ \ - 2, /* lstore */ \ - 2, /* fstore */ \ - 2, /* dstore */ \ - 2, /* astore */ \ - 1, /* istore_0 */ \ - 1, /* istore_1 */ \ - 1, /* istore_2 */ \ - 1, /* istore_3 */ \ - 1, /* lstore_0 */ \ - 1, /* lstore_1 */ \ - 1, /* lstore_2 */ \ - 1, /* lstore_3 */ \ - 1, /* fstore_0 */ \ - 1, /* fstore_1 */ \ - 1, /* fstore_2 */ \ - 1, /* fstore_3 */ \ - 1, /* dstore_0 */ \ - 1, /* dstore_1 */ \ - 1, /* dstore_2 */ \ - 1, /* dstore_3 */ \ - 1, /* astore_0 */ \ - 1, /* astore_1 */ \ - 1, /* astore_2 */ \ - 1, /* astore_3 */ \ - 1, /* iastore */ \ - 1, /* lastore */ \ - 1, /* fastore */ \ - 1, /* dastore */ \ - 1, /* aastore */ \ - 1, /* bastore */ \ - 1, /* castore */ \ - 1, /* sastore */ \ - 1, /* pop */ \ - 1, /* pop2 */ \ - 1, /* dup */ \ - 1, /* dup_x1 */ \ - 1, /* dup_x2 */ \ - 1, /* dup2 */ \ - 1, /* dup2_x1 */ \ - 1, /* dup2_x2 */ \ - 1, /* swap */ \ - 1, /* iadd */ \ - 1, /* ladd */ \ - 1, /* fadd */ \ - 1, /* dadd */ \ - 1, /* isub */ \ - 1, /* lsub */ \ - 1, /* fsub */ \ - 1, /* dsub */ \ - 1, /* imul */ \ - 1, /* lmul */ \ - 1, /* fmul */ \ - 1, /* dmul */ \ - 1, /* idiv */ \ - 1, /* ldiv */ \ - 1, /* fdiv */ \ - 1, /* ddiv */ \ - 1, /* irem */ \ - 1, /* lrem */ \ - 1, /* frem */ \ - 1, /* drem */ \ - 1, /* ineg */ \ - 1, /* lneg */ \ - 1, /* fneg */ \ - 1, /* dneg */ \ - 1, /* ishl */ \ - 1, /* lshl */ \ - 1, /* ishr */ \ - 1, /* lshr */ \ - 1, /* iushr */ \ - 1, /* lushr */ \ - 1, /* iand */ \ - 1, /* land */ \ - 1, /* ior */ \ - 1, /* lor */ \ - 1, /* ixor */ \ - 1, /* lxor */ \ - 3, /* iinc */ \ - 1, /* i2l */ \ - 1, /* i2f */ \ - 1, /* i2d */ \ - 1, /* l2i */ \ - 1, /* l2f */ \ - 1, /* l2d */ \ - 1, /* f2i */ \ - 1, /* f2l */ \ - 1, /* f2d */ \ - 1, /* d2i */ \ - 1, /* d2l */ \ - 1, /* d2f */ \ - 1, /* i2b */ \ - 1, /* i2c */ \ - 1, /* i2s */ \ - 1, /* lcmp */ \ - 1, /* fcmpl */ \ - 1, /* fcmpg */ \ - 1, /* dcmpl */ \ - 1, /* dcmpg */ \ - 3, /* ifeq */ \ - 3, /* ifne */ \ - 3, /* iflt */ \ - 3, /* ifge */ \ - 3, /* ifgt */ \ - 3, /* ifle */ \ - 3, /* if_icmpeq */ \ - 3, /* if_icmpne */ \ - 3, /* if_icmplt */ \ - 3, /* if_icmpge */ \ - 3, /* if_icmpgt */ \ - 3, /* if_icmple */ \ - 3, /* if_acmpeq */ \ - 3, /* if_acmpne */ \ - 3, /* goto */ \ - 3, /* jsr */ \ - 2, /* ret */ \ - 99, /* tableswitch */ \ - 99, /* lookupswitch */ \ - 1, /* ireturn */ \ - 1, /* lreturn */ \ - 1, /* freturn */ \ - 1, /* dreturn */ \ - 1, /* areturn */ \ - 1, /* return */ \ - 3, /* getstatic */ \ - 3, /* putstatic */ \ - 3, /* getfield */ \ - 3, /* putfield */ \ - 3, /* invokevirtual */ \ - 3, /* invokespecial */ \ - 3, /* invokestatic */ \ - 5, /* invokeinterface */ \ - 0, /* xxxunusedxxx */ \ - 3, /* new */ \ - 2, /* newarray */ \ - 3, /* anewarray */ \ - 1, /* arraylength */ \ - 1, /* athrow */ \ - 3, /* checkcast */ \ - 3, /* instanceof */ \ - 1, /* monitorenter */ \ - 1, /* monitorexit */ \ - 0, /* wide */ \ - 4, /* multianewarray */ \ - 3, /* ifnull */ \ - 3, /* ifnonnull */ \ - 5, /* goto_w */ \ - 5 /* jsr_w */ \ -} - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* CLASSFILE_CONSTANTS */ diff --git a/cpp/nativecall/include/jawt.h b/cpp/nativecall/include/jawt.h deleted file mode 100644 index 87e0b18..0000000 --- a/cpp/nativecall/include/jawt.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -#ifndef _JAVASOFT_JAWT_H_ -#define _JAVASOFT_JAWT_H_ - -#include "jni.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * AWT native interface (new in JDK 1.3) - * - * The AWT native interface allows a native C or C++ application a means - * by which to access native structures in AWT. This is to facilitate moving - * legacy C and C++ applications to Java and to target the needs of the - * community who, at present, wish to do their own native rendering to canvases - * for performance reasons. Standard extensions such as Java3D also require a - * means to access the underlying native data structures of AWT. - * - * There may be future extensions to this API depending on demand. - * - * A VM does not have to implement this API in order to pass the JCK. - * It is recommended, however, that this API is implemented on VMs that support - * standard extensions, such as Java3D. - * - * Since this is a native API, any program which uses it cannot be considered - * 100% pure java. - */ - -/* - * AWT Native Drawing Surface (JAWT_DrawingSurface). - * - * For each platform, there is a native drawing surface structure. This - * platform-specific structure can be found in jawt_md.h. It is recommended - * that additional platforms follow the same model. It is also recommended - * that VMs on Win32 and Solaris support the existing structures in jawt_md.h. - * - ******************* - * EXAMPLE OF USAGE: - ******************* - * - * In Win32, a programmer wishes to access the HWND of a canvas to perform - * native rendering into it. The programmer has declared the paint() method - * for their canvas subclass to be native: - * - * - * MyCanvas.java: - * - * import java.awt.*; - * - * public class MyCanvas extends Canvas { - * - * static { - * System.loadLibrary("mylib"); - * } - * - * public native void paint(Graphics g); - * } - * - * - * myfile.c: - * - * #include "jawt_md.h" - * #include - * - * JNIEXPORT void JNICALL - * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics) - * { - * JAWT awt; - * JAWT_DrawingSurface* ds; - * JAWT_DrawingSurfaceInfo* dsi; - * JAWT_Win32DrawingSurfaceInfo* dsi_win; - * jboolean result; - * jint lock; - * - * // Get the AWT - * awt.version = JAWT_VERSION_1_3; - * result = JAWT_GetAWT(env, &awt); - * assert(result != JNI_FALSE); - * - * // Get the drawing surface - * ds = awt.GetDrawingSurface(env, canvas); - * assert(ds != NULL); - * - * // Lock the drawing surface - * lock = ds->Lock(ds); - * assert((lock & JAWT_LOCK_ERROR) == 0); - * - * // Get the drawing surface info - * dsi = ds->GetDrawingSurfaceInfo(ds); - * - * // Get the platform-specific drawing info - * dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; - * - * ////////////////////////////// - * // !!! DO PAINTING HERE !!! // - * ////////////////////////////// - * - * // Free the drawing surface info - * ds->FreeDrawingSurfaceInfo(dsi); - * - * // Unlock the drawing surface - * ds->Unlock(ds); - * - * // Free the drawing surface - * awt.FreeDrawingSurface(ds); - * } - * - */ - -/* - * JAWT_Rectangle - * Structure for a native rectangle. - */ -typedef struct jawt_Rectangle { - jint x; - jint y; - jint width; - jint height; -} JAWT_Rectangle; - -struct jawt_DrawingSurface; - -/* - * JAWT_DrawingSurfaceInfo - * Structure for containing the underlying drawing information of a component. - */ -typedef struct jawt_DrawingSurfaceInfo { - /* - * Pointer to the platform-specific information. This can be safely - * cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a - * JAWT_X11DrawingSurfaceInfo on Solaris. See jawt_md.h for details. - */ - void* platformInfo; - /* Cached pointer to the underlying drawing surface */ - struct jawt_DrawingSurface* ds; - /* Bounding rectangle of the drawing surface */ - JAWT_Rectangle bounds; - /* Number of rectangles in the clip */ - jint clipSize; - /* Clip rectangle array */ - JAWT_Rectangle* clip; -} JAWT_DrawingSurfaceInfo; - -#define JAWT_LOCK_ERROR 0x00000001 -#define JAWT_LOCK_CLIP_CHANGED 0x00000002 -#define JAWT_LOCK_BOUNDS_CHANGED 0x00000004 -#define JAWT_LOCK_SURFACE_CHANGED 0x00000008 - -/* - * JAWT_DrawingSurface - * Structure for containing the underlying drawing information of a component. - * All operations on a JAWT_DrawingSurface MUST be performed from the same - * thread as the call to GetDrawingSurface. - */ -typedef struct jawt_DrawingSurface { - /* - * Cached reference to the Java environment of the calling thread. - * If Lock(), Unlock(), GetDrawingSurfaceInfo() or - * FreeDrawingSurfaceInfo() are called from a different thread, - * this data member should be set before calling those functions. - */ - JNIEnv* env; - /* Cached reference to the target object */ - jobject target; - /* - * Lock the surface of the target component for native rendering. - * When finished drawing, the surface must be unlocked with - * Unlock(). This function returns a bitmask with one or more of the - * following values: - * - * JAWT_LOCK_ERROR - When an error has occurred and the surface could not - * be locked. - * - * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed. - * - * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed. - * - * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed - */ - jint (JNICALL *Lock) - (struct jawt_DrawingSurface* ds); - /* - * Get the drawing surface info. - * The value returned may be cached, but the values may change if - * additional calls to Lock() or Unlock() are made. - * Lock() must be called before this can return a valid value. - * Returns NULL if an error has occurred. - * When finished with the returned value, FreeDrawingSurfaceInfo must be - * called. - */ - JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo) - (struct jawt_DrawingSurface* ds); - /* - * Free the drawing surface info. - */ - void (JNICALL *FreeDrawingSurfaceInfo) - (JAWT_DrawingSurfaceInfo* dsi); - /* - * Unlock the drawing surface of the target component for native rendering. - */ - void (JNICALL *Unlock) - (struct jawt_DrawingSurface* ds); -} JAWT_DrawingSurface; - -/* - * JAWT - * Structure for containing native AWT functions. - */ -typedef struct jawt { - /* - * Version of this structure. This must always be set before - * calling JAWT_GetAWT() - */ - jint version; - /* - * Return a drawing surface from a target jobject. This value - * may be cached. - * Returns NULL if an error has occurred. - * Target must be a java.awt.Component (should be a Canvas - * or Window for native rendering). - * FreeDrawingSurface() must be called when finished with the - * returned JAWT_DrawingSurface. - */ - JAWT_DrawingSurface* (JNICALL *GetDrawingSurface) - (JNIEnv* env, jobject target); - /* - * Free the drawing surface allocated in GetDrawingSurface. - */ - void (JNICALL *FreeDrawingSurface) - (JAWT_DrawingSurface* ds); - /* - * Since 1.4 - * Locks the entire AWT for synchronization purposes - */ - void (JNICALL *Lock)(JNIEnv* env); - /* - * Since 1.4 - * Unlocks the entire AWT for synchronization purposes - */ - void (JNICALL *Unlock)(JNIEnv* env); - /* - * Since 1.4 - * Returns a reference to a java.awt.Component from a native - * platform handle. On Windows, this corresponds to an HWND; - * on Solaris and Linux, this is a Drawable. For other platforms, - * see the appropriate machine-dependent header file for a description. - * The reference returned by this function is a local - * reference that is only valid in this environment. - * This function returns a NULL reference if no component could be - * found with matching platform information. - */ - jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo); - -} JAWT; - -/* - * Get the AWT native structure. This function returns JNI_FALSE if - * an error occurs. - */ -_JNI_IMPORT_OR_EXPORT_ -jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt); - -#define JAWT_VERSION_1_3 0x00010003 -#define JAWT_VERSION_1_4 0x00010004 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* !_JAVASOFT_JAWT_H_ */ diff --git a/cpp/nativecall/include/jdwpTransport.h b/cpp/nativecall/include/jdwpTransport.h deleted file mode 100644 index eae435a..0000000 --- a/cpp/nativecall/include/jdwpTransport.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -/* - * Java Debug Wire Protocol Transport Service Provider Interface. - */ - -#ifndef JDWPTRANSPORT_H -#define JDWPTRANSPORT_H - -#include "jni.h" - -enum { - JDWPTRANSPORT_VERSION_1_0 = 0x00010000 -}; - -#ifdef __cplusplus -extern "C" { -#endif - -struct jdwpTransportNativeInterface_; - -struct _jdwpTransportEnv; - -#ifdef __cplusplus -typedef _jdwpTransportEnv jdwpTransportEnv; -#else -typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv; -#endif /* __cplusplus */ - -/* - * Errors. Universal errors with JVMTI/JVMDI equivalents keep the - * values the same. - */ -typedef enum { - JDWPTRANSPORT_ERROR_NONE = 0, - JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103, - JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110, - JDWPTRANSPORT_ERROR_INTERNAL = 113, - JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201, - JDWPTRANSPORT_ERROR_IO_ERROR = 202, - JDWPTRANSPORT_ERROR_TIMEOUT = 203, - JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204 -} jdwpTransportError; - - -/* - * Structure to define capabilities - */ -typedef struct { - unsigned int can_timeout_attach :1; - unsigned int can_timeout_accept :1; - unsigned int can_timeout_handshake :1; - unsigned int reserved3 :1; - unsigned int reserved4 :1; - unsigned int reserved5 :1; - unsigned int reserved6 :1; - unsigned int reserved7 :1; - unsigned int reserved8 :1; - unsigned int reserved9 :1; - unsigned int reserved10 :1; - unsigned int reserved11 :1; - unsigned int reserved12 :1; - unsigned int reserved13 :1; - unsigned int reserved14 :1; - unsigned int reserved15 :1; -} JDWPTransportCapabilities; - - -/* - * Structures to define packet layout. - * - * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html - */ - -enum { - JDWPTRANSPORT_FLAGS_NONE = 0x0, - JDWPTRANSPORT_FLAGS_REPLY = 0x80 -}; - -typedef struct { - jint len; - jint id; - jbyte flags; - jbyte cmdSet; - jbyte cmd; - jbyte *data; -} jdwpCmdPacket; - -typedef struct { - jint len; - jint id; - jbyte flags; - jshort errorCode; - jbyte *data; -} jdwpReplyPacket; - -typedef struct { - union { - jdwpCmdPacket cmd; - jdwpReplyPacket reply; - } type; -} jdwpPacket; - -/* - * JDWP functions called by the transport. - */ -typedef struct jdwpTransportCallback { - void *(*alloc)(jint numBytes); /* Call this for all allocations */ - void (*free)(void *buffer); /* Call this for all deallocations */ -} jdwpTransportCallback; - -typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm, - jdwpTransportCallback *callback, - jint version, - jdwpTransportEnv** env); - - - -/* Function Interface */ - -struct jdwpTransportNativeInterface_ { - /* 1 : RESERVED */ - void *reserved1; - - /* 2 : Get Capabilities */ - jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env, - JDWPTransportCapabilities *capabilities_ptr); - - /* 3 : Attach */ - jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env, - const char* address, - jlong attach_timeout, - jlong handshake_timeout); - - /* 4: StartListening */ - jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env, - const char* address, - char** actual_address); - - /* 5: StopListening */ - jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env); - - /* 6: Accept */ - jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env, - jlong accept_timeout, - jlong handshake_timeout); - - /* 7: IsOpen */ - jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env); - - /* 8: Close */ - jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env); - - /* 9: ReadPacket */ - jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env, - jdwpPacket *pkt); - - /* 10: Write Packet */ - jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env, - const jdwpPacket* pkt); - - /* 11: GetLastError */ - jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env, - char** error); - -}; - - -/* - * Use inlined functions so that C++ code can use syntax such as - * env->Attach("mymachine:5000", 10*1000, 0); - * - * rather than using C's :- - * - * (*env)->Attach(env, "mymachine:5000", 10*1000, 0); - */ -struct _jdwpTransportEnv { - const struct jdwpTransportNativeInterface_ *functions; -#ifdef __cplusplus - - jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) { - return functions->GetCapabilities(this, capabilities_ptr); - } - - jdwpTransportError Attach(const char* address, jlong attach_timeout, - jlong handshake_timeout) { - return functions->Attach(this, address, attach_timeout, handshake_timeout); - } - - jdwpTransportError StartListening(const char* address, - char** actual_address) { - return functions->StartListening(this, address, actual_address); - } - - jdwpTransportError StopListening(void) { - return functions->StopListening(this); - } - - jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) { - return functions->Accept(this, accept_timeout, handshake_timeout); - } - - jboolean IsOpen(void) { - return functions->IsOpen(this); - } - - jdwpTransportError Close(void) { - return functions->Close(this); - } - - jdwpTransportError ReadPacket(jdwpPacket *pkt) { - return functions->ReadPacket(this, pkt); - } - - jdwpTransportError WritePacket(const jdwpPacket* pkt) { - return functions->WritePacket(this, pkt); - } - - jdwpTransportError GetLastError(char** error) { - return functions->GetLastError(this, error); - } - - -#endif /* __cplusplus */ -}; - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* JDWPTRANSPORT_H */ - diff --git a/cpp/nativecall/include/jni.h b/cpp/nativecall/include/jni.h deleted file mode 100644 index 8ed7366..0000000 --- a/cpp/nativecall/include/jni.h +++ /dev/null @@ -1,1944 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -/* - * We used part of Netscape's Java Runtime Interface (JRI) as the starting - * point of our design and implementation. - */ - -/****************************************************************************** - * Java Runtime Interface - * Copyright (c) 1996 Netscape Communications Corporation. All rights reserved. - *****************************************************************************/ - -#ifndef _JAVASOFT_JNI_H_ -#define _JAVASOFT_JNI_H_ - -#include -#include - -/* jni_md.h contains the machine-dependent typedefs for jbyte, jint - and jlong */ - -#include "jni_md.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * JNI Types - */ - -#ifndef JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H - -typedef unsigned char jboolean; -typedef unsigned short jchar; -typedef short jshort; -typedef float jfloat; -typedef double jdouble; - -typedef jint jsize; - -#ifdef __cplusplus - -class _jobject {}; -class _jclass : public _jobject {}; -class _jthrowable : public _jobject {}; -class _jstring : public _jobject {}; -class _jarray : public _jobject {}; -class _jbooleanArray : public _jarray {}; -class _jbyteArray : public _jarray {}; -class _jcharArray : public _jarray {}; -class _jshortArray : public _jarray {}; -class _jintArray : public _jarray {}; -class _jlongArray : public _jarray {}; -class _jfloatArray : public _jarray {}; -class _jdoubleArray : public _jarray {}; -class _jobjectArray : public _jarray {}; - -typedef _jobject *jobject; -typedef _jclass *jclass; -typedef _jthrowable *jthrowable; -typedef _jstring *jstring; -typedef _jarray *jarray; -typedef _jbooleanArray *jbooleanArray; -typedef _jbyteArray *jbyteArray; -typedef _jcharArray *jcharArray; -typedef _jshortArray *jshortArray; -typedef _jintArray *jintArray; -typedef _jlongArray *jlongArray; -typedef _jfloatArray *jfloatArray; -typedef _jdoubleArray *jdoubleArray; -typedef _jobjectArray *jobjectArray; - -#else - -struct _jobject; - -typedef struct _jobject *jobject; -typedef jobject jclass; -typedef jobject jthrowable; -typedef jobject jstring; -typedef jobject jarray; -typedef jarray jbooleanArray; -typedef jarray jbyteArray; -typedef jarray jcharArray; -typedef jarray jshortArray; -typedef jarray jintArray; -typedef jarray jlongArray; -typedef jarray jfloatArray; -typedef jarray jdoubleArray; -typedef jarray jobjectArray; - -#endif - -typedef jobject jweak; - -typedef union jvalue { - jboolean z; - jbyte b; - jchar c; - jshort s; - jint i; - jlong j; - jfloat f; - jdouble d; - jobject l; -} jvalue; - -struct _jfieldID; -typedef struct _jfieldID *jfieldID; - -struct _jmethodID; -typedef struct _jmethodID *jmethodID; - -/* Return values from jobjectRefType */ -typedef enum _jobjectType { - JNIInvalidRefType = 0, - JNILocalRefType = 1, - JNIGlobalRefType = 2, - JNIWeakGlobalRefType = 3 -} jobjectRefType; - - -#endif /* JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H */ - -/* - * jboolean constants - */ - -#define JNI_FALSE 0 -#define JNI_TRUE 1 - -/* - * possible return values for JNI functions. - */ - -#define JNI_OK 0 /* success */ -#define JNI_ERR (-1) /* unknown error */ -#define JNI_EDETACHED (-2) /* thread detached from the VM */ -#define JNI_EVERSION (-3) /* JNI version error */ -#define JNI_ENOMEM (-4) /* not enough memory */ -#define JNI_EEXIST (-5) /* VM already created */ -#define JNI_EINVAL (-6) /* invalid arguments */ - -/* - * used in ReleaseScalarArrayElements - */ - -#define JNI_COMMIT 1 -#define JNI_ABORT 2 - -/* - * used in RegisterNatives to describe native method name, signature, - * and function pointer. - */ - -typedef struct { - char *name; - char *signature; - void *fnPtr; -} JNINativeMethod; - -/* - * JNI Native Method Interface. - */ - -struct JNINativeInterface_; - -struct JNIEnv_; - -#ifdef __cplusplus -typedef JNIEnv_ JNIEnv; -#else -typedef const struct JNINativeInterface_ *JNIEnv; -#endif - -/* - * JNI Invocation Interface. - */ - -struct JNIInvokeInterface_; - -struct JavaVM_; - -#ifdef __cplusplus -typedef JavaVM_ JavaVM; -#else -typedef const struct JNIInvokeInterface_ *JavaVM; -#endif - -struct JNINativeInterface_ { - void *reserved0; - void *reserved1; - void *reserved2; - - void *reserved3; - jint (JNICALL *GetVersion)(JNIEnv *env); - - jclass (JNICALL *DefineClass) - (JNIEnv *env, const char *name, jobject loader, const jbyte *buf, - jsize len); - jclass (JNICALL *FindClass) - (JNIEnv *env, const char *name); - - jmethodID (JNICALL *FromReflectedMethod) - (JNIEnv *env, jobject method); - jfieldID (JNICALL *FromReflectedField) - (JNIEnv *env, jobject field); - - jobject (JNICALL *ToReflectedMethod) - (JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic); - - jclass (JNICALL *GetSuperclass) - (JNIEnv *env, jclass sub); - jboolean (JNICALL *IsAssignableFrom) - (JNIEnv *env, jclass sub, jclass sup); - - jobject (JNICALL *ToReflectedField) - (JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic); - - jint (JNICALL *Throw) - (JNIEnv *env, jthrowable obj); - jint (JNICALL *ThrowNew) - (JNIEnv *env, jclass clazz, const char *msg); - jthrowable (JNICALL *ExceptionOccurred) - (JNIEnv *env); - void (JNICALL *ExceptionDescribe) - (JNIEnv *env); - void (JNICALL *ExceptionClear) - (JNIEnv *env); - void (JNICALL *FatalError) - (JNIEnv *env, const char *msg); - - jint (JNICALL *PushLocalFrame) - (JNIEnv *env, jint capacity); - jobject (JNICALL *PopLocalFrame) - (JNIEnv *env, jobject result); - - jobject (JNICALL *NewGlobalRef) - (JNIEnv *env, jobject lobj); - void (JNICALL *DeleteGlobalRef) - (JNIEnv *env, jobject gref); - void (JNICALL *DeleteLocalRef) - (JNIEnv *env, jobject obj); - jboolean (JNICALL *IsSameObject) - (JNIEnv *env, jobject obj1, jobject obj2); - jobject (JNICALL *NewLocalRef) - (JNIEnv *env, jobject ref); - jint (JNICALL *EnsureLocalCapacity) - (JNIEnv *env, jint capacity); - - jobject (JNICALL *AllocObject) - (JNIEnv *env, jclass clazz); - jobject (JNICALL *NewObject) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jobject (JNICALL *NewObjectV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jobject (JNICALL *NewObjectA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jclass (JNICALL *GetObjectClass) - (JNIEnv *env, jobject obj); - jboolean (JNICALL *IsInstanceOf) - (JNIEnv *env, jobject obj, jclass clazz); - - jmethodID (JNICALL *GetMethodID) - (JNIEnv *env, jclass clazz, const char *name, const char *sig); - - jobject (JNICALL *CallObjectMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jobject (JNICALL *CallObjectMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jobject (JNICALL *CallObjectMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args); - - jboolean (JNICALL *CallBooleanMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jboolean (JNICALL *CallBooleanMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jboolean (JNICALL *CallBooleanMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args); - - jbyte (JNICALL *CallByteMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jbyte (JNICALL *CallByteMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jbyte (JNICALL *CallByteMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jchar (JNICALL *CallCharMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jchar (JNICALL *CallCharMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jchar (JNICALL *CallCharMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jshort (JNICALL *CallShortMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jshort (JNICALL *CallShortMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jshort (JNICALL *CallShortMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jint (JNICALL *CallIntMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jint (JNICALL *CallIntMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jint (JNICALL *CallIntMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jlong (JNICALL *CallLongMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jlong (JNICALL *CallLongMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jlong (JNICALL *CallLongMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jfloat (JNICALL *CallFloatMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jfloat (JNICALL *CallFloatMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jfloat (JNICALL *CallFloatMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - jdouble (JNICALL *CallDoubleMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - jdouble (JNICALL *CallDoubleMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - jdouble (JNICALL *CallDoubleMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); - - void (JNICALL *CallVoidMethod) - (JNIEnv *env, jobject obj, jmethodID methodID, ...); - void (JNICALL *CallVoidMethodV) - (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); - void (JNICALL *CallVoidMethodA) - (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args); - - jobject (JNICALL *CallNonvirtualObjectMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jobject (JNICALL *CallNonvirtualObjectMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jobject (JNICALL *CallNonvirtualObjectMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue * args); - - jboolean (JNICALL *CallNonvirtualBooleanMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jboolean (JNICALL *CallNonvirtualBooleanMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jboolean (JNICALL *CallNonvirtualBooleanMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue * args); - - jbyte (JNICALL *CallNonvirtualByteMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jbyte (JNICALL *CallNonvirtualByteMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jbyte (JNICALL *CallNonvirtualByteMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jchar (JNICALL *CallNonvirtualCharMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jchar (JNICALL *CallNonvirtualCharMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jchar (JNICALL *CallNonvirtualCharMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jshort (JNICALL *CallNonvirtualShortMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jshort (JNICALL *CallNonvirtualShortMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jshort (JNICALL *CallNonvirtualShortMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jint (JNICALL *CallNonvirtualIntMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jint (JNICALL *CallNonvirtualIntMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jint (JNICALL *CallNonvirtualIntMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jlong (JNICALL *CallNonvirtualLongMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jlong (JNICALL *CallNonvirtualLongMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jlong (JNICALL *CallNonvirtualLongMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jfloat (JNICALL *CallNonvirtualFloatMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jfloat (JNICALL *CallNonvirtualFloatMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jfloat (JNICALL *CallNonvirtualFloatMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - jdouble (JNICALL *CallNonvirtualDoubleMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - jdouble (JNICALL *CallNonvirtualDoubleMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - jdouble (JNICALL *CallNonvirtualDoubleMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue *args); - - void (JNICALL *CallNonvirtualVoidMethod) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); - void (JNICALL *CallNonvirtualVoidMethodV) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - va_list args); - void (JNICALL *CallNonvirtualVoidMethodA) - (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, - const jvalue * args); - - jfieldID (JNICALL *GetFieldID) - (JNIEnv *env, jclass clazz, const char *name, const char *sig); - - jobject (JNICALL *GetObjectField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jboolean (JNICALL *GetBooleanField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jbyte (JNICALL *GetByteField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jchar (JNICALL *GetCharField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jshort (JNICALL *GetShortField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jint (JNICALL *GetIntField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jlong (JNICALL *GetLongField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jfloat (JNICALL *GetFloatField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - jdouble (JNICALL *GetDoubleField) - (JNIEnv *env, jobject obj, jfieldID fieldID); - - void (JNICALL *SetObjectField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val); - void (JNICALL *SetBooleanField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val); - void (JNICALL *SetByteField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val); - void (JNICALL *SetCharField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val); - void (JNICALL *SetShortField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val); - void (JNICALL *SetIntField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jint val); - void (JNICALL *SetLongField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val); - void (JNICALL *SetFloatField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val); - void (JNICALL *SetDoubleField) - (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val); - - jmethodID (JNICALL *GetStaticMethodID) - (JNIEnv *env, jclass clazz, const char *name, const char *sig); - - jobject (JNICALL *CallStaticObjectMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jobject (JNICALL *CallStaticObjectMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jobject (JNICALL *CallStaticObjectMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jboolean (JNICALL *CallStaticBooleanMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jboolean (JNICALL *CallStaticBooleanMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jboolean (JNICALL *CallStaticBooleanMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jbyte (JNICALL *CallStaticByteMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jbyte (JNICALL *CallStaticByteMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jbyte (JNICALL *CallStaticByteMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jchar (JNICALL *CallStaticCharMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jchar (JNICALL *CallStaticCharMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jchar (JNICALL *CallStaticCharMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jshort (JNICALL *CallStaticShortMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jshort (JNICALL *CallStaticShortMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jshort (JNICALL *CallStaticShortMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jint (JNICALL *CallStaticIntMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jint (JNICALL *CallStaticIntMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jint (JNICALL *CallStaticIntMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jlong (JNICALL *CallStaticLongMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jlong (JNICALL *CallStaticLongMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jlong (JNICALL *CallStaticLongMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jfloat (JNICALL *CallStaticFloatMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jfloat (JNICALL *CallStaticFloatMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jfloat (JNICALL *CallStaticFloatMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - jdouble (JNICALL *CallStaticDoubleMethod) - (JNIEnv *env, jclass clazz, jmethodID methodID, ...); - jdouble (JNICALL *CallStaticDoubleMethodV) - (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); - jdouble (JNICALL *CallStaticDoubleMethodA) - (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); - - void (JNICALL *CallStaticVoidMethod) - (JNIEnv *env, jclass cls, jmethodID methodID, ...); - void (JNICALL *CallStaticVoidMethodV) - (JNIEnv *env, jclass cls, jmethodID methodID, va_list args); - void (JNICALL *CallStaticVoidMethodA) - (JNIEnv *env, jclass cls, jmethodID methodID, const jvalue * args); - - jfieldID (JNICALL *GetStaticFieldID) - (JNIEnv *env, jclass clazz, const char *name, const char *sig); - jobject (JNICALL *GetStaticObjectField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jboolean (JNICALL *GetStaticBooleanField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jbyte (JNICALL *GetStaticByteField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jchar (JNICALL *GetStaticCharField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jshort (JNICALL *GetStaticShortField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jint (JNICALL *GetStaticIntField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jlong (JNICALL *GetStaticLongField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jfloat (JNICALL *GetStaticFloatField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - jdouble (JNICALL *GetStaticDoubleField) - (JNIEnv *env, jclass clazz, jfieldID fieldID); - - void (JNICALL *SetStaticObjectField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value); - void (JNICALL *SetStaticBooleanField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value); - void (JNICALL *SetStaticByteField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value); - void (JNICALL *SetStaticCharField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value); - void (JNICALL *SetStaticShortField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value); - void (JNICALL *SetStaticIntField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jint value); - void (JNICALL *SetStaticLongField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value); - void (JNICALL *SetStaticFloatField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value); - void (JNICALL *SetStaticDoubleField) - (JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value); - - jstring (JNICALL *NewString) - (JNIEnv *env, const jchar *unicode, jsize len); - jsize (JNICALL *GetStringLength) - (JNIEnv *env, jstring str); - const jchar *(JNICALL *GetStringChars) - (JNIEnv *env, jstring str, jboolean *isCopy); - void (JNICALL *ReleaseStringChars) - (JNIEnv *env, jstring str, const jchar *chars); - - jstring (JNICALL *NewStringUTF) - (JNIEnv *env, const char *utf); - jsize (JNICALL *GetStringUTFLength) - (JNIEnv *env, jstring str); - const char* (JNICALL *GetStringUTFChars) - (JNIEnv *env, jstring str, jboolean *isCopy); - void (JNICALL *ReleaseStringUTFChars) - (JNIEnv *env, jstring str, const char* chars); - - - jsize (JNICALL *GetArrayLength) - (JNIEnv *env, jarray array); - - jobjectArray (JNICALL *NewObjectArray) - (JNIEnv *env, jsize len, jclass clazz, jobject init); - jobject (JNICALL *GetObjectArrayElement) - (JNIEnv *env, jobjectArray array, jsize index); - void (JNICALL *SetObjectArrayElement) - (JNIEnv *env, jobjectArray array, jsize index, jobject val); - - jbooleanArray (JNICALL *NewBooleanArray) - (JNIEnv *env, jsize len); - jbyteArray (JNICALL *NewByteArray) - (JNIEnv *env, jsize len); - jcharArray (JNICALL *NewCharArray) - (JNIEnv *env, jsize len); - jshortArray (JNICALL *NewShortArray) - (JNIEnv *env, jsize len); - jintArray (JNICALL *NewIntArray) - (JNIEnv *env, jsize len); - jlongArray (JNICALL *NewLongArray) - (JNIEnv *env, jsize len); - jfloatArray (JNICALL *NewFloatArray) - (JNIEnv *env, jsize len); - jdoubleArray (JNICALL *NewDoubleArray) - (JNIEnv *env, jsize len); - - jboolean * (JNICALL *GetBooleanArrayElements) - (JNIEnv *env, jbooleanArray array, jboolean *isCopy); - jbyte * (JNICALL *GetByteArrayElements) - (JNIEnv *env, jbyteArray array, jboolean *isCopy); - jchar * (JNICALL *GetCharArrayElements) - (JNIEnv *env, jcharArray array, jboolean *isCopy); - jshort * (JNICALL *GetShortArrayElements) - (JNIEnv *env, jshortArray array, jboolean *isCopy); - jint * (JNICALL *GetIntArrayElements) - (JNIEnv *env, jintArray array, jboolean *isCopy); - jlong * (JNICALL *GetLongArrayElements) - (JNIEnv *env, jlongArray array, jboolean *isCopy); - jfloat * (JNICALL *GetFloatArrayElements) - (JNIEnv *env, jfloatArray array, jboolean *isCopy); - jdouble * (JNICALL *GetDoubleArrayElements) - (JNIEnv *env, jdoubleArray array, jboolean *isCopy); - - void (JNICALL *ReleaseBooleanArrayElements) - (JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode); - void (JNICALL *ReleaseByteArrayElements) - (JNIEnv *env, jbyteArray array, jbyte *elems, jint mode); - void (JNICALL *ReleaseCharArrayElements) - (JNIEnv *env, jcharArray array, jchar *elems, jint mode); - void (JNICALL *ReleaseShortArrayElements) - (JNIEnv *env, jshortArray array, jshort *elems, jint mode); - void (JNICALL *ReleaseIntArrayElements) - (JNIEnv *env, jintArray array, jint *elems, jint mode); - void (JNICALL *ReleaseLongArrayElements) - (JNIEnv *env, jlongArray array, jlong *elems, jint mode); - void (JNICALL *ReleaseFloatArrayElements) - (JNIEnv *env, jfloatArray array, jfloat *elems, jint mode); - void (JNICALL *ReleaseDoubleArrayElements) - (JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode); - - void (JNICALL *GetBooleanArrayRegion) - (JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf); - void (JNICALL *GetByteArrayRegion) - (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf); - void (JNICALL *GetCharArrayRegion) - (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf); - void (JNICALL *GetShortArrayRegion) - (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf); - void (JNICALL *GetIntArrayRegion) - (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf); - void (JNICALL *GetLongArrayRegion) - (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf); - void (JNICALL *GetFloatArrayRegion) - (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf); - void (JNICALL *GetDoubleArrayRegion) - (JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf); - - void (JNICALL *SetBooleanArrayRegion) - (JNIEnv *env, jbooleanArray array, jsize start, jsize l, const jboolean *buf); - void (JNICALL *SetByteArrayRegion) - (JNIEnv *env, jbyteArray array, jsize start, jsize len, const jbyte *buf); - void (JNICALL *SetCharArrayRegion) - (JNIEnv *env, jcharArray array, jsize start, jsize len, const jchar *buf); - void (JNICALL *SetShortArrayRegion) - (JNIEnv *env, jshortArray array, jsize start, jsize len, const jshort *buf); - void (JNICALL *SetIntArrayRegion) - (JNIEnv *env, jintArray array, jsize start, jsize len, const jint *buf); - void (JNICALL *SetLongArrayRegion) - (JNIEnv *env, jlongArray array, jsize start, jsize len, const jlong *buf); - void (JNICALL *SetFloatArrayRegion) - (JNIEnv *env, jfloatArray array, jsize start, jsize len, const jfloat *buf); - void (JNICALL *SetDoubleArrayRegion) - (JNIEnv *env, jdoubleArray array, jsize start, jsize len, const jdouble *buf); - - jint (JNICALL *RegisterNatives) - (JNIEnv *env, jclass clazz, const JNINativeMethod *methods, - jint nMethods); - jint (JNICALL *UnregisterNatives) - (JNIEnv *env, jclass clazz); - - jint (JNICALL *MonitorEnter) - (JNIEnv *env, jobject obj); - jint (JNICALL *MonitorExit) - (JNIEnv *env, jobject obj); - - jint (JNICALL *GetJavaVM) - (JNIEnv *env, JavaVM **vm); - - void (JNICALL *GetStringRegion) - (JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf); - void (JNICALL *GetStringUTFRegion) - (JNIEnv *env, jstring str, jsize start, jsize len, char *buf); - - void * (JNICALL *GetPrimitiveArrayCritical) - (JNIEnv *env, jarray array, jboolean *isCopy); - void (JNICALL *ReleasePrimitiveArrayCritical) - (JNIEnv *env, jarray array, void *carray, jint mode); - - const jchar * (JNICALL *GetStringCritical) - (JNIEnv *env, jstring string, jboolean *isCopy); - void (JNICALL *ReleaseStringCritical) - (JNIEnv *env, jstring string, const jchar *cstring); - - jweak (JNICALL *NewWeakGlobalRef) - (JNIEnv *env, jobject obj); - void (JNICALL *DeleteWeakGlobalRef) - (JNIEnv *env, jweak ref); - - jboolean (JNICALL *ExceptionCheck) - (JNIEnv *env); - - jobject (JNICALL *NewDirectByteBuffer) - (JNIEnv* env, void* address, jlong capacity); - void* (JNICALL *GetDirectBufferAddress) - (JNIEnv* env, jobject buf); - jlong (JNICALL *GetDirectBufferCapacity) - (JNIEnv* env, jobject buf); - - /* New JNI 1.6 Features */ - - jobjectRefType (JNICALL *GetObjectRefType) - (JNIEnv* env, jobject obj); -}; - -/* - * We use inlined functions for C++ so that programmers can write: - * - * env->FindClass("java/lang/String") - * - * in C++ rather than: - * - * (*env)->FindClass(env, "java/lang/String") - * - * in C. - */ - -struct JNIEnv_ { - const struct JNINativeInterface_ *functions; -#ifdef __cplusplus - - jint GetVersion() { - return functions->GetVersion(this); - } - jclass DefineClass(const char *name, jobject loader, const jbyte *buf, - jsize len) { - return functions->DefineClass(this, name, loader, buf, len); - } - jclass FindClass(const char *name) { - return functions->FindClass(this, name); - } - jmethodID FromReflectedMethod(jobject method) { - return functions->FromReflectedMethod(this,method); - } - jfieldID FromReflectedField(jobject field) { - return functions->FromReflectedField(this,field); - } - - jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) { - return functions->ToReflectedMethod(this, cls, methodID, isStatic); - } - - jclass GetSuperclass(jclass sub) { - return functions->GetSuperclass(this, sub); - } - jboolean IsAssignableFrom(jclass sub, jclass sup) { - return functions->IsAssignableFrom(this, sub, sup); - } - - jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) { - return functions->ToReflectedField(this,cls,fieldID,isStatic); - } - - jint Throw(jthrowable obj) { - return functions->Throw(this, obj); - } - jint ThrowNew(jclass clazz, const char *msg) { - return functions->ThrowNew(this, clazz, msg); - } - jthrowable ExceptionOccurred() { - return functions->ExceptionOccurred(this); - } - void ExceptionDescribe() { - functions->ExceptionDescribe(this); - } - void ExceptionClear() { - functions->ExceptionClear(this); - } - void FatalError(const char *msg) { - functions->FatalError(this, msg); - } - - jint PushLocalFrame(jint capacity) { - return functions->PushLocalFrame(this,capacity); - } - jobject PopLocalFrame(jobject result) { - return functions->PopLocalFrame(this,result); - } - - jobject NewGlobalRef(jobject lobj) { - return functions->NewGlobalRef(this,lobj); - } - void DeleteGlobalRef(jobject gref) { - functions->DeleteGlobalRef(this,gref); - } - void DeleteLocalRef(jobject obj) { - functions->DeleteLocalRef(this, obj); - } - - jboolean IsSameObject(jobject obj1, jobject obj2) { - return functions->IsSameObject(this,obj1,obj2); - } - - jobject NewLocalRef(jobject ref) { - return functions->NewLocalRef(this,ref); - } - jint EnsureLocalCapacity(jint capacity) { - return functions->EnsureLocalCapacity(this,capacity); - } - - jobject AllocObject(jclass clazz) { - return functions->AllocObject(this,clazz); - } - jobject NewObject(jclass clazz, jmethodID methodID, ...) { - va_list args; - jobject result; - va_start(args, methodID); - result = functions->NewObjectV(this,clazz,methodID,args); - va_end(args); - return result; - } - jobject NewObjectV(jclass clazz, jmethodID methodID, - va_list args) { - return functions->NewObjectV(this,clazz,methodID,args); - } - jobject NewObjectA(jclass clazz, jmethodID methodID, - const jvalue *args) { - return functions->NewObjectA(this,clazz,methodID,args); - } - - jclass GetObjectClass(jobject obj) { - return functions->GetObjectClass(this,obj); - } - jboolean IsInstanceOf(jobject obj, jclass clazz) { - return functions->IsInstanceOf(this,obj,clazz); - } - - jmethodID GetMethodID(jclass clazz, const char *name, - const char *sig) { - return functions->GetMethodID(this,clazz,name,sig); - } - - jobject CallObjectMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jobject result; - va_start(args,methodID); - result = functions->CallObjectMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jobject CallObjectMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallObjectMethodV(this,obj,methodID,args); - } - jobject CallObjectMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallObjectMethodA(this,obj,methodID,args); - } - - jboolean CallBooleanMethod(jobject obj, - jmethodID methodID, ...) { - va_list args; - jboolean result; - va_start(args,methodID); - result = functions->CallBooleanMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jboolean CallBooleanMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallBooleanMethodV(this,obj,methodID,args); - } - jboolean CallBooleanMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallBooleanMethodA(this,obj,methodID, args); - } - - jbyte CallByteMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jbyte result; - va_start(args,methodID); - result = functions->CallByteMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jbyte CallByteMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallByteMethodV(this,obj,methodID,args); - } - jbyte CallByteMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallByteMethodA(this,obj,methodID,args); - } - - jchar CallCharMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jchar result; - va_start(args,methodID); - result = functions->CallCharMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jchar CallCharMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallCharMethodV(this,obj,methodID,args); - } - jchar CallCharMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallCharMethodA(this,obj,methodID,args); - } - - jshort CallShortMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jshort result; - va_start(args,methodID); - result = functions->CallShortMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jshort CallShortMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallShortMethodV(this,obj,methodID,args); - } - jshort CallShortMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallShortMethodA(this,obj,methodID,args); - } - - jint CallIntMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jint result; - va_start(args,methodID); - result = functions->CallIntMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jint CallIntMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallIntMethodV(this,obj,methodID,args); - } - jint CallIntMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallIntMethodA(this,obj,methodID,args); - } - - jlong CallLongMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jlong result; - va_start(args,methodID); - result = functions->CallLongMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jlong CallLongMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallLongMethodV(this,obj,methodID,args); - } - jlong CallLongMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallLongMethodA(this,obj,methodID,args); - } - - jfloat CallFloatMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jfloat result; - va_start(args,methodID); - result = functions->CallFloatMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jfloat CallFloatMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallFloatMethodV(this,obj,methodID,args); - } - jfloat CallFloatMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallFloatMethodA(this,obj,methodID,args); - } - - jdouble CallDoubleMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - jdouble result; - va_start(args,methodID); - result = functions->CallDoubleMethodV(this,obj,methodID,args); - va_end(args); - return result; - } - jdouble CallDoubleMethodV(jobject obj, jmethodID methodID, - va_list args) { - return functions->CallDoubleMethodV(this,obj,methodID,args); - } - jdouble CallDoubleMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - return functions->CallDoubleMethodA(this,obj,methodID,args); - } - - void CallVoidMethod(jobject obj, jmethodID methodID, ...) { - va_list args; - va_start(args,methodID); - functions->CallVoidMethodV(this,obj,methodID,args); - va_end(args); - } - void CallVoidMethodV(jobject obj, jmethodID methodID, - va_list args) { - functions->CallVoidMethodV(this,obj,methodID,args); - } - void CallVoidMethodA(jobject obj, jmethodID methodID, - const jvalue * args) { - functions->CallVoidMethodA(this,obj,methodID,args); - } - - jobject CallNonvirtualObjectMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jobject result; - va_start(args,methodID); - result = functions->CallNonvirtualObjectMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jobject CallNonvirtualObjectMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualObjectMethodV(this,obj,clazz, - methodID,args); - } - jobject CallNonvirtualObjectMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualObjectMethodA(this,obj,clazz, - methodID,args); - } - - jboolean CallNonvirtualBooleanMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jboolean result; - va_start(args,methodID); - result = functions->CallNonvirtualBooleanMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jboolean CallNonvirtualBooleanMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualBooleanMethodV(this,obj,clazz, - methodID,args); - } - jboolean CallNonvirtualBooleanMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualBooleanMethodA(this,obj,clazz, - methodID, args); - } - - jbyte CallNonvirtualByteMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jbyte result; - va_start(args,methodID); - result = functions->CallNonvirtualByteMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jbyte CallNonvirtualByteMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualByteMethodV(this,obj,clazz, - methodID,args); - } - jbyte CallNonvirtualByteMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualByteMethodA(this,obj,clazz, - methodID,args); - } - - jchar CallNonvirtualCharMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jchar result; - va_start(args,methodID); - result = functions->CallNonvirtualCharMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jchar CallNonvirtualCharMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualCharMethodV(this,obj,clazz, - methodID,args); - } - jchar CallNonvirtualCharMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualCharMethodA(this,obj,clazz, - methodID,args); - } - - jshort CallNonvirtualShortMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jshort result; - va_start(args,methodID); - result = functions->CallNonvirtualShortMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jshort CallNonvirtualShortMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualShortMethodV(this,obj,clazz, - methodID,args); - } - jshort CallNonvirtualShortMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualShortMethodA(this,obj,clazz, - methodID,args); - } - - jint CallNonvirtualIntMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jint result; - va_start(args,methodID); - result = functions->CallNonvirtualIntMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jint CallNonvirtualIntMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualIntMethodV(this,obj,clazz, - methodID,args); - } - jint CallNonvirtualIntMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualIntMethodA(this,obj,clazz, - methodID,args); - } - - jlong CallNonvirtualLongMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jlong result; - va_start(args,methodID); - result = functions->CallNonvirtualLongMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jlong CallNonvirtualLongMethodV(jobject obj, jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallNonvirtualLongMethodV(this,obj,clazz, - methodID,args); - } - jlong CallNonvirtualLongMethodA(jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) { - return functions->CallNonvirtualLongMethodA(this,obj,clazz, - methodID,args); - } - - jfloat CallNonvirtualFloatMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jfloat result; - va_start(args,methodID); - result = functions->CallNonvirtualFloatMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jfloat CallNonvirtualFloatMethodV(jobject obj, jclass clazz, - jmethodID methodID, - va_list args) { - return functions->CallNonvirtualFloatMethodV(this,obj,clazz, - methodID,args); - } - jfloat CallNonvirtualFloatMethodA(jobject obj, jclass clazz, - jmethodID methodID, - const jvalue * args) { - return functions->CallNonvirtualFloatMethodA(this,obj,clazz, - methodID,args); - } - - jdouble CallNonvirtualDoubleMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - jdouble result; - va_start(args,methodID); - result = functions->CallNonvirtualDoubleMethodV(this,obj,clazz, - methodID,args); - va_end(args); - return result; - } - jdouble CallNonvirtualDoubleMethodV(jobject obj, jclass clazz, - jmethodID methodID, - va_list args) { - return functions->CallNonvirtualDoubleMethodV(this,obj,clazz, - methodID,args); - } - jdouble CallNonvirtualDoubleMethodA(jobject obj, jclass clazz, - jmethodID methodID, - const jvalue * args) { - return functions->CallNonvirtualDoubleMethodA(this,obj,clazz, - methodID,args); - } - - void CallNonvirtualVoidMethod(jobject obj, jclass clazz, - jmethodID methodID, ...) { - va_list args; - va_start(args,methodID); - functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args); - va_end(args); - } - void CallNonvirtualVoidMethodV(jobject obj, jclass clazz, - jmethodID methodID, - va_list args) { - functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args); - } - void CallNonvirtualVoidMethodA(jobject obj, jclass clazz, - jmethodID methodID, - const jvalue * args) { - functions->CallNonvirtualVoidMethodA(this,obj,clazz,methodID,args); - } - - jfieldID GetFieldID(jclass clazz, const char *name, - const char *sig) { - return functions->GetFieldID(this,clazz,name,sig); - } - - jobject GetObjectField(jobject obj, jfieldID fieldID) { - return functions->GetObjectField(this,obj,fieldID); - } - jboolean GetBooleanField(jobject obj, jfieldID fieldID) { - return functions->GetBooleanField(this,obj,fieldID); - } - jbyte GetByteField(jobject obj, jfieldID fieldID) { - return functions->GetByteField(this,obj,fieldID); - } - jchar GetCharField(jobject obj, jfieldID fieldID) { - return functions->GetCharField(this,obj,fieldID); - } - jshort GetShortField(jobject obj, jfieldID fieldID) { - return functions->GetShortField(this,obj,fieldID); - } - jint GetIntField(jobject obj, jfieldID fieldID) { - return functions->GetIntField(this,obj,fieldID); - } - jlong GetLongField(jobject obj, jfieldID fieldID) { - return functions->GetLongField(this,obj,fieldID); - } - jfloat GetFloatField(jobject obj, jfieldID fieldID) { - return functions->GetFloatField(this,obj,fieldID); - } - jdouble GetDoubleField(jobject obj, jfieldID fieldID) { - return functions->GetDoubleField(this,obj,fieldID); - } - - void SetObjectField(jobject obj, jfieldID fieldID, jobject val) { - functions->SetObjectField(this,obj,fieldID,val); - } - void SetBooleanField(jobject obj, jfieldID fieldID, - jboolean val) { - functions->SetBooleanField(this,obj,fieldID,val); - } - void SetByteField(jobject obj, jfieldID fieldID, - jbyte val) { - functions->SetByteField(this,obj,fieldID,val); - } - void SetCharField(jobject obj, jfieldID fieldID, - jchar val) { - functions->SetCharField(this,obj,fieldID,val); - } - void SetShortField(jobject obj, jfieldID fieldID, - jshort val) { - functions->SetShortField(this,obj,fieldID,val); - } - void SetIntField(jobject obj, jfieldID fieldID, - jint val) { - functions->SetIntField(this,obj,fieldID,val); - } - void SetLongField(jobject obj, jfieldID fieldID, - jlong val) { - functions->SetLongField(this,obj,fieldID,val); - } - void SetFloatField(jobject obj, jfieldID fieldID, - jfloat val) { - functions->SetFloatField(this,obj,fieldID,val); - } - void SetDoubleField(jobject obj, jfieldID fieldID, - jdouble val) { - functions->SetDoubleField(this,obj,fieldID,val); - } - - jmethodID GetStaticMethodID(jclass clazz, const char *name, - const char *sig) { - return functions->GetStaticMethodID(this,clazz,name,sig); - } - - jobject CallStaticObjectMethod(jclass clazz, jmethodID methodID, - ...) { - va_list args; - jobject result; - va_start(args,methodID); - result = functions->CallStaticObjectMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jobject CallStaticObjectMethodV(jclass clazz, jmethodID methodID, - va_list args) { - return functions->CallStaticObjectMethodV(this,clazz,methodID,args); - } - jobject CallStaticObjectMethodA(jclass clazz, jmethodID methodID, - const jvalue *args) { - return functions->CallStaticObjectMethodA(this,clazz,methodID,args); - } - - jboolean CallStaticBooleanMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jboolean result; - va_start(args,methodID); - result = functions->CallStaticBooleanMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jboolean CallStaticBooleanMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticBooleanMethodV(this,clazz,methodID,args); - } - jboolean CallStaticBooleanMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticBooleanMethodA(this,clazz,methodID,args); - } - - jbyte CallStaticByteMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jbyte result; - va_start(args,methodID); - result = functions->CallStaticByteMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jbyte CallStaticByteMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticByteMethodV(this,clazz,methodID,args); - } - jbyte CallStaticByteMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticByteMethodA(this,clazz,methodID,args); - } - - jchar CallStaticCharMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jchar result; - va_start(args,methodID); - result = functions->CallStaticCharMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jchar CallStaticCharMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticCharMethodV(this,clazz,methodID,args); - } - jchar CallStaticCharMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticCharMethodA(this,clazz,methodID,args); - } - - jshort CallStaticShortMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jshort result; - va_start(args,methodID); - result = functions->CallStaticShortMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jshort CallStaticShortMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticShortMethodV(this,clazz,methodID,args); - } - jshort CallStaticShortMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticShortMethodA(this,clazz,methodID,args); - } - - jint CallStaticIntMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jint result; - va_start(args,methodID); - result = functions->CallStaticIntMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jint CallStaticIntMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticIntMethodV(this,clazz,methodID,args); - } - jint CallStaticIntMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticIntMethodA(this,clazz,methodID,args); - } - - jlong CallStaticLongMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jlong result; - va_start(args,methodID); - result = functions->CallStaticLongMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jlong CallStaticLongMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticLongMethodV(this,clazz,methodID,args); - } - jlong CallStaticLongMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticLongMethodA(this,clazz,methodID,args); - } - - jfloat CallStaticFloatMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jfloat result; - va_start(args,methodID); - result = functions->CallStaticFloatMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jfloat CallStaticFloatMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticFloatMethodV(this,clazz,methodID,args); - } - jfloat CallStaticFloatMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticFloatMethodA(this,clazz,methodID,args); - } - - jdouble CallStaticDoubleMethod(jclass clazz, - jmethodID methodID, ...) { - va_list args; - jdouble result; - va_start(args,methodID); - result = functions->CallStaticDoubleMethodV(this,clazz,methodID,args); - va_end(args); - return result; - } - jdouble CallStaticDoubleMethodV(jclass clazz, - jmethodID methodID, va_list args) { - return functions->CallStaticDoubleMethodV(this,clazz,methodID,args); - } - jdouble CallStaticDoubleMethodA(jclass clazz, - jmethodID methodID, const jvalue *args) { - return functions->CallStaticDoubleMethodA(this,clazz,methodID,args); - } - - void CallStaticVoidMethod(jclass cls, jmethodID methodID, ...) { - va_list args; - va_start(args,methodID); - functions->CallStaticVoidMethodV(this,cls,methodID,args); - va_end(args); - } - void CallStaticVoidMethodV(jclass cls, jmethodID methodID, - va_list args) { - functions->CallStaticVoidMethodV(this,cls,methodID,args); - } - void CallStaticVoidMethodA(jclass cls, jmethodID methodID, - const jvalue * args) { - functions->CallStaticVoidMethodA(this,cls,methodID,args); - } - - jfieldID GetStaticFieldID(jclass clazz, const char *name, - const char *sig) { - return functions->GetStaticFieldID(this,clazz,name,sig); - } - jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticObjectField(this,clazz,fieldID); - } - jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticBooleanField(this,clazz,fieldID); - } - jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticByteField(this,clazz,fieldID); - } - jchar GetStaticCharField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticCharField(this,clazz,fieldID); - } - jshort GetStaticShortField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticShortField(this,clazz,fieldID); - } - jint GetStaticIntField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticIntField(this,clazz,fieldID); - } - jlong GetStaticLongField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticLongField(this,clazz,fieldID); - } - jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticFloatField(this,clazz,fieldID); - } - jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) { - return functions->GetStaticDoubleField(this,clazz,fieldID); - } - - void SetStaticObjectField(jclass clazz, jfieldID fieldID, - jobject value) { - functions->SetStaticObjectField(this,clazz,fieldID,value); - } - void SetStaticBooleanField(jclass clazz, jfieldID fieldID, - jboolean value) { - functions->SetStaticBooleanField(this,clazz,fieldID,value); - } - void SetStaticByteField(jclass clazz, jfieldID fieldID, - jbyte value) { - functions->SetStaticByteField(this,clazz,fieldID,value); - } - void SetStaticCharField(jclass clazz, jfieldID fieldID, - jchar value) { - functions->SetStaticCharField(this,clazz,fieldID,value); - } - void SetStaticShortField(jclass clazz, jfieldID fieldID, - jshort value) { - functions->SetStaticShortField(this,clazz,fieldID,value); - } - void SetStaticIntField(jclass clazz, jfieldID fieldID, - jint value) { - functions->SetStaticIntField(this,clazz,fieldID,value); - } - void SetStaticLongField(jclass clazz, jfieldID fieldID, - jlong value) { - functions->SetStaticLongField(this,clazz,fieldID,value); - } - void SetStaticFloatField(jclass clazz, jfieldID fieldID, - jfloat value) { - functions->SetStaticFloatField(this,clazz,fieldID,value); - } - void SetStaticDoubleField(jclass clazz, jfieldID fieldID, - jdouble value) { - functions->SetStaticDoubleField(this,clazz,fieldID,value); - } - - jstring NewString(const jchar *unicode, jsize len) { - return functions->NewString(this,unicode,len); - } - jsize GetStringLength(jstring str) { - return functions->GetStringLength(this,str); - } - const jchar *GetStringChars(jstring str, jboolean *isCopy) { - return functions->GetStringChars(this,str,isCopy); - } - void ReleaseStringChars(jstring str, const jchar *chars) { - functions->ReleaseStringChars(this,str,chars); - } - - jstring NewStringUTF(const char *utf) { - return functions->NewStringUTF(this,utf); - } - jsize GetStringUTFLength(jstring str) { - return functions->GetStringUTFLength(this,str); - } - const char* GetStringUTFChars(jstring str, jboolean *isCopy) { - return functions->GetStringUTFChars(this,str,isCopy); - } - void ReleaseStringUTFChars(jstring str, const char* chars) { - functions->ReleaseStringUTFChars(this,str,chars); - } - - jsize GetArrayLength(jarray array) { - return functions->GetArrayLength(this,array); - } - - jobjectArray NewObjectArray(jsize len, jclass clazz, - jobject init) { - return functions->NewObjectArray(this,len,clazz,init); - } - jobject GetObjectArrayElement(jobjectArray array, jsize index) { - return functions->GetObjectArrayElement(this,array,index); - } - void SetObjectArrayElement(jobjectArray array, jsize index, - jobject val) { - functions->SetObjectArrayElement(this,array,index,val); - } - - jbooleanArray NewBooleanArray(jsize len) { - return functions->NewBooleanArray(this,len); - } - jbyteArray NewByteArray(jsize len) { - return functions->NewByteArray(this,len); - } - jcharArray NewCharArray(jsize len) { - return functions->NewCharArray(this,len); - } - jshortArray NewShortArray(jsize len) { - return functions->NewShortArray(this,len); - } - jintArray NewIntArray(jsize len) { - return functions->NewIntArray(this,len); - } - jlongArray NewLongArray(jsize len) { - return functions->NewLongArray(this,len); - } - jfloatArray NewFloatArray(jsize len) { - return functions->NewFloatArray(this,len); - } - jdoubleArray NewDoubleArray(jsize len) { - return functions->NewDoubleArray(this,len); - } - - jboolean * GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy) { - return functions->GetBooleanArrayElements(this,array,isCopy); - } - jbyte * GetByteArrayElements(jbyteArray array, jboolean *isCopy) { - return functions->GetByteArrayElements(this,array,isCopy); - } - jchar * GetCharArrayElements(jcharArray array, jboolean *isCopy) { - return functions->GetCharArrayElements(this,array,isCopy); - } - jshort * GetShortArrayElements(jshortArray array, jboolean *isCopy) { - return functions->GetShortArrayElements(this,array,isCopy); - } - jint * GetIntArrayElements(jintArray array, jboolean *isCopy) { - return functions->GetIntArrayElements(this,array,isCopy); - } - jlong * GetLongArrayElements(jlongArray array, jboolean *isCopy) { - return functions->GetLongArrayElements(this,array,isCopy); - } - jfloat * GetFloatArrayElements(jfloatArray array, jboolean *isCopy) { - return functions->GetFloatArrayElements(this,array,isCopy); - } - jdouble * GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy) { - return functions->GetDoubleArrayElements(this,array,isCopy); - } - - void ReleaseBooleanArrayElements(jbooleanArray array, - jboolean *elems, - jint mode) { - functions->ReleaseBooleanArrayElements(this,array,elems,mode); - } - void ReleaseByteArrayElements(jbyteArray array, - jbyte *elems, - jint mode) { - functions->ReleaseByteArrayElements(this,array,elems,mode); - } - void ReleaseCharArrayElements(jcharArray array, - jchar *elems, - jint mode) { - functions->ReleaseCharArrayElements(this,array,elems,mode); - } - void ReleaseShortArrayElements(jshortArray array, - jshort *elems, - jint mode) { - functions->ReleaseShortArrayElements(this,array,elems,mode); - } - void ReleaseIntArrayElements(jintArray array, - jint *elems, - jint mode) { - functions->ReleaseIntArrayElements(this,array,elems,mode); - } - void ReleaseLongArrayElements(jlongArray array, - jlong *elems, - jint mode) { - functions->ReleaseLongArrayElements(this,array,elems,mode); - } - void ReleaseFloatArrayElements(jfloatArray array, - jfloat *elems, - jint mode) { - functions->ReleaseFloatArrayElements(this,array,elems,mode); - } - void ReleaseDoubleArrayElements(jdoubleArray array, - jdouble *elems, - jint mode) { - functions->ReleaseDoubleArrayElements(this,array,elems,mode); - } - - void GetBooleanArrayRegion(jbooleanArray array, - jsize start, jsize len, jboolean *buf) { - functions->GetBooleanArrayRegion(this,array,start,len,buf); - } - void GetByteArrayRegion(jbyteArray array, - jsize start, jsize len, jbyte *buf) { - functions->GetByteArrayRegion(this,array,start,len,buf); - } - void GetCharArrayRegion(jcharArray array, - jsize start, jsize len, jchar *buf) { - functions->GetCharArrayRegion(this,array,start,len,buf); - } - void GetShortArrayRegion(jshortArray array, - jsize start, jsize len, jshort *buf) { - functions->GetShortArrayRegion(this,array,start,len,buf); - } - void GetIntArrayRegion(jintArray array, - jsize start, jsize len, jint *buf) { - functions->GetIntArrayRegion(this,array,start,len,buf); - } - void GetLongArrayRegion(jlongArray array, - jsize start, jsize len, jlong *buf) { - functions->GetLongArrayRegion(this,array,start,len,buf); - } - void GetFloatArrayRegion(jfloatArray array, - jsize start, jsize len, jfloat *buf) { - functions->GetFloatArrayRegion(this,array,start,len,buf); - } - void GetDoubleArrayRegion(jdoubleArray array, - jsize start, jsize len, jdouble *buf) { - functions->GetDoubleArrayRegion(this,array,start,len,buf); - } - - void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, - const jboolean *buf) { - functions->SetBooleanArrayRegion(this,array,start,len,buf); - } - void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, - const jbyte *buf) { - functions->SetByteArrayRegion(this,array,start,len,buf); - } - void SetCharArrayRegion(jcharArray array, jsize start, jsize len, - const jchar *buf) { - functions->SetCharArrayRegion(this,array,start,len,buf); - } - void SetShortArrayRegion(jshortArray array, jsize start, jsize len, - const jshort *buf) { - functions->SetShortArrayRegion(this,array,start,len,buf); - } - void SetIntArrayRegion(jintArray array, jsize start, jsize len, - const jint *buf) { - functions->SetIntArrayRegion(this,array,start,len,buf); - } - void SetLongArrayRegion(jlongArray array, jsize start, jsize len, - const jlong *buf) { - functions->SetLongArrayRegion(this,array,start,len,buf); - } - void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, - const jfloat *buf) { - functions->SetFloatArrayRegion(this,array,start,len,buf); - } - void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, - const jdouble *buf) { - functions->SetDoubleArrayRegion(this,array,start,len,buf); - } - - jint RegisterNatives(jclass clazz, const JNINativeMethod *methods, - jint nMethods) { - return functions->RegisterNatives(this,clazz,methods,nMethods); - } - jint UnregisterNatives(jclass clazz) { - return functions->UnregisterNatives(this,clazz); - } - - jint MonitorEnter(jobject obj) { - return functions->MonitorEnter(this,obj); - } - jint MonitorExit(jobject obj) { - return functions->MonitorExit(this,obj); - } - - jint GetJavaVM(JavaVM **vm) { - return functions->GetJavaVM(this,vm); - } - - void GetStringRegion(jstring str, jsize start, jsize len, jchar *buf) { - functions->GetStringRegion(this,str,start,len,buf); - } - void GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf) { - functions->GetStringUTFRegion(this,str,start,len,buf); - } - - void * GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) { - return functions->GetPrimitiveArrayCritical(this,array,isCopy); - } - void ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode) { - functions->ReleasePrimitiveArrayCritical(this,array,carray,mode); - } - - const jchar * GetStringCritical(jstring string, jboolean *isCopy) { - return functions->GetStringCritical(this,string,isCopy); - } - void ReleaseStringCritical(jstring string, const jchar *cstring) { - functions->ReleaseStringCritical(this,string,cstring); - } - - jweak NewWeakGlobalRef(jobject obj) { - return functions->NewWeakGlobalRef(this,obj); - } - void DeleteWeakGlobalRef(jweak ref) { - functions->DeleteWeakGlobalRef(this,ref); - } - - jboolean ExceptionCheck() { - return functions->ExceptionCheck(this); - } - - jobject NewDirectByteBuffer(void* address, jlong capacity) { - return functions->NewDirectByteBuffer(this, address, capacity); - } - void* GetDirectBufferAddress(jobject buf) { - return functions->GetDirectBufferAddress(this, buf); - } - jlong GetDirectBufferCapacity(jobject buf) { - return functions->GetDirectBufferCapacity(this, buf); - } - jobjectRefType GetObjectRefType(jobject obj) { - return functions->GetObjectRefType(this, obj); - } - -#endif /* __cplusplus */ -}; - -typedef struct JavaVMOption { - char *optionString; - void *extraInfo; -} JavaVMOption; - -typedef struct JavaVMInitArgs { - jint version; - - jint nOptions; - JavaVMOption *options; - jboolean ignoreUnrecognized; -} JavaVMInitArgs; - -typedef struct JavaVMAttachArgs { - jint version; - - char *name; - jobject group; -} JavaVMAttachArgs; - -/* These will be VM-specific. */ - -#define JDK1_2 -#define JDK1_4 - -/* End VM-specific. */ - -struct JNIInvokeInterface_ { - void *reserved0; - void *reserved1; - void *reserved2; - - jint (JNICALL *DestroyJavaVM)(JavaVM *vm); - - jint (JNICALL *AttachCurrentThread)(JavaVM *vm, void **penv, void *args); - - jint (JNICALL *DetachCurrentThread)(JavaVM *vm); - - jint (JNICALL *GetEnv)(JavaVM *vm, void **penv, jint version); - - jint (JNICALL *AttachCurrentThreadAsDaemon)(JavaVM *vm, void **penv, void *args); -}; - -struct JavaVM_ { - const struct JNIInvokeInterface_ *functions; -#ifdef __cplusplus - - jint DestroyJavaVM() { - return functions->DestroyJavaVM(this); - } - jint AttachCurrentThread(void **penv, void *args) { - return functions->AttachCurrentThread(this, penv, args); - } - jint DetachCurrentThread() { - return functions->DetachCurrentThread(this); - } - - jint GetEnv(void **penv, jint version) { - return functions->GetEnv(this, penv, version); - } - jint AttachCurrentThreadAsDaemon(void **penv, void *args) { - return functions->AttachCurrentThreadAsDaemon(this, penv, args); - } -#endif -}; - -#ifdef _JNI_IMPLEMENTATION_ -#define _JNI_IMPORT_OR_EXPORT_ JNIEXPORT -#else -#define _JNI_IMPORT_OR_EXPORT_ JNIIMPORT -#endif -_JNI_IMPORT_OR_EXPORT_ jint JNICALL -JNI_GetDefaultJavaVMInitArgs(void *args); - -_JNI_IMPORT_OR_EXPORT_ jint JNICALL -JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args); - -_JNI_IMPORT_OR_EXPORT_ jint JNICALL -JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *); - -/* Defined by native libraries. */ -JNIEXPORT jint JNICALL -JNI_OnLoad(JavaVM *vm, void *reserved); - -JNIEXPORT void JNICALL -JNI_OnUnload(JavaVM *vm, void *reserved); - -#define JNI_VERSION_1_1 0x00010001 -#define JNI_VERSION_1_2 0x00010002 -#define JNI_VERSION_1_4 0x00010004 -#define JNI_VERSION_1_6 0x00010006 - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* !_JAVASOFT_JNI_H_ */ - - - diff --git a/cpp/nativecall/include/jvmti.h b/cpp/nativecall/include/jvmti.h deleted file mode 100644 index 865f21e..0000000 --- a/cpp/nativecall/include/jvmti.h +++ /dev/null @@ -1,2504 +0,0 @@ -#ifdef USE_PRAGMA_IDENT_HDR -#pragma ident "@(#)jvmtiLib.xsl 1.38 06/08/02 23:22:31 JVM" -#endif -/* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - - /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */ - - - /* Include file for the Java(tm) Virtual Machine Tool Interface */ - -#ifndef _JAVA_JVMTI_H_ -#define _JAVA_JVMTI_H_ - -#include "jni.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - JVMTI_VERSION_1 = 0x30010000, - JVMTI_VERSION_1_0 = 0x30010000, - JVMTI_VERSION_1_1 = 0x30010100, - - JVMTI_VERSION = 0x30000000 + (1 * 0x10000) + (1 * 0x100) + 102 /* version: 1.1.102 */ -}; - -JNIEXPORT jint JNICALL -Agent_OnLoad(JavaVM *vm, char *options, void *reserved); - -JNIEXPORT jint JNICALL -Agent_OnAttach(JavaVM* vm, char* options, void* reserved); - -JNIEXPORT void JNICALL -Agent_OnUnload(JavaVM *vm); - - /* Forward declaration of the environment */ - -struct _jvmtiEnv; - -struct jvmtiInterface_1_; - -#ifdef __cplusplus -typedef _jvmtiEnv jvmtiEnv; -#else -typedef const struct jvmtiInterface_1_ *jvmtiEnv; -#endif /* __cplusplus */ - -/* Derived Base Types */ - -typedef jobject jthread; -typedef jobject jthreadGroup; -typedef jlong jlocation; -struct _jrawMonitorID; -typedef struct _jrawMonitorID *jrawMonitorID; -typedef struct JNINativeInterface_ jniNativeInterface; - - /* Constants */ - - - /* Thread State Flags */ - -enum { - JVMTI_THREAD_STATE_ALIVE = 0x0001, - JVMTI_THREAD_STATE_TERMINATED = 0x0002, - JVMTI_THREAD_STATE_RUNNABLE = 0x0004, - JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400, - JVMTI_THREAD_STATE_WAITING = 0x0080, - JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010, - JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020, - JVMTI_THREAD_STATE_SLEEPING = 0x0040, - JVMTI_THREAD_STATE_IN_OBJECT_WAIT = 0x0100, - JVMTI_THREAD_STATE_PARKED = 0x0200, - JVMTI_THREAD_STATE_SUSPENDED = 0x100000, - JVMTI_THREAD_STATE_INTERRUPTED = 0x200000, - JVMTI_THREAD_STATE_IN_NATIVE = 0x400000, - JVMTI_THREAD_STATE_VENDOR_1 = 0x10000000, - JVMTI_THREAD_STATE_VENDOR_2 = 0x20000000, - JVMTI_THREAD_STATE_VENDOR_3 = 0x40000000 -}; - - /* java.lang.Thread.State Conversion Masks */ - -enum { - JVMTI_JAVA_LANG_THREAD_STATE_MASK = JVMTI_THREAD_STATE_TERMINATED | JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT, - JVMTI_JAVA_LANG_THREAD_STATE_NEW = 0, - JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED = JVMTI_THREAD_STATE_TERMINATED, - JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE, - JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, - JVMTI_JAVA_LANG_THREAD_STATE_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY, - JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT -}; - - /* Thread Priority Constants */ - -enum { - JVMTI_THREAD_MIN_PRIORITY = 1, - JVMTI_THREAD_NORM_PRIORITY = 5, - JVMTI_THREAD_MAX_PRIORITY = 10 -}; - - /* Heap Filter Flags */ - -enum { - JVMTI_HEAP_FILTER_TAGGED = 0x4, - JVMTI_HEAP_FILTER_UNTAGGED = 0x8, - JVMTI_HEAP_FILTER_CLASS_TAGGED = 0x10, - JVMTI_HEAP_FILTER_CLASS_UNTAGGED = 0x20 -}; - - /* Heap Visit Control Flags */ - -enum { - JVMTI_VISIT_OBJECTS = 0x100, - JVMTI_VISIT_ABORT = 0x8000 -}; - - /* Heap Reference Enumeration */ - -typedef enum { - JVMTI_HEAP_REFERENCE_CLASS = 1, - JVMTI_HEAP_REFERENCE_FIELD = 2, - JVMTI_HEAP_REFERENCE_ARRAY_ELEMENT = 3, - JVMTI_HEAP_REFERENCE_CLASS_LOADER = 4, - JVMTI_HEAP_REFERENCE_SIGNERS = 5, - JVMTI_HEAP_REFERENCE_PROTECTION_DOMAIN = 6, - JVMTI_HEAP_REFERENCE_INTERFACE = 7, - JVMTI_HEAP_REFERENCE_STATIC_FIELD = 8, - JVMTI_HEAP_REFERENCE_CONSTANT_POOL = 9, - JVMTI_HEAP_REFERENCE_SUPERCLASS = 10, - JVMTI_HEAP_REFERENCE_JNI_GLOBAL = 21, - JVMTI_HEAP_REFERENCE_SYSTEM_CLASS = 22, - JVMTI_HEAP_REFERENCE_MONITOR = 23, - JVMTI_HEAP_REFERENCE_STACK_LOCAL = 24, - JVMTI_HEAP_REFERENCE_JNI_LOCAL = 25, - JVMTI_HEAP_REFERENCE_THREAD = 26, - JVMTI_HEAP_REFERENCE_OTHER = 27 -} jvmtiHeapReferenceKind; - - /* Primitive Type Enumeration */ - -typedef enum { - JVMTI_PRIMITIVE_TYPE_BOOLEAN = 90, - JVMTI_PRIMITIVE_TYPE_BYTE = 66, - JVMTI_PRIMITIVE_TYPE_CHAR = 67, - JVMTI_PRIMITIVE_TYPE_SHORT = 83, - JVMTI_PRIMITIVE_TYPE_INT = 73, - JVMTI_PRIMITIVE_TYPE_LONG = 74, - JVMTI_PRIMITIVE_TYPE_FLOAT = 70, - JVMTI_PRIMITIVE_TYPE_DOUBLE = 68 -} jvmtiPrimitiveType; - - /* Heap Object Filter Enumeration */ - -typedef enum { - JVMTI_HEAP_OBJECT_TAGGED = 1, - JVMTI_HEAP_OBJECT_UNTAGGED = 2, - JVMTI_HEAP_OBJECT_EITHER = 3 -} jvmtiHeapObjectFilter; - - /* Heap Root Kind Enumeration */ - -typedef enum { - JVMTI_HEAP_ROOT_JNI_GLOBAL = 1, - JVMTI_HEAP_ROOT_SYSTEM_CLASS = 2, - JVMTI_HEAP_ROOT_MONITOR = 3, - JVMTI_HEAP_ROOT_STACK_LOCAL = 4, - JVMTI_HEAP_ROOT_JNI_LOCAL = 5, - JVMTI_HEAP_ROOT_THREAD = 6, - JVMTI_HEAP_ROOT_OTHER = 7 -} jvmtiHeapRootKind; - - /* Object Reference Enumeration */ - -typedef enum { - JVMTI_REFERENCE_CLASS = 1, - JVMTI_REFERENCE_FIELD = 2, - JVMTI_REFERENCE_ARRAY_ELEMENT = 3, - JVMTI_REFERENCE_CLASS_LOADER = 4, - JVMTI_REFERENCE_SIGNERS = 5, - JVMTI_REFERENCE_PROTECTION_DOMAIN = 6, - JVMTI_REFERENCE_INTERFACE = 7, - JVMTI_REFERENCE_STATIC_FIELD = 8, - JVMTI_REFERENCE_CONSTANT_POOL = 9 -} jvmtiObjectReferenceKind; - - /* Iteration Control Enumeration */ - -typedef enum { - JVMTI_ITERATION_CONTINUE = 1, - JVMTI_ITERATION_IGNORE = 2, - JVMTI_ITERATION_ABORT = 0 -} jvmtiIterationControl; - - /* Class Status Flags */ - -enum { - JVMTI_CLASS_STATUS_VERIFIED = 1, - JVMTI_CLASS_STATUS_PREPARED = 2, - JVMTI_CLASS_STATUS_INITIALIZED = 4, - JVMTI_CLASS_STATUS_ERROR = 8, - JVMTI_CLASS_STATUS_ARRAY = 16, - JVMTI_CLASS_STATUS_PRIMITIVE = 32 -}; - - /* Event Enable/Disable */ - -typedef enum { - JVMTI_ENABLE = 1, - JVMTI_DISABLE = 0 -} jvmtiEventMode; - - /* Extension Function/Event Parameter Types */ - -typedef enum { - JVMTI_TYPE_JBYTE = 101, - JVMTI_TYPE_JCHAR = 102, - JVMTI_TYPE_JSHORT = 103, - JVMTI_TYPE_JINT = 104, - JVMTI_TYPE_JLONG = 105, - JVMTI_TYPE_JFLOAT = 106, - JVMTI_TYPE_JDOUBLE = 107, - JVMTI_TYPE_JBOOLEAN = 108, - JVMTI_TYPE_JOBJECT = 109, - JVMTI_TYPE_JTHREAD = 110, - JVMTI_TYPE_JCLASS = 111, - JVMTI_TYPE_JVALUE = 112, - JVMTI_TYPE_JFIELDID = 113, - JVMTI_TYPE_JMETHODID = 114, - JVMTI_TYPE_CCHAR = 115, - JVMTI_TYPE_CVOID = 116, - JVMTI_TYPE_JNIENV = 117 -} jvmtiParamTypes; - - /* Extension Function/Event Parameter Kinds */ - -typedef enum { - JVMTI_KIND_IN = 91, - JVMTI_KIND_IN_PTR = 92, - JVMTI_KIND_IN_BUF = 93, - JVMTI_KIND_ALLOC_BUF = 94, - JVMTI_KIND_ALLOC_ALLOC_BUF = 95, - JVMTI_KIND_OUT = 96, - JVMTI_KIND_OUT_BUF = 97 -} jvmtiParamKind; - - /* Timer Kinds */ - -typedef enum { - JVMTI_TIMER_USER_CPU = 30, - JVMTI_TIMER_TOTAL_CPU = 31, - JVMTI_TIMER_ELAPSED = 32 -} jvmtiTimerKind; - - /* Phases of execution */ - -typedef enum { - JVMTI_PHASE_ONLOAD = 1, - JVMTI_PHASE_PRIMORDIAL = 2, - JVMTI_PHASE_START = 6, - JVMTI_PHASE_LIVE = 4, - JVMTI_PHASE_DEAD = 8 -} jvmtiPhase; - - /* Version Interface Types */ - -enum { - JVMTI_VERSION_INTERFACE_JNI = 0x00000000, - JVMTI_VERSION_INTERFACE_JVMTI = 0x30000000 -}; - - /* Version Masks */ - -enum { - JVMTI_VERSION_MASK_INTERFACE_TYPE = 0x70000000, - JVMTI_VERSION_MASK_MAJOR = 0x0FFF0000, - JVMTI_VERSION_MASK_MINOR = 0x0000FF00, - JVMTI_VERSION_MASK_MICRO = 0x000000FF -}; - - /* Version Shifts */ - -enum { - JVMTI_VERSION_SHIFT_MAJOR = 16, - JVMTI_VERSION_SHIFT_MINOR = 8, - JVMTI_VERSION_SHIFT_MICRO = 0 -}; - - /* Verbose Flag Enumeration */ - -typedef enum { - JVMTI_VERBOSE_OTHER = 0, - JVMTI_VERBOSE_GC = 1, - JVMTI_VERBOSE_CLASS = 2, - JVMTI_VERBOSE_JNI = 4 -} jvmtiVerboseFlag; - - /* JLocation Format Enumeration */ - -typedef enum { - JVMTI_JLOCATION_JVMBCI = 1, - JVMTI_JLOCATION_MACHINEPC = 2, - JVMTI_JLOCATION_OTHER = 0 -} jvmtiJlocationFormat; - - /* Resource Exhaustion Flags */ - -enum { - JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR = 0x0001, - JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP = 0x0002, - JVMTI_RESOURCE_EXHAUSTED_THREADS = 0x0004 -}; - - /* Errors */ - -typedef enum { - JVMTI_ERROR_NONE = 0, - JVMTI_ERROR_INVALID_THREAD = 10, - JVMTI_ERROR_INVALID_THREAD_GROUP = 11, - JVMTI_ERROR_INVALID_PRIORITY = 12, - JVMTI_ERROR_THREAD_NOT_SUSPENDED = 13, - JVMTI_ERROR_THREAD_SUSPENDED = 14, - JVMTI_ERROR_THREAD_NOT_ALIVE = 15, - JVMTI_ERROR_INVALID_OBJECT = 20, - JVMTI_ERROR_INVALID_CLASS = 21, - JVMTI_ERROR_CLASS_NOT_PREPARED = 22, - JVMTI_ERROR_INVALID_METHODID = 23, - JVMTI_ERROR_INVALID_LOCATION = 24, - JVMTI_ERROR_INVALID_FIELDID = 25, - JVMTI_ERROR_NO_MORE_FRAMES = 31, - JVMTI_ERROR_OPAQUE_FRAME = 32, - JVMTI_ERROR_TYPE_MISMATCH = 34, - JVMTI_ERROR_INVALID_SLOT = 35, - JVMTI_ERROR_DUPLICATE = 40, - JVMTI_ERROR_NOT_FOUND = 41, - JVMTI_ERROR_INVALID_MONITOR = 50, - JVMTI_ERROR_NOT_MONITOR_OWNER = 51, - JVMTI_ERROR_INTERRUPT = 52, - JVMTI_ERROR_INVALID_CLASS_FORMAT = 60, - JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION = 61, - JVMTI_ERROR_FAILS_VERIFICATION = 62, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED = 63, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED = 64, - JVMTI_ERROR_INVALID_TYPESTATE = 65, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED = 66, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED = 67, - JVMTI_ERROR_UNSUPPORTED_VERSION = 68, - JVMTI_ERROR_NAMES_DONT_MATCH = 69, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED = 70, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71, - JVMTI_ERROR_UNMODIFIABLE_CLASS = 79, - JVMTI_ERROR_NOT_AVAILABLE = 98, - JVMTI_ERROR_MUST_POSSESS_CAPABILITY = 99, - JVMTI_ERROR_NULL_POINTER = 100, - JVMTI_ERROR_ABSENT_INFORMATION = 101, - JVMTI_ERROR_INVALID_EVENT_TYPE = 102, - JVMTI_ERROR_ILLEGAL_ARGUMENT = 103, - JVMTI_ERROR_NATIVE_METHOD = 104, - JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED = 106, - JVMTI_ERROR_OUT_OF_MEMORY = 110, - JVMTI_ERROR_ACCESS_DENIED = 111, - JVMTI_ERROR_WRONG_PHASE = 112, - JVMTI_ERROR_INTERNAL = 113, - JVMTI_ERROR_UNATTACHED_THREAD = 115, - JVMTI_ERROR_INVALID_ENVIRONMENT = 116, - JVMTI_ERROR_MAX = 116 -} jvmtiError; - - /* Event IDs */ - -typedef enum { - JVMTI_MIN_EVENT_TYPE_VAL = 50, - JVMTI_EVENT_VM_INIT = 50, - JVMTI_EVENT_VM_DEATH = 51, - JVMTI_EVENT_THREAD_START = 52, - JVMTI_EVENT_THREAD_END = 53, - JVMTI_EVENT_CLASS_FILE_LOAD_HOOK = 54, - JVMTI_EVENT_CLASS_LOAD = 55, - JVMTI_EVENT_CLASS_PREPARE = 56, - JVMTI_EVENT_VM_START = 57, - JVMTI_EVENT_EXCEPTION = 58, - JVMTI_EVENT_EXCEPTION_CATCH = 59, - JVMTI_EVENT_SINGLE_STEP = 60, - JVMTI_EVENT_FRAME_POP = 61, - JVMTI_EVENT_BREAKPOINT = 62, - JVMTI_EVENT_FIELD_ACCESS = 63, - JVMTI_EVENT_FIELD_MODIFICATION = 64, - JVMTI_EVENT_METHOD_ENTRY = 65, - JVMTI_EVENT_METHOD_EXIT = 66, - JVMTI_EVENT_NATIVE_METHOD_BIND = 67, - JVMTI_EVENT_COMPILED_METHOD_LOAD = 68, - JVMTI_EVENT_COMPILED_METHOD_UNLOAD = 69, - JVMTI_EVENT_DYNAMIC_CODE_GENERATED = 70, - JVMTI_EVENT_DATA_DUMP_REQUEST = 71, - JVMTI_EVENT_MONITOR_WAIT = 73, - JVMTI_EVENT_MONITOR_WAITED = 74, - JVMTI_EVENT_MONITOR_CONTENDED_ENTER = 75, - JVMTI_EVENT_MONITOR_CONTENDED_ENTERED = 76, - JVMTI_EVENT_RESOURCE_EXHAUSTED = 80, - JVMTI_EVENT_GARBAGE_COLLECTION_START = 81, - JVMTI_EVENT_GARBAGE_COLLECTION_FINISH = 82, - JVMTI_EVENT_OBJECT_FREE = 83, - JVMTI_EVENT_VM_OBJECT_ALLOC = 84, - JVMTI_MAX_EVENT_TYPE_VAL = 84 -} jvmtiEvent; - - - /* Pre-Declarations */ -struct _jvmtiThreadInfo; -typedef struct _jvmtiThreadInfo jvmtiThreadInfo; -struct _jvmtiMonitorStackDepthInfo; -typedef struct _jvmtiMonitorStackDepthInfo jvmtiMonitorStackDepthInfo; -struct _jvmtiThreadGroupInfo; -typedef struct _jvmtiThreadGroupInfo jvmtiThreadGroupInfo; -struct _jvmtiFrameInfo; -typedef struct _jvmtiFrameInfo jvmtiFrameInfo; -struct _jvmtiStackInfo; -typedef struct _jvmtiStackInfo jvmtiStackInfo; -struct _jvmtiHeapReferenceInfoField; -typedef struct _jvmtiHeapReferenceInfoField jvmtiHeapReferenceInfoField; -struct _jvmtiHeapReferenceInfoArray; -typedef struct _jvmtiHeapReferenceInfoArray jvmtiHeapReferenceInfoArray; -struct _jvmtiHeapReferenceInfoConstantPool; -typedef struct _jvmtiHeapReferenceInfoConstantPool jvmtiHeapReferenceInfoConstantPool; -struct _jvmtiHeapReferenceInfoStackLocal; -typedef struct _jvmtiHeapReferenceInfoStackLocal jvmtiHeapReferenceInfoStackLocal; -struct _jvmtiHeapReferenceInfoJniLocal; -typedef struct _jvmtiHeapReferenceInfoJniLocal jvmtiHeapReferenceInfoJniLocal; -struct _jvmtiHeapReferenceInfoReserved; -typedef struct _jvmtiHeapReferenceInfoReserved jvmtiHeapReferenceInfoReserved; -union _jvmtiHeapReferenceInfo; -typedef union _jvmtiHeapReferenceInfo jvmtiHeapReferenceInfo; -struct _jvmtiHeapCallbacks; -typedef struct _jvmtiHeapCallbacks jvmtiHeapCallbacks; -struct _jvmtiClassDefinition; -typedef struct _jvmtiClassDefinition jvmtiClassDefinition; -struct _jvmtiMonitorUsage; -typedef struct _jvmtiMonitorUsage jvmtiMonitorUsage; -struct _jvmtiLineNumberEntry; -typedef struct _jvmtiLineNumberEntry jvmtiLineNumberEntry; -struct _jvmtiLocalVariableEntry; -typedef struct _jvmtiLocalVariableEntry jvmtiLocalVariableEntry; -struct _jvmtiParamInfo; -typedef struct _jvmtiParamInfo jvmtiParamInfo; -struct _jvmtiExtensionFunctionInfo; -typedef struct _jvmtiExtensionFunctionInfo jvmtiExtensionFunctionInfo; -struct _jvmtiExtensionEventInfo; -typedef struct _jvmtiExtensionEventInfo jvmtiExtensionEventInfo; -struct _jvmtiTimerInfo; -typedef struct _jvmtiTimerInfo jvmtiTimerInfo; -struct _jvmtiAddrLocationMap; -typedef struct _jvmtiAddrLocationMap jvmtiAddrLocationMap; - - /* Function Types */ - -typedef void (JNICALL *jvmtiStartFunction) - (jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg); - -typedef jint (JNICALL *jvmtiHeapIterationCallback) - (jlong class_tag, jlong size, jlong* tag_ptr, jint length, void* user_data); - -typedef jint (JNICALL *jvmtiHeapReferenceCallback) - (jvmtiHeapReferenceKind reference_kind, const jvmtiHeapReferenceInfo* reference_info, jlong class_tag, jlong referrer_class_tag, jlong size, jlong* tag_ptr, jlong* referrer_tag_ptr, jint length, void* user_data); - -typedef jint (JNICALL *jvmtiPrimitiveFieldCallback) - (jvmtiHeapReferenceKind kind, const jvmtiHeapReferenceInfo* info, jlong object_class_tag, jlong* object_tag_ptr, jvalue value, jvmtiPrimitiveType value_type, void* user_data); - -typedef jint (JNICALL *jvmtiArrayPrimitiveValueCallback) - (jlong class_tag, jlong size, jlong* tag_ptr, jint element_count, jvmtiPrimitiveType element_type, const void* elements, void* user_data); - -typedef jint (JNICALL *jvmtiStringPrimitiveValueCallback) - (jlong class_tag, jlong size, jlong* tag_ptr, const jchar* value, jint value_length, void* user_data); - -typedef jint (JNICALL *jvmtiReservedCallback) - (); - -typedef jvmtiIterationControl (JNICALL *jvmtiHeapObjectCallback) - (jlong class_tag, jlong size, jlong* tag_ptr, void* user_data); - -typedef jvmtiIterationControl (JNICALL *jvmtiHeapRootCallback) - (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, void* user_data); - -typedef jvmtiIterationControl (JNICALL *jvmtiStackReferenceCallback) - (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong thread_tag, jint depth, jmethodID method, jint slot, void* user_data); - -typedef jvmtiIterationControl (JNICALL *jvmtiObjectReferenceCallback) - (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data); - -typedef jvmtiError (JNICALL *jvmtiExtensionFunction) - (jvmtiEnv* jvmti_env, ...); - -typedef void (JNICALL *jvmtiExtensionEvent) - (jvmtiEnv* jvmti_env, ...); - - - /* Structure Types */ -struct _jvmtiThreadInfo { - char* name; - jint priority; - jboolean is_daemon; - jthreadGroup thread_group; - jobject context_class_loader; -}; -struct _jvmtiMonitorStackDepthInfo { - jobject monitor; - jint stack_depth; -}; -struct _jvmtiThreadGroupInfo { - jthreadGroup parent; - char* name; - jint max_priority; - jboolean is_daemon; -}; -struct _jvmtiFrameInfo { - jmethodID method; - jlocation location; -}; -struct _jvmtiStackInfo { - jthread thread; - jint state; - jvmtiFrameInfo* frame_buffer; - jint frame_count; -}; -struct _jvmtiHeapReferenceInfoField { - jint index; -}; -struct _jvmtiHeapReferenceInfoArray { - jint index; -}; -struct _jvmtiHeapReferenceInfoConstantPool { - jint index; -}; -struct _jvmtiHeapReferenceInfoStackLocal { - jlong thread_tag; - jlong thread_id; - jint depth; - jmethodID method; - jlocation location; - jint slot; -}; -struct _jvmtiHeapReferenceInfoJniLocal { - jlong thread_tag; - jlong thread_id; - jint depth; - jmethodID method; -}; -struct _jvmtiHeapReferenceInfoReserved { - jlong reserved1; - jlong reserved2; - jlong reserved3; - jlong reserved4; - jlong reserved5; - jlong reserved6; - jlong reserved7; - jlong reserved8; -}; -union _jvmtiHeapReferenceInfo { - jvmtiHeapReferenceInfoField field; - jvmtiHeapReferenceInfoArray array; - jvmtiHeapReferenceInfoConstantPool constant_pool; - jvmtiHeapReferenceInfoStackLocal stack_local; - jvmtiHeapReferenceInfoJniLocal jni_local; - jvmtiHeapReferenceInfoReserved other; -}; -struct _jvmtiHeapCallbacks { - jvmtiHeapIterationCallback heap_iteration_callback; - jvmtiHeapReferenceCallback heap_reference_callback; - jvmtiPrimitiveFieldCallback primitive_field_callback; - jvmtiArrayPrimitiveValueCallback array_primitive_value_callback; - jvmtiStringPrimitiveValueCallback string_primitive_value_callback; - jvmtiReservedCallback reserved5; - jvmtiReservedCallback reserved6; - jvmtiReservedCallback reserved7; - jvmtiReservedCallback reserved8; - jvmtiReservedCallback reserved9; - jvmtiReservedCallback reserved10; - jvmtiReservedCallback reserved11; - jvmtiReservedCallback reserved12; - jvmtiReservedCallback reserved13; - jvmtiReservedCallback reserved14; - jvmtiReservedCallback reserved15; -}; -struct _jvmtiClassDefinition { - jclass klass; - jint class_byte_count; - const unsigned char* class_bytes; -}; -struct _jvmtiMonitorUsage { - jthread owner; - jint entry_count; - jint waiter_count; - jthread* waiters; - jint notify_waiter_count; - jthread* notify_waiters; -}; -struct _jvmtiLineNumberEntry { - jlocation start_location; - jint line_number; -}; -struct _jvmtiLocalVariableEntry { - jlocation start_location; - jint length; - char* name; - char* signature; - char* generic_signature; - jint slot; -}; -struct _jvmtiParamInfo { - char* name; - jvmtiParamKind kind; - jvmtiParamTypes base_type; - jboolean null_ok; -}; -struct _jvmtiExtensionFunctionInfo { - jvmtiExtensionFunction func; - char* id; - char* short_description; - jint param_count; - jvmtiParamInfo* params; - jint error_count; - jvmtiError* errors; -}; -struct _jvmtiExtensionEventInfo { - jint extension_event_index; - char* id; - char* short_description; - jint param_count; - jvmtiParamInfo* params; -}; -struct _jvmtiTimerInfo { - jlong max_value; - jboolean may_skip_forward; - jboolean may_skip_backward; - jvmtiTimerKind kind; - jlong reserved1; - jlong reserved2; -}; -struct _jvmtiAddrLocationMap { - const void* start_address; - jlocation location; -}; - -typedef struct { - unsigned int can_tag_objects : 1; - unsigned int can_generate_field_modification_events : 1; - unsigned int can_generate_field_access_events : 1; - unsigned int can_get_bytecodes : 1; - unsigned int can_get_synthetic_attribute : 1; - unsigned int can_get_owned_monitor_info : 1; - unsigned int can_get_current_contended_monitor : 1; - unsigned int can_get_monitor_info : 1; - unsigned int can_pop_frame : 1; - unsigned int can_redefine_classes : 1; - unsigned int can_signal_thread : 1; - unsigned int can_get_source_file_name : 1; - unsigned int can_get_line_numbers : 1; - unsigned int can_get_source_debug_extension : 1; - unsigned int can_access_local_variables : 1; - unsigned int can_maintain_original_method_order : 1; - unsigned int can_generate_single_step_events : 1; - unsigned int can_generate_exception_events : 1; - unsigned int can_generate_frame_pop_events : 1; - unsigned int can_generate_breakpoint_events : 1; - unsigned int can_suspend : 1; - unsigned int can_redefine_any_class : 1; - unsigned int can_get_current_thread_cpu_time : 1; - unsigned int can_get_thread_cpu_time : 1; - unsigned int can_generate_method_entry_events : 1; - unsigned int can_generate_method_exit_events : 1; - unsigned int can_generate_all_class_hook_events : 1; - unsigned int can_generate_compiled_method_load_events : 1; - unsigned int can_generate_monitor_events : 1; - unsigned int can_generate_vm_object_alloc_events : 1; - unsigned int can_generate_native_method_bind_events : 1; - unsigned int can_generate_garbage_collection_events : 1; - unsigned int can_generate_object_free_events : 1; - unsigned int can_force_early_return : 1; - unsigned int can_get_owned_monitor_stack_depth_info : 1; - unsigned int can_get_constant_pool : 1; - unsigned int can_set_native_method_prefix : 1; - unsigned int can_retransform_classes : 1; - unsigned int can_retransform_any_class : 1; - unsigned int can_generate_resource_exhaustion_heap_events : 1; - unsigned int can_generate_resource_exhaustion_threads_events : 1; - unsigned int : 7; - unsigned int : 16; - unsigned int : 16; - unsigned int : 16; - unsigned int : 16; - unsigned int : 16; -} jvmtiCapabilities; - - - /* Event Definitions */ - -typedef void (JNICALL *jvmtiEventReserved)(void); - - -typedef void (JNICALL *jvmtiEventBreakpoint) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location); - -typedef void (JNICALL *jvmtiEventClassFileLoadHook) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jclass class_being_redefined, - jobject loader, - const char* name, - jobject protection_domain, - jint class_data_len, - const unsigned char* class_data, - jint* new_class_data_len, - unsigned char** new_class_data); - -typedef void (JNICALL *jvmtiEventClassLoad) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jclass klass); - -typedef void (JNICALL *jvmtiEventClassPrepare) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jclass klass); - -typedef void (JNICALL *jvmtiEventCompiledMethodLoad) - (jvmtiEnv *jvmti_env, - jmethodID method, - jint code_size, - const void* code_addr, - jint map_length, - const jvmtiAddrLocationMap* map, - const void* compile_info); - -typedef void (JNICALL *jvmtiEventCompiledMethodUnload) - (jvmtiEnv *jvmti_env, - jmethodID method, - const void* code_addr); - -typedef void (JNICALL *jvmtiEventDataDumpRequest) - (jvmtiEnv *jvmti_env); - -typedef void (JNICALL *jvmtiEventDynamicCodeGenerated) - (jvmtiEnv *jvmti_env, - const char* name, - const void* address, - jint length); - -typedef void (JNICALL *jvmtiEventException) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location, - jobject exception, - jmethodID catch_method, - jlocation catch_location); - -typedef void (JNICALL *jvmtiEventExceptionCatch) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location, - jobject exception); - -typedef void (JNICALL *jvmtiEventFieldAccess) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location, - jclass field_klass, - jobject object, - jfieldID field); - -typedef void (JNICALL *jvmtiEventFieldModification) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location, - jclass field_klass, - jobject object, - jfieldID field, - char signature_type, - jvalue new_value); - -typedef void (JNICALL *jvmtiEventFramePop) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jboolean was_popped_by_exception); - -typedef void (JNICALL *jvmtiEventGarbageCollectionFinish) - (jvmtiEnv *jvmti_env); - -typedef void (JNICALL *jvmtiEventGarbageCollectionStart) - (jvmtiEnv *jvmti_env); - -typedef void (JNICALL *jvmtiEventMethodEntry) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method); - -typedef void (JNICALL *jvmtiEventMethodExit) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jboolean was_popped_by_exception, - jvalue return_value); - -typedef void (JNICALL *jvmtiEventMonitorContendedEnter) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object); - -typedef void (JNICALL *jvmtiEventMonitorContendedEntered) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object); - -typedef void (JNICALL *jvmtiEventMonitorWait) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object, - jlong timeout); - -typedef void (JNICALL *jvmtiEventMonitorWaited) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object, - jboolean timed_out); - -typedef void (JNICALL *jvmtiEventNativeMethodBind) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - void* address, - void** new_address_ptr); - -typedef void (JNICALL *jvmtiEventObjectFree) - (jvmtiEnv *jvmti_env, - jlong tag); - -typedef void (JNICALL *jvmtiEventResourceExhausted) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jint flags, - const void* reserved, - const char* description); - -typedef void (JNICALL *jvmtiEventSingleStep) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jmethodID method, - jlocation location); - -typedef void (JNICALL *jvmtiEventThreadEnd) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread); - -typedef void (JNICALL *jvmtiEventThreadStart) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread); - -typedef void (JNICALL *jvmtiEventVMDeath) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env); - -typedef void (JNICALL *jvmtiEventVMInit) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread); - -typedef void (JNICALL *jvmtiEventVMObjectAlloc) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env, - jthread thread, - jobject object, - jclass object_klass, - jlong size); - -typedef void (JNICALL *jvmtiEventVMStart) - (jvmtiEnv *jvmti_env, - JNIEnv* jni_env); - - /* Event Callback Structure */ - -typedef struct { - /* 50 : VM Initialization Event */ - jvmtiEventVMInit VMInit; - /* 51 : VM Death Event */ - jvmtiEventVMDeath VMDeath; - /* 52 : Thread Start */ - jvmtiEventThreadStart ThreadStart; - /* 53 : Thread End */ - jvmtiEventThreadEnd ThreadEnd; - /* 54 : Class File Load Hook */ - jvmtiEventClassFileLoadHook ClassFileLoadHook; - /* 55 : Class Load */ - jvmtiEventClassLoad ClassLoad; - /* 56 : Class Prepare */ - jvmtiEventClassPrepare ClassPrepare; - /* 57 : VM Start Event */ - jvmtiEventVMStart VMStart; - /* 58 : Exception */ - jvmtiEventException Exception; - /* 59 : Exception Catch */ - jvmtiEventExceptionCatch ExceptionCatch; - /* 60 : Single Step */ - jvmtiEventSingleStep SingleStep; - /* 61 : Frame Pop */ - jvmtiEventFramePop FramePop; - /* 62 : Breakpoint */ - jvmtiEventBreakpoint Breakpoint; - /* 63 : Field Access */ - jvmtiEventFieldAccess FieldAccess; - /* 64 : Field Modification */ - jvmtiEventFieldModification FieldModification; - /* 65 : Method Entry */ - jvmtiEventMethodEntry MethodEntry; - /* 66 : Method Exit */ - jvmtiEventMethodExit MethodExit; - /* 67 : Native Method Bind */ - jvmtiEventNativeMethodBind NativeMethodBind; - /* 68 : Compiled Method Load */ - jvmtiEventCompiledMethodLoad CompiledMethodLoad; - /* 69 : Compiled Method Unload */ - jvmtiEventCompiledMethodUnload CompiledMethodUnload; - /* 70 : Dynamic Code Generated */ - jvmtiEventDynamicCodeGenerated DynamicCodeGenerated; - /* 71 : Data Dump Request */ - jvmtiEventDataDumpRequest DataDumpRequest; - /* 72 */ - jvmtiEventReserved reserved72; - /* 73 : Monitor Wait */ - jvmtiEventMonitorWait MonitorWait; - /* 74 : Monitor Waited */ - jvmtiEventMonitorWaited MonitorWaited; - /* 75 : Monitor Contended Enter */ - jvmtiEventMonitorContendedEnter MonitorContendedEnter; - /* 76 : Monitor Contended Entered */ - jvmtiEventMonitorContendedEntered MonitorContendedEntered; - /* 77 */ - jvmtiEventReserved reserved77; - /* 78 */ - jvmtiEventReserved reserved78; - /* 79 */ - jvmtiEventReserved reserved79; - /* 80 : Resource Exhausted */ - jvmtiEventResourceExhausted ResourceExhausted; - /* 81 : Garbage Collection Start */ - jvmtiEventGarbageCollectionStart GarbageCollectionStart; - /* 82 : Garbage Collection Finish */ - jvmtiEventGarbageCollectionFinish GarbageCollectionFinish; - /* 83 : Object Free */ - jvmtiEventObjectFree ObjectFree; - /* 84 : VM Object Allocation */ - jvmtiEventVMObjectAlloc VMObjectAlloc; -} jvmtiEventCallbacks; - - - /* Function Interface */ - -typedef struct jvmtiInterface_1_ { - - /* 1 : RESERVED */ - void *reserved1; - - /* 2 : Set Event Notification Mode */ - jvmtiError (JNICALL *SetEventNotificationMode) (jvmtiEnv* env, - jvmtiEventMode mode, - jvmtiEvent event_type, - jthread event_thread, - ...); - - /* 3 : RESERVED */ - void *reserved3; - - /* 4 : Get All Threads */ - jvmtiError (JNICALL *GetAllThreads) (jvmtiEnv* env, - jint* threads_count_ptr, - jthread** threads_ptr); - - /* 5 : Suspend Thread */ - jvmtiError (JNICALL *SuspendThread) (jvmtiEnv* env, - jthread thread); - - /* 6 : Resume Thread */ - jvmtiError (JNICALL *ResumeThread) (jvmtiEnv* env, - jthread thread); - - /* 7 : Stop Thread */ - jvmtiError (JNICALL *StopThread) (jvmtiEnv* env, - jthread thread, - jobject exception); - - /* 8 : Interrupt Thread */ - jvmtiError (JNICALL *InterruptThread) (jvmtiEnv* env, - jthread thread); - - /* 9 : Get Thread Info */ - jvmtiError (JNICALL *GetThreadInfo) (jvmtiEnv* env, - jthread thread, - jvmtiThreadInfo* info_ptr); - - /* 10 : Get Owned Monitor Info */ - jvmtiError (JNICALL *GetOwnedMonitorInfo) (jvmtiEnv* env, - jthread thread, - jint* owned_monitor_count_ptr, - jobject** owned_monitors_ptr); - - /* 11 : Get Current Contended Monitor */ - jvmtiError (JNICALL *GetCurrentContendedMonitor) (jvmtiEnv* env, - jthread thread, - jobject* monitor_ptr); - - /* 12 : Run Agent Thread */ - jvmtiError (JNICALL *RunAgentThread) (jvmtiEnv* env, - jthread thread, - jvmtiStartFunction proc, - const void* arg, - jint priority); - - /* 13 : Get Top Thread Groups */ - jvmtiError (JNICALL *GetTopThreadGroups) (jvmtiEnv* env, - jint* group_count_ptr, - jthreadGroup** groups_ptr); - - /* 14 : Get Thread Group Info */ - jvmtiError (JNICALL *GetThreadGroupInfo) (jvmtiEnv* env, - jthreadGroup group, - jvmtiThreadGroupInfo* info_ptr); - - /* 15 : Get Thread Group Children */ - jvmtiError (JNICALL *GetThreadGroupChildren) (jvmtiEnv* env, - jthreadGroup group, - jint* thread_count_ptr, - jthread** threads_ptr, - jint* group_count_ptr, - jthreadGroup** groups_ptr); - - /* 16 : Get Frame Count */ - jvmtiError (JNICALL *GetFrameCount) (jvmtiEnv* env, - jthread thread, - jint* count_ptr); - - /* 17 : Get Thread State */ - jvmtiError (JNICALL *GetThreadState) (jvmtiEnv* env, - jthread thread, - jint* thread_state_ptr); - - /* 18 : Get Current Thread */ - jvmtiError (JNICALL *GetCurrentThread) (jvmtiEnv* env, - jthread* thread_ptr); - - /* 19 : Get Frame Location */ - jvmtiError (JNICALL *GetFrameLocation) (jvmtiEnv* env, - jthread thread, - jint depth, - jmethodID* method_ptr, - jlocation* location_ptr); - - /* 20 : Notify Frame Pop */ - jvmtiError (JNICALL *NotifyFramePop) (jvmtiEnv* env, - jthread thread, - jint depth); - - /* 21 : Get Local Variable - Object */ - jvmtiError (JNICALL *GetLocalObject) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jobject* value_ptr); - - /* 22 : Get Local Variable - Int */ - jvmtiError (JNICALL *GetLocalInt) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jint* value_ptr); - - /* 23 : Get Local Variable - Long */ - jvmtiError (JNICALL *GetLocalLong) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jlong* value_ptr); - - /* 24 : Get Local Variable - Float */ - jvmtiError (JNICALL *GetLocalFloat) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jfloat* value_ptr); - - /* 25 : Get Local Variable - Double */ - jvmtiError (JNICALL *GetLocalDouble) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jdouble* value_ptr); - - /* 26 : Set Local Variable - Object */ - jvmtiError (JNICALL *SetLocalObject) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jobject value); - - /* 27 : Set Local Variable - Int */ - jvmtiError (JNICALL *SetLocalInt) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jint value); - - /* 28 : Set Local Variable - Long */ - jvmtiError (JNICALL *SetLocalLong) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jlong value); - - /* 29 : Set Local Variable - Float */ - jvmtiError (JNICALL *SetLocalFloat) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jfloat value); - - /* 30 : Set Local Variable - Double */ - jvmtiError (JNICALL *SetLocalDouble) (jvmtiEnv* env, - jthread thread, - jint depth, - jint slot, - jdouble value); - - /* 31 : Create Raw Monitor */ - jvmtiError (JNICALL *CreateRawMonitor) (jvmtiEnv* env, - const char* name, - jrawMonitorID* monitor_ptr); - - /* 32 : Destroy Raw Monitor */ - jvmtiError (JNICALL *DestroyRawMonitor) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 33 : Raw Monitor Enter */ - jvmtiError (JNICALL *RawMonitorEnter) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 34 : Raw Monitor Exit */ - jvmtiError (JNICALL *RawMonitorExit) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 35 : Raw Monitor Wait */ - jvmtiError (JNICALL *RawMonitorWait) (jvmtiEnv* env, - jrawMonitorID monitor, - jlong millis); - - /* 36 : Raw Monitor Notify */ - jvmtiError (JNICALL *RawMonitorNotify) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 37 : Raw Monitor Notify All */ - jvmtiError (JNICALL *RawMonitorNotifyAll) (jvmtiEnv* env, - jrawMonitorID monitor); - - /* 38 : Set Breakpoint */ - jvmtiError (JNICALL *SetBreakpoint) (jvmtiEnv* env, - jmethodID method, - jlocation location); - - /* 39 : Clear Breakpoint */ - jvmtiError (JNICALL *ClearBreakpoint) (jvmtiEnv* env, - jmethodID method, - jlocation location); - - /* 40 : RESERVED */ - void *reserved40; - - /* 41 : Set Field Access Watch */ - jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv* env, - jclass klass, - jfieldID field); - - /* 42 : Clear Field Access Watch */ - jvmtiError (JNICALL *ClearFieldAccessWatch) (jvmtiEnv* env, - jclass klass, - jfieldID field); - - /* 43 : Set Field Modification Watch */ - jvmtiError (JNICALL *SetFieldModificationWatch) (jvmtiEnv* env, - jclass klass, - jfieldID field); - - /* 44 : Clear Field Modification Watch */ - jvmtiError (JNICALL *ClearFieldModificationWatch) (jvmtiEnv* env, - jclass klass, - jfieldID field); - - /* 45 : Is Modifiable Class */ - jvmtiError (JNICALL *IsModifiableClass) (jvmtiEnv* env, - jclass klass, - jboolean* is_modifiable_class_ptr); - - /* 46 : Allocate */ - jvmtiError (JNICALL *Allocate) (jvmtiEnv* env, - jlong size, - unsigned char** mem_ptr); - - /* 47 : Deallocate */ - jvmtiError (JNICALL *Deallocate) (jvmtiEnv* env, - unsigned char* mem); - - /* 48 : Get Class Signature */ - jvmtiError (JNICALL *GetClassSignature) (jvmtiEnv* env, - jclass klass, - char** signature_ptr, - char** generic_ptr); - - /* 49 : Get Class Status */ - jvmtiError (JNICALL *GetClassStatus) (jvmtiEnv* env, - jclass klass, - jint* status_ptr); - - /* 50 : Get Source File Name */ - jvmtiError (JNICALL *GetSourceFileName) (jvmtiEnv* env, - jclass klass, - char** source_name_ptr); - - /* 51 : Get Class Modifiers */ - jvmtiError (JNICALL *GetClassModifiers) (jvmtiEnv* env, - jclass klass, - jint* modifiers_ptr); - - /* 52 : Get Class Methods */ - jvmtiError (JNICALL *GetClassMethods) (jvmtiEnv* env, - jclass klass, - jint* method_count_ptr, - jmethodID** methods_ptr); - - /* 53 : Get Class Fields */ - jvmtiError (JNICALL *GetClassFields) (jvmtiEnv* env, - jclass klass, - jint* field_count_ptr, - jfieldID** fields_ptr); - - /* 54 : Get Implemented Interfaces */ - jvmtiError (JNICALL *GetImplementedInterfaces) (jvmtiEnv* env, - jclass klass, - jint* interface_count_ptr, - jclass** interfaces_ptr); - - /* 55 : Is Interface */ - jvmtiError (JNICALL *IsInterface) (jvmtiEnv* env, - jclass klass, - jboolean* is_interface_ptr); - - /* 56 : Is Array Class */ - jvmtiError (JNICALL *IsArrayClass) (jvmtiEnv* env, - jclass klass, - jboolean* is_array_class_ptr); - - /* 57 : Get Class Loader */ - jvmtiError (JNICALL *GetClassLoader) (jvmtiEnv* env, - jclass klass, - jobject* classloader_ptr); - - /* 58 : Get Object Hash Code */ - jvmtiError (JNICALL *GetObjectHashCode) (jvmtiEnv* env, - jobject object, - jint* hash_code_ptr); - - /* 59 : Get Object Monitor Usage */ - jvmtiError (JNICALL *GetObjectMonitorUsage) (jvmtiEnv* env, - jobject object, - jvmtiMonitorUsage* info_ptr); - - /* 60 : Get Field Name (and Signature) */ - jvmtiError (JNICALL *GetFieldName) (jvmtiEnv* env, - jclass klass, - jfieldID field, - char** name_ptr, - char** signature_ptr, - char** generic_ptr); - - /* 61 : Get Field Declaring Class */ - jvmtiError (JNICALL *GetFieldDeclaringClass) (jvmtiEnv* env, - jclass klass, - jfieldID field, - jclass* declaring_class_ptr); - - /* 62 : Get Field Modifiers */ - jvmtiError (JNICALL *GetFieldModifiers) (jvmtiEnv* env, - jclass klass, - jfieldID field, - jint* modifiers_ptr); - - /* 63 : Is Field Synthetic */ - jvmtiError (JNICALL *IsFieldSynthetic) (jvmtiEnv* env, - jclass klass, - jfieldID field, - jboolean* is_synthetic_ptr); - - /* 64 : Get Method Name (and Signature) */ - jvmtiError (JNICALL *GetMethodName) (jvmtiEnv* env, - jmethodID method, - char** name_ptr, - char** signature_ptr, - char** generic_ptr); - - /* 65 : Get Method Declaring Class */ - jvmtiError (JNICALL *GetMethodDeclaringClass) (jvmtiEnv* env, - jmethodID method, - jclass* declaring_class_ptr); - - /* 66 : Get Method Modifiers */ - jvmtiError (JNICALL *GetMethodModifiers) (jvmtiEnv* env, - jmethodID method, - jint* modifiers_ptr); - - /* 67 : RESERVED */ - void *reserved67; - - /* 68 : Get Max Locals */ - jvmtiError (JNICALL *GetMaxLocals) (jvmtiEnv* env, - jmethodID method, - jint* max_ptr); - - /* 69 : Get Arguments Size */ - jvmtiError (JNICALL *GetArgumentsSize) (jvmtiEnv* env, - jmethodID method, - jint* size_ptr); - - /* 70 : Get Line Number Table */ - jvmtiError (JNICALL *GetLineNumberTable) (jvmtiEnv* env, - jmethodID method, - jint* entry_count_ptr, - jvmtiLineNumberEntry** table_ptr); - - /* 71 : Get Method Location */ - jvmtiError (JNICALL *GetMethodLocation) (jvmtiEnv* env, - jmethodID method, - jlocation* start_location_ptr, - jlocation* end_location_ptr); - - /* 72 : Get Local Variable Table */ - jvmtiError (JNICALL *GetLocalVariableTable) (jvmtiEnv* env, - jmethodID method, - jint* entry_count_ptr, - jvmtiLocalVariableEntry** table_ptr); - - /* 73 : Set Native Method Prefix */ - jvmtiError (JNICALL *SetNativeMethodPrefix) (jvmtiEnv* env, - const char* prefix); - - /* 74 : Set Native Method Prefixes */ - jvmtiError (JNICALL *SetNativeMethodPrefixes) (jvmtiEnv* env, - jint prefix_count, - char** prefixes); - - /* 75 : Get Bytecodes */ - jvmtiError (JNICALL *GetBytecodes) (jvmtiEnv* env, - jmethodID method, - jint* bytecode_count_ptr, - unsigned char** bytecodes_ptr); - - /* 76 : Is Method Native */ - jvmtiError (JNICALL *IsMethodNative) (jvmtiEnv* env, - jmethodID method, - jboolean* is_native_ptr); - - /* 77 : Is Method Synthetic */ - jvmtiError (JNICALL *IsMethodSynthetic) (jvmtiEnv* env, - jmethodID method, - jboolean* is_synthetic_ptr); - - /* 78 : Get Loaded Classes */ - jvmtiError (JNICALL *GetLoadedClasses) (jvmtiEnv* env, - jint* class_count_ptr, - jclass** classes_ptr); - - /* 79 : Get Classloader Classes */ - jvmtiError (JNICALL *GetClassLoaderClasses) (jvmtiEnv* env, - jobject initiating_loader, - jint* class_count_ptr, - jclass** classes_ptr); - - /* 80 : Pop Frame */ - jvmtiError (JNICALL *PopFrame) (jvmtiEnv* env, - jthread thread); - - /* 81 : Force Early Return - Object */ - jvmtiError (JNICALL *ForceEarlyReturnObject) (jvmtiEnv* env, - jthread thread, - jobject value); - - /* 82 : Force Early Return - Int */ - jvmtiError (JNICALL *ForceEarlyReturnInt) (jvmtiEnv* env, - jthread thread, - jint value); - - /* 83 : Force Early Return - Long */ - jvmtiError (JNICALL *ForceEarlyReturnLong) (jvmtiEnv* env, - jthread thread, - jlong value); - - /* 84 : Force Early Return - Float */ - jvmtiError (JNICALL *ForceEarlyReturnFloat) (jvmtiEnv* env, - jthread thread, - jfloat value); - - /* 85 : Force Early Return - Double */ - jvmtiError (JNICALL *ForceEarlyReturnDouble) (jvmtiEnv* env, - jthread thread, - jdouble value); - - /* 86 : Force Early Return - Void */ - jvmtiError (JNICALL *ForceEarlyReturnVoid) (jvmtiEnv* env, - jthread thread); - - /* 87 : Redefine Classes */ - jvmtiError (JNICALL *RedefineClasses) (jvmtiEnv* env, - jint class_count, - const jvmtiClassDefinition* class_definitions); - - /* 88 : Get Version Number */ - jvmtiError (JNICALL *GetVersionNumber) (jvmtiEnv* env, - jint* version_ptr); - - /* 89 : Get Capabilities */ - jvmtiError (JNICALL *GetCapabilities) (jvmtiEnv* env, - jvmtiCapabilities* capabilities_ptr); - - /* 90 : Get Source Debug Extension */ - jvmtiError (JNICALL *GetSourceDebugExtension) (jvmtiEnv* env, - jclass klass, - char** source_debug_extension_ptr); - - /* 91 : Is Method Obsolete */ - jvmtiError (JNICALL *IsMethodObsolete) (jvmtiEnv* env, - jmethodID method, - jboolean* is_obsolete_ptr); - - /* 92 : Suspend Thread List */ - jvmtiError (JNICALL *SuspendThreadList) (jvmtiEnv* env, - jint request_count, - const jthread* request_list, - jvmtiError* results); - - /* 93 : Resume Thread List */ - jvmtiError (JNICALL *ResumeThreadList) (jvmtiEnv* env, - jint request_count, - const jthread* request_list, - jvmtiError* results); - - /* 94 : RESERVED */ - void *reserved94; - - /* 95 : RESERVED */ - void *reserved95; - - /* 96 : RESERVED */ - void *reserved96; - - /* 97 : RESERVED */ - void *reserved97; - - /* 98 : RESERVED */ - void *reserved98; - - /* 99 : RESERVED */ - void *reserved99; - - /* 100 : Get All Stack Traces */ - jvmtiError (JNICALL *GetAllStackTraces) (jvmtiEnv* env, - jint max_frame_count, - jvmtiStackInfo** stack_info_ptr, - jint* thread_count_ptr); - - /* 101 : Get Thread List Stack Traces */ - jvmtiError (JNICALL *GetThreadListStackTraces) (jvmtiEnv* env, - jint thread_count, - const jthread* thread_list, - jint max_frame_count, - jvmtiStackInfo** stack_info_ptr); - - /* 102 : Get Thread Local Storage */ - jvmtiError (JNICALL *GetThreadLocalStorage) (jvmtiEnv* env, - jthread thread, - void** data_ptr); - - /* 103 : Set Thread Local Storage */ - jvmtiError (JNICALL *SetThreadLocalStorage) (jvmtiEnv* env, - jthread thread, - const void* data); - - /* 104 : Get Stack Trace */ - jvmtiError (JNICALL *GetStackTrace) (jvmtiEnv* env, - jthread thread, - jint start_depth, - jint max_frame_count, - jvmtiFrameInfo* frame_buffer, - jint* count_ptr); - - /* 105 : RESERVED */ - void *reserved105; - - /* 106 : Get Tag */ - jvmtiError (JNICALL *GetTag) (jvmtiEnv* env, - jobject object, - jlong* tag_ptr); - - /* 107 : Set Tag */ - jvmtiError (JNICALL *SetTag) (jvmtiEnv* env, - jobject object, - jlong tag); - - /* 108 : Force Garbage Collection */ - jvmtiError (JNICALL *ForceGarbageCollection) (jvmtiEnv* env); - - /* 109 : Iterate Over Objects Reachable From Object */ - jvmtiError (JNICALL *IterateOverObjectsReachableFromObject) (jvmtiEnv* env, - jobject object, - jvmtiObjectReferenceCallback object_reference_callback, - const void* user_data); - - /* 110 : Iterate Over Reachable Objects */ - jvmtiError (JNICALL *IterateOverReachableObjects) (jvmtiEnv* env, - jvmtiHeapRootCallback heap_root_callback, - jvmtiStackReferenceCallback stack_ref_callback, - jvmtiObjectReferenceCallback object_ref_callback, - const void* user_data); - - /* 111 : Iterate Over Heap */ - jvmtiError (JNICALL *IterateOverHeap) (jvmtiEnv* env, - jvmtiHeapObjectFilter object_filter, - jvmtiHeapObjectCallback heap_object_callback, - const void* user_data); - - /* 112 : Iterate Over Instances Of Class */ - jvmtiError (JNICALL *IterateOverInstancesOfClass) (jvmtiEnv* env, - jclass klass, - jvmtiHeapObjectFilter object_filter, - jvmtiHeapObjectCallback heap_object_callback, - const void* user_data); - - /* 113 : RESERVED */ - void *reserved113; - - /* 114 : Get Objects With Tags */ - jvmtiError (JNICALL *GetObjectsWithTags) (jvmtiEnv* env, - jint tag_count, - const jlong* tags, - jint* count_ptr, - jobject** object_result_ptr, - jlong** tag_result_ptr); - - /* 115 : Follow References */ - jvmtiError (JNICALL *FollowReferences) (jvmtiEnv* env, - jint heap_filter, - jclass klass, - jobject initial_object, - const jvmtiHeapCallbacks* callbacks, - const void* user_data); - - /* 116 : Iterate Through Heap */ - jvmtiError (JNICALL *IterateThroughHeap) (jvmtiEnv* env, - jint heap_filter, - jclass klass, - const jvmtiHeapCallbacks* callbacks, - const void* user_data); - - /* 117 : RESERVED */ - void *reserved117; - - /* 118 : RESERVED */ - void *reserved118; - - /* 119 : RESERVED */ - void *reserved119; - - /* 120 : Set JNI Function Table */ - jvmtiError (JNICALL *SetJNIFunctionTable) (jvmtiEnv* env, - const jniNativeInterface* function_table); - - /* 121 : Get JNI Function Table */ - jvmtiError (JNICALL *GetJNIFunctionTable) (jvmtiEnv* env, - jniNativeInterface** function_table); - - /* 122 : Set Event Callbacks */ - jvmtiError (JNICALL *SetEventCallbacks) (jvmtiEnv* env, - const jvmtiEventCallbacks* callbacks, - jint size_of_callbacks); - - /* 123 : Generate Events */ - jvmtiError (JNICALL *GenerateEvents) (jvmtiEnv* env, - jvmtiEvent event_type); - - /* 124 : Get Extension Functions */ - jvmtiError (JNICALL *GetExtensionFunctions) (jvmtiEnv* env, - jint* extension_count_ptr, - jvmtiExtensionFunctionInfo** extensions); - - /* 125 : Get Extension Events */ - jvmtiError (JNICALL *GetExtensionEvents) (jvmtiEnv* env, - jint* extension_count_ptr, - jvmtiExtensionEventInfo** extensions); - - /* 126 : Set Extension Event Callback */ - jvmtiError (JNICALL *SetExtensionEventCallback) (jvmtiEnv* env, - jint extension_event_index, - jvmtiExtensionEvent callback); - - /* 127 : Dispose Environment */ - jvmtiError (JNICALL *DisposeEnvironment) (jvmtiEnv* env); - - /* 128 : Get Error Name */ - jvmtiError (JNICALL *GetErrorName) (jvmtiEnv* env, - jvmtiError error, - char** name_ptr); - - /* 129 : Get JLocation Format */ - jvmtiError (JNICALL *GetJLocationFormat) (jvmtiEnv* env, - jvmtiJlocationFormat* format_ptr); - - /* 130 : Get System Properties */ - jvmtiError (JNICALL *GetSystemProperties) (jvmtiEnv* env, - jint* count_ptr, - char*** property_ptr); - - /* 131 : Get System Property */ - jvmtiError (JNICALL *GetSystemProperty) (jvmtiEnv* env, - const char* property, - char** value_ptr); - - /* 132 : Set System Property */ - jvmtiError (JNICALL *SetSystemProperty) (jvmtiEnv* env, - const char* property, - const char* value); - - /* 133 : Get Phase */ - jvmtiError (JNICALL *GetPhase) (jvmtiEnv* env, - jvmtiPhase* phase_ptr); - - /* 134 : Get Current Thread CPU Timer Information */ - jvmtiError (JNICALL *GetCurrentThreadCpuTimerInfo) (jvmtiEnv* env, - jvmtiTimerInfo* info_ptr); - - /* 135 : Get Current Thread CPU Time */ - jvmtiError (JNICALL *GetCurrentThreadCpuTime) (jvmtiEnv* env, - jlong* nanos_ptr); - - /* 136 : Get Thread CPU Timer Information */ - jvmtiError (JNICALL *GetThreadCpuTimerInfo) (jvmtiEnv* env, - jvmtiTimerInfo* info_ptr); - - /* 137 : Get Thread CPU Time */ - jvmtiError (JNICALL *GetThreadCpuTime) (jvmtiEnv* env, - jthread thread, - jlong* nanos_ptr); - - /* 138 : Get Timer Information */ - jvmtiError (JNICALL *GetTimerInfo) (jvmtiEnv* env, - jvmtiTimerInfo* info_ptr); - - /* 139 : Get Time */ - jvmtiError (JNICALL *GetTime) (jvmtiEnv* env, - jlong* nanos_ptr); - - /* 140 : Get Potential Capabilities */ - jvmtiError (JNICALL *GetPotentialCapabilities) (jvmtiEnv* env, - jvmtiCapabilities* capabilities_ptr); - - /* 141 : RESERVED */ - void *reserved141; - - /* 142 : Add Capabilities */ - jvmtiError (JNICALL *AddCapabilities) (jvmtiEnv* env, - const jvmtiCapabilities* capabilities_ptr); - - /* 143 : Relinquish Capabilities */ - jvmtiError (JNICALL *RelinquishCapabilities) (jvmtiEnv* env, - const jvmtiCapabilities* capabilities_ptr); - - /* 144 : Get Available Processors */ - jvmtiError (JNICALL *GetAvailableProcessors) (jvmtiEnv* env, - jint* processor_count_ptr); - - /* 145 : Get Class Version Numbers */ - jvmtiError (JNICALL *GetClassVersionNumbers) (jvmtiEnv* env, - jclass klass, - jint* minor_version_ptr, - jint* major_version_ptr); - - /* 146 : Get Constant Pool */ - jvmtiError (JNICALL *GetConstantPool) (jvmtiEnv* env, - jclass klass, - jint* constant_pool_count_ptr, - jint* constant_pool_byte_count_ptr, - unsigned char** constant_pool_bytes_ptr); - - /* 147 : Get Environment Local Storage */ - jvmtiError (JNICALL *GetEnvironmentLocalStorage) (jvmtiEnv* env, - void** data_ptr); - - /* 148 : Set Environment Local Storage */ - jvmtiError (JNICALL *SetEnvironmentLocalStorage) (jvmtiEnv* env, - const void* data); - - /* 149 : Add To Bootstrap Class Loader Search */ - jvmtiError (JNICALL *AddToBootstrapClassLoaderSearch) (jvmtiEnv* env, - const char* segment); - - /* 150 : Set Verbose Flag */ - jvmtiError (JNICALL *SetVerboseFlag) (jvmtiEnv* env, - jvmtiVerboseFlag flag, - jboolean value); - - /* 151 : Add To System Class Loader Search */ - jvmtiError (JNICALL *AddToSystemClassLoaderSearch) (jvmtiEnv* env, - const char* segment); - - /* 152 : Retransform Classes */ - jvmtiError (JNICALL *RetransformClasses) (jvmtiEnv* env, - jint class_count, - const jclass* classes); - - /* 153 : Get Owned Monitor Stack Depth Info */ - jvmtiError (JNICALL *GetOwnedMonitorStackDepthInfo) (jvmtiEnv* env, - jthread thread, - jint* monitor_info_count_ptr, - jvmtiMonitorStackDepthInfo** monitor_info_ptr); - - /* 154 : Get Object Size */ - jvmtiError (JNICALL *GetObjectSize) (jvmtiEnv* env, - jobject object, - jlong* size_ptr); - -} jvmtiInterface_1; - -struct _jvmtiEnv { - const struct jvmtiInterface_1_ *functions; -#ifdef __cplusplus - - - jvmtiError Allocate(jlong size, - unsigned char** mem_ptr) { - return functions->Allocate(this, size, mem_ptr); - } - - jvmtiError Deallocate(unsigned char* mem) { - return functions->Deallocate(this, mem); - } - - jvmtiError GetThreadState(jthread thread, - jint* thread_state_ptr) { - return functions->GetThreadState(this, thread, thread_state_ptr); - } - - jvmtiError GetCurrentThread(jthread* thread_ptr) { - return functions->GetCurrentThread(this, thread_ptr); - } - - jvmtiError GetAllThreads(jint* threads_count_ptr, - jthread** threads_ptr) { - return functions->GetAllThreads(this, threads_count_ptr, threads_ptr); - } - - jvmtiError SuspendThread(jthread thread) { - return functions->SuspendThread(this, thread); - } - - jvmtiError SuspendThreadList(jint request_count, - const jthread* request_list, - jvmtiError* results) { - return functions->SuspendThreadList(this, request_count, request_list, results); - } - - jvmtiError ResumeThread(jthread thread) { - return functions->ResumeThread(this, thread); - } - - jvmtiError ResumeThreadList(jint request_count, - const jthread* request_list, - jvmtiError* results) { - return functions->ResumeThreadList(this, request_count, request_list, results); - } - - jvmtiError StopThread(jthread thread, - jobject exception) { - return functions->StopThread(this, thread, exception); - } - - jvmtiError InterruptThread(jthread thread) { - return functions->InterruptThread(this, thread); - } - - jvmtiError GetThreadInfo(jthread thread, - jvmtiThreadInfo* info_ptr) { - return functions->GetThreadInfo(this, thread, info_ptr); - } - - jvmtiError GetOwnedMonitorInfo(jthread thread, - jint* owned_monitor_count_ptr, - jobject** owned_monitors_ptr) { - return functions->GetOwnedMonitorInfo(this, thread, owned_monitor_count_ptr, owned_monitors_ptr); - } - - jvmtiError GetOwnedMonitorStackDepthInfo(jthread thread, - jint* monitor_info_count_ptr, - jvmtiMonitorStackDepthInfo** monitor_info_ptr) { - return functions->GetOwnedMonitorStackDepthInfo(this, thread, monitor_info_count_ptr, monitor_info_ptr); - } - - jvmtiError GetCurrentContendedMonitor(jthread thread, - jobject* monitor_ptr) { - return functions->GetCurrentContendedMonitor(this, thread, monitor_ptr); - } - - jvmtiError RunAgentThread(jthread thread, - jvmtiStartFunction proc, - const void* arg, - jint priority) { - return functions->RunAgentThread(this, thread, proc, arg, priority); - } - - jvmtiError SetThreadLocalStorage(jthread thread, - const void* data) { - return functions->SetThreadLocalStorage(this, thread, data); - } - - jvmtiError GetThreadLocalStorage(jthread thread, - void** data_ptr) { - return functions->GetThreadLocalStorage(this, thread, data_ptr); - } - - jvmtiError GetTopThreadGroups(jint* group_count_ptr, - jthreadGroup** groups_ptr) { - return functions->GetTopThreadGroups(this, group_count_ptr, groups_ptr); - } - - jvmtiError GetThreadGroupInfo(jthreadGroup group, - jvmtiThreadGroupInfo* info_ptr) { - return functions->GetThreadGroupInfo(this, group, info_ptr); - } - - jvmtiError GetThreadGroupChildren(jthreadGroup group, - jint* thread_count_ptr, - jthread** threads_ptr, - jint* group_count_ptr, - jthreadGroup** groups_ptr) { - return functions->GetThreadGroupChildren(this, group, thread_count_ptr, threads_ptr, group_count_ptr, groups_ptr); - } - - jvmtiError GetStackTrace(jthread thread, - jint start_depth, - jint max_frame_count, - jvmtiFrameInfo* frame_buffer, - jint* count_ptr) { - return functions->GetStackTrace(this, thread, start_depth, max_frame_count, frame_buffer, count_ptr); - } - - jvmtiError GetAllStackTraces(jint max_frame_count, - jvmtiStackInfo** stack_info_ptr, - jint* thread_count_ptr) { - return functions->GetAllStackTraces(this, max_frame_count, stack_info_ptr, thread_count_ptr); - } - - jvmtiError GetThreadListStackTraces(jint thread_count, - const jthread* thread_list, - jint max_frame_count, - jvmtiStackInfo** stack_info_ptr) { - return functions->GetThreadListStackTraces(this, thread_count, thread_list, max_frame_count, stack_info_ptr); - } - - jvmtiError GetFrameCount(jthread thread, - jint* count_ptr) { - return functions->GetFrameCount(this, thread, count_ptr); - } - - jvmtiError PopFrame(jthread thread) { - return functions->PopFrame(this, thread); - } - - jvmtiError GetFrameLocation(jthread thread, - jint depth, - jmethodID* method_ptr, - jlocation* location_ptr) { - return functions->GetFrameLocation(this, thread, depth, method_ptr, location_ptr); - } - - jvmtiError NotifyFramePop(jthread thread, - jint depth) { - return functions->NotifyFramePop(this, thread, depth); - } - - jvmtiError ForceEarlyReturnObject(jthread thread, - jobject value) { - return functions->ForceEarlyReturnObject(this, thread, value); - } - - jvmtiError ForceEarlyReturnInt(jthread thread, - jint value) { - return functions->ForceEarlyReturnInt(this, thread, value); - } - - jvmtiError ForceEarlyReturnLong(jthread thread, - jlong value) { - return functions->ForceEarlyReturnLong(this, thread, value); - } - - jvmtiError ForceEarlyReturnFloat(jthread thread, - jfloat value) { - return functions->ForceEarlyReturnFloat(this, thread, value); - } - - jvmtiError ForceEarlyReturnDouble(jthread thread, - jdouble value) { - return functions->ForceEarlyReturnDouble(this, thread, value); - } - - jvmtiError ForceEarlyReturnVoid(jthread thread) { - return functions->ForceEarlyReturnVoid(this, thread); - } - - jvmtiError FollowReferences(jint heap_filter, - jclass klass, - jobject initial_object, - const jvmtiHeapCallbacks* callbacks, - const void* user_data) { - return functions->FollowReferences(this, heap_filter, klass, initial_object, callbacks, user_data); - } - - jvmtiError IterateThroughHeap(jint heap_filter, - jclass klass, - const jvmtiHeapCallbacks* callbacks, - const void* user_data) { - return functions->IterateThroughHeap(this, heap_filter, klass, callbacks, user_data); - } - - jvmtiError GetTag(jobject object, - jlong* tag_ptr) { - return functions->GetTag(this, object, tag_ptr); - } - - jvmtiError SetTag(jobject object, - jlong tag) { - return functions->SetTag(this, object, tag); - } - - jvmtiError GetObjectsWithTags(jint tag_count, - const jlong* tags, - jint* count_ptr, - jobject** object_result_ptr, - jlong** tag_result_ptr) { - return functions->GetObjectsWithTags(this, tag_count, tags, count_ptr, object_result_ptr, tag_result_ptr); - } - - jvmtiError ForceGarbageCollection() { - return functions->ForceGarbageCollection(this); - } - - jvmtiError IterateOverObjectsReachableFromObject(jobject object, - jvmtiObjectReferenceCallback object_reference_callback, - const void* user_data) { - return functions->IterateOverObjectsReachableFromObject(this, object, object_reference_callback, user_data); - } - - jvmtiError IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback, - jvmtiStackReferenceCallback stack_ref_callback, - jvmtiObjectReferenceCallback object_ref_callback, - const void* user_data) { - return functions->IterateOverReachableObjects(this, heap_root_callback, stack_ref_callback, object_ref_callback, user_data); - } - - jvmtiError IterateOverHeap(jvmtiHeapObjectFilter object_filter, - jvmtiHeapObjectCallback heap_object_callback, - const void* user_data) { - return functions->IterateOverHeap(this, object_filter, heap_object_callback, user_data); - } - - jvmtiError IterateOverInstancesOfClass(jclass klass, - jvmtiHeapObjectFilter object_filter, - jvmtiHeapObjectCallback heap_object_callback, - const void* user_data) { - return functions->IterateOverInstancesOfClass(this, klass, object_filter, heap_object_callback, user_data); - } - - jvmtiError GetLocalObject(jthread thread, - jint depth, - jint slot, - jobject* value_ptr) { - return functions->GetLocalObject(this, thread, depth, slot, value_ptr); - } - - jvmtiError GetLocalInt(jthread thread, - jint depth, - jint slot, - jint* value_ptr) { - return functions->GetLocalInt(this, thread, depth, slot, value_ptr); - } - - jvmtiError GetLocalLong(jthread thread, - jint depth, - jint slot, - jlong* value_ptr) { - return functions->GetLocalLong(this, thread, depth, slot, value_ptr); - } - - jvmtiError GetLocalFloat(jthread thread, - jint depth, - jint slot, - jfloat* value_ptr) { - return functions->GetLocalFloat(this, thread, depth, slot, value_ptr); - } - - jvmtiError GetLocalDouble(jthread thread, - jint depth, - jint slot, - jdouble* value_ptr) { - return functions->GetLocalDouble(this, thread, depth, slot, value_ptr); - } - - jvmtiError SetLocalObject(jthread thread, - jint depth, - jint slot, - jobject value) { - return functions->SetLocalObject(this, thread, depth, slot, value); - } - - jvmtiError SetLocalInt(jthread thread, - jint depth, - jint slot, - jint value) { - return functions->SetLocalInt(this, thread, depth, slot, value); - } - - jvmtiError SetLocalLong(jthread thread, - jint depth, - jint slot, - jlong value) { - return functions->SetLocalLong(this, thread, depth, slot, value); - } - - jvmtiError SetLocalFloat(jthread thread, - jint depth, - jint slot, - jfloat value) { - return functions->SetLocalFloat(this, thread, depth, slot, value); - } - - jvmtiError SetLocalDouble(jthread thread, - jint depth, - jint slot, - jdouble value) { - return functions->SetLocalDouble(this, thread, depth, slot, value); - } - - jvmtiError SetBreakpoint(jmethodID method, - jlocation location) { - return functions->SetBreakpoint(this, method, location); - } - - jvmtiError ClearBreakpoint(jmethodID method, - jlocation location) { - return functions->ClearBreakpoint(this, method, location); - } - - jvmtiError SetFieldAccessWatch(jclass klass, - jfieldID field) { - return functions->SetFieldAccessWatch(this, klass, field); - } - - jvmtiError ClearFieldAccessWatch(jclass klass, - jfieldID field) { - return functions->ClearFieldAccessWatch(this, klass, field); - } - - jvmtiError SetFieldModificationWatch(jclass klass, - jfieldID field) { - return functions->SetFieldModificationWatch(this, klass, field); - } - - jvmtiError ClearFieldModificationWatch(jclass klass, - jfieldID field) { - return functions->ClearFieldModificationWatch(this, klass, field); - } - - jvmtiError GetLoadedClasses(jint* class_count_ptr, - jclass** classes_ptr) { - return functions->GetLoadedClasses(this, class_count_ptr, classes_ptr); - } - - jvmtiError GetClassLoaderClasses(jobject initiating_loader, - jint* class_count_ptr, - jclass** classes_ptr) { - return functions->GetClassLoaderClasses(this, initiating_loader, class_count_ptr, classes_ptr); - } - - jvmtiError GetClassSignature(jclass klass, - char** signature_ptr, - char** generic_ptr) { - return functions->GetClassSignature(this, klass, signature_ptr, generic_ptr); - } - - jvmtiError GetClassStatus(jclass klass, - jint* status_ptr) { - return functions->GetClassStatus(this, klass, status_ptr); - } - - jvmtiError GetSourceFileName(jclass klass, - char** source_name_ptr) { - return functions->GetSourceFileName(this, klass, source_name_ptr); - } - - jvmtiError GetClassModifiers(jclass klass, - jint* modifiers_ptr) { - return functions->GetClassModifiers(this, klass, modifiers_ptr); - } - - jvmtiError GetClassMethods(jclass klass, - jint* method_count_ptr, - jmethodID** methods_ptr) { - return functions->GetClassMethods(this, klass, method_count_ptr, methods_ptr); - } - - jvmtiError GetClassFields(jclass klass, - jint* field_count_ptr, - jfieldID** fields_ptr) { - return functions->GetClassFields(this, klass, field_count_ptr, fields_ptr); - } - - jvmtiError GetImplementedInterfaces(jclass klass, - jint* interface_count_ptr, - jclass** interfaces_ptr) { - return functions->GetImplementedInterfaces(this, klass, interface_count_ptr, interfaces_ptr); - } - - jvmtiError GetClassVersionNumbers(jclass klass, - jint* minor_version_ptr, - jint* major_version_ptr) { - return functions->GetClassVersionNumbers(this, klass, minor_version_ptr, major_version_ptr); - } - - jvmtiError GetConstantPool(jclass klass, - jint* constant_pool_count_ptr, - jint* constant_pool_byte_count_ptr, - unsigned char** constant_pool_bytes_ptr) { - return functions->GetConstantPool(this, klass, constant_pool_count_ptr, constant_pool_byte_count_ptr, constant_pool_bytes_ptr); - } - - jvmtiError IsInterface(jclass klass, - jboolean* is_interface_ptr) { - return functions->IsInterface(this, klass, is_interface_ptr); - } - - jvmtiError IsArrayClass(jclass klass, - jboolean* is_array_class_ptr) { - return functions->IsArrayClass(this, klass, is_array_class_ptr); - } - - jvmtiError IsModifiableClass(jclass klass, - jboolean* is_modifiable_class_ptr) { - return functions->IsModifiableClass(this, klass, is_modifiable_class_ptr); - } - - jvmtiError GetClassLoader(jclass klass, - jobject* classloader_ptr) { - return functions->GetClassLoader(this, klass, classloader_ptr); - } - - jvmtiError GetSourceDebugExtension(jclass klass, - char** source_debug_extension_ptr) { - return functions->GetSourceDebugExtension(this, klass, source_debug_extension_ptr); - } - - jvmtiError RetransformClasses(jint class_count, - const jclass* classes) { - return functions->RetransformClasses(this, class_count, classes); - } - - jvmtiError RedefineClasses(jint class_count, - const jvmtiClassDefinition* class_definitions) { - return functions->RedefineClasses(this, class_count, class_definitions); - } - - jvmtiError GetObjectSize(jobject object, - jlong* size_ptr) { - return functions->GetObjectSize(this, object, size_ptr); - } - - jvmtiError GetObjectHashCode(jobject object, - jint* hash_code_ptr) { - return functions->GetObjectHashCode(this, object, hash_code_ptr); - } - - jvmtiError GetObjectMonitorUsage(jobject object, - jvmtiMonitorUsage* info_ptr) { - return functions->GetObjectMonitorUsage(this, object, info_ptr); - } - - jvmtiError GetFieldName(jclass klass, - jfieldID field, - char** name_ptr, - char** signature_ptr, - char** generic_ptr) { - return functions->GetFieldName(this, klass, field, name_ptr, signature_ptr, generic_ptr); - } - - jvmtiError GetFieldDeclaringClass(jclass klass, - jfieldID field, - jclass* declaring_class_ptr) { - return functions->GetFieldDeclaringClass(this, klass, field, declaring_class_ptr); - } - - jvmtiError GetFieldModifiers(jclass klass, - jfieldID field, - jint* modifiers_ptr) { - return functions->GetFieldModifiers(this, klass, field, modifiers_ptr); - } - - jvmtiError IsFieldSynthetic(jclass klass, - jfieldID field, - jboolean* is_synthetic_ptr) { - return functions->IsFieldSynthetic(this, klass, field, is_synthetic_ptr); - } - - jvmtiError GetMethodName(jmethodID method, - char** name_ptr, - char** signature_ptr, - char** generic_ptr) { - return functions->GetMethodName(this, method, name_ptr, signature_ptr, generic_ptr); - } - - jvmtiError GetMethodDeclaringClass(jmethodID method, - jclass* declaring_class_ptr) { - return functions->GetMethodDeclaringClass(this, method, declaring_class_ptr); - } - - jvmtiError GetMethodModifiers(jmethodID method, - jint* modifiers_ptr) { - return functions->GetMethodModifiers(this, method, modifiers_ptr); - } - - jvmtiError GetMaxLocals(jmethodID method, - jint* max_ptr) { - return functions->GetMaxLocals(this, method, max_ptr); - } - - jvmtiError GetArgumentsSize(jmethodID method, - jint* size_ptr) { - return functions->GetArgumentsSize(this, method, size_ptr); - } - - jvmtiError GetLineNumberTable(jmethodID method, - jint* entry_count_ptr, - jvmtiLineNumberEntry** table_ptr) { - return functions->GetLineNumberTable(this, method, entry_count_ptr, table_ptr); - } - - jvmtiError GetMethodLocation(jmethodID method, - jlocation* start_location_ptr, - jlocation* end_location_ptr) { - return functions->GetMethodLocation(this, method, start_location_ptr, end_location_ptr); - } - - jvmtiError GetLocalVariableTable(jmethodID method, - jint* entry_count_ptr, - jvmtiLocalVariableEntry** table_ptr) { - return functions->GetLocalVariableTable(this, method, entry_count_ptr, table_ptr); - } - - jvmtiError GetBytecodes(jmethodID method, - jint* bytecode_count_ptr, - unsigned char** bytecodes_ptr) { - return functions->GetBytecodes(this, method, bytecode_count_ptr, bytecodes_ptr); - } - - jvmtiError IsMethodNative(jmethodID method, - jboolean* is_native_ptr) { - return functions->IsMethodNative(this, method, is_native_ptr); - } - - jvmtiError IsMethodSynthetic(jmethodID method, - jboolean* is_synthetic_ptr) { - return functions->IsMethodSynthetic(this, method, is_synthetic_ptr); - } - - jvmtiError IsMethodObsolete(jmethodID method, - jboolean* is_obsolete_ptr) { - return functions->IsMethodObsolete(this, method, is_obsolete_ptr); - } - - jvmtiError SetNativeMethodPrefix(const char* prefix) { - return functions->SetNativeMethodPrefix(this, prefix); - } - - jvmtiError SetNativeMethodPrefixes(jint prefix_count, - char** prefixes) { - return functions->SetNativeMethodPrefixes(this, prefix_count, prefixes); - } - - jvmtiError CreateRawMonitor(const char* name, - jrawMonitorID* monitor_ptr) { - return functions->CreateRawMonitor(this, name, monitor_ptr); - } - - jvmtiError DestroyRawMonitor(jrawMonitorID monitor) { - return functions->DestroyRawMonitor(this, monitor); - } - - jvmtiError RawMonitorEnter(jrawMonitorID monitor) { - return functions->RawMonitorEnter(this, monitor); - } - - jvmtiError RawMonitorExit(jrawMonitorID monitor) { - return functions->RawMonitorExit(this, monitor); - } - - jvmtiError RawMonitorWait(jrawMonitorID monitor, - jlong millis) { - return functions->RawMonitorWait(this, monitor, millis); - } - - jvmtiError RawMonitorNotify(jrawMonitorID monitor) { - return functions->RawMonitorNotify(this, monitor); - } - - jvmtiError RawMonitorNotifyAll(jrawMonitorID monitor) { - return functions->RawMonitorNotifyAll(this, monitor); - } - - jvmtiError SetJNIFunctionTable(const jniNativeInterface* function_table) { - return functions->SetJNIFunctionTable(this, function_table); - } - - jvmtiError GetJNIFunctionTable(jniNativeInterface** function_table) { - return functions->GetJNIFunctionTable(this, function_table); - } - - jvmtiError SetEventCallbacks(const jvmtiEventCallbacks* callbacks, - jint size_of_callbacks) { - return functions->SetEventCallbacks(this, callbacks, size_of_callbacks); - } - - jvmtiError SetEventNotificationMode(jvmtiEventMode mode, - jvmtiEvent event_type, - jthread event_thread, - ...) { - return functions->SetEventNotificationMode(this, mode, event_type, event_thread); - } - - jvmtiError GenerateEvents(jvmtiEvent event_type) { - return functions->GenerateEvents(this, event_type); - } - - jvmtiError GetExtensionFunctions(jint* extension_count_ptr, - jvmtiExtensionFunctionInfo** extensions) { - return functions->GetExtensionFunctions(this, extension_count_ptr, extensions); - } - - jvmtiError GetExtensionEvents(jint* extension_count_ptr, - jvmtiExtensionEventInfo** extensions) { - return functions->GetExtensionEvents(this, extension_count_ptr, extensions); - } - - jvmtiError SetExtensionEventCallback(jint extension_event_index, - jvmtiExtensionEvent callback) { - return functions->SetExtensionEventCallback(this, extension_event_index, callback); - } - - jvmtiError GetPotentialCapabilities(jvmtiCapabilities* capabilities_ptr) { - return functions->GetPotentialCapabilities(this, capabilities_ptr); - } - - jvmtiError AddCapabilities(const jvmtiCapabilities* capabilities_ptr) { - return functions->AddCapabilities(this, capabilities_ptr); - } - - jvmtiError RelinquishCapabilities(const jvmtiCapabilities* capabilities_ptr) { - return functions->RelinquishCapabilities(this, capabilities_ptr); - } - - jvmtiError GetCapabilities(jvmtiCapabilities* capabilities_ptr) { - return functions->GetCapabilities(this, capabilities_ptr); - } - - jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { - return functions->GetCurrentThreadCpuTimerInfo(this, info_ptr); - } - - jvmtiError GetCurrentThreadCpuTime(jlong* nanos_ptr) { - return functions->GetCurrentThreadCpuTime(this, nanos_ptr); - } - - jvmtiError GetThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { - return functions->GetThreadCpuTimerInfo(this, info_ptr); - } - - jvmtiError GetThreadCpuTime(jthread thread, - jlong* nanos_ptr) { - return functions->GetThreadCpuTime(this, thread, nanos_ptr); - } - - jvmtiError GetTimerInfo(jvmtiTimerInfo* info_ptr) { - return functions->GetTimerInfo(this, info_ptr); - } - - jvmtiError GetTime(jlong* nanos_ptr) { - return functions->GetTime(this, nanos_ptr); - } - - jvmtiError GetAvailableProcessors(jint* processor_count_ptr) { - return functions->GetAvailableProcessors(this, processor_count_ptr); - } - - jvmtiError AddToBootstrapClassLoaderSearch(const char* segment) { - return functions->AddToBootstrapClassLoaderSearch(this, segment); - } - - jvmtiError AddToSystemClassLoaderSearch(const char* segment) { - return functions->AddToSystemClassLoaderSearch(this, segment); - } - - jvmtiError GetSystemProperties(jint* count_ptr, - char*** property_ptr) { - return functions->GetSystemProperties(this, count_ptr, property_ptr); - } - - jvmtiError GetSystemProperty(const char* property, - char** value_ptr) { - return functions->GetSystemProperty(this, property, value_ptr); - } - - jvmtiError SetSystemProperty(const char* property, - const char* value) { - return functions->SetSystemProperty(this, property, value); - } - - jvmtiError GetPhase(jvmtiPhase* phase_ptr) { - return functions->GetPhase(this, phase_ptr); - } - - jvmtiError DisposeEnvironment() { - return functions->DisposeEnvironment(this); - } - - jvmtiError SetEnvironmentLocalStorage(const void* data) { - return functions->SetEnvironmentLocalStorage(this, data); - } - - jvmtiError GetEnvironmentLocalStorage(void** data_ptr) { - return functions->GetEnvironmentLocalStorage(this, data_ptr); - } - - jvmtiError GetVersionNumber(jint* version_ptr) { - return functions->GetVersionNumber(this, version_ptr); - } - - jvmtiError GetErrorName(jvmtiError error, - char** name_ptr) { - return functions->GetErrorName(this, error, name_ptr); - } - - jvmtiError SetVerboseFlag(jvmtiVerboseFlag flag, - jboolean value) { - return functions->SetVerboseFlag(this, flag, value); - } - - jvmtiError GetJLocationFormat(jvmtiJlocationFormat* format_ptr) { - return functions->GetJLocationFormat(this, format_ptr); - } - -#endif /* __cplusplus */ -}; - - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* !_JAVA_JVMTI_H_ */ - diff --git a/cpp/nativecall/include/win32/jawt_md.h b/cpp/nativecall/include/win32/jawt_md.h deleted file mode 100644 index 82ba034..0000000 --- a/cpp/nativecall/include/win32/jawt_md.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -#ifndef _JAVASOFT_JAWT_MD_H_ -#define _JAVASOFT_JAWT_MD_H_ - -#include -#include "jawt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Win32-specific declarations for AWT native interface. - * See notes in jawt.h for an example of use. - */ -typedef struct jawt_Win32DrawingSurfaceInfo { - /* Native window, DDB, or DIB handle */ - union { - HWND hwnd; - HBITMAP hbitmap; - void* pbits; - }; - /* - * This HDC should always be used instead of the HDC returned from - * BeginPaint() or any calls to GetDC(). - */ - HDC hdc; - HPALETTE hpalette; -} JAWT_Win32DrawingSurfaceInfo; - -#ifdef __cplusplus -} -#endif - -#endif /* !_JAVASOFT_JAWT_MD_H_ */ diff --git a/cpp/nativecall/include/win32/jni_md.h b/cpp/nativecall/include/win32/jni_md.h deleted file mode 100644 index 9ac4718..0000000 --- a/cpp/nativecall/include/win32/jni_md.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -#ifndef _JAVASOFT_JNI_MD_H_ -#define _JAVASOFT_JNI_MD_H_ - -#define JNIEXPORT __declspec(dllexport) -#define JNIIMPORT __declspec(dllimport) -#define JNICALL __stdcall - -typedef long jint; -typedef __int64 jlong; -typedef signed char jbyte; - -#endif /* !_JAVASOFT_JNI_MD_H_ */ diff --git a/cpp/nativecall/msvc/copy.bat b/cpp/nativecall/msvc/copy.bat deleted file mode 100644 index bfd231a..0000000 --- a/cpp/nativecall/msvc/copy.bat +++ /dev/null @@ -1 +0,0 @@ -copy Release\nativecall.dll ..\..\..\java\native \ No newline at end of file diff --git a/cpp/nativecall/msvc/nativecall.sln b/cpp/nativecall/msvc/nativecall.sln deleted file mode 100644 index 152c04f..0000000 --- a/cpp/nativecall/msvc/nativecall.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C++ Express 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nativecall", "nativecall.vcxproj", "{64CA530A-A10E-4AF5-A940-E0034CEC10E7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {64CA530A-A10E-4AF5-A940-E0034CEC10E7}.Debug|Win32.ActiveCfg = Debug|Win32 - {64CA530A-A10E-4AF5-A940-E0034CEC10E7}.Debug|Win32.Build.0 = Debug|Win32 - {64CA530A-A10E-4AF5-A940-E0034CEC10E7}.Release|Win32.ActiveCfg = Release|Win32 - {64CA530A-A10E-4AF5-A940-E0034CEC10E7}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/cpp/nativecall/msvc/nativecall.suo b/cpp/nativecall/msvc/nativecall.suo deleted file mode 100644 index 6386fe5..0000000 Binary files a/cpp/nativecall/msvc/nativecall.suo and /dev/null differ diff --git a/cpp/nativecall/msvc/nativecall.vcxproj b/cpp/nativecall/msvc/nativecall.vcxproj deleted file mode 100644 index 8e90b48..0000000 --- a/cpp/nativecall/msvc/nativecall.vcxproj +++ /dev/null @@ -1,98 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {64CA530A-A10E-4AF5-A940-E0034CEC10E7} - Win32Proj - nativecall - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - true - ..\include;..\include\win32;$(IncludePath) - - - false - ..\include;..\include\win32;$(IncludePath) - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;_USRDLL;NATIVECALL_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - - - copy.bat - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;NATIVECALL_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - copy.bat - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cpp/nativecall/msvc/nativecall.vcxproj.filters b/cpp/nativecall/msvc/nativecall.vcxproj.filters deleted file mode 100644 index 9cca3d1..0000000 --- a/cpp/nativecall/msvc/nativecall.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/cpp/nativecall/msvc/nativecall.vcxproj.user b/cpp/nativecall/msvc/nativecall.vcxproj.user deleted file mode 100644 index 695b5c7..0000000 --- a/cpp/nativecall/msvc/nativecall.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file