summaryrefslogtreecommitdiffstats
path: root/unix/tclLoadDl.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-02-28 12:06:07 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-02-28 12:06:07 (GMT)
commit52e543c5691a60c3ef802fecf1ae08e7efcf19b7 (patch)
tree1f02ba454f2725719d80901eef77168723e980f7 /unix/tclLoadDl.c
parentf9ddbba3d621449f2cb1b2a4d0a94927b48391eb (diff)
parent24a416ad3867b536dd613454c6f07df349f797f2 (diff)
downloadtcl-52e543c5691a60c3ef802fecf1ae08e7efcf19b7.zip
tcl-52e543c5691a60c3ef802fecf1ae08e7efcf19b7.tar.gz
tcl-52e543c5691a60c3ef802fecf1ae08e7efcf19b7.tar.bz2
Implement TIP #557: C++ support for Tcl
Diffstat (limited to 'unix/tclLoadDl.c')
-rw-r--r--unix/tclLoadDl.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c
index 7b85a67..052aa07 100644
--- a/unix/tclLoadDl.c
+++ b/unix/tclLoadDl.c
@@ -83,7 +83,7 @@ TclpDlopen(
* relative path.
*/
- native = Tcl_FSGetNativePath(pathPtr);
+ native = (const char *)Tcl_FSGetNativePath(pathPtr);
/*
* Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070]
*/
@@ -131,7 +131,7 @@ TclpDlopen(
}
return TCL_ERROR;
}
- newHandle = ckalloc(sizeof(*newHandle));
+ newHandle = (Tcl_LoadHandle)ckalloc(sizeof(*newHandle));
newHandle->clientData = handle;
newHandle->findSymbolProcPtr = &FindSymbol;
newHandle->unloadFileProcPtr = &UnloadFile;
@@ -188,6 +188,31 @@ FindSymbol(
proc = dlsym(handle, native); /* INTL: Native. */
Tcl_DStringFree(&newName);
}
+#ifdef __cplusplus
+ if (proc == NULL) {
+ char buf[32];
+ sprintf(buf, "%d", Tcl_DStringLength(&ds));
+ Tcl_DStringInit(&newName);
+ TclDStringAppendLiteral(&newName, "__Z");
+ Tcl_DStringAppend(&newName, buf, -1);
+ Tcl_DStringAppend(&newName, Tcl_DStringValue(&ds), -1);
+ TclDStringAppendLiteral(&newName, "P10Tcl_Interp");
+ native = Tcl_DStringValue(&newName);
+ proc = dlsym(handle, native + 1); /* INTL: Native. */
+ if (proc == NULL) {
+ proc = dlsym(handle, native); /* INTL: Native. */
+ }
+ if (proc == NULL) {
+ TclDStringAppendLiteral(&newName, "i");
+ native = Tcl_DStringValue(&newName);
+ proc = dlsym(handle, native + 1); /* INTL: Native. */
+ }
+ if (proc == NULL) {
+ proc = dlsym(handle, native); /* INTL: Native. */
+ }
+ Tcl_DStringFree(&newName);
+ }
+#endif
Tcl_DStringFree(&ds);
if (proc == NULL) {
const char *errorStr = dlerror();
@@ -261,6 +286,8 @@ TclGuessPackageName(
Tcl_DString *bufPtr) /* Initialized empty dstring. Append package
* name to this if possible. */
{
+ (void)fileName;
+ (void)bufPtr;
return 0;
}