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.

100 lines
3.3KB

  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. #pragma once
  18. #include "../Project/jucer_Project.h"
  19. class JucerDocument;
  20. //==============================================================================
  21. /**
  22. A class for collecting the various snippets of c++ that will be assembled into
  23. the final cpp and header files.
  24. */
  25. class GeneratedCode
  26. {
  27. public:
  28. GeneratedCode (const JucerDocument*);
  29. ~GeneratedCode();
  30. //==============================================================================
  31. void applyToCode (String& code,
  32. const File& targetFile,
  33. const String& oldFileWithUserData,
  34. Project* project) const;
  35. int getUniqueSuffix();
  36. //==============================================================================
  37. const JucerDocument* const document;
  38. String className;
  39. String componentName;
  40. String parentClassInitialiser; // optional parent class initialiser to go before the items in the initialisers list
  41. StringArray initialisers; // (a list of the member variables that need initalising after the constructor declaration)
  42. String parentClasses;
  43. String constructorParams;
  44. String privateMemberDeclarations;
  45. String publicMemberDeclarations;
  46. Array<File> includeFilesH, includeFilesCPP;
  47. String constructorCode;
  48. String destructorCode;
  49. String staticMemberDefinitions;
  50. String jucerMetadata;
  51. struct CallbackMethod
  52. {
  53. String requiredParentClass;
  54. String returnType;
  55. String prototype;
  56. String content;
  57. bool hasPrePostUserSections;
  58. };
  59. OwnedArray<CallbackMethod> callbacks;
  60. String& getCallbackCode (const String& requiredParentClass,
  61. const String& returnType,
  62. const String& prototype,
  63. const bool hasPrePostUserSections);
  64. void removeCallback (const String& returnType, const String& prototype);
  65. void addImageResourceLoader (const String& imageMemberName, const String& resourceName);
  66. String getCallbackDeclarations() const;
  67. String getCallbackDefinitions() const;
  68. StringArray getExtraParentClasses() const;
  69. bool shouldUseTransMacro() const noexcept;
  70. private:
  71. String getClassDeclaration() const;
  72. String getInitialiserList() const;
  73. int suffix;
  74. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GeneratedCode)
  75. };