summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2005-05-25 16:13:16 (GMT)
committerdgp <dgp@users.sourceforge.net>2005-05-25 16:13:16 (GMT)
commit17da6ea9da2761c0e93da57cbbd779ec138e7a39 (patch)
tree5f85fe1c5270262b37c3b75c16728b3c5cc54428 /generic
parentf4ce59d358e3993aa45141bf6f1c37c1166ae2ec (diff)
downloadtcl-17da6ea9da2761c0e93da57cbbd779ec138e7a39.zip
tcl-17da6ea9da2761c0e93da57cbbd779ec138e7a39.tar.gz
tcl-17da6ea9da2761c0e93da57cbbd779ec138e7a39.tar.bz2
TIP#182 IMPLEMENTATION [Patch 1165062]
* doc/mathfunc.n: New built-in math function bool(). * generic/tclBasic.c: * tests/expr.test: * tests/info.test:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBasic.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 7637f62..e526dc2 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBasic.c,v 1.156 2005/05/22 01:30:44 chengyemao Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.157 2005/05/25 16:13:17 dgp Exp $
*/
#include "tclInt.h"
@@ -52,6 +52,8 @@ static int ExprAbsFunc _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int argc, Tcl_Obj *CONST *objv));
static int ExprBinaryFunc _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int argc, Tcl_Obj *CONST *objv));
+static int ExprBoolFunc _ANSI_ARGS_((ClientData clientData,
+ Tcl_Interp *interp, int argc, Tcl_Obj *CONST *objv));
static int ExprDoubleFunc _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int argc, Tcl_Obj *CONST *objv));
static int ExprIntFunc _ANSI_ARGS_((ClientData clientData,
@@ -249,6 +251,7 @@ BuiltinFuncDef BuiltinFuncTable[] = {
{ "::tcl::mathfunc::asin", ExprUnaryFunc, (ClientData) asin },
{ "::tcl::mathfunc::atan", ExprUnaryFunc, (ClientData) atan },
{ "::tcl::mathfunc::atan2", ExprBinaryFunc, (ClientData) atan2 },
+ { "::tcl::mathfunc::bool", ExprBoolFunc, NULL },
{ "::tcl::mathfunc::ceil", ExprUnaryFunc, (ClientData) ceil },
{ "::tcl::mathfunc::cos", ExprUnaryFunc, (ClientData) cos },
{ "::tcl::mathfunc::cosh", ExprUnaryFunc, (ClientData) cosh },
@@ -5127,6 +5130,27 @@ ExprAbsFunc(clientData, interp, objc, objv)
}
static int
+ExprBoolFunc(clientData, interp, objc, objv)
+ ClientData clientData; /* Ignored. */
+ Tcl_Interp *interp; /* The interpreter in which to execute the
+ * function. */
+ int objc; /* Actual parameter count */
+ Tcl_Obj *CONST *objv; /* Actual parameter vector */
+{
+ int value;
+
+ if (objc != 2) {
+ MathFuncWrongNumArgs(interp, 2, objc, objv);
+ return TCL_ERROR;
+ }
+ if (Tcl_GetBooleanFromObj(interp, objv[1], &value) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(value));
+ return TCL_OK;
+}
+
+static int
ExprDoubleFunc(clientData, interp, objc, objv)
ClientData clientData; /* Ignored. */
Tcl_Interp *interp; /* The interpreter in which to execute the