mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1435483
part 6. Add an infallible "lineNumber" getter on nsIStackFrame. r=qdot
MozReview-Commit-ID: 7aYg9kJhiab
This commit is contained in:
parent
02f7baafc0
commit
2c00c8c971
@ -281,10 +281,8 @@ Exception::GetLineNumber(JSContext* aCx, uint32_t *aLineNumber)
|
||||
NS_ENSURE_ARG_POINTER(aLineNumber);
|
||||
|
||||
if (mLocation) {
|
||||
int32_t lineno;
|
||||
nsresult rv = mLocation->GetLineNumber(aCx, &lineno);
|
||||
*aLineNumber = lineno;
|
||||
return rv;
|
||||
*aLineNumber = mLocation->GetLineNumber(aCx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aLineNumber = 0;
|
||||
@ -399,11 +397,7 @@ uint32_t
|
||||
Exception::LineNumber(JSContext* aCx) const
|
||||
{
|
||||
if (mLocation) {
|
||||
int32_t lineno;
|
||||
if (NS_SUCCEEDED(mLocation->GetLineNumber(aCx, &lineno))) {
|
||||
return lineno;
|
||||
}
|
||||
return 0;
|
||||
return mLocation->GetLineNumber(aCx);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -244,8 +244,6 @@ public:
|
||||
explicit JSStackFrame(JS::Handle<JSObject*> aStack);
|
||||
|
||||
protected:
|
||||
int32_t GetLineno(JSContext* aCx);
|
||||
|
||||
int32_t GetColNo(JSContext* aCx);
|
||||
|
||||
private:
|
||||
@ -431,7 +429,7 @@ NS_IMETHODIMP JSStackFrame::GetName(JSContext* aCx, nsAString& aFunction)
|
||||
}
|
||||
|
||||
int32_t
|
||||
JSStackFrame::GetLineno(JSContext* aCx)
|
||||
JSStackFrame::GetLineNumber(JSContext* aCx)
|
||||
{
|
||||
if (!mStack) {
|
||||
return 0;
|
||||
@ -454,9 +452,10 @@ JSStackFrame::GetLineno(JSContext* aCx)
|
||||
return line;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetLineNumber(JSContext* aCx, int32_t* aLineNumber)
|
||||
NS_IMETHODIMP
|
||||
JSStackFrame::GetLineNumberXPCOM(JSContext* aCx, int32_t* aLineNumber)
|
||||
{
|
||||
*aLineNumber = GetLineno(aCx);
|
||||
*aLineNumber = GetLineNumber(aCx);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -668,7 +667,7 @@ NS_IMETHODIMP JSStackFrame::ToString(JSContext* aCx, nsACString& _retval)
|
||||
funname.AssignLiteral("<TOP_LEVEL>");
|
||||
}
|
||||
|
||||
int32_t lineno = GetLineno(aCx);
|
||||
int32_t lineno = GetLineNumber(aCx);
|
||||
|
||||
static const char format[] = "JS frame :: %s :: %s :: line %d";
|
||||
_retval.AppendPrintf(format,
|
||||
|
@ -1161,14 +1161,10 @@ StackFrameToStackEntry(JSContext* aCx, nsIStackFrame* aStackFrame,
|
||||
|
||||
aStackFrame->GetFilename(aCx, aStackEntry.mFilename);
|
||||
|
||||
int32_t lineNumber;
|
||||
nsresult rv = aStackFrame->GetLineNumber(aCx, &lineNumber);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aStackEntry.mLineNumber = lineNumber;
|
||||
aStackEntry.mLineNumber = aStackFrame->GetLineNumber(aCx);
|
||||
|
||||
int32_t columnNumber;
|
||||
rv = aStackFrame->GetColumnNumber(aCx, &columnNumber);
|
||||
nsresult rv = aStackFrame->GetColumnNumber(aCx, &columnNumber);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aStackEntry.mColumnNumber = columnNumber;
|
||||
@ -2698,15 +2694,11 @@ Console::MaybeExecuteDumpFunctionForTrace(JSContext* aCx, nsIStackFrame* aStack)
|
||||
message.Append(filename);
|
||||
message.AppendLiteral(" ");
|
||||
|
||||
int32_t lineNumber;
|
||||
nsresult rv = stack->GetLineNumber(aCx, &lineNumber);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
message.AppendInt(lineNumber);
|
||||
message.AppendInt(stack->GetLineNumber(aCx));
|
||||
message.AppendLiteral(" ");
|
||||
|
||||
nsAutoString functionName;
|
||||
rv = stack->GetName(aCx, functionName);
|
||||
nsresult rv = stack->GetName(aCx, functionName);
|
||||
NS_ENSURE_SUCCESS_VOID(rv);
|
||||
|
||||
message.Append(filename);
|
||||
|
@ -356,10 +356,9 @@ class BlobURLsReporter final : public nsIMemoryReporter
|
||||
|
||||
for (uint32_t i = 0; frame; ++i) {
|
||||
nsString fileNameUTF16;
|
||||
int32_t lineNumber = 0;
|
||||
|
||||
frame->GetFilename(cx, fileNameUTF16);
|
||||
frame->GetLineNumber(cx, &lineNumber);
|
||||
|
||||
int32_t lineNumber = frame->GetLineNumber(cx);
|
||||
|
||||
if (!fileNameUTF16.IsEmpty()) {
|
||||
NS_ConvertUTF16toUTF8 fileName(fileNameUTF16);
|
||||
|
@ -1767,9 +1767,8 @@ AssembleSandboxMemoryReporterName(JSContext* cx, nsCString& sandboxName)
|
||||
// Append the caller's location information.
|
||||
if (frame) {
|
||||
nsString location;
|
||||
int32_t lineNumber = 0;
|
||||
frame->GetFilename(cx, location);
|
||||
frame->GetLineNumber(cx, &lineNumber);
|
||||
int32_t lineNumber = frame->GetLineNumber(cx);
|
||||
|
||||
sandboxName.AppendLiteral(" (from: ");
|
||||
sandboxName.Append(NS_ConvertUTF16toUTF8(location));
|
||||
|
@ -2137,7 +2137,7 @@ nsXPCComponents_Utils::ReportError(HandleValue error, JSContext* cx)
|
||||
nsCOMPtr<nsIStackFrame> frame = dom::GetCurrentJSStack();
|
||||
if (frame) {
|
||||
frame->GetFilename(cx, fileName);
|
||||
frame->GetLineNumber(cx, &lineNo);
|
||||
lineNo = frame->GetLineNumber(cx);
|
||||
JS::Rooted<JS::Value> stack(cx);
|
||||
nsresult rv = frame->GetNativeSavedFrame(&stack);
|
||||
if (NS_SUCCEEDED(rv) && stack.isObject()) {
|
||||
@ -2219,7 +2219,7 @@ nsXPCComponents_Utils::EvalInSandbox(const nsAString& source,
|
||||
nsString frameFile;
|
||||
frame->GetFilename(cx, frameFile);
|
||||
CopyUTF16toUTF8(frameFile, filename);
|
||||
frame->GetLineNumber(cx, &lineNo);
|
||||
lineNo = frame->GetLineNumber(cx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -998,7 +998,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
||||
GetLocation(getter_AddRefs(location));
|
||||
if (location) {
|
||||
// Get line number.
|
||||
location->GetLineNumber(cx, &lineNumber);
|
||||
lineNumber = location->GetLineNumber(cx);
|
||||
|
||||
// get a filename.
|
||||
location->GetFilename(cx, sourceName);
|
||||
|
@ -54,8 +54,7 @@ SandboxLogJSStack(void)
|
||||
// Don't stop unwinding if an attribute can't be read.
|
||||
fileName.SetIsVoid(true);
|
||||
frame->GetFilename(cx, fileName);
|
||||
lineNumber = 0;
|
||||
Unused << frame->GetLineNumber(cx, &lineNumber);
|
||||
lineNumber = frame->GetLineNumber(cx);
|
||||
funName.SetIsVoid(true);
|
||||
Unused << frame->GetName(cx, funName);
|
||||
|
||||
|
@ -18,7 +18,7 @@ interface nsIStackFrame : nsISupports
|
||||
[implicit_jscontext]
|
||||
readonly attribute AString name;
|
||||
// Valid line numbers begin at '1'. '0' indicates unknown.
|
||||
[implicit_jscontext]
|
||||
[implicit_jscontext, binaryname(LineNumberXPCOM)]
|
||||
readonly attribute int32_t lineNumber;
|
||||
[implicit_jscontext]
|
||||
readonly attribute int32_t columnNumber;
|
||||
@ -46,6 +46,8 @@ interface nsIStackFrame : nsISupports
|
||||
// Infallible things to be called from C++.
|
||||
[notxpcom, nostdcall]
|
||||
void getFilename(in JSContext aCx, out AString aFilename);
|
||||
[notxpcom, nostdcall]
|
||||
int32_t getLineNumber(in JSContext aCx);
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(4371b5bf-6845-487f-8d9d-3f1e4a9badd2)]
|
||||
|
Loading…
Reference in New Issue
Block a user