chiark / gitweb /
finalise changelog
[chiark-tcl.git] / base / tcmdiflib.c
1 /*
2  * base code for various Tcl extensions
3  * Copyright 2006-2012 Ian Jackson
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this library; if not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include "chiark-tcl-base.h"
20
21 int cht_pat_enum(Tcl_Interp *ip, Tcl_Obj *obj, const void **val,
22              const void *opts, size_t sz, const char *what) {
23   *val= cht_enum_lookup_cached_func(ip,obj,opts,sz,what);
24   if (!*val) return TCL_ERROR;
25   return TCL_OK;
26 }
27   
28 int cht_pat_obj(Tcl_Interp *ip, Tcl_Obj *obj, Tcl_Obj **val) {
29   *val= obj;
30   return TCL_OK;
31 }
32
33 Tcl_Obj *cht_ret_int(Tcl_Interp *ip, int val) {
34   return Tcl_NewIntObj(val);
35 }
36
37 Tcl_Obj *cht_ret_obj(Tcl_Interp *ip, Tcl_Obj *val) {
38   return val;
39 }
40
41 void cht_setstringresult(Tcl_Interp *ip, const char *m) {
42   Tcl_ResetResult(ip);
43   Tcl_AppendResult(ip, m, (char*)0);
44 }