From 4f970286ec90b02eaf3ad950648ca61a79c193e9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 31 Oct 2013 08:51:10 +0000 Subject: Put extern "C" guards around all stub table struct definitions, so it is usable to be used for C++ compilers as well without the danger of modifying the calling convention. For tkDecls.h, ttkDecls.h tkIntXlibDecls.h is was no problem, because tk.h, tkTheme.h and Xlib.h already contain those guards. But not for the other *Decls.h files. --- generic/tkDecls.h | 8 +++++--- generic/tkInt.h | 8 -------- generic/tkIntDecls.h | 8 +++++--- generic/tkIntPlatDecls.h | 8 +++++--- generic/tkIntXlibDecls.h | 8 +++++--- generic/tkPlatDecls.h | 8 +++++--- generic/ttk/ttkDecls.h | 8 +++++--- generic/ttk/ttkGenStubs.tcl | 28 ++++++++++++++++++++++------ 8 files changed, 52 insertions(+), 32 deletions(-) diff --git a/generic/tkDecls.h b/generic/tkDecls.h index 6a2cca0..00a3dde 100644 --- a/generic/tkDecls.h +++ b/generic/tkDecls.h @@ -25,6 +25,10 @@ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -1970,10 +1974,8 @@ typedef struct TkStubs { void (*tkUnusedStubEntry) (void); /* 275 */ } TkStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TkStubs *tkStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/tkInt.h b/generic/tkInt.h index 74fd351..15a01c5 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -976,11 +976,6 @@ MODULE_SCOPE CONST char *const tkWebColors[20]; #include "tkIntDecls.h" -#ifdef BUILD_tk -#undef TCL_STORAGE_CLASS -#define TCL_STORAGE_CLASS DLLEXPORT -#endif - /* * Themed widget set init function: */ @@ -1201,9 +1196,6 @@ MODULE_SCOPE int TkUnsupported1ObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -#undef TCL_STORAGE_CLASS -#define TCL_STORAGE_CLASS DLLIMPORT - #endif /* _TKINT */ /* diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h index 063301d..9dea8d4 100644 --- a/generic/tkIntDecls.h +++ b/generic/tkIntDecls.h @@ -28,6 +28,10 @@ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -1189,10 +1193,8 @@ typedef struct TkIntStubs { void (*tkUnusedStubEntry) (void); /* 184 */ } TkIntStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TkIntStubs *tkIntStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index a181073..9b800f3 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -26,6 +26,10 @@ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -731,10 +735,8 @@ typedef struct TkIntPlatStubs { #endif /* X11 */ } TkIntPlatStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TkIntPlatStubs *tkIntPlatStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 1357ceb..b978561 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -36,6 +36,10 @@ typedef int (*XAfterFunction) ( /* WARNING, this type not in Xlib spec */ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -1453,10 +1457,8 @@ typedef struct TkIntXlibStubs { #endif /* AQUA */ } TkIntXlibStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TkIntXlibStubs *tkIntXlibStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/tkPlatDecls.h b/generic/tkPlatDecls.h index 549ae30..eb3d74d 100644 --- a/generic/tkPlatDecls.h +++ b/generic/tkPlatDecls.h @@ -25,6 +25,10 @@ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -154,10 +158,8 @@ typedef struct TkPlatStubs { #endif /* AQUA */ } TkPlatStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TkPlatStubs *tkPlatStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/ttk/ttkDecls.h b/generic/ttk/ttkDecls.h index ee679b7..8473d36 100644 --- a/generic/ttk/ttkDecls.h +++ b/generic/ttk/ttkDecls.h @@ -23,6 +23,10 @@ extern const char *TtkInitializeStubs( #define TTK_STUBS_EPOCH 0 #define TTK_STUBS_REVISION 31 +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -178,10 +182,8 @@ typedef struct TtkStubs { int (*ttk_GetOrientFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *orient); /* 40 */ } TtkStubs; -#ifdef __cplusplus -extern "C" { -#endif extern const TtkStubs *ttkStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/ttk/ttkGenStubs.tcl b/generic/ttk/ttkGenStubs.tcl index 90dea25..3c8eb19 100644 --- a/generic/ttk/ttkGenStubs.tcl +++ b/generic/ttk/ttkGenStubs.tcl @@ -187,7 +187,6 @@ proc genStubs::declare {args} { variable revision incr revision - if {[llength $args] == 2} { lassign $args index decl set status current @@ -214,7 +213,25 @@ proc genStubs::declare {args} { if {$index > $stubs($curName,lastNum)} { set stubs($curName,lastNum) $index } + return +} + +# genStubs::export -- +# +# This function is used in the declarations file to declare a symbol +# that is exported from the library but is not in the stubs table. +# +# Arguments: +# decl The C function declaration, or {} for an undefined +# entry. +# +# Results: +# None. +proc genStubs::export {args} { + if {[llength $args] != 1} { + puts stderr "wrong # args: export $args" + } return } @@ -410,7 +427,6 @@ proc genStubs::parseArg {arg} { proc genStubs::makeDecl {name decl index} { variable scspec - lassign $decl rtype fname args append text "/* $index */\n" @@ -731,6 +747,8 @@ proc genStubs::emitHeader {name} { append text "#define ${CAPName}_STUBS_EPOCH $epoch\n" append text "#define ${CAPName}_STUBS_REVISION $revision\n" + append text "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n" + emitDeclarations $name text if {[info exists hooks($name)]} { @@ -752,8 +770,7 @@ proc genStubs::emitHeader {name} { append text "} ${capName}Stubs;\n\n" - append text "#ifdef __cplusplus\nextern \"C\" {\n#endif\n" - append text "extern const ${capName}Stubs *${name}StubsPtr;\n" + append text "extern const ${capName}Stubs *${name}StubsPtr;\n\n" append text "#ifdef __cplusplus\n}\n#endif\n" emitMacros $name text @@ -778,10 +795,9 @@ proc genStubs::emitInit {name textVar} { variable interfaces variable epoch variable revision - upvar $textVar text - set root 1 + set root 1 set capName [string toupper [string index $name 0]] append capName [string range $name 1 end] set CAPName [string toupper $name] -- cgit v0.12