From 1ccb1757625c3021e539617c1e216066c990e3ad Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 12 Aug 2009 15:54:25 +0000 Subject: [PATCH] tidied up whitespace in files --- .../juce_linux_Midi.cpp | 974 +-- .../juce_linux_Threads.cpp | 2 +- .../juce_mac_CameraDevice.mm | 4 +- .../juce_mac_MessageManager.mm | 934 +-- .../juce_mac_NSViewComponent.mm | 322 +- .../juce_mac_NSViewComponentPeer.mm | 2 +- .../juce_mac_NativeCode.mm | 4 +- .../juce_win32_ASIO.cpp | 2 +- .../juce_win32_CameraDevice.cpp | 52 +- .../juce_win32_Files.cpp | 2 +- .../juce_win32_NativeIncludes.h | 2 +- .../juce_win32_Windowing.cpp | 2 +- .../wrapper/AU/juce_AU_Wrapper.mm | 4 +- .../wrapper/RTAS/juce_RTAS_DigiCode_Header.h | 156 +- .../wrapper/RTAS/juce_RTAS_Wrapper.cpp | 2004 ++--- .../wrapper/VST/juce_VST_Wrapper.cpp | 38 +- .../wrapper/VST/juce_VST_Wrapper.mm | 364 +- .../demo/src/BrowserPluginCharacteristics.h | 2 +- .../demo/src/JuceBrowserPluginDemo.cpp | 304 +- .../demo/src/juce_LibrarySource.mm | 22 +- .../wrapper/juce_ActiveX_GlueCode.cpp | 32 +- .../wrapper/juce_BrowserPluginComponent.h | 18 +- .../wrapper/juce_IncludeBrowserPluginInfo.h | 106 +- .../wrapper/juce_NPAPI_GlueCode.cpp | 57 +- extras/browser plugins/wrapper/npapi/jni.h | 3944 +++++----- extras/browser plugins/wrapper/npapi/jni_md.h | 430 +- extras/browser plugins/wrapper/npapi/jri.h | 1378 ++-- extras/browser plugins/wrapper/npapi/jri_md.h | 1148 +-- .../browser plugins/wrapper/npapi/jritypes.h | 486 +- extras/browser plugins/wrapper/npapi/npapi.h | 1532 ++-- .../browser plugins/wrapper/npapi/npruntime.h | 846 +-- .../browser plugins/wrapper/npapi/nptypes.h | 210 +- extras/browser plugins/wrapper/npapi/npupp.h | 1430 ++-- .../wrapper/npapi/obsolete/protypes.h | 504 +- .../browser plugins/wrapper/npapi/prcpucfg.h | 600 +- .../browser plugins/wrapper/npapi/prtypes.h | 1137 ++- extras/juce demo/src/MainDemoWindow.cpp | 2 +- extras/the jucer/src/BinaryData.cpp | 1 - .../model/components/jucer_ViewportHandler.h | 1384 ++-- .../src/model/jucer_BinaryResources.cpp | 2 +- .../src/model/jucer_GeneratedCode.cpp | 776 +- .../paintelements/jucer_PaintElementImage.h | 1072 +-- juce_amalgamated.cpp | 54 +- juce_amalgamated.h | 6650 ++++++++--------- src/juce_app_includes.h | 180 +- .../juce_AiffAudioFormat.cpp | 2 +- .../audio_file_formats/juce_AudioFormat.cpp | 8 +- .../juce_AudioFormatReader.h | 28 +- .../juce_AudioSubsectionReader.cpp | 2 +- .../audio/devices/juce_AudioDeviceManager.h | 6 +- .../gui/components/controls/juce_Label.cpp | 2 +- .../gui/components/controls/juce_Label.h | 2 +- .../gui/components/controls/juce_ListBox.cpp | 2 +- .../gui/components/controls/juce_TreeView.cpp | 2 +- .../gui/components/juce_Component.h | 2 +- .../layout/juce_ResizableBorderComponent.cpp | 12 +- .../components/lookandfeel/juce_LookAndFeel.h | 4 +- .../components/windows/juce_TooltipWindow.cpp | 390 +- .../components/windows/juce_TooltipWindow.h | 2 +- .../containers/juce_ReferenceCountedArray.h | 4 +- src/juce_core/io/network/juce_Socket.h | 4 +- src/juce_core/io/network/juce_URL.cpp | 10 +- src/juce_core/io/network/juce_URL.h | 10 +- src/juce_core/text/juce_String.cpp | 2 +- src/juce_core/threads/juce_Thread.cpp | 4 +- src/juce_core/threads/juce_ThreadPool.cpp | 4 +- src/juce_core/threads/juce_ThreadPool.h | 4 +- src/juce_core_includes.h | 36 +- 68 files changed, 14856 insertions(+), 14861 deletions(-) diff --git a/build/linux/platform_specific_code/juce_linux_Midi.cpp b/build/linux/platform_specific_code/juce_linux_Midi.cpp index 76b96d040e..390c182607 100644 --- a/build/linux/platform_specific_code/juce_linux_Midi.cpp +++ b/build/linux/platform_specific_code/juce_linux_Midi.cpp @@ -1,487 +1,487 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#include "../../../juce_Config.h" - -#if JUCE_ALSA - -#include "../../../src/juce_core/basics/juce_StandardHeader.h" -#include - -BEGIN_JUCE_NAMESPACE - -#include "../../../src/juce_appframework/audio/devices/juce_MidiOutput.h" -#include "../../../src/juce_appframework/audio/devices/juce_MidiInput.h" -#include "../../../src/juce_core/threads/juce_Thread.h" -#include "../../../src/juce_core/basics/juce_Time.h" - - -//============================================================================== -static snd_seq_t* iterateDevices (const bool forInput, - StringArray& deviceNamesFound, - const int deviceIndexToOpen) -{ - snd_seq_t* returnedHandle = 0; - snd_seq_t* seqHandle; - - if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT - : SND_SEQ_OPEN_OUTPUT, 0) == 0) - { - snd_seq_system_info_t* systemInfo; - snd_seq_client_info_t* clientInfo; - - if (snd_seq_system_info_malloc (&systemInfo) == 0) - { - if (snd_seq_system_info (seqHandle, systemInfo) == 0 - && snd_seq_client_info_malloc (&clientInfo) == 0) - { - int numClients = snd_seq_system_info_get_cur_clients (systemInfo); - - while (--numClients >= 0 && returnedHandle == 0) - { - if (snd_seq_query_next_client (seqHandle, clientInfo) == 0) - { - snd_seq_port_info_t* portInfo; - if (snd_seq_port_info_malloc (&portInfo) == 0) - { - int numPorts = snd_seq_client_info_get_num_ports (clientInfo); - const int client = snd_seq_client_info_get_client (clientInfo); - - snd_seq_port_info_set_client (portInfo, client); - snd_seq_port_info_set_port (portInfo, -1); - - while (--numPorts >= 0) - { - if (snd_seq_query_next_port (seqHandle, portInfo) == 0 - && (snd_seq_port_info_get_capability (portInfo) - & (forInput ? SND_SEQ_PORT_CAP_READ - : SND_SEQ_PORT_CAP_WRITE)) != 0) - { - deviceNamesFound.add (snd_seq_client_info_get_name (clientInfo)); - - if (deviceNamesFound.size() == deviceIndexToOpen + 1) - { - const int sourcePort = snd_seq_port_info_get_port (portInfo); - const int sourceClient = snd_seq_client_info_get_client (clientInfo); - - if (sourcePort != -1) - { - snd_seq_set_client_name (seqHandle, - forInput ? "Juce Midi Input" - : "Juce Midi Output"); - - const int portId - = snd_seq_create_simple_port (seqHandle, - forInput ? "Juce Midi In Port" - : "Juce Midi Out Port", - forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) - : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), - SND_SEQ_PORT_TYPE_MIDI_GENERIC); - - snd_seq_connect_from (seqHandle, portId, sourceClient, sourcePort); - - returnedHandle = seqHandle; - } - } - } - } - - snd_seq_port_info_free (portInfo); - } - } - } - - snd_seq_client_info_free (clientInfo); - } - - snd_seq_system_info_free (systemInfo); - } - - if (returnedHandle == 0) - snd_seq_close (seqHandle); - } - - deviceNamesFound.appendNumbersToDuplicates (true, true); - - return returnedHandle; -} - -static snd_seq_t* createDevice (const bool forInput, - const String& deviceNameToOpen) -{ - snd_seq_t* seqHandle = 0; - - if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT - : SND_SEQ_OPEN_OUTPUT, 0) == 0) - { - snd_seq_set_client_name (seqHandle, - (const char*) (forInput ? (deviceNameToOpen + T(" Input")) - : (deviceNameToOpen + T(" Output")))); - - const int portId - = snd_seq_create_simple_port (seqHandle, - forInput ? "in" - : "out", - forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) - : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), - forInput ? SND_SEQ_PORT_TYPE_APPLICATION - : SND_SEQ_PORT_TYPE_MIDI_GENERIC); - - if (portId < 0) - { - snd_seq_close (seqHandle); - seqHandle = 0; - } - } - - return seqHandle; -} - -//============================================================================== -class MidiOutputDevice -{ -public: - MidiOutputDevice (MidiOutput* const midiOutput_, - snd_seq_t* const seqHandle_) - : - midiOutput (midiOutput_), - seqHandle (seqHandle_), - maxEventSize (16 * 1024) - { - jassert (seqHandle != 0 && midiOutput != 0); - snd_midi_event_new (maxEventSize, &midiParser); - } - - ~MidiOutputDevice() - { - snd_midi_event_free (midiParser); - snd_seq_close (seqHandle); - } - - void sendMessageNow (const MidiMessage& message) - { - if (message.getRawDataSize() > maxEventSize) - { - maxEventSize = message.getRawDataSize(); - snd_midi_event_free (midiParser); - snd_midi_event_new (maxEventSize, &midiParser); - } - - snd_seq_event_t event; - snd_seq_ev_clear (&event); - - snd_midi_event_encode (midiParser, - message.getRawData(), - message.getRawDataSize(), - &event); - - snd_midi_event_reset_encode (midiParser); - - snd_seq_ev_set_source (&event, 0); - snd_seq_ev_set_subs (&event); - snd_seq_ev_set_direct (&event); - - snd_seq_event_output (seqHandle, &event); - snd_seq_drain_output (seqHandle); - } - - juce_UseDebuggingNewOperator - -private: - MidiOutput* const midiOutput; - snd_seq_t* const seqHandle; - snd_midi_event_t* midiParser; - int maxEventSize; -}; - -const StringArray MidiOutput::getDevices() -{ - StringArray devices; - iterateDevices (false, devices, -1); - return devices; -} - -int MidiOutput::getDefaultDeviceIndex() -{ - return 0; -} - -MidiOutput* MidiOutput::openDevice (int deviceIndex) -{ - MidiOutput* newDevice = 0; - - StringArray devices; - snd_seq_t* const handle = iterateDevices (false, devices, deviceIndex); - - if (handle != 0) - { - newDevice = new MidiOutput(); - newDevice->internal = new MidiOutputDevice (newDevice, handle); - } - - return newDevice; -} - -MidiOutput* MidiOutput::createNewDevice (const String& deviceName) -{ - MidiOutput* newDevice = 0; - - snd_seq_t* const handle = createDevice (false, deviceName); - - if (handle != 0) - { - newDevice = new MidiOutput(); - newDevice->internal = new MidiOutputDevice (newDevice, handle); - } - - return newDevice; -} - -MidiOutput::~MidiOutput() -{ - MidiOutputDevice* const device = (MidiOutputDevice*) internal; - delete device; -} - -void MidiOutput::reset() -{ -} - -bool MidiOutput::getVolume (float& leftVol, float& rightVol) -{ - return false; -} - -void MidiOutput::setVolume (float leftVol, float rightVol) -{ -} - -void MidiOutput::sendMessageNow (const MidiMessage& message) -{ - ((MidiOutputDevice*) internal)->sendMessageNow (message); -} - - -//============================================================================== -class MidiInputThread : public Thread -{ -public: - MidiInputThread (MidiInput* const midiInput_, - snd_seq_t* const seqHandle_, - MidiInputCallback* const callback_) - : Thread (T("Juce MIDI Input")), - midiInput (midiInput_), - seqHandle (seqHandle_), - callback (callback_) - { - jassert (seqHandle != 0 && callback != 0 && midiInput != 0); - } - - ~MidiInputThread() - { - snd_seq_close (seqHandle); - } - - void run() - { - const int maxEventSize = 16 * 1024; - snd_midi_event_t* midiParser; - - if (snd_midi_event_new (maxEventSize, &midiParser) >= 0) - { - uint8* const buffer = (uint8*) juce_malloc (maxEventSize); - - const int numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN); - struct pollfd* const pfd = (struct pollfd*) alloca (numPfds * sizeof (struct pollfd)); - - snd_seq_poll_descriptors (seqHandle, pfd, numPfds, POLLIN); - - while (! threadShouldExit()) - { - if (poll (pfd, numPfds, 500) > 0) - { - snd_seq_event_t* inputEvent = 0; - - snd_seq_nonblock (seqHandle, 1); - - do - { - if (snd_seq_event_input (seqHandle, &inputEvent) >= 0) - { - // xxx what about SYSEXes that are too big for the buffer? - const int numBytes = snd_midi_event_decode (midiParser, buffer, maxEventSize, inputEvent); - - snd_midi_event_reset_decode (midiParser); - - if (numBytes > 0) - { - const MidiMessage message ((const uint8*) buffer, - numBytes, - Time::getMillisecondCounter() * 0.001); - - - callback->handleIncomingMidiMessage (midiInput, message); - } - - snd_seq_free_event (inputEvent); - } - } - while (snd_seq_event_input_pending (seqHandle, 0) > 0); - - snd_seq_free_event (inputEvent); - } - } - - snd_midi_event_free (midiParser); - juce_free (buffer); - } - }; - - juce_UseDebuggingNewOperator - -private: - MidiInput* const midiInput; - snd_seq_t* const seqHandle; - MidiInputCallback* const callback; -}; - -//============================================================================== -MidiInput::MidiInput (const String& name_) - : name (name_), - internal (0) -{ -} - -MidiInput::~MidiInput() -{ - stop(); - MidiInputThread* const thread = (MidiInputThread*) internal; - delete thread; -} - -void MidiInput::start() -{ - ((MidiInputThread*) internal)->startThread(); -} - -void MidiInput::stop() -{ - ((MidiInputThread*) internal)->stopThread (3000); -} - -int MidiInput::getDefaultDeviceIndex() -{ - return 0; -} - -const StringArray MidiInput::getDevices() -{ - StringArray devices; - iterateDevices (true, devices, -1); - return devices; -} - -MidiInput* MidiInput::openDevice (int deviceIndex, MidiInputCallback* callback) -{ - MidiInput* newDevice = 0; - - StringArray devices; - snd_seq_t* const handle = iterateDevices (true, devices, deviceIndex); - - if (handle != 0) - { - newDevice = new MidiInput (devices [deviceIndex]); - newDevice->internal = new MidiInputThread (newDevice, handle, callback); - } - - return newDevice; -} - -MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallback* callback) -{ - MidiInput* newDevice = 0; - - snd_seq_t* const handle = createDevice (true, deviceName); - - if (handle != 0) - { - newDevice = new MidiInput (deviceName); - newDevice->internal = new MidiInputThread (newDevice, handle, callback); - } - - return newDevice; -} - - - -END_JUCE_NAMESPACE - -//============================================================================== - -#else - -//============================================================================== -// (These are just stub functions if ALSA is unavailable...) - -#include "../../../src/juce_core/basics/juce_StandardHeader.h" - -BEGIN_JUCE_NAMESPACE - -#include "../../../src/juce_appframework/audio/devices/juce_MidiOutput.h" -#include "../../../src/juce_appframework/audio/devices/juce_MidiInput.h" - -//============================================================================== -const StringArray MidiOutput::getDevices() { return StringArray(); } -int MidiOutput::getDefaultDeviceIndex() { return 0; } -MidiOutput* MidiOutput::openDevice (int) { return 0; } -MidiOutput* MidiOutput::createNewDevice (const String&) { return 0; } -MidiOutput::~MidiOutput() {} -void MidiOutput::reset() {} -bool MidiOutput::getVolume (float&, float&) { return false; } -void MidiOutput::setVolume (float, float) {} -void MidiOutput::sendMessageNow (const MidiMessage&) {} - -MidiInput::MidiInput (const String& name_) - : name (name_), - internal (0) -{} - -MidiInput::~MidiInput() {} -void MidiInput::start() {} -void MidiInput::stop() {} -int MidiInput::getDefaultDeviceIndex() { return 0; } -const StringArray MidiInput::getDevices() { return StringArray(); } -MidiInput* MidiInput::openDevice (int, MidiInputCallback*) { return 0; } -MidiInput* MidiInput::createNewDevice (const String&, MidiInputCallback*) { return 0; } - -END_JUCE_NAMESPACE - -#endif +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#include "../../../juce_Config.h" + +#if JUCE_ALSA + +#include "../../../src/juce_core/basics/juce_StandardHeader.h" +#include + +BEGIN_JUCE_NAMESPACE + +#include "../../../src/juce_appframework/audio/devices/juce_MidiOutput.h" +#include "../../../src/juce_appframework/audio/devices/juce_MidiInput.h" +#include "../../../src/juce_core/threads/juce_Thread.h" +#include "../../../src/juce_core/basics/juce_Time.h" + + +//============================================================================== +static snd_seq_t* iterateDevices (const bool forInput, + StringArray& deviceNamesFound, + const int deviceIndexToOpen) +{ + snd_seq_t* returnedHandle = 0; + snd_seq_t* seqHandle; + + if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT + : SND_SEQ_OPEN_OUTPUT, 0) == 0) + { + snd_seq_system_info_t* systemInfo; + snd_seq_client_info_t* clientInfo; + + if (snd_seq_system_info_malloc (&systemInfo) == 0) + { + if (snd_seq_system_info (seqHandle, systemInfo) == 0 + && snd_seq_client_info_malloc (&clientInfo) == 0) + { + int numClients = snd_seq_system_info_get_cur_clients (systemInfo); + + while (--numClients >= 0 && returnedHandle == 0) + { + if (snd_seq_query_next_client (seqHandle, clientInfo) == 0) + { + snd_seq_port_info_t* portInfo; + if (snd_seq_port_info_malloc (&portInfo) == 0) + { + int numPorts = snd_seq_client_info_get_num_ports (clientInfo); + const int client = snd_seq_client_info_get_client (clientInfo); + + snd_seq_port_info_set_client (portInfo, client); + snd_seq_port_info_set_port (portInfo, -1); + + while (--numPorts >= 0) + { + if (snd_seq_query_next_port (seqHandle, portInfo) == 0 + && (snd_seq_port_info_get_capability (portInfo) + & (forInput ? SND_SEQ_PORT_CAP_READ + : SND_SEQ_PORT_CAP_WRITE)) != 0) + { + deviceNamesFound.add (snd_seq_client_info_get_name (clientInfo)); + + if (deviceNamesFound.size() == deviceIndexToOpen + 1) + { + const int sourcePort = snd_seq_port_info_get_port (portInfo); + const int sourceClient = snd_seq_client_info_get_client (clientInfo); + + if (sourcePort != -1) + { + snd_seq_set_client_name (seqHandle, + forInput ? "Juce Midi Input" + : "Juce Midi Output"); + + const int portId + = snd_seq_create_simple_port (seqHandle, + forInput ? "Juce Midi In Port" + : "Juce Midi Out Port", + forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) + : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), + SND_SEQ_PORT_TYPE_MIDI_GENERIC); + + snd_seq_connect_from (seqHandle, portId, sourceClient, sourcePort); + + returnedHandle = seqHandle; + } + } + } + } + + snd_seq_port_info_free (portInfo); + } + } + } + + snd_seq_client_info_free (clientInfo); + } + + snd_seq_system_info_free (systemInfo); + } + + if (returnedHandle == 0) + snd_seq_close (seqHandle); + } + + deviceNamesFound.appendNumbersToDuplicates (true, true); + + return returnedHandle; +} + +static snd_seq_t* createDevice (const bool forInput, + const String& deviceNameToOpen) +{ + snd_seq_t* seqHandle = 0; + + if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT + : SND_SEQ_OPEN_OUTPUT, 0) == 0) + { + snd_seq_set_client_name (seqHandle, + (const char*) (forInput ? (deviceNameToOpen + T(" Input")) + : (deviceNameToOpen + T(" Output")))); + + const int portId + = snd_seq_create_simple_port (seqHandle, + forInput ? "in" + : "out", + forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE) + : (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ), + forInput ? SND_SEQ_PORT_TYPE_APPLICATION + : SND_SEQ_PORT_TYPE_MIDI_GENERIC); + + if (portId < 0) + { + snd_seq_close (seqHandle); + seqHandle = 0; + } + } + + return seqHandle; +} + +//============================================================================== +class MidiOutputDevice +{ +public: + MidiOutputDevice (MidiOutput* const midiOutput_, + snd_seq_t* const seqHandle_) + : + midiOutput (midiOutput_), + seqHandle (seqHandle_), + maxEventSize (16 * 1024) + { + jassert (seqHandle != 0 && midiOutput != 0); + snd_midi_event_new (maxEventSize, &midiParser); + } + + ~MidiOutputDevice() + { + snd_midi_event_free (midiParser); + snd_seq_close (seqHandle); + } + + void sendMessageNow (const MidiMessage& message) + { + if (message.getRawDataSize() > maxEventSize) + { + maxEventSize = message.getRawDataSize(); + snd_midi_event_free (midiParser); + snd_midi_event_new (maxEventSize, &midiParser); + } + + snd_seq_event_t event; + snd_seq_ev_clear (&event); + + snd_midi_event_encode (midiParser, + message.getRawData(), + message.getRawDataSize(), + &event); + + snd_midi_event_reset_encode (midiParser); + + snd_seq_ev_set_source (&event, 0); + snd_seq_ev_set_subs (&event); + snd_seq_ev_set_direct (&event); + + snd_seq_event_output (seqHandle, &event); + snd_seq_drain_output (seqHandle); + } + + juce_UseDebuggingNewOperator + +private: + MidiOutput* const midiOutput; + snd_seq_t* const seqHandle; + snd_midi_event_t* midiParser; + int maxEventSize; +}; + +const StringArray MidiOutput::getDevices() +{ + StringArray devices; + iterateDevices (false, devices, -1); + return devices; +} + +int MidiOutput::getDefaultDeviceIndex() +{ + return 0; +} + +MidiOutput* MidiOutput::openDevice (int deviceIndex) +{ + MidiOutput* newDevice = 0; + + StringArray devices; + snd_seq_t* const handle = iterateDevices (false, devices, deviceIndex); + + if (handle != 0) + { + newDevice = new MidiOutput(); + newDevice->internal = new MidiOutputDevice (newDevice, handle); + } + + return newDevice; +} + +MidiOutput* MidiOutput::createNewDevice (const String& deviceName) +{ + MidiOutput* newDevice = 0; + + snd_seq_t* const handle = createDevice (false, deviceName); + + if (handle != 0) + { + newDevice = new MidiOutput(); + newDevice->internal = new MidiOutputDevice (newDevice, handle); + } + + return newDevice; +} + +MidiOutput::~MidiOutput() +{ + MidiOutputDevice* const device = (MidiOutputDevice*) internal; + delete device; +} + +void MidiOutput::reset() +{ +} + +bool MidiOutput::getVolume (float& leftVol, float& rightVol) +{ + return false; +} + +void MidiOutput::setVolume (float leftVol, float rightVol) +{ +} + +void MidiOutput::sendMessageNow (const MidiMessage& message) +{ + ((MidiOutputDevice*) internal)->sendMessageNow (message); +} + + +//============================================================================== +class MidiInputThread : public Thread +{ +public: + MidiInputThread (MidiInput* const midiInput_, + snd_seq_t* const seqHandle_, + MidiInputCallback* const callback_) + : Thread (T("Juce MIDI Input")), + midiInput (midiInput_), + seqHandle (seqHandle_), + callback (callback_) + { + jassert (seqHandle != 0 && callback != 0 && midiInput != 0); + } + + ~MidiInputThread() + { + snd_seq_close (seqHandle); + } + + void run() + { + const int maxEventSize = 16 * 1024; + snd_midi_event_t* midiParser; + + if (snd_midi_event_new (maxEventSize, &midiParser) >= 0) + { + uint8* const buffer = (uint8*) juce_malloc (maxEventSize); + + const int numPfds = snd_seq_poll_descriptors_count (seqHandle, POLLIN); + struct pollfd* const pfd = (struct pollfd*) alloca (numPfds * sizeof (struct pollfd)); + + snd_seq_poll_descriptors (seqHandle, pfd, numPfds, POLLIN); + + while (! threadShouldExit()) + { + if (poll (pfd, numPfds, 500) > 0) + { + snd_seq_event_t* inputEvent = 0; + + snd_seq_nonblock (seqHandle, 1); + + do + { + if (snd_seq_event_input (seqHandle, &inputEvent) >= 0) + { + // xxx what about SYSEXes that are too big for the buffer? + const int numBytes = snd_midi_event_decode (midiParser, buffer, maxEventSize, inputEvent); + + snd_midi_event_reset_decode (midiParser); + + if (numBytes > 0) + { + const MidiMessage message ((const uint8*) buffer, + numBytes, + Time::getMillisecondCounter() * 0.001); + + + callback->handleIncomingMidiMessage (midiInput, message); + } + + snd_seq_free_event (inputEvent); + } + } + while (snd_seq_event_input_pending (seqHandle, 0) > 0); + + snd_seq_free_event (inputEvent); + } + } + + snd_midi_event_free (midiParser); + juce_free (buffer); + } + }; + + juce_UseDebuggingNewOperator + +private: + MidiInput* const midiInput; + snd_seq_t* const seqHandle; + MidiInputCallback* const callback; +}; + +//============================================================================== +MidiInput::MidiInput (const String& name_) + : name (name_), + internal (0) +{ +} + +MidiInput::~MidiInput() +{ + stop(); + MidiInputThread* const thread = (MidiInputThread*) internal; + delete thread; +} + +void MidiInput::start() +{ + ((MidiInputThread*) internal)->startThread(); +} + +void MidiInput::stop() +{ + ((MidiInputThread*) internal)->stopThread (3000); +} + +int MidiInput::getDefaultDeviceIndex() +{ + return 0; +} + +const StringArray MidiInput::getDevices() +{ + StringArray devices; + iterateDevices (true, devices, -1); + return devices; +} + +MidiInput* MidiInput::openDevice (int deviceIndex, MidiInputCallback* callback) +{ + MidiInput* newDevice = 0; + + StringArray devices; + snd_seq_t* const handle = iterateDevices (true, devices, deviceIndex); + + if (handle != 0) + { + newDevice = new MidiInput (devices [deviceIndex]); + newDevice->internal = new MidiInputThread (newDevice, handle, callback); + } + + return newDevice; +} + +MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallback* callback) +{ + MidiInput* newDevice = 0; + + snd_seq_t* const handle = createDevice (true, deviceName); + + if (handle != 0) + { + newDevice = new MidiInput (deviceName); + newDevice->internal = new MidiInputThread (newDevice, handle, callback); + } + + return newDevice; +} + + + +END_JUCE_NAMESPACE + +//============================================================================== + +#else + +//============================================================================== +// (These are just stub functions if ALSA is unavailable...) + +#include "../../../src/juce_core/basics/juce_StandardHeader.h" + +BEGIN_JUCE_NAMESPACE + +#include "../../../src/juce_appframework/audio/devices/juce_MidiOutput.h" +#include "../../../src/juce_appframework/audio/devices/juce_MidiInput.h" + +//============================================================================== +const StringArray MidiOutput::getDevices() { return StringArray(); } +int MidiOutput::getDefaultDeviceIndex() { return 0; } +MidiOutput* MidiOutput::openDevice (int) { return 0; } +MidiOutput* MidiOutput::createNewDevice (const String&) { return 0; } +MidiOutput::~MidiOutput() {} +void MidiOutput::reset() {} +bool MidiOutput::getVolume (float&, float&) { return false; } +void MidiOutput::setVolume (float, float) {} +void MidiOutput::sendMessageNow (const MidiMessage&) {} + +MidiInput::MidiInput (const String& name_) + : name (name_), + internal (0) +{} + +MidiInput::~MidiInput() {} +void MidiInput::start() {} +void MidiInput::stop() {} +int MidiInput::getDefaultDeviceIndex() { return 0; } +const StringArray MidiInput::getDevices() { return StringArray(); } +MidiInput* MidiInput::openDevice (int, MidiInputCallback*) { return 0; } +MidiInput* MidiInput::createNewDevice (const String&, MidiInputCallback*) { return 0; } + +END_JUCE_NAMESPACE + +#endif diff --git a/build/linux/platform_specific_code/juce_linux_Threads.cpp b/build/linux/platform_specific_code/juce_linux_Threads.cpp index e841201c1d..0ab088d6d1 100644 --- a/build/linux/platform_specific_code/juce_linux_Threads.cpp +++ b/build/linux/platform_specific_code/juce_linux_Threads.cpp @@ -139,7 +139,7 @@ bool juce_setThreadPriority (void* handle, int priority) throw() return pthread_setschedparam ((pthread_t) handle, policy, ¶m) == 0; } - + return false; } diff --git a/build/macosx/platform_specific_code/juce_mac_CameraDevice.mm b/build/macosx/platform_specific_code/juce_mac_CameraDevice.mm index 0c33d543c0..daf769a574 100644 --- a/build/macosx/platform_specific_code/juce_mac_CameraDevice.mm +++ b/build/macosx/platform_specific_code/juce_mac_CameraDevice.mm @@ -261,8 +261,8 @@ END_JUCE_NAMESPACE fromConnection: (QTCaptureConnection*) connection { const ScopedAutoReleasePool pool; - CIImage* image = [CIImage imageWithCVImageBuffer: videoFrame]; - NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] initWithCIImage: image] autorelease]; + CIImage* image = [CIImage imageWithCVImageBuffer: videoFrame]; + NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] initWithCIImage: image] autorelease]; internal->callListeners (bitmap); } diff --git a/build/macosx/platform_specific_code/juce_mac_MessageManager.mm b/build/macosx/platform_specific_code/juce_mac_MessageManager.mm index 29f663e141..b71c1e29aa 100644 --- a/build/macosx/platform_specific_code/juce_mac_MessageManager.mm +++ b/build/macosx/platform_specific_code/juce_mac_MessageManager.mm @@ -1,467 +1,467 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -// (This file gets included by juce_mac_NativeCode.mm, rather than being -// compiled on its own). -#ifdef JUCE_INCLUDED_FILE - -struct CallbackMessagePayload -{ - MessageCallbackFunction* function; - void* parameter; - void* volatile result; - bool volatile hasBeenExecuted; -}; - -/* When you use multiple DLLs which share similarly-named obj-c classes - like - for example having more than one juce plugin loaded into a host, then when a - method is called, the actual code that runs might actually be in a different module - than the one you expect... So any calls to library functions or statics that are - made inside obj-c methods will probably end up getting executed in a different DLL's - memory space. Not a great thing to happen - this obviously leads to bizarre crashes. - - To work around this insanity, I'm only allowing obj-c methods to make calls to - virtual methods of an object that's known to live inside the right module's space. -*/ -class AppDelegateRedirector -{ -public: - AppDelegateRedirector() {} - virtual ~AppDelegateRedirector() {} - - virtual NSApplicationTerminateReply shouldTerminate() - { - if (JUCEApplication::getInstance() != 0) - { - JUCEApplication::getInstance()->systemRequestedQuit(); - return NSTerminateCancel; - } - - return NSTerminateNow; - } - - virtual BOOL openFile (const NSString* filename) - { - if (JUCEApplication::getInstance() != 0) - { - JUCEApplication::getInstance()->anotherInstanceStarted (nsStringToJuce (filename)); - return YES; - } - - return NO; - } - - virtual void openFiles (NSArray* filenames) - { - StringArray files; - for (unsigned int i = 0; i < [filenames count]; ++i) - files.add (nsStringToJuce ((NSString*) [filenames objectAtIndex: i])); - - if (files.size() > 0 && JUCEApplication::getInstance() != 0) - { - JUCEApplication::getInstance()->anotherInstanceStarted (files.joinIntoString (T(" "))); - } - } - - virtual void focusChanged() - { - juce_HandleProcessFocusChange(); - } - - virtual void deliverMessage (void* message) - { - // no need for an mm lock here - deliverMessage locks it - MessageManager::getInstance()->deliverMessage (message); - } - - virtual void performCallback (CallbackMessagePayload* pl) - { - pl->result = (*pl->function) (pl->parameter); - pl->hasBeenExecuted = true; - } - - virtual void deleteSelf() - { - delete this; - } -}; - -END_JUCE_NAMESPACE -using namespace JUCE_NAMESPACE; - -#define JuceAppDelegate MakeObjCClassName(JuceAppDelegate) - -static int numPendingMessages = 0; - -@interface JuceAppDelegate : NSObject -{ -@private - id oldDelegate; - AppDelegateRedirector* redirector; - -@public - bool flushingMessages; -} - -- (JuceAppDelegate*) init; -- (void) dealloc; -- (BOOL) application: (NSApplication*) theApplication openFile: (NSString*) filename; -- (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames; -- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app; -- (void) applicationDidBecomeActive: (NSNotification*) aNotification; -- (void) applicationDidResignActive: (NSNotification*) aNotification; -- (void) applicationWillUnhide: (NSNotification*) aNotification; -- (void) customEvent: (id) data; -- (void) performCallback: (id) info; -- (void) dummyMethod; -@end - -@implementation JuceAppDelegate - -- (JuceAppDelegate*) init -{ - [super init]; - - redirector = new AppDelegateRedirector(); - numPendingMessages = 0; - flushingMessages = false; - - NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; - - if (JUCEApplication::getInstance() != 0) - { - oldDelegate = [NSApp delegate]; - [NSApp setDelegate: self]; - } - else - { - oldDelegate = 0; - [center addObserver: self selector: @selector (applicationDidResignActive:) - name: NSApplicationDidResignActiveNotification object: NSApp]; - - [center addObserver: self selector: @selector (applicationDidBecomeActive:) - name: NSApplicationDidBecomeActiveNotification object: NSApp]; - - [center addObserver: self selector: @selector (applicationWillUnhide:) - name: NSApplicationWillUnhideNotification object: NSApp]; - } - - return self; -} - -- (void) dealloc -{ - if (oldDelegate != 0) - [NSApp setDelegate: oldDelegate]; - - redirector->deleteSelf(); - [super dealloc]; -} - -- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app -{ - return redirector->shouldTerminate(); -} - -- (BOOL) application: (NSApplication*) app openFile: (NSString*) filename -{ - return redirector->openFile (filename); -} - -- (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames -{ - return redirector->openFiles (filenames); -} - -- (void) applicationDidBecomeActive: (NSNotification*) aNotification -{ - redirector->focusChanged(); -} - -- (void) applicationDidResignActive: (NSNotification*) aNotification -{ - redirector->focusChanged(); -} - -- (void) applicationWillUnhide: (NSNotification*) aNotification -{ - redirector->focusChanged(); -} - -- (void) customEvent: (id) n -{ - atomicDecrement (numPendingMessages); - - NSData* data = (NSData*) n; - void* message = 0; - [data getBytes: &message length: sizeof (message)]; - - if (message != 0 && ! flushingMessages) - redirector->deliverMessage (message); -} - -- (void) performCallback: (id) info -{ - if ([info isKindOfClass: [NSData class]]) - { - CallbackMessagePayload* pl = (CallbackMessagePayload*) [((NSData*) info) bytes]; - - if (pl != 0) - redirector->performCallback (pl); - } - else - { - jassertfalse // should never get here! - } -} - -- (void) dummyMethod {} // (used as a way of running a dummy thread) - -@end - -BEGIN_JUCE_NAMESPACE - -static JuceAppDelegate* juceAppDelegate = 0; - -void MessageManager::runDispatchLoop() -{ - if (! quitMessagePosted) // check that the quit message wasn't already posted.. - { - const ScopedAutoReleasePool pool; - - // must only be called by the message thread! - jassert (isThisTheMessageThread()); - - [NSApp run]; - } -} - -void MessageManager::stopDispatchLoop() -{ - quitMessagePosted = true; - [NSApp stop: nil]; - [NSApp activateIgnoringOtherApps: YES]; // (if the app is inactive, it sits there and ignores the quit request until the next time it gets activated) -} - -static bool isEventBlockedByModalComps (NSEvent* e) -{ - if (Component::getNumCurrentlyModalComponents() == 0) - return false; - - NSWindow* const w = [e window]; - if (w == 0 || [w worksWhenModal]) - return false; - - bool isKey = false, isInputAttempt = false; - - switch ([e type]) - { - case NSKeyDown: - case NSKeyUp: - isKey = isInputAttempt = true; - break; - - case NSLeftMouseDown: - case NSRightMouseDown: - case NSOtherMouseDown: - isInputAttempt = true; - break; - - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSLeftMouseUp: - case NSRightMouseUp: - case NSOtherMouseUp: - case NSOtherMouseDragged: - if (Component::getComponentUnderMouse() != 0) - return false; - break; - - case NSMouseMoved: - case NSMouseEntered: - case NSMouseExited: - case NSCursorUpdate: - case NSScrollWheel: - case NSTabletPoint: - case NSTabletProximity: - break; - - default: - return false; - } - - for (int i = ComponentPeer::getNumPeers(); --i >= 0;) - { - ComponentPeer* const peer = ComponentPeer::getPeer (i); - NSView* const compView = (NSView*) peer->getNativeHandle(); - - if ([compView window] == w) - { - if (isKey) - { - if (compView == [w firstResponder]) - return false; - } - else - { - if (NSPointInRect ([compView convertPoint: [e locationInWindow] fromView: nil], - [compView bounds])) - return false; - } - } - } - - if (isInputAttempt) - { - if (! [NSApp isActive]) - [NSApp activateIgnoringOtherApps: YES]; - - Component* const modal = Component::getCurrentlyModalComponent (0); - if (modal != 0) - modal->inputAttemptWhenModal(); - } - - return true; -} - -bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) -{ - const ScopedAutoReleasePool pool; - jassert (isThisTheMessageThread()); // must only be called by the message thread - - uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor; - NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001]; - - while (Time::getMillisecondCounter() < endTime && ! quitMessagePosted) - { - const ScopedAutoReleasePool pool; - - [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode - beforeDate: endDate]; - - NSEvent* e = [NSApp nextEventMatchingMask: NSAnyEventMask - untilDate: endDate - inMode: NSDefaultRunLoopMode - dequeue: YES]; - - if (e != 0 && ! isEventBlockedByModalComps (e)) - [NSApp sendEvent: e]; - } - - return ! quitMessagePosted; -} - -//============================================================================== -void MessageManager::doPlatformSpecificInitialisation() -{ - if (juceAppDelegate == 0) - juceAppDelegate = [[JuceAppDelegate alloc] init]; - - // This launches a dummy thread, which forces Cocoa to initialise NSThreads - // correctly (needed prior to 10.5) - if (! [NSThread isMultiThreaded]) - [NSThread detachNewThreadSelector: @selector (dummyMethod) - toTarget: juceAppDelegate - withObject: nil]; - - initialiseMainMenu(); -} - -void MessageManager::doPlatformSpecificShutdown() -{ - if (juceAppDelegate != 0) - { - [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget: juceAppDelegate]; - [[NSNotificationCenter defaultCenter] removeObserver: juceAppDelegate]; - - // Annoyingly, cancelPerformSelectorsWithTarget can't actually cancel the messages - // sent by performSelectorOnMainThread, so need to manually flush these before quitting.. - juceAppDelegate->flushingMessages = true; - - for (int i = 100; --i >= 0 && numPendingMessages > 0;) - { - const ScopedAutoReleasePool pool; - [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode - beforeDate: [NSDate dateWithTimeIntervalSinceNow: 5 * 0.001]]; - } - - [juceAppDelegate release]; - juceAppDelegate = 0; - } -} - -bool juce_postMessageToSystemQueue (void* message) -{ - atomicIncrement (numPendingMessages); - - [juceAppDelegate performSelectorOnMainThread: @selector (customEvent:) - withObject: (id) [NSData dataWithBytes: &message length: (int) sizeof (message)] - waitUntilDone: NO]; - return true; -} - -void MessageManager::broadcastMessage (const String& value) throw() -{ -} - -void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, - void* data) -{ - if (isThisTheMessageThread()) - { - return (*callback) (data); - } - else - { - // If a thread has a MessageManagerLock and then tries to call this method, it'll - // deadlock because the message manager is blocked from running, so can never - // call your function.. - jassert (! MessageManager::getInstance()->currentThreadHasLockedMessageManager()); - - const ScopedAutoReleasePool pool; - - CallbackMessagePayload cmp; - cmp.function = callback; - cmp.parameter = data; - cmp.result = 0; - cmp.hasBeenExecuted = false; - - [juceAppDelegate performSelectorOnMainThread: @selector (performCallback:) - withObject: [NSData dataWithBytesNoCopy: &cmp - length: sizeof (cmp) - freeWhenDone: NO] - waitUntilDone: YES]; - - return cmp.result; - } -} - -#endif +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +// (This file gets included by juce_mac_NativeCode.mm, rather than being +// compiled on its own). +#ifdef JUCE_INCLUDED_FILE + +struct CallbackMessagePayload +{ + MessageCallbackFunction* function; + void* parameter; + void* volatile result; + bool volatile hasBeenExecuted; +}; + +/* When you use multiple DLLs which share similarly-named obj-c classes - like + for example having more than one juce plugin loaded into a host, then when a + method is called, the actual code that runs might actually be in a different module + than the one you expect... So any calls to library functions or statics that are + made inside obj-c methods will probably end up getting executed in a different DLL's + memory space. Not a great thing to happen - this obviously leads to bizarre crashes. + + To work around this insanity, I'm only allowing obj-c methods to make calls to + virtual methods of an object that's known to live inside the right module's space. +*/ +class AppDelegateRedirector +{ +public: + AppDelegateRedirector() {} + virtual ~AppDelegateRedirector() {} + + virtual NSApplicationTerminateReply shouldTerminate() + { + if (JUCEApplication::getInstance() != 0) + { + JUCEApplication::getInstance()->systemRequestedQuit(); + return NSTerminateCancel; + } + + return NSTerminateNow; + } + + virtual BOOL openFile (const NSString* filename) + { + if (JUCEApplication::getInstance() != 0) + { + JUCEApplication::getInstance()->anotherInstanceStarted (nsStringToJuce (filename)); + return YES; + } + + return NO; + } + + virtual void openFiles (NSArray* filenames) + { + StringArray files; + for (unsigned int i = 0; i < [filenames count]; ++i) + files.add (nsStringToJuce ((NSString*) [filenames objectAtIndex: i])); + + if (files.size() > 0 && JUCEApplication::getInstance() != 0) + { + JUCEApplication::getInstance()->anotherInstanceStarted (files.joinIntoString (T(" "))); + } + } + + virtual void focusChanged() + { + juce_HandleProcessFocusChange(); + } + + virtual void deliverMessage (void* message) + { + // no need for an mm lock here - deliverMessage locks it + MessageManager::getInstance()->deliverMessage (message); + } + + virtual void performCallback (CallbackMessagePayload* pl) + { + pl->result = (*pl->function) (pl->parameter); + pl->hasBeenExecuted = true; + } + + virtual void deleteSelf() + { + delete this; + } +}; + +END_JUCE_NAMESPACE +using namespace JUCE_NAMESPACE; + +#define JuceAppDelegate MakeObjCClassName(JuceAppDelegate) + +static int numPendingMessages = 0; + +@interface JuceAppDelegate : NSObject +{ +@private + id oldDelegate; + AppDelegateRedirector* redirector; + +@public + bool flushingMessages; +} + +- (JuceAppDelegate*) init; +- (void) dealloc; +- (BOOL) application: (NSApplication*) theApplication openFile: (NSString*) filename; +- (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames; +- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app; +- (void) applicationDidBecomeActive: (NSNotification*) aNotification; +- (void) applicationDidResignActive: (NSNotification*) aNotification; +- (void) applicationWillUnhide: (NSNotification*) aNotification; +- (void) customEvent: (id) data; +- (void) performCallback: (id) info; +- (void) dummyMethod; +@end + +@implementation JuceAppDelegate + +- (JuceAppDelegate*) init +{ + [super init]; + + redirector = new AppDelegateRedirector(); + numPendingMessages = 0; + flushingMessages = false; + + NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; + + if (JUCEApplication::getInstance() != 0) + { + oldDelegate = [NSApp delegate]; + [NSApp setDelegate: self]; + } + else + { + oldDelegate = 0; + [center addObserver: self selector: @selector (applicationDidResignActive:) + name: NSApplicationDidResignActiveNotification object: NSApp]; + + [center addObserver: self selector: @selector (applicationDidBecomeActive:) + name: NSApplicationDidBecomeActiveNotification object: NSApp]; + + [center addObserver: self selector: @selector (applicationWillUnhide:) + name: NSApplicationWillUnhideNotification object: NSApp]; + } + + return self; +} + +- (void) dealloc +{ + if (oldDelegate != 0) + [NSApp setDelegate: oldDelegate]; + + redirector->deleteSelf(); + [super dealloc]; +} + +- (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication*) app +{ + return redirector->shouldTerminate(); +} + +- (BOOL) application: (NSApplication*) app openFile: (NSString*) filename +{ + return redirector->openFile (filename); +} + +- (void) application: (NSApplication*) sender openFiles: (NSArray*) filenames +{ + return redirector->openFiles (filenames); +} + +- (void) applicationDidBecomeActive: (NSNotification*) aNotification +{ + redirector->focusChanged(); +} + +- (void) applicationDidResignActive: (NSNotification*) aNotification +{ + redirector->focusChanged(); +} + +- (void) applicationWillUnhide: (NSNotification*) aNotification +{ + redirector->focusChanged(); +} + +- (void) customEvent: (id) n +{ + atomicDecrement (numPendingMessages); + + NSData* data = (NSData*) n; + void* message = 0; + [data getBytes: &message length: sizeof (message)]; + + if (message != 0 && ! flushingMessages) + redirector->deliverMessage (message); +} + +- (void) performCallback: (id) info +{ + if ([info isKindOfClass: [NSData class]]) + { + CallbackMessagePayload* pl = (CallbackMessagePayload*) [((NSData*) info) bytes]; + + if (pl != 0) + redirector->performCallback (pl); + } + else + { + jassertfalse // should never get here! + } +} + +- (void) dummyMethod {} // (used as a way of running a dummy thread) + +@end + +BEGIN_JUCE_NAMESPACE + +static JuceAppDelegate* juceAppDelegate = 0; + +void MessageManager::runDispatchLoop() +{ + if (! quitMessagePosted) // check that the quit message wasn't already posted.. + { + const ScopedAutoReleasePool pool; + + // must only be called by the message thread! + jassert (isThisTheMessageThread()); + + [NSApp run]; + } +} + +void MessageManager::stopDispatchLoop() +{ + quitMessagePosted = true; + [NSApp stop: nil]; + [NSApp activateIgnoringOtherApps: YES]; // (if the app is inactive, it sits there and ignores the quit request until the next time it gets activated) +} + +static bool isEventBlockedByModalComps (NSEvent* e) +{ + if (Component::getNumCurrentlyModalComponents() == 0) + return false; + + NSWindow* const w = [e window]; + if (w == 0 || [w worksWhenModal]) + return false; + + bool isKey = false, isInputAttempt = false; + + switch ([e type]) + { + case NSKeyDown: + case NSKeyUp: + isKey = isInputAttempt = true; + break; + + case NSLeftMouseDown: + case NSRightMouseDown: + case NSOtherMouseDown: + isInputAttempt = true; + break; + + case NSLeftMouseDragged: + case NSRightMouseDragged: + case NSLeftMouseUp: + case NSRightMouseUp: + case NSOtherMouseUp: + case NSOtherMouseDragged: + if (Component::getComponentUnderMouse() != 0) + return false; + break; + + case NSMouseMoved: + case NSMouseEntered: + case NSMouseExited: + case NSCursorUpdate: + case NSScrollWheel: + case NSTabletPoint: + case NSTabletProximity: + break; + + default: + return false; + } + + for (int i = ComponentPeer::getNumPeers(); --i >= 0;) + { + ComponentPeer* const peer = ComponentPeer::getPeer (i); + NSView* const compView = (NSView*) peer->getNativeHandle(); + + if ([compView window] == w) + { + if (isKey) + { + if (compView == [w firstResponder]) + return false; + } + else + { + if (NSPointInRect ([compView convertPoint: [e locationInWindow] fromView: nil], + [compView bounds])) + return false; + } + } + } + + if (isInputAttempt) + { + if (! [NSApp isActive]) + [NSApp activateIgnoringOtherApps: YES]; + + Component* const modal = Component::getCurrentlyModalComponent (0); + if (modal != 0) + modal->inputAttemptWhenModal(); + } + + return true; +} + +bool MessageManager::runDispatchLoopUntil (int millisecondsToRunFor) +{ + const ScopedAutoReleasePool pool; + jassert (isThisTheMessageThread()); // must only be called by the message thread + + uint32 endTime = Time::getMillisecondCounter() + millisecondsToRunFor; + NSDate* endDate = [NSDate dateWithTimeIntervalSinceNow: millisecondsToRunFor * 0.001]; + + while (Time::getMillisecondCounter() < endTime && ! quitMessagePosted) + { + const ScopedAutoReleasePool pool; + + [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode + beforeDate: endDate]; + + NSEvent* e = [NSApp nextEventMatchingMask: NSAnyEventMask + untilDate: endDate + inMode: NSDefaultRunLoopMode + dequeue: YES]; + + if (e != 0 && ! isEventBlockedByModalComps (e)) + [NSApp sendEvent: e]; + } + + return ! quitMessagePosted; +} + +//============================================================================== +void MessageManager::doPlatformSpecificInitialisation() +{ + if (juceAppDelegate == 0) + juceAppDelegate = [[JuceAppDelegate alloc] init]; + + // This launches a dummy thread, which forces Cocoa to initialise NSThreads + // correctly (needed prior to 10.5) + if (! [NSThread isMultiThreaded]) + [NSThread detachNewThreadSelector: @selector (dummyMethod) + toTarget: juceAppDelegate + withObject: nil]; + + initialiseMainMenu(); +} + +void MessageManager::doPlatformSpecificShutdown() +{ + if (juceAppDelegate != 0) + { + [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget: juceAppDelegate]; + [[NSNotificationCenter defaultCenter] removeObserver: juceAppDelegate]; + + // Annoyingly, cancelPerformSelectorsWithTarget can't actually cancel the messages + // sent by performSelectorOnMainThread, so need to manually flush these before quitting.. + juceAppDelegate->flushingMessages = true; + + for (int i = 100; --i >= 0 && numPendingMessages > 0;) + { + const ScopedAutoReleasePool pool; + [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode + beforeDate: [NSDate dateWithTimeIntervalSinceNow: 5 * 0.001]]; + } + + [juceAppDelegate release]; + juceAppDelegate = 0; + } +} + +bool juce_postMessageToSystemQueue (void* message) +{ + atomicIncrement (numPendingMessages); + + [juceAppDelegate performSelectorOnMainThread: @selector (customEvent:) + withObject: (id) [NSData dataWithBytes: &message length: (int) sizeof (message)] + waitUntilDone: NO]; + return true; +} + +void MessageManager::broadcastMessage (const String& value) throw() +{ +} + +void* MessageManager::callFunctionOnMessageThread (MessageCallbackFunction* callback, + void* data) +{ + if (isThisTheMessageThread()) + { + return (*callback) (data); + } + else + { + // If a thread has a MessageManagerLock and then tries to call this method, it'll + // deadlock because the message manager is blocked from running, so can never + // call your function.. + jassert (! MessageManager::getInstance()->currentThreadHasLockedMessageManager()); + + const ScopedAutoReleasePool pool; + + CallbackMessagePayload cmp; + cmp.function = callback; + cmp.parameter = data; + cmp.result = 0; + cmp.hasBeenExecuted = false; + + [juceAppDelegate performSelectorOnMainThread: @selector (performCallback:) + withObject: [NSData dataWithBytesNoCopy: &cmp + length: sizeof (cmp) + freeWhenDone: NO] + waitUntilDone: YES]; + + return cmp.result; + } +} + +#endif diff --git a/build/macosx/platform_specific_code/juce_mac_NSViewComponent.mm b/build/macosx/platform_specific_code/juce_mac_NSViewComponent.mm index c7ba2f919f..9366e37c52 100644 --- a/build/macosx/platform_specific_code/juce_mac_NSViewComponent.mm +++ b/build/macosx/platform_specific_code/juce_mac_NSViewComponent.mm @@ -1,161 +1,161 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -// (This file gets included by juce_mac_NativeCode.mm, rather than being -// compiled on its own). -#ifdef JUCE_INCLUDED_FILE - -//============================================================================== -class NSViewComponentInternal : public ComponentMovementWatcher -{ - Component* const owner; - NSViewComponentPeer* currentPeer; - bool wasShowing; - -public: - NSView* const view; - - //============================================================================== - NSViewComponentInternal (NSView* const view_, Component* const owner_) - : ComponentMovementWatcher (owner_), - owner (owner_), - currentPeer (0), - wasShowing (false), - view (view_) - { - [view_ retain]; - - if (owner_->isShowing()) - componentPeerChanged(); - } - - ~NSViewComponentInternal() - { - [view removeFromSuperview]; - [view release]; - } - - //============================================================================== - void componentMovedOrResized (Component& comp, bool wasMoved, bool wasResized) - { - ComponentMovementWatcher::componentMovedOrResized (comp, wasMoved, wasResized); - - // The ComponentMovementWatcher version of this method avoids calling - // us when the top-level comp is resized, but for an NSView we need to know this - // because with inverted co-ords, we need to update the position even if the - // top-left pos hasn't changed - if (comp.isOnDesktop() && wasResized) - componentMovedOrResized (wasMoved, wasResized); - } - - void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) - { - Component* const topComp = owner->getTopLevelComponent(); - - if (topComp->getPeer() != 0) - { - int x = 0, y = 0; - owner->relativePositionToOtherComponent (topComp, x, y); - - NSRect r; - r.origin.x = (float) x; - r.origin.y = (float) y; - r.size.width = (float) owner->getWidth(); - r.size.height = (float) owner->getHeight(); - r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height); - - [view setFrame: r]; - } - } - - void componentPeerChanged() - { - NSViewComponentPeer* const peer = dynamic_cast (owner->getPeer()); - - if (currentPeer != peer) - { - [view removeFromSuperview]; - currentPeer = peer; - - if (peer != 0) - { - [peer->view addSubview: view]; - componentMovedOrResized (false, false); - } - } - - [view setHidden: ! owner->isShowing()]; - } - - void componentVisibilityChanged (Component&) - { - componentPeerChanged(); - } - - juce_UseDebuggingNewOperator - -private: - NSViewComponentInternal (const NSViewComponentInternal&); - const NSViewComponentInternal& operator= (const NSViewComponentInternal&); -}; - -//============================================================================== -NSViewComponent::NSViewComponent() - : info (0) -{ -} - -NSViewComponent::~NSViewComponent() -{ - delete info; -} - -void NSViewComponent::setView (void* view) -{ - if (view != getView()) - { - deleteAndZero (info); - - if (view != 0) - info = new NSViewComponentInternal ((NSView*) view, this); - } -} - -void* NSViewComponent::getView() const -{ - return info == 0 ? 0 : info->view; -} - -void NSViewComponent::paint (Graphics& g) -{ -} - -#endif +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +// (This file gets included by juce_mac_NativeCode.mm, rather than being +// compiled on its own). +#ifdef JUCE_INCLUDED_FILE + +//============================================================================== +class NSViewComponentInternal : public ComponentMovementWatcher +{ + Component* const owner; + NSViewComponentPeer* currentPeer; + bool wasShowing; + +public: + NSView* const view; + + //============================================================================== + NSViewComponentInternal (NSView* const view_, Component* const owner_) + : ComponentMovementWatcher (owner_), + owner (owner_), + currentPeer (0), + wasShowing (false), + view (view_) + { + [view_ retain]; + + if (owner_->isShowing()) + componentPeerChanged(); + } + + ~NSViewComponentInternal() + { + [view removeFromSuperview]; + [view release]; + } + + //============================================================================== + void componentMovedOrResized (Component& comp, bool wasMoved, bool wasResized) + { + ComponentMovementWatcher::componentMovedOrResized (comp, wasMoved, wasResized); + + // The ComponentMovementWatcher version of this method avoids calling + // us when the top-level comp is resized, but for an NSView we need to know this + // because with inverted co-ords, we need to update the position even if the + // top-left pos hasn't changed + if (comp.isOnDesktop() && wasResized) + componentMovedOrResized (wasMoved, wasResized); + } + + void componentMovedOrResized (bool /*wasMoved*/, bool /*wasResized*/) + { + Component* const topComp = owner->getTopLevelComponent(); + + if (topComp->getPeer() != 0) + { + int x = 0, y = 0; + owner->relativePositionToOtherComponent (topComp, x, y); + + NSRect r; + r.origin.x = (float) x; + r.origin.y = (float) y; + r.size.width = (float) owner->getWidth(); + r.size.height = (float) owner->getHeight(); + r.origin.y = [[view superview] frame].size.height - (r.origin.y + r.size.height); + + [view setFrame: r]; + } + } + + void componentPeerChanged() + { + NSViewComponentPeer* const peer = dynamic_cast (owner->getPeer()); + + if (currentPeer != peer) + { + [view removeFromSuperview]; + currentPeer = peer; + + if (peer != 0) + { + [peer->view addSubview: view]; + componentMovedOrResized (false, false); + } + } + + [view setHidden: ! owner->isShowing()]; + } + + void componentVisibilityChanged (Component&) + { + componentPeerChanged(); + } + + juce_UseDebuggingNewOperator + +private: + NSViewComponentInternal (const NSViewComponentInternal&); + const NSViewComponentInternal& operator= (const NSViewComponentInternal&); +}; + +//============================================================================== +NSViewComponent::NSViewComponent() + : info (0) +{ +} + +NSViewComponent::~NSViewComponent() +{ + delete info; +} + +void NSViewComponent::setView (void* view) +{ + if (view != getView()) + { + deleteAndZero (info); + + if (view != 0) + info = new NSViewComponentInternal ((NSView*) view, this); + } +} + +void* NSViewComponent::getView() const +{ + return info == 0 ? 0 : info->view; +} + +void NSViewComponent::paint (Graphics& g) +{ +} + +#endif diff --git a/build/macosx/platform_specific_code/juce_mac_NSViewComponentPeer.mm b/build/macosx/platform_specific_code/juce_mac_NSViewComponentPeer.mm index dc28c01eb4..13a72bf589 100644 --- a/build/macosx/platform_specific_code/juce_mac_NSViewComponentPeer.mm +++ b/build/macosx/platform_specific_code/juce_mac_NSViewComponentPeer.mm @@ -1456,7 +1456,7 @@ bool NSViewComponentPeer::canBecomeKeyWindow() // If running as a plugin, let the component decide whether it's going to allow the window to get focused. return ((getStyleFlags() & juce::ComponentPeer::windowIsTemporary) == 0) && (JUCEApplication::getInstance() != 0 - || (isValidPeer (this) + || (isValidPeer (this) && ! getComponent()->getComponentPropertyBool ("juce_disallowFocus", false, false))); } diff --git a/build/macosx/platform_specific_code/juce_mac_NativeCode.mm b/build/macosx/platform_specific_code/juce_mac_NativeCode.mm index d1133cb4c1..dcdc509f4c 100644 --- a/build/macosx/platform_specific_code/juce_mac_NativeCode.mm +++ b/build/macosx/platform_specific_code/juce_mac_NativeCode.mm @@ -81,10 +81,10 @@ BEGIN_JUCE_NAMESPACE //============================================================================== /** This suffix is used for naming all Obj-C classes that are used inside juce. - + Because of the flat naming structure used by Obj-C, you can get horrible situations where two DLLs are loaded into a host, each of which uses classes with the same names, and these get - cross-linked so that when you make a call to a class that you thought was private, it ends up + cross-linked so that when you make a call to a class that you thought was private, it ends up actually calling into a similarly named class in the other module's address space. By changing this macro to a unique value, you ensure that all the obj-C classes in your app diff --git a/build/win32/platform_specific_code/juce_win32_ASIO.cpp b/build/win32/platform_specific_code/juce_win32_ASIO.cpp index 0ac2e89809..5ca9d092aa 100644 --- a/build/win32/platform_specific_code/juce_win32_ASIO.cpp +++ b/build/win32/platform_specific_code/juce_win32_ASIO.cpp @@ -86,7 +86,7 @@ class JUCE_API ASIOAudioIODevice : public AudioIODevice, public: Component ourWindow; - ASIOAudioIODevice (const String& name_, const CLSID classId_, const int slotNumber, + ASIOAudioIODevice (const String& name_, const CLSID classId_, const int slotNumber, const String& optionalDllForDirectLoading_) : AudioIODevice (name_, T("ASIO")), asioObject (0), diff --git a/build/win32/platform_specific_code/juce_win32_CameraDevice.cpp b/build/win32/platform_specific_code/juce_win32_CameraDevice.cpp index b3581c4539..9177f2ab3b 100644 --- a/build/win32/platform_specific_code/juce_win32_CameraDevice.cpp +++ b/build/win32/platform_specific_code/juce_win32_CameraDevice.cpp @@ -196,7 +196,7 @@ public: } imageSwapLock.enter(); - int ls, ps; + int ls, ps; const int lineStride = width * 3; uint8* const dest = loadingImage->lockPixelDataReadWrite (0, 0, width, height, ls, ps); @@ -535,11 +535,11 @@ private: while (enumerator->Next (1, &pin, 0) == S_OK) { - PIN_DIRECTION dir; - pin->QueryDirection (&dir); + PIN_DIRECTION dir; + pin->QueryDirection (&dir); - if (wantedDirection == dir) - { + if (wantedDirection == dir) + { PIN_INFO info; zerostruct (info); pin->QueryPinInfo (&info); @@ -547,10 +547,10 @@ private: if (pinName == 0 || String (pinName).equalsIgnoreCase (String (info.achName))) { pin.p->AddRef(); - *result = pin; - return true; + *result = pin; + return true; } - } + } } return false; @@ -578,7 +578,7 @@ private: return false; graphRegistrationID = 0; - return SUCCEEDED (rot->Register (0, graphBuilder, moniker, &graphRegistrationID)); + return SUCCEEDED (rot->Register (0, graphBuilder, moniker, &graphRegistrationID)); } void removeGraphFromRot() @@ -586,7 +586,7 @@ private: ComSmartPtr rot; if (SUCCEEDED (GetRunningObjectTable (0, &rot))) - rot->Revoke (graphRegistrationID); + rot->Revoke (graphRegistrationID); } static void deleteMediaType (AM_MEDIA_TYPE* const pmt) @@ -606,23 +606,23 @@ private: public: GrabberCallback (DShowCameraDeviceInteral& owner_) : owner (owner_) - { + { } HRESULT __stdcall QueryInterface (REFIID id, void** result) { - if (id == IID_IUnknown) - *result = dynamic_cast (this); - else if (id == IID_ISampleGrabberCB) - *result = dynamic_cast (this); - else - { - *result = 0; - return E_NOINTERFACE; - } - - AddRef(); - return S_OK; + if (id == IID_IUnknown) + *result = dynamic_cast (this); + else if (id == IID_ISampleGrabberCB) + *result = dynamic_cast (this); + else + { + *result = 0; + return E_NOINTERFACE; + } + + AddRef(); + return S_OK; } ULONG __stdcall AddRef() { return ++refCount; } @@ -631,13 +631,13 @@ private: //============================================================================== STDMETHODIMP SampleCB (double /*SampleTime*/, IMediaSample* /*pSample*/) { - return E_FAIL; + return E_FAIL; } STDMETHODIMP BufferCB (double time, BYTE* buffer, long bufferSize) { - owner.handleFrame (time, buffer, bufferSize); - return S_OK; + owner.handleFrame (time, buffer, bufferSize); + return S_OK; } private: diff --git a/build/win32/platform_specific_code/juce_win32_Files.cpp b/build/win32/platform_specific_code/juce_win32_Files.cpp index b6af68d04e..b492296ae9 100644 --- a/build/win32/platform_specific_code/juce_win32_Files.cpp +++ b/build/win32/platform_specific_code/juce_win32_Files.cpp @@ -372,7 +372,7 @@ static int64 getDiskSpaceInfo (String fn, const bool total) throw() ULARGE_INTEGER spc, tot, totFree; if (GetDiskFreeSpaceEx (fn, &spc, &tot, &totFree)) - return (int64) (total ? tot.QuadPart + return (int64) (total ? tot.QuadPart : spc.QuadPart); return 0; diff --git a/build/win32/platform_specific_code/juce_win32_NativeIncludes.h b/build/win32/platform_specific_code/juce_win32_NativeIncludes.h index 975d62bb16..1016e83a42 100644 --- a/build/win32/platform_specific_code/juce_win32_NativeIncludes.h +++ b/build/win32/platform_specific_code/juce_win32_NativeIncludes.h @@ -201,7 +201,7 @@ public: HRESULT CoCreateInstance (REFCLSID rclsid, DWORD dwClsContext) { -#ifndef __MINGW32__ +#ifndef __MINGW32__ operator= (0); return ::CoCreateInstance (rclsid, 0, dwClsContext, __uuidof(T), (void**) &p); #else diff --git a/build/win32/platform_specific_code/juce_win32_Windowing.cpp b/build/win32/platform_specific_code/juce_win32_Windowing.cpp index 7657b5c2bd..267a848942 100644 --- a/build/win32/platform_specific_code/juce_win32_Windowing.cpp +++ b/build/win32/platform_specific_code/juce_win32_Windowing.cpp @@ -2301,7 +2301,7 @@ bool Process::isForegroundProcess() throw() if (fg == 0) return true; - // when running as a plugin in IE8, the browser UI runs in a different process to the plugin, so + // when running as a plugin in IE8, the browser UI runs in a different process to the plugin, so // process ID isn't a reliable way to check if the foreground window belongs to us - instead, we // have to see if any of our windows are children of the foreground window fg = GetAncestor (fg, GA_ROOT); diff --git a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm index 29c7b8733c..a431c20e78 100644 --- a/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm +++ b/extras/audio plugins/wrapper/AU/juce_AU_Wrapper.mm @@ -1191,7 +1191,7 @@ private: setSize (contentComp->getWidth(), contentComp->getHeight()); SizeControl (parentHIView, contentComp->getWidth(), contentComp->getHeight()); - + WindowRef windowRef = HIViewGetWindow (parentHIView); hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef]; @@ -1239,7 +1239,7 @@ private: if (comp != 0) comp->removeComponentListener (this); - + const ScopedAutoReleasePool pool; NSWindow* pluginWindow = [((NSView*) getWindowHandle()) window]; diff --git a/extras/audio plugins/wrapper/RTAS/juce_RTAS_DigiCode_Header.h b/extras/audio plugins/wrapper/RTAS/juce_RTAS_DigiCode_Header.h index 166d403a5c..ef3b4d6883 100644 --- a/extras/audio plugins/wrapper/RTAS/juce_RTAS_DigiCode_Header.h +++ b/extras/audio plugins/wrapper/RTAS/juce_RTAS_DigiCode_Header.h @@ -1,78 +1,78 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#ifndef __JUCE_RTAS_DIGICODE_HEADER_JUCEHEADER__ -#define __JUCE_RTAS_DIGICODE_HEADER_JUCEHEADER__ - -#include "../juce_IncludeCharacteristics.h" - -//============================================================================== -#if JucePlugin_Build_RTAS -#ifdef _MSC_VER - - #define kCompileAsCodeResource 0 - #define kBuildStandAlone 0 - #define kNoDSP 0 - #define kNoDAE 0 - #define kNoSDS 0 - #define kNoViews 0 - #define kUseDSPCodeDecode 0 - - #define WINDOWS_VERSION 1 - #define PLUGIN_SDK_BUILD 1 - #define PLUGIN_SDK_DIRECTMIDI 1 - - // the Digidesign projects all use a struct alignment of 2.. - #pragma pack (2) - #pragma warning (disable: 4267 4996 4311 4312 4103) - - #include "ForcedInclude.h" - -#else - - #define kCompileAsCodeResource 0 - #define kNoDSP 1 - #define kNoDAE 0 - #define kNoSDS 0 - #define kNoViews 0 - #define kUseDSPCodeDecode 0 - - #define MAC_VERSION 1 - #define PLUGIN_SDK_BUILD 1 - #define PLUGIN_SDK_DIRECTMIDI 1 - #define DIGI_PASCAL - - #include "MacAlwaysInclude.h" - -#endif -#endif - -#endif // __JUCE_RTAS_DIGICODE_HEADER_JUCEHEADER__ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#ifndef __JUCE_RTAS_DIGICODE_HEADER_JUCEHEADER__ +#define __JUCE_RTAS_DIGICODE_HEADER_JUCEHEADER__ + +#include "../juce_IncludeCharacteristics.h" + +//============================================================================== +#if JucePlugin_Build_RTAS +#ifdef _MSC_VER + + #define kCompileAsCodeResource 0 + #define kBuildStandAlone 0 + #define kNoDSP 0 + #define kNoDAE 0 + #define kNoSDS 0 + #define kNoViews 0 + #define kUseDSPCodeDecode 0 + + #define WINDOWS_VERSION 1 + #define PLUGIN_SDK_BUILD 1 + #define PLUGIN_SDK_DIRECTMIDI 1 + + // the Digidesign projects all use a struct alignment of 2.. + #pragma pack (2) + #pragma warning (disable: 4267 4996 4311 4312 4103) + + #include "ForcedInclude.h" + +#else + + #define kCompileAsCodeResource 0 + #define kNoDSP 1 + #define kNoDAE 0 + #define kNoSDS 0 + #define kNoViews 0 + #define kUseDSPCodeDecode 0 + + #define MAC_VERSION 1 + #define PLUGIN_SDK_BUILD 1 + #define PLUGIN_SDK_DIRECTMIDI 1 + #define DIGI_PASCAL + + #include "MacAlwaysInclude.h" + +#endif +#endif + +#endif // __JUCE_RTAS_DIGICODE_HEADER_JUCEHEADER__ diff --git a/extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp b/extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp index ff03ac94b2..63392bae7d 100644 --- a/extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp +++ b/extras/audio plugins/wrapper/RTAS/juce_RTAS_Wrapper.cpp @@ -1,1002 +1,1002 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#ifdef _MSC_VER - // (this is a workaround for a build problem in VC9) - #define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY - #include -#endif - -#include "juce_RTAS_DigiCode_Header.h" - -#if JucePlugin_Build_RTAS - -#ifdef _MSC_VER - #include "Mac2Win.H" -#endif - -/* Note about include paths - ------------------------ - - To be able to include all the Digidesign headers correctly, you'll need to add this - lot to your include path: - - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\EffectClasses - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\ProcessClasses - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\ProcessClasses\Interfaces - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Utilities - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\RTASP_Adapt - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\CoreClasses - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Controls - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Meters - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\ViewClasses - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\DSPClasses - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Interfaces - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\common - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\common\Platform - c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\SignalProcessing\Public - C:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugIns\DSPManager\Interfaces - c:\yourdirectory\PT_80_SDK\AlturaPorts\SADriver\Interfaces - c:\yourdirectory\PT_80_SDK\AlturaPorts\DigiPublic\Interfaces - c:\yourdirectory\PT_80_SDK\AlturaPorts\Fic\Interfaces\DAEClient - c:\yourdirectory\PT_80_SDK\AlturaPorts\NewFileLibs\Cmn - c:\yourdirectory\PT_80_SDK\AlturaPorts\NewFileLibs\DOA - c:\yourdirectory\PT_80_SDK\AlturaPorts\AlturaSource\PPC_H - c:\yourdirectory\PT_80_SDK\AlturaPorts\AlturaSource\AppSupport - c:\yourdirectory\PT_80_SDK\AvidCode\AVX2sdk\AVX\avx2\avx2sdk\inc - C:\yourdirectory\PT_80_SDK\xplat\AVX\avx2\avx2sdk\inc - - NB. If you hit a huge pile of bugs around here, make sure that you've not got the - Apple QuickTime headers before the PT headers in your path, because there are - some filename clashes between them. - -*/ -#include "CEffectGroupMIDI.h" -#include "CEffectProcessMIDI.h" -#include "CEffectProcessRTAS.h" -#include "CCustomView.h" -#include "CEffectTypeRTAS.h" -#include "CPluginControl.h" -#include "CPluginControl_OnOff.h" -#include "FicProcessTokens.h" - -//============================================================================== -#ifdef _MSC_VER - #pragma pack (push, 8) -#endif - -#include "../juce_PluginHeaders.h" - -#ifdef _MSC_VER - #pragma pack (pop) - - #if JUCE_DEBUG - #define PT_LIB_PATH JucePlugin_WinBag_path "\\Debug\\lib\\" - #else - #define PT_LIB_PATH JucePlugin_WinBag_path "\\Release\\lib\\" - #endif - - #pragma comment(lib, PT_LIB_PATH "DAE.lib") - #pragma comment(lib, PT_LIB_PATH "DigiExt.lib") - #pragma comment(lib, PT_LIB_PATH "DSI.lib") - #pragma comment(lib, PT_LIB_PATH "PluginLib.lib") - -#endif - -#undef Component -#undef MemoryBlock - -//============================================================================== -#if JUCE_WIN32 - extern void JUCE_CALLTYPE attachSubWindow (void* hostWindow, int& titleW, int& titleH, JUCE_NAMESPACE::Component* comp); - extern void JUCE_CALLTYPE resizeHostWindow (void* hostWindow, int& titleW, int& titleH, JUCE_NAMESPACE::Component* comp); - #if ! JucePlugin_EditorRequiresKeyboardFocus - extern void JUCE_CALLTYPE passFocusToHostWindow (void* hostWindow); - #endif -#else - extern void* attachSubWindow (void* hostWindowRef, JUCE_NAMESPACE::Component* comp); - extern void removeSubWindow (void* nsWindow, JUCE_NAMESPACE::Component* comp); -#endif - -const int midiBufferSize = 1024; -const OSType juceChunkType = 'juce'; -static const int bypassControlIndex = 1; - -//============================================================================== -/** Somewhere in the codebase of your plugin, you need to implement this function - and make it return a new instance of the filter subclass that you're building. -*/ -extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); - - -//============================================================================== -static float longToFloat (const long n) throw() -{ - return (float) ((((double) n) + (double) 0x80000000) / (double) 0xffffffff); -} - -static long floatToLong (const float n) throw() -{ - return roundDoubleToInt (jlimit (-(double) 0x80000000, - (double) 0x7fffffff, - n * (double) 0xffffffff - (double) 0x80000000)); -} - -static int numInstances = 0; - -//============================================================================== -class JucePlugInProcess : public CEffectProcessMIDI, - public CEffectProcessRTAS, - public AudioProcessorListener, - public AudioPlayHead, - public AsyncUpdater -{ -public: - //============================================================================== - JucePlugInProcess() - : midiBufferNode (0), - midiTransport (0), - channels (0), - prepared (false), - sampleRate (44100.0) - { - juceFilter = createPluginFilter(); - jassert (juceFilter != 0); - - AddChunk (juceChunkType, "Juce Audio Plugin Data"); - - ++numInstances; - } - - ~JucePlugInProcess() - { - if (mLoggedIn) - MIDILogOut(); - - deleteAndZero (midiBufferNode); - deleteAndZero (midiTransport); - - if (prepared) - juceFilter->releaseResources(); - - delete juceFilter; - juce_free (channels); - - if (--numInstances == 0) - shutdownJuce_GUI(); - } - - //============================================================================== - class JuceCustomUIView : public CCustomView, - public Timer - { - public: - //============================================================================== - JuceCustomUIView (AudioProcessor* const filter_, - JucePlugInProcess* const process_) - : filter (filter_), - process (process_), - wrapper (0), - editorComp (0) - { - // setting the size in here crashes PT for some reason, so keep it simple.. - } - - ~JuceCustomUIView() - { - deleteEditorComp(); - } - - //============================================================================== - void updateSize() - { - if (editorComp == 0) - { - editorComp = filter->createEditorIfNeeded(); - jassert (editorComp != 0); - } - - Rect oldRect; - GetRect (&oldRect); - - Rect r; - r.left = 0; - r.top = 0; - r.right = editorComp->getWidth(); - r.bottom = editorComp->getHeight(); - SetRect (&r); - - if ((oldRect.right != r.right) || (oldRect.bottom != r.bottom)) - startTimer (50); - } - - void timerCallback() - { - if (! JUCE_NAMESPACE::Component::isMouseButtonDownAnywhere()) - { - stopTimer(); - - // Send a token to the host to tell it about the resize - SSetProcessWindowResizeToken token (process->fRootNameId, process->fRootNameId); - FicSDSDispatchToken (&token); - } - } - - void attachToWindow (GrafPtr port) - { - if (port != 0) - { - updateSize(); - -#if JUCE_WIN32 - void* const hostWindow = (void*) ASI_GethWnd ((WindowPtr) port); -#else - void* const hostWindow = (void*) GetWindowFromPort (port); -#endif - deleteAndZero (wrapper); - - wrapper = new EditorCompWrapper (hostWindow, editorComp, this); - } - else - { - deleteEditorComp(); - } - } - - void DrawContents (Rect*) - { -#if JUCE_WIN32 - if (wrapper != 0) - { - ComponentPeer* const peer = wrapper->getPeer(); - - if (peer != 0) - { - // (seems to be required in PT6.4, but not in 7.x) - peer->repaint (0, 0, wrapper->getWidth(), wrapper->getHeight()); - } - } -#endif - } - - void DrawBackground (Rect*) {} - - //============================================================================== - private: - AudioProcessor* const filter; - JucePlugInProcess* const process; - JUCE_NAMESPACE::Component* wrapper; - AudioProcessorEditor* editorComp; - - void deleteEditorComp() - { - if (editorComp != 0 || wrapper != 0) - { -#if JUCE_MAC - const ScopedAutoReleasePool pool; -#endif - PopupMenu::dismissAllActiveMenus(); - - JUCE_NAMESPACE::Component* const modalComponent = JUCE_NAMESPACE::Component::getCurrentlyModalComponent(); - if (modalComponent != 0) - modalComponent->exitModalState (0); - - filter->editorBeingDeleted (editorComp); - - deleteAndZero (editorComp); - deleteAndZero (wrapper); - } - } - - //============================================================================== - // A component to hold the AudioProcessorEditor, and cope with some housekeeping - // chores when it changes or repaints. - class EditorCompWrapper : public JUCE_NAMESPACE::Component -#if ! JUCE_MAC - , public FocusChangeListener -#endif - { - public: - EditorCompWrapper (void* const hostWindow_, - Component* const editorComp, - JuceCustomUIView* const owner_) - : hostWindow (hostWindow_), - owner (owner_), - titleW (0), - titleH (0) - { -#if JucePlugin_EditorRequiresKeyboardFocus - setWantsKeyboardFocus (true); -#else - setComponentProperty ("juce_disallowFocus", true); - setWantsKeyboardFocus (false); -#endif - setOpaque (true); - setBroughtToFrontOnMouseClick (true); - setBounds (editorComp->getBounds()); - editorComp->setTopLeftPosition (0, 0); - addAndMakeVisible (editorComp); - -#if JUCE_WIN32 - attachSubWindow (hostWindow, titleW, titleH, this); -#else - nsWindow = attachSubWindow (hostWindow, this); -#endif - setVisible (true); - -#if JUCE_WIN32 && ! JucePlugin_EditorRequiresKeyboardFocus - Desktop::getInstance().addFocusChangeListener (this); -#endif - } - - ~EditorCompWrapper() - { -#if JUCE_WIN32 && ! JucePlugin_EditorRequiresKeyboardFocus - Desktop::getInstance().removeFocusChangeListener (this); -#endif - -#if JUCE_MAC - removeSubWindow (nsWindow, this); -#endif - } - - void paint (Graphics&) - { - } - - void resized() - { - JUCE_NAMESPACE::Component* const c = getChildComponent (0); - - if (c != 0) - c->setBounds (0, 0, getWidth(), getHeight()); - - repaint(); - } - -#if JUCE_WIN32 - void globalFocusChanged (JUCE_NAMESPACE::Component*) - { - #if ! JucePlugin_EditorRequiresKeyboardFocus - if (hasKeyboardFocus (true)) - passFocusToHostWindow (hostWindow); - #endif - } -#endif - - void childBoundsChanged (JUCE_NAMESPACE::Component* child) - { - setSize (child->getWidth(), child->getHeight()); - child->setTopLeftPosition (0, 0); - -#if JUCE_WIN32 - resizeHostWindow (hostWindow, titleW, titleH, this); -#endif - owner->updateSize(); - } - - void userTriedToCloseWindow() - { - } - - //============================================================================== - juce_UseDebuggingNewOperator - - private: - void* const hostWindow; - void* nsWindow; - JuceCustomUIView* const owner; - int titleW, titleH; - }; - }; - - JuceCustomUIView* getView() const - { - return dynamic_cast (fOurPlugInView); - } - - void GetViewRect (Rect* size) - { - if (getView() != 0) - getView()->updateSize(); - - CEffectProcessRTAS::GetViewRect (size); - } - - CPlugInView* CreateCPlugInView() - { - return new JuceCustomUIView (juceFilter, this); - } - - void SetViewPort (GrafPtr port) - { - CEffectProcessRTAS::SetViewPort (port); - - if (getView() != 0) - getView()->attachToWindow (port); - } - - //============================================================================== -protected: - ComponentResult GetDelaySamplesLong (long* aNumSamples) - { - if (aNumSamples != 0) - *aNumSamples = juceFilter != 0 ? juceFilter->getLatencySamples() : 0; - - return noErr; - } - - //============================================================================== - void EffectInit() - { - SFicPlugInStemFormats stems; - GetProcessType()->GetStemFormats (&stems); - - juceFilter->setPlayConfigDetails (fNumInputs, fNumOutputs, - juceFilter->getSampleRate(), juceFilter->getBlockSize()); - - AddControl (new CPluginControl_OnOff ('bypa', "Master Bypass\nMastrByp\nMByp\nByp", false, true)); - DefineMasterBypassControlIndex (bypassControlIndex); - - for (int i = 0; i < juceFilter->getNumParameters(); ++i) - AddControl (new JucePluginControl (juceFilter, i)); - - // we need to do this midi log-in to get timecode, regardless of whether - // the plugin actually uses midi... - if (MIDILogIn() == noErr) - { -#if JucePlugin_WantsMidiInput - CEffectType* const type = dynamic_cast (this->GetProcessType()); - - if (type != 0) - { - char nodeName [64]; - type->GetProcessTypeName (63, nodeName); - p2cstrcpy (nodeName, reinterpret_cast (nodeName)); - - midiBufferNode = new CEffectMIDIOtherBufferedNode (&mMIDIWorld, - 8192, - eLocalNode, - nodeName, - midiBuffer); - - midiBufferNode->Initialize (1, true); - } -#endif - } - - midiTransport = new CEffectMIDITransport (&mMIDIWorld); - - juceFilter->setPlayHead (this); - juceFilter->addListener (this); - } - - void handleAsyncUpdate() - { - if (! prepared) - { - sampleRate = gProcessGroup->GetSampleRate(); - jassert (sampleRate > 0); - - juce_free (channels); - channels = (float**) juce_calloc (sizeof (float*) * jmax (juceFilter->getNumInputChannels(), - juceFilter->getNumOutputChannels())); - - juceFilter->setPlayConfigDetails (fNumInputs, fNumOutputs, - sampleRate, mRTGlobals->mHWBufferSizeInSamples); - - juceFilter->prepareToPlay (sampleRate, - mRTGlobals->mHWBufferSizeInSamples); - - prepared = true; - } - } - - void RenderAudio (float** inputs, float** outputs, long numSamples) - { - if (! prepared) - { - triggerAsyncUpdate(); - bypassBuffers (inputs, outputs, numSamples); - return; - } - - if (mBypassed) - { - bypassBuffers (inputs, outputs, numSamples); - return; - } - -#if JucePlugin_WantsMidiInput - midiEvents.clear(); - - const Cmn_UInt32 bufferSize = mRTGlobals->mHWBufferSizeInSamples; - - if (midiBufferNode->GetAdvanceScheduleTime() != bufferSize) - midiBufferNode->SetAdvanceScheduleTime (bufferSize); - - if (midiBufferNode->FillMIDIBuffer (mRTGlobals->mRunningTime, numSamples) == noErr) - { - jassert (midiBufferNode->GetBufferPtr() != 0); - const int numMidiEvents = midiBufferNode->GetBufferSize(); - - for (int i = 0; i < numMidiEvents; ++i) - { - const DirectMidiPacket& m = midiBuffer[i]; - - jassert ((int) m.mTimestamp < numSamples); - - midiEvents.addEvent (m.mData, m.mLength, - jlimit (0, (int) numSamples - 1, (int) m.mTimestamp)); - } - } -#endif - -#if defined (JUCE_DEBUG) || JUCE_LOG_ASSERTIONS - const int numMidiEventsComingIn = midiEvents.getNumEvents(); - (void) numMidiEventsComingIn; -#endif - - { - const ScopedLock sl (juceFilter->getCallbackLock()); - - const int numIn = juceFilter->getNumInputChannels(); - const int numOut = juceFilter->getNumOutputChannels(); - const int totalChans = jmax (numIn, numOut); - - if (juceFilter->isSuspended()) - { - for (int i = 0; i < numOut; ++i) - zeromem (outputs [i], sizeof (float) * numSamples); - } - else - { - { - int i; - for (i = 0; i < numOut; ++i) - { - channels[i] = outputs [i]; - - if (i < numIn && inputs != outputs) - memcpy (outputs [i], inputs[i], sizeof (float) * numSamples); - } - - for (; i < numIn; ++i) - channels [i] = inputs [i]; - } - - AudioSampleBuffer chans (channels, totalChans, numSamples); - - juceFilter->processBlock (chans, midiEvents); - } - } - - if (! midiEvents.isEmpty()) - { -#if JucePlugin_ProducesMidiOutput - const juce::uint8* midiEventData; - int midiEventSize, midiEventPosition; - MidiBuffer::Iterator i (midiEvents); - - while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition)) - { -// jassert (midiEventPosition >= 0 && midiEventPosition < (int) numSamples); - - //xxx - } -#else - // if your plugin creates midi messages, you'll need to set - // the JucePlugin_ProducesMidiOutput macro to 1 in your - // JucePluginCharacteristics.h file - jassert (midiEvents.getNumEvents() <= numMidiEventsComingIn); -#endif - - midiEvents.clear(); - } - } - - //============================================================================== - ComponentResult GetChunkSize (OSType chunkID, long* size) - { - if (chunkID == juceChunkType) - { - tempFilterData.setSize (0); - juceFilter->getStateInformation (tempFilterData); - - *size = sizeof (SFicPlugInChunkHeader) + tempFilterData.getSize(); - return noErr; - } - - return CEffectProcessMIDI::GetChunkSize (chunkID, size); - } - - ComponentResult GetChunk (OSType chunkID, SFicPlugInChunk* chunk) - { - if (chunkID == juceChunkType) - { - if (tempFilterData.getSize() == 0) - juceFilter->getStateInformation (tempFilterData); - - chunk->fSize = sizeof (SFicPlugInChunkHeader) + tempFilterData.getSize(); - tempFilterData.copyTo ((void*) chunk->fData, 0, tempFilterData.getSize()); - - tempFilterData.setSize (0); - - return noErr; - } - - return CEffectProcessMIDI::GetChunk (chunkID, chunk); - } - - ComponentResult SetChunk (OSType chunkID, SFicPlugInChunk* chunk) - { - if (chunkID == juceChunkType) - { - tempFilterData.setSize (0); - - if (chunk->fSize - sizeof (SFicPlugInChunkHeader) > 0) - { - juceFilter->setStateInformation ((void*) chunk->fData, - chunk->fSize - sizeof (SFicPlugInChunkHeader)); - } - - return noErr; - } - - return CEffectProcessMIDI::SetChunk (chunkID, chunk); - } - - //============================================================================== - ComponentResult UpdateControlValue (long controlIndex, long value) - { - if (controlIndex != bypassControlIndex) - juceFilter->setParameter (controlIndex - 2, longToFloat (value)); - else - mBypassed = (value > 0); - - return CProcess::UpdateControlValue (controlIndex, value); - } - - //============================================================================== - bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info) - { - // this method can only be called while the plugin is running - jassert (prepared); - - Cmn_Float64 bpm = 120.0; - Cmn_Int32 num = 4, denom = 4; - Cmn_Int64 ticks = 0; - Cmn_Bool isPlaying = false; - - if (midiTransport != 0) - { - midiTransport->GetCurrentTempo (&bpm); - midiTransport->IsTransportPlaying (&isPlaying); - midiTransport->GetCurrentMeter (&num, &denom); - midiTransport->GetCurrentTickPosition (&ticks); - } - - info.bpm = bpm; - info.timeSigNumerator = num; - info.timeSigDenominator = denom; - info.isPlaying = isPlaying; - info.isRecording = false; - info.ppqPosition = ticks / 960000.0; - info.ppqPositionOfLastBarStart = 0; //xxx no idea how to get this correctly.. - - // xxx incorrect if there are tempo changes, but there's no - // other way of getting this info.. - info.timeInSeconds = ticks * (60.0 / 960000.0) / bpm; - - double framesPerSec = 24.0; - - switch (fTimeCodeInfo.mFrameRate) - { - case ficFrameRate_24Frame: - info.frameRate = AudioPlayHead::fps24; - break; - - case ficFrameRate_25Frame: - info.frameRate = AudioPlayHead::fps25; - framesPerSec = 25.0; - break; - - case ficFrameRate_2997NonDrop: - info.frameRate = AudioPlayHead::fps2997; - framesPerSec = 29.97002997; - break; - - case ficFrameRate_2997DropFrame: - info.frameRate = AudioPlayHead::fps2997drop; - framesPerSec = 29.97002997; - break; - - case ficFrameRate_30NonDrop: - info.frameRate = AudioPlayHead::fps30; - framesPerSec = 30.0; - break; - - case ficFrameRate_30DropFrame: - info.frameRate = AudioPlayHead::fps30drop; - framesPerSec = 30.0; - break; - - case ficFrameRate_23976: - // xxx not strictly true.. - info.frameRate = AudioPlayHead::fps24; - framesPerSec = 23.976; - break; - - default: - info.frameRate = AudioPlayHead::fpsUnknown; - break; - } - - info.editOriginTime = fTimeCodeInfo.mFrameOffset / framesPerSec; - - return true; - } - - void audioProcessorParameterChanged (AudioProcessor*, int index, float newValue) - { - SetControlValue (index + 2, floatToLong (newValue)); - } - - void audioProcessorParameterChangeGestureBegin (AudioProcessor*, int index) - { - TouchControl (index + 2); - } - - void audioProcessorParameterChangeGestureEnd (AudioProcessor*, int index) - { - ReleaseControl (index + 2); - } - - void audioProcessorChanged (AudioProcessor*) - { - // xxx is there an RTAS equivalent? - } - - //============================================================================== -private: - AudioProcessor* juceFilter; - MidiBuffer midiEvents; - CEffectMIDIOtherBufferedNode* midiBufferNode; - CEffectMIDITransport* midiTransport; - DirectMidiPacket midiBuffer [midiBufferSize]; - - JUCE_NAMESPACE::MemoryBlock tempFilterData; - float** channels; - bool prepared; - double sampleRate; - - void bypassBuffers (float** const inputs, float** const outputs, const long numSamples) const - { - for (int i = fNumOutputs; --i >= 0;) - { - if (i < fNumInputs) - memcpy (outputs[i], inputs[i], numSamples * sizeof (float)); - else - zeromem (outputs[i], numSamples * sizeof (float)); - } - } - - //============================================================================== - class JucePluginControl : public CPluginControl - { - public: - //============================================================================== - JucePluginControl (AudioProcessor* const juceFilter_, const int index_) - : juceFilter (juceFilter_), - index (index_) - { - } - - ~JucePluginControl() - { - } - - //============================================================================== - OSType GetID() const { return index + 1; } - long GetDefaultValue() const { return floatToLong (0); } - void SetDefaultValue (long) {} - long GetNumSteps() const { return 0xffffffff; } - - long ConvertStringToValue (const char* valueString) const - { - return floatToLong (String (valueString).getFloatValue()); - } - - Cmn_Bool IsKeyValid (long key) const { return true; } - - void GetNameOfLength (char* name, int maxLength, OSType inControllerType) const - { - juceFilter->getParameterName (index).copyToBuffer (name, maxLength); - } - - long GetPriority() const { return kFicCooperativeTaskPriority; } - - long GetOrientation() const - { - return kDAE_LeftMinRightMax | kDAE_BottomMinTopMax - | kDAE_RotarySingleDotMode | kDAE_RotaryLeftMinRightMax; - } - - long GetControlType() const { return kDAE_ContinuousValues; } - - void GetValueString (char* valueString, int maxLength, long value) const - { - juceFilter->getParameterText (index).copyToBuffer (valueString, maxLength); - } - - Cmn_Bool IsAutomatable() const - { - return juceFilter->isParameterAutomatable (index); - } - - private: - //============================================================================== - AudioProcessor* const juceFilter; - const int index; - - JucePluginControl (const JucePluginControl&); - const JucePluginControl& operator= (const JucePluginControl&); - }; -}; - -//============================================================================== -class JucePlugInGroup : public CEffectGroupMIDI -{ -public: - //============================================================================== - JucePlugInGroup() - { - DefineManufacturerNamesAndID (JucePlugin_Manufacturer, JucePlugin_RTASManufacturerCode); - DefinePlugInNamesAndVersion (createRTASName(), JucePlugin_VersionCode); - -#ifndef JUCE_DEBUG - AddGestalt (pluginGestalt_IsCacheable); -#endif - } - - ~JucePlugInGroup() - { - shutdownJuce_GUI(); - shutdownJuce_NonGUI(); - } - - //============================================================================== - void CreateEffectTypes() - { - const short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations }; - const int numConfigs = numElementsInArray (channelConfigs); - - // You need to actually add some configurations to the JucePlugin_PreferredChannelConfigurations - // value in your JucePluginCharacteristics.h file.. - jassert (numConfigs > 0); - - for (int i = 0; i < numConfigs; ++i) - { - CEffectType* const type - = new CEffectTypeRTAS ('jcaa' + i, - JucePlugin_RTASProductId, - JucePlugin_RTASCategory); - - type->DefineTypeNames (createRTASName()); - type->DefineSampleRateSupport (eSupports48kAnd96kAnd192k); - - type->DefineStemFormats (getFormatForChans (channelConfigs [i][0] != 0 ? channelConfigs [i][0] : channelConfigs [i][1]), - getFormatForChans (channelConfigs [i][1] != 0 ? channelConfigs [i][1] : channelConfigs [i][0])); - - type->AddGestalt (pluginGestalt_CanBypass); - type->AddGestalt (pluginGestalt_SupportsVariableQuanta); - type->AttachEffectProcessCreator (createNewProcess); - - AddEffectType (type); - } - } - - void Initialize() - { - CEffectGroupMIDI::Initialize(); - } - - //============================================================================== -private: - static CEffectProcess* createNewProcess() - { - // Juce setup -#if JUCE_WIN32 - PlatformUtilities::setCurrentModuleInstanceHandle (gThisModule); -#endif - initialiseJuce_GUI(); - - return new JucePlugInProcess(); - } - - static const String createRTASName() - { - return String (JucePlugin_Name) + T("\n") - + String (JucePlugin_Name).substring (0, 4); - } - - static EPlugIn_StemFormat getFormatForChans (const int numChans) throw() - { - switch (numChans) - { - case 0: - return ePlugIn_StemFormat_Generic; - - case 1: - return ePlugIn_StemFormat_Mono; - - case 2: - return ePlugIn_StemFormat_Stereo; - - case 3: - return ePlugIn_StemFormat_LCR; - - case 4: - return ePlugIn_StemFormat_Quad; - - case 5: - return ePlugIn_StemFormat_5dot0; - - case 6: - return ePlugIn_StemFormat_5dot1; - - case 7: - return ePlugIn_StemFormat_6dot1; - - case 8: - return ePlugIn_StemFormat_7dot1; - - default: - jassertfalse // hmm - not a valid number of chans for RTAS.. - break; - } - - return ePlugIn_StemFormat_Generic; - } -}; - -void initialiseMacRTAS(); - -CProcessGroupInterface* CProcessGroup::CreateProcessGroup() -{ -#if JUCE_MAC - initialiseMacRTAS(); -#endif - initialiseJuce_NonGUI(); - return new JucePlugInGroup(); -} - -#endif +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#ifdef _MSC_VER + // (this is a workaround for a build problem in VC9) + #define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY + #include +#endif + +#include "juce_RTAS_DigiCode_Header.h" + +#if JucePlugin_Build_RTAS + +#ifdef _MSC_VER + #include "Mac2Win.H" +#endif + +/* Note about include paths + ------------------------ + + To be able to include all the Digidesign headers correctly, you'll need to add this + lot to your include path: + + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\EffectClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\ProcessClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\ProcessClasses\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Utilities + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\RTASP_Adapt + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\CoreClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Controls + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Meters + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\ViewClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\DSPClasses + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\PluginLibrary\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\common + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\common\Platform + c:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugins\SignalProcessing\Public + C:\yourdirectory\PT_80_SDK\AlturaPorts\TDMPlugIns\DSPManager\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\SADriver\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\DigiPublic\Interfaces + c:\yourdirectory\PT_80_SDK\AlturaPorts\Fic\Interfaces\DAEClient + c:\yourdirectory\PT_80_SDK\AlturaPorts\NewFileLibs\Cmn + c:\yourdirectory\PT_80_SDK\AlturaPorts\NewFileLibs\DOA + c:\yourdirectory\PT_80_SDK\AlturaPorts\AlturaSource\PPC_H + c:\yourdirectory\PT_80_SDK\AlturaPorts\AlturaSource\AppSupport + c:\yourdirectory\PT_80_SDK\AvidCode\AVX2sdk\AVX\avx2\avx2sdk\inc + C:\yourdirectory\PT_80_SDK\xplat\AVX\avx2\avx2sdk\inc + + NB. If you hit a huge pile of bugs around here, make sure that you've not got the + Apple QuickTime headers before the PT headers in your path, because there are + some filename clashes between them. + +*/ +#include "CEffectGroupMIDI.h" +#include "CEffectProcessMIDI.h" +#include "CEffectProcessRTAS.h" +#include "CCustomView.h" +#include "CEffectTypeRTAS.h" +#include "CPluginControl.h" +#include "CPluginControl_OnOff.h" +#include "FicProcessTokens.h" + +//============================================================================== +#ifdef _MSC_VER + #pragma pack (push, 8) +#endif + +#include "../juce_PluginHeaders.h" + +#ifdef _MSC_VER + #pragma pack (pop) + + #if JUCE_DEBUG + #define PT_LIB_PATH JucePlugin_WinBag_path "\\Debug\\lib\\" + #else + #define PT_LIB_PATH JucePlugin_WinBag_path "\\Release\\lib\\" + #endif + + #pragma comment(lib, PT_LIB_PATH "DAE.lib") + #pragma comment(lib, PT_LIB_PATH "DigiExt.lib") + #pragma comment(lib, PT_LIB_PATH "DSI.lib") + #pragma comment(lib, PT_LIB_PATH "PluginLib.lib") + +#endif + +#undef Component +#undef MemoryBlock + +//============================================================================== +#if JUCE_WIN32 + extern void JUCE_CALLTYPE attachSubWindow (void* hostWindow, int& titleW, int& titleH, JUCE_NAMESPACE::Component* comp); + extern void JUCE_CALLTYPE resizeHostWindow (void* hostWindow, int& titleW, int& titleH, JUCE_NAMESPACE::Component* comp); + #if ! JucePlugin_EditorRequiresKeyboardFocus + extern void JUCE_CALLTYPE passFocusToHostWindow (void* hostWindow); + #endif +#else + extern void* attachSubWindow (void* hostWindowRef, JUCE_NAMESPACE::Component* comp); + extern void removeSubWindow (void* nsWindow, JUCE_NAMESPACE::Component* comp); +#endif + +const int midiBufferSize = 1024; +const OSType juceChunkType = 'juce'; +static const int bypassControlIndex = 1; + +//============================================================================== +/** Somewhere in the codebase of your plugin, you need to implement this function + and make it return a new instance of the filter subclass that you're building. +*/ +extern AudioProcessor* JUCE_CALLTYPE createPluginFilter(); + + +//============================================================================== +static float longToFloat (const long n) throw() +{ + return (float) ((((double) n) + (double) 0x80000000) / (double) 0xffffffff); +} + +static long floatToLong (const float n) throw() +{ + return roundDoubleToInt (jlimit (-(double) 0x80000000, + (double) 0x7fffffff, + n * (double) 0xffffffff - (double) 0x80000000)); +} + +static int numInstances = 0; + +//============================================================================== +class JucePlugInProcess : public CEffectProcessMIDI, + public CEffectProcessRTAS, + public AudioProcessorListener, + public AudioPlayHead, + public AsyncUpdater +{ +public: + //============================================================================== + JucePlugInProcess() + : midiBufferNode (0), + midiTransport (0), + channels (0), + prepared (false), + sampleRate (44100.0) + { + juceFilter = createPluginFilter(); + jassert (juceFilter != 0); + + AddChunk (juceChunkType, "Juce Audio Plugin Data"); + + ++numInstances; + } + + ~JucePlugInProcess() + { + if (mLoggedIn) + MIDILogOut(); + + deleteAndZero (midiBufferNode); + deleteAndZero (midiTransport); + + if (prepared) + juceFilter->releaseResources(); + + delete juceFilter; + juce_free (channels); + + if (--numInstances == 0) + shutdownJuce_GUI(); + } + + //============================================================================== + class JuceCustomUIView : public CCustomView, + public Timer + { + public: + //============================================================================== + JuceCustomUIView (AudioProcessor* const filter_, + JucePlugInProcess* const process_) + : filter (filter_), + process (process_), + wrapper (0), + editorComp (0) + { + // setting the size in here crashes PT for some reason, so keep it simple.. + } + + ~JuceCustomUIView() + { + deleteEditorComp(); + } + + //============================================================================== + void updateSize() + { + if (editorComp == 0) + { + editorComp = filter->createEditorIfNeeded(); + jassert (editorComp != 0); + } + + Rect oldRect; + GetRect (&oldRect); + + Rect r; + r.left = 0; + r.top = 0; + r.right = editorComp->getWidth(); + r.bottom = editorComp->getHeight(); + SetRect (&r); + + if ((oldRect.right != r.right) || (oldRect.bottom != r.bottom)) + startTimer (50); + } + + void timerCallback() + { + if (! JUCE_NAMESPACE::Component::isMouseButtonDownAnywhere()) + { + stopTimer(); + + // Send a token to the host to tell it about the resize + SSetProcessWindowResizeToken token (process->fRootNameId, process->fRootNameId); + FicSDSDispatchToken (&token); + } + } + + void attachToWindow (GrafPtr port) + { + if (port != 0) + { + updateSize(); + +#if JUCE_WIN32 + void* const hostWindow = (void*) ASI_GethWnd ((WindowPtr) port); +#else + void* const hostWindow = (void*) GetWindowFromPort (port); +#endif + deleteAndZero (wrapper); + + wrapper = new EditorCompWrapper (hostWindow, editorComp, this); + } + else + { + deleteEditorComp(); + } + } + + void DrawContents (Rect*) + { +#if JUCE_WIN32 + if (wrapper != 0) + { + ComponentPeer* const peer = wrapper->getPeer(); + + if (peer != 0) + { + // (seems to be required in PT6.4, but not in 7.x) + peer->repaint (0, 0, wrapper->getWidth(), wrapper->getHeight()); + } + } +#endif + } + + void DrawBackground (Rect*) {} + + //============================================================================== + private: + AudioProcessor* const filter; + JucePlugInProcess* const process; + JUCE_NAMESPACE::Component* wrapper; + AudioProcessorEditor* editorComp; + + void deleteEditorComp() + { + if (editorComp != 0 || wrapper != 0) + { +#if JUCE_MAC + const ScopedAutoReleasePool pool; +#endif + PopupMenu::dismissAllActiveMenus(); + + JUCE_NAMESPACE::Component* const modalComponent = JUCE_NAMESPACE::Component::getCurrentlyModalComponent(); + if (modalComponent != 0) + modalComponent->exitModalState (0); + + filter->editorBeingDeleted (editorComp); + + deleteAndZero (editorComp); + deleteAndZero (wrapper); + } + } + + //============================================================================== + // A component to hold the AudioProcessorEditor, and cope with some housekeeping + // chores when it changes or repaints. + class EditorCompWrapper : public JUCE_NAMESPACE::Component +#if ! JUCE_MAC + , public FocusChangeListener +#endif + { + public: + EditorCompWrapper (void* const hostWindow_, + Component* const editorComp, + JuceCustomUIView* const owner_) + : hostWindow (hostWindow_), + owner (owner_), + titleW (0), + titleH (0) + { +#if JucePlugin_EditorRequiresKeyboardFocus + setWantsKeyboardFocus (true); +#else + setComponentProperty ("juce_disallowFocus", true); + setWantsKeyboardFocus (false); +#endif + setOpaque (true); + setBroughtToFrontOnMouseClick (true); + setBounds (editorComp->getBounds()); + editorComp->setTopLeftPosition (0, 0); + addAndMakeVisible (editorComp); + +#if JUCE_WIN32 + attachSubWindow (hostWindow, titleW, titleH, this); +#else + nsWindow = attachSubWindow (hostWindow, this); +#endif + setVisible (true); + +#if JUCE_WIN32 && ! JucePlugin_EditorRequiresKeyboardFocus + Desktop::getInstance().addFocusChangeListener (this); +#endif + } + + ~EditorCompWrapper() + { +#if JUCE_WIN32 && ! JucePlugin_EditorRequiresKeyboardFocus + Desktop::getInstance().removeFocusChangeListener (this); +#endif + +#if JUCE_MAC + removeSubWindow (nsWindow, this); +#endif + } + + void paint (Graphics&) + { + } + + void resized() + { + JUCE_NAMESPACE::Component* const c = getChildComponent (0); + + if (c != 0) + c->setBounds (0, 0, getWidth(), getHeight()); + + repaint(); + } + +#if JUCE_WIN32 + void globalFocusChanged (JUCE_NAMESPACE::Component*) + { + #if ! JucePlugin_EditorRequiresKeyboardFocus + if (hasKeyboardFocus (true)) + passFocusToHostWindow (hostWindow); + #endif + } +#endif + + void childBoundsChanged (JUCE_NAMESPACE::Component* child) + { + setSize (child->getWidth(), child->getHeight()); + child->setTopLeftPosition (0, 0); + +#if JUCE_WIN32 + resizeHostWindow (hostWindow, titleW, titleH, this); +#endif + owner->updateSize(); + } + + void userTriedToCloseWindow() + { + } + + //============================================================================== + juce_UseDebuggingNewOperator + + private: + void* const hostWindow; + void* nsWindow; + JuceCustomUIView* const owner; + int titleW, titleH; + }; + }; + + JuceCustomUIView* getView() const + { + return dynamic_cast (fOurPlugInView); + } + + void GetViewRect (Rect* size) + { + if (getView() != 0) + getView()->updateSize(); + + CEffectProcessRTAS::GetViewRect (size); + } + + CPlugInView* CreateCPlugInView() + { + return new JuceCustomUIView (juceFilter, this); + } + + void SetViewPort (GrafPtr port) + { + CEffectProcessRTAS::SetViewPort (port); + + if (getView() != 0) + getView()->attachToWindow (port); + } + + //============================================================================== +protected: + ComponentResult GetDelaySamplesLong (long* aNumSamples) + { + if (aNumSamples != 0) + *aNumSamples = juceFilter != 0 ? juceFilter->getLatencySamples() : 0; + + return noErr; + } + + //============================================================================== + void EffectInit() + { + SFicPlugInStemFormats stems; + GetProcessType()->GetStemFormats (&stems); + + juceFilter->setPlayConfigDetails (fNumInputs, fNumOutputs, + juceFilter->getSampleRate(), juceFilter->getBlockSize()); + + AddControl (new CPluginControl_OnOff ('bypa', "Master Bypass\nMastrByp\nMByp\nByp", false, true)); + DefineMasterBypassControlIndex (bypassControlIndex); + + for (int i = 0; i < juceFilter->getNumParameters(); ++i) + AddControl (new JucePluginControl (juceFilter, i)); + + // we need to do this midi log-in to get timecode, regardless of whether + // the plugin actually uses midi... + if (MIDILogIn() == noErr) + { +#if JucePlugin_WantsMidiInput + CEffectType* const type = dynamic_cast (this->GetProcessType()); + + if (type != 0) + { + char nodeName [64]; + type->GetProcessTypeName (63, nodeName); + p2cstrcpy (nodeName, reinterpret_cast (nodeName)); + + midiBufferNode = new CEffectMIDIOtherBufferedNode (&mMIDIWorld, + 8192, + eLocalNode, + nodeName, + midiBuffer); + + midiBufferNode->Initialize (1, true); + } +#endif + } + + midiTransport = new CEffectMIDITransport (&mMIDIWorld); + + juceFilter->setPlayHead (this); + juceFilter->addListener (this); + } + + void handleAsyncUpdate() + { + if (! prepared) + { + sampleRate = gProcessGroup->GetSampleRate(); + jassert (sampleRate > 0); + + juce_free (channels); + channels = (float**) juce_calloc (sizeof (float*) * jmax (juceFilter->getNumInputChannels(), + juceFilter->getNumOutputChannels())); + + juceFilter->setPlayConfigDetails (fNumInputs, fNumOutputs, + sampleRate, mRTGlobals->mHWBufferSizeInSamples); + + juceFilter->prepareToPlay (sampleRate, + mRTGlobals->mHWBufferSizeInSamples); + + prepared = true; + } + } + + void RenderAudio (float** inputs, float** outputs, long numSamples) + { + if (! prepared) + { + triggerAsyncUpdate(); + bypassBuffers (inputs, outputs, numSamples); + return; + } + + if (mBypassed) + { + bypassBuffers (inputs, outputs, numSamples); + return; + } + +#if JucePlugin_WantsMidiInput + midiEvents.clear(); + + const Cmn_UInt32 bufferSize = mRTGlobals->mHWBufferSizeInSamples; + + if (midiBufferNode->GetAdvanceScheduleTime() != bufferSize) + midiBufferNode->SetAdvanceScheduleTime (bufferSize); + + if (midiBufferNode->FillMIDIBuffer (mRTGlobals->mRunningTime, numSamples) == noErr) + { + jassert (midiBufferNode->GetBufferPtr() != 0); + const int numMidiEvents = midiBufferNode->GetBufferSize(); + + for (int i = 0; i < numMidiEvents; ++i) + { + const DirectMidiPacket& m = midiBuffer[i]; + + jassert ((int) m.mTimestamp < numSamples); + + midiEvents.addEvent (m.mData, m.mLength, + jlimit (0, (int) numSamples - 1, (int) m.mTimestamp)); + } + } +#endif + +#if defined (JUCE_DEBUG) || JUCE_LOG_ASSERTIONS + const int numMidiEventsComingIn = midiEvents.getNumEvents(); + (void) numMidiEventsComingIn; +#endif + + { + const ScopedLock sl (juceFilter->getCallbackLock()); + + const int numIn = juceFilter->getNumInputChannels(); + const int numOut = juceFilter->getNumOutputChannels(); + const int totalChans = jmax (numIn, numOut); + + if (juceFilter->isSuspended()) + { + for (int i = 0; i < numOut; ++i) + zeromem (outputs [i], sizeof (float) * numSamples); + } + else + { + { + int i; + for (i = 0; i < numOut; ++i) + { + channels[i] = outputs [i]; + + if (i < numIn && inputs != outputs) + memcpy (outputs [i], inputs[i], sizeof (float) * numSamples); + } + + for (; i < numIn; ++i) + channels [i] = inputs [i]; + } + + AudioSampleBuffer chans (channels, totalChans, numSamples); + + juceFilter->processBlock (chans, midiEvents); + } + } + + if (! midiEvents.isEmpty()) + { +#if JucePlugin_ProducesMidiOutput + const juce::uint8* midiEventData; + int midiEventSize, midiEventPosition; + MidiBuffer::Iterator i (midiEvents); + + while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition)) + { +// jassert (midiEventPosition >= 0 && midiEventPosition < (int) numSamples); + + //xxx + } +#else + // if your plugin creates midi messages, you'll need to set + // the JucePlugin_ProducesMidiOutput macro to 1 in your + // JucePluginCharacteristics.h file + jassert (midiEvents.getNumEvents() <= numMidiEventsComingIn); +#endif + + midiEvents.clear(); + } + } + + //============================================================================== + ComponentResult GetChunkSize (OSType chunkID, long* size) + { + if (chunkID == juceChunkType) + { + tempFilterData.setSize (0); + juceFilter->getStateInformation (tempFilterData); + + *size = sizeof (SFicPlugInChunkHeader) + tempFilterData.getSize(); + return noErr; + } + + return CEffectProcessMIDI::GetChunkSize (chunkID, size); + } + + ComponentResult GetChunk (OSType chunkID, SFicPlugInChunk* chunk) + { + if (chunkID == juceChunkType) + { + if (tempFilterData.getSize() == 0) + juceFilter->getStateInformation (tempFilterData); + + chunk->fSize = sizeof (SFicPlugInChunkHeader) + tempFilterData.getSize(); + tempFilterData.copyTo ((void*) chunk->fData, 0, tempFilterData.getSize()); + + tempFilterData.setSize (0); + + return noErr; + } + + return CEffectProcessMIDI::GetChunk (chunkID, chunk); + } + + ComponentResult SetChunk (OSType chunkID, SFicPlugInChunk* chunk) + { + if (chunkID == juceChunkType) + { + tempFilterData.setSize (0); + + if (chunk->fSize - sizeof (SFicPlugInChunkHeader) > 0) + { + juceFilter->setStateInformation ((void*) chunk->fData, + chunk->fSize - sizeof (SFicPlugInChunkHeader)); + } + + return noErr; + } + + return CEffectProcessMIDI::SetChunk (chunkID, chunk); + } + + //============================================================================== + ComponentResult UpdateControlValue (long controlIndex, long value) + { + if (controlIndex != bypassControlIndex) + juceFilter->setParameter (controlIndex - 2, longToFloat (value)); + else + mBypassed = (value > 0); + + return CProcess::UpdateControlValue (controlIndex, value); + } + + //============================================================================== + bool getCurrentPosition (AudioPlayHead::CurrentPositionInfo& info) + { + // this method can only be called while the plugin is running + jassert (prepared); + + Cmn_Float64 bpm = 120.0; + Cmn_Int32 num = 4, denom = 4; + Cmn_Int64 ticks = 0; + Cmn_Bool isPlaying = false; + + if (midiTransport != 0) + { + midiTransport->GetCurrentTempo (&bpm); + midiTransport->IsTransportPlaying (&isPlaying); + midiTransport->GetCurrentMeter (&num, &denom); + midiTransport->GetCurrentTickPosition (&ticks); + } + + info.bpm = bpm; + info.timeSigNumerator = num; + info.timeSigDenominator = denom; + info.isPlaying = isPlaying; + info.isRecording = false; + info.ppqPosition = ticks / 960000.0; + info.ppqPositionOfLastBarStart = 0; //xxx no idea how to get this correctly.. + + // xxx incorrect if there are tempo changes, but there's no + // other way of getting this info.. + info.timeInSeconds = ticks * (60.0 / 960000.0) / bpm; + + double framesPerSec = 24.0; + + switch (fTimeCodeInfo.mFrameRate) + { + case ficFrameRate_24Frame: + info.frameRate = AudioPlayHead::fps24; + break; + + case ficFrameRate_25Frame: + info.frameRate = AudioPlayHead::fps25; + framesPerSec = 25.0; + break; + + case ficFrameRate_2997NonDrop: + info.frameRate = AudioPlayHead::fps2997; + framesPerSec = 29.97002997; + break; + + case ficFrameRate_2997DropFrame: + info.frameRate = AudioPlayHead::fps2997drop; + framesPerSec = 29.97002997; + break; + + case ficFrameRate_30NonDrop: + info.frameRate = AudioPlayHead::fps30; + framesPerSec = 30.0; + break; + + case ficFrameRate_30DropFrame: + info.frameRate = AudioPlayHead::fps30drop; + framesPerSec = 30.0; + break; + + case ficFrameRate_23976: + // xxx not strictly true.. + info.frameRate = AudioPlayHead::fps24; + framesPerSec = 23.976; + break; + + default: + info.frameRate = AudioPlayHead::fpsUnknown; + break; + } + + info.editOriginTime = fTimeCodeInfo.mFrameOffset / framesPerSec; + + return true; + } + + void audioProcessorParameterChanged (AudioProcessor*, int index, float newValue) + { + SetControlValue (index + 2, floatToLong (newValue)); + } + + void audioProcessorParameterChangeGestureBegin (AudioProcessor*, int index) + { + TouchControl (index + 2); + } + + void audioProcessorParameterChangeGestureEnd (AudioProcessor*, int index) + { + ReleaseControl (index + 2); + } + + void audioProcessorChanged (AudioProcessor*) + { + // xxx is there an RTAS equivalent? + } + + //============================================================================== +private: + AudioProcessor* juceFilter; + MidiBuffer midiEvents; + CEffectMIDIOtherBufferedNode* midiBufferNode; + CEffectMIDITransport* midiTransport; + DirectMidiPacket midiBuffer [midiBufferSize]; + + JUCE_NAMESPACE::MemoryBlock tempFilterData; + float** channels; + bool prepared; + double sampleRate; + + void bypassBuffers (float** const inputs, float** const outputs, const long numSamples) const + { + for (int i = fNumOutputs; --i >= 0;) + { + if (i < fNumInputs) + memcpy (outputs[i], inputs[i], numSamples * sizeof (float)); + else + zeromem (outputs[i], numSamples * sizeof (float)); + } + } + + //============================================================================== + class JucePluginControl : public CPluginControl + { + public: + //============================================================================== + JucePluginControl (AudioProcessor* const juceFilter_, const int index_) + : juceFilter (juceFilter_), + index (index_) + { + } + + ~JucePluginControl() + { + } + + //============================================================================== + OSType GetID() const { return index + 1; } + long GetDefaultValue() const { return floatToLong (0); } + void SetDefaultValue (long) {} + long GetNumSteps() const { return 0xffffffff; } + + long ConvertStringToValue (const char* valueString) const + { + return floatToLong (String (valueString).getFloatValue()); + } + + Cmn_Bool IsKeyValid (long key) const { return true; } + + void GetNameOfLength (char* name, int maxLength, OSType inControllerType) const + { + juceFilter->getParameterName (index).copyToBuffer (name, maxLength); + } + + long GetPriority() const { return kFicCooperativeTaskPriority; } + + long GetOrientation() const + { + return kDAE_LeftMinRightMax | kDAE_BottomMinTopMax + | kDAE_RotarySingleDotMode | kDAE_RotaryLeftMinRightMax; + } + + long GetControlType() const { return kDAE_ContinuousValues; } + + void GetValueString (char* valueString, int maxLength, long value) const + { + juceFilter->getParameterText (index).copyToBuffer (valueString, maxLength); + } + + Cmn_Bool IsAutomatable() const + { + return juceFilter->isParameterAutomatable (index); + } + + private: + //============================================================================== + AudioProcessor* const juceFilter; + const int index; + + JucePluginControl (const JucePluginControl&); + const JucePluginControl& operator= (const JucePluginControl&); + }; +}; + +//============================================================================== +class JucePlugInGroup : public CEffectGroupMIDI +{ +public: + //============================================================================== + JucePlugInGroup() + { + DefineManufacturerNamesAndID (JucePlugin_Manufacturer, JucePlugin_RTASManufacturerCode); + DefinePlugInNamesAndVersion (createRTASName(), JucePlugin_VersionCode); + +#ifndef JUCE_DEBUG + AddGestalt (pluginGestalt_IsCacheable); +#endif + } + + ~JucePlugInGroup() + { + shutdownJuce_GUI(); + shutdownJuce_NonGUI(); + } + + //============================================================================== + void CreateEffectTypes() + { + const short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations }; + const int numConfigs = numElementsInArray (channelConfigs); + + // You need to actually add some configurations to the JucePlugin_PreferredChannelConfigurations + // value in your JucePluginCharacteristics.h file.. + jassert (numConfigs > 0); + + for (int i = 0; i < numConfigs; ++i) + { + CEffectType* const type + = new CEffectTypeRTAS ('jcaa' + i, + JucePlugin_RTASProductId, + JucePlugin_RTASCategory); + + type->DefineTypeNames (createRTASName()); + type->DefineSampleRateSupport (eSupports48kAnd96kAnd192k); + + type->DefineStemFormats (getFormatForChans (channelConfigs [i][0] != 0 ? channelConfigs [i][0] : channelConfigs [i][1]), + getFormatForChans (channelConfigs [i][1] != 0 ? channelConfigs [i][1] : channelConfigs [i][0])); + + type->AddGestalt (pluginGestalt_CanBypass); + type->AddGestalt (pluginGestalt_SupportsVariableQuanta); + type->AttachEffectProcessCreator (createNewProcess); + + AddEffectType (type); + } + } + + void Initialize() + { + CEffectGroupMIDI::Initialize(); + } + + //============================================================================== +private: + static CEffectProcess* createNewProcess() + { + // Juce setup +#if JUCE_WIN32 + PlatformUtilities::setCurrentModuleInstanceHandle (gThisModule); +#endif + initialiseJuce_GUI(); + + return new JucePlugInProcess(); + } + + static const String createRTASName() + { + return String (JucePlugin_Name) + T("\n") + + String (JucePlugin_Name).substring (0, 4); + } + + static EPlugIn_StemFormat getFormatForChans (const int numChans) throw() + { + switch (numChans) + { + case 0: + return ePlugIn_StemFormat_Generic; + + case 1: + return ePlugIn_StemFormat_Mono; + + case 2: + return ePlugIn_StemFormat_Stereo; + + case 3: + return ePlugIn_StemFormat_LCR; + + case 4: + return ePlugIn_StemFormat_Quad; + + case 5: + return ePlugIn_StemFormat_5dot0; + + case 6: + return ePlugIn_StemFormat_5dot1; + + case 7: + return ePlugIn_StemFormat_6dot1; + + case 8: + return ePlugIn_StemFormat_7dot1; + + default: + jassertfalse // hmm - not a valid number of chans for RTAS.. + break; + } + + return ePlugIn_StemFormat_Generic; + } +}; + +void initialiseMacRTAS(); + +CProcessGroupInterface* CProcessGroup::CreateProcessGroup() +{ +#if JUCE_MAC + initialiseMacRTAS(); +#endif + initialiseJuce_NonGUI(); + return new JucePlugInGroup(); +} + +#endif diff --git a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp index 1f99cba371..54cb37f678 100644 --- a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp +++ b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp @@ -66,7 +66,7 @@ #if JUCE_USE_VSTSDK_2_4 #ifdef __GNUC__ #define __cdecl - #endif + #endif // VSTSDK V2.4 includes.. #include "public.sdk/source/vst2.x/audioeffectx.h" @@ -76,7 +76,7 @@ #if ! VST_2_4_EXTENSIONS #error // You're probably trying to include the wrong VSTSDK version - make sure your include path matches the JUCE_USE_VSTSDK_2_4 flag - #endif + #endif #else // VSTSDK V2.3 includes.. @@ -87,7 +87,7 @@ #if (! VST_2_3_EXTENSIONS) || VST_2_4_EXTENSIONS #error // You're probably trying to include the wrong VSTSDK version - make sure your include path matches the JUCE_USE_VSTSDK_2_4 flag - #endif + #endif #define __aeffect__ // (needed for juce_VSTMidiEventList.h to work) @@ -130,7 +130,7 @@ VstIntPtr resvd2; ///< zero (Reserved for future use) }; - typedef int VstSpeakerArrangementType; + typedef int VstSpeakerArrangementType; #endif //============================================================================== @@ -225,7 +225,7 @@ public: initialised (false) { startThread (7); - + while (! initialised) sleep (1); } @@ -256,7 +256,7 @@ public: } juce_DeclareSingleton (SharedMessageThread, false) - + private: bool initialised; }; @@ -288,7 +288,7 @@ public: #if ! JucePlugin_EditorRequiresKeyboardFocus setComponentProperty ("juce_disallowFocus", true); #endif - + #if JUCE_WIN32 addMouseListener (this, true); #endif @@ -551,12 +551,12 @@ public: { if (filter == 0 || index >= JucePlugin_MaxNumInputChannels) return false; - + const String name (filter->getInputChannelName ((int) index)); - + name.copyToBuffer (properties->label, kVstMaxLabelLen - 1); name.copyToBuffer (properties->shortLabel, kVstMaxShortLabelLen - 1); - + if (speakerIn != kSpeakerArrEmpty) { properties->flags = kVstPinUseSpeaker; @@ -565,26 +565,26 @@ public: else { properties->flags = kVstPinIsActive; - + if (filter->isInputChannelStereoPair ((int) index)) properties->flags |= kVstPinIsStereo; - + properties->arrangementType = 0; } return true; } - + bool getOutputProperties (VstInt32 index, VstPinProperties* properties) { if (filter == 0 || index >= JucePlugin_MaxNumOutputChannels) return false; - + const String name (filter->getOutputChannelName ((int) index)); - + name.copyToBuffer (properties->label, kVstMaxLabelLen - 1); name.copyToBuffer (properties->shortLabel, kVstMaxShortLabelLen - 1); - + if (speakerOut != kSpeakerArrEmpty) { properties->flags = kVstPinUseSpeaker; @@ -593,10 +593,10 @@ public: else { properties->flags = kVstPinIsActive; - + if (filter->isOutputChannelStereoPair ((int) index)) properties->flags |= kVstPinIsStereo; - + properties->arrangementType = 0; } @@ -1021,7 +1021,7 @@ public: return filter != 0 && filter->isParameterAutomatable ((int) index); } - bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput, + bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput, VstSpeakerArrangement* pluginOutput) { const short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations }; diff --git a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm index 8449ecc678..d515addd55 100644 --- a/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm +++ b/extras/audio plugins/wrapper/VST/juce_VST_Wrapper.mm @@ -1,182 +1,182 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -//============================================================================== -#include "../juce_IncludeCharacteristics.h" - -#if JucePlugin_Build_VST - -#include - -#define ADD_CARBON_BODGE 1 // see note below.. - -#include - -#include "../juce_PluginHeaders.h" - -//============================================================================== -BEGIN_JUCE_NAMESPACE - -#if ADD_CARBON_BODGE -/* When you wrap a WindowRef as an NSWindow, it seems to bugger up the HideWindow - function, so when the host tries (and fails) to hide the window, this catches - the event and does the job properly. -*/ - -static pascal OSStatus windowVisibilityBodge (EventHandlerCallRef, EventRef e, void* user) -{ - NSWindow* hostWindow = (NSWindow*) user; - - switch (GetEventKind (e)) - { - case kEventWindowShown: - [hostWindow orderFront: nil]; - break; - case kEventWindowHidden: - [hostWindow orderOut: nil]; - break; - } - - return eventNotHandledErr; -} -#endif - -//============================================================================== -void initialiseMac() -{ - NSApplicationLoad(); -} - -void* attachComponentToWindowRef (Component* comp, void* windowRef) -{ - const ScopedAutoReleasePool pool; - - NSWindow* hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef]; - [hostWindow retain]; - [hostWindow setCanHide: YES]; - [hostWindow setReleasedWhenClosed: YES]; - - NSView* content = [hostWindow contentView]; - NSRect f = [content frame]; - NSPoint windowPos = [hostWindow convertBaseToScreen: f.origin]; - windowPos.y = [[NSScreen mainScreen] frame].size.height - (windowPos.y + f.size.height); - comp->setTopLeftPosition ((int) windowPos.x, (int) windowPos.y); - -#if ! JucePlugin_EditorRequiresKeyboardFocus - comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); -#else - comp->addToDesktop (ComponentPeer::windowIsTemporary); -#endif - - comp->setVisible (true); - comp->toFront (false); - - NSView* pluginView = (NSView*) comp->getWindowHandle(); - NSWindow* pluginWindow = [pluginView window]; - [pluginWindow setExcludedFromWindowsMenu: YES]; - [pluginWindow setCanHide: YES]; - - [hostWindow addChildWindow: pluginWindow - ordered: NSWindowAbove]; - [hostWindow orderFront: nil]; - [pluginWindow orderFront: nil]; - -#if ADD_CARBON_BODGE - // Adds a callback bodge to work around some problems with wrapped - // carbon windows.. - const EventTypeSpec eventsToCatch[] = { - { kEventClassWindow, kEventWindowShown }, - { kEventClassWindow, kEventWindowHidden } - }; - - EventHandlerRef ref; - InstallWindowEventHandler ((WindowRef) windowRef, - NewEventHandlerUPP (windowVisibilityBodge), - GetEventTypeCount (eventsToCatch), eventsToCatch, - (void*) hostWindow, &ref); - comp->setComponentProperty ("carbonEventRef", String::toHexString ((pointer_sized_int) (void*) ref)); -#endif - - return hostWindow; -} - -void detachComponentFromWindowRef (Component* comp, void* nsWindow) -{ - const ScopedAutoReleasePool pool; - -#if ADD_CARBON_BODGE - EventHandlerRef ref = (EventHandlerRef) (void*) (pointer_sized_int) - comp->getComponentProperty ("carbonEventRef", false, String::empty).getHexValue64(); - RemoveEventHandler (ref); -#endif - - NSWindow* hostWindow = (NSWindow*) nsWindow; - NSView* pluginView = (NSView*) comp->getWindowHandle(); - NSWindow* pluginWindow = [pluginView window]; - - [hostWindow removeChildWindow: pluginWindow]; - comp->removeFromDesktop(); - - [hostWindow release]; - - // The event loop needs to be run between closing the window and deleting the plugin, - // presumably to let the cocoa objects get tidied up. Leaving out this line causes crashes - // in Live when you delete the plugin with its window open. - MessageManager::getInstance()->runDispatchLoopUntil (10); -} - -void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight) -{ - NSWindow* hostWindow = (NSWindow*) nsWindow; - if (hostWindow != 0) - { - ScopedAutoReleasePool pool; - - // Can't use the cocoa NSWindow resizing code, or it messes up in Live. - Rect r; - GetWindowBounds ((WindowRef) [hostWindow windowRef], kWindowContentRgn, &r); - r.right += newWidth - component->getWidth(); - r.bottom += newHeight - component->getHeight(); - SetWindowBounds ((WindowRef) [hostWindow windowRef], kWindowContentRgn, &r); - - [[hostWindow contentView] setNeedsDisplay: YES]; - } -} - -void checkWindowVisibility (void* nsWindow, Component* comp) -{ - NSWindow* hostWindow = (NSWindow*) nsWindow; - comp->setVisible ([hostWindow isVisible]); -} - -END_JUCE_NAMESPACE - -#endif +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +//============================================================================== +#include "../juce_IncludeCharacteristics.h" + +#if JucePlugin_Build_VST + +#include + +#define ADD_CARBON_BODGE 1 // see note below.. + +#include + +#include "../juce_PluginHeaders.h" + +//============================================================================== +BEGIN_JUCE_NAMESPACE + +#if ADD_CARBON_BODGE +/* When you wrap a WindowRef as an NSWindow, it seems to bugger up the HideWindow + function, so when the host tries (and fails) to hide the window, this catches + the event and does the job properly. +*/ + +static pascal OSStatus windowVisibilityBodge (EventHandlerCallRef, EventRef e, void* user) +{ + NSWindow* hostWindow = (NSWindow*) user; + + switch (GetEventKind (e)) + { + case kEventWindowShown: + [hostWindow orderFront: nil]; + break; + case kEventWindowHidden: + [hostWindow orderOut: nil]; + break; + } + + return eventNotHandledErr; +} +#endif + +//============================================================================== +void initialiseMac() +{ + NSApplicationLoad(); +} + +void* attachComponentToWindowRef (Component* comp, void* windowRef) +{ + const ScopedAutoReleasePool pool; + + NSWindow* hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef]; + [hostWindow retain]; + [hostWindow setCanHide: YES]; + [hostWindow setReleasedWhenClosed: YES]; + + NSView* content = [hostWindow contentView]; + NSRect f = [content frame]; + NSPoint windowPos = [hostWindow convertBaseToScreen: f.origin]; + windowPos.y = [[NSScreen mainScreen] frame].size.height - (windowPos.y + f.size.height); + comp->setTopLeftPosition ((int) windowPos.x, (int) windowPos.y); + +#if ! JucePlugin_EditorRequiresKeyboardFocus + comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); +#else + comp->addToDesktop (ComponentPeer::windowIsTemporary); +#endif + + comp->setVisible (true); + comp->toFront (false); + + NSView* pluginView = (NSView*) comp->getWindowHandle(); + NSWindow* pluginWindow = [pluginView window]; + [pluginWindow setExcludedFromWindowsMenu: YES]; + [pluginWindow setCanHide: YES]; + + [hostWindow addChildWindow: pluginWindow + ordered: NSWindowAbove]; + [hostWindow orderFront: nil]; + [pluginWindow orderFront: nil]; + +#if ADD_CARBON_BODGE + // Adds a callback bodge to work around some problems with wrapped + // carbon windows.. + const EventTypeSpec eventsToCatch[] = { + { kEventClassWindow, kEventWindowShown }, + { kEventClassWindow, kEventWindowHidden } + }; + + EventHandlerRef ref; + InstallWindowEventHandler ((WindowRef) windowRef, + NewEventHandlerUPP (windowVisibilityBodge), + GetEventTypeCount (eventsToCatch), eventsToCatch, + (void*) hostWindow, &ref); + comp->setComponentProperty ("carbonEventRef", String::toHexString ((pointer_sized_int) (void*) ref)); +#endif + + return hostWindow; +} + +void detachComponentFromWindowRef (Component* comp, void* nsWindow) +{ + const ScopedAutoReleasePool pool; + +#if ADD_CARBON_BODGE + EventHandlerRef ref = (EventHandlerRef) (void*) (pointer_sized_int) + comp->getComponentProperty ("carbonEventRef", false, String::empty).getHexValue64(); + RemoveEventHandler (ref); +#endif + + NSWindow* hostWindow = (NSWindow*) nsWindow; + NSView* pluginView = (NSView*) comp->getWindowHandle(); + NSWindow* pluginWindow = [pluginView window]; + + [hostWindow removeChildWindow: pluginWindow]; + comp->removeFromDesktop(); + + [hostWindow release]; + + // The event loop needs to be run between closing the window and deleting the plugin, + // presumably to let the cocoa objects get tidied up. Leaving out this line causes crashes + // in Live when you delete the plugin with its window open. + MessageManager::getInstance()->runDispatchLoopUntil (10); +} + +void setNativeHostWindowSize (void* nsWindow, Component* component, int newWidth, int newHeight) +{ + NSWindow* hostWindow = (NSWindow*) nsWindow; + if (hostWindow != 0) + { + ScopedAutoReleasePool pool; + + // Can't use the cocoa NSWindow resizing code, or it messes up in Live. + Rect r; + GetWindowBounds ((WindowRef) [hostWindow windowRef], kWindowContentRgn, &r); + r.right += newWidth - component->getWidth(); + r.bottom += newHeight - component->getHeight(); + SetWindowBounds ((WindowRef) [hostWindow windowRef], kWindowContentRgn, &r); + + [[hostWindow contentView] setNeedsDisplay: YES]; + } +} + +void checkWindowVisibility (void* nsWindow, Component* comp) +{ + NSWindow* hostWindow = (NSWindow*) nsWindow; + comp->setVisible ([hostWindow isVisible]); +} + +END_JUCE_NAMESPACE + +#endif diff --git a/extras/browser plugins/demo/src/BrowserPluginCharacteristics.h b/extras/browser plugins/demo/src/BrowserPluginCharacteristics.h index d0e9547399..4cae8bfe33 100644 --- a/extras/browser plugins/demo/src/BrowserPluginCharacteristics.h +++ b/extras/browser plugins/demo/src/BrowserPluginCharacteristics.h @@ -20,7 +20,7 @@ //============================================================================== /** This is the mime-type of the plugin. - + In your HTML, this is the 'type' parameter of the embed tag, e.g. diff --git a/extras/browser plugins/demo/src/JuceBrowserPluginDemo.cpp b/extras/browser plugins/demo/src/JuceBrowserPluginDemo.cpp index 72edf2dcea..e26cc5a7da 100644 --- a/extras/browser plugins/demo/src/JuceBrowserPluginDemo.cpp +++ b/extras/browser plugins/demo/src/JuceBrowserPluginDemo.cpp @@ -1,152 +1,152 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#include "../../wrapper/juce_BrowserPluginComponent.h" - - -//============================================================================== -/** - This is our top-level component for our plugin.. -*/ -class JuceDemoBrowserPlugin : public BrowserPluginComponent, - public ButtonListener -{ -public: - JuceDemoBrowserPlugin() - { - addAndMakeVisible (textBox = new TextEditor (String::empty)); - textBox->setMultiLine (true); - textBox->setBounds (8, 8, 300, 300); - - addAndMakeVisible (button = new TextButton ("Send a message to the webpage")); - button->setBounds (320, 8, 180, 22); - button->addButtonListener (this); - button->setEnabled (false); - - ourJavascriptObject = new DemoBrowserObject (this); - - textBox->setText ("Browser version info: " + getBrowserVersion()); - } - - ~JuceDemoBrowserPlugin() - { - deleteAllChildren(); - } - - const var getJavascriptObject() - { - // The browser calls this to get the javascript object that represents our plugin.. - return ourJavascriptObject; - } - - void paint (Graphics& g) - { - g.fillAll (Colours::lightblue); - } - - void setJavascriptObjectFromBrowser (var callbackObject) - { - javascriptObjectFromBrowser = callbackObject; - - button->setEnabled (javascriptObjectFromBrowser.isObject()); - } - - void buttonClicked (Button*) - { - javascriptObjectFromBrowser.call ("printmessage", "This is a message sent from the plugin..."); - } - - var ourJavascriptObject; - var javascriptObjectFromBrowser; - TextEditor* textBox; - TextButton* button; - - //============================================================================== - /** This is the javascript object that the browser uses when the webpage accesses - methods or properties on our plugin object. - */ - class DemoBrowserObject : public DynamicObject - { - public: - DemoBrowserObject (JuceDemoBrowserPlugin* owner_) - : owner (owner_) - { - // Add a couple of methods to our object.. - setMethod ("printText", (var::MethodFunction) &DemoBrowserObject::printText); - setMethod ("popUpMessageBox", (var::MethodFunction) &DemoBrowserObject::popUpMessageBox); - setMethod ("registerCallbackObject", (var::MethodFunction) &DemoBrowserObject::registerCallbackObject); - - // Add some value properties that the webpage can access - setProperty ("property1", "testing testing..."); - setProperty ("property2", 12345678.0); - } - - DemoBrowserObject() - { - } - - //============================================================================== - // These methods are called by javascript in the webpage... - const var printText (const var* params, int numParams) - { - if (numParams > 0) - owner->textBox->setText (owner->textBox->getText() + "\n" + params[0].toString()); - - return "text was printed ok!"; - } - - const var popUpMessageBox (const var* params, int numParams) - { - if (numParams > 0) - AlertWindow::showMessageBox (AlertWindow::InfoIcon, - "A message from the webpage", - params[0].toString(), - String::empty, owner); - return var(); - } - - const var registerCallbackObject (const var* params, int numParams) - { - if (numParams > 0) - owner->setJavascriptObjectFromBrowser (params[0]); - - return var(); - } - - //============================================================================== - JuceDemoBrowserPlugin* owner; - }; -}; - -BrowserPluginComponent* JUCE_CALLTYPE createBrowserPlugin() -{ - return new JuceDemoBrowserPlugin(); -} +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#include "../../wrapper/juce_BrowserPluginComponent.h" + + +//============================================================================== +/** + This is our top-level component for our plugin.. +*/ +class JuceDemoBrowserPlugin : public BrowserPluginComponent, + public ButtonListener +{ +public: + JuceDemoBrowserPlugin() + { + addAndMakeVisible (textBox = new TextEditor (String::empty)); + textBox->setMultiLine (true); + textBox->setBounds (8, 8, 300, 300); + + addAndMakeVisible (button = new TextButton ("Send a message to the webpage")); + button->setBounds (320, 8, 180, 22); + button->addButtonListener (this); + button->setEnabled (false); + + ourJavascriptObject = new DemoBrowserObject (this); + + textBox->setText ("Browser version info: " + getBrowserVersion()); + } + + ~JuceDemoBrowserPlugin() + { + deleteAllChildren(); + } + + const var getJavascriptObject() + { + // The browser calls this to get the javascript object that represents our plugin.. + return ourJavascriptObject; + } + + void paint (Graphics& g) + { + g.fillAll (Colours::lightblue); + } + + void setJavascriptObjectFromBrowser (var callbackObject) + { + javascriptObjectFromBrowser = callbackObject; + + button->setEnabled (javascriptObjectFromBrowser.isObject()); + } + + void buttonClicked (Button*) + { + javascriptObjectFromBrowser.call ("printmessage", "This is a message sent from the plugin..."); + } + + var ourJavascriptObject; + var javascriptObjectFromBrowser; + TextEditor* textBox; + TextButton* button; + + //============================================================================== + /** This is the javascript object that the browser uses when the webpage accesses + methods or properties on our plugin object. + */ + class DemoBrowserObject : public DynamicObject + { + public: + DemoBrowserObject (JuceDemoBrowserPlugin* owner_) + : owner (owner_) + { + // Add a couple of methods to our object.. + setMethod ("printText", (var::MethodFunction) &DemoBrowserObject::printText); + setMethod ("popUpMessageBox", (var::MethodFunction) &DemoBrowserObject::popUpMessageBox); + setMethod ("registerCallbackObject", (var::MethodFunction) &DemoBrowserObject::registerCallbackObject); + + // Add some value properties that the webpage can access + setProperty ("property1", "testing testing..."); + setProperty ("property2", 12345678.0); + } + + DemoBrowserObject() + { + } + + //============================================================================== + // These methods are called by javascript in the webpage... + const var printText (const var* params, int numParams) + { + if (numParams > 0) + owner->textBox->setText (owner->textBox->getText() + "\n" + params[0].toString()); + + return "text was printed ok!"; + } + + const var popUpMessageBox (const var* params, int numParams) + { + if (numParams > 0) + AlertWindow::showMessageBox (AlertWindow::InfoIcon, + "A message from the webpage", + params[0].toString(), + String::empty, owner); + return var(); + } + + const var registerCallbackObject (const var* params, int numParams) + { + if (numParams > 0) + owner->setJavascriptObjectFromBrowser (params[0]); + + return var(); + } + + //============================================================================== + JuceDemoBrowserPlugin* owner; + }; +}; + +BrowserPluginComponent* JUCE_CALLTYPE createBrowserPlugin() +{ + return new JuceDemoBrowserPlugin(); +} diff --git a/extras/browser plugins/demo/src/juce_LibrarySource.mm b/extras/browser plugins/demo/src/juce_LibrarySource.mm index e696df6c87..ea3a3739eb 100644 --- a/extras/browser plugins/demo/src/juce_LibrarySource.mm +++ b/extras/browser plugins/demo/src/juce_LibrarySource.mm @@ -1,11 +1,11 @@ - -/* - This file includes the entire juce source tree via the amalgamated file. - - You could add the amalgamated file directly to your project, but doing it - like this allows you to put your app's config settings in the - juce_AppConfig.h file and have them applied to both the juce headers and - the source code. -*/ - -#include "../../../../juce_amalgamated.mm" + +/* + This file includes the entire juce source tree via the amalgamated file. + + You could add the amalgamated file directly to your project, but doing it + like this allows you to put your app's config settings in the + juce_AppConfig.h file and have them applied to both the juce headers and + the source code. +*/ + +#include "../../../../juce_amalgamated.mm" diff --git a/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp b/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp index b237aa2bf1..824fcb1552 100644 --- a/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp +++ b/extras/browser plugins/wrapper/juce_ActiveX_GlueCode.cpp @@ -209,7 +209,7 @@ public: HRESULT __stdcall GetTypeInfoCount (UINT*) { return E_NOTIMPL; } HRESULT __stdcall GetTypeInfo (UINT, LCID, ITypeInfo**) { return E_NOTIMPL; } - HRESULT __stdcall GetIDsOfNames (REFIID riid, LPOLESTR* rgszNames, UINT cNames, + HRESULT __stdcall GetIDsOfNames (REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) { return iDispatchHelper.doGetIDsOfNames (rgszNames, cNames, rgDispId); @@ -219,7 +219,7 @@ public: DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) { - return iDispatchHelper.doInvoke (object, dispIdMember, riid, lcid, wFlags, pDispParams, + return iDispatchHelper.doInvoke (object, dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); } @@ -571,13 +571,13 @@ static const String getExeVersion (const String& exeFileName, const String& fiel TCHAR* result = 0; unsigned int resultLen = 0; - // try the 1200 codepage (Unicode) + // try the 1200 codepage (Unicode) String queryStr ("\\StringFileInfo\\040904B0\\" + fieldName); if (! VerQueryValue (exeInfo, queryStr, (void**) &result, &resultLen)) { - // try the 1252 codepage (Windows Multilingual) - queryStr = "\\StringFileInfo\\040904E4\\" + fieldName; + // try the 1252 codepage (Windows Multilingual) + queryStr = "\\StringFileInfo\\040904E4\\" + fieldName; VerQueryValue (exeInfo, queryStr, (void**) &result, &resultLen); } @@ -632,21 +632,21 @@ public: HRESULT __stdcall GetTypeInfoCount (UINT* pctinfo) { return E_NOTIMPL; } HRESULT __stdcall GetTypeInfo (UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) { return E_NOTIMPL; } - HRESULT __stdcall GetIDsOfNames (REFIID riid, LPOLESTR* rgszNames, UINT cNames, + HRESULT __stdcall GetIDsOfNames (REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) { return iDispatchHelper.doGetIDsOfNames (rgszNames, cNames, rgDispId); } - HRESULT __stdcall Invoke (DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, - DISPPARAMS* pDispParams, VARIANT* pVarResult, + HRESULT __stdcall Invoke (DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, + DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) { if (holderComp == 0) return DISP_E_MEMBERNOTFOUND; - return iDispatchHelper.doInvoke (holderComp->getObject(), - dispIdMember, riid, lcid, wFlags, pDispParams, + return iDispatchHelper.doInvoke (holderComp->getObject(), + dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); } @@ -713,8 +713,8 @@ public: } HRESULT __stdcall GetSite (REFIID riid, void **ppvSite) - { - *ppvSite = site; + { + *ppvSite = site; return S_OK; } @@ -824,7 +824,7 @@ extern "C" BOOL WINAPI DllMain (HANDLE instance, DWORD reason, LPVOID) log ("DLL_PROCESS_DETACH"); browserVersionDesc = String::empty; - // IE has a tendency to leak our objects, so although none of this should be + // IE has a tendency to leak our objects, so although none of this should be // necessary, it's best to make sure.. jassert (numActivePlugins == 0); shutdownJuce_GUI(); @@ -875,7 +875,7 @@ STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID* ppv) return CLASS_E_CLASSNOTAVAILABLE; } -STDAPI DllCanUnloadNow() +STDAPI DllCanUnloadNow() { #pragma EXPORTED_FUNCTION return S_OK; @@ -938,7 +938,7 @@ static HRESULT doRegistration (const bool unregister) PlatformUtilities::setRegistryValue (settings.getAllKeys()[i], settings [settings.getAllKeys()[i]]); - // check whether the registration actually worked - if not, we probably don't have + // check whether the registration actually worked - if not, we probably don't have // enough privileges to write to the registry.. if (PlatformUtilities::getRegistryValue (clsIDRoot + "InProcServer32\\") != dllPath) return SELFREG_E_CLASS; @@ -947,7 +947,7 @@ static HRESULT doRegistration (const bool unregister) return S_OK; } -STDAPI DllRegisterServer() +STDAPI DllRegisterServer() { #pragma EXPORTED_FUNCTION return doRegistration (false); diff --git a/extras/browser plugins/wrapper/juce_BrowserPluginComponent.h b/extras/browser plugins/wrapper/juce_BrowserPluginComponent.h index 0cc2cbbef6..215663383a 100644 --- a/extras/browser plugins/wrapper/juce_BrowserPluginComponent.h +++ b/extras/browser plugins/wrapper/juce_BrowserPluginComponent.h @@ -29,8 +29,8 @@ ============================================================================== */ -#ifndef __JUCE_BROWSERPLUGINCOMP_H__ -#define __JUCE_BROWSERPLUGINCOMP_H__ +#ifndef __JUCE_BROWSERPLUGINCOMPONENT_JUCEHEADER__ +#define __JUCE_BROWSERPLUGINCOMPONENT_JUCEHEADER__ #include "../../../../juce/juce_amalgamated.h" @@ -38,10 +38,10 @@ //============================================================================== /** Base class for a browser plugin object. - + You need to implement a createBrowserPlugin() function that the host will call when it needs a new instance of your BrowserPluginComponent subclass. The host will - delete the BrowserPluginComponent later when the user navigates away from the + delete the BrowserPluginComponent later when the user navigates away from the page. */ class BrowserPluginComponent : public Component @@ -53,7 +53,7 @@ public: @see createBrowserPlugin */ BrowserPluginComponent(); - + /** Destructor. */ ~BrowserPluginComponent(); @@ -65,10 +65,10 @@ public: /** Returns the URL that the browser is currently showing. */ const String getBrowserURL() const; - + /** The plugin must implement this method to return a variant object whose properties and methods can be accessed by javascript in the browser. - + If your plugin doesn't need to represent itself, you can just return a void var() object here. */ @@ -81,7 +81,7 @@ public: //============================================================================== /** - This function must be implemented somewhere in your code to create the actual + This function must be implemented somewhere in your code to create the actual plugin object that you want to use. Obviously multiple instances may be used simultaneously, so be VERY cautious @@ -90,4 +90,4 @@ public: BrowserPluginComponent* JUCE_CALLTYPE createBrowserPlugin(); -#endif +#endif // __JUCE_BROWSERPLUGINCOMPONENT_JUCEHEADER__ diff --git a/extras/browser plugins/wrapper/juce_IncludeBrowserPluginInfo.h b/extras/browser plugins/wrapper/juce_IncludeBrowserPluginInfo.h index d5b89e9063..79e3823c62 100644 --- a/extras/browser plugins/wrapper/juce_IncludeBrowserPluginInfo.h +++ b/extras/browser plugins/wrapper/juce_IncludeBrowserPluginInfo.h @@ -1,53 +1,53 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#ifndef __JUCE_INCLUDE_BROWSER_PLUGIN_INFO_H__ -#define __JUCE_INCLUDE_BROWSER_PLUGIN_INFO_H__ - -#include "BrowserPluginCharacteristics.h" - - -//============================================================================== -// The following macros just cause a compile error if you've forgotten to -// define all your plugin settings properly. - -#if ! (defined (JuceBrowserPlugin_Name) \ - && defined (JuceBrowserPlugin_Desc) \ - && defined (JuceBrowserPlugin_Company) \ - && defined (JuceBrowserPlugin_MimeType) \ - && defined (JuceBrowserPlugin_MimeType_Raw) \ - && defined (JuceBrowserPlugin_FileSuffix) \ - && defined (JuceBrowserPlugin_Version) \ - && defined (JuceBrowserPlugin_WinVersion)) - #error "You haven't defined all the necessary JuceBrowserPlugin_xx values in your BrowserPluginCharacteristics.h file!" -#endif - -#endif +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#ifndef __JUCE_INCLUDEBROWSERPLUGININFO_JUCEHEADER__ +#define __JUCE_INCLUDEBROWSERPLUGININFO_JUCEHEADER__ + +#include "BrowserPluginCharacteristics.h" + + +//============================================================================== +// The following macros just cause a compile error if you've forgotten to +// define all your plugin settings properly. + +#if ! (defined (JuceBrowserPlugin_Name) \ + && defined (JuceBrowserPlugin_Desc) \ + && defined (JuceBrowserPlugin_Company) \ + && defined (JuceBrowserPlugin_MimeType) \ + && defined (JuceBrowserPlugin_MimeType_Raw) \ + && defined (JuceBrowserPlugin_FileSuffix) \ + && defined (JuceBrowserPlugin_Version) \ + && defined (JuceBrowserPlugin_WinVersion)) + #error "You haven't defined all the necessary JuceBrowserPlugin_xx values in your BrowserPluginCharacteristics.h file!" +#endif + +#endif // __JUCE_INCLUDEBROWSERPLUGININFO_JUCEHEADER__ diff --git a/extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp b/extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp index 65367e5155..e1e24334fd 100644 --- a/extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp +++ b/extras/browser plugins/wrapper/juce_NPAPI_GlueCode.cpp @@ -103,7 +103,7 @@ extern "C" } #pragma export off -#ifndef NP_CLASS_STRUCT_VERSION_ENUM // fill in some symbols that are missing from the OSX 10.4 SDK +#ifndef NP_CLASS_STRUCT_VERSION_ENUM // fill in some symbols that are missing from the OSX 10.4 SDK #define NPNVpluginDrawingModel 1000 #define NPDrawingModelCoreGraphics 1 @@ -312,7 +312,7 @@ public: { return child->getJavascriptObject(); } - + //============================================================================== NPP npp; BrowserPluginComponent* child; @@ -417,7 +417,7 @@ public: Rectangle rr (frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); Rectangle rr2 (bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); //log (String ((int) x) + ", " + String ((int) y) + " - " + nsStringToJuce([parent description]) + " " + rr.toString() + " " + rr2.toString()); - + if (x >= 0 && x < frame.size.width && y >= 0 && y < frame.size.height) { x += bounds.origin.x; // adjust for scrolling panels @@ -482,7 +482,7 @@ public: NSRect v = [content convertRect: [content frame] toView: nil]; NSRect w = [win frame]; - log ("wx: " + Rectangle (v.origin.x, v.origin.y, v.size.width, v.size.height).toString() + log ("wx: " + Rectangle (v.origin.x, v.origin.y, v.size.width, v.size.height).toString() + " " + Rectangle (w.origin.x, w.origin.y, w.size.width, w.size.height).toString()); // adjust the requested window pos to deal with the content view's origin within the window @@ -576,7 +576,7 @@ public: { NPVariant value; createNPVariantFromValue (npp, value, newValue); - + browser.setproperty (npp, source, getIdentifierFromString (propertyName), &value); browser.releasevariantvalue (&value); } @@ -596,7 +596,7 @@ public: int numParameters) { var returnVal; - + NPVariant result; VOID_TO_NPVARIANT (result); @@ -617,7 +617,7 @@ public: for (i = 0; i < numParameters; ++i) browser.releasevariantvalue (¶ms[i]); - + juce_free (params); } else @@ -706,7 +706,7 @@ private: return false; const var result (o->getProperty (propName)); - + if (out != 0) createNPVariantFromValue (npp, *out, result); @@ -782,12 +782,12 @@ static NPClass sNPObjectWrappingDynamicObject_NPClass = #else static NPClass sNPObjectWrappingDynamicObject_NPClass = { - NP_CLASS_STRUCT_VERSION_ENUM, NPObjectWrappingDynamicObject::createInstance, - NPObjectWrappingDynamicObject::class_deallocate, NPObjectWrappingDynamicObject::class_invalidate, - NPObjectWrappingDynamicObject::class_hasMethod, NPObjectWrappingDynamicObject::class_invoke, - NPObjectWrappingDynamicObject::class_invokeDefault, NPObjectWrappingDynamicObject::class_hasProperty, - NPObjectWrappingDynamicObject::class_getProperty, NPObjectWrappingDynamicObject::class_setProperty, - NPObjectWrappingDynamicObject::class_removeProperty, NPObjectWrappingDynamicObject::class_enumerate + NP_CLASS_STRUCT_VERSION_ENUM, NPObjectWrappingDynamicObject::createInstance, + NPObjectWrappingDynamicObject::class_deallocate, NPObjectWrappingDynamicObject::class_invalidate, + NPObjectWrappingDynamicObject::class_hasMethod, NPObjectWrappingDynamicObject::class_invoke, + NPObjectWrappingDynamicObject::class_invokeDefault, NPObjectWrappingDynamicObject::class_hasProperty, + NPObjectWrappingDynamicObject::class_getProperty, NPObjectWrappingDynamicObject::class_setProperty, + NPObjectWrappingDynamicObject::class_removeProperty, NPObjectWrappingDynamicObject::class_enumerate }; #endif @@ -810,7 +810,7 @@ NPObject* NPObjectWrappingDynamicObject::create (NPP npp, const var& objectToWra if (nppObject != 0) ((NPObjectWrappingDynamicObject*) nppObject)->object = objectToWrap; - + return nppObject; } @@ -826,10 +826,10 @@ static const var createValueFromNPVariant (NPP npp, const NPVariant& v) return var (NPVARIANT_TO_DOUBLE (v)); else if (NPVARIANT_IS_STRING (v)) #if JUCE_MAC - return var (String::fromUTF8 ((const juce::uint8*) (NPVARIANT_TO_STRING (v).UTF8Characters), + return var (String::fromUTF8 ((const juce::uint8*) (NPVARIANT_TO_STRING (v).UTF8Characters), (int) NPVARIANT_TO_STRING (v).UTF8Length)); #else - return var (String::fromUTF8 ((const juce::uint8*) (NPVARIANT_TO_STRING (v).utf8characters), + return var (String::fromUTF8 ((const juce::uint8*) (NPVARIANT_TO_STRING (v).utf8characters), (int) NPVARIANT_TO_STRING (v).utf8length)); #endif else if (NPVARIANT_IS_OBJECT (v)) @@ -843,9 +843,9 @@ static void createNPVariantFromValue (NPP npp, NPVariant& out, const var& v) if (v.isInt()) INT32_TO_NPVARIANT ((int) v, out); else if (v.isBool()) - BOOLEAN_TO_NPVARIANT ((bool) v, out); + BOOLEAN_TO_NPVARIANT ((bool) v, out); else if (v.isDouble()) - DOUBLE_TO_NPVARIANT ((double) v, out); + DOUBLE_TO_NPVARIANT ((double) v, out); else if (v.isString()) { const String s (v.toString()); @@ -892,7 +892,7 @@ public: deleteAndZero (holderComp); scriptObject = 0; } - + return true; } @@ -987,18 +987,18 @@ NPError NPP_SetWindow (NPP npp, NPWindow* pNPWindow) JucePluginInstance* const p = (JucePluginInstance*) npp->pdata; - if (p == 0) + if (p == 0) return NPERR_GENERIC_ERROR; currentlyInitialisingNPP = npp; - NPError result = p->setWindow (pNPWindow) ? NPERR_NO_ERROR + NPError result = p->setWindow (pNPWindow) ? NPERR_NO_ERROR : NPERR_MODULE_LOAD_FAILED_ERROR; currentlyInitialisingNPP = 0; return result; } //============================================================================== -NPError NPP_GetValue (NPP npp, NPPVariable variable, void* value) +NPError NPP_GetValue (NPP npp, NPPVariable variable, void* value) { if (npp == 0) return NPERR_INVALID_INSTANCE_ERROR; @@ -1008,7 +1008,7 @@ NPError NPP_GetValue (NPP npp, NPPVariable variable, void* value) if (p == 0) return NPERR_GENERIC_ERROR; - switch (variable) + switch (variable) { case NPPVpluginNameString: *((char**) value) = JuceBrowserPlugin_Name; @@ -1029,7 +1029,7 @@ NPError NPP_GetValue (NPP npp, NPPVariable variable, void* value) NPError NPP_NewStream (NPP npp, NPMIMEType type, - NPStream* stream, + NPStream* stream, NPBool seekable, ::uint16* stype) { @@ -1159,7 +1159,7 @@ const String BrowserPluginComponent::getBrowserURL() const if (windowObj != 0) { NPVariant location; - bool ok = browser.getproperty (npp, windowObj, + bool ok = browser.getproperty (npp, windowObj, browser.getstringidentifier ("location"), &location); browser.releaseobject (windowObj); @@ -1167,7 +1167,7 @@ const String BrowserPluginComponent::getBrowserURL() const if (ok) { NPVariant href; - ok = browser.getproperty (npp, location.value.objectValue, + ok = browser.getproperty (npp, location.value.objectValue, browser.getstringidentifier ("href"), &href); browser.releasevariantvalue (&location); @@ -1180,7 +1180,6 @@ const String BrowserPluginComponent::getBrowserURL() const } } } - + return result; } - diff --git a/extras/browser plugins/wrapper/npapi/jni.h b/extras/browser plugins/wrapper/npapi/jni.h index 6105e030b3..8ffe6fa6e3 100644 --- a/extras/browser plugins/wrapper/npapi/jni.h +++ b/extras/browser plugins/wrapper/npapi/jni.h @@ -1,1973 +1,1971 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Java Runtime Interface. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation and Sun Microsystems, Inc. - * Portions created by the Initial Developer are Copyright (C) 1993-1996 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef JNI_H -#define 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 - */ - -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; - -#if 0 /* moved to jri_md.h */ -typedef jobject jref; /* For transition---not meant to be part of public - API anymore.*/ -#endif - -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; - -/* - * 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, jboolean *buf); - void (JNICALL *SetByteArrayRegion) - (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf); - void (JNICALL *SetCharArrayRegion) - (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf); - void (JNICALL *SetShortArrayRegion) - (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf); - void (JNICALL *SetIntArrayRegion) - (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf); - void (JNICALL *SetLongArrayRegion) - (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf); - void (JNICALL *SetFloatArrayRegion) - (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf); - void (JNICALL *SetDoubleArrayRegion) - (JNIEnv *env, jdoubleArray array, jsize start, jsize len, 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); -}; - -/* - * 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, - 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, 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, 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, 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, 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, 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, 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, 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, - 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, - 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, - 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, - 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, 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, 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, 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, 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, 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, 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, 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, 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, - 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, - jboolean *buf) { - functions->SetBooleanArrayRegion(this,array,start,len,buf); - } - void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, - jbyte *buf) { - functions->SetByteArrayRegion(this,array,start,len,buf); - } - void SetCharArrayRegion(jcharArray array, jsize start, jsize len, - jchar *buf) { - functions->SetCharArrayRegion(this,array,start,len,buf); - } - void SetShortArrayRegion(jshortArray array, jsize start, jsize len, - jshort *buf) { - functions->SetShortArrayRegion(this,array,start,len,buf); - } - void SetIntArrayRegion(jintArray array, jsize start, jsize len, - jint *buf) { - functions->SetIntArrayRegion(this,array,start,len,buf); - } - void SetLongArrayRegion(jlongArray array, jsize start, jsize len, - jlong *buf) { - functions->SetLongArrayRegion(this,array,start,len,buf); - } - void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, - jfloat *buf) { - functions->SetFloatArrayRegion(this,array,start,len,buf); - } - void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, - 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); - } - -#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 structures will be VM-specific. */ - -typedef struct JDK1_1InitArgs { - jint version; - - char **properties; - jint checkSource; - jint nativeStackSize; - jint javaStackSize; - jint minHeapSize; - jint maxHeapSize; - jint verifyMode; - char *classpath; - - jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args); - void (JNICALL *exit)(jint code); - void (JNICALL *abort)(void); - - jint enableClassGC; - jint enableVerboseGC; - jint disableAsyncGC; - jint verbose; - jboolean debugging; - jint debugPort; -} JDK1_1InitArgs; - -typedef struct JDK1_1AttachArgs { - void * __padding; /* C compilers don't allow empty structures. */ -} JDK1_1AttachArgs; - -#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 - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* JNI_H */ - - +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Java Runtime Interface. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation and Sun Microsystems, Inc. + * Portions created by the Initial Developer are Copyright (C) 1993-1996 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef JNI_H +#define 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 + */ + +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; + +#if 0 /* moved to jri_md.h */ +typedef jobject jref; /* For transition---not meant to be part of public + API anymore.*/ +#endif + +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; + +/* + * 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, jboolean *buf); + void (JNICALL *SetByteArrayRegion) + (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf); + void (JNICALL *SetCharArrayRegion) + (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf); + void (JNICALL *SetShortArrayRegion) + (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf); + void (JNICALL *SetIntArrayRegion) + (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf); + void (JNICALL *SetLongArrayRegion) + (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf); + void (JNICALL *SetFloatArrayRegion) + (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf); + void (JNICALL *SetDoubleArrayRegion) + (JNIEnv *env, jdoubleArray array, jsize start, jsize len, 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); +}; + +/* + * 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, 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, 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, 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, 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, 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, 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, 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, + 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, + 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, + 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, + 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, 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, 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, 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, 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, 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, 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, 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, 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, + 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, + jboolean *buf) { + functions->SetBooleanArrayRegion(this,array,start,len,buf); + } + void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, + jbyte *buf) { + functions->SetByteArrayRegion(this,array,start,len,buf); + } + void SetCharArrayRegion(jcharArray array, jsize start, jsize len, + jchar *buf) { + functions->SetCharArrayRegion(this,array,start,len,buf); + } + void SetShortArrayRegion(jshortArray array, jsize start, jsize len, + jshort *buf) { + functions->SetShortArrayRegion(this,array,start,len,buf); + } + void SetIntArrayRegion(jintArray array, jsize start, jsize len, + jint *buf) { + functions->SetIntArrayRegion(this,array,start,len,buf); + } + void SetLongArrayRegion(jlongArray array, jsize start, jsize len, + jlong *buf) { + functions->SetLongArrayRegion(this,array,start,len,buf); + } + void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, + jfloat *buf) { + functions->SetFloatArrayRegion(this,array,start,len,buf); + } + void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, + 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); + } + +#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 structures will be VM-specific. */ + +typedef struct JDK1_1InitArgs { + jint version; + + char **properties; + jint checkSource; + jint nativeStackSize; + jint javaStackSize; + jint minHeapSize; + jint maxHeapSize; + jint verifyMode; + char *classpath; + + jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args); + void (JNICALL *exit)(jint code); + void (JNICALL *abort)(void); + + jint enableClassGC; + jint enableVerboseGC; + jint disableAsyncGC; + jint verbose; + jboolean debugging; + jint debugPort; +} JDK1_1InitArgs; + +typedef struct JDK1_1AttachArgs { + void * __padding; /* C compilers don't allow empty structures. */ +} JDK1_1AttachArgs; + +#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 + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* JNI_H */ diff --git a/extras/browser plugins/wrapper/npapi/jni_md.h b/extras/browser plugins/wrapper/npapi/jni_md.h index 9e51692ef1..61bf2f35fb 100644 --- a/extras/browser plugins/wrapper/npapi/jni_md.h +++ b/extras/browser plugins/wrapper/npapi/jni_md.h @@ -1,215 +1,215 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** - * - * - * This Original Code has been modified by IBM Corporation. - * Modifications made by IBM described herein are - * Copyright (c) International Business Machines - * Corporation, 2000 - * - * Modifications to Mozilla code or documentation - * identified per MPL Section 3.3 - * - * Date Modified by Description of modification - * 03/27/2000 IBM Corp. Set JNICALL to Optlink for - * use in OS2 - */ - -/******************************************************************************* - * Netscape version of jni_md.h -- depends on jri_md.h - ******************************************************************************/ - -#ifndef JNI_MD_H -#define JNI_MD_H - -#include "prtypes.h" /* needed for _declspec */ - -/******************************************************************************* - * WHAT'S UP WITH THIS FILE? - * - * This is where we define the mystical JNI_PUBLIC_API macro that works on all - * platforms. If you're running with Visual C++, Symantec C, or Borland's - * development environment on the PC, you're all set. Or if you're on the Mac - * with Metrowerks, Symantec or MPW with SC you're ok too. For UNIX it shouldn't - * matter. - - * Changes by sailesh on 9/26 - - * There are two symbols used in the declaration of the JNI functions - * and native code that uses the JNI: - * JNICALL - specifies the calling convention - * JNIEXPORT - specifies export status of the function - * - * The syntax to specify calling conventions is different in Win16 and - * Win32 - the brains at Micro$oft at work here. JavaSoft in their - * infinite wisdom cares for no platform other than Win32, and so they - * just define these two symbols as: - - #define JNIEXPORT __declspec(dllexport) - #define JNICALL __stdcall - - * We deal with this, in the way JRI defines the JRI_PUBLIC_API, by - * defining a macro called JNI_PUBLIC_API. Any of our developers who - * wish to use code for Win16 and Win32, _must_ use JNI_PUBLIC_API to - * be able to export functions properly. - - * Since we must also maintain compatibility with JavaSoft, we - * continue to define the symbol JNIEXPORT. However, use of this - * internally is deprecated, since it will cause a mess on Win16. - - * We _do not_ need a new symbol called JNICALL. Instead we - * redefine JNICALL in the same way JRI_CALLBACK was defined. - - ******************************************************************************/ - -/* DLL Entry modifiers... */ -/* Win32 */ -#if defined(XP_WIN) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32) -# include -# if defined(_MSC_VER) || defined(__GNUC__) -# if defined(WIN32) || defined(_WIN32) -# define JNI_PUBLIC_API(ResultType) _declspec(dllexport) ResultType __stdcall -# define JNI_PUBLIC_VAR(VarType) VarType -# define JNI_NATIVE_STUB(ResultType) _declspec(dllexport) ResultType -# define JNICALL __stdcall -# else /* !_WIN32 */ -# if defined(_WINDLL) -# define JNI_PUBLIC_API(ResultType) ResultType __cdecl __export __loadds -# define JNI_PUBLIC_VAR(VarType) VarType -# define JNI_NATIVE_STUB(ResultType) ResultType __cdecl __loadds -# define JNICALL __loadds -# else /* !WINDLL */ -# define JNI_PUBLIC_API(ResultType) ResultType __cdecl __export -# define JNI_PUBLIC_VAR(VarType) VarType -# define JNI_NATIVE_STUB(ResultType) ResultType __cdecl __export -# define JNICALL __export -# endif /* !WINDLL */ -# endif /* !_WIN32 */ -# elif defined(__BORLANDC__) -# if defined(WIN32) || defined(_WIN32) -# define JNI_PUBLIC_API(ResultType) __export ResultType -# define JNI_PUBLIC_VAR(VarType) VarType -# define JNI_NATIVE_STUB(ResultType) __export ResultType -# define JNICALL -# else /* !_WIN32 */ -# define JNI_PUBLIC_API(ResultType) ResultType _cdecl _export _loadds -# define JNI_PUBLIC_VAR(VarType) VarType -# define JNI_NATIVE_STUB(ResultType) ResultType _cdecl _loadds -# define JNICALL _loadds -# endif -# else -# error Unsupported PC development environment. -# endif -# ifndef IS_LITTLE_ENDIAN -# define IS_LITTLE_ENDIAN -# endif - /* This is the stuff inherited from JavaSoft .. */ -# define JNIEXPORT __declspec(dllexport) -# define JNIIMPORT __declspec(dllimport) - -/* OS/2 */ -#elif defined(XP_OS2) -# ifdef XP_OS2_VACPP -# define JNI_PUBLIC_API(ResultType) ResultType _System -# define JNI_PUBLIC_VAR(VarType) VarType -# define JNICALL _Optlink -# define JNIEXPORT -# define JNIIMPORT -# elif defined(__declspec) -# define JNI_PUBLIC_API(ResultType) __declspec(dllexport) ResultType -# define JNI_PUBLIC_VAR(VarType) VarType -# define JNI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType -# define JNICALL -# define JNIEXPORT -# define JNIIMPORT -# else -# define JNI_PUBLIC_API(ResultType) ResultType -# define JNI_PUBLIC_VAR(VarType) VarType -# define JNICALL -# define JNIEXPORT -# define JNIIMPORT -# endif -# ifndef IS_LITTLE_ENDIAN -# define IS_LITTLE_ENDIAN -# endif - -/* Mac */ -#elif macintosh || Macintosh || THINK_C -# if defined(__MWERKS__) /* Metrowerks */ -# if !__option(enumsalwaysint) -# error You need to define 'Enums Always Int' for your project. -# endif -# if defined(TARGET_CPU_68K) && !TARGET_RT_MAC_CFM -# if !__option(fourbyteints) -# error You need to define 'Struct Alignment: 68k' for your project. -# endif -# endif /* !GENERATINGCFM */ -# define JNI_PUBLIC_API(ResultType) __declspec(export) ResultType -# define JNI_PUBLIC_VAR(VarType) JNI_PUBLIC_API(VarType) -# define JNI_NATIVE_STUB(ResultType) JNI_PUBLIC_API(ResultType) -# elif defined(__SC__) /* Symantec */ -# error What are the Symantec defines? (warren@netscape.com) -# elif macintosh && applec /* MPW */ -# error Please upgrade to the latest MPW compiler (SC). -# else -# error Unsupported Mac development environment. -# endif -# define JNICALL - /* This is the stuff inherited from JavaSoft .. */ -# define JNIEXPORT -# define JNIIMPORT - -/* Unix or else */ -#else -# define JNI_PUBLIC_API(ResultType) ResultType -# define JNI_PUBLIC_VAR(VarType) VarType -# define JNI_NATIVE_STUB(ResultType) ResultType -# define JNICALL - /* This is the stuff inherited from JavaSoft .. */ -# define JNIEXPORT -# define JNIIMPORT -#endif - -#ifndef FAR /* for non-Win16 */ -#define FAR -#endif - -/* Get the rest of the stuff from jri_md.h */ -#include "jri_md.h" - -#endif /* JNI_MD_H */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** + * + * + * This Original Code has been modified by IBM Corporation. + * Modifications made by IBM described herein are + * Copyright (c) International Business Machines + * Corporation, 2000 + * + * Modifications to Mozilla code or documentation + * identified per MPL Section 3.3 + * + * Date Modified by Description of modification + * 03/27/2000 IBM Corp. Set JNICALL to Optlink for + * use in OS2 + */ + +/******************************************************************************* + * Netscape version of jni_md.h -- depends on jri_md.h + ******************************************************************************/ + +#ifndef JNI_MD_H +#define JNI_MD_H + +#include "prtypes.h" /* needed for _declspec */ + +/******************************************************************************* + * WHAT'S UP WITH THIS FILE? + * + * This is where we define the mystical JNI_PUBLIC_API macro that works on all + * platforms. If you're running with Visual C++, Symantec C, or Borland's + * development environment on the PC, you're all set. Or if you're on the Mac + * with Metrowerks, Symantec or MPW with SC you're ok too. For UNIX it shouldn't + * matter. + + * Changes by sailesh on 9/26 + + * There are two symbols used in the declaration of the JNI functions + * and native code that uses the JNI: + * JNICALL - specifies the calling convention + * JNIEXPORT - specifies export status of the function + * + * The syntax to specify calling conventions is different in Win16 and + * Win32 - the brains at Micro$oft at work here. JavaSoft in their + * infinite wisdom cares for no platform other than Win32, and so they + * just define these two symbols as: + + #define JNIEXPORT __declspec(dllexport) + #define JNICALL __stdcall + + * We deal with this, in the way JRI defines the JRI_PUBLIC_API, by + * defining a macro called JNI_PUBLIC_API. Any of our developers who + * wish to use code for Win16 and Win32, _must_ use JNI_PUBLIC_API to + * be able to export functions properly. + + * Since we must also maintain compatibility with JavaSoft, we + * continue to define the symbol JNIEXPORT. However, use of this + * internally is deprecated, since it will cause a mess on Win16. + + * We _do not_ need a new symbol called JNICALL. Instead we + * redefine JNICALL in the same way JRI_CALLBACK was defined. + + ******************************************************************************/ + +/* DLL Entry modifiers... */ +/* Win32 */ +#if defined(XP_WIN) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32) +# include +# if defined(_MSC_VER) || defined(__GNUC__) +# if defined(WIN32) || defined(_WIN32) +# define JNI_PUBLIC_API(ResultType) _declspec(dllexport) ResultType __stdcall +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) _declspec(dllexport) ResultType +# define JNICALL __stdcall +# else /* !_WIN32 */ +# if defined(_WINDLL) +# define JNI_PUBLIC_API(ResultType) ResultType __cdecl __export __loadds +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) ResultType __cdecl __loadds +# define JNICALL __loadds +# else /* !WINDLL */ +# define JNI_PUBLIC_API(ResultType) ResultType __cdecl __export +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) ResultType __cdecl __export +# define JNICALL __export +# endif /* !WINDLL */ +# endif /* !_WIN32 */ +# elif defined(__BORLANDC__) +# if defined(WIN32) || defined(_WIN32) +# define JNI_PUBLIC_API(ResultType) __export ResultType +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) __export ResultType +# define JNICALL +# else /* !_WIN32 */ +# define JNI_PUBLIC_API(ResultType) ResultType _cdecl _export _loadds +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) ResultType _cdecl _loadds +# define JNICALL _loadds +# endif +# else +# error Unsupported PC development environment. +# endif +# ifndef IS_LITTLE_ENDIAN +# define IS_LITTLE_ENDIAN +# endif + /* This is the stuff inherited from JavaSoft .. */ +# define JNIEXPORT __declspec(dllexport) +# define JNIIMPORT __declspec(dllimport) + +/* OS/2 */ +#elif defined(XP_OS2) +# ifdef XP_OS2_VACPP +# define JNI_PUBLIC_API(ResultType) ResultType _System +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNICALL _Optlink +# define JNIEXPORT +# define JNIIMPORT +# elif defined(__declspec) +# define JNI_PUBLIC_API(ResultType) __declspec(dllexport) ResultType +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType +# define JNICALL +# define JNIEXPORT +# define JNIIMPORT +# else +# define JNI_PUBLIC_API(ResultType) ResultType +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNICALL +# define JNIEXPORT +# define JNIIMPORT +# endif +# ifndef IS_LITTLE_ENDIAN +# define IS_LITTLE_ENDIAN +# endif + +/* Mac */ +#elif macintosh || Macintosh || THINK_C +# if defined(__MWERKS__) /* Metrowerks */ +# if !__option(enumsalwaysint) +# error You need to define 'Enums Always Int' for your project. +# endif +# if defined(TARGET_CPU_68K) && !TARGET_RT_MAC_CFM +# if !__option(fourbyteints) +# error You need to define 'Struct Alignment: 68k' for your project. +# endif +# endif /* !GENERATINGCFM */ +# define JNI_PUBLIC_API(ResultType) __declspec(export) ResultType +# define JNI_PUBLIC_VAR(VarType) JNI_PUBLIC_API(VarType) +# define JNI_NATIVE_STUB(ResultType) JNI_PUBLIC_API(ResultType) +# elif defined(__SC__) /* Symantec */ +# error What are the Symantec defines? (warren@netscape.com) +# elif macintosh && applec /* MPW */ +# error Please upgrade to the latest MPW compiler (SC). +# else +# error Unsupported Mac development environment. +# endif +# define JNICALL + /* This is the stuff inherited from JavaSoft .. */ +# define JNIEXPORT +# define JNIIMPORT + +/* Unix or else */ +#else +# define JNI_PUBLIC_API(ResultType) ResultType +# define JNI_PUBLIC_VAR(VarType) VarType +# define JNI_NATIVE_STUB(ResultType) ResultType +# define JNICALL + /* This is the stuff inherited from JavaSoft .. */ +# define JNIEXPORT +# define JNIIMPORT +#endif + +#ifndef FAR /* for non-Win16 */ +#define FAR +#endif + +/* Get the rest of the stuff from jri_md.h */ +#include "jri_md.h" + +#endif /* JNI_MD_H */ diff --git a/extras/browser plugins/wrapper/npapi/jri.h b/extras/browser plugins/wrapper/npapi/jri.h index 866fc69aa4..7029a3763e 100644 --- a/extras/browser plugins/wrapper/npapi/jri.h +++ b/extras/browser plugins/wrapper/npapi/jri.h @@ -1,689 +1,689 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/******************************************************************************* - * Java Runtime Interface - ******************************************************************************/ - -#ifndef JRI_H -#define JRI_H - -#include "jritypes.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/******************************************************************************* - * JRIEnv - ******************************************************************************/ - -/* The type of the JRIEnv interface. */ -typedef struct JRIEnvInterface JRIEnvInterface; - -/* The type of a JRIEnv instance. */ -typedef const JRIEnvInterface* JRIEnv; - -/******************************************************************************* - * JRIEnv Operations - ******************************************************************************/ - -#define JRI_DefineClass(env, classLoader, buf, bufLen) \ - (((*(env))->DefineClass)(env, JRI_DefineClass_op, classLoader, buf, bufLen)) - -#define JRI_FindClass(env, name) \ - (((*(env))->FindClass)(env, JRI_FindClass_op, name)) - -#define JRI_Throw(env, obj) \ - (((*(env))->Throw)(env, JRI_Throw_op, obj)) - -#define JRI_ThrowNew(env, clazz, message) \ - (((*(env))->ThrowNew)(env, JRI_ThrowNew_op, clazz, message)) - -#define JRI_ExceptionOccurred(env) \ - (((*(env))->ExceptionOccurred)(env, JRI_ExceptionOccurred_op)) - -#define JRI_ExceptionDescribe(env) \ - (((*(env))->ExceptionDescribe)(env, JRI_ExceptionDescribe_op)) - -#define JRI_ExceptionClear(env) \ - (((*(env))->ExceptionClear)(env, JRI_ExceptionClear_op)) - -#define JRI_NewGlobalRef(env, ref) \ - (((*(env))->NewGlobalRef)(env, JRI_NewGlobalRef_op, ref)) - -#define JRI_DisposeGlobalRef(env, gref) \ - (((*(env))->DisposeGlobalRef)(env, JRI_DisposeGlobalRef_op, gref)) - -#define JRI_GetGlobalRef(env, gref) \ - (((*(env))->GetGlobalRef)(env, JRI_GetGlobalRef_op, gref)) - -#define JRI_SetGlobalRef(env, gref, ref) \ - (((*(env))->SetGlobalRef)(env, JRI_SetGlobalRef_op, gref, ref)) - -#define JRI_IsSameObject(env, a, b) \ - (((*(env))->IsSameObject)(env, JRI_IsSameObject_op, a, b)) - -#define JRI_NewObject(env) ((*(env))->NewObject) -#define JRI_NewObjectV(env, clazz, methodID, args) \ - (((*(env))->NewObjectV)(env, JRI_NewObject_op_va_list, clazz, methodID, args)) -#define JRI_NewObjectA(env, clazz, method, args) \ - (((*(env))->NewObjectA)(env, JRI_NewObject_op_array, clazz, methodID, args)) - -#define JRI_GetObjectClass(env, obj) \ - (((*(env))->GetObjectClass)(env, JRI_GetObjectClass_op, obj)) - -#define JRI_IsInstanceOf(env, obj, clazz) \ - (((*(env))->IsInstanceOf)(env, JRI_IsInstanceOf_op, obj, clazz)) - -#define JRI_GetMethodID(env, clazz, name, sig) \ - (((*(env))->GetMethodID)(env, JRI_GetMethodID_op, clazz, name, sig)) - -#define JRI_CallMethod(env) ((*(env))->CallMethod) -#define JRI_CallMethodV(env, obj, methodID, args) \ - (((*(env))->CallMethodV)(env, JRI_CallMethod_op_va_list, obj, methodID, args)) -#define JRI_CallMethodA(env, obj, methodID, args) \ - (((*(env))->CallMethodA)(env, JRI_CallMethod_op_array, obj, methodID, args)) - -#define JRI_CallMethodBoolean(env) ((*(env))->CallMethodBoolean) -#define JRI_CallMethodBooleanV(env, obj, methodID, args) \ - (((*(env))->CallMethodBooleanV)(env, JRI_CallMethodBoolean_op_va_list, obj, methodID, args)) -#define JRI_CallMethodBooleanA(env, obj, methodID, args) \ - (((*(env))->CallMethodBooleanA)(env, JRI_CallMethodBoolean_op_array, obj, methodID, args)) - -#define JRI_CallMethodByte(env) ((*(env))->CallMethodByte) -#define JRI_CallMethodByteV(env, obj, methodID, args) \ - (((*(env))->CallMethodByteV)(env, JRI_CallMethodByte_op_va_list, obj, methodID, args)) -#define JRI_CallMethodByteA(env, obj, methodID, args) \ - (((*(env))->CallMethodByteA)(env, JRI_CallMethodByte_op_array, obj, methodID, args)) - -#define JRI_CallMethodChar(env) ((*(env))->CallMethodChar) -#define JRI_CallMethodCharV(env, obj, methodID, args) \ - (((*(env))->CallMethodCharV)(env, JRI_CallMethodChar_op_va_list, obj, methodID, args)) -#define JRI_CallMethodCharA(env, obj, methodID, args) \ - (((*(env))->CallMethodCharA)(env, JRI_CallMethodChar_op_array, obj, methodID, args)) - -#define JRI_CallMethodShort(env) ((*(env))->CallMethodShort) -#define JRI_CallMethodShortV(env, obj, methodID, args) \ - (((*(env))->CallMethodShortV)(env, JRI_CallMethodShort_op_va_list, obj, methodID, args)) -#define JRI_CallMethodShortA(env, obj, methodID, args) \ - (((*(env))->CallMethodShortA)(env, JRI_CallMethodShort_op_array, obj, methodID, args)) - -#define JRI_CallMethodInt(env) ((*(env))->CallMethodInt) -#define JRI_CallMethodIntV(env, obj, methodID, args) \ - (((*(env))->CallMethodIntV)(env, JRI_CallMethodInt_op_va_list, obj, methodID, args)) -#define JRI_CallMethodIntA(env, obj, methodID, args) \ - (((*(env))->CallMethodIntA)(env, JRI_CallMethodInt_op_array, obj, methodID, args)) - -#define JRI_CallMethodLong(env) ((*(env))->CallMethodLong) -#define JRI_CallMethodLongV(env, obj, methodID, args) \ - (((*(env))->CallMethodLongV)(env, JRI_CallMethodLong_op_va_list, obj, methodID, args)) -#define JRI_CallMethodLongA(env, obj, methodID, args) \ - (((*(env))->CallMethodLongA)(env, JRI_CallMethodLong_op_array, obj, methodID, args)) - -#define JRI_CallMethodFloat(env) ((*(env))->CallMethodFloat) -#define JRI_CallMethodFloatV(env, obj, methodID, args) \ - (((*(env))->CallMethodFloatV)(env, JRI_CallMethodFloat_op_va_list, obj, methodID, args)) -#define JRI_CallMethodFloatA(env, obj, methodID, args) \ - (((*(env))->CallMethodFloatA)(env, JRI_CallMethodFloat_op_array, obj, methodID, args)) - -#define JRI_CallMethodDouble(env) ((*(env))->CallMethodDouble) -#define JRI_CallMethodDoubleV(env, obj, methodID, args) \ - (((*(env))->CallMethodDoubleV)(env, JRI_CallMethodDouble_op_va_list, obj, methodID, args)) -#define JRI_CallMethodDoubleA(env, obj, methodID, args) \ - (((*(env))->CallMethodDoubleA)(env, JRI_CallMethodDouble_op_array, obj, methodID, args)) - -#define JRI_GetFieldID(env, clazz, name, sig) \ - (((*(env))->GetFieldID)(env, JRI_GetFieldID_op, clazz, name, sig)) - -#define JRI_GetField(env, obj, fieldID) \ - (((*(env))->GetField)(env, JRI_GetField_op, obj, fieldID)) - -#define JRI_GetFieldBoolean(env, obj, fieldID) \ - (((*(env))->GetFieldBoolean)(env, JRI_GetFieldBoolean_op, obj, fieldID)) - -#define JRI_GetFieldByte(env, obj, fieldID) \ - (((*(env))->GetFieldByte)(env, JRI_GetFieldByte_op, obj, fieldID)) - -#define JRI_GetFieldChar(env, obj, fieldID) \ - (((*(env))->GetFieldChar)(env, JRI_GetFieldChar_op, obj, fieldID)) - -#define JRI_GetFieldShort(env, obj, fieldID) \ - (((*(env))->GetFieldShort)(env, JRI_GetFieldShort_op, obj, fieldID)) - -#define JRI_GetFieldInt(env, obj, fieldID) \ - (((*(env))->GetFieldInt)(env, JRI_GetFieldInt_op, obj, fieldID)) - -#define JRI_GetFieldLong(env, obj, fieldID) \ - (((*(env))->GetFieldLong)(env, JRI_GetFieldLong_op, obj, fieldID)) - -#define JRI_GetFieldFloat(env, obj, fieldID) \ - (((*(env))->GetFieldFloat)(env, JRI_GetFieldFloat_op, obj, fieldID)) - -#define JRI_GetFieldDouble(env, obj, fieldID) \ - (((*(env))->GetFieldDouble)(env, JRI_GetFieldDouble_op, obj, fieldID)) - -#define JRI_SetField(env, obj, fieldID, value) \ - (((*(env))->SetField)(env, JRI_SetField_op, obj, fieldID, value)) - -#define JRI_SetFieldBoolean(env, obj, fieldID, value) \ - (((*(env))->SetFieldBoolean)(env, JRI_SetFieldBoolean_op, obj, fieldID, value)) - -#define JRI_SetFieldByte(env, obj, fieldID, value) \ - (((*(env))->SetFieldByte)(env, JRI_SetFieldByte_op, obj, fieldID, value)) - -#define JRI_SetFieldChar(env, obj, fieldID, value) \ - (((*(env))->SetFieldChar)(env, JRI_SetFieldChar_op, obj, fieldID, value)) - -#define JRI_SetFieldShort(env, obj, fieldID, value) \ - (((*(env))->SetFieldShort)(env, JRI_SetFieldShort_op, obj, fieldID, value)) - -#define JRI_SetFieldInt(env, obj, fieldID, value) \ - (((*(env))->SetFieldInt)(env, JRI_SetFieldInt_op, obj, fieldID, value)) - -#define JRI_SetFieldLong(env, obj, fieldID, value) \ - (((*(env))->SetFieldLong)(env, JRI_SetFieldLong_op, obj, fieldID, value)) - -#define JRI_SetFieldFloat(env, obj, fieldID, value) \ - (((*(env))->SetFieldFloat)(env, JRI_SetFieldFloat_op, obj, fieldID, value)) - -#define JRI_SetFieldDouble(env, obj, fieldID, value) \ - (((*(env))->SetFieldDouble)(env, JRI_SetFieldDouble_op, obj, fieldID, value)) - -#define JRI_IsSubclassOf(env, a, b) \ - (((*(env))->IsSubclassOf)(env, JRI_IsSubclassOf_op, a, b)) - -#define JRI_GetStaticMethodID(env, clazz, name, sig) \ - (((*(env))->GetStaticMethodID)(env, JRI_GetStaticMethodID_op, clazz, name, sig)) - -#define JRI_CallStaticMethod(env) ((*(env))->CallStaticMethod) -#define JRI_CallStaticMethodV(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodV)(env, JRI_CallStaticMethod_op_va_list, clazz, methodID, args)) -#define JRI_CallStaticMethodA(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodA)(env, JRI_CallStaticMethod_op_array, clazz, methodID, args)) - -#define JRI_CallStaticMethodBoolean(env) ((*(env))->CallStaticMethodBoolean) -#define JRI_CallStaticMethodBooleanV(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodBooleanV)(env, JRI_CallStaticMethodBoolean_op_va_list, clazz, methodID, args)) -#define JRI_CallStaticMethodBooleanA(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodBooleanA)(env, JRI_CallStaticMethodBoolean_op_array, clazz, methodID, args)) - -#define JRI_CallStaticMethodByte(env) ((*(env))->CallStaticMethodByte) -#define JRI_CallStaticMethodByteV(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodByteV)(env, JRI_CallStaticMethodByte_op_va_list, clazz, methodID, args)) -#define JRI_CallStaticMethodByteA(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodByteA)(env, JRI_CallStaticMethodByte_op_array, clazz, methodID, args)) - -#define JRI_CallStaticMethodChar(env) ((*(env))->CallStaticMethodChar) -#define JRI_CallStaticMethodCharV(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodCharV)(env, JRI_CallStaticMethodChar_op_va_list, clazz, methodID, args)) -#define JRI_CallStaticMethodCharA(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodCharA)(env, JRI_CallStaticMethodChar_op_array, clazz, methodID, args)) - -#define JRI_CallStaticMethodShort(env) ((*(env))->CallStaticMethodShort) -#define JRI_CallStaticMethodShortV(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodShortV)(env, JRI_CallStaticMethodShort_op_va_list, clazz, methodID, args)) -#define JRI_CallStaticMethodShortA(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodShortA)(env, JRI_CallStaticMethodShort_op_array, clazz, methodID, args)) - -#define JRI_CallStaticMethodInt(env) ((*(env))->CallStaticMethodInt) -#define JRI_CallStaticMethodIntV(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodIntV)(env, JRI_CallStaticMethodInt_op_va_list, clazz, methodID, args)) -#define JRI_CallStaticMethodIntA(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodIntA)(env, JRI_CallStaticMethodInt_op_array, clazz, methodID, args)) - -#define JRI_CallStaticMethodLong(env) ((*(env))->CallStaticMethodLong) -#define JRI_CallStaticMethodLongV(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodLongV)(env, JRI_CallStaticMethodLong_op_va_list, clazz, methodID, args)) -#define JRI_CallStaticMethodLongA(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodLongA)(env, JRI_CallStaticMethodLong_op_array, clazz, methodID, args)) - -#define JRI_CallStaticMethodFloat(env) ((*(env))->CallStaticMethodFloat) -#define JRI_CallStaticMethodFloatV(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodFloatV)(env, JRI_CallStaticMethodFloat_op_va_list, clazz, methodID, args)) -#define JRI_CallStaticMethodFloatA(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodFloatA)(env, JRI_CallStaticMethodFloat_op_array, clazz, methodID, args)) - -#define JRI_CallStaticMethodDouble(env) ((*(env))->CallStaticMethodDouble) -#define JRI_CallStaticMethodDoubleV(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodDoubleV)(env, JRI_CallStaticMethodDouble_op_va_list, clazz, methodID, args)) -#define JRI_CallStaticMethodDoubleA(env, clazz, methodID, args) \ - (((*(env))->CallStaticMethodDoubleA)(env, JRI_CallStaticMethodDouble_op_array, clazz, methodID, args)) - -#define JRI_GetStaticFieldID(env, clazz, name, sig) \ - (((*(env))->GetStaticFieldID)(env, JRI_GetStaticFieldID_op, clazz, name, sig)) - -#define JRI_GetStaticField(env, clazz, fieldID) \ - (((*(env))->GetStaticField)(env, JRI_GetStaticField_op, clazz, fieldID)) - -#define JRI_GetStaticFieldBoolean(env, clazz, fieldID) \ - (((*(env))->GetStaticFieldBoolean)(env, JRI_GetStaticFieldBoolean_op, clazz, fieldID)) - -#define JRI_GetStaticFieldByte(env, clazz, fieldID) \ - (((*(env))->GetStaticFieldByte)(env, JRI_GetStaticFieldByte_op, clazz, fieldID)) - -#define JRI_GetStaticFieldChar(env, clazz, fieldID) \ - (((*(env))->GetStaticFieldChar)(env, JRI_GetStaticFieldChar_op, clazz, fieldID)) - -#define JRI_GetStaticFieldShort(env, clazz, fieldID) \ - (((*(env))->GetStaticFieldShort)(env, JRI_GetStaticFieldShort_op, clazz, fieldID)) - -#define JRI_GetStaticFieldInt(env, clazz, fieldID) \ - (((*(env))->GetStaticFieldInt)(env, JRI_GetStaticFieldInt_op, clazz, fieldID)) - -#define JRI_GetStaticFieldLong(env, clazz, fieldID) \ - (((*(env))->GetStaticFieldLong)(env, JRI_GetStaticFieldLong_op, clazz, fieldID)) - -#define JRI_GetStaticFieldFloat(env, clazz, fieldID) \ - (((*(env))->GetStaticFieldFloat)(env, JRI_GetStaticFieldFloat_op, clazz, fieldID)) - -#define JRI_GetStaticFieldDouble(env, clazz, fieldID) \ - (((*(env))->GetStaticFieldDouble)(env, JRI_GetStaticFieldDouble_op, clazz, fieldID)) - -#define JRI_SetStaticField(env, clazz, fieldID, value) \ - (((*(env))->SetStaticField)(env, JRI_SetStaticField_op, clazz, fieldID, value)) - -#define JRI_SetStaticFieldBoolean(env, clazz, fieldID, value) \ - (((*(env))->SetStaticFieldBoolean)(env, JRI_SetStaticFieldBoolean_op, clazz, fieldID, value)) - -#define JRI_SetStaticFieldByte(env, clazz, fieldID, value) \ - (((*(env))->SetStaticFieldByte)(env, JRI_SetStaticFieldByte_op, clazz, fieldID, value)) - -#define JRI_SetStaticFieldChar(env, clazz, fieldID, value) \ - (((*(env))->SetStaticFieldChar)(env, JRI_SetStaticFieldChar_op, clazz, fieldID, value)) - -#define JRI_SetStaticFieldShort(env, clazz, fieldID, value) \ - (((*(env))->SetStaticFieldShort)(env, JRI_SetStaticFieldShort_op, clazz, fieldID, value)) - -#define JRI_SetStaticFieldInt(env, clazz, fieldID, value) \ - (((*(env))->SetStaticFieldInt)(env, JRI_SetStaticFieldInt_op, clazz, fieldID, value)) - -#define JRI_SetStaticFieldLong(env, clazz, fieldID, value) \ - (((*(env))->SetStaticFieldLong)(env, JRI_SetStaticFieldLong_op, clazz, fieldID, value)) - -#define JRI_SetStaticFieldFloat(env, clazz, fieldID, value) \ - (((*(env))->SetStaticFieldFloat)(env, JRI_SetStaticFieldFloat_op, clazz, fieldID, value)) - -#define JRI_SetStaticFieldDouble(env, clazz, fieldID, value) \ - (((*(env))->SetStaticFieldDouble)(env, JRI_SetStaticFieldDouble_op, clazz, fieldID, value)) - -#define JRI_NewString(env, unicode, len) \ - (((*(env))->NewString)(env, JRI_NewString_op, unicode, len)) - -#define JRI_GetStringLength(env, string) \ - (((*(env))->GetStringLength)(env, JRI_GetStringLength_op, string)) - -#define JRI_GetStringChars(env, string) \ - (((*(env))->GetStringChars)(env, JRI_GetStringChars_op, string)) - -#define JRI_NewStringUTF(env, utf, len) \ - (((*(env))->NewStringUTF)(env, JRI_NewStringUTF_op, utf, len)) - -#define JRI_GetStringUTFLength(env, string) \ - (((*(env))->GetStringUTFLength)(env, JRI_GetStringUTFLength_op, string)) - -#define JRI_GetStringUTFChars(env, string) \ - (((*(env))->GetStringUTFChars)(env, JRI_GetStringUTFChars_op, string)) - -#define JRI_NewScalarArray(env, length, elementSig, initialElements) \ - (((*(env))->NewScalarArray)(env, JRI_NewScalarArray_op, length, elementSig, initialElements)) - -#define JRI_GetScalarArrayLength(env, array) \ - (((*(env))->GetScalarArrayLength)(env, JRI_GetScalarArrayLength_op, array)) - -#define JRI_GetScalarArrayElements(env, array) \ - (((*(env))->GetScalarArrayElements)(env, JRI_GetScalarArrayElements_op, array)) - -#define JRI_NewObjectArray(env, length, elementClass, initialElement) \ - (((*(env))->NewObjectArray)(env, JRI_NewObjectArray_op, length, elementClass, initialElement)) - -#define JRI_GetObjectArrayLength(env, array) \ - (((*(env))->GetObjectArrayLength)(env, JRI_GetObjectArrayLength_op, array)) - -#define JRI_GetObjectArrayElement(env, array, index) \ - (((*(env))->GetObjectArrayElement)(env, JRI_GetObjectArrayElement_op, array, index)) - -#define JRI_SetObjectArrayElement(env, array, index, value) \ - (((*(env))->SetObjectArrayElement)(env, JRI_SetObjectArrayElement_op, array, index, value)) - -#define JRI_RegisterNatives(env, clazz, nameAndSigArray, nativeProcArray) \ - (((*(env))->RegisterNatives)(env, JRI_RegisterNatives_op, clazz, nameAndSigArray, nativeProcArray)) - -#define JRI_UnregisterNatives(env, clazz) \ - (((*(env))->UnregisterNatives)(env, JRI_UnregisterNatives_op, clazz)) - -#define JRI_NewStringPlatform(env, string, len, encoding, encodingLength) \ - (((*(env))->NewStringPlatform)(env, JRI_NewStringPlatform_op, string, len, encoding, encodingLength)) - -#define JRI_GetStringPlatformChars(env, string, encoding, encodingLength) \ - (((*(env))->GetStringPlatformChars)(env, JRI_GetStringPlatformChars_op, string, encoding, encodingLength)) - - -/******************************************************************************* - * JRIEnv Interface - ******************************************************************************/ - -struct java_lang_ClassLoader; -struct java_lang_Class; -struct java_lang_Throwable; -struct java_lang_Object; -struct java_lang_String; - -struct JRIEnvInterface { - void* reserved0; - void* reserved1; - void* reserved2; - void* reserved3; - struct java_lang_Class* (*FindClass)(JRIEnv* env, jint op, const char* a); - void (*Throw)(JRIEnv* env, jint op, struct java_lang_Throwable* a); - void (*ThrowNew)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b); - struct java_lang_Throwable* (*ExceptionOccurred)(JRIEnv* env, jint op); - void (*ExceptionDescribe)(JRIEnv* env, jint op); - void (*ExceptionClear)(JRIEnv* env, jint op); - jglobal (*NewGlobalRef)(JRIEnv* env, jint op, void* a); - void (*DisposeGlobalRef)(JRIEnv* env, jint op, jglobal a); - void* (*GetGlobalRef)(JRIEnv* env, jint op, jglobal a); - void (*SetGlobalRef)(JRIEnv* env, jint op, jglobal a, void* b); - jbool (*IsSameObject)(JRIEnv* env, jint op, void* a, void* b); - void* (*NewObject)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - void* (*NewObjectV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - void* (*NewObjectA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - struct java_lang_Class* (*GetObjectClass)(JRIEnv* env, jint op, void* a); - jbool (*IsInstanceOf)(JRIEnv* env, jint op, void* a, struct java_lang_Class* b); - jint (*GetMethodID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); - void* (*CallMethod)(JRIEnv* env, jint op, void* a, jint b, ...); - void* (*CallMethodV)(JRIEnv* env, jint op, void* a, jint b, va_list c); - void* (*CallMethodA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); - jbool (*CallMethodBoolean)(JRIEnv* env, jint op, void* a, jint b, ...); - jbool (*CallMethodBooleanV)(JRIEnv* env, jint op, void* a, jint b, va_list c); - jbool (*CallMethodBooleanA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); - jbyte (*CallMethodByte)(JRIEnv* env, jint op, void* a, jint b, ...); - jbyte (*CallMethodByteV)(JRIEnv* env, jint op, void* a, jint b, va_list c); - jbyte (*CallMethodByteA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); - jchar (*CallMethodChar)(JRIEnv* env, jint op, void* a, jint b, ...); - jchar (*CallMethodCharV)(JRIEnv* env, jint op, void* a, jint b, va_list c); - jchar (*CallMethodCharA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); - jshort (*CallMethodShort)(JRIEnv* env, jint op, void* a, jint b, ...); - jshort (*CallMethodShortV)(JRIEnv* env, jint op, void* a, jint b, va_list c); - jshort (*CallMethodShortA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); - jint (*CallMethodInt)(JRIEnv* env, jint op, void* a, jint b, ...); - jint (*CallMethodIntV)(JRIEnv* env, jint op, void* a, jint b, va_list c); - jint (*CallMethodIntA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); - jlong (*CallMethodLong)(JRIEnv* env, jint op, void* a, jint b, ...); - jlong (*CallMethodLongV)(JRIEnv* env, jint op, void* a, jint b, va_list c); - jlong (*CallMethodLongA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); - jfloat (*CallMethodFloat)(JRIEnv* env, jint op, void* a, jint b, ...); - jfloat (*CallMethodFloatV)(JRIEnv* env, jint op, void* a, jint b, va_list c); - jfloat (*CallMethodFloatA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); - jdouble (*CallMethodDouble)(JRIEnv* env, jint op, void* a, jint b, ...); - jdouble (*CallMethodDoubleV)(JRIEnv* env, jint op, void* a, jint b, va_list c); - jdouble (*CallMethodDoubleA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); - jint (*GetFieldID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); - void* (*GetField)(JRIEnv* env, jint op, void* a, jint b); - jbool (*GetFieldBoolean)(JRIEnv* env, jint op, void* a, jint b); - jbyte (*GetFieldByte)(JRIEnv* env, jint op, void* a, jint b); - jchar (*GetFieldChar)(JRIEnv* env, jint op, void* a, jint b); - jshort (*GetFieldShort)(JRIEnv* env, jint op, void* a, jint b); - jint (*GetFieldInt)(JRIEnv* env, jint op, void* a, jint b); - jlong (*GetFieldLong)(JRIEnv* env, jint op, void* a, jint b); - jfloat (*GetFieldFloat)(JRIEnv* env, jint op, void* a, jint b); - jdouble (*GetFieldDouble)(JRIEnv* env, jint op, void* a, jint b); - void (*SetField)(JRIEnv* env, jint op, void* a, jint b, void* c); - void (*SetFieldBoolean)(JRIEnv* env, jint op, void* a, jint b, jbool c); - void (*SetFieldByte)(JRIEnv* env, jint op, void* a, jint b, jbyte c); - void (*SetFieldChar)(JRIEnv* env, jint op, void* a, jint b, jchar c); - void (*SetFieldShort)(JRIEnv* env, jint op, void* a, jint b, jshort c); - void (*SetFieldInt)(JRIEnv* env, jint op, void* a, jint b, jint c); - void (*SetFieldLong)(JRIEnv* env, jint op, void* a, jint b, jlong c); - void (*SetFieldFloat)(JRIEnv* env, jint op, void* a, jint b, jfloat c); - void (*SetFieldDouble)(JRIEnv* env, jint op, void* a, jint b, jdouble c); - jbool (*IsSubclassOf)(JRIEnv* env, jint op, struct java_lang_Class* a, struct java_lang_Class* b); - jint (*GetStaticMethodID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); - void* (*CallStaticMethod)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - void* (*CallStaticMethodV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - void* (*CallStaticMethodA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - jbool (*CallStaticMethodBoolean)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - jbool (*CallStaticMethodBooleanV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - jbool (*CallStaticMethodBooleanA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - jbyte (*CallStaticMethodByte)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - jbyte (*CallStaticMethodByteV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - jbyte (*CallStaticMethodByteA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - jchar (*CallStaticMethodChar)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - jchar (*CallStaticMethodCharV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - jchar (*CallStaticMethodCharA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - jshort (*CallStaticMethodShort)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - jshort (*CallStaticMethodShortV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - jshort (*CallStaticMethodShortA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - jint (*CallStaticMethodInt)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - jint (*CallStaticMethodIntV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - jint (*CallStaticMethodIntA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - jlong (*CallStaticMethodLong)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - jlong (*CallStaticMethodLongV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - jlong (*CallStaticMethodLongA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - jfloat (*CallStaticMethodFloat)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - jfloat (*CallStaticMethodFloatV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - jfloat (*CallStaticMethodFloatA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - jdouble (*CallStaticMethodDouble)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); - jdouble (*CallStaticMethodDoubleV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); - jdouble (*CallStaticMethodDoubleA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); - jint (*GetStaticFieldID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); - void* (*GetStaticField)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); - jbool (*GetStaticFieldBoolean)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); - jbyte (*GetStaticFieldByte)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); - jchar (*GetStaticFieldChar)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); - jshort (*GetStaticFieldShort)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); - jint (*GetStaticFieldInt)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); - jlong (*GetStaticFieldLong)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); - jfloat (*GetStaticFieldFloat)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); - jdouble (*GetStaticFieldDouble)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); - void (*SetStaticField)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, void* c); - void (*SetStaticFieldBoolean)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jbool c); - void (*SetStaticFieldByte)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jbyte c); - void (*SetStaticFieldChar)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jchar c); - void (*SetStaticFieldShort)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jshort c); - void (*SetStaticFieldInt)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jint c); - void (*SetStaticFieldLong)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jlong c); - void (*SetStaticFieldFloat)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jfloat c); - void (*SetStaticFieldDouble)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jdouble c); - struct java_lang_String* (*NewString)(JRIEnv* env, jint op, const jchar* a, jint b); - jint (*GetStringLength)(JRIEnv* env, jint op, struct java_lang_String* a); - const jchar* (*GetStringChars)(JRIEnv* env, jint op, struct java_lang_String* a); - struct java_lang_String* (*NewStringUTF)(JRIEnv* env, jint op, const jbyte* a, jint b); - jint (*GetStringUTFLength)(JRIEnv* env, jint op, struct java_lang_String* a); - const jbyte* (*GetStringUTFChars)(JRIEnv* env, jint op, struct java_lang_String* a); - void* (*NewScalarArray)(JRIEnv* env, jint op, jint a, const char* b, const jbyte* c); - jint (*GetScalarArrayLength)(JRIEnv* env, jint op, void* a); - jbyte* (*GetScalarArrayElements)(JRIEnv* env, jint op, void* a); - void* (*NewObjectArray)(JRIEnv* env, jint op, jint a, struct java_lang_Class* b, void* c); - jint (*GetObjectArrayLength)(JRIEnv* env, jint op, void* a); - void* (*GetObjectArrayElement)(JRIEnv* env, jint op, void* a, jint b); - void (*SetObjectArrayElement)(JRIEnv* env, jint op, void* a, jint b, void* c); - void (*RegisterNatives)(JRIEnv* env, jint op, struct java_lang_Class* a, char** b, void** c); - void (*UnregisterNatives)(JRIEnv* env, jint op, struct java_lang_Class* a); - struct java_lang_Class* (*DefineClass)(JRIEnv* env, jint op, struct java_lang_ClassLoader* a, jbyte* b, jsize bLen); - struct java_lang_String* (*NewStringPlatform)(JRIEnv* env, jint op, const jbyte* a, jint b, const jbyte* c, jint d); - const jbyte* (*GetStringPlatformChars)(JRIEnv* env, jint op, struct java_lang_String* a, const jbyte* b, jint c); -}; - -/* -** **************************************************************************** -** JRIEnv Operation IDs -** *************************************************************************** -*/ - -typedef enum JRIEnvOperations { - JRI_Reserved0_op, - JRI_Reserved1_op, - JRI_Reserved2_op, - JRI_Reserved3_op, - JRI_FindClass_op, - JRI_Throw_op, - JRI_ThrowNew_op, - JRI_ExceptionOccurred_op, - JRI_ExceptionDescribe_op, - JRI_ExceptionClear_op, - JRI_NewGlobalRef_op, - JRI_DisposeGlobalRef_op, - JRI_GetGlobalRef_op, - JRI_SetGlobalRef_op, - JRI_IsSameObject_op, - JRI_NewObject_op, - JRI_NewObject_op_va_list, - JRI_NewObject_op_array, - JRI_GetObjectClass_op, - JRI_IsInstanceOf_op, - JRI_GetMethodID_op, - JRI_CallMethod_op, - JRI_CallMethod_op_va_list, - JRI_CallMethod_op_array, - JRI_CallMethodBoolean_op, - JRI_CallMethodBoolean_op_va_list, - JRI_CallMethodBoolean_op_array, - JRI_CallMethodByte_op, - JRI_CallMethodByte_op_va_list, - JRI_CallMethodByte_op_array, - JRI_CallMethodChar_op, - JRI_CallMethodChar_op_va_list, - JRI_CallMethodChar_op_array, - JRI_CallMethodShort_op, - JRI_CallMethodShort_op_va_list, - JRI_CallMethodShort_op_array, - JRI_CallMethodInt_op, - JRI_CallMethodInt_op_va_list, - JRI_CallMethodInt_op_array, - JRI_CallMethodLong_op, - JRI_CallMethodLong_op_va_list, - JRI_CallMethodLong_op_array, - JRI_CallMethodFloat_op, - JRI_CallMethodFloat_op_va_list, - JRI_CallMethodFloat_op_array, - JRI_CallMethodDouble_op, - JRI_CallMethodDouble_op_va_list, - JRI_CallMethodDouble_op_array, - JRI_GetFieldID_op, - JRI_GetField_op, - JRI_GetFieldBoolean_op, - JRI_GetFieldByte_op, - JRI_GetFieldChar_op, - JRI_GetFieldShort_op, - JRI_GetFieldInt_op, - JRI_GetFieldLong_op, - JRI_GetFieldFloat_op, - JRI_GetFieldDouble_op, - JRI_SetField_op, - JRI_SetFieldBoolean_op, - JRI_SetFieldByte_op, - JRI_SetFieldChar_op, - JRI_SetFieldShort_op, - JRI_SetFieldInt_op, - JRI_SetFieldLong_op, - JRI_SetFieldFloat_op, - JRI_SetFieldDouble_op, - JRI_IsSubclassOf_op, - JRI_GetStaticMethodID_op, - JRI_CallStaticMethod_op, - JRI_CallStaticMethod_op_va_list, - JRI_CallStaticMethod_op_array, - JRI_CallStaticMethodBoolean_op, - JRI_CallStaticMethodBoolean_op_va_list, - JRI_CallStaticMethodBoolean_op_array, - JRI_CallStaticMethodByte_op, - JRI_CallStaticMethodByte_op_va_list, - JRI_CallStaticMethodByte_op_array, - JRI_CallStaticMethodChar_op, - JRI_CallStaticMethodChar_op_va_list, - JRI_CallStaticMethodChar_op_array, - JRI_CallStaticMethodShort_op, - JRI_CallStaticMethodShort_op_va_list, - JRI_CallStaticMethodShort_op_array, - JRI_CallStaticMethodInt_op, - JRI_CallStaticMethodInt_op_va_list, - JRI_CallStaticMethodInt_op_array, - JRI_CallStaticMethodLong_op, - JRI_CallStaticMethodLong_op_va_list, - JRI_CallStaticMethodLong_op_array, - JRI_CallStaticMethodFloat_op, - JRI_CallStaticMethodFloat_op_va_list, - JRI_CallStaticMethodFloat_op_array, - JRI_CallStaticMethodDouble_op, - JRI_CallStaticMethodDouble_op_va_list, - JRI_CallStaticMethodDouble_op_array, - JRI_GetStaticFieldID_op, - JRI_GetStaticField_op, - JRI_GetStaticFieldBoolean_op, - JRI_GetStaticFieldByte_op, - JRI_GetStaticFieldChar_op, - JRI_GetStaticFieldShort_op, - JRI_GetStaticFieldInt_op, - JRI_GetStaticFieldLong_op, - JRI_GetStaticFieldFloat_op, - JRI_GetStaticFieldDouble_op, - JRI_SetStaticField_op, - JRI_SetStaticFieldBoolean_op, - JRI_SetStaticFieldByte_op, - JRI_SetStaticFieldChar_op, - JRI_SetStaticFieldShort_op, - JRI_SetStaticFieldInt_op, - JRI_SetStaticFieldLong_op, - JRI_SetStaticFieldFloat_op, - JRI_SetStaticFieldDouble_op, - JRI_NewString_op, - JRI_GetStringLength_op, - JRI_GetStringChars_op, - JRI_NewStringUTF_op, - JRI_GetStringUTFLength_op, - JRI_GetStringUTFChars_op, - JRI_NewScalarArray_op, - JRI_GetScalarArrayLength_op, - JRI_GetScalarArrayElements_op, - JRI_NewObjectArray_op, - JRI_GetObjectArrayLength_op, - JRI_GetObjectArrayElement_op, - JRI_SetObjectArrayElement_op, - JRI_RegisterNatives_op, - JRI_UnregisterNatives_op, - JRI_DefineClass_op, - JRI_NewStringPlatform_op, - JRI_GetStringPlatformChars_op -} JRIEnvOperations; - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* JRI_H */ -/******************************************************************************/ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/******************************************************************************* + * Java Runtime Interface + ******************************************************************************/ + +#ifndef JRI_H +#define JRI_H + +#include "jritypes.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/******************************************************************************* + * JRIEnv + ******************************************************************************/ + +/* The type of the JRIEnv interface. */ +typedef struct JRIEnvInterface JRIEnvInterface; + +/* The type of a JRIEnv instance. */ +typedef const JRIEnvInterface* JRIEnv; + +/******************************************************************************* + * JRIEnv Operations + ******************************************************************************/ + +#define JRI_DefineClass(env, classLoader, buf, bufLen) \ + (((*(env))->DefineClass)(env, JRI_DefineClass_op, classLoader, buf, bufLen)) + +#define JRI_FindClass(env, name) \ + (((*(env))->FindClass)(env, JRI_FindClass_op, name)) + +#define JRI_Throw(env, obj) \ + (((*(env))->Throw)(env, JRI_Throw_op, obj)) + +#define JRI_ThrowNew(env, clazz, message) \ + (((*(env))->ThrowNew)(env, JRI_ThrowNew_op, clazz, message)) + +#define JRI_ExceptionOccurred(env) \ + (((*(env))->ExceptionOccurred)(env, JRI_ExceptionOccurred_op)) + +#define JRI_ExceptionDescribe(env) \ + (((*(env))->ExceptionDescribe)(env, JRI_ExceptionDescribe_op)) + +#define JRI_ExceptionClear(env) \ + (((*(env))->ExceptionClear)(env, JRI_ExceptionClear_op)) + +#define JRI_NewGlobalRef(env, ref) \ + (((*(env))->NewGlobalRef)(env, JRI_NewGlobalRef_op, ref)) + +#define JRI_DisposeGlobalRef(env, gref) \ + (((*(env))->DisposeGlobalRef)(env, JRI_DisposeGlobalRef_op, gref)) + +#define JRI_GetGlobalRef(env, gref) \ + (((*(env))->GetGlobalRef)(env, JRI_GetGlobalRef_op, gref)) + +#define JRI_SetGlobalRef(env, gref, ref) \ + (((*(env))->SetGlobalRef)(env, JRI_SetGlobalRef_op, gref, ref)) + +#define JRI_IsSameObject(env, a, b) \ + (((*(env))->IsSameObject)(env, JRI_IsSameObject_op, a, b)) + +#define JRI_NewObject(env) ((*(env))->NewObject) +#define JRI_NewObjectV(env, clazz, methodID, args) \ + (((*(env))->NewObjectV)(env, JRI_NewObject_op_va_list, clazz, methodID, args)) +#define JRI_NewObjectA(env, clazz, method, args) \ + (((*(env))->NewObjectA)(env, JRI_NewObject_op_array, clazz, methodID, args)) + +#define JRI_GetObjectClass(env, obj) \ + (((*(env))->GetObjectClass)(env, JRI_GetObjectClass_op, obj)) + +#define JRI_IsInstanceOf(env, obj, clazz) \ + (((*(env))->IsInstanceOf)(env, JRI_IsInstanceOf_op, obj, clazz)) + +#define JRI_GetMethodID(env, clazz, name, sig) \ + (((*(env))->GetMethodID)(env, JRI_GetMethodID_op, clazz, name, sig)) + +#define JRI_CallMethod(env) ((*(env))->CallMethod) +#define JRI_CallMethodV(env, obj, methodID, args) \ + (((*(env))->CallMethodV)(env, JRI_CallMethod_op_va_list, obj, methodID, args)) +#define JRI_CallMethodA(env, obj, methodID, args) \ + (((*(env))->CallMethodA)(env, JRI_CallMethod_op_array, obj, methodID, args)) + +#define JRI_CallMethodBoolean(env) ((*(env))->CallMethodBoolean) +#define JRI_CallMethodBooleanV(env, obj, methodID, args) \ + (((*(env))->CallMethodBooleanV)(env, JRI_CallMethodBoolean_op_va_list, obj, methodID, args)) +#define JRI_CallMethodBooleanA(env, obj, methodID, args) \ + (((*(env))->CallMethodBooleanA)(env, JRI_CallMethodBoolean_op_array, obj, methodID, args)) + +#define JRI_CallMethodByte(env) ((*(env))->CallMethodByte) +#define JRI_CallMethodByteV(env, obj, methodID, args) \ + (((*(env))->CallMethodByteV)(env, JRI_CallMethodByte_op_va_list, obj, methodID, args)) +#define JRI_CallMethodByteA(env, obj, methodID, args) \ + (((*(env))->CallMethodByteA)(env, JRI_CallMethodByte_op_array, obj, methodID, args)) + +#define JRI_CallMethodChar(env) ((*(env))->CallMethodChar) +#define JRI_CallMethodCharV(env, obj, methodID, args) \ + (((*(env))->CallMethodCharV)(env, JRI_CallMethodChar_op_va_list, obj, methodID, args)) +#define JRI_CallMethodCharA(env, obj, methodID, args) \ + (((*(env))->CallMethodCharA)(env, JRI_CallMethodChar_op_array, obj, methodID, args)) + +#define JRI_CallMethodShort(env) ((*(env))->CallMethodShort) +#define JRI_CallMethodShortV(env, obj, methodID, args) \ + (((*(env))->CallMethodShortV)(env, JRI_CallMethodShort_op_va_list, obj, methodID, args)) +#define JRI_CallMethodShortA(env, obj, methodID, args) \ + (((*(env))->CallMethodShortA)(env, JRI_CallMethodShort_op_array, obj, methodID, args)) + +#define JRI_CallMethodInt(env) ((*(env))->CallMethodInt) +#define JRI_CallMethodIntV(env, obj, methodID, args) \ + (((*(env))->CallMethodIntV)(env, JRI_CallMethodInt_op_va_list, obj, methodID, args)) +#define JRI_CallMethodIntA(env, obj, methodID, args) \ + (((*(env))->CallMethodIntA)(env, JRI_CallMethodInt_op_array, obj, methodID, args)) + +#define JRI_CallMethodLong(env) ((*(env))->CallMethodLong) +#define JRI_CallMethodLongV(env, obj, methodID, args) \ + (((*(env))->CallMethodLongV)(env, JRI_CallMethodLong_op_va_list, obj, methodID, args)) +#define JRI_CallMethodLongA(env, obj, methodID, args) \ + (((*(env))->CallMethodLongA)(env, JRI_CallMethodLong_op_array, obj, methodID, args)) + +#define JRI_CallMethodFloat(env) ((*(env))->CallMethodFloat) +#define JRI_CallMethodFloatV(env, obj, methodID, args) \ + (((*(env))->CallMethodFloatV)(env, JRI_CallMethodFloat_op_va_list, obj, methodID, args)) +#define JRI_CallMethodFloatA(env, obj, methodID, args) \ + (((*(env))->CallMethodFloatA)(env, JRI_CallMethodFloat_op_array, obj, methodID, args)) + +#define JRI_CallMethodDouble(env) ((*(env))->CallMethodDouble) +#define JRI_CallMethodDoubleV(env, obj, methodID, args) \ + (((*(env))->CallMethodDoubleV)(env, JRI_CallMethodDouble_op_va_list, obj, methodID, args)) +#define JRI_CallMethodDoubleA(env, obj, methodID, args) \ + (((*(env))->CallMethodDoubleA)(env, JRI_CallMethodDouble_op_array, obj, methodID, args)) + +#define JRI_GetFieldID(env, clazz, name, sig) \ + (((*(env))->GetFieldID)(env, JRI_GetFieldID_op, clazz, name, sig)) + +#define JRI_GetField(env, obj, fieldID) \ + (((*(env))->GetField)(env, JRI_GetField_op, obj, fieldID)) + +#define JRI_GetFieldBoolean(env, obj, fieldID) \ + (((*(env))->GetFieldBoolean)(env, JRI_GetFieldBoolean_op, obj, fieldID)) + +#define JRI_GetFieldByte(env, obj, fieldID) \ + (((*(env))->GetFieldByte)(env, JRI_GetFieldByte_op, obj, fieldID)) + +#define JRI_GetFieldChar(env, obj, fieldID) \ + (((*(env))->GetFieldChar)(env, JRI_GetFieldChar_op, obj, fieldID)) + +#define JRI_GetFieldShort(env, obj, fieldID) \ + (((*(env))->GetFieldShort)(env, JRI_GetFieldShort_op, obj, fieldID)) + +#define JRI_GetFieldInt(env, obj, fieldID) \ + (((*(env))->GetFieldInt)(env, JRI_GetFieldInt_op, obj, fieldID)) + +#define JRI_GetFieldLong(env, obj, fieldID) \ + (((*(env))->GetFieldLong)(env, JRI_GetFieldLong_op, obj, fieldID)) + +#define JRI_GetFieldFloat(env, obj, fieldID) \ + (((*(env))->GetFieldFloat)(env, JRI_GetFieldFloat_op, obj, fieldID)) + +#define JRI_GetFieldDouble(env, obj, fieldID) \ + (((*(env))->GetFieldDouble)(env, JRI_GetFieldDouble_op, obj, fieldID)) + +#define JRI_SetField(env, obj, fieldID, value) \ + (((*(env))->SetField)(env, JRI_SetField_op, obj, fieldID, value)) + +#define JRI_SetFieldBoolean(env, obj, fieldID, value) \ + (((*(env))->SetFieldBoolean)(env, JRI_SetFieldBoolean_op, obj, fieldID, value)) + +#define JRI_SetFieldByte(env, obj, fieldID, value) \ + (((*(env))->SetFieldByte)(env, JRI_SetFieldByte_op, obj, fieldID, value)) + +#define JRI_SetFieldChar(env, obj, fieldID, value) \ + (((*(env))->SetFieldChar)(env, JRI_SetFieldChar_op, obj, fieldID, value)) + +#define JRI_SetFieldShort(env, obj, fieldID, value) \ + (((*(env))->SetFieldShort)(env, JRI_SetFieldShort_op, obj, fieldID, value)) + +#define JRI_SetFieldInt(env, obj, fieldID, value) \ + (((*(env))->SetFieldInt)(env, JRI_SetFieldInt_op, obj, fieldID, value)) + +#define JRI_SetFieldLong(env, obj, fieldID, value) \ + (((*(env))->SetFieldLong)(env, JRI_SetFieldLong_op, obj, fieldID, value)) + +#define JRI_SetFieldFloat(env, obj, fieldID, value) \ + (((*(env))->SetFieldFloat)(env, JRI_SetFieldFloat_op, obj, fieldID, value)) + +#define JRI_SetFieldDouble(env, obj, fieldID, value) \ + (((*(env))->SetFieldDouble)(env, JRI_SetFieldDouble_op, obj, fieldID, value)) + +#define JRI_IsSubclassOf(env, a, b) \ + (((*(env))->IsSubclassOf)(env, JRI_IsSubclassOf_op, a, b)) + +#define JRI_GetStaticMethodID(env, clazz, name, sig) \ + (((*(env))->GetStaticMethodID)(env, JRI_GetStaticMethodID_op, clazz, name, sig)) + +#define JRI_CallStaticMethod(env) ((*(env))->CallStaticMethod) +#define JRI_CallStaticMethodV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodV)(env, JRI_CallStaticMethod_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodA)(env, JRI_CallStaticMethod_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodBoolean(env) ((*(env))->CallStaticMethodBoolean) +#define JRI_CallStaticMethodBooleanV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodBooleanV)(env, JRI_CallStaticMethodBoolean_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodBooleanA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodBooleanA)(env, JRI_CallStaticMethodBoolean_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodByte(env) ((*(env))->CallStaticMethodByte) +#define JRI_CallStaticMethodByteV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodByteV)(env, JRI_CallStaticMethodByte_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodByteA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodByteA)(env, JRI_CallStaticMethodByte_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodChar(env) ((*(env))->CallStaticMethodChar) +#define JRI_CallStaticMethodCharV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodCharV)(env, JRI_CallStaticMethodChar_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodCharA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodCharA)(env, JRI_CallStaticMethodChar_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodShort(env) ((*(env))->CallStaticMethodShort) +#define JRI_CallStaticMethodShortV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodShortV)(env, JRI_CallStaticMethodShort_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodShortA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodShortA)(env, JRI_CallStaticMethodShort_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodInt(env) ((*(env))->CallStaticMethodInt) +#define JRI_CallStaticMethodIntV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodIntV)(env, JRI_CallStaticMethodInt_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodIntA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodIntA)(env, JRI_CallStaticMethodInt_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodLong(env) ((*(env))->CallStaticMethodLong) +#define JRI_CallStaticMethodLongV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodLongV)(env, JRI_CallStaticMethodLong_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodLongA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodLongA)(env, JRI_CallStaticMethodLong_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodFloat(env) ((*(env))->CallStaticMethodFloat) +#define JRI_CallStaticMethodFloatV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodFloatV)(env, JRI_CallStaticMethodFloat_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodFloatA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodFloatA)(env, JRI_CallStaticMethodFloat_op_array, clazz, methodID, args)) + +#define JRI_CallStaticMethodDouble(env) ((*(env))->CallStaticMethodDouble) +#define JRI_CallStaticMethodDoubleV(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodDoubleV)(env, JRI_CallStaticMethodDouble_op_va_list, clazz, methodID, args)) +#define JRI_CallStaticMethodDoubleA(env, clazz, methodID, args) \ + (((*(env))->CallStaticMethodDoubleA)(env, JRI_CallStaticMethodDouble_op_array, clazz, methodID, args)) + +#define JRI_GetStaticFieldID(env, clazz, name, sig) \ + (((*(env))->GetStaticFieldID)(env, JRI_GetStaticFieldID_op, clazz, name, sig)) + +#define JRI_GetStaticField(env, clazz, fieldID) \ + (((*(env))->GetStaticField)(env, JRI_GetStaticField_op, clazz, fieldID)) + +#define JRI_GetStaticFieldBoolean(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldBoolean)(env, JRI_GetStaticFieldBoolean_op, clazz, fieldID)) + +#define JRI_GetStaticFieldByte(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldByte)(env, JRI_GetStaticFieldByte_op, clazz, fieldID)) + +#define JRI_GetStaticFieldChar(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldChar)(env, JRI_GetStaticFieldChar_op, clazz, fieldID)) + +#define JRI_GetStaticFieldShort(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldShort)(env, JRI_GetStaticFieldShort_op, clazz, fieldID)) + +#define JRI_GetStaticFieldInt(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldInt)(env, JRI_GetStaticFieldInt_op, clazz, fieldID)) + +#define JRI_GetStaticFieldLong(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldLong)(env, JRI_GetStaticFieldLong_op, clazz, fieldID)) + +#define JRI_GetStaticFieldFloat(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldFloat)(env, JRI_GetStaticFieldFloat_op, clazz, fieldID)) + +#define JRI_GetStaticFieldDouble(env, clazz, fieldID) \ + (((*(env))->GetStaticFieldDouble)(env, JRI_GetStaticFieldDouble_op, clazz, fieldID)) + +#define JRI_SetStaticField(env, clazz, fieldID, value) \ + (((*(env))->SetStaticField)(env, JRI_SetStaticField_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldBoolean(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldBoolean)(env, JRI_SetStaticFieldBoolean_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldByte(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldByte)(env, JRI_SetStaticFieldByte_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldChar(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldChar)(env, JRI_SetStaticFieldChar_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldShort(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldShort)(env, JRI_SetStaticFieldShort_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldInt(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldInt)(env, JRI_SetStaticFieldInt_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldLong(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldLong)(env, JRI_SetStaticFieldLong_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldFloat(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldFloat)(env, JRI_SetStaticFieldFloat_op, clazz, fieldID, value)) + +#define JRI_SetStaticFieldDouble(env, clazz, fieldID, value) \ + (((*(env))->SetStaticFieldDouble)(env, JRI_SetStaticFieldDouble_op, clazz, fieldID, value)) + +#define JRI_NewString(env, unicode, len) \ + (((*(env))->NewString)(env, JRI_NewString_op, unicode, len)) + +#define JRI_GetStringLength(env, string) \ + (((*(env))->GetStringLength)(env, JRI_GetStringLength_op, string)) + +#define JRI_GetStringChars(env, string) \ + (((*(env))->GetStringChars)(env, JRI_GetStringChars_op, string)) + +#define JRI_NewStringUTF(env, utf, len) \ + (((*(env))->NewStringUTF)(env, JRI_NewStringUTF_op, utf, len)) + +#define JRI_GetStringUTFLength(env, string) \ + (((*(env))->GetStringUTFLength)(env, JRI_GetStringUTFLength_op, string)) + +#define JRI_GetStringUTFChars(env, string) \ + (((*(env))->GetStringUTFChars)(env, JRI_GetStringUTFChars_op, string)) + +#define JRI_NewScalarArray(env, length, elementSig, initialElements) \ + (((*(env))->NewScalarArray)(env, JRI_NewScalarArray_op, length, elementSig, initialElements)) + +#define JRI_GetScalarArrayLength(env, array) \ + (((*(env))->GetScalarArrayLength)(env, JRI_GetScalarArrayLength_op, array)) + +#define JRI_GetScalarArrayElements(env, array) \ + (((*(env))->GetScalarArrayElements)(env, JRI_GetScalarArrayElements_op, array)) + +#define JRI_NewObjectArray(env, length, elementClass, initialElement) \ + (((*(env))->NewObjectArray)(env, JRI_NewObjectArray_op, length, elementClass, initialElement)) + +#define JRI_GetObjectArrayLength(env, array) \ + (((*(env))->GetObjectArrayLength)(env, JRI_GetObjectArrayLength_op, array)) + +#define JRI_GetObjectArrayElement(env, array, index) \ + (((*(env))->GetObjectArrayElement)(env, JRI_GetObjectArrayElement_op, array, index)) + +#define JRI_SetObjectArrayElement(env, array, index, value) \ + (((*(env))->SetObjectArrayElement)(env, JRI_SetObjectArrayElement_op, array, index, value)) + +#define JRI_RegisterNatives(env, clazz, nameAndSigArray, nativeProcArray) \ + (((*(env))->RegisterNatives)(env, JRI_RegisterNatives_op, clazz, nameAndSigArray, nativeProcArray)) + +#define JRI_UnregisterNatives(env, clazz) \ + (((*(env))->UnregisterNatives)(env, JRI_UnregisterNatives_op, clazz)) + +#define JRI_NewStringPlatform(env, string, len, encoding, encodingLength) \ + (((*(env))->NewStringPlatform)(env, JRI_NewStringPlatform_op, string, len, encoding, encodingLength)) + +#define JRI_GetStringPlatformChars(env, string, encoding, encodingLength) \ + (((*(env))->GetStringPlatformChars)(env, JRI_GetStringPlatformChars_op, string, encoding, encodingLength)) + + +/******************************************************************************* + * JRIEnv Interface + ******************************************************************************/ + +struct java_lang_ClassLoader; +struct java_lang_Class; +struct java_lang_Throwable; +struct java_lang_Object; +struct java_lang_String; + +struct JRIEnvInterface { + void* reserved0; + void* reserved1; + void* reserved2; + void* reserved3; + struct java_lang_Class* (*FindClass)(JRIEnv* env, jint op, const char* a); + void (*Throw)(JRIEnv* env, jint op, struct java_lang_Throwable* a); + void (*ThrowNew)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b); + struct java_lang_Throwable* (*ExceptionOccurred)(JRIEnv* env, jint op); + void (*ExceptionDescribe)(JRIEnv* env, jint op); + void (*ExceptionClear)(JRIEnv* env, jint op); + jglobal (*NewGlobalRef)(JRIEnv* env, jint op, void* a); + void (*DisposeGlobalRef)(JRIEnv* env, jint op, jglobal a); + void* (*GetGlobalRef)(JRIEnv* env, jint op, jglobal a); + void (*SetGlobalRef)(JRIEnv* env, jint op, jglobal a, void* b); + jbool (*IsSameObject)(JRIEnv* env, jint op, void* a, void* b); + void* (*NewObject)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + void* (*NewObjectV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + void* (*NewObjectA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + struct java_lang_Class* (*GetObjectClass)(JRIEnv* env, jint op, void* a); + jbool (*IsInstanceOf)(JRIEnv* env, jint op, void* a, struct java_lang_Class* b); + jint (*GetMethodID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); + void* (*CallMethod)(JRIEnv* env, jint op, void* a, jint b, ...); + void* (*CallMethodV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + void* (*CallMethodA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jbool (*CallMethodBoolean)(JRIEnv* env, jint op, void* a, jint b, ...); + jbool (*CallMethodBooleanV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jbool (*CallMethodBooleanA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jbyte (*CallMethodByte)(JRIEnv* env, jint op, void* a, jint b, ...); + jbyte (*CallMethodByteV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jbyte (*CallMethodByteA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jchar (*CallMethodChar)(JRIEnv* env, jint op, void* a, jint b, ...); + jchar (*CallMethodCharV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jchar (*CallMethodCharA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jshort (*CallMethodShort)(JRIEnv* env, jint op, void* a, jint b, ...); + jshort (*CallMethodShortV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jshort (*CallMethodShortA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jint (*CallMethodInt)(JRIEnv* env, jint op, void* a, jint b, ...); + jint (*CallMethodIntV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jint (*CallMethodIntA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jlong (*CallMethodLong)(JRIEnv* env, jint op, void* a, jint b, ...); + jlong (*CallMethodLongV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jlong (*CallMethodLongA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jfloat (*CallMethodFloat)(JRIEnv* env, jint op, void* a, jint b, ...); + jfloat (*CallMethodFloatV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jfloat (*CallMethodFloatA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jdouble (*CallMethodDouble)(JRIEnv* env, jint op, void* a, jint b, ...); + jdouble (*CallMethodDoubleV)(JRIEnv* env, jint op, void* a, jint b, va_list c); + jdouble (*CallMethodDoubleA)(JRIEnv* env, jint op, void* a, jint b, JRIValue* c); + jint (*GetFieldID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); + void* (*GetField)(JRIEnv* env, jint op, void* a, jint b); + jbool (*GetFieldBoolean)(JRIEnv* env, jint op, void* a, jint b); + jbyte (*GetFieldByte)(JRIEnv* env, jint op, void* a, jint b); + jchar (*GetFieldChar)(JRIEnv* env, jint op, void* a, jint b); + jshort (*GetFieldShort)(JRIEnv* env, jint op, void* a, jint b); + jint (*GetFieldInt)(JRIEnv* env, jint op, void* a, jint b); + jlong (*GetFieldLong)(JRIEnv* env, jint op, void* a, jint b); + jfloat (*GetFieldFloat)(JRIEnv* env, jint op, void* a, jint b); + jdouble (*GetFieldDouble)(JRIEnv* env, jint op, void* a, jint b); + void (*SetField)(JRIEnv* env, jint op, void* a, jint b, void* c); + void (*SetFieldBoolean)(JRIEnv* env, jint op, void* a, jint b, jbool c); + void (*SetFieldByte)(JRIEnv* env, jint op, void* a, jint b, jbyte c); + void (*SetFieldChar)(JRIEnv* env, jint op, void* a, jint b, jchar c); + void (*SetFieldShort)(JRIEnv* env, jint op, void* a, jint b, jshort c); + void (*SetFieldInt)(JRIEnv* env, jint op, void* a, jint b, jint c); + void (*SetFieldLong)(JRIEnv* env, jint op, void* a, jint b, jlong c); + void (*SetFieldFloat)(JRIEnv* env, jint op, void* a, jint b, jfloat c); + void (*SetFieldDouble)(JRIEnv* env, jint op, void* a, jint b, jdouble c); + jbool (*IsSubclassOf)(JRIEnv* env, jint op, struct java_lang_Class* a, struct java_lang_Class* b); + jint (*GetStaticMethodID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); + void* (*CallStaticMethod)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + void* (*CallStaticMethodV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + void* (*CallStaticMethodA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jbool (*CallStaticMethodBoolean)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jbool (*CallStaticMethodBooleanV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jbool (*CallStaticMethodBooleanA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jbyte (*CallStaticMethodByte)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jbyte (*CallStaticMethodByteV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jbyte (*CallStaticMethodByteA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jchar (*CallStaticMethodChar)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jchar (*CallStaticMethodCharV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jchar (*CallStaticMethodCharA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jshort (*CallStaticMethodShort)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jshort (*CallStaticMethodShortV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jshort (*CallStaticMethodShortA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jint (*CallStaticMethodInt)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jint (*CallStaticMethodIntV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jint (*CallStaticMethodIntA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jlong (*CallStaticMethodLong)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jlong (*CallStaticMethodLongV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jlong (*CallStaticMethodLongA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jfloat (*CallStaticMethodFloat)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jfloat (*CallStaticMethodFloatV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jfloat (*CallStaticMethodFloatA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jdouble (*CallStaticMethodDouble)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, ...); + jdouble (*CallStaticMethodDoubleV)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, va_list c); + jdouble (*CallStaticMethodDoubleA)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, JRIValue* c); + jint (*GetStaticFieldID)(JRIEnv* env, jint op, struct java_lang_Class* a, const char* b, const char* c); + void* (*GetStaticField)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jbool (*GetStaticFieldBoolean)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jbyte (*GetStaticFieldByte)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jchar (*GetStaticFieldChar)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jshort (*GetStaticFieldShort)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jint (*GetStaticFieldInt)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jlong (*GetStaticFieldLong)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jfloat (*GetStaticFieldFloat)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + jdouble (*GetStaticFieldDouble)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b); + void (*SetStaticField)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, void* c); + void (*SetStaticFieldBoolean)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jbool c); + void (*SetStaticFieldByte)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jbyte c); + void (*SetStaticFieldChar)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jchar c); + void (*SetStaticFieldShort)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jshort c); + void (*SetStaticFieldInt)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jint c); + void (*SetStaticFieldLong)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jlong c); + void (*SetStaticFieldFloat)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jfloat c); + void (*SetStaticFieldDouble)(JRIEnv* env, jint op, struct java_lang_Class* a, jint b, jdouble c); + struct java_lang_String* (*NewString)(JRIEnv* env, jint op, const jchar* a, jint b); + jint (*GetStringLength)(JRIEnv* env, jint op, struct java_lang_String* a); + const jchar* (*GetStringChars)(JRIEnv* env, jint op, struct java_lang_String* a); + struct java_lang_String* (*NewStringUTF)(JRIEnv* env, jint op, const jbyte* a, jint b); + jint (*GetStringUTFLength)(JRIEnv* env, jint op, struct java_lang_String* a); + const jbyte* (*GetStringUTFChars)(JRIEnv* env, jint op, struct java_lang_String* a); + void* (*NewScalarArray)(JRIEnv* env, jint op, jint a, const char* b, const jbyte* c); + jint (*GetScalarArrayLength)(JRIEnv* env, jint op, void* a); + jbyte* (*GetScalarArrayElements)(JRIEnv* env, jint op, void* a); + void* (*NewObjectArray)(JRIEnv* env, jint op, jint a, struct java_lang_Class* b, void* c); + jint (*GetObjectArrayLength)(JRIEnv* env, jint op, void* a); + void* (*GetObjectArrayElement)(JRIEnv* env, jint op, void* a, jint b); + void (*SetObjectArrayElement)(JRIEnv* env, jint op, void* a, jint b, void* c); + void (*RegisterNatives)(JRIEnv* env, jint op, struct java_lang_Class* a, char** b, void** c); + void (*UnregisterNatives)(JRIEnv* env, jint op, struct java_lang_Class* a); + struct java_lang_Class* (*DefineClass)(JRIEnv* env, jint op, struct java_lang_ClassLoader* a, jbyte* b, jsize bLen); + struct java_lang_String* (*NewStringPlatform)(JRIEnv* env, jint op, const jbyte* a, jint b, const jbyte* c, jint d); + const jbyte* (*GetStringPlatformChars)(JRIEnv* env, jint op, struct java_lang_String* a, const jbyte* b, jint c); +}; + +/* +** **************************************************************************** +** JRIEnv Operation IDs +** *************************************************************************** +*/ + +typedef enum JRIEnvOperations { + JRI_Reserved0_op, + JRI_Reserved1_op, + JRI_Reserved2_op, + JRI_Reserved3_op, + JRI_FindClass_op, + JRI_Throw_op, + JRI_ThrowNew_op, + JRI_ExceptionOccurred_op, + JRI_ExceptionDescribe_op, + JRI_ExceptionClear_op, + JRI_NewGlobalRef_op, + JRI_DisposeGlobalRef_op, + JRI_GetGlobalRef_op, + JRI_SetGlobalRef_op, + JRI_IsSameObject_op, + JRI_NewObject_op, + JRI_NewObject_op_va_list, + JRI_NewObject_op_array, + JRI_GetObjectClass_op, + JRI_IsInstanceOf_op, + JRI_GetMethodID_op, + JRI_CallMethod_op, + JRI_CallMethod_op_va_list, + JRI_CallMethod_op_array, + JRI_CallMethodBoolean_op, + JRI_CallMethodBoolean_op_va_list, + JRI_CallMethodBoolean_op_array, + JRI_CallMethodByte_op, + JRI_CallMethodByte_op_va_list, + JRI_CallMethodByte_op_array, + JRI_CallMethodChar_op, + JRI_CallMethodChar_op_va_list, + JRI_CallMethodChar_op_array, + JRI_CallMethodShort_op, + JRI_CallMethodShort_op_va_list, + JRI_CallMethodShort_op_array, + JRI_CallMethodInt_op, + JRI_CallMethodInt_op_va_list, + JRI_CallMethodInt_op_array, + JRI_CallMethodLong_op, + JRI_CallMethodLong_op_va_list, + JRI_CallMethodLong_op_array, + JRI_CallMethodFloat_op, + JRI_CallMethodFloat_op_va_list, + JRI_CallMethodFloat_op_array, + JRI_CallMethodDouble_op, + JRI_CallMethodDouble_op_va_list, + JRI_CallMethodDouble_op_array, + JRI_GetFieldID_op, + JRI_GetField_op, + JRI_GetFieldBoolean_op, + JRI_GetFieldByte_op, + JRI_GetFieldChar_op, + JRI_GetFieldShort_op, + JRI_GetFieldInt_op, + JRI_GetFieldLong_op, + JRI_GetFieldFloat_op, + JRI_GetFieldDouble_op, + JRI_SetField_op, + JRI_SetFieldBoolean_op, + JRI_SetFieldByte_op, + JRI_SetFieldChar_op, + JRI_SetFieldShort_op, + JRI_SetFieldInt_op, + JRI_SetFieldLong_op, + JRI_SetFieldFloat_op, + JRI_SetFieldDouble_op, + JRI_IsSubclassOf_op, + JRI_GetStaticMethodID_op, + JRI_CallStaticMethod_op, + JRI_CallStaticMethod_op_va_list, + JRI_CallStaticMethod_op_array, + JRI_CallStaticMethodBoolean_op, + JRI_CallStaticMethodBoolean_op_va_list, + JRI_CallStaticMethodBoolean_op_array, + JRI_CallStaticMethodByte_op, + JRI_CallStaticMethodByte_op_va_list, + JRI_CallStaticMethodByte_op_array, + JRI_CallStaticMethodChar_op, + JRI_CallStaticMethodChar_op_va_list, + JRI_CallStaticMethodChar_op_array, + JRI_CallStaticMethodShort_op, + JRI_CallStaticMethodShort_op_va_list, + JRI_CallStaticMethodShort_op_array, + JRI_CallStaticMethodInt_op, + JRI_CallStaticMethodInt_op_va_list, + JRI_CallStaticMethodInt_op_array, + JRI_CallStaticMethodLong_op, + JRI_CallStaticMethodLong_op_va_list, + JRI_CallStaticMethodLong_op_array, + JRI_CallStaticMethodFloat_op, + JRI_CallStaticMethodFloat_op_va_list, + JRI_CallStaticMethodFloat_op_array, + JRI_CallStaticMethodDouble_op, + JRI_CallStaticMethodDouble_op_va_list, + JRI_CallStaticMethodDouble_op_array, + JRI_GetStaticFieldID_op, + JRI_GetStaticField_op, + JRI_GetStaticFieldBoolean_op, + JRI_GetStaticFieldByte_op, + JRI_GetStaticFieldChar_op, + JRI_GetStaticFieldShort_op, + JRI_GetStaticFieldInt_op, + JRI_GetStaticFieldLong_op, + JRI_GetStaticFieldFloat_op, + JRI_GetStaticFieldDouble_op, + JRI_SetStaticField_op, + JRI_SetStaticFieldBoolean_op, + JRI_SetStaticFieldByte_op, + JRI_SetStaticFieldChar_op, + JRI_SetStaticFieldShort_op, + JRI_SetStaticFieldInt_op, + JRI_SetStaticFieldLong_op, + JRI_SetStaticFieldFloat_op, + JRI_SetStaticFieldDouble_op, + JRI_NewString_op, + JRI_GetStringLength_op, + JRI_GetStringChars_op, + JRI_NewStringUTF_op, + JRI_GetStringUTFLength_op, + JRI_GetStringUTFChars_op, + JRI_NewScalarArray_op, + JRI_GetScalarArrayLength_op, + JRI_GetScalarArrayElements_op, + JRI_NewObjectArray_op, + JRI_GetObjectArrayLength_op, + JRI_GetObjectArrayElement_op, + JRI_SetObjectArrayElement_op, + JRI_RegisterNatives_op, + JRI_UnregisterNatives_op, + JRI_DefineClass_op, + JRI_NewStringPlatform_op, + JRI_GetStringPlatformChars_op +} JRIEnvOperations; + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* JRI_H */ +/******************************************************************************/ diff --git a/extras/browser plugins/wrapper/npapi/jri_md.h b/extras/browser plugins/wrapper/npapi/jri_md.h index 950481de35..384f0c506b 100644 --- a/extras/browser plugins/wrapper/npapi/jri_md.h +++ b/extras/browser plugins/wrapper/npapi/jri_md.h @@ -1,574 +1,574 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/******************************************************************************* - * Java Runtime Interface - Machine Dependent Types - ******************************************************************************/ - -#ifndef JRI_MD_H -#define JRI_MD_H - -#include -#include "prtypes.h" /* Needed for HAS_LONG_LONG ifdefs */ - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************* - * WHAT'S UP WITH THIS FILE? - * - * This is where we define the mystical JRI_PUBLIC_API macro that works on all - * platforms. If you're running with Visual C++, Symantec C, or Borland's - * development environment on the PC, you're all set. Or if you're on the Mac - * with Metrowerks, Symantec or MPW with SC you're ok too. For UNIX it shouldn't - * matter. - * - * On UNIX though you probably care about a couple of other symbols though: - * IS_LITTLE_ENDIAN must be defined for little-endian systems - * HAVE_LONG_LONG must be defined on systems that have 'long long' integers - * HAVE_ALIGNED_LONGLONGS must be defined if long-longs must be 8 byte aligned - * HAVE_ALIGNED_DOUBLES must be defined if doubles must be 8 byte aligned - * IS_64 must be defined on 64-bit machines (like Dec Alpha) - ******************************************************************************/ - -/* DLL Entry modifiers... */ - -/* Windows */ -#if defined(XP_WIN) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32) -# include -# if defined(_MSC_VER) || defined(__GNUC__) -# if defined(WIN32) || defined(_WIN32) -# define JRI_PUBLIC_API(ResultType) __declspec(dllexport) ResultType -# define JRI_PUBLIC_VAR(VarType) VarType -# define JRI_PUBLIC_VAR_EXP(VarType) __declspec(dllexport) VarType -# define JRI_PUBLIC_VAR_IMP(VarType) __declspec(dllimport) VarType -# define JRI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType -# define JRI_CALLBACK -# else /* !_WIN32 */ -# if defined(_WINDLL) -# define JRI_PUBLIC_API(ResultType) ResultType __cdecl __export __loadds -# define JRI_PUBLIC_VAR(VarType) VarType -# define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType) -# define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType) -# define JRI_NATIVE_STUB(ResultType) ResultType __cdecl __loadds -# define JRI_CALLBACK __loadds -# else /* !WINDLL */ -# define JRI_PUBLIC_API(ResultType) ResultType __cdecl __export -# define JRI_PUBLIC_VAR(VarType) VarType -# define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType) -# define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType) -# define JRI_NATIVE_STUB(ResultType) ResultType __cdecl __export -# define JRI_CALLBACK __export -# endif /* !WINDLL */ -# endif /* !_WIN32 */ -# elif defined(__BORLANDC__) -# if defined(WIN32) || defined(_WIN32) -# define JRI_PUBLIC_API(ResultType) __export ResultType -# define JRI_PUBLIC_VAR(VarType) VarType -# define JRI_PUBLIC_VAR_EXP(VarType) __export VarType -# define JRI_PUBLIC_VAR_IMP(VarType) __import VarType -# define JRI_NATIVE_STUB(ResultType) __export ResultType -# define JRI_CALLBACK -# else /* !_WIN32 */ -# define JRI_PUBLIC_API(ResultType) ResultType _cdecl _export _loadds -# define JRI_PUBLIC_VAR(VarType) VarType -# define JRI_PUBLIC_VAR_EXP(VarType) __cdecl __export VarType -# define JRI_PUBLIC_VAR_IMP(VarType) __cdecl __import VarType -# define JRI_NATIVE_STUB(ResultType) ResultType _cdecl _loadds -# define JRI_CALLBACK _loadds -# endif -# else -# error Unsupported PC development environment. -# endif -# ifndef IS_LITTLE_ENDIAN -# define IS_LITTLE_ENDIAN -# endif - -/* OS/2 */ -#elif defined(XP_OS2) -# ifdef XP_OS2_VACPP -# define JRI_PUBLIC_API(ResultType) ResultType _Optlink -# define JRI_PUBLIC_VAR(VarType) VarType -# define JRI_CALLBACK -# elif defined(__declspec) -# define JRI_PUBLIC_API(ResultType) __declspec(dllexport) ResultType -# define JRI_PUBLIC_VAR(VarType) VarType -# define JRI_PUBLIC_VAR_EXP(VarType) __declspec(dllexport) VarType -# define JRI_PUBLIC_VAR_IMP(VarType) __declspec(dllimport) VarType -# define JRI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType -# define JRI_CALLBACK -# else -# define JRI_PUBLIC_API(ResultType) ResultType -# define JRI_PUBLIC_VAR(VarType) VarType -# define JRI_CALLBACK -# endif - -/* Mac */ -#elif defined (macintosh) || Macintosh || THINK_C -# if defined(__MWERKS__) /* Metrowerks */ -# if !__option(enumsalwaysint) -# error You need to define 'Enums Always Int' for your project. -# endif -# if defined(TARGET_CPU_68K) && !TARGET_RT_MAC_CFM -# if !__option(fourbyteints) -# error You need to define 'Struct Alignment: 68k' for your project. -# endif -# endif /* !GENERATINGCFM */ -# define JRI_PUBLIC_API(ResultType) __declspec(export) ResultType -# define JRI_PUBLIC_VAR(VarType) JRI_PUBLIC_API(VarType) -# define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_API(VarType) -# define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_API(VarType) -# define JRI_NATIVE_STUB(ResultType) JRI_PUBLIC_API(ResultType) -# elif defined(__SC__) /* Symantec */ -# error What are the Symantec defines? (warren@netscape.com) -# elif macintosh && applec /* MPW */ -# error Please upgrade to the latest MPW compiler (SC). -# else -# error Unsupported Mac development environment. -# endif -# define JRI_CALLBACK - -/* Unix or else */ -#else -# define JRI_PUBLIC_API(ResultType) ResultType -# define JRI_PUBLIC_VAR(VarType) VarType -# define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType) -# define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType) -# define JRI_NATIVE_STUB(ResultType) ResultType -# define JRI_CALLBACK -#endif - -#ifndef FAR /* for non-Win16 */ -#define FAR -#endif - -/******************************************************************************/ - -/* Java Scalar Types */ - -#if 0 /* now in jni.h */ -typedef short jchar; -typedef short jshort; -typedef float jfloat; -typedef double jdouble; -typedef juint jsize; -#endif - -/* moved from jni.h -- Sun's new jni.h doesn't have this anymore */ -#ifdef __cplusplus -typedef class _jobject *jref; -#else -typedef struct _jobject *jref; -#endif - -typedef unsigned char jbool; -typedef signed char jbyte; -#ifdef IS_64 /* XXX ok for alpha, but not right on all 64-bit architectures */ -typedef unsigned int juint; -typedef int jint; -#else -typedef unsigned long juint; -typedef long jint; -#endif - -/******************************************************************************* - * jlong : long long (64-bit signed integer type) support. - ******************************************************************************/ - -/* -** Bit masking macros. (n must be <= 31 to be portable) -*/ -#define JRI_BIT(n) ((juint)1 << (n)) -#define JRI_BITMASK(n) (JRI_BIT(n) - 1) - -#ifdef HAVE_LONG_LONG - -#ifdef OSF1 - -/* long is default 64-bit on OSF1, -std1 does not allow long long */ -typedef long jlong; -typedef unsigned long julong; -#define jlong_MAXINT 0x7fffffffffffffffL -#define jlong_MININT 0x8000000000000000L -#define jlong_ZERO 0x0L - -#elif (defined(WIN32) || defined(_WIN32)) - -typedef LONGLONG jlong; -typedef DWORDLONG julong; -#define jlong_MAXINT 0x7fffffffffffffffi64 -#define jlong_MININT 0x8000000000000000i64 -#define jlong_ZERO 0x0i64 - -#else - -typedef long long jlong; -typedef unsigned long long julong; -#define jlong_MAXINT 0x7fffffffffffffffLL -#define jlong_MININT 0x8000000000000000LL -#define jlong_ZERO 0x0LL - -#endif - -#define jlong_IS_ZERO(a) ((a) == 0) -#define jlong_EQ(a, b) ((a) == (b)) -#define jlong_NE(a, b) ((a) != (b)) -#define jlong_GE_ZERO(a) ((a) >= 0) -#define jlong_CMP(a, op, b) ((a) op (b)) - -#define jlong_AND(r, a, b) ((r) = (a) & (b)) -#define jlong_OR(r, a, b) ((r) = (a) | (b)) -#define jlong_XOR(r, a, b) ((r) = (a) ^ (b)) -#define jlong_OR2(r, a) ((r) = (r) | (a)) -#define jlong_NOT(r, a) ((r) = ~(a)) - -#define jlong_NEG(r, a) ((r) = -(a)) -#define jlong_ADD(r, a, b) ((r) = (a) + (b)) -#define jlong_SUB(r, a, b) ((r) = (a) - (b)) - -#define jlong_MUL(r, a, b) ((r) = (a) * (b)) -#define jlong_DIV(r, a, b) ((r) = (a) / (b)) -#define jlong_MOD(r, a, b) ((r) = (a) % (b)) - -#define jlong_SHL(r, a, b) ((r) = (a) << (b)) -#define jlong_SHR(r, a, b) ((r) = (a) >> (b)) -#define jlong_USHR(r, a, b) ((r) = (julong)(a) >> (b)) -#define jlong_ISHL(r, a, b) ((r) = ((jlong)(a)) << (b)) - -#define jlong_L2I(i, l) ((i) = (int)(l)) -#define jlong_L2UI(ui, l) ((ui) =(unsigned int)(l)) -#define jlong_L2F(f, l) ((f) = (l)) -#define jlong_L2D(d, l) ((d) = (l)) - -#define jlong_I2L(l, i) ((l) = (i)) -#define jlong_UI2L(l, ui) ((l) = (ui)) -#define jlong_F2L(l, f) ((l) = (f)) -#define jlong_D2L(l, d) ((l) = (d)) - -#define jlong_UDIVMOD(qp, rp, a, b) \ - (*(qp) = ((julong)(a) / (b)), \ - *(rp) = ((julong)(a) % (b))) - -#else /* !HAVE_LONG_LONG */ - -typedef struct { -#ifdef IS_LITTLE_ENDIAN - juint lo, hi; -#else - juint hi, lo; -#endif -} jlong; -typedef jlong julong; - -extern jlong jlong_MAXINT, jlong_MININT, jlong_ZERO; - -#define jlong_IS_ZERO(a) (((a).hi == 0) && ((a).lo == 0)) -#define jlong_EQ(a, b) (((a).hi == (b).hi) && ((a).lo == (b).lo)) -#define jlong_NE(a, b) (((a).hi != (b).hi) || ((a).lo != (b).lo)) -#define jlong_GE_ZERO(a) (((a).hi >> 31) == 0) - -/* - * NB: jlong_CMP and jlong_UCMP work only for strict relationals (<, >). - */ -#define jlong_CMP(a, op, b) (((int32)(a).hi op (int32)(b).hi) || \ - (((a).hi == (b).hi) && ((a).lo op (b).lo))) -#define jlong_UCMP(a, op, b) (((a).hi op (b).hi) || \ - (((a).hi == (b).hi) && ((a).lo op (b).lo))) - -#define jlong_AND(r, a, b) ((r).lo = (a).lo & (b).lo, \ - (r).hi = (a).hi & (b).hi) -#define jlong_OR(r, a, b) ((r).lo = (a).lo | (b).lo, \ - (r).hi = (a).hi | (b).hi) -#define jlong_XOR(r, a, b) ((r).lo = (a).lo ^ (b).lo, \ - (r).hi = (a).hi ^ (b).hi) -#define jlong_OR2(r, a) ((r).lo = (r).lo | (a).lo, \ - (r).hi = (r).hi | (a).hi) -#define jlong_NOT(r, a) ((r).lo = ~(a).lo, \ - (r).hi = ~(a).hi) - -#define jlong_NEG(r, a) ((r).lo = -(int32)(a).lo, \ - (r).hi = -(int32)(a).hi - ((r).lo != 0)) -#define jlong_ADD(r, a, b) { \ - jlong _a, _b; \ - _a = a; _b = b; \ - (r).lo = _a.lo + _b.lo; \ - (r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \ -} - -#define jlong_SUB(r, a, b) { \ - jlong _a, _b; \ - _a = a; _b = b; \ - (r).lo = _a.lo - _b.lo; \ - (r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \ -} \ - -/* - * Multiply 64-bit operands a and b to get 64-bit result r. - * First multiply the low 32 bits of a and b to get a 64-bit result in r. - * Then add the outer and inner products to r.hi. - */ -#define jlong_MUL(r, a, b) { \ - jlong _a, _b; \ - _a = a; _b = b; \ - jlong_MUL32(r, _a.lo, _b.lo); \ - (r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \ -} - -/* XXX _jlong_lo16(a) = ((a) << 16 >> 16) is better on some archs (not on mips) */ -#define _jlong_lo16(a) ((a) & JRI_BITMASK(16)) -#define _jlong_hi16(a) ((a) >> 16) - -/* - * Multiply 32-bit operands a and b to get 64-bit result r. - * Use polynomial expansion based on primitive field element (1 << 16). - */ -#define jlong_MUL32(r, a, b) { \ - juint _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \ - _a1 = _jlong_hi16(a), _a0 = _jlong_lo16(a); \ - _b1 = _jlong_hi16(b), _b0 = _jlong_lo16(b); \ - _y0 = _a0 * _b0; \ - _y1 = _a0 * _b1; \ - _y2 = _a1 * _b0; \ - _y3 = _a1 * _b1; \ - _y1 += _jlong_hi16(_y0); /* can't carry */ \ - _y1 += _y2; /* might carry */ \ - if (_y1 < _y2) _y3 += 1 << 16; /* propagate */ \ - (r).lo = (_jlong_lo16(_y1) << 16) + _jlong_lo16(_y0); \ - (r).hi = _y3 + _jlong_hi16(_y1); \ -} - -/* - * Divide 64-bit unsigned operand a by 64-bit unsigned operand b, setting *qp - * to the 64-bit unsigned quotient, and *rp to the 64-bit unsigned remainder. - * Minimize effort if one of qp and rp is null. - */ -#define jlong_UDIVMOD(qp, rp, a, b) jlong_udivmod(qp, rp, a, b) - -extern JRI_PUBLIC_API(void) -jlong_udivmod(julong *qp, julong *rp, julong a, julong b); - -#define jlong_DIV(r, a, b) { \ - jlong _a, _b; \ - juint _negative = (int32)(a).hi < 0; \ - if (_negative) { \ - jlong_NEG(_a, a); \ - } else { \ - _a = a; \ - } \ - if ((int32)(b).hi < 0) { \ - _negative ^= 1; \ - jlong_NEG(_b, b); \ - } else { \ - _b = b; \ - } \ - jlong_UDIVMOD(&(r), 0, _a, _b); \ - if (_negative) \ - jlong_NEG(r, r); \ -} - -#define jlong_MOD(r, a, b) { \ - jlong _a, _b; \ - juint _negative = (int32)(a).hi < 0; \ - if (_negative) { \ - jlong_NEG(_a, a); \ - } else { \ - _a = a; \ - } \ - if ((int32)(b).hi < 0) { \ - jlong_NEG(_b, b); \ - } else { \ - _b = b; \ - } \ - jlong_UDIVMOD(0, &(r), _a, _b); \ - if (_negative) \ - jlong_NEG(r, r); \ -} - -/* - * NB: b is a juint, not jlong or julong, for the shift ops. - */ -#define jlong_SHL(r, a, b) { \ - if (b) { \ - jlong _a; \ - _a = a; \ - if ((b) < 32) { \ - (r).lo = _a.lo << (b); \ - (r).hi = (_a.hi << (b)) | (_a.lo >> (32 - (b))); \ - } else { \ - (r).lo = 0; \ - (r).hi = _a.lo << ((b) & 31); \ - } \ - } else { \ - (r) = (a); \ - } \ -} - -/* a is an int32, b is int32, r is jlong */ -#define jlong_ISHL(r, a, b) { \ - if (b) { \ - jlong _a; \ - _a.lo = (a); \ - _a.hi = 0; \ - if ((b) < 32) { \ - (r).lo = (a) << (b); \ - (r).hi = ((a) >> (32 - (b))); \ - } else { \ - (r).lo = 0; \ - (r).hi = (a) << ((b) & 31); \ - } \ - } else { \ - (r).lo = (a); \ - (r).hi = 0; \ - } \ -} - -#define jlong_SHR(r, a, b) { \ - if (b) { \ - jlong _a; \ - _a = a; \ - if ((b) < 32) { \ - (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b)); \ - (r).hi = (int32)_a.hi >> (b); \ - } else { \ - (r).lo = (int32)_a.hi >> ((b) & 31); \ - (r).hi = (int32)_a.hi >> 31; \ - } \ - } else { \ - (r) = (a); \ - } \ -} - -#define jlong_USHR(r, a, b) { \ - if (b) { \ - jlong _a; \ - _a = a; \ - if ((b) < 32) { \ - (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b)); \ - (r).hi = _a.hi >> (b); \ - } else { \ - (r).lo = _a.hi >> ((b) & 31); \ - (r).hi = 0; \ - } \ - } else { \ - (r) = (a); \ - } \ -} - -#define jlong_L2I(i, l) ((i) = (l).lo) -#define jlong_L2UI(ui, l) ((ui) = (l).lo) -#define jlong_L2F(f, l) { double _d; jlong_L2D(_d, l); (f) = (float) _d; } - -#define jlong_L2D(d, l) { \ - int32 _negative; \ - jlong _absval; \ - \ - _negative = (l).hi >> 31; \ - if (_negative) { \ - jlong_NEG(_absval, l); \ - } else { \ - _absval = l; \ - } \ - (d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \ - if (_negative) \ - (d) = -(d); \ -} - -#define jlong_I2L(l, i) ((l).hi = (i) >> 31, (l).lo = (i)) -#define jlong_UI2L(l, ui) ((l).hi = 0, (l).lo = (ui)) -#define jlong_F2L(l, f) { double _d = (double) f; jlong_D2L(l, _d); } - -#define jlong_D2L(l, d) { \ - int _negative; \ - double _absval, _d_hi; \ - jlong _lo_d; \ - \ - _negative = ((d) < 0); \ - _absval = _negative ? -(d) : (d); \ - \ - (l).hi = (juint)(_absval / 4.294967296e9); \ - (l).lo = 0; \ - jlong_L2D(_d_hi, l); \ - _absval -= _d_hi; \ - _lo_d.hi = 0; \ - if (_absval < 0) { \ - _lo_d.lo = (juint) -_absval; \ - jlong_SUB(l, l, _lo_d); \ - } else { \ - _lo_d.lo = (juint) _absval; \ - jlong_ADD(l, l, _lo_d); \ - } \ - \ - if (_negative) \ - jlong_NEG(l, l); \ -} - -#endif /* !HAVE_LONG_LONG */ - -/******************************************************************************/ - -#ifdef HAVE_ALIGNED_LONGLONGS -#define JRI_GET_INT64(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \ - ((_t).x[1] = ((jint*)(_addr))[1]), \ - (_t).l ) -#define JRI_SET_INT64(_t, _addr, _v) ( (_t).l = (_v), \ - ((jint*)(_addr))[0] = (_t).x[0], \ - ((jint*)(_addr))[1] = (_t).x[1] ) -#else -#define JRI_GET_INT64(_t,_addr) (*(jlong*)(_addr)) -#define JRI_SET_INT64(_t, _addr, _v) (*(jlong*)(_addr) = (_v)) -#endif - -/* If double's must be aligned on doubleword boundaries then define this */ -#ifdef HAVE_ALIGNED_DOUBLES -#define JRI_GET_DOUBLE(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \ - ((_t).x[1] = ((jint*)(_addr))[1]), \ - (_t).d ) -#define JRI_SET_DOUBLE(_t, _addr, _v) ( (_t).d = (_v), \ - ((jint*)(_addr))[0] = (_t).x[0], \ - ((jint*)(_addr))[1] = (_t).x[1] ) -#else -#define JRI_GET_DOUBLE(_t,_addr) (*(jdouble*)(_addr)) -#define JRI_SET_DOUBLE(_t, _addr, _v) (*(jdouble*)(_addr) = (_v)) -#endif - -/******************************************************************************/ -#ifdef __cplusplus -} -#endif -#endif /* JRI_MD_H */ -/******************************************************************************/ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/******************************************************************************* + * Java Runtime Interface - Machine Dependent Types + ******************************************************************************/ + +#ifndef JRI_MD_H +#define JRI_MD_H + +#include +#include "prtypes.h" /* Needed for HAS_LONG_LONG ifdefs */ + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************* + * WHAT'S UP WITH THIS FILE? + * + * This is where we define the mystical JRI_PUBLIC_API macro that works on all + * platforms. If you're running with Visual C++, Symantec C, or Borland's + * development environment on the PC, you're all set. Or if you're on the Mac + * with Metrowerks, Symantec or MPW with SC you're ok too. For UNIX it shouldn't + * matter. + * + * On UNIX though you probably care about a couple of other symbols though: + * IS_LITTLE_ENDIAN must be defined for little-endian systems + * HAVE_LONG_LONG must be defined on systems that have 'long long' integers + * HAVE_ALIGNED_LONGLONGS must be defined if long-longs must be 8 byte aligned + * HAVE_ALIGNED_DOUBLES must be defined if doubles must be 8 byte aligned + * IS_64 must be defined on 64-bit machines (like Dec Alpha) + ******************************************************************************/ + +/* DLL Entry modifiers... */ + +/* Windows */ +#if defined(XP_WIN) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32) +# include +# if defined(_MSC_VER) || defined(__GNUC__) +# if defined(WIN32) || defined(_WIN32) +# define JRI_PUBLIC_API(ResultType) __declspec(dllexport) ResultType +# define JRI_PUBLIC_VAR(VarType) VarType +# define JRI_PUBLIC_VAR_EXP(VarType) __declspec(dllexport) VarType +# define JRI_PUBLIC_VAR_IMP(VarType) __declspec(dllimport) VarType +# define JRI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType +# define JRI_CALLBACK +# else /* !_WIN32 */ +# if defined(_WINDLL) +# define JRI_PUBLIC_API(ResultType) ResultType __cdecl __export __loadds +# define JRI_PUBLIC_VAR(VarType) VarType +# define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType) +# define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType) +# define JRI_NATIVE_STUB(ResultType) ResultType __cdecl __loadds +# define JRI_CALLBACK __loadds +# else /* !WINDLL */ +# define JRI_PUBLIC_API(ResultType) ResultType __cdecl __export +# define JRI_PUBLIC_VAR(VarType) VarType +# define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType) +# define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType) +# define JRI_NATIVE_STUB(ResultType) ResultType __cdecl __export +# define JRI_CALLBACK __export +# endif /* !WINDLL */ +# endif /* !_WIN32 */ +# elif defined(__BORLANDC__) +# if defined(WIN32) || defined(_WIN32) +# define JRI_PUBLIC_API(ResultType) __export ResultType +# define JRI_PUBLIC_VAR(VarType) VarType +# define JRI_PUBLIC_VAR_EXP(VarType) __export VarType +# define JRI_PUBLIC_VAR_IMP(VarType) __import VarType +# define JRI_NATIVE_STUB(ResultType) __export ResultType +# define JRI_CALLBACK +# else /* !_WIN32 */ +# define JRI_PUBLIC_API(ResultType) ResultType _cdecl _export _loadds +# define JRI_PUBLIC_VAR(VarType) VarType +# define JRI_PUBLIC_VAR_EXP(VarType) __cdecl __export VarType +# define JRI_PUBLIC_VAR_IMP(VarType) __cdecl __import VarType +# define JRI_NATIVE_STUB(ResultType) ResultType _cdecl _loadds +# define JRI_CALLBACK _loadds +# endif +# else +# error Unsupported PC development environment. +# endif +# ifndef IS_LITTLE_ENDIAN +# define IS_LITTLE_ENDIAN +# endif + +/* OS/2 */ +#elif defined(XP_OS2) +# ifdef XP_OS2_VACPP +# define JRI_PUBLIC_API(ResultType) ResultType _Optlink +# define JRI_PUBLIC_VAR(VarType) VarType +# define JRI_CALLBACK +# elif defined(__declspec) +# define JRI_PUBLIC_API(ResultType) __declspec(dllexport) ResultType +# define JRI_PUBLIC_VAR(VarType) VarType +# define JRI_PUBLIC_VAR_EXP(VarType) __declspec(dllexport) VarType +# define JRI_PUBLIC_VAR_IMP(VarType) __declspec(dllimport) VarType +# define JRI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType +# define JRI_CALLBACK +# else +# define JRI_PUBLIC_API(ResultType) ResultType +# define JRI_PUBLIC_VAR(VarType) VarType +# define JRI_CALLBACK +# endif + +/* Mac */ +#elif defined (macintosh) || Macintosh || THINK_C +# if defined(__MWERKS__) /* Metrowerks */ +# if !__option(enumsalwaysint) +# error You need to define 'Enums Always Int' for your project. +# endif +# if defined(TARGET_CPU_68K) && !TARGET_RT_MAC_CFM +# if !__option(fourbyteints) +# error You need to define 'Struct Alignment: 68k' for your project. +# endif +# endif /* !GENERATINGCFM */ +# define JRI_PUBLIC_API(ResultType) __declspec(export) ResultType +# define JRI_PUBLIC_VAR(VarType) JRI_PUBLIC_API(VarType) +# define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_API(VarType) +# define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_API(VarType) +# define JRI_NATIVE_STUB(ResultType) JRI_PUBLIC_API(ResultType) +# elif defined(__SC__) /* Symantec */ +# error What are the Symantec defines? (warren@netscape.com) +# elif macintosh && applec /* MPW */ +# error Please upgrade to the latest MPW compiler (SC). +# else +# error Unsupported Mac development environment. +# endif +# define JRI_CALLBACK + +/* Unix or else */ +#else +# define JRI_PUBLIC_API(ResultType) ResultType +# define JRI_PUBLIC_VAR(VarType) VarType +# define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType) +# define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType) +# define JRI_NATIVE_STUB(ResultType) ResultType +# define JRI_CALLBACK +#endif + +#ifndef FAR /* for non-Win16 */ +#define FAR +#endif + +/******************************************************************************/ + +/* Java Scalar Types */ + +#if 0 /* now in jni.h */ +typedef short jchar; +typedef short jshort; +typedef float jfloat; +typedef double jdouble; +typedef juint jsize; +#endif + +/* moved from jni.h -- Sun's new jni.h doesn't have this anymore */ +#ifdef __cplusplus +typedef class _jobject *jref; +#else +typedef struct _jobject *jref; +#endif + +typedef unsigned char jbool; +typedef signed char jbyte; +#ifdef IS_64 /* XXX ok for alpha, but not right on all 64-bit architectures */ +typedef unsigned int juint; +typedef int jint; +#else +typedef unsigned long juint; +typedef long jint; +#endif + +/******************************************************************************* + * jlong : long long (64-bit signed integer type) support. + ******************************************************************************/ + +/* +** Bit masking macros. (n must be <= 31 to be portable) +*/ +#define JRI_BIT(n) ((juint)1 << (n)) +#define JRI_BITMASK(n) (JRI_BIT(n) - 1) + +#ifdef HAVE_LONG_LONG + +#ifdef OSF1 + +/* long is default 64-bit on OSF1, -std1 does not allow long long */ +typedef long jlong; +typedef unsigned long julong; +#define jlong_MAXINT 0x7fffffffffffffffL +#define jlong_MININT 0x8000000000000000L +#define jlong_ZERO 0x0L + +#elif (defined(WIN32) || defined(_WIN32)) + +typedef LONGLONG jlong; +typedef DWORDLONG julong; +#define jlong_MAXINT 0x7fffffffffffffffi64 +#define jlong_MININT 0x8000000000000000i64 +#define jlong_ZERO 0x0i64 + +#else + +typedef long long jlong; +typedef unsigned long long julong; +#define jlong_MAXINT 0x7fffffffffffffffLL +#define jlong_MININT 0x8000000000000000LL +#define jlong_ZERO 0x0LL + +#endif + +#define jlong_IS_ZERO(a) ((a) == 0) +#define jlong_EQ(a, b) ((a) == (b)) +#define jlong_NE(a, b) ((a) != (b)) +#define jlong_GE_ZERO(a) ((a) >= 0) +#define jlong_CMP(a, op, b) ((a) op (b)) + +#define jlong_AND(r, a, b) ((r) = (a) & (b)) +#define jlong_OR(r, a, b) ((r) = (a) | (b)) +#define jlong_XOR(r, a, b) ((r) = (a) ^ (b)) +#define jlong_OR2(r, a) ((r) = (r) | (a)) +#define jlong_NOT(r, a) ((r) = ~(a)) + +#define jlong_NEG(r, a) ((r) = -(a)) +#define jlong_ADD(r, a, b) ((r) = (a) + (b)) +#define jlong_SUB(r, a, b) ((r) = (a) - (b)) + +#define jlong_MUL(r, a, b) ((r) = (a) * (b)) +#define jlong_DIV(r, a, b) ((r) = (a) / (b)) +#define jlong_MOD(r, a, b) ((r) = (a) % (b)) + +#define jlong_SHL(r, a, b) ((r) = (a) << (b)) +#define jlong_SHR(r, a, b) ((r) = (a) >> (b)) +#define jlong_USHR(r, a, b) ((r) = (julong)(a) >> (b)) +#define jlong_ISHL(r, a, b) ((r) = ((jlong)(a)) << (b)) + +#define jlong_L2I(i, l) ((i) = (int)(l)) +#define jlong_L2UI(ui, l) ((ui) =(unsigned int)(l)) +#define jlong_L2F(f, l) ((f) = (l)) +#define jlong_L2D(d, l) ((d) = (l)) + +#define jlong_I2L(l, i) ((l) = (i)) +#define jlong_UI2L(l, ui) ((l) = (ui)) +#define jlong_F2L(l, f) ((l) = (f)) +#define jlong_D2L(l, d) ((l) = (d)) + +#define jlong_UDIVMOD(qp, rp, a, b) \ + (*(qp) = ((julong)(a) / (b)), \ + *(rp) = ((julong)(a) % (b))) + +#else /* !HAVE_LONG_LONG */ + +typedef struct { +#ifdef IS_LITTLE_ENDIAN + juint lo, hi; +#else + juint hi, lo; +#endif +} jlong; +typedef jlong julong; + +extern jlong jlong_MAXINT, jlong_MININT, jlong_ZERO; + +#define jlong_IS_ZERO(a) (((a).hi == 0) && ((a).lo == 0)) +#define jlong_EQ(a, b) (((a).hi == (b).hi) && ((a).lo == (b).lo)) +#define jlong_NE(a, b) (((a).hi != (b).hi) || ((a).lo != (b).lo)) +#define jlong_GE_ZERO(a) (((a).hi >> 31) == 0) + +/* + * NB: jlong_CMP and jlong_UCMP work only for strict relationals (<, >). + */ +#define jlong_CMP(a, op, b) (((int32)(a).hi op (int32)(b).hi) || \ + (((a).hi == (b).hi) && ((a).lo op (b).lo))) +#define jlong_UCMP(a, op, b) (((a).hi op (b).hi) || \ + (((a).hi == (b).hi) && ((a).lo op (b).lo))) + +#define jlong_AND(r, a, b) ((r).lo = (a).lo & (b).lo, \ + (r).hi = (a).hi & (b).hi) +#define jlong_OR(r, a, b) ((r).lo = (a).lo | (b).lo, \ + (r).hi = (a).hi | (b).hi) +#define jlong_XOR(r, a, b) ((r).lo = (a).lo ^ (b).lo, \ + (r).hi = (a).hi ^ (b).hi) +#define jlong_OR2(r, a) ((r).lo = (r).lo | (a).lo, \ + (r).hi = (r).hi | (a).hi) +#define jlong_NOT(r, a) ((r).lo = ~(a).lo, \ + (r).hi = ~(a).hi) + +#define jlong_NEG(r, a) ((r).lo = -(int32)(a).lo, \ + (r).hi = -(int32)(a).hi - ((r).lo != 0)) +#define jlong_ADD(r, a, b) { \ + jlong _a, _b; \ + _a = a; _b = b; \ + (r).lo = _a.lo + _b.lo; \ + (r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \ +} + +#define jlong_SUB(r, a, b) { \ + jlong _a, _b; \ + _a = a; _b = b; \ + (r).lo = _a.lo - _b.lo; \ + (r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \ +} \ + +/* + * Multiply 64-bit operands a and b to get 64-bit result r. + * First multiply the low 32 bits of a and b to get a 64-bit result in r. + * Then add the outer and inner products to r.hi. + */ +#define jlong_MUL(r, a, b) { \ + jlong _a, _b; \ + _a = a; _b = b; \ + jlong_MUL32(r, _a.lo, _b.lo); \ + (r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \ +} + +/* XXX _jlong_lo16(a) = ((a) << 16 >> 16) is better on some archs (not on mips) */ +#define _jlong_lo16(a) ((a) & JRI_BITMASK(16)) +#define _jlong_hi16(a) ((a) >> 16) + +/* + * Multiply 32-bit operands a and b to get 64-bit result r. + * Use polynomial expansion based on primitive field element (1 << 16). + */ +#define jlong_MUL32(r, a, b) { \ + juint _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \ + _a1 = _jlong_hi16(a), _a0 = _jlong_lo16(a); \ + _b1 = _jlong_hi16(b), _b0 = _jlong_lo16(b); \ + _y0 = _a0 * _b0; \ + _y1 = _a0 * _b1; \ + _y2 = _a1 * _b0; \ + _y3 = _a1 * _b1; \ + _y1 += _jlong_hi16(_y0); /* can't carry */ \ + _y1 += _y2; /* might carry */ \ + if (_y1 < _y2) _y3 += 1 << 16; /* propagate */ \ + (r).lo = (_jlong_lo16(_y1) << 16) + _jlong_lo16(_y0); \ + (r).hi = _y3 + _jlong_hi16(_y1); \ +} + +/* + * Divide 64-bit unsigned operand a by 64-bit unsigned operand b, setting *qp + * to the 64-bit unsigned quotient, and *rp to the 64-bit unsigned remainder. + * Minimize effort if one of qp and rp is null. + */ +#define jlong_UDIVMOD(qp, rp, a, b) jlong_udivmod(qp, rp, a, b) + +extern JRI_PUBLIC_API(void) +jlong_udivmod(julong *qp, julong *rp, julong a, julong b); + +#define jlong_DIV(r, a, b) { \ + jlong _a, _b; \ + juint _negative = (int32)(a).hi < 0; \ + if (_negative) { \ + jlong_NEG(_a, a); \ + } else { \ + _a = a; \ + } \ + if ((int32)(b).hi < 0) { \ + _negative ^= 1; \ + jlong_NEG(_b, b); \ + } else { \ + _b = b; \ + } \ + jlong_UDIVMOD(&(r), 0, _a, _b); \ + if (_negative) \ + jlong_NEG(r, r); \ +} + +#define jlong_MOD(r, a, b) { \ + jlong _a, _b; \ + juint _negative = (int32)(a).hi < 0; \ + if (_negative) { \ + jlong_NEG(_a, a); \ + } else { \ + _a = a; \ + } \ + if ((int32)(b).hi < 0) { \ + jlong_NEG(_b, b); \ + } else { \ + _b = b; \ + } \ + jlong_UDIVMOD(0, &(r), _a, _b); \ + if (_negative) \ + jlong_NEG(r, r); \ +} + +/* + * NB: b is a juint, not jlong or julong, for the shift ops. + */ +#define jlong_SHL(r, a, b) { \ + if (b) { \ + jlong _a; \ + _a = a; \ + if ((b) < 32) { \ + (r).lo = _a.lo << (b); \ + (r).hi = (_a.hi << (b)) | (_a.lo >> (32 - (b))); \ + } else { \ + (r).lo = 0; \ + (r).hi = _a.lo << ((b) & 31); \ + } \ + } else { \ + (r) = (a); \ + } \ +} + +/* a is an int32, b is int32, r is jlong */ +#define jlong_ISHL(r, a, b) { \ + if (b) { \ + jlong _a; \ + _a.lo = (a); \ + _a.hi = 0; \ + if ((b) < 32) { \ + (r).lo = (a) << (b); \ + (r).hi = ((a) >> (32 - (b))); \ + } else { \ + (r).lo = 0; \ + (r).hi = (a) << ((b) & 31); \ + } \ + } else { \ + (r).lo = (a); \ + (r).hi = 0; \ + } \ +} + +#define jlong_SHR(r, a, b) { \ + if (b) { \ + jlong _a; \ + _a = a; \ + if ((b) < 32) { \ + (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b)); \ + (r).hi = (int32)_a.hi >> (b); \ + } else { \ + (r).lo = (int32)_a.hi >> ((b) & 31); \ + (r).hi = (int32)_a.hi >> 31; \ + } \ + } else { \ + (r) = (a); \ + } \ +} + +#define jlong_USHR(r, a, b) { \ + if (b) { \ + jlong _a; \ + _a = a; \ + if ((b) < 32) { \ + (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b)); \ + (r).hi = _a.hi >> (b); \ + } else { \ + (r).lo = _a.hi >> ((b) & 31); \ + (r).hi = 0; \ + } \ + } else { \ + (r) = (a); \ + } \ +} + +#define jlong_L2I(i, l) ((i) = (l).lo) +#define jlong_L2UI(ui, l) ((ui) = (l).lo) +#define jlong_L2F(f, l) { double _d; jlong_L2D(_d, l); (f) = (float) _d; } + +#define jlong_L2D(d, l) { \ + int32 _negative; \ + jlong _absval; \ + \ + _negative = (l).hi >> 31; \ + if (_negative) { \ + jlong_NEG(_absval, l); \ + } else { \ + _absval = l; \ + } \ + (d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \ + if (_negative) \ + (d) = -(d); \ +} + +#define jlong_I2L(l, i) ((l).hi = (i) >> 31, (l).lo = (i)) +#define jlong_UI2L(l, ui) ((l).hi = 0, (l).lo = (ui)) +#define jlong_F2L(l, f) { double _d = (double) f; jlong_D2L(l, _d); } + +#define jlong_D2L(l, d) { \ + int _negative; \ + double _absval, _d_hi; \ + jlong _lo_d; \ + \ + _negative = ((d) < 0); \ + _absval = _negative ? -(d) : (d); \ + \ + (l).hi = (juint)(_absval / 4.294967296e9); \ + (l).lo = 0; \ + jlong_L2D(_d_hi, l); \ + _absval -= _d_hi; \ + _lo_d.hi = 0; \ + if (_absval < 0) { \ + _lo_d.lo = (juint) -_absval; \ + jlong_SUB(l, l, _lo_d); \ + } else { \ + _lo_d.lo = (juint) _absval; \ + jlong_ADD(l, l, _lo_d); \ + } \ + \ + if (_negative) \ + jlong_NEG(l, l); \ +} + +#endif /* !HAVE_LONG_LONG */ + +/******************************************************************************/ + +#ifdef HAVE_ALIGNED_LONGLONGS +#define JRI_GET_INT64(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \ + ((_t).x[1] = ((jint*)(_addr))[1]), \ + (_t).l ) +#define JRI_SET_INT64(_t, _addr, _v) ( (_t).l = (_v), \ + ((jint*)(_addr))[0] = (_t).x[0], \ + ((jint*)(_addr))[1] = (_t).x[1] ) +#else +#define JRI_GET_INT64(_t,_addr) (*(jlong*)(_addr)) +#define JRI_SET_INT64(_t, _addr, _v) (*(jlong*)(_addr) = (_v)) +#endif + +/* If double's must be aligned on doubleword boundaries then define this */ +#ifdef HAVE_ALIGNED_DOUBLES +#define JRI_GET_DOUBLE(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \ + ((_t).x[1] = ((jint*)(_addr))[1]), \ + (_t).d ) +#define JRI_SET_DOUBLE(_t, _addr, _v) ( (_t).d = (_v), \ + ((jint*)(_addr))[0] = (_t).x[0], \ + ((jint*)(_addr))[1] = (_t).x[1] ) +#else +#define JRI_GET_DOUBLE(_t,_addr) (*(jdouble*)(_addr)) +#define JRI_SET_DOUBLE(_t, _addr, _v) (*(jdouble*)(_addr) = (_v)) +#endif + +/******************************************************************************/ +#ifdef __cplusplus +} +#endif +#endif /* JRI_MD_H */ +/******************************************************************************/ diff --git a/extras/browser plugins/wrapper/npapi/jritypes.h b/extras/browser plugins/wrapper/npapi/jritypes.h index 2ef14aebeb..021f4dd590 100644 --- a/extras/browser plugins/wrapper/npapi/jritypes.h +++ b/extras/browser plugins/wrapper/npapi/jritypes.h @@ -1,243 +1,243 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/******************************************************************************* - * Java Runtime Interface - ******************************************************************************/ - -#ifndef JRITYPES_H -#define JRITYPES_H - -#include "jri_md.h" -#include "jni.h" -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/******************************************************************************* - * Types - ******************************************************************************/ - -struct JRIEnvInterface; - -typedef void* JRIRef; -typedef void* JRIGlobalRef; - -typedef jint JRIFieldID; -typedef jint JRIMethodID; - -/* synonyms: */ -typedef JRIGlobalRef jglobal; - -typedef union JRIValue { - jbool z; - jbyte b; - jchar c; - jshort s; - jint i; - jlong l; - jfloat f; - jdouble d; - jref r; -} JRIValue; - -typedef enum JRIBoolean { - JRIFalse = 0, - JRITrue = 1 -} JRIBoolean; - -typedef enum JRIConstant { - JRIUninitialized = -1 -} JRIConstant; - -/* convenience types (these must be distinct struct types for c++ overloading): */ -#if 0 /* now in jni.h */ -typedef struct jbooleanArrayStruct* jbooleanArray; -typedef struct jbyteArrayStruct* jbyteArray; -typedef struct jcharArrayStruct* jcharArray; -typedef struct jshortArrayStruct* jshortArray; -typedef struct jintArrayStruct* jintArray; -typedef struct jlongArrayStruct* jlongArray; -typedef struct jfloatArrayStruct* jfloatArray; -typedef struct jdoubleArrayStruct* jdoubleArray; -typedef struct jobjectArrayStruct* jobjectArray; -#endif -typedef struct jstringArrayStruct* jstringArray; -typedef struct jarrayArrayStruct* jarrayArray; - -#define JRIConstructorMethodName "" - -/******************************************************************************* - * Signature Construction Macros - ******************************************************************************/ - -/* -** These macros can be used to construct signature strings. Hopefully their names -** are a little easier to remember than the single character they correspond to. -** For example, to specify the signature of the method: -** -** public int read(byte b[], int off, int len); -** -** you could write something like this in C: -** -** char* readSig = JRISigMethod(JRISigArray(JRISigByte) -** JRISigInt -** JRISigInt) JRISigInt; -** -** Of course, don't put commas between the types. -*/ -#define JRISigArray(T) "[" T -#define JRISigByte "B" -#define JRISigChar "C" -#define JRISigClass(name) "L" name ";" -#define JRISigFloat "F" -#define JRISigDouble "D" -#define JRISigMethod(args) "(" args ")" -#define JRISigNoArgs "" -#define JRISigInt "I" -#define JRISigLong "J" -#define JRISigShort "S" -#define JRISigVoid "V" -#define JRISigBoolean "Z" - -/******************************************************************************* - * Environments - ******************************************************************************/ - -extern JRI_PUBLIC_API(const struct JRIEnvInterface**) -JRI_GetCurrentEnv(void); - -/******************************************************************************* - * Specific Scalar Array Types - ******************************************************************************/ - -/* -** The JRI Native Method Interface does not support boolean arrays. This -** is to allow Java runtime implementations to optimize boolean array -** storage. Using the ScalarArray operations on boolean arrays is bound -** to fail, so convert any boolean arrays to byte arrays in Java before -** passing them to a native method. -*/ - -#define JRI_NewByteArray(env, length, initialValues) \ - JRI_NewScalarArray(env, length, JRISigByte, (jbyte*)(initialValues)) -#define JRI_GetByteArrayLength(env, array) \ - JRI_GetScalarArrayLength(env, array) -#define JRI_GetByteArrayElements(env, array) \ - JRI_GetScalarArrayElements(env, array) - -#define JRI_NewCharArray(env, length, initialValues) \ - JRI_NewScalarArray(env, ((length) * sizeof(jchar)), JRISigChar, (jbyte*)(initialValues)) -#define JRI_GetCharArrayLength(env, array) \ - JRI_GetScalarArrayLength(env, array) -#define JRI_GetCharArrayElements(env, array) \ - ((jchar*)JRI_GetScalarArrayElements(env, array)) - -#define JRI_NewShortArray(env, length, initialValues) \ - JRI_NewScalarArray(env, ((length) * sizeof(jshort)), JRISigShort, (jbyte*)(initialValues)) -#define JRI_GetShortArrayLength(env, array) \ - JRI_GetScalarArrayLength(env, array) -#define JRI_GetShortArrayElements(env, array) \ - ((jshort*)JRI_GetScalarArrayElements(env, array)) - -#define JRI_NewIntArray(env, length, initialValues) \ - JRI_NewScalarArray(env, ((length) * sizeof(jint)), JRISigInt, (jbyte*)(initialValues)) -#define JRI_GetIntArrayLength(env, array) \ - JRI_GetScalarArrayLength(env, array) -#define JRI_GetIntArrayElements(env, array) \ - ((jint*)JRI_GetScalarArrayElements(env, array)) - -#define JRI_NewLongArray(env, length, initialValues) \ - JRI_NewScalarArray(env, ((length) * sizeof(jlong)), JRISigLong, (jbyte*)(initialValues)) -#define JRI_GetLongArrayLength(env, array) \ - JRI_GetScalarArrayLength(env, array) -#define JRI_GetLongArrayElements(env, array) \ - ((jlong*)JRI_GetScalarArrayElements(env, array)) - -#define JRI_NewFloatArray(env, length, initialValues) \ - JRI_NewScalarArray(env, ((length) * sizeof(jfloat)), JRISigFloat, (jbyte*)(initialValues)) -#define JRI_GetFloatArrayLength(env, array) \ - JRI_GetScalarArrayLength(env, array) -#define JRI_GetFloatArrayElements(env, array) \ - ((jfloat*)JRI_GetScalarArrayElements(env, array)) - -#define JRI_NewDoubleArray(env, length, initialValues) \ - JRI_NewScalarArray(env, ((length) * sizeof(jdouble)), JRISigDouble, (jbyte*)(initialValues)) -#define JRI_GetDoubleArrayLength(env, array) \ - JRI_GetScalarArrayLength(env, array) -#define JRI_GetDoubleArrayElements(env, array) \ - ((jdouble*)JRI_GetScalarArrayElements(env, array)) - -/******************************************************************************/ -/* -** JDK Stuff -- This stuff is still needed while we're using the JDK -** dynamic linking strategy to call native methods. -*/ - -typedef union JRI_JDK_stack_item { - /* Non pointer items */ - jint i; - jfloat f; - jint o; - /* Pointer items */ - void *h; - void *p; - unsigned char *addr; -#ifdef IS_64 - double d; - long l; /* == 64bits! */ -#endif -} JRI_JDK_stack_item; - -typedef union JRI_JDK_Java8Str { - jint x[2]; - jdouble d; - jlong l; - void *p; - float f; -} JRI_JDK_Java8; - -/******************************************************************************/ -#ifdef __cplusplus -} -#endif -#endif /* JRITYPES_H */ -/******************************************************************************/ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/******************************************************************************* + * Java Runtime Interface + ******************************************************************************/ + +#ifndef JRITYPES_H +#define JRITYPES_H + +#include "jri_md.h" +#include "jni.h" +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************* + * Types + ******************************************************************************/ + +struct JRIEnvInterface; + +typedef void* JRIRef; +typedef void* JRIGlobalRef; + +typedef jint JRIFieldID; +typedef jint JRIMethodID; + +/* synonyms: */ +typedef JRIGlobalRef jglobal; + +typedef union JRIValue { + jbool z; + jbyte b; + jchar c; + jshort s; + jint i; + jlong l; + jfloat f; + jdouble d; + jref r; +} JRIValue; + +typedef enum JRIBoolean { + JRIFalse = 0, + JRITrue = 1 +} JRIBoolean; + +typedef enum JRIConstant { + JRIUninitialized = -1 +} JRIConstant; + +/* convenience types (these must be distinct struct types for c++ overloading): */ +#if 0 /* now in jni.h */ +typedef struct jbooleanArrayStruct* jbooleanArray; +typedef struct jbyteArrayStruct* jbyteArray; +typedef struct jcharArrayStruct* jcharArray; +typedef struct jshortArrayStruct* jshortArray; +typedef struct jintArrayStruct* jintArray; +typedef struct jlongArrayStruct* jlongArray; +typedef struct jfloatArrayStruct* jfloatArray; +typedef struct jdoubleArrayStruct* jdoubleArray; +typedef struct jobjectArrayStruct* jobjectArray; +#endif +typedef struct jstringArrayStruct* jstringArray; +typedef struct jarrayArrayStruct* jarrayArray; + +#define JRIConstructorMethodName "" + +/******************************************************************************* + * Signature Construction Macros + ******************************************************************************/ + +/* +** These macros can be used to construct signature strings. Hopefully their names +** are a little easier to remember than the single character they correspond to. +** For example, to specify the signature of the method: +** +** public int read(byte b[], int off, int len); +** +** you could write something like this in C: +** +** char* readSig = JRISigMethod(JRISigArray(JRISigByte) +** JRISigInt +** JRISigInt) JRISigInt; +** +** Of course, don't put commas between the types. +*/ +#define JRISigArray(T) "[" T +#define JRISigByte "B" +#define JRISigChar "C" +#define JRISigClass(name) "L" name ";" +#define JRISigFloat "F" +#define JRISigDouble "D" +#define JRISigMethod(args) "(" args ")" +#define JRISigNoArgs "" +#define JRISigInt "I" +#define JRISigLong "J" +#define JRISigShort "S" +#define JRISigVoid "V" +#define JRISigBoolean "Z" + +/******************************************************************************* + * Environments + ******************************************************************************/ + +extern JRI_PUBLIC_API(const struct JRIEnvInterface**) +JRI_GetCurrentEnv(void); + +/******************************************************************************* + * Specific Scalar Array Types + ******************************************************************************/ + +/* +** The JRI Native Method Interface does not support boolean arrays. This +** is to allow Java runtime implementations to optimize boolean array +** storage. Using the ScalarArray operations on boolean arrays is bound +** to fail, so convert any boolean arrays to byte arrays in Java before +** passing them to a native method. +*/ + +#define JRI_NewByteArray(env, length, initialValues) \ + JRI_NewScalarArray(env, length, JRISigByte, (jbyte*)(initialValues)) +#define JRI_GetByteArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetByteArrayElements(env, array) \ + JRI_GetScalarArrayElements(env, array) + +#define JRI_NewCharArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jchar)), JRISigChar, (jbyte*)(initialValues)) +#define JRI_GetCharArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetCharArrayElements(env, array) \ + ((jchar*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewShortArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jshort)), JRISigShort, (jbyte*)(initialValues)) +#define JRI_GetShortArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetShortArrayElements(env, array) \ + ((jshort*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewIntArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jint)), JRISigInt, (jbyte*)(initialValues)) +#define JRI_GetIntArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetIntArrayElements(env, array) \ + ((jint*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewLongArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jlong)), JRISigLong, (jbyte*)(initialValues)) +#define JRI_GetLongArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetLongArrayElements(env, array) \ + ((jlong*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewFloatArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jfloat)), JRISigFloat, (jbyte*)(initialValues)) +#define JRI_GetFloatArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetFloatArrayElements(env, array) \ + ((jfloat*)JRI_GetScalarArrayElements(env, array)) + +#define JRI_NewDoubleArray(env, length, initialValues) \ + JRI_NewScalarArray(env, ((length) * sizeof(jdouble)), JRISigDouble, (jbyte*)(initialValues)) +#define JRI_GetDoubleArrayLength(env, array) \ + JRI_GetScalarArrayLength(env, array) +#define JRI_GetDoubleArrayElements(env, array) \ + ((jdouble*)JRI_GetScalarArrayElements(env, array)) + +/******************************************************************************/ +/* +** JDK Stuff -- This stuff is still needed while we're using the JDK +** dynamic linking strategy to call native methods. +*/ + +typedef union JRI_JDK_stack_item { + /* Non pointer items */ + jint i; + jfloat f; + jint o; + /* Pointer items */ + void *h; + void *p; + unsigned char *addr; +#ifdef IS_64 + double d; + long l; /* == 64bits! */ +#endif +} JRI_JDK_stack_item; + +typedef union JRI_JDK_Java8Str { + jint x[2]; + jdouble d; + jlong l; + void *p; + float f; +} JRI_JDK_Java8; + +/******************************************************************************/ +#ifdef __cplusplus +} +#endif +#endif /* JRITYPES_H */ +/******************************************************************************/ diff --git a/extras/browser plugins/wrapper/npapi/npapi.h b/extras/browser plugins/wrapper/npapi/npapi.h index 6f783a1ddf..2522b723f6 100644 --- a/extras/browser plugins/wrapper/npapi/npapi.h +++ b/extras/browser plugins/wrapper/npapi/npapi.h @@ -1,766 +1,766 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - - -/* - * npapi.h $Revision: 3.48 $ - * Netscape client plug-in API spec - */ - -#ifndef _NPAPI_H_ -#define _NPAPI_H_ - -#ifdef __OS2__ -#pragma pack(1) -#endif - -#include "prtypes.h" -/* Copied from xp_core.h */ -/* removed #ifdef for hpux defined in /usr/include/model.h */ -#ifndef _INT16 -#define _INT16 -#endif -#ifndef _INT32 -#define _INT32 -#endif -#ifndef _UINT16 -#define _UINT16 -#endif -#ifndef _UINT32 -#define _UINT32 -#endif - -/* - * NO_NSPR_10_SUPPORT disables the inclusion - * of obsolete/protypes.h, whose int16, uint16, - * int32, and uint32 typedefs conflict with those - * in this file. - */ -#ifndef NO_NSPR_10_SUPPORT -#define NO_NSPR_10_SUPPORT -#endif -#ifdef OJI -#include "jri.h" /* Java Runtime Interface */ -#endif - -#if defined (__OS2__ ) || defined (OS2) -# ifndef XP_OS2 -# define XP_OS2 1 -# endif /* XP_OS2 */ -#endif /* __OS2__ */ - -#ifdef _WINDOWS -# include -# ifndef XP_WIN -# define XP_WIN 1 -# endif /* XP_WIN */ -#endif /* _WINDOWS */ - -#ifdef __MWERKS__ -# define _declspec __declspec -# ifdef __INTEL__ -# undef NULL -# ifndef XP_WIN -# define XP_WIN 1 -# endif /* XP_WIN */ -# endif /* __INTEL__ */ -#endif /* __MWERKS__ */ - -#ifdef XP_MACOSX -#include -#ifdef __LP64__ -#define NP_NO_QUICKDRAW -#endif -#endif - -#if defined(XP_UNIX) -# include -# if defined(MOZ_X11) -# include -# include -# endif -#endif - -/*----------------------------------------------------------------------*/ -/* Plugin Version Constants */ -/*----------------------------------------------------------------------*/ - -#define NP_VERSION_MAJOR 0 -#define NP_VERSION_MINOR 19 - - -/* The OS/2 version of Netscape uses RC_DATA to define the - mime types, file extensions, etc that are required. - Use a vertical bar to separate types, end types with \0. - FileVersion and ProductVersion are 32bit ints, all other - entries are strings the MUST be terminated wwith a \0. - -AN EXAMPLE: - -RCDATA NP_INFO_ProductVersion { 1,0,0,1,} - -RCDATA NP_INFO_MIMEType { "video/x-video|", - "video/x-flick\0" } -RCDATA NP_INFO_FileExtents { "avi|", - "flc\0" } -RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|", - "MMOS2 Flc/Fli player(*.flc)\0" } - -RCDATA NP_INFO_FileVersion { 1,0,0,1 } -RCDATA NP_INFO_CompanyName { "Netscape Communications\0" } -RCDATA NP_INFO_FileDescription { "NPAVI32 Extension DLL\0" -RCDATA NP_INFO_InternalName { "NPAVI32\0" ) -RCDATA NP_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0" -RCDATA NP_INFO_OriginalFilename { "NVAPI32.DLL" } -RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" } - -*/ - - -/* RC_DATA types for version info - required */ -#define NP_INFO_ProductVersion 1 -#define NP_INFO_MIMEType 2 -#define NP_INFO_FileOpenName 3 -#define NP_INFO_FileExtents 4 - -/* RC_DATA types for version info - used if found */ -#define NP_INFO_FileDescription 5 -#define NP_INFO_ProductName 6 - -/* RC_DATA types for version info - optional */ -#define NP_INFO_CompanyName 7 -#define NP_INFO_FileVersion 8 -#define NP_INFO_InternalName 9 -#define NP_INFO_LegalCopyright 10 -#define NP_INFO_OriginalFilename 11 - -#ifndef RC_INVOKED - - - -/*----------------------------------------------------------------------*/ -/* Definition of Basic Types */ -/*----------------------------------------------------------------------*/ - -#ifndef _UINT16 -typedef unsigned short uint16; -#endif - -#ifndef _UINT32 -# if defined(__alpha) || defined(__amd64__) || defined(__x86_64__) -typedef unsigned int uint32; -# else /* __alpha */ -typedef unsigned long uint32; -# endif /* __alpha */ -#endif - -/* - * AIX defines these in sys/inttypes.h included from sys/types.h - */ -#ifndef AIX -#ifndef _INT16 -typedef short int16; -#endif - -#ifndef _INT32 -# if defined(__alpha) || defined(__amd64__) || defined(__x86_64__) -typedef int int32; -# else /* __alpha */ -typedef long int32; -# endif /* __alpha */ -#endif -#endif - -#ifndef FALSE -#define FALSE (0) -#endif -#ifndef TRUE -#define TRUE (1) -#endif -#ifndef NULL -#define NULL (0L) -#endif - -#ifdef XP_MACOSX -typedef enum { -#ifndef NP_NO_QUICKDRAW - NPDrawingModelQuickDraw = 0, -#endif - NPDrawingModelCoreGraphics = 1 -} NPDrawingModel; -#endif - -typedef unsigned char NPBool; -typedef int16 NPError; -typedef int16 NPReason; -typedef char* NPMIMEType; - - - -/*----------------------------------------------------------------------*/ -/* Structures and definitions */ -/*----------------------------------------------------------------------*/ - -/* - * NPP is a plug-in's opaque instance handle - */ -typedef struct _NPP -{ - void* pdata; /* plug-in private data */ - void* ndata; /* netscape private data */ -} NPP_t; - -typedef NPP_t* NPP; - - -typedef struct _NPStream -{ - void* pdata; /* plug-in private data */ - void* ndata; /* netscape private data */ - const char* url; - uint32 end; - uint32 lastmodified; - void* notifyData; - const char* headers; /* Response headers from host. - * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS. - * Used for HTTP only; NULL for non-HTTP. - * Available from NPP_NewStream onwards. - * Plugin should copy this data before storing it. - * Includes HTTP status line and all headers, - * preferably verbatim as received from server, - * headers formatted as in HTTP ("Header: Value"), - * and newlines (\n, NOT \r\n) separating lines. - * Terminated by \n\0 (NOT \n\n\0). */ -} NPStream; - - -typedef struct _NPByteRange -{ - int32 offset; /* negative offset means from the end */ - uint32 length; - struct _NPByteRange* next; -} NPByteRange; - - -typedef struct _NPSavedData -{ - int32 len; - void* buf; -} NPSavedData; - - -typedef struct _NPRect -{ - uint16 top; - uint16 left; - uint16 bottom; - uint16 right; -} NPRect; - -typedef struct _NPSize -{ - int32 width; - int32 height; -} NPSize; - -#ifdef XP_UNIX -/* - * Unix specific structures and definitions - */ - -/* - * Callback Structures. - * - * These are used to pass additional platform specific information. - */ -enum { - NP_SETWINDOW = 1, - NP_PRINT -}; - -typedef struct -{ - int32 type; -} NPAnyCallbackStruct; - -typedef struct -{ - int32 type; -#ifdef MOZ_X11 - Display* display; - Visual* visual; - Colormap colormap; - unsigned int depth; -#endif -} NPSetWindowCallbackStruct; - -typedef struct -{ - int32 type; - FILE* fp; -} NPPrintCallbackStruct; - -#endif /* XP_UNIX */ - - -/* - * The following masks are applied on certain platforms to NPNV and - * NPPV selectors that pass around pointers to COM interfaces. Newer - * compilers on some platforms may generate vtables that are not - * compatible with older compilers. To prevent older plugins from - * not understanding a new browser's ABI, these masks change the - * values of those selectors on those platforms. To remain backwards - * compatible with differenet versions of the browser, plugins can - * use these masks to dynamically determine and use the correct C++ - * ABI that the browser is expecting. This does not apply to Windows - * as Microsoft's COM ABI will likely not change. - */ - -#define NP_ABI_GCC3_MASK 0x10000000 -/* - * gcc 3.x generated vtables on UNIX and OSX are incompatible with - * previous compilers. - */ -#if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3)) -#define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK -#else -#define _NP_ABI_MIXIN_FOR_GCC3 0 -#endif - - -#define NP_ABI_MACHO_MASK 0x01000000 -/* - * On OSX, the Mach-O executable format is significantly - * different than CFM. In addition to having a different - * C++ ABI, it also has has different C calling convention. - * You must use glue code when calling between CFM and - * Mach-O C functions. - */ -#if (defined(TARGET_RT_MAC_MACHO)) -#define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK -#else -#define _NP_ABI_MIXIN_FOR_MACHO 0 -#endif - - -#define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO) - -/* - * List of variable names for which NPP_GetValue shall be implemented - */ -typedef enum { - NPPVpluginNameString = 1, - NPPVpluginDescriptionString, - NPPVpluginWindowBool, - NPPVpluginTransparentBool, - NPPVjavaClass, /* Not implemented in Mozilla 1.0 */ - NPPVpluginWindowSize, - NPPVpluginTimerInterval, - - NPPVpluginScriptableInstance = (10 | NP_ABI_MASK), - NPPVpluginScriptableIID = 11, - - /* Introduced in Mozilla 0.9.9 */ - NPPVjavascriptPushCallerBool = 12, - - /* Introduced in Mozilla 1.0 */ - NPPVpluginKeepLibraryInMemory = 13, - NPPVpluginNeedsXEmbed = 14, - - /* Get the NPObject for scripting the plugin. Introduced in Firefox - * 1.0 (NPAPI minor version 14). - */ - NPPVpluginScriptableNPObject = 15, - - /* Get the plugin value (as \0-terminated UTF-8 string data) for - * form submission if the plugin is part of a form. Use - * NPN_MemAlloc() to allocate memory for the string data. Introduced - * in Mozilla 1.8b2 (NPAPI minor version 15). - */ - NPPVformValue = 16 -#ifdef XP_MACOSX - /* Used for negotiating drawing models */ - , NPPVpluginDrawingModel = 1000 -#endif -} NPPVariable; - -/* - * List of variable names for which NPN_GetValue is implemented by Mozilla - */ -typedef enum { - NPNVxDisplay = 1, - NPNVxtAppContext, - NPNVnetscapeWindow, - NPNVjavascriptEnabledBool, - NPNVasdEnabledBool, - NPNVisOfflineBool, - - /* 10 and over are available on Mozilla builds starting with 0.9.4 */ - NPNVserviceManager = (10 | NP_ABI_MASK), - NPNVDOMElement = (11 | NP_ABI_MASK), /* available in Mozilla 1.2 */ - NPNVDOMWindow = (12 | NP_ABI_MASK), - NPNVToolkit = (13 | NP_ABI_MASK), - NPNVSupportsXEmbedBool = 14, - - /* Get the NPObject wrapper for the browser window. */ - NPNVWindowNPObject = 15, - - /* Get the NPObject wrapper for the plugins DOM element. */ - NPNVPluginElementNPObject = 16, - - NPNVSupportsWindowless = 17 - -#ifdef XP_MACOSX - /* Used for negotiating drawing models */ - , NPNVpluginDrawingModel = 1000 -#ifndef NP_NO_QUICKDRAW - , NPNVsupportsQuickDrawBool = 2000 -#endif - , NPNVsupportsCoreGraphicsBool = 2001 -#endif -} NPNVariable; - -/* - * The type of Tookkit the widgets use - */ -typedef enum { - NPNVGtk12 = 1, - NPNVGtk2 -} NPNToolkitType; - -/* - * The type of a NPWindow - it specifies the type of the data structure - * returned in the window field. - */ -typedef enum { - NPWindowTypeWindow = 1, - NPWindowTypeDrawable -} NPWindowType; - -typedef struct _NPWindow -{ - void* window; /* Platform specific window handle */ - /* OS/2: x - Position of bottom left corner */ - /* OS/2: y - relative to visible netscape window */ - int32 x; /* Position of top left corner relative */ - int32 y; /* to a netscape page. */ - uint32 width; /* Maximum window size */ - uint32 height; - NPRect clipRect; /* Clipping rectangle in port coordinates */ - /* Used by MAC only. */ -#if defined(XP_UNIX) && !defined(XP_MACOSX) - void * ws_info; /* Platform-dependent additonal data */ -#endif /* XP_UNIX */ - NPWindowType type; /* Is this a window or a drawable? */ -} NPWindow; - - -typedef struct _NPFullPrint -{ - NPBool pluginPrinted;/* Set TRUE if plugin handled fullscreen printing */ - NPBool printOne; /* TRUE if plugin should print one copy to default printer */ - void* platformPrint; /* Platform-specific printing info */ -} NPFullPrint; - -typedef struct _NPEmbedPrint -{ - NPWindow window; - void* platformPrint; /* Platform-specific printing info */ -} NPEmbedPrint; - -typedef struct _NPPrint -{ - uint16 mode; /* NP_FULL or NP_EMBED */ - union - { - NPFullPrint fullPrint; /* if mode is NP_FULL */ - NPEmbedPrint embedPrint; /* if mode is NP_EMBED */ - } print; -} NPPrint; - -#ifdef XP_MACOSX -typedef EventRecord NPEvent; -#elif defined(XP_WIN) -typedef struct _NPEvent -{ - uint16 event; - uint32 wParam; - uint32 lParam; -} NPEvent; -#elif defined(XP_OS2) -typedef struct _NPEvent -{ - uint32 event; - uint32 wParam; - uint32 lParam; -} NPEvent; -#elif defined (XP_UNIX) && defined(MOZ_X11) -typedef XEvent NPEvent; -#else -typedef void* NPEvent; -#endif /* XP_MACOSX */ - -#ifdef XP_MACOSX -typedef void* NPRegion; -#ifndef NP_NO_QUICKDRAW -typedef RgnHandle NPQDRegion; -#endif -typedef CGPathRef NPCGRegion; -#elif defined(XP_WIN) -typedef HRGN NPRegion; -#elif defined(XP_UNIX) && defined(MOZ_X11) -typedef Region NPRegion; -#else -typedef void *NPRegion; -#endif /* XP_MACOSX */ - -#ifdef XP_MACOSX -/* - * Mac-specific structures and definitions. - */ - -typedef struct NP_Port -{ - CGrafPtr port; /* Grafport */ - int32 portx; /* position inside the topmost window */ - int32 porty; -} NP_Port; - -typedef struct NP_CGContext -{ - CGContextRef context; - WindowRef window; -} NP_CGContext; - -/* - * Non-standard event types that can be passed to HandleEvent - */ - -enum NPEventType { - NPEventType_GetFocusEvent = (osEvt + 16), - NPEventType_LoseFocusEvent, - NPEventType_AdjustCursorEvent, - NPEventType_MenuCommandEvent, - NPEventType_ClippingChangedEvent, - NPEventType_ScrollingBeginsEvent = 1000, - NPEventType_ScrollingEndsEvent -}; - -#ifdef OBSOLETE -#define getFocusEvent (osEvt + 16) -#define loseFocusEvent (osEvt + 17) -#define adjustCursorEvent (osEvt + 18) -#endif -#endif /* XP_MACOSX */ - -/* - * Values for mode passed to NPP_New: - */ -#define NP_EMBED 1 -#define NP_FULL 2 - -/* - * Values for stream type passed to NPP_NewStream: - */ -#define NP_NORMAL 1 -#define NP_SEEK 2 -#define NP_ASFILE 3 -#define NP_ASFILEONLY 4 - -#define NP_MAXREADY (((unsigned)(~0)<<1)>>1) - - -/*----------------------------------------------------------------------*/ -/* Error and Reason Code definitions */ -/*----------------------------------------------------------------------*/ - -/* - * Values of type NPError: - */ -#define NPERR_BASE 0 -#define NPERR_NO_ERROR (NPERR_BASE + 0) -#define NPERR_GENERIC_ERROR (NPERR_BASE + 1) -#define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2) -#define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3) -#define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4) -#define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5) -#define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6) -#define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7) -#define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8) -#define NPERR_INVALID_PARAM (NPERR_BASE + 9) -#define NPERR_INVALID_URL (NPERR_BASE + 10) -#define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11) -#define NPERR_NO_DATA (NPERR_BASE + 12) -#define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13) - -/* - * Values of type NPReason: - */ -#define NPRES_BASE 0 -#define NPRES_DONE (NPRES_BASE + 0) -#define NPRES_NETWORK_ERR (NPRES_BASE + 1) -#define NPRES_USER_BREAK (NPRES_BASE + 2) - -/* - * Don't use these obsolete error codes any more. - */ -#define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR -#define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR -#define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK - -/* - * Version feature information - */ -#define NPVERS_HAS_STREAMOUTPUT 8 -#define NPVERS_HAS_NOTIFICATION 9 -#define NPVERS_HAS_LIVECONNECT 9 -#define NPVERS_WIN16_HAS_LIVECONNECT 9 -#define NPVERS_68K_HAS_LIVECONNECT 11 -#define NPVERS_HAS_WINDOWLESS 11 -#define NPVERS_HAS_XPCONNECT_SCRIPTING 13 -#define NPVERS_HAS_NPRUNTIME_SCRIPTING 14 -#define NPVERS_HAS_FORM_VALUES 15 -#define NPVERS_HAS_POPUPS_ENABLED_STATE 16 -#define NPVERS_HAS_RESPONSE_HEADERS 17 -#define NPVERS_HAS_NPOBJECT_ENUM 18 -#define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19 - -/*----------------------------------------------------------------------*/ -/* Function Prototypes */ -/*----------------------------------------------------------------------*/ - -#if defined(_WINDOWS) && !defined(WIN32) -#define NP_LOADDS _loadds -#else -#if defined(__OS2__) -#define NP_LOADDS _System -#else -#define NP_LOADDS -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * NPP_* functions are provided by the plugin and called by the navigator. - */ - -#ifdef XP_UNIX -char* NPP_GetMIMEDescription(void); -#endif /* XP_UNIX */ - -NPError NP_LOADDS NPP_Initialize(void); -void NP_LOADDS NPP_Shutdown(void); -NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance, - uint16 mode, int16 argc, char* argn[], - char* argv[], NPSavedData* saved); -NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save); -NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window); -NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type, - NPStream* stream, NPBool seekable, - uint16* stype); -NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream, - NPReason reason); -int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream); -int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset, - int32 len, void* buffer); -void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream, - const char* fname); -void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint); -int16 NP_LOADDS NPP_HandleEvent(NPP instance, void* event); -void NP_LOADDS NPP_URLNotify(NPP instance, const char* url, - NPReason reason, void* notifyData); -#ifdef OJI -jref NP_LOADDS NPP_GetJavaClass(void); -#endif -NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value); -NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value); - -/* - * NPN_* functions are provided by the navigator and called by the plugin. - */ -void NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor, - int* netscape_major, int* netscape_minor); -NPError NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url, - const char* target, void* notifyData); -NPError NP_LOADDS NPN_GetURL(NPP instance, const char* url, - const char* target); -NPError NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url, - const char* target, uint32 len, - const char* buf, NPBool file, - void* notifyData); -NPError NP_LOADDS NPN_PostURL(NPP instance, const char* url, - const char* target, uint32 len, - const char* buf, NPBool file); -NPError NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList); -NPError NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type, - const char* target, NPStream** stream); -int32 NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer); -NPError NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason); -void NP_LOADDS NPN_Status(NPP instance, const char* message); -const char* NP_LOADDS NPN_UserAgent(NPP instance); -void* NP_LOADDS NPN_MemAlloc(uint32 size); -void NP_LOADDS NPN_MemFree(void* ptr); -uint32 NP_LOADDS NPN_MemFlush(uint32 size); -void NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages); -#ifdef OJI -JRIEnv* NP_LOADDS NPN_GetJavaEnv(void); -jref NP_LOADDS NPN_GetJavaPeer(NPP instance); -#endif -NPError NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable, void *value); -NPError NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, void *value); -void NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect); -void NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion); -void NP_LOADDS NPN_ForceRedraw(NPP instance); -void NP_LOADDS NPN_PushPopupsEnabledState(NPP instance, NPBool enabled); -void NP_LOADDS NPN_PopPopupsEnabledState(NPP instance); -void NP_LOADDS NPN_PluginThreadAsyncCall(NPP instance, - void (*func) (void *), - void *userData); - -#ifdef __cplusplus -} /* end extern "C" */ -#endif - -#endif /* RC_INVOKED */ -#ifdef __OS2__ -#pragma pack() -#endif - -#endif /* _NPAPI_H_ */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +/* + * npapi.h $Revision: 3.48 $ + * Netscape client plug-in API spec + */ + +#ifndef _NPAPI_H_ +#define _NPAPI_H_ + +#ifdef __OS2__ +#pragma pack(1) +#endif + +#include "prtypes.h" +/* Copied from xp_core.h */ +/* removed #ifdef for hpux defined in /usr/include/model.h */ +#ifndef _INT16 +#define _INT16 +#endif +#ifndef _INT32 +#define _INT32 +#endif +#ifndef _UINT16 +#define _UINT16 +#endif +#ifndef _UINT32 +#define _UINT32 +#endif + +/* + * NO_NSPR_10_SUPPORT disables the inclusion + * of obsolete/protypes.h, whose int16, uint16, + * int32, and uint32 typedefs conflict with those + * in this file. + */ +#ifndef NO_NSPR_10_SUPPORT +#define NO_NSPR_10_SUPPORT +#endif +#ifdef OJI +#include "jri.h" /* Java Runtime Interface */ +#endif + +#if defined (__OS2__ ) || defined (OS2) +# ifndef XP_OS2 +# define XP_OS2 1 +# endif /* XP_OS2 */ +#endif /* __OS2__ */ + +#ifdef _WINDOWS +# include +# ifndef XP_WIN +# define XP_WIN 1 +# endif /* XP_WIN */ +#endif /* _WINDOWS */ + +#ifdef __MWERKS__ +# define _declspec __declspec +# ifdef __INTEL__ +# undef NULL +# ifndef XP_WIN +# define XP_WIN 1 +# endif /* XP_WIN */ +# endif /* __INTEL__ */ +#endif /* __MWERKS__ */ + +#ifdef XP_MACOSX +#include +#ifdef __LP64__ +#define NP_NO_QUICKDRAW +#endif +#endif + +#if defined(XP_UNIX) +# include +# if defined(MOZ_X11) +# include +# include +# endif +#endif + +/*----------------------------------------------------------------------*/ +/* Plugin Version Constants */ +/*----------------------------------------------------------------------*/ + +#define NP_VERSION_MAJOR 0 +#define NP_VERSION_MINOR 19 + + +/* The OS/2 version of Netscape uses RC_DATA to define the + mime types, file extensions, etc that are required. + Use a vertical bar to separate types, end types with \0. + FileVersion and ProductVersion are 32bit ints, all other + entries are strings the MUST be terminated wwith a \0. + +AN EXAMPLE: + +RCDATA NP_INFO_ProductVersion { 1,0,0,1,} + +RCDATA NP_INFO_MIMEType { "video/x-video|", + "video/x-flick\0" } +RCDATA NP_INFO_FileExtents { "avi|", + "flc\0" } +RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|", + "MMOS2 Flc/Fli player(*.flc)\0" } + +RCDATA NP_INFO_FileVersion { 1,0,0,1 } +RCDATA NP_INFO_CompanyName { "Netscape Communications\0" } +RCDATA NP_INFO_FileDescription { "NPAVI32 Extension DLL\0" +RCDATA NP_INFO_InternalName { "NPAVI32\0" ) +RCDATA NP_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0" +RCDATA NP_INFO_OriginalFilename { "NVAPI32.DLL" } +RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" } + +*/ + + +/* RC_DATA types for version info - required */ +#define NP_INFO_ProductVersion 1 +#define NP_INFO_MIMEType 2 +#define NP_INFO_FileOpenName 3 +#define NP_INFO_FileExtents 4 + +/* RC_DATA types for version info - used if found */ +#define NP_INFO_FileDescription 5 +#define NP_INFO_ProductName 6 + +/* RC_DATA types for version info - optional */ +#define NP_INFO_CompanyName 7 +#define NP_INFO_FileVersion 8 +#define NP_INFO_InternalName 9 +#define NP_INFO_LegalCopyright 10 +#define NP_INFO_OriginalFilename 11 + +#ifndef RC_INVOKED + + + +/*----------------------------------------------------------------------*/ +/* Definition of Basic Types */ +/*----------------------------------------------------------------------*/ + +#ifndef _UINT16 +typedef unsigned short uint16; +#endif + +#ifndef _UINT32 +# if defined(__alpha) || defined(__amd64__) || defined(__x86_64__) +typedef unsigned int uint32; +# else /* __alpha */ +typedef unsigned long uint32; +# endif /* __alpha */ +#endif + +/* + * AIX defines these in sys/inttypes.h included from sys/types.h + */ +#ifndef AIX +#ifndef _INT16 +typedef short int16; +#endif + +#ifndef _INT32 +# if defined(__alpha) || defined(__amd64__) || defined(__x86_64__) +typedef int int32; +# else /* __alpha */ +typedef long int32; +# endif /* __alpha */ +#endif +#endif + +#ifndef FALSE +#define FALSE (0) +#endif +#ifndef TRUE +#define TRUE (1) +#endif +#ifndef NULL +#define NULL (0L) +#endif + +#ifdef XP_MACOSX +typedef enum { +#ifndef NP_NO_QUICKDRAW + NPDrawingModelQuickDraw = 0, +#endif + NPDrawingModelCoreGraphics = 1 +} NPDrawingModel; +#endif + +typedef unsigned char NPBool; +typedef int16 NPError; +typedef int16 NPReason; +typedef char* NPMIMEType; + + + +/*----------------------------------------------------------------------*/ +/* Structures and definitions */ +/*----------------------------------------------------------------------*/ + +/* + * NPP is a plug-in's opaque instance handle + */ +typedef struct _NPP +{ + void* pdata; /* plug-in private data */ + void* ndata; /* netscape private data */ +} NPP_t; + +typedef NPP_t* NPP; + + +typedef struct _NPStream +{ + void* pdata; /* plug-in private data */ + void* ndata; /* netscape private data */ + const char* url; + uint32 end; + uint32 lastmodified; + void* notifyData; + const char* headers; /* Response headers from host. + * Exists only for >= NPVERS_HAS_RESPONSE_HEADERS. + * Used for HTTP only; NULL for non-HTTP. + * Available from NPP_NewStream onwards. + * Plugin should copy this data before storing it. + * Includes HTTP status line and all headers, + * preferably verbatim as received from server, + * headers formatted as in HTTP ("Header: Value"), + * and newlines (\n, NOT \r\n) separating lines. + * Terminated by \n\0 (NOT \n\n\0). */ +} NPStream; + + +typedef struct _NPByteRange +{ + int32 offset; /* negative offset means from the end */ + uint32 length; + struct _NPByteRange* next; +} NPByteRange; + + +typedef struct _NPSavedData +{ + int32 len; + void* buf; +} NPSavedData; + + +typedef struct _NPRect +{ + uint16 top; + uint16 left; + uint16 bottom; + uint16 right; +} NPRect; + +typedef struct _NPSize +{ + int32 width; + int32 height; +} NPSize; + +#ifdef XP_UNIX +/* + * Unix specific structures and definitions + */ + +/* + * Callback Structures. + * + * These are used to pass additional platform specific information. + */ +enum { + NP_SETWINDOW = 1, + NP_PRINT +}; + +typedef struct +{ + int32 type; +} NPAnyCallbackStruct; + +typedef struct +{ + int32 type; +#ifdef MOZ_X11 + Display* display; + Visual* visual; + Colormap colormap; + unsigned int depth; +#endif +} NPSetWindowCallbackStruct; + +typedef struct +{ + int32 type; + FILE* fp; +} NPPrintCallbackStruct; + +#endif /* XP_UNIX */ + + +/* + * The following masks are applied on certain platforms to NPNV and + * NPPV selectors that pass around pointers to COM interfaces. Newer + * compilers on some platforms may generate vtables that are not + * compatible with older compilers. To prevent older plugins from + * not understanding a new browser's ABI, these masks change the + * values of those selectors on those platforms. To remain backwards + * compatible with differenet versions of the browser, plugins can + * use these masks to dynamically determine and use the correct C++ + * ABI that the browser is expecting. This does not apply to Windows + * as Microsoft's COM ABI will likely not change. + */ + +#define NP_ABI_GCC3_MASK 0x10000000 +/* + * gcc 3.x generated vtables on UNIX and OSX are incompatible with + * previous compilers. + */ +#if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3)) +#define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK +#else +#define _NP_ABI_MIXIN_FOR_GCC3 0 +#endif + + +#define NP_ABI_MACHO_MASK 0x01000000 +/* + * On OSX, the Mach-O executable format is significantly + * different than CFM. In addition to having a different + * C++ ABI, it also has has different C calling convention. + * You must use glue code when calling between CFM and + * Mach-O C functions. + */ +#if (defined(TARGET_RT_MAC_MACHO)) +#define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK +#else +#define _NP_ABI_MIXIN_FOR_MACHO 0 +#endif + + +#define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO) + +/* + * List of variable names for which NPP_GetValue shall be implemented + */ +typedef enum { + NPPVpluginNameString = 1, + NPPVpluginDescriptionString, + NPPVpluginWindowBool, + NPPVpluginTransparentBool, + NPPVjavaClass, /* Not implemented in Mozilla 1.0 */ + NPPVpluginWindowSize, + NPPVpluginTimerInterval, + + NPPVpluginScriptableInstance = (10 | NP_ABI_MASK), + NPPVpluginScriptableIID = 11, + + /* Introduced in Mozilla 0.9.9 */ + NPPVjavascriptPushCallerBool = 12, + + /* Introduced in Mozilla 1.0 */ + NPPVpluginKeepLibraryInMemory = 13, + NPPVpluginNeedsXEmbed = 14, + + /* Get the NPObject for scripting the plugin. Introduced in Firefox + * 1.0 (NPAPI minor version 14). + */ + NPPVpluginScriptableNPObject = 15, + + /* Get the plugin value (as \0-terminated UTF-8 string data) for + * form submission if the plugin is part of a form. Use + * NPN_MemAlloc() to allocate memory for the string data. Introduced + * in Mozilla 1.8b2 (NPAPI minor version 15). + */ + NPPVformValue = 16 +#ifdef XP_MACOSX + /* Used for negotiating drawing models */ + , NPPVpluginDrawingModel = 1000 +#endif +} NPPVariable; + +/* + * List of variable names for which NPN_GetValue is implemented by Mozilla + */ +typedef enum { + NPNVxDisplay = 1, + NPNVxtAppContext, + NPNVnetscapeWindow, + NPNVjavascriptEnabledBool, + NPNVasdEnabledBool, + NPNVisOfflineBool, + + /* 10 and over are available on Mozilla builds starting with 0.9.4 */ + NPNVserviceManager = (10 | NP_ABI_MASK), + NPNVDOMElement = (11 | NP_ABI_MASK), /* available in Mozilla 1.2 */ + NPNVDOMWindow = (12 | NP_ABI_MASK), + NPNVToolkit = (13 | NP_ABI_MASK), + NPNVSupportsXEmbedBool = 14, + + /* Get the NPObject wrapper for the browser window. */ + NPNVWindowNPObject = 15, + + /* Get the NPObject wrapper for the plugins DOM element. */ + NPNVPluginElementNPObject = 16, + + NPNVSupportsWindowless = 17 + +#ifdef XP_MACOSX + /* Used for negotiating drawing models */ + , NPNVpluginDrawingModel = 1000 +#ifndef NP_NO_QUICKDRAW + , NPNVsupportsQuickDrawBool = 2000 +#endif + , NPNVsupportsCoreGraphicsBool = 2001 +#endif +} NPNVariable; + +/* + * The type of Tookkit the widgets use + */ +typedef enum { + NPNVGtk12 = 1, + NPNVGtk2 +} NPNToolkitType; + +/* + * The type of a NPWindow - it specifies the type of the data structure + * returned in the window field. + */ +typedef enum { + NPWindowTypeWindow = 1, + NPWindowTypeDrawable +} NPWindowType; + +typedef struct _NPWindow +{ + void* window; /* Platform specific window handle */ + /* OS/2: x - Position of bottom left corner */ + /* OS/2: y - relative to visible netscape window */ + int32 x; /* Position of top left corner relative */ + int32 y; /* to a netscape page. */ + uint32 width; /* Maximum window size */ + uint32 height; + NPRect clipRect; /* Clipping rectangle in port coordinates */ + /* Used by MAC only. */ +#if defined(XP_UNIX) && !defined(XP_MACOSX) + void * ws_info; /* Platform-dependent additonal data */ +#endif /* XP_UNIX */ + NPWindowType type; /* Is this a window or a drawable? */ +} NPWindow; + + +typedef struct _NPFullPrint +{ + NPBool pluginPrinted;/* Set TRUE if plugin handled fullscreen printing */ + NPBool printOne; /* TRUE if plugin should print one copy to default printer */ + void* platformPrint; /* Platform-specific printing info */ +} NPFullPrint; + +typedef struct _NPEmbedPrint +{ + NPWindow window; + void* platformPrint; /* Platform-specific printing info */ +} NPEmbedPrint; + +typedef struct _NPPrint +{ + uint16 mode; /* NP_FULL or NP_EMBED */ + union + { + NPFullPrint fullPrint; /* if mode is NP_FULL */ + NPEmbedPrint embedPrint; /* if mode is NP_EMBED */ + } print; +} NPPrint; + +#ifdef XP_MACOSX +typedef EventRecord NPEvent; +#elif defined(XP_WIN) +typedef struct _NPEvent +{ + uint16 event; + uint32 wParam; + uint32 lParam; +} NPEvent; +#elif defined(XP_OS2) +typedef struct _NPEvent +{ + uint32 event; + uint32 wParam; + uint32 lParam; +} NPEvent; +#elif defined (XP_UNIX) && defined(MOZ_X11) +typedef XEvent NPEvent; +#else +typedef void* NPEvent; +#endif /* XP_MACOSX */ + +#ifdef XP_MACOSX +typedef void* NPRegion; +#ifndef NP_NO_QUICKDRAW +typedef RgnHandle NPQDRegion; +#endif +typedef CGPathRef NPCGRegion; +#elif defined(XP_WIN) +typedef HRGN NPRegion; +#elif defined(XP_UNIX) && defined(MOZ_X11) +typedef Region NPRegion; +#else +typedef void *NPRegion; +#endif /* XP_MACOSX */ + +#ifdef XP_MACOSX +/* + * Mac-specific structures and definitions. + */ + +typedef struct NP_Port +{ + CGrafPtr port; /* Grafport */ + int32 portx; /* position inside the topmost window */ + int32 porty; +} NP_Port; + +typedef struct NP_CGContext +{ + CGContextRef context; + WindowRef window; +} NP_CGContext; + +/* + * Non-standard event types that can be passed to HandleEvent + */ + +enum NPEventType { + NPEventType_GetFocusEvent = (osEvt + 16), + NPEventType_LoseFocusEvent, + NPEventType_AdjustCursorEvent, + NPEventType_MenuCommandEvent, + NPEventType_ClippingChangedEvent, + NPEventType_ScrollingBeginsEvent = 1000, + NPEventType_ScrollingEndsEvent +}; + +#ifdef OBSOLETE +#define getFocusEvent (osEvt + 16) +#define loseFocusEvent (osEvt + 17) +#define adjustCursorEvent (osEvt + 18) +#endif +#endif /* XP_MACOSX */ + +/* + * Values for mode passed to NPP_New: + */ +#define NP_EMBED 1 +#define NP_FULL 2 + +/* + * Values for stream type passed to NPP_NewStream: + */ +#define NP_NORMAL 1 +#define NP_SEEK 2 +#define NP_ASFILE 3 +#define NP_ASFILEONLY 4 + +#define NP_MAXREADY (((unsigned)(~0)<<1)>>1) + + +/*----------------------------------------------------------------------*/ +/* Error and Reason Code definitions */ +/*----------------------------------------------------------------------*/ + +/* + * Values of type NPError: + */ +#define NPERR_BASE 0 +#define NPERR_NO_ERROR (NPERR_BASE + 0) +#define NPERR_GENERIC_ERROR (NPERR_BASE + 1) +#define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2) +#define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3) +#define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4) +#define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5) +#define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6) +#define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7) +#define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8) +#define NPERR_INVALID_PARAM (NPERR_BASE + 9) +#define NPERR_INVALID_URL (NPERR_BASE + 10) +#define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11) +#define NPERR_NO_DATA (NPERR_BASE + 12) +#define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13) + +/* + * Values of type NPReason: + */ +#define NPRES_BASE 0 +#define NPRES_DONE (NPRES_BASE + 0) +#define NPRES_NETWORK_ERR (NPRES_BASE + 1) +#define NPRES_USER_BREAK (NPRES_BASE + 2) + +/* + * Don't use these obsolete error codes any more. + */ +#define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR +#define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR +#define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK + +/* + * Version feature information + */ +#define NPVERS_HAS_STREAMOUTPUT 8 +#define NPVERS_HAS_NOTIFICATION 9 +#define NPVERS_HAS_LIVECONNECT 9 +#define NPVERS_WIN16_HAS_LIVECONNECT 9 +#define NPVERS_68K_HAS_LIVECONNECT 11 +#define NPVERS_HAS_WINDOWLESS 11 +#define NPVERS_HAS_XPCONNECT_SCRIPTING 13 +#define NPVERS_HAS_NPRUNTIME_SCRIPTING 14 +#define NPVERS_HAS_FORM_VALUES 15 +#define NPVERS_HAS_POPUPS_ENABLED_STATE 16 +#define NPVERS_HAS_RESPONSE_HEADERS 17 +#define NPVERS_HAS_NPOBJECT_ENUM 18 +#define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19 + +/*----------------------------------------------------------------------*/ +/* Function Prototypes */ +/*----------------------------------------------------------------------*/ + +#if defined(_WINDOWS) && !defined(WIN32) +#define NP_LOADDS _loadds +#else +#if defined(__OS2__) +#define NP_LOADDS _System +#else +#define NP_LOADDS +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * NPP_* functions are provided by the plugin and called by the navigator. + */ + +#ifdef XP_UNIX +char* NPP_GetMIMEDescription(void); +#endif /* XP_UNIX */ + +NPError NP_LOADDS NPP_Initialize(void); +void NP_LOADDS NPP_Shutdown(void); +NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance, + uint16 mode, int16 argc, char* argn[], + char* argv[], NPSavedData* saved); +NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save); +NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window); +NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type, + NPStream* stream, NPBool seekable, + uint16* stype); +NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream, + NPReason reason); +int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream); +int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset, + int32 len, void* buffer); +void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream, + const char* fname); +void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint); +int16 NP_LOADDS NPP_HandleEvent(NPP instance, void* event); +void NP_LOADDS NPP_URLNotify(NPP instance, const char* url, + NPReason reason, void* notifyData); +#ifdef OJI +jref NP_LOADDS NPP_GetJavaClass(void); +#endif +NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value); +NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value); + +/* + * NPN_* functions are provided by the navigator and called by the plugin. + */ +void NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor, + int* netscape_major, int* netscape_minor); +NPError NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url, + const char* target, void* notifyData); +NPError NP_LOADDS NPN_GetURL(NPP instance, const char* url, + const char* target); +NPError NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url, + const char* target, uint32 len, + const char* buf, NPBool file, + void* notifyData); +NPError NP_LOADDS NPN_PostURL(NPP instance, const char* url, + const char* target, uint32 len, + const char* buf, NPBool file); +NPError NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList); +NPError NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type, + const char* target, NPStream** stream); +int32 NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer); +NPError NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason); +void NP_LOADDS NPN_Status(NPP instance, const char* message); +const char* NP_LOADDS NPN_UserAgent(NPP instance); +void* NP_LOADDS NPN_MemAlloc(uint32 size); +void NP_LOADDS NPN_MemFree(void* ptr); +uint32 NP_LOADDS NPN_MemFlush(uint32 size); +void NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages); +#ifdef OJI +JRIEnv* NP_LOADDS NPN_GetJavaEnv(void); +jref NP_LOADDS NPN_GetJavaPeer(NPP instance); +#endif +NPError NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable, void *value); +NPError NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, void *value); +void NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect); +void NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion); +void NP_LOADDS NPN_ForceRedraw(NPP instance); +void NP_LOADDS NPN_PushPopupsEnabledState(NPP instance, NPBool enabled); +void NP_LOADDS NPN_PopPopupsEnabledState(NPP instance); +void NP_LOADDS NPN_PluginThreadAsyncCall(NPP instance, + void (*func) (void *), + void *userData); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif + +#endif /* RC_INVOKED */ +#ifdef __OS2__ +#pragma pack() +#endif + +#endif /* _NPAPI_H_ */ diff --git a/extras/browser plugins/wrapper/npapi/npruntime.h b/extras/browser plugins/wrapper/npapi/npruntime.h index 5a2dc75d1e..cd66ed85ab 100644 --- a/extras/browser plugins/wrapper/npapi/npruntime.h +++ b/extras/browser plugins/wrapper/npapi/npruntime.h @@ -1,423 +1,423 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright © 2004, Apple Computer, Inc. and The Mozilla Foundation. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla - * Foundation ("Mozilla") nor the names of their contributors may be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR - * THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Revision 1 (March 4, 2004): - * Initial proposal. - * - * Revision 2 (March 10, 2004): - * All calls into script were made asynchronous. Results are - * provided via the NPScriptResultFunctionPtr callback. - * - * Revision 3 (March 10, 2004): - * Corrected comments to not refer to class retain/release FunctionPtrs. - * - * Revision 4 (March 11, 2004): - * Added additional convenience NPN_SetExceptionWithUTF8(). - * Changed NPHasPropertyFunctionPtr and NPHasMethodFunctionPtr to take NPClass - * pointers instead of NPObject pointers. - * Added NPIsValidIdentifier(). - * - * Revision 5 (March 17, 2004): - * Added context parameter to result callbacks from ScriptObject functions. - * - * Revision 6 (March 29, 2004): - * Renamed functions implemented by user agent to NPN_*. Removed _ from - * type names. - * Renamed "JavaScript" types to "Script". - * - * Revision 7 (April 21, 2004): - * NPIdentifier becomes a void*, was int32_t - * Remove NP_IsValidIdentifier, renamed NP_IdentifierFromUTF8 to NP_GetIdentifier - * Added NPVariant and modified functions to use this new type. - * - * Revision 8 (July 9, 2004): - * Updated to joint Apple-Mozilla license. - * - */ -#ifndef _NP_RUNTIME_H_ -#define _NP_RUNTIME_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "nptypes.h" - -/* - This API is used to facilitate binding code written in C to script - objects. The API in this header does not assume the presence of a - user agent. That is, it can be used to bind C code to scripting - environments outside of the context of a user agent. - - However, the normal use of the this API is in the context of a - scripting environment running in a browser or other user agent. - In particular it is used to support the extended Netscape - script-ability API for plugins (NP-SAP). NP-SAP is an extension - of the Netscape plugin API. As such we have adopted the use of - the "NP" prefix for this API. - - The following NP{N|P}Variables were added to the Netscape plugin - API (in npapi.h): - - NPNVWindowNPObject - NPNVPluginElementNPObject - NPPVpluginScriptableNPObject - - These variables are exposed through NPN_GetValue() and - NPP_GetValue() (respectively) and are used to establish the - initial binding between the user agent and native code. The DOM - objects in the user agent can be examined and manipulated using - the NPN_ functions that operate on NPObjects described in this - header. - - To the extent possible the assumptions about the scripting - language used by the scripting environment have been minimized. -*/ - -#define NP_BEGIN_MACRO do { -#define NP_END_MACRO } while (0) - -/* - Objects (non-primitive data) passed between 'C' and script is - always wrapped in an NPObject. The 'interface' of an NPObject is - described by an NPClass. -*/ -typedef struct NPObject NPObject; -typedef struct NPClass NPClass; - -typedef char NPUTF8; -typedef struct _NPString { - const NPUTF8 *utf8characters; - uint32_t utf8length; -} NPString; - -typedef enum { - NPVariantType_Void, - NPVariantType_Null, - NPVariantType_Bool, - NPVariantType_Int32, - NPVariantType_Double, - NPVariantType_String, - NPVariantType_Object -} NPVariantType; - -typedef struct _NPVariant { - NPVariantType type; - union { - bool boolValue; - int32_t intValue; - double doubleValue; - NPString stringValue; - NPObject *objectValue; - } value; -} NPVariant; - -/* - NPN_ReleaseVariantValue is called on all 'out' parameters - references. Specifically it is to be called on variants that own - their value, as is the case with all non-const NPVariant* - arguments after a successful call to any methods (except this one) - in this API. - - After calling NPN_ReleaseVariantValue, the type of the variant - will be NPVariantType_Void. -*/ -void NPN_ReleaseVariantValue(NPVariant *variant); - -#define NPVARIANT_IS_VOID(_v) ((_v).type == NPVariantType_Void) -#define NPVARIANT_IS_NULL(_v) ((_v).type == NPVariantType_Null) -#define NPVARIANT_IS_BOOLEAN(_v) ((_v).type == NPVariantType_Bool) -#define NPVARIANT_IS_INT32(_v) ((_v).type == NPVariantType_Int32) -#define NPVARIANT_IS_DOUBLE(_v) ((_v).type == NPVariantType_Double) -#define NPVARIANT_IS_STRING(_v) ((_v).type == NPVariantType_String) -#define NPVARIANT_IS_OBJECT(_v) ((_v).type == NPVariantType_Object) - -#define NPVARIANT_TO_BOOLEAN(_v) ((_v).value.boolValue) -#define NPVARIANT_TO_INT32(_v) ((_v).value.intValue) -#define NPVARIANT_TO_DOUBLE(_v) ((_v).value.doubleValue) -#define NPVARIANT_TO_STRING(_v) ((_v).value.stringValue) -#define NPVARIANT_TO_OBJECT(_v) ((_v).value.objectValue) - -#define VOID_TO_NPVARIANT(_v) \ -NP_BEGIN_MACRO \ - (_v).type = NPVariantType_Void; \ - (_v).value.objectValue = NULL; \ -NP_END_MACRO - -#define NULL_TO_NPVARIANT(_v) \ -NP_BEGIN_MACRO \ - (_v).type = NPVariantType_Null; \ - (_v).value.objectValue = NULL; \ -NP_END_MACRO - -#define BOOLEAN_TO_NPVARIANT(_val, _v) \ -NP_BEGIN_MACRO \ - (_v).type = NPVariantType_Bool; \ - (_v).value.boolValue = !!(_val); \ -NP_END_MACRO - -#define INT32_TO_NPVARIANT(_val, _v) \ -NP_BEGIN_MACRO \ - (_v).type = NPVariantType_Int32; \ - (_v).value.intValue = _val; \ -NP_END_MACRO - -#define DOUBLE_TO_NPVARIANT(_val, _v) \ -NP_BEGIN_MACRO \ - (_v).type = NPVariantType_Double; \ - (_v).value.doubleValue = _val; \ -NP_END_MACRO - -#define STRINGZ_TO_NPVARIANT(_val, _v) \ -NP_BEGIN_MACRO \ - (_v).type = NPVariantType_String; \ - NPString str = { _val, strlen(_val) }; \ - (_v).value.stringValue = str; \ -NP_END_MACRO - -#define STRINGN_TO_NPVARIANT(_val, _len, _v) \ -NP_BEGIN_MACRO \ - (_v).type = NPVariantType_String; \ - NPString str = { _val, _len }; \ - (_v).value.stringValue = str; \ -NP_END_MACRO - -#define OBJECT_TO_NPVARIANT(_val, _v) \ -NP_BEGIN_MACRO \ - (_v).type = NPVariantType_Object; \ - (_v).value.objectValue = _val; \ -NP_END_MACRO - - -/* - Type mappings (JavaScript types have been used for illustration - purposes): - - JavaScript to C (NPVariant with type:) - undefined NPVariantType_Void - null NPVariantType_Null - Boolean NPVariantType_Bool - Number NPVariantType_Double or NPVariantType_Int32 - String NPVariantType_String - Object NPVariantType_Object - - C (NPVariant with type:) to JavaScript - NPVariantType_Void undefined - NPVariantType_Null null - NPVariantType_Bool Boolean - NPVariantType_Int32 Number - NPVariantType_Double Number - NPVariantType_String String - NPVariantType_Object Object -*/ - -typedef void *NPIdentifier; - -/* - NPObjects have methods and properties. Methods and properties are - identified with NPIdentifiers. These identifiers may be reflected - in script. NPIdentifiers can be either strings or integers, IOW, - methods and properties can be identified by either strings or - integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be - compared using ==. In case of any errors, the requested - NPIdentifier(s) will be NULL. -*/ -NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name); -void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, - NPIdentifier *identifiers); -NPIdentifier NPN_GetIntIdentifier(int32_t intid); -bool NPN_IdentifierIsString(NPIdentifier identifier); - -/* - The NPUTF8 returned from NPN_UTF8FromIdentifier SHOULD be freed. -*/ -NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier); - -/* - Get the integer represented by identifier. If identifier is not an - integer identifier, the behaviour is undefined. -*/ -int32_t NPN_IntFromIdentifier(NPIdentifier identifier); - -/* - NPObject behavior is implemented using the following set of - callback functions. - - The NPVariant *result argument of these functions (where - applicable) should be released using NPN_ReleaseVariantValue(). -*/ -typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass); -typedef void (*NPDeallocateFunctionPtr)(NPObject *npobj); -typedef void (*NPInvalidateFunctionPtr)(NPObject *npobj); -typedef bool (*NPHasMethodFunctionPtr)(NPObject *npobj, NPIdentifier name); -typedef bool (*NPInvokeFunctionPtr)(NPObject *npobj, NPIdentifier name, - const NPVariant *args, uint32_t argCount, - NPVariant *result); -typedef bool (*NPInvokeDefaultFunctionPtr)(NPObject *npobj, - const NPVariant *args, - uint32_t argCount, - NPVariant *result); -typedef bool (*NPHasPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name); -typedef bool (*NPGetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name, - NPVariant *result); -typedef bool (*NPSetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name, - const NPVariant *value); -typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj, - NPIdentifier name); -typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value, - uint32_t *count); -typedef bool (*NPConstructFunctionPtr)(NPObject *npobj, - const NPVariant *args, - uint32_t argCount, - NPVariant *result); - -/* - NPObjects returned by create, retain, invoke, and getProperty pass - a reference count to the caller. That is, the callee adds a - reference count which passes to the caller. It is the caller's - responsibility to release the returned object. - - NPInvokeFunctionPtr function may return 0 to indicate a void - result. - - NPInvalidateFunctionPtr is called by the scripting environment - when the native code is shutdown. Any attempt to message a - NPObject instance after the invalidate callback has been - called will result in undefined behavior, even if the native code - is still retaining those NPObject instances. (The runtime - will typically return immediately, with 0 or NULL, from an attempt - to dispatch to a NPObject, but this behavior should not be - depended upon.) - - The NPEnumerationFunctionPtr function may pass an array of - NPIdentifiers back to the caller. The callee allocs the memory of - the array using NPN_MemAlloc(), and it's the caller's responsibility - to release it using NPN_MemFree(). -*/ -struct NPClass -{ - uint32_t structVersion; - NPAllocateFunctionPtr allocate; - NPDeallocateFunctionPtr deallocate; - NPInvalidateFunctionPtr invalidate; - NPHasMethodFunctionPtr hasMethod; - NPInvokeFunctionPtr invoke; - NPInvokeDefaultFunctionPtr invokeDefault; - NPHasPropertyFunctionPtr hasProperty; - NPGetPropertyFunctionPtr getProperty; - NPSetPropertyFunctionPtr setProperty; - NPRemovePropertyFunctionPtr removeProperty; - NPEnumerationFunctionPtr enumerate; - NPConstructFunctionPtr construct; -}; - -#define NP_CLASS_STRUCT_VERSION 3 - -#define NP_CLASS_STRUCT_VERSION_ENUM 2 -#define NP_CLASS_STRUCT_VERSION_CTOR 3 - -#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass) \ - ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM) - -#define NP_CLASS_STRUCT_VERSION_HAS_CTOR(npclass) \ - ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_CTOR) - -struct NPObject { - NPClass *_class; - uint32_t referenceCount; - /* - * Additional space may be allocated here by types of NPObjects - */ -}; - -/* - If the class has an allocate function, NPN_CreateObject invokes - that function, otherwise a NPObject is allocated and - returned. This method will initialize the referenceCount member of - the NPObject to 1. -*/ -NPObject *NPN_CreateObject(NPP npp, NPClass *aClass); - -/* - Increment the NPObject's reference count. -*/ -NPObject *NPN_RetainObject(NPObject *npobj); - -/* - Decremented the NPObject's reference count. If the reference - count goes to zero, the class's destroy function is invoke if - specified, otherwise the object is freed directly. -*/ -void NPN_ReleaseObject(NPObject *npobj); - -/* - Functions to access script objects represented by NPObject. - - Calls to script objects are synchronous. If a function returns a - value, it will be supplied via the result NPVariant - argument. Successful calls will return true, false will be - returned in case of an error. - - Calls made from plugin code to script must be made from the thread - on which the plugin was initialized. -*/ - -bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, - const NPVariant *args, uint32_t argCount, NPVariant *result); -bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, - uint32_t argCount, NPVariant *result); -bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, - NPVariant *result); -bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, - NPVariant *result); -bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, - const NPVariant *value); -bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); -bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); -bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName); -bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, - uint32_t *count); -bool NPN_Construct(NPP npp, NPObject *npobj, const NPVariant *args, - uint32_t argCount, NPVariant *result); - -/* - NPN_SetException may be called to trigger a script exception upon - return from entry points into NPObjects. Typical usage: - - NPN_SetException (npobj, message); -*/ -void NPN_SetException(NPObject *npobj, const NPUTF8 *message); - -#ifdef __cplusplus -} -#endif - -#endif +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright ) 2004, Apple Computer, Inc. and The Mozilla Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla + * Foundation ("Mozilla") nor the names of their contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR + * THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Revision 1 (March 4, 2004): + * Initial proposal. + * + * Revision 2 (March 10, 2004): + * All calls into script were made asynchronous. Results are + * provided via the NPScriptResultFunctionPtr callback. + * + * Revision 3 (March 10, 2004): + * Corrected comments to not refer to class retain/release FunctionPtrs. + * + * Revision 4 (March 11, 2004): + * Added additional convenience NPN_SetExceptionWithUTF8(). + * Changed NPHasPropertyFunctionPtr and NPHasMethodFunctionPtr to take NPClass + * pointers instead of NPObject pointers. + * Added NPIsValidIdentifier(). + * + * Revision 5 (March 17, 2004): + * Added context parameter to result callbacks from ScriptObject functions. + * + * Revision 6 (March 29, 2004): + * Renamed functions implemented by user agent to NPN_*. Removed _ from + * type names. + * Renamed "JavaScript" types to "Script". + * + * Revision 7 (April 21, 2004): + * NPIdentifier becomes a void*, was int32_t + * Remove NP_IsValidIdentifier, renamed NP_IdentifierFromUTF8 to NP_GetIdentifier + * Added NPVariant and modified functions to use this new type. + * + * Revision 8 (July 9, 2004): + * Updated to joint Apple-Mozilla license. + * + */ +#ifndef _NP_RUNTIME_H_ +#define _NP_RUNTIME_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "nptypes.h" + +/* + This API is used to facilitate binding code written in C to script + objects. The API in this header does not assume the presence of a + user agent. That is, it can be used to bind C code to scripting + environments outside of the context of a user agent. + + However, the normal use of the this API is in the context of a + scripting environment running in a browser or other user agent. + In particular it is used to support the extended Netscape + script-ability API for plugins (NP-SAP). NP-SAP is an extension + of the Netscape plugin API. As such we have adopted the use of + the "NP" prefix for this API. + + The following NP{N|P}Variables were added to the Netscape plugin + API (in npapi.h): + + NPNVWindowNPObject + NPNVPluginElementNPObject + NPPVpluginScriptableNPObject + + These variables are exposed through NPN_GetValue() and + NPP_GetValue() (respectively) and are used to establish the + initial binding between the user agent and native code. The DOM + objects in the user agent can be examined and manipulated using + the NPN_ functions that operate on NPObjects described in this + header. + + To the extent possible the assumptions about the scripting + language used by the scripting environment have been minimized. +*/ + +#define NP_BEGIN_MACRO do { +#define NP_END_MACRO } while (0) + +/* + Objects (non-primitive data) passed between 'C' and script is + always wrapped in an NPObject. The 'interface' of an NPObject is + described by an NPClass. +*/ +typedef struct NPObject NPObject; +typedef struct NPClass NPClass; + +typedef char NPUTF8; +typedef struct _NPString { + const NPUTF8 *utf8characters; + uint32_t utf8length; +} NPString; + +typedef enum { + NPVariantType_Void, + NPVariantType_Null, + NPVariantType_Bool, + NPVariantType_Int32, + NPVariantType_Double, + NPVariantType_String, + NPVariantType_Object +} NPVariantType; + +typedef struct _NPVariant { + NPVariantType type; + union { + bool boolValue; + int32_t intValue; + double doubleValue; + NPString stringValue; + NPObject *objectValue; + } value; +} NPVariant; + +/* + NPN_ReleaseVariantValue is called on all 'out' parameters + references. Specifically it is to be called on variants that own + their value, as is the case with all non-const NPVariant* + arguments after a successful call to any methods (except this one) + in this API. + + After calling NPN_ReleaseVariantValue, the type of the variant + will be NPVariantType_Void. +*/ +void NPN_ReleaseVariantValue(NPVariant *variant); + +#define NPVARIANT_IS_VOID(_v) ((_v).type == NPVariantType_Void) +#define NPVARIANT_IS_NULL(_v) ((_v).type == NPVariantType_Null) +#define NPVARIANT_IS_BOOLEAN(_v) ((_v).type == NPVariantType_Bool) +#define NPVARIANT_IS_INT32(_v) ((_v).type == NPVariantType_Int32) +#define NPVARIANT_IS_DOUBLE(_v) ((_v).type == NPVariantType_Double) +#define NPVARIANT_IS_STRING(_v) ((_v).type == NPVariantType_String) +#define NPVARIANT_IS_OBJECT(_v) ((_v).type == NPVariantType_Object) + +#define NPVARIANT_TO_BOOLEAN(_v) ((_v).value.boolValue) +#define NPVARIANT_TO_INT32(_v) ((_v).value.intValue) +#define NPVARIANT_TO_DOUBLE(_v) ((_v).value.doubleValue) +#define NPVARIANT_TO_STRING(_v) ((_v).value.stringValue) +#define NPVARIANT_TO_OBJECT(_v) ((_v).value.objectValue) + +#define VOID_TO_NPVARIANT(_v) \ +NP_BEGIN_MACRO \ + (_v).type = NPVariantType_Void; \ + (_v).value.objectValue = NULL; \ +NP_END_MACRO + +#define NULL_TO_NPVARIANT(_v) \ +NP_BEGIN_MACRO \ + (_v).type = NPVariantType_Null; \ + (_v).value.objectValue = NULL; \ +NP_END_MACRO + +#define BOOLEAN_TO_NPVARIANT(_val, _v) \ +NP_BEGIN_MACRO \ + (_v).type = NPVariantType_Bool; \ + (_v).value.boolValue = !!(_val); \ +NP_END_MACRO + +#define INT32_TO_NPVARIANT(_val, _v) \ +NP_BEGIN_MACRO \ + (_v).type = NPVariantType_Int32; \ + (_v).value.intValue = _val; \ +NP_END_MACRO + +#define DOUBLE_TO_NPVARIANT(_val, _v) \ +NP_BEGIN_MACRO \ + (_v).type = NPVariantType_Double; \ + (_v).value.doubleValue = _val; \ +NP_END_MACRO + +#define STRINGZ_TO_NPVARIANT(_val, _v) \ +NP_BEGIN_MACRO \ + (_v).type = NPVariantType_String; \ + NPString str = { _val, strlen(_val) }; \ + (_v).value.stringValue = str; \ +NP_END_MACRO + +#define STRINGN_TO_NPVARIANT(_val, _len, _v) \ +NP_BEGIN_MACRO \ + (_v).type = NPVariantType_String; \ + NPString str = { _val, _len }; \ + (_v).value.stringValue = str; \ +NP_END_MACRO + +#define OBJECT_TO_NPVARIANT(_val, _v) \ +NP_BEGIN_MACRO \ + (_v).type = NPVariantType_Object; \ + (_v).value.objectValue = _val; \ +NP_END_MACRO + + +/* + Type mappings (JavaScript types have been used for illustration + purposes): + + JavaScript to C (NPVariant with type:) + undefined NPVariantType_Void + null NPVariantType_Null + Boolean NPVariantType_Bool + Number NPVariantType_Double or NPVariantType_Int32 + String NPVariantType_String + Object NPVariantType_Object + + C (NPVariant with type:) to JavaScript + NPVariantType_Void undefined + NPVariantType_Null null + NPVariantType_Bool Boolean + NPVariantType_Int32 Number + NPVariantType_Double Number + NPVariantType_String String + NPVariantType_Object Object +*/ + +typedef void *NPIdentifier; + +/* + NPObjects have methods and properties. Methods and properties are + identified with NPIdentifiers. These identifiers may be reflected + in script. NPIdentifiers can be either strings or integers, IOW, + methods and properties can be identified by either strings or + integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be + compared using ==. In case of any errors, the requested + NPIdentifier(s) will be NULL. +*/ +NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name); +void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, + NPIdentifier *identifiers); +NPIdentifier NPN_GetIntIdentifier(int32_t intid); +bool NPN_IdentifierIsString(NPIdentifier identifier); + +/* + The NPUTF8 returned from NPN_UTF8FromIdentifier SHOULD be freed. +*/ +NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier); + +/* + Get the integer represented by identifier. If identifier is not an + integer identifier, the behaviour is undefined. +*/ +int32_t NPN_IntFromIdentifier(NPIdentifier identifier); + +/* + NPObject behavior is implemented using the following set of + callback functions. + + The NPVariant *result argument of these functions (where + applicable) should be released using NPN_ReleaseVariantValue(). +*/ +typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass); +typedef void (*NPDeallocateFunctionPtr)(NPObject *npobj); +typedef void (*NPInvalidateFunctionPtr)(NPObject *npobj); +typedef bool (*NPHasMethodFunctionPtr)(NPObject *npobj, NPIdentifier name); +typedef bool (*NPInvokeFunctionPtr)(NPObject *npobj, NPIdentifier name, + const NPVariant *args, uint32_t argCount, + NPVariant *result); +typedef bool (*NPInvokeDefaultFunctionPtr)(NPObject *npobj, + const NPVariant *args, + uint32_t argCount, + NPVariant *result); +typedef bool (*NPHasPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name); +typedef bool (*NPGetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name, + NPVariant *result); +typedef bool (*NPSetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name, + const NPVariant *value); +typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj, + NPIdentifier name); +typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value, + uint32_t *count); +typedef bool (*NPConstructFunctionPtr)(NPObject *npobj, + const NPVariant *args, + uint32_t argCount, + NPVariant *result); + +/* + NPObjects returned by create, retain, invoke, and getProperty pass + a reference count to the caller. That is, the callee adds a + reference count which passes to the caller. It is the caller's + responsibility to release the returned object. + + NPInvokeFunctionPtr function may return 0 to indicate a void + result. + + NPInvalidateFunctionPtr is called by the scripting environment + when the native code is shutdown. Any attempt to message a + NPObject instance after the invalidate callback has been + called will result in undefined behavior, even if the native code + is still retaining those NPObject instances. (The runtime + will typically return immediately, with 0 or NULL, from an attempt + to dispatch to a NPObject, but this behavior should not be + depended upon.) + + The NPEnumerationFunctionPtr function may pass an array of + NPIdentifiers back to the caller. The callee allocs the memory of + the array using NPN_MemAlloc(), and it's the caller's responsibility + to release it using NPN_MemFree(). +*/ +struct NPClass +{ + uint32_t structVersion; + NPAllocateFunctionPtr allocate; + NPDeallocateFunctionPtr deallocate; + NPInvalidateFunctionPtr invalidate; + NPHasMethodFunctionPtr hasMethod; + NPInvokeFunctionPtr invoke; + NPInvokeDefaultFunctionPtr invokeDefault; + NPHasPropertyFunctionPtr hasProperty; + NPGetPropertyFunctionPtr getProperty; + NPSetPropertyFunctionPtr setProperty; + NPRemovePropertyFunctionPtr removeProperty; + NPEnumerationFunctionPtr enumerate; + NPConstructFunctionPtr construct; +}; + +#define NP_CLASS_STRUCT_VERSION 3 + +#define NP_CLASS_STRUCT_VERSION_ENUM 2 +#define NP_CLASS_STRUCT_VERSION_CTOR 3 + +#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass) \ + ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM) + +#define NP_CLASS_STRUCT_VERSION_HAS_CTOR(npclass) \ + ((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_CTOR) + +struct NPObject { + NPClass *_class; + uint32_t referenceCount; + /* + * Additional space may be allocated here by types of NPObjects + */ +}; + +/* + If the class has an allocate function, NPN_CreateObject invokes + that function, otherwise a NPObject is allocated and + returned. This method will initialize the referenceCount member of + the NPObject to 1. +*/ +NPObject *NPN_CreateObject(NPP npp, NPClass *aClass); + +/* + Increment the NPObject's reference count. +*/ +NPObject *NPN_RetainObject(NPObject *npobj); + +/* + Decremented the NPObject's reference count. If the reference + count goes to zero, the class's destroy function is invoke if + specified, otherwise the object is freed directly. +*/ +void NPN_ReleaseObject(NPObject *npobj); + +/* + Functions to access script objects represented by NPObject. + + Calls to script objects are synchronous. If a function returns a + value, it will be supplied via the result NPVariant + argument. Successful calls will return true, false will be + returned in case of an error. + + Calls made from plugin code to script must be made from the thread + on which the plugin was initialized. +*/ + +bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName, + const NPVariant *args, uint32_t argCount, NPVariant *result); +bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args, + uint32_t argCount, NPVariant *result); +bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, + NPVariant *result); +bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, + NPVariant *result); +bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, + const NPVariant *value); +bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); +bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName); +bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName); +bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier, + uint32_t *count); +bool NPN_Construct(NPP npp, NPObject *npobj, const NPVariant *args, + uint32_t argCount, NPVariant *result); + +/* + NPN_SetException may be called to trigger a script exception upon + return from entry points into NPObjects. Typical usage: + + NPN_SetException (npobj, message); +*/ +void NPN_SetException(NPObject *npobj, const NPUTF8 *message); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/extras/browser plugins/wrapper/npapi/nptypes.h b/extras/browser plugins/wrapper/npapi/nptypes.h index 6f6e3fbf4d..ea20080627 100644 --- a/extras/browser plugins/wrapper/npapi/nptypes.h +++ b/extras/browser plugins/wrapper/npapi/nptypes.h @@ -1,105 +1,105 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * mozilla.org. - * Portions created by the Initial Developer are Copyright (C) 2004 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Johnny Stenback (Original author) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Header file for ensuring that C99 types ([u]int32_t and bool) are - * available. - */ - -#if defined(WIN32) || defined(OS2) - /* - * Win32 and OS/2 don't know C99, so define [u]int_32 here. The bool - * is predefined tho, both in C and C++. - */ - typedef int int32_t; - typedef unsigned int uint32_t; -#elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX) - /* - * AIX and SunOS ship a inttypes.h header that defines [u]int32_t, - * but not bool for C. - */ - #include - - #ifndef __cplusplus - typedef int bool; - #endif -#elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD) - /* - * BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and - * u_int32_t. - */ - #include - - /* - * BSD/OS ships no header that defines uint32_t, nor bool (for C) - */ - #if defined(bsdi) - typedef u_int32_t uint32_t; - - #if !defined(__cplusplus) - typedef int bool; - #endif - #else - /* - * FreeBSD and OpenBSD define uint32_t and bool. - */ - #include - #include - #endif -#elif defined(BEOS) - #include -#else - /* - * For those that ship a standard C99 stdint.h header file, include - * it. Can't do the same for stdbool.h tho, since some systems ship - * with a stdbool.h file that doesn't compile! - */ - #include - - #ifndef __cplusplus - #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95) - #include - #else - /* - * GCC 2.91 can't deal with a typedef for bool, but a #define - * works. - */ - #define bool int - #endif - #endif -#endif +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * mozilla.org. + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Johnny Stenback (Original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Header file for ensuring that C99 types ([u]int32_t and bool) are + * available. + */ + +#if defined(WIN32) || defined(OS2) + /* + * Win32 and OS/2 don't know C99, so define [u]int_32 here. The bool + * is predefined tho, both in C and C++. + */ + typedef int int32_t; + typedef unsigned int uint32_t; +#elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX) + /* + * AIX and SunOS ship a inttypes.h header that defines [u]int32_t, + * but not bool for C. + */ + #include + + #ifndef __cplusplus + typedef int bool; + #endif +#elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD) + /* + * BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and + * u_int32_t. + */ + #include + + /* + * BSD/OS ships no header that defines uint32_t, nor bool (for C) + */ + #if defined(bsdi) + typedef u_int32_t uint32_t; + + #if !defined(__cplusplus) + typedef int bool; + #endif + #else + /* + * FreeBSD and OpenBSD define uint32_t and bool. + */ + #include + #include + #endif +#elif defined(BEOS) + #include +#else + /* + * For those that ship a standard C99 stdint.h header file, include + * it. Can't do the same for stdbool.h tho, since some systems ship + * with a stdbool.h file that doesn't compile! + */ + #include + + #ifndef __cplusplus + #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95) + #include + #else + /* + * GCC 2.91 can't deal with a typedef for bool, but a #define + * works. + */ + #define bool int + #endif + #endif +#endif diff --git a/extras/browser plugins/wrapper/npapi/npupp.h b/extras/browser plugins/wrapper/npapi/npupp.h index f3e229fca9..59dd942ddf 100644 --- a/extras/browser plugins/wrapper/npapi/npupp.h +++ b/extras/browser plugins/wrapper/npapi/npupp.h @@ -1,715 +1,715 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - - -/* - * npupp.h $Revision: 3.26 $ - * function call mecahnics needed by platform specific glue code. - */ - - -#ifndef _NPUPP_H_ -#define _NPUPP_H_ - -#if defined(__OS2__) -#pragma pack(1) -#endif - -#ifndef GENERATINGCFM -#define GENERATINGCFM 0 -#endif - -#ifndef _NPAPI_H_ -#include "npapi.h" -#endif - -#include "npruntime.h" - -#include "jri.h" - - -/****************************************************************************************** - plug-in function table macros - for each function in and out of the plugin API we define - typedef NPP_FooUPP - #define NewNPP_FooProc - #define CallNPP_FooProc - *******************************************************************************************/ - - -/* NPP_Initialize */ -typedef void (* NP_LOADDS NPP_InitializeUPP)(void); -#define NewNPP_InitializeProc(FUNC) \ - ((NPP_InitializeUPP) (FUNC)) -#define CallNPP_InitializeProc(FUNC) \ - (*(FUNC))() - -/* NPP_Shutdown */ -typedef void (* NP_LOADDS NPP_ShutdownUPP)(void); -#define NewNPP_ShutdownProc(FUNC) \ - ((NPP_ShutdownUPP) (FUNC)) -#define CallNPP_ShutdownProc(FUNC) \ - (*(FUNC))() - -/* NPP_New */ -typedef NPError (* NP_LOADDS NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved); -#define NewNPP_NewProc(FUNC) \ - ((NPP_NewUPP) (FUNC)) -#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7)) - -/* NPP_Destroy */ -typedef NPError (* NP_LOADDS NPP_DestroyUPP)(NPP instance, NPSavedData** save); -#define NewNPP_DestroyProc(FUNC) \ - ((NPP_DestroyUPP) (FUNC)) -#define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \ - (*(FUNC))((ARG1), (ARG2)) - -/* NPP_SetWindow */ -typedef NPError (* NP_LOADDS NPP_SetWindowUPP)(NPP instance, NPWindow* window); -#define NewNPP_SetWindowProc(FUNC) \ - ((NPP_SetWindowUPP) (FUNC)) -#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \ - (*(FUNC))((ARG1), (ARG2)) - -/* NPP_NewStream */ -typedef NPError (* NP_LOADDS NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype); -#define NewNPP_NewStreamProc(FUNC) \ - ((NPP_NewStreamUPP) (FUNC)) -#define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5)) - -/* NPP_DestroyStream */ -typedef NPError (* NP_LOADDS NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason); -#define NewNPP_DestroyStreamProc(FUNC) \ - ((NPP_DestroyStreamUPP) (FUNC)) -#define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPReasonArg) \ - (*(FUNC))((NPParg), (NPStreamPtr), (NPReasonArg)) - -/* NPP_WriteReady */ -typedef int32 (* NP_LOADDS NPP_WriteReadyUPP)(NPP instance, NPStream* stream); -#define NewNPP_WriteReadyProc(FUNC) \ - ((NPP_WriteReadyUPP) (FUNC)) -#define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \ - (*(FUNC))((NPParg), (NPStreamPtr)) - -/* NPP_Write */ -typedef int32 (* NP_LOADDS NPP_WriteUPP)(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer); -#define NewNPP_WriteProc(FUNC) \ - ((NPP_WriteUPP) (FUNC)) -#define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \ - (*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr)) - -/* NPP_StreamAsFile */ -typedef void (* NP_LOADDS NPP_StreamAsFileUPP)(NPP instance, NPStream* stream, const char* fname); -#define NewNPP_StreamAsFileProc(FUNC) \ - ((NPP_StreamAsFileUPP) (FUNC)) -#define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPP_Print */ -typedef void (* NP_LOADDS NPP_PrintUPP)(NPP instance, NPPrint* platformPrint); -#define NewNPP_PrintProc(FUNC) \ - ((NPP_PrintUPP) (FUNC)) -#define CallNPP_PrintProc(FUNC, NPParg, NPPrintArg) \ - (*(FUNC))((NPParg), (NPPrintArg)) - -/* NPP_HandleEvent */ -typedef int16 (* NP_LOADDS NPP_HandleEventUPP)(NPP instance, void* event); -#define NewNPP_HandleEventProc(FUNC) \ - ((NPP_HandleEventUPP) (FUNC)) -#define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \ - (*(FUNC))((NPParg), (voidPtr)) - -/* NPP_URLNotify */ -typedef void (* NP_LOADDS NPP_URLNotifyUPP)(NPP instance, const char* url, NPReason reason, void* notifyData); -#define NewNPP_URLNotifyProc(FUNC) \ - ((NPP_URLNotifyUPP) (FUNC)) -#define CallNPP_URLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) - -/* NPP_GetValue */ -typedef NPError (* NP_LOADDS NPP_GetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue); -#define NewNPP_GetValueProc(FUNC) \ - ((NPP_GetValueUPP) (FUNC)) -#define CallNPP_GetValueProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPP_SetValue */ -typedef NPError (* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue); -#define NewNPP_SetValueProc(FUNC) \ - ((NPP_SetValueUPP) (FUNC)) -#define CallNPP_SetValueProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* - * Netscape entry points - */ - - -/* NPN_GetValue */ -typedef NPError (* NP_LOADDS NPN_GetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue); -#define NewNPN_GetValueProc(FUNC) \ - ((NPN_GetValueUPP) (FUNC)) -#define CallNPN_GetValueProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPN_SetValue */ -typedef NPError (* NP_LOADDS NPN_SetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue); -#define NewNPN_SetValueProc(FUNC) \ - ((NPN_SetValueUPP) (FUNC)) -#define CallNPN_SetValueProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPN_GetUrlNotify */ -typedef NPError (* NP_LOADDS NPN_GetURLNotifyUPP)(NPP instance, const char* url, const char* window, void* notifyData); -#define NewNPN_GetURLNotifyProc(FUNC) \ - ((NPN_GetURLNotifyUPP) (FUNC)) -#define CallNPN_GetURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) - -/* NPN_PostUrlNotify */ -typedef NPError (* NP_LOADDS NPN_PostURLNotifyUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData); -#define NewNPN_PostURLNotifyProc(FUNC) \ - ((NPN_PostURLNotifyUPP) (FUNC)) -#define CallNPN_PostURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7)) - -/* NPN_GetUrl */ -typedef NPError (* NP_LOADDS NPN_GetURLUPP)(NPP instance, const char* url, const char* window); -#define NewNPN_GetURLProc(FUNC) \ - ((NPN_GetURLUPP) (FUNC)) -#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPN_PostUrl */ -typedef NPError (* NP_LOADDS NPN_PostURLUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file); -#define NewNPN_PostURLProc(FUNC) \ - ((NPN_PostURLUPP) (FUNC)) -#define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6)) - -/* NPN_RequestRead */ -typedef NPError (* NP_LOADDS NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList); -#define NewNPN_RequestReadProc(FUNC) \ - ((NPN_RequestReadUPP) (FUNC)) -#define CallNPN_RequestReadProc(FUNC, stream, range) \ - (*(FUNC))((stream), (range)) - -/* NPN_NewStream */ -typedef NPError (* NP_LOADDS NPN_NewStreamUPP)(NPP instance, NPMIMEType type, const char* window, NPStream** stream); -#define NewNPN_NewStreamProc(FUNC) \ - ((NPN_NewStreamUPP) (FUNC)) -#define CallNPN_NewStreamProc(FUNC, npp, type, window, stream) \ - (*(FUNC))((npp), (type), (window), (stream)) - -/* NPN_Write */ -typedef int32 (* NP_LOADDS NPN_WriteUPP)(NPP instance, NPStream* stream, int32 len, void* buffer); -#define NewNPN_WriteProc(FUNC) \ - ((NPN_WriteUPP) (FUNC)) -#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \ - (*(FUNC))((npp), (stream), (len), (buffer)) - -/* NPN_DestroyStream */ -typedef NPError (* NP_LOADDS NPN_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason); -#define NewNPN_DestroyStreamProc(FUNC) \ - ((NPN_DestroyStreamUPP) (FUNC)) -#define CallNPN_DestroyStreamProc(FUNC, npp, stream, reason) \ - (*(FUNC))((npp), (stream), (reason)) - -/* NPN_Status */ -typedef void (* NP_LOADDS NPN_StatusUPP)(NPP instance, const char* message); -#define NewNPN_StatusProc(FUNC) \ - ((NPN_StatusUPP) (FUNC)) -#define CallNPN_StatusProc(FUNC, npp, msg) \ - (*(FUNC))((npp), (msg)) - -/* NPN_UserAgent */ -typedef const char* (* NP_LOADDS NPN_UserAgentUPP)(NPP instance); -#define NewNPN_UserAgentProc(FUNC) \ - ((NPN_UserAgentUPP) (FUNC)) -#define CallNPN_UserAgentProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_MemAlloc */ -typedef void* (* NP_LOADDS NPN_MemAllocUPP)(uint32 size); -#define NewNPN_MemAllocProc(FUNC) \ - ((NPN_MemAllocUPP) (FUNC)) -#define CallNPN_MemAllocProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN__MemFree */ -typedef void (* NP_LOADDS NPN_MemFreeUPP)(void* ptr); -#define NewNPN_MemFreeProc(FUNC) \ - ((NPN_MemFreeUPP) (FUNC)) -#define CallNPN_MemFreeProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_MemFlush */ -typedef uint32 (* NP_LOADDS NPN_MemFlushUPP)(uint32 size); -#define NewNPN_MemFlushProc(FUNC) \ - ((NPN_MemFlushUPP) (FUNC)) -#define CallNPN_MemFlushProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_ReloadPlugins */ -typedef void (* NP_LOADDS NPN_ReloadPluginsUPP)(NPBool reloadPages); -#define NewNPN_ReloadPluginsProc(FUNC) \ - ((NPN_ReloadPluginsUPP) (FUNC)) -#define CallNPN_ReloadPluginsProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_GetJavaEnv */ -typedef JRIEnv* (* NP_LOADDS NPN_GetJavaEnvUPP)(void); -#define NewNPN_GetJavaEnvProc(FUNC) \ - ((NPN_GetJavaEnvUPP) (FUNC)) -#define CallNPN_GetJavaEnvProc(FUNC) \ - (*(FUNC))() - -/* NPN_GetJavaPeer */ -typedef jref (* NP_LOADDS NPN_GetJavaPeerUPP)(NPP instance); -#define NewNPN_GetJavaPeerProc(FUNC) \ - ((NPN_GetJavaPeerUPP) (FUNC)) -#define CallNPN_GetJavaPeerProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_InvalidateRect */ -typedef void (* NP_LOADDS NPN_InvalidateRectUPP)(NPP instance, NPRect *rect); -#define NewNPN_InvalidateRectProc(FUNC) \ - ((NPN_InvalidateRectUPP) (FUNC)) -#define CallNPN_InvalidateRectProc(FUNC, ARG1, ARG2) \ - (*(FUNC))((ARG1), (ARG2)) - -/* NPN_InvalidateRegion */ -typedef void (* NP_LOADDS NPN_InvalidateRegionUPP)(NPP instance, NPRegion region); -#define NewNPN_InvalidateRegionProc(FUNC) \ - ((NPN_InvalidateRegionUPP) (FUNC)) -#define CallNPN_InvalidateRegionProc(FUNC, ARG1, ARG2) \ - (*(FUNC))((ARG1), (ARG2)) - -/* NPN_ForceRedraw */ -typedef void (* NP_LOADDS NPN_ForceRedrawUPP)(NPP instance); -#define NewNPN_ForceRedrawProc(FUNC) \ - ((NPN_ForceRedrawUPP) (FUNC)) -#define CallNPN_ForceRedrawProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_GetStringIdentifier */ -typedef NPIdentifier (* NP_LOADDS NPN_GetStringIdentifierUPP)(const NPUTF8* name); -#define NewNPN_GetStringIdentifierProc(FUNC) \ - ((NPN_GetStringIdentifierUPP) (FUNC)) -#define CallNPN_GetStringIdentifierProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_GetStringIdentifiers */ -typedef void (* NP_LOADDS NPN_GetStringIdentifiersUPP)(const NPUTF8** names, - int32_t nameCount, - NPIdentifier* identifiers); -#define NewNPN_GetStringIdentifiersProc(FUNC) \ - ((NPN_GetStringIdentifiersUPP) (FUNC)) -#define CallNPN_GetStringIdentifiersProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPN_GetIntIdentifier */ -typedef NPIdentifier (* NP_LOADDS NPN_GetIntIdentifierUPP)(int32_t intid); -#define NewNPN_GetIntIdentifierProc(FUNC) \ - ((NPN_GetIntIdentifierUPP) (FUNC)) -#define CallNPN_GetIntIdentifierProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_IdentifierIsString */ -typedef bool (* NP_LOADDS NPN_IdentifierIsStringUPP)(NPIdentifier identifier); -#define NewNPN_IdentifierIsStringProc(FUNC) \ - ((NPN_IdentifierIsStringUPP) (FUNC)) -#define CallNPN_IdentifierIsStringProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_UTF8FromIdentifier */ -typedef NPUTF8* (* NP_LOADDS NPN_UTF8FromIdentifierUPP)(NPIdentifier identifier); -#define NewNPN_UTF8FromIdentifierProc(FUNC) \ - ((NPN_UTF8FromIdentifierUPP) (FUNC)) -#define CallNPN_UTF8FromIdentifierProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_IntFromIdentifier */ -typedef int32_t (* NP_LOADDS NPN_IntFromIdentifierUPP)(NPIdentifier identifier); -#define NewNPN_IntFromIdentifierProc(FUNC) \ - ((NPN_IntFromIdentifierUPP) (FUNC)) -#define CallNPN_IntFromIdentifierProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_CreateObject */ -typedef NPObject* (* NP_LOADDS NPN_CreateObjectUPP)(NPP npp, NPClass *aClass); -#define NewNPN_CreateObjectProc(FUNC) \ - ((NPN_CreateObjectUPP) (FUNC)) -#define CallNPN_CreateObjectProc(FUNC, ARG1, ARG2) \ - (*(FUNC))((ARG1), (ARG2)) - -/* NPN_RetainObject */ -typedef NPObject* (* NP_LOADDS NPN_RetainObjectUPP)(NPObject *obj); -#define NewNPN_RetainObjectProc(FUNC) \ - ((NPN_RetainObjectUPP) (FUNC)) -#define CallNPN_RetainObjectProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_ReleaseObject */ -typedef void (* NP_LOADDS NPN_ReleaseObjectUPP)(NPObject *obj); -#define NewNPN_ReleaseObjectProc(FUNC) \ - ((NPN_ReleaseObjectUPP) (FUNC)) -#define CallNPN_ReleaseObjectProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_Invoke */ -typedef bool (* NP_LOADDS NPN_InvokeUPP)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); -#define NewNPN_InvokeProc(FUNC) \ - ((NPN_InvokeUPP) (FUNC)) -#define CallNPN_InvokeProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6)) - -/* NPN_InvokeDefault */ -typedef bool (* NP_LOADDS NPN_InvokeDefaultUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); -#define NewNPN_InvokeDefaultProc(FUNC) \ - ((NPN_InvokeDefaultUPP) (FUNC)) -#define CallNPN_InvokeDefaultProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5)) - -/* NPN_Evaluate */ -typedef bool (* NP_LOADDS NPN_EvaluateUPP)(NPP npp, NPObject *obj, NPString *script, NPVariant *result); -#define NewNPN_EvaluateProc(FUNC) \ - ((NPN_EvaluateUPP) (FUNC)) -#define CallNPN_EvaluateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) - -/* NPN_GetProperty */ -typedef bool (* NP_LOADDS NPN_GetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result); -#define NewNPN_GetPropertyProc(FUNC) \ - ((NPN_GetPropertyUPP) (FUNC)) -#define CallNPN_GetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) - -/* NPN_SetProperty */ -typedef bool (* NP_LOADDS NPN_SetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value); -#define NewNPN_SetPropertyProc(FUNC) \ - ((NPN_SetPropertyUPP) (FUNC)) -#define CallNPN_SetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) - -/* NPN_RemoveProperty */ -typedef bool (* NP_LOADDS NPN_RemovePropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName); -#define NewNPN_RemovePropertyProc(FUNC) \ - ((NPN_RemovePropertyUPP) (FUNC)) -#define CallNPN_RemovePropertyProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPN_HasProperty */ -typedef bool (* NP_LOADDS NPN_HasPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName); -#define NewNPN_HasPropertyProc(FUNC) \ - ((NPN_HasPropertyUPP) (FUNC)) -#define CallNPN_HasPropertyProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPN_HasMethod */ -typedef bool (* NP_LOADDS NPN_HasMethodUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName); -#define NewNPN_HasMethodProc(FUNC) \ - ((NPN_HasMethodUPP) (FUNC)) -#define CallNPN_HasMethodProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPN_ReleaseVariantValue */ -typedef void (* NP_LOADDS NPN_ReleaseVariantValueUPP)(NPVariant *variant); -#define NewNPN_ReleaseVariantValueProc(FUNC) \ - ((NPN_ReleaseVariantValueUPP) (FUNC)) -#define CallNPN_ReleaseVariantValueProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_SetException */ -typedef void (* NP_LOADDS NPN_SetExceptionUPP)(NPObject *obj, const NPUTF8 *message); -#define NewNPN_SetExceptionProc(FUNC) \ - ((NPN_SetExceptionUPP) (FUNC)) -#define CallNPN_SetExceptionProc(FUNC, ARG1, ARG2) \ - (*(FUNC))((ARG1), (ARG2)) - -/* NPN_PushPopupsEnabledStateUPP */ -typedef bool (* NP_LOADDS NPN_PushPopupsEnabledStateUPP)(NPP npp, NPBool enabled); -#define NewNPN_PushPopupsEnabledStateProc(FUNC) \ - ((NPN_PushPopupsEnabledStateUPP) (FUNC)) -#define CallNPN_PushPopupsEnabledStateProc(FUNC, ARG1, ARG2) \ - (*(FUNC))((ARG1), (ARG2)) - -/* NPN_PopPopupsEnabledState */ -typedef bool (* NP_LOADDS NPN_PopPopupsEnabledStateUPP)(NPP npp); -#define NewNPN_PopPopupsEnabledStateProc(FUNC) \ - ((NPN_PopPopupsEnabledStateUPP) (FUNC)) -#define CallNPN_PopPopupsEnabledStateProc(FUNC, ARG1) \ - (*(FUNC))((ARG1)) - -/* NPN_Enumerate */ -typedef bool (* NP_LOADDS NPN_EnumerateUPP)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count); -#define NewNPN_EnumerateProc(FUNC) \ - ((NPN_EnumerateUPP) (FUNC)) -#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) - -/* NPN_PluginThreadAsyncCall */ -typedef void (* NP_LOADDS NPN_PluginThreadAsyncCallUPP)(NPP instance, void (*func)(void *), void *userData); -#define NewNPN_PluginThreadAsyncCallProc(FUNC) \ - ((NPN_PluginThreadAsyncCallUPP) (FUNC)) -#define CallNPN_PluginThreadAsyncCallProc(FUNC, ARG1, ARG2, ARG3) \ - (*(FUNC))((ARG1), (ARG2), (ARG3)) - -/* NPN_Construct */ -typedef bool (* NP_LOADDS NPN_ConstructUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); -#define NewNPN_ConstructProc(FUNC) \ - ((NPN_ConstructUPP) (FUNC)) -#define CallNPN_ConstructProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \ - (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5)) - - - -/****************************************************************************************** - * The actual plugin function table definitions - *******************************************************************************************/ - -typedef struct _NPPluginFuncs { - uint16 size; - uint16 version; - NPP_NewUPP newp; - NPP_DestroyUPP destroy; - NPP_SetWindowUPP setwindow; - NPP_NewStreamUPP newstream; - NPP_DestroyStreamUPP destroystream; - NPP_StreamAsFileUPP asfile; - NPP_WriteReadyUPP writeready; - NPP_WriteUPP write; - NPP_PrintUPP print; - NPP_HandleEventUPP event; - NPP_URLNotifyUPP urlnotify; - JRIGlobalRef javaClass; - NPP_GetValueUPP getvalue; - NPP_SetValueUPP setvalue; -} NPPluginFuncs; - -typedef struct _NPNetscapeFuncs { - uint16 size; - uint16 version; - NPN_GetURLUPP geturl; - NPN_PostURLUPP posturl; - NPN_RequestReadUPP requestread; - NPN_NewStreamUPP newstream; - NPN_WriteUPP write; - NPN_DestroyStreamUPP destroystream; - NPN_StatusUPP status; - NPN_UserAgentUPP uagent; - NPN_MemAllocUPP memalloc; - NPN_MemFreeUPP memfree; - NPN_MemFlushUPP memflush; - NPN_ReloadPluginsUPP reloadplugins; - NPN_GetJavaEnvUPP getJavaEnv; - NPN_GetJavaPeerUPP getJavaPeer; - NPN_GetURLNotifyUPP geturlnotify; - NPN_PostURLNotifyUPP posturlnotify; - NPN_GetValueUPP getvalue; - NPN_SetValueUPP setvalue; - NPN_InvalidateRectUPP invalidaterect; - NPN_InvalidateRegionUPP invalidateregion; - NPN_ForceRedrawUPP forceredraw; - NPN_GetStringIdentifierUPP getstringidentifier; - NPN_GetStringIdentifiersUPP getstringidentifiers; - NPN_GetIntIdentifierUPP getintidentifier; - NPN_IdentifierIsStringUPP identifierisstring; - NPN_UTF8FromIdentifierUPP utf8fromidentifier; - NPN_IntFromIdentifierUPP intfromidentifier; - NPN_CreateObjectUPP createobject; - NPN_RetainObjectUPP retainobject; - NPN_ReleaseObjectUPP releaseobject; - NPN_InvokeUPP invoke; - NPN_InvokeDefaultUPP invokeDefault; - NPN_EvaluateUPP evaluate; - NPN_GetPropertyUPP getproperty; - NPN_SetPropertyUPP setproperty; - NPN_RemovePropertyUPP removeproperty; - NPN_HasPropertyUPP hasproperty; - NPN_HasMethodUPP hasmethod; - NPN_ReleaseVariantValueUPP releasevariantvalue; - NPN_SetExceptionUPP setexception; - NPN_PushPopupsEnabledStateUPP pushpopupsenabledstate; - NPN_PopPopupsEnabledStateUPP poppopupsenabledstate; - NPN_EnumerateUPP enumerate; - NPN_PluginThreadAsyncCallUPP pluginthreadasynccall; - NPN_ConstructUPP construct; -} NPNetscapeFuncs; - - -#ifdef XP_MACOSX -/****************************************************************************************** - * Mac platform-specific plugin glue stuff - *******************************************************************************************/ - -/* - * Main entry point of the plugin. - * This routine will be called when the plugin is loaded. The function - * tables are passed in and the plugin fills in the NPPluginFuncs table - * and NPPShutdownUPP for Netscape's use. - */ -typedef NPError (* NP_LOADDS NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownUPP*); -#define NewNPP_MainEntryProc(FUNC) \ - ((NPP_MainEntryUPP) (FUNC)) -#define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \ - (*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP)) - -/* - * Mac OS X version(s) of NP_GetMIMEDescription(const char *) - * These can be called to retreive MIME information from the plugin dynamically - * - * Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way - * to get mime info from the plugin only on OSX and may not be supported - * in furture version -- use NP_GetMIMEDescription instead - */ - -enum -{ - kBPSupportedMIMETypesStructVers_1 = 1 -}; - -typedef struct _BPSupportedMIMETypes -{ - SInt32 structVersion; /* struct version */ - Handle typeStrings; /* STR# formated handle, allocated by plug-in */ - Handle infoStrings; /* STR# formated handle, allocated by plug-in */ -} BPSupportedMIMETypes; -OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags); - - /* NP_GetMIMEDescription */ -#define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription" -typedef const char* (* NP_LOADDS NP_GetMIMEDescriptionUPP)(); -#define NewNP_GetMIMEDescEntryProc(FUNC) \ - ((NP_GetMIMEDescriptionUPP) (FUNC)) -#define CallNP_GetMIMEDescEntryProc(FUNC) \ - (*(FUNC))() - -/* BP_GetSupportedMIMETypes */ -typedef OSErr (* NP_LOADDS BP_GetSupportedMIMETypesUPP)(BPSupportedMIMETypes*, UInt32); -#define NewBP_GetSupportedMIMETypesEntryProc(FUNC) \ - ((BP_GetSupportedMIMETypesUPP) (FUNC)) -#define CallBP_GetMIMEDescEntryProc(FUNC, mimeInfo, flags) \ - (*(FUNC))((mimeInfo), (flags)) - -#endif /* XP_MACOSX */ - -#if defined(_WINDOWS) -#define OSCALL WINAPI -#else -#if defined(__OS2__) -#define OSCALL _System -#else -#define OSCALL -#endif -#endif - -#if defined(XP_UNIX) -/* GCC 3.3 and later support the visibility attribute. */ -#if defined(__GNUC__) && \ - ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) -#define NP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) -#else -#define NP_VISIBILITY_DEFAULT -#endif - -#define NP_EXPORT(__type) NP_VISIBILITY_DEFAULT __type -#endif - -#if defined( _WINDOWS ) || defined (__OS2__) - -#ifdef __cplusplus -extern "C" { -#endif - -/* plugin meta member functions */ -#if defined(__OS2__) - -typedef struct _NPPluginData { /* Alternate OS2 Plugin interface */ - char *pMimeTypes; - char *pFileExtents; - char *pFileOpenTemplate; - char *pProductName; - char *pProductDescription; - unsigned long dwProductVersionMS; - unsigned long dwProductVersionLS; -} NPPluginData; - -NPError OSCALL NP_GetPluginData(NPPluginData * pPluginData); - -#endif - -NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs); - -NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs); - -NPError OSCALL NP_Shutdown(); - -char* NP_GetMIMEDescription(); - -#ifdef __cplusplus -} -#endif - -#endif /* _WINDOWS || __OS2__ */ - -#if defined(__OS2__) -#pragma pack() -#endif - -#ifdef XP_UNIX - -#ifdef __cplusplus -extern "C" { -#endif - -/* plugin meta member functions */ - -NP_EXPORT(char*) NP_GetMIMEDescription(void); -NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs*, NPPluginFuncs*); -NP_EXPORT(NPError) NP_Shutdown(void); -NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue); - -#ifdef __cplusplus -} -#endif - -#endif /* XP_UNIX */ - -#endif /* _NPUPP_H_ */ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +/* + * npupp.h $Revision: 3.26 $ + * function call mecahnics needed by platform specific glue code. + */ + + +#ifndef _NPUPP_H_ +#define _NPUPP_H_ + +#if defined(__OS2__) +#pragma pack(1) +#endif + +#ifndef GENERATINGCFM +#define GENERATINGCFM 0 +#endif + +#ifndef _NPAPI_H_ +#include "npapi.h" +#endif + +#include "npruntime.h" + +#include "jri.h" + + +/****************************************************************************************** + plug-in function table macros + for each function in and out of the plugin API we define + typedef NPP_FooUPP + #define NewNPP_FooProc + #define CallNPP_FooProc + *******************************************************************************************/ + + +/* NPP_Initialize */ +typedef void (* NP_LOADDS NPP_InitializeUPP)(void); +#define NewNPP_InitializeProc(FUNC) \ + ((NPP_InitializeUPP) (FUNC)) +#define CallNPP_InitializeProc(FUNC) \ + (*(FUNC))() + +/* NPP_Shutdown */ +typedef void (* NP_LOADDS NPP_ShutdownUPP)(void); +#define NewNPP_ShutdownProc(FUNC) \ + ((NPP_ShutdownUPP) (FUNC)) +#define CallNPP_ShutdownProc(FUNC) \ + (*(FUNC))() + +/* NPP_New */ +typedef NPError (* NP_LOADDS NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved); +#define NewNPP_NewProc(FUNC) \ + ((NPP_NewUPP) (FUNC)) +#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7)) + +/* NPP_Destroy */ +typedef NPError (* NP_LOADDS NPP_DestroyUPP)(NPP instance, NPSavedData** save); +#define NewNPP_DestroyProc(FUNC) \ + ((NPP_DestroyUPP) (FUNC)) +#define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \ + (*(FUNC))((ARG1), (ARG2)) + +/* NPP_SetWindow */ +typedef NPError (* NP_LOADDS NPP_SetWindowUPP)(NPP instance, NPWindow* window); +#define NewNPP_SetWindowProc(FUNC) \ + ((NPP_SetWindowUPP) (FUNC)) +#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \ + (*(FUNC))((ARG1), (ARG2)) + +/* NPP_NewStream */ +typedef NPError (* NP_LOADDS NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype); +#define NewNPP_NewStreamProc(FUNC) \ + ((NPP_NewStreamUPP) (FUNC)) +#define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5)) + +/* NPP_DestroyStream */ +typedef NPError (* NP_LOADDS NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason); +#define NewNPP_DestroyStreamProc(FUNC) \ + ((NPP_DestroyStreamUPP) (FUNC)) +#define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPReasonArg) \ + (*(FUNC))((NPParg), (NPStreamPtr), (NPReasonArg)) + +/* NPP_WriteReady */ +typedef int32 (* NP_LOADDS NPP_WriteReadyUPP)(NPP instance, NPStream* stream); +#define NewNPP_WriteReadyProc(FUNC) \ + ((NPP_WriteReadyUPP) (FUNC)) +#define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \ + (*(FUNC))((NPParg), (NPStreamPtr)) + +/* NPP_Write */ +typedef int32 (* NP_LOADDS NPP_WriteUPP)(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer); +#define NewNPP_WriteProc(FUNC) \ + ((NPP_WriteUPP) (FUNC)) +#define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \ + (*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr)) + +/* NPP_StreamAsFile */ +typedef void (* NP_LOADDS NPP_StreamAsFileUPP)(NPP instance, NPStream* stream, const char* fname); +#define NewNPP_StreamAsFileProc(FUNC) \ + ((NPP_StreamAsFileUPP) (FUNC)) +#define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPP_Print */ +typedef void (* NP_LOADDS NPP_PrintUPP)(NPP instance, NPPrint* platformPrint); +#define NewNPP_PrintProc(FUNC) \ + ((NPP_PrintUPP) (FUNC)) +#define CallNPP_PrintProc(FUNC, NPParg, NPPrintArg) \ + (*(FUNC))((NPParg), (NPPrintArg)) + +/* NPP_HandleEvent */ +typedef int16 (* NP_LOADDS NPP_HandleEventUPP)(NPP instance, void* event); +#define NewNPP_HandleEventProc(FUNC) \ + ((NPP_HandleEventUPP) (FUNC)) +#define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \ + (*(FUNC))((NPParg), (voidPtr)) + +/* NPP_URLNotify */ +typedef void (* NP_LOADDS NPP_URLNotifyUPP)(NPP instance, const char* url, NPReason reason, void* notifyData); +#define NewNPP_URLNotifyProc(FUNC) \ + ((NPP_URLNotifyUPP) (FUNC)) +#define CallNPP_URLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) + +/* NPP_GetValue */ +typedef NPError (* NP_LOADDS NPP_GetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue); +#define NewNPP_GetValueProc(FUNC) \ + ((NPP_GetValueUPP) (FUNC)) +#define CallNPP_GetValueProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPP_SetValue */ +typedef NPError (* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue); +#define NewNPP_SetValueProc(FUNC) \ + ((NPP_SetValueUPP) (FUNC)) +#define CallNPP_SetValueProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* + * Netscape entry points + */ + + +/* NPN_GetValue */ +typedef NPError (* NP_LOADDS NPN_GetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue); +#define NewNPN_GetValueProc(FUNC) \ + ((NPN_GetValueUPP) (FUNC)) +#define CallNPN_GetValueProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPN_SetValue */ +typedef NPError (* NP_LOADDS NPN_SetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue); +#define NewNPN_SetValueProc(FUNC) \ + ((NPN_SetValueUPP) (FUNC)) +#define CallNPN_SetValueProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPN_GetUrlNotify */ +typedef NPError (* NP_LOADDS NPN_GetURLNotifyUPP)(NPP instance, const char* url, const char* window, void* notifyData); +#define NewNPN_GetURLNotifyProc(FUNC) \ + ((NPN_GetURLNotifyUPP) (FUNC)) +#define CallNPN_GetURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) + +/* NPN_PostUrlNotify */ +typedef NPError (* NP_LOADDS NPN_PostURLNotifyUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData); +#define NewNPN_PostURLNotifyProc(FUNC) \ + ((NPN_PostURLNotifyUPP) (FUNC)) +#define CallNPN_PostURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7)) + +/* NPN_GetUrl */ +typedef NPError (* NP_LOADDS NPN_GetURLUPP)(NPP instance, const char* url, const char* window); +#define NewNPN_GetURLProc(FUNC) \ + ((NPN_GetURLUPP) (FUNC)) +#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPN_PostUrl */ +typedef NPError (* NP_LOADDS NPN_PostURLUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file); +#define NewNPN_PostURLProc(FUNC) \ + ((NPN_PostURLUPP) (FUNC)) +#define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6)) + +/* NPN_RequestRead */ +typedef NPError (* NP_LOADDS NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList); +#define NewNPN_RequestReadProc(FUNC) \ + ((NPN_RequestReadUPP) (FUNC)) +#define CallNPN_RequestReadProc(FUNC, stream, range) \ + (*(FUNC))((stream), (range)) + +/* NPN_NewStream */ +typedef NPError (* NP_LOADDS NPN_NewStreamUPP)(NPP instance, NPMIMEType type, const char* window, NPStream** stream); +#define NewNPN_NewStreamProc(FUNC) \ + ((NPN_NewStreamUPP) (FUNC)) +#define CallNPN_NewStreamProc(FUNC, npp, type, window, stream) \ + (*(FUNC))((npp), (type), (window), (stream)) + +/* NPN_Write */ +typedef int32 (* NP_LOADDS NPN_WriteUPP)(NPP instance, NPStream* stream, int32 len, void* buffer); +#define NewNPN_WriteProc(FUNC) \ + ((NPN_WriteUPP) (FUNC)) +#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \ + (*(FUNC))((npp), (stream), (len), (buffer)) + +/* NPN_DestroyStream */ +typedef NPError (* NP_LOADDS NPN_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason); +#define NewNPN_DestroyStreamProc(FUNC) \ + ((NPN_DestroyStreamUPP) (FUNC)) +#define CallNPN_DestroyStreamProc(FUNC, npp, stream, reason) \ + (*(FUNC))((npp), (stream), (reason)) + +/* NPN_Status */ +typedef void (* NP_LOADDS NPN_StatusUPP)(NPP instance, const char* message); +#define NewNPN_StatusProc(FUNC) \ + ((NPN_StatusUPP) (FUNC)) +#define CallNPN_StatusProc(FUNC, npp, msg) \ + (*(FUNC))((npp), (msg)) + +/* NPN_UserAgent */ +typedef const char* (* NP_LOADDS NPN_UserAgentUPP)(NPP instance); +#define NewNPN_UserAgentProc(FUNC) \ + ((NPN_UserAgentUPP) (FUNC)) +#define CallNPN_UserAgentProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_MemAlloc */ +typedef void* (* NP_LOADDS NPN_MemAllocUPP)(uint32 size); +#define NewNPN_MemAllocProc(FUNC) \ + ((NPN_MemAllocUPP) (FUNC)) +#define CallNPN_MemAllocProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN__MemFree */ +typedef void (* NP_LOADDS NPN_MemFreeUPP)(void* ptr); +#define NewNPN_MemFreeProc(FUNC) \ + ((NPN_MemFreeUPP) (FUNC)) +#define CallNPN_MemFreeProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_MemFlush */ +typedef uint32 (* NP_LOADDS NPN_MemFlushUPP)(uint32 size); +#define NewNPN_MemFlushProc(FUNC) \ + ((NPN_MemFlushUPP) (FUNC)) +#define CallNPN_MemFlushProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_ReloadPlugins */ +typedef void (* NP_LOADDS NPN_ReloadPluginsUPP)(NPBool reloadPages); +#define NewNPN_ReloadPluginsProc(FUNC) \ + ((NPN_ReloadPluginsUPP) (FUNC)) +#define CallNPN_ReloadPluginsProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_GetJavaEnv */ +typedef JRIEnv* (* NP_LOADDS NPN_GetJavaEnvUPP)(void); +#define NewNPN_GetJavaEnvProc(FUNC) \ + ((NPN_GetJavaEnvUPP) (FUNC)) +#define CallNPN_GetJavaEnvProc(FUNC) \ + (*(FUNC))() + +/* NPN_GetJavaPeer */ +typedef jref (* NP_LOADDS NPN_GetJavaPeerUPP)(NPP instance); +#define NewNPN_GetJavaPeerProc(FUNC) \ + ((NPN_GetJavaPeerUPP) (FUNC)) +#define CallNPN_GetJavaPeerProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_InvalidateRect */ +typedef void (* NP_LOADDS NPN_InvalidateRectUPP)(NPP instance, NPRect *rect); +#define NewNPN_InvalidateRectProc(FUNC) \ + ((NPN_InvalidateRectUPP) (FUNC)) +#define CallNPN_InvalidateRectProc(FUNC, ARG1, ARG2) \ + (*(FUNC))((ARG1), (ARG2)) + +/* NPN_InvalidateRegion */ +typedef void (* NP_LOADDS NPN_InvalidateRegionUPP)(NPP instance, NPRegion region); +#define NewNPN_InvalidateRegionProc(FUNC) \ + ((NPN_InvalidateRegionUPP) (FUNC)) +#define CallNPN_InvalidateRegionProc(FUNC, ARG1, ARG2) \ + (*(FUNC))((ARG1), (ARG2)) + +/* NPN_ForceRedraw */ +typedef void (* NP_LOADDS NPN_ForceRedrawUPP)(NPP instance); +#define NewNPN_ForceRedrawProc(FUNC) \ + ((NPN_ForceRedrawUPP) (FUNC)) +#define CallNPN_ForceRedrawProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_GetStringIdentifier */ +typedef NPIdentifier (* NP_LOADDS NPN_GetStringIdentifierUPP)(const NPUTF8* name); +#define NewNPN_GetStringIdentifierProc(FUNC) \ + ((NPN_GetStringIdentifierUPP) (FUNC)) +#define CallNPN_GetStringIdentifierProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_GetStringIdentifiers */ +typedef void (* NP_LOADDS NPN_GetStringIdentifiersUPP)(const NPUTF8** names, + int32_t nameCount, + NPIdentifier* identifiers); +#define NewNPN_GetStringIdentifiersProc(FUNC) \ + ((NPN_GetStringIdentifiersUPP) (FUNC)) +#define CallNPN_GetStringIdentifiersProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPN_GetIntIdentifier */ +typedef NPIdentifier (* NP_LOADDS NPN_GetIntIdentifierUPP)(int32_t intid); +#define NewNPN_GetIntIdentifierProc(FUNC) \ + ((NPN_GetIntIdentifierUPP) (FUNC)) +#define CallNPN_GetIntIdentifierProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_IdentifierIsString */ +typedef bool (* NP_LOADDS NPN_IdentifierIsStringUPP)(NPIdentifier identifier); +#define NewNPN_IdentifierIsStringProc(FUNC) \ + ((NPN_IdentifierIsStringUPP) (FUNC)) +#define CallNPN_IdentifierIsStringProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_UTF8FromIdentifier */ +typedef NPUTF8* (* NP_LOADDS NPN_UTF8FromIdentifierUPP)(NPIdentifier identifier); +#define NewNPN_UTF8FromIdentifierProc(FUNC) \ + ((NPN_UTF8FromIdentifierUPP) (FUNC)) +#define CallNPN_UTF8FromIdentifierProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_IntFromIdentifier */ +typedef int32_t (* NP_LOADDS NPN_IntFromIdentifierUPP)(NPIdentifier identifier); +#define NewNPN_IntFromIdentifierProc(FUNC) \ + ((NPN_IntFromIdentifierUPP) (FUNC)) +#define CallNPN_IntFromIdentifierProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_CreateObject */ +typedef NPObject* (* NP_LOADDS NPN_CreateObjectUPP)(NPP npp, NPClass *aClass); +#define NewNPN_CreateObjectProc(FUNC) \ + ((NPN_CreateObjectUPP) (FUNC)) +#define CallNPN_CreateObjectProc(FUNC, ARG1, ARG2) \ + (*(FUNC))((ARG1), (ARG2)) + +/* NPN_RetainObject */ +typedef NPObject* (* NP_LOADDS NPN_RetainObjectUPP)(NPObject *obj); +#define NewNPN_RetainObjectProc(FUNC) \ + ((NPN_RetainObjectUPP) (FUNC)) +#define CallNPN_RetainObjectProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_ReleaseObject */ +typedef void (* NP_LOADDS NPN_ReleaseObjectUPP)(NPObject *obj); +#define NewNPN_ReleaseObjectProc(FUNC) \ + ((NPN_ReleaseObjectUPP) (FUNC)) +#define CallNPN_ReleaseObjectProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_Invoke */ +typedef bool (* NP_LOADDS NPN_InvokeUPP)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result); +#define NewNPN_InvokeProc(FUNC) \ + ((NPN_InvokeUPP) (FUNC)) +#define CallNPN_InvokeProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6)) + +/* NPN_InvokeDefault */ +typedef bool (* NP_LOADDS NPN_InvokeDefaultUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); +#define NewNPN_InvokeDefaultProc(FUNC) \ + ((NPN_InvokeDefaultUPP) (FUNC)) +#define CallNPN_InvokeDefaultProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5)) + +/* NPN_Evaluate */ +typedef bool (* NP_LOADDS NPN_EvaluateUPP)(NPP npp, NPObject *obj, NPString *script, NPVariant *result); +#define NewNPN_EvaluateProc(FUNC) \ + ((NPN_EvaluateUPP) (FUNC)) +#define CallNPN_EvaluateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) + +/* NPN_GetProperty */ +typedef bool (* NP_LOADDS NPN_GetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result); +#define NewNPN_GetPropertyProc(FUNC) \ + ((NPN_GetPropertyUPP) (FUNC)) +#define CallNPN_GetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) + +/* NPN_SetProperty */ +typedef bool (* NP_LOADDS NPN_SetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value); +#define NewNPN_SetPropertyProc(FUNC) \ + ((NPN_SetPropertyUPP) (FUNC)) +#define CallNPN_SetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) + +/* NPN_RemoveProperty */ +typedef bool (* NP_LOADDS NPN_RemovePropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName); +#define NewNPN_RemovePropertyProc(FUNC) \ + ((NPN_RemovePropertyUPP) (FUNC)) +#define CallNPN_RemovePropertyProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPN_HasProperty */ +typedef bool (* NP_LOADDS NPN_HasPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName); +#define NewNPN_HasPropertyProc(FUNC) \ + ((NPN_HasPropertyUPP) (FUNC)) +#define CallNPN_HasPropertyProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPN_HasMethod */ +typedef bool (* NP_LOADDS NPN_HasMethodUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName); +#define NewNPN_HasMethodProc(FUNC) \ + ((NPN_HasMethodUPP) (FUNC)) +#define CallNPN_HasMethodProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPN_ReleaseVariantValue */ +typedef void (* NP_LOADDS NPN_ReleaseVariantValueUPP)(NPVariant *variant); +#define NewNPN_ReleaseVariantValueProc(FUNC) \ + ((NPN_ReleaseVariantValueUPP) (FUNC)) +#define CallNPN_ReleaseVariantValueProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_SetException */ +typedef void (* NP_LOADDS NPN_SetExceptionUPP)(NPObject *obj, const NPUTF8 *message); +#define NewNPN_SetExceptionProc(FUNC) \ + ((NPN_SetExceptionUPP) (FUNC)) +#define CallNPN_SetExceptionProc(FUNC, ARG1, ARG2) \ + (*(FUNC))((ARG1), (ARG2)) + +/* NPN_PushPopupsEnabledStateUPP */ +typedef bool (* NP_LOADDS NPN_PushPopupsEnabledStateUPP)(NPP npp, NPBool enabled); +#define NewNPN_PushPopupsEnabledStateProc(FUNC) \ + ((NPN_PushPopupsEnabledStateUPP) (FUNC)) +#define CallNPN_PushPopupsEnabledStateProc(FUNC, ARG1, ARG2) \ + (*(FUNC))((ARG1), (ARG2)) + +/* NPN_PopPopupsEnabledState */ +typedef bool (* NP_LOADDS NPN_PopPopupsEnabledStateUPP)(NPP npp); +#define NewNPN_PopPopupsEnabledStateProc(FUNC) \ + ((NPN_PopPopupsEnabledStateUPP) (FUNC)) +#define CallNPN_PopPopupsEnabledStateProc(FUNC, ARG1) \ + (*(FUNC))((ARG1)) + +/* NPN_Enumerate */ +typedef bool (* NP_LOADDS NPN_EnumerateUPP)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count); +#define NewNPN_EnumerateProc(FUNC) \ + ((NPN_EnumerateUPP) (FUNC)) +#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4)) + +/* NPN_PluginThreadAsyncCall */ +typedef void (* NP_LOADDS NPN_PluginThreadAsyncCallUPP)(NPP instance, void (*func)(void *), void *userData); +#define NewNPN_PluginThreadAsyncCallProc(FUNC) \ + ((NPN_PluginThreadAsyncCallUPP) (FUNC)) +#define CallNPN_PluginThreadAsyncCallProc(FUNC, ARG1, ARG2, ARG3) \ + (*(FUNC))((ARG1), (ARG2), (ARG3)) + +/* NPN_Construct */ +typedef bool (* NP_LOADDS NPN_ConstructUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result); +#define NewNPN_ConstructProc(FUNC) \ + ((NPN_ConstructUPP) (FUNC)) +#define CallNPN_ConstructProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \ + (*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5)) + + + +/****************************************************************************************** + * The actual plugin function table definitions + *******************************************************************************************/ + +typedef struct _NPPluginFuncs { + uint16 size; + uint16 version; + NPP_NewUPP newp; + NPP_DestroyUPP destroy; + NPP_SetWindowUPP setwindow; + NPP_NewStreamUPP newstream; + NPP_DestroyStreamUPP destroystream; + NPP_StreamAsFileUPP asfile; + NPP_WriteReadyUPP writeready; + NPP_WriteUPP write; + NPP_PrintUPP print; + NPP_HandleEventUPP event; + NPP_URLNotifyUPP urlnotify; + JRIGlobalRef javaClass; + NPP_GetValueUPP getvalue; + NPP_SetValueUPP setvalue; +} NPPluginFuncs; + +typedef struct _NPNetscapeFuncs { + uint16 size; + uint16 version; + NPN_GetURLUPP geturl; + NPN_PostURLUPP posturl; + NPN_RequestReadUPP requestread; + NPN_NewStreamUPP newstream; + NPN_WriteUPP write; + NPN_DestroyStreamUPP destroystream; + NPN_StatusUPP status; + NPN_UserAgentUPP uagent; + NPN_MemAllocUPP memalloc; + NPN_MemFreeUPP memfree; + NPN_MemFlushUPP memflush; + NPN_ReloadPluginsUPP reloadplugins; + NPN_GetJavaEnvUPP getJavaEnv; + NPN_GetJavaPeerUPP getJavaPeer; + NPN_GetURLNotifyUPP geturlnotify; + NPN_PostURLNotifyUPP posturlnotify; + NPN_GetValueUPP getvalue; + NPN_SetValueUPP setvalue; + NPN_InvalidateRectUPP invalidaterect; + NPN_InvalidateRegionUPP invalidateregion; + NPN_ForceRedrawUPP forceredraw; + NPN_GetStringIdentifierUPP getstringidentifier; + NPN_GetStringIdentifiersUPP getstringidentifiers; + NPN_GetIntIdentifierUPP getintidentifier; + NPN_IdentifierIsStringUPP identifierisstring; + NPN_UTF8FromIdentifierUPP utf8fromidentifier; + NPN_IntFromIdentifierUPP intfromidentifier; + NPN_CreateObjectUPP createobject; + NPN_RetainObjectUPP retainobject; + NPN_ReleaseObjectUPP releaseobject; + NPN_InvokeUPP invoke; + NPN_InvokeDefaultUPP invokeDefault; + NPN_EvaluateUPP evaluate; + NPN_GetPropertyUPP getproperty; + NPN_SetPropertyUPP setproperty; + NPN_RemovePropertyUPP removeproperty; + NPN_HasPropertyUPP hasproperty; + NPN_HasMethodUPP hasmethod; + NPN_ReleaseVariantValueUPP releasevariantvalue; + NPN_SetExceptionUPP setexception; + NPN_PushPopupsEnabledStateUPP pushpopupsenabledstate; + NPN_PopPopupsEnabledStateUPP poppopupsenabledstate; + NPN_EnumerateUPP enumerate; + NPN_PluginThreadAsyncCallUPP pluginthreadasynccall; + NPN_ConstructUPP construct; +} NPNetscapeFuncs; + + +#ifdef XP_MACOSX +/****************************************************************************************** + * Mac platform-specific plugin glue stuff + *******************************************************************************************/ + +/* + * Main entry point of the plugin. + * This routine will be called when the plugin is loaded. The function + * tables are passed in and the plugin fills in the NPPluginFuncs table + * and NPPShutdownUPP for Netscape's use. + */ +typedef NPError (* NP_LOADDS NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownUPP*); +#define NewNPP_MainEntryProc(FUNC) \ + ((NPP_MainEntryUPP) (FUNC)) +#define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \ + (*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP)) + +/* + * Mac OS X version(s) of NP_GetMIMEDescription(const char *) + * These can be called to retreive MIME information from the plugin dynamically + * + * Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way + * to get mime info from the plugin only on OSX and may not be supported + * in furture version -- use NP_GetMIMEDescription instead + */ + +enum +{ + kBPSupportedMIMETypesStructVers_1 = 1 +}; + +typedef struct _BPSupportedMIMETypes +{ + SInt32 structVersion; /* struct version */ + Handle typeStrings; /* STR# formated handle, allocated by plug-in */ + Handle infoStrings; /* STR# formated handle, allocated by plug-in */ +} BPSupportedMIMETypes; +OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags); + + /* NP_GetMIMEDescription */ +#define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription" +typedef const char* (* NP_LOADDS NP_GetMIMEDescriptionUPP)(); +#define NewNP_GetMIMEDescEntryProc(FUNC) \ + ((NP_GetMIMEDescriptionUPP) (FUNC)) +#define CallNP_GetMIMEDescEntryProc(FUNC) \ + (*(FUNC))() + +/* BP_GetSupportedMIMETypes */ +typedef OSErr (* NP_LOADDS BP_GetSupportedMIMETypesUPP)(BPSupportedMIMETypes*, UInt32); +#define NewBP_GetSupportedMIMETypesEntryProc(FUNC) \ + ((BP_GetSupportedMIMETypesUPP) (FUNC)) +#define CallBP_GetMIMEDescEntryProc(FUNC, mimeInfo, flags) \ + (*(FUNC))((mimeInfo), (flags)) + +#endif /* XP_MACOSX */ + +#if defined(_WINDOWS) +#define OSCALL WINAPI +#else +#if defined(__OS2__) +#define OSCALL _System +#else +#define OSCALL +#endif +#endif + +#if defined(XP_UNIX) +/* GCC 3.3 and later support the visibility attribute. */ +#if defined(__GNUC__) && \ + ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) +#define NP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) +#else +#define NP_VISIBILITY_DEFAULT +#endif + +#define NP_EXPORT(__type) NP_VISIBILITY_DEFAULT __type +#endif + +#if defined( _WINDOWS ) || defined (__OS2__) + +#ifdef __cplusplus +extern "C" { +#endif + +/* plugin meta member functions */ +#if defined(__OS2__) + +typedef struct _NPPluginData { /* Alternate OS2 Plugin interface */ + char *pMimeTypes; + char *pFileExtents; + char *pFileOpenTemplate; + char *pProductName; + char *pProductDescription; + unsigned long dwProductVersionMS; + unsigned long dwProductVersionLS; +} NPPluginData; + +NPError OSCALL NP_GetPluginData(NPPluginData * pPluginData); + +#endif + +NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs); + +NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs); + +NPError OSCALL NP_Shutdown(); + +char* NP_GetMIMEDescription(); + +#ifdef __cplusplus +} +#endif + +#endif /* _WINDOWS || __OS2__ */ + +#if defined(__OS2__) +#pragma pack() +#endif + +#ifdef XP_UNIX + +#ifdef __cplusplus +extern "C" { +#endif + +/* plugin meta member functions */ + +NP_EXPORT(char*) NP_GetMIMEDescription(void); +NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs*, NPPluginFuncs*); +NP_EXPORT(NPError) NP_Shutdown(void); +NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue); + +#ifdef __cplusplus +} +#endif + +#endif /* XP_UNIX */ + +#endif /* _NPUPP_H_ */ diff --git a/extras/browser plugins/wrapper/npapi/obsolete/protypes.h b/extras/browser plugins/wrapper/npapi/obsolete/protypes.h index 4405bfce2f..73ed153085 100644 --- a/extras/browser plugins/wrapper/npapi/obsolete/protypes.h +++ b/extras/browser plugins/wrapper/npapi/obsolete/protypes.h @@ -1,252 +1,252 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * This header typedefs the old 'native' types to the new PRs. - * These definitions are scheduled to be eliminated at the earliest - * possible time. The NSPR API is implemented and documented using - * the new definitions. - */ - -#if !defined(PROTYPES_H) -#define PROTYPES_H - -typedef PRUintn uintn; -#ifndef _XP_Core_ -typedef PRIntn intn; -#endif - -/* - * It is trickier to define uint, int8, uint8, int16, uint16, - * int32, uint32, int64, and uint64 because some of these int - * types are defined by standard header files on some platforms. - * Our strategy here is to include all such standard headers - * first, and then define these int types only if they are not - * defined by those standard headers. - */ - -/* - * BeOS defines all the int types below in its standard header - * file SupportDefs.h. - */ -#ifdef XP_BEOS -#include -#endif - -/* - * OpenVMS defines all the int types below in its standard - * header files ints.h and types.h. - */ -#ifdef VMS -#include -#include -#endif - -/* - * SVR4 typedef of uint is commonly found on UNIX machines. - * - * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h) - * defines the types int8, int16, int32, and int64. - */ -#ifdef XP_UNIX -#include -#endif - -/* model.h on HP-UX defines int8, int16, and int32. */ -#ifdef HPUX -#include -#endif - -/* - * uint - */ - -#if !defined(XP_BEOS) && !defined(VMS) \ - && !defined(XP_UNIX) || defined(NTO) -typedef PRUintn uint; -#endif - -/* - * uint64 - */ - -#if !defined(XP_BEOS) && !defined(VMS) -typedef PRUint64 uint64; -#endif - -/* - * uint32 - */ - -#if !defined(XP_BEOS) && !defined(VMS) -#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO) -typedef PRUint32 uint32; -#else -typedef unsigned long uint32; -#endif -#endif - -/* - * uint16 - */ - -#if !defined(XP_BEOS) && !defined(VMS) -typedef PRUint16 uint16; -#endif - -/* - * uint8 - */ - -#if !defined(XP_BEOS) && !defined(VMS) -typedef PRUint8 uint8; -#endif - -/* - * int64 - */ - -#if !defined(XP_BEOS) && !defined(VMS) \ - && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) -typedef PRInt64 int64; -#endif - -/* - * int32 - */ - -#if !defined(XP_BEOS) && !defined(VMS) \ - && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ - && !defined(HPUX) -#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO) -typedef PRInt32 int32; -#else -typedef long int32; -#endif -#endif - -/* - * int16 - */ - -#if !defined(XP_BEOS) && !defined(VMS) \ - && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ - && !defined(HPUX) -typedef PRInt16 int16; -#endif - -/* - * int8 - */ - -#if !defined(XP_BEOS) && !defined(VMS) \ - && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ - && !defined(HPUX) -typedef PRInt8 int8; -#endif - -typedef PRFloat64 float64; -typedef PRUptrdiff uptrdiff_t; -typedef PRUword uprword_t; -typedef PRWord prword_t; - - -/* Re: prbit.h */ -#define TEST_BIT PR_TEST_BIT -#define SET_BIT PR_SET_BIT -#define CLEAR_BIT PR_CLEAR_BIT - -/* Re: prarena.h->plarena.h */ -#define PRArena PLArena -#define PRArenaPool PLArenaPool -#define PRArenaStats PLArenaStats -#define PR_ARENA_ALIGN PL_ARENA_ALIGN -#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL -#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE -#define PR_ARENA_GROW PL_ARENA_GROW -#define PR_ARENA_MARK PL_ARENA_MARK -#define PR_CLEAR_UNUSED PL_CLEAR_UNUSED -#define PR_CLEAR_ARENA PL_CLEAR_ARENA -#define PR_ARENA_RELEASE PL_ARENA_RELEASE -#define PR_COUNT_ARENA PL_COUNT_ARENA -#define PR_ARENA_DESTROY PL_ARENA_DESTROY -#define PR_InitArenaPool PL_InitArenaPool -#define PR_FreeArenaPool PL_FreeArenaPool -#define PR_FinishArenaPool PL_FinishArenaPool -#define PR_CompactArenaPool PL_CompactArenaPool -#define PR_ArenaFinish PL_ArenaFinish -#define PR_ArenaAllocate PL_ArenaAllocate -#define PR_ArenaGrow PL_ArenaGrow -#define PR_ArenaRelease PL_ArenaRelease -#define PR_ArenaCountAllocation PL_ArenaCountAllocation -#define PR_ArenaCountInplaceGrowth PL_ArenaCountInplaceGrowth -#define PR_ArenaCountGrowth PL_ArenaCountGrowth -#define PR_ArenaCountRelease PL_ArenaCountRelease -#define PR_ArenaCountRetract PL_ArenaCountRetract - -/* Re: prhash.h->plhash.h */ -#define PRHashEntry PLHashEntry -#define PRHashTable PLHashTable -#define PRHashNumber PLHashNumber -#define PRHashFunction PLHashFunction -#define PRHashComparator PLHashComparator -#define PRHashEnumerator PLHashEnumerator -#define PRHashAllocOps PLHashAllocOps -#define PR_NewHashTable PL_NewHashTable -#define PR_HashTableDestroy PL_HashTableDestroy -#define PR_HashTableRawLookup PL_HashTableRawLookup -#define PR_HashTableRawAdd PL_HashTableRawAdd -#define PR_HashTableRawRemove PL_HashTableRawRemove -#define PR_HashTableAdd PL_HashTableAdd -#define PR_HashTableRemove PL_HashTableRemove -#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries -#define PR_HashTableLookup PL_HashTableLookup -#define PR_HashTableDump PL_HashTableDump -#define PR_HashString PL_HashString -#define PR_CompareStrings PL_CompareStrings -#define PR_CompareValues PL_CompareValues - -#if defined(XP_MAC) -#ifndef TRUE /* Mac standard is lower case true */ - #define TRUE 1 -#endif -#ifndef FALSE /* Mac standard is lower case false */ - #define FALSE 0 -#endif -#endif - -#endif /* !defined(PROTYPES_H) */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * This header typedefs the old 'native' types to the new PRs. + * These definitions are scheduled to be eliminated at the earliest + * possible time. The NSPR API is implemented and documented using + * the new definitions. + */ + +#if !defined(PROTYPES_H) +#define PROTYPES_H + +typedef PRUintn uintn; +#ifndef _XP_Core_ +typedef PRIntn intn; +#endif + +/* + * It is trickier to define uint, int8, uint8, int16, uint16, + * int32, uint32, int64, and uint64 because some of these int + * types are defined by standard header files on some platforms. + * Our strategy here is to include all such standard headers + * first, and then define these int types only if they are not + * defined by those standard headers. + */ + +/* + * BeOS defines all the int types below in its standard header + * file SupportDefs.h. + */ +#ifdef XP_BEOS +#include +#endif + +/* + * OpenVMS defines all the int types below in its standard + * header files ints.h and types.h. + */ +#ifdef VMS +#include +#include +#endif + +/* + * SVR4 typedef of uint is commonly found on UNIX machines. + * + * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h) + * defines the types int8, int16, int32, and int64. + */ +#ifdef XP_UNIX +#include +#endif + +/* model.h on HP-UX defines int8, int16, and int32. */ +#ifdef HPUX +#include +#endif + +/* + * uint + */ + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(XP_UNIX) || defined(NTO) +typedef PRUintn uint; +#endif + +/* + * uint64 + */ + +#if !defined(XP_BEOS) && !defined(VMS) +typedef PRUint64 uint64; +#endif + +/* + * uint32 + */ + +#if !defined(XP_BEOS) && !defined(VMS) +#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO) +typedef PRUint32 uint32; +#else +typedef unsigned long uint32; +#endif +#endif + +/* + * uint16 + */ + +#if !defined(XP_BEOS) && !defined(VMS) +typedef PRUint16 uint16; +#endif + +/* + * uint8 + */ + +#if !defined(XP_BEOS) && !defined(VMS) +typedef PRUint8 uint8; +#endif + +/* + * int64 + */ + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) +typedef PRInt64 int64; +#endif + +/* + * int32 + */ + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ + && !defined(HPUX) +#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO) +typedef PRInt32 int32; +#else +typedef long int32; +#endif +#endif + +/* + * int16 + */ + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ + && !defined(HPUX) +typedef PRInt16 int16; +#endif + +/* + * int8 + */ + +#if !defined(XP_BEOS) && !defined(VMS) \ + && !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \ + && !defined(HPUX) +typedef PRInt8 int8; +#endif + +typedef PRFloat64 float64; +typedef PRUptrdiff uptrdiff_t; +typedef PRUword uprword_t; +typedef PRWord prword_t; + + +/* Re: prbit.h */ +#define TEST_BIT PR_TEST_BIT +#define SET_BIT PR_SET_BIT +#define CLEAR_BIT PR_CLEAR_BIT + +/* Re: prarena.h->plarena.h */ +#define PRArena PLArena +#define PRArenaPool PLArenaPool +#define PRArenaStats PLArenaStats +#define PR_ARENA_ALIGN PL_ARENA_ALIGN +#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL +#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE +#define PR_ARENA_GROW PL_ARENA_GROW +#define PR_ARENA_MARK PL_ARENA_MARK +#define PR_CLEAR_UNUSED PL_CLEAR_UNUSED +#define PR_CLEAR_ARENA PL_CLEAR_ARENA +#define PR_ARENA_RELEASE PL_ARENA_RELEASE +#define PR_COUNT_ARENA PL_COUNT_ARENA +#define PR_ARENA_DESTROY PL_ARENA_DESTROY +#define PR_InitArenaPool PL_InitArenaPool +#define PR_FreeArenaPool PL_FreeArenaPool +#define PR_FinishArenaPool PL_FinishArenaPool +#define PR_CompactArenaPool PL_CompactArenaPool +#define PR_ArenaFinish PL_ArenaFinish +#define PR_ArenaAllocate PL_ArenaAllocate +#define PR_ArenaGrow PL_ArenaGrow +#define PR_ArenaRelease PL_ArenaRelease +#define PR_ArenaCountAllocation PL_ArenaCountAllocation +#define PR_ArenaCountInplaceGrowth PL_ArenaCountInplaceGrowth +#define PR_ArenaCountGrowth PL_ArenaCountGrowth +#define PR_ArenaCountRelease PL_ArenaCountRelease +#define PR_ArenaCountRetract PL_ArenaCountRetract + +/* Re: prhash.h->plhash.h */ +#define PRHashEntry PLHashEntry +#define PRHashTable PLHashTable +#define PRHashNumber PLHashNumber +#define PRHashFunction PLHashFunction +#define PRHashComparator PLHashComparator +#define PRHashEnumerator PLHashEnumerator +#define PRHashAllocOps PLHashAllocOps +#define PR_NewHashTable PL_NewHashTable +#define PR_HashTableDestroy PL_HashTableDestroy +#define PR_HashTableRawLookup PL_HashTableRawLookup +#define PR_HashTableRawAdd PL_HashTableRawAdd +#define PR_HashTableRawRemove PL_HashTableRawRemove +#define PR_HashTableAdd PL_HashTableAdd +#define PR_HashTableRemove PL_HashTableRemove +#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries +#define PR_HashTableLookup PL_HashTableLookup +#define PR_HashTableDump PL_HashTableDump +#define PR_HashString PL_HashString +#define PR_CompareStrings PL_CompareStrings +#define PR_CompareValues PL_CompareValues + +#if defined(XP_MAC) +#ifndef TRUE /* Mac standard is lower case true */ + #define TRUE 1 +#endif +#ifndef FALSE /* Mac standard is lower case false */ + #define FALSE 0 +#endif +#endif + +#endif /* !defined(PROTYPES_H) */ diff --git a/extras/browser plugins/wrapper/npapi/prcpucfg.h b/extras/browser plugins/wrapper/npapi/prcpucfg.h index 026258b8c3..af285483f9 100644 --- a/extras/browser plugins/wrapper/npapi/prcpucfg.h +++ b/extras/browser plugins/wrapper/npapi/prcpucfg.h @@ -1,300 +1,300 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nspr_cpucfg___ -#define nspr_cpucfg___ - -#ifndef XP_PC -#define XP_PC -#endif - -#ifndef WIN32 -#define WIN32 -#endif - -#ifndef WIN95 -#define WIN95 -#endif - -#define PR_AF_INET6 23 /* same as AF_INET6 */ - -#if defined(_M_IX86) || defined(_X86_) - -#define IS_LITTLE_ENDIAN 1 -#undef IS_BIG_ENDIAN - -#define PR_BYTES_PER_BYTE 1 -#define PR_BYTES_PER_SHORT 2 -#define PR_BYTES_PER_INT 4 -#define PR_BYTES_PER_INT64 8 -#define PR_BYTES_PER_LONG 4 -#define PR_BYTES_PER_FLOAT 4 -#define PR_BYTES_PER_WORD 4 -#define PR_BYTES_PER_DWORD 8 -#define PR_BYTES_PER_DOUBLE 8 - -#define PR_BITS_PER_BYTE 8 -#define PR_BITS_PER_SHORT 16 -#define PR_BITS_PER_INT 32 -#define PR_BITS_PER_INT64 64 -#define PR_BITS_PER_LONG 32 -#define PR_BITS_PER_FLOAT 32 -#define PR_BITS_PER_WORD 32 -#define PR_BITS_PER_DWORD 64 -#define PR_BITS_PER_DOUBLE 64 - -#define PR_BITS_PER_BYTE_LOG2 3 -#define PR_BITS_PER_SHORT_LOG2 4 -#define PR_BITS_PER_INT_LOG2 5 -#define PR_BITS_PER_INT64_LOG2 6 -#define PR_BITS_PER_LONG_LOG2 5 -#define PR_BITS_PER_FLOAT_LOG2 5 -#define PR_BITS_PER_WORD_LOG2 5 -#define PR_BITS_PER_DWORD_LOG2 6 -#define PR_BITS_PER_DOUBLE_LOG2 6 - -#define PR_ALIGN_OF_SHORT 2 -#define PR_ALIGN_OF_INT 4 -#define PR_ALIGN_OF_LONG 4 -#define PR_ALIGN_OF_INT64 8 -#define PR_ALIGN_OF_FLOAT 4 -#define PR_ALIGN_OF_WORD 4 -#define PR_ALIGN_OF_DWORD 8 -#define PR_ALIGN_OF_DOUBLE 4 -#define PR_ALIGN_OF_POINTER 4 - -#define PR_BYTES_PER_WORD_LOG2 2 -#define PR_BYTES_PER_DWORD_LOG2 2 - -#elif defined(_ALPHA_) - -#define IS_LITTLE_ENDIAN 1 -#undef IS_BIG_ENDIAN - -#define PR_BYTES_PER_BYTE 1 -#define PR_BYTES_PER_SHORT 2 -#define PR_BYTES_PER_INT 4 -#define PR_BYTES_PER_INT64 8 -#define PR_BYTES_PER_LONG 4 -#define PR_BYTES_PER_FLOAT 4 -#define PR_BYTES_PER_DOUBLE 8 -#define PR_BYTES_PER_WORD 4 -#define PR_BYTES_PER_DWORD 8 - -#define PR_BITS_PER_BYTE 8 -#define PR_BITS_PER_SHORT 16 -#define PR_BITS_PER_INT 32 -#define PR_BITS_PER_INT64 64 -#define PR_BITS_PER_LONG 32 -#define PR_BITS_PER_FLOAT 32 -#define PR_BITS_PER_DOUBLE 64 -#define PR_BITS_PER_WORD 32 - -#define PR_BITS_PER_BYTE_LOG2 3 -#define PR_BITS_PER_SHORT_LOG2 4 -#define PR_BITS_PER_INT_LOG2 5 -#define PR_BITS_PER_INT64_LOG2 6 -#define PR_BITS_PER_LONG_LOG2 5 -#define PR_BITS_PER_FLOAT_LOG2 5 -#define PR_BITS_PER_DOUBLE_LOG2 6 -#define PR_BITS_PER_WORD_LOG2 5 - -#define PR_BYTES_PER_WORD_LOG2 2 -#define PR_BYTES_PER_DWORD_LOG2 3 - -#define PR_ALIGN_OF_SHORT 2 -#define PR_ALIGN_OF_INT 4 -#define PR_ALIGN_OF_LONG 4 -#define PR_ALIGN_OF_INT64 8 -#define PR_ALIGN_OF_FLOAT 4 -#define PR_ALIGN_OF_DOUBLE 8 -#define PR_ALIGN_OF_POINTER 4 - -#elif defined(_AMD64_) - -#define IS_LITTLE_ENDIAN 1 -#undef IS_BIG_ENDIAN -#define IS_64 - -#define PR_BYTES_PER_BYTE 1 -#define PR_BYTES_PER_SHORT 2 -#define PR_BYTES_PER_INT 4 -#define PR_BYTES_PER_INT64 8 -#define PR_BYTES_PER_LONG 4 -#define PR_BYTES_PER_FLOAT 4 -#define PR_BYTES_PER_WORD 8 -#define PR_BYTES_PER_DWORD 8 -#define PR_BYTES_PER_DOUBLE 8 - -#define PR_BITS_PER_BYTE 8 -#define PR_BITS_PER_SHORT 16 -#define PR_BITS_PER_INT 32 -#define PR_BITS_PER_INT64 64 -#define PR_BITS_PER_LONG 32 -#define PR_BITS_PER_FLOAT 32 -#define PR_BITS_PER_WORD 64 -#define PR_BITS_PER_DWORD 64 -#define PR_BITS_PER_DOUBLE 64 - -#define PR_BITS_PER_BYTE_LOG2 3 -#define PR_BITS_PER_SHORT_LOG2 4 -#define PR_BITS_PER_INT_LOG2 5 -#define PR_BITS_PER_INT64_LOG2 6 -#define PR_BITS_PER_LONG_LOG2 5 -#define PR_BITS_PER_FLOAT_LOG2 5 -#define PR_BITS_PER_WORD_LOG2 6 -#define PR_BITS_PER_DWORD_LOG2 6 -#define PR_BITS_PER_DOUBLE_LOG2 6 - -#define PR_ALIGN_OF_SHORT 2 -#define PR_ALIGN_OF_INT 4 -#define PR_ALIGN_OF_LONG 4 -#define PR_ALIGN_OF_INT64 8 -#define PR_ALIGN_OF_FLOAT 4 -#define PR_ALIGN_OF_WORD 8 -#define PR_ALIGN_OF_DWORD 8 -#define PR_ALIGN_OF_DOUBLE 8 -#define PR_ALIGN_OF_POINTER 8 - -#define PR_BYTES_PER_WORD_LOG2 3 -#define PR_BYTES_PER_DWORD_LOG2 3 - -#elif defined(_IA64_) - -#define IS_LITTLE_ENDIAN 1 -#undef IS_BIG_ENDIAN -#define IS_64 - -#define PR_BYTES_PER_BYTE 1 -#define PR_BYTES_PER_SHORT 2 -#define PR_BYTES_PER_INT 4 -#define PR_BYTES_PER_INT64 8 -#define PR_BYTES_PER_LONG 4 -#define PR_BYTES_PER_FLOAT 4 -#define PR_BYTES_PER_WORD 8 -#define PR_BYTES_PER_DWORD 8 -#define PR_BYTES_PER_DOUBLE 8 - -#define PR_BITS_PER_BYTE 8 -#define PR_BITS_PER_SHORT 16 -#define PR_BITS_PER_INT 32 -#define PR_BITS_PER_INT64 64 -#define PR_BITS_PER_LONG 32 -#define PR_BITS_PER_FLOAT 32 -#define PR_BITS_PER_WORD 64 -#define PR_BITS_PER_DWORD 64 -#define PR_BITS_PER_DOUBLE 64 - -#define PR_BITS_PER_BYTE_LOG2 3 -#define PR_BITS_PER_SHORT_LOG2 4 -#define PR_BITS_PER_INT_LOG2 5 -#define PR_BITS_PER_INT64_LOG2 6 -#define PR_BITS_PER_LONG_LOG2 5 -#define PR_BITS_PER_FLOAT_LOG2 5 -#define PR_BITS_PER_WORD_LOG2 6 -#define PR_BITS_PER_DWORD_LOG2 6 -#define PR_BITS_PER_DOUBLE_LOG2 6 - -#define PR_ALIGN_OF_SHORT 2 -#define PR_ALIGN_OF_INT 4 -#define PR_ALIGN_OF_LONG 4 -#define PR_ALIGN_OF_INT64 8 -#define PR_ALIGN_OF_FLOAT 4 -#define PR_ALIGN_OF_WORD 8 -#define PR_ALIGN_OF_DWORD 8 -#define PR_ALIGN_OF_DOUBLE 8 -#define PR_ALIGN_OF_POINTER 8 - -#define PR_BYTES_PER_WORD_LOG2 3 -#define PR_BYTES_PER_DWORD_LOG2 3 - -#else /* defined(_M_IX86) || defined(_X86_) */ - -#error unknown processor architecture - -#endif /* defined(_M_IX86) || defined(_X86_) */ - -#ifndef HAVE_LONG_LONG -#define HAVE_LONG_LONG -#endif - -#ifndef NO_NSPR_10_SUPPORT - -#define BYTES_PER_BYTE PR_BYTES_PER_BYTE -#define BYTES_PER_SHORT PR_BYTES_PER_SHORT -#define BYTES_PER_INT PR_BYTES_PER_INT -#define BYTES_PER_INT64 PR_BYTES_PER_INT64 -#define BYTES_PER_LONG PR_BYTES_PER_LONG -#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT -#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE -#define BYTES_PER_WORD PR_BYTES_PER_WORD -#define BYTES_PER_DWORD PR_BYTES_PER_DWORD - -#define BITS_PER_BYTE PR_BITS_PER_BYTE -#define BITS_PER_SHORT PR_BITS_PER_SHORT -#define BITS_PER_INT PR_BITS_PER_INT -#define BITS_PER_INT64 PR_BITS_PER_INT64 -#define BITS_PER_LONG PR_BITS_PER_LONG -#define BITS_PER_FLOAT PR_BITS_PER_FLOAT -#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE -#define BITS_PER_WORD PR_BITS_PER_WORD - -#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 -#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 -#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 -#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 -#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 -#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 -#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 -#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 - -#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT -#define ALIGN_OF_INT PR_ALIGN_OF_INT -#define ALIGN_OF_LONG PR_ALIGN_OF_LONG -#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 -#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT -#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE -#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER -#define ALIGN_OF_WORD PR_ALIGN_OF_WORD - -#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 -#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 -#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 - -#endif /* NO_NSPR_10_SUPPORT */ - -#endif /* nspr_cpucfg___ */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nspr_cpucfg___ +#define nspr_cpucfg___ + +#ifndef XP_PC +#define XP_PC +#endif + +#ifndef WIN32 +#define WIN32 +#endif + +#ifndef WIN95 +#define WIN95 +#endif + +#define PR_AF_INET6 23 /* same as AF_INET6 */ + +#if defined(_M_IX86) || defined(_X86_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 32 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 5 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 4 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 4 +#define PR_ALIGN_OF_POINTER 4 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 2 + +#elif defined(_ALPHA_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 4 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 32 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 5 + +#define PR_BYTES_PER_WORD_LOG2 2 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 4 + +#elif defined(_AMD64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#elif defined(_IA64_) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 4 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 +#define PR_BYTES_PER_DOUBLE 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 32 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_WORD 64 +#define PR_BITS_PER_DWORD 64 +#define PR_BITS_PER_DOUBLE 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 5 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_WORD_LOG2 6 +#define PR_BITS_PER_DWORD_LOG2 6 +#define PR_BITS_PER_DOUBLE_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 4 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_WORD 8 +#define PR_ALIGN_OF_DWORD 8 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + +#else /* defined(_M_IX86) || defined(_X86_) */ + +#error unknown processor architecture + +#endif /* defined(_M_IX86) || defined(_X86_) */ + +#ifndef HAVE_LONG_LONG +#define HAVE_LONG_LONG +#endif + +#ifndef NO_NSPR_10_SUPPORT + +#define BYTES_PER_BYTE PR_BYTES_PER_BYTE +#define BYTES_PER_SHORT PR_BYTES_PER_SHORT +#define BYTES_PER_INT PR_BYTES_PER_INT +#define BYTES_PER_INT64 PR_BYTES_PER_INT64 +#define BYTES_PER_LONG PR_BYTES_PER_LONG +#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT +#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE +#define BYTES_PER_WORD PR_BYTES_PER_WORD +#define BYTES_PER_DWORD PR_BYTES_PER_DWORD + +#define BITS_PER_BYTE PR_BITS_PER_BYTE +#define BITS_PER_SHORT PR_BITS_PER_SHORT +#define BITS_PER_INT PR_BITS_PER_INT +#define BITS_PER_INT64 PR_BITS_PER_INT64 +#define BITS_PER_LONG PR_BITS_PER_LONG +#define BITS_PER_FLOAT PR_BITS_PER_FLOAT +#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE +#define BITS_PER_WORD PR_BITS_PER_WORD + +#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2 +#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2 +#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2 +#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2 +#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2 +#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2 +#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2 +#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2 + +#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT +#define ALIGN_OF_INT PR_ALIGN_OF_INT +#define ALIGN_OF_LONG PR_ALIGN_OF_LONG +#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64 +#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT +#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE +#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER +#define ALIGN_OF_WORD PR_ALIGN_OF_WORD + +#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2 +#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2 +#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2 + +#endif /* NO_NSPR_10_SUPPORT */ + +#endif /* nspr_cpucfg___ */ diff --git a/extras/browser plugins/wrapper/npapi/prtypes.h b/extras/browser plugins/wrapper/npapi/prtypes.h index 6850d6f9ac..7adb4c9b6c 100644 --- a/extras/browser plugins/wrapper/npapi/prtypes.h +++ b/extras/browser plugins/wrapper/npapi/prtypes.h @@ -1,569 +1,568 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the Netscape Portable Runtime (NSPR). - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998-2000 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* -** File: prtypes.h -** Description: Definitions of NSPR's basic types -** -** Prototypes and macros used to make up for deficiencies that we have found -** in ANSI environments. -** -** Since we do not wrap and all the other standard headers, authors -** of portable code will not know in general that they need these definitions. -** Instead of requiring these authors to find the dependent uses in their code -** and take the following steps only in those C files, we take steps once here -** for all C files. -**/ - -#ifndef prtypes_h___ -#define prtypes_h___ - -#ifdef MDCPUCFG -#include MDCPUCFG -#else -#include "prcpucfg.h" -#endif - -#include - -/*********************************************************************** -** MACROS: PR_EXTERN -** PR_IMPLEMENT -** DESCRIPTION: -** These are only for externally visible routines and globals. For -** internal routines, just use "extern" for type checking and that -** will not export internal cross-file or forward-declared symbols. -** Define a macro for declaring procedures return types. We use this to -** deal with windoze specific type hackery for DLL definitions. Use -** PR_EXTERN when the prototype for the method is declared. Use -** PR_IMPLEMENT for the implementation of the method. -** -** Example: -** in dowhim.h -** PR_EXTERN( void ) DoWhatIMean( void ); -** in dowhim.c -** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; } -** -** -***********************************************************************/ -#if defined(WIN32) - -#define PR_EXPORT(__type) extern __declspec(dllexport) __type -#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type -#define PR_IMPORT(__type) __declspec(dllimport) __type -#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type - -#define PR_EXTERN(__type) extern __declspec(dllexport) __type -#define PR_IMPLEMENT(__type) __declspec(dllexport) __type -#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type -#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type - -#define PR_CALLBACK -#define PR_CALLBACK_DECL -#define PR_STATIC_CALLBACK(__x) static __x - -#elif defined(XP_BEOS) - -#define PR_EXPORT(__type) extern __declspec(dllexport) __type -#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type -#define PR_IMPORT(__type) extern __declspec(dllexport) __type -#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type - -#define PR_EXTERN(__type) extern __declspec(dllexport) __type -#define PR_IMPLEMENT(__type) __declspec(dllexport) __type -#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type -#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type - -#define PR_CALLBACK -#define PR_CALLBACK_DECL -#define PR_STATIC_CALLBACK(__x) static __x - -#elif defined(WIN16) - -#define PR_CALLBACK_DECL __cdecl - -#if defined(_WINDLL) -#define PR_EXPORT(__type) extern __type _cdecl _export _loadds -#define PR_IMPORT(__type) extern __type _cdecl _export _loadds -#define PR_EXPORT_DATA(__type) extern __type _export -#define PR_IMPORT_DATA(__type) extern __type _export - -#define PR_EXTERN(__type) extern __type _cdecl _export _loadds -#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds -#define PR_EXTERN_DATA(__type) extern __type _export -#define PR_IMPLEMENT_DATA(__type) __type _export - -#define PR_CALLBACK __cdecl __loadds -#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK - -#else /* this must be .EXE */ -#define PR_EXPORT(__type) extern __type _cdecl _export -#define PR_IMPORT(__type) extern __type _cdecl _export -#define PR_EXPORT_DATA(__type) extern __type _export -#define PR_IMPORT_DATA(__type) extern __type _export - -#define PR_EXTERN(__type) extern __type _cdecl _export -#define PR_IMPLEMENT(__type) __type _cdecl _export -#define PR_EXTERN_DATA(__type) extern __type _export -#define PR_IMPLEMENT_DATA(__type) __type _export - -#define PR_CALLBACK __cdecl __loadds -#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK -#endif /* _WINDLL */ - -#elif defined(XP_MAC) - -#define PR_EXPORT(__type) extern __declspec(export) __type -#define PR_EXPORT_DATA(__type) extern __declspec(export) __type -#define PR_IMPORT(__type) extern __declspec(export) __type -#define PR_IMPORT_DATA(__type) extern __declspec(export) __type - -#define PR_EXTERN(__type) extern __declspec(export) __type -#define PR_IMPLEMENT(__type) __declspec(export) __type -#define PR_EXTERN_DATA(__type) extern __declspec(export) __type -#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type - -#define PR_CALLBACK -#define PR_CALLBACK_DECL -#define PR_STATIC_CALLBACK(__x) static __x - -#elif defined(XP_OS2) && defined(__declspec) - -#define PR_EXPORT(__type) extern __declspec(dllexport) __type -#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type -#define PR_IMPORT(__type) extern __declspec(dllimport) __type -#define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type - -#define PR_EXTERN(__type) extern __declspec(dllexport) __type -#define PR_IMPLEMENT(__type) __declspec(dllexport) __type -#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type -#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type - -#define PR_CALLBACK -#define PR_CALLBACK_DECL -#define PR_STATIC_CALLBACK(__x) static __x - -#elif defined(XP_OS2_VACPP) - -#define PR_EXPORT(__type) extern __type -#define PR_EXPORT_DATA(__type) extern __type -#define PR_IMPORT(__type) extern __type -#define PR_IMPORT_DATA(__type) extern __type - -#define PR_EXTERN(__type) extern __type -#define PR_IMPLEMENT(__type) __type -#define PR_EXTERN_DATA(__type) extern __type -#define PR_IMPLEMENT_DATA(__type) __type -#define PR_CALLBACK _Optlink -#define PR_CALLBACK_DECL -#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK - -#else /* Unix */ - -/* GCC 3.3 and later support the visibility attribute. */ -#if (__GNUC__ >= 4) || \ - (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) -#define PR_VISIBILITY_DEFAULT __attribute__((visibility("default"))) -#else -#define PR_VISIBILITY_DEFAULT -#endif - -#define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type -#define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type -#define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type -#define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type - -#define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type -#define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type -#define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type -#define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type -#define PR_CALLBACK -#define PR_CALLBACK_DECL -#define PR_STATIC_CALLBACK(__x) static __x - -#endif - -#if defined(_NSPR_BUILD_) -#define NSPR_API(__type) PR_EXPORT(__type) -#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type) -#else -#define NSPR_API(__type) PR_IMPORT(__type) -#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type) -#endif - -/*********************************************************************** -** MACROS: PR_BEGIN_MACRO -** PR_END_MACRO -** DESCRIPTION: -** Macro body brackets so that macros with compound statement definitions -** behave syntactically more like functions when called. -***********************************************************************/ -#define PR_BEGIN_MACRO do { -#define PR_END_MACRO } while (0) - -/*********************************************************************** -** MACROS: PR_BEGIN_EXTERN_C -** PR_END_EXTERN_C -** DESCRIPTION: -** Macro shorthands for conditional C++ extern block delimiters. -***********************************************************************/ -#ifdef __cplusplus -#define PR_BEGIN_EXTERN_C extern "C" { -#define PR_END_EXTERN_C } -#else -#define PR_BEGIN_EXTERN_C -#define PR_END_EXTERN_C -#endif - -/*********************************************************************** -** MACROS: PR_BIT -** PR_BITMASK -** DESCRIPTION: -** Bit masking macros. XXX n must be <= 31 to be portable -***********************************************************************/ -#define PR_BIT(n) ((PRUint32)1 << (n)) -#define PR_BITMASK(n) (PR_BIT(n) - 1) - -/*********************************************************************** -** MACROS: PR_ROUNDUP -** PR_MIN -** PR_MAX -** PR_ABS -** DESCRIPTION: -** Commonly used macros for operations on compatible types. -***********************************************************************/ -#define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y)) -#define PR_MIN(x,y) ((x)<(y)?(x):(y)) -#define PR_MAX(x,y) ((x)>(y)?(x):(y)) -#define PR_ABS(x) ((x)<0?-(x):(x)) - -PR_BEGIN_EXTERN_C - -/************************************************************************ -** TYPES: PRUint8 -** PRInt8 -** DESCRIPTION: -** The int8 types are known to be 8 bits each. There is no type that -** is equivalent to a plain "char". -************************************************************************/ -#if PR_BYTES_PER_BYTE == 1 -typedef unsigned char PRUint8; -/* -** Some cfront-based C++ compilers do not like 'signed char' and -** issue the warning message: -** warning: "signed" not implemented (ignored) -** For these compilers, we have to define PRInt8 as plain 'char'. -** Make sure that plain 'char' is indeed signed under these compilers. -*/ -#if (defined(HPUX) && defined(__cplusplus) \ - && !defined(__GNUC__) && __cplusplus < 199707L) \ - || (defined(SCO) && defined(__cplusplus) \ - && !defined(__GNUC__) && __cplusplus == 1L) -typedef char PRInt8; -#else -typedef signed char PRInt8; -#endif -#else -#error No suitable type for PRInt8/PRUint8 -#endif - -/************************************************************************ - * MACROS: PR_INT8_MAX - * PR_INT8_MIN - * PR_UINT8_MAX - * DESCRIPTION: - * The maximum and minimum values of a PRInt8 or PRUint8. -************************************************************************/ - -#define PR_INT8_MAX 127 -#define PR_INT8_MIN (-128) -#define PR_UINT8_MAX 255U - -/************************************************************************ -** TYPES: PRUint16 -** PRInt16 -** DESCRIPTION: -** The int16 types are known to be 16 bits each. -************************************************************************/ -#if PR_BYTES_PER_SHORT == 2 -typedef unsigned short PRUint16; -typedef short PRInt16; -#else -#error No suitable type for PRInt16/PRUint16 -#endif - -/************************************************************************ - * MACROS: PR_INT16_MAX - * PR_INT16_MIN - * PR_UINT16_MAX - * DESCRIPTION: - * The maximum and minimum values of a PRInt16 or PRUint16. -************************************************************************/ - -#define PR_INT16_MAX 32767 -#define PR_INT16_MIN (-32768) -#define PR_UINT16_MAX 65535U - -/************************************************************************ -** TYPES: PRUint32 -** PRInt32 -** DESCRIPTION: -** The int32 types are known to be 32 bits each. -************************************************************************/ -#if PR_BYTES_PER_INT == 4 -typedef unsigned int PRUint32; -typedef int PRInt32; -#define PR_INT32(x) x -#define PR_UINT32(x) x ## U -#elif PR_BYTES_PER_LONG == 4 -typedef unsigned long PRUint32; -typedef long PRInt32; -#define PR_INT32(x) x ## L -#define PR_UINT32(x) x ## UL -#else -#error No suitable type for PRInt32/PRUint32 -#endif - -/************************************************************************ - * MACROS: PR_INT32_MAX - * PR_INT32_MIN - * PR_UINT32_MAX - * DESCRIPTION: - * The maximum and minimum values of a PRInt32 or PRUint32. -************************************************************************/ - -#define PR_INT32_MAX PR_INT32(2147483647) -#define PR_INT32_MIN (-PR_INT32_MAX - 1) -#define PR_UINT32_MAX PR_UINT32(4294967295) - -/************************************************************************ -** TYPES: PRUint64 -** PRInt64 -** DESCRIPTION: -** The int64 types are known to be 64 bits each. Care must be used when -** declaring variables of type PRUint64 or PRInt64. Different hardware -** architectures and even different compilers have varying support for -** 64 bit values. The only guaranteed portability requires the use of -** the LL_ macros (see prlong.h). -************************************************************************/ -#ifdef HAVE_LONG_LONG -#if PR_BYTES_PER_LONG == 8 -typedef long PRInt64; -typedef unsigned long PRUint64; -#elif defined(WIN16) -typedef __int64 PRInt64; -typedef unsigned __int64 PRUint64; -#elif defined(WIN32) && !defined(__GNUC__) -typedef __int64 PRInt64; -typedef unsigned __int64 PRUint64; -#else -typedef long long PRInt64; -typedef unsigned long long PRUint64; -#endif /* PR_BYTES_PER_LONG == 8 */ -#else /* !HAVE_LONG_LONG */ -typedef struct { -#ifdef IS_LITTLE_ENDIAN - PRUint32 lo, hi; -#else - PRUint32 hi, lo; -#endif -} PRInt64; -typedef PRInt64 PRUint64; -#endif /* !HAVE_LONG_LONG */ - -/************************************************************************ -** TYPES: PRUintn -** PRIntn -** DESCRIPTION: -** The PRIntn types are most appropriate for automatic variables. They are -** guaranteed to be at least 16 bits, though various architectures may -** define them to be wider (e.g., 32 or even 64 bits). These types are -** never valid for fields of a structure. -************************************************************************/ -#if PR_BYTES_PER_INT >= 2 -typedef int PRIntn; -typedef unsigned int PRUintn; -#else -#error 'sizeof(int)' not sufficient for platform use -#endif - -/************************************************************************ -** TYPES: PRFloat64 -** DESCRIPTION: -** NSPR's floating point type is always 64 bits. -************************************************************************/ -typedef double PRFloat64; - -/************************************************************************ -** TYPES: PRSize -** DESCRIPTION: -** A type for representing the size of objects. -************************************************************************/ -typedef size_t PRSize; - - -/************************************************************************ -** TYPES: PROffset32, PROffset64 -** DESCRIPTION: -** A type for representing byte offsets from some location. -************************************************************************/ -typedef PRInt32 PROffset32; -typedef PRInt64 PROffset64; - -/************************************************************************ -** TYPES: PRPtrDiff -** DESCRIPTION: -** A type for pointer difference. Variables of this type are suitable -** for storing a pointer or pointer subtraction. -************************************************************************/ -typedef ptrdiff_t PRPtrdiff; - -/************************************************************************ -** TYPES: PRUptrdiff -** DESCRIPTION: -** A type for pointer difference. Variables of this type are suitable -** for storing a pointer or pointer sutraction. -************************************************************************/ -#ifdef _WIN64 -typedef unsigned __int64 PRUptrdiff; -#else -typedef unsigned long PRUptrdiff; -#endif - -/************************************************************************ -** TYPES: PRBool -** DESCRIPTION: -** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE -** for clarity of target type in assignments and actual arguments. Use -** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans -** just as you would C int-valued conditions. -************************************************************************/ -typedef PRIntn PRBool; -#define PR_TRUE 1 -#define PR_FALSE 0 - -/************************************************************************ -** TYPES: PRPackedBool -** DESCRIPTION: -** Use PRPackedBool within structs where bitfields are not desirable -** but minimum and consistant overhead matters. -************************************************************************/ -typedef PRUint8 PRPackedBool; - -/* -** Status code used by some routines that have a single point of failure or -** special status return. -*/ -typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus; - -#ifndef __PRUNICHAR__ -#define __PRUNICHAR__ -#if defined(WIN32) || defined(XP_MAC) -typedef wchar_t PRUnichar; -#else -typedef PRUint16 PRUnichar; -#endif -#endif - -/* -** WARNING: The undocumented data types PRWord and PRUword are -** only used in the garbage collection and arena code. Do not -** use PRWord and PRUword in new code. -** -** A PRWord is an integer that is the same size as a void*. -** It implements the notion of a "word" in the Java Virtual -** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine -** Specification, Addison-Wesley, September 1996. -** http://java.sun.com/docs/books/vmspec/index.html.) -*/ -#ifdef _WIN64 -typedef __int64 PRWord; -typedef unsigned __int64 PRUword; -#else -typedef long PRWord; -typedef unsigned long PRUword; -#endif - -#if defined(NO_NSPR_10_SUPPORT) -#else -/********* ???????????????? FIX ME ??????????????????????????? *****/ -/********************** Some old definitions until pr=>ds transition is done ***/ -/********************** Also, we are still using NSPR 1.0. GC ******************/ -/* -** Fundamental NSPR macros, used nearly everywhere. -*/ - -#define PR_PUBLIC_API PR_IMPLEMENT - -/* -** Macro body brackets so that macros with compound statement definitions -** behave syntactically more like functions when called. -*/ -#define NSPR_BEGIN_MACRO do { -#define NSPR_END_MACRO } while (0) - -/* -** Macro shorthands for conditional C++ extern block delimiters. -*/ -#ifdef NSPR_BEGIN_EXTERN_C -#undef NSPR_BEGIN_EXTERN_C -#endif -#ifdef NSPR_END_EXTERN_C -#undef NSPR_END_EXTERN_C -#endif - -#ifdef __cplusplus -#define NSPR_BEGIN_EXTERN_C extern "C" { -#define NSPR_END_EXTERN_C } -#else -#define NSPR_BEGIN_EXTERN_C -#define NSPR_END_EXTERN_C -#endif - -#ifdef XP_MAC -#include "protypes.h" -#else -#include "obsolete/protypes.h" -#endif - -/********* ????????????? End Fix me ?????????????????????????????? *****/ -#endif /* NO_NSPR_10_SUPPORT */ - -PR_END_EXTERN_C - -#endif /* prtypes_h___ */ - +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Netscape Portable Runtime (NSPR). + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* +** File: prtypes.h +** Description: Definitions of NSPR's basic types +** +** Prototypes and macros used to make up for deficiencies that we have found +** in ANSI environments. +** +** Since we do not wrap and all the other standard headers, authors +** of portable code will not know in general that they need these definitions. +** Instead of requiring these authors to find the dependent uses in their code +** and take the following steps only in those C files, we take steps once here +** for all C files. +**/ + +#ifndef prtypes_h___ +#define prtypes_h___ + +#ifdef MDCPUCFG +#include MDCPUCFG +#else +#include "prcpucfg.h" +#endif + +#include + +/*********************************************************************** +** MACROS: PR_EXTERN +** PR_IMPLEMENT +** DESCRIPTION: +** These are only for externally visible routines and globals. For +** internal routines, just use "extern" for type checking and that +** will not export internal cross-file or forward-declared symbols. +** Define a macro for declaring procedures return types. We use this to +** deal with windoze specific type hackery for DLL definitions. Use +** PR_EXTERN when the prototype for the method is declared. Use +** PR_IMPLEMENT for the implementation of the method. +** +** Example: +** in dowhim.h +** PR_EXTERN( void ) DoWhatIMean( void ); +** in dowhim.c +** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; } +** +** +***********************************************************************/ +#if defined(WIN32) + +#define PR_EXPORT(__type) extern __declspec(dllexport) __type +#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPORT(__type) __declspec(dllimport) __type +#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type + +#define PR_EXTERN(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT(__type) __declspec(dllexport) __type +#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type + +#define PR_CALLBACK +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x + +#elif defined(XP_BEOS) + +#define PR_EXPORT(__type) extern __declspec(dllexport) __type +#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPORT(__type) extern __declspec(dllexport) __type +#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type + +#define PR_EXTERN(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT(__type) __declspec(dllexport) __type +#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type + +#define PR_CALLBACK +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x + +#elif defined(WIN16) + +#define PR_CALLBACK_DECL __cdecl + +#if defined(_WINDLL) +#define PR_EXPORT(__type) extern __type _cdecl _export _loadds +#define PR_IMPORT(__type) extern __type _cdecl _export _loadds +#define PR_EXPORT_DATA(__type) extern __type _export +#define PR_IMPORT_DATA(__type) extern __type _export + +#define PR_EXTERN(__type) extern __type _cdecl _export _loadds +#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds +#define PR_EXTERN_DATA(__type) extern __type _export +#define PR_IMPLEMENT_DATA(__type) __type _export + +#define PR_CALLBACK __cdecl __loadds +#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK + +#else /* this must be .EXE */ +#define PR_EXPORT(__type) extern __type _cdecl _export +#define PR_IMPORT(__type) extern __type _cdecl _export +#define PR_EXPORT_DATA(__type) extern __type _export +#define PR_IMPORT_DATA(__type) extern __type _export + +#define PR_EXTERN(__type) extern __type _cdecl _export +#define PR_IMPLEMENT(__type) __type _cdecl _export +#define PR_EXTERN_DATA(__type) extern __type _export +#define PR_IMPLEMENT_DATA(__type) __type _export + +#define PR_CALLBACK __cdecl __loadds +#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK +#endif /* _WINDLL */ + +#elif defined(XP_MAC) + +#define PR_EXPORT(__type) extern __declspec(export) __type +#define PR_EXPORT_DATA(__type) extern __declspec(export) __type +#define PR_IMPORT(__type) extern __declspec(export) __type +#define PR_IMPORT_DATA(__type) extern __declspec(export) __type + +#define PR_EXTERN(__type) extern __declspec(export) __type +#define PR_IMPLEMENT(__type) __declspec(export) __type +#define PR_EXTERN_DATA(__type) extern __declspec(export) __type +#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type + +#define PR_CALLBACK +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x + +#elif defined(XP_OS2) && defined(__declspec) + +#define PR_EXPORT(__type) extern __declspec(dllexport) __type +#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPORT(__type) extern __declspec(dllimport) __type +#define PR_IMPORT_DATA(__type) extern __declspec(dllimport) __type + +#define PR_EXTERN(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT(__type) __declspec(dllexport) __type +#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type +#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type + +#define PR_CALLBACK +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x + +#elif defined(XP_OS2_VACPP) + +#define PR_EXPORT(__type) extern __type +#define PR_EXPORT_DATA(__type) extern __type +#define PR_IMPORT(__type) extern __type +#define PR_IMPORT_DATA(__type) extern __type + +#define PR_EXTERN(__type) extern __type +#define PR_IMPLEMENT(__type) __type +#define PR_EXTERN_DATA(__type) extern __type +#define PR_IMPLEMENT_DATA(__type) __type +#define PR_CALLBACK _Optlink +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK + +#else /* Unix */ + +/* GCC 3.3 and later support the visibility attribute. */ +#if (__GNUC__ >= 4) || \ + (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) +#define PR_VISIBILITY_DEFAULT __attribute__((visibility("default"))) +#else +#define PR_VISIBILITY_DEFAULT +#endif + +#define PR_EXPORT(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_EXPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_IMPORT(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_IMPORT_DATA(__type) extern PR_VISIBILITY_DEFAULT __type + +#define PR_EXTERN(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_IMPLEMENT(__type) PR_VISIBILITY_DEFAULT __type +#define PR_EXTERN_DATA(__type) extern PR_VISIBILITY_DEFAULT __type +#define PR_IMPLEMENT_DATA(__type) PR_VISIBILITY_DEFAULT __type +#define PR_CALLBACK +#define PR_CALLBACK_DECL +#define PR_STATIC_CALLBACK(__x) static __x + +#endif + +#if defined(_NSPR_BUILD_) +#define NSPR_API(__type) PR_EXPORT(__type) +#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type) +#else +#define NSPR_API(__type) PR_IMPORT(__type) +#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type) +#endif + +/*********************************************************************** +** MACROS: PR_BEGIN_MACRO +** PR_END_MACRO +** DESCRIPTION: +** Macro body brackets so that macros with compound statement definitions +** behave syntactically more like functions when called. +***********************************************************************/ +#define PR_BEGIN_MACRO do { +#define PR_END_MACRO } while (0) + +/*********************************************************************** +** MACROS: PR_BEGIN_EXTERN_C +** PR_END_EXTERN_C +** DESCRIPTION: +** Macro shorthands for conditional C++ extern block delimiters. +***********************************************************************/ +#ifdef __cplusplus +#define PR_BEGIN_EXTERN_C extern "C" { +#define PR_END_EXTERN_C } +#else +#define PR_BEGIN_EXTERN_C +#define PR_END_EXTERN_C +#endif + +/*********************************************************************** +** MACROS: PR_BIT +** PR_BITMASK +** DESCRIPTION: +** Bit masking macros. XXX n must be <= 31 to be portable +***********************************************************************/ +#define PR_BIT(n) ((PRUint32)1 << (n)) +#define PR_BITMASK(n) (PR_BIT(n) - 1) + +/*********************************************************************** +** MACROS: PR_ROUNDUP +** PR_MIN +** PR_MAX +** PR_ABS +** DESCRIPTION: +** Commonly used macros for operations on compatible types. +***********************************************************************/ +#define PR_ROUNDUP(x,y) ((((x)+((y)-1))/(y))*(y)) +#define PR_MIN(x,y) ((x)<(y)?(x):(y)) +#define PR_MAX(x,y) ((x)>(y)?(x):(y)) +#define PR_ABS(x) ((x)<0?-(x):(x)) + +PR_BEGIN_EXTERN_C + +/************************************************************************ +** TYPES: PRUint8 +** PRInt8 +** DESCRIPTION: +** The int8 types are known to be 8 bits each. There is no type that +** is equivalent to a plain "char". +************************************************************************/ +#if PR_BYTES_PER_BYTE == 1 +typedef unsigned char PRUint8; +/* +** Some cfront-based C++ compilers do not like 'signed char' and +** issue the warning message: +** warning: "signed" not implemented (ignored) +** For these compilers, we have to define PRInt8 as plain 'char'. +** Make sure that plain 'char' is indeed signed under these compilers. +*/ +#if (defined(HPUX) && defined(__cplusplus) \ + && !defined(__GNUC__) && __cplusplus < 199707L) \ + || (defined(SCO) && defined(__cplusplus) \ + && !defined(__GNUC__) && __cplusplus == 1L) +typedef char PRInt8; +#else +typedef signed char PRInt8; +#endif +#else +#error No suitable type for PRInt8/PRUint8 +#endif + +/************************************************************************ + * MACROS: PR_INT8_MAX + * PR_INT8_MIN + * PR_UINT8_MAX + * DESCRIPTION: + * The maximum and minimum values of a PRInt8 or PRUint8. +************************************************************************/ + +#define PR_INT8_MAX 127 +#define PR_INT8_MIN (-128) +#define PR_UINT8_MAX 255U + +/************************************************************************ +** TYPES: PRUint16 +** PRInt16 +** DESCRIPTION: +** The int16 types are known to be 16 bits each. +************************************************************************/ +#if PR_BYTES_PER_SHORT == 2 +typedef unsigned short PRUint16; +typedef short PRInt16; +#else +#error No suitable type for PRInt16/PRUint16 +#endif + +/************************************************************************ + * MACROS: PR_INT16_MAX + * PR_INT16_MIN + * PR_UINT16_MAX + * DESCRIPTION: + * The maximum and minimum values of a PRInt16 or PRUint16. +************************************************************************/ + +#define PR_INT16_MAX 32767 +#define PR_INT16_MIN (-32768) +#define PR_UINT16_MAX 65535U + +/************************************************************************ +** TYPES: PRUint32 +** PRInt32 +** DESCRIPTION: +** The int32 types are known to be 32 bits each. +************************************************************************/ +#if PR_BYTES_PER_INT == 4 +typedef unsigned int PRUint32; +typedef int PRInt32; +#define PR_INT32(x) x +#define PR_UINT32(x) x ## U +#elif PR_BYTES_PER_LONG == 4 +typedef unsigned long PRUint32; +typedef long PRInt32; +#define PR_INT32(x) x ## L +#define PR_UINT32(x) x ## UL +#else +#error No suitable type for PRInt32/PRUint32 +#endif + +/************************************************************************ + * MACROS: PR_INT32_MAX + * PR_INT32_MIN + * PR_UINT32_MAX + * DESCRIPTION: + * The maximum and minimum values of a PRInt32 or PRUint32. +************************************************************************/ + +#define PR_INT32_MAX PR_INT32(2147483647) +#define PR_INT32_MIN (-PR_INT32_MAX - 1) +#define PR_UINT32_MAX PR_UINT32(4294967295) + +/************************************************************************ +** TYPES: PRUint64 +** PRInt64 +** DESCRIPTION: +** The int64 types are known to be 64 bits each. Care must be used when +** declaring variables of type PRUint64 or PRInt64. Different hardware +** architectures and even different compilers have varying support for +** 64 bit values. The only guaranteed portability requires the use of +** the LL_ macros (see prlong.h). +************************************************************************/ +#ifdef HAVE_LONG_LONG +#if PR_BYTES_PER_LONG == 8 +typedef long PRInt64; +typedef unsigned long PRUint64; +#elif defined(WIN16) +typedef __int64 PRInt64; +typedef unsigned __int64 PRUint64; +#elif defined(WIN32) && !defined(__GNUC__) +typedef __int64 PRInt64; +typedef unsigned __int64 PRUint64; +#else +typedef long long PRInt64; +typedef unsigned long long PRUint64; +#endif /* PR_BYTES_PER_LONG == 8 */ +#else /* !HAVE_LONG_LONG */ +typedef struct { +#ifdef IS_LITTLE_ENDIAN + PRUint32 lo, hi; +#else + PRUint32 hi, lo; +#endif +} PRInt64; +typedef PRInt64 PRUint64; +#endif /* !HAVE_LONG_LONG */ + +/************************************************************************ +** TYPES: PRUintn +** PRIntn +** DESCRIPTION: +** The PRIntn types are most appropriate for automatic variables. They are +** guaranteed to be at least 16 bits, though various architectures may +** define them to be wider (e.g., 32 or even 64 bits). These types are +** never valid for fields of a structure. +************************************************************************/ +#if PR_BYTES_PER_INT >= 2 +typedef int PRIntn; +typedef unsigned int PRUintn; +#else +#error 'sizeof(int)' not sufficient for platform use +#endif + +/************************************************************************ +** TYPES: PRFloat64 +** DESCRIPTION: +** NSPR's floating point type is always 64 bits. +************************************************************************/ +typedef double PRFloat64; + +/************************************************************************ +** TYPES: PRSize +** DESCRIPTION: +** A type for representing the size of objects. +************************************************************************/ +typedef size_t PRSize; + + +/************************************************************************ +** TYPES: PROffset32, PROffset64 +** DESCRIPTION: +** A type for representing byte offsets from some location. +************************************************************************/ +typedef PRInt32 PROffset32; +typedef PRInt64 PROffset64; + +/************************************************************************ +** TYPES: PRPtrDiff +** DESCRIPTION: +** A type for pointer difference. Variables of this type are suitable +** for storing a pointer or pointer subtraction. +************************************************************************/ +typedef ptrdiff_t PRPtrdiff; + +/************************************************************************ +** TYPES: PRUptrdiff +** DESCRIPTION: +** A type for pointer difference. Variables of this type are suitable +** for storing a pointer or pointer sutraction. +************************************************************************/ +#ifdef _WIN64 +typedef unsigned __int64 PRUptrdiff; +#else +typedef unsigned long PRUptrdiff; +#endif + +/************************************************************************ +** TYPES: PRBool +** DESCRIPTION: +** Use PRBool for variables and parameter types. Use PR_FALSE and PR_TRUE +** for clarity of target type in assignments and actual arguments. Use +** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans +** just as you would C int-valued conditions. +************************************************************************/ +typedef PRIntn PRBool; +#define PR_TRUE 1 +#define PR_FALSE 0 + +/************************************************************************ +** TYPES: PRPackedBool +** DESCRIPTION: +** Use PRPackedBool within structs where bitfields are not desirable +** but minimum and consistant overhead matters. +************************************************************************/ +typedef PRUint8 PRPackedBool; + +/* +** Status code used by some routines that have a single point of failure or +** special status return. +*/ +typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus; + +#ifndef __PRUNICHAR__ +#define __PRUNICHAR__ +#if defined(WIN32) || defined(XP_MAC) +typedef wchar_t PRUnichar; +#else +typedef PRUint16 PRUnichar; +#endif +#endif + +/* +** WARNING: The undocumented data types PRWord and PRUword are +** only used in the garbage collection and arena code. Do not +** use PRWord and PRUword in new code. +** +** A PRWord is an integer that is the same size as a void*. +** It implements the notion of a "word" in the Java Virtual +** Machine. (See Sec. 3.4 "Words", The Java Virtual Machine +** Specification, Addison-Wesley, September 1996. +** http://java.sun.com/docs/books/vmspec/index.html.) +*/ +#ifdef _WIN64 +typedef __int64 PRWord; +typedef unsigned __int64 PRUword; +#else +typedef long PRWord; +typedef unsigned long PRUword; +#endif + +#if defined(NO_NSPR_10_SUPPORT) +#else +/********* ???????????????? FIX ME ??????????????????????????? *****/ +/********************** Some old definitions until pr=>ds transition is done ***/ +/********************** Also, we are still using NSPR 1.0. GC ******************/ +/* +** Fundamental NSPR macros, used nearly everywhere. +*/ + +#define PR_PUBLIC_API PR_IMPLEMENT + +/* +** Macro body brackets so that macros with compound statement definitions +** behave syntactically more like functions when called. +*/ +#define NSPR_BEGIN_MACRO do { +#define NSPR_END_MACRO } while (0) + +/* +** Macro shorthands for conditional C++ extern block delimiters. +*/ +#ifdef NSPR_BEGIN_EXTERN_C +#undef NSPR_BEGIN_EXTERN_C +#endif +#ifdef NSPR_END_EXTERN_C +#undef NSPR_END_EXTERN_C +#endif + +#ifdef __cplusplus +#define NSPR_BEGIN_EXTERN_C extern "C" { +#define NSPR_END_EXTERN_C } +#else +#define NSPR_BEGIN_EXTERN_C +#define NSPR_END_EXTERN_C +#endif + +#ifdef XP_MAC +#include "obsolete/protypes.h" +#else +#include "obsolete/protypes.h" +#endif + +/********* ????????????? End Fix me ?????????????????????????????? *****/ +#endif /* NO_NSPR_10_SUPPORT */ + +PR_END_EXTERN_C + +#endif /* prtypes_h___ */ diff --git a/extras/juce demo/src/MainDemoWindow.cpp b/extras/juce demo/src/MainDemoWindow.cpp index 6d7f2b0ebc..622d11afd9 100644 --- a/extras/juce demo/src/MainDemoWindow.cpp +++ b/extras/juce demo/src/MainDemoWindow.cpp @@ -376,7 +376,7 @@ public: result.setInfo (T("Web Browser"), T("Shows the web browser demo"), demosCategory, 0); result.addDefaultKeypress (T('i'), ModifierKeys::commandModifier); result.setTicked (currentDemoId == showWebBrowser); -#if ! JUCE_WEB_BROWSER +#if (! JUCE_WEB_BROWSER) || JUCE_LINUX result.setActive (false); #endif break; diff --git a/extras/the jucer/src/BinaryData.cpp b/extras/the jucer/src/BinaryData.cpp index c08fddd03e..1279f531a8 100644 --- a/extras/the jucer/src/BinaryData.cpp +++ b/extras/the jucer/src/BinaryData.cpp @@ -911,4 +911,3 @@ static const unsigned char temp4[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68 0,98,28,9,155,95,0,2,104,68,236,11,1,8,160,17,225,73,128,0,3,0,120,52,172,151,198,78,252,63,0,0,0,0,73,69,78,68,174,66, 96,130,0,0}; const char* BinaryData::prefs_misc_png = (const char*) temp4; - diff --git a/extras/the jucer/src/model/components/jucer_ViewportHandler.h b/extras/the jucer/src/model/components/jucer_ViewportHandler.h index 68b5ba3fa4..ccf633724a 100644 --- a/extras/the jucer/src/model/components/jucer_ViewportHandler.h +++ b/extras/the jucer/src/model/components/jucer_ViewportHandler.h @@ -1,692 +1,692 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#ifndef __JUCER_VIEWPORTHANDLER_JUCEHEADER__ -#define __JUCER_VIEWPORTHANDLER_JUCEHEADER__ - - -//============================================================================== -/** -*/ -class ViewportHandler : public ComponentTypeHandler -{ -public: - //============================================================================== - ViewportHandler() - : ComponentTypeHandler ("Viewport", "Viewport", typeid (UpdatingViewport), 150, 150) - {} - - //============================================================================== - Component* createNewComponent (JucerDocument*) - { - Viewport* const v = new UpdatingViewport (T("new viewport")); - v->setViewedComponent (new ViewportDemoContentComp()); - - return v; - } - - XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout) - { - Viewport* const v = dynamic_cast (comp); - XmlElement* const e = ComponentTypeHandler::createXmlFor (comp, layout); - - e->setAttribute (T("vscroll"), v->isVerticalScrollBarShown()); - e->setAttribute (T("hscroll"), v->isHorizontalScrollBarShown()); - e->setAttribute (T("scrollbarThickness"), v->getScrollBarThickness()); - - e->setAttribute (T("contentType"), getViewportContentType (v)); - e->setAttribute (T("jucerFile"), getViewportJucerComponentFile (v)); - e->setAttribute (T("contentClass"), getViewportGenericComponentClass (v)); - e->setAttribute (T("constructorParams"), getViewportConstructorParams (v)); - - return e; - } - - bool restoreFromXml (const XmlElement& xml, Component* comp, const ComponentLayout* layout) - { - if (! ComponentTypeHandler::restoreFromXml (xml, comp, layout)) - return false; - - Viewport defaultViewport; - Viewport* const v = dynamic_cast (comp); - v->setScrollBarsShown (xml.getBoolAttribute (T("vscroll"), defaultViewport.isVerticalScrollBarShown()), - xml.getBoolAttribute (T("hscroll"), defaultViewport.isHorizontalScrollBarShown())); - - v->setScrollBarThickness (xml.getIntAttribute (T("scrollbarThickness"), defaultViewport.getScrollBarThickness())); - - setViewportJucerComponentFile (v, xml.getStringAttribute (T("jucerFile"), String::empty)); - setViewportGenericComponentClass (v, xml.getStringAttribute (T("contentClass"))); - setViewportContentType (v, xml.getIntAttribute (T("contentType"), 0)); - setViewportConstructorParams (v, xml.getStringAttribute (T("constructorParams"))); - - return true; - } - - void getEditableProperties (Component* component, JucerDocument& document, Array & properties) - { - ComponentTypeHandler::getEditableProperties (component, document, properties); - - Viewport* const v = dynamic_cast (component); - - properties.add (new ViewportScrollbarShownProperty (v, document, true)); - properties.add (new ViewportScrollbarShownProperty (v, document, false)); - properties.add (new ViewportScrollbarSizeProperty (v, document)); - properties.add (new ViewportContentTypeProperty (v, document)); - - if (getViewportContentType (v) == 1) - { - properties.add (new ViewportJucerFileProperty (v, document)); - properties.add (new ConstructorParamsProperty (v, document)); - } - else if (getViewportContentType (v) == 2) - { - properties.add (new ViewportContentClassProperty (v, document)); - properties.add (new ConstructorParamsProperty (v, document)); - } - } - - const String getCreationParameters (Component* comp) - { - return quotedString (comp->getName()); - } - - void fillInCreationCode (GeneratedCode& code, Component* component, const String& memberVariableName) - { - Viewport defaultViewport; - Viewport* const v = dynamic_cast (component); - - ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName); - - if (defaultViewport.isVerticalScrollBarShown() != v->isVerticalScrollBarShown() - || defaultViewport.isHorizontalScrollBarShown() != v->isHorizontalScrollBarShown()) - { - code.constructorCode - << memberVariableName << "->setScrollBarsShown (" - << boolToString (v->isVerticalScrollBarShown()) << ", " - << boolToString (v->isHorizontalScrollBarShown()) << ");\n"; - } - - if (defaultViewport.getScrollBarThickness() != v->getScrollBarThickness()) - { - code.constructorCode - << memberVariableName << "->setScrollBarThickness (" - << v->getScrollBarThickness() << ");\n"; - } - - if (getViewportContentType (v) != 0) - { - String className (getViewportGenericComponentClass (v)); - - if (getViewportContentType (v) == 1) - { - File file; - - const String filename (getViewportJucerComponentFile (v)); - - if (filename.isNotEmpty()) - file = code.document->getFile().getSiblingFile (filename); - - JucerDocument* doc = ObjectTypes::loadDocumentFromFile (file, false); - - if (doc != 0) - { - code.includeFilesCPP.add (doc->getFile().withFileExtension (T("h")) - .getRelativePathFrom (code.document->getFile().getParentDirectory()) - .replaceCharacter (T('\\'), T('/'))); - - className = doc->getClassName(); - delete doc; - } - else - { - className = String::empty; - } - } - - if (className.isNotEmpty()) - { - code.constructorCode - << memberVariableName << "->setViewedComponent (new " - << className; - - if (getViewportConstructorParams (v).trim().isNotEmpty()) - { - code.constructorCode << " (" << getViewportConstructorParams (v).trim() << "));\n"; - } - else - { - code.constructorCode << "());\n"; - } - } - } - - code.constructorCode << "\n"; - } - - static void updateViewportContentComp (Viewport* vp) - { - if (getViewportContentType (vp) == 1) - { - JucerDocument* doc = findParentDocument (vp); - TestComponent* tc = new TestComponent (doc, 0, false); - - tc->setFilename (getViewportJucerComponentFile (vp)); - tc->setToInitialSize(); - - vp->setViewedComponent (tc); - } - else - { - vp->setViewedComponent (new ViewportDemoContentComp()); - } - } - - static int getViewportContentType (Viewport* vp) - { - return vp->getComponentPropertyInt (T("contentType"), false, 0); - } - - static void setViewportContentType (Viewport* vp, int newValue) - { - if (newValue != getViewportContentType (vp)) - { - vp->setComponentProperty (T("contentType"), newValue); - updateViewportContentComp (vp); - } - } - - static const String getViewportJucerComponentFile (Viewport* vp) - { - return vp->getComponentProperty (T("jucerFile"), false); - } - - static void setViewportJucerComponentFile (Viewport* vp, const String& file) - { - if (file != getViewportJucerComponentFile (vp)) - { - vp->setComponentProperty (T("jucerFile"), file); - updateViewportContentComp (vp); - } - } - - static const String getViewportGenericComponentClass (Viewport* vp) - { - return vp->getComponentProperty (T("contentClass"), false); - } - - static void setViewportGenericComponentClass (Viewport* vp, const String& className) - { - if (className != getViewportGenericComponentClass (vp)) - { - vp->setComponentProperty (T("contentClass"), className); - updateViewportContentComp (vp); - } - } - - static const String getViewportConstructorParams (Viewport* vp) - { - return vp->getComponentProperty (T("constructorParams"), false); - } - - static void setViewportConstructorParams (Viewport* vp, const String& newParams) - { - if (newParams != getViewportConstructorParams (vp)) - { - vp->setComponentProperty (T("constructorParams"), newParams); - updateViewportContentComp (vp); - } - } - - juce_UseDebuggingNewOperator - -private: - //============================================================================== - class UpdatingViewport : public Viewport - { - public: - UpdatingViewport (const String& name) - : Viewport (name) - { - } - - ~UpdatingViewport() - { - } - - void parentHierarchyChanged() - { - Viewport::parentHierarchyChanged(); - updateViewportContentComp (this); - } - }; - - //============================================================================== - class ViewportDemoContentComp : public Component - { - public: - ViewportDemoContentComp() - { - setSize (2048, 2048); - } - - ~ViewportDemoContentComp() - { - } - - void paint (Graphics& g) - { - g.fillCheckerBoard (0, 0, getWidth(), getHeight(), - 50, 50, - Colours::lightgrey.withAlpha (0.5f), - Colours::darkgrey.withAlpha (0.5f)); - } - }; - - //============================================================================== - class ViewportScrollbarShownProperty : public ComponentBooleanProperty - { - public: - ViewportScrollbarShownProperty (Viewport* comp, JucerDocument& document, const bool vertical_) - : ComponentBooleanProperty (vertical_ ? T("V scrollbar") : T("H scrollbar"), - T("enabled"), T("enabled"), - comp, document), - vertical (vertical_) - { - } - - void setState (const bool newState) - { - document.perform (new ViewportScrollbarChangeAction (component, *document.getComponentLayout(), vertical, newState), - T("Change Viewport scrollbar")); - } - - bool getState() const - { - return vertical ? component->isVerticalScrollBarShown() - : component->isHorizontalScrollBarShown(); - } - - const bool vertical; - - private: - class ViewportScrollbarChangeAction : public ComponentUndoableAction - { - public: - ViewportScrollbarChangeAction (Viewport* const comp, ComponentLayout& layout, const bool vertical_, const bool newState_) - : ComponentUndoableAction (comp, layout), - vertical (vertical_), - newState (newState_) - { - oldState = vertical ? comp->isVerticalScrollBarShown() - : comp->isHorizontalScrollBarShown(); - } - - bool perform() - { - showCorrectTab(); - if (vertical) - getComponent()->setScrollBarsShown (newState, getComponent()->isHorizontalScrollBarShown()); - else - getComponent()->setScrollBarsShown (getComponent()->isVerticalScrollBarShown(), newState); - - changed(); - return true; - } - - bool undo() - { - showCorrectTab(); - if (vertical) - getComponent()->setScrollBarsShown (oldState, getComponent()->isHorizontalScrollBarShown()); - else - getComponent()->setScrollBarsShown (getComponent()->isVerticalScrollBarShown(), oldState); - changed(); - return true; - } - - bool vertical, newState, oldState; - }; - }; - - //============================================================================== - class ViewportScrollbarSizeProperty : public SliderPropertyComponent, - public ChangeListener - { - public: - ViewportScrollbarSizeProperty (Viewport* comp, JucerDocument& document_) - : SliderPropertyComponent (T("scrollbar size"), 3.0, 30.0, 1.0, 1.0), - component (comp), - document (document_) - { - document.addChangeListener (this); - } - - ~ViewportScrollbarSizeProperty() - { - document.removeChangeListener (this); - } - - void setValue (const double newValue) - { - document.getUndoManager().undoCurrentTransactionOnly(); - - document.perform (new ViewportScrollbarSizeChangeAction (component, *document.getComponentLayout(), roundDoubleToInt (newValue)), - T("Change Viewport scrollbar size")); - } - - const double getValue() const - { - return component->getScrollBarThickness(); - } - - void changeListenerCallback (void*) - { - refresh(); - } - - Viewport* component; - JucerDocument& document; - - private: - class ViewportScrollbarSizeChangeAction : public ComponentUndoableAction - { - public: - ViewportScrollbarSizeChangeAction (Viewport* const comp, ComponentLayout& layout, const int newState_) - : ComponentUndoableAction (comp, layout), - newState (newState_) - { - oldState = comp->getScrollBarThickness(); - } - - bool perform() - { - showCorrectTab(); - getComponent()->setScrollBarThickness (newState); - changed(); - return true; - } - - bool undo() - { - showCorrectTab(); - getComponent()->setScrollBarThickness (newState); - changed(); - return true; - } - - int newState, oldState; - }; - }; - - //============================================================================== - class ViewportContentTypeProperty : public ComponentChoiceProperty - { - public: - ViewportContentTypeProperty (Viewport* comp, JucerDocument& document) - : ComponentChoiceProperty (T("content"), comp, document) - { - choices.add (T("No content component")); - choices.add (T("Jucer content component")); - choices.add (T("Named content component")); - } - - void setIndex (const int newIndex) - { - document.perform (new ViewportContentTypeChangeAction (component, *document.getComponentLayout(), newIndex), - T("Change Viewport content type")); - } - - int getIndex() const - { - return getViewportContentType (component); - } - - private: - class ViewportContentTypeChangeAction : public ComponentUndoableAction - { - public: - ViewportContentTypeChangeAction (Viewport* const comp, ComponentLayout& layout, const int newValue_) - : ComponentUndoableAction (comp, layout), - newValue (newValue_) - { - oldValue = getViewportContentType (comp); - } - - bool perform() - { - showCorrectTab(); - setViewportContentType (getComponent(), newValue); - changed(); - layout.getDocument()->refreshAllPropertyComps(); - return true; - } - - bool undo() - { - showCorrectTab(); - setViewportContentType (getComponent(), oldValue); - changed(); - layout.getDocument()->refreshAllPropertyComps(); - return true; - } - - int newValue, oldValue; - }; - }; - - //============================================================================== - class ViewportJucerFileProperty : public FilePropertyComponent, - public ChangeListener - { - public: - ViewportJucerFileProperty (Viewport* const component_, JucerDocument& document_) - : FilePropertyComponent (T("Jucer file"), false, true), - component (component_), - document (document_) - { - document.addChangeListener (this); - } - - ~ViewportJucerFileProperty() - { - document.removeChangeListener (this); - } - - //============================================================================== - void setFile (const File& newFile) - { - document.perform (new JucerCompFileChangeAction (component, *document.getComponentLayout(), - newFile.getRelativePathFrom (document.getFile().getParentDirectory()) - .replaceCharacter (T('\\'), T('/')) -), - T("Change Jucer component file")); - } - - const File getFile() const - { - const String filename (getViewportJucerComponentFile (component)); - - if (filename.isEmpty()) - return File::nonexistent; - - return document.getFile().getSiblingFile (filename); - } - - void changeListenerCallback (void*) - { - refresh(); - } - - private: - Viewport* const component; - JucerDocument& document; - - class JucerCompFileChangeAction : public ComponentUndoableAction - { - public: - JucerCompFileChangeAction (Viewport* const comp, ComponentLayout& layout, const String& newState_) - : ComponentUndoableAction (comp, layout), - newState (newState_) - { - oldState = getViewportJucerComponentFile (comp); - } - - bool perform() - { - showCorrectTab(); - setViewportJucerComponentFile (getComponent(), newState); - changed(); - return true; - } - - bool undo() - { - showCorrectTab(); - setViewportJucerComponentFile (getComponent(), oldState); - changed(); - return true; - } - - String newState, oldState; - }; - }; - - //============================================================================== - class ViewportContentClassProperty : public ComponentTextProperty - { - public: - ViewportContentClassProperty (Viewport* comp, JucerDocument& document) - : ComponentTextProperty (T("content class"), 256, false, comp, document) - { - } - - void setText (const String& newText) - { - document.perform (new ViewportClassNameChangeAction (component, *document.getComponentLayout(), newText), - T("Change Viewport content class")); - } - - const String getText() const - { - return getViewportGenericComponentClass (component); - } - - private: - class ViewportClassNameChangeAction : public ComponentUndoableAction - { - public: - ViewportClassNameChangeAction (Viewport* const comp, ComponentLayout& layout, const String& newValue_) - : ComponentUndoableAction (comp, layout), - newValue (newValue_) - { - oldValue = getViewportGenericComponentClass (comp); - } - - bool perform() - { - showCorrectTab(); - setViewportGenericComponentClass (getComponent(), newValue); - changed(); - layout.getDocument()->refreshAllPropertyComps(); - return true; - } - - bool undo() - { - showCorrectTab(); - setViewportGenericComponentClass (getComponent(), oldValue); - changed(); - layout.getDocument()->refreshAllPropertyComps(); - return true; - } - - String newValue, oldValue; - }; - }; - - //============================================================================== - class ConstructorParamsProperty : public ComponentTextProperty - { - public: - ConstructorParamsProperty (Viewport* comp, JucerDocument& document) - : ComponentTextProperty (T("constructor params"), 512, false, comp, document) - { - } - - void setText (const String& newText) - { - document.perform (new ConstructorParamChangeAction (component, *document.getComponentLayout(), newText), - T("Change Viewport content constructor params")); - } - - const String getText() const - { - return getViewportConstructorParams (component); - } - - private: - int tabIndex; - - class ConstructorParamChangeAction : public ComponentUndoableAction - { - public: - ConstructorParamChangeAction (Viewport* const comp, ComponentLayout& layout, const String& newValue_) - : ComponentUndoableAction (comp, layout), - newValue (newValue_) - { - oldValue = getViewportConstructorParams (comp); - } - - bool perform() - { - showCorrectTab(); - setViewportConstructorParams (getComponent(), newValue); - changed(); - layout.getDocument()->refreshAllPropertyComps(); - return true; - } - - bool undo() - { - showCorrectTab(); - setViewportConstructorParams (getComponent(), oldValue); - changed(); - layout.getDocument()->refreshAllPropertyComps(); - return true; - } - - String newValue, oldValue; - }; - }; -}; - - -#endif // __JUCER_VIEWPORTHANDLER_JUCEHEADER__ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#ifndef __JUCER_VIEWPORTHANDLER_JUCEHEADER__ +#define __JUCER_VIEWPORTHANDLER_JUCEHEADER__ + + +//============================================================================== +/** +*/ +class ViewportHandler : public ComponentTypeHandler +{ +public: + //============================================================================== + ViewportHandler() + : ComponentTypeHandler ("Viewport", "Viewport", typeid (UpdatingViewport), 150, 150) + {} + + //============================================================================== + Component* createNewComponent (JucerDocument*) + { + Viewport* const v = new UpdatingViewport (T("new viewport")); + v->setViewedComponent (new ViewportDemoContentComp()); + + return v; + } + + XmlElement* createXmlFor (Component* comp, const ComponentLayout* layout) + { + Viewport* const v = dynamic_cast (comp); + XmlElement* const e = ComponentTypeHandler::createXmlFor (comp, layout); + + e->setAttribute (T("vscroll"), v->isVerticalScrollBarShown()); + e->setAttribute (T("hscroll"), v->isHorizontalScrollBarShown()); + e->setAttribute (T("scrollbarThickness"), v->getScrollBarThickness()); + + e->setAttribute (T("contentType"), getViewportContentType (v)); + e->setAttribute (T("jucerFile"), getViewportJucerComponentFile (v)); + e->setAttribute (T("contentClass"), getViewportGenericComponentClass (v)); + e->setAttribute (T("constructorParams"), getViewportConstructorParams (v)); + + return e; + } + + bool restoreFromXml (const XmlElement& xml, Component* comp, const ComponentLayout* layout) + { + if (! ComponentTypeHandler::restoreFromXml (xml, comp, layout)) + return false; + + Viewport defaultViewport; + Viewport* const v = dynamic_cast (comp); + v->setScrollBarsShown (xml.getBoolAttribute (T("vscroll"), defaultViewport.isVerticalScrollBarShown()), + xml.getBoolAttribute (T("hscroll"), defaultViewport.isHorizontalScrollBarShown())); + + v->setScrollBarThickness (xml.getIntAttribute (T("scrollbarThickness"), defaultViewport.getScrollBarThickness())); + + setViewportJucerComponentFile (v, xml.getStringAttribute (T("jucerFile"), String::empty)); + setViewportGenericComponentClass (v, xml.getStringAttribute (T("contentClass"))); + setViewportContentType (v, xml.getIntAttribute (T("contentType"), 0)); + setViewportConstructorParams (v, xml.getStringAttribute (T("constructorParams"))); + + return true; + } + + void getEditableProperties (Component* component, JucerDocument& document, Array & properties) + { + ComponentTypeHandler::getEditableProperties (component, document, properties); + + Viewport* const v = dynamic_cast (component); + + properties.add (new ViewportScrollbarShownProperty (v, document, true)); + properties.add (new ViewportScrollbarShownProperty (v, document, false)); + properties.add (new ViewportScrollbarSizeProperty (v, document)); + properties.add (new ViewportContentTypeProperty (v, document)); + + if (getViewportContentType (v) == 1) + { + properties.add (new ViewportJucerFileProperty (v, document)); + properties.add (new ConstructorParamsProperty (v, document)); + } + else if (getViewportContentType (v) == 2) + { + properties.add (new ViewportContentClassProperty (v, document)); + properties.add (new ConstructorParamsProperty (v, document)); + } + } + + const String getCreationParameters (Component* comp) + { + return quotedString (comp->getName()); + } + + void fillInCreationCode (GeneratedCode& code, Component* component, const String& memberVariableName) + { + Viewport defaultViewport; + Viewport* const v = dynamic_cast (component); + + ComponentTypeHandler::fillInCreationCode (code, component, memberVariableName); + + if (defaultViewport.isVerticalScrollBarShown() != v->isVerticalScrollBarShown() + || defaultViewport.isHorizontalScrollBarShown() != v->isHorizontalScrollBarShown()) + { + code.constructorCode + << memberVariableName << "->setScrollBarsShown (" + << boolToString (v->isVerticalScrollBarShown()) << ", " + << boolToString (v->isHorizontalScrollBarShown()) << ");\n"; + } + + if (defaultViewport.getScrollBarThickness() != v->getScrollBarThickness()) + { + code.constructorCode + << memberVariableName << "->setScrollBarThickness (" + << v->getScrollBarThickness() << ");\n"; + } + + if (getViewportContentType (v) != 0) + { + String className (getViewportGenericComponentClass (v)); + + if (getViewportContentType (v) == 1) + { + File file; + + const String filename (getViewportJucerComponentFile (v)); + + if (filename.isNotEmpty()) + file = code.document->getFile().getSiblingFile (filename); + + JucerDocument* doc = ObjectTypes::loadDocumentFromFile (file, false); + + if (doc != 0) + { + code.includeFilesCPP.add (doc->getFile().withFileExtension (T("h")) + .getRelativePathFrom (code.document->getFile().getParentDirectory()) + .replaceCharacter (T('\\'), T('/'))); + + className = doc->getClassName(); + delete doc; + } + else + { + className = String::empty; + } + } + + if (className.isNotEmpty()) + { + code.constructorCode + << memberVariableName << "->setViewedComponent (new " + << className; + + if (getViewportConstructorParams (v).trim().isNotEmpty()) + { + code.constructorCode << " (" << getViewportConstructorParams (v).trim() << "));\n"; + } + else + { + code.constructorCode << "());\n"; + } + } + } + + code.constructorCode << "\n"; + } + + static void updateViewportContentComp (Viewport* vp) + { + if (getViewportContentType (vp) == 1) + { + JucerDocument* doc = findParentDocument (vp); + TestComponent* tc = new TestComponent (doc, 0, false); + + tc->setFilename (getViewportJucerComponentFile (vp)); + tc->setToInitialSize(); + + vp->setViewedComponent (tc); + } + else + { + vp->setViewedComponent (new ViewportDemoContentComp()); + } + } + + static int getViewportContentType (Viewport* vp) + { + return vp->getComponentPropertyInt (T("contentType"), false, 0); + } + + static void setViewportContentType (Viewport* vp, int newValue) + { + if (newValue != getViewportContentType (vp)) + { + vp->setComponentProperty (T("contentType"), newValue); + updateViewportContentComp (vp); + } + } + + static const String getViewportJucerComponentFile (Viewport* vp) + { + return vp->getComponentProperty (T("jucerFile"), false); + } + + static void setViewportJucerComponentFile (Viewport* vp, const String& file) + { + if (file != getViewportJucerComponentFile (vp)) + { + vp->setComponentProperty (T("jucerFile"), file); + updateViewportContentComp (vp); + } + } + + static const String getViewportGenericComponentClass (Viewport* vp) + { + return vp->getComponentProperty (T("contentClass"), false); + } + + static void setViewportGenericComponentClass (Viewport* vp, const String& className) + { + if (className != getViewportGenericComponentClass (vp)) + { + vp->setComponentProperty (T("contentClass"), className); + updateViewportContentComp (vp); + } + } + + static const String getViewportConstructorParams (Viewport* vp) + { + return vp->getComponentProperty (T("constructorParams"), false); + } + + static void setViewportConstructorParams (Viewport* vp, const String& newParams) + { + if (newParams != getViewportConstructorParams (vp)) + { + vp->setComponentProperty (T("constructorParams"), newParams); + updateViewportContentComp (vp); + } + } + + juce_UseDebuggingNewOperator + +private: + //============================================================================== + class UpdatingViewport : public Viewport + { + public: + UpdatingViewport (const String& name) + : Viewport (name) + { + } + + ~UpdatingViewport() + { + } + + void parentHierarchyChanged() + { + Viewport::parentHierarchyChanged(); + updateViewportContentComp (this); + } + }; + + //============================================================================== + class ViewportDemoContentComp : public Component + { + public: + ViewportDemoContentComp() + { + setSize (2048, 2048); + } + + ~ViewportDemoContentComp() + { + } + + void paint (Graphics& g) + { + g.fillCheckerBoard (0, 0, getWidth(), getHeight(), + 50, 50, + Colours::lightgrey.withAlpha (0.5f), + Colours::darkgrey.withAlpha (0.5f)); + } + }; + + //============================================================================== + class ViewportScrollbarShownProperty : public ComponentBooleanProperty + { + public: + ViewportScrollbarShownProperty (Viewport* comp, JucerDocument& document, const bool vertical_) + : ComponentBooleanProperty (vertical_ ? T("V scrollbar") : T("H scrollbar"), + T("enabled"), T("enabled"), + comp, document), + vertical (vertical_) + { + } + + void setState (const bool newState) + { + document.perform (new ViewportScrollbarChangeAction (component, *document.getComponentLayout(), vertical, newState), + T("Change Viewport scrollbar")); + } + + bool getState() const + { + return vertical ? component->isVerticalScrollBarShown() + : component->isHorizontalScrollBarShown(); + } + + const bool vertical; + + private: + class ViewportScrollbarChangeAction : public ComponentUndoableAction + { + public: + ViewportScrollbarChangeAction (Viewport* const comp, ComponentLayout& layout, const bool vertical_, const bool newState_) + : ComponentUndoableAction (comp, layout), + vertical (vertical_), + newState (newState_) + { + oldState = vertical ? comp->isVerticalScrollBarShown() + : comp->isHorizontalScrollBarShown(); + } + + bool perform() + { + showCorrectTab(); + if (vertical) + getComponent()->setScrollBarsShown (newState, getComponent()->isHorizontalScrollBarShown()); + else + getComponent()->setScrollBarsShown (getComponent()->isVerticalScrollBarShown(), newState); + + changed(); + return true; + } + + bool undo() + { + showCorrectTab(); + if (vertical) + getComponent()->setScrollBarsShown (oldState, getComponent()->isHorizontalScrollBarShown()); + else + getComponent()->setScrollBarsShown (getComponent()->isVerticalScrollBarShown(), oldState); + changed(); + return true; + } + + bool vertical, newState, oldState; + }; + }; + + //============================================================================== + class ViewportScrollbarSizeProperty : public SliderPropertyComponent, + public ChangeListener + { + public: + ViewportScrollbarSizeProperty (Viewport* comp, JucerDocument& document_) + : SliderPropertyComponent (T("scrollbar size"), 3.0, 30.0, 1.0, 1.0), + component (comp), + document (document_) + { + document.addChangeListener (this); + } + + ~ViewportScrollbarSizeProperty() + { + document.removeChangeListener (this); + } + + void setValue (const double newValue) + { + document.getUndoManager().undoCurrentTransactionOnly(); + + document.perform (new ViewportScrollbarSizeChangeAction (component, *document.getComponentLayout(), roundDoubleToInt (newValue)), + T("Change Viewport scrollbar size")); + } + + const double getValue() const + { + return component->getScrollBarThickness(); + } + + void changeListenerCallback (void*) + { + refresh(); + } + + Viewport* component; + JucerDocument& document; + + private: + class ViewportScrollbarSizeChangeAction : public ComponentUndoableAction + { + public: + ViewportScrollbarSizeChangeAction (Viewport* const comp, ComponentLayout& layout, const int newState_) + : ComponentUndoableAction (comp, layout), + newState (newState_) + { + oldState = comp->getScrollBarThickness(); + } + + bool perform() + { + showCorrectTab(); + getComponent()->setScrollBarThickness (newState); + changed(); + return true; + } + + bool undo() + { + showCorrectTab(); + getComponent()->setScrollBarThickness (newState); + changed(); + return true; + } + + int newState, oldState; + }; + }; + + //============================================================================== + class ViewportContentTypeProperty : public ComponentChoiceProperty + { + public: + ViewportContentTypeProperty (Viewport* comp, JucerDocument& document) + : ComponentChoiceProperty (T("content"), comp, document) + { + choices.add (T("No content component")); + choices.add (T("Jucer content component")); + choices.add (T("Named content component")); + } + + void setIndex (const int newIndex) + { + document.perform (new ViewportContentTypeChangeAction (component, *document.getComponentLayout(), newIndex), + T("Change Viewport content type")); + } + + int getIndex() const + { + return getViewportContentType (component); + } + + private: + class ViewportContentTypeChangeAction : public ComponentUndoableAction + { + public: + ViewportContentTypeChangeAction (Viewport* const comp, ComponentLayout& layout, const int newValue_) + : ComponentUndoableAction (comp, layout), + newValue (newValue_) + { + oldValue = getViewportContentType (comp); + } + + bool perform() + { + showCorrectTab(); + setViewportContentType (getComponent(), newValue); + changed(); + layout.getDocument()->refreshAllPropertyComps(); + return true; + } + + bool undo() + { + showCorrectTab(); + setViewportContentType (getComponent(), oldValue); + changed(); + layout.getDocument()->refreshAllPropertyComps(); + return true; + } + + int newValue, oldValue; + }; + }; + + //============================================================================== + class ViewportJucerFileProperty : public FilePropertyComponent, + public ChangeListener + { + public: + ViewportJucerFileProperty (Viewport* const component_, JucerDocument& document_) + : FilePropertyComponent (T("Jucer file"), false, true), + component (component_), + document (document_) + { + document.addChangeListener (this); + } + + ~ViewportJucerFileProperty() + { + document.removeChangeListener (this); + } + + //============================================================================== + void setFile (const File& newFile) + { + document.perform (new JucerCompFileChangeAction (component, *document.getComponentLayout(), + newFile.getRelativePathFrom (document.getFile().getParentDirectory()) + .replaceCharacter (T('\\'), T('/')) +), + T("Change Jucer component file")); + } + + const File getFile() const + { + const String filename (getViewportJucerComponentFile (component)); + + if (filename.isEmpty()) + return File::nonexistent; + + return document.getFile().getSiblingFile (filename); + } + + void changeListenerCallback (void*) + { + refresh(); + } + + private: + Viewport* const component; + JucerDocument& document; + + class JucerCompFileChangeAction : public ComponentUndoableAction + { + public: + JucerCompFileChangeAction (Viewport* const comp, ComponentLayout& layout, const String& newState_) + : ComponentUndoableAction (comp, layout), + newState (newState_) + { + oldState = getViewportJucerComponentFile (comp); + } + + bool perform() + { + showCorrectTab(); + setViewportJucerComponentFile (getComponent(), newState); + changed(); + return true; + } + + bool undo() + { + showCorrectTab(); + setViewportJucerComponentFile (getComponent(), oldState); + changed(); + return true; + } + + String newState, oldState; + }; + }; + + //============================================================================== + class ViewportContentClassProperty : public ComponentTextProperty + { + public: + ViewportContentClassProperty (Viewport* comp, JucerDocument& document) + : ComponentTextProperty (T("content class"), 256, false, comp, document) + { + } + + void setText (const String& newText) + { + document.perform (new ViewportClassNameChangeAction (component, *document.getComponentLayout(), newText), + T("Change Viewport content class")); + } + + const String getText() const + { + return getViewportGenericComponentClass (component); + } + + private: + class ViewportClassNameChangeAction : public ComponentUndoableAction + { + public: + ViewportClassNameChangeAction (Viewport* const comp, ComponentLayout& layout, const String& newValue_) + : ComponentUndoableAction (comp, layout), + newValue (newValue_) + { + oldValue = getViewportGenericComponentClass (comp); + } + + bool perform() + { + showCorrectTab(); + setViewportGenericComponentClass (getComponent(), newValue); + changed(); + layout.getDocument()->refreshAllPropertyComps(); + return true; + } + + bool undo() + { + showCorrectTab(); + setViewportGenericComponentClass (getComponent(), oldValue); + changed(); + layout.getDocument()->refreshAllPropertyComps(); + return true; + } + + String newValue, oldValue; + }; + }; + + //============================================================================== + class ConstructorParamsProperty : public ComponentTextProperty + { + public: + ConstructorParamsProperty (Viewport* comp, JucerDocument& document) + : ComponentTextProperty (T("constructor params"), 512, false, comp, document) + { + } + + void setText (const String& newText) + { + document.perform (new ConstructorParamChangeAction (component, *document.getComponentLayout(), newText), + T("Change Viewport content constructor params")); + } + + const String getText() const + { + return getViewportConstructorParams (component); + } + + private: + int tabIndex; + + class ConstructorParamChangeAction : public ComponentUndoableAction + { + public: + ConstructorParamChangeAction (Viewport* const comp, ComponentLayout& layout, const String& newValue_) + : ComponentUndoableAction (comp, layout), + newValue (newValue_) + { + oldValue = getViewportConstructorParams (comp); + } + + bool perform() + { + showCorrectTab(); + setViewportConstructorParams (getComponent(), newValue); + changed(); + layout.getDocument()->refreshAllPropertyComps(); + return true; + } + + bool undo() + { + showCorrectTab(); + setViewportConstructorParams (getComponent(), oldValue); + changed(); + layout.getDocument()->refreshAllPropertyComps(); + return true; + } + + String newValue, oldValue; + }; + }; +}; + + +#endif // __JUCER_VIEWPORTHANDLER_JUCEHEADER__ diff --git a/extras/the jucer/src/model/jucer_BinaryResources.cpp b/extras/the jucer/src/model/jucer_BinaryResources.cpp index ce746d5e8c..f8a4d94078 100644 --- a/extras/the jucer/src/model/jucer_BinaryResources.cpp +++ b/extras/the jucer/src/model/jucer_BinaryResources.cpp @@ -302,7 +302,7 @@ void BinaryResources::fillInGeneratedCode (GeneratedCode& code) const const MemoryBlock& mb = resources[i]->data; defs << "// JUCER_RESOURCE: " << name << ", " << mb.getSize() - << ", \"" + << ", \"" << File (resources[i]->originalFilename) .getRelativePathFrom (code.document->getFile()) .replaceCharacter (T('\\'), T('/')) diff --git a/extras/the jucer/src/model/jucer_GeneratedCode.cpp b/extras/the jucer/src/model/jucer_GeneratedCode.cpp index 1c6433903c..1ba5251778 100644 --- a/extras/the jucer/src/model/jucer_GeneratedCode.cpp +++ b/extras/the jucer/src/model/jucer_GeneratedCode.cpp @@ -1,388 +1,388 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#include "../jucer_Headers.h" -#include "jucer_GeneratedCode.h" - - -//============================================================================== -GeneratedCode::GeneratedCode (const JucerDocument* const document_) - : document (document_), - suffix (0) -{ -} - -GeneratedCode::~GeneratedCode() -{ -} - -int GeneratedCode::getUniqueSuffix() -{ - return ++suffix; -} - -//============================================================================== -String& GeneratedCode::getCallbackCode (const String& requiredParentClass, - const String& returnType, - const String& prototype, - const bool hasPrePostUserSections) -{ - String parentClass (requiredParentClass); - if (parentClass.isNotEmpty() - && ! (parentClass.startsWith (T("public ")) - || parentClass.startsWith (T("private ")) - || parentClass.startsWith (T("protected ")))) - { - parentClass = T("public ") + parentClass; - } - - for (int i = callbacks.size(); --i >= 0;) - { - CallbackMethod* const cm = callbacks.getUnchecked(i); - - if (cm->requiredParentClass == parentClass - && cm->returnType == returnType - && cm->prototype == prototype) - return cm->content; - } - - CallbackMethod* const cm = new CallbackMethod(); - callbacks.add (cm); - - cm->requiredParentClass = parentClass; - cm->returnType = returnType; - cm->prototype = prototype; - cm->hasPrePostUserSections = hasPrePostUserSections; - return cm->content; -} - -void GeneratedCode::removeCallback (const String& returnType, const String& prototype) -{ - for (int i = callbacks.size(); --i >= 0;) - { - CallbackMethod* const cm = callbacks.getUnchecked(i); - - if (cm->returnType == returnType && cm->prototype == prototype) - callbacks.remove (i); - } -} - -void GeneratedCode::addImageResourceLoader (const String& imageMemberName, const String& resourceName) -{ - const String initialiser (imageMemberName + T(" (0)")); - - if (! initialisers.contains (initialiser, false)) - { - initialisers.add (initialiser); - - privateMemberDeclarations - << "Image* " << imageMemberName << ";\n"; - - if (resourceName.isNotEmpty()) - { - constructorCode - << imageMemberName << " = ImageCache::getFromMemory (" - << resourceName << ", " << resourceName << "Size);\n"; - - destructorCode - << "ImageCache::release (" << imageMemberName << ");\n"; - } - } -} - -const StringArray GeneratedCode::getExtraParentClasses() const -{ - StringArray s; - - for (int i = 0; i < callbacks.size(); ++i) - { - CallbackMethod* const cm = callbacks.getUnchecked(i); - s.add (cm->requiredParentClass); - } - - return s; -} - -const String GeneratedCode::getCallbackDeclarations() const -{ - String s; - - for (int i = 0; i < callbacks.size(); ++i) - { - CallbackMethod* const cm = callbacks.getUnchecked(i); - - s << cm->returnType << " " << cm->prototype << ";\n"; - } - - return s; -} - -const String GeneratedCode::getCallbackDefinitions() const -{ - String s; - - for (int i = 0; i < callbacks.size(); ++i) - { - CallbackMethod* const cm = callbacks.getUnchecked(i); - - const String userCodeBlockName (T("User") - + makeValidCppIdentifier (cm->prototype.upToFirstOccurrenceOf (T("("), false, false), - true, true, false).trim()); - - if (userCodeBlockName.isNotEmpty() && cm->hasPrePostUserSections) - { - s << cm->returnType << " " << className << "::" << cm->prototype - << "\n{\n //[" << userCodeBlockName << "_Pre]\n //[/" << userCodeBlockName - << "_Pre]\n\n " - << indentCode (cm->content.trim(), 4) - << "\n\n //[" << userCodeBlockName << "_Post]\n //[/" << userCodeBlockName - << "_Post]\n}\n\n"; - } - else - { - s << cm->returnType << " " << className << "::" << cm->prototype - << "\n{\n " - << indentCode (cm->content.trim(), 4) - << "\n}\n\n"; - } - } - - return s; -} - -//============================================================================== -const String GeneratedCode::getClassDeclaration() const -{ - StringArray parentClassLines; - parentClassLines.addTokens (parentClasses, T(","), 0); - parentClassLines.addArray (getExtraParentClasses()); - - parentClassLines.trim(); - parentClassLines.removeEmptyStrings(); - parentClassLines.removeDuplicates (false); - - if (parentClassLines.contains (T("public Button"), false)) - parentClassLines.removeString (("public Component"), false); - - String r (T("class ")); - r << className << T(" : "); - - r += parentClassLines.joinIntoString (T(",\n") + String::repeatedString (T(" "), r.length())); - - return r; -} - -const String GeneratedCode::getInitialiserList() const -{ - StringArray inits (initialisers); - - if (parentClassInitialiser.isNotEmpty()) - inits.insert (0, parentClassInitialiser); - - inits.trim(); - inits.removeEmptyStrings(); - inits.removeDuplicates (false); - - String s; - - if (inits.size() == 0) - return s; - - s << " : "; - - for (int i = 0; i < inits.size(); ++i) - { - String init (inits[i]); - - while (init.endsWithChar (T(','))) - init = init.dropLastCharacters (1); - - s << init; - - if (i < inits.size() - 1) - s << ",\n "; - else - s << "\n"; - } - - return s; -} - -static const String getIncludeFileCode (StringArray files) -{ - files.trim(); - files.removeEmptyStrings(); - files.removeDuplicates (false); - - String s; - - for (int i = 0; i < files.size(); ++i) - s << T("#include \"") << files[i] << T("\"\n"); - - return s; -} - -//============================================================================== -static void replaceTemplate (String& text, const String& itemName, const String& value) -{ - for (;;) - { - const int index = text.indexOf (T("%%") + itemName + T("%%")); - - if (index < 0) - break; - - int indentLevel = 0; - - for (int i = index; --i >= 0;) - { - if (text[i] == T('\n')) - break; - - ++indentLevel; - } - - text = text.replaceSection (index, itemName.length() + 4, - indentCode (value, indentLevel)); - } -} - -//============================================================================== -static bool getUserSection (const StringArray& lines, const String& tag, StringArray& resultLines) -{ - const int start = indexOfLineStartingWith (lines, T("//[") + tag + T("]"), 0); - - if (start < 0) - return false; - - const int end = indexOfLineStartingWith (lines, T("//[/") + tag + T("]"), start + 1); - - for (int i = start + 1; i < end; ++i) - resultLines.add (lines [i]); - - return true; -} - -static void copyAcrossUserSections (String& dest, const String& src) -{ - StringArray srcLines, dstLines; - srcLines.addLines (src); - dstLines.addLines (dest); - - for (int i = 0; i < dstLines.size(); ++i) - { - if (dstLines[i].trimStart().startsWith (T("//["))) - { - String tag (dstLines[i].trimStart().substring (3)); - tag = tag.upToFirstOccurrenceOf (T("]"), false, false); - - jassert (! tag.startsWithChar (T('/'))); - - if (! tag.startsWithChar (T('/'))) - { - const int endLine = indexOfLineStartingWith (dstLines, - T("//[/") + tag + T("]"), - i + 1); - - if (endLine > i) - { - StringArray sourceLines; - - if (getUserSection (srcLines, tag, sourceLines)) - { - int j; - for (j = endLine - i; --j > 0;) - dstLines.remove (i + 1); - - for (j = 0; j < sourceLines.size(); ++j) - dstLines.insert (++i, sourceLines [j].trimEnd()); - - ++i; - } - else - { - i = endLine; - } - } - } - } - - dstLines.set (i, dstLines[i].trimEnd()); - } - - dest = dstLines.joinIntoString (T("\n")) + T("\n"); -} - -//============================================================================== -void GeneratedCode::applyToCode (String& code, - const String& fileNameRoot, - const bool isForPreview, - const String& oldFileWithUserData) const -{ - // header guard.. - String headerGuard ("__JUCER_HEADER_"); - headerGuard << className.toUpperCase().retainCharacters (T("ABCDEFGHIJKLMNOPQRSTUVWXYZ")) - << "_" << fileNameRoot.toUpperCase().retainCharacters (T("ABCDEFGHIJKLMNOPQRSTUVWXYZ")) - << "_" << String::toHexString (Random::getSystemRandom().nextInt()).toUpperCase() - << "__"; - replaceTemplate (code, "headerGuard", headerGuard); - - replaceTemplate (code, "creationTime", Time::getCurrentTime().toString (true, true, true)); - - replaceTemplate (code, "className", className); - replaceTemplate (code, "constructorParams", constructorParams); - replaceTemplate (code, "initialisers", getInitialiserList()); - - replaceTemplate (code, "classDeclaration", getClassDeclaration()); - replaceTemplate (code, "privateMemberDeclarations", privateMemberDeclarations); - replaceTemplate (code, "publicMemberDeclarations", getCallbackDeclarations() + "\n" + publicMemberDeclarations); - - replaceTemplate (code, "methodDefinitions", getCallbackDefinitions()); - - replaceTemplate (code, "includeFilesH", getIncludeFileCode (includeFilesH)); - replaceTemplate (code, "includeFilesCPP", getIncludeFileCode (includeFilesCPP)); - - replaceTemplate (code, "constructor", constructorCode); - replaceTemplate (code, "destructor", destructorCode); - - if (! isForPreview) - { - replaceTemplate (code, "metadata", jucerMetadata); - replaceTemplate (code, "staticMemberDefinitions", staticMemberDefinitions); - } - else - { - replaceTemplate (code, "metadata", T(" << Metadata isn't shown in the code preview >>\n")); - replaceTemplate (code, "staticMemberDefinitions", T("// Static member declarations and resources would go here... (these aren't shown in the code preview)")); - } - - copyAcrossUserSections (code, oldFileWithUserData); -} +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#include "../jucer_Headers.h" +#include "jucer_GeneratedCode.h" + + +//============================================================================== +GeneratedCode::GeneratedCode (const JucerDocument* const document_) + : document (document_), + suffix (0) +{ +} + +GeneratedCode::~GeneratedCode() +{ +} + +int GeneratedCode::getUniqueSuffix() +{ + return ++suffix; +} + +//============================================================================== +String& GeneratedCode::getCallbackCode (const String& requiredParentClass, + const String& returnType, + const String& prototype, + const bool hasPrePostUserSections) +{ + String parentClass (requiredParentClass); + if (parentClass.isNotEmpty() + && ! (parentClass.startsWith (T("public ")) + || parentClass.startsWith (T("private ")) + || parentClass.startsWith (T("protected ")))) + { + parentClass = T("public ") + parentClass; + } + + for (int i = callbacks.size(); --i >= 0;) + { + CallbackMethod* const cm = callbacks.getUnchecked(i); + + if (cm->requiredParentClass == parentClass + && cm->returnType == returnType + && cm->prototype == prototype) + return cm->content; + } + + CallbackMethod* const cm = new CallbackMethod(); + callbacks.add (cm); + + cm->requiredParentClass = parentClass; + cm->returnType = returnType; + cm->prototype = prototype; + cm->hasPrePostUserSections = hasPrePostUserSections; + return cm->content; +} + +void GeneratedCode::removeCallback (const String& returnType, const String& prototype) +{ + for (int i = callbacks.size(); --i >= 0;) + { + CallbackMethod* const cm = callbacks.getUnchecked(i); + + if (cm->returnType == returnType && cm->prototype == prototype) + callbacks.remove (i); + } +} + +void GeneratedCode::addImageResourceLoader (const String& imageMemberName, const String& resourceName) +{ + const String initialiser (imageMemberName + T(" (0)")); + + if (! initialisers.contains (initialiser, false)) + { + initialisers.add (initialiser); + + privateMemberDeclarations + << "Image* " << imageMemberName << ";\n"; + + if (resourceName.isNotEmpty()) + { + constructorCode + << imageMemberName << " = ImageCache::getFromMemory (" + << resourceName << ", " << resourceName << "Size);\n"; + + destructorCode + << "ImageCache::release (" << imageMemberName << ");\n"; + } + } +} + +const StringArray GeneratedCode::getExtraParentClasses() const +{ + StringArray s; + + for (int i = 0; i < callbacks.size(); ++i) + { + CallbackMethod* const cm = callbacks.getUnchecked(i); + s.add (cm->requiredParentClass); + } + + return s; +} + +const String GeneratedCode::getCallbackDeclarations() const +{ + String s; + + for (int i = 0; i < callbacks.size(); ++i) + { + CallbackMethod* const cm = callbacks.getUnchecked(i); + + s << cm->returnType << " " << cm->prototype << ";\n"; + } + + return s; +} + +const String GeneratedCode::getCallbackDefinitions() const +{ + String s; + + for (int i = 0; i < callbacks.size(); ++i) + { + CallbackMethod* const cm = callbacks.getUnchecked(i); + + const String userCodeBlockName (T("User") + + makeValidCppIdentifier (cm->prototype.upToFirstOccurrenceOf (T("("), false, false), + true, true, false).trim()); + + if (userCodeBlockName.isNotEmpty() && cm->hasPrePostUserSections) + { + s << cm->returnType << " " << className << "::" << cm->prototype + << "\n{\n //[" << userCodeBlockName << "_Pre]\n //[/" << userCodeBlockName + << "_Pre]\n\n " + << indentCode (cm->content.trim(), 4) + << "\n\n //[" << userCodeBlockName << "_Post]\n //[/" << userCodeBlockName + << "_Post]\n}\n\n"; + } + else + { + s << cm->returnType << " " << className << "::" << cm->prototype + << "\n{\n " + << indentCode (cm->content.trim(), 4) + << "\n}\n\n"; + } + } + + return s; +} + +//============================================================================== +const String GeneratedCode::getClassDeclaration() const +{ + StringArray parentClassLines; + parentClassLines.addTokens (parentClasses, T(","), 0); + parentClassLines.addArray (getExtraParentClasses()); + + parentClassLines.trim(); + parentClassLines.removeEmptyStrings(); + parentClassLines.removeDuplicates (false); + + if (parentClassLines.contains (T("public Button"), false)) + parentClassLines.removeString (("public Component"), false); + + String r (T("class ")); + r << className << T(" : "); + + r += parentClassLines.joinIntoString (T(",\n") + String::repeatedString (T(" "), r.length())); + + return r; +} + +const String GeneratedCode::getInitialiserList() const +{ + StringArray inits (initialisers); + + if (parentClassInitialiser.isNotEmpty()) + inits.insert (0, parentClassInitialiser); + + inits.trim(); + inits.removeEmptyStrings(); + inits.removeDuplicates (false); + + String s; + + if (inits.size() == 0) + return s; + + s << " : "; + + for (int i = 0; i < inits.size(); ++i) + { + String init (inits[i]); + + while (init.endsWithChar (T(','))) + init = init.dropLastCharacters (1); + + s << init; + + if (i < inits.size() - 1) + s << ",\n "; + else + s << "\n"; + } + + return s; +} + +static const String getIncludeFileCode (StringArray files) +{ + files.trim(); + files.removeEmptyStrings(); + files.removeDuplicates (false); + + String s; + + for (int i = 0; i < files.size(); ++i) + s << T("#include \"") << files[i] << T("\"\n"); + + return s; +} + +//============================================================================== +static void replaceTemplate (String& text, const String& itemName, const String& value) +{ + for (;;) + { + const int index = text.indexOf (T("%%") + itemName + T("%%")); + + if (index < 0) + break; + + int indentLevel = 0; + + for (int i = index; --i >= 0;) + { + if (text[i] == T('\n')) + break; + + ++indentLevel; + } + + text = text.replaceSection (index, itemName.length() + 4, + indentCode (value, indentLevel)); + } +} + +//============================================================================== +static bool getUserSection (const StringArray& lines, const String& tag, StringArray& resultLines) +{ + const int start = indexOfLineStartingWith (lines, T("//[") + tag + T("]"), 0); + + if (start < 0) + return false; + + const int end = indexOfLineStartingWith (lines, T("//[/") + tag + T("]"), start + 1); + + for (int i = start + 1; i < end; ++i) + resultLines.add (lines [i]); + + return true; +} + +static void copyAcrossUserSections (String& dest, const String& src) +{ + StringArray srcLines, dstLines; + srcLines.addLines (src); + dstLines.addLines (dest); + + for (int i = 0; i < dstLines.size(); ++i) + { + if (dstLines[i].trimStart().startsWith (T("//["))) + { + String tag (dstLines[i].trimStart().substring (3)); + tag = tag.upToFirstOccurrenceOf (T("]"), false, false); + + jassert (! tag.startsWithChar (T('/'))); + + if (! tag.startsWithChar (T('/'))) + { + const int endLine = indexOfLineStartingWith (dstLines, + T("//[/") + tag + T("]"), + i + 1); + + if (endLine > i) + { + StringArray sourceLines; + + if (getUserSection (srcLines, tag, sourceLines)) + { + int j; + for (j = endLine - i; --j > 0;) + dstLines.remove (i + 1); + + for (j = 0; j < sourceLines.size(); ++j) + dstLines.insert (++i, sourceLines [j].trimEnd()); + + ++i; + } + else + { + i = endLine; + } + } + } + } + + dstLines.set (i, dstLines[i].trimEnd()); + } + + dest = dstLines.joinIntoString (T("\n")) + T("\n"); +} + +//============================================================================== +void GeneratedCode::applyToCode (String& code, + const String& fileNameRoot, + const bool isForPreview, + const String& oldFileWithUserData) const +{ + // header guard.. + String headerGuard ("__JUCER_HEADER_"); + headerGuard << className.toUpperCase().retainCharacters (T("ABCDEFGHIJKLMNOPQRSTUVWXYZ")) + << "_" << fileNameRoot.toUpperCase().retainCharacters (T("ABCDEFGHIJKLMNOPQRSTUVWXYZ")) + << "_" << String::toHexString (Random::getSystemRandom().nextInt()).toUpperCase() + << "__"; + replaceTemplate (code, "headerGuard", headerGuard); + + replaceTemplate (code, "creationTime", Time::getCurrentTime().toString (true, true, true)); + + replaceTemplate (code, "className", className); + replaceTemplate (code, "constructorParams", constructorParams); + replaceTemplate (code, "initialisers", getInitialiserList()); + + replaceTemplate (code, "classDeclaration", getClassDeclaration()); + replaceTemplate (code, "privateMemberDeclarations", privateMemberDeclarations); + replaceTemplate (code, "publicMemberDeclarations", getCallbackDeclarations() + "\n" + publicMemberDeclarations); + + replaceTemplate (code, "methodDefinitions", getCallbackDefinitions()); + + replaceTemplate (code, "includeFilesH", getIncludeFileCode (includeFilesH)); + replaceTemplate (code, "includeFilesCPP", getIncludeFileCode (includeFilesCPP)); + + replaceTemplate (code, "constructor", constructorCode); + replaceTemplate (code, "destructor", destructorCode); + + if (! isForPreview) + { + replaceTemplate (code, "metadata", jucerMetadata); + replaceTemplate (code, "staticMemberDefinitions", staticMemberDefinitions); + } + else + { + replaceTemplate (code, "metadata", T(" << Metadata isn't shown in the code preview >>\n")); + replaceTemplate (code, "staticMemberDefinitions", T("// Static member declarations and resources would go here... (these aren't shown in the code preview)")); + } + + copyAcrossUserSections (code, oldFileWithUserData); +} diff --git a/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h b/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h index 4a243c9722..4485659f89 100644 --- a/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h +++ b/extras/the jucer/src/model/paintelements/jucer_PaintElementImage.h @@ -1,536 +1,536 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#ifndef __JUCER_PAINTELEMENTIMAGE_JUCEHEADER__ -#define __JUCER_PAINTELEMENTIMAGE_JUCEHEADER__ - -#include "../jucer_PaintRoutine.h" -#include "../../properties/jucer_FilePropertyComponent.h" -#include "jucer_ImageResourceProperty.h" -#include "jucer_PaintElementUndoableAction.h" - - -//============================================================================== -/** -*/ -class PaintElementImage : public PaintElement -{ -public: - enum StretchMode - { - stretched = 0, - proportional = 1, - proportionalReducingOnly = 2 - }; - - //============================================================================== - PaintElementImage (PaintRoutine* owner) - : PaintElement (owner, T("Image")), - opacity (1.0), - mode (stretched) - { - } - - ~PaintElementImage() - { - } - - //============================================================================== - const Drawable* getDrawable() - { - JucerDocument* const document = getDocument(); - - if (document != 0) - return document->getResources().getDrawable (resourceName); - - return 0; - } - - void draw (Graphics& g, const ComponentLayout* layout, const Rectangle& parentArea) - { - const Rectangle r (position.getRectangle (parentArea, layout)); - - const Drawable* const image = getDrawable(); - - if (image != 0) - { - g.setColour (Colours::black.withAlpha ((float) opacity)); - - image->drawWithin (g, r.getX(), r.getY(), r.getWidth(), r.getHeight(), - mode == stretched ? RectanglePlacement::stretchToFit - : (mode == proportionalReducingOnly ? (RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize) - : RectanglePlacement::centred)); - } - else - { - g.setColour (Colours::grey.withAlpha (0.5f)); - g.fillRect (r); - - g.setColour (Colours::black); - g.drawText (T("(image missing)"), - r.getX(), r.getY(), r.getWidth(), r.getHeight(), - Justification::centred, true); - } - } - - //============================================================================== - void getEditableProperties (Array & properties) - { - PaintElement::getEditableProperties (properties); - - properties.add (new ImageElementResourceProperty (this)); - properties.add (new StretchModeProperty (this)); - properties.add (new OpacityProperty (this)); - properties.add (new ResetSizeProperty (this)); - } - - void fillInGeneratedCode (GeneratedCode& code, String& paintMethodCode) - { - String r; - - if (opacity > 0) - { - if (dynamic_cast (getDrawable()) != 0) - { - const String imageVariable ("cachedImage_" + resourceName); - - code.addImageResourceLoader (imageVariable, resourceName); - - if (opacity >= 254.0 / 255.0) - r << "g.setColour (Colours::black);\n"; - else - r << "g.setColour (Colours::black.withAlpha (" << valueToFloat (opacity) << "));\n"; - - String x, y, w, h; - positionToCode (position, getDocument()->getComponentLayout(), x, y, w, h); - - if (mode == stretched) - { - r << "g.drawImage (" << imageVariable << ",\n " - << x << ", " << y << ", " << w << ", " << h - << ",\n 0, 0, " - << imageVariable << "->getWidth(), " - << imageVariable << "->getHeight());\n\n"; - } - else - { - r << "g.drawImageWithin (" << imageVariable << ",\n " - << x << ", " << y << ", " << w << ", " << h - << ",\n "; - - if (mode == proportionalReducingOnly) - r << "RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize"; - else - r << "RectanglePlacement::centred"; - - r << ",\n false);\n\n"; - } - - paintMethodCode += r; - } - else - { - if (resourceName.isNotEmpty()) - { - const String imageVariable (T("drawable") + String (code.getUniqueSuffix())); - - code.privateMemberDeclarations - << "Drawable* " << imageVariable << ";\n"; - - code.constructorCode - << imageVariable << " = Drawable::createFromImageData (" - << resourceName << ", " << resourceName << "Size);\n"; - - code.destructorCode - << "deleteAndZero (" << imageVariable << ");\n"; - - if (opacity >= 254.0 / 255.0) - r << "g.setColour (Colours::black);\n"; - else - r << "g.setColour (Colours::black.withAlpha (" << valueToFloat (opacity) << "));\n"; - - String x, y, w, h; - positionToCode (position, code.document->getComponentLayout(), x, y, w, h); - - r << "jassert (" << imageVariable << " != 0);\n" - << "if (" << imageVariable << " != 0)\n " - << imageVariable << "->drawWithin (g, " - << x << ", " << y << ", " << w << ", " << h - << ",\n" - << String::repeatedString (T(" "), imageVariable.length() + 18) - << (mode == stretched ? "RectanglePlacement::stretchToFit" - : (mode == proportionalReducingOnly ? "RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize" - : "RectanglePlacement::centred")) - << ");\n\n"; - - paintMethodCode += r; - } - else - { - jassertfalse // this resource isn't valid! - } - } - } - } - - //============================================================================== - class SetResourceAction : public PaintElementUndoableAction - { - public: - SetResourceAction (PaintElementImage* const element, const String& newResource_) - : PaintElementUndoableAction (element), - newResource (newResource_) - { - oldResource = element->getResource(); - } - - bool perform() - { - showCorrectTab(); - getElement()->setResource (newResource, false); - return true; - } - - bool undo() - { - showCorrectTab(); - getElement()->setResource (oldResource, false); - return true; - } - - private: - String newResource, oldResource; - }; - - void setResource (const String& newName, const bool undoable) - { - if (resourceName != newName) - { - if (undoable) - { - perform (new SetResourceAction (this, newName), - T("Change image resource")); - } - else - { - resourceName = newName; - changed(); - } - } - - repaint(); - } - - const String getResource() const - { - return resourceName; - } - - //============================================================================== - class SetOpacityAction : public PaintElementUndoableAction - { - public: - SetOpacityAction (PaintElementImage* const element, const double newOpacity_) - : PaintElementUndoableAction (element), - newOpacity (newOpacity_) - { - oldOpacity = element->getOpacity(); - } - - bool perform() - { - showCorrectTab(); - getElement()->setOpacity (newOpacity, false); - return true; - } - - bool undo() - { - showCorrectTab(); - getElement()->setOpacity (oldOpacity, false); - return true; - } - - private: - double newOpacity, oldOpacity; - }; - - void setOpacity (double newOpacity, const bool undoable) - { - newOpacity = jlimit (0.0, 1.0, newOpacity); - - if (opacity != newOpacity) - { - if (undoable) - { - perform (new SetOpacityAction (this, newOpacity), - T("Change image opacity")); - } - else - { - opacity = newOpacity; - changed(); - } - } - } - - double getOpacity() const throw() { return opacity; } - - //============================================================================== - static const tchar* getTagName() throw() { return T("IMAGE"); } - - void resetToImageSize() - { - const Drawable* const image = getDrawable(); - - if (image != 0 && getParentComponent() != 0) - { - const Rectangle parentArea (((PaintRoutineEditor*) getParentComponent())->getComponentArea()); - - Rectangle r (getCurrentBounds (parentArea)); - - float x, y, w, h; - image->getBounds (x, y, w, h); - - r.setSize ((int) (w + 1.0f), (int) (h + 1.0f)); - - setCurrentBounds (r, parentArea, true); - } - } - - //============================================================================== - class SetStretchModeAction : public PaintElementUndoableAction - { - public: - SetStretchModeAction (PaintElementImage* const element, const StretchMode newValue_) - : PaintElementUndoableAction (element), - newValue (newValue_) - { - oldValue = element->getStretchMode(); - } - - bool perform() - { - showCorrectTab(); - getElement()->setStretchMode (newValue, false); - return true; - } - - bool undo() - { - showCorrectTab(); - getElement()->setStretchMode (oldValue, false); - return true; - } - - private: - StretchMode newValue, oldValue; - }; - - StretchMode getStretchMode() const throw() { return mode; } - - void setStretchMode (const StretchMode newMode, const bool undoable) - { - if (mode != newMode) - { - if (undoable) - { - perform (new SetStretchModeAction (this, newMode), - T("Change image mode")); - } - else - { - mode = newMode; - changed(); - } - } - } - - //============================================================================== - XmlElement* createXml() const - { - XmlElement* e = new XmlElement (getTagName()); - position.applyToXml (*e); - e->setAttribute (T("resource"), resourceName); - e->setAttribute (T("opacity"), opacity); - e->setAttribute (T("mode"), (int) mode); - - return e; - } - - bool loadFromXml (const XmlElement& xml) - { - if (xml.hasTagName (getTagName())) - { - position.restoreFromXml (xml, position); - resourceName = xml.getStringAttribute (T("resource"), String::empty); - opacity = xml.getDoubleAttribute (T("opacity"), 1.0); - mode = (StretchMode) xml.getIntAttribute (T("mode"), (int) stretched); - - repaint(); - return true; - } - else - { - jassertfalse - return false; - } - } - - //============================================================================== - juce_UseDebuggingNewOperator - -private: - String resourceName; - double opacity; - StretchMode mode; - - //============================================================================== - class ImageElementResourceProperty : public ImageResourceProperty - { - public: - ImageElementResourceProperty (PaintElementImage* const element_) - : ImageResourceProperty (element_, T("image source")) - { - } - - //============================================================================== - void setResource (const String& newName) - { - element->setResource (newName, true); - } - - const String getResource() const - { - return element->getResource(); - } - }; - - //============================================================================== - class OpacityProperty : public SliderPropertyComponent, - private ChangeListener - { - public: - OpacityProperty (PaintElementImage* const element_) - : SliderPropertyComponent (T("opacity"), 0.0, 1.0, 0.001), - element (element_) - { - element->getDocument()->addChangeListener (this); - } - - ~OpacityProperty() - { - element->getDocument()->removeChangeListener (this); - } - - void setValue (const double newValue) - { - element->getDocument()->getUndoManager().undoCurrentTransactionOnly(); - - element->setOpacity (newValue, true); - } - - const double getValue() const - { - return element->getOpacity(); - } - - void changeListenerCallback (void*) - { - refresh(); - } - - private: - PaintElementImage* const element; - }; - - class StretchModeProperty : public ChoicePropertyComponent, - private ChangeListener - { - public: - StretchModeProperty (PaintElementImage* const element_) - : ChoicePropertyComponent (T("stretch mode")), - element (element_) - { - choices.add (T("Stretched to fit")); - choices.add (T("Maintain aspect ratio")); - choices.add (T("Maintain aspect ratio, only reduce in size")); - - element->getDocument()->addChangeListener (this); - } - - ~StretchModeProperty() - { - element->getDocument()->removeChangeListener (this); - } - - void setIndex (const int newIndex) - { - element->setStretchMode ((StretchMode) newIndex, true); - } - - int getIndex() const - { - return (int) element->getStretchMode(); - } - - void changeListenerCallback (void*) - { - refresh(); - } - - private: - PaintElementImage* const element; - }; - - class ResetSizeProperty : public ButtonPropertyComponent - { - public: - ResetSizeProperty (PaintElementImage* const element_) - : ButtonPropertyComponent (T("reset"), false), - element (element_) - { - } - - void buttonClicked() - { - element->resetToImageSize(); - } - - const String getButtonText() const { return T("reset to image size"); } - - private: - PaintElementImage* const element; - }; -}; - - -#endif // __JUCER_PAINTELEMENTIMAGE_JUCEHEADER__ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#ifndef __JUCER_PAINTELEMENTIMAGE_JUCEHEADER__ +#define __JUCER_PAINTELEMENTIMAGE_JUCEHEADER__ + +#include "../jucer_PaintRoutine.h" +#include "../../properties/jucer_FilePropertyComponent.h" +#include "jucer_ImageResourceProperty.h" +#include "jucer_PaintElementUndoableAction.h" + + +//============================================================================== +/** +*/ +class PaintElementImage : public PaintElement +{ +public: + enum StretchMode + { + stretched = 0, + proportional = 1, + proportionalReducingOnly = 2 + }; + + //============================================================================== + PaintElementImage (PaintRoutine* owner) + : PaintElement (owner, T("Image")), + opacity (1.0), + mode (stretched) + { + } + + ~PaintElementImage() + { + } + + //============================================================================== + const Drawable* getDrawable() + { + JucerDocument* const document = getDocument(); + + if (document != 0) + return document->getResources().getDrawable (resourceName); + + return 0; + } + + void draw (Graphics& g, const ComponentLayout* layout, const Rectangle& parentArea) + { + const Rectangle r (position.getRectangle (parentArea, layout)); + + const Drawable* const image = getDrawable(); + + if (image != 0) + { + g.setColour (Colours::black.withAlpha ((float) opacity)); + + image->drawWithin (g, r.getX(), r.getY(), r.getWidth(), r.getHeight(), + mode == stretched ? RectanglePlacement::stretchToFit + : (mode == proportionalReducingOnly ? (RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize) + : RectanglePlacement::centred)); + } + else + { + g.setColour (Colours::grey.withAlpha (0.5f)); + g.fillRect (r); + + g.setColour (Colours::black); + g.drawText (T("(image missing)"), + r.getX(), r.getY(), r.getWidth(), r.getHeight(), + Justification::centred, true); + } + } + + //============================================================================== + void getEditableProperties (Array & properties) + { + PaintElement::getEditableProperties (properties); + + properties.add (new ImageElementResourceProperty (this)); + properties.add (new StretchModeProperty (this)); + properties.add (new OpacityProperty (this)); + properties.add (new ResetSizeProperty (this)); + } + + void fillInGeneratedCode (GeneratedCode& code, String& paintMethodCode) + { + String r; + + if (opacity > 0) + { + if (dynamic_cast (getDrawable()) != 0) + { + const String imageVariable ("cachedImage_" + resourceName); + + code.addImageResourceLoader (imageVariable, resourceName); + + if (opacity >= 254.0 / 255.0) + r << "g.setColour (Colours::black);\n"; + else + r << "g.setColour (Colours::black.withAlpha (" << valueToFloat (opacity) << "));\n"; + + String x, y, w, h; + positionToCode (position, getDocument()->getComponentLayout(), x, y, w, h); + + if (mode == stretched) + { + r << "g.drawImage (" << imageVariable << ",\n " + << x << ", " << y << ", " << w << ", " << h + << ",\n 0, 0, " + << imageVariable << "->getWidth(), " + << imageVariable << "->getHeight());\n\n"; + } + else + { + r << "g.drawImageWithin (" << imageVariable << ",\n " + << x << ", " << y << ", " << w << ", " << h + << ",\n "; + + if (mode == proportionalReducingOnly) + r << "RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize"; + else + r << "RectanglePlacement::centred"; + + r << ",\n false);\n\n"; + } + + paintMethodCode += r; + } + else + { + if (resourceName.isNotEmpty()) + { + const String imageVariable (T("drawable") + String (code.getUniqueSuffix())); + + code.privateMemberDeclarations + << "Drawable* " << imageVariable << ";\n"; + + code.constructorCode + << imageVariable << " = Drawable::createFromImageData (" + << resourceName << ", " << resourceName << "Size);\n"; + + code.destructorCode + << "deleteAndZero (" << imageVariable << ");\n"; + + if (opacity >= 254.0 / 255.0) + r << "g.setColour (Colours::black);\n"; + else + r << "g.setColour (Colours::black.withAlpha (" << valueToFloat (opacity) << "));\n"; + + String x, y, w, h; + positionToCode (position, code.document->getComponentLayout(), x, y, w, h); + + r << "jassert (" << imageVariable << " != 0);\n" + << "if (" << imageVariable << " != 0)\n " + << imageVariable << "->drawWithin (g, " + << x << ", " << y << ", " << w << ", " << h + << ",\n" + << String::repeatedString (T(" "), imageVariable.length() + 18) + << (mode == stretched ? "RectanglePlacement::stretchToFit" + : (mode == proportionalReducingOnly ? "RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize" + : "RectanglePlacement::centred")) + << ");\n\n"; + + paintMethodCode += r; + } + else + { + jassertfalse // this resource isn't valid! + } + } + } + } + + //============================================================================== + class SetResourceAction : public PaintElementUndoableAction + { + public: + SetResourceAction (PaintElementImage* const element, const String& newResource_) + : PaintElementUndoableAction (element), + newResource (newResource_) + { + oldResource = element->getResource(); + } + + bool perform() + { + showCorrectTab(); + getElement()->setResource (newResource, false); + return true; + } + + bool undo() + { + showCorrectTab(); + getElement()->setResource (oldResource, false); + return true; + } + + private: + String newResource, oldResource; + }; + + void setResource (const String& newName, const bool undoable) + { + if (resourceName != newName) + { + if (undoable) + { + perform (new SetResourceAction (this, newName), + T("Change image resource")); + } + else + { + resourceName = newName; + changed(); + } + } + + repaint(); + } + + const String getResource() const + { + return resourceName; + } + + //============================================================================== + class SetOpacityAction : public PaintElementUndoableAction + { + public: + SetOpacityAction (PaintElementImage* const element, const double newOpacity_) + : PaintElementUndoableAction (element), + newOpacity (newOpacity_) + { + oldOpacity = element->getOpacity(); + } + + bool perform() + { + showCorrectTab(); + getElement()->setOpacity (newOpacity, false); + return true; + } + + bool undo() + { + showCorrectTab(); + getElement()->setOpacity (oldOpacity, false); + return true; + } + + private: + double newOpacity, oldOpacity; + }; + + void setOpacity (double newOpacity, const bool undoable) + { + newOpacity = jlimit (0.0, 1.0, newOpacity); + + if (opacity != newOpacity) + { + if (undoable) + { + perform (new SetOpacityAction (this, newOpacity), + T("Change image opacity")); + } + else + { + opacity = newOpacity; + changed(); + } + } + } + + double getOpacity() const throw() { return opacity; } + + //============================================================================== + static const tchar* getTagName() throw() { return T("IMAGE"); } + + void resetToImageSize() + { + const Drawable* const image = getDrawable(); + + if (image != 0 && getParentComponent() != 0) + { + const Rectangle parentArea (((PaintRoutineEditor*) getParentComponent())->getComponentArea()); + + Rectangle r (getCurrentBounds (parentArea)); + + float x, y, w, h; + image->getBounds (x, y, w, h); + + r.setSize ((int) (w + 1.0f), (int) (h + 1.0f)); + + setCurrentBounds (r, parentArea, true); + } + } + + //============================================================================== + class SetStretchModeAction : public PaintElementUndoableAction + { + public: + SetStretchModeAction (PaintElementImage* const element, const StretchMode newValue_) + : PaintElementUndoableAction (element), + newValue (newValue_) + { + oldValue = element->getStretchMode(); + } + + bool perform() + { + showCorrectTab(); + getElement()->setStretchMode (newValue, false); + return true; + } + + bool undo() + { + showCorrectTab(); + getElement()->setStretchMode (oldValue, false); + return true; + } + + private: + StretchMode newValue, oldValue; + }; + + StretchMode getStretchMode() const throw() { return mode; } + + void setStretchMode (const StretchMode newMode, const bool undoable) + { + if (mode != newMode) + { + if (undoable) + { + perform (new SetStretchModeAction (this, newMode), + T("Change image mode")); + } + else + { + mode = newMode; + changed(); + } + } + } + + //============================================================================== + XmlElement* createXml() const + { + XmlElement* e = new XmlElement (getTagName()); + position.applyToXml (*e); + e->setAttribute (T("resource"), resourceName); + e->setAttribute (T("opacity"), opacity); + e->setAttribute (T("mode"), (int) mode); + + return e; + } + + bool loadFromXml (const XmlElement& xml) + { + if (xml.hasTagName (getTagName())) + { + position.restoreFromXml (xml, position); + resourceName = xml.getStringAttribute (T("resource"), String::empty); + opacity = xml.getDoubleAttribute (T("opacity"), 1.0); + mode = (StretchMode) xml.getIntAttribute (T("mode"), (int) stretched); + + repaint(); + return true; + } + else + { + jassertfalse + return false; + } + } + + //============================================================================== + juce_UseDebuggingNewOperator + +private: + String resourceName; + double opacity; + StretchMode mode; + + //============================================================================== + class ImageElementResourceProperty : public ImageResourceProperty + { + public: + ImageElementResourceProperty (PaintElementImage* const element_) + : ImageResourceProperty (element_, T("image source")) + { + } + + //============================================================================== + void setResource (const String& newName) + { + element->setResource (newName, true); + } + + const String getResource() const + { + return element->getResource(); + } + }; + + //============================================================================== + class OpacityProperty : public SliderPropertyComponent, + private ChangeListener + { + public: + OpacityProperty (PaintElementImage* const element_) + : SliderPropertyComponent (T("opacity"), 0.0, 1.0, 0.001), + element (element_) + { + element->getDocument()->addChangeListener (this); + } + + ~OpacityProperty() + { + element->getDocument()->removeChangeListener (this); + } + + void setValue (const double newValue) + { + element->getDocument()->getUndoManager().undoCurrentTransactionOnly(); + + element->setOpacity (newValue, true); + } + + const double getValue() const + { + return element->getOpacity(); + } + + void changeListenerCallback (void*) + { + refresh(); + } + + private: + PaintElementImage* const element; + }; + + class StretchModeProperty : public ChoicePropertyComponent, + private ChangeListener + { + public: + StretchModeProperty (PaintElementImage* const element_) + : ChoicePropertyComponent (T("stretch mode")), + element (element_) + { + choices.add (T("Stretched to fit")); + choices.add (T("Maintain aspect ratio")); + choices.add (T("Maintain aspect ratio, only reduce in size")); + + element->getDocument()->addChangeListener (this); + } + + ~StretchModeProperty() + { + element->getDocument()->removeChangeListener (this); + } + + void setIndex (const int newIndex) + { + element->setStretchMode ((StretchMode) newIndex, true); + } + + int getIndex() const + { + return (int) element->getStretchMode(); + } + + void changeListenerCallback (void*) + { + refresh(); + } + + private: + PaintElementImage* const element; + }; + + class ResetSizeProperty : public ButtonPropertyComponent + { + public: + ResetSizeProperty (PaintElementImage* const element_) + : ButtonPropertyComponent (T("reset"), false), + element (element_) + { + } + + void buttonClicked() + { + element->resetToImageSize(); + } + + const String getButtonText() const { return T("reset to image size"); } + + private: + PaintElementImage* const element; + }; +}; + + +#endif // __JUCER_PAINTELEMENTIMAGE_JUCEHEADER__ diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 269ec27226..d148867c88 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -255232,7 +255232,7 @@ public: } imageSwapLock.enter(); - int ls, ps; + int ls, ps; const int lineStride = width * 3; uint8* const dest = loadingImage->lockPixelDataReadWrite (0, 0, width, height, ls, ps); @@ -255568,11 +255568,11 @@ private: while (enumerator->Next (1, &pin, 0) == S_OK) { - PIN_DIRECTION dir; - pin->QueryDirection (&dir); + PIN_DIRECTION dir; + pin->QueryDirection (&dir); - if (wantedDirection == dir) - { + if (wantedDirection == dir) + { PIN_INFO info; zerostruct (info); pin->QueryPinInfo (&info); @@ -255580,10 +255580,10 @@ private: if (pinName == 0 || String (pinName).equalsIgnoreCase (String (info.achName))) { pin.p->AddRef(); - *result = pin; - return true; + *result = pin; + return true; } - } + } } return false; @@ -255611,7 +255611,7 @@ private: return false; graphRegistrationID = 0; - return SUCCEEDED (rot->Register (0, graphBuilder, moniker, &graphRegistrationID)); + return SUCCEEDED (rot->Register (0, graphBuilder, moniker, &graphRegistrationID)); } void removeGraphFromRot() @@ -255619,7 +255619,7 @@ private: ComSmartPtr rot; if (SUCCEEDED (GetRunningObjectTable (0, &rot))) - rot->Revoke (graphRegistrationID); + rot->Revoke (graphRegistrationID); } static void deleteMediaType (AM_MEDIA_TYPE* const pmt) @@ -255638,23 +255638,23 @@ private: public: GrabberCallback (DShowCameraDeviceInteral& owner_) : owner (owner_) - { + { } HRESULT __stdcall QueryInterface (REFIID id, void** result) { - if (id == IID_IUnknown) - *result = dynamic_cast (this); - else if (id == IID_ISampleGrabberCB) - *result = dynamic_cast (this); - else - { - *result = 0; - return E_NOINTERFACE; - } + if (id == IID_IUnknown) + *result = dynamic_cast (this); + else if (id == IID_ISampleGrabberCB) + *result = dynamic_cast (this); + else + { + *result = 0; + return E_NOINTERFACE; + } - AddRef(); - return S_OK; + AddRef(); + return S_OK; } ULONG __stdcall AddRef() { return ++refCount; } @@ -255662,13 +255662,13 @@ private: STDMETHODIMP SampleCB (double /*SampleTime*/, IMediaSample* /*pSample*/) { - return E_FAIL; + return E_FAIL; } STDMETHODIMP BufferCB (double time, BYTE* buffer, long bufferSize) { - owner.handleFrame (time, buffer, bufferSize); - return S_OK; + owner.handleFrame (time, buffer, bufferSize); + return S_OK; } private: @@ -274301,8 +274301,8 @@ END_JUCE_NAMESPACE fromConnection: (QTCaptureConnection*) connection { const ScopedAutoReleasePool pool; - CIImage* image = [CIImage imageWithCVImageBuffer: videoFrame]; - NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] initWithCIImage: image] autorelease]; + CIImage* image = [CIImage imageWithCVImageBuffer: videoFrame]; + NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc] initWithCIImage: image] autorelease]; internal->callListeners (bitmap); } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 993cab93ad..4f4715e7ae 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -2743,7 +2743,7 @@ BEGIN_JUCE_NAMESPACE /********* End of inlined file: juce_Atomic.h *********/ #endif -#ifndef __JUCE_DATACONVERSIONS_JUCEHEADER__ +#ifndef __JUCE_STANDARDHEADER_JUCEHEADER__ #endif #ifndef __JUCE_FILELOGGER_JUCEHEADER__ @@ -7851,9 +7851,6 @@ private: #endif // __JUCE_SINGLETON_JUCEHEADER__ /********* End of inlined file: juce_Singleton.h *********/ -#endif -#ifndef __JUCE_STANDARDHEADER_JUCEHEADER__ - #endif #ifndef __JUCE_SYSTEMSTATS_JUCEHEADER__ @@ -8002,11 +7999,14 @@ public: #ifndef __JUCE_TIME_JUCEHEADER__ #endif -#ifndef __JUCE_ARRAY_JUCEHEADER__ +#ifndef __JUCE_DATACONVERSIONS_JUCEHEADER__ #endif #ifndef __JUCE_ARRAYALLOCATIONBASE_JUCEHEADER__ +#endif +#ifndef __JUCE_ARRAY_JUCEHEADER__ + #endif #ifndef __JUCE_BITARRAY_JUCEHEADER__ @@ -8016,9 +8016,6 @@ public: #endif #ifndef __JUCE_MEMORYBLOCK_JUCEHEADER__ -#endif -#ifndef __JUCE_OWNEDARRAY_JUCEHEADER__ - #endif #ifndef __JUCE_PROPERTYSET_JUCEHEADER__ @@ -9488,11 +9485,7 @@ private: /********* End of inlined file: juce_PropertySet.h *********/ #endif -#ifndef __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ - -/********* Start of inlined file: juce_ReferenceCountedArray.h *********/ -#ifndef __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ -#define __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ +#ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__ /********* Start of inlined file: juce_ReferenceCountedObject.h *********/ #ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__ @@ -9714,757 +9707,334 @@ private: #endif // __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__ /********* End of inlined file: juce_ReferenceCountedObject.h *********/ -/** - Holds a list of objects derived from ReferenceCountedObject. +#endif +#ifndef __JUCE_SPARSESET_JUCEHEADER__ - A ReferenceCountedArray holds objects derived from ReferenceCountedObject, - and takes care of incrementing and decrementing their ref counts when they - are added and removed from the array. +/********* Start of inlined file: juce_SparseSet.h *********/ +#ifndef __JUCE_SPARSESET_JUCEHEADER__ +#define __JUCE_SPARSESET_JUCEHEADER__ - To make all the array's methods thread-safe, pass in "CriticalSection" as the templated - TypeOfCriticalSectionToUse parameter, instead of the default DummyCriticalSection. +/** + Holds a set of primitive values, storing them as a set of ranges. - @see Array, OwnedArray, StringArray + This container acts like a simple BitArray, but can efficiently hold large + continguous ranges of values. It's quite a specialised class, mostly useful + for things like keeping the set of selected rows in a listbox. + + The type used as a template paramter must be an integer type, such as int, short, + int64, etc. */ -template -class ReferenceCountedArray : private ArrayAllocationBase +template +class SparseSet { public: - /** Creates an empty array. - - @param granularity this is the size of increment by which the internal storage - used by the array will grow. Only change it from the default if you know the - array is going to be very big and needs to be able to grow efficiently. - - @see ReferenceCountedObject, ArrayAllocationBase, Array, OwnedArray - */ - ReferenceCountedArray (const int granularity = juceDefaultArrayGranularity) throw() - : ArrayAllocationBase (granularity), - numUsed (0) + /** Creates a new empty set. */ + SparseSet() throw() { } - /** Creates a copy of another array */ - ReferenceCountedArray (const ReferenceCountedArray& other) throw() - : ArrayAllocationBase (other.granularity), - numUsed (other.numUsed) + /** Creates a copy of another SparseSet. */ + SparseSet (const SparseSet& other) throw() + : values (other.values) { - other.lockArray(); - this->setAllocatedSize (numUsed); - memcpy (this->elements, other.elements, numUsed * sizeof (ObjectClass*)); - - for (int i = numUsed; --i >= 0;) - if (this->elements[i] != 0) - this->elements[i]->incReferenceCount(); - - other.unlockArray(); } - /** Copies another array into this one. - - Any existing objects in this array will first be released. - */ - const ReferenceCountedArray& operator= (const ReferenceCountedArray& other) throw() + /** Destructor. */ + ~SparseSet() throw() { - if (this != &other) - { - other.lockArray(); - lock.enter(); - - clear(); - - this->granularity = other.granularity; - this->ensureAllocatedSize (other.numUsed); - numUsed = other.numUsed; - memcpy (this->elements, other.elements, numUsed * sizeof (ObjectClass*)); - minimiseStorageOverheads(); - - for (int i = numUsed; --i >= 0;) - if (this->elements[i] != 0) - this->elements[i]->incReferenceCount(); - - lock.exit(); - other.unlockArray(); - } + } - return *this; + /** Clears the set. */ + void clear() throw() + { + values.clear(); } - /** Destructor. + /** Checks whether the set is empty. - Any objects in the array will be released, and may be deleted if not referenced from elsewhere. + This is much quicker than using (size() == 0). */ - ~ReferenceCountedArray() + bool isEmpty() const throw() { - clear(); + return values.size() == 0; } - /** Removes all objects from the array. + /** Returns the number of values in the set. - Any objects in the array that are not referenced from elsewhere will be deleted. + Because of the way the data is stored, this method can take longer if there + are a lot of items in the set. Use isEmpty() for a quick test of whether there + are any items. */ - void clear() + Type size() const throw() { - lock.enter(); - - while (numUsed > 0) - if (this->elements [--numUsed] != 0) - this->elements [numUsed]->decReferenceCount(); + Type num = 0; - jassert (numUsed == 0); - this->setAllocatedSize (0); + for (int i = 0; i < values.size(); i += 2) + num += values[i + 1] - values[i]; - lock.exit(); + return num; } - /** Returns the current number of objects in the array. */ - inline int size() const throw() + /** Returns one of the values in the set. + + @param index the index of the value to retrieve, in the range 0 to (size() - 1). + @returns the value at this index, or 0 if it's out-of-range + */ + Type operator[] (int index) const throw() { - return numUsed; - } + for (int i = 0; i < values.size(); i += 2) + { + const Type s = values.getUnchecked(i); + const Type e = values.getUnchecked(i + 1); - /** Returns a pointer to the object at this index in the array. + if (index < e - s) + return s + index; - If the index is out-of-range, this will return a null pointer, (and - it could be null anyway, because it's ok for the array to hold null - pointers as well as objects). + index -= e - s; + } - @see getUnchecked - */ - inline const ReferenceCountedObjectPtr operator[] (const int index) const throw() - { - lock.enter(); - const ReferenceCountedObjectPtr result ((((unsigned int) index) < (unsigned int) numUsed) - ? this->elements [index] - : (ObjectClass*) 0); - lock.exit(); - return result; + return (Type) 0; } - /** Returns a pointer to the object at this index in the array, without checking whether the index is in-range. - - This is a faster and less safe version of operator[] which doesn't check the index passed in, so - it can be used when you're sure the index if always going to be legal. - */ - inline const ReferenceCountedObjectPtr getUnchecked (const int index) const throw() + /** Checks whether a particular value is in the set. */ + bool contains (const Type valueToLookFor) const throw() { - lock.enter(); - jassert (((unsigned int) index) < (unsigned int) numUsed); - const ReferenceCountedObjectPtr result (this->elements [index]); - lock.exit(); - return result; - } + bool on = false; - /** Returns a pointer to the first object in the array. + for (int i = 0; i < values.size(); ++i) + { + if (values.getUnchecked(i) > valueToLookFor) + return on; - This will return a null pointer if the array's empty. - @see getLast - */ - inline const ReferenceCountedObjectPtr getFirst() const throw() - { - lock.enter(); - const ReferenceCountedObjectPtr result ((numUsed > 0) ? this->elements [0] - : (ObjectClass*) 0); - lock.exit(); + on = ! on; + } - return result; + return false; } - /** Returns a pointer to the last object in the array. + /** Returns the number of contiguous blocks of values. - This will return a null pointer if the array's empty. - @see getFirst + @see getRange */ - inline const ReferenceCountedObjectPtr getLast() const throw() + int getNumRanges() const throw() { - lock.enter(); - const ReferenceCountedObjectPtr result ((numUsed > 0) ? this->elements [numUsed - 1] - : (ObjectClass*) 0); - lock.exit(); - - return result; + return values.size() >> 1; } - /** Finds the index of the first occurrence of an object in the array. + /** Returns one of the contiguous ranges of values stored. - @param objectToLookFor the object to look for - @returns the index at which the object was found, or -1 if it's not found + @param rangeIndex the index of the range to look up, between 0 + and (getNumRanges() - 1) + @param startValue on return, the value at the start of the range + @param numValues on return, the number of values in the range + + @see getTotalRange */ - int indexOf (const ObjectClass* const objectToLookFor) const throw() + bool getRange (const int rangeIndex, + Type& startValue, + Type& numValues) const throw() { - int result = -1; - - lock.enter(); - ObjectClass** e = this->elements; - - for (int i = numUsed; --i >= 0;) + if (((unsigned int) rangeIndex) < (unsigned int) getNumRanges()) { - if (objectToLookFor == *e) - { - result = (int) (e - this->elements); - break; - } + startValue = values [rangeIndex << 1]; + numValues = values [(rangeIndex << 1) + 1] - startValue; - ++e; + return true; } - lock.exit(); - return result; + return false; } - /** Returns true if the array contains a specified object. + /** Returns the lowest and highest values in the set. - @param objectToLookFor the object to look for - @returns true if the object is in the array + @see getRange */ - bool contains (const ObjectClass* const objectToLookFor) const throw() + bool getTotalRange (Type& lowestValue, + Type& highestValue) const throw() { - lock.enter(); - ObjectClass** e = this->elements; - - for (int i = numUsed; --i >= 0;) + if (values.size() > 0) { - if (objectToLookFor == *e) - { - lock.exit(); - return true; - } - - ++e; + lowestValue = values.getUnchecked (0); + highestValue = values.getUnchecked (values.size() - 1); + return true; } - lock.exit(); return false; } - /** Appends a new object to the end of the array. + /** Adds a range of contiguous values to the set. - This will increase the new object's reference count. + e.g. addRange (10, 4) will add (10, 11, 12, 13) to the set. - @param newObject the new object to add to the array - @see set, insert, addIfNotAlreadyThere, addSorted, addArray + @param firstValue the start of the range of values to add + @param numValuesToAdd how many values to add */ - void add (ObjectClass* const newObject) throw() + void addRange (const Type firstValue, + const Type numValuesToAdd) throw() { - lock.enter(); - this->ensureAllocatedSize (numUsed + 1); - this->elements [numUsed++] = newObject; + jassert (numValuesToAdd >= 0); - if (newObject != 0) - newObject->incReferenceCount(); + if (numValuesToAdd > 0) + { + removeRange (firstValue, numValuesToAdd); - lock.exit(); - } + IntegerElementComparator sorter; + values.addSorted (sorter, firstValue); + values.addSorted (sorter, firstValue + numValuesToAdd); - /** Inserts a new object into the array at the given index. + simplify(); + } + } - If the index is less than 0 or greater than the size of the array, the - element will be added to the end of the array. - Otherwise, it will be inserted into the array, moving all the later elements - along to make room. + /** Removes a range of values from the set. - This will increase the new object's reference count. + e.g. removeRange (10, 4) will remove (10, 11, 12, 13) from the set. - @param indexToInsertAt the index at which the new element should be inserted - @param newObject the new object to add to the array - @see add, addSorted, addIfNotAlreadyThere, set + @param firstValue the start of the range of values to remove + @param numValuesToRemove how many values to remove */ - void insert (int indexToInsertAt, - ObjectClass* const newObject) throw() + void removeRange (const Type firstValue, + const Type numValuesToRemove) throw() { - if (indexToInsertAt >= 0) + jassert (numValuesToRemove >= 0); + + if (numValuesToRemove >= 0 + && firstValue < values.getLast()) { - lock.enter(); + const bool onAtStart = contains (firstValue - 1); + const Type lastValue = firstValue + jmin (numValuesToRemove, values.getLast() - firstValue); + const bool onAtEnd = contains (lastValue); - if (indexToInsertAt > numUsed) - indexToInsertAt = numUsed; + for (int i = values.size(); --i >= 0;) + { + if (values.getUnchecked(i) <= lastValue) + { + while (values.getUnchecked(i) >= firstValue) + { + values.remove (i); - this->ensureAllocatedSize (numUsed + 1); + if (--i < 0) + break; + } - ObjectClass** const e = this->elements + indexToInsertAt; - const int numToMove = numUsed - indexToInsertAt; + break; + } + } - if (numToMove > 0) - memmove (e + 1, e, numToMove * sizeof (ObjectClass*)); + IntegerElementComparator sorter; - *e = newObject; + if (onAtStart) + values.addSorted (sorter, firstValue); - if (newObject != 0) - newObject->incReferenceCount(); + if (onAtEnd) + values.addSorted (sorter, lastValue); - ++numUsed; - lock.exit(); - } - else - { - add (newObject); + simplify(); } } - /** Appends a new object at the end of the array as long as the array doesn't - already contain it. - - If the array already contains a matching object, nothing will be done. - - @param newObject the new object to add to the array - */ - void addIfNotAlreadyThere (ObjectClass* const newObject) throw() + /** Does an XOR of the values in a given range. */ + void invertRange (const Type firstValue, + const Type numValues) { - lock.enter(); + SparseSet newItems; + newItems.addRange (firstValue, numValues); - if (! contains (newObject)) - add (newObject); + int i; + for (i = getNumRanges(); --i >= 0;) + { + const int start = values [i << 1]; + const int end = values [(i << 1) + 1]; - lock.exit(); - } + newItems.removeRange (start, end); + } - /** Replaces an object in the array with a different one. + removeRange (firstValue, numValues); - If the index is less than zero, this method does nothing. - If the index is beyond the end of the array, the new object is added to the end of the array. + for (i = newItems.getNumRanges(); --i >= 0;) + { + const int start = newItems.values [i << 1]; + const int end = newItems.values [(i << 1) + 1]; - The object being added has its reference count increased, and if it's replacing - another object, then that one has its reference count decreased, and may be deleted. + addRange (start, end); + } + } - @param indexToChange the index whose value you want to change - @param newObject the new value to set for this index. - @see add, insert, remove - */ - void set (const int indexToChange, - ObjectClass* const newObject) + /** Checks whether any part of a given range overlaps any part of this one. */ + bool overlapsRange (const Type firstValue, + const Type numValues) throw() { - if (indexToChange >= 0) - { - lock.enter(); - - if (newObject != 0) - newObject->incReferenceCount(); + jassert (numValues >= 0); - if (indexToChange < numUsed) + if (numValues > 0) + { + for (int i = getNumRanges(); --i >= 0;) { - if (this->elements [indexToChange] != 0) - this->elements [indexToChange]->decReferenceCount(); + if (firstValue >= values.getUnchecked ((i << 1) + 1)) + return false; - this->elements [indexToChange] = newObject; - } - else - { - this->ensureAllocatedSize (numUsed + 1); - this->elements [numUsed++] = newObject; + if (firstValue + numValues > values.getUnchecked (i << 1)) + return true; } - - lock.exit(); } - } - /** Adds elements from another array to the end of this array. + return false; + } - @param arrayToAddFrom the array from which to copy the elements - @param startIndex the first element of the other array to start copying from - @param numElementsToAdd how many elements to add from the other array. If this - value is negative or greater than the number of available elements, - all available elements will be copied. - @see add - */ - void addArray (const ReferenceCountedArray& arrayToAddFrom, - int startIndex = 0, - int numElementsToAdd = -1) throw() + /** Checks whether the whole of a given range is contained within this one. */ + bool containsRange (const Type firstValue, + const Type numValues) throw() { - arrayToAddFrom.lockArray(); - lock.enter(); - - if (startIndex < 0) - { - jassertfalse - startIndex = 0; - } - - if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) - numElementsToAdd = arrayToAddFrom.size() - startIndex; + jassert (numValues >= 0); - if (numElementsToAdd > 0) + if (numValues > 0) { - this->ensureAllocatedSize (numUsed + numElementsToAdd); + for (int i = getNumRanges(); --i >= 0;) + { + if (firstValue >= values.getUnchecked ((i << 1) + 1)) + return false; - while (--numElementsToAdd >= 0) - add (arrayToAddFrom.getUnchecked (startIndex++)); + if (firstValue >= values.getUnchecked (i << 1) + && firstValue + numValues <= values.getUnchecked ((i << 1) + 1)) + return true; + } } - lock.exit(); - arrayToAddFrom.unlockArray(); + return false; } - /** Inserts a new object into the array assuming that the array is sorted. - - This will use a comparator to find the position at which the new object - should go. If the array isn't sorted, the behaviour of this - method will be unpredictable. + bool operator== (const SparseSet& other) throw() + { + return values == other.values; + } - @param comparator the comparator object to use to compare the elements - see the - sort() method for details about this object's form - @param newObject the new object to insert to the array - @see add, sort - */ - template - void addSorted (ElementComparator& comparator, - ObjectClass* newObject) throw() + bool operator!= (const SparseSet& other) throw() { - lock.enter(); - insert (findInsertIndexInSortedArray (comparator, this->elements, newObject, 0, numUsed), newObject); - lock.exit(); + return values != other.values; } - /** Inserts or replaces an object in the array, assuming it is sorted. + juce_UseDebuggingNewOperator - This is similar to addSorted, but if a matching element already exists, then it will be - replaced by the new one, rather than the new one being added as well. - */ - template - void addOrReplaceSorted (ElementComparator& comparator, - ObjectClass* newObject) throw() +private: + // alternating start/end values of ranges of values that are present. + Array values; + + void simplify() throw() { - lock.enter(); - const int index = findInsertIndexInSortedArray (comparator, this->elements, newObject, 0, numUsed); - - if (index > 0 && comparator.compareElements (newObject, this->elements [index - 1]) == 0) - set (index - 1, newObject); // replace an existing object that matches - else - insert (index, newObject); // no match, so insert the new one - - lock.exit(); - } - - /** Removes an object from the array. - - This will remove the object at a given index and move back all the - subsequent objects to close the gap. - - If the index passed in is out-of-range, nothing will happen. - - The object that is removed will have its reference count decreased, - and may be deleted if not referenced from elsewhere. - - @param indexToRemove the index of the element to remove - @see removeObject, removeRange - */ - void remove (const int indexToRemove) - { - lock.enter(); - - if (((unsigned int) indexToRemove) < (unsigned int) numUsed) - { - ObjectClass** const e = this->elements + indexToRemove; - - if (*e != 0) - (*e)->decReferenceCount(); - - --numUsed; - const int numberToShift = numUsed - indexToRemove; - - if (numberToShift > 0) - memmove (e, e + 1, numberToShift * sizeof (ObjectClass*)); - - if ((numUsed << 1) < this->numAllocated) - minimiseStorageOverheads(); - } - - lock.exit(); - } - - /** Removes the first occurrence of a specified object from the array. - - If the item isn't found, no action is taken. If it is found, it is - removed and has its reference count decreased. - - @param objectToRemove the object to try to remove - @see remove, removeRange - */ - void removeObject (ObjectClass* const objectToRemove) - { - lock.enter(); - remove (indexOf (objectToRemove)); - lock.exit(); - } - - /** Removes a range of objects from the array. - - This will remove a set of objects, starting from the given index, - and move any subsequent elements down to close the gap. - - If the range extends beyond the bounds of the array, it will - be safely clipped to the size of the array. - - The objects that are removed will have their reference counts decreased, - and may be deleted if not referenced from elsewhere. - - @param startIndex the index of the first object to remove - @param numberToRemove how many objects should be removed - @see remove, removeObject - */ - void removeRange (const int startIndex, - const int numberToRemove) - { - lock.enter(); - - const int start = jlimit (0, numUsed, startIndex); - const int end = jlimit (0, numUsed, startIndex + numberToRemove); - - if (end > start) - { - int i; - for (i = start; i < end; ++i) - { - if (this->elements[i] != 0) - { - this->elements[i]->decReferenceCount(); - this->elements[i] = 0; // (in case one of the destructors accesses this array and hits a dangling pointer) - } - } - - const int rangeSize = end - start; - ObjectClass** e = this->elements + start; - i = numUsed - end; - numUsed -= rangeSize; - - while (--i >= 0) - { - *e = e [rangeSize]; - ++e; - } - - if ((numUsed << 1) < this->numAllocated) - minimiseStorageOverheads(); - } - - lock.exit(); - } - - /** Removes the last n objects from the array. - - The objects that are removed will have their reference counts decreased, - and may be deleted if not referenced from elsewhere. - - @param howManyToRemove how many objects to remove from the end of the array - @see remove, removeObject, removeRange - */ - void removeLast (int howManyToRemove = 1) - { - lock.enter(); - - if (howManyToRemove > numUsed) - howManyToRemove = numUsed; - - while (--howManyToRemove >= 0) - remove (numUsed - 1); - - lock.exit(); - } - - /** Swaps a pair of objects in the array. - - If either of the indexes passed in is out-of-range, nothing will happen, - otherwise the two objects at these positions will be exchanged. - */ - void swap (const int index1, - const int index2) throw() - { - lock.enter(); - - if (((unsigned int) index1) < (unsigned int) numUsed - && ((unsigned int) index2) < (unsigned int) numUsed) - { - swapVariables (this->elements [index1], - this->elements [index2]); - } - - lock.exit(); - } - - /** Moves one of the objects to a different position. - - This will move the object to a specified index, shuffling along - any intervening elements as required. - - So for example, if you have the array { 0, 1, 2, 3, 4, 5 } then calling - move (2, 4) would result in { 0, 1, 3, 4, 2, 5 }. - - @param currentIndex the index of the object to be moved. If this isn't a - valid index, then nothing will be done - @param newIndex the index at which you'd like this object to end up. If this - is less than zero, it will be moved to the end of the array - */ - void move (const int currentIndex, - int newIndex) throw() - { - if (currentIndex != newIndex) - { - lock.enter(); - - if (((unsigned int) currentIndex) < (unsigned int) numUsed) - { - if (((unsigned int) newIndex) >= (unsigned int) numUsed) - newIndex = numUsed - 1; - - ObjectClass* const value = this->elements [currentIndex]; - - if (newIndex > currentIndex) - { - memmove (this->elements + currentIndex, - this->elements + currentIndex + 1, - (newIndex - currentIndex) * sizeof (ObjectClass*)); - } - else - { - memmove (this->elements + newIndex + 1, - this->elements + newIndex, - (currentIndex - newIndex) * sizeof (ObjectClass*)); - } - - this->elements [newIndex] = value; - } - - lock.exit(); - } - } - - /** Compares this array to another one. - - @returns true only if the other array contains the same objects in the same order - */ - bool operator== (const ReferenceCountedArray& other) const throw() - { - other.lockArray(); - lock.enter(); - - bool result = numUsed == other.numUsed; - - if (result) - { - for (int i = numUsed; --i >= 0;) - { - if (this->elements [i] != other.elements [i]) - { - result = false; - break; - } - } - } - - lock.exit(); - other.unlockArray(); - - return result; - } - - /** Compares this array to another one. - - @see operator== - */ - bool operator!= (const ReferenceCountedArray& other) const throw() - { - return ! operator== (other); - } - - /** Sorts the elements in the array. - - This will use a comparator object to sort the elements into order. The object - passed must have a method of the form: - @code - int compareElements (ElementType first, ElementType second); - @endcode - - ..and this method must return: - - a value of < 0 if the first comes before the second - - a value of 0 if the two objects are equivalent - - a value of > 0 if the second comes before the first - - To improve performance, the compareElements() method can be declared as static or const. - - @param comparator the comparator to use for comparing elements. - @param retainOrderOfEquivalentItems if this is true, then items - which the comparator says are equivalent will be - kept in the order in which they currently appear - in the array. This is slower to perform, but may - be important in some cases. If it's false, a faster - algorithm is used, but equivalent elements may be - rearranged. - - @see sortArray - */ - template - void sort (ElementComparator& comparator, - const bool retainOrderOfEquivalentItems = false) const throw() - { - (void) comparator; // if you pass in an object with a static compareElements() method, this - // avoids getting warning messages about the parameter being unused - - lock.enter(); - sortArray (comparator, this->elements, 0, size() - 1, retainOrderOfEquivalentItems); - lock.exit(); - } - - /** Reduces the amount of storage being used by the array. - - Arrays typically allocate slightly more storage than they need, and after - removing elements, they may have quite a lot of unused space allocated. - This method will reduce the amount of allocated storage to a minimum. - */ - void minimiseStorageOverheads() throw() - { - lock.enter(); - - if (numUsed == 0) - { - this->setAllocatedSize (0); - } - else - { - const int newAllocation = this->granularity * (numUsed / this->granularity + 1); - - if (newAllocation < this->numAllocated) - this->setAllocatedSize (newAllocation); - } - - lock.exit(); - } - - /** Locks the array's CriticalSection. - - Of course if the type of section used is a DummyCriticalSection, this won't - have any effect. - - @see unlockArray - */ - void lockArray() const throw() - { - lock.enter(); - } - - /** Unlocks the array's CriticalSection. - - Of course if the type of section used is a DummyCriticalSection, this won't - have any effect. + jassert ((values.size() & 1) == 0); - @see lockArray - */ - void unlockArray() const throw() - { - lock.exit(); + for (int i = values.size(); --i > 0;) + if (values.getUnchecked(i) == values.getUnchecked (i - 1)) + values.removeRange (i - 1, 2); } - - juce_UseDebuggingNewOperator - -private: - int numUsed; - TypeOfCriticalSectionToUse lock; }; -#endif // __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ -/********* End of inlined file: juce_ReferenceCountedArray.h *********/ +#endif // __JUCE_SPARSESET_JUCEHEADER__ +/********* End of inlined file: juce_SparseSet.h *********/ #endif -#ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__ +#ifndef __JUCE_VOIDARRAY_JUCEHEADER__ #endif #ifndef __JUCE_SORTEDSET_JUCEHEADER__ @@ -11077,435 +10647,868 @@ private: /********* End of inlined file: juce_SortedSet.h *********/ #endif -#ifndef __JUCE_SPARSESET_JUCEHEADER__ +#ifndef __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ -/********* Start of inlined file: juce_SparseSet.h *********/ -#ifndef __JUCE_SPARSESET_JUCEHEADER__ -#define __JUCE_SPARSESET_JUCEHEADER__ +/********* Start of inlined file: juce_ReferenceCountedArray.h *********/ +#ifndef __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ +#define __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ /** - Holds a set of primitive values, storing them as a set of ranges. + Holds a list of objects derived from ReferenceCountedObject. - This container acts like a simple BitArray, but can efficiently hold large - continguous ranges of values. It's quite a specialised class, mostly useful - for things like keeping the set of selected rows in a listbox. + A ReferenceCountedArray holds objects derived from ReferenceCountedObject, + and takes care of incrementing and decrementing their ref counts when they + are added and removed from the array. - The type used as a template paramter must be an integer type, such as int, short, - int64, etc. + To make all the array's methods thread-safe, pass in "CriticalSection" as the templated + TypeOfCriticalSectionToUse parameter, instead of the default DummyCriticalSection. + + @see Array, OwnedArray, StringArray */ -template -class SparseSet +template +class ReferenceCountedArray : private ArrayAllocationBase { public: - /** Creates a new empty set. */ - SparseSet() throw() - { - } + /** Creates an empty array. - /** Creates a copy of another SparseSet. */ - SparseSet (const SparseSet& other) throw() - : values (other.values) - { - } + @param granularity this is the size of increment by which the internal storage + used by the array will grow. Only change it from the default if you know the + array is going to be very big and needs to be able to grow efficiently. - /** Destructor. */ - ~SparseSet() throw() + @see ReferenceCountedObject, ArrayAllocationBase, Array, OwnedArray + */ + ReferenceCountedArray (const int granularity = juceDefaultArrayGranularity) throw() + : ArrayAllocationBase (granularity), + numUsed (0) { } - /** Clears the set. */ - void clear() throw() + /** Creates a copy of another array */ + ReferenceCountedArray (const ReferenceCountedArray& other) throw() + : ArrayAllocationBase (other.granularity), + numUsed (other.numUsed) { - values.clear(); + other.lockArray(); + this->setAllocatedSize (numUsed); + memcpy (this->elements, other.elements, numUsed * sizeof (ObjectClass*)); + + for (int i = numUsed; --i >= 0;) + if (this->elements[i] != 0) + this->elements[i]->incReferenceCount(); + + other.unlockArray(); } - /** Checks whether the set is empty. + /** Copies another array into this one. - This is much quicker than using (size() == 0). + Any existing objects in this array will first be released. */ - bool isEmpty() const throw() + const ReferenceCountedArray& operator= (const ReferenceCountedArray& other) throw() { - return values.size() == 0; + if (this != &other) + { + other.lockArray(); + lock.enter(); + + clear(); + + this->granularity = other.granularity; + this->ensureAllocatedSize (other.numUsed); + numUsed = other.numUsed; + memcpy (this->elements, other.elements, numUsed * sizeof (ObjectClass*)); + minimiseStorageOverheads(); + + for (int i = numUsed; --i >= 0;) + if (this->elements[i] != 0) + this->elements[i]->incReferenceCount(); + + lock.exit(); + other.unlockArray(); + } + + return *this; } - /** Returns the number of values in the set. + /** Destructor. - Because of the way the data is stored, this method can take longer if there - are a lot of items in the set. Use isEmpty() for a quick test of whether there - are any items. + Any objects in the array will be released, and may be deleted if not referenced from elsewhere. */ - Type size() const throw() + ~ReferenceCountedArray() { - Type num = 0; - - for (int i = 0; i < values.size(); i += 2) - num += values[i + 1] - values[i]; - - return num; + clear(); } - /** Returns one of the values in the set. + /** Removes all objects from the array. - @param index the index of the value to retrieve, in the range 0 to (size() - 1). - @returns the value at this index, or 0 if it's out-of-range + Any objects in the array that are not referenced from elsewhere will be deleted. */ - Type operator[] (int index) const throw() + void clear() { - for (int i = 0; i < values.size(); i += 2) - { - const Type s = values.getUnchecked(i); - const Type e = values.getUnchecked(i + 1); + lock.enter(); - if (index < e - s) - return s + index; + while (numUsed > 0) + if (this->elements [--numUsed] != 0) + this->elements [numUsed]->decReferenceCount(); - index -= e - s; - } + jassert (numUsed == 0); + this->setAllocatedSize (0); - return (Type) 0; + lock.exit(); } - /** Checks whether a particular value is in the set. */ - bool contains (const Type valueToLookFor) const throw() + /** Returns the current number of objects in the array. */ + inline int size() const throw() { - bool on = false; + return numUsed; + } - for (int i = 0; i < values.size(); ++i) - { - if (values.getUnchecked(i) > valueToLookFor) - return on; + /** Returns a pointer to the object at this index in the array. - on = ! on; - } + If the index is out-of-range, this will return a null pointer, (and + it could be null anyway, because it's ok for the array to hold null + pointers as well as objects). - return false; + @see getUnchecked + */ + inline const ReferenceCountedObjectPtr operator[] (const int index) const throw() + { + lock.enter(); + const ReferenceCountedObjectPtr result ((((unsigned int) index) < (unsigned int) numUsed) + ? this->elements [index] + : (ObjectClass*) 0); + lock.exit(); + return result; } - /** Returns the number of contiguous blocks of values. + /** Returns a pointer to the object at this index in the array, without checking whether the index is in-range. - @see getRange + This is a faster and less safe version of operator[] which doesn't check the index passed in, so + it can be used when you're sure the index if always going to be legal. */ - int getNumRanges() const throw() + inline const ReferenceCountedObjectPtr getUnchecked (const int index) const throw() { - return values.size() >> 1; + lock.enter(); + jassert (((unsigned int) index) < (unsigned int) numUsed); + const ReferenceCountedObjectPtr result (this->elements [index]); + lock.exit(); + return result; } - /** Returns one of the contiguous ranges of values stored. + /** Returns a pointer to the first object in the array. - @param rangeIndex the index of the range to look up, between 0 - and (getNumRanges() - 1) - @param startValue on return, the value at the start of the range - @param numValues on return, the number of values in the range + This will return a null pointer if the array's empty. + @see getLast + */ + inline const ReferenceCountedObjectPtr getFirst() const throw() + { + lock.enter(); + const ReferenceCountedObjectPtr result ((numUsed > 0) ? this->elements [0] + : (ObjectClass*) 0); + lock.exit(); - @see getTotalRange + return result; + } + + /** Returns a pointer to the last object in the array. + + This will return a null pointer if the array's empty. + @see getFirst */ - bool getRange (const int rangeIndex, - Type& startValue, - Type& numValues) const throw() + inline const ReferenceCountedObjectPtr getLast() const throw() { - if (((unsigned int) rangeIndex) < (unsigned int) getNumRanges()) + lock.enter(); + const ReferenceCountedObjectPtr result ((numUsed > 0) ? this->elements [numUsed - 1] + : (ObjectClass*) 0); + lock.exit(); + + return result; + } + + /** Finds the index of the first occurrence of an object in the array. + + @param objectToLookFor the object to look for + @returns the index at which the object was found, or -1 if it's not found + */ + int indexOf (const ObjectClass* const objectToLookFor) const throw() + { + int result = -1; + + lock.enter(); + ObjectClass** e = this->elements; + + for (int i = numUsed; --i >= 0;) { - startValue = values [rangeIndex << 1]; - numValues = values [(rangeIndex << 1) + 1] - startValue; + if (objectToLookFor == *e) + { + result = (int) (e - this->elements); + break; + } - return true; + ++e; } - return false; + lock.exit(); + return result; } - /** Returns the lowest and highest values in the set. + /** Returns true if the array contains a specified object. - @see getRange + @param objectToLookFor the object to look for + @returns true if the object is in the array */ - bool getTotalRange (Type& lowestValue, - Type& highestValue) const throw() + bool contains (const ObjectClass* const objectToLookFor) const throw() { - if (values.size() > 0) + lock.enter(); + ObjectClass** e = this->elements; + + for (int i = numUsed; --i >= 0;) { - lowestValue = values.getUnchecked (0); - highestValue = values.getUnchecked (values.size() - 1); - return true; + if (objectToLookFor == *e) + { + lock.exit(); + return true; + } + + ++e; } + lock.exit(); return false; } - /** Adds a range of contiguous values to the set. + /** Appends a new object to the end of the array. - e.g. addRange (10, 4) will add (10, 11, 12, 13) to the set. + This will increase the new object's reference count. - @param firstValue the start of the range of values to add - @param numValuesToAdd how many values to add + @param newObject the new object to add to the array + @see set, insert, addIfNotAlreadyThere, addSorted, addArray */ - void addRange (const Type firstValue, - const Type numValuesToAdd) throw() + void add (ObjectClass* const newObject) throw() { - jassert (numValuesToAdd >= 0); - - if (numValuesToAdd > 0) - { - removeRange (firstValue, numValuesToAdd); + lock.enter(); + this->ensureAllocatedSize (numUsed + 1); + this->elements [numUsed++] = newObject; - IntegerElementComparator sorter; - values.addSorted (sorter, firstValue); - values.addSorted (sorter, firstValue + numValuesToAdd); + if (newObject != 0) + newObject->incReferenceCount(); - simplify(); - } + lock.exit(); } - /** Removes a range of values from the set. + /** Inserts a new object into the array at the given index. - e.g. removeRange (10, 4) will remove (10, 11, 12, 13) from the set. + If the index is less than 0 or greater than the size of the array, the + element will be added to the end of the array. + Otherwise, it will be inserted into the array, moving all the later elements + along to make room. - @param firstValue the start of the range of values to remove - @param numValuesToRemove how many values to remove + This will increase the new object's reference count. + + @param indexToInsertAt the index at which the new element should be inserted + @param newObject the new object to add to the array + @see add, addSorted, addIfNotAlreadyThere, set */ - void removeRange (const Type firstValue, - const Type numValuesToRemove) throw() + void insert (int indexToInsertAt, + ObjectClass* const newObject) throw() { - jassert (numValuesToRemove >= 0); - - if (numValuesToRemove >= 0 - && firstValue < values.getLast()) + if (indexToInsertAt >= 0) { - const bool onAtStart = contains (firstValue - 1); - const Type lastValue = firstValue + jmin (numValuesToRemove, values.getLast() - firstValue); - const bool onAtEnd = contains (lastValue); + lock.enter(); - for (int i = values.size(); --i >= 0;) - { - if (values.getUnchecked(i) <= lastValue) - { - while (values.getUnchecked(i) >= firstValue) - { - values.remove (i); + if (indexToInsertAt > numUsed) + indexToInsertAt = numUsed; - if (--i < 0) - break; - } + this->ensureAllocatedSize (numUsed + 1); - break; - } - } + ObjectClass** const e = this->elements + indexToInsertAt; + const int numToMove = numUsed - indexToInsertAt; - IntegerElementComparator sorter; + if (numToMove > 0) + memmove (e + 1, e, numToMove * sizeof (ObjectClass*)); - if (onAtStart) - values.addSorted (sorter, firstValue); + *e = newObject; - if (onAtEnd) - values.addSorted (sorter, lastValue); + if (newObject != 0) + newObject->incReferenceCount(); - simplify(); + ++numUsed; + lock.exit(); + } + else + { + add (newObject); } } - /** Does an XOR of the values in a given range. */ - void invertRange (const Type firstValue, - const Type numValues) + /** Appends a new object at the end of the array as long as the array doesn't + already contain it. + + If the array already contains a matching object, nothing will be done. + + @param newObject the new object to add to the array + */ + void addIfNotAlreadyThere (ObjectClass* const newObject) throw() { - SparseSet newItems; - newItems.addRange (firstValue, numValues); + lock.enter(); - int i; - for (i = getNumRanges(); --i >= 0;) - { - const int start = values [i << 1]; - const int end = values [(i << 1) + 1]; + if (! contains (newObject)) + add (newObject); - newItems.removeRange (start, end); - } + lock.exit(); + } - removeRange (firstValue, numValues); + /** Replaces an object in the array with a different one. - for (i = newItems.getNumRanges(); --i >= 0;) - { - const int start = newItems.values [i << 1]; - const int end = newItems.values [(i << 1) + 1]; + If the index is less than zero, this method does nothing. + If the index is beyond the end of the array, the new object is added to the end of the array. - addRange (start, end); - } - } + The object being added has its reference count increased, and if it's replacing + another object, then that one has its reference count decreased, and may be deleted. - /** Checks whether any part of a given range overlaps any part of this one. */ - bool overlapsRange (const Type firstValue, - const Type numValues) throw() + @param indexToChange the index whose value you want to change + @param newObject the new value to set for this index. + @see add, insert, remove + */ + void set (const int indexToChange, + ObjectClass* const newObject) { - jassert (numValues >= 0); - - if (numValues > 0) + if (indexToChange >= 0) { - for (int i = getNumRanges(); --i >= 0;) + lock.enter(); + + if (newObject != 0) + newObject->incReferenceCount(); + + if (indexToChange < numUsed) { - if (firstValue >= values.getUnchecked ((i << 1) + 1)) - return false; + if (this->elements [indexToChange] != 0) + this->elements [indexToChange]->decReferenceCount(); - if (firstValue + numValues > values.getUnchecked (i << 1)) - return true; + this->elements [indexToChange] = newObject; + } + else + { + this->ensureAllocatedSize (numUsed + 1); + this->elements [numUsed++] = newObject; } - } - return false; + lock.exit(); + } } - /** Checks whether the whole of a given range is contained within this one. */ - bool containsRange (const Type firstValue, - const Type numValues) throw() + /** Adds elements from another array to the end of this array. + + @param arrayToAddFrom the array from which to copy the elements + @param startIndex the first element of the other array to start copying from + @param numElementsToAdd how many elements to add from the other array. If this + value is negative or greater than the number of available elements, + all available elements will be copied. + @see add + */ + void addArray (const ReferenceCountedArray& arrayToAddFrom, + int startIndex = 0, + int numElementsToAdd = -1) throw() { - jassert (numValues >= 0); + arrayToAddFrom.lockArray(); + lock.enter(); - if (numValues > 0) + if (startIndex < 0) { - for (int i = getNumRanges(); --i >= 0;) - { - if (firstValue >= values.getUnchecked ((i << 1) + 1)) - return false; + jassertfalse + startIndex = 0; + } - if (firstValue >= values.getUnchecked (i << 1) - && firstValue + numValues <= values.getUnchecked ((i << 1) + 1)) - return true; - } + if (numElementsToAdd < 0 || startIndex + numElementsToAdd > arrayToAddFrom.size()) + numElementsToAdd = arrayToAddFrom.size() - startIndex; + + if (numElementsToAdd > 0) + { + this->ensureAllocatedSize (numUsed + numElementsToAdd); + + while (--numElementsToAdd >= 0) + add (arrayToAddFrom.getUnchecked (startIndex++)); } - return false; + lock.exit(); + arrayToAddFrom.unlockArray(); } - bool operator== (const SparseSet& other) throw() + /** Inserts a new object into the array assuming that the array is sorted. + + This will use a comparator to find the position at which the new object + should go. If the array isn't sorted, the behaviour of this + method will be unpredictable. + + @param comparator the comparator object to use to compare the elements - see the + sort() method for details about this object's form + @param newObject the new object to insert to the array + @see add, sort + */ + template + void addSorted (ElementComparator& comparator, + ObjectClass* newObject) throw() { - return values == other.values; + lock.enter(); + insert (findInsertIndexInSortedArray (comparator, this->elements, newObject, 0, numUsed), newObject); + lock.exit(); } - bool operator!= (const SparseSet& other) throw() + /** Inserts or replaces an object in the array, assuming it is sorted. + + This is similar to addSorted, but if a matching element already exists, then it will be + replaced by the new one, rather than the new one being added as well. + */ + template + void addOrReplaceSorted (ElementComparator& comparator, + ObjectClass* newObject) throw() { - return values != other.values; + lock.enter(); + const int index = findInsertIndexInSortedArray (comparator, this->elements, newObject, 0, numUsed); + + if (index > 0 && comparator.compareElements (newObject, this->elements [index - 1]) == 0) + set (index - 1, newObject); // replace an existing object that matches + else + insert (index, newObject); // no match, so insert the new one + + lock.exit(); } - juce_UseDebuggingNewOperator + /** Removes an object from the array. -private: - // alternating start/end values of ranges of values that are present. - Array values; + This will remove the object at a given index and move back all the + subsequent objects to close the gap. - void simplify() throw() - { - jassert ((values.size() & 1) == 0); + If the index passed in is out-of-range, nothing will happen. - for (int i = values.size(); --i > 0;) - if (values.getUnchecked(i) == values.getUnchecked (i - 1)) - values.removeRange (i - 1, 2); - } -}; + The object that is removed will have its reference count decreased, + and may be deleted if not referenced from elsewhere. -#endif // __JUCE_SPARSESET_JUCEHEADER__ -/********* End of inlined file: juce_SparseSet.h *********/ + @param indexToRemove the index of the element to remove + @see removeObject, removeRange + */ + void remove (const int indexToRemove) + { + lock.enter(); -#endif -#ifndef __JUCE_VARIANT_JUCEHEADER__ + if (((unsigned int) indexToRemove) < (unsigned int) numUsed) + { + ObjectClass** const e = this->elements + indexToRemove; -/********* Start of inlined file: juce_Variant.h *********/ -#ifndef __JUCE_VARIANT_JUCEHEADER__ -#define __JUCE_VARIANT_JUCEHEADER__ + if (*e != 0) + (*e)->decReferenceCount(); -class JUCE_API DynamicObject; + --numUsed; + const int numberToShift = numUsed - indexToRemove; -/** - A variant class, that can be used to hold a range of primitive values. + if (numberToShift > 0) + memmove (e, e + 1, numberToShift * sizeof (ObjectClass*)); - A var object can hold a range of simple primitive values, strings, or - a reference-counted pointer to a DynamicObject. The var class is intended - to act like the values used in dynamic scripting languages. + if ((numUsed << 1) < this->numAllocated) + minimiseStorageOverheads(); + } - @see DynamicObject -*/ -class JUCE_API var -{ -public: + lock.exit(); + } - typedef const var (DynamicObject::*MethodFunction) (const var* arguments, int numArguments); + /** Removes the first occurrence of a specified object from the array. - /** Creates a void variant. */ - var() throw(); + If the item isn't found, no action is taken. If it is found, it is + removed and has its reference count decreased. - /** Destructor. */ - ~var(); + @param objectToRemove the object to try to remove + @see remove, removeRange + */ + void removeObject (ObjectClass* const objectToRemove) + { + lock.enter(); + remove (indexOf (objectToRemove)); + lock.exit(); + } - var (const var& valueToCopy) throw(); - var (const int value) throw(); - var (const bool value) throw(); - var (const double value) throw(); - var (const char* const value) throw(); - var (const juce_wchar* const value) throw(); - var (const String& value) throw(); - var (DynamicObject* const object) throw(); - var (MethodFunction method) throw(); + /** Removes a range of objects from the array. - const var& operator= (const var& valueToCopy) throw(); - const var& operator= (const int value) throw(); - const var& operator= (const bool value) throw(); - const var& operator= (const double value) throw(); - const var& operator= (const char* const value) throw(); - const var& operator= (const juce_wchar* const value) throw(); - const var& operator= (const String& value) throw(); - const var& operator= (DynamicObject* const object) throw(); - const var& operator= (MethodFunction method) throw(); + This will remove a set of objects, starting from the given index, + and move any subsequent elements down to close the gap. - operator int() const throw(); - operator bool() const throw(); - operator double() const throw(); - operator const String() const throw(); - const String toString() const throw(); - DynamicObject* getObject() const throw(); + If the range extends beyond the bounds of the array, it will + be safely clipped to the size of the array. - bool isVoid() const throw() { return type == voidType; } - bool isInt() const throw() { return type == intType; } - bool isBool() const throw() { return type == boolType; } - bool isDouble() const throw() { return type == doubleType; } - bool isString() const throw() { return type == stringType; } - bool isObject() const throw() { return type == objectType; } - bool isMethod() const throw() { return type == methodType; } + The objects that are removed will have their reference counts decreased, + and may be deleted if not referenced from elsewhere. - class JUCE_API identifier + @param startIndex the index of the first object to remove + @param numberToRemove how many objects should be removed + @see remove, removeObject + */ + void removeRange (const int startIndex, + const int numberToRemove) { - public: - identifier (const char* const name) throw(); - identifier (const String& name) throw(); - ~identifier() throw(); + lock.enter(); - bool operator== (const identifier& other) const throw() { return hashCode == other.hashCode; } + const int start = jlimit (0, numUsed, startIndex); + const int end = jlimit (0, numUsed, startIndex + numberToRemove); - String name; - int hashCode; - }; + if (end > start) + { + int i; + for (i = start; i < end; ++i) + { + if (this->elements[i] != 0) + { + this->elements[i]->decReferenceCount(); + this->elements[i] = 0; // (in case one of the destructors accesses this array and hits a dangling pointer) + } + } - /** If this variant is an object, this returns one of its properties. */ - const var operator[] (const identifier& propertyName) const throw(); + const int rangeSize = end - start; + ObjectClass** e = this->elements + start; + i = numUsed - end; + numUsed -= rangeSize; - /** If this variant is an object, this invokes one of its methods with no arguments. */ - const var call (const identifier& method) const; - /** If this variant is an object, this invokes one of its methods with one argument. */ - const var call (const identifier& method, const var& arg1) const; - /** If this variant is an object, this invokes one of its methods with 2 arguments. */ - const var call (const identifier& method, const var& arg1, const var& arg2) const; - /** If this variant is an object, this invokes one of its methods with 3 arguments. */ - const var call (const identifier& method, const var& arg1, const var& arg2, const var& arg3); - /** If this variant is an object, this invokes one of its methods with 4 arguments. */ - const var call (const identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4) const; - /** If this variant is an object, this invokes one of its methods with 5 arguments. */ - const var call (const identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const; + while (--i >= 0) + { + *e = e [rangeSize]; + ++e; + } - /** If this variant is an object, this invokes one of its methods with a list of arguments. */ - const var invoke (const identifier& method, const var* arguments, int numArguments) const; + if ((numUsed << 1) < this->numAllocated) + minimiseStorageOverheads(); + } - /** If this variant is a method pointer, this invokes it on a target object. */ - const var invoke (const var& targetObject, const var* arguments, int numArguments) const; + lock.exit(); + } - juce_UseDebuggingNewOperator + /** Removes the last n objects from the array. -private: - enum Type + The objects that are removed will have their reference counts decreased, + and may be deleted if not referenced from elsewhere. + + @param howManyToRemove how many objects to remove from the end of the array + @see remove, removeObject, removeRange + */ + void removeLast (int howManyToRemove = 1) + { + lock.enter(); + + if (howManyToRemove > numUsed) + howManyToRemove = numUsed; + + while (--howManyToRemove >= 0) + remove (numUsed - 1); + + lock.exit(); + } + + /** Swaps a pair of objects in the array. + + If either of the indexes passed in is out-of-range, nothing will happen, + otherwise the two objects at these positions will be exchanged. + */ + void swap (const int index1, + const int index2) throw() + { + lock.enter(); + + if (((unsigned int) index1) < (unsigned int) numUsed + && ((unsigned int) index2) < (unsigned int) numUsed) + { + swapVariables (this->elements [index1], + this->elements [index2]); + } + + lock.exit(); + } + + /** Moves one of the objects to a different position. + + This will move the object to a specified index, shuffling along + any intervening elements as required. + + So for example, if you have the array { 0, 1, 2, 3, 4, 5 } then calling + move (2, 4) would result in { 0, 1, 3, 4, 2, 5 }. + + @param currentIndex the index of the object to be moved. If this isn't a + valid index, then nothing will be done + @param newIndex the index at which you'd like this object to end up. If this + is less than zero, it will be moved to the end of the array + */ + void move (const int currentIndex, + int newIndex) throw() + { + if (currentIndex != newIndex) + { + lock.enter(); + + if (((unsigned int) currentIndex) < (unsigned int) numUsed) + { + if (((unsigned int) newIndex) >= (unsigned int) numUsed) + newIndex = numUsed - 1; + + ObjectClass* const value = this->elements [currentIndex]; + + if (newIndex > currentIndex) + { + memmove (this->elements + currentIndex, + this->elements + currentIndex + 1, + (newIndex - currentIndex) * sizeof (ObjectClass*)); + } + else + { + memmove (this->elements + newIndex + 1, + this->elements + newIndex, + (currentIndex - newIndex) * sizeof (ObjectClass*)); + } + + this->elements [newIndex] = value; + } + + lock.exit(); + } + } + + /** Compares this array to another one. + + @returns true only if the other array contains the same objects in the same order + */ + bool operator== (const ReferenceCountedArray& other) const throw() + { + other.lockArray(); + lock.enter(); + + bool result = numUsed == other.numUsed; + + if (result) + { + for (int i = numUsed; --i >= 0;) + { + if (this->elements [i] != other.elements [i]) + { + result = false; + break; + } + } + } + + lock.exit(); + other.unlockArray(); + + return result; + } + + /** Compares this array to another one. + + @see operator== + */ + bool operator!= (const ReferenceCountedArray& other) const throw() + { + return ! operator== (other); + } + + /** Sorts the elements in the array. + + This will use a comparator object to sort the elements into order. The object + passed must have a method of the form: + @code + int compareElements (ElementType first, ElementType second); + @endcode + + ..and this method must return: + - a value of < 0 if the first comes before the second + - a value of 0 if the two objects are equivalent + - a value of > 0 if the second comes before the first + + To improve performance, the compareElements() method can be declared as static or const. + + @param comparator the comparator to use for comparing elements. + @param retainOrderOfEquivalentItems if this is true, then items + which the comparator says are equivalent will be + kept in the order in which they currently appear + in the array. This is slower to perform, but may + be important in some cases. If it's false, a faster + algorithm is used, but equivalent elements may be + rearranged. + + @see sortArray + */ + template + void sort (ElementComparator& comparator, + const bool retainOrderOfEquivalentItems = false) const throw() + { + (void) comparator; // if you pass in an object with a static compareElements() method, this + // avoids getting warning messages about the parameter being unused + + lock.enter(); + sortArray (comparator, this->elements, 0, size() - 1, retainOrderOfEquivalentItems); + lock.exit(); + } + + /** Reduces the amount of storage being used by the array. + + Arrays typically allocate slightly more storage than they need, and after + removing elements, they may have quite a lot of unused space allocated. + This method will reduce the amount of allocated storage to a minimum. + */ + void minimiseStorageOverheads() throw() + { + lock.enter(); + + if (numUsed == 0) + { + this->setAllocatedSize (0); + } + else + { + const int newAllocation = this->granularity * (numUsed / this->granularity + 1); + + if (newAllocation < this->numAllocated) + this->setAllocatedSize (newAllocation); + } + + lock.exit(); + } + + /** Locks the array's CriticalSection. + + Of course if the type of section used is a DummyCriticalSection, this won't + have any effect. + + @see unlockArray + */ + void lockArray() const throw() + { + lock.enter(); + } + + /** Unlocks the array's CriticalSection. + + Of course if the type of section used is a DummyCriticalSection, this won't + have any effect. + + @see lockArray + */ + void unlockArray() const throw() + { + lock.exit(); + } + + juce_UseDebuggingNewOperator + +private: + int numUsed; + TypeOfCriticalSectionToUse lock; +}; + +#endif // __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ +/********* End of inlined file: juce_ReferenceCountedArray.h *********/ + +#endif +#ifndef __JUCE_OWNEDARRAY_JUCEHEADER__ + +#endif +#ifndef __JUCE_VARIANT_JUCEHEADER__ + +/********* Start of inlined file: juce_Variant.h *********/ +#ifndef __JUCE_VARIANT_JUCEHEADER__ +#define __JUCE_VARIANT_JUCEHEADER__ + +class JUCE_API DynamicObject; + +/** + A variant class, that can be used to hold a range of primitive values. + + A var object can hold a range of simple primitive values, strings, or + a reference-counted pointer to a DynamicObject. The var class is intended + to act like the values used in dynamic scripting languages. + + @see DynamicObject +*/ +class JUCE_API var +{ +public: + + typedef const var (DynamicObject::*MethodFunction) (const var* arguments, int numArguments); + + /** Creates a void variant. */ + var() throw(); + + /** Destructor. */ + ~var(); + + var (const var& valueToCopy) throw(); + var (const int value) throw(); + var (const bool value) throw(); + var (const double value) throw(); + var (const char* const value) throw(); + var (const juce_wchar* const value) throw(); + var (const String& value) throw(); + var (DynamicObject* const object) throw(); + var (MethodFunction method) throw(); + + const var& operator= (const var& valueToCopy) throw(); + const var& operator= (const int value) throw(); + const var& operator= (const bool value) throw(); + const var& operator= (const double value) throw(); + const var& operator= (const char* const value) throw(); + const var& operator= (const juce_wchar* const value) throw(); + const var& operator= (const String& value) throw(); + const var& operator= (DynamicObject* const object) throw(); + const var& operator= (MethodFunction method) throw(); + + operator int() const throw(); + operator bool() const throw(); + operator double() const throw(); + operator const String() const throw(); + const String toString() const throw(); + DynamicObject* getObject() const throw(); + + bool isVoid() const throw() { return type == voidType; } + bool isInt() const throw() { return type == intType; } + bool isBool() const throw() { return type == boolType; } + bool isDouble() const throw() { return type == doubleType; } + bool isString() const throw() { return type == stringType; } + bool isObject() const throw() { return type == objectType; } + bool isMethod() const throw() { return type == methodType; } + + class JUCE_API identifier + { + public: + identifier (const char* const name) throw(); + identifier (const String& name) throw(); + ~identifier() throw(); + + bool operator== (const identifier& other) const throw() { return hashCode == other.hashCode; } + + String name; + int hashCode; + }; + + /** If this variant is an object, this returns one of its properties. */ + const var operator[] (const identifier& propertyName) const throw(); + + /** If this variant is an object, this invokes one of its methods with no arguments. */ + const var call (const identifier& method) const; + /** If this variant is an object, this invokes one of its methods with one argument. */ + const var call (const identifier& method, const var& arg1) const; + /** If this variant is an object, this invokes one of its methods with 2 arguments. */ + const var call (const identifier& method, const var& arg1, const var& arg2) const; + /** If this variant is an object, this invokes one of its methods with 3 arguments. */ + const var call (const identifier& method, const var& arg1, const var& arg2, const var& arg3); + /** If this variant is an object, this invokes one of its methods with 4 arguments. */ + const var call (const identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4) const; + /** If this variant is an object, this invokes one of its methods with 5 arguments. */ + const var call (const identifier& method, const var& arg1, const var& arg2, const var& arg3, const var& arg4, const var& arg5) const; + + /** If this variant is an object, this invokes one of its methods with a list of arguments. */ + const var invoke (const identifier& method, const var* arguments, int numArguments) const; + + /** If this variant is a method pointer, this invokes it on a target object. */ + const var invoke (const var& targetObject, const var* arguments, int numArguments) const; + + juce_UseDebuggingNewOperator + +private: + enum Type { voidType = 0, intType, @@ -11610,9 +11613,6 @@ private: #endif // __JUCE_VARIANT_JUCEHEADER__ /********* End of inlined file: juce_Variant.h *********/ -#endif -#ifndef __JUCE_VOIDARRAY_JUCEHEADER__ - #endif #ifndef __JUCE_INPUTSTREAM_JUCEHEADER__ @@ -23872,6 +23872,52 @@ private: #endif #ifndef __JUCE_APPLICATIONCOMMANDID_JUCEHEADER__ +#endif +#ifndef __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ + +/********* Start of inlined file: juce_DeletedAtShutdown.h *********/ +#ifndef __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ +#define __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ + +/** + Classes derived from this will be automatically deleted when the application exits. + + After JUCEApplication::shutdown() has been called, any objects derived from + DeletedAtShutdown which are still in existence will be deleted in the reverse + order to that in which they were created. + + So if you've got a singleton and don't want to have to explicitly delete it, just + inherit from this and it'll be taken care of. +*/ +class JUCE_API DeletedAtShutdown +{ +protected: + /** Creates a DeletedAtShutdown object. */ + DeletedAtShutdown() throw(); + + /** Destructor. + + It's ok to delete these objects explicitly - it's only the ones left + dangling at the end that will be deleted automatically. + */ + virtual ~DeletedAtShutdown(); + +public: + /** Deletes all extant objects. + + This shouldn't be used by applications, as it's called automatically + in the shutdown code of the JUCEApplication class. + */ + static void deleteAll(); + +private: + DeletedAtShutdown (const DeletedAtShutdown&); + const DeletedAtShutdown& operator= (const DeletedAtShutdown&); +}; + +#endif // __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ +/********* End of inlined file: juce_DeletedAtShutdown.h *********/ + #endif #ifndef __JUCE_APPLICATIONCOMMANDINFO_JUCEHEADER__ @@ -23972,49 +24018,6 @@ private: #ifndef __JUCE_DESKTOP_JUCEHEADER__ #define __JUCE_DESKTOP_JUCEHEADER__ -/********* Start of inlined file: juce_DeletedAtShutdown.h *********/ -#ifndef __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ -#define __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ - -/** - Classes derived from this will be automatically deleted when the application exits. - - After JUCEApplication::shutdown() has been called, any objects derived from - DeletedAtShutdown which are still in existence will be deleted in the reverse - order to that in which they were created. - - So if you've got a singleton and don't want to have to explicitly delete it, just - inherit from this and it'll be taken care of. -*/ -class JUCE_API DeletedAtShutdown -{ -protected: - /** Creates a DeletedAtShutdown object. */ - DeletedAtShutdown() throw(); - - /** Destructor. - - It's ok to delete these objects explicitly - it's only the ones left - dangling at the end that will be deleted automatically. - */ - virtual ~DeletedAtShutdown(); - -public: - /** Deletes all extant objects. - - This shouldn't be used by applications, as it's called automatically - in the shutdown code of the JUCEApplication class. - */ - static void deleteAll(); - -private: - DeletedAtShutdown (const DeletedAtShutdown&); - const DeletedAtShutdown& operator= (const DeletedAtShutdown&); -}; - -#endif // __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ -/********* End of inlined file: juce_DeletedAtShutdown.h *********/ - /********* Start of inlined file: juce_Timer.h *********/ #ifndef __JUCE_TIMER_JUCEHEADER__ #define __JUCE_TIMER_JUCEHEADER__ @@ -25135,9 +25138,6 @@ private: #endif // __JUCE_APPLICATIONPROPERTIES_JUCEHEADER__ /********* End of inlined file: juce_ApplicationProperties.h *********/ -#endif -#ifndef __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ - #endif #ifndef __JUCE_PROPERTIESFILE_JUCEHEADER__ @@ -26823,6 +26823,9 @@ private: #endif #ifndef __JUCE_MIDIMESSAGE_JUCEHEADER__ +#endif +#ifndef __JUCE_MIDIMESSAGESEQUENCE_JUCEHEADER__ + #endif #ifndef __JUCE_MIDIMESSAGECOLLECTOR_JUCEHEADER__ @@ -27057,9 +27060,6 @@ private: #endif // __JUCE_MIDIMESSAGECOLLECTOR_JUCEHEADER__ /********* End of inlined file: juce_MidiMessageCollector.h *********/ -#endif -#ifndef __JUCE_MIDIMESSAGESEQUENCE_JUCEHEADER__ - #endif #ifndef __JUCE_AUDIODATACONVERTERS_JUCEHEADER__ @@ -28414,6 +28414,9 @@ private: #endif #ifndef __JUCE_AUDIOPROCESSOREDITOR_JUCEHEADER__ +#endif +#ifndef __JUCE_AUDIOPROCESSORLISTENER_JUCEHEADER__ + #endif #ifndef __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ @@ -29676,9 +29679,6 @@ private: #endif // __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ /********* End of inlined file: juce_AudioProcessorGraph.h *********/ -#endif -#ifndef __JUCE_AUDIOPROCESSORLISTENER_JUCEHEADER__ - #endif #ifndef __JUCE_AUDIOPROCESSORPLAYER_JUCEHEADER__ @@ -32539,6 +32539,12 @@ private: #endif // __JUCE_TONEGENERATORAUDIOSOURCE_JUCEHEADER__ /********* End of inlined file: juce_ToneGeneratorAudioSource.h *********/ +#endif +#ifndef __JUCE_AUDIOIODEVICE_JUCEHEADER__ + +#endif +#ifndef __JUCE_MIDIINPUT_JUCEHEADER__ + #endif #ifndef __JUCE_AUDIODEVICEMANAGER_JUCEHEADER__ @@ -34855,17 +34861,11 @@ private: /********* End of inlined file: juce_AudioDeviceManager.h *********/ #endif -#ifndef __JUCE_AUDIOIODEVICE_JUCEHEADER__ +#ifndef __JUCE_MIDIOUTPUT_JUCEHEADER__ #endif #ifndef __JUCE_AUDIOIODEVICETYPE_JUCEHEADER__ -#endif -#ifndef __JUCE_MIDIINPUT_JUCEHEADER__ - -#endif -#ifndef __JUCE_MIDIOUTPUT_JUCEHEADER__ - #endif #ifndef __JUCE_SAMPLER_JUCEHEADER__ @@ -36947,162 +36947,6 @@ private: #endif // __JUCE_AUDIOCDBURNER_JUCEHEADER__ /********* End of inlined file: juce_AudioCDBurner.h *********/ -#endif -#ifndef __JUCE_AUDIOCDREADER_JUCEHEADER__ - -/********* Start of inlined file: juce_AudioCDReader.h *********/ -#ifndef __JUCE_AUDIOCDREADER_JUCEHEADER__ -#define __JUCE_AUDIOCDREADER_JUCEHEADER__ - -#if JUCE_MAC - -#endif - -/** - A type of AudioFormatReader that reads from an audio CD. - - One of these can be used to read a CD as if it's one big audio stream. Use the - getPositionOfTrackStart() method to find where the individual tracks are - within the stream. - - @see AudioFormatReader -*/ -class JUCE_API AudioCDReader : public AudioFormatReader -{ -public: - - /** Returns a list of names of Audio CDs currently available for reading. - - If there's a CD drive but no CD in it, this might return an empty list, or - possibly a device that can be opened but which has no tracks, depending - on the platform. - - @see createReaderForCD - */ - static const StringArray getAvailableCDNames(); - - /** Tries to create an AudioFormatReader that can read from an Audio CD. - - @param index the index of one of the available CDs - use getAvailableCDNames() - to find out how many there are. - @returns a new AudioCDReader object, or 0 if it couldn't be created. The - caller will be responsible for deleting the object returned. - */ - static AudioCDReader* createReaderForCD (const int index); - - /** Destructor. */ - ~AudioCDReader(); - - /** Implementation of the AudioFormatReader method. */ - bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, - int64 startSampleInFile, int numSamples); - - /** Checks whether the CD has been removed from the drive. - */ - bool isCDStillPresent() const; - - /** Returns the total number of tracks (audio + data). - */ - int getNumTracks() const; - - /** Finds the sample offset of the start of a track. - - @param trackNum the track number, where 0 is the first track. - */ - int getPositionOfTrackStart (int trackNum) const; - - /** Returns true if a given track is an audio track. - - @param trackNum the track number, where 0 is the first track. - */ - bool isTrackAudio (int trackNum) const; - - /** Refreshes the object's table of contents. - - If the disc has been ejected and a different one put in since this - object was created, this will cause it to update its idea of how many tracks - there are, etc. - */ - void refreshTrackLengths(); - - /** Enables scanning for indexes within tracks. - - @see getLastIndex - */ - void enableIndexScanning (bool enabled); - - /** Returns the index number found during the last read() call. - - Index scanning is turned off by default - turn it on with enableIndexScanning(). - - Then when the read() method is called, if it comes across an index within that - block, the index number is stored and returned by this method. - - Some devices might not support indexes, of course. - - (If you don't know what CD indexes are, it's unlikely you'll ever need them). - - @see enableIndexScanning - */ - int getLastIndex() const; - - /** Scans a track to find the position of any indexes within it. - - @param trackNumber the track to look in, where 0 is the first track on the disc - @returns an array of sample positions of any index points found (not including - the index that marks the start of the track) - */ - const Array findIndexesInTrack (const int trackNumber); - - /** Returns the CDDB id number for the CD. - - It's not a great way of identifying a disc, but it's traditional. - */ - int getCDDBId(); - - /** Tries to eject the disk. - - Of course this might not be possible, if some other process is using it. - */ - void ejectDisk(); - - juce_UseDebuggingNewOperator - -private: - -#if JUCE_MAC - File volumeDir; - OwnedArray tracks; - Array trackStartSamples; - int currentReaderTrack; - AudioFormatReader* reader; - AudioCDReader (const File& volume); -public: - static int compareElements (const File* const, const File* const) throw(); -private: - -#elif JUCE_WIN32 - int numTracks; - int trackStarts[100]; - bool audioTracks [100]; - void* handle; - bool indexingEnabled; - int lastIndex, firstFrameInBuffer, samplesInBuffer; - MemoryBlock buffer; - AudioCDReader (void* handle); - int getIndexAt (int samplePos); - -#elif JUCE_LINUX - AudioCDReader(); -#endif - - AudioCDReader (const AudioCDReader&); - const AudioCDReader& operator= (const AudioCDReader&); -}; - -#endif // __JUCE_AUDIOCDREADER_JUCEHEADER__ -/********* End of inlined file: juce_AudioCDReader.h *********/ - #endif #ifndef __JUCE_AUDIOFORMAT_JUCEHEADER__ @@ -37222,78 +37066,9 @@ private: #endif // __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__ /********* End of inlined file: juce_AudioFormatManager.h *********/ -#endif -#ifndef __JUCE_AUDIOFORMATREADER_JUCEHEADER__ - #endif #ifndef __JUCE_AUDIOFORMATWRITER_JUCEHEADER__ -#endif -#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ - -/********* Start of inlined file: juce_AudioSubsectionReader.h *********/ -#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ -#define __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ - -/** - This class is used to wrap an AudioFormatReader and only read from a - subsection of the file. - - So if you have a reader which can read a 1000 sample file, you could wrap it - in one of these to only access, e.g. samples 100 to 200, and any samples - outside that will come back as 0. Accessing sample 0 from this reader will - actually read the first sample from the other's subsection, which might - be at a non-zero position. - - @see AudioFormatReader -*/ -class JUCE_API AudioSubsectionReader : public AudioFormatReader -{ -public: - - /** Creates a AudioSubsectionReader for a given data source. - - @param sourceReader the source reader from which we'll be taking data - @param subsectionStartSample the sample within the source reader which will be - mapped onto sample 0 for this reader. - @param subsectionLength the number of samples from the source that will - make up the subsection. If this reader is asked for - any samples beyond this region, it will return zero. - @param deleteSourceWhenDeleted if true, the sourceReader object will be deleted when - this object is deleted. - */ - AudioSubsectionReader (AudioFormatReader* const sourceReader, - const int64 subsectionStartSample, - const int64 subsectionLength, - const bool deleteSourceWhenDeleted); - - /** Destructor. */ - ~AudioSubsectionReader(); - - bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, - int64 startSampleInFile, int numSamples); - - void readMaxLevels (int64 startSample, - int64 numSamples, - float& lowestLeft, - float& highestLeft, - float& lowestRight, - float& highestRight); - - juce_UseDebuggingNewOperator - -private: - AudioFormatReader* const source; - int64 startSample, length; - const bool deleteSourceWhenDeleted; - - AudioSubsectionReader (const AudioSubsectionReader&); - const AudioSubsectionReader& operator= (const AudioSubsectionReader&); -}; - -#endif // __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ -/********* End of inlined file: juce_AudioSubsectionReader.h *********/ - #endif #ifndef __JUCE_AUDIOTHUMBNAIL_JUCEHEADER__ @@ -37562,6 +37337,128 @@ public: #endif // __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ /********* End of inlined file: juce_FlacAudioFormat.h *********/ +#endif +#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ + +/********* Start of inlined file: juce_WavAudioFormat.h *********/ +#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ +#define __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ + +/** + Reads and Writes WAV format audio files. + + @see AudioFormat +*/ +class JUCE_API WavAudioFormat : public AudioFormat +{ +public: + + /** Creates a format object. */ + WavAudioFormat(); + + /** Destructor. */ + ~WavAudioFormat(); + + /** Metadata property name used by wav readers and writers for adding + a BWAV chunk to the file. + + @see AudioFormatReader::metadataValues, createWriterFor + */ + static const tchar* const bwavDescription; + + /** Metadata property name used by wav readers and writers for adding + a BWAV chunk to the file. + + @see AudioFormatReader::metadataValues, createWriterFor + */ + static const tchar* const bwavOriginator; + + /** Metadata property name used by wav readers and writers for adding + a BWAV chunk to the file. + + @see AudioFormatReader::metadataValues, createWriterFor + */ + static const tchar* const bwavOriginatorRef; + + /** Metadata property name used by wav readers and writers for adding + a BWAV chunk to the file. + + Date format is: yyyy-mm-dd + + @see AudioFormatReader::metadataValues, createWriterFor + */ + static const tchar* const bwavOriginationDate; + + /** Metadata property name used by wav readers and writers for adding + a BWAV chunk to the file. + + Time format is: hh-mm-ss + + @see AudioFormatReader::metadataValues, createWriterFor + */ + static const tchar* const bwavOriginationTime; + + /** Metadata property name used by wav readers and writers for adding + a BWAV chunk to the file. + + This is the number of samples from the start of an edit that the + file is supposed to begin at. Seems like an obvious mistake to + only allow a file to occur in an edit once, but that's the way + it is.. + + @see AudioFormatReader::metadataValues, createWriterFor + */ + static const tchar* const bwavTimeReference; + + /** Metadata property name used by wav readers and writers for adding + a BWAV chunk to the file. + + This is a + + @see AudioFormatReader::metadataValues, createWriterFor + */ + static const tchar* const bwavCodingHistory; + + /** Utility function to fill out the appropriate metadata for a BWAV file. + + This just makes it easier than using the property names directly, and it + fills out the time and date in the right format. + */ + static const StringPairArray createBWAVMetadata (const String& description, + const String& originator, + const String& originatorRef, + const Time& dateAndTime, + const int64 timeReferenceSamples, + const String& codingHistory); + + const Array getPossibleSampleRates(); + const Array getPossibleBitDepths(); + bool canDoStereo(); + bool canDoMono(); + + AudioFormatReader* createReaderFor (InputStream* sourceStream, + const bool deleteStreamIfOpeningFails); + + AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo, + double sampleRateToUse, + unsigned int numberOfChannels, + int bitsPerSample, + const StringPairArray& metadataValues, + int qualityOptionIndex); + + /** Utility function to replace the metadata in a wav file with a new set of values. + + If possible, this cheats by overwriting just the metadata region of the file, rather + than by copying the whole file again. + */ + bool replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata); + + juce_UseDebuggingNewOperator +}; + +#endif // __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ +/********* End of inlined file: juce_WavAudioFormat.h *********/ + #endif #ifndef __JUCE_OGGVORBISAUDIOFORMAT_JUCEHEADER__ @@ -37622,147 +37519,190 @@ public: /********* End of inlined file: juce_OggVorbisAudioFormat.h *********/ #endif -#ifndef __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ +#ifndef __JUCE_AUDIOFORMATREADER_JUCEHEADER__ -/********* Start of inlined file: juce_QuickTimeAudioFormat.h *********/ -#ifndef __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ -#define __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ +#endif +#ifndef __JUCE_AUDIOCDREADER_JUCEHEADER__ -#if JUCE_QUICKTIME +/********* Start of inlined file: juce_AudioCDReader.h *********/ +#ifndef __JUCE_AUDIOCDREADER_JUCEHEADER__ +#define __JUCE_AUDIOCDREADER_JUCEHEADER__ + +#if JUCE_MAC + +#endif /** - Uses QuickTime to read the audio track a movie or media file. + A type of AudioFormatReader that reads from an audio CD. - As well as QuickTime movies, this should also manage to open other audio - files that quicktime can understand, like mp3, m4a, etc. + One of these can be used to read a CD as if it's one big audio stream. Use the + getPositionOfTrackStart() method to find where the individual tracks are + within the stream. - @see AudioFormat + @see AudioFormatReader */ -class JUCE_API QuickTimeAudioFormat : public AudioFormat +class JUCE_API AudioCDReader : public AudioFormatReader { public: - /** Creates a format object. */ - QuickTimeAudioFormat(); + /** Returns a list of names of Audio CDs currently available for reading. - /** Destructor. */ - ~QuickTimeAudioFormat(); + If there's a CD drive but no CD in it, this might return an empty list, or + possibly a device that can be opened but which has no tracks, depending + on the platform. - const Array getPossibleSampleRates(); - const Array getPossibleBitDepths(); - bool canDoStereo(); - bool canDoMono(); + @see createReaderForCD + */ + static const StringArray getAvailableCDNames(); - AudioFormatReader* createReaderFor (InputStream* sourceStream, - const bool deleteStreamIfOpeningFails); + /** Tries to create an AudioFormatReader that can read from an Audio CD. - AudioFormatWriter* createWriterFor (OutputStream* streamToWriteTo, - double sampleRateToUse, - unsigned int numberOfChannels, - int bitsPerSample, - const StringPairArray& metadataValues, - int qualityOptionIndex); + @param index the index of one of the available CDs - use getAvailableCDNames() + to find out how many there are. + @returns a new AudioCDReader object, or 0 if it couldn't be created. The + caller will be responsible for deleting the object returned. + */ + static AudioCDReader* createReaderForCD (const int index); - juce_UseDebuggingNewOperator -}; + /** Destructor. */ + ~AudioCDReader(); -#endif -#endif // __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ -/********* End of inlined file: juce_QuickTimeAudioFormat.h *********/ + /** Implementation of the AudioFormatReader method. */ + bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, + int64 startSampleInFile, int numSamples); -#endif -#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ + /** Checks whether the CD has been removed from the drive. + */ + bool isCDStillPresent() const; -/********* Start of inlined file: juce_WavAudioFormat.h *********/ -#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ -#define __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ + /** Returns the total number of tracks (audio + data). + */ + int getNumTracks() const; -/** - Reads and Writes WAV format audio files. + /** Finds the sample offset of the start of a track. - @see AudioFormat -*/ -class JUCE_API WavAudioFormat : public AudioFormat -{ -public: + @param trackNum the track number, where 0 is the first track. + */ + int getPositionOfTrackStart (int trackNum) const; - /** Creates a format object. */ - WavAudioFormat(); + /** Returns true if a given track is an audio track. - /** Destructor. */ - ~WavAudioFormat(); + @param trackNum the track number, where 0 is the first track. + */ + bool isTrackAudio (int trackNum) const; - /** Metadata property name used by wav readers and writers for adding - a BWAV chunk to the file. + /** Refreshes the object's table of contents. - @see AudioFormatReader::metadataValues, createWriterFor + If the disc has been ejected and a different one put in since this + object was created, this will cause it to update its idea of how many tracks + there are, etc. */ - static const tchar* const bwavDescription; + void refreshTrackLengths(); - /** Metadata property name used by wav readers and writers for adding - a BWAV chunk to the file. + /** Enables scanning for indexes within tracks. - @see AudioFormatReader::metadataValues, createWriterFor + @see getLastIndex */ - static const tchar* const bwavOriginator; + void enableIndexScanning (bool enabled); - /** Metadata property name used by wav readers and writers for adding - a BWAV chunk to the file. + /** Returns the index number found during the last read() call. - @see AudioFormatReader::metadataValues, createWriterFor - */ - static const tchar* const bwavOriginatorRef; + Index scanning is turned off by default - turn it on with enableIndexScanning(). - /** Metadata property name used by wav readers and writers for adding - a BWAV chunk to the file. + Then when the read() method is called, if it comes across an index within that + block, the index number is stored and returned by this method. - Date format is: yyyy-mm-dd + Some devices might not support indexes, of course. - @see AudioFormatReader::metadataValues, createWriterFor - */ - static const tchar* const bwavOriginationDate; + (If you don't know what CD indexes are, it's unlikely you'll ever need them). - /** Metadata property name used by wav readers and writers for adding - a BWAV chunk to the file. + @see enableIndexScanning + */ + int getLastIndex() const; - Time format is: hh-mm-ss + /** Scans a track to find the position of any indexes within it. - @see AudioFormatReader::metadataValues, createWriterFor + @param trackNumber the track to look in, where 0 is the first track on the disc + @returns an array of sample positions of any index points found (not including + the index that marks the start of the track) */ - static const tchar* const bwavOriginationTime; + const Array findIndexesInTrack (const int trackNumber); - /** Metadata property name used by wav readers and writers for adding - a BWAV chunk to the file. + /** Returns the CDDB id number for the CD. - This is the number of samples from the start of an edit that the - file is supposed to begin at. Seems like an obvious mistake to - only allow a file to occur in an edit once, but that's the way - it is.. + It's not a great way of identifying a disc, but it's traditional. + */ + int getCDDBId(); - @see AudioFormatReader::metadataValues, createWriterFor + /** Tries to eject the disk. + + Of course this might not be possible, if some other process is using it. */ - static const tchar* const bwavTimeReference; + void ejectDisk(); - /** Metadata property name used by wav readers and writers for adding - a BWAV chunk to the file. + juce_UseDebuggingNewOperator - This is a +private: - @see AudioFormatReader::metadataValues, createWriterFor - */ - static const tchar* const bwavCodingHistory; +#if JUCE_MAC + File volumeDir; + OwnedArray tracks; + Array trackStartSamples; + int currentReaderTrack; + AudioFormatReader* reader; + AudioCDReader (const File& volume); +public: + static int compareElements (const File* const, const File* const) throw(); +private: - /** Utility function to fill out the appropriate metadata for a BWAV file. +#elif JUCE_WIN32 + int numTracks; + int trackStarts[100]; + bool audioTracks [100]; + void* handle; + bool indexingEnabled; + int lastIndex, firstFrameInBuffer, samplesInBuffer; + MemoryBlock buffer; + AudioCDReader (void* handle); + int getIndexAt (int samplePos); - This just makes it easier than using the property names directly, and it - fills out the time and date in the right format. - */ - static const StringPairArray createBWAVMetadata (const String& description, - const String& originator, - const String& originatorRef, - const Time& dateAndTime, - const int64 timeReferenceSamples, - const String& codingHistory); +#elif JUCE_LINUX + AudioCDReader(); +#endif + + AudioCDReader (const AudioCDReader&); + const AudioCDReader& operator= (const AudioCDReader&); +}; + +#endif // __JUCE_AUDIOCDREADER_JUCEHEADER__ +/********* End of inlined file: juce_AudioCDReader.h *********/ + +#endif +#ifndef __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ + +/********* Start of inlined file: juce_QuickTimeAudioFormat.h *********/ +#ifndef __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ +#define __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ + +#if JUCE_QUICKTIME + +/** + Uses QuickTime to read the audio track a movie or media file. + + As well as QuickTime movies, this should also manage to open other audio + files that quicktime can understand, like mp3, m4a, etc. + + @see AudioFormat +*/ +class JUCE_API QuickTimeAudioFormat : public AudioFormat +{ +public: + + /** Creates a format object. */ + QuickTimeAudioFormat(); + + /** Destructor. */ + ~QuickTimeAudioFormat(); const Array getPossibleSampleRates(); const Array getPossibleBitDepths(); @@ -37779,18 +37719,78 @@ public: const StringPairArray& metadataValues, int qualityOptionIndex); - /** Utility function to replace the metadata in a wav file with a new set of values. + juce_UseDebuggingNewOperator +}; - If possible, this cheats by overwriting just the metadata region of the file, rather - than by copying the whole file again. +#endif +#endif // __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ +/********* End of inlined file: juce_QuickTimeAudioFormat.h *********/ + +#endif +#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ + +/********* Start of inlined file: juce_AudioSubsectionReader.h *********/ +#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ +#define __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ + +/** + This class is used to wrap an AudioFormatReader and only read from a + subsection of the file. + + So if you have a reader which can read a 1000 sample file, you could wrap it + in one of these to only access, e.g. samples 100 to 200, and any samples + outside that will come back as 0. Accessing sample 0 from this reader will + actually read the first sample from the other's subsection, which might + be at a non-zero position. + + @see AudioFormatReader +*/ +class JUCE_API AudioSubsectionReader : public AudioFormatReader +{ +public: + + /** Creates a AudioSubsectionReader for a given data source. + + @param sourceReader the source reader from which we'll be taking data + @param subsectionStartSample the sample within the source reader which will be + mapped onto sample 0 for this reader. + @param subsectionLength the number of samples from the source that will + make up the subsection. If this reader is asked for + any samples beyond this region, it will return zero. + @param deleteSourceWhenDeleted if true, the sourceReader object will be deleted when + this object is deleted. */ - bool replaceMetadataInFile (const File& wavFile, const StringPairArray& newMetadata); + AudioSubsectionReader (AudioFormatReader* const sourceReader, + const int64 subsectionStartSample, + const int64 subsectionLength, + const bool deleteSourceWhenDeleted); + + /** Destructor. */ + ~AudioSubsectionReader(); + + bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, + int64 startSampleInFile, int numSamples); + + void readMaxLevels (int64 startSample, + int64 numSamples, + float& lowestLeft, + float& highestLeft, + float& lowestRight, + float& highestRight); juce_UseDebuggingNewOperator + +private: + AudioFormatReader* const source; + int64 startSample, length; + const bool deleteSourceWhenDeleted; + + AudioSubsectionReader (const AudioSubsectionReader&); + const AudioSubsectionReader& operator= (const AudioSubsectionReader&); }; -#endif // __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ -/********* End of inlined file: juce_WavAudioFormat.h *********/ +#endif // __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ +/********* End of inlined file: juce_AudioSubsectionReader.h *********/ #endif #ifndef __JUCE_ACTIONBROADCASTER_JUCEHEADER__ @@ -38251,6 +38251,111 @@ private: #endif #ifndef __JUCE_MESSAGELISTENER_JUCEHEADER__ +#endif +#ifndef __JUCE_MULTITIMER_JUCEHEADER__ + +/********* Start of inlined file: juce_MultiTimer.h *********/ +#ifndef __JUCE_MULTITIMER_JUCEHEADER__ +#define __JUCE_MULTITIMER_JUCEHEADER__ + +/** + A type of timer class that can run multiple timers with different frequencies, + all of which share a single callback. + + This class is very similar to the Timer class, but allows you run multiple + separate timers, where each one has a unique ID number. The methods in this + class are exactly equivalent to those in Timer, but with the addition of + this ID number. + + To use it, you need to create a subclass of MultiTimer, implementing the + timerCallback() method. Then you can start timers with startTimer(), and + each time the callback is triggered, it passes in the ID of the timer that + caused it. + + @see Timer +*/ +class JUCE_API MultiTimer +{ +protected: + + /** Creates a MultiTimer. + + When created, no timers are running, so use startTimer() to start things off. + */ + MultiTimer() throw(); + + /** Creates a copy of another timer. + + Note that this timer will not contain any running timers, even if the one you're + copying from was running. + */ + MultiTimer (const MultiTimer& other) throw(); + +public: + + /** Destructor. */ + virtual ~MultiTimer(); + + /** The user-defined callback routine that actually gets called by each of the + timers that are running. + + It's perfectly ok to call startTimer() or stopTimer() from within this + callback to change the subsequent intervals. + */ + virtual void timerCallback (const int timerId) = 0; + + /** Starts a timer and sets the length of interval required. + + If the timer is already started, this will reset it, so the + time between calling this method and the next timer callback + will not be less than the interval length passed in. + + @param timerId a unique Id number that identifies the timer to + start. This is the id that will be passed back + to the timerCallback() method when this timer is + triggered + @param intervalInMilliseconds the interval to use (any values less than 1 will be + rounded up to 1) + */ + void startTimer (const int timerId, const int intervalInMilliseconds) throw(); + + /** Stops a timer. + + If a timer has been started with the given ID number, it will be cancelled. + No more callbacks will be made for the specified timer after this method returns. + + If this is called from a different thread, any callbacks that may + be currently executing may be allowed to finish before the method + returns. + */ + void stopTimer (const int timerId) throw(); + + /** Checks whether a timer has been started for a specified ID. + + @returns true if a timer with the given ID is running. + */ + bool isTimerRunning (const int timerId) const throw(); + + /** Returns the interval for a specified timer ID. + + @returns the timer's interval in milliseconds if it's running, or 0 if it's no timer + is running for the ID number specified. + */ + int getTimerInterval (const int timerId) const throw(); + +private: + CriticalSection timerListLock; + VoidArray timers; + + const MultiTimer& operator= (const MultiTimer&); +}; + +#endif // __JUCE_MULTITIMER_JUCEHEADER__ +/********* End of inlined file: juce_MultiTimer.h *********/ + +#endif +#ifndef __JUCE_TIMER_JUCEHEADER__ + #endif #ifndef __JUCE_MESSAGEMANAGER_JUCEHEADER__ @@ -38522,111 +38627,6 @@ private: #endif // __JUCE_MESSAGEMANAGER_JUCEHEADER__ /********* End of inlined file: juce_MessageManager.h *********/ -#endif -#ifndef __JUCE_MULTITIMER_JUCEHEADER__ - -/********* Start of inlined file: juce_MultiTimer.h *********/ -#ifndef __JUCE_MULTITIMER_JUCEHEADER__ -#define __JUCE_MULTITIMER_JUCEHEADER__ - -/** - A type of timer class that can run multiple timers with different frequencies, - all of which share a single callback. - - This class is very similar to the Timer class, but allows you run multiple - separate timers, where each one has a unique ID number. The methods in this - class are exactly equivalent to those in Timer, but with the addition of - this ID number. - - To use it, you need to create a subclass of MultiTimer, implementing the - timerCallback() method. Then you can start timers with startTimer(), and - each time the callback is triggered, it passes in the ID of the timer that - caused it. - - @see Timer -*/ -class JUCE_API MultiTimer -{ -protected: - - /** Creates a MultiTimer. - - When created, no timers are running, so use startTimer() to start things off. - */ - MultiTimer() throw(); - - /** Creates a copy of another timer. - - Note that this timer will not contain any running timers, even if the one you're - copying from was running. - */ - MultiTimer (const MultiTimer& other) throw(); - -public: - - /** Destructor. */ - virtual ~MultiTimer(); - - /** The user-defined callback routine that actually gets called by each of the - timers that are running. - - It's perfectly ok to call startTimer() or stopTimer() from within this - callback to change the subsequent intervals. - */ - virtual void timerCallback (const int timerId) = 0; - - /** Starts a timer and sets the length of interval required. - - If the timer is already started, this will reset it, so the - time between calling this method and the next timer callback - will not be less than the interval length passed in. - - @param timerId a unique Id number that identifies the timer to - start. This is the id that will be passed back - to the timerCallback() method when this timer is - triggered - @param intervalInMilliseconds the interval to use (any values less than 1 will be - rounded up to 1) - */ - void startTimer (const int timerId, const int intervalInMilliseconds) throw(); - - /** Stops a timer. - - If a timer has been started with the given ID number, it will be cancelled. - No more callbacks will be made for the specified timer after this method returns. - - If this is called from a different thread, any callbacks that may - be currently executing may be allowed to finish before the method - returns. - */ - void stopTimer (const int timerId) throw(); - - /** Checks whether a timer has been started for a specified ID. - - @returns true if a timer with the given ID is running. - */ - bool isTimerRunning (const int timerId) const throw(); - - /** Returns the interval for a specified timer ID. - - @returns the timer's interval in milliseconds if it's running, or 0 if it's no timer - is running for the ID number specified. - */ - int getTimerInterval (const int timerId) const throw(); - -private: - CriticalSection timerListLock; - VoidArray timers; - - const MultiTimer& operator= (const MultiTimer&); -}; - -#endif // __JUCE_MULTITIMER_JUCEHEADER__ -/********* End of inlined file: juce_MultiTimer.h *********/ - -#endif -#ifndef __JUCE_TIMER_JUCEHEADER__ - #endif #ifndef __JUCE_BRUSH_JUCEHEADER__ @@ -39954,6 +39954,9 @@ public: #endif // __JUCE_LOWLEVELGRAPHICSCONTEXT_JUCEHEADER__ /********* End of inlined file: juce_LowLevelGraphicsContext.h *********/ +#endif +#ifndef __JUCE_RECTANGLEPLACEMENT_JUCEHEADER__ + #endif #ifndef __JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_JUCEHEADER__ @@ -40189,9 +40192,6 @@ protected: #endif // __JUCE_LOWLEVELGRAPHICSSOFTWARERENDERER_JUCEHEADER__ /********* End of inlined file: juce_LowLevelGraphicsSoftwareRenderer.h *********/ -#endif -#ifndef __JUCE_RECTANGLEPLACEMENT_JUCEHEADER__ - #endif #ifndef __JUCE_AFFINETRANSFORM_JUCEHEADER__ @@ -40625,135 +40625,6 @@ private: #endif #ifndef __JUCE_RECTANGLELIST_JUCEHEADER__ -#endif -#ifndef __JUCE_CAMERADEVICE_JUCEHEADER__ - -/********* Start of inlined file: juce_CameraDevice.h *********/ -#ifndef __JUCE_CAMERADEVICE_JUCEHEADER__ -#define __JUCE_CAMERADEVICE_JUCEHEADER__ - -#if JUCE_USE_CAMERA - -/** - Receives callbacks with images from a CameraDevice. - - @see CameraDevice::addListener -*/ -class CameraImageListener -{ -public: - CameraImageListener() {} - virtual ~CameraImageListener() {} - - /** This method is called when a new image arrives. - - This may be called by any thread, so be careful about thread-safety, - and make sure that you process the data as quickly as possible to - avoid glitching! - */ - virtual void imageReceived (Image& image) = 0; -}; - -/** - Controls any camera capture devices that might be available. - - Use getAvailableDevices() to list the devices that are attached to the - system, then call openDevice to open one for use. Once you have a CameraDevice - object, you can get a viewer component from it, and use its methods to - stream to a file or capture still-frames. -*/ -class JUCE_API CameraDevice -{ -public: - /** Destructor. */ - virtual ~CameraDevice(); - - /** Returns a list of the available cameras on this machine. - - You can open one of these devices by calling openDevice(). - */ - static const StringArray getAvailableDevices(); - - /** Opens a camera device. - - The index parameter indicates which of the items returned by getAvailableDevices() - to open. - - The size constraints allow the method to choose between different resolutions if - the camera supports this. If the resolution cam't be specified (e.g. on the Mac) - then these will be ignored. - */ - static CameraDevice* openDevice (int deviceIndex, - int minWidth = 128, int minHeight = 64, - int maxWidth = 1024, int maxHeight = 768); - - /** Returns the name of this device */ - const String getName() const throw() { return name; } - - /** Creates a component that can be used to display a preview of the - video from this camera. - */ - Component* createViewerComponent(); - - /** Starts recording video to the specified file. - - You should use getFileExtension() to find out the correct extension to - use for your filename. - - If the file exists, it will be deleted before the recording starts. - - This method may not start recording instantly, so if you need to know the - exact time at which the file begins, you can call getTimeOfFirstRecordedFrame() - after the recording has finished. - */ - void startRecordingToFile (const File& file); - - /** Stops recording, after a call to startRecordingToFile(). - */ - void stopRecording(); - - /** Returns the file extension that should be used for the files - that you pass to startRecordingToFile(). - - This may be platform-specific, e.g. ".mov" or ".avi". - */ - static const String getFileExtension(); - - /** After calling stopRecording(), this method can be called to return the timestamp - of the first frame that was written to the file. - */ - const Time getTimeOfFirstRecordedFrame() const; - - /** Adds a listener to receive images from the camera. - - Be very careful not to delete the listener without first removing it by calling - removeListener(). - */ - void addListener (CameraImageListener* listenerToAdd); - - /** Removes a listener that was previously added with addListener(). - */ - void removeListener (CameraImageListener* listenerToRemove); - - juce_UseDebuggingNewOperator - -protected: - /** @internal */ - CameraDevice (const String& name, int index); - -private: - void* internal; - bool isRecording; - String name; - - CameraDevice (const CameraDevice&); - const CameraDevice& operator= (const CameraDevice&); -}; - -#endif -#endif // __JUCE_CAMERADEVICE_JUCEHEADER__ -/********* End of inlined file: juce_CameraDevice.h *********/ - #endif #ifndef __JUCE_IMAGE_JUCEHEADER__ @@ -40999,6 +40870,135 @@ private: #endif // __JUCE_IMAGECONVOLUTIONKERNEL_JUCEHEADER__ /********* End of inlined file: juce_ImageConvolutionKernel.h *********/ +#endif +#ifndef __JUCE_CAMERADEVICE_JUCEHEADER__ + +/********* Start of inlined file: juce_CameraDevice.h *********/ +#ifndef __JUCE_CAMERADEVICE_JUCEHEADER__ +#define __JUCE_CAMERADEVICE_JUCEHEADER__ + +#if JUCE_USE_CAMERA + +/** + Receives callbacks with images from a CameraDevice. + + @see CameraDevice::addListener +*/ +class CameraImageListener +{ +public: + CameraImageListener() {} + virtual ~CameraImageListener() {} + + /** This method is called when a new image arrives. + + This may be called by any thread, so be careful about thread-safety, + and make sure that you process the data as quickly as possible to + avoid glitching! + */ + virtual void imageReceived (Image& image) = 0; +}; + +/** + Controls any camera capture devices that might be available. + + Use getAvailableDevices() to list the devices that are attached to the + system, then call openDevice to open one for use. Once you have a CameraDevice + object, you can get a viewer component from it, and use its methods to + stream to a file or capture still-frames. +*/ +class JUCE_API CameraDevice +{ +public: + /** Destructor. */ + virtual ~CameraDevice(); + + /** Returns a list of the available cameras on this machine. + + You can open one of these devices by calling openDevice(). + */ + static const StringArray getAvailableDevices(); + + /** Opens a camera device. + + The index parameter indicates which of the items returned by getAvailableDevices() + to open. + + The size constraints allow the method to choose between different resolutions if + the camera supports this. If the resolution cam't be specified (e.g. on the Mac) + then these will be ignored. + */ + static CameraDevice* openDevice (int deviceIndex, + int minWidth = 128, int minHeight = 64, + int maxWidth = 1024, int maxHeight = 768); + + /** Returns the name of this device */ + const String getName() const throw() { return name; } + + /** Creates a component that can be used to display a preview of the + video from this camera. + */ + Component* createViewerComponent(); + + /** Starts recording video to the specified file. + + You should use getFileExtension() to find out the correct extension to + use for your filename. + + If the file exists, it will be deleted before the recording starts. + + This method may not start recording instantly, so if you need to know the + exact time at which the file begins, you can call getTimeOfFirstRecordedFrame() + after the recording has finished. + */ + void startRecordingToFile (const File& file); + + /** Stops recording, after a call to startRecordingToFile(). + */ + void stopRecording(); + + /** Returns the file extension that should be used for the files + that you pass to startRecordingToFile(). + + This may be platform-specific, e.g. ".mov" or ".avi". + */ + static const String getFileExtension(); + + /** After calling stopRecording(), this method can be called to return the timestamp + of the first frame that was written to the file. + */ + const Time getTimeOfFirstRecordedFrame() const; + + /** Adds a listener to receive images from the camera. + + Be very careful not to delete the listener without first removing it by calling + removeListener(). + */ + void addListener (CameraImageListener* listenerToAdd); + + /** Removes a listener that was previously added with addListener(). + */ + void removeListener (CameraImageListener* listenerToRemove); + + juce_UseDebuggingNewOperator + +protected: + /** @internal */ + CameraDevice (const String& name, int index); + +private: + void* internal; + bool isRecording; + String name; + + CameraDevice (const CameraDevice&); + const CameraDevice& operator= (const CameraDevice&); +}; + +#endif +#endif // __JUCE_CAMERADEVICE_JUCEHEADER__ +/********* End of inlined file: juce_CameraDevice.h *********/ + #endif #ifndef __JUCE_IMAGEFILEFORMAT_JUCEHEADER__ @@ -41690,9 +41690,6 @@ private: #endif // __JUCE_DRAWABLETEXT_JUCEHEADER__ /********* End of inlined file: juce_DrawableText.h *********/ -#endif -#ifndef __JUCE_COMPONENT_JUCEHEADER__ - #endif #ifndef __JUCE_COMPONENTDELETIONWATCHER_JUCEHEADER__ @@ -41702,6 +41699,9 @@ private: #endif #ifndef __JUCE_DESKTOP_JUCEHEADER__ +#endif +#ifndef __JUCE_COMPONENT_JUCEHEADER__ + #endif #ifndef __JUCE_ARROWBUTTON_JUCEHEADER__ @@ -41817,9 +41817,6 @@ private: #endif // __JUCE_ARROWBUTTON_JUCEHEADER__ /********* End of inlined file: juce_ArrowButton.h *********/ -#endif -#ifndef __JUCE_BUTTON_JUCEHEADER__ - #endif #ifndef __JUCE_DRAWABLEBUTTON_JUCEHEADER__ @@ -42207,6 +42204,9 @@ private: #endif // __JUCE_IMAGEBUTTON_JUCEHEADER__ /********* End of inlined file: juce_ImageButton.h *********/ +#endif +#ifndef __JUCE_BUTTON_JUCEHEADER__ + #endif #ifndef __JUCE_SHAPEBUTTON_JUCEHEADER__ @@ -43368,7 +43368,7 @@ private: #ifndef __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__ #endif -#ifndef __JUCE_KEYLISTENER_JUCEHEADER__ +#ifndef __JUCE_KEYPRESS_JUCEHEADER__ #endif #ifndef __JUCE_KEYMAPPINGEDITORCOMPONENT_JUCEHEADER__ @@ -44314,13 +44314,13 @@ private: /********* End of inlined file: juce_KeyMappingEditorComponent.h *********/ #endif -#ifndef __JUCE_KEYPRESS_JUCEHEADER__ +#ifndef __JUCE_MODIFIERKEYS_JUCEHEADER__ #endif -#ifndef __JUCE_KEYPRESSMAPPINGSET_JUCEHEADER__ +#ifndef __JUCE_KEYLISTENER_JUCEHEADER__ #endif -#ifndef __JUCE_MODIFIERKEYS_JUCEHEADER__ +#ifndef __JUCE_KEYPRESSMAPPINGSET_JUCEHEADER__ #endif #ifndef __JUCE_MENUBARCOMPONENT_JUCEHEADER__ @@ -45520,15 +45520,9 @@ private: #endif #ifndef __JUCE_TOOLTIPCLIENT_JUCEHEADER__ -#endif -#ifndef __JUCE_COMBOBOX_JUCEHEADER__ - #endif #ifndef __JUCE_LABEL_JUCEHEADER__ -#endif -#ifndef __JUCE_LISTBOX_JUCEHEADER__ - #endif #ifndef __JUCE_PROGRESSBAR_JUCEHEADER__ @@ -47055,15 +47049,9 @@ private: #endif // __JUCE_TABLELISTBOX_JUCEHEADER__ /********* End of inlined file: juce_TableListBox.h *********/ -#endif -#ifndef __JUCE_TEXTEDITOR_JUCEHEADER__ - #endif #ifndef __JUCE_TOOLBAR_JUCEHEADER__ -#endif -#ifndef __JUCE_TOOLBARITEMCOMPONENT_JUCEHEADER__ - #endif #ifndef __JUCE_TOOLBARITEMFACTORY_JUCEHEADER__ @@ -47149,6 +47137,9 @@ public: #endif // __JUCE_TOOLBARITEMFACTORY_JUCEHEADER__ /********* End of inlined file: juce_ToolbarItemFactory.h *********/ +#endif +#ifndef __JUCE_TOOLBARITEMCOMPONENT_JUCEHEADER__ + #endif #ifndef __JUCE_TOOLBARITEMPALETTE_JUCEHEADER__ @@ -47207,6 +47198,15 @@ private: #endif #ifndef __JUCE_TREEVIEW_JUCEHEADER__ +#endif +#ifndef __JUCE_TEXTEDITOR_JUCEHEADER__ + +#endif +#ifndef __JUCE_LISTBOX_JUCEHEADER__ + +#endif +#ifndef __JUCE_COMBOBOX_JUCEHEADER__ + #endif #ifndef __JUCE_BOOLEANPROPERTYCOMPONENT_JUCEHEADER__ @@ -49364,6 +49364,12 @@ private: #endif #ifndef __JUCE_SCROLLBAR_JUCEHEADER__ +#endif +#ifndef __JUCE_TABBEDBUTTONBAR_JUCEHEADER__ + +#endif +#ifndef __JUCE_TABBEDCOMPONENT_JUCEHEADER__ + #endif #ifndef __JUCE_STRETCHABLELAYOUTMANAGER_JUCEHEADER__ @@ -49759,12 +49765,6 @@ private: #endif // __JUCE_STRETCHABLEOBJECTRESIZER_JUCEHEADER__ /********* End of inlined file: juce_StretchableObjectResizer.h *********/ -#endif -#ifndef __JUCE_TABBEDBUTTONBAR_JUCEHEADER__ - -#endif -#ifndef __JUCE_TABBEDCOMPONENT_JUCEHEADER__ - #endif #ifndef __JUCE_VIEWPORT_JUCEHEADER__ @@ -50112,11 +50112,14 @@ protected: #ifndef __JUCE_DIRECTORYCONTENTSLIST_JUCEHEADER__ #endif -#ifndef __JUCE_FILEBROWSERCOMPONENT_JUCEHEADER__ +#ifndef __JUCE_FILEBROWSERLISTENER_JUCEHEADER__ -/********* Start of inlined file: juce_FileBrowserComponent.h *********/ -#ifndef __JUCE_FILEBROWSERCOMPONENT_JUCEHEADER__ -#define __JUCE_FILEBROWSERCOMPONENT_JUCEHEADER__ +#endif +#ifndef __JUCE_FILECHOOSER_JUCEHEADER__ + +/********* Start of inlined file: juce_FileChooser.h *********/ +#ifndef __JUCE_FILECHOOSER_JUCEHEADER__ +#define __JUCE_FILECHOOSER_JUCEHEADER__ /********* Start of inlined file: juce_FilePreviewComponent.h *********/ #ifndef __JUCE_FILEPREVIEWCOMPONENT_JUCEHEADER__ @@ -50160,6 +50163,175 @@ private: #endif // __JUCE_FILEPREVIEWCOMPONENT_JUCEHEADER__ /********* End of inlined file: juce_FilePreviewComponent.h *********/ +/** + Creates a dialog box to choose a file or directory to load or save. + + To use a FileChooser: + - create one (as a local stack variable is the neatest way) + - call one of its browseFor.. methods + - if this returns true, the user has selected a file, so you can retrieve it + with the getResult() method. + + e.g. @code + void loadMooseFile() + { + FileChooser myChooser ("Please select the moose you want to load...", + File::getSpecialLocation (File::userHomeDirectory), + "*.moose"); + + if (myChooser.browseForFileToOpen()) + { + File mooseFile (myChooser.getResult()); + + loadMoose (mooseFile); + } + } + @endcode +*/ +class JUCE_API FileChooser +{ +public: + + /** Creates a FileChooser. + + After creating one of these, use one of the browseFor... methods to display it. + + @param dialogBoxTitle a text string to display in the dialog box to + tell the user what's going on + @param initialFileOrDirectory the file or directory that should be selected when + the dialog box opens. If this parameter is set to + File::nonexistent, a sensible default directory + will be used instead. + @param filePatternsAllowed a set of file patterns to specify which files can be + selected - each pattern should be separated by a + comma or semi-colon, e.g. "*" or "*.jpg;*.gif". An + empty string means that all files are allowed + @param useOSNativeDialogBox if true, then a native dialog box will be used if + possible; if false, then a Juce-based browser dialog + box will always be used + @see browseForFileToOpen, browseForFileToSave, browseForDirectory + */ + FileChooser (const String& dialogBoxTitle, + const File& initialFileOrDirectory = File::nonexistent, + const String& filePatternsAllowed = String::empty, + const bool useOSNativeDialogBox = true); + + /** Destructor. */ + ~FileChooser(); + + /** Shows a dialog box to choose a file to open. + + This will display the dialog box modally, using an "open file" mode, so that + it won't allow non-existent files or directories to be chosen. + + @param previewComponent an optional component to display inside the dialog + box to show special info about the files that the user + is browsing. The component will not be deleted by this + object, so the caller must take care of it. + @returns true if the user selected a file, in which case, use the getResult() + method to find out what it was. Returns false if they cancelled instead. + @see browseForFileToSave, browseForDirectory + */ + bool browseForFileToOpen (FilePreviewComponent* previewComponent = 0); + + /** Same as browseForFileToOpen, but allows the user to select multiple files. + + The files that are returned can be obtained by calling getResults(). See + browseForFileToOpen() for more info about the behaviour of this method. + */ + bool browseForMultipleFilesToOpen (FilePreviewComponent* previewComponent = 0); + + /** Shows a dialog box to choose a file to save. + + This will display the dialog box modally, using an "save file" mode, so it + will allow non-existent files to be chosen, but not directories. + + @param warnAboutOverwritingExistingFiles if true, the dialog box will ask + the user if they're sure they want to overwrite a file that already + exists + @returns true if the user chose a file and pressed 'ok', in which case, use + the getResult() method to find out what the file was. Returns false + if they cancelled instead. + @see browseForFileToOpen, browseForDirectory + */ + bool browseForFileToSave (const bool warnAboutOverwritingExistingFiles); + + /** Shows a dialog box to choose a directory. + + This will display the dialog box modally, using an "open directory" mode, so it + will only allow directories to be returned, not files. + + @returns true if the user chose a directory and pressed 'ok', in which case, use + the getResult() method to find out what they chose. Returns false + if they cancelled instead. + @see browseForFileToOpen, browseForFileToSave + */ + bool browseForDirectory(); + + /** Returns the last file that was chosen by one of the browseFor methods. + + After calling the appropriate browseFor... method, this method lets you + find out what file or directory they chose. + + Note that the file returned is only valid if the browse method returned true (i.e. + if the user pressed 'ok' rather than cancelling). + + If you're using a multiple-file select, then use the getResults() method instead, + to obtain the list of all files chosen. + + @see getResults + */ + const File getResult() const; + + /** Returns a list of all the files that were chosen during the last call to a + browse method. + + This array may be empty if no files were chosen, or can contain multiple entries + if multiple files were chosen. + + @see getResult + */ + const OwnedArray & getResults() const; + + juce_UseDebuggingNewOperator + +private: + String title, filters; + File startingFile; + OwnedArray results; + bool useNativeDialogBox; + + bool showDialog (const bool isDirectory, + const bool isSave, + const bool warnAboutOverwritingExistingFiles, + const bool selectMultipleFiles, + FilePreviewComponent* const previewComponent); + + static void showPlatformDialog (OwnedArray& results, + const String& title, + const File& file, + const String& filters, + bool isDirectory, + bool isSave, + bool warnAboutOverwritingExistingFiles, + bool selectMultipleFiles, + FilePreviewComponent* previewComponent); +}; + +#endif // __JUCE_FILECHOOSER_JUCEHEADER__ +/********* End of inlined file: juce_FileChooser.h *********/ + +#endif +#ifndef __JUCE_FILECHOOSERDIALOGBOX_JUCEHEADER__ + +/********* Start of inlined file: juce_FileChooserDialogBox.h *********/ +#ifndef __JUCE_FILECHOOSERDIALOGBOX_JUCEHEADER__ +#define __JUCE_FILECHOOSERDIALOGBOX_JUCEHEADER__ + +/********* Start of inlined file: juce_FileBrowserComponent.h *********/ +#ifndef __JUCE_FILEBROWSERCOMPONENT_JUCEHEADER__ +#define __JUCE_FILEBROWSERCOMPONENT_JUCEHEADER__ + /** A component for browsing and selecting a file or directory to open or save. @@ -50325,181 +50497,6 @@ private: #endif // __JUCE_FILEBROWSERCOMPONENT_JUCEHEADER__ /********* End of inlined file: juce_FileBrowserComponent.h *********/ -#endif -#ifndef __JUCE_FILEBROWSERLISTENER_JUCEHEADER__ - -#endif -#ifndef __JUCE_FILECHOOSER_JUCEHEADER__ - -/********* Start of inlined file: juce_FileChooser.h *********/ -#ifndef __JUCE_FILECHOOSER_JUCEHEADER__ -#define __JUCE_FILECHOOSER_JUCEHEADER__ - -/** - Creates a dialog box to choose a file or directory to load or save. - - To use a FileChooser: - - create one (as a local stack variable is the neatest way) - - call one of its browseFor.. methods - - if this returns true, the user has selected a file, so you can retrieve it - with the getResult() method. - - e.g. @code - void loadMooseFile() - { - FileChooser myChooser ("Please select the moose you want to load...", - File::getSpecialLocation (File::userHomeDirectory), - "*.moose"); - - if (myChooser.browseForFileToOpen()) - { - File mooseFile (myChooser.getResult()); - - loadMoose (mooseFile); - } - } - @endcode -*/ -class JUCE_API FileChooser -{ -public: - - /** Creates a FileChooser. - - After creating one of these, use one of the browseFor... methods to display it. - - @param dialogBoxTitle a text string to display in the dialog box to - tell the user what's going on - @param initialFileOrDirectory the file or directory that should be selected when - the dialog box opens. If this parameter is set to - File::nonexistent, a sensible default directory - will be used instead. - @param filePatternsAllowed a set of file patterns to specify which files can be - selected - each pattern should be separated by a - comma or semi-colon, e.g. "*" or "*.jpg;*.gif". An - empty string means that all files are allowed - @param useOSNativeDialogBox if true, then a native dialog box will be used if - possible; if false, then a Juce-based browser dialog - box will always be used - @see browseForFileToOpen, browseForFileToSave, browseForDirectory - */ - FileChooser (const String& dialogBoxTitle, - const File& initialFileOrDirectory = File::nonexistent, - const String& filePatternsAllowed = String::empty, - const bool useOSNativeDialogBox = true); - - /** Destructor. */ - ~FileChooser(); - - /** Shows a dialog box to choose a file to open. - - This will display the dialog box modally, using an "open file" mode, so that - it won't allow non-existent files or directories to be chosen. - - @param previewComponent an optional component to display inside the dialog - box to show special info about the files that the user - is browsing. The component will not be deleted by this - object, so the caller must take care of it. - @returns true if the user selected a file, in which case, use the getResult() - method to find out what it was. Returns false if they cancelled instead. - @see browseForFileToSave, browseForDirectory - */ - bool browseForFileToOpen (FilePreviewComponent* previewComponent = 0); - - /** Same as browseForFileToOpen, but allows the user to select multiple files. - - The files that are returned can be obtained by calling getResults(). See - browseForFileToOpen() for more info about the behaviour of this method. - */ - bool browseForMultipleFilesToOpen (FilePreviewComponent* previewComponent = 0); - - /** Shows a dialog box to choose a file to save. - - This will display the dialog box modally, using an "save file" mode, so it - will allow non-existent files to be chosen, but not directories. - - @param warnAboutOverwritingExistingFiles if true, the dialog box will ask - the user if they're sure they want to overwrite a file that already - exists - @returns true if the user chose a file and pressed 'ok', in which case, use - the getResult() method to find out what the file was. Returns false - if they cancelled instead. - @see browseForFileToOpen, browseForDirectory - */ - bool browseForFileToSave (const bool warnAboutOverwritingExistingFiles); - - /** Shows a dialog box to choose a directory. - - This will display the dialog box modally, using an "open directory" mode, so it - will only allow directories to be returned, not files. - - @returns true if the user chose a directory and pressed 'ok', in which case, use - the getResult() method to find out what they chose. Returns false - if they cancelled instead. - @see browseForFileToOpen, browseForFileToSave - */ - bool browseForDirectory(); - - /** Returns the last file that was chosen by one of the browseFor methods. - - After calling the appropriate browseFor... method, this method lets you - find out what file or directory they chose. - - Note that the file returned is only valid if the browse method returned true (i.e. - if the user pressed 'ok' rather than cancelling). - - If you're using a multiple-file select, then use the getResults() method instead, - to obtain the list of all files chosen. - - @see getResults - */ - const File getResult() const; - - /** Returns a list of all the files that were chosen during the last call to a - browse method. - - This array may be empty if no files were chosen, or can contain multiple entries - if multiple files were chosen. - - @see getResult - */ - const OwnedArray & getResults() const; - - juce_UseDebuggingNewOperator - -private: - String title, filters; - File startingFile; - OwnedArray results; - bool useNativeDialogBox; - - bool showDialog (const bool isDirectory, - const bool isSave, - const bool warnAboutOverwritingExistingFiles, - const bool selectMultipleFiles, - FilePreviewComponent* const previewComponent); - - static void showPlatformDialog (OwnedArray& results, - const String& title, - const File& file, - const String& filters, - bool isDirectory, - bool isSave, - bool warnAboutOverwritingExistingFiles, - bool selectMultipleFiles, - FilePreviewComponent* previewComponent); -}; - -#endif // __JUCE_FILECHOOSER_JUCEHEADER__ -/********* End of inlined file: juce_FileChooser.h *********/ - -#endif -#ifndef __JUCE_FILECHOOSERDIALOGBOX_JUCEHEADER__ - -/********* Start of inlined file: juce_FileChooserDialogBox.h *********/ -#ifndef __JUCE_FILECHOOSERDIALOGBOX_JUCEHEADER__ -#define __JUCE_FILECHOOSERDIALOGBOX_JUCEHEADER__ - /** A file open/save dialog box. @@ -50685,198 +50682,79 @@ private: /********* End of inlined file: juce_FileListComponent.h *********/ #endif -#ifndef __JUCE_FILENAMECOMPONENT_JUCEHEADER__ - -/********* Start of inlined file: juce_FilenameComponent.h *********/ -#ifndef __JUCE_FILENAMECOMPONENT_JUCEHEADER__ -#define __JUCE_FILENAMECOMPONENT_JUCEHEADER__ - -class FilenameComponent; - -/** - Listens for events happening to a FilenameComponent. - - Use FilenameComponent::addListener() and FilenameComponent::removeListener() to - register one of these objects for event callbacks when the filename is changed. +#ifndef __JUCE_FILEPREVIEWCOMPONENT_JUCEHEADER__ - @see FilenameComponent -*/ -class JUCE_API FilenameComponentListener -{ -public: - /** Destructor. */ - virtual ~FilenameComponentListener() {} +#endif +#ifndef __JUCE_FILETREECOMPONENT_JUCEHEADER__ - /** This method is called after the FilenameComponent's file has been changed. */ - virtual void filenameComponentChanged (FilenameComponent* fileComponentThatHasChanged) = 0; -}; +/********* Start of inlined file: juce_FileTreeComponent.h *********/ +#ifndef __JUCE_FILETREECOMPONENT_JUCEHEADER__ +#define __JUCE_FILETREECOMPONENT_JUCEHEADER__ /** - Shows a filename as an editable text box, with a 'browse' button and a - drop-down list for recently selected files. + A component that displays the files in a directory as a treeview. - A handy component for dialogue boxes where you want the user to be able to - select a file or directory. + This implements the DirectoryContentsDisplayComponent base class so that + it can be used in a FileBrowserComponent. - Attach an FilenameComponentListener using the addListener() method, and it will - get called each time the user changes the filename, either by browsing for a file - and clicking 'ok', or by typing a new filename into the box and pressing return. + To attach a listener to it, use its DirectoryContentsDisplayComponent base + class and the FileBrowserListener class. - @see FileChooser, ComboBox + @see DirectoryContentsList, FileListComponent */ -class JUCE_API FilenameComponent : public Component, - public SettableTooltipClient, - public FileDragAndDropTarget, - private AsyncUpdater, - private ButtonListener, - private ComboBoxListener +class JUCE_API FileTreeComponent : public TreeView, + public DirectoryContentsDisplayComponent { public: - /** Creates a FilenameComponent. - - @param name the name for this component. - @param currentFile the file to initially show in the box - @param canEditFilename if true, the user can manually edit the filename; if false, - they can only change it by browsing for a new file - @param isDirectory if true, the file will be treated as a directory, and - an appropriate directory browser used - @param isForSaving if true, the file browser will allow non-existent files to - be picked, as the file is assumed to be used for saving rather - than loading - @param fileBrowserWildcard a wildcard pattern to use in the file browser - e.g. "*.txt;*.foo". - If an empty string is passed in, then the pattern is assumed to be "*" - @param enforcedSuffix if this is non-empty, it is treated as a suffix that will be added - to any filenames that are entered or chosen - @param textWhenNothingSelected the message to display in the box before any filename is entered. (This - will only appear if the initial file isn't valid) + /** Creates a listbox to show the contents of a specified directory. */ - FilenameComponent (const String& name, - const File& currentFile, - const bool canEditFilename, - const bool isDirectory, - const bool isForSaving, - const String& fileBrowserWildcard, - const String& enforcedSuffix, - const String& textWhenNothingSelected); + FileTreeComponent (DirectoryContentsList& listToShow); /** Destructor. */ - ~FilenameComponent(); - - /** Returns the currently displayed filename. */ - const File getCurrentFile() const; - - /** Changes the current filename. - - If addToRecentlyUsedList is true, the filename will also be added to the - drop-down list of recent files. - - If sendChangeNotification is false, then the listeners won't be told of the - change. - */ - void setCurrentFile (File newFile, - const bool addToRecentlyUsedList, - const bool sendChangeNotification = true); - - /** Changes whether the use can type into the filename box. - */ - void setFilenameIsEditable (const bool shouldBeEditable); - - /** Sets a file or directory to be the default starting point for the browser to show. + ~FileTreeComponent(); - This is only used if the current file hasn't been set. + /** Returns the number of selected files in the tree. */ - void setDefaultBrowseTarget (const File& newDefaultDirectory) throw(); - - /** Returns all the entries on the recent files list. + int getNumSelectedFiles() const throw() { return TreeView::getNumSelectedItems(); } - This can be used in conjunction with setRecentlyUsedFilenames() for saving the - state of this list. + /** Returns one of the files that the user has currently selected. - @see setRecentlyUsedFilenames + Returns File::nonexistent if none is selected. */ - const StringArray getRecentlyUsedFilenames() const; - - /** Sets all the entries on the recent files list. + const File getSelectedFile (int index) const throw(); - This can be used in conjunction with getRecentlyUsedFilenames() for saving the - state of this list. + /** Returns the first of the files that the user has currently selected. - @see getRecentlyUsedFilenames, addRecentlyUsedFile + Returns File::nonexistent if none is selected. */ - void setRecentlyUsedFilenames (const StringArray& filenames); - - /** Adds an entry to the recently-used files dropdown list. + const File getSelectedFile() const; - If the file is already in the list, it will be moved to the top. A limit - is also placed on the number of items that are kept in the list. + /** Scrolls the list to the top. */ + void scrollToTop(); - @see getRecentlyUsedFilenames, setRecentlyUsedFilenames, setMaxNumberOfRecentFiles - */ - void addRecentlyUsedFile (const File& file); + /** Setting a name for this allows tree items to be dragged. - /** Changes the limit for the number of files that will be stored in the recent-file list. + The string that you pass in here will be returned by the getDragSourceDescription() + of the items in the tree. For more info, see TreeViewItem::getDragSourceDescription(). */ - void setMaxNumberOfRecentFiles (const int newMaximum); - - /** Changes the text shown on the 'browse' button. + void setDragAndDropDescription (const String& description) throw(); - By default this button just says "..." but you can change it. The button itself - can be changed using the look-and-feel classes, so it might not actually have any - text on it. + /** Returns the last value that was set by setDragAndDropDescription(). */ - void setBrowseButtonText (const String& browseButtonText); - - /** Adds a listener that will be called when the selected file is changed. */ - void addListener (FilenameComponentListener* const listener) throw(); - - /** Removes a previously-registered listener. */ - void removeListener (FilenameComponentListener* const listener) throw(); - - /** Gives the component a tooltip. */ - void setTooltip (const String& newTooltip); - - /** @internal */ - void paintOverChildren (Graphics& g); - /** @internal */ - void resized(); - /** @internal */ - void lookAndFeelChanged(); - /** @internal */ - bool isInterestedInFileDrag (const StringArray& files); - /** @internal */ - void filesDropped (const StringArray& files, int, int); - /** @internal */ - void fileDragEnter (const StringArray& files, int, int); - /** @internal */ - void fileDragExit (const StringArray& files); + const String& getDragAndDropDescription() const throw() { return dragAndDropDescription; } juce_UseDebuggingNewOperator private: + String dragAndDropDescription; - ComboBox* filenameBox; - String lastFilename; - Button* browseButton; - int maxRecentFiles; - bool isDir, isSaving, isFileDragOver; - String wildcard, enforcedSuffix, browseButtonText; - SortedSet listeners; - File defaultBrowseFile; - - void comboBoxChanged (ComboBox*); - void buttonClicked (Button* button); - void handleAsyncUpdate(); - - FilenameComponent (const FilenameComponent&); - const FilenameComponent& operator= (const FilenameComponent&); + FileTreeComponent (const FileTreeComponent&); + const FileTreeComponent& operator= (const FileTreeComponent&); }; -#endif // __JUCE_FILENAMECOMPONENT_JUCEHEADER__ -/********* End of inlined file: juce_FilenameComponent.h *********/ - -#endif -#ifndef __JUCE_FILEPREVIEWCOMPONENT_JUCEHEADER__ +#endif // __JUCE_FILETREECOMPONENT_JUCEHEADER__ +/********* End of inlined file: juce_FileTreeComponent.h *********/ #endif #ifndef __JUCE_FILESEARCHPATHLISTCOMPONENT_JUCEHEADER__ @@ -50980,76 +50858,54 @@ private: /********* End of inlined file: juce_FileSearchPathListComponent.h *********/ #endif -#ifndef __JUCE_FILETREECOMPONENT_JUCEHEADER__ +#ifndef __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ -/********* Start of inlined file: juce_FileTreeComponent.h *********/ -#ifndef __JUCE_FILETREECOMPONENT_JUCEHEADER__ -#define __JUCE_FILETREECOMPONENT_JUCEHEADER__ +/********* Start of inlined file: juce_WildcardFileFilter.h *********/ +#ifndef __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ +#define __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ /** - A component that displays the files in a directory as a treeview. - - This implements the DirectoryContentsDisplayComponent base class so that - it can be used in a FileBrowserComponent. + A type of FileFilter that works by wildcard pattern matching. - To attach a listener to it, use its DirectoryContentsDisplayComponent base - class and the FileBrowserListener class. + This filter only allows files that match one of the specified patterns, but + allows all directories through. - @see DirectoryContentsList, FileListComponent + @see FileFilter, DirectoryContentsList, FileListComponent, FileBrowserComponent */ -class JUCE_API FileTreeComponent : public TreeView, - public DirectoryContentsDisplayComponent +class JUCE_API WildcardFileFilter : public FileFilter { public: - /** Creates a listbox to show the contents of a specified directory. - */ - FileTreeComponent (DirectoryContentsList& listToShow); - - /** Destructor. */ - ~FileTreeComponent(); - - /** Returns the number of selected files in the tree. - */ - int getNumSelectedFiles() const throw() { return TreeView::getNumSelectedItems(); } - - /** Returns one of the files that the user has currently selected. - - Returns File::nonexistent if none is selected. - */ - const File getSelectedFile (int index) const throw(); + /** + Creates a wildcard filter for one or more patterns. - /** Returns the first of the files that the user has currently selected. + The wildcardPatterns parameter is a comma or semicolon-delimited set of + patterns, e.g. "*.wav;*.aiff" would look for files ending in either .wav + or .aiff. - Returns File::nonexistent if none is selected. + The description is a name to show the user in a list of possible patterns, so + for the wav/aiff example, your description might be "audio files". */ - const File getSelectedFile() const; - - /** Scrolls the list to the top. */ - void scrollToTop(); + WildcardFileFilter (const String& wildcardPatterns, + const String& description); - /** Setting a name for this allows tree items to be dragged. + /** Destructor. */ + ~WildcardFileFilter(); - The string that you pass in here will be returned by the getDragSourceDescription() - of the items in the tree. For more info, see TreeViewItem::getDragSourceDescription(). - */ - void setDragAndDropDescription (const String& description) throw(); + /** Returns true if the filename matches one of the patterns specified. */ + bool isFileSuitable (const File& file) const; - /** Returns the last value that was set by setDragAndDropDescription(). - */ - const String& getDragAndDropDescription() const throw() { return dragAndDropDescription; } + /** This always returns true. */ + bool isDirectorySuitable (const File& file) const; juce_UseDebuggingNewOperator private: - String dragAndDropDescription; - - FileTreeComponent (const FileTreeComponent&); - const FileTreeComponent& operator= (const FileTreeComponent&); + StringArray wildcards; }; -#endif // __JUCE_FILETREECOMPONENT_JUCEHEADER__ -/********* End of inlined file: juce_FileTreeComponent.h *********/ +#endif // __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ +/********* End of inlined file: juce_WildcardFileFilter.h *********/ #endif #ifndef __JUCE_IMAGEPREVIEWCOMPONENT_JUCEHEADER__ @@ -51098,65 +50954,209 @@ private: /********* End of inlined file: juce_ImagePreviewComponent.h *********/ #endif -#ifndef __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ +#ifndef __JUCE_FILENAMECOMPONENT_JUCEHEADER__ -/********* Start of inlined file: juce_WildcardFileFilter.h *********/ -#ifndef __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ -#define __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ +/********* Start of inlined file: juce_FilenameComponent.h *********/ +#ifndef __JUCE_FILENAMECOMPONENT_JUCEHEADER__ +#define __JUCE_FILENAMECOMPONENT_JUCEHEADER__ + +class FilenameComponent; /** - A type of FileFilter that works by wildcard pattern matching. + Listens for events happening to a FilenameComponent. - This filter only allows files that match one of the specified patterns, but - allows all directories through. + Use FilenameComponent::addListener() and FilenameComponent::removeListener() to + register one of these objects for event callbacks when the filename is changed. - @see FileFilter, DirectoryContentsList, FileListComponent, FileBrowserComponent + @see FilenameComponent */ -class JUCE_API WildcardFileFilter : public FileFilter +class JUCE_API FilenameComponentListener { public: - - /** - Creates a wildcard filter for one or more patterns. - - The wildcardPatterns parameter is a comma or semicolon-delimited set of - patterns, e.g. "*.wav;*.aiff" would look for files ending in either .wav - or .aiff. - - The description is a name to show the user in a list of possible patterns, so - for the wav/aiff example, your description might be "audio files". - */ - WildcardFileFilter (const String& wildcardPatterns, - const String& description); - /** Destructor. */ - ~WildcardFileFilter(); - - /** Returns true if the filename matches one of the patterns specified. */ - bool isFileSuitable (const File& file) const; - - /** This always returns true. */ - bool isDirectorySuitable (const File& file) const; - - juce_UseDebuggingNewOperator + virtual ~FilenameComponentListener() {} -private: - StringArray wildcards; + /** This method is called after the FilenameComponent's file has been changed. */ + virtual void filenameComponentChanged (FilenameComponent* fileComponentThatHasChanged) = 0; }; -#endif // __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ -/********* End of inlined file: juce_WildcardFileFilter.h *********/ - -#endif -#ifndef __JUCE_ALERTWINDOW_JUCEHEADER__ +/** + Shows a filename as an editable text box, with a 'browse' button and a + drop-down list for recently selected files. -/********* Start of inlined file: juce_AlertWindow.h *********/ -#ifndef __JUCE_ALERTWINDOW_JUCEHEADER__ -#define __JUCE_ALERTWINDOW_JUCEHEADER__ + A handy component for dialogue boxes where you want the user to be able to + select a file or directory. -/** A window that displays a message and has buttons for the user to react to it. + Attach an FilenameComponentListener using the addListener() method, and it will + get called each time the user changes the filename, either by browsing for a file + and clicking 'ok', or by typing a new filename into the box and pressing return. - For simple dialog boxes with just a couple of buttons on them, there are + @see FileChooser, ComboBox +*/ +class JUCE_API FilenameComponent : public Component, + public SettableTooltipClient, + public FileDragAndDropTarget, + private AsyncUpdater, + private ButtonListener, + private ComboBoxListener +{ +public: + + /** Creates a FilenameComponent. + + @param name the name for this component. + @param currentFile the file to initially show in the box + @param canEditFilename if true, the user can manually edit the filename; if false, + they can only change it by browsing for a new file + @param isDirectory if true, the file will be treated as a directory, and + an appropriate directory browser used + @param isForSaving if true, the file browser will allow non-existent files to + be picked, as the file is assumed to be used for saving rather + than loading + @param fileBrowserWildcard a wildcard pattern to use in the file browser - e.g. "*.txt;*.foo". + If an empty string is passed in, then the pattern is assumed to be "*" + @param enforcedSuffix if this is non-empty, it is treated as a suffix that will be added + to any filenames that are entered or chosen + @param textWhenNothingSelected the message to display in the box before any filename is entered. (This + will only appear if the initial file isn't valid) + */ + FilenameComponent (const String& name, + const File& currentFile, + const bool canEditFilename, + const bool isDirectory, + const bool isForSaving, + const String& fileBrowserWildcard, + const String& enforcedSuffix, + const String& textWhenNothingSelected); + + /** Destructor. */ + ~FilenameComponent(); + + /** Returns the currently displayed filename. */ + const File getCurrentFile() const; + + /** Changes the current filename. + + If addToRecentlyUsedList is true, the filename will also be added to the + drop-down list of recent files. + + If sendChangeNotification is false, then the listeners won't be told of the + change. + */ + void setCurrentFile (File newFile, + const bool addToRecentlyUsedList, + const bool sendChangeNotification = true); + + /** Changes whether the use can type into the filename box. + */ + void setFilenameIsEditable (const bool shouldBeEditable); + + /** Sets a file or directory to be the default starting point for the browser to show. + + This is only used if the current file hasn't been set. + */ + void setDefaultBrowseTarget (const File& newDefaultDirectory) throw(); + + /** Returns all the entries on the recent files list. + + This can be used in conjunction with setRecentlyUsedFilenames() for saving the + state of this list. + + @see setRecentlyUsedFilenames + */ + const StringArray getRecentlyUsedFilenames() const; + + /** Sets all the entries on the recent files list. + + This can be used in conjunction with getRecentlyUsedFilenames() for saving the + state of this list. + + @see getRecentlyUsedFilenames, addRecentlyUsedFile + */ + void setRecentlyUsedFilenames (const StringArray& filenames); + + /** Adds an entry to the recently-used files dropdown list. + + If the file is already in the list, it will be moved to the top. A limit + is also placed on the number of items that are kept in the list. + + @see getRecentlyUsedFilenames, setRecentlyUsedFilenames, setMaxNumberOfRecentFiles + */ + void addRecentlyUsedFile (const File& file); + + /** Changes the limit for the number of files that will be stored in the recent-file list. + */ + void setMaxNumberOfRecentFiles (const int newMaximum); + + /** Changes the text shown on the 'browse' button. + + By default this button just says "..." but you can change it. The button itself + can be changed using the look-and-feel classes, so it might not actually have any + text on it. + */ + void setBrowseButtonText (const String& browseButtonText); + + /** Adds a listener that will be called when the selected file is changed. */ + void addListener (FilenameComponentListener* const listener) throw(); + + /** Removes a previously-registered listener. */ + void removeListener (FilenameComponentListener* const listener) throw(); + + /** Gives the component a tooltip. */ + void setTooltip (const String& newTooltip); + + /** @internal */ + void paintOverChildren (Graphics& g); + /** @internal */ + void resized(); + /** @internal */ + void lookAndFeelChanged(); + /** @internal */ + bool isInterestedInFileDrag (const StringArray& files); + /** @internal */ + void filesDropped (const StringArray& files, int, int); + /** @internal */ + void fileDragEnter (const StringArray& files, int, int); + /** @internal */ + void fileDragExit (const StringArray& files); + + juce_UseDebuggingNewOperator + +private: + + ComboBox* filenameBox; + String lastFilename; + Button* browseButton; + int maxRecentFiles; + bool isDir, isSaving, isFileDragOver; + String wildcard, enforcedSuffix, browseButtonText; + SortedSet listeners; + File defaultBrowseFile; + + void comboBoxChanged (ComboBox*); + void buttonClicked (Button* button); + void handleAsyncUpdate(); + + FilenameComponent (const FilenameComponent&); + const FilenameComponent& operator= (const FilenameComponent&); +}; + +#endif // __JUCE_FILENAMECOMPONENT_JUCEHEADER__ +/********* End of inlined file: juce_FilenameComponent.h *********/ + +#endif +#ifndef __JUCE_FILEBROWSERCOMPONENT_JUCEHEADER__ + +#endif +#ifndef __JUCE_ALERTWINDOW_JUCEHEADER__ + +/********* Start of inlined file: juce_AlertWindow.h *********/ +#ifndef __JUCE_ALERTWINDOW_JUCEHEADER__ +#define __JUCE_ALERTWINDOW_JUCEHEADER__ + +/** A window that displays a message and has buttons for the user to react to it. + + For simple dialog boxes with just a couple of buttons on them, there are some static methods for running these. For more complex dialogs, an AlertWindow can be created, then it can have some @@ -51464,1462 +51464,985 @@ private: AlertIconType alertIconType; ComponentBoundsConstrainer constrainer; ComponentDragger dragger; - Rectangle textArea; - VoidArray buttons, textBoxes, comboBoxes; - VoidArray progressBars, customComps, textBlocks, allComps; - StringArray textboxNames, comboBoxNames; - Font font; - Component* associatedComponent; - - void updateLayout (const bool onlyIncreaseSize); - - // disable copy constructor - AlertWindow (const AlertWindow&); - const AlertWindow& operator= (const AlertWindow&); -}; - -#endif // __JUCE_ALERTWINDOW_JUCEHEADER__ -/********* End of inlined file: juce_AlertWindow.h *********/ - -#endif -#ifndef __JUCE_COMPONENTPEER_JUCEHEADER__ - -#endif -#ifndef __JUCE_DIALOGWINDOW_JUCEHEADER__ - -/********* Start of inlined file: juce_DialogWindow.h *********/ -#ifndef __JUCE_DIALOGWINDOW_JUCEHEADER__ -#define __JUCE_DIALOGWINDOW_JUCEHEADER__ - -/** - A dialog-box style window. - - This class is a convenient way of creating a DocumentWindow with a close button - that can be triggered by pressing the escape key. - - Any of the methods available to a DocumentWindow or ResizableWindow are also - available to this, so it can be made resizable, have a menu bar, etc. - - To add items to the box, see the ResizableWindow::setContentComponent() method. - Don't add components directly to this class - always put them in a content component! - - You'll need to override the DocumentWindow::closeButtonPressed() method to handle - the user clicking the close button - for more info, see the DocumentWindow - help. - - @see DocumentWindow, ResizableWindow -*/ -class JUCE_API DialogWindow : public DocumentWindow -{ -public: - - /** Creates a DialogWindow. - - @param name the name to give the component - this is also - the title shown at the top of the window. To change - this later, use setName() - @param backgroundColour the colour to use for filling the window's background. - @param escapeKeyTriggersCloseButton if true, then pressing the escape key will cause the - close button to be triggered - @param addToDesktop if true, the window will be automatically added to the - desktop; if false, you can use it as a child component - */ - DialogWindow (const String& name, - const Colour& backgroundColour, - const bool escapeKeyTriggersCloseButton, - const bool addToDesktop = true); - - /** Destructor. - - If a content component has been set with setContentComponent(), it - will be deleted. - */ - ~DialogWindow(); - - /** Easy way of quickly showing a dialog box containing a given component. - - This will open and display a DialogWindow containing a given component, returning - when the user clicks its close button. - - It returns the value that was returned by the dialog box's runModalLoop() call. - - To close the dialog programatically, you should call exitModalState (returnValue) on - the DialogWindow that is created. To find a pointer to this window from your - contentComponent, you can do something like this: - @code - Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0); - - if (dw != 0) - dw->exitModalState (1234); - @endcode - - @param dialogTitle the dialog box's title - @param contentComponent the content component for the dialog box. Make sure - that this has been set to the size you want it to - be before calling this method. The component won't - be deleted by this call, so you can re-use it or delete - it afterwards - @param componentToCentreAround if this is non-zero, it indicates a component that - you'd like to show this dialog box in front of. See the - DocumentWindow::centreAroundComponent() method for more - info on this parameter - @param backgroundColour a colour to use for the dialog box's background colour - @param escapeKeyTriggersCloseButton if true, then pressing the escape key will cause the - close button to be triggered - @param shouldBeResizable if true, the dialog window has either a resizable border, or - a corner resizer - @param useBottomRightCornerResizer if shouldBeResizable is true, this indicates whether - to use a border or corner resizer component. See ResizableWindow::setResizable() - */ - static int showModalDialog (const String& dialogTitle, - Component* contentComponent, - Component* componentToCentreAround, - const Colour& backgroundColour, - const bool escapeKeyTriggersCloseButton, - const bool shouldBeResizable = false, - const bool useBottomRightCornerResizer = false); - - juce_UseDebuggingNewOperator - -protected: - /** @internal */ - void resized(); - -private: - bool escapeKeyTriggersCloseButton; - - DialogWindow (const DialogWindow&); - const DialogWindow& operator= (const DialogWindow&); -}; - -#endif // __JUCE_DIALOGWINDOW_JUCEHEADER__ -/********* End of inlined file: juce_DialogWindow.h *********/ - -#endif -#ifndef __JUCE_DOCUMENTWINDOW_JUCEHEADER__ - -#endif -#ifndef __JUCE_RESIZABLEWINDOW_JUCEHEADER__ - -#endif -#ifndef __JUCE_SPLASHSCREEN_JUCEHEADER__ - -/********* Start of inlined file: juce_SplashScreen.h *********/ -#ifndef __JUCE_SPLASHSCREEN_JUCEHEADER__ -#define __JUCE_SPLASHSCREEN_JUCEHEADER__ - -/** A component for showing a splash screen while your app starts up. - - This will automatically position itself, and delete itself when the app has - finished initialising (it uses the JUCEApplication::isInitialising() to detect - this). - - To use it, just create one of these in your JUCEApplication::initialise() method, - call its show() method and let the object delete itself later. - - E.g. @code - - void MyApp::initialise (const String& commandLine) - { - SplashScreen* splash = new SplashScreen(); - - splash->show (T("welcome to my app"), - ImageCache::getFromFile (File ("/foobar/splash.jpg")), - 4000, false); - - .. no need to delete the splash screen - it'll do that itself. - } - - @endcode -*/ -class JUCE_API SplashScreen : public Component, - public Timer, - private DeletedAtShutdown -{ -public: - - /** Creates a SplashScreen object. - - After creating one of these (or your subclass of it), call one of the show() - methods to display it. - */ - SplashScreen(); - - /** Destructor. */ - ~SplashScreen(); - - /** Creates a SplashScreen object that will display an image. - - As soon as this is called, the SplashScreen will be displayed in the centre of the - screen. This method will also dispatch any pending messages to make sure that when - it returns, the splash screen has been completely drawn, and your initialisation - code can carry on. - - @param title the name to give the component - @param backgroundImage an image to draw on the component. The component's size - will be set to the size of this image, and if the image is - semi-transparent, the component will be made semi-transparent - too. This image will be deleted (or released from the ImageCache - if that's how it was created) by the splash screen object when - it is itself deleted. - @param minimumTimeToDisplayFor how long (in milliseconds) the splash screen - should stay visible for. If the initialisation takes longer than - this time, the splash screen will wait for it to finish before - disappearing, but if initialisation is very quick, this lets - you make sure that people get a good look at your splash. - @param useDropShadow if true, the window will have a drop shadow - @param removeOnMouseClick if true, the window will go away as soon as the user clicks - the mouse (anywhere) - */ - void show (const String& title, - Image* const backgroundImage, - const int minimumTimeToDisplayFor, - const bool useDropShadow, - const bool removeOnMouseClick = true); - - /** Creates a SplashScreen object with a specified size. - - For a custom splash screen, you can use this method to display it at a certain size - and then override the paint() method yourself to do whatever's necessary. - - As soon as this is called, the SplashScreen will be displayed in the centre of the - screen. This method will also dispatch any pending messages to make sure that when - it returns, the splash screen has been completely drawn, and your initialisation - code can carry on. - - @param title the name to give the component - @param width the width to use - @param height the height to use - @param minimumTimeToDisplayFor how long (in milliseconds) the splash screen - should stay visible for. If the initialisation takes longer than - this time, the splash screen will wait for it to finish before - disappearing, but if initialisation is very quick, this lets - you make sure that people get a good look at your splash. - @param useDropShadow if true, the window will have a drop shadow - @param removeOnMouseClick if true, the window will go away as soon as the user clicks - the mouse (anywhere) - */ - void show (const String& title, - const int width, - const int height, - const int minimumTimeToDisplayFor, - const bool useDropShadow, - const bool removeOnMouseClick = true); - - /** @internal */ - void paint (Graphics& g); - /** @internal */ - void timerCallback(); - - juce_UseDebuggingNewOperator - -private: - Image* backgroundImage; - Time earliestTimeToDelete; - int originalClickCounter; - bool isImageInCache; - - SplashScreen (const SplashScreen&); - const SplashScreen& operator= (const SplashScreen&); -}; - -#endif // __JUCE_SPLASHSCREEN_JUCEHEADER__ -/********* End of inlined file: juce_SplashScreen.h *********/ - -#endif -#ifndef __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ - -/********* Start of inlined file: juce_ThreadWithProgressWindow.h *********/ -#ifndef __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ -#define __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ - -/** - A thread that automatically pops up a modal dialog box with a progress bar - and cancel button while it's busy running. - - These are handy for performing some sort of task while giving the user feedback - about how long there is to go, etc. - - E.g. @code - class MyTask : public ThreadWithProgressWindow - { - public: - MyTask() : ThreadWithProgressWindow (T("busy..."), true, true) - { - } - - ~MyTask() - { - } - - void run() - { - for (int i = 0; i < thingsToDo; ++i) - { - // must check this as often as possible, because this is - // how we know if the user's pressed 'cancel' - if (threadShouldExit()) - break; - - // this will update the progress bar on the dialog box - setProgress (i / (double) thingsToDo); - - // ... do the business here... - } - } - }; - - void doTheTask() - { - MyTask m; - - if (m.runThread()) - { - // thread finished normally.. - } - else - { - // user pressed the cancel button.. - } - } - - @endcode - - @see Thread, AlertWindow -*/ -class JUCE_API ThreadWithProgressWindow : public Thread, - private Timer -{ -public: - - /** Creates the thread. - - Initially, the dialog box won't be visible, it'll only appear when the - runThread() method is called. - - @param windowTitle the title to go at the top of the dialog box - @param hasProgressBar whether the dialog box should have a progress bar (see - setProgress() ) - @param hasCancelButton whether the dialog box should have a cancel button - @param timeOutMsWhenCancelling when 'cancel' is pressed, this is how long to wait for - the thread to stop before killing it forcibly (see - Thread::stopThread() ) - @param cancelButtonText the text that should be shown in the cancel button - (if it has one) - */ - ThreadWithProgressWindow (const String& windowTitle, - const bool hasProgressBar, - const bool hasCancelButton, - const int timeOutMsWhenCancelling = 10000, - const String& cancelButtonText = JUCE_T("Cancel")); - - /** Destructor. */ - ~ThreadWithProgressWindow(); - - /** Starts the thread and waits for it to finish. - - This will start the thread, make the dialog box appear, and wait until either - the thread finishes normally, or until the cancel button is pressed. - - Before returning, the dialog box will be hidden. - - @param threadPriority the priority to use when starting the thread - see - Thread::startThread() for values - @returns true if the thread finished normally; false if the user pressed cancel - */ - bool runThread (const int threadPriority = 5); - - /** The thread should call this periodically to update the position of the progress bar. - - @param newProgress the progress, from 0.0 to 1.0 - @see setStatusMessage - */ - void setProgress (const double newProgress); - - /** The thread can call this to change the message that's displayed in the dialog box. - */ - void setStatusMessage (const String& newStatusMessage); - - juce_UseDebuggingNewOperator - -private: - void timerCallback(); - - double progress; - AlertWindow* alertWindow; - String message; - CriticalSection messageLock; - const int timeOutMsWhenCancelling; - - ThreadWithProgressWindow (const ThreadWithProgressWindow&); - const ThreadWithProgressWindow& operator= (const ThreadWithProgressWindow&); -}; - -#endif // __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ -/********* End of inlined file: juce_ThreadWithProgressWindow.h *********/ - -#endif -#ifndef __JUCE_TOOLTIPWINDOW_JUCEHEADER__ - -#endif -#ifndef __JUCE_TOPLEVELWINDOW_JUCEHEADER__ - -#endif -#ifndef __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ - -/********* Start of inlined file: juce_ActiveXControlComponent.h *********/ -#ifndef __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ -#define __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ - -#if JUCE_WIN32 || DOXYGEN - -/** - A Windows-specific class that can create and embed an ActiveX control inside - itself. - - To use it, create one of these, put it in place and make sure it's visible in a - window, then use createControl() to instantiate an ActiveX control. The control - will then be moved and resized to follow the movements of this component. - - Of course, since the control is a heavyweight window, it'll obliterate any - juce components that may overlap this component, but that's life. -*/ -class JUCE_API ActiveXControlComponent : public Component -{ -public: - - /** Create an initially-empty container. */ - ActiveXControlComponent(); - - /** Destructor. */ - ~ActiveXControlComponent(); - - /** Tries to create an ActiveX control and embed it in this peer. - - The peer controlIID is a pointer to an IID structure - it's treated - as a void* because when including the Juce headers, you might not always - have included windows.h first, in which case IID wouldn't be defined. - - e.g. @code - const IID myIID = __uuidof (QTControl); - myControlComp->createControl (&myIID); - @endcode - */ - bool createControl (const void* controlIID); - - /** Deletes the ActiveX control, if one has been created. - */ - void deleteControl(); - - /** Returns true if a control is currently in use. */ - bool isControlOpen() const throw() { return control != 0; } - - /** Does a QueryInterface call on the embedded control object. - - This allows you to cast the control to whatever type of COM object you need. - - The iid parameter is a pointer to an IID structure - it's treated - as a void* because when including the Juce headers, you might not always - have included windows.h first, in which case IID wouldn't be defined, but - you should just pass a pointer to an IID. - - e.g. @code - const IID iid = __uuidof (IOleWindow); - - IOleWindow* oleWindow = (IOleWindow*) myControlComp->queryInterface (&iid); - - if (oleWindow != 0) - { - HWND hwnd; - oleWindow->GetWindow (&hwnd); - - ... - - oleWindow->Release(); - } - @endcode - */ - void* queryInterface (const void* iid) const; - - /** Set this to false to stop mouse events being allowed through to the control. - */ - void setMouseEventsAllowed (const bool eventsCanReachControl); - - /** Returns true if mouse events are allowed to get through to the control. - */ - bool areMouseEventsAllowed() const throw() { return mouseEventsAllowed; } - - /** @internal */ - void paint (Graphics& g); - /** @internal */ - void* originalWndProc; - - juce_UseDebuggingNewOperator - -private: - friend class ActiveXControlData; - void* control; - bool mouseEventsAllowed; - - ActiveXControlComponent (const ActiveXControlComponent&); - const ActiveXControlComponent& operator= (const ActiveXControlComponent&); - - void setControlBounds (const Rectangle& bounds) const; - void setControlVisible (const bool b) const; -}; - -#endif - -#endif // __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ -/********* End of inlined file: juce_ActiveXControlComponent.h *********/ - -#endif -#ifndef __JUCE_AUDIODEVICESELECTORCOMPONENT_JUCEHEADER__ - -/********* Start of inlined file: juce_AudioDeviceSelectorComponent.h *********/ -#ifndef __JUCE_AUDIODEVICESELECTORCOMPONENT_JUCEHEADER__ -#define __JUCE_AUDIODEVICESELECTORCOMPONENT_JUCEHEADER__ - -class MidiInputSelectorComponentListBox; - -/** - A component containing controls to let the user change the audio settings of - an AudioDeviceManager object. - - Very easy to use - just create one of these and show it to the user. - - @see AudioDeviceManager -*/ -class JUCE_API AudioDeviceSelectorComponent : public Component, - public ComboBoxListener, - public ButtonListener, - public ChangeListener -{ -public: - - /** Creates the component. - - If your app needs only output channels, you might ask for a maximum of 0 input - channels, and the component won't display any options for choosing the input - channels. And likewise if you're doing an input-only app. - - @param deviceManager the device manager that this component should control - @param minAudioInputChannels the minimum number of audio input channels that the application needs - @param maxAudioInputChannels the maximum number of audio input channels that the application needs - @param minAudioOutputChannels the minimum number of audio output channels that the application needs - @param maxAudioOutputChannels the maximum number of audio output channels that the application needs - @param showMidiInputOptions if true, the component will allow the user to select which midi inputs are enabled - @param showMidiOutputSelector if true, the component will let the user choose a default midi output device - @param showChannelsAsStereoPairs if true, channels will be treated as pairs; if false, channels will be - treated as a set of separate mono channels. - @param hideAdvancedOptionsWithButton if true, only the minimum amount of UI components - are shown, with an "advanced" button that shows the rest of them - */ - AudioDeviceSelectorComponent (AudioDeviceManager& deviceManager, - const int minAudioInputChannels, - const int maxAudioInputChannels, - const int minAudioOutputChannels, - const int maxAudioOutputChannels, - const bool showMidiInputOptions, - const bool showMidiOutputSelector, - const bool showChannelsAsStereoPairs, - const bool hideAdvancedOptionsWithButton); - - /** Destructor */ - ~AudioDeviceSelectorComponent(); - - /** @internal */ - void resized(); - /** @internal */ - void comboBoxChanged (ComboBox*); - /** @internal */ - void buttonClicked (Button*); - /** @internal */ - void changeListenerCallback (void*); - - juce_UseDebuggingNewOperator - -private: - AudioDeviceManager& deviceManager; - ComboBox* deviceTypeDropDown; - Label* deviceTypeDropDownLabel; - Component* audioDeviceSettingsComp; - String audioDeviceSettingsCompType; - const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels; - const bool showChannelsAsStereoPairs; - const bool hideAdvancedOptionsWithButton; + Rectangle textArea; + VoidArray buttons, textBoxes, comboBoxes; + VoidArray progressBars, customComps, textBlocks, allComps; + StringArray textboxNames, comboBoxNames; + Font font; + Component* associatedComponent; - MidiInputSelectorComponentListBox* midiInputsList; - Label* midiInputsLabel; - ComboBox* midiOutputSelector; - Label* midiOutputLabel; + void updateLayout (const bool onlyIncreaseSize); - AudioDeviceSelectorComponent (const AudioDeviceSelectorComponent&); - const AudioDeviceSelectorComponent& operator= (const AudioDeviceSelectorComponent&); + // disable copy constructor + AlertWindow (const AlertWindow&); + const AlertWindow& operator= (const AlertWindow&); }; -#endif // __JUCE_AUDIODEVICESELECTORCOMPONENT_JUCEHEADER__ -/********* End of inlined file: juce_AudioDeviceSelectorComponent.h *********/ +#endif // __JUCE_ALERTWINDOW_JUCEHEADER__ +/********* End of inlined file: juce_AlertWindow.h *********/ #endif -#ifndef __JUCE_BUBBLECOMPONENT_JUCEHEADER__ +#ifndef __JUCE_DIALOGWINDOW_JUCEHEADER__ -/********* Start of inlined file: juce_BubbleComponent.h *********/ -#ifndef __JUCE_BUBBLECOMPONENT_JUCEHEADER__ -#define __JUCE_BUBBLECOMPONENT_JUCEHEADER__ +/********* Start of inlined file: juce_DialogWindow.h *********/ +#ifndef __JUCE_DIALOGWINDOW_JUCEHEADER__ +#define __JUCE_DIALOGWINDOW_JUCEHEADER__ /** - A component for showing a message or other graphics inside a speech-bubble-shaped - outline, pointing at a location on the screen. - - This is a base class that just draws and positions the bubble shape, but leaves - the drawing of any content up to a subclass. See BubbleMessageComponent for a subclass - that draws a text message. + A dialog-box style window. - To use it, create your subclass, then either add it to a parent component or - put it on the desktop with addToDesktop (0), use setPosition() to - resize and position it, then make it visible. + This class is a convenient way of creating a DocumentWindow with a close button + that can be triggered by pressing the escape key. - @see BubbleMessageComponent -*/ -class JUCE_API BubbleComponent : public Component -{ -protected: + Any of the methods available to a DocumentWindow or ResizableWindow are also + available to this, so it can be made resizable, have a menu bar, etc. - /** Creates a BubbleComponent. + To add items to the box, see the ResizableWindow::setContentComponent() method. + Don't add components directly to this class - always put them in a content component! - Your subclass will need to implement the getContentSize() and paintContent() - methods to draw the bubble's contents. - */ - BubbleComponent(); + You'll need to override the DocumentWindow::closeButtonPressed() method to handle + the user clicking the close button - for more info, see the DocumentWindow + help. + @see DocumentWindow, ResizableWindow +*/ +class JUCE_API DialogWindow : public DocumentWindow +{ public: - /** Destructor. */ - ~BubbleComponent(); - /** A list of permitted placements for the bubble, relative to the co-ordinates - at which it should be pointing. + /** Creates a DialogWindow. - @see setAllowedPlacement + @param name the name to give the component - this is also + the title shown at the top of the window. To change + this later, use setName() + @param backgroundColour the colour to use for filling the window's background. + @param escapeKeyTriggersCloseButton if true, then pressing the escape key will cause the + close button to be triggered + @param addToDesktop if true, the window will be automatically added to the + desktop; if false, you can use it as a child component */ - enum BubblePlacement - { - above = 1, - below = 2, - left = 4, - right = 8 - }; - - /** Tells the bubble which positions it's allowed to put itself in, relative to the - point at which it's pointing. - - By default when setPosition() is called, the bubble will place itself either - above, below, left, or right of the target area. You can pass in a bitwise-'or' of - the values in BubblePlacement to restrict this choice. + DialogWindow (const String& name, + const Colour& backgroundColour, + const bool escapeKeyTriggersCloseButton, + const bool addToDesktop = true); - E.g. if you only want your bubble to appear above or below the target area, - use setAllowedPlacement (above | below); + /** Destructor. - @see BubblePlacement + If a content component has been set with setContentComponent(), it + will be deleted. */ - void setAllowedPlacement (const int newPlacement); + ~DialogWindow(); - /** Moves and resizes the bubble to point at a given component. + /** Easy way of quickly showing a dialog box containing a given component. - This will resize the bubble to fit its content, then find a position for it - so that it's next to, but doesn't overlap the given component. + This will open and display a DialogWindow containing a given component, returning + when the user clicks its close button. - It'll put itself either above, below, or to the side of the component depending - on where there's the most space, honouring any restrictions that were set - with setAllowedPlacement(). - */ - void setPosition (Component* componentToPointTo); + It returns the value that was returned by the dialog box's runModalLoop() call. - /** Moves and resizes the bubble to point at a given point. + To close the dialog programatically, you should call exitModalState (returnValue) on + the DialogWindow that is created. To find a pointer to this window from your + contentComponent, you can do something like this: + @code + Dialogwindow* dw = contentComponent->findParentComponentOfClass ((DialogWindow*) 0); - This will resize the bubble to fit its content, then position it - so that the tip of the bubble points to the given co-ordinate. The co-ordinates - are relative to either the bubble component's parent component if it has one, or - they are screen co-ordinates if not. + if (dw != 0) + dw->exitModalState (1234); + @endcode - It'll put itself either above, below, or to the side of this point, depending - on where there's the most space, honouring any restrictions that were set - with setAllowedPlacement(). + @param dialogTitle the dialog box's title + @param contentComponent the content component for the dialog box. Make sure + that this has been set to the size you want it to + be before calling this method. The component won't + be deleted by this call, so you can re-use it or delete + it afterwards + @param componentToCentreAround if this is non-zero, it indicates a component that + you'd like to show this dialog box in front of. See the + DocumentWindow::centreAroundComponent() method for more + info on this parameter + @param backgroundColour a colour to use for the dialog box's background colour + @param escapeKeyTriggersCloseButton if true, then pressing the escape key will cause the + close button to be triggered + @param shouldBeResizable if true, the dialog window has either a resizable border, or + a corner resizer + @param useBottomRightCornerResizer if shouldBeResizable is true, this indicates whether + to use a border or corner resizer component. See ResizableWindow::setResizable() */ - void setPosition (const int arrowTipX, - const int arrowTipY); - - /** Moves and resizes the bubble to point at a given rectangle. - - This will resize the bubble to fit its content, then find a position for it - so that it's next to, but doesn't overlap the given rectangle. The rectangle's - co-ordinates are relative to either the bubble component's parent component - if it has one, or they are screen co-ordinates if not. + static int showModalDialog (const String& dialogTitle, + Component* contentComponent, + Component* componentToCentreAround, + const Colour& backgroundColour, + const bool escapeKeyTriggersCloseButton, + const bool shouldBeResizable = false, + const bool useBottomRightCornerResizer = false); - It'll put itself either above, below, or to the side of the component depending - on where there's the most space, honouring any restrictions that were set - with setAllowedPlacement(). - */ - void setPosition (const Rectangle& rectangleToPointTo); + juce_UseDebuggingNewOperator protected: + /** @internal */ + void resized(); - /** Subclasses should override this to return the size of the content they - want to draw inside the bubble. - */ - virtual void getContentSize (int& width, int& height) = 0; +private: + bool escapeKeyTriggersCloseButton; - /** Subclasses should override this to draw their bubble's contents. + DialogWindow (const DialogWindow&); + const DialogWindow& operator= (const DialogWindow&); +}; - The graphics object's clip region and the dimensions passed in here are - set up to paint just the rectangle inside the bubble. - */ - virtual void paintContent (Graphics& g, int width, int height) = 0; +#endif // __JUCE_DIALOGWINDOW_JUCEHEADER__ +/********* End of inlined file: juce_DialogWindow.h *********/ -public: +#endif +#ifndef __JUCE_DOCUMENTWINDOW_JUCEHEADER__ - /** @internal */ - void paint (Graphics& g); +#endif +#ifndef __JUCE_RESIZABLEWINDOW_JUCEHEADER__ - juce_UseDebuggingNewOperator +#endif +#ifndef __JUCE_SPLASHSCREEN_JUCEHEADER__ -private: - Rectangle content; - int side, allowablePlacements; - float arrowTipX, arrowTipY; - DropShadowEffect shadow; +/********* Start of inlined file: juce_SplashScreen.h *********/ +#ifndef __JUCE_SPLASHSCREEN_JUCEHEADER__ +#define __JUCE_SPLASHSCREEN_JUCEHEADER__ - BubbleComponent (const BubbleComponent&); - const BubbleComponent& operator= (const BubbleComponent&); -}; +/** A component for showing a splash screen while your app starts up. -#endif // __JUCE_BUBBLECOMPONENT_JUCEHEADER__ -/********* End of inlined file: juce_BubbleComponent.h *********/ + This will automatically position itself, and delete itself when the app has + finished initialising (it uses the JUCEApplication::isInitialising() to detect + this). -#endif -#ifndef __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ + To use it, just create one of these in your JUCEApplication::initialise() method, + call its show() method and let the object delete itself later. -/********* Start of inlined file: juce_BubbleMessageComponent.h *********/ -#ifndef __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ -#define __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ + E.g. @code -/** - A speech-bubble component that displays a short message. + void MyApp::initialise (const String& commandLine) + { + SplashScreen* splash = new SplashScreen(); - This can be used to show a message with the tail of the speech bubble - pointing to a particular component or location on the screen. + splash->show (T("welcome to my app"), + ImageCache::getFromFile (File ("/foobar/splash.jpg")), + 4000, false); - @see BubbleComponent + .. no need to delete the splash screen - it'll do that itself. + } + + @endcode */ -class JUCE_API BubbleMessageComponent : public BubbleComponent, - private Timer +class JUCE_API SplashScreen : public Component, + public Timer, + private DeletedAtShutdown { public: - /** Creates a bubble component. + /** Creates a SplashScreen object. - After creating one a BubbleComponent, do the following: - - add it to an appropriate parent component, or put it on the - desktop with Component::addToDesktop (0). - - use the showAt() method to show a message. - - it will make itself invisible after it times-out (and can optionally - also delete itself), or you can reuse it somewhere else by calling - showAt() again. + After creating one of these (or your subclass of it), call one of the show() + methods to display it. */ - BubbleMessageComponent (const int fadeOutLengthMs = 150); + SplashScreen(); /** Destructor. */ - ~BubbleMessageComponent(); - - /** Shows a message bubble at a particular position. + ~SplashScreen(); - This shows the bubble with its stem pointing to the given location - (co-ordinates being relative to its parent component). + /** Creates a SplashScreen object that will display an image. - For details about exactly how it decides where to position itself, see - BubbleComponent::updatePosition(). + As soon as this is called, the SplashScreen will be displayed in the centre of the + screen. This method will also dispatch any pending messages to make sure that when + it returns, the splash screen has been completely drawn, and your initialisation + code can carry on. - @param x the x co-ordinate of end of the bubble's tail - @param y the y co-ordinate of end of the bubble's tail - @param message the text to display - @param numMillisecondsBeforeRemoving how long to leave it on the screen before removing itself - from its parent compnent. If this is 0 or less, it - will stay there until manually removed. - @param removeWhenMouseClicked if this is true, the bubble will disappear as soon as a - mouse button is pressed (anywhere on the screen) - @param deleteSelfAfterUse if true, then the component will delete itself after - it becomes invisible + @param title the name to give the component + @param backgroundImage an image to draw on the component. The component's size + will be set to the size of this image, and if the image is + semi-transparent, the component will be made semi-transparent + too. This image will be deleted (or released from the ImageCache + if that's how it was created) by the splash screen object when + it is itself deleted. + @param minimumTimeToDisplayFor how long (in milliseconds) the splash screen + should stay visible for. If the initialisation takes longer than + this time, the splash screen will wait for it to finish before + disappearing, but if initialisation is very quick, this lets + you make sure that people get a good look at your splash. + @param useDropShadow if true, the window will have a drop shadow + @param removeOnMouseClick if true, the window will go away as soon as the user clicks + the mouse (anywhere) */ - void showAt (int x, int y, - const String& message, - const int numMillisecondsBeforeRemoving, - const bool removeWhenMouseClicked = true, - const bool deleteSelfAfterUse = false); + void show (const String& title, + Image* const backgroundImage, + const int minimumTimeToDisplayFor, + const bool useDropShadow, + const bool removeOnMouseClick = true); - /** Shows a message bubble next to a particular component. + /** Creates a SplashScreen object with a specified size. - This shows the bubble with its stem pointing at the given component. + For a custom splash screen, you can use this method to display it at a certain size + and then override the paint() method yourself to do whatever's necessary. - For details about exactly how it decides where to position itself, see - BubbleComponent::updatePosition(). + As soon as this is called, the SplashScreen will be displayed in the centre of the + screen. This method will also dispatch any pending messages to make sure that when + it returns, the splash screen has been completely drawn, and your initialisation + code can carry on. - @param component the component that you want to point at - @param message the text to display - @param numMillisecondsBeforeRemoving how long to leave it on the screen before removing itself - from its parent compnent. If this is 0 or less, it - will stay there until manually removed. - @param removeWhenMouseClicked if this is true, the bubble will disappear as soon as a - mouse button is pressed (anywhere on the screen) - @param deleteSelfAfterUse if true, then the component will delete itself after - it becomes invisible + @param title the name to give the component + @param width the width to use + @param height the height to use + @param minimumTimeToDisplayFor how long (in milliseconds) the splash screen + should stay visible for. If the initialisation takes longer than + this time, the splash screen will wait for it to finish before + disappearing, but if initialisation is very quick, this lets + you make sure that people get a good look at your splash. + @param useDropShadow if true, the window will have a drop shadow + @param removeOnMouseClick if true, the window will go away as soon as the user clicks + the mouse (anywhere) */ - void showAt (Component* const component, - const String& message, - const int numMillisecondsBeforeRemoving, - const bool removeWhenMouseClicked = true, - const bool deleteSelfAfterUse = false); + void show (const String& title, + const int width, + const int height, + const int minimumTimeToDisplayFor, + const bool useDropShadow, + const bool removeOnMouseClick = true); /** @internal */ - void getContentSize (int& w, int& h); - /** @internal */ - void paintContent (Graphics& g, int w, int h); + void paint (Graphics& g); /** @internal */ void timerCallback(); juce_UseDebuggingNewOperator private: - int fadeOutLength, mouseClickCounter; - TextLayout textLayout; - int64 expiryTime; - bool deleteAfterUse; - - void init (const int numMillisecondsBeforeRemoving, - const bool removeWhenMouseClicked, - const bool deleteSelfAfterUse); + Image* backgroundImage; + Time earliestTimeToDelete; + int originalClickCounter; + bool isImageInCache; - BubbleMessageComponent (const BubbleMessageComponent&); - const BubbleMessageComponent& operator= (const BubbleMessageComponent&); + SplashScreen (const SplashScreen&); + const SplashScreen& operator= (const SplashScreen&); }; -#endif // __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ -/********* End of inlined file: juce_BubbleMessageComponent.h *********/ +#endif // __JUCE_SPLASHSCREEN_JUCEHEADER__ +/********* End of inlined file: juce_SplashScreen.h *********/ #endif -#ifndef __JUCE_COLOURSELECTOR_JUCEHEADER__ +#ifndef __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ -/********* Start of inlined file: juce_ColourSelector.h *********/ -#ifndef __JUCE_COLOURSELECTOR_JUCEHEADER__ -#define __JUCE_COLOURSELECTOR_JUCEHEADER__ +/********* Start of inlined file: juce_ThreadWithProgressWindow.h *********/ +#ifndef __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ +#define __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ /** - A component that lets the user choose a colour. - - This shows RGB sliders and a colourspace that the user can pick colours from. + A thread that automatically pops up a modal dialog box with a progress bar + and cancel button while it's busy running. - This class is also a ChangeBroadcaster, so listeners can register to be told - when the colour changes. -*/ -class JUCE_API ColourSelector : public Component, - public ChangeBroadcaster, - protected SliderListener -{ -public: + These are handy for performing some sort of task while giving the user feedback + about how long there is to go, etc. - /** Options for the type of selector to show. These are passed into the constructor. */ - enum ColourSelectorOptions + E.g. @code + class MyTask : public ThreadWithProgressWindow { - showAlphaChannel = 1 << 0, /**< if set, the colour's alpha channel can be changed as well as its RGB. */ - - showColourAtTop = 1 << 1, /**< if set, a swatch of the colour is shown at the top of the component. */ - showSliders = 1 << 2, /**< if set, RGB sliders are shown at the bottom of the component. */ - showColourspace = 1 << 3 /**< if set, a big HSV selector is shown. */ - }; + public: + MyTask() : ThreadWithProgressWindow (T("busy..."), true, true) + { + } - /** Creates a ColourSelector object. + ~MyTask() + { + } - The flags are a combination of values from the ColourSelectorOptions enum, specifying - which of the selector's features should be visible. + void run() + { + for (int i = 0; i < thingsToDo; ++i) + { + // must check this as often as possible, because this is + // how we know if the user's pressed 'cancel' + if (threadShouldExit()) + break; - The edgeGap value specifies the amount of space to leave around the edge. + // this will update the progress bar on the dialog box + setProgress (i / (double) thingsToDo); - gapAroundColourSpaceComponent indicates how much of a gap to put around the - colourspace and hue selector components. - */ - ColourSelector (const int sectionsToShow = (showAlphaChannel | showColourAtTop | showSliders | showColourspace), - const int edgeGap = 4, - const int gapAroundColourSpaceComponent = 7); + // ... do the business here... + } + } + }; - /** Destructor. */ - ~ColourSelector(); + void doTheTask() + { + MyTask m; - /** Returns the colour that the user has currently selected. + if (m.runThread()) + { + // thread finished normally.. + } + else + { + // user pressed the cancel button.. + } + } - The ColourSelector class is also a ChangeBroadcaster, so listeners can - register to be told when the colour changes. + @endcode - @see setCurrentColour - */ - const Colour getCurrentColour() const; + @see Thread, AlertWindow +*/ +class JUCE_API ThreadWithProgressWindow : public Thread, + private Timer +{ +public: - /** Changes the colour that is currently being shown. - */ - void setCurrentColour (const Colour& newColour); + /** Creates the thread. - /** Tells the selector how many preset colour swatches you want to have on the component. + Initially, the dialog box won't be visible, it'll only appear when the + runThread() method is called. - To enable swatches, you'll need to override getNumSwatches(), getSwatchColour(), and - setSwatchColour(), to return the number of colours you want, and to set and retrieve - their values. + @param windowTitle the title to go at the top of the dialog box + @param hasProgressBar whether the dialog box should have a progress bar (see + setProgress() ) + @param hasCancelButton whether the dialog box should have a cancel button + @param timeOutMsWhenCancelling when 'cancel' is pressed, this is how long to wait for + the thread to stop before killing it forcibly (see + Thread::stopThread() ) + @param cancelButtonText the text that should be shown in the cancel button + (if it has one) */ - virtual int getNumSwatches() const; - - /** Called by the selector to find out the colour of one of the swatches. + ThreadWithProgressWindow (const String& windowTitle, + const bool hasProgressBar, + const bool hasCancelButton, + const int timeOutMsWhenCancelling = 10000, + const String& cancelButtonText = JUCE_T("Cancel")); - Your subclass should return the colour of the swatch with the given index. + /** Destructor. */ + ~ThreadWithProgressWindow(); - To enable swatches, you'll need to override getNumSwatches(), getSwatchColour(), and - setSwatchColour(), to return the number of colours you want, and to set and retrieve - their values. - */ - virtual const Colour getSwatchColour (const int index) const; + /** Starts the thread and waits for it to finish. - /** Called by the selector when the user puts a new colour into one of the swatches. + This will start the thread, make the dialog box appear, and wait until either + the thread finishes normally, or until the cancel button is pressed. - Your subclass should change the colour of the swatch with the given index. + Before returning, the dialog box will be hidden. - To enable swatches, you'll need to override getNumSwatches(), getSwatchColour(), and - setSwatchColour(), to return the number of colours you want, and to set and retrieve - their values. + @param threadPriority the priority to use when starting the thread - see + Thread::startThread() for values + @returns true if the thread finished normally; false if the user pressed cancel */ - virtual void setSwatchColour (const int index, const Colour& newColour) const; + bool runThread (const int threadPriority = 5); - /** A set of colour IDs to use to change the colour of various aspects of the keyboard. + /** The thread should call this periodically to update the position of the progress bar. - These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() - methods. + @param newProgress the progress, from 0.0 to 1.0 + @see setStatusMessage + */ + void setProgress (const double newProgress); - @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + /** The thread can call this to change the message that's displayed in the dialog box. */ - enum ColourIds - { - backgroundColourId = 0x1007000, /**< the colour used to fill the component's background. */ - labelTextColourId = 0x1007001 /**< the colour used for the labels next to the sliders. */ - }; + void setStatusMessage (const String& newStatusMessage); juce_UseDebuggingNewOperator private: - friend class ColourSpaceView; - friend class HueSelectorComp; - Colour colour; - float h, s, v; - Slider* sliders[4]; - Component* colourSpace; - Component* hueSelector; - VoidArray swatchComponents; - const int flags; - int topSpace, edgeGap; - - void setHue (float newH); - void setSV (float newS, float newV); - void updateHSV(); - void update(); - void sliderValueChanged (Slider*); - void paint (Graphics& g); - void resized(); + void timerCallback(); - ColourSelector (const ColourSelector&); - const ColourSelector& operator= (const ColourSelector&); + double progress; + AlertWindow* alertWindow; + String message; + CriticalSection messageLock; + const int timeOutMsWhenCancelling; - // this constructor is here temporarily to prevent old code compiling, because the parameters - // have changed - if you get an error here, update your code to use the new constructor instead.. - // (xxx - note to self: remember to remove this at some point in the future) - ColourSelector (const bool); + ThreadWithProgressWindow (const ThreadWithProgressWindow&); + const ThreadWithProgressWindow& operator= (const ThreadWithProgressWindow&); }; -#endif // __JUCE_COLOURSELECTOR_JUCEHEADER__ -/********* End of inlined file: juce_ColourSelector.h *********/ +#endif // __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ +/********* End of inlined file: juce_ThreadWithProgressWindow.h *********/ #endif -#ifndef __JUCE_DROPSHADOWER_JUCEHEADER__ +#ifndef __JUCE_TOPLEVELWINDOW_JUCEHEADER__ #endif -#ifndef __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ +#ifndef __JUCE_COMPONENTPEER_JUCEHEADER__ -/********* Start of inlined file: juce_MagnifierComponent.h *********/ -#ifndef __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ -#define __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ +#endif +#ifndef __JUCE_TOOLTIPWINDOW_JUCEHEADER__ + +#endif +#ifndef __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ + +/********* Start of inlined file: juce_ActiveXControlComponent.h *********/ +#ifndef __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ +#define __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ + +#if JUCE_WIN32 || DOXYGEN /** - A component that contains another component, and can magnify or shrink it. + A Windows-specific class that can create and embed an ActiveX control inside + itself. - This component will continually update its size so that it fits the zoomed - version of the content component that you put inside it, so don't try to - change the size of this component directly - instead change that of the - content component. + To use it, create one of these, put it in place and make sure it's visible in a + window, then use createControl() to instantiate an ActiveX control. The control + will then be moved and resized to follow the movements of this component. - To make it all work, the magnifier uses extremely cunning ComponentPeer tricks - to remap mouse events correctly. This means that the content component won't - appear to be a direct child of this component, and instead will think its - on the desktop. + Of course, since the control is a heavyweight window, it'll obliterate any + juce components that may overlap this component, but that's life. */ -class JUCE_API MagnifierComponent : public Component +class JUCE_API ActiveXControlComponent : public Component { public: - /** Creates a MagnifierComponent. + /** Create an initially-empty container. */ + ActiveXControlComponent(); - This component will continually update its size so that it fits the zoomed - version of the content component that you put inside it, so don't try to - change the size of this component directly - instead change that of the - content component. + /** Destructor. */ + ~ActiveXControlComponent(); - @param contentComponent the component to add as the magnified one - @param deleteContentCompWhenNoLongerNeeded if true, the content component will - be deleted when this component is deleted. If false, - it's the caller's responsibility to delete it later. + /** Tries to create an ActiveX control and embed it in this peer. + + The peer controlIID is a pointer to an IID structure - it's treated + as a void* because when including the Juce headers, you might not always + have included windows.h first, in which case IID wouldn't be defined. + + e.g. @code + const IID myIID = __uuidof (QTControl); + myControlComp->createControl (&myIID); + @endcode */ - MagnifierComponent (Component* const contentComponent, - const bool deleteContentCompWhenNoLongerNeeded); + bool createControl (const void* controlIID); - /** Destructor. */ - ~MagnifierComponent(); + /** Deletes the ActiveX control, if one has been created. + */ + void deleteControl(); - /** Returns the current content component. */ - Component* getContentComponent() const throw() { return content; } + /** Returns true if a control is currently in use. */ + bool isControlOpen() const throw() { return control != 0; } - /** Changes the zoom level. + /** Does a QueryInterface call on the embedded control object. - The scale factor must be greater than zero. Values less than 1 will shrink the - image; values greater than 1 will multiply its size by this amount. + This allows you to cast the control to whatever type of COM object you need. - When this is called, this component will change its size to fit the full extent - of the newly zoomed content. - */ - void setScaleFactor (double newScaleFactor); + The iid parameter is a pointer to an IID structure - it's treated + as a void* because when including the Juce headers, you might not always + have included windows.h first, in which case IID wouldn't be defined, but + you should just pass a pointer to an IID. - /** Returns the current zoom factor. */ - double getScaleFactor() const throw() { return scaleFactor; } + e.g. @code + const IID iid = __uuidof (IOleWindow); - /** Changes the quality setting used to rescale the graphics. + IOleWindow* oleWindow = (IOleWindow*) myControlComp->queryInterface (&iid); + + if (oleWindow != 0) + { + HWND hwnd; + oleWindow->GetWindow (&hwnd); + + ... + + oleWindow->Release(); + } + @endcode */ - void setResamplingQuality (Graphics::ResamplingQuality newQuality); + void* queryInterface (const void* iid) const; - juce_UseDebuggingNewOperator + /** Set this to false to stop mouse events being allowed through to the control. + */ + void setMouseEventsAllowed (const bool eventsCanReachControl); + + /** Returns true if mouse events are allowed to get through to the control. + */ + bool areMouseEventsAllowed() const throw() { return mouseEventsAllowed; } /** @internal */ - void childBoundsChanged (Component*); + void paint (Graphics& g); + /** @internal */ + void* originalWndProc; -private: - Component* content; - Component* holderComp; - double scaleFactor; - ComponentPeer* peer; - bool deleteContent; - Graphics::ResamplingQuality quality; + juce_UseDebuggingNewOperator - void paint (Graphics& g); - void mouseDown (const MouseEvent& e); - void mouseUp (const MouseEvent& e); - void mouseDrag (const MouseEvent& e); - void mouseMove (const MouseEvent& e); - void mouseEnter (const MouseEvent& e); - void mouseExit (const MouseEvent& e); - void mouseWheelMove (const MouseEvent& e, float, float); +private: + friend class ActiveXControlData; + void* control; + bool mouseEventsAllowed; - int scaleInt (const int n) const throw(); + ActiveXControlComponent (const ActiveXControlComponent&); + const ActiveXControlComponent& operator= (const ActiveXControlComponent&); - MagnifierComponent (const MagnifierComponent&); - const MagnifierComponent& operator= (const MagnifierComponent&); + void setControlBounds (const Rectangle& bounds) const; + void setControlVisible (const bool b) const; }; -#endif // __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ -/********* End of inlined file: juce_MagnifierComponent.h *********/ - #endif -#ifndef __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ -/********* Start of inlined file: juce_MidiKeyboardComponent.h *********/ -#ifndef __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ -#define __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ +#endif // __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ +/********* End of inlined file: juce_ActiveXControlComponent.h *********/ -/** - A component that displays a piano keyboard, whose notes can be clicked on. +#endif +#ifndef __JUCE_AUDIODEVICESELECTORCOMPONENT_JUCEHEADER__ - This component will mimic a physical midi keyboard, showing the current state of - a MidiKeyboardState object. When the on-screen keys are clicked on, it will play these - notes by calling the noteOn() and noteOff() methods of its MidiKeyboardState object. +/********* Start of inlined file: juce_AudioDeviceSelectorComponent.h *********/ +#ifndef __JUCE_AUDIODEVICESELECTORCOMPONENT_JUCEHEADER__ +#define __JUCE_AUDIODEVICESELECTORCOMPONENT_JUCEHEADER__ - Another feature is that the computer keyboard can also be used to play notes. By - default it maps the top two rows of a standard querty keyboard to the notes, but - these can be remapped if needed. It will only respond to keypresses when it has - the keyboard focus, so to disable this feature you can call setWantsKeyboardFocus (false). +class MidiInputSelectorComponentListBox; - The component is also a ChangeBroadcaster, so if you want to be informed when the - keyboard is scrolled, you can register a ChangeListener for callbacks. +/** + A component containing controls to let the user change the audio settings of + an AudioDeviceManager object. - @see MidiKeyboardState + Very easy to use - just create one of these and show it to the user. + + @see AudioDeviceManager */ -class JUCE_API MidiKeyboardComponent : public Component, - public MidiKeyboardStateListener, - public ChangeBroadcaster, - private Timer, - private AsyncUpdater +class JUCE_API AudioDeviceSelectorComponent : public Component, + public ComboBoxListener, + public ButtonListener, + public ChangeListener { public: - /** The direction of the keyboard. - - @see setOrientation - */ - enum Orientation - { - horizontalKeyboard, - verticalKeyboardFacingLeft, - verticalKeyboardFacingRight, - }; + /** Creates the component. - /** Creates a MidiKeyboardComponent. + If your app needs only output channels, you might ask for a maximum of 0 input + channels, and the component won't display any options for choosing the input + channels. And likewise if you're doing an input-only app. - @param state the midi keyboard model that this component will represent - @param orientation whether the keyboard is horizonal or vertical + @param deviceManager the device manager that this component should control + @param minAudioInputChannels the minimum number of audio input channels that the application needs + @param maxAudioInputChannels the maximum number of audio input channels that the application needs + @param minAudioOutputChannels the minimum number of audio output channels that the application needs + @param maxAudioOutputChannels the maximum number of audio output channels that the application needs + @param showMidiInputOptions if true, the component will allow the user to select which midi inputs are enabled + @param showMidiOutputSelector if true, the component will let the user choose a default midi output device + @param showChannelsAsStereoPairs if true, channels will be treated as pairs; if false, channels will be + treated as a set of separate mono channels. + @param hideAdvancedOptionsWithButton if true, only the minimum amount of UI components + are shown, with an "advanced" button that shows the rest of them */ - MidiKeyboardComponent (MidiKeyboardState& state, - const Orientation orientation); + AudioDeviceSelectorComponent (AudioDeviceManager& deviceManager, + const int minAudioInputChannels, + const int maxAudioInputChannels, + const int minAudioOutputChannels, + const int maxAudioOutputChannels, + const bool showMidiInputOptions, + const bool showMidiOutputSelector, + const bool showChannelsAsStereoPairs, + const bool hideAdvancedOptionsWithButton); - /** Destructor. */ - ~MidiKeyboardComponent(); + /** Destructor */ + ~AudioDeviceSelectorComponent(); - /** Changes the velocity used in midi note-on messages that are triggered by clicking - on the component. + /** @internal */ + void resized(); + /** @internal */ + void comboBoxChanged (ComboBox*); + /** @internal */ + void buttonClicked (Button*); + /** @internal */ + void changeListenerCallback (void*); - Values are 0 to 1.0, where 1.0 is the heaviest. + juce_UseDebuggingNewOperator - @see setMidiChannel - */ - void setVelocity (const float velocity); +private: + AudioDeviceManager& deviceManager; + ComboBox* deviceTypeDropDown; + Label* deviceTypeDropDownLabel; + Component* audioDeviceSettingsComp; + String audioDeviceSettingsCompType; + const int minOutputChannels, maxOutputChannels, minInputChannels, maxInputChannels; + const bool showChannelsAsStereoPairs; + const bool hideAdvancedOptionsWithButton; - /** Changes the midi channel number that will be used for events triggered by clicking - on the component. + MidiInputSelectorComponentListBox* midiInputsList; + Label* midiInputsLabel; + ComboBox* midiOutputSelector; + Label* midiOutputLabel; - The channel must be between 1 and 16 (inclusive). This is the channel that will be - passed on to the MidiKeyboardState::noteOn() method when the user clicks the component. + AudioDeviceSelectorComponent (const AudioDeviceSelectorComponent&); + const AudioDeviceSelectorComponent& operator= (const AudioDeviceSelectorComponent&); +}; - Although this is the channel used for outgoing events, the component can display - incoming events from more than one channel - see setMidiChannelsToDisplay() +#endif // __JUCE_AUDIODEVICESELECTORCOMPONENT_JUCEHEADER__ +/********* End of inlined file: juce_AudioDeviceSelectorComponent.h *********/ - @see setVelocity - */ - void setMidiChannel (const int midiChannelNumber); +#endif +#ifndef __JUCE_BUBBLECOMPONENT_JUCEHEADER__ - /** Returns the midi channel that the keyboard is using for midi messages. +/********* Start of inlined file: juce_BubbleComponent.h *********/ +#ifndef __JUCE_BUBBLECOMPONENT_JUCEHEADER__ +#define __JUCE_BUBBLECOMPONENT_JUCEHEADER__ - @see setMidiChannel - */ - int getMidiChannel() const throw() { return midiChannel; } +/** + A component for showing a message or other graphics inside a speech-bubble-shaped + outline, pointing at a location on the screen. - /** Sets a mask to indicate which incoming midi channels should be represented by - key movements. + This is a base class that just draws and positions the bubble shape, but leaves + the drawing of any content up to a subclass. See BubbleMessageComponent for a subclass + that draws a text message. - The mask is a set of bits, where bit 0 = midi channel 1, bit 1 = midi channel 2, etc. + To use it, create your subclass, then either add it to a parent component or + put it on the desktop with addToDesktop (0), use setPosition() to + resize and position it, then make it visible. - If the MidiKeyboardState has a key down for any of the channels whose bits are set - in this mask, the on-screen keys will also go down. + @see BubbleMessageComponent +*/ +class JUCE_API BubbleComponent : public Component +{ +protected: - By default, this mask is set to 0xffff (all channels displayed). + /** Creates a BubbleComponent. - @see setMidiChannel + Your subclass will need to implement the getContentSize() and paintContent() + methods to draw the bubble's contents. */ - void setMidiChannelsToDisplay (const int midiChannelMask); + BubbleComponent(); - /** Returns the current set of midi channels represented by the component. +public: + /** Destructor. */ + ~BubbleComponent(); - This is the value that was set with setMidiChannelsToDisplay(). + /** A list of permitted placements for the bubble, relative to the co-ordinates + at which it should be pointing. + + @see setAllowedPlacement */ - int getMidiChannelsToDisplay() const throw() { return midiInChannelMask; } + enum BubblePlacement + { + above = 1, + below = 2, + left = 4, + right = 8 + }; - /** Changes the width used to draw the white keys. */ - void setKeyWidth (const float widthInPixels); + /** Tells the bubble which positions it's allowed to put itself in, relative to the + point at which it's pointing. - /** Returns the width that was set by setKeyWidth(). */ - float getKeyWidth() const throw() { return keyWidth; } + By default when setPosition() is called, the bubble will place itself either + above, below, left, or right of the target area. You can pass in a bitwise-'or' of + the values in BubblePlacement to restrict this choice. - /** Changes the keyboard's current direction. */ - void setOrientation (const Orientation newOrientation); + E.g. if you only want your bubble to appear above or below the target area, + use setAllowedPlacement (above | below); - /** Returns the keyboard's current direction. */ - const Orientation getOrientation() const throw() { return orientation; } + @see BubblePlacement + */ + void setAllowedPlacement (const int newPlacement); - /** Sets the range of midi notes that the keyboard will be limited to. + /** Moves and resizes the bubble to point at a given component. - By default the range is 0 to 127 (inclusive), but you can limit this if you - only want a restricted set of the keys to be shown. + This will resize the bubble to fit its content, then find a position for it + so that it's next to, but doesn't overlap the given component. - Note that the values here are inclusive and must be between 0 and 127. + It'll put itself either above, below, or to the side of the component depending + on where there's the most space, honouring any restrictions that were set + with setAllowedPlacement(). */ - void setAvailableRange (const int lowestNote, - const int highestNote); - - /** Returns the first note in the available range. + void setPosition (Component* componentToPointTo); - @see setAvailableRange - */ - int getRangeStart() const throw() { return rangeStart; } + /** Moves and resizes the bubble to point at a given point. - /** Returns the last note in the available range. + This will resize the bubble to fit its content, then position it + so that the tip of the bubble points to the given co-ordinate. The co-ordinates + are relative to either the bubble component's parent component if it has one, or + they are screen co-ordinates if not. - @see setAvailableRange + It'll put itself either above, below, or to the side of this point, depending + on where there's the most space, honouring any restrictions that were set + with setAllowedPlacement(). */ - int getRangeEnd() const throw() { return rangeEnd; } + void setPosition (const int arrowTipX, + const int arrowTipY); - /** If the keyboard extends beyond the size of the component, this will scroll - it to show the given key at the start. + /** Moves and resizes the bubble to point at a given rectangle. - Whenever the keyboard's position is changed, this will use the ChangeBroadcaster - base class to send a callback to any ChangeListeners that have been registered. + This will resize the bubble to fit its content, then find a position for it + so that it's next to, but doesn't overlap the given rectangle. The rectangle's + co-ordinates are relative to either the bubble component's parent component + if it has one, or they are screen co-ordinates if not. + + It'll put itself either above, below, or to the side of the component depending + on where there's the most space, honouring any restrictions that were set + with setAllowedPlacement(). */ - void setLowestVisibleKey (int noteNumber); + void setPosition (const Rectangle& rectangleToPointTo); - /** Returns the number of the first key shown in the component. +protected: - @see setLowestVisibleKey + /** Subclasses should override this to return the size of the content they + want to draw inside the bubble. */ - int getLowestVisibleKey() const throw() { return firstKey; } + virtual void getContentSize (int& width, int& height) = 0; - /** Returns the length of the black notes. + /** Subclasses should override this to draw their bubble's contents. - This will be their vertical or horizontal length, depending on the keyboard's orientation. + The graphics object's clip region and the dimensions passed in here are + set up to paint just the rectangle inside the bubble. */ - int getBlackNoteLength() const throw() { return blackNoteLength; } + virtual void paintContent (Graphics& g, int width, int height) = 0; - /** If set to true, then scroll buttons will appear at either end of the keyboard - if there are too many notes to fit them all in the component at once. - */ - void setScrollButtonsVisible (const bool canScroll); +public: - /** A set of colour IDs to use to change the colour of various aspects of the keyboard. + /** @internal */ + void paint (Graphics& g); - These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() - methods. + juce_UseDebuggingNewOperator - @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour - */ - enum ColourIds - { - whiteNoteColourId = 0x1005000, - blackNoteColourId = 0x1005001, - keySeparatorLineColourId = 0x1005002, - mouseOverKeyOverlayColourId = 0x1005003, /**< This colour will be overlaid on the normal note colour. */ - keyDownOverlayColourId = 0x1005004, /**< This colour will be overlaid on the normal note colour. */ - textLabelColourId = 0x1005005, - upDownButtonBackgroundColourId = 0x1005006, - upDownButtonArrowColourId = 0x1005007 - }; +private: + Rectangle content; + int side, allowablePlacements; + float arrowTipX, arrowTipY; + DropShadowEffect shadow; - /** Returns the position within the component of the left-hand edge of a key. + BubbleComponent (const BubbleComponent&); + const BubbleComponent& operator= (const BubbleComponent&); +}; - Depending on the keyboard's orientation, this may be a horizontal or vertical - distance, in either direction. - */ - int getKeyStartPosition (const int midiNoteNumber) const; +#endif // __JUCE_BUBBLECOMPONENT_JUCEHEADER__ +/********* End of inlined file: juce_BubbleComponent.h *********/ - /** Deletes all key-mappings. +#endif +#ifndef __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ - @see setKeyPressForNote - */ - void clearKeyMappings(); +/********* Start of inlined file: juce_BubbleMessageComponent.h *********/ +#ifndef __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ +#define __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ - /** Maps a key-press to a given note. +/** + A speech-bubble component that displays a short message. - @param key the key that should trigger the note - @param midiNoteOffsetFromC how many semitones above C the triggered note should - be. The actual midi note that gets played will be - this value + (12 * the current base octave). To change - the base octave, see setKeyPressBaseOctave() - */ - void setKeyPressForNote (const KeyPress& key, - const int midiNoteOffsetFromC); + This can be used to show a message with the tail of the speech bubble + pointing to a particular component or location on the screen. + + @see BubbleComponent +*/ +class JUCE_API BubbleMessageComponent : public BubbleComponent, + private Timer +{ +public: - /** Removes any key-mappings for a given note. + /** Creates a bubble component. - For a description of what the note number means, see setKeyPressForNote(). + After creating one a BubbleComponent, do the following: + - add it to an appropriate parent component, or put it on the + desktop with Component::addToDesktop (0). + - use the showAt() method to show a message. + - it will make itself invisible after it times-out (and can optionally + also delete itself), or you can reuse it somewhere else by calling + showAt() again. */ - void removeKeyPressForNote (const int midiNoteOffsetFromC); + BubbleMessageComponent (const int fadeOutLengthMs = 150); - /** Changes the base note above which key-press-triggered notes are played. + /** Destructor. */ + ~BubbleMessageComponent(); - The set of key-mappings that trigger notes can be moved up and down to cover - the entire scale using this method. + /** Shows a message bubble at a particular position. - The value passed in is an octave number between 0 and 10 (inclusive), and - indicates which C is the base note to which the key-mapped notes are - relative. - */ - void setKeyPressBaseOctave (const int newOctaveNumber); + This shows the bubble with its stem pointing to the given location + (co-ordinates being relative to its parent component). - /** This sets the octave number which is shown as the octave number for middle C. + For details about exactly how it decides where to position itself, see + BubbleComponent::updatePosition(). - This affects only the default implementation of getWhiteNoteText(), which - passes this octave number to MidiMessage::getMidiNoteName() in order to - get the note text. See MidiMessage::getMidiNoteName() for more info about - the parameter. + @param x the x co-ordinate of end of the bubble's tail + @param y the y co-ordinate of end of the bubble's tail + @param message the text to display + @param numMillisecondsBeforeRemoving how long to leave it on the screen before removing itself + from its parent compnent. If this is 0 or less, it + will stay there until manually removed. + @param removeWhenMouseClicked if this is true, the bubble will disappear as soon as a + mouse button is pressed (anywhere on the screen) + @param deleteSelfAfterUse if true, then the component will delete itself after + it becomes invisible + */ + void showAt (int x, int y, + const String& message, + const int numMillisecondsBeforeRemoving, + const bool removeWhenMouseClicked = true, + const bool deleteSelfAfterUse = false); - By default this value is set to 3. + /** Shows a message bubble next to a particular component. - @see getOctaveForMiddleC - */ - void setOctaveForMiddleC (const int octaveNumForMiddleC) throw(); + This shows the bubble with its stem pointing at the given component. - /** This returns the value set by setOctaveForMiddleC(). - @see setOctaveForMiddleC + For details about exactly how it decides where to position itself, see + BubbleComponent::updatePosition(). + + @param component the component that you want to point at + @param message the text to display + @param numMillisecondsBeforeRemoving how long to leave it on the screen before removing itself + from its parent compnent. If this is 0 or less, it + will stay there until manually removed. + @param removeWhenMouseClicked if this is true, the bubble will disappear as soon as a + mouse button is pressed (anywhere on the screen) + @param deleteSelfAfterUse if true, then the component will delete itself after + it becomes invisible */ - int getOctaveForMiddleC() const throw() { return octaveNumForMiddleC; } + void showAt (Component* const component, + const String& message, + const int numMillisecondsBeforeRemoving, + const bool removeWhenMouseClicked = true, + const bool deleteSelfAfterUse = false); /** @internal */ - void paint (Graphics& g); - /** @internal */ - void resized(); - /** @internal */ - void mouseMove (const MouseEvent& e); - /** @internal */ - void mouseDrag (const MouseEvent& e); - /** @internal */ - void mouseDown (const MouseEvent& e); - /** @internal */ - void mouseUp (const MouseEvent& e); - /** @internal */ - void mouseEnter (const MouseEvent& e); - /** @internal */ - void mouseExit (const MouseEvent& e); + void getContentSize (int& w, int& h); /** @internal */ - void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); + void paintContent (Graphics& g, int w, int h); /** @internal */ void timerCallback(); - /** @internal */ - bool keyStateChanged (const bool isKeyDown); - /** @internal */ - void focusLost (FocusChangeType cause); - /** @internal */ - void handleNoteOn (MidiKeyboardState* source, int midiChannel, int midiNoteNumber, float velocity); - /** @internal */ - void handleNoteOff (MidiKeyboardState* source, int midiChannel, int midiNoteNumber); - /** @internal */ - void handleAsyncUpdate(); - /** @internal */ - void colourChanged(); juce_UseDebuggingNewOperator -protected: - friend class MidiKeyboardUpDownButton; +private: + int fadeOutLength, mouseClickCounter; + TextLayout textLayout; + int64 expiryTime; + bool deleteAfterUse; - /** Draws a white note in the given rectangle. + void init (const int numMillisecondsBeforeRemoving, + const bool removeWhenMouseClicked, + const bool deleteSelfAfterUse); - isOver indicates whether the mouse is over the key, isDown indicates whether the key is - currently pressed down. + BubbleMessageComponent (const BubbleMessageComponent&); + const BubbleMessageComponent& operator= (const BubbleMessageComponent&); +}; - When doing this, be sure to note the keyboard's orientation. - */ - virtual void drawWhiteNote (int midiNoteNumber, - Graphics& g, - int x, int y, int w, int h, - bool isDown, bool isOver, - const Colour& lineColour, - const Colour& textColour); +#endif // __JUCE_BUBBLEMESSAGECOMPONENT_JUCEHEADER__ +/********* End of inlined file: juce_BubbleMessageComponent.h *********/ - /** Draws a black note in the given rectangle. +#endif +#ifndef __JUCE_COLOURSELECTOR_JUCEHEADER__ - isOver indicates whether the mouse is over the key, isDown indicates whether the key is - currently pressed down. +/********* Start of inlined file: juce_ColourSelector.h *********/ +#ifndef __JUCE_COLOURSELECTOR_JUCEHEADER__ +#define __JUCE_COLOURSELECTOR_JUCEHEADER__ - When doing this, be sure to note the keyboard's orientation. - */ - virtual void drawBlackNote (int midiNoteNumber, - Graphics& g, - int x, int y, int w, int h, - bool isDown, bool isOver, - const Colour& noteFillColour); +/** + A component that lets the user choose a colour. - /** Allows text to be drawn on the white notes. + This shows RGB sliders and a colourspace that the user can pick colours from. - By default this is used to label the C in each octave, but could be used for other things. + This class is also a ChangeBroadcaster, so listeners can register to be told + when the colour changes. +*/ +class JUCE_API ColourSelector : public Component, + public ChangeBroadcaster, + protected SliderListener +{ +public: - @see setOctaveForMiddleC + /** Options for the type of selector to show. These are passed into the constructor. */ + enum ColourSelectorOptions + { + showAlphaChannel = 1 << 0, /**< if set, the colour's alpha channel can be changed as well as its RGB. */ + + showColourAtTop = 1 << 1, /**< if set, a swatch of the colour is shown at the top of the component. */ + showSliders = 1 << 2, /**< if set, RGB sliders are shown at the bottom of the component. */ + showColourspace = 1 << 3 /**< if set, a big HSV selector is shown. */ + }; + + /** Creates a ColourSelector object. + + The flags are a combination of values from the ColourSelectorOptions enum, specifying + which of the selector's features should be visible. + + The edgeGap value specifies the amount of space to leave around the edge. + + gapAroundColourSpaceComponent indicates how much of a gap to put around the + colourspace and hue selector components. */ - virtual const String getWhiteNoteText (const int midiNoteNumber); + ColourSelector (const int sectionsToShow = (showAlphaChannel | showColourAtTop | showSliders | showColourspace), + const int edgeGap = 4, + const int gapAroundColourSpaceComponent = 7); - /** Draws the up and down buttons that change the base note. */ - virtual void drawUpDownButton (Graphics& g, int w, int h, - const bool isMouseOver, - const bool isButtonPressed, - const bool movesOctavesUp); + /** Destructor. */ + ~ColourSelector(); - /** Callback when the mouse is clicked on a key. + /** Returns the colour that the user has currently selected. - You could use this to do things like handle right-clicks on keys, etc. + The ColourSelector class is also a ChangeBroadcaster, so listeners can + register to be told when the colour changes. - Return true if you want the click to trigger the note, or false if you - want to handle it yourself and not have the note played. + @see setCurrentColour + */ + const Colour getCurrentColour() const; - @see mouseDraggedToKey + /** Changes the colour that is currently being shown. */ - virtual bool mouseDownOnKey (int midiNoteNumber, const MouseEvent& e); + void setCurrentColour (const Colour& newColour); - /** Callback when the mouse is dragged from one key onto another. + /** Tells the selector how many preset colour swatches you want to have on the component. - @see mouseDownOnKey + To enable swatches, you'll need to override getNumSwatches(), getSwatchColour(), and + setSwatchColour(), to return the number of colours you want, and to set and retrieve + their values. */ - virtual void mouseDraggedToKey (int midiNoteNumber, const MouseEvent& e); + virtual int getNumSwatches() const; - /** Calculates the positon of a given midi-note. + /** Called by the selector to find out the colour of one of the swatches. - This can be overridden to create layouts with custom key-widths. + Your subclass should return the colour of the swatch with the given index. - @param midiNoteNumber the note to find - @param keyWidth the desired width in pixels of one key - see setKeyWidth() - @param x the x position of the left-hand edge of the key (this method - always works in terms of a horizontal keyboard) - @param w the width of the key + To enable swatches, you'll need to override getNumSwatches(), getSwatchColour(), and + setSwatchColour(), to return the number of colours you want, and to set and retrieve + their values. */ - virtual void getKeyPosition (int midiNoteNumber, float keyWidth, - int& x, int& w) const; + virtual const Colour getSwatchColour (const int index) const; -private: + /** Called by the selector when the user puts a new colour into one of the swatches. - MidiKeyboardState& state; - int xOffset, blackNoteLength; - float keyWidth; - Orientation orientation; + Your subclass should change the colour of the swatch with the given index. - int midiChannel, midiInChannelMask; - float velocity; - int noteUnderMouse, mouseDownNote; - BitArray keysPressed, keysCurrentlyDrawnDown; + To enable swatches, you'll need to override getNumSwatches(), getSwatchColour(), and + setSwatchColour(), to return the number of colours you want, and to set and retrieve + their values. + */ + virtual void setSwatchColour (const int index, const Colour& newColour) const; - int rangeStart, rangeEnd, firstKey; - bool canScroll, mouseDragging; - Button* scrollDown; - Button* scrollUp; + /** A set of colour IDs to use to change the colour of various aspects of the keyboard. - Array keyPresses; - Array keyPressNotes; - int keyMappingOctave; - int octaveNumForMiddleC; + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. - void getKeyPos (int midiNoteNumber, int& x, int& w) const; - int xyToNote (int x, int y); - int remappedXYToNote (int x, int y) const; - void resetAnyKeysInUse(); - void updateNoteUnderMouse (int x, int y); - void repaintNote (const int midiNoteNumber); + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + backgroundColourId = 0x1007000, /**< the colour used to fill the component's background. */ + labelTextColourId = 0x1007001 /**< the colour used for the labels next to the sliders. */ + }; - MidiKeyboardComponent (const MidiKeyboardComponent&); - const MidiKeyboardComponent& operator= (const MidiKeyboardComponent&); + juce_UseDebuggingNewOperator + +private: + friend class ColourSpaceView; + friend class HueSelectorComp; + Colour colour; + float h, s, v; + Slider* sliders[4]; + Component* colourSpace; + Component* hueSelector; + VoidArray swatchComponents; + const int flags; + int topSpace, edgeGap; + + void setHue (float newH); + void setSV (float newS, float newV); + void updateHSV(); + void update(); + void sliderValueChanged (Slider*); + void paint (Graphics& g); + void resized(); + + ColourSelector (const ColourSelector&); + const ColourSelector& operator= (const ColourSelector&); + + // this constructor is here temporarily to prevent old code compiling, because the parameters + // have changed - if you get an error here, update your code to use the new constructor instead.. + // (xxx - note to self: remember to remove this at some point in the future) + ColourSelector (const bool); }; -#endif // __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ -/********* End of inlined file: juce_MidiKeyboardComponent.h *********/ +#endif // __JUCE_COLOURSELECTOR_JUCEHEADER__ +/********* End of inlined file: juce_ColourSelector.h *********/ + +#endif +#ifndef __JUCE_DROPSHADOWER_JUCEHEADER__ #endif #ifndef __JUCE_NSVIEWCOMPONENT_JUCEHEADER__ @@ -53316,107 +52839,299 @@ private: each button having an icon above its name. Clicking these will show an appropriate prefs page below it. - You can either put one of these inside your own component, or just use the - showInDialogBox() method to show it in a window and run it modally. + You can either put one of these inside your own component, or just use the + showInDialogBox() method to show it in a window and run it modally. + + To use it, just add a set of named pages with the addSettingsPage() method, + and implement the createComponentForPage() method to create suitable components + for each of these pages. +*/ +class JUCE_API PreferencesPanel : public Component, + private ButtonListener +{ +public: + + /** Creates an empty panel. + + Use addSettingsPage() to add some pages to it in your constructor. + */ + PreferencesPanel(); + + /** Destructor. */ + ~PreferencesPanel(); + + /** Creates a page using a set of drawables to define the page's icon. + + Note that the other version of this method is much easier if you're using + an image instead of a custom drawable. + + @param pageTitle the name of this preferences page - you'll need to + make sure your createComponentForPage() method creates + a suitable component when it is passed this name + @param normalIcon the drawable to display in the page's button normally + @param overIcon the drawable to display in the page's button when the mouse is over + @param downIcon the drawable to display in the page's button when the button is down + @see DrawableButton + */ + void addSettingsPage (const String& pageTitle, + const Drawable* normalIcon, + const Drawable* overIcon, + const Drawable* downIcon); + + /** Creates a page using a set of drawables to define the page's icon. + + The other version of this method gives you more control over the icon, but this + one is much easier if you're just loading it from a file. + + @param pageTitle the name of this preferences page - you'll need to + make sure your createComponentForPage() method creates + a suitable component when it is passed this name + @param imageData a block of data containing an image file, e.g. a jpeg, png or gif. + For this to look good, you'll probably want to use a nice + transparent png file. + @param imageDataSize the size of the image data, in bytes + */ + void addSettingsPage (const String& pageTitle, + const char* imageData, + const int imageDataSize); + + /** Utility method to display this panel in a DialogWindow. + + Calling this will create a DialogWindow containing this panel with the + given size and title, and will run it modally, returning when the user + closes the dialog box. + */ + void showInDialogBox (const String& dialogtitle, + int dialogWidth, + int dialogHeight, + const Colour& backgroundColour = Colours::white); + + /** Subclasses must override this to return a component for each preferences page. + + The subclass should return a pointer to a new component representing the named + page, which the panel will then display. + + The panel will delete the component later when the user goes to another page + or deletes the panel. + */ + virtual Component* createComponentForPage (const String& pageName) = 0; + + /** Changes the current page being displayed. */ + void setCurrentPage (const String& pageName); + + /** @internal */ + void resized(); + /** @internal */ + void paint (Graphics& g); + /** @internal */ + void buttonClicked (Button* button); + + juce_UseDebuggingNewOperator + +private: + + String currentPageName; + Component* currentPage; + int buttonSize; + + PreferencesPanel (const PreferencesPanel&); + const PreferencesPanel& operator= (const PreferencesPanel&); +}; + +#endif // __JUCE_PREFERENCESPANEL_JUCEHEADER__ +/********* End of inlined file: juce_PreferencesPanel.h *********/ + +#endif +#ifndef __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ + +/********* Start of inlined file: juce_MagnifierComponent.h *********/ +#ifndef __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ +#define __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ + +/** + A component that contains another component, and can magnify or shrink it. + + This component will continually update its size so that it fits the zoomed + version of the content component that you put inside it, so don't try to + change the size of this component directly - instead change that of the + content component. + + To make it all work, the magnifier uses extremely cunning ComponentPeer tricks + to remap mouse events correctly. This means that the content component won't + appear to be a direct child of this component, and instead will think its + on the desktop. +*/ +class JUCE_API MagnifierComponent : public Component +{ +public: + + /** Creates a MagnifierComponent. + + This component will continually update its size so that it fits the zoomed + version of the content component that you put inside it, so don't try to + change the size of this component directly - instead change that of the + content component. + + @param contentComponent the component to add as the magnified one + @param deleteContentCompWhenNoLongerNeeded if true, the content component will + be deleted when this component is deleted. If false, + it's the caller's responsibility to delete it later. + */ + MagnifierComponent (Component* const contentComponent, + const bool deleteContentCompWhenNoLongerNeeded); + + /** Destructor. */ + ~MagnifierComponent(); + + /** Returns the current content component. */ + Component* getContentComponent() const throw() { return content; } + + /** Changes the zoom level. + + The scale factor must be greater than zero. Values less than 1 will shrink the + image; values greater than 1 will multiply its size by this amount. + + When this is called, this component will change its size to fit the full extent + of the newly zoomed content. + */ + void setScaleFactor (double newScaleFactor); + + /** Returns the current zoom factor. */ + double getScaleFactor() const throw() { return scaleFactor; } + + /** Changes the quality setting used to rescale the graphics. + */ + void setResamplingQuality (Graphics::ResamplingQuality newQuality); + + juce_UseDebuggingNewOperator + + /** @internal */ + void childBoundsChanged (Component*); + +private: + Component* content; + Component* holderComp; + double scaleFactor; + ComponentPeer* peer; + bool deleteContent; + Graphics::ResamplingQuality quality; + + void paint (Graphics& g); + void mouseDown (const MouseEvent& e); + void mouseUp (const MouseEvent& e); + void mouseDrag (const MouseEvent& e); + void mouseMove (const MouseEvent& e); + void mouseEnter (const MouseEvent& e); + void mouseExit (const MouseEvent& e); + void mouseWheelMove (const MouseEvent& e, float, float); + + int scaleInt (const int n) const throw(); + + MagnifierComponent (const MagnifierComponent&); + const MagnifierComponent& operator= (const MagnifierComponent&); +}; + +#endif // __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ +/********* End of inlined file: juce_MagnifierComponent.h *********/ + +#endif +#ifndef __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ + +/********* Start of inlined file: juce_WebBrowserComponent.h *********/ +#ifndef __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ +#define __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ + +#if JUCE_WEB_BROWSER + +class WebBrowserComponentInternal; + +/** + A component that displays an embedded web browser. + + The browser itself will be platform-dependent. On the Mac, probably Safari, on + Windows, probably IE. - To use it, just add a set of named pages with the addSettingsPage() method, - and implement the createComponentForPage() method to create suitable components - for each of these pages. */ -class JUCE_API PreferencesPanel : public Component, - private ButtonListener +class JUCE_API WebBrowserComponent : public Component { public: - /** Creates an empty panel. + /** Creates a WebBrowserComponent. - Use addSettingsPage() to add some pages to it in your constructor. + Once it's created and visible, send the browser to a URL using goToURL(). */ - PreferencesPanel(); + WebBrowserComponent(); /** Destructor. */ - ~PreferencesPanel(); - - /** Creates a page using a set of drawables to define the page's icon. + ~WebBrowserComponent(); - Note that the other version of this method is much easier if you're using - an image instead of a custom drawable. + /** Sends the browser to a particular URL. - @param pageTitle the name of this preferences page - you'll need to - make sure your createComponentForPage() method creates - a suitable component when it is passed this name - @param normalIcon the drawable to display in the page's button normally - @param overIcon the drawable to display in the page's button when the mouse is over - @param downIcon the drawable to display in the page's button when the button is down - @see DrawableButton + @param url the URL to go to. + @param headers an optional set of parameters to put in the HTTP header. If + you supply this, it should be a set of string in the form + "HeaderKey: HeaderValue" + @param postData an optional block of data that will be attached to the HTTP + POST request */ - void addSettingsPage (const String& pageTitle, - const Drawable* normalIcon, - const Drawable* overIcon, - const Drawable* downIcon); - - /** Creates a page using a set of drawables to define the page's icon. - - The other version of this method gives you more control over the icon, but this - one is much easier if you're just loading it from a file. + void goToURL (const String& url, + const StringArray* headers = 0, + const MemoryBlock* postData = 0); - @param pageTitle the name of this preferences page - you'll need to - make sure your createComponentForPage() method creates - a suitable component when it is passed this name - @param imageData a block of data containing an image file, e.g. a jpeg, png or gif. - For this to look good, you'll probably want to use a nice - transparent png file. - @param imageDataSize the size of the image data, in bytes + /** Stops the current page loading. */ - void addSettingsPage (const String& pageTitle, - const char* imageData, - const int imageDataSize); + void stop(); - /** Utility method to display this panel in a DialogWindow. + /** Sends the browser back one page. + */ + void goBack(); - Calling this will create a DialogWindow containing this panel with the - given size and title, and will run it modally, returning when the user - closes the dialog box. + /** Sends the browser forward one page. */ - void showInDialogBox (const String& dialogtitle, - int dialogWidth, - int dialogHeight, - const Colour& backgroundColour = Colours::white); + void goForward(); - /** Subclasses must override this to return a component for each preferences page. + /** Refreshes the browser. + */ + void refresh(); - The subclass should return a pointer to a new component representing the named - page, which the panel will then display. + /** This callback is called when the browser is about to navigate + to a new location. - The panel will delete the component later when the user goes to another page - or deletes the panel. + You can override this method to perform some action when the user + tries to go to a particular URL. To allow the operation to carry on, + return true, or return false to stop the navigation happening. */ - virtual Component* createComponentForPage (const String& pageName) = 0; - - /** Changes the current page being displayed. */ - void setCurrentPage (const String& pageName); + virtual bool pageAboutToLoad (const String& newURL); + /** @internal */ + void paint (Graphics& g); /** @internal */ void resized(); /** @internal */ - void paint (Graphics& g); + void parentHierarchyChanged(); /** @internal */ - void buttonClicked (Button* button); + void visibilityChanged(); juce_UseDebuggingNewOperator private: + WebBrowserComponentInternal* browser; + bool blankPageShown; - String currentPageName; - Component* currentPage; - int buttonSize; + String lastURL; + StringArray lastHeaders; + MemoryBlock lastPostData; - PreferencesPanel (const PreferencesPanel&); - const PreferencesPanel& operator= (const PreferencesPanel&); + void reloadLastURL(); + void checkWindowAssociation(); + + WebBrowserComponent (const WebBrowserComponent&); + const WebBrowserComponent& operator= (const WebBrowserComponent&); }; -#endif // __JUCE_PREFERENCESPANEL_JUCEHEADER__ -/********* End of inlined file: juce_PreferencesPanel.h *********/ +#endif +#endif // __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ +/********* End of inlined file: juce_WebBrowserComponent.h *********/ #endif #ifndef __JUCE_QUICKTIMEMOVIECOMPONENT_JUCEHEADER__ @@ -53652,103 +53367,388 @@ private: /********* End of inlined file: juce_SystemTrayIconComponent.h *********/ #endif -#ifndef __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ +#ifndef __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ -/********* Start of inlined file: juce_WebBrowserComponent.h *********/ -#ifndef __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ -#define __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ +/********* Start of inlined file: juce_MidiKeyboardComponent.h *********/ +#ifndef __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ +#define __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ -#if JUCE_WEB_BROWSER +/** + A component that displays a piano keyboard, whose notes can be clicked on. -class WebBrowserComponentInternal; + This component will mimic a physical midi keyboard, showing the current state of + a MidiKeyboardState object. When the on-screen keys are clicked on, it will play these + notes by calling the noteOn() and noteOff() methods of its MidiKeyboardState object. -/** - A component that displays an embedded web browser. + Another feature is that the computer keyboard can also be used to play notes. By + default it maps the top two rows of a standard querty keyboard to the notes, but + these can be remapped if needed. It will only respond to keypresses when it has + the keyboard focus, so to disable this feature you can call setWantsKeyboardFocus (false). - The browser itself will be platform-dependent. On the Mac, probably Safari, on - Windows, probably IE. + The component is also a ChangeBroadcaster, so if you want to be informed when the + keyboard is scrolled, you can register a ChangeListener for callbacks. + @see MidiKeyboardState */ -class JUCE_API WebBrowserComponent : public Component +class JUCE_API MidiKeyboardComponent : public Component, + public MidiKeyboardStateListener, + public ChangeBroadcaster, + private Timer, + private AsyncUpdater { public: - /** Creates a WebBrowserComponent. + /** The direction of the keyboard. - Once it's created and visible, send the browser to a URL using goToURL(). + @see setOrientation */ - WebBrowserComponent(); + enum Orientation + { + horizontalKeyboard, + verticalKeyboardFacingLeft, + verticalKeyboardFacingRight, + }; + + /** Creates a MidiKeyboardComponent. + + @param state the midi keyboard model that this component will represent + @param orientation whether the keyboard is horizonal or vertical + */ + MidiKeyboardComponent (MidiKeyboardState& state, + const Orientation orientation); /** Destructor. */ - ~WebBrowserComponent(); + ~MidiKeyboardComponent(); - /** Sends the browser to a particular URL. + /** Changes the velocity used in midi note-on messages that are triggered by clicking + on the component. - @param url the URL to go to. - @param headers an optional set of parameters to put in the HTTP header. If - you supply this, it should be a set of string in the form - "HeaderKey: HeaderValue" - @param postData an optional block of data that will be attached to the HTTP - POST request + Values are 0 to 1.0, where 1.0 is the heaviest. + + @see setMidiChannel */ - void goToURL (const String& url, - const StringArray* headers = 0, - const MemoryBlock* postData = 0); + void setVelocity (const float velocity); - /** Stops the current page loading. + /** Changes the midi channel number that will be used for events triggered by clicking + on the component. + + The channel must be between 1 and 16 (inclusive). This is the channel that will be + passed on to the MidiKeyboardState::noteOn() method when the user clicks the component. + + Although this is the channel used for outgoing events, the component can display + incoming events from more than one channel - see setMidiChannelsToDisplay() + + @see setVelocity */ - void stop(); + void setMidiChannel (const int midiChannelNumber); - /** Sends the browser back one page. + /** Returns the midi channel that the keyboard is using for midi messages. + + @see setMidiChannel */ - void goBack(); + int getMidiChannel() const throw() { return midiChannel; } - /** Sends the browser forward one page. + /** Sets a mask to indicate which incoming midi channels should be represented by + key movements. + + The mask is a set of bits, where bit 0 = midi channel 1, bit 1 = midi channel 2, etc. + + If the MidiKeyboardState has a key down for any of the channels whose bits are set + in this mask, the on-screen keys will also go down. + + By default, this mask is set to 0xffff (all channels displayed). + + @see setMidiChannel */ - void goForward(); + void setMidiChannelsToDisplay (const int midiChannelMask); - /** Refreshes the browser. + /** Returns the current set of midi channels represented by the component. + + This is the value that was set with setMidiChannelsToDisplay(). */ - void refresh(); + int getMidiChannelsToDisplay() const throw() { return midiInChannelMask; } - /** This callback is called when the browser is about to navigate - to a new location. + /** Changes the width used to draw the white keys. */ + void setKeyWidth (const float widthInPixels); - You can override this method to perform some action when the user - tries to go to a particular URL. To allow the operation to carry on, - return true, or return false to stop the navigation happening. + /** Returns the width that was set by setKeyWidth(). */ + float getKeyWidth() const throw() { return keyWidth; } + + /** Changes the keyboard's current direction. */ + void setOrientation (const Orientation newOrientation); + + /** Returns the keyboard's current direction. */ + const Orientation getOrientation() const throw() { return orientation; } + + /** Sets the range of midi notes that the keyboard will be limited to. + + By default the range is 0 to 127 (inclusive), but you can limit this if you + only want a restricted set of the keys to be shown. + + Note that the values here are inclusive and must be between 0 and 127. */ - virtual bool pageAboutToLoad (const String& newURL); + void setAvailableRange (const int lowestNote, + const int highestNote); + + /** Returns the first note in the available range. + + @see setAvailableRange + */ + int getRangeStart() const throw() { return rangeStart; } + + /** Returns the last note in the available range. + + @see setAvailableRange + */ + int getRangeEnd() const throw() { return rangeEnd; } + + /** If the keyboard extends beyond the size of the component, this will scroll + it to show the given key at the start. + + Whenever the keyboard's position is changed, this will use the ChangeBroadcaster + base class to send a callback to any ChangeListeners that have been registered. + */ + void setLowestVisibleKey (int noteNumber); + + /** Returns the number of the first key shown in the component. + + @see setLowestVisibleKey + */ + int getLowestVisibleKey() const throw() { return firstKey; } + + /** Returns the length of the black notes. + + This will be their vertical or horizontal length, depending on the keyboard's orientation. + */ + int getBlackNoteLength() const throw() { return blackNoteLength; } + + /** If set to true, then scroll buttons will appear at either end of the keyboard + if there are too many notes to fit them all in the component at once. + */ + void setScrollButtonsVisible (const bool canScroll); + + /** A set of colour IDs to use to change the colour of various aspects of the keyboard. + + These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() + methods. + + @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour + */ + enum ColourIds + { + whiteNoteColourId = 0x1005000, + blackNoteColourId = 0x1005001, + keySeparatorLineColourId = 0x1005002, + mouseOverKeyOverlayColourId = 0x1005003, /**< This colour will be overlaid on the normal note colour. */ + keyDownOverlayColourId = 0x1005004, /**< This colour will be overlaid on the normal note colour. */ + textLabelColourId = 0x1005005, + upDownButtonBackgroundColourId = 0x1005006, + upDownButtonArrowColourId = 0x1005007 + }; + + /** Returns the position within the component of the left-hand edge of a key. + + Depending on the keyboard's orientation, this may be a horizontal or vertical + distance, in either direction. + */ + int getKeyStartPosition (const int midiNoteNumber) const; + + /** Deletes all key-mappings. + + @see setKeyPressForNote + */ + void clearKeyMappings(); + + /** Maps a key-press to a given note. + + @param key the key that should trigger the note + @param midiNoteOffsetFromC how many semitones above C the triggered note should + be. The actual midi note that gets played will be + this value + (12 * the current base octave). To change + the base octave, see setKeyPressBaseOctave() + */ + void setKeyPressForNote (const KeyPress& key, + const int midiNoteOffsetFromC); + + /** Removes any key-mappings for a given note. + + For a description of what the note number means, see setKeyPressForNote(). + */ + void removeKeyPressForNote (const int midiNoteOffsetFromC); + + /** Changes the base note above which key-press-triggered notes are played. + + The set of key-mappings that trigger notes can be moved up and down to cover + the entire scale using this method. + + The value passed in is an octave number between 0 and 10 (inclusive), and + indicates which C is the base note to which the key-mapped notes are + relative. + */ + void setKeyPressBaseOctave (const int newOctaveNumber); + + /** This sets the octave number which is shown as the octave number for middle C. + + This affects only the default implementation of getWhiteNoteText(), which + passes this octave number to MidiMessage::getMidiNoteName() in order to + get the note text. See MidiMessage::getMidiNoteName() for more info about + the parameter. + + By default this value is set to 3. + + @see getOctaveForMiddleC + */ + void setOctaveForMiddleC (const int octaveNumForMiddleC) throw(); + + /** This returns the value set by setOctaveForMiddleC(). + @see setOctaveForMiddleC + */ + int getOctaveForMiddleC() const throw() { return octaveNumForMiddleC; } /** @internal */ void paint (Graphics& g); /** @internal */ void resized(); /** @internal */ - void parentHierarchyChanged(); + void mouseMove (const MouseEvent& e); /** @internal */ - void visibilityChanged(); + void mouseDrag (const MouseEvent& e); + /** @internal */ + void mouseDown (const MouseEvent& e); + /** @internal */ + void mouseUp (const MouseEvent& e); + /** @internal */ + void mouseEnter (const MouseEvent& e); + /** @internal */ + void mouseExit (const MouseEvent& e); + /** @internal */ + void mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY); + /** @internal */ + void timerCallback(); + /** @internal */ + bool keyStateChanged (const bool isKeyDown); + /** @internal */ + void focusLost (FocusChangeType cause); + /** @internal */ + void handleNoteOn (MidiKeyboardState* source, int midiChannel, int midiNoteNumber, float velocity); + /** @internal */ + void handleNoteOff (MidiKeyboardState* source, int midiChannel, int midiNoteNumber); + /** @internal */ + void handleAsyncUpdate(); + /** @internal */ + void colourChanged(); juce_UseDebuggingNewOperator +protected: + friend class MidiKeyboardUpDownButton; + + /** Draws a white note in the given rectangle. + + isOver indicates whether the mouse is over the key, isDown indicates whether the key is + currently pressed down. + + When doing this, be sure to note the keyboard's orientation. + */ + virtual void drawWhiteNote (int midiNoteNumber, + Graphics& g, + int x, int y, int w, int h, + bool isDown, bool isOver, + const Colour& lineColour, + const Colour& textColour); + + /** Draws a black note in the given rectangle. + + isOver indicates whether the mouse is over the key, isDown indicates whether the key is + currently pressed down. + + When doing this, be sure to note the keyboard's orientation. + */ + virtual void drawBlackNote (int midiNoteNumber, + Graphics& g, + int x, int y, int w, int h, + bool isDown, bool isOver, + const Colour& noteFillColour); + + /** Allows text to be drawn on the white notes. + + By default this is used to label the C in each octave, but could be used for other things. + + @see setOctaveForMiddleC + */ + virtual const String getWhiteNoteText (const int midiNoteNumber); + + /** Draws the up and down buttons that change the base note. */ + virtual void drawUpDownButton (Graphics& g, int w, int h, + const bool isMouseOver, + const bool isButtonPressed, + const bool movesOctavesUp); + + /** Callback when the mouse is clicked on a key. + + You could use this to do things like handle right-clicks on keys, etc. + + Return true if you want the click to trigger the note, or false if you + want to handle it yourself and not have the note played. + + @see mouseDraggedToKey + */ + virtual bool mouseDownOnKey (int midiNoteNumber, const MouseEvent& e); + + /** Callback when the mouse is dragged from one key onto another. + + @see mouseDownOnKey + */ + virtual void mouseDraggedToKey (int midiNoteNumber, const MouseEvent& e); + + /** Calculates the positon of a given midi-note. + + This can be overridden to create layouts with custom key-widths. + + @param midiNoteNumber the note to find + @param keyWidth the desired width in pixels of one key - see setKeyWidth() + @param x the x position of the left-hand edge of the key (this method + always works in terms of a horizontal keyboard) + @param w the width of the key + */ + virtual void getKeyPosition (int midiNoteNumber, float keyWidth, + int& x, int& w) const; + private: - WebBrowserComponentInternal* browser; - bool blankPageShown; - String lastURL; - StringArray lastHeaders; - MemoryBlock lastPostData; + MidiKeyboardState& state; + int xOffset, blackNoteLength; + float keyWidth; + Orientation orientation; - void reloadLastURL(); - void checkWindowAssociation(); + int midiChannel, midiInChannelMask; + float velocity; + int noteUnderMouse, mouseDownNote; + BitArray keysPressed, keysCurrentlyDrawnDown; - WebBrowserComponent (const WebBrowserComponent&); - const WebBrowserComponent& operator= (const WebBrowserComponent&); + int rangeStart, rangeEnd, firstKey; + bool canScroll, mouseDragging; + Button* scrollDown; + Button* scrollUp; + + Array keyPresses; + Array keyPressNotes; + int keyMappingOctave; + int octaveNumForMiddleC; + + void getKeyPos (int midiNoteNumber, int& x, int& w) const; + int xyToNote (int x, int y); + int remappedXYToNote (int x, int y) const; + void resetAnyKeysInUse(); + void updateNoteUnderMouse (int x, int y); + void repaintNote (const int midiNoteNumber); + + MidiKeyboardComponent (const MidiKeyboardComponent&); + const MidiKeyboardComponent& operator= (const MidiKeyboardComponent&); }; -#endif -#endif // __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ -/********* End of inlined file: juce_WebBrowserComponent.h *********/ +#endif // __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ +/********* End of inlined file: juce_MidiKeyboardComponent.h *********/ #endif #ifndef __JUCE_LOOKANDFEEL_JUCEHEADER__ diff --git a/src/juce_app_includes.h b/src/juce_app_includes.h index aaed892846..1be5a757da 100644 --- a/src/juce_app_includes.h +++ b/src/juce_app_includes.h @@ -38,6 +38,9 @@ #ifndef __JUCE_APPLICATIONCOMMANDID_JUCEHEADER__ #include "juce_appframework/application/juce_ApplicationCommandID.h" #endif +#ifndef __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ + #include "juce_appframework/application/juce_DeletedAtShutdown.h" +#endif #ifndef __JUCE_APPLICATIONCOMMANDINFO_JUCEHEADER__ #include "juce_appframework/application/juce_ApplicationCommandInfo.h" #endif @@ -50,9 +53,6 @@ #ifndef __JUCE_APPLICATIONPROPERTIES_JUCEHEADER__ #include "juce_appframework/application/juce_ApplicationProperties.h" #endif -#ifndef __JUCE_DELETEDATSHUTDOWN_JUCEHEADER__ - #include "juce_appframework/application/juce_DeletedAtShutdown.h" -#endif #ifndef __JUCE_PROPERTIESFILE_JUCEHEADER__ #include "juce_appframework/application/juce_PropertiesFile.h" #endif @@ -71,12 +71,12 @@ #ifndef __JUCE_MIDIMESSAGE_JUCEHEADER__ #include "juce_appframework/audio/midi/juce_MidiMessage.h" #endif -#ifndef __JUCE_MIDIMESSAGECOLLECTOR_JUCEHEADER__ - #include "juce_appframework/audio/midi/juce_MidiMessageCollector.h" -#endif #ifndef __JUCE_MIDIMESSAGESEQUENCE_JUCEHEADER__ #include "juce_appframework/audio/midi/juce_MidiMessageSequence.h" #endif +#ifndef __JUCE_MIDIMESSAGECOLLECTOR_JUCEHEADER__ + #include "juce_appframework/audio/midi/juce_MidiMessageCollector.h" +#endif #ifndef __JUCE_AUDIODATACONVERTERS_JUCEHEADER__ #include "juce_appframework/audio/dsp/juce_AudioDataConverters.h" #endif @@ -95,12 +95,12 @@ #ifndef __JUCE_AUDIOPROCESSOREDITOR_JUCEHEADER__ #include "juce_appframework/audio/processors/juce_AudioProcessorEditor.h" #endif -#ifndef __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ - #include "juce_appframework/audio/processors/juce_AudioProcessorGraph.h" -#endif #ifndef __JUCE_AUDIOPROCESSORLISTENER_JUCEHEADER__ #include "juce_appframework/audio/processors/juce_AudioProcessorListener.h" #endif +#ifndef __JUCE_AUDIOPROCESSORGRAPH_JUCEHEADER__ + #include "juce_appframework/audio/processors/juce_AudioProcessorGraph.h" +#endif #ifndef __JUCE_AUDIOPROCESSORPLAYER_JUCEHEADER__ #include "juce_appframework/audio/processors/juce_AudioProcessorPlayer.h" #endif @@ -140,21 +140,21 @@ #ifndef __JUCE_TONEGENERATORAUDIOSOURCE_JUCEHEADER__ #include "juce_appframework/audio/audio_sources/juce_ToneGeneratorAudioSource.h" #endif -#ifndef __JUCE_AUDIODEVICEMANAGER_JUCEHEADER__ - #include "juce_appframework/audio/devices/juce_AudioDeviceManager.h" -#endif #ifndef __JUCE_AUDIOIODEVICE_JUCEHEADER__ #include "juce_appframework/audio/devices/juce_AudioIODevice.h" #endif -#ifndef __JUCE_AUDIOIODEVICETYPE_JUCEHEADER__ - #include "juce_appframework/audio/devices/juce_AudioIODeviceType.h" -#endif #ifndef __JUCE_MIDIINPUT_JUCEHEADER__ #include "juce_appframework/audio/devices/juce_MidiInput.h" #endif +#ifndef __JUCE_AUDIODEVICEMANAGER_JUCEHEADER__ + #include "juce_appframework/audio/devices/juce_AudioDeviceManager.h" +#endif #ifndef __JUCE_MIDIOUTPUT_JUCEHEADER__ #include "juce_appframework/audio/devices/juce_MidiOutput.h" #endif +#ifndef __JUCE_AUDIOIODEVICETYPE_JUCEHEADER__ + #include "juce_appframework/audio/devices/juce_AudioIODeviceType.h" +#endif #ifndef __JUCE_SAMPLER_JUCEHEADER__ #include "juce_appframework/audio/synthesisers/juce_Sampler.h" #endif @@ -203,24 +203,15 @@ #ifndef __JUCE_AUDIOCDBURNER_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_AudioCDBurner.h" #endif -#ifndef __JUCE_AUDIOCDREADER_JUCEHEADER__ - #include "juce_appframework/audio/audio_file_formats/juce_AudioCDReader.h" -#endif #ifndef __JUCE_AUDIOFORMAT_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_AudioFormat.h" #endif #ifndef __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_AudioFormatManager.h" #endif -#ifndef __JUCE_AUDIOFORMATREADER_JUCEHEADER__ - #include "juce_appframework/audio/audio_file_formats/juce_AudioFormatReader.h" -#endif #ifndef __JUCE_AUDIOFORMATWRITER_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_AudioFormatWriter.h" #endif -#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ - #include "juce_appframework/audio/audio_file_formats/juce_AudioSubsectionReader.h" -#endif #ifndef __JUCE_AUDIOTHUMBNAIL_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_AudioThumbnail.h" #endif @@ -230,14 +221,23 @@ #ifndef __JUCE_FLACAUDIOFORMAT_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_FlacAudioFormat.h" #endif +#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ + #include "juce_appframework/audio/audio_file_formats/juce_WavAudioFormat.h" +#endif #ifndef __JUCE_OGGVORBISAUDIOFORMAT_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_OggVorbisAudioFormat.h" #endif +#ifndef __JUCE_AUDIOFORMATREADER_JUCEHEADER__ + #include "juce_appframework/audio/audio_file_formats/juce_AudioFormatReader.h" +#endif +#ifndef __JUCE_AUDIOCDREADER_JUCEHEADER__ + #include "juce_appframework/audio/audio_file_formats/juce_AudioCDReader.h" +#endif #ifndef __JUCE_QUICKTIMEAUDIOFORMAT_JUCEHEADER__ #include "juce_appframework/audio/audio_file_formats/juce_QuickTimeAudioFormat.h" #endif -#ifndef __JUCE_WAVAUDIOFORMAT_JUCEHEADER__ - #include "juce_appframework/audio/audio_file_formats/juce_WavAudioFormat.h" +#ifndef __JUCE_AUDIOSUBSECTIONREADER_JUCEHEADER__ + #include "juce_appframework/audio/audio_file_formats/juce_AudioSubsectionReader.h" #endif #ifndef __JUCE_ACTIONBROADCASTER_JUCEHEADER__ #include "juce_appframework/events/juce_ActionBroadcaster.h" @@ -275,15 +275,15 @@ #ifndef __JUCE_MESSAGELISTENER_JUCEHEADER__ #include "juce_appframework/events/juce_MessageListener.h" #endif -#ifndef __JUCE_MESSAGEMANAGER_JUCEHEADER__ - #include "juce_appframework/events/juce_MessageManager.h" -#endif #ifndef __JUCE_MULTITIMER_JUCEHEADER__ #include "juce_appframework/events/juce_MultiTimer.h" #endif #ifndef __JUCE_TIMER_JUCEHEADER__ #include "juce_appframework/events/juce_Timer.h" #endif +#ifndef __JUCE_MESSAGEMANAGER_JUCEHEADER__ + #include "juce_appframework/events/juce_MessageManager.h" +#endif #ifndef __JUCE_BRUSH_JUCEHEADER__ #include "juce_appframework/gui/graphics/brushes/juce_Brush.h" #endif @@ -332,15 +332,15 @@ #ifndef __JUCE_LOWLEVELGRAPHICSCONTEXT_JUCEHEADER__ #include "juce_appframework/gui/graphics/contexts/juce_LowLevelGraphicsContext.h" #endif +#ifndef __JUCE_RECTANGLEPLACEMENT_JUCEHEADER__ + #include "juce_appframework/gui/graphics/contexts/juce_RectanglePlacement.h" +#endif #ifndef __JUCE_LOWLEVELGRAPHICSPOSTSCRIPTRENDERER_JUCEHEADER__ #include "juce_appframework/gui/graphics/contexts/juce_LowLevelGraphicsPostScriptRenderer.h" #endif #ifndef __JUCE_LOWLEVELGRAPHICSSOFTWARERENDERER_JUCEHEADER__ #include "juce_appframework/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.h" #endif -#ifndef __JUCE_RECTANGLEPLACEMENT_JUCEHEADER__ - #include "juce_appframework/gui/graphics/contexts/juce_RectanglePlacement.h" -#endif #ifndef __JUCE_AFFINETRANSFORM_JUCEHEADER__ #include "juce_appframework/gui/graphics/geometry/juce_AffineTransform.h" #endif @@ -371,9 +371,6 @@ #ifndef __JUCE_RECTANGLELIST_JUCEHEADER__ #include "juce_appframework/gui/graphics/geometry/juce_RectangleList.h" #endif -#ifndef __JUCE_CAMERADEVICE_JUCEHEADER__ - #include "juce_appframework/gui/graphics/imaging/juce_CameraDevice.h" -#endif #ifndef __JUCE_IMAGE_JUCEHEADER__ #include "juce_appframework/gui/graphics/imaging/juce_Image.h" #endif @@ -383,6 +380,9 @@ #ifndef __JUCE_IMAGECONVOLUTIONKERNEL_JUCEHEADER__ #include "juce_appframework/gui/graphics/imaging/juce_ImageConvolutionKernel.h" #endif +#ifndef __JUCE_CAMERADEVICE_JUCEHEADER__ + #include "juce_appframework/gui/graphics/imaging/juce_CameraDevice.h" +#endif #ifndef __JUCE_IMAGEFILEFORMAT_JUCEHEADER__ #include "juce_appframework/gui/graphics/imaging/juce_ImageFileFormat.h" #endif @@ -401,9 +401,6 @@ #ifndef __JUCE_DRAWABLETEXT_JUCEHEADER__ #include "juce_appframework/gui/graphics/drawables/juce_DrawableText.h" #endif -#ifndef __JUCE_COMPONENT_JUCEHEADER__ - #include "juce_appframework/gui/components/juce_Component.h" -#endif #ifndef __JUCE_COMPONENTDELETIONWATCHER_JUCEHEADER__ #include "juce_appframework/gui/components/juce_ComponentDeletionWatcher.h" #endif @@ -413,12 +410,12 @@ #ifndef __JUCE_DESKTOP_JUCEHEADER__ #include "juce_appframework/gui/components/juce_Desktop.h" #endif +#ifndef __JUCE_COMPONENT_JUCEHEADER__ + #include "juce_appframework/gui/components/juce_Component.h" +#endif #ifndef __JUCE_ARROWBUTTON_JUCEHEADER__ #include "juce_appframework/gui/components/buttons/juce_ArrowButton.h" #endif -#ifndef __JUCE_BUTTON_JUCEHEADER__ - #include "juce_appframework/gui/components/buttons/juce_Button.h" -#endif #ifndef __JUCE_DRAWABLEBUTTON_JUCEHEADER__ #include "juce_appframework/gui/components/buttons/juce_DrawableButton.h" #endif @@ -428,6 +425,9 @@ #ifndef __JUCE_IMAGEBUTTON_JUCEHEADER__ #include "juce_appframework/gui/components/buttons/juce_ImageButton.h" #endif +#ifndef __JUCE_BUTTON_JUCEHEADER__ + #include "juce_appframework/gui/components/buttons/juce_Button.h" +#endif #ifndef __JUCE_SHAPEBUTTON_JUCEHEADER__ #include "juce_appframework/gui/components/buttons/juce_ShapeButton.h" #endif @@ -455,21 +455,21 @@ #ifndef __JUCE_KEYBOARDFOCUSTRAVERSER_JUCEHEADER__ #include "juce_appframework/gui/components/keyboard/juce_KeyboardFocusTraverser.h" #endif -#ifndef __JUCE_KEYLISTENER_JUCEHEADER__ - #include "juce_appframework/gui/components/keyboard/juce_KeyListener.h" +#ifndef __JUCE_KEYPRESS_JUCEHEADER__ + #include "juce_appframework/gui/components/keyboard/juce_KeyPress.h" #endif #ifndef __JUCE_KEYMAPPINGEDITORCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/keyboard/juce_KeyMappingEditorComponent.h" #endif -#ifndef __JUCE_KEYPRESS_JUCEHEADER__ - #include "juce_appframework/gui/components/keyboard/juce_KeyPress.h" +#ifndef __JUCE_MODIFIERKEYS_JUCEHEADER__ + #include "juce_appframework/gui/components/keyboard/juce_ModifierKeys.h" +#endif +#ifndef __JUCE_KEYLISTENER_JUCEHEADER__ + #include "juce_appframework/gui/components/keyboard/juce_KeyListener.h" #endif #ifndef __JUCE_KEYPRESSMAPPINGSET_JUCEHEADER__ #include "juce_appframework/gui/components/keyboard/juce_KeyPressMappingSet.h" #endif -#ifndef __JUCE_MODIFIERKEYS_JUCEHEADER__ - #include "juce_appframework/gui/components/keyboard/juce_ModifierKeys.h" -#endif #ifndef __JUCE_MENUBARCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/menus/juce_MenuBarComponent.h" #endif @@ -512,15 +512,9 @@ #ifndef __JUCE_TOOLTIPCLIENT_JUCEHEADER__ #include "juce_appframework/gui/components/mouse/juce_TooltipClient.h" #endif -#ifndef __JUCE_COMBOBOX_JUCEHEADER__ - #include "juce_appframework/gui/components/controls/juce_ComboBox.h" -#endif #ifndef __JUCE_LABEL_JUCEHEADER__ #include "juce_appframework/gui/components/controls/juce_Label.h" #endif -#ifndef __JUCE_LISTBOX_JUCEHEADER__ - #include "juce_appframework/gui/components/controls/juce_ListBox.h" -#endif #ifndef __JUCE_PROGRESSBAR_JUCEHEADER__ #include "juce_appframework/gui/components/controls/juce_ProgressBar.h" #endif @@ -536,24 +530,30 @@ #ifndef __JUCE_TABLELISTBOX_JUCEHEADER__ #include "juce_appframework/gui/components/controls/juce_TableListBox.h" #endif -#ifndef __JUCE_TEXTEDITOR_JUCEHEADER__ - #include "juce_appframework/gui/components/controls/juce_TextEditor.h" -#endif #ifndef __JUCE_TOOLBAR_JUCEHEADER__ #include "juce_appframework/gui/components/controls/juce_Toolbar.h" #endif -#ifndef __JUCE_TOOLBARITEMCOMPONENT_JUCEHEADER__ - #include "juce_appframework/gui/components/controls/juce_ToolbarItemComponent.h" -#endif #ifndef __JUCE_TOOLBARITEMFACTORY_JUCEHEADER__ #include "juce_appframework/gui/components/controls/juce_ToolbarItemFactory.h" #endif +#ifndef __JUCE_TOOLBARITEMCOMPONENT_JUCEHEADER__ + #include "juce_appframework/gui/components/controls/juce_ToolbarItemComponent.h" +#endif #ifndef __JUCE_TOOLBARITEMPALETTE_JUCEHEADER__ #include "juce_appframework/gui/components/controls/juce_ToolbarItemPalette.h" #endif #ifndef __JUCE_TREEVIEW_JUCEHEADER__ #include "juce_appframework/gui/components/controls/juce_TreeView.h" #endif +#ifndef __JUCE_TEXTEDITOR_JUCEHEADER__ + #include "juce_appframework/gui/components/controls/juce_TextEditor.h" +#endif +#ifndef __JUCE_LISTBOX_JUCEHEADER__ + #include "juce_appframework/gui/components/controls/juce_ListBox.h" +#endif +#ifndef __JUCE_COMBOBOX_JUCEHEADER__ + #include "juce_appframework/gui/components/controls/juce_ComboBox.h" +#endif #ifndef __JUCE_BOOLEANPROPERTYCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/properties/juce_BooleanPropertyComponent.h" #endif @@ -599,6 +599,12 @@ #ifndef __JUCE_SCROLLBAR_JUCEHEADER__ #include "juce_appframework/gui/components/layout/juce_ScrollBar.h" #endif +#ifndef __JUCE_TABBEDBUTTONBAR_JUCEHEADER__ + #include "juce_appframework/gui/components/layout/juce_TabbedButtonBar.h" +#endif +#ifndef __JUCE_TABBEDCOMPONENT_JUCEHEADER__ + #include "juce_appframework/gui/components/layout/juce_TabbedComponent.h" +#endif #ifndef __JUCE_STRETCHABLELAYOUTMANAGER_JUCEHEADER__ #include "juce_appframework/gui/components/layout/juce_StretchableLayoutManager.h" #endif @@ -608,12 +614,6 @@ #ifndef __JUCE_STRETCHABLEOBJECTRESIZER_JUCEHEADER__ #include "juce_appframework/gui/components/layout/juce_StretchableObjectResizer.h" #endif -#ifndef __JUCE_TABBEDBUTTONBAR_JUCEHEADER__ - #include "juce_appframework/gui/components/layout/juce_TabbedButtonBar.h" -#endif -#ifndef __JUCE_TABBEDCOMPONENT_JUCEHEADER__ - #include "juce_appframework/gui/components/layout/juce_TabbedComponent.h" -#endif #ifndef __JUCE_VIEWPORT_JUCEHEADER__ #include "juce_appframework/gui/components/layout/juce_Viewport.h" #endif @@ -623,9 +623,6 @@ #ifndef __JUCE_DIRECTORYCONTENTSLIST_JUCEHEADER__ #include "juce_appframework/gui/components/filebrowser/juce_DirectoryContentsList.h" #endif -#ifndef __JUCE_FILEBROWSERCOMPONENT_JUCEHEADER__ - #include "juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.h" -#endif #ifndef __JUCE_FILEBROWSERLISTENER_JUCEHEADER__ #include "juce_appframework/gui/components/filebrowser/juce_FileBrowserListener.h" #endif @@ -641,30 +638,30 @@ #ifndef __JUCE_FILELISTCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/filebrowser/juce_FileListComponent.h" #endif -#ifndef __JUCE_FILENAMECOMPONENT_JUCEHEADER__ - #include "juce_appframework/gui/components/filebrowser/juce_FilenameComponent.h" -#endif #ifndef __JUCE_FILEPREVIEWCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/filebrowser/juce_FilePreviewComponent.h" #endif +#ifndef __JUCE_FILETREECOMPONENT_JUCEHEADER__ + #include "juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.h" +#endif #ifndef __JUCE_FILESEARCHPATHLISTCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/filebrowser/juce_FileSearchPathListComponent.h" #endif -#ifndef __JUCE_FILETREECOMPONENT_JUCEHEADER__ - #include "juce_appframework/gui/components/filebrowser/juce_FileTreeComponent.h" +#ifndef __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ + #include "juce_appframework/gui/components/filebrowser/juce_WildcardFileFilter.h" #endif #ifndef __JUCE_IMAGEPREVIEWCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/filebrowser/juce_ImagePreviewComponent.h" #endif -#ifndef __JUCE_WILDCARDFILEFILTER_JUCEHEADER__ - #include "juce_appframework/gui/components/filebrowser/juce_WildcardFileFilter.h" +#ifndef __JUCE_FILENAMECOMPONENT_JUCEHEADER__ + #include "juce_appframework/gui/components/filebrowser/juce_FilenameComponent.h" +#endif +#ifndef __JUCE_FILEBROWSERCOMPONENT_JUCEHEADER__ + #include "juce_appframework/gui/components/filebrowser/juce_FileBrowserComponent.h" #endif #ifndef __JUCE_ALERTWINDOW_JUCEHEADER__ #include "juce_appframework/gui/components/windows/juce_AlertWindow.h" #endif -#ifndef __JUCE_COMPONENTPEER_JUCEHEADER__ - #include "juce_appframework/gui/components/windows/juce_ComponentPeer.h" -#endif #ifndef __JUCE_DIALOGWINDOW_JUCEHEADER__ #include "juce_appframework/gui/components/windows/juce_DialogWindow.h" #endif @@ -680,12 +677,15 @@ #ifndef __JUCE_THREADWITHPROGRESSWINDOW_JUCEHEADER__ #include "juce_appframework/gui/components/windows/juce_ThreadWithProgressWindow.h" #endif -#ifndef __JUCE_TOOLTIPWINDOW_JUCEHEADER__ - #include "juce_appframework/gui/components/windows/juce_TooltipWindow.h" -#endif #ifndef __JUCE_TOPLEVELWINDOW_JUCEHEADER__ #include "juce_appframework/gui/components/windows/juce_TopLevelWindow.h" #endif +#ifndef __JUCE_COMPONENTPEER_JUCEHEADER__ + #include "juce_appframework/gui/components/windows/juce_ComponentPeer.h" +#endif +#ifndef __JUCE_TOOLTIPWINDOW_JUCEHEADER__ + #include "juce_appframework/gui/components/windows/juce_TooltipWindow.h" +#endif #ifndef __JUCE_ACTIVEXCONTROLCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/special/juce_ActiveXControlComponent.h" #endif @@ -704,12 +704,6 @@ #ifndef __JUCE_DROPSHADOWER_JUCEHEADER__ #include "juce_appframework/gui/components/special/juce_DropShadower.h" #endif -#ifndef __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ - #include "juce_appframework/gui/components/special/juce_MagnifierComponent.h" -#endif -#ifndef __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ - #include "juce_appframework/gui/components/special/juce_MidiKeyboardComponent.h" -#endif #ifndef __JUCE_NSVIEWCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/special/juce_NSViewComponent.h" #endif @@ -719,14 +713,20 @@ #ifndef __JUCE_PREFERENCESPANEL_JUCEHEADER__ #include "juce_appframework/gui/components/special/juce_PreferencesPanel.h" #endif +#ifndef __JUCE_MAGNIFIERCOMPONENT_JUCEHEADER__ + #include "juce_appframework/gui/components/special/juce_MagnifierComponent.h" +#endif +#ifndef __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ + #include "juce_appframework/gui/components/special/juce_WebBrowserComponent.h" +#endif #ifndef __JUCE_QUICKTIMEMOVIECOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/special/juce_QuickTimeMovieComponent.h" #endif #ifndef __JUCE_SYSTEMTRAYICONCOMPONENT_JUCEHEADER__ #include "juce_appframework/gui/components/special/juce_SystemTrayIconComponent.h" #endif -#ifndef __JUCE_WEBBROWSERCOMPONENT_JUCEHEADER__ - #include "juce_appframework/gui/components/special/juce_WebBrowserComponent.h" +#ifndef __JUCE_MIDIKEYBOARDCOMPONENT_JUCEHEADER__ + #include "juce_appframework/gui/components/special/juce_MidiKeyboardComponent.h" #endif #ifndef __JUCE_LOOKANDFEEL_JUCEHEADER__ #include "juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h" diff --git a/src/juce_appframework/audio/audio_file_formats/juce_AiffAudioFormat.cpp b/src/juce_appframework/audio/audio_file_formats/juce_AiffAudioFormat.cpp index 20117ac2f3..bca915e57e 100644 --- a/src/juce_appframework/audio/audio_file_formats/juce_AiffAudioFormat.cpp +++ b/src/juce_appframework/audio/audio_file_formats/juce_AiffAudioFormat.cpp @@ -162,7 +162,7 @@ public: int64 startSampleInFile, int numSamples) { numSamples = (int) jmin ((int64) numSamples, lengthInSamples - startSampleInFile); - + if (numSamples <= 0) return true; diff --git a/src/juce_appframework/audio/audio_file_formats/juce_AudioFormat.cpp b/src/juce_appframework/audio/audio_file_formats/juce_AudioFormat.cpp index f2407f3c43..b201e9ea46 100644 --- a/src/juce_appframework/audio/audio_file_formats/juce_AudioFormat.cpp +++ b/src/juce_appframework/audio/audio_file_formats/juce_AudioFormat.cpp @@ -55,9 +55,9 @@ AudioFormatReader::~AudioFormatReader() delete input; } -bool AudioFormatReader::read (int** destSamples, +bool AudioFormatReader::read (int** destSamples, int numDestChannels, - int64 startSampleInSource, + int64 startSampleInSource, int numSamplesToRead, const bool fillLeftoverChannelsWithCopies) { @@ -81,7 +81,7 @@ bool AudioFormatReader::read (int** destSamples, if (numSamplesToRead <= 0) return true; - if (! readSamples (destSamples, jmin (numChannels, numDestChannels), startOffsetInDestBuffer, + if (! readSamples (destSamples, jmin (numChannels, numDestChannels), startOffsetInDestBuffer, startSampleInSource, numSamplesToRead)) return false; @@ -90,7 +90,7 @@ bool AudioFormatReader::read (int** destSamples, if (fillLeftoverChannelsWithCopies) { int* lastFullChannel = destSamples[0]; - + for (int i = numDestChannels; --i > 0;) { if (destSamples[i] != 0) diff --git a/src/juce_appframework/audio/audio_file_formats/juce_AudioFormatReader.h b/src/juce_appframework/audio/audio_file_formats/juce_AudioFormatReader.h index 367e400f4c..255b7cb929 100644 --- a/src/juce_appframework/audio/audio_file_formats/juce_AudioFormatReader.h +++ b/src/juce_appframework/audio/audio_file_formats/juce_AudioFormatReader.h @@ -95,15 +95,15 @@ public: stream. It's ok for this to be beyond the start or end of the available data - any samples that are out-of-range will be returned as zeros. - @param numSamplesToRead the number of samples to read. If this is greater than the number + @param numSamplesToRead the number of samples to read. If this is greater than the number of samples that the file or stream contains. the result will be padded with zeros @param fillLeftoverChannelsWithCopies if true, this indicates that if there's no source data available - for some of the channels that you pass in, then they should be filled with - copies of valid source channels. + for some of the channels that you pass in, then they should be filled with + copies of valid source channels. E.g. if you're reading a mono file and you pass 2 channels to this method, then - if fillLeftoverChannelsWithCopies is true, both destination channels will be filled - with the same data from the file's single channel. If fillLeftoverChannelsWithCopies + if fillLeftoverChannelsWithCopies is true, both destination channels will be filled + with the same data from the file's single channel. If fillLeftoverChannelsWithCopies was false, then only the first channel would be filled with the file's contents, and the second would be cleared. If there are many channels, e.g. you try to read 4 channels from a stereo file, then the last 3 would all end up with copies of the same data. @@ -112,9 +112,9 @@ public: error - the reader should just return zeros for these regions @see readMaxLevels */ - bool read (int** destSamples, + bool read (int** destSamples, int numDestChannels, - int64 startSampleInSource, + int64 startSampleInSource, int numSamplesToRead, const bool fillLeftoverChannelsWithCopies); @@ -200,27 +200,27 @@ public: //============================================================================== /** Subclasses must implement this method to perform the low-level read operation. - + Callers should use read() instead of calling this directly. - + @param destSamples the array of destination buffers to fill. Some of these pointers may be null @param numDestChannels the number of items in the destSamples array. This - value is guaranteed not to be greater than the number of + value is guaranteed not to be greater than the number of channels that this reader object contains - @param startOffsetInDestBuffer the number of samples from the start of the + @param startOffsetInDestBuffer the number of samples from the start of the dest data at which to begin writing @param startSampleInFile the number of samples into the source data at which to begin reading. This value is guaranteed to be >= 0. @param numSamples the number of samples to read */ - virtual bool readSamples (int** destSamples, + virtual bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) = 0; - - + + //============================================================================== juce_UseDebuggingNewOperator diff --git a/src/juce_appframework/audio/audio_file_formats/juce_AudioSubsectionReader.cpp b/src/juce_appframework/audio/audio_file_formats/juce_AudioSubsectionReader.cpp index adbbf0806d..d2622101d8 100644 --- a/src/juce_appframework/audio/audio_file_formats/juce_AudioSubsectionReader.cpp +++ b/src/juce_appframework/audio/audio_file_formats/juce_AudioSubsectionReader.cpp @@ -72,7 +72,7 @@ bool AudioSubsectionReader::readSamples (int** destSamples, int numDestChannels, zeromem (destSamples[i], sizeof (int) * numSamples); numSamples = jmin (numSamples, (int) (length - startSampleInFile)); - + if (numSamples <= 0) return true; } diff --git a/src/juce_appframework/audio/devices/juce_AudioDeviceManager.h b/src/juce_appframework/audio/devices/juce_AudioDeviceManager.h index ee862f1dc2..a0264e28cb 100644 --- a/src/juce_appframework/audio/devices/juce_AudioDeviceManager.h +++ b/src/juce_appframework/audio/devices/juce_AudioDeviceManager.h @@ -229,12 +229,12 @@ public: @see setCurrentAudioDeviceType */ const String getCurrentAudioDeviceType() const throw() { return currentDeviceType; } - + /** Changes the class of audio device being used. - + This switches between, e.g. ASIO and DirectSound. On the Mac you probably won't ever call this because there's only one type: CoreAudio. - + For a list of types, see getAvailableDeviceTypes(). */ void setCurrentAudioDeviceType (const String& type, diff --git a/src/juce_appframework/gui/components/controls/juce_Label.cpp b/src/juce_appframework/gui/components/controls/juce_Label.cpp index 24338c507b..2b6e13d550 100644 --- a/src/juce_appframework/gui/components/controls/juce_Label.cpp +++ b/src/juce_appframework/gui/components/controls/juce_Label.cpp @@ -213,7 +213,7 @@ void Label::showEditor() repaint(); editorShown (editor); - + enterModalState(); editor->grabKeyboardFocus(); } diff --git a/src/juce_appframework/gui/components/controls/juce_Label.h b/src/juce_appframework/gui/components/controls/juce_Label.h index 6821d38282..034984f3c3 100644 --- a/src/juce_appframework/gui/components/controls/juce_Label.h +++ b/src/juce_appframework/gui/components/controls/juce_Label.h @@ -308,7 +308,7 @@ protected: /** Called when the text has been altered. */ virtual void textWasChanged(); - + /** Called when the text editor has just appeared, due to a user click or other focus change. */ diff --git a/src/juce_appframework/gui/components/controls/juce_ListBox.cpp b/src/juce_appframework/gui/components/controls/juce_ListBox.cpp index 1fc8419015..1729f8fd57 100644 --- a/src/juce_appframework/gui/components/controls/juce_ListBox.cpp +++ b/src/juce_appframework/gui/components/controls/juce_ListBox.cpp @@ -793,7 +793,7 @@ bool ListBox::keyPressed (const KeyPress& key) bool ListBox::keyStateChanged (const bool isKeyDown) { - return isKeyDown + return isKeyDown && (KeyPress::isKeyCurrentlyDown (KeyPress::upKey) || KeyPress::isKeyCurrentlyDown (KeyPress::pageUpKey) || KeyPress::isKeyCurrentlyDown (KeyPress::downKey) diff --git a/src/juce_appframework/gui/components/controls/juce_TreeView.cpp b/src/juce_appframework/gui/components/controls/juce_TreeView.cpp index 6bcb20378b..13c3592559 100644 --- a/src/juce_appframework/gui/components/controls/juce_TreeView.cpp +++ b/src/juce_appframework/gui/components/controls/juce_TreeView.cpp @@ -363,7 +363,7 @@ private: item->setSelected ((! cmd) || (! item->isSelected()), ! cmd); } } - + bool containsItem (TreeViewItem* const item) const { for (int i = rowComponentItems.size(); --i >= 0;) diff --git a/src/juce_appframework/gui/components/juce_Component.h b/src/juce_appframework/gui/components/juce_Component.h index c7d1927d8b..e45347835a 100644 --- a/src/juce_appframework/gui/components/juce_Component.h +++ b/src/juce_appframework/gui/components/juce_Component.h @@ -1481,7 +1481,7 @@ public: To find out which keys are up or down at any time, see the KeyPress::isKeyCurrentlyDown() method. - + @param isKeyDown true if a key has been pressed; false if it has been released @see keyPressed, KeyPress, getCurrentlyFocusedComponent, addKeyListener diff --git a/src/juce_appframework/gui/components/layout/juce_ResizableBorderComponent.cpp b/src/juce_appframework/gui/components/layout/juce_ResizableBorderComponent.cpp index 1a5054b120..b5c98a14e6 100644 --- a/src/juce_appframework/gui/components/layout/juce_ResizableBorderComponent.cpp +++ b/src/juce_appframework/gui/components/layout/juce_ResizableBorderComponent.cpp @@ -173,20 +173,20 @@ void ResizableBorderComponent::updateMouseZone (const MouseEvent& e) throw() if (ResizableBorderComponent::hitTest (e.x, e.y)) { - if (e.x < jmax (borderSize.getLeft(), - proportionOfWidth (0.1f), + if (e.x < jmax (borderSize.getLeft(), + proportionOfWidth (0.1f), jmin (10, proportionOfWidth (0.33f)))) newZone |= zoneL; - else if (e.x >= jmin (getWidth() - borderSize.getRight(), + else if (e.x >= jmin (getWidth() - borderSize.getRight(), proportionOfWidth (0.9f), getWidth() - jmin (10, proportionOfWidth (0.33f)))) newZone |= zoneR; - if (e.y < jmax (borderSize.getTop(), - proportionOfHeight (0.1f), + if (e.y < jmax (borderSize.getTop(), + proportionOfHeight (0.1f), jmin (10, proportionOfHeight (0.33f)))) newZone |= zoneT; - else if (e.y >= jmin (getHeight() - borderSize.getBottom(), + else if (e.y >= jmin (getHeight() - borderSize.getBottom(), proportionOfHeight (0.9f), getHeight() - jmin (10, proportionOfHeight (0.33f)))) newZone |= zoneB; diff --git a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h index 003ebbf23d..c19083c57d 100644 --- a/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h +++ b/src/juce_appframework/gui/components/lookandfeel/juce_LookAndFeel.h @@ -178,7 +178,7 @@ public: const bool isButtonDown); //============================================================================== - /* AlertWindow handling.. + /* AlertWindow handling.. */ virtual AlertWindow* createAlertWindow (const String& title, const String& message, @@ -455,7 +455,7 @@ public: //============================================================================== virtual void fillResizableWindowBackground (Graphics& g, int w, int h, - const BorderSize& border, + const BorderSize& border, ResizableWindow& window); virtual void drawResizableWindowBorder (Graphics& g, diff --git a/src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp b/src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp index 71b18f62c8..029f524fc4 100644 --- a/src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp +++ b/src/juce_appframework/gui/components/windows/juce_TooltipWindow.cpp @@ -1,195 +1,195 @@ -/* - ============================================================================== - - This file is part of the JUCE library - "Jules' Utility Class Extensions" - Copyright 2004-7 by Raw Material Software ltd. - - ------------------------------------------------------------------------------ - - JUCE can be redistributed and/or modified under the terms of the - GNU General Public License, as published by the Free Software Foundation; - either version 2 of the License, or (at your option) any later version. - - JUCE 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with JUCE; if not, visit www.gnu.org/licenses or write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - If you'd like to release a closed-source product which uses JUCE, commercial - licenses are also available: visit www.rawmaterialsoftware.com/juce for - more information. - - ============================================================================== -*/ - -#include "../../../../juce_core/basics/juce_StandardHeader.h" - -BEGIN_JUCE_NAMESPACE - - -#include "juce_TooltipWindow.h" -#include "../../../../juce_core/basics/juce_Time.h" -#include "../../../../juce_core/threads/juce_Process.h" -#include "../lookandfeel/juce_LookAndFeel.h" -#include "../juce_Desktop.h" - - -//============================================================================== -TooltipWindow::TooltipWindow (Component* const parentComponent, - const int millisecondsBeforeTipAppears_) - : Component ("tooltip"), - millisecondsBeforeTipAppears (millisecondsBeforeTipAppears_), - mouseX (0), - mouseY (0), - lastHideTime (0), - lastComponentUnderMouse (0), - changedCompsSinceShown (true) -{ - startTimer (123); - - setAlwaysOnTop (true); - setOpaque (true); - - if (parentComponent != 0) - parentComponent->addChildComponent (this); -} - -TooltipWindow::~TooltipWindow() -{ - hide(); -} - -void TooltipWindow::setMillisecondsBeforeTipAppears (const int newTimeMs) throw() -{ - millisecondsBeforeTipAppears = newTimeMs; -} - -void TooltipWindow::paint (Graphics& g) -{ - getLookAndFeel().drawTooltip (g, tipShowing, getWidth(), getHeight()); -} - -void TooltipWindow::mouseEnter (const MouseEvent&) -{ - hide(); -} - -void TooltipWindow::showFor (Component* const c, const String& tip) -{ - jassert (tip.isNotEmpty()); - tipShowing = tip; - - int mx, my; - Desktop::getMousePosition (mx, my); - - if (getParentComponent() != 0) - getParentComponent()->globalPositionToRelative (mx, my); - - int x, y, w, h; - getLookAndFeel().getTooltipSize (tip, w, h); - - if (mx > getParentWidth() / 2) - x = mx - (w + 12); - else - x = mx + 24; - - if (my > getParentHeight() / 2) - y = my - (h + 6); - else - y = my + 6; - - setBounds (x, y, w, h); - setVisible (true); - - if (getParentComponent() == 0) - { - addToDesktop (ComponentPeer::windowHasDropShadow - | ComponentPeer::windowIsTemporary); - } - - toFront (false); -} - -const String TooltipWindow::getTipFor (Component* const c) -{ - if (c->isValidComponent() - && Process::isForegroundProcess() - && ! Component::isMouseButtonDownAnywhere()) - { - TooltipClient* const ttc = dynamic_cast (c); - - if (ttc != 0 && ! c->isCurrentlyBlockedByAnotherModalComponent()) - return ttc->getTooltip(); - } - - return String::empty; -} - -void TooltipWindow::hide() -{ - tipShowing = String::empty; - removeFromDesktop(); - setVisible (false); -} - -void TooltipWindow::timerCallback() -{ - const unsigned int now = Time::getApproximateMillisecondCounter(); - Component* const newComp = Component::getComponentUnderMouse(); - const String newTip (getTipFor (newComp)); - - const bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse); - lastComponentUnderMouse = newComp; - lastTipUnderMouse = newTip; - - const int clickCount = Desktop::getInstance().getMouseButtonClickCounter(); - const bool mouseWasClicked = clickCount > mouseClicks; - mouseClicks = clickCount; - - int mx, my; - Desktop::getMousePosition (mx, my); - const bool mouseMovedQuickly = (abs (mx - mouseX) + abs (my - mouseY) > 12); - mouseX = mx; - mouseY = my; - - if (tipChanged || mouseWasClicked || mouseMovedQuickly) - lastCompChangeTime = now; - - if (isVisible() || now < lastHideTime + 500) - { - // if a tip is currently visible (or has just disappeared), update to a new one - // immediately if needed.. - if (newComp == 0 || mouseWasClicked || newTip.isEmpty()) - { - if (isVisible()) - { - lastHideTime = now; - hide(); - } - } - else if (tipChanged) - { - showFor (newComp, newTip); - } - } - else - { - // if there isn't currently a tip, but one is needed, only let it - // appear after a timeout.. - if (newTip.isNotEmpty() - && newTip != tipShowing - && now > lastCompChangeTime + millisecondsBeforeTipAppears) - { - showFor (newComp, newTip); - } - } -} - -END_JUCE_NAMESPACE +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-7 by Raw Material Software ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the + GNU General Public License, as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version. + + JUCE 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with JUCE; if not, visit www.gnu.org/licenses or write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + ------------------------------------------------------------------------------ + + If you'd like to release a closed-source product which uses JUCE, commercial + licenses are also available: visit www.rawmaterialsoftware.com/juce for + more information. + + ============================================================================== +*/ + +#include "../../../../juce_core/basics/juce_StandardHeader.h" + +BEGIN_JUCE_NAMESPACE + + +#include "juce_TooltipWindow.h" +#include "../../../../juce_core/basics/juce_Time.h" +#include "../../../../juce_core/threads/juce_Process.h" +#include "../lookandfeel/juce_LookAndFeel.h" +#include "../juce_Desktop.h" + + +//============================================================================== +TooltipWindow::TooltipWindow (Component* const parentComponent, + const int millisecondsBeforeTipAppears_) + : Component ("tooltip"), + millisecondsBeforeTipAppears (millisecondsBeforeTipAppears_), + mouseX (0), + mouseY (0), + lastHideTime (0), + lastComponentUnderMouse (0), + changedCompsSinceShown (true) +{ + startTimer (123); + + setAlwaysOnTop (true); + setOpaque (true); + + if (parentComponent != 0) + parentComponent->addChildComponent (this); +} + +TooltipWindow::~TooltipWindow() +{ + hide(); +} + +void TooltipWindow::setMillisecondsBeforeTipAppears (const int newTimeMs) throw() +{ + millisecondsBeforeTipAppears = newTimeMs; +} + +void TooltipWindow::paint (Graphics& g) +{ + getLookAndFeel().drawTooltip (g, tipShowing, getWidth(), getHeight()); +} + +void TooltipWindow::mouseEnter (const MouseEvent&) +{ + hide(); +} + +void TooltipWindow::showFor (Component* const c, const String& tip) +{ + jassert (tip.isNotEmpty()); + tipShowing = tip; + + int mx, my; + Desktop::getMousePosition (mx, my); + + if (getParentComponent() != 0) + getParentComponent()->globalPositionToRelative (mx, my); + + int x, y, w, h; + getLookAndFeel().getTooltipSize (tip, w, h); + + if (mx > getParentWidth() / 2) + x = mx - (w + 12); + else + x = mx + 24; + + if (my > getParentHeight() / 2) + y = my - (h + 6); + else + y = my + 6; + + setBounds (x, y, w, h); + setVisible (true); + + if (getParentComponent() == 0) + { + addToDesktop (ComponentPeer::windowHasDropShadow + | ComponentPeer::windowIsTemporary); + } + + toFront (false); +} + +const String TooltipWindow::getTipFor (Component* const c) +{ + if (c->isValidComponent() + && Process::isForegroundProcess() + && ! Component::isMouseButtonDownAnywhere()) + { + TooltipClient* const ttc = dynamic_cast (c); + + if (ttc != 0 && ! c->isCurrentlyBlockedByAnotherModalComponent()) + return ttc->getTooltip(); + } + + return String::empty; +} + +void TooltipWindow::hide() +{ + tipShowing = String::empty; + removeFromDesktop(); + setVisible (false); +} + +void TooltipWindow::timerCallback() +{ + const unsigned int now = Time::getApproximateMillisecondCounter(); + Component* const newComp = Component::getComponentUnderMouse(); + const String newTip (getTipFor (newComp)); + + const bool tipChanged = (newTip != lastTipUnderMouse || newComp != lastComponentUnderMouse); + lastComponentUnderMouse = newComp; + lastTipUnderMouse = newTip; + + const int clickCount = Desktop::getInstance().getMouseButtonClickCounter(); + const bool mouseWasClicked = clickCount > mouseClicks; + mouseClicks = clickCount; + + int mx, my; + Desktop::getMousePosition (mx, my); + const bool mouseMovedQuickly = (abs (mx - mouseX) + abs (my - mouseY) > 12); + mouseX = mx; + mouseY = my; + + if (tipChanged || mouseWasClicked || mouseMovedQuickly) + lastCompChangeTime = now; + + if (isVisible() || now < lastHideTime + 500) + { + // if a tip is currently visible (or has just disappeared), update to a new one + // immediately if needed.. + if (newComp == 0 || mouseWasClicked || newTip.isEmpty()) + { + if (isVisible()) + { + lastHideTime = now; + hide(); + } + } + else if (tipChanged) + { + showFor (newComp, newTip); + } + } + else + { + // if there isn't currently a tip, but one is needed, only let it + // appear after a timeout.. + if (newTip.isNotEmpty() + && newTip != tipShowing + && now > lastCompChangeTime + millisecondsBeforeTipAppears) + { + showFor (newComp, newTip); + } + } +} + +END_JUCE_NAMESPACE diff --git a/src/juce_appframework/gui/components/windows/juce_TooltipWindow.h b/src/juce_appframework/gui/components/windows/juce_TooltipWindow.h index a43c612480..2806585ed3 100644 --- a/src/juce_appframework/gui/components/windows/juce_TooltipWindow.h +++ b/src/juce_appframework/gui/components/windows/juce_TooltipWindow.h @@ -84,7 +84,7 @@ public: This lets you change the value that was set in the constructor. */ void setMillisecondsBeforeTipAppears (const int newTimeMs = 700) throw(); - + //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the tooltip. diff --git a/src/juce_core/containers/juce_ReferenceCountedArray.h b/src/juce_core/containers/juce_ReferenceCountedArray.h index 1bab568127..9b6d311fde 100644 --- a/src/juce_core/containers/juce_ReferenceCountedArray.h +++ b/src/juce_core/containers/juce_ReferenceCountedArray.h @@ -443,8 +443,8 @@ public: } /** Inserts or replaces an object in the array, assuming it is sorted. - - This is similar to addSorted, but if a matching element already exists, then it will be + + This is similar to addSorted, but if a matching element already exists, then it will be replaced by the new one, rather than the new one being added as well. */ template diff --git a/src/juce_core/io/network/juce_Socket.h b/src/juce_core/io/network/juce_Socket.h index dfe2c1d811..6745fc3d40 100644 --- a/src/juce_core/io/network/juce_Socket.h +++ b/src/juce_core/io/network/juce_Socket.h @@ -195,13 +195,13 @@ public: To use the socket for sending, call the connect() method. This will not immediately make a connection, but will save the destination you've provided. After this, you can call read() or write(). - + If enableBroadcasting is true, the socket will be allowed to send broadcast messages (may require extra privileges on linux) To wait for other sockets to connect to this one, call waitForNextConnection(). */ - DatagramSocket (const int localPortNumber, + DatagramSocket (const int localPortNumber, const bool enableBroadcasting = false); /** Destructor. */ diff --git a/src/juce_core/io/network/juce_URL.cpp b/src/juce_core/io/network/juce_URL.cpp index 4742a191e4..d0641b4615 100644 --- a/src/juce_core/io/network/juce_URL.cpp +++ b/src/juce_core/io/network/juce_URL.cpp @@ -137,10 +137,10 @@ static int findStartOfDomain (const String& url) { int i = 0; - while (CharacterFunctions::isLetterOrDigit (url[i]) + while (CharacterFunctions::isLetterOrDigit (url[i]) || CharacterFunctions::indexOfChar (T("+-."), url[i], false) >= 0) ++i; - + return url[i] == T(':') ? i + 1 : 0; } @@ -149,11 +149,11 @@ const String URL::getDomain() const int start = findStartOfDomain (url); while (url[start] == T('/')) ++start; - + const int end1 = url.indexOfChar (start, T('/')); const int end2 = url.indexOfChar (start, T(':')); - const int end = (end1 < 0 || end2 < 0) ? jmax (end1, end2) + const int end = (end1 < 0 || end2 < 0) ? jmax (end1, end2) : jmin (end1, end2); return url.substring (start, end); @@ -191,7 +191,7 @@ const URL URL::withNewSubPath (const String& newPath) const if (! u.url.endsWithChar (T('/'))) u.url << '/'; - + if (newPath.startsWithChar (T('/'))) u.url << newPath.substring (1); else diff --git a/src/juce_core/io/network/juce_URL.h b/src/juce_core/io/network/juce_URL.h index 63398aa669..30718cca5d 100644 --- a/src/juce_core/io/network/juce_URL.h +++ b/src/juce_core/io/network/juce_URL.h @@ -86,16 +86,16 @@ public: E.g. for "http://www.xyz.com/foo/bar?x=1", this will return "foo/bar". */ const String getSubPath() const; - - /** Returns the scheme of the URL. - E.g. for "http://www.xyz.com/foobar", this will return "http". (It won't + /** Returns the scheme of the URL. + + E.g. for "http://www.xyz.com/foobar", this will return "http". (It won't include the colon). */ const String getScheme() const; - + /** Returns a new version of this URL that uses a different sub-path. - + E.g. if the URL is "http://www.xyz.com/foo?x=1" and you call this with "bar", it'll return "http://www.xyz.com/bar?x=1". */ diff --git a/src/juce_core/text/juce_String.cpp b/src/juce_core/text/juce_String.cpp index adb3c96112..f1e95ccc42 100644 --- a/src/juce_core/text/juce_String.cpp +++ b/src/juce_core/text/juce_String.cpp @@ -1375,7 +1375,7 @@ const String String::replaceSection (int index, const int newStringLen = (stringToInsert != 0) ? CharacterFunctions::length (stringToInsert) : 0; const int newTotalLen = len + newStringLen - numCharsToReplace; - + if (newTotalLen <= 0) return String::empty; diff --git a/src/juce_core/threads/juce_Thread.cpp b/src/juce_core/threads/juce_Thread.cpp index 0f1f0a3fe1..6e41339820 100644 --- a/src/juce_core/threads/juce_Thread.cpp +++ b/src/juce_core/threads/juce_Thread.cpp @@ -215,10 +215,10 @@ bool Thread::setPriority (const int priority) throw() const ScopedLock sl (startStopLock); const bool worked = juce_setThreadPriority (threadHandle_, priority); - + if (worked) threadPriority_ = priority; - + return worked; } diff --git a/src/juce_core/threads/juce_ThreadPool.cpp b/src/juce_core/threads/juce_ThreadPool.cpp index debfeefde8..2cffa83116 100644 --- a/src/juce_core/threads/juce_ThreadPool.cpp +++ b/src/juce_core/threads/juce_ThreadPool.cpp @@ -281,7 +281,7 @@ bool ThreadPool::removeAllJobs (const bool interruptRunningJobs, else { jobs.remove (i); - + if (deleteInactiveJobs) delete job; } @@ -329,7 +329,7 @@ bool ThreadPool::setThreadPriorities (const int newPriority) if (! threads[i]->setPriority (newPriority)) ok = false; } - + return ok; } diff --git a/src/juce_core/threads/juce_ThreadPool.h b/src/juce_core/threads/juce_ThreadPool.h index 15f53d6be3..bf6eeb2e9b 100644 --- a/src/juce_core/threads/juce_ThreadPool.h +++ b/src/juce_core/threads/juce_ThreadPool.h @@ -218,8 +218,8 @@ public: methods called to try to interrupt them @param timeOutMilliseconds the length of time this method should wait for all the jobs to finish before giving up and returning false - @param deleteInactiveJobs if true, any jobs that aren't currently running will be deleted. If false, - they will simply be removed from the pool. Jobs that are already running when + @param deleteInactiveJobs if true, any jobs that aren't currently running will be deleted. If false, + they will simply be removed from the pool. Jobs that are already running when this method is called can choose whether they should be deleted by returning jobHasFinishedAndShouldBeDeleted from their runJob() method. @returns true if all jobs are successfully stopped and removed; false if the timeout period diff --git a/src/juce_core_includes.h b/src/juce_core_includes.h index 610565803a..ddbb467fc5 100644 --- a/src/juce_core_includes.h +++ b/src/juce_core_includes.h @@ -35,8 +35,8 @@ #ifndef __JUCE_ATOMIC_JUCEHEADER__ #include "juce_core/basics/juce_Atomic.h" #endif -#ifndef __JUCE_DATACONVERSIONS_JUCEHEADER__ - #include "juce_core/basics/juce_DataConversions.h" +#ifndef __JUCE_STANDARDHEADER_JUCEHEADER__ + #include "juce_core/basics/juce_StandardHeader.h" #endif #ifndef __JUCE_FILELOGGER_JUCEHEADER__ #include "juce_core/basics/juce_FileLogger.h" @@ -65,21 +65,21 @@ #ifndef __JUCE_SINGLETON_JUCEHEADER__ #include "juce_core/basics/juce_Singleton.h" #endif -#ifndef __JUCE_STANDARDHEADER_JUCEHEADER__ - #include "juce_core/basics/juce_StandardHeader.h" -#endif #ifndef __JUCE_SYSTEMSTATS_JUCEHEADER__ #include "juce_core/basics/juce_SystemStats.h" #endif #ifndef __JUCE_TIME_JUCEHEADER__ #include "juce_core/basics/juce_Time.h" #endif -#ifndef __JUCE_ARRAY_JUCEHEADER__ - #include "juce_core/containers/juce_Array.h" +#ifndef __JUCE_DATACONVERSIONS_JUCEHEADER__ + #include "juce_core/basics/juce_DataConversions.h" #endif #ifndef __JUCE_ARRAYALLOCATIONBASE_JUCEHEADER__ #include "juce_core/containers/juce_ArrayAllocationBase.h" #endif +#ifndef __JUCE_ARRAY_JUCEHEADER__ + #include "juce_core/containers/juce_Array.h" +#endif #ifndef __JUCE_BITARRAY_JUCEHEADER__ #include "juce_core/containers/juce_BitArray.h" #endif @@ -89,30 +89,30 @@ #ifndef __JUCE_MEMORYBLOCK_JUCEHEADER__ #include "juce_core/containers/juce_MemoryBlock.h" #endif -#ifndef __JUCE_OWNEDARRAY_JUCEHEADER__ - #include "juce_core/containers/juce_OwnedArray.h" -#endif #ifndef __JUCE_PROPERTYSET_JUCEHEADER__ #include "juce_core/containers/juce_PropertySet.h" #endif -#ifndef __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ - #include "juce_core/containers/juce_ReferenceCountedArray.h" -#endif #ifndef __JUCE_REFERENCECOUNTEDOBJECT_JUCEHEADER__ #include "juce_core/containers/juce_ReferenceCountedObject.h" #endif +#ifndef __JUCE_SPARSESET_JUCEHEADER__ + #include "juce_core/containers/juce_SparseSet.h" +#endif +#ifndef __JUCE_VOIDARRAY_JUCEHEADER__ + #include "juce_core/containers/juce_VoidArray.h" +#endif #ifndef __JUCE_SORTEDSET_JUCEHEADER__ #include "juce_core/containers/juce_SortedSet.h" #endif -#ifndef __JUCE_SPARSESET_JUCEHEADER__ - #include "juce_core/containers/juce_SparseSet.h" +#ifndef __JUCE_REFERENCECOUNTEDARRAY_JUCEHEADER__ + #include "juce_core/containers/juce_ReferenceCountedArray.h" +#endif +#ifndef __JUCE_OWNEDARRAY_JUCEHEADER__ + #include "juce_core/containers/juce_OwnedArray.h" #endif #ifndef __JUCE_VARIANT_JUCEHEADER__ #include "juce_core/containers/juce_Variant.h" #endif -#ifndef __JUCE_VOIDARRAY_JUCEHEADER__ - #include "juce_core/containers/juce_VoidArray.h" -#endif #ifndef __JUCE_INPUTSTREAM_JUCEHEADER__ #include "juce_core/io/juce_InputStream.h" #endif