示例#1
0
// New initializes a PHP engine instance on which contexts can be executed. It
// corresponds to PHP's MINIT (module init) phase.
func New() (*Engine, error) {
	ptr, err := C.engine_init()
	if err != nil {
		return nil, fmt.Errorf("PHP engine failed to initialize")
	}

	return &Engine{engine: ptr, contexts: make([]*context.Context, 0)}, nil
}
示例#2
0
// New initializes a PHP engine instance on which contexts can be executed. It
// corresponds to PHP's MINIT (module init) phase.
func New() (*Engine, error) {
	ptr, err := C.engine_init()
	if err != nil {
		return nil, fmt.Errorf("PHP engine failed to initialize")
	}

	e := &Engine{
		engine:    ptr,
		contexts:  make([]*Context, 0),
		receivers: make(map[string]*Receiver),
	}

	return e, nil
}
示例#3
0
文件: engine.go 项目: deuill/sigil
func init() {
	ptr, err := C.engine_init()
	if err != nil {
		panic("PHP engine failed to initialize")
	}

	e := &Engine{
		engine: ptr,
	}

	runtime.SetFinalizer(e, func(e *Engine) {
		C.engine_shutdown(e.engine)
	})

	engine.Register("php", e, []string{".php"})
}
示例#4
0
文件: engine.go 项目: deuill/go-php
// New initializes a PHP engine instance on which contexts can be executed. It
// corresponds to PHP's MINIT (module init) phase.
func New() (*Engine, error) {
	if engine != nil {
		return nil, fmt.Errorf("Cannot activate multiple engine instances")
	}

	ptr, err := C.engine_init()
	if err != nil {
		return nil, fmt.Errorf("PHP engine failed to initialize")
	}

	engine = &Engine{
		engine:    ptr,
		contexts:  make(map[*C.struct__engine_context]*Context),
		receivers: make(map[string]*Receiver),
	}

	return engine, nil
}