Javascript.h 992 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  2. // Please see LICENSE.md in repository root for license information
  3. // https://github.com/AtomicGameEngine/AtomicGameEngine
  4. #pragma once
  5. #include <Atomic/Core/Context.h>
  6. #include <Atomic/Core/Object.h>
  7. #include "JSVM.h"
  8. namespace Atomic
  9. {
  10. class JSVM;
  11. /// Javascript subsystem.
  12. class ATOMIC_API Javascript : public Object
  13. {
  14. OBJECT(Javascript);
  15. public:
  16. /// Construct.
  17. Javascript(Context* context);
  18. /// Destruct.
  19. ~Javascript();
  20. /// Returns NULL if a VM with name already exists
  21. JSVM* InstantiateVM(const String& name);
  22. /// Gets a VM with the given name
  23. inline JSVM* GetVM(const String& name)
  24. {
  25. return vms_[name];
  26. }
  27. /// Closes the VM with the given name
  28. void ShutdownVM(const String& name);
  29. private:
  30. HashMap<String, SharedPtr<JSVM> > vms_;
  31. };
  32. /// Register Javascript library objects.
  33. void ATOMIC_API RegisterJavascriptLibrary(Context* context);
  34. }