JSBModule.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #pragma once
  8. #include <Atomic/Core/Object.h>
  9. using namespace Atomic;
  10. namespace Atomic
  11. {
  12. class JSONFile;
  13. }
  14. namespace ToolCore
  15. {
  16. class JSBPackage;
  17. class JSBHeader;
  18. class JSBClass;
  19. class JSBEnum;
  20. class JSBPrimitiveType;
  21. class JSBModule : public Object
  22. {
  23. friend class JSBModuleWriter;
  24. friend class CSBModuleWriter;
  25. OBJECT(JSBModule)
  26. public:
  27. JSBModule(Context* context, JSBPackage* package);
  28. virtual ~JSBModule();
  29. const String& GetName() { return name_; }
  30. JSBPackage* GetPackage() { return package_; }
  31. JSBClass* GetClass(const String& name);
  32. Vector<SharedPtr<JSBClass>> GetClasses();
  33. Vector<SharedPtr<JSBEnum>> GetEnums();
  34. HashMap<String, JSBPrimitiveType*>& GetConstants() { return constants_; }
  35. void RegisterClass(String name);
  36. JSBEnum* GetEnum(const String& name);
  37. void RegisterEnum(JSBEnum* jenum);
  38. bool ContainsConstant(const String& constantName);
  39. void RegisterConstant(const String& constantName, unsigned type);
  40. bool Requires(const String& requirement) { return requirements_.Contains(requirement); }
  41. bool Load(const String& jsonFilename);
  42. void PreprocessHeaders();
  43. void VisitHeaders();
  44. void PreprocessClasses();
  45. void ProcessClasses();
  46. void PostProcessClasses();
  47. void GenerateSource(const String& outPath);
  48. void GenerateCSharpSource(const String& outPath);
  49. const String& GetSource();
  50. private:
  51. void ProcessOverloads();
  52. void ProcessExcludes();
  53. void ProcessTypeScriptDecl();
  54. void ProcessHaxeDecl();
  55. void ScanHeaders();
  56. String name_;
  57. SharedPtr<JSBPackage> package_;
  58. Vector<SharedPtr<JSBHeader>> headers_;
  59. Vector<String> includes_;
  60. Vector<String> sourceDirs_;
  61. Vector<String> classnames_;
  62. HashMap<String, String> classRenames_;
  63. // native name -> JSBClass
  64. HashMap<StringHash, SharedPtr<JSBClass> > classes_;
  65. HashMap<StringHash, SharedPtr<JSBEnum> > enums_;
  66. HashMap<String, JSBPrimitiveType*> constants_;
  67. Vector<String> requirements_;
  68. SharedPtr<JSONFile> moduleJSON_;
  69. String source_;
  70. };
  71. }