Python Bindings using SWIG


#1

Hi,

 

I got the code for the python bindings using the SWIG library as mentioned here : http://www.juce.com/forum/topic/python-bindings?page=1

I have updated the interface file for the latest JUCE source code:

 

JUCE.i :

 


%module(directors="1", autodoc="1") JUCE
// #pragma SWIG nowarn=362
%include exception.i
%include implicit.i
%include typemaps.i
// "#define Rectangle" in juce.h generates errors in WinGDI.h !
/*
%{
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#include <windows.h>
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}
#endif // defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
%}
*/
%{
#include <juce\juce.h>
%}
%extend StringArray
{
    const String &__getitem__(int subscript)
    {
        return self->StringArray::operator[](subscript);
    }
}

%rename(RelativeTimeCopy) RelativeTime::RelativeTime(const RelativeTime&) throw();
%rename(TimeCopy) Time::Time(const RelativeTime&) throw();
%rename(ArrayCopy) Array::Array(const Array&) throw();
%rename(BitArrayCopy) BitArray::BitArray(const BitArray&) throw();
%rename(OwnedArrayCopy) OwnedArray::OwnedArray(const OwnedArray&) throw();
%rename(ReferenceCountedArrayCopy) ReferenceCountedArray::ReferenceCountedArray(const ReferenceCountedArray&) throw();
%rename(ReferenceCountedObjectCopy) ReferenceCountedObject::ReferenceCountedObject(const ReferenceCountedObject&) throw();
%rename(SortedSetCopy) SortedSet::SortedSet(const SortedSet&) throw();
%rename(FileCopy) File::File(const File&) throw();
%rename(FileSearchPathCopy) FileSearchPath::FileSearchPath(const FileSearchPath&) throw();
%rename(URLCopy) URL::URL(const URL&) throw();
%rename(StringCopy) String::String(const String&) throw();
%rename(StringArrayCopy) StringArray::StringArray(const StringArray&) throw();
%rename(StringPairArrayCopy) StringPairArray::StringPairArray(const StringPairArray&) throw();
%rename(AudioSampleBufferCopy) AudioSampleBuffer::AudioSampleBuffer(const AudioSampleBuffer&);
%rename(MidiMessageCopy) MidiMessage::MidiMessage(const MidiMessage&) throw();
%rename(MidiMessageSequenceCopy) MidiMessageSequence::MidiMessageSequence(const MidiMessageSequence&);
// %rename(ColourCopy) Colour::Colour(const Colour&) throw();
%rename(EdgeTableCopy) EdgeTable::EdgeTable(const EdgeTable&) throw();
%rename(JustificationCopy) Justification::Justification(const Justification&) throw();
// %rename(GlyphArrangementCopy) GlyphArrangement::GlyphArrangement(cont GlyphArrangement&);
%rename(TextLayoutCopy) TextLayout::TextLayout(const TextLayout&);
%rename(TypefaceCopy) Typeface::Typeface(const Typeface&);
%rename(AffineTransformCopy) AffineTransform::AffineTransform(const AffineTransform&) throw();
%rename(LineCopy) Line::Line(const Line&);
%rename(PathCopy) Path::Path(const Path&) throw();
%rename(PointCopy) Point::Point(const Point&);
%rename(RectangleList) RectangleList::RectangleList(const RectangleList&) throw();
%rename(ImageCopy) Image::Image(const Image&);
%rename(KeyPressCopy) KeyPress::KeyPress(const KeyPress&) throw();
%rename(ModifierKeysCopy) ModifierKeys::ModifierKeys(const ModifierKeys&) throw();
%rename(PopupMenuCopy) PopupMenu::PopupMenu(const PopupMenu&);
%rename(MouseCursorCopy) MouseCursor::MouseCursor(const MouseCursor&) throw();

// Thread::yield --> yield is a python keyword !
%rename(handover) yield;
%rename(ComponentWithName) Component::Component(const String& componentName) throw();

