예제 #1
0
파일: v8_engine.go 프로젝트: kingland/gnode
//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_
}
예제 #2
0
파일: v8_engine.go 프로젝트: yangou/go-v8
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
}
예제 #3
0
파일: v8_engine.go 프로젝트: navy1125/v8.go
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
}