Subject: Simplification: don't declare struct types that are never used.

From: "[email-masked]" <jan.nijtmans>
Date: Thu, 15 Nov 2012 11:48:05 +0000

---
 generic/tclDecls.h        | 4 ++--
 generic/tclIntDecls.h     | 2 +-
 generic/tclIntPlatDecls.h | 2 +-
 generic/tclOODecls.h      | 4 ++--
 generic/tclOOIntDecls.h   | 2 +-
 generic/tclPlatDecls.h    | 2 +-
 generic/tclTomMathDecls.h | 2 +-
 tools/genStubs.tcl        | 8 ++++++--
 8 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 3ae8b33..2801102 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -1812,7 +1812,7 @@ EXTERN void		Tcl_ZlibStreamSetCompressionDictionary(
 				Tcl_ZlibStream zhandle,
 				Tcl_Obj *compressionDictionaryObj);
 
-typedef struct TclStubHooks {
+typedef struct {
     const struct TclPlatStubs *tclPlatStubs;
     const struct TclIntStubs *tclIntStubs;
     const struct TclIntPlatStubs *tclIntPlatStubs;
@@ -1820,7 +1820,7 @@ typedef struct TclStubHooks {
 
 typedef struct TclStubs {
     int magic;
-    const struct TclStubHooks *hooks;
+    const TclStubHooks *hooks;
 
     int (*tcl_PkgProvideEx) (Tcl_Interp *interp, const char *name, const char *version, const void *clientData); /* 0 */
     CONST84_RETURN char * (*tcl_PkgRequireEx) (Tcl_Interp *interp, const char *name, const char *version, int exact, void *clientDataPtr); /* 1 */
diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h
index d01d10a..df5ac97 100644
--- a/generic/tclIntDecls.h
+++ b/generic/tclIntDecls.h
@@ -604,7 +604,7 @@ EXTERN void		TclSetSlaveCancelFlags(Tcl_Interp *interp, int flags,
 
 typedef struct TclIntStubs {
     int magic;
-    const struct TclIntStubHooks *hooks;
+    void *hooks;
 
     void (*reserved0)(void);
     void (*reserved1)(void);
diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h
index 16d8896..f265e7e 100644
--- a/generic/tclIntPlatDecls.h
+++ b/generic/tclIntPlatDecls.h
@@ -246,7 +246,7 @@ EXTERN int		TclWinCPUID(unsigned int index, unsigned int *regs);
 
 typedef struct TclIntPlatStubs {
     int magic;
-    const struct TclIntPlatStubHooks *hooks;
+    void *hooks;
 
 #if !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* UNIX */
     void (*tclGetAndDetachPids) (Tcl_Interp *interp, Tcl_Channel chan); /* 0 */
diff --git a/generic/tclOODecls.h b/generic/tclOODecls.h
index 6316303..58871c6 100644
--- a/generic/tclOODecls.h
+++ b/generic/tclOODecls.h
@@ -100,13 +100,13 @@ TCLOOAPI void		Tcl_ClassSetDestructor(Tcl_Interp *interp,
 TCLOOAPI Tcl_Obj *	Tcl_GetObjectName(Tcl_Interp *interp,
 				Tcl_Object object);
 
-typedef struct TclOOStubHooks {
+typedef struct {
     const struct TclOOIntStubs *tclOOIntStubs;
 } TclOOStubHooks;
 
 typedef struct TclOOStubs {
     int magic;
-    const struct TclOOStubHooks *hooks;
+    const TclOOStubHooks *hooks;
 
     Tcl_Object (*tcl_CopyObjectInstance) (Tcl_Interp *interp, Tcl_Object sourceObject, const char *targetName, const char *targetNamespaceName); /* 0 */
     Tcl_Object (*tcl_GetClassAsObject) (Tcl_Class clazz); /* 1 */
diff --git a/generic/tclOOIntDecls.h b/generic/tclOOIntDecls.h
index c751838..acafb18 100644
--- a/generic/tclOOIntDecls.h
+++ b/generic/tclOOIntDecls.h
@@ -90,7 +90,7 @@ TCLOOAPI void		TclOOClassSetMixins(Tcl_Interp *interp,
 
 typedef struct TclOOIntStubs {
     int magic;
-    const struct TclOOIntStubHooks *hooks;
+    void *hooks;
 
     Tcl_Object (*tclOOGetDefineCmdContext) (Tcl_Interp *interp); /* 0 */
     Tcl_Method (*tclOOMakeProcInstanceMethod) (Tcl_Interp *interp, Object *oPtr, int flags, Tcl_Obj *nameObj, Tcl_Obj *argsObj, Tcl_Obj *bodyObj, const Tcl_MethodType *typePtr, ClientData clientData, Proc **procPtrPtr); /* 1 */
diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h
index 48ad390..e9b92fe 100644
--- a/generic/tclPlatDecls.h
+++ b/generic/tclPlatDecls.h
@@ -69,7 +69,7 @@ EXTERN int		Tcl_MacOSXOpenVersionedBundleResources(
 
 typedef struct TclPlatStubs {
     int magic;
-    const struct TclPlatStubHooks *hooks;
+    void *hooks;
 
 #if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */
     TCHAR * (*tcl_WinUtfToTChar) (const char *str, int len, Tcl_DString *dsPtr); /* 0 */
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h
index 4f6c3bf..ef22153 100644
--- a/generic/tclTomMathDecls.h
+++ b/generic/tclTomMathDecls.h
@@ -278,7 +278,7 @@ EXTERN int		TclBN_mp_cnt_lsb(const mp_int *a);
 
 typedef struct TclTomMathStubs {
     int magic;
-    const struct TclTomMathStubHooks *hooks;
+    void *hooks;
 
     int (*tclBN_epoch) (void); /* 0 */
     int (*tclBN_revision) (void); /* 1 */
diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl
index dea63e6..bbeb4bf 100644
--- a/tools/genStubs.tcl
+++ b/tools/genStubs.tcl
@@ -986,7 +986,7 @@ proc genStubs::emitHeader {name} {
     emitDeclarations $name text
 
     if {[info exists hooks($name)]} {
-	append text "\ntypedef struct ${capName}StubHooks {\n"
+	append text "\ntypedef struct {\n"
 	foreach hook $hooks($name) {
 	    set capHook [string toupper [string index $hook 0]]
 	    append capHook [string range $hook 1 end]
@@ -1000,7 +1000,11 @@ proc genStubs::emitHeader {name} {
 	append text "    int epoch;\n"
 	append text "    int revision;\n"
     }
-    append text "    const struct ${capName}StubHooks *hooks;\n\n"
+    if {[info exists hooks($name)]} {
+	append text "    const ${capName}StubHooks *hooks;\n\n"
+    } else {
+	append text "    void *hooks;\n\n"
+    }
 
     emitSlots $name text
 
-- 
cgit v0.12