54 const char *
sName(
void)
const;
55 int Read(
int argc,
char *argv[]);
76 Tcl_DecrRefCount(
cmd);
78 if (--interp_cnt == 0) {
94 char *s_type = argv[0];
95 if (strcasecmp(s_type,
"real") == 0) {
98 }
else if (strcasecmp(s_type,
"integer") == 0) {
101 }
else if (strcasecmp(s_type,
"bool") == 0) {
105 silent_cerr(
"unknown or unhandled type \"" << s_type <<
"\"" << std::endl);
109 char *s_tcl = argv[1];
110 if (strncasecmp(s_tcl,
"file://",
STRLENOF(
"file://")) == 0) {
111 char *fname = &s_tcl[
STRLENOF(
"file://")];
117 fin = fopen(fname,
"r");
119 silent_cerr(
"TclPlugIn::Read: unable to open file \"" << fname <<
"\"" << std::endl);
123 if (!fgets(buf,
sizeof(buf), fin)) {
124 silent_cerr(
"TclPlugIn::Read: unable to read from file \"" << fname <<
"\"" << std::endl);
131 while (fgets(buf,
sizeof(buf), fin)) {
136 cmd = Tcl_NewStringObj(s.c_str(), s.length());
143 cmd = Tcl_NewStringObj(s_tcl, strlen(s_tcl));
147 silent_cerr(
"TclPlugIn::Read: Tcl_NewStringObj failed" << std::endl);
151 Tcl_IncrRefCount(
cmd);
167 if (Tcl_EvalObjEx(
interp,
cmd, 0) != TCL_OK) {
168 silent_cerr(
"TclPlugIn::GetVal: Tcl_EvalObjEx failed"
173 res = Tcl_GetObjResult(
interp);
175 silent_cerr(
"TclPlugIn::GetVal: Tcl_GetObjResult failed"
183 if (Tcl_GetIntFromObj(0, res, &i) != TCL_OK) {
184 silent_cerr(
"TclPlugIn::GetVal: Tcl_GetIntFromObj failed"
193 if (Tcl_GetDoubleFromObj(0, res, &d) != TCL_OK) {
194 silent_cerr(
"TclPlugIn::GetVal: Tcl_GetDoubleFromObj failed"
TypedValue GetVal(void) const
#define MBDYN_EXCEPT_ARGS
const char * sName(void) const
int module_init(const char *module_name, void *pdm, void *php)
This function registers our user defined element for the math parser.
TclPlugIn(MathParser &mp)
int Read(int argc, char *argv[])
virtual MathParser & GetMathParser(void)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
static MathParser::PlugIn * tcl_plugin(MathParser &mp, void *arg)
static doublereal buf[BUFSIZE]
int RegisterPlugIn(const char *name, MathParser::PlugIn *(*)(MathParser &, void *), void *arg)
static std::stack< const HighParser * > pHP
TypedValue::Type GetType(void) const
static Tcl_Interp * interp