changeset 420:0631c4bd56f9

Js: - add js::This - add defineProperty
author David Demelier <markand@malikania.fr>
date Thu, 08 Oct 2015 14:04:59 +0200
parents ee155fc84c56
children d046379137f3
files C++/modules/Js/Js.h
diffstat 1 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/C++/modules/Js/Js.h	Thu Oct 08 10:55:41 2015 +0200
+++ b/C++/modules/Js/Js.h	Thu Oct 08 14:04:59 2015 +0200
@@ -87,6 +87,13 @@
 };
 
 /**
+ * @class This
+ * @brief Empty class tag to push this binding to the stack.
+ */
+class This {
+};
+
+/**
  * @class Pointer
  * @brief Push a non-managed pointer to Duktape, the pointer will never be deleted.
  * @note For a managed pointer with prototype, see TypeInfoPointer
@@ -324,6 +331,18 @@
 	 */
 
 	/**
+	 * Define a property.
+	 *
+	 * @param index the object index
+	 * @param flags the flags
+	 * @note Wrapper of duk_def_prop
+	 */
+	inline void defineProperty(int index, int flags)
+	{
+		duk_def_prop(m_handle.get(), index, flags);
+	}
+
+	/**
 	 * Get the type of the value at the specified index.
 	 *
 	 * @param ctx the context
@@ -1631,6 +1650,20 @@
 };
 
 /**
+ * @brief Push this binding into the stack.
+ *
+ * Provides: push.
+ */
+template <>
+class TypeInfo<This> {
+public:
+	static inline void push(Context &ctx, const This &)
+	{
+		duk_push_this(ctx);
+	}
+};
+
+/**
  * @class TypeInfo<Global>
  * @brief Push the global object to the stack.
  *