在 ruby​​ 中嵌入 tcl [英] Embedding tcl in ruby

查看:28
本文介绍了在 ruby​​ 中嵌入 tcl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法做到这一点?似乎唯一可能的方法是使用 ruby​​/tk 并通过该 api 创建一个 tcl 解释器.但是,我想在没有 GUI (x windows) 的系统上使用它.我没有选择了吗?

Is there any way to do this? It seems the only possible way to do this is by using ruby/tk and creating a tcl interpreter through that api. However, I'd like to use this on a system with no GUI (x windows). Am I out of options?

谢谢

推荐答案

如果你可以在 Tcl 的 C API 中调用任意简单的函数,关键是:

If you can invoke arbitrary simple functions in Tcl's C API, the key ones are:

  • Tcl_FindExecutable – 首先调用它来初始化库
  • Tcl_CreateInterp – 返回新执行上下文的句柄
  • Tcl_Eval – 评估脚本;返回常量 TCL_OK (0) 或 TCL_ERROR (1)(或其他一些在一般代码中很少见的)
  • Tcl_GetResult – 返回结果值(或错误消息)
  • Tcl_ResetResult – 清除结果值
  • Tcl_DeleteInterp – 也许你能猜到这是做什么的……
  • Tcl_FindExecutable – Call this first to initialize the library
  • Tcl_CreateInterp – This returns a handle for a new execution context
  • Tcl_Eval – This evaluates a script; returns constants TCL_OK (0) or TCL_ERROR (1) (or a few others which are rare in general code)
  • Tcl_GetResult – This returns the result value (or error message)
  • Tcl_ResetResult – This clears the result value
  • Tcl_DeleteInterp – Maybe you can guess what this does…

您还可以使用 Tcl_GetVarTcl_SetVar 在上下文中访问全局"变量;这是传递可能不是有效脚本的值的一种非常方便的方法.

You can also access "global" variables in the context with Tcl_GetVar and Tcl_SetVar; this is a very convenient way to pass in values that might not be valid scripts.

这篇关于在 ruby​​ 中嵌入 tcl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