forked from svaarala/duktape
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduk_call_prop.yaml
More file actions
48 lines (37 loc) · 1.39 KB
/
duk_call_prop.yaml
File metadata and controls
48 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: duk_call_prop
proto: |
void duk_call_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);
stack: |
[ ... obj! ... key! arg1! ...! argN! ] -> [ ... obj! ... retval! ]
summary: |
<p>Call <code>obj.key</code> with <code>nargs</code> arguments, with <code>this</code>
binding set to <code>obj</code>. The property name and the function arguments
are replaced by a single return value; the target object is not touched.
An error during the function call is not automatically caught.</p>
<p>If the target function is not strict, the binding value seen by the
target function may be modified by processing specified in
<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-10.4.3">Entering Function Code</a>.
</p>
<p>This API call is equivalent to:</p>
<pre class="ecmascript-code">
var retval = obj[key](arg1, ..., argN);
</pre>
<p>or:</p>
<pre class="ecmascript-code">
var func = obj[key];
var retval = func.call(obj, arg1, ..., argN);
</pre>
<div include="object-can-be-any-value.html" />
example: |
/* obj.myAdderMethod(2,3) -> 5 */
duk_idx_t obj_idx = /* ... */;
duk_push_string(ctx, "myAdderMethod");
duk_push_int(ctx, 2);
duk_push_int(ctx, 3);
duk_call_prop(ctx, obj_idx, 2); /* [ ... "myAdderMethod" 2 3 ] -> [ ... 5 ] */
printf("2+3=%ld\n", (long) duk_get_int(ctx, -1));
duk_pop(ctx);
tags:
- property
- call
introduced: 1.0.0