JSBPackage.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include <Atomic/Core/Object.h>
  24. using namespace Atomic;
  25. namespace ToolCore
  26. {
  27. class JSBModule;
  28. class JSBClass;
  29. class JSBEnum;
  30. class JSBPackageWriter;
  31. class JSBPackage : public Object
  32. {
  33. friend class JSPackageWriter;
  34. friend class CSPackageWriter;
  35. OBJECT(JSBPackage)
  36. public:
  37. JSBPackage(Context* context);
  38. virtual ~JSBPackage();
  39. bool Load(const String& packageFolder);
  40. Vector<SharedPtr<JSBModule>>& GetModules() {return modules_;}
  41. void PreprocessModules();
  42. void ProcessModules();
  43. const String& GetName() { return name_; }
  44. const String& GetNamespace() { return namespace_; }
  45. JSBClass* GetClass(const String& name);
  46. PODVector<JSBClass*>& GetAllClasses() { return allClasses_; }
  47. void RegisterClass(JSBClass* cls) {allClasses_.Push(cls); }
  48. // get a class by name across all loaded packages
  49. static JSBClass* GetClassAllPackages(const String& name);
  50. JSBEnum* GetEnum(const String& name);
  51. // get an enum by name across all loaded packages
  52. static JSBEnum* GetEnumAllPackages(const String& name);
  53. bool ContainsConstant(const String& constantName);
  54. static bool ContainsConstantAllPackages(const String& constantName);
  55. void GenerateSource(JSBPackageWriter& packageWriter);
  56. private:
  57. // The name of the package
  58. String name_;
  59. // The name of the C++ namespace if any
  60. String namespace_;
  61. Vector<SharedPtr<JSBPackage> > dependencies_;
  62. HashMap<String, Vector<String>> moduleExcludes_;
  63. Vector<SharedPtr<JSBModule> > modules_;
  64. PODVector<JSBClass*> allClasses_;
  65. static Vector<SharedPtr<JSBPackage> > allPackages_;
  66. };
  67. }