示例#1
0
func NewValue(engine_ *Engine, self_ unsafe.Pointer) *Value {
	if self_ == nil {
		return nil
	}
	valueId++
	id_ := valueId
	val_ := &Value{
		engine:   engine_,
		self:     self_,
		disposed: false,
		id:       id_,
	}

	engine_.SetAliveValue(id_, val_)
	runtime.SetFinalizer(val_, func(v *Value) {
		if traceDispose {
			println("v8.Value.Dispose()")
		}
		if !v.disposed {
			//C.V8_DisposeValue(v.self)
			C.V8_Engine_DisposeValue(v.self)
		}
	})

	return val_
}
示例#2
0
func (val_ *Value) Disposed() {
	if val_.disposed {
		return
	}
	engine_ := val_.GetEngine()
	id_ := val_.id
	val_.disposed = true
	delete(engine_.aliveValue, id_)
	C.V8_Engine_DisposeValue(val_.self)
}