%{
typedef MidiMessageSequence::MidiEventHolder MidiEventHolder;
%}
%{
typedef ZipFile::ZipEntry ZipEntry;
%}
namespace JUCE
{
    class MouseHoverDetector
    {
    public:
        MouseHoverDetector (const int hoverTimeMillisecs = 400);
        virtual ~MouseHoverDetector();
        void setHoverTimeMillisecs (const int newTimeInMillisecs);
        void setHoverComponent (Component* const newSourceComponent);
    protected:
        virtual void mouseHovered (int mouseX, int mouseY) = 0;
        virtual void mouseMovedAfterHover() = 0;
    };
}
//
//
// DIRECTORS
//
%{
#include <iostream>
%}
%feature("director");
%feature("director:except")
{
    if($error)
    {
        PyErr_Print();
        throw Swig::DirectorMethodException();
    }
}
%exception
{
    try
    {
        $action;
    }
    catch(const Swig::DirectorException &e)
    {
        SWIG_exception(SWIG_UnknownError, e.getMessage());
    }
    catch(const std::runtime_error &e)
    {
        SWIG_exception(SWIG_RuntimeError, e.what());
    }
    catch(const std::exception &e)
    {
        SWIG_exception(SWIG_UnknownError, e.what());
    }
    catch(...)
    {
        SWIG_exception(SWIG_UnknownError, "");
    }
}
// Some problems with variable length arguments
%feature("nodirector") OutputStream;
%feature("nodirector") FileOutputStream;
%feature("nodirector") GZIPCompressorOutputStream;
%feature("nodirector") MemoryOutputStream;
%feature("nodirector") LookAndFeel;
%feature("nodirector") NativeDesktopWindow;
// Those classes are abstract but SWIG generates constructors wrappers anyway ...
%ignore InputStream::InputStream;
%ignore AudioFormatReader::AudioFormatReader;
// Not implemented in JUCE 1.9 (bug ?)
%ignore SystemStats::getEnvironmentVariable;
%ignore ThreadPoolJob::setJobName;
%ignore Label::actionListenerCallback;
#define _WIN32
// VisualStudio specific keywords
#define __int64 long long
#define __fastcall
// JUCE specific keywords
#define forcedinline
#define inline_assembly
%include <juce/juce.h>

