当前位置: 首页>>代码示例>>Golang>>正文


Golang C.Tcl_GetCurrentThread函数代码示例

本文整理汇总了Golang中C.Tcl_GetCurrentThread函数的典型用法代码示例。如果您正苦于以下问题:Golang Tcl_GetCurrentThread函数的具体用法?Golang Tcl_GetCurrentThread怎么用?Golang Tcl_GetCurrentThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Tcl_GetCurrentThread函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: EvalAs

// Works exactly as Eval with exception that it writes the result of executed
// code into `out`.
func (ir *Interpreter) EvalAs(out interface{}, format string, args ...interface{}) error {
	// interpreter thread
	if C.Tcl_GetCurrentThread() == ir.ir.thread {
		ir.ir.cmdbuf.Reset()
		err := sprintf(&ir.ir.cmdbuf, format, args...)
		if err != nil {
			return ir.ir.filt(err)
		}
		err = ir.ir.eval_as(out, ir.ir.cmdbuf.Bytes())
		return ir.ir.filt(err)
	}

	// foreign thread
	buf := buffer_pool.get()
	err := sprintf(&buf, format, args...)
	if err != nil {
		buffer_pool.put(buf)
		return ir.ir.filt(err)
	}
	script := buf.Bytes()
	err = ir.ir.run_and_wait(func() error {
		return ir.ir.filt(ir.ir.eval_as(out, script))
	})
	buffer_pool.put(buf)
	return err
}
开发者ID:sinni800,项目名称:gothic,代码行数:28,代码来源:interpreter.go

示例2: UnregisterCommands

// Unregisters (deletes) previously registered command set within the `name`
// namespace.
func (ir *Interpreter) UnregisterCommands(name string) error {
	if C.Tcl_GetCurrentThread() == ir.ir.thread {
		return ir.ir.filt(ir.ir.unregister_commands(name))
	}
	return ir.ir.run_and_wait(func() error {
		return ir.ir.filt(ir.ir.unregister_commands(name))
	})
}
开发者ID:sinni800,项目名称:gothic,代码行数:10,代码来源:interpreter.go

示例3: RegisterCommands

// Register multiple TCL command within the `name` namespace. The method uses
// runtime reflection and registers only those methods of the `val` which have
// one of the following prefixes: "TCL" or "TCL_". The name of the resulting
// command doesn't include the prefix.
func (ir *Interpreter) RegisterCommands(name string, val interface{}) error {
	if C.Tcl_GetCurrentThread() == ir.ir.thread {
		return ir.ir.filt(ir.ir.register_commands(name, val))
	}
	return ir.ir.run_and_wait(func() error {
		return ir.ir.filt(ir.ir.register_commands(name, val))
	})
}
开发者ID:sinni800,项目名称:gothic,代码行数:12,代码来源:interpreter.go

示例4: UploadImage

func (ir *Interpreter) UploadImage(name string, img image.Image) error {
	if C.Tcl_GetCurrentThread() == ir.ir.thread {
		return ir.ir.filt(ir.ir.upload_image(name, img))
	}
	return ir.ir.run_and_wait(func() error {
		return ir.ir.filt(ir.ir.upload_image(name, img))
	})
}
开发者ID:sinni800,项目名称:gothic,代码行数:8,代码来源:interpreter.go

示例5: EvalBytes

// Works the same way as Eval("%{}", byte_slice), but avoids unnecessary
// buffering.
func (ir *Interpreter) EvalBytes(s []byte) error {
	if C.Tcl_GetCurrentThread() == ir.ir.thread {
		return ir.ir.filt(ir.ir.eval(s))
	}
	return ir.ir.run_and_wait(func() error {
		return ir.ir.filt(ir.ir.eval(s))
	})
}
开发者ID:sinni800,项目名称:gothic,代码行数:10,代码来源:interpreter.go

示例6: Eval

func (ir *Interpreter) Eval(args ...interface{}) error {
	if C.Tcl_GetCurrentThread() == ir.ir.thread {
		return ir.ir.filt(ir.ir.eval(args...))
	}
	return ir.ir.run_and_wait(func() error {
		return ir.ir.filt(ir.ir.eval(args...))
	})
}
开发者ID:screscent,项目名称:gothic,代码行数:8,代码来源:interpreter.go

示例7: ErrorFilter

// Every TCL error goes through the filter passed to this function. If you pass
// nil, then no error filter is set.
func (ir *Interpreter) ErrorFilter(filt func(error) error) {
	if C.Tcl_GetCurrentThread() == ir.ir.thread {
		ir.ir.errfilt = filt
	}
	ir.ir.run_and_wait(func() error {
		ir.ir.errfilt = filt
		return nil
	})
}
开发者ID:sinni800,项目名称:gothic,代码行数:11,代码来源:interpreter.go

示例8: new_interpreter

func new_interpreter(init interface{}) (*interpreter, error) {
	ir := &interpreter{
		C:              C.Tcl_CreateInterp(),
		errfilt:        func(err error) error { return err },
		commands:       make(map[string]interface{}),
		methods:        make(map[string]interface{}),
		method_handles: make(map[string][]int),
		valuesbuf:      make([]reflect.Value, 0, 10),
		queue:          make(chan async_action, 50),
		thread:         C.Tcl_GetCurrentThread(),
	}

	C.Tcl_FindExecutable(C.CString(os.Args[0]))

	switch realinit := init.(type) {
	case string:
		err := ir.eval([]byte(realinit))
		if err != nil {
			panic(err)
		}
	case func(*interpreter):
		realinit(ir)
	}

	status := C.Tcl_Init(ir.C)
	if status != C.TCL_OK {
		return nil, errors.New(C.GoString(C.Tcl_GetStringResult(ir.C)))
	}

	status = C.Tk_Init(ir.C)
	if status != C.TCL_OK {
		return nil, errors.New(C.GoString(C.Tcl_GetStringResult(ir.C)))
	}

	ir.id = global_handles.get_handle_for_value(ir)
	runtime.SetFinalizer(ir, release_interpreter)
	return ir, nil
}
开发者ID:sinni800,项目名称:gothic,代码行数:38,代码来源:interpreter.go

示例9: new_interpreter

func new_interpreter() (*interpreter, error) {
	ir := &interpreter{
		C:         C.Tcl_CreateInterp(),
		errfilt:   func(err error) error { return err },
		commands:  make(map[string]interface{}),
		channels:  make(map[string]interface{}),
		valuesbuf: make([]reflect.Value, 0, 10),
		queue:     make(chan async_action, 50),
		thread:    C.Tcl_GetCurrentThread(),
	}

	status := C.Tcl_Init(ir.C)
	if status != C.TCL_OK {
		return nil, errors.New(C.GoString(C.Tcl_GetStringResult(ir.C)))
	}

	status = C.Tk_Init(ir.C)
	if status != C.TCL_OK {
		return nil, errors.New(C.GoString(C.Tcl_GetStringResult(ir.C)))
	}

	return ir, nil
}
开发者ID:screscent,项目名称:gothic,代码行数:23,代码来源:interpreter.go

示例10: MainLoop

func (ir *Interpreter) MainLoop() {
	ir.thread = C.Tcl_GetCurrentThread()
	C.Tk_MainLoop()
}
开发者ID:sebastianskejoe,项目名称:gothic,代码行数:4,代码来源:interpreter.go


注:本文中的C.Tcl_GetCurrentThread函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。