akapav/js — pull request #22 by neonsquare (2012-10-24 22:44:05+00:00)
Title: Some fixes to get "underscore.js" running

I tried getting underscore.js running in CL-JS and hit some issues:

1) the function defining the |-Operator ( JS-\| ) used pipe-escaping which also escaped the case of the name (so its name was "js-\" instead of JS-\|.

2) Underscore.js implements an "isObject" method as follows:

function (obj) { return obj === Object(obj) }

CL-JS always created a new VOBJ for the given argument - so this didn't work. I've changed that to a call to TO-OBJECT, which preserves identity for given OBJ in this case.

3) Underscore defines several other "isX" methods with X being ("Function", "Arguments", "Date"...)
It uses the print syntax of Object.prototype.toString to get the name of the objects "class". This is actually an official use case in EcmaScript. I've implemented a new generic function OBJ-CLASS-NAME which is then use to give the name of many different JS objects including the more obscure cases like "undefined" as "Undefined", null as "Null" a.s.o.

After this fixes underscore.js loads and seems to work.

All tests done in Lispworks. I'll test it in CCL in the next days.