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.

104 lines
3.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCER_GENERATEDCODE_H_INCLUDED
  18. #define JUCER_GENERATEDCODE_H_INCLUDED
  19. #include "../Project/jucer_Project.h"
  20. class JucerDocument;
  21. //==============================================================================
  22. /**
  23. A class for collecting the various snippets of c++ that will be assembled into
  24. the final cpp and header files.
  25. */
  26. class GeneratedCode
  27. {
  28. public:
  29. GeneratedCode (const JucerDocument*);
  30. ~GeneratedCode();
  31. //==============================================================================
  32. void applyToCode (String& code,
  33. const File& targetFile,
  34. const String& oldFileWithUserData,
  35. Project* project) const;
  36. int getUniqueSuffix();
  37. //==============================================================================
  38. const JucerDocument* const document;
  39. String className;
  40. String componentName;
  41. String parentClassInitialiser; // optional parent class initialiser to go before the items in the initialisers list
  42. StringArray initialisers; // (a list of the member variables that need initalising after the constructor declaration)
  43. String parentClasses;
  44. String constructorParams;
  45. String privateMemberDeclarations;
  46. String publicMemberDeclarations;
  47. Array<File> includeFilesH, includeFilesCPP;
  48. String constructorCode;
  49. String destructorCode;
  50. String staticMemberDefinitions;
  51. String jucerMetadata;
  52. struct CallbackMethod
  53. {
  54. String requiredParentClass;
  55. String returnType;
  56. String prototype;
  57. String content;
  58. bool hasPrePostUserSections;
  59. };
  60. OwnedArray<CallbackMethod> callbacks;
  61. String& getCallbackCode (const String& requiredParentClass,
  62. const String& returnType,
  63. const String& prototype,
  64. const bool hasPrePostUserSections);
  65. void removeCallback (const String& returnType, const String& prototype);
  66. void addImageResourceLoader (const String& imageMemberName, const String& resourceName);
  67. String getCallbackDeclarations() const;
  68. String getCallbackDefinitions() const;
  69. StringArray getExtraParentClasses() const;
  70. bool shouldUseTransMacro() const noexcept;
  71. private:
  72. String getClassDeclaration() const;
  73. String getInitialiserList() const;
  74. int suffix;
  75. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GeneratedCode)
  76. };
  77. #endif // JUCER_GENERATEDCODE_H_INCLUDED