static JSBool WriteCallback(const jschar *buf, uint32 len, void *data) { StringifyClosure *sc = (StringifyClosure*)(data); JSString *s1 = JSVAL_TO_STRING(*sc->s); JSString *s2 = JS_NewUCStringCopyN(sc->cx, buf, len); if (!s2) return JS_FALSE; s1 = js_ConcatStrings(sc->cx, s1, s2); if (!s1) return JS_FALSE; *sc->s = STRING_TO_JSVAL(s1); return JS_TRUE; }
static JSBool WriteCallback(const jschar *buf, uint32 len, void *data) { StringifyClosure *sc = static_cast<StringifyClosure*>(data); JSString *s1 = JSVAL_TO_STRING(sc->s[0]); JSString *s2 = js_NewStringCopyN(sc->cx, buf, len); if (!s2) return JS_FALSE; sc->s[1] = STRING_TO_JSVAL(s2); s1 = js_ConcatStrings(sc->cx, s1, s2); if (!s1) return JS_FALSE; sc->s[0] = STRING_TO_JSVAL(s1); sc->s[1] = JSVAL_VOID; return JS_TRUE; }