I am running some off target unit tests using a build of the squirrel run time I got from their website. I use the blob.tostring() method in my code at one point, and obviously it fails on my machine because that is an extension the EI added.
Can I get a hint on how to modify the squirrel source files so I can have that method locally, preferably with the same (or similar) functionality that the EI squirrel run time uses?
This method copies the target blob’s bytes into a new string of 8-bit character values and then returns it. This is behavior unique to the imp implementation of Squirrel, not a standard behavior of the language.
function readstr(blob) { if(blob.eos()) return null; // if RW pointer is at the end of the stream return null (blob is empty) local out = ""; for(local n = 0; n<blob.len; n++) { // I'm not sure which how this length is represented, I assume it's in bytes but make sure to check if(!blob.eos()) break; local c = blob.readn('b'); out += c.tochar(); } return out; }
Disclaimer I haven’t tested this but at a quick glance I’m pretty sure it should work.