///////////////////////////////////////////////////////////////////////////////
//
//                                   JUCE CORE
//
///////////////////////////////////////////////////////////////////////////////
//
//
// JUCE CORE - BASICS
//
// defines juce_UseDebuggingNewOperator --> include it first
%include <juce/modules/juce_core/memory/juce_Memory.h>
// @see http://www.swig.org/Doc1.3/Preprocessor.html#Preprocessor_nn5
// %include <juce/modules/juce_core/system/juce_PlatformDefs.h>
%include <juce/modules/juce_core/memory/juce_Atomic.h>
//%include <juce/modules/juce_core/basics/juce_DataConversions.h>
%include <juce/modules/juce_core/logging/juce_FileLogger.h>
%include <juce/modules/juce_core/logging/juce_Logger.h>
%include <juce/modules/juce_core/maths/juce_MathsFunctions.h>
%include <juce/modules/juce_core/maths/juce_Random.h>
%include <juce/modules/juce_core/time/juce_RelativeTime.h>
%include <juce/modules/juce_core/memory/juce_Singleton.h>
%include <juce/modules/juce_core/system/juce_StandardHeader.h>
%include <juce/modules/juce_core/system/juce_SystemStats.h>
%include <juce/modules/juce_core/time/juce_Time.h>
//
//
// JUCE CORE - CONTAINERS
//
%include <juce/modules/juce_core/containers/juce_Array.h>
%include <juce/modules/juce_core/containers/juce_ArrayAllocationBase.h>
//%include <juce/modules/juce_core/containers/juce_BitArray.h>
%include <juce/modules/juce_core/containers/juce_ElementComparator.h>
%apply String &OUTPUT { String &destString }; // MemoryBlockBase::to64BitEncoding
// AlignedMemoryBlock::AlignedMemoryBlock(int) is ambiguous !!
// %include <juce/modules/juce_core/containers/juce_MemoryBlock.h>
%clear String &destString;
%include <juce/modules/juce_core/containers/juce_OwnedArray.h>
%include <juce/modules/juce_core/containers/juce_ReferenceCountedArray.h>
%include <juce/modules/juce_core/memory/juce_ReferenceCountedObject.h>
%include <juce/modules/juce_core/containers/juce_SortedSet.h>
%include <juce/modules/juce_core/containers/juce_SparseSet.h>
//%include <juce/modules/juce_core/containers/juce_VoidArray.h>
//
//
// JUCE CORE - CRYPTOGRAPHY
//
%include <juce/modules/juce_cryptography/encryption/juce_BlowFish.h>
%include <juce/modules/juce_cryptography/hashing/juce_MD5.h>
%include <juce/modules/juce_cryptography/encryption/juce_Primes.h>
%include <juce/modules/juce_cryptography/encryption/juce_RSAKey.h>
//
//
// JUCE CORE - IO
//
%include <juce/modules/juce_core/streams/juce_InputStream.h>
%include <juce/modules/juce_core/streams/juce_OutputStream.h>
%include <juce/modules/juce_core/files/juce_DirectoryIterator.h>
%include <juce/modules/juce_core/files/juce_File.h>
%include <juce/modules/juce_core/files/juce_FileInputStream.h>
%include <juce/modules/juce_core/files/juce_FileOutputStream.h>
%include <juce/modules/juce_core/files/juce_FileSearchPath.h>
%include <juce/modules/juce_core/network/juce_URL.h>
%include <juce/modules/juce_core/streams/juce_BufferedInputStream.h>
%include <juce/modules/juce_core/zip/juce_GZIPCompressorOutputStream.h>
%include <juce/modules/juce_core/zip/juce_GZIPDecompressorInputStream.h>
%include <juce/modules/juce_core/streams/juce_MemoryInputStream.h>
%include <juce/modules/juce_core/streams/juce_MemoryOutputStream.h>
%include <juce/modules/juce_core/streams/juce_SubregionStream.h>
// Zlib don t compile
// %include <juce/modules/juce_core/io/streams/zlib/deflate.h>
// %include <juce/modules/juce_core/io/streams/zlib/infblock.h>
// %include <juce/modules/juce_core/io/streams/zlib/infcodes.h>
// %include <juce/modules/juce_core/io/streams/zlib/inffast.h>
// %include <juce/modules/juce_core/io/streams/zlib/inffixed.h>
// %include <juce/modules/juce_core/io/streams/zlib/inftrees.h>
// %include <juce/modules/juce_core/io/streams/zlib/infutil.h>
// %include <juce/modules/juce_core/io/streams/zlib/trees.h>
// %include <juce/modules/juce_core/io/streams/zlib/zconf.h>
// %include <juce/modules/juce_core/io/streams/zlib/zlib.h>
// %include <juce/modules/juce_core/io/streams/zlib/zutil.h>
//
//
// JUCE CORE - MISC
//
%include <juce/modules/juce_core/time/juce_PerformanceCounter.h>
//%include <juce/modules/juce_core/misc/juce_PlatformUtilities.h>
%include <juce/modules/juce_core/misc/juce_Uuid.h>
%include <juce/modules/juce_core/zip/juce_ZipFile.h>
//
//
// JUCE CORE - TEXT
//
%include <pystrings.swg>
%fragment(SWIG_AsPtr_frag(String),"header", fragment="SWIG_AsCharPtrAndSize")
{
    SWIGINTERN int SWIG_AsPtr(String)(PyObject* obj, String **val)
    {
        static swig_type_info *string_info = SWIG_TypeQuery("String *");
        String *vptr;    
        if(SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) != -1)
        {
            if(val)
                *val = vptr;
            return SWIG_OLDOBJ;
        }
        else
        {
            PyErr_Clear();
            char *buf = 0;
            size_t size = 0;
            if(SWIG_AsCharPtrAndSize(obj, &buf, &size))
            {
                if(buf)
                {
                    if(val)
                        *val = new String(buf, size - 1);
                    return SWIG_NEWOBJ;
                }
            }
            else
                PyErr_Clear();
            if(val)
                PyErr_SetString(PyExc_TypeError,"a string is expected");
            return 0;
        }
    }
}
%fragment(SWIG_From_frag(String),"header", fragment="SWIG_FromCharArray")
{
    SWIGINTERNSHORT PyObject *SWIG_From(String)(const String &s)
    {
        return SWIG_FromCharArray((const char*)(s), s.length());
    }
}
%fragment(SWIG_AsVal_frag(String),"header", fragment=SWIG_AsPtr_frag(String))
{
    SWIGINTERN int SWIG_AsVal(String)(PyObject* obj, String *val)
    {
        String *s;
        int res = SWIG_AsPtr(String)(obj, &s);
        if(res && s)
        {
            if(val)
                *val = *s;
            if(res == SWIG_NEWOBJ)
                delete s;
            return res;
        }
        
        if(val)
            PyErr_SetString(PyExc_TypeError,"a string is expected");
            
        return 0;
    }
}
%typemap_asptrfromn(SWIG_CCode(STRING), String);
%include <juce/modules/juce_core/text/juce_String.h>
%include <juce/modules/juce_core/text/juce_LocalisedStrings.h>
%include <juce/modules/juce_core/text/juce_StringArray.h>
%include <juce/modules/juce_core/text/juce_StringPairArray.h>
//%include <juce/modules/juce_core/text/juce_TextFunctions.h>
%include <juce/modules/juce_core/xml/juce_XmlDocument.h>
%include <juce/modules/juce_core/xml/juce_XmlElement.h>
//
//
// JUCE CORE - THREADS
//
%include <juce/modules/juce_core/threads/juce_CriticalSection.h>
%include <juce/modules/juce_core/threads/juce_InterProcessLock.h>
%include <juce/modules/juce_core/threads/juce_Process.h>
%include <juce/modules/juce_core/threads/juce_ReadWriteLock.cpp>
%include <juce/modules/juce_core/threads/juce_ReadWriteLock.h>
%include <juce/modules/juce_core/threads/juce_ScopedLock.h>
%include <juce/modules/juce_core/threads/juce_ScopedReadLock.h>
%include <juce/modules/juce_core/threads/juce_ScopedWriteLock.h>
%include <juce/modules/juce_core/threads/juce_Thread.h>
%include <juce/modules/juce_core/threads/juce_ThreadPool.h>
%include <juce/modules/juce_core/threads/juce_TimeSliceThread.h>
%include <juce/modules/juce_core/threads/juce_WaitableEvent.h>


