X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-tcl.git;a=blobdiff_plain;f=base%2Fhook.c;h=e0b16d4fac762d7feb2ddb59948f63b89d7917be;hp=56a32681a52756138a73cd4d5f5f42fbe5b7aeab;hb=dea4e335a78d52ed5f4b71908aa8fcbf392e96be;hpb=40a4738e440a8412c61a12eca34ed6aa98d71a5a diff --git a/base/hook.c b/base/hook.c index 56a3268..e0b16d4 100644 --- a/base/hook.c +++ b/base/hook.c @@ -1,9 +1,24 @@ /* + * base code for various Tcl extensions + * Copyright 2006 Ian Jackson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301, USA. */ -#include - -#include "chiark-tcl.h" +#include "chiark-tcl-base.h" int cht_staticerr(Tcl_Interp *ip, const char *m, const char *ec) { Tcl_SetResult(ip, (char*)m, TCL_STATIC); @@ -87,33 +102,21 @@ int cht_get_urandom(Tcl_Interp *ip, Byte *buffer, int l) { } } -int cht_initextension(Tcl_Interp *ip, const TopLevel_Command *cmds, - int *donep /* or 0, meaning no types follow */, - ... /* types, terminated by 0 */) { - static int cht_initd; - - const TopLevel_Command *cmd; - Tcl_ObjType *ot; - - va_list al; - - if (!cht_initd) { - cht_initd= 1; - Tcl_RegisterObjType(&cht_enum_nearlytype); - Tcl_RegisterObjType(&cht_enum1_nearlytype); - } +void cht_prepare__basic(Tcl_Interp *ip) { + static int prepared; - if (donep && !*donep) { - *donep= 1; - va_start(al, donep); - while ((ot= va_arg(al, Tcl_ObjType*))) - Tcl_RegisterObjType(ot); - } + if (prepared) return; + Tcl_RegisterObjType(&cht_tabledataid_nearlytype); + Tcl_RegisterObjType(&cht_enum_nearlytype); + Tcl_RegisterObjType(&cht_enum1_nearlytype); + prepared= 1; +} +void cht_setup__commands(Tcl_Interp *ip, const TopLevel_Command *cmds) { + const TopLevel_Command *cmd; + for (cmd= cmds; cmd->name; cmd++) Tcl_CreateObjCommand(ip, (char*)cmd->name, cmd->func, 0,0); - - return TCL_OK; }