From dbd9c34d17d087fab47cf5e2a990b656f0fe5814 Mon Sep 17 00:00:00 2001 From: "mhochsteger@cerbsim.com" Date: Mon, 11 Oct 2021 16:04:00 +0200 Subject: [PATCH] tcl wrapper (no need to have tcl.h to build ngsolve) --- ng/CMakeLists.txt | 6 +++++- ng/ngtcl.cpp | 16 ++++++++++++++++ ng/ngtcl.hpp | 30 ++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 ng/ngtcl.cpp create mode 100644 ng/ngtcl.hpp diff --git a/ng/CMakeLists.txt b/ng/CMakeLists.txt index 235ad46c..50e4835c 100644 --- a/ng/CMakeLists.txt +++ b/ng/CMakeLists.txt @@ -14,7 +14,7 @@ endif(WIN32) if(USE_GUI) add_library(gui SHARED - gui.cpp ngpkg.cpp demoview.cpp parallelfunc.cpp + gui.cpp ngpkg.cpp demoview.cpp parallelfunc.cpp ngtcl.cpp ../libsrc/stlgeom/stlpkg.cpp ../libsrc/visualization/visualpkg.cpp ../libsrc/csg/csgpkg.cpp ../libsrc/geom2d/geom2dpkg.cpp ../libsrc/occ/occpkg.cpp ../libsrc/occ/vsocc.cpp @@ -83,5 +83,9 @@ if(USE_GUI) endif() add_subdirectory(Togl2.1) + install(FILES + ngtcl.hpp + DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel + ) endif(USE_GUI) diff --git a/ng/ngtcl.cpp b/ng/ngtcl.cpp new file mode 100644 index 00000000..367228cb --- /dev/null +++ b/ng/ngtcl.cpp @@ -0,0 +1,16 @@ +#include "ngtcl.hpp" + +#include + +namespace netgen +{ + void Ng_Tcl_SetResult(Tcl_Interp *interp, char *result, const int freeProc) + { + Tcl_SetResult(interp, result, (Tcl_FreeProc*)freeProc); + } + + void Ng_Tcl_CreateCommand(Tcl_Interp *interp, const char *cmdName, Tcl_CmdProc *proc) + { + Tcl_CreateCommand(interp, cmdName, proc, nullptr, nullptr); + } +} diff --git a/ng/ngtcl.hpp b/ng/ngtcl.hpp new file mode 100644 index 00000000..a548cad9 --- /dev/null +++ b/ng/ngtcl.hpp @@ -0,0 +1,30 @@ +#ifndef FILE_NG_TCL_HPP +#define FILE_NG_TCL_HPP + +#include + +class Tcl_Interp; +class Tcl_cmdProc; + +namespace netgen +{ + typedef int (Tcl_CmdProc) (void * clientData, Tcl_Interp *interp, + int argc, const char *argv[]); + + inline constexpr int NG_TCL_VOLATILE = 1; + inline constexpr int NG_TCL_STATIC = 0; + inline constexpr int NG_TCL_DYNAMIC = 3; + + inline constexpr int NG_TCL_OK = 0; + inline constexpr int NG_TCL_ERROR = 1; + inline constexpr int NG_TCL_RETURN = 2; + inline constexpr int NG_TCL_BREAK = 3; + inline constexpr int NG_TCL_CONTINUE = 4; + + DLL_HEADER void Ng_Tcl_SetResult(Tcl_Interp *interp, char *result, const int freeProc); + DLL_HEADER void Ng_Tcl_CreateCommand(Tcl_Interp *interp, + const char *cmdName, Tcl_CmdProc *proc); + +} + +#endif // FILE_NG_TCL_HPP