From a55f14fe9d46dbc42a85ac81bf481c2d7a2c7ed2 Mon Sep 17 00:00:00 2001 From: nijtmans Date: Fri, 23 Feb 2007 23:02:53 +0000 Subject: various "const" additions, in line with TIP #27 --- doc/CrtChannel.3 | 6 +-- generic/tcl.decls | 36 +++++++------- generic/tclDecls.h | 71 +++++++++++++-------------- generic/tclIO.c | 138 ++++++++++++++++++++++++++--------------------------- tools/genStubs.tcl | 30 ++++++++++-- 5 files changed, 152 insertions(+), 129 deletions(-) diff --git a/doc/CrtChannel.3 b/doc/CrtChannel.3 index f23ea6d..2e5e815 100644 --- a/doc/CrtChannel.3 +++ b/doc/CrtChannel.3 @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: CrtChannel.3,v 1.33 2006/03/27 18:08:50 andreas_kupries Exp $ +'\" RCS: @(#) $Id: CrtChannel.3,v 1.34 2007/02/23 23:02:54 nijtmans Exp $ .so man.macros .TH Tcl_CreateChannel 3 8.4 Tcl "Tcl Library Procedures" .BS @@ -122,8 +122,8 @@ Tcl_DriverHandlerProc * \fBTcl_ChannelHandlerProc\fR(\fItypePtr\fR) .sp .SH ARGUMENTS -.AS Tcl_ChannelType *channelName -.AP Tcl_ChannelType *typePtr in +.AS "const char" *channelName +.AP "const Tcl_ChannelType" *typePtr in Points to a structure containing the addresses of procedures that can be called to perform I/O and other functions on the channel. .AP "const char" *channelName in diff --git a/generic/tcl.decls b/generic/tcl.decls index 8ae593b..5d44688 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tcl.decls,v 1.124 2006/12/01 14:31:18 dgp Exp $ +# RCS: @(#) $Id: tcl.decls,v 1.125 2007/02/23 23:02:54 nijtmans Exp $ library tcl @@ -1409,50 +1409,50 @@ declare 397 generic { int Tcl_ChannelBuffered(Tcl_Channel chan) } declare 398 generic { - CONST84_RETURN char * Tcl_ChannelName(Tcl_ChannelType *chanTypePtr) + CONST84_RETURN char * Tcl_ChannelName(CONST Tcl_ChannelType *chanTypePtr) } declare 399 generic { - Tcl_ChannelTypeVersion Tcl_ChannelVersion(Tcl_ChannelType *chanTypePtr) + Tcl_ChannelTypeVersion Tcl_ChannelVersion(CONST Tcl_ChannelType *chanTypePtr) } declare 400 generic { - Tcl_DriverBlockModeProc * Tcl_ChannelBlockModeProc(Tcl_ChannelType + Tcl_DriverBlockModeProc * Tcl_ChannelBlockModeProc(CONST Tcl_ChannelType *chanTypePtr) } declare 401 generic { - Tcl_DriverCloseProc * Tcl_ChannelCloseProc(Tcl_ChannelType *chanTypePtr) + Tcl_DriverCloseProc * Tcl_ChannelCloseProc(CONST Tcl_ChannelType *chanTypePtr) } declare 402 generic { - Tcl_DriverClose2Proc * Tcl_ChannelClose2Proc(Tcl_ChannelType *chanTypePtr) + Tcl_DriverClose2Proc * Tcl_ChannelClose2Proc(CONST Tcl_ChannelType *chanTypePtr) } declare 403 generic { - Tcl_DriverInputProc * Tcl_ChannelInputProc(Tcl_ChannelType *chanTypePtr) + Tcl_DriverInputProc * Tcl_ChannelInputProc(CONST Tcl_ChannelType *chanTypePtr) } declare 404 generic { - Tcl_DriverOutputProc * Tcl_ChannelOutputProc(Tcl_ChannelType *chanTypePtr) + Tcl_DriverOutputProc * Tcl_ChannelOutputProc(CONST Tcl_ChannelType *chanTypePtr) } declare 405 generic { - Tcl_DriverSeekProc * Tcl_ChannelSeekProc(Tcl_ChannelType *chanTypePtr) + Tcl_DriverSeekProc * Tcl_ChannelSeekProc(CONST Tcl_ChannelType *chanTypePtr) } declare 406 generic { - Tcl_DriverSetOptionProc * Tcl_ChannelSetOptionProc(Tcl_ChannelType + Tcl_DriverSetOptionProc * Tcl_ChannelSetOptionProc(CONST Tcl_ChannelType *chanTypePtr) } declare 407 generic { - Tcl_DriverGetOptionProc * Tcl_ChannelGetOptionProc(Tcl_ChannelType + Tcl_DriverGetOptionProc * Tcl_ChannelGetOptionProc(CONST Tcl_ChannelType *chanTypePtr) } declare 408 generic { - Tcl_DriverWatchProc * Tcl_ChannelWatchProc(Tcl_ChannelType *chanTypePtr) + Tcl_DriverWatchProc * Tcl_ChannelWatchProc(CONST Tcl_ChannelType *chanTypePtr) } declare 409 generic { - Tcl_DriverGetHandleProc * Tcl_ChannelGetHandleProc(Tcl_ChannelType + Tcl_DriverGetHandleProc * Tcl_ChannelGetHandleProc(CONST Tcl_ChannelType *chanTypePtr) } declare 410 generic { - Tcl_DriverFlushProc * Tcl_ChannelFlushProc(Tcl_ChannelType *chanTypePtr) + Tcl_DriverFlushProc * Tcl_ChannelFlushProc(CONST Tcl_ChannelType *chanTypePtr) } declare 411 generic { - Tcl_DriverHandlerProc * Tcl_ChannelHandlerProc(Tcl_ChannelType + Tcl_DriverHandlerProc * Tcl_ChannelHandlerProc(CONST Tcl_ChannelType *chanTypePtr) } @@ -1752,7 +1752,7 @@ declare 492 generic { # New export due to TIP#91 declare 493 generic { Tcl_DriverWideSeekProc * Tcl_ChannelWideSeekProc( - Tcl_ChannelType *chanTypePtr) + CONST Tcl_ChannelType *chanTypePtr) } # DICTIONARIES - TIP#111 @@ -1987,7 +1987,7 @@ declare 553 generic { } # TIP#218 (Driver Thread Actions) davygrvy/akupries ChannelType ver 4 declare 554 generic { - Tcl_DriverThreadActionProc *Tcl_ChannelThreadActionProc(Tcl_ChannelType *chanTypePtr) + Tcl_DriverThreadActionProc *Tcl_ChannelThreadActionProc(CONST Tcl_ChannelType *chanTypePtr) } # TIP#237 (Arbitrary-precision Integers) kevin kenny @@ -2014,7 +2014,7 @@ declare 560 generic { } declare 561 generic { Tcl_DriverTruncateProc *Tcl_ChannelTruncateProc( - Tcl_ChannelType *chanTypePtr) + CONST Tcl_ChannelType *chanTypePtr) } # TIP#219 (Tcl Channel Reflection API) akupries diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 7568dd1..c1621c0 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclDecls.h,v 1.127 2006/12/01 14:31:19 dgp Exp $ + * RCS: @(#) $Id: tclDecls.h,v 1.128 2007/02/23 23:02:53 nijtmans Exp $ */ #ifndef _TCLDECLS @@ -2377,85 +2377,86 @@ EXTERN int Tcl_ChannelBuffered (Tcl_Channel chan); #ifndef Tcl_ChannelName_TCL_DECLARED #define Tcl_ChannelName_TCL_DECLARED /* 398 */ -EXTERN CONST84_RETURN char * Tcl_ChannelName (Tcl_ChannelType * chanTypePtr); +EXTERN CONST84_RETURN char * Tcl_ChannelName ( + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelVersion_TCL_DECLARED #define Tcl_ChannelVersion_TCL_DECLARED /* 399 */ EXTERN Tcl_ChannelTypeVersion Tcl_ChannelVersion ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelBlockModeProc_TCL_DECLARED #define Tcl_ChannelBlockModeProc_TCL_DECLARED /* 400 */ EXTERN Tcl_DriverBlockModeProc * Tcl_ChannelBlockModeProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelCloseProc_TCL_DECLARED #define Tcl_ChannelCloseProc_TCL_DECLARED /* 401 */ EXTERN Tcl_DriverCloseProc * Tcl_ChannelCloseProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelClose2Proc_TCL_DECLARED #define Tcl_ChannelClose2Proc_TCL_DECLARED /* 402 */ EXTERN Tcl_DriverClose2Proc * Tcl_ChannelClose2Proc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelInputProc_TCL_DECLARED #define Tcl_ChannelInputProc_TCL_DECLARED /* 403 */ EXTERN Tcl_DriverInputProc * Tcl_ChannelInputProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelOutputProc_TCL_DECLARED #define Tcl_ChannelOutputProc_TCL_DECLARED /* 404 */ EXTERN Tcl_DriverOutputProc * Tcl_ChannelOutputProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelSeekProc_TCL_DECLARED #define Tcl_ChannelSeekProc_TCL_DECLARED /* 405 */ EXTERN Tcl_DriverSeekProc * Tcl_ChannelSeekProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelSetOptionProc_TCL_DECLARED #define Tcl_ChannelSetOptionProc_TCL_DECLARED /* 406 */ EXTERN Tcl_DriverSetOptionProc * Tcl_ChannelSetOptionProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelGetOptionProc_TCL_DECLARED #define Tcl_ChannelGetOptionProc_TCL_DECLARED /* 407 */ EXTERN Tcl_DriverGetOptionProc * Tcl_ChannelGetOptionProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelWatchProc_TCL_DECLARED #define Tcl_ChannelWatchProc_TCL_DECLARED /* 408 */ EXTERN Tcl_DriverWatchProc * Tcl_ChannelWatchProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelGetHandleProc_TCL_DECLARED #define Tcl_ChannelGetHandleProc_TCL_DECLARED /* 409 */ EXTERN Tcl_DriverGetHandleProc * Tcl_ChannelGetHandleProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelFlushProc_TCL_DECLARED #define Tcl_ChannelFlushProc_TCL_DECLARED /* 410 */ EXTERN Tcl_DriverFlushProc * Tcl_ChannelFlushProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_ChannelHandlerProc_TCL_DECLARED #define Tcl_ChannelHandlerProc_TCL_DECLARED /* 411 */ EXTERN Tcl_DriverHandlerProc * Tcl_ChannelHandlerProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_JoinThread_TCL_DECLARED #define Tcl_JoinThread_TCL_DECLARED @@ -2934,7 +2935,7 @@ EXTERN Tcl_WideInt Tcl_Tell (Tcl_Channel chan); #define Tcl_ChannelWideSeekProc_TCL_DECLARED /* 493 */ EXTERN Tcl_DriverWideSeekProc * Tcl_ChannelWideSeekProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_DictObjPut_TCL_DECLARED #define Tcl_DictObjPut_TCL_DECLARED @@ -3305,7 +3306,7 @@ EXTERN void Tcl_QueryTimeProc (Tcl_GetTimeProc** getProc, #define Tcl_ChannelThreadActionProc_TCL_DECLARED /* 554 */ EXTERN Tcl_DriverThreadActionProc * Tcl_ChannelThreadActionProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_NewBignumObj_TCL_DECLARED #define Tcl_NewBignumObj_TCL_DECLARED @@ -3345,7 +3346,7 @@ EXTERN int Tcl_TruncateChannel (Tcl_Channel chan, #define Tcl_ChannelTruncateProc_TCL_DECLARED /* 561 */ EXTERN Tcl_DriverTruncateProc * Tcl_ChannelTruncateProc ( - Tcl_ChannelType * chanTypePtr); + CONST Tcl_ChannelType * chanTypePtr); #endif #ifndef Tcl_SetChannelErrorInterp_TCL_DECLARED #define Tcl_SetChannelErrorInterp_TCL_DECLARED @@ -3893,20 +3894,20 @@ typedef struct TclStubs { int (*tcl_WriteRaw) (Tcl_Channel chan, CONST char * src, int srcLen); /* 395 */ Tcl_Channel (*tcl_GetTopChannel) (Tcl_Channel chan); /* 396 */ int (*tcl_ChannelBuffered) (Tcl_Channel chan); /* 397 */ - CONST84_RETURN char * (*tcl_ChannelName) (Tcl_ChannelType * chanTypePtr); /* 398 */ - Tcl_ChannelTypeVersion (*tcl_ChannelVersion) (Tcl_ChannelType * chanTypePtr); /* 399 */ - Tcl_DriverBlockModeProc * (*tcl_ChannelBlockModeProc) (Tcl_ChannelType * chanTypePtr); /* 400 */ - Tcl_DriverCloseProc * (*tcl_ChannelCloseProc) (Tcl_ChannelType * chanTypePtr); /* 401 */ - Tcl_DriverClose2Proc * (*tcl_ChannelClose2Proc) (Tcl_ChannelType * chanTypePtr); /* 402 */ - Tcl_DriverInputProc * (*tcl_ChannelInputProc) (Tcl_ChannelType * chanTypePtr); /* 403 */ - Tcl_DriverOutputProc * (*tcl_ChannelOutputProc) (Tcl_ChannelType * chanTypePtr); /* 404 */ - Tcl_DriverSeekProc * (*tcl_ChannelSeekProc) (Tcl_ChannelType * chanTypePtr); /* 405 */ - Tcl_DriverSetOptionProc * (*tcl_ChannelSetOptionProc) (Tcl_ChannelType * chanTypePtr); /* 406 */ - Tcl_DriverGetOptionProc * (*tcl_ChannelGetOptionProc) (Tcl_ChannelType * chanTypePtr); /* 407 */ - Tcl_DriverWatchProc * (*tcl_ChannelWatchProc) (Tcl_ChannelType * chanTypePtr); /* 408 */ - Tcl_DriverGetHandleProc * (*tcl_ChannelGetHandleProc) (Tcl_ChannelType * chanTypePtr); /* 409 */ - Tcl_DriverFlushProc * (*tcl_ChannelFlushProc) (Tcl_ChannelType * chanTypePtr); /* 410 */ - Tcl_DriverHandlerProc * (*tcl_ChannelHandlerProc) (Tcl_ChannelType * chanTypePtr); /* 411 */ + CONST84_RETURN char * (*tcl_ChannelName) (CONST Tcl_ChannelType * chanTypePtr); /* 398 */ + Tcl_ChannelTypeVersion (*tcl_ChannelVersion) (CONST Tcl_ChannelType * chanTypePtr); /* 399 */ + Tcl_DriverBlockModeProc * (*tcl_ChannelBlockModeProc) (CONST Tcl_ChannelType * chanTypePtr); /* 400 */ + Tcl_DriverCloseProc * (*tcl_ChannelCloseProc) (CONST Tcl_ChannelType * chanTypePtr); /* 401 */ + Tcl_DriverClose2Proc * (*tcl_ChannelClose2Proc) (CONST Tcl_ChannelType * chanTypePtr); /* 402 */ + Tcl_DriverInputProc * (*tcl_ChannelInputProc) (CONST Tcl_ChannelType * chanTypePtr); /* 403 */ + Tcl_DriverOutputProc * (*tcl_ChannelOutputProc) (CONST Tcl_ChannelType * chanTypePtr); /* 404 */ + Tcl_DriverSeekProc * (*tcl_ChannelSeekProc) (CONST Tcl_ChannelType * chanTypePtr); /* 405 */ + Tcl_DriverSetOptionProc * (*tcl_ChannelSetOptionProc) (CONST Tcl_ChannelType * chanTypePtr); /* 406 */ + Tcl_DriverGetOptionProc * (*tcl_ChannelGetOptionProc) (CONST Tcl_ChannelType * chanTypePtr); /* 407 */ + Tcl_DriverWatchProc * (*tcl_ChannelWatchProc) (CONST Tcl_ChannelType * chanTypePtr); /* 408 */ + Tcl_DriverGetHandleProc * (*tcl_ChannelGetHandleProc) (CONST Tcl_ChannelType * chanTypePtr); /* 409 */ + Tcl_DriverFlushProc * (*tcl_ChannelFlushProc) (CONST Tcl_ChannelType * chanTypePtr); /* 410 */ + Tcl_DriverHandlerProc * (*tcl_ChannelHandlerProc) (CONST Tcl_ChannelType * chanTypePtr); /* 411 */ int (*tcl_JoinThread) (Tcl_ThreadId threadId, int* result); /* 412 */ int (*tcl_IsChannelShared) (Tcl_Channel channel); /* 413 */ int (*tcl_IsChannelRegistered) (Tcl_Interp* interp, Tcl_Channel channel); /* 414 */ @@ -3988,7 +3989,7 @@ typedef struct TclStubs { Tcl_StatBuf * (*tcl_AllocStatBuf) (void); /* 490 */ Tcl_WideInt (*tcl_Seek) (Tcl_Channel chan, Tcl_WideInt offset, int mode); /* 491 */ Tcl_WideInt (*tcl_Tell) (Tcl_Channel chan); /* 492 */ - Tcl_DriverWideSeekProc * (*tcl_ChannelWideSeekProc) (Tcl_ChannelType * chanTypePtr); /* 493 */ + Tcl_DriverWideSeekProc * (*tcl_ChannelWideSeekProc) (CONST Tcl_ChannelType * chanTypePtr); /* 493 */ int (*tcl_DictObjPut) (Tcl_Interp * interp, Tcl_Obj * dictPtr, Tcl_Obj * keyPtr, Tcl_Obj * valuePtr); /* 494 */ int (*tcl_DictObjGet) (Tcl_Interp * interp, Tcl_Obj * dictPtr, Tcl_Obj * keyPtr, Tcl_Obj ** valuePtrPtr); /* 495 */ int (*tcl_DictObjRemove) (Tcl_Interp * interp, Tcl_Obj * dictPtr, Tcl_Obj * keyPtr); /* 496 */ @@ -4049,14 +4050,14 @@ typedef struct TclStubs { int (*tcl_GetEnsembleNamespace) (Tcl_Interp * interp, Tcl_Command token, Tcl_Namespace ** namespacePtrPtr); /* 551 */ void (*tcl_SetTimeProc) (Tcl_GetTimeProc* getProc, Tcl_ScaleTimeProc* scaleProc, ClientData clientData); /* 552 */ void (*tcl_QueryTimeProc) (Tcl_GetTimeProc** getProc, Tcl_ScaleTimeProc** scaleProc, ClientData* clientData); /* 553 */ - Tcl_DriverThreadActionProc * (*tcl_ChannelThreadActionProc) (Tcl_ChannelType * chanTypePtr); /* 554 */ + Tcl_DriverThreadActionProc * (*tcl_ChannelThreadActionProc) (CONST Tcl_ChannelType * chanTypePtr); /* 554 */ Tcl_Obj* (*tcl_NewBignumObj) (mp_int* value); /* 555 */ Tcl_Obj* (*tcl_DbNewBignumObj) (mp_int* value, CONST char* file, int line); /* 556 */ void (*tcl_SetBignumObj) (Tcl_Obj* obj, mp_int* value); /* 557 */ int (*tcl_GetBignumFromObj) (Tcl_Interp* interp, Tcl_Obj* obj, mp_int* value); /* 558 */ int (*tcl_TakeBignumFromObj) (Tcl_Interp* interp, Tcl_Obj* obj, mp_int* value); /* 559 */ int (*tcl_TruncateChannel) (Tcl_Channel chan, Tcl_WideInt length); /* 560 */ - Tcl_DriverTruncateProc * (*tcl_ChannelTruncateProc) (Tcl_ChannelType * chanTypePtr); /* 561 */ + Tcl_DriverTruncateProc * (*tcl_ChannelTruncateProc) (CONST Tcl_ChannelType * chanTypePtr); /* 561 */ void (*tcl_SetChannelErrorInterp) (Tcl_Interp* interp, Tcl_Obj* msg); /* 562 */ void (*tcl_GetChannelErrorInterp) (Tcl_Interp* interp, Tcl_Obj** msg); /* 563 */ void (*tcl_SetChannelError) (Tcl_Channel chan, Tcl_Obj* msg); /* 564 */ diff --git a/generic/tclIO.c b/generic/tclIO.c index ae49484..5d84324 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIO.c,v 1.115 2007/01/17 10:20:56 dkf Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.116 2007/02/23 23:02:53 nijtmans Exp $ */ #include "tclInt.h" @@ -87,10 +87,10 @@ static void DiscardInputQueued(ChannelState *statePtr, int discardSavedBuffers); static void DiscardOutputQueued(ChannelState *chanPtr); static int DoRead(Channel *chanPtr, char *srcPtr, int slen); -static int DoWrite(Channel *chanPtr, CONST char *src, int srcLen); +static int DoWrite(Channel *chanPtr, const char *src, int srcLen); static int DoReadChars(Channel *chan, Tcl_Obj *objPtr, int toRead, int appendFlag); -static int DoWriteChars(Channel *chan, CONST char *src, int len); +static int DoWriteChars(Channel *chan, const char *src, int len); static int FilterInputBytes(Channel *chanPtr, GetsState *statePtr); static int FlushChannel(Tcl_Interp *interp, Channel *chanPtr, @@ -98,7 +98,7 @@ static int FlushChannel(Tcl_Interp *interp, Channel *chanPtr, static void FreeBinaryEncoding(ClientData clientData); static Tcl_HashTable * GetChannelTable(Tcl_Interp *interp); static int GetInput(Channel *chanPtr); -static int HaveVersion(Tcl_ChannelType *typePtr, +static int HaveVersion(const Tcl_ChannelType *typePtr, Tcl_ChannelTypeVersion minimumVersion); static void PeekAhead(Channel *chanPtr, char **dstEndPtr, GetsState *gsPtr); @@ -113,13 +113,13 @@ static int SetBlockMode(Tcl_Interp *interp, Channel *chanPtr, int mode); static void StopCopy(CopyState *csPtr); static int TranslateInputEOL(ChannelState *statePtr, char *dst, - CONST char *src, int *dstLenPtr, int *srcLenPtr); + const char *src, int *dstLenPtr, int *srcLenPtr); static int TranslateOutputEOL(ChannelState *statePtr, char *dst, - CONST char *src, int *dstLenPtr, int *srcLenPtr); + const char *src, int *dstLenPtr, int *srcLenPtr); static void UpdateInterest(Channel *chanPtr); -static int WriteBytes(Channel *chanPtr, CONST char *src, +static int WriteBytes(Channel *chanPtr, const char *src, int srcLen); -static int WriteChars(Channel *chanPtr, CONST char *src, +static int WriteChars(Channel *chanPtr, const char *src, int srcLen); static Tcl_Obj * FixLevelCode(Tcl_Obj *msg); static void SpliceChannel(Tcl_Channel chan); @@ -1043,7 +1043,7 @@ Tcl_Channel Tcl_GetChannel( Tcl_Interp *interp, /* Interpreter in which to find or create the * channel. */ - CONST char *chanName, /* The name of the channel. */ + const char *chanName, /* The name of the channel. */ int *modePtr) /* Where to store the mode in which the * channel was opened? Will contain an ORed * combination of TCL_READABLE and @@ -1052,7 +1052,7 @@ Tcl_GetChannel( Channel *chanPtr; /* The actual channel. */ Tcl_HashTable *hTblPtr; /* Hash table of channels. */ Tcl_HashEntry *hPtr; /* Search variable. */ - CONST char *name; /* Translated name. */ + const char *name; /* Translated name. */ /* * Substitute "stdin", etc. Note that even though we immediately find the @@ -1121,8 +1121,8 @@ Tcl_GetChannel( Tcl_Channel Tcl_CreateChannel( - Tcl_ChannelType *typePtr, /* The channel type record. */ - CONST char *chanName, /* Name of channel to record. */ + Tcl_ChannelType *typePtr, /* The channel type record. */ + const char *chanName, /* Name of channel to record. */ ClientData instanceData, /* Instance specific data. */ int mask) /* TCL_READABLE & TCL_WRITABLE to indicate if * the channel is readable, writable. */ @@ -1130,7 +1130,7 @@ Tcl_CreateChannel( Channel *chanPtr; /* The channel structure newly created. */ ChannelState *statePtr; /* The stack-level independent state info for * the channel. */ - CONST char *name; + const char *name; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); /* @@ -1316,7 +1316,7 @@ Tcl_CreateChannel( Tcl_Channel Tcl_StackChannel( Tcl_Interp *interp, /* The interpreter we are working in */ - Tcl_ChannelType *typePtr, /* The channel type record for the new + Tcl_ChannelType *typePtr, /* The channel type record for the new * channel. */ ClientData instanceData, /* Instance specific data for the new * channel. */ @@ -1853,7 +1853,7 @@ Tcl_GetChannelMode( *---------------------------------------------------------------------- */ -CONST char * +const char * Tcl_GetChannelName( Tcl_Channel chan) /* The channel for which to return the name. */ { @@ -2274,8 +2274,8 @@ FlushChannel( if (interp != NULL && !TclChanCaughtErrorBypass(interp, (Tcl_Channel) chanPtr)) { /* - * Casting away CONST here is safe because the - * TCL_VOLATILE flag guarantees CONST treatment of the + * Casting away const here is safe because the + * TCL_VOLATILE flag guarantees const treatment of the * Posix error string. */ @@ -3044,7 +3044,7 @@ Tcl_ClearChannelHandlers( int Tcl_Write( Tcl_Channel chan, /* The channel to buffer output for. */ - CONST char *src, /* Data to queue in output buffer. */ + const char *src, /* Data to queue in output buffer. */ int srcLen) /* Length of data in bytes, or < 0 for * strlen(). */ { @@ -3095,7 +3095,7 @@ Tcl_Write( int Tcl_WriteRaw( Tcl_Channel chan, /* The channel to buffer output for. */ - CONST char *src, /* Data to queue in output buffer. */ + const char *src, /* Data to queue in output buffer. */ int srcLen) /* Length of data in bytes, or < 0 for * strlen(). */ { @@ -3153,7 +3153,7 @@ Tcl_WriteRaw( int Tcl_WriteChars( Tcl_Channel chan, /* The channel to buffer output for. */ - CONST char *src, /* UTF-8 characters to queue in output + const char *src, /* UTF-8 characters to queue in output * buffer. */ int len) /* Length of string in bytes, or < 0 for * strlen(). */ @@ -3195,7 +3195,7 @@ Tcl_WriteChars( static int DoWriteChars( Channel *chanPtr, /* The channel to buffer output for. */ - CONST char *src, /* UTF-8 characters to queue in output + const char *src, /* UTF-8 characters to queue in output * buffer. */ int len) /* Length of string in bytes, or < 0 for * strlen(). */ @@ -3308,7 +3308,7 @@ Tcl_WriteObj( static int WriteBytes( Channel *chanPtr, /* The channel to buffer output for. */ - CONST char *src, /* Bytes to write. */ + const char *src, /* Bytes to write. */ int srcLen) /* Number of bytes to write. */ { ChannelState *statePtr = chanPtr->state; @@ -3398,7 +3398,7 @@ WriteBytes( static int WriteChars( Channel *chanPtr, /* The channel to buffer output for. */ - CONST char *src, /* UTF-8 string to write. */ + const char *src, /* UTF-8 string to write. */ int srcLen) /* Length of UTF-8 string in bytes. */ { ChannelState *statePtr = chanPtr->state; @@ -3629,7 +3629,7 @@ TranslateOutputEOL( char *dst, /* Output buffer filled with UTF-8 chars by * applying appropriate EOL translation to * source characters. */ - CONST char *src, /* Source UTF-8 characters. */ + const char *src, /* Source UTF-8 characters. */ int *dstLenPtr, /* On entry, the maximum length of output * buffer in bytes. On exit, the number of * bytes actually used in output buffer. */ @@ -3674,7 +3674,7 @@ TranslateOutputEOL( */ char *dstStart, *dstMax; - CONST char *srcStart; + const char *srcStart; dstStart = dst; dstMax = dst + *dstLenPtr; @@ -5278,7 +5278,7 @@ ReadChars( * Got too many chars. */ - CONST char *eof; + const char *eof; eof = Tcl_UtfAtIndex(dst, toRead); statePtr->inputEncodingState = oldState; @@ -5324,7 +5324,7 @@ TranslateInputEOL( char *dstStart, /* Output buffer filled with chars by applying * appropriate EOL translation to source * characters. */ - CONST char *srcStart, /* Source characters. */ + const char *srcStart, /* Source characters. */ int *dstLenPtr, /* On entry, the maximum length of output * buffer in bytes; must be <= *srcLenPtr. On * exit, the number of bytes actually used in @@ -5334,7 +5334,7 @@ TranslateInputEOL( * source buffer. */ { int dstLen, srcLen, inEofChar; - CONST char *eof; + const char *eof; dstLen = *dstLenPtr; @@ -5348,7 +5348,7 @@ TranslateInputEOL( * buffer. */ - CONST char *src, *srcMax; + const char *src, *srcMax; srcMax = srcStart + *srcLenPtr; for (src = srcStart; src < srcMax; src++) { @@ -5387,7 +5387,7 @@ TranslateInputEOL( } case TCL_TRANSLATE_CRLF: { char *dst; - CONST char *src, *srcEnd, *srcMax; + const char *src, *srcEnd, *srcMax; dst = dstStart; src = srcStart; @@ -5414,7 +5414,7 @@ TranslateInputEOL( } case TCL_TRANSLATE_AUTO: { char *dst; - CONST char *src, *srcEnd, *srcMax; + const char *src, *srcEnd, *srcMax; dst = dstStart; src = srcStart; @@ -5489,7 +5489,7 @@ TranslateInputEOL( int Tcl_Ungets( Tcl_Channel chan, /* The channel for which to add the input. */ - CONST char *str, /* The input itself. */ + const char *str, /* The input itself. */ int len, /* The length of the input. */ int atEnd) /* If non-zero, add at end of queue; otherwise * add at head of queue. */ @@ -6630,15 +6630,15 @@ Tcl_GetChannelBufferSize( int Tcl_BadChannelOption( Tcl_Interp *interp, /* Current interpreter (can be NULL).*/ - CONST char *optionName, /* 'bad option' name */ - CONST char *optionList) /* Specific options list to append to the + const char *optionName, /* 'bad option' name */ + const char *optionList) /* Specific options list to append to the * standard generic options. Can be NULL for * generic options only. */ { if (interp != NULL) { - CONST char *genericopt = + const char *genericopt = "blocking buffering buffersize encoding eofchar translation"; - CONST char **argv; + const char **argv; int argc, i; Tcl_DString ds; @@ -6691,7 +6691,7 @@ int Tcl_GetChannelOption( Tcl_Interp *interp, /* For error reporting - can be NULL. */ Tcl_Channel chan, /* Channel on which to get option. */ - CONST char *optionName, /* Option to get. */ + const char *optionName, /* Option to get. */ Tcl_DString *dsPtr) /* Where to store value(s). */ { size_t len; /* Length of optionName string. */ @@ -6927,8 +6927,8 @@ int Tcl_SetChannelOption( Tcl_Interp *interp, /* For error reporting - can be NULL. */ Tcl_Channel chan, /* Channel on which to set mode. */ - CONST char *optionName, /* Which option to set? */ - CONST char *newValue) /* New value for option. */ + const char *optionName, /* Which option to set? */ + const char *newValue) /* New value for option. */ { Channel *chanPtr = (Channel *) chan; /* The real IO channel. */ @@ -6936,7 +6936,7 @@ Tcl_SetChannelOption( /* State info for channel */ size_t len; /* Length of optionName string. */ int argc; - CONST char **argv; + const char **argv; /* * If the channel is in the middle of a background copy, fail. @@ -7090,7 +7090,7 @@ Tcl_SetChannelOption( return TCL_OK; } else if ((len > 1) && (optionName[1] == 't') && (strncmp(optionName, "-translation", len) == 0)) { - CONST char *readMode, *writeMode; + const char *readMode, *writeMode; if (Tcl_SplitList(interp, newValue, &argc, &argv) == TCL_ERROR) { return TCL_ERROR; @@ -7319,7 +7319,7 @@ Tcl_NotifyChannel( ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); NextChannelHandler nh; Channel *upChanPtr; - Tcl_ChannelType *upTypePtr; + const Tcl_ChannelType *upTypePtr; #ifdef TCL_IO_TRACK_OS_FOR_DRIVER_WITH_BAD_BLOCKING /* @@ -7959,7 +7959,7 @@ Tcl_FileEventObjCmd( Tcl_Interp *interp, /* Interpreter in which the channel for which * to create the handler is found. */ int objc, /* Number of arguments. */ - Tcl_Obj *CONST objv[]) /* Argument objects. */ + Tcl_Obj *const objv[]) /* Argument objects. */ { Channel *chanPtr; /* The channel to create the handler for. */ ChannelState *statePtr; /* State info for channel */ @@ -7967,7 +7967,7 @@ Tcl_FileEventObjCmd( char *chanName; int modeIndex; /* Index of mode argument. */ int mask; - static CONST char *modeOptions[] = {"readable", "writable", NULL}; + static const char *modeOptions[] = {"readable", "writable", NULL}; static int maskArray[] = {TCL_READABLE, TCL_WRITABLE}; if ((objc != 3) && (objc != 4)) { @@ -8846,7 +8846,7 @@ CopyBuffer( static int DoWrite( Channel *chanPtr, /* The channel to buffer output for. */ - CONST char *src, /* Data to write. */ + const char *src, /* Data to write. */ int srcLen) /* Number of bytes to write. */ { ChannelState *statePtr = chanPtr->state; @@ -8854,7 +8854,7 @@ DoWrite( ChannelBuffer *outBufPtr; /* Current output buffer. */ int foundNewline; /* Did we find a newline in output? */ char *dPtr; - CONST char *sPtr; /* Search variables for newline. */ + const char *sPtr; /* Search variables for newline. */ int crsent; /* In CRLF eol translation mode, remember the * fact that a CR was output to the channel * without its following NL. */ @@ -9226,11 +9226,11 @@ Tcl_GetChannelNames( int Tcl_GetChannelNamesEx( Tcl_Interp *interp, /* Interp for error reporting. */ - CONST char *pattern) /* Pattern to filter on. */ + const char *pattern) /* Pattern to filter on. */ { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); ChannelState *statePtr; - CONST char *name; /* Name for channel */ + const char *name; /* Name for channel */ Tcl_Obj *resultPtr; /* Pointer to result object */ Tcl_HashTable *hTblPtr; /* Hash table of channels. */ Tcl_HashEntry *hPtr; /* Search variable. */ @@ -9386,11 +9386,11 @@ Tcl_IsChannelShared( int Tcl_IsChannelExisting( - CONST char *chanName) /* The name of the channel to look for. */ + const char *chanName) /* The name of the channel to look for. */ { ChannelState *statePtr; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); - CONST char *name; + const char *name; int chanNameLen; chanNameLen = strlen(chanName); @@ -9431,9 +9431,9 @@ Tcl_IsChannelExisting( *---------------------------------------------------------------------- */ -CONST char * +const char * Tcl_ChannelName( - Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->typeName; } @@ -9456,7 +9456,7 @@ Tcl_ChannelName( Tcl_ChannelTypeVersion Tcl_ChannelVersion( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { if (chanTypePtr->version == TCL_CHANNEL_VERSION_2) { @@ -9496,7 +9496,7 @@ Tcl_ChannelVersion( static int HaveVersion( - Tcl_ChannelType *chanTypePtr, + const Tcl_ChannelType *chanTypePtr, Tcl_ChannelTypeVersion minimumVersion) { Tcl_ChannelTypeVersion actualVersion = Tcl_ChannelVersion(chanTypePtr); @@ -9521,7 +9521,7 @@ HaveVersion( Tcl_DriverBlockModeProc * Tcl_ChannelBlockModeProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) { @@ -9553,7 +9553,7 @@ Tcl_ChannelBlockModeProc( Tcl_DriverCloseProc * Tcl_ChannelCloseProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->closeProc; @@ -9577,7 +9577,7 @@ Tcl_ChannelCloseProc( Tcl_DriverClose2Proc * Tcl_ChannelClose2Proc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->close2Proc; @@ -9601,7 +9601,7 @@ Tcl_ChannelClose2Proc( Tcl_DriverInputProc * Tcl_ChannelInputProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->inputProc; @@ -9625,7 +9625,7 @@ Tcl_ChannelInputProc( Tcl_DriverOutputProc * Tcl_ChannelOutputProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->outputProc; @@ -9649,7 +9649,7 @@ Tcl_ChannelOutputProc( Tcl_DriverSeekProc * Tcl_ChannelSeekProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->seekProc; @@ -9673,7 +9673,7 @@ Tcl_ChannelSeekProc( Tcl_DriverSetOptionProc * Tcl_ChannelSetOptionProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->setOptionProc; @@ -9697,7 +9697,7 @@ Tcl_ChannelSetOptionProc( Tcl_DriverGetOptionProc * Tcl_ChannelGetOptionProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->getOptionProc; @@ -9721,7 +9721,7 @@ Tcl_ChannelGetOptionProc( Tcl_DriverWatchProc * Tcl_ChannelWatchProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->watchProc; @@ -9745,7 +9745,7 @@ Tcl_ChannelWatchProc( Tcl_DriverGetHandleProc * Tcl_ChannelGetHandleProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { return chanTypePtr->getHandleProc; @@ -9769,7 +9769,7 @@ Tcl_ChannelGetHandleProc( Tcl_DriverFlushProc * Tcl_ChannelFlushProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) { @@ -9797,7 +9797,7 @@ Tcl_ChannelFlushProc( Tcl_DriverHandlerProc * Tcl_ChannelHandlerProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_2)) { @@ -9825,7 +9825,7 @@ Tcl_ChannelHandlerProc( Tcl_DriverWideSeekProc * Tcl_ChannelWideSeekProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_3)) { @@ -9854,7 +9854,7 @@ Tcl_ChannelWideSeekProc( Tcl_DriverThreadActionProc * Tcl_ChannelThreadActionProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_4)) { @@ -10164,7 +10164,7 @@ Tcl_GetChannelError( Tcl_DriverTruncateProc * Tcl_ChannelTruncateProc( - Tcl_ChannelType *chanTypePtr) + const Tcl_ChannelType *chanTypePtr) /* Pointer to channel type. */ { if (HaveVersion(chanTypePtr, TCL_CHANNEL_VERSION_5)) { diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl index db00f04..a332ede 100644 --- a/tools/genStubs.tcl +++ b/tools/genStubs.tcl @@ -8,7 +8,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: genStubs.tcl,v 1.19 2006/11/15 14:58:27 dgp Exp $ +# RCS: @(#) $Id: genStubs.tcl,v 1.20 2007/02/23 23:02:54 nijtmans Exp $ package require Tcl 8 @@ -272,8 +272,8 @@ proc genStubs::emitSlots {name textVar} { proc genStubs::parseDecl {decl} { if {![regexp {^(.*)\((.*)\)$} $decl all prefix args]} { - puts stderr "Malformed declaration: $decl" - return + set prefix $decl + set args {} } set prefix [string trim $prefix] if {![regexp {^(.+[ ][*]*)([^ *]+)$} $prefix all rtype fname]} { @@ -281,6 +281,9 @@ proc genStubs::parseDecl {decl} { return } set rtype [string trim $rtype] + if {$args == ""} { + return [list $rtype $fname {}] + } foreach arg [split $args ,] { lappend argList [string trim $arg] } @@ -363,6 +366,12 @@ proc genStubs::makeDecl {name decl index} { append line " " set pad 0 } + if {$args == ""} { + append line $fname + append text $line + append text ";\n" + return $text + } append line "$fname " set arg1 [lindex $args 0] @@ -433,6 +442,11 @@ proc genStubs::makeMacro {name decl index} { append lfname [string range $fname 1 end] set text "#ifndef $fname\n#define $fname" + if {$args == ""} { + append text " \\\n\t(*${name}StubsPtr->$lfname)" + append text " /* $index */\n#endif\n" + return $text + } append text " \\\n\t(${name}StubsPtr->$lfname)" append text " /* $index */\n#endif\n" return $text @@ -522,6 +536,10 @@ proc genStubs::makeSlot {name decl index} { append lfname [string range $fname 1 end] set text " " + if {$args == ""} { + append text $rtype " *" $lfname "; /* $index */\n" + return $text + } append text $rtype " (*" $lfname ") " set arg1 [lindex $args 0] @@ -566,7 +584,11 @@ proc genStubs::makeSlot {name decl index} { # Returns the formatted declaration string. proc genStubs::makeInit {name decl index} { - append text " " [lindex $decl 1] ", /* " $index " */\n" + if {[lindex $decl 2] == ""} { + append text " &" [lindex $decl 1] ", /* " $index " */\n" + } else { + append text " " [lindex $decl 1] ", /* " $index " */\n" + } return $text } -- cgit v0.12