JSAPI.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 <Duktape/duktape.h>
  6. typedef void* JS_HEAP_PTR;
  7. #include "../Javascript/JSVM.h"
  8. #define JS_GLOBALSTASH_INDEX_COMPONENTS 0
  9. #define JS_GLOBALSTASH_INDEX_NODE_REGISTRY 1
  10. // indexers for instance objects
  11. #define JS_INSTANCE_INDEX_FINALIZED 0
  12. namespace Atomic
  13. {
  14. class JSVM;
  15. class Object;
  16. void js_class_declare_internal(JSVM* vm, void* uniqueClassID, const char* package, const char* classname, duk_c_function constructor);
  17. template<typename T>
  18. void js_class_declare(JSVM* vm, const char* package, const char* classname, duk_c_function constructor)
  19. {
  20. void* uniqueID = (void*) T::GetTypeNameStatic().CString();
  21. js_class_declare_internal(vm, uniqueID, package, classname, constructor);
  22. }
  23. void js_constructor_basecall(duk_context* ctx, const char* package, const char* baseclass);
  24. void js_setup_prototype(JSVM* vm, const char* package, const char* classname, const char* basePackage, const char* basename, bool hasProperties = false);
  25. void js_class_push_propertyobject(JSVM* vm, const char* package, const char* classname);
  26. void js_class_get_prototype(duk_context* ctx, const char* package, const char *classname);
  27. /// Pushes variant value or undefined if can't be pushed
  28. void js_push_variant(duk_context* ctx, const Variant &v);
  29. void js_object_to_variantmap(duk_context* ctx, int objIdx, VariantMap &v);
  30. }