summaryrefslogtreecommitdiffstats
path: root/src/bltInt.C
diff options
context:
space:
mode:
authorjoye <joye>2013-09-05 20:59:27 (GMT)
committerjoye <joye>2013-09-05 20:59:27 (GMT)
commitde13418f43aa51593082644e628cd538405d8229 (patch)
treecc24424be796e476fa9d83e86af945eed3f443e9 /src/bltInt.C
parent74ef426eee50d3dd94809eb833ce7f5d038fbb59 (diff)
downloadblt-de13418f43aa51593082644e628cd538405d8229.zip
blt-de13418f43aa51593082644e628cd538405d8229.tar.gz
blt-de13418f43aa51593082644e628cd538405d8229.tar.bz2
*** empty log message ***
Diffstat (limited to 'src/bltInt.C')
-rw-r--r--src/bltInt.C185
1 files changed, 66 insertions, 119 deletions
diff --git a/src/bltInt.C b/src/bltInt.C
index a702050..5303ffc 100644
--- a/src/bltInt.C
+++ b/src/bltInt.C
@@ -1,4 +1,3 @@
-
/*
* bltCoreInit.c --
*
@@ -28,110 +27,54 @@
*/
#include "bltInt.h"
-#include "bltNsUtil.h"
-#include "bltMath.h"
-#ifndef BLT_LIBRARY
-# define BLT_LIBRARY "unknown"
+Tcl_AppInitProc Blt_core_Init;
+Tcl_AppInitProc Blt_core_SafeInit;
+Tcl_AppInitProc Blt_x_Init;
+Tcl_AppInitProc Blt_x_SafeInit;
+Tcl_AppInitProc Blt_Init;
+
+int Blt_core_Init(Tcl_Interp *interp)
+{
+ Tcl_Namespace *nsPtr;
+
+ if(
+#ifdef USE_TCL_STUBS
+ Tcl_InitStubs(interp, TCL_PATCH_LEVEL, 0)
+#else
+ Tcl_PkgRequire(interp, "Tcl", TCL_PATCH_LEVEL, 0)
#endif
+ == NULL) {
+ return TCL_ERROR;
+ }
-BLT_EXTERN Tcl_AppInitProc Blt_core_Init;
-BLT_EXTERN Tcl_AppInitProc Blt_core_SafeInit;
+ nsPtr = Tcl_FindNamespace(interp, "::blt", (Tcl_Namespace *)NULL, 0);
+ if (nsPtr == NULL) {
+ nsPtr = Tcl_CreateNamespace(interp, "::blt", NULL, NULL);
+ if (nsPtr == NULL) {
+ return TCL_ERROR;
+ }
+ }
-static char libPath[1024] =
-{
- BLT_LIBRARY
-};
+ if (Blt_VectorCmdInitProc(interp) != TCL_OK)
+ return TCL_ERROR;
-/*
- * Script to set the BLT library path in the variable global "blt_library"
- *
- * Checks the usual locations for a file (bltGraph.pro) from the BLT library.
- * The places searched in order are
- *
- * $BLT_LIBRARY
- * $BLT_LIBRARY/blt2.4
- * $BLT_LIBRARY/..
- * $BLT_LIBRARY/../blt2.4
- * $blt_libPath
- * $blt_libPath/blt2.4
- * $blt_libPath/..
- * $blt_libPath/../blt2.4
- * $tcl_library
- * $tcl_library/blt2.4
- * $tcl_library/..
- * $tcl_library/../blt2.4
- * $env(TCL_LIBRARY)
- * $env(TCL_LIBRARY)/blt2.4
- * $env(TCL_LIBRARY)/..
- * $env(TCL_LIBRARY)/../blt2.4
- *
- * The TCL variable "blt_library" is set to the discovered path. If the file
- * wasn't found, no error is returned. The actual usage of $blt_library is
- * purposely deferred so that it can be set from within a script.
- */
+ if (Tcl_PkgProvide(interp, "blt_core", BLT_VERSION) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ return TCL_OK;
+}
-/* FIXME: Change this to a namespace procedure in 3.0 */
-
-static char initScript[] =
-{"\n\
-global blt_library blt_libPath blt_version tcl_library env\n\
-set blt_library {}\n\
-set path {}\n\
-foreach var { env(BLT_LIBRARY) blt_libPath tcl_library env(TCL_LIBRARY) } { \n\
- if { ![info exists $var] } { \n\
- continue \n\
- } \n\
- set path [set $var] \n\
- if { [file readable [file join $path bltGraph.pro]] } { \n\
- set blt_library $path\n\
- break \n\
- } \n\
- set path [file join $path blt$blt_version ] \n\
- if { [file readable [file join $path bltGraph.pro]] } { \n\
- set blt_library $path\n\
- break \n\
- } \n\
- set path [file dirname [set $var]] \n\
- if { [file readable [file join $path bltGraph.pro]] } { \n\
- set blt_library $path\n\
- break \n\
- } \n\
- set path [file join $path blt$blt_version ] \n\
- if { [file readable [file join $path bltGraph.pro]] } { \n\
- set blt_library $path\n\
- break \n\
- } \n\
-} \n\
-if { $blt_library != \"\" } { \n\
- global auto_path \n\
- lappend auto_path $blt_library \n\
-}\n\
-unset var path\n\
-\n"
-};
-
-static int
-SetLibraryPath(Tcl_Interp *interp)
+int
+Blt_core_SafeInit(Tcl_Interp *interp)
{
- Tcl_DString dString;
- const char *value;
-
- Tcl_DStringInit(&dString);
- Tcl_DStringAppend(&dString, libPath, -1);
- value = Tcl_SetVar(interp, "blt_libPath", Tcl_DStringValue(&dString),
- TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG);
- Tcl_DStringFree(&dString);
- if (value == NULL) {
- return TCL_ERROR;
- }
- return TCL_OK;
+ return Blt_core_Init(interp);
}
-int Blt_core_Init(Tcl_Interp *interp)
+int
+Blt_x_Init(Tcl_Interp *interp) /* Interpreter to add extra commands */
{
Tcl_Namespace *nsPtr;
- const char *result;
if(
#ifdef USE_TCL_STUBS
@@ -143,45 +86,49 @@ int Blt_core_Init(Tcl_Interp *interp)
return TCL_ERROR;
}
- /* Set the "blt_version", "blt_patchLevel", and "blt_libPath" Tcl
- * variables. We'll use them in the following script. */
+ if(
+#ifdef USE_TCL_STUBS
+ Tk_InitStubs(interp, TK_PATCH_LEVEL, 0)
+#else
+ Tcl_PkgRequire(interp, "Tk", TK_PATCH_LEVEL, 0)
+#endif
+ == NULL) {
+ return TCL_ERROR;
+ }
- result = Tcl_SetVar(interp, "blt_version", BLT_VERSION, TCL_GLOBAL_ONLY);
- if (result == NULL) {
- return TCL_ERROR;
- }
- result = Tcl_SetVar(interp, "blt_patchLevel", BLT_PATCH_LEVEL,
- TCL_GLOBAL_ONLY);
- if (result == NULL) {
- return TCL_ERROR;
- }
- if (SetLibraryPath(interp) != TCL_OK) {
- return TCL_ERROR;
- }
- if (Tcl_Eval(interp, initScript) != TCL_OK) {
+ nsPtr = Tcl_CreateNamespace(interp, "::blt::tk", NULL, NULL);
+ if (nsPtr == NULL) {
return TCL_ERROR;
}
-
- nsPtr = Tcl_FindNamespace(interp, "::blt", (Tcl_Namespace *)NULL, 0);
+ nsPtr = Tcl_FindNamespace(interp, "::blt", NULL, TCL_LEAVE_ERR_MSG);
if (nsPtr == NULL) {
- nsPtr = Tcl_CreateNamespace(interp, "::blt", NULL, NULL);
- if (nsPtr == NULL) {
- return TCL_ERROR;
- }
+ return TCL_ERROR;
}
- if (Blt_VectorCmdInitProc(interp) != TCL_OK)
+ if (Blt_GraphCmdInitProc(interp) != TCL_OK)
return TCL_ERROR;
- if (Tcl_PkgProvide(interp, "blt_core", BLT_VERSION) != TCL_OK) {
+ if (Tcl_PkgProvide(interp, "blt_extra", BLT_VERSION) != TCL_OK) {
return TCL_ERROR;
}
return TCL_OK;
}
int
-Blt_core_SafeInit(Tcl_Interp *interp)
+Blt_x_SafeInit(Tcl_Interp *interp)
+{
+ return Blt_x_Init(interp);
+}
+
+int
+Blt_Init(Tcl_Interp *interp)
{
- return Blt_core_Init(interp);
+ if (Blt_core_Init(interp) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (Blt_x_Init(interp) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ return TCL_OK;
}