diff --git a/extras/Jucer (experimental)/Builds/Linux/Makefile b/extras/Jucer (experimental)/Builds/Linux/Makefile index e348fc5946..0955bbd1da 100644 --- a/extras/Jucer (experimental)/Builds/Linux/Makefile +++ b/extras/Jucer (experimental)/Builds/Linux/Makefile @@ -45,6 +45,7 @@ endif OBJECTS := \ $(OBJDIR)/jucer_ComponentTypeManager.o \ $(OBJDIR)/jucer_ComponentDocument.o \ + $(OBJDIR)/jucer_CodeGenerator.o \ $(OBJDIR)/jucer_Coordinate.o \ $(OBJDIR)/jucer_DrawableDocument.o \ $(OBJDIR)/jucer_NewFileWizard.o \ @@ -100,6 +101,11 @@ $(OBJDIR)/jucer_ComponentDocument.o: ../../Source/model/jucer_ComponentDocument. @echo $(notdir $<) @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" +$(OBJDIR)/jucer_CodeGenerator.o: ../../Source/model/jucer_CodeGenerator.cpp + -@mkdir -p $(OBJDIR) + @echo $(notdir $<) + @$(CXX) $(CXXFLAGS) -o "$@" -c "$<" + $(OBJDIR)/jucer_Coordinate.o: ../../Source/model/jucer_Coordinate.cpp -@mkdir -p $(OBJDIR) @echo $(notdir $<) diff --git a/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj b/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj index 496b9e545c..77cbb223d0 100644 --- a/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj +++ b/extras/Jucer (experimental)/Builds/MacOSX/The Jucer.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 2E6836738CE7EB452FDC7E9A = { isa = PBXBuildFile; fileRef = D9FB1A5365FEEB854A0FF7BF; }; 52D75B8B0F52DD4F37A4B1C0 = { isa = PBXBuildFile; fileRef = 82A1EC47692975C7031B3973; }; CD4226951C3F7FE19CF8A7CE = { isa = PBXBuildFile; fileRef = 2D6D6985B452EA0B67A18914; }; + 8E859D542404B684D5E1545F = { isa = PBXBuildFile; fileRef = 42CEC4195577AE91AA6CBA7F; }; 1DF9688E29753A0459E6C32A = { isa = PBXBuildFile; fileRef = 45C80436FD5A8438D0E6BE17; }; 1174D3512AF8207950094C56 = { isa = PBXBuildFile; fileRef = FF625CB50FB5C3536BA40604; }; 087CCE9E7146F1EC4F241254 = { isa = PBXBuildFile; fileRef = DA142548FCADFAC50648ED3C; }; @@ -77,6 +78,8 @@ 03AD2BF6C80C6AF47BBDB7E9 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_Viewport.h; path = "../../Source/model/Component Types/jucer_Viewport.h"; sourceTree = SOURCE_ROOT; }; 2D6D6985B452EA0B67A18914 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_ComponentDocument.cpp; path = ../../Source/model/jucer_ComponentDocument.cpp; sourceTree = SOURCE_ROOT; }; E6CC3A04349F6B227FDAB26F = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentDocument.h; path = ../../Source/model/jucer_ComponentDocument.h; sourceTree = SOURCE_ROOT; }; + 42CEC4195577AE91AA6CBA7F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_CodeGenerator.cpp; path = ../../Source/model/jucer_CodeGenerator.cpp; sourceTree = SOURCE_ROOT; }; + FE3EB6472027A398A978CBE4 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_CodeGenerator.h; path = ../../Source/model/jucer_CodeGenerator.h; sourceTree = SOURCE_ROOT; }; 45C80436FD5A8438D0E6BE17 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_Coordinate.cpp; path = ../../Source/model/jucer_Coordinate.cpp; sourceTree = SOURCE_ROOT; }; 420E4189E7DE25E9D0D8E5B8 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_Coordinate.h; path = ../../Source/model/jucer_Coordinate.h; sourceTree = SOURCE_ROOT; }; FF625CB50FB5C3536BA40604 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_DrawableDocument.cpp; path = ../../Source/model/jucer_DrawableDocument.cpp; sourceTree = SOURCE_ROOT; }; @@ -143,6 +146,8 @@ 1C52B91B15DF56E0A37F3EEE = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_AudioPluginEditorTemplate.h; path = ../../Source/templates/jucer_AudioPluginEditorTemplate.h; sourceTree = SOURCE_ROOT; }; 4D62A4E094921086FBB82248 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_AudioPluginFilterTemplate.cpp; path = ../../Source/templates/jucer_AudioPluginFilterTemplate.cpp; sourceTree = SOURCE_ROOT; }; C2AE936214AC10DC4FABAC2F = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_AudioPluginFilterTemplate.h; path = ../../Source/templates/jucer_AudioPluginFilterTemplate.h; sourceTree = SOURCE_ROOT; }; + AC0E488751C4C402D9D84B93 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_ComponentTemplate.cpp; path = ../../Source/templates/jucer_ComponentTemplate.cpp; sourceTree = SOURCE_ROOT; }; + B2FB0FD53553DB371FD1C748 = { isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = jucer_ComponentTemplate.h; path = ../../Source/templates/jucer_ComponentTemplate.h; sourceTree = SOURCE_ROOT; }; 061B86C84B0D279F1EABBBE2 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_MainConsoleAppTemplate.cpp; path = ../../Source/templates/jucer_MainConsoleAppTemplate.cpp; sourceTree = SOURCE_ROOT; }; 1EC5B7483B37A4163CA19549 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_MainTemplate.cpp; path = ../../Source/templates/jucer_MainTemplate.cpp; sourceTree = SOURCE_ROOT; }; 4A80C6415DB1C1CB47DBE23F = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = jucer_NewCppFileTemplate.cpp; path = ../../Source/templates/jucer_NewCppFileTemplate.cpp; sourceTree = SOURCE_ROOT; }; @@ -177,6 +182,8 @@ D3D6EC2C17524688F2E803EB, 2D6D6985B452EA0B67A18914, E6CC3A04349F6B227FDAB26F, + 42CEC4195577AE91AA6CBA7F, + FE3EB6472027A398A978CBE4, 45C80436FD5A8438D0E6BE17, 420E4189E7DE25E9D0D8E5B8, FF625CB50FB5C3536BA40604, @@ -251,6 +258,8 @@ 1C52B91B15DF56E0A37F3EEE, 4D62A4E094921086FBB82248, C2AE936214AC10DC4FABAC2F, + AC0E488751C4C402D9D84B93, + B2FB0FD53553DB371FD1C748, 061B86C84B0D279F1EABBBE2, 1EC5B7483B37A4163CA19549, 4A80C6415DB1C1CB47DBE23F, @@ -359,6 +368,7 @@ 5362E03ADF975A126C1F2F7B = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 52D75B8B0F52DD4F37A4B1C0, CD4226951C3F7FE19CF8A7CE, + 8E859D542404B684D5E1545F, 1DF9688E29753A0459E6C32A, 1174D3512AF8207950094C56, 087CCE9E7146F1EC4F241254, diff --git a/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj b/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj index e95c9cbdee..d7771a24fe 100644 --- a/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj +++ b/extras/Jucer (experimental)/Builds/VisualStudio2005/The Jucer.vcproj @@ -151,6 +151,8 @@ + + @@ -274,6 +276,26 @@ + + + + + + + + + + + + + + + + diff --git a/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj b/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj index 16e97f17c0..0886514e0e 100644 --- a/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj +++ b/extras/Jucer (experimental)/Builds/VisualStudio2008/The Jucer.vcproj @@ -151,6 +151,8 @@ + + @@ -274,6 +276,26 @@ + + + + + + + + + + + + + + + + diff --git a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp index 946a515824..f1ed9b676e 100644 --- a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp +++ b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.cpp @@ -22,6 +22,8 @@ const char* BinaryData::getNamedResource (const char* resourceNameUTF8, int& num case 0x4d0721bf: numBytes = BinaryData::jucer_AudioPluginEditorTemplate_hSize; return BinaryData::jucer_AudioPluginEditorTemplate_h; case 0x51b49ac5: numBytes = BinaryData::jucer_AudioPluginFilterTemplate_cppSize; return BinaryData::jucer_AudioPluginFilterTemplate_cpp; case 0x488afa0a: numBytes = BinaryData::jucer_AudioPluginFilterTemplate_hSize; return BinaryData::jucer_AudioPluginFilterTemplate_h; + case 0xabad7041: numBytes = BinaryData::jucer_ComponentTemplate_cppSize; return BinaryData::jucer_ComponentTemplate_cpp; + case 0xfc72fe86: numBytes = BinaryData::jucer_ComponentTemplate_hSize; return BinaryData::jucer_ComponentTemplate_h; case 0x8905395b: numBytes = BinaryData::jucer_MainConsoleAppTemplate_cppSize; return BinaryData::jucer_MainConsoleAppTemplate_cpp; case 0x7a0186b1: numBytes = BinaryData::jucer_MainTemplate_cppSize; return BinaryData::jucer_MainTemplate_cpp; case 0x02a2a077: numBytes = BinaryData::jucer_NewCppFileTemplate_cppSize; return BinaryData::jucer_NewCppFileTemplate_cpp; @@ -416,6 +418,155 @@ static const unsigned char temp_a7c425dd[] = const char* BinaryData::jucer_AudioPluginFilterTemplate_h = (const char*) temp_a7c425dd; +//================== jucer_ComponentTemplate.cpp ================== +static const unsigned char temp_73015554[] = +"/*\r\n" +" ==============================================================================\r\n" +"\r\n" +" This is an automatically generated file created by the Jucer!\r\n" +"\r\n" +" Creation date: %%creationTime%%\r\n" +"\r\n" +" Be careful when adding custom code to these files, as only the code within\r\n" +" the \"//[xyz]\" and \"//[/xyz]\" sections will be retained when the file is loaded\r\n" +" and re-saved.\r\n" +"\r\n" +" Jucer version: 1.12\r\n" +"\r\n" +" ------------------------------------------------------------------------------\r\n" +"\r\n" +" The Jucer is part of the JUCE library - \"Jules' Utility Class Extensions\"\r\n" +" Copyright 2004-6 by Raw Material Software ltd.\r\n" +"\r\n" +" ==============================================================================\r\n" +"*/\r\n" +"\r\n" +"//[Headers] You can add your own extra header files here...\r\n" +"//[/Headers]\r\n" +"\r\n" +"%%includeFilesCPP%%\r\n" +"\r\n" +"//[MiscUserDefs] You can add your own user definitions and misc code here...\r\n" +"//[/MiscUserDefs]\r\n" +"\r\n" +"//==============================================================================\r\n" +"%%className%%::%%className%% (%%constructorParams%%)\r\n" +"%%initialisers%%{\r\n" +" %%constructor%%\r\n" +"\r\n" +" //[Constructor] You can add your own custom stuff here..\r\n" +" //[/Constructor]\r\n" +"}\r\n" +"\r\n" +"%%className%%::~%%className%%()\r\n" +"{\r\n" +" //[Destructor_pre]. You can add your own custom destruction code here..\r\n" +" //[/Destructor_pre]\r\n" +"\r\n" +" %%destructor%%\r\n" +"\r\n" +" //[Destructor]. You can add your own custom destruction code here..\r\n" +" //[/Destructor]\r\n" +"}\r\n" +"\r\n" +"//==============================================================================\r\n" +"%%methodDefinitions%%\r\n" +"\r\n" +"//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...\r\n" +"//[/MiscUserCode]\r\n" +"\r\n" +"\r\n" +"//==============================================================================\r\n" +"#if 0\r\n" +"/* -- Jucer information section --\r\n" +"\r\n" +" This is where the Jucer puts all of its metadata, so don't change anything in here!\r\n" +"\r\n" +"BEGIN_JUCER_METADATA\r\n" +"\r\n" +"%%metadata%%\r\n" +"END_JUCER_METADATA\r\n" +"*/\r\n" +"#endif\r\n" +"\r\n" +"%%staticMemberDefinitions%%\r\n"; + +const char* BinaryData::jucer_ComponentTemplate_cpp = (const char*) temp_73015554; + +//================== jucer_ComponentTemplate.h ================== +static const unsigned char temp_b930c59[] = +"/*\r\n" +" ==============================================================================\r\n" +"\r\n" +" This is an automatically generated file created by the Jucer!\r\n" +"\r\n" +" Creation date: %%creationTime%%\r\n" +"\r\n" +" Be careful when adding custom code to these files, as only the code within\r\n" +" the \"//[xyz]\" and \"//[/xyz]\" sections will be retained when the file is loaded\r\n" +" and re-saved.\r\n" +"\r\n" +" Jucer version: 1.12\r\n" +"\r\n" +" ------------------------------------------------------------------------------\r\n" +"\r\n" +" The Jucer is part of the JUCE library - \"Jules' Utility Class Extensions\"\r\n" +" Copyright 2004-6 by Raw Material Software ltd.\r\n" +"\r\n" +" ==============================================================================\r\n" +"*/\r\n" +"\r\n" +"#ifndef %%headerGuard%%\r\n" +"#define %%headerGuard%%\r\n" +"\r\n" +"//[Headers] -- You can add your own extra header files here --\r\n" +"#include \"juce.h\"\r\n" +"//[/Headers]\r\n" +"\r\n" +"%%includeFilesH%%\r\n" +"\r\n" +"//==============================================================================\r\n" +"/**\r\n" +" //[Comments]\r\n" +" An auto-generated component, created by the Jucer.\r\n" +"\r\n" +" Describe your class and how it works here!\r\n" +" //[/Comments]\r\n" +"*/\r\n" +"%%classDeclaration%%\r\n" +"{\r\n" +"public:\r\n" +" //==============================================================================\r\n" +" %%className%% (%%constructorParams%%);\r\n" +" ~%%className%%();\r\n" +"\r\n" +" //==============================================================================\r\n" +" //[UserMethods] -- You can add your own custom methods in this section.\r\n" +" //[/UserMethods]\r\n" +"\r\n" +" %%publicMemberDeclarations%%\r\n" +"\r\n" +" //==============================================================================\r\n" +" juce_UseDebuggingNewOperator\r\n" +"\r\n" +"private:\r\n" +" //[UserVariables] -- You can add your own custom variables in this section.\r\n" +" //[/UserVariables]\r\n" +"\r\n" +" //==============================================================================\r\n" +" %%privateMemberDeclarations%%\r\n" +"\r\n" +" //==============================================================================\r\n" +" // (prevent copy constructor and operator= being generated..)\r\n" +" %%className%% (const %%className%%&);\r\n" +" const %%className%%& operator= (const %%className%%&);\r\n" +"};\r\n" +"\r\n" +"\r\n" +"#endif // %%headerGuard%%\r\n"; + +const char* BinaryData::jucer_ComponentTemplate_h = (const char*) temp_b930c59; + //================== jucer_MainConsoleAppTemplate.cpp ================== static const unsigned char temp_a4c7812a[] = "/*\r\n" diff --git a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h index c468da37d5..e68f279930 100644 --- a/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h +++ b/extras/Jucer (experimental)/JuceLibraryCode/BinaryData.h @@ -22,6 +22,12 @@ namespace BinaryData extern const char* jucer_AudioPluginFilterTemplate_h; const int jucer_AudioPluginFilterTemplate_hSize = 2353; + extern const char* jucer_ComponentTemplate_cpp; + const int jucer_ComponentTemplate_cppSize = 1975; + + extern const char* jucer_ComponentTemplate_h; + const int jucer_ComponentTemplate_hSize = 2309; + extern const char* jucer_MainConsoleAppTemplate_cpp; const int jucer_MainConsoleAppTemplate_cppSize = 749; diff --git a/extras/Jucer (experimental)/Jucer.jucer b/extras/Jucer (experimental)/Jucer.jucer index bae1deadc4..ed7e42a242 100644 --- a/extras/Jucer (experimental)/Jucer.jucer +++ b/extras/Jucer (experimental)/Jucer.jucer @@ -61,6 +61,10 @@ resource="0" file="Source/model/jucer_ComponentDocument.cpp"/> + + + + = 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 CodeGenerator::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 CodeGenerator::addImageResourceLoader (const String& imageMemberName, const String& resourceName) +{ + const String initialiser (imageMemberName + " (0)"); + + if (! memberInitialisers.contains (initialiser, false)) + { + memberInitialisers.add (initialiser); + + privateMemberDeclarations + << "Image* " << imageMemberName << ";" << newLine; + + if (resourceName.isNotEmpty()) + { + constructorCode + << imageMemberName << " = ImageCache::getFromMemory (" + << resourceName << ", " << resourceName << "Size);" << newLine; + + destructorCode + << "ImageCache::release (" << imageMemberName << ");" << newLine; + } + } +} + +const StringArray CodeGenerator::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 CodeGenerator::getCallbackDeclarations() const +{ + String s; + + for (int i = 0; i < callbacks.size(); ++i) + { + CallbackMethod* const cm = callbacks.getUnchecked(i); + + s << cm->returnType << " " << cm->prototype << ";" << newLine; + } + + return s; +} + +const String CodeGenerator::getCallbackDefinitions() const +{ + String s; + + for (int i = 0; i < callbacks.size(); ++i) + { + CallbackMethod* const cm = callbacks.getUnchecked(i); + + const String userCodeBlockName ("User" + makeValidCppIdentifier (cm->prototype.upToFirstOccurrenceOf ("(", false, false), + true, true, false).trim()); + + if (userCodeBlockName.isNotEmpty() && cm->hasPrePostUserSections) + { + s << cm->returnType << " " << className << "::" << cm->prototype + << newLine + << "{" << newLine + << " //[" << userCodeBlockName << "_Pre]" << newLine + << " //[/" << userCodeBlockName + << "_Pre]" << newLine << newLine + << " " << indentCode (cm->content.trim(), 4) << newLine + << newLine + << " //[" << userCodeBlockName << "_Post]" << newLine + << " //[/" << userCodeBlockName << "_Post]" << newLine + << "}" << newLine + << newLine; + } + else + { + s << cm->returnType << " " << className << "::" << cm->prototype << newLine + << "{" << newLine + << " " << indentCode (cm->content.trim(), 4) << newLine + << "}" << newLine + << newLine; + } + } + + return s; +} + +//============================================================================== +const String CodeGenerator::getClassDeclaration() const +{ + StringArray parentClassLines; + parentClassLines.addTokens (parentClasses, ",", String::empty); + parentClassLines.addArray (getExtraParentClasses()); + + parentClassLines.trim(); + parentClassLines.removeEmptyStrings(); + parentClassLines.removeDuplicates (false); + + if (parentClassLines.contains ("public Button", false)) + parentClassLines.removeString ("public Component", false); + + String r ("class "); + r << className << " : "; + + r += parentClassLines.joinIntoString ("," + String (newLine) + String::repeatedString (" ", r.length())); + + return r; +} + +const String CodeGenerator::getInitialiserList() const +{ + StringArray inits (memberInitialisers); + + 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 (',')) + init = init.dropLastCharacters (1); + + s << init; + + if (i < inits.size() - 1) + s << "," << newLine << " "; + else + s << newLine; + } + + 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 << "#include \"" << files[i] << "\"" << newLine; + + return s; +} + +//============================================================================== +static bool getUserSection (const StringArray& lines, const String& tag, StringArray& resultLines) +{ + const int start = indexOfLineStartingWith (lines, "//[" + tag + "]", 0); + + if (start < 0) + return false; + + const int end = indexOfLineStartingWith (lines, "//[/" + tag + "]", 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 ("//[")) + { + String tag (dstLines[i].trimStart().substring (3)); + tag = tag.upToFirstOccurrenceOf ("]", false, false); + + jassert (! tag.startsWithChar ('/')); + + if (! tag.startsWithChar ('/')) + { + const int endLine = indexOfLineStartingWith (dstLines, + "//[/" + tag + "]", + 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 (newLine) + newLine; +} + +//============================================================================== +static void replaceTemplate (String& text, const String& itemName, const String& value) +{ + for (;;) + { + const int index = text.indexOf ("%%" + itemName + "%%"); + + if (index < 0) + break; + + int indentLevel = 0; + + for (int i = index; --i >= 0;) + { + if (text[i] == '\n') + break; + + ++indentLevel; + } + + text = text.replaceSection (index, itemName.length() + 4, + indentCode (value, indentLevel)); + } +} + +//============================================================================== +void CodeGenerator::applyToCode (String& code, + const String& fileNameRoot, + const bool isForPreview, + const String& oldFileWithUserData) const +{ + // header guard.. + String headerGuard ("__JUCER_HEADER_"); + headerGuard << className.toUpperCase().retainCharacters ("ABCDEFGHIJKLMNOPQRSTUVWXYZ") + << "_" << fileNameRoot.toUpperCase().retainCharacters ("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() + newLine + 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", " << Metadata isn't shown in the code preview >>" + String (newLine)); + replaceTemplate (code, "staticMemberDefinitions", "// Static member declarations and resources would go here... (these aren't shown in the code preview)"); + } + + copyAcrossUserSections (code, oldFileWithUserData); +} diff --git a/extras/Jucer (experimental)/Source/model/jucer_CodeGenerator.h b/extras/Jucer (experimental)/Source/model/jucer_CodeGenerator.h new file mode 100644 index 0000000000..ab8ca80522 --- /dev/null +++ b/extras/Jucer (experimental)/Source/model/jucer_CodeGenerator.h @@ -0,0 +1,94 @@ +/* + ============================================================================== + + This file is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-9 by Raw Material Software Ltd. + + ------------------------------------------------------------------------------ + + JUCE can be redistributed and/or modified under the terms of the GNU General + Public License (Version 2), as published by the Free Software Foundation. + A copy of the license is included in the JUCE distribution, or can be found + online at www.gnu.org/licenses. + + 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. + + ------------------------------------------------------------------------------ + + To release a closed-source product which uses JUCE, commercial licenses are + available: visit www.rawmaterialsoftware.com/juce for more information. + + ============================================================================== +*/ + +#ifndef __JUCER_CODEGENERATOR_H_F79AEF58__ +#define __JUCER_CODEGENERATOR_H_F79AEF58__ + +#include "../jucer_Headers.h" + + +//============================================================================== +class CodeGenerator +{ +public: + //============================================================================== + CodeGenerator(); + ~CodeGenerator(); + + //============================================================================== + void applyToCode (String& codeTemplate, + const String& fileNameRoot, + const bool isForPreview, + const String& oldFileContents) const; + + int getUniqueSuffix(); + + //============================================================================== + String className; + String componentName; + String parentClassInitialiser; // optional parent class initialiser to go before the items in the initialisers list + StringArray memberInitialisers; + String parentClasses; + String constructorParams; + String privateMemberDeclarations; + String publicMemberDeclarations; + StringArray includeFilesH, includeFilesCPP; + String constructorCode; + String destructorCode; + String staticMemberDefinitions; + String jucerMetadata; + + struct CallbackMethod + { + String requiredParentClass, returnType, prototype, content; + bool hasPrePostUserSections; + }; + + OwnedArray callbacks; + + String& getCallbackCode (const String& requiredParentClass, + const String& returnType, + const String& prototype, + const bool hasPrePostUserSections); + + void removeCallback (const String& returnType, const String& prototype); + + void addImageResourceLoader (const String& imageMemberName, const String& resourceName); + + const String getCallbackDeclarations() const; + const String getCallbackDefinitions() const; + const StringArray getExtraParentClasses() const; + +private: + const String getClassDeclaration() const; + const String getInitialiserList() const; + int suffix; + + CodeGenerator (const CodeGenerator&); + CodeGenerator& operator= (const CodeGenerator&); +}; + + +#endif // __JUCER_CODEGENERATOR_H_F79AEF58__ diff --git a/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h b/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h index 57b262326e..ea82f71820 100644 --- a/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h +++ b/extras/Jucer (experimental)/Source/model/jucer_ProjectExport_XCode.h @@ -525,10 +525,7 @@ private: if (iPhone) { - s.addTokens ("UIKit Foundation CoreGraphics AudioToolbox", false); - - if ((int) project.getJuceConfigFlag ("JUCE_OPENGL").getValue() == 1) - s.addTokens ("QuartzCore OpenGLES", false); + s.addTokens ("UIKit Foundation CoreGraphics AudioToolbox QuartzCore OpenGLES", false); } else { diff --git a/extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.cpp b/extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.cpp new file mode 100644 index 0000000000..28a72216c0 --- /dev/null +++ b/extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.cpp @@ -0,0 +1,70 @@ +/* + ============================================================================== + + This is an automatically generated file created by the Jucer! + + Creation date: %%creationTime%% + + Be careful when adding custom code to these files, as only the code within + the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded + and re-saved. + + Jucer version: 1.12 + + ------------------------------------------------------------------------------ + + The Jucer is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-6 by Raw Material Software ltd. + + ============================================================================== +*/ + +//[Headers] You can add your own extra header files here... +//[/Headers] + +%%includeFilesCPP%% + +//[MiscUserDefs] You can add your own user definitions and misc code here... +//[/MiscUserDefs] + +//============================================================================== +%%className%%::%%className%% (%%constructorParams%%) +%%initialisers%%{ + %%constructor%% + + //[Constructor] You can add your own custom stuff here.. + //[/Constructor] +} + +%%className%%::~%%className%%() +{ + //[Destructor_pre]. You can add your own custom destruction code here.. + //[/Destructor_pre] + + %%destructor%% + + //[Destructor]. You can add your own custom destruction code here.. + //[/Destructor] +} + +//============================================================================== +%%methodDefinitions%% + +//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... +//[/MiscUserCode] + + +//============================================================================== +#if 0 +/* -- Jucer information section -- + + This is where the Jucer puts all of its metadata, so don't change anything in here! + +BEGIN_JUCER_METADATA + +%%metadata%% +END_JUCER_METADATA +*/ +#endif + +%%staticMemberDefinitions%% diff --git a/extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.h b/extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.h new file mode 100644 index 0000000000..210d2372b0 --- /dev/null +++ b/extras/Jucer (experimental)/Source/templates/jucer_ComponentTemplate.h @@ -0,0 +1,69 @@ +/* + ============================================================================== + + This is an automatically generated file created by the Jucer! + + Creation date: %%creationTime%% + + Be careful when adding custom code to these files, as only the code within + the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded + and re-saved. + + Jucer version: 1.12 + + ------------------------------------------------------------------------------ + + The Jucer is part of the JUCE library - "Jules' Utility Class Extensions" + Copyright 2004-6 by Raw Material Software ltd. + + ============================================================================== +*/ + +#ifndef %%headerGuard%% +#define %%headerGuard%% + +//[Headers] -- You can add your own extra header files here -- +#include "juce.h" +//[/Headers] + +%%includeFilesH%% + +//============================================================================== +/** + //[Comments] + An auto-generated component, created by the Jucer. + + Describe your class and how it works here! + //[/Comments] +*/ +%%classDeclaration%% +{ +public: + //============================================================================== + %%className%% (%%constructorParams%%); + ~%%className%%(); + + //============================================================================== + //[UserMethods] -- You can add your own custom methods in this section. + //[/UserMethods] + + %%publicMemberDeclarations%% + + //============================================================================== + juce_UseDebuggingNewOperator + +private: + //[UserVariables] -- You can add your own custom variables in this section. + //[/UserVariables] + + //============================================================================== + %%privateMemberDeclarations%% + + //============================================================================== + // (prevent copy constructor and operator= being generated..) + %%className%% (const %%className%%&); + const %%className%%& operator= (const %%className%%&); +}; + + +#endif // %%headerGuard%% diff --git a/extras/Jucer (experimental)/Source/ui/jucer_ProjectInformationComponent.cpp b/extras/Jucer (experimental)/Source/ui/jucer_ProjectInformationComponent.cpp index 5c9b81eccd..4fd492c286 100644 --- a/extras/Jucer (experimental)/Source/ui/jucer_ProjectInformationComponent.cpp +++ b/extras/Jucer (experimental)/Source/ui/jucer_ProjectInformationComponent.cpp @@ -83,6 +83,9 @@ public: if (exp != 0) exp->createPropertyEditors (props); + + for (int i = props.size(); --i >= 0;) + props.getUnchecked(i)->setPreferredHeight (22); } getPanel()->addProperties (props); diff --git a/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp b/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp index 468f52645d..3591e3a116 100644 --- a/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp +++ b/extras/Jucer (experimental)/Source/utility/jucer_UtilityFunctions.cpp @@ -486,7 +486,7 @@ const String indentCode (const String& code, const int numSpaces) lines.set (i, s); } - return lines.joinIntoString ("\n"); + return lines.joinIntoString (newLine); } int indexOfLineStartingWith (const StringArray& lines, const String& text, int startIndex) diff --git a/extras/example projects/Builds/iPhone/HelloWorld.xcodeproj/project.pbxproj b/extras/example projects/Builds/iPhone/HelloWorld.xcodeproj/project.pbxproj index ad4a122cc4..2d318c6308 100644 --- a/extras/example projects/Builds/iPhone/HelloWorld.xcodeproj/project.pbxproj +++ b/extras/example projects/Builds/iPhone/HelloWorld.xcodeproj/project.pbxproj @@ -10,6 +10,8 @@ D8DBAED4AB03622A655367C6 = { isa = PBXBuildFile; fileRef = 3DE047A554FB376BE3DA4C65; }; 1622BC343C98F98AC2AC0459 = { isa = PBXBuildFile; fileRef = AA21728A979A53287A0DEFED; }; D397D8CEF8663F449B4439C0 = { isa = PBXBuildFile; fileRef = 18665A7A93EDBA956B64774E; }; + 9EA4F1C0E2356AB5C07CE95E = { isa = PBXBuildFile; fileRef = E6809DE026C8BEAB082B3DEB; }; + C37934E8A18A3A82637C1445 = { isa = PBXBuildFile; fileRef = 541D7BED72093B09E01E3FD1; }; C67B5243DBC7218FEC5DBCC0 = { isa = PBXBuildFile; fileRef = E7507E799D8BDA92BDB78915; }; 9B11A7532637EC12F1DC4B2E = { isa = PBXBuildFile; fileRef = 0DB195C2B3538434D7D20B51; }; CFFBB821ECB7D85603624533 = { isa = PBXBuildFile; fileRef = 57FFE120531343D50B7D2D28; }; @@ -20,6 +22,8 @@ 3DE047A554FB376BE3DA4C65 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; AA21728A979A53287A0DEFED = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 18665A7A93EDBA956B64774E = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + E6809DE026C8BEAB082B3DEB = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 541D7BED72093B09E01E3FD1 = { isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; D5A29444C637255D66ACB7AE = { isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld.app; sourceTree = BUILT_PRODUCTS_DIR; }; B786F246076E6F5D363A6A2C = { isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Info.plist; sourceTree = SOURCE_ROOT; }; E7507E799D8BDA92BDB78915 = { isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Main.cpp; path = ../../Source/Main.cpp; sourceTree = SOURCE_ROOT; }; @@ -48,7 +52,9 @@ 6B236CD90C0803738D7B5235, 3DE047A554FB376BE3DA4C65, AA21728A979A53287A0DEFED, - 18665A7A93EDBA956B64774E ); name = Frameworks; sourceTree = ""; }; + 18665A7A93EDBA956B64774E, + E6809DE026C8BEAB082B3DEB, + 541D7BED72093B09E01E3FD1 ); name = Frameworks; sourceTree = ""; }; DC3A70675753A61E8C7CD36B = { isa = PBXGroup; children = ( D5A29444C637255D66ACB7AE ); name = Products; sourceTree = ""; }; 4297D3C9A6348BA224516847 = { isa = PBXGroup; children = ( @@ -131,7 +137,9 @@ BAEB975FAD8A99FA884DC593, D8DBAED4AB03622A655367C6, 1622BC343C98F98AC2AC0459, - D397D8CEF8663F449B4439C0 ); runOnlyForDeploymentPostprocessing = 0; }; + D397D8CEF8663F449B4439C0, + 9EA4F1C0E2356AB5C07CE95E, + C37934E8A18A3A82637C1445 ); runOnlyForDeploymentPostprocessing = 0; }; 9F559EB2CC99871D47887B82 = { isa = PBXNativeTarget; buildConfigurationList = 6F5E160F06E7FAD8B5C96752; buildPhases = ( 4B8D17F77F2E2E7A2419CB17, 172414663F1A38D78D2B00C3, diff --git a/extras/juce demo/Juce Demo.jucer b/extras/juce demo/Juce Demo.jucer index 345beca48b..800c840baf 100644 --- a/extras/juce demo/Juce Demo.jucer +++ b/extras/juce demo/Juce Demo.jucer @@ -100,13 +100,13 @@ diff --git a/extras/juce demo/JuceLibraryCode/AppConfig.h b/extras/juce demo/JuceLibraryCode/AppConfig.h index fdbd650785..2084b095ce 100644 --- a/extras/juce demo/JuceLibraryCode/AppConfig.h +++ b/extras/juce demo/JuceLibraryCode/AppConfig.h @@ -14,16 +14,16 @@ //#define JUCE_FORCE_DEBUG //#define JUCE_LOG_ASSERTIONS //#define JUCE_ASIO -#define JUCE_WASAPI 1 +//#define JUCE_WASAPI //#define JUCE_DIRECTSOUND //#define JUCE_ALSA -#define JUCE_QUICKTIME 1 -#define JUCE_OPENGL 1 +//#define JUCE_QUICKTIME +//#define JUCE_OPENGL //#define JUCE_USE_FLAC //#define JUCE_USE_OGGVORBIS //#define JUCE_USE_CDBURNER //#define JUCE_USE_CDREADER -#define JUCE_USE_CAMERA 1 +//#define JUCE_USE_CAMERA //#define JUCE_ENABLE_REPAINT_DEBUGGING //#define JUCE_USE_XINERAMA //#define JUCE_USE_XSHM @@ -32,7 +32,7 @@ #define JUCE_PLUGINHOST_VST 0 #define JUCE_PLUGINHOST_AU 0 //#define JUCE_ONLY_BUILD_CORE_LIBRARY -#define JUCE_WEB_BROWSER 1 +//#define JUCE_WEB_BROWSER //#define JUCE_SUPPORT_CARBON //#define JUCE_CHECK_MEMORY_LEAKS //#define JUCE_CATCH_UNHANDLED_EXCEPTIONS diff --git a/juce_Config.h b/juce_Config.h index 13794ca42a..6edc4b590a 100644 --- a/juce_Config.h +++ b/juce_Config.h @@ -227,7 +227,7 @@ If you're not using any embedded web-pages, turning this off may reduce your code size. */ #ifndef JUCE_WEB_BROWSER - #define JUCE_WEB_BROWSER 0 + #define JUCE_WEB_BROWSER 1 #endif diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 6816d42c5f..deb6be0a84 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -260,7 +260,7 @@ #endif #ifndef JUCE_WEB_BROWSER - #define JUCE_WEB_BROWSER 0 + #define JUCE_WEB_BROWSER 1 #endif #ifndef JUCE_SUPPORT_CARBON @@ -226869,7 +226869,7 @@ private: if (pinName == 0 || String (pinName).equalsIgnoreCase (String (info.achName))) { - pin.p->AddRef(); + pin->AddRef(); *result = pin; return true; } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 42545efd05..456a2971c3 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -281,7 +281,7 @@ #endif #ifndef JUCE_WEB_BROWSER - #define JUCE_WEB_BROWSER 0 + #define JUCE_WEB_BROWSER 1 #endif #ifndef JUCE_SUPPORT_CARBON @@ -5900,11 +5900,6 @@ public: simplify(); } - - String s; - for (int i = 0; i < values.size(); ++i) - s << values[i] << " "; - DBG (s); } void removeRange (const Range& rangeToRemove) diff --git a/src/containers/juce_SparseSet.h b/src/containers/juce_SparseSet.h index 42ef1601f8..2d54af1286 100644 --- a/src/containers/juce_SparseSet.h +++ b/src/containers/juce_SparseSet.h @@ -180,11 +180,6 @@ public: simplify(); } - - String s; - for (int i = 0; i < values.size(); ++i) - s << values[i] << " "; - DBG (s); } /** Removes a range of values from the set. diff --git a/src/native/windows/juce_win32_CameraDevice.cpp b/src/native/windows/juce_win32_CameraDevice.cpp index 1eba9366f3..203d06fb71 100644 --- a/src/native/windows/juce_win32_CameraDevice.cpp +++ b/src/native/windows/juce_win32_CameraDevice.cpp @@ -569,7 +569,7 @@ private: if (pinName == 0 || String (pinName).equalsIgnoreCase (String (info.achName))) { - pin.p->AddRef(); + pin->AddRef(); *result = pin; return true; }