| @@ -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 <alsa/asoundlib.h> | |||
| 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 <alsa/asoundlib.h> | |||
| 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 | |||
| @@ -139,7 +139,7 @@ bool juce_setThreadPriority (void* handle, int priority) throw() | |||
| return pthread_setschedparam ((pthread_t) handle, policy, ¶m) == 0; | |||
| } | |||
| return false; | |||
| } | |||
| @@ -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); | |||
| } | |||
| @@ -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 | |||
| @@ -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 <NSViewComponentPeer*> (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 <NSViewComponentPeer*> (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 | |||
| @@ -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))); | |||
| } | |||
| @@ -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 | |||
| @@ -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), | |||
| @@ -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 <IRunningObjectTable> 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 <IUnknown*> (this); | |||
| else if (id == IID_ISampleGrabberCB) | |||
| *result = dynamic_cast <ISampleGrabberCB*> (this); | |||
| else | |||
| { | |||
| *result = 0; | |||
| return E_NOINTERFACE; | |||
| } | |||
| AddRef(); | |||
| return S_OK; | |||
| if (id == IID_IUnknown) | |||
| *result = dynamic_cast <IUnknown*> (this); | |||
| else if (id == IID_ISampleGrabberCB) | |||
| *result = dynamic_cast <ISampleGrabberCB*> (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: | |||
| @@ -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; | |||
| @@ -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 | |||
| @@ -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); | |||
| @@ -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]; | |||
| @@ -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__ | |||
| @@ -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 }; | |||
| @@ -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 <Cocoa/Cocoa.h> | |||
| #define ADD_CARBON_BODGE 1 // see note below.. | |||
| #include <Carbon/Carbon.h> | |||
| #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 <Cocoa/Cocoa.h> | |||
| #define ADD_CARBON_BODGE 1 // see note below.. | |||
| #include <Carbon/Carbon.h> | |||
| #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 | |||
| @@ -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. | |||
| <embed id="plugin" type="application/npjucedemo-plugin" width=90% height=500> | |||
| @@ -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(); | |||
| } | |||
| @@ -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" | |||
| @@ -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); | |||
| @@ -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__ | |||
| @@ -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__ | |||
| @@ -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; | |||
| } | |||
| @@ -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 <windows.h> | |||
| # 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 <windows.h> | |||
| # 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 */ | |||
| @@ -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 <stddef.h> | |||
| #include <stdlib.h> | |||
| #include <stdarg.h> | |||
| #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 "<init>" | |||
| /******************************************************************************* | |||
| * 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 <stddef.h> | |||
| #include <stdlib.h> | |||
| #include <stdarg.h> | |||
| #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 "<init>" | |||
| /******************************************************************************* | |||
| * 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 */ | |||
| /******************************************************************************/ | |||
| @@ -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 | |||
| @@ -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 <jst@mozilla.org> (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 <inttypes.h> | |||
| #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 <sys/types.h> | |||
| /* | |||
| * 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 <inttypes.h> | |||
| #include <stdbool.h> | |||
| #endif | |||
| #elif defined(BEOS) | |||
| #include <inttypes.h> | |||
| #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 <stdint.h> | |||
| #ifndef __cplusplus | |||
| #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95) | |||
| #include <stdbool.h> | |||
| #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 <jst@mozilla.org> (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 <inttypes.h> | |||
| #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 <sys/types.h> | |||
| /* | |||
| * 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 <inttypes.h> | |||
| #include <stdbool.h> | |||
| #endif | |||
| #elif defined(BEOS) | |||
| #include <inttypes.h> | |||
| #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 <stdint.h> | |||
| #ifndef __cplusplus | |||
| #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95) | |||
| #include <stdbool.h> | |||
| #else | |||
| /* | |||
| * GCC 2.91 can't deal with a typedef for bool, but a #define | |||
| * works. | |||
| */ | |||
| #define bool int | |||
| #endif | |||
| #endif | |||
| #endif | |||
| @@ -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 PR<type>s. | |||
| * 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 <support/SupportDefs.h> | |||
| #endif | |||
| /* | |||
| * OpenVMS defines all the int types below in its standard | |||
| * header files ints.h and types.h. | |||
| */ | |||
| #ifdef VMS | |||
| #include <ints.h> | |||
| #include <types.h> | |||
| #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 <sys/types.h> | |||
| #endif | |||
| /* model.h on HP-UX defines int8, int16, and int32. */ | |||
| #ifdef HPUX | |||
| #include <model.h> | |||
| #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 PR<type>s. | |||
| * 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 <support/SupportDefs.h> | |||
| #endif | |||
| /* | |||
| * OpenVMS defines all the int types below in its standard | |||
| * header files ints.h and types.h. | |||
| */ | |||
| #ifdef VMS | |||
| #include <ints.h> | |||
| #include <types.h> | |||
| #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 <sys/types.h> | |||
| #endif | |||
| /* model.h on HP-UX defines int8, int16, and int32. */ | |||
| #ifdef HPUX | |||
| #include <model.h> | |||
| #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) */ | |||
| @@ -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___ */ | |||
| @@ -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; | |||
| @@ -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; | |||
| @@ -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('/')) | |||
| @@ -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); | |||
| } | |||
| @@ -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 <IRunningObjectTable> 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 <IUnknown*> (this); | |||
| else if (id == IID_ISampleGrabberCB) | |||
| *result = dynamic_cast <ISampleGrabberCB*> (this); | |||
| else | |||
| { | |||
| *result = 0; | |||
| return E_NOINTERFACE; | |||
| } | |||
| if (id == IID_IUnknown) | |||
| *result = dynamic_cast <IUnknown*> (this); | |||
| else if (id == IID_ISampleGrabberCB) | |||
| *result = dynamic_cast <ISampleGrabberCB*> (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); | |||
| } | |||
| @@ -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" | |||
| @@ -162,7 +162,7 @@ public: | |||
| int64 startSampleInFile, int numSamples) | |||
| { | |||
| numSamples = (int) jmin ((int64) numSamples, lengthInSamples - startSampleInFile); | |||
| if (numSamples <= 0) | |||
| return true; | |||
| @@ -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) | |||
| @@ -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 | |||
| @@ -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; | |||
| } | |||
| @@ -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, | |||
| @@ -213,7 +213,7 @@ void Label::showEditor() | |||
| repaint(); | |||
| editorShown (editor); | |||
| enterModalState(); | |||
| editor->grabKeyboardFocus(); | |||
| } | |||
| @@ -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. | |||
| */ | |||
| @@ -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) | |||
| @@ -363,7 +363,7 @@ private: | |||
| item->setSelected ((! cmd) || (! item->isSelected()), ! cmd); | |||
| } | |||
| } | |||
| bool containsItem (TreeViewItem* const item) const | |||
| { | |||
| for (int i = rowComponentItems.size(); --i >= 0;) | |||
| @@ -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 | |||
| @@ -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; | |||
| @@ -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, | |||
| @@ -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 <TooltipClient*> (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 <TooltipClient*> (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 | |||
| @@ -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. | |||
| @@ -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 <class ElementComparator> | |||
| @@ -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. */ | |||
| @@ -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 | |||
| @@ -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". | |||
| */ | |||
| @@ -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; | |||
| @@ -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; | |||
| } | |||
| @@ -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; | |||
| } | |||
| @@ -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 | |||
| @@ -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 | |||