Ejemplo n.º 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
}
Ejemplo n.º 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
}
Ejemplo n.º 3
0
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"})
}
Ejemplo n.º 4
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) {
	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
}