Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-13
11:18 • Closed ticket [1091046fff]: Accessor functions for iPtr->scriptFile plus ... artifact: fafdd6bc56 user: serhiy.storchaka
2004-12-29
17:56 • Ticket [1091046fff]: 2 changes artifact: 3d760dd053 user: vincentdarley
2004-12-28
01:28 • Ticket [1091046fff]: 4 changes artifact: 2cce79013f user: hobbs
01:22 • Ticket [1091046fff]: 4 changes artifact: e8002e5d6c user: davidw
00:52 • Ticket [1091046fff]: 4 changes artifact: dcdad27eb4 user: hobbs
2004-12-25
09:10 • New ticket [1091046fff]. artifact: 4873b1cab5 user: davidw

Accessor functions for iPtr->scriptFile

Closed / Wont Fix1091046fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 20 days ago
Descriptionplain2004-12-25 09:10:19
Hi,

In Apache Rivet, we would like to be able to do the
equivalent of

info script foobar

to set the name of the rivet file being parsed and
evaluated.  I measured a significant, if not huge
speedup when I set things directly:

Interp *iPtr = (Interp *) interp;
if (iPtr->scriptFile != NULL) {
    Tcl_DecrRefCount(iPtr->scriptFile);
}
iPtr->scriptFile = Tcl_NewStringObj(r->filename, -1);
Tcl_IncrRefCount(iPtr->scriptFile);

Instead of building up and evaluating an "info script
...." command.

However, we have to use the internal API to do the
above... providing a pair of get/set accessor functions
would be appreciated.

Should I write a TIP for this?

Thanks,
Dave
hobbsplain2004-12-28 00:52:36
Logged In: YES 
user_id=72656

I have a hard time thinking of why C code would be setting
the script file, considering this is something meant while
sourcing Tcl files ... are you sure you will be handling it
correctly?
davidwplain2004-12-28 01:22:02
Logged In: YES 
user_id=240

Well... here's how it's used:

There is a file like /var/www/tcl/hello.rvt that gets
accessed like http://foo.bar.com/tcl/hello.rvt

hello.rvt is a template file that is part HTML, part Tcl, so
it doesn't get sourced directly.  We would like it to "know
its name", so to speak.

If there's a better way, we're open to suggestions.

Thanks
hobbsplain2004-12-28 01:28:45
Logged In: YES 
user_id=72656

That depends on how you set that all up.  Tcl_EvalFile
itself does set the scriptFile, but I imagine that you
separate out pieces of the code and eval them separately? 
With so many Tcl_Eval's, it would seem that one more for
'info script' isn't a big deal.  You can speed it up by
doing Tcl_EvalObjv, but I don't see a big deal in making a C
API for this kind of case.
vincentdarley Ticket [1091046fff]: 2 changes [History diff]2004-12-29 17:56:31
serhiy.storchakawiki2026-11-13 11:18:43

Closing per hobbs' comments: no C accessor for the script file was added, evaluating info script through Tcl_EvalObjv remains the way to set it.

Log in (anonymous is fine) to add a comment.