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.

89 lines
2.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. #pragma once
  14. #include "../Project/jucer_Project.h"
  15. class JucerDocument;
  16. //==============================================================================
  17. /**
  18. A class for collecting the various snippets of c++ that will be assembled into
  19. the final cpp and header files.
  20. */
  21. class GeneratedCode
  22. {
  23. public:
  24. GeneratedCode (const JucerDocument*);
  25. ~GeneratedCode();
  26. //==============================================================================
  27. void applyToCode (String& code, const File& targetFile, const String& oldFileWithUserData) const;
  28. int getUniqueSuffix();
  29. //==============================================================================
  30. const JucerDocument* const document;
  31. String className;
  32. String componentName;
  33. String parentClassInitialiser; // optional parent class initialiser to go before the items in the initialisers list
  34. StringArray initialisers; // (a list of the member variables that need initialising after the constructor declaration)
  35. String parentClasses;
  36. String constructorParams;
  37. String privateMemberDeclarations;
  38. String publicMemberDeclarations;
  39. Array<File> includeFilesH, includeFilesCPP;
  40. String constructorCode;
  41. String destructorCode;
  42. String staticMemberDefinitions;
  43. String jucerMetadata;
  44. struct CallbackMethod
  45. {
  46. String requiredParentClass;
  47. String returnType;
  48. String prototype;
  49. String content;
  50. bool hasPrePostUserSections;
  51. };
  52. OwnedArray<CallbackMethod> callbacks;
  53. String& getCallbackCode (const String& requiredParentClass,
  54. const String& returnType,
  55. const String& prototype,
  56. const bool hasPrePostUserSections);
  57. void removeCallback (const String& returnType, const String& prototype);
  58. void addImageResourceLoader (const String& imageMemberName, const String& resourceName);
  59. String getCallbackDeclarations() const;
  60. String getCallbackDefinitions() const;
  61. StringArray getExtraParentClasses() const;
  62. bool shouldUseTransMacro() const noexcept;
  63. private:
  64. String getClassDeclaration() const;
  65. String getInitialiserList() const;
  66. int suffix;
  67. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GeneratedCode)
  68. };