///////////////////////////////////////////////////////////////////////////////
//
//                        JUCE APPLICATION FRAMEWORK
//
///////////////////////////////////////////////////////////////////////////////
%{
    class PyJUCEApplication : public JUCE::JUCEApplication
    {
    public:
        PyJUCEApplication(const JUCE::String &applicationName, PyObject *initialiseCallback, PyObject *shutdownCallback)
        : applicationName(applicationName), initialiseCallback(initialiseCallback), shutdownCallback(shutdownCallback)
        {;}
        
        virtual void initialise(const String &commandLineParameters)
        {
            if(!initialiseCallback || (initialiseCallback == Py_None))
                return;
            ::PyObject *args = ::PyTuple_New(0);
            if(!args)
                throw this;
            ::PyObject *result = ::PyObject_Call(initialiseCallback, args, NULL);
            if(!result && ::PyErr_Occurred())
            {
                ::PyErr_Print();
                throw this;
            }
            Py_XDECREF(args);
            Py_XDECREF(result);
        }
        virtual void shutdown()
        {
            if(!shutdownCallback || (shutdownCallback == Py_None))
                return;
            ::PyObject *args = ::PyTuple_New(0);
            if(!args)
                throw this;
            ::PyObject *result = ::PyObject_Call(shutdownCallback, args, NULL);
            if(!result && ::PyErr_Occurred())
            {
                ::PyErr_Print();
                throw this;
            }
            Py_XDECREF(args);
            Py_XDECREF(result);
        }
        const String getApplicationName()
        {
            return applicationName;
        }
    private:
        JUCE::String applicationName;
        ::PyObject *initialiseCallback,
                   *shutdownCallback;
    };

%}
%inline %{
    void mainLoop(const JUCE::String &applicationName, ::PyObject *initialiseCallback = 0, ::PyObject *shutdownCallback = 0)
    {
        JUCE::JUCEApplication::main(0, new PyJUCEApplication(applicationName, initialiseCallback, shutdownCallback));
    }
    void quit(bool useMaximumForce = false)
    {
        JUCE::JUCEApplication::quit(useMaximumForce);
    }
%}
// We use our own Application
// %include <juce/modules/juce_appframework/application/juce_Application.h>
%include <juce/modules/juce_events/messages/juce_DeletedAtShutdown.h>
%include <juce/modules/juce_gui_basics/keyboard/juce_SystemClipboard.h>
//
//
// JUCE APPLICATION FRAMEWORK - EVENTS
//
%include <juce/modules/juce_events/messages/juce_Message.h>
%include <juce/modules/juce_events/messages/juce_MessageListener.h>
%include <juce/modules/juce_events/broadcasters/juce_ActionBroadcaster.h>
%include <juce/modules/juce_events/broadcasters/juce_ActionListener.h>
//%include <juce/modules/juce_appframework/events/juce_ActionListenerList.h>
%include <juce/modules/juce_events/broadcasters/juce_AsyncUpdater.h>
%include <juce/modules/juce_events/broadcasters/juce_ChangeBroadcaster.h>
%include <juce/modules/juce_events/broadcasters/juce_ChangeListener.h>
//%include <juce/modules/juce_appframework/events/juce_ChangeListenerList.h>
%include <juce/modules/juce_events/messages/juce_MessageManager.h>
%include <juce/modules/juce_events/timers/juce_Timer.h>
//
//
// JUCE APPLICATION FRAMEWORK - AUDIO
//
//%include <juce/modules/juce_appframework/audio/juce_ASIOAudioIODevice.h>
%include <juce/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h>
%include <juce/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h>
%include <juce/modules/juce_audio_basics/midi/juce_MidiFile.h>
%include <juce/modules/juce_audio_devices/midi_io/juce_MidiInput.h>
%apply int &OUTPUT { int &hours, int &minutes, int &seconds, int &frames }; // MidiMessage::getFullFrameParameters
%apply SmpteTimecodeType &OUTPUT { SmpteTimecodeType &timecodeType }; // MidiMessage::getFullFrameParameters
%apply int &INOUT { int &hours, int &minutes, int &seconds, int &frames }; // MidiMessage::isMidiMachineControlGoto 
%apply int &INOUT { int &numBytesUsed }; // MidiMessage::readVariableLengthVal
%include <juce/modules/juce_audio_basics/midi/juce_MidiMessage.h>
%clear int &numBytesUsed;
%clear int &hours, int &minutes, int &seconds, int &frames;
%clear SmpteTimecodeType &timecodeType;
%clear int &hours, int &minutes, int &seconds, int &frames;
%include <juce/modules/juce_audio_basics/midi/juce_MidiMessageSequence.h>
%apply float &OUTPUT { float &leftVol, float &rightVol }; // MidiOutput::getVolume
%include <juce/modules/juce_audio_devices/midi_io/juce_MidiOutput.h>
%clear float &leftVol, float &rightVol;
%include <juce/modules/juce_audio_formats/format/juce_AudioFormat.h>
%apply float &OUTPUT { float& lowestLeft, float& highestLeft, float& lowestRight, float& highestRight };
%include <juce/modules/juce_audio_formats/format/juce_AudioFormatReader.h>
%clear float& lowestLeft, float& highestLeft, float& lowestRight, float& highestRight;
%include <juce/modules/juce_audio_formats/codecs/juce_AiffAudioFormat.h>
%nodefault; // SWIG don t see AudioCDReader already has a contructor with arguments
%include <juce/modules/juce_audio_devices/audio_cd/juce_AudioCDReader.h>
%makedefault;
%include <juce/modules/juce_audio_formats/format/juce_AudioFormatWriter.h>
%include <juce/modules/juce_audio_formats/format/juce_AudioSubsectionReader.h>
%include <juce/modules/juce_audio_formats/codecs/juce_WavAudioFormat.h>
%include <juce/modules/juce_audio_basics/sources/juce_AudioSource.h>
%include <juce/modules/juce_audio_basics/sources/juce_PositionableAudioSource.h>
%include <juce/modules/juce_audio_formats/format/juce_AudioFormatReaderSource.h>
%include <juce/modules/juce_audio_devices/sources/juce_AudioSourcePlayer.h>
%include <juce/modules/juce_audio_devices/sources/juce_AudioTransportSource.h>
%include <juce/modules/juce_audio_basics/sources/juce_BufferingAudioSource.h>
%include <juce/modules/juce_audio_basics/sources/juce_MixerAudioSource.h>
%include <juce/modules/juce_audio_basics/sources/juce_ResamplingAudioSource.h>
//
//
// JUCE APPLICATION FRAMEWORK - GUI (GRAPHICS)
//

