Example #1
0
// Destroy tears down the current execution context along with any active value
// bindings for that context.
func (c *Context) Destroy() {
	for _, v := range c.values {
		v.Destroy()
	}

	c.values = nil

	if c.context != nil {
		C.context_destroy(c.context)
		c.context = nil
	}
}
Example #2
0
// Destroy tears down the current execution context along with any active value
// bindings for that context.
func (c *Context) Destroy() {
	if c.context == nil {
		return
	}

	for _, v := range c.values {
		v.Destroy()
	}

	c.values = nil

	C.context_destroy(c.context)
	c.context = nil
}
Example #3
0
func (e *Engine) NewContext(w io.Writer) (engine.Context, error) {
	ctx := &Context{writer: w}

	ptr, err := C.context_new(e.engine, unsafe.Pointer(ctx))
	if err != nil {
		return nil, fmt.Errorf("Failed to initialize context for PHP engine")
	}

	ctx.context = ptr

	runtime.SetFinalizer(ctx, func(ctx *Context) {
		C.context_destroy(ctx.context)
	})

	return ctx, nil
}