Skip to content

Commit

Permalink
More usage of Tcl_Size, in stead of #if's
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Nov 4, 2022
1 parent 95729ce commit 2447c7a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 32 deletions.
19 changes: 7 additions & 12 deletions generic/itcl.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,17 @@ ITCL_EXTERN int Itcl_SafeInit(Tcl_Interp *interp);
#define ITCL_PRIVATE 3
#define ITCL_DEFAULT_PROTECT 4

#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 7) && !defined(Tcl_Size)
# define Tcl_Size int
#endif

/*
* Generic stack.
*/
typedef struct Itcl_Stack {
void **values; /* values on stack */
#if TCL_MAJOR_VERSION > 8
size_t len; /* number of values on stack */
size_t max; /* maximum size of stack */
#else
int len;
int max;
#endif
Tcl_Size len; /* number of values on stack */
Tcl_Size max; /* maximum size of stack */
void *space[5]; /* initial space for stack data */
} Itcl_Stack;

Expand All @@ -162,11 +161,7 @@ typedef struct Itcl_ListElem {

typedef struct Itcl_List {
int validate; /* validation stamp */
#if TCL_MAJOR_VERSION > 8
size_t num; /* number of elements */
#else
int num;
#endif
Tcl_Size num; /* number of elements */
struct Itcl_ListElem *head; /* previous element in linked list */
struct Itcl_ListElem *tail; /* next element in linked list */
} Itcl_List;
Expand Down
14 changes: 5 additions & 9 deletions generic/itclInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,10 @@
# endif
#endif

#if TCL_MAJOR_VERSION > 8
# define ITCL_Z_MODIFIER TCL_Z_MODIFIER
#else
#if TCL_MAJOR_VERSION == 8
# define ITCL_Z_MODIFIER ""
#endif

#if !defined(Tcl_Size)
# define Tcl_Size int
#else
# define ITCL_Z_MODIFIER TCL_Z_MODIFIER
#endif

/*
Expand Down Expand Up @@ -612,7 +608,7 @@ typedef struct ItclMethodVariable {
typedef struct ItclClassCmdInfo {
int type;
int protection;
#if TCL_MAJOR_VERSION < 9
#if TCL_MAJOR_VERSION == 8
int cmdNum; /* not actually used */
#endif
Tcl_Namespace *nsPtr;
Expand Down Expand Up @@ -640,7 +636,7 @@ typedef struct ItclVarLookup {
*/
typedef struct ItclCmdLookup {
ItclMemberFunc* imPtr; /* function definition */
#if TCL_MAJOR_VERSION < 9
#if TCL_MAJOR_VERSION == 8
int cmdNum; /* not actually used */
#endif
ItclClassCmdInfo *classCmdInfoPtr;
Expand Down
4 changes: 0 additions & 4 deletions generic/itclIntDecls.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#ifndef _ITCLINTDECLS
#define _ITCLINTDECLS

#if !defined(Tcl_Size)
# define Tcl_Size int
#endif

/* !BEGIN!: Do not edit below this line. */

#define ITCLINT_STUBS_EPOCH 0
Expand Down
8 changes: 1 addition & 7 deletions generic/itclMigrate2TclCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,9 @@ typedef struct Tcl_ResolvedVarInfo {
Tcl_ResolveVarDeleteProc *deleteProc;
} Tcl_ResolvedVarInfo;

#if TCL_MAJOR_VERSION > 8
typedef int (Tcl_ResolveCompiledVarProc) (Tcl_Interp *interp,
const char *name, size_t length, Tcl_Namespace *context,
const char *name, Tcl_Size length, Tcl_Namespace *context,
Tcl_ResolvedVarInfo **rPtr);
#else
typedef int (Tcl_ResolveCompiledVarProc) (Tcl_Interp *interp,
const char *name, int length, Tcl_Namespace *context,
Tcl_ResolvedVarInfo **rPtr);
#endif

typedef int (Tcl_ResolveVarProc) (Tcl_Interp *interp, const char *name,
Tcl_Namespace *context, int flags, Tcl_Var *rPtr);
Expand Down

0 comments on commit 2447c7a

Please sign in to comment.