Exemple #1
0
//create engine
func NewEngine() *Engine {
	self_ := C.V8_NewEngine(-1, -1)
	engine_ := &Engine{
		self:               self_,
		disposed:           false,
		aliveContext:       make(map[int]*Context),
		aliveScript:        make(map[int]*Script),
		aliveUnboundScript: make(map[int]*UnboundScript),
		aliveValue:         make(map[int32]*Value),
		//contextId : 0,
		//scriptId : 0,
		//unboundScriptId : 0,
		//valueId : 0,
	}
	engine_.SetOwner()
	runtime.SetFinalizer(engine_, func(e *Engine) {
		if traceDispose {
			println("V8_Engine_Dispose()", e.self)
		}
		if !e.disposed {
			C.V8_Engine_Dispose(e.self)
		}
	})
	return engine_
}
Exemple #2
0
func NewEngine() *Engine {
	self := C.V8_NewEngine()

	if self == nil {
		return nil
	}

	result := &Engine{
		self:            self,
		funcTemplates:   make(map[int]*FunctionTemplate),
		objectTemplates: make(map[int]*ObjectTemplate),
	}

	runtime.SetFinalizer(result, func(e *Engine) {
		if traceDispose {
			println("v8.Engine.Dispose()", e.self)
		}
		C.V8_DisposeEngine(e.self)
	})

	return result
}
Exemple #3
0
func NewEngine() *Engine {
	self := C.V8_NewEngine()

	if self == nil {
		return nil
	}

	engine := &Engine{
		self:            self,
		funcTemplates:   make(map[int64]*FunctionTemplate),
		objectTemplates: make(map[int64]*ObjectTemplate),
		fieldOwners:     make(map[int64]interface{}),
		bindTypes:       make(map[reflect.Type]*ObjectTemplate),
	}

	runtime.SetFinalizer(engine, func(e *Engine) {
		if traceDispose {
			println("v8.Engine.Dispose()", e.self)
		}
		C.V8_DisposeEngine(e.self)
	})

	return engine
}