Is there a way to tell what chaiscript file is being evaluated with the "eval_file" or "use" functions from inside the file?


#1

Hi,
I have my own print function that replaces Chaiscript’s. I’m wondering if I can add a feature here to show the context of a print statement being triggered.

For example, my C++ logging system uses this “info” macro.
#define info(string) diagnosticLog(p::INFO, __FILE__, __FUNCTION__, __LINE__, string);
Which uses compiler-defined values to work out where the print statement happened during compilation to produce:
“INFO[fake/path/file.cpp (fakeFunction:12)]: string”

Does chaiscript have anything that I can use like I used __FILE__, __FUNCTION__ and __LINE__ in MSC? Or are there any alternative methods of getting the evaluation context that I can use from the C++ side?

Thanks for any help.


#2

No… I don’t currently have anything like that. I mean technically you could throw, the catch, then look at the eval stack, then continue, but that’s not really what you want I’m guessing.

Please add a feature request to the bug tracker.


#3

Throwing then catching would work. How would I do that and get an eval stack?


#4

I’ve just tried several methods that I thought would work and was unable to come up with an actual viable option - sorry. I’ll see about addressing it as a new feature.