The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-10 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCER_CODEGENERATOR_H_F79AEF58__
  19. #define __JUCER_CODEGENERATOR_H_F79AEF58__
  20. #include "../jucer_Headers.h"
  21. #include "jucer_Project.h"
  22. //==============================================================================
  23. class CodeGenerator
  24. {
  25. public:
  26. //==============================================================================
  27. CodeGenerator();
  28. ~CodeGenerator();
  29. //==============================================================================
  30. String className;
  31. String parentClassInitialiser; // optional parent class initialiser to go before the items in the initialisers list
  32. StringArray memberInitialisers;
  33. String parentClasses;
  34. String constructorParams;
  35. String privateMemberDeclarations;
  36. String publicMemberDeclarations;
  37. StringArray includeFilesH, includeFilesCPP;
  38. String constructorCode;
  39. String destructorCode;
  40. String staticMemberDefinitions;
  41. String jucerMetadata;
  42. struct CallbackMethod
  43. {
  44. String requiredParentClass, returnType, prototype, content;
  45. bool hasPrePostUserSections;
  46. };
  47. OwnedArray<CallbackMethod> callbacks;
  48. String& getCallbackCode (const String& requiredParentClass,
  49. const String& returnType,
  50. const String& prototype,
  51. const bool hasPrePostUserSections);
  52. void removeCallback (const String& returnType, const String& prototype);
  53. const String getCallbackDeclarations() const;
  54. const String getCallbackDefinitions() const;
  55. const StringArray getExtraParentClasses() const;
  56. int getUniqueSuffix();
  57. //==============================================================================
  58. // An object to load and store all the user-defined bits of code as documents.
  59. class CustomisedCodeSnippets
  60. {
  61. public:
  62. CustomisedCodeSnippets();
  63. ~CustomisedCodeSnippets();
  64. void reloadFrom (const String& fileContent);
  65. void applyTo (String& fileContent) const;
  66. bool areAnySnippetsUnsaved() const;
  67. CodeDocument* getDocumentFor (const String& sectionName, bool createIfNotFound);
  68. const String getSectionContent (const String& sectionName) const;
  69. void removeSection (const String& sectionName);
  70. private:
  71. StringArray sectionNames;
  72. OwnedArray <CodeDocument> sectionContent;
  73. };
  74. //==============================================================================
  75. void applyToCode (String& codeTemplate, const File& targetFile,
  76. bool isForPreview, Project* project) const;
  77. private:
  78. //==============================================================================
  79. const String getClassDeclaration() const;
  80. const String getInitialiserList() const;
  81. int suffix;
  82. CodeGenerator (const CodeGenerator&);
  83. CodeGenerator& operator= (const CodeGenerator&);
  84. };
  85. #endif // __JUCER_CODEGENERATOR_H_F79AEF58__