mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-29 21:25:35 +00:00
Bug 1343292
- change return types in GenericPrinter; r=nbp
MozReview-Commit-ID: 1GJYujhrWj7 --HG-- extra : rebase_source : 90aef429db4285707f23105f950d9d930f98c21b
This commit is contained in:
parent
25c2747782
commit
550affaf12
@ -195,7 +195,7 @@ DumpPCCounts(JSContext* cx, HandleScript script, Sprinter* sp)
|
||||
if (!Disassemble1(cx, script, pc, script->pcToOffset(pc), true, sp))
|
||||
return false;
|
||||
|
||||
if (sp->put(" {") < 0)
|
||||
if (!sp->put(" {"))
|
||||
return false;
|
||||
|
||||
PCCounts* counts = script->maybeGetPCCounts(pc);
|
||||
@ -203,7 +203,7 @@ DumpPCCounts(JSContext* cx, HandleScript script, Sprinter* sp)
|
||||
if (!sp->jsprintf("\"%s\": %.0f", PCCounts::numExecName, val))
|
||||
return false;
|
||||
}
|
||||
if (sp->put("}\n") < 0)
|
||||
if (!sp->put("}\n"))
|
||||
return false;
|
||||
|
||||
pc = next;
|
||||
@ -1056,48 +1056,48 @@ DisassembleAtPC(JSContext* cx, JSScript* scriptArg, bool lines,
|
||||
}
|
||||
|
||||
if (pc != nullptr) {
|
||||
if (sp->put(" ") < 0)
|
||||
if (!sp->put(" "))
|
||||
return false;
|
||||
}
|
||||
if (showAll) {
|
||||
if (sp->put("sn stack ") < 0)
|
||||
if (!sp->put("sn stack "))
|
||||
return false;
|
||||
}
|
||||
if (sp->put("loc ") < 0)
|
||||
if (!sp->put("loc "))
|
||||
return false;
|
||||
if (lines) {
|
||||
if (sp->put("line") < 0)
|
||||
if (!sp->put("line"))
|
||||
return false;
|
||||
}
|
||||
if (sp->put(" op\n") < 0)
|
||||
if (!sp->put(" op\n"))
|
||||
return false;
|
||||
|
||||
if (pc != nullptr) {
|
||||
if (sp->put(" ") < 0)
|
||||
if (!sp->put(" "))
|
||||
return false;
|
||||
}
|
||||
if (showAll) {
|
||||
if (sp->put("-- ----- ") < 0)
|
||||
if (!sp->put("-- ----- "))
|
||||
return false;
|
||||
}
|
||||
if (sp->put("----- ") < 0)
|
||||
if (!sp->put("----- "))
|
||||
return false;
|
||||
if (lines) {
|
||||
if (sp->put("----") < 0)
|
||||
if (!sp->put("----"))
|
||||
return false;
|
||||
}
|
||||
if (sp->put(" --\n") < 0)
|
||||
if (!sp->put(" --\n"))
|
||||
return false;
|
||||
|
||||
jsbytecode* next = script->code();
|
||||
jsbytecode* end = script->codeEnd();
|
||||
while (next < end) {
|
||||
if (next == script->main()) {
|
||||
if (sp->put("main:\n") < 0)
|
||||
if (!sp->put("main:\n"))
|
||||
return false;
|
||||
}
|
||||
if (pc != nullptr) {
|
||||
if (sp->put(pc == next ? "--> " : " ") < 0)
|
||||
if (!sp->put(pc == next ? "--> " : " "))
|
||||
return false;
|
||||
}
|
||||
if (showAll) {
|
||||
@ -1114,14 +1114,14 @@ DisassembleAtPC(JSContext* cx, JSScript* scriptArg, bool lines,
|
||||
if (!sp->jsprintf("%02u ", SN_TYPE(sn)))
|
||||
return false;
|
||||
} else {
|
||||
if (sp->put(" ") < 0)
|
||||
if (!sp->put(" "))
|
||||
return false;
|
||||
}
|
||||
if (parser.isReachable(next)) {
|
||||
if (!sp->jsprintf("%05u ", parser.stackDepthAtPC(next)))
|
||||
return false;
|
||||
} else {
|
||||
if (sp->put(" ") < 0)
|
||||
if (!sp->put(" "))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1376,20 +1376,23 @@ Disassemble1(JSContext* cx, HandleScript script, jsbytecode* pc,
|
||||
MOZ_ASSERT(after >= before);
|
||||
|
||||
static const size_t stack_column = 40;
|
||||
for (size_t i = after - before; i < stack_column - 1; i++)
|
||||
sp->put(" ");
|
||||
for (size_t i = after - before; i < stack_column - 1; i++) {
|
||||
if (!sp->put(" "))
|
||||
return false;
|
||||
}
|
||||
|
||||
sp->put(" # ");
|
||||
if (!sp->put(" # "))
|
||||
return false;
|
||||
|
||||
if (!parser->isReachable(pc)) {
|
||||
if (sp->put("!!! UNREACHABLE !!!") < 0)
|
||||
if (!sp->put("!!! UNREACHABLE !!!"))
|
||||
return false;
|
||||
} else {
|
||||
uint32_t depth = parser->stackDepthAfterPC(pc);
|
||||
|
||||
for (uint32_t i = 0; i < depth; i++) {
|
||||
if (i) {
|
||||
if (sp->put(" ") < 0)
|
||||
if (!sp->put(" "))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1851,7 +1854,7 @@ ExpressionDecompiler::decompilePC(jsbytecode* pc, uint8_t defIndex)
|
||||
case JSOP_UINT16:
|
||||
case JSOP_UINT24:
|
||||
case JSOP_INT32:
|
||||
return sprinter.printf("%d", GetBytecodeInteger(pc)) >= 0;
|
||||
return sprinter.printf("%d", GetBytecodeInteger(pc));
|
||||
case JSOP_STRING:
|
||||
return quote(loadAtom(pc), '"');
|
||||
case JSOP_SYMBOL: {
|
||||
@ -1972,7 +1975,7 @@ ExpressionDecompiler::decompilePC(jsbytecode* pc, uint8_t defIndex)
|
||||
return write("OBJPROTO");
|
||||
|
||||
case JSOP_DOUBLE:
|
||||
return sprinter.printf("%lf", script->getConst(GET_UINT32_INDEX(pc)).toDouble()) >= 0;
|
||||
return sprinter.printf("%lf", script->getConst(GET_UINT32_INDEX(pc)).toDouble());
|
||||
|
||||
case JSOP_EXCEPTION:
|
||||
return write("EXCEPTION");
|
||||
@ -2132,7 +2135,7 @@ ExpressionDecompiler::init()
|
||||
bool
|
||||
ExpressionDecompiler::write(const char* s)
|
||||
{
|
||||
return sprinter.put(s) >= 0;
|
||||
return sprinter.put(s);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2140,7 +2143,7 @@ ExpressionDecompiler::write(JSString* str)
|
||||
{
|
||||
if (str == cx->names().dotThis)
|
||||
return write("this");
|
||||
return sprinter.putString(str) >= 0;
|
||||
return sprinter.putString(str);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -4021,7 +4021,7 @@ js::PutEscapedStringImpl(char* buffer, size_t bufferSize, GenericPrinter* out, c
|
||||
buffer = nullptr;
|
||||
}
|
||||
} else if (out) {
|
||||
if (out->put(&c, 1) < 0)
|
||||
if (!out->put(&c, 1))
|
||||
return size_t(-1);
|
||||
}
|
||||
n++;
|
||||
|
@ -2532,10 +2532,10 @@ UpdateSwitchTableBounds(JSContext* cx, HandleScript script, unsigned offset,
|
||||
static MOZ_MUST_USE bool
|
||||
SrcNotes(JSContext* cx, HandleScript script, Sprinter* sp)
|
||||
{
|
||||
if (sp->put("\nSource notes:\n") < 0 ||
|
||||
if (!sp->put("\nSource notes:\n") ||
|
||||
!sp->jsprintf("%4s %4s %5s %6s %-8s %s\n",
|
||||
"ofs", "line", "pc", "delta", "desc", "args") ||
|
||||
sp->put("---- ---- ----- ------ -------- ------\n") < 0)
|
||||
!sp->put("---- ---- ----- ------ -------- ------\n"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -2643,7 +2643,7 @@ SrcNotes(JSContext* cx, HandleScript script, Sprinter* sp)
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("unrecognized srcnote");
|
||||
}
|
||||
if (sp->put("\n") < 0)
|
||||
if (!sp->put("\n"))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2701,7 +2701,7 @@ TryNotes(JSContext* cx, HandleScript script, Sprinter* sp)
|
||||
if (!script->hasTrynotes())
|
||||
return true;
|
||||
|
||||
if (sp->put("\nException table:\nkind stack start end\n") < 0)
|
||||
if (!sp->put("\nException table:\nkind stack start end\n"))
|
||||
return false;
|
||||
|
||||
JSTryNote* tn = script->trynotes()->vector;
|
||||
@ -2724,7 +2724,7 @@ ScopeNotes(JSContext* cx, HandleScript script, Sprinter* sp)
|
||||
if (!script->hasScopeNotes())
|
||||
return true;
|
||||
|
||||
if (sp->put("\nScope notes:\n index parent start end\n") < 0)
|
||||
if (!sp->put("\nScope notes:\n index parent start end\n"))
|
||||
return false;
|
||||
|
||||
ScopeNoteArray* notes = script->scopeNotes();
|
||||
@ -2755,41 +2755,41 @@ DisassembleScript(JSContext* cx, HandleScript script, HandleFunction fun,
|
||||
bool lines, bool recursive, bool sourceNotes, Sprinter* sp)
|
||||
{
|
||||
if (fun) {
|
||||
if (sp->put("flags:") < 0)
|
||||
if (!sp->put("flags:"))
|
||||
return false;
|
||||
if (fun->isLambda()) {
|
||||
if (sp->put(" LAMBDA") < 0)
|
||||
if (!sp->put(" LAMBDA"))
|
||||
return false;
|
||||
}
|
||||
if (fun->needsCallObject()) {
|
||||
if (sp->put(" NEEDS_CALLOBJECT") < 0)
|
||||
if (!sp->put(" NEEDS_CALLOBJECT"))
|
||||
return false;
|
||||
}
|
||||
if (fun->needsExtraBodyVarEnvironment()) {
|
||||
if (sp->put(" NEEDS_EXTRABODYVARENV") < 0)
|
||||
if (!sp->put(" NEEDS_EXTRABODYVARENV"))
|
||||
return false;
|
||||
}
|
||||
if (fun->needsNamedLambdaEnvironment()) {
|
||||
if (sp->put(" NEEDS_NAMEDLAMBDAENV") < 0)
|
||||
if (!sp->put(" NEEDS_NAMEDLAMBDAENV"))
|
||||
return false;
|
||||
}
|
||||
if (fun->isConstructor()) {
|
||||
if (sp->put(" CONSTRUCTOR") < 0)
|
||||
if (!sp->put(" CONSTRUCTOR"))
|
||||
return false;
|
||||
}
|
||||
if (script->isExprBody()) {
|
||||
if (sp->put(" EXPRESSION_CLOSURE") < 0)
|
||||
if (!sp->put(" EXPRESSION_CLOSURE"))
|
||||
return false;
|
||||
}
|
||||
if (fun->isSelfHostedBuiltin()) {
|
||||
if (sp->put(" SELF_HOSTED") < 0)
|
||||
if (!sp->put(" SELF_HOSTED"))
|
||||
return false;
|
||||
}
|
||||
if (fun->isArrow()) {
|
||||
if (sp->put(" ARROW") < 0)
|
||||
if (!sp->put(" ARROW"))
|
||||
return false;
|
||||
}
|
||||
if (sp->put("\n") < 0)
|
||||
if (!sp->put("\n"))
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2809,7 +2809,7 @@ DisassembleScript(JSContext* cx, HandleScript script, HandleFunction fun,
|
||||
for (unsigned i = 0; i != objects->length; ++i) {
|
||||
JSObject* obj = objects->vector[i];
|
||||
if (obj->is<JSFunction>()) {
|
||||
if (sp->put("\n") < 0)
|
||||
if (!sp->put("\n"))
|
||||
return false;
|
||||
|
||||
RootedFunction fun(cx, &obj->as<JSFunction>());
|
||||
@ -2820,7 +2820,7 @@ DisassembleScript(JSContext* cx, HandleScript script, HandleFunction fun,
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (sp->put("[native code]\n") < 0)
|
||||
if (!sp->put("[native code]\n"))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -5502,7 +5502,7 @@ class SprintOptimizationTypeInfoOp : public JS::ForEachTrackedOptimizationTypeIn
|
||||
do {
|
||||
if (!startedTypes_) {
|
||||
startedTypes_ = true;
|
||||
if (sp->put("{\"typeset\": [") < 0)
|
||||
if (!sp->put("{\"typeset\": ["))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -5524,7 +5524,7 @@ class SprintOptimizationTypeInfoOp : public JS::ForEachTrackedOptimizationTypeIn
|
||||
if (!sp->jsprintf(",\"line\":%u", *lineno))
|
||||
break;
|
||||
}
|
||||
if (sp->put("},") < 0)
|
||||
if (!sp->put("},"))
|
||||
break;
|
||||
|
||||
return;
|
||||
@ -5542,12 +5542,12 @@ class SprintOptimizationTypeInfoOp : public JS::ForEachTrackedOptimizationTypeIn
|
||||
// Clear trailing ,
|
||||
if ((*sp)[sp->getOffset() - 1] == ',')
|
||||
(*sp)[sp->getOffset() - 1] = ' ';
|
||||
if (sp->put("],") < 0)
|
||||
if (!sp->put("],"))
|
||||
break;
|
||||
|
||||
startedTypes_ = false;
|
||||
} else {
|
||||
if (sp->put("{") < 0)
|
||||
if (!sp->put("{"))
|
||||
break;
|
||||
}
|
||||
|
||||
@ -5641,7 +5641,7 @@ ReflectTrackedOptimizations(JSContext* cx, unsigned argc, Value* vp)
|
||||
const jit::IonTrackedOptimizationsRegionTable* regions =
|
||||
entry.ionEntry().trackedOptimizationsRegionTable();
|
||||
|
||||
if (sp.put("{\"regions\": [") < 0)
|
||||
if (!sp.put("{\"regions\": ["))
|
||||
return false;
|
||||
|
||||
for (uint32_t i = 0; i < regions->numEntries(); i++) {
|
||||
@ -5671,10 +5671,10 @@ ReflectTrackedOptimizations(JSContext* cx, unsigned argc, Value* vp)
|
||||
}
|
||||
}
|
||||
|
||||
if (sp.put("],") < 0)
|
||||
if (!sp.put("],"))
|
||||
return false;
|
||||
|
||||
if (sp.put("\"opts\": [") < 0)
|
||||
if (!sp.put("\"opts\": ["))
|
||||
return false;
|
||||
|
||||
for (uint8_t i = 0; i < entry.ionEntry().numOptimizationAttempts(); i++) {
|
||||
@ -5691,7 +5691,7 @@ ReflectTrackedOptimizations(JSContext* cx, unsigned argc, Value* vp)
|
||||
if (sp[sp.getOffset() - 1] == ',')
|
||||
sp[sp.getOffset() - 1] = ' ';
|
||||
|
||||
if (sp.put("],\"attempts\":[") < 0)
|
||||
if (!sp.put("],\"attempts\":["))
|
||||
return false;
|
||||
|
||||
SprintOptimizationAttemptsOp aop(&sp);
|
||||
@ -5703,11 +5703,11 @@ ReflectTrackedOptimizations(JSContext* cx, unsigned argc, Value* vp)
|
||||
if (sp[sp.getOffset() - 1] == ',')
|
||||
sp[sp.getOffset() - 1] = ' ';
|
||||
|
||||
if (sp.put("]}") < 0)
|
||||
if (!sp.put("]}"))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sp.put("]}") < 0)
|
||||
if (!sp.put("]}"))
|
||||
return false;
|
||||
|
||||
if (sp.hadOutOfMemory())
|
||||
|
@ -41,17 +41,17 @@ GenericPrinter::hadOutOfMemory() const
|
||||
return hadOOM_;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
GenericPrinter::printf(const char* fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
int i = vprintf(fmt, va);
|
||||
bool r = vprintf(fmt, va);
|
||||
va_end(va);
|
||||
return i;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
GenericPrinter::vprintf(const char* fmt, va_list ap)
|
||||
{
|
||||
// Simple shortcut to avoid allocating strings.
|
||||
@ -62,11 +62,11 @@ GenericPrinter::vprintf(const char* fmt, va_list ap)
|
||||
bp = JS_vsmprintf(fmt, ap); /* XXX vsaprintf */
|
||||
if (!bp) {
|
||||
reportOutOfMemory();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
int i = put(bp);
|
||||
bool r = put(bp);
|
||||
js_free(bp);
|
||||
return i;
|
||||
return r;
|
||||
}
|
||||
|
||||
const size_t Sprinter::DefaultSize = 64;
|
||||
@ -171,7 +171,7 @@ Sprinter::reserve(size_t len)
|
||||
return sb;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
Sprinter::put(const char* s, size_t len)
|
||||
{
|
||||
InvariantChecker ic(this);
|
||||
@ -179,10 +179,9 @@ Sprinter::put(const char* s, size_t len)
|
||||
const char* oldBase = base;
|
||||
const char* oldEnd = base + size;
|
||||
|
||||
ptrdiff_t oldOffset = offset;
|
||||
char* bp = reserve(len);
|
||||
if (!bp)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
/* s is within the buffer already */
|
||||
if (s >= oldBase && s < oldEnd) {
|
||||
@ -195,10 +194,10 @@ Sprinter::put(const char* s, size_t len)
|
||||
}
|
||||
|
||||
bp[len] = 0;
|
||||
return oldOffset;
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
Sprinter::vprintf(const char* fmt, va_list ap)
|
||||
{
|
||||
InvariantChecker ic(this);
|
||||
@ -210,14 +209,14 @@ Sprinter::vprintf(const char* fmt, va_list ap)
|
||||
va_end(aq);
|
||||
if (i > -1 && (size_t) i < size - offset) {
|
||||
offset += i;
|
||||
return i;
|
||||
return true;
|
||||
}
|
||||
} while (realloc_(size * 2));
|
||||
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
Sprinter::putString(JSString* s)
|
||||
{
|
||||
InvariantChecker ic(this);
|
||||
@ -225,14 +224,13 @@ Sprinter::putString(JSString* s)
|
||||
size_t length = s->length();
|
||||
size_t size = length;
|
||||
|
||||
ptrdiff_t oldOffset = offset;
|
||||
char* buffer = reserve(size);
|
||||
if (!buffer)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
JSLinearString* linear = s->ensureLinear(context);
|
||||
if (!linear)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
if (linear->hasLatin1Chars())
|
||||
@ -241,7 +239,7 @@ Sprinter::putString(JSString* s)
|
||||
DeflateStringToBuffer(nullptr, linear->twoByteChars(nogc), length, buffer, &size);
|
||||
|
||||
buffer[size] = 0;
|
||||
return oldOffset;
|
||||
return true;
|
||||
}
|
||||
|
||||
ptrdiff_t
|
||||
@ -273,7 +271,7 @@ Sprinter::jsprintf(const char* format, ...)
|
||||
return false;
|
||||
}
|
||||
|
||||
return put(chars.get()) >= 0;
|
||||
return put(chars.get());
|
||||
}
|
||||
|
||||
const char js_EscapeMap[] = {
|
||||
@ -358,7 +356,7 @@ QuoteString(Sprinter* sp, const mozilla::Range<const CharT> chars, char16_t quot
|
||||
* the return below gives a valid result.
|
||||
*/
|
||||
if (offset == sp->getOffset()) {
|
||||
if (sp->put("") < 0)
|
||||
if (!sp->put(""))
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -442,39 +440,39 @@ Fprinter::finish()
|
||||
file_ = nullptr;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
Fprinter::put(const char* s, size_t len)
|
||||
{
|
||||
MOZ_ASSERT(file_);
|
||||
int i = fwrite(s, len, 1, file_);
|
||||
if (size_t(i) != len) {
|
||||
reportOutOfMemory();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
return i;
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
Fprinter::printf(const char* fmt, ...)
|
||||
{
|
||||
MOZ_ASSERT(file_);
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int i = vfprintf(file_, fmt, ap);
|
||||
if (i == -1)
|
||||
bool r = vfprintf(file_, fmt, ap);
|
||||
if (!r)
|
||||
reportOutOfMemory();
|
||||
va_end(ap);
|
||||
return i;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
Fprinter::vprintf(const char* fmt, va_list ap)
|
||||
{
|
||||
MOZ_ASSERT(file_);
|
||||
int i = vfprintf(file_, fmt, ap);
|
||||
if (i == -1)
|
||||
bool r = vfprintf(file_, fmt, ap);
|
||||
if (!r)
|
||||
reportOutOfMemory();
|
||||
return i;
|
||||
return r;
|
||||
}
|
||||
|
||||
LSprinter::LSprinter(LifoAlloc* lifoAlloc)
|
||||
@ -510,7 +508,7 @@ LSprinter::clear()
|
||||
hadOOM_ = false;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
LSprinter::put(const char* s, size_t len)
|
||||
{
|
||||
// Compute how much data will fit in the current chunk.
|
||||
@ -531,7 +529,7 @@ LSprinter::put(const char* s, size_t len)
|
||||
last = reinterpret_cast<Chunk*>(alloc_->alloc(allocLength));
|
||||
if (!last) {
|
||||
reportOutOfMemory();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -574,20 +572,20 @@ LSprinter::put(const char* s, size_t len)
|
||||
}
|
||||
|
||||
MOZ_ASSERT(len <= INT_MAX);
|
||||
return int(len);
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
LSprinter::printf(const char* fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
int i = vprintf(fmt, va);
|
||||
bool r = vprintf(fmt, va);
|
||||
va_end(va);
|
||||
return i;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
LSprinter::vprintf(const char* fmt, va_list ap)
|
||||
{
|
||||
// Simple shortcut to avoid allocating strings.
|
||||
@ -598,11 +596,11 @@ LSprinter::vprintf(const char* fmt, va_list ap)
|
||||
bp = JS_vsmprintf(fmt, ap); /* XXX vsaprintf */
|
||||
if (!bp) {
|
||||
reportOutOfMemory();
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
int i = put(bp);
|
||||
bool r = put(bp);
|
||||
js_free(bp);
|
||||
return i;
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -35,17 +35,17 @@ class GenericPrinter
|
||||
GenericPrinter();
|
||||
|
||||
public:
|
||||
// Puts |len| characters from |s| at the current position and return an offset to
|
||||
// the beginning of this new data.
|
||||
virtual int put(const char* s, size_t len) = 0;
|
||||
// Puts |len| characters from |s| at the current position and
|
||||
// return true on success, false on failure.
|
||||
virtual bool put(const char* s, size_t len) = 0;
|
||||
|
||||
inline int put(const char* s) {
|
||||
inline bool put(const char* s) {
|
||||
return put(s, strlen(s));
|
||||
}
|
||||
|
||||
// Prints a formatted string into the buffer.
|
||||
virtual int printf(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
|
||||
virtual int vprintf(const char* fmt, va_list ap);
|
||||
virtual bool printf(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
|
||||
virtual bool vprintf(const char* fmt, va_list ap);
|
||||
|
||||
// Report that a string operation failed to get the memory it requested. The
|
||||
// first call to this function calls JS_ReportOutOfMemory, and sets this
|
||||
@ -108,10 +108,10 @@ class Sprinter final : public GenericPrinter
|
||||
// internal content. The caller *must* completely fill this space on success.
|
||||
char* reserve(size_t len);
|
||||
|
||||
// Puts |len| characters from |s| at the current position and return an offset to
|
||||
// the beginning of this new data.
|
||||
virtual int put(const char* s, size_t len) override;
|
||||
using GenericPrinter::put; // pick up |inline int put(const char* s);|
|
||||
// Puts |len| characters from |s| at the current position and
|
||||
// return true on success, false on failure.
|
||||
virtual bool put(const char* s, size_t len) override;
|
||||
using GenericPrinter::put; // pick up |inline bool put(const char* s);|
|
||||
|
||||
// Format the given format/arguments as if by JS_vsmprintf, then put it.
|
||||
// Return true on success, else return false and report an error (typically
|
||||
@ -119,9 +119,9 @@ class Sprinter final : public GenericPrinter
|
||||
MOZ_MUST_USE bool jsprintf(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
|
||||
|
||||
// Prints a formatted string into the buffer.
|
||||
virtual int vprintf(const char* fmt, va_list ap) override;
|
||||
virtual bool vprintf(const char* fmt, va_list ap) override;
|
||||
|
||||
int putString(JSString* str);
|
||||
bool putString(JSString* str);
|
||||
|
||||
ptrdiff_t getOffset() const;
|
||||
|
||||
@ -152,14 +152,14 @@ class Fprinter final : public GenericPrinter
|
||||
void flush();
|
||||
void finish();
|
||||
|
||||
// Puts |len| characters from |s| at the current position and return an
|
||||
// offset to the beginning of this new data.
|
||||
virtual int put(const char* s, size_t len) override;
|
||||
using GenericPrinter::put; // pick up |inline int put(const char* s);|
|
||||
// Puts |len| characters from |s| at the current position and
|
||||
// return true on success, false on failure.
|
||||
virtual bool put(const char* s, size_t len) override;
|
||||
using GenericPrinter::put; // pick up |inline bool put(const char* s);|
|
||||
|
||||
// Prints a formatted string into the buffer.
|
||||
virtual int printf(const char* fmt, ...) override MOZ_FORMAT_PRINTF(2, 3);
|
||||
virtual int vprintf(const char* fmt, va_list ap) override;
|
||||
virtual bool printf(const char* fmt, ...) override MOZ_FORMAT_PRINTF(2, 3);
|
||||
virtual bool vprintf(const char* fmt, va_list ap) override;
|
||||
};
|
||||
|
||||
// LSprinter, is similar to Sprinter except that instead of using an
|
||||
@ -198,14 +198,14 @@ class LSprinter final : public GenericPrinter
|
||||
// Drop the current string, and let them be free with the LifoAlloc.
|
||||
void clear();
|
||||
|
||||
// Puts |len| characters from |s| at the current position and return an
|
||||
// offset to the beginning of this new data.
|
||||
virtual int put(const char* s, size_t len) override;
|
||||
using GenericPrinter::put; // pick up |inline int put(const char* s);|
|
||||
// Puts |len| characters from |s| at the current position and
|
||||
// return true on success, false on failure.
|
||||
virtual bool put(const char* s, size_t len) override;
|
||||
using GenericPrinter::put; // pick up |inline bool put(const char* s);|
|
||||
|
||||
// Prints a formatted string into the buffer.
|
||||
virtual int printf(const char* fmt, ...) override MOZ_FORMAT_PRINTF(2, 3);
|
||||
virtual int vprintf(const char* fmt, va_list ap) override;
|
||||
virtual bool printf(const char* fmt, ...) override MOZ_FORMAT_PRINTF(2, 3);
|
||||
virtual bool vprintf(const char* fmt, va_list ap) override;
|
||||
|
||||
// Report that a string operation failed to get the memory it requested. The
|
||||
// first call to this function calls JS_ReportOutOfMemory, and sets this
|
||||
|
Loading…
Reference in New Issue
Block a user