Execute the function with the given arguments.
(this *Value, args ...*Value)
| 414 | |
| 415 | // Execute the function with the given arguments. |
| 416 | func (v *Value) Execute(this *Value, args ...*Value) *Value { |
| 417 | if !v.isAlive() || !this.belongsTo(v.ctx) { |
| 418 | return nil |
| 419 | } |
| 420 | cargs := []C.JSValue{} |
| 421 | for _, x := range args { |
| 422 | if !x.belongsTo(v.ctx) { |
| 423 | return nil |
| 424 | } |
| 425 | cargs = append(cargs, x.ref) |
| 426 | } |
| 427 | var val *Value |
| 428 | if len(cargs) == 0 { |
| 429 | val = &Value{ctx: v.ctx, ref: C.JS_Call(v.ctx.ref, v.ref, this.ref, C.int(0), nil)} |
| 430 | } else { |
| 431 | val = &Value{ctx: v.ctx, ref: C.JS_Call(v.ctx.ref, v.ref, this.ref, C.int(len(cargs)), &cargs[0])} |
| 432 | } |
| 433 | |
| 434 | return val |
| 435 | } |
| 436 | |
| 437 | // New calls the constructor with the given arguments. |
| 438 | func (v *Value) New(args ...*Value) *Value { |