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.

96 lines
3.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  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, const File& targetFile, const String& oldFileWithUserData) const;
  33. int getUniqueSuffix();
  34. //==============================================================================
  35. const JucerDocument* const document;
  36. String className;
  37. String componentName;
  38. String parentClassInitialiser; // optional parent class initialiser to go before the items in the initialisers list
  39. StringArray initialisers; // (a list of the member variables that need initialising after the constructor declaration)
  40. String parentClasses;
  41. String constructorParams;
  42. String privateMemberDeclarations;
  43. String publicMemberDeclarations;
  44. Array<File> includeFilesH, includeFilesCPP;
  45. String constructorCode;
  46. String destructorCode;
  47. String staticMemberDefinitions;
  48. String jucerMetadata;
  49. struct CallbackMethod
  50. {
  51. String requiredParentClass;
  52. String returnType;
  53. String prototype;
  54. String content;
  55. bool hasPrePostUserSections;
  56. };
  57. OwnedArray<CallbackMethod> callbacks;
  58. String& getCallbackCode (const String& requiredParentClass,
  59. const String& returnType,
  60. const String& prototype,
  61. bool hasPrePostUserSections);
  62. void removeCallback (const String& returnType, const String& prototype);
  63. void addImageResourceLoader (const String& imageMemberName, const String& resourceName);
  64. String getCallbackDeclarations() const;
  65. String getCallbackDefinitions() const;
  66. StringArray getExtraParentClasses() const;
  67. bool shouldUseTransMacro() const noexcept;
  68. private:
  69. String getClassDeclaration() const;
  70. String getInitialiserList() const;
  71. int suffix;
  72. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GeneratedCode)
  73. };