mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
7 years ago
14 changed files with 128 additions and 7 deletions
@ -0,0 +1,29 @@ |
|||
name: duk_del_prop_heapptr |
|||
|
|||
proto: | |
|||
duk_bool_t duk_del_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); |
|||
|
|||
stack: | |
|||
[ ... obj! ... ] -> [ ... obj! ... ] |
|||
|
|||
summary: | |
|||
<p>Like <code><a href="#duk_del_prop">duk_del_prop()</a></code>, but the |
|||
property name is given as a Duktape heap pointer obtained e.g. using |
|||
<code><a href="#duk_get_heapptr">duk_get_heapptr()</a></code>. If |
|||
<code>ptr</code> is NULL, <code>undefined</code> is used as the key.</p> |
|||
|
|||
example: | |
|||
duk_bool_t rc; |
|||
void *ptr; |
|||
|
|||
duk_push_string(ctx, "propertyName"); |
|||
ptr = duk_get_heapptr(ctx, -1); |
|||
/* String behind 'ptr' must remain reachable! */ |
|||
|
|||
rc = duk_del_prop_heapptr(ctx, -3, ptr); |
|||
printf("delete obj.propertyName -> rc=%d\n", (int) rc); |
|||
|
|||
tags: |
|||
- property |
|||
|
|||
introduced: 2.2.0 |
@ -0,0 +1,30 @@ |
|||
name: duk_get_prop_heapptr |
|||
|
|||
proto: | |
|||
duk_bool_t duk_get_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); |
|||
|
|||
stack: | |
|||
[ ... obj! ... ] -> [ ... obj! ... val! ] (if key exists) |
|||
[ ... obj! ... ] -> [ ... obj! ... undefined! ] (if key doesn't exist) |
|||
|
|||
summary: | |
|||
<p>Like <code><a href="#duk_get_prop">duk_get_prop()</a></code>, but the |
|||
property name is given as a Duktape heap pointer obtained e.g. using |
|||
<code><a href="#duk_get_heapptr">duk_get_heapptr()</a></code>. If |
|||
<code>ptr</code> is NULL, <code>undefined</code> is used as the key.</p> |
|||
|
|||
example: | |
|||
void *ptr; |
|||
|
|||
duk_push_string(ctx, "propertyName"); |
|||
ptr = duk_get_heapptr(ctx, -1); |
|||
/* String behind 'ptr' must remain reachable! */ |
|||
|
|||
(void) duk_get_prop_heapptr(ctx, -3, ptr); |
|||
printf("obj.propertyName = %s\n", duk_to_string(ctx, -1)); |
|||
duk_pop(ctx); |
|||
|
|||
tags: |
|||
- property |
|||
|
|||
introduced: 2.2.0 |
@ -0,0 +1,31 @@ |
|||
name: duk_has_prop_heapptr |
|||
|
|||
proto: | |
|||
duk_bool_t duk_has_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); |
|||
|
|||
stack: | |
|||
[ ... obj! ... ] -> [ ... obj! ... ] |
|||
|
|||
summary: | |
|||
<p>Like <code><a href="#duk_has_prop">duk_has_prop()</a></code>, but the |
|||
property name is given as a Duktape heap pointer obtained e.g. using |
|||
<code><a href="#duk_get_heapptr">duk_get_heapptr()</a></code>. If |
|||
<code>ptr</code> is NULL, <code>undefined</code> is used as the key.</p> |
|||
|
|||
example: | |
|||
void *ptr; |
|||
|
|||
duk_push_string(ctx, "propertyName"); |
|||
ptr = duk_get_heapptr(ctx, -1); |
|||
/* String behind 'ptr' must remain reachable! */ |
|||
|
|||
if (duk_has_prop_heapptr(ctx, -3, ptr)) { |
|||
printf("obj has 'myProperty'\n"); |
|||
} else { |
|||
printf("obj does not have 'myProperty'\n"); |
|||
} |
|||
|
|||
tags: |
|||
- property |
|||
|
|||
introduced: 2.2.0 |
@ -0,0 +1,30 @@ |
|||
name: duk_put_prop_heapptr |
|||
|
|||
proto: | |
|||
duk_bool_t duk_put_prop_heapptr(duk_context *ctx, duk_idx_t obj_idx, void *ptr); |
|||
|
|||
stack: | |
|||
[ ... obj! ... val! ] -> [ ... obj! ... ] |
|||
|
|||
summary: | |
|||
<p>Like <code><a href="#duk_put_prop">duk_put_prop()</a></code>, but the |
|||
property name is given as a Duktape heap pointer obtained e.g. using |
|||
<code><a href="#duk_get_heapptr">duk_get_heapptr()</a></code>. If |
|||
<code>ptr</code> is NULL, <code>undefined</code> is used as the key.</p> |
|||
|
|||
example: | |
|||
duk_bool_t rc; |
|||
void *ptr; |
|||
|
|||
duk_push_string(ctx, "propertyName"); |
|||
ptr = duk_get_heapptr(ctx, -1); |
|||
/* String behind 'ptr' must remain reachable! */ |
|||
|
|||
duk_push_string(ctx, "value"); |
|||
rc = duk_put_prop_heapptr(ctx, -3, ptr); |
|||
printf("rc=%d\n", (int) rc); |
|||
|
|||
tags: |
|||
- property |
|||
|
|||
introduced: 2.2.0 |
Loading…
Reference in new issue