アットウィキロゴ

Tcl_Eval

概要

Tcl_EvalExを呼び出し、文字列で表現されたTCLコマンドを実行する。

引数

  • Tcl_Interp *interp TCLインタープリタへのポインター
  • const char *script 実行するTCLコマンド

戻り値

Evalした結果

処理

 Tcl_EvalExの呼び出し。
 int code = Tcl_EvalEx(interp, script, -1, 0);

 互換性のために、文字列をコピーする。
 (void) Tcl_GetStringResult(interp);
 return code;

ソース

 /*
  *----------------------------------------------------------------------
  *
  * Tcl_Eval --
  *
  *	Execute a Tcl command in a string. This function executes the script
  *	directly, rather than compiling it to bytecodes. Before the arrival of
  *	the bytecode compiler in Tcl 8.0 Tcl_Eval was the main function used
  *	for executing Tcl commands, but nowadays it isn't used much.
  *
  * Results:
  *	The return value is one of the return codes defined in tcl.h (such as
  *	TCL_OK), and interp's result contains a value to supplement the return
  *	code. The value of the result will persist only until the next call to
  *	Tcl_Eval or Tcl_EvalObj: you must copy it or lose it!
  *
  * Side effects:
  *	Can be almost arbitrary, depending on the commands in the script.
  *
  *----------------------------------------------------------------------
  */
 
 int
 Tcl_Eval(
     [[Tcl_Interp]] *interp,		/* Token for command interpreter (returned by
 				 * previous call to Tcl_CreateInterp). */
     const char *script)		/* Pointer to TCL command to execute. */
 {
     int code = Tcl_EvalEx(interp, script, -1, 0);
 
     /*
      * For backwards compatibility with old C code that predates the object
      * system in Tcl 8.0, we have to mirror the object result back into the
      * string result (some callers may expect it there).
      */
 
     (void) Tcl_GetStringResult(interp);
     return code;
 }
最終更新:2011年11月01日 10:46