%extend AffineTransform
{
    AffineTransform __mul__(AffineTransform *x)
    {
        return self->followedBy(*x);
    }
    
    %pythoncode
    {
        def transform(self, point):
            (x, y) = point
            self.transformPoint(xp, yp)
            return (x, y)
    }
};
%implicit(Justification, int);
%inline
{
int get(const Justification &justification)
{
    return justification.getFlags();
}
}
//%include <juce/modules/juce_appframework/gui/graphics/brushes/juce_Brush.h>
//%include <juce/modules/juce_appframework/gui/graphics/brushes/juce_GradientBrush.h>
//%include <juce/modules/juce_appframework/gui/graphics/brushes/juce_ImageBrush.h>
//%include <juce/modules/juce_appframework/gui/graphics/brushes/juce_SolidColourBrush.h>
%apply float &OUTPUT { float& hue, float& saturation, float& brightness };
%include <juce/modules/juce_graphics/colour/juce_Colour.h>
%clear float& hue, float& saturation, float& brightness;
%include <juce/modules/juce_graphics/colour/juce_Colours.h>
%include <juce/modules/juce_graphics/colour/juce_PixelFormats.h>
%include <juce/modules/juce_graphics/geometry/juce_EdgeTable.h>
%apply float &OUTPUT { int &originX, int &originY }; // Graphics::getUnderlyingImage 
%include <juce/modules/juce_graphics/juce_Graphics.h>
%clear int &originX, int &originY;
%apply int &OUTPUT { int &x, int &y }; // Justification::applyToRectangle 
%include <juce/modules/juce_graphics/placement/juce_Justification.h>
%clear int &x, int &y;
%include <juce/modules/juce_graphics/effects/juce_ImageEffectFilter.h>
%include <juce/modules/juce_graphics/effects/juce_DropShadowEffect.h>
%include <juce/modules/juce_graphics/effects/juce_GlowEffect.h>
//%include <juce/modules/juce_graphics/effects/juce_ReduceOpacityEffect.h>
%include <juce/modules/juce_graphics/fonts/juce_Font.h>
%apply float &OUTPUT { float &left, float &top, float &right, float &bottom };
%include <juce/modules/juce_graphics/fonts/juce_GlyphArrangement.h>
%clear float &left, float &top, float &right, float &bottom;
%include <juce/modules/juce_graphics/fonts/juce_TextLayout.h>
%include <juce/modules/juce_graphics/fonts/juce_Typeface.h>
%apply float &INOUT { float& x, float& y };
%include <juce/modules/juce_graphics/geometry/juce_AffineTransform.h>
%clear float& x, float& y;
%apply float &OUTPUT { float &intersectionX, float &intersectionY }; // Line::intersects
%include <juce/modules/juce_graphics/geometry/juce_Line.h>
%clear float &intersectionX, float &intersectionY;
%apply float &OUTPUT { float &x, float &y, float &w, float &h }; // Path::getBounds
%include <juce/modules/juce_graphics/geometry/juce_Path.h>
%clear float &x, float &y, float &w, float &h;
%include <juce/modules/juce_graphics/geometry/juce_PathIterator.h>
%include <juce/modules/juce_graphics/geometry/juce_PathStrokeType.h>
%include <juce/modules/juce_graphics/geometry/juce_Point.h>
%apply int &INOUT { int &x1, int &y1, int &w1, int &h1 }; // Rectangle::intersectRectangles
%include <juce/modules/juce_graphics/geometry/juce_Rectangle.h>
%clear int &x1, int &y1, int &w1, int &h1;
%include <juce/modules/juce_graphics/geometry/juce_RectangleList.h>
// SWIG can t parse libjpeg headers
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/deflate.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jconfig.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jdct.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jdhuff.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jerror.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jinclude.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jmemsys.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jmorecfg.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jpegint.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jpeglib.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/jpglib/jversion.h>
// Don t use GIFLoader directly in an application
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/juce_GIFLoader.h>
// SWIG can t parse libpng headers
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/pnglib/png.h>
// %include <juce/modules/juce_appframework/gui/graphics/imaging/image_file_formats/pnglib/pngconf.h>
%include <juce/modules/juce_graphics/images/juce_Image.h>
%include <juce/modules/juce_graphics/images/juce_ImageCache.h>
%include <juce/modules/juce_graphics/images/juce_ImageConvolutionKernel.h>
%include <juce/modules/juce_graphics/images/juce_ImageFileFormat.h>
//
//
// JUCE APPLICATION FRAMEWORK - GUI (COMPONENTS)
//
%include <juce/modules/juce_gui_basics/keyboard/juce_KeyListener.h>
%include <juce/modules/juce_gui_basics/keyboard/juce_KeyPress.h>
%include <juce/modules/juce_gui_basics/commands/juce_KeyPressMappingSet.h>
%include <juce/modules/juce_gui_basics/keyboard/juce_ModifierKeys.h>
%apply JUCE::Colour &OUTPUT { JUCE::Colour &text, JUCE::Colour &background, JUCE::Colour &highlightText, JUCE::Colour &highlightBackground }; // LookAndFeel::getPopupMenuColours
%apply int &OUTPUT { int &idealWidth, int &idealHeight }; // LookAndFeel::getIdealPopupMenuItemSize
%apply JUCE::Colour &OUTPUT { JUCE::Colour &background, JUCE::Colour &textColour, JUCE::Colour &outlineColour, JUCE::Colour &buttonColour, JUCE::Colour &popupBackground, JUCE::Colour &popupText, JUCE::Colour &popupHighlight }; // LookAndFeel::getComboBoxColours
// LookAndFeel::getComboBoxFonts
// LookAndFeel::getSliderColours 
// LookAndFeel::getSliderFont 
// LookAndFeel::getTooltipSize 
%include <juce/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel.h>
%clear JUCE::Colour &background, JUCE::Colour &textColour, JUCE::Colour &outlineColour, JUCE::Colour &buttonColour, JUCE::Colour &popupBackground, JUCE::Colour &popupText, JUCE::Colour &popupHighlight;
%clear int &idealWidth, int &idealHeight;
%clear JUCE::Colour &text, JUCE::Colour &background, JUCE::Colour &highlightText, JUCE::Colour &highlightBackground;
%include <juce/modules/juce_gui_basics/mouse/juce_MouseCursor.h>
%include <juce/modules/juce_gui_basics/mouse/juce_MouseEvent.h>
// Nested class MouseHoverDetector::HoverDetectorInternal is not supported by SWIG parser
// Use a "manual" proxy class
// %include <juce/modules/juce_appframework/gui/gui_components/mouse/juce_MouseHoverDetector.h>
%include <juce/modules/juce_gui_basics/mouse/juce_MouseListener.h>
%apply RectangleList &OUTPUT { RectangleList &result };
%include <juce/modules/juce_gui_basics/components/juce_Component.h>
%clear RectangleList &result;
%include <juce/modules/juce_gui_basics/components/juce_ComponentListener.h>
%apply int &OUTPUT { int &x, int &y }; // Desktop::getMousePosition, Desktop::getLastMouseDownPosition
%include <juce/modules/juce_gui_basics/components/juce_Desktop.h>
%clear int &x, int &y;
//%include <juce/modules/juce_gui_basics/menus/juce_MenuBar.h>
%include <juce/modules/juce_gui_basics/menus/juce_PopupMenu.h>
//%include <juce/modules/juce_gui_basics/menus/juce_PopupMenuCustomComponent.h>
%include <juce/modules/juce_gui_basics/misc/juce_BubbleComponent.h>
%include <juce/modules/juce_gui_extra/misc/juce_ColourSelector.h>
%include <juce/modules/juce_gui_basics/widgets/juce_ComboBox.h>
%include <juce/modules/juce_gui_basics/mouse/juce_DragAndDropContainer.h>
%include <juce/modules/juce_gui_basics/mouse/juce_DragAndDropTarget.h>
%include <juce/modules/juce_gui_basics/misc/juce_DropShadower.h>
%include <juce/modules/juce_gui_basics/filebrowser/juce_FilenameComponent.h>
%include <juce/modules/juce_gui_basics/widgets/juce_ListBox.h>
//%include <juce/modules/juce_gui_basics/widgets/juce_OpenGLComponent.h>
//%include <juce/modules/juce_gui_basics/widgets/juce_SimpleListBox.h>
%include <juce/modules/juce_gui_extra/misc/juce_KeyMappingEditorComponent.h>
%include <juce/modules/juce_gui_basics/widgets/juce_TextEditor.h>
%include <juce/modules/juce_gui_basics/widgets/juce_Label.h>
%include <juce/modules/juce_video/playback/juce_QuickTimeMovieComponent.h>
//%include <juce/modules/juce_gui_basics/widgets/juce_ResizerComponent.h>
%include <juce/modules/juce_gui_basics/layout/juce_ScrollBar.h>
%include <juce/modules/juce_gui_basics/widgets/juce_Slider.h>
%include <juce/modules/juce_gui_basics/layout/juce_TabbedComponent.h>
%include <juce/modules/juce_gui_basics/windows/juce_ThreadWithProgressWindow.h>
%include <juce/modules/juce_gui_basics/windows/juce_ToolTipWindow.h>
%include <juce/modules/juce_gui_basics/widgets/juce_TreeView.h>
%include <juce/modules/juce_gui_basics/layout/juce_Viewport.h>
// SWIG bug !
// %include <juce/modules/juce_appframework/gui/gui_components/buttons/juce_Button.h>
%include <juce/modules/juce_gui_basics/buttons/juce_ArrowButton.h>
%include <juce/modules/juce_gui_basics/buttons/juce_HyperlinkButton.h>
%include <juce/modules/juce_gui_basics/buttons/juce_ImageButton.h>
%include <juce/modules/juce_gui_basics/buttons/juce_ShapeButton.h>
%include <juce/modules/juce_gui_basics/buttons/juce_TextButton.h>
%include <juce/modules/juce_gui_basics/buttons/juce_ToggleButton.h>
%include <juce/modules/juce_gui_basics/windows/juce_AlertWindow.h>
%include <juce/modules/juce_gui_basics/windows/juce_DialogWindow.h>
%include <juce/modules/juce_gui_basics/filebrowser/juce_FileChooser.h>
%apply int &OUTPUT { int &x, int &y, int &w, int &h }; // NativeDesktopWindow::getBounds
%apply int &OUTPUT { int &leftThickness, int &topThickness, int &bottomThickness, int &rightThickness }; // NativeDesktopWindow::getFrameSize
//%include <juce/modules/juce_gui_basics/windows/juce_NativeDesktopWindow.h>
%clear int &x, int &y, int &w, int &h;
%clear int &leftThickness, int &topThickness, int &bottomThickness, int &rightThickness;
%include <juce/modules/juce_gui_extra/misc/juce_SplashScreen.h>


//
//
// JUCE APPLICATION FRAMEWORK - TOOLBAG
//
%include <juce/modules/juce_data_structures/app_properties/juce_PropertiesFile.h>
%include <juce/modules/juce_data_structures/undomanager/juce_UndoableAction.h>
%include <juce/modules/juce_data_structures/undomanager/juce_UndoManager.h>


#2

I get an error when running swig :

juce\modules\juce_core\memory\juce_Atomic.h(73) : Warning 362: operator= ignored
juce\modules\juce_core\memory\juce_Atomic.h(76) : Warning 362: operator= ignored
juce\modules\juce_core\memory\juce_Atomic.h(79) : Warning 321: 'set' conflicts with a built-in name in python
juce\modules\juce_core\memory\juce_Atomic.h(91) : Warning 383: operator++ ignored
juce\modules\juce_core\memory\juce_Atomic.h(94) : Warning 384: operator-- ignored
juce\modules\juce_core\memory\juce_Atomic.h(146) : Error: Syntax error in input(3).

 

This seems to do with the JUCE_ALIGN macro at juce_Atomic.h(146) . I wonder if anyone knows how to ensure proper macro processing with SWIG.