예제 #1
0
파일: context.go 프로젝트: zhoupingl/go-php
// 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
	}
}
예제 #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
}
예제 #3
0
파일: engine.go 프로젝트: deuill/sigil
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
}