summaryrefslogtreecommitdiffstats
path: root/src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c b/src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c
new file mode 100644
index 000000000..8916577a4
--- /dev/null
+++ b/src/civetweb/src/third_party/duktape-1.5.2/src-separate/duk_hobject_misc.c
@@ -0,0 +1,52 @@
+/*
+ * Misc support functions
+ */
+
+#include "duk_internal.h"
+
+DUK_INTERNAL duk_bool_t duk_hobject_prototype_chain_contains(duk_hthread *thr, duk_hobject *h, duk_hobject *p, duk_bool_t ignore_loop) {
+ duk_uint_t sanity;
+
+ DUK_ASSERT(thr != NULL);
+
+ /* False if the object is NULL or the prototype 'p' is NULL.
+ * In particular, false if both are NULL (don't compare equal).
+ */
+ if (h == NULL || p == NULL) {
+ return 0;
+ }
+
+ sanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;
+ do {
+ if (h == p) {
+ return 1;
+ }
+
+ if (sanity-- == 0) {
+ if (ignore_loop) {
+ break;
+ } else {
+ DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT);
+ }
+ }
+ h = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);
+ } while (h);
+
+ return 0;
+}
+
+DUK_INTERNAL void duk_hobject_set_prototype_updref(duk_hthread *thr, duk_hobject *h, duk_hobject *p) {
+#ifdef DUK_USE_REFERENCE_COUNTING
+ duk_hobject *tmp;
+
+ DUK_ASSERT(h);
+ tmp = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);
+ DUK_HOBJECT_SET_PROTOTYPE(thr->heap, h, p);
+ DUK_HOBJECT_INCREF_ALLOWNULL(thr, p); /* avoid problems if p == h->prototype */
+ DUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp);
+#else
+ DUK_ASSERT(h);
+ DUK_UNREF(thr);
+ DUK_HOBJECT_SET_PROTOTYPE(thr->heap, h, p);
+#endif
+}