mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1147193. Go back to having our accessors on JSStackFrame infallible. r=bholley
This commit is contained in:
parent
01104399e3
commit
4c56278b8a
@ -243,16 +243,14 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual nsresult GetLineno(int32_t* aLineNo)
|
||||
virtual int32_t GetLineno()
|
||||
{
|
||||
*aLineNo = mLineno;
|
||||
return NS_OK;
|
||||
return mLineno;
|
||||
}
|
||||
|
||||
virtual nsresult GetColNo(int32_t* aColNo)
|
||||
virtual int32_t GetColNo()
|
||||
{
|
||||
*aColNo = mColNo;
|
||||
return NS_OK;
|
||||
return mColNo;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStackFrame> mCaller;
|
||||
@ -318,8 +316,8 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual nsresult GetLineno(int32_t* aLineNo) override;
|
||||
virtual nsresult GetColNo(int32_t* aColNo) override;
|
||||
virtual int32_t GetLineno() override;
|
||||
virtual int32_t GetColNo() override;
|
||||
|
||||
private:
|
||||
virtual ~JSStackFrame();
|
||||
@ -437,7 +435,11 @@ GetValueIfNotCached(JSContext* aCx, JSObject* aStack,
|
||||
/* readonly attribute AString filename; */
|
||||
NS_IMETHODIMP JSStackFrame::GetFilename(nsAString& aFilename)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStack, NS_ERROR_NOT_AVAILABLE);
|
||||
if (!mStack) {
|
||||
aFilename.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSString*> filename(cx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
@ -449,7 +451,9 @@ NS_IMETHODIMP JSStackFrame::GetFilename(nsAString& aFilename)
|
||||
|
||||
nsAutoJSString str;
|
||||
if (!str.init(cx, filename)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
JS_ClearPendingException(cx);
|
||||
aFilename.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
aFilename = str;
|
||||
|
||||
@ -476,7 +480,11 @@ NS_IMETHODIMP StackFrame::GetFilename(nsAString& aFilename)
|
||||
/* readonly attribute AString name; */
|
||||
NS_IMETHODIMP JSStackFrame::GetName(nsAString& aFunction)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStack, NS_ERROR_NOT_AVAILABLE);
|
||||
if (!mStack) {
|
||||
aFunction.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSString*> name(cx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
@ -491,7 +499,9 @@ NS_IMETHODIMP JSStackFrame::GetName(nsAString& aFunction)
|
||||
if (name) {
|
||||
nsAutoJSString str;
|
||||
if (!str.init(cx, name)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
JS_ClearPendingException(cx);
|
||||
aFunction.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
aFunction = str;
|
||||
} else {
|
||||
@ -519,10 +529,13 @@ NS_IMETHODIMP StackFrame::GetName(nsAString& aFunction)
|
||||
}
|
||||
|
||||
// virtual
|
||||
nsresult
|
||||
JSStackFrame::GetLineno(int32_t* aLineNo)
|
||||
int32_t
|
||||
JSStackFrame::GetLineno()
|
||||
{
|
||||
NS_ENSURE_TRUE(mStack, NS_ERROR_NOT_AVAILABLE);
|
||||
if (!mStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
uint32_t line;
|
||||
bool canCache = false, useCachedValue = false;
|
||||
@ -530,30 +543,32 @@ JSStackFrame::GetLineno(int32_t* aLineNo)
|
||||
&canCache, &useCachedValue, &line);
|
||||
|
||||
if (useCachedValue) {
|
||||
return StackFrame::GetLineno(aLineNo);
|
||||
return StackFrame::GetLineno();
|
||||
}
|
||||
|
||||
*aLineNo = line;
|
||||
|
||||
if (canCache) {
|
||||
mLineno = line;
|
||||
mLinenoInitialized = true;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return line;
|
||||
}
|
||||
|
||||
/* readonly attribute int32_t lineNumber; */
|
||||
NS_IMETHODIMP StackFrame::GetLineNumber(int32_t* aLineNumber)
|
||||
{
|
||||
return GetLineno(aLineNumber);
|
||||
*aLineNumber = GetLineno();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// virtual
|
||||
nsresult
|
||||
JSStackFrame::GetColNo(int32_t* aColNo)
|
||||
int32_t
|
||||
JSStackFrame::GetColNo()
|
||||
{
|
||||
NS_ENSURE_TRUE(mStack, NS_ERROR_NOT_AVAILABLE);
|
||||
if (!mStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
uint32_t col;
|
||||
bool canCache = false, useCachedValue = false;
|
||||
@ -561,23 +576,22 @@ JSStackFrame::GetColNo(int32_t* aColNo)
|
||||
&canCache, &useCachedValue, &col);
|
||||
|
||||
if (useCachedValue) {
|
||||
return StackFrame::GetColNo(aColNo);
|
||||
return StackFrame::GetColNo();
|
||||
}
|
||||
|
||||
*aColNo = col;
|
||||
|
||||
if (canCache) {
|
||||
mColNo = col;
|
||||
mColNoInitialized = true;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return col;
|
||||
}
|
||||
|
||||
/* readonly attribute int32_t columnNumber; */
|
||||
NS_IMETHODIMP StackFrame::GetColumnNumber(int32_t* aColumnNumber)
|
||||
{
|
||||
return GetColNo(aColumnNumber);
|
||||
*aColumnNumber = GetColNo();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute AUTF8String sourceLine; */
|
||||
@ -590,7 +604,11 @@ NS_IMETHODIMP StackFrame::GetSourceLine(nsACString& aSourceLine)
|
||||
/* readonly attribute AString asyncCause; */
|
||||
NS_IMETHODIMP JSStackFrame::GetAsyncCause(nsAString& aAsyncCause)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStack, NS_ERROR_NOT_AVAILABLE);
|
||||
if (!mStack) {
|
||||
aAsyncCause.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSString*> asyncCause(cx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
@ -605,7 +623,9 @@ NS_IMETHODIMP JSStackFrame::GetAsyncCause(nsAString& aAsyncCause)
|
||||
if (asyncCause) {
|
||||
nsAutoJSString str;
|
||||
if (!str.init(cx, asyncCause)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
JS_ClearPendingException(cx);
|
||||
aAsyncCause.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
aAsyncCause = str;
|
||||
} else {
|
||||
@ -635,7 +655,11 @@ NS_IMETHODIMP StackFrame::GetAsyncCause(nsAString& aAsyncCause)
|
||||
/* readonly attribute nsIStackFrame asyncCaller; */
|
||||
NS_IMETHODIMP JSStackFrame::GetAsyncCaller(nsIStackFrame** aAsyncCaller)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStack, NS_ERROR_NOT_AVAILABLE);
|
||||
if (!mStack) {
|
||||
*aAsyncCaller = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> asyncCallerObj(cx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
@ -668,7 +692,11 @@ NS_IMETHODIMP StackFrame::GetAsyncCaller(nsIStackFrame** aAsyncCaller)
|
||||
/* readonly attribute nsIStackFrame caller; */
|
||||
NS_IMETHODIMP JSStackFrame::GetCaller(nsIStackFrame** aCaller)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStack, NS_ERROR_NOT_AVAILABLE);
|
||||
if (!mStack) {
|
||||
*aCaller = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ThreadsafeAutoJSContext cx;
|
||||
JS::Rooted<JSObject*> callerObj(cx);
|
||||
bool canCache = false, useCachedValue = false;
|
||||
@ -706,7 +734,11 @@ NS_IMETHODIMP StackFrame::GetCaller(nsIStackFrame** aCaller)
|
||||
|
||||
NS_IMETHODIMP JSStackFrame::GetFormattedStack(nsAString& aStack)
|
||||
{
|
||||
NS_ENSURE_TRUE(mStack, NS_ERROR_NOT_AVAILABLE);
|
||||
if (!mStack) {
|
||||
aStack.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Sadly we can't use GetValueIfNotCached here, because our getter
|
||||
// returns bool, not JS::SavedFrameResult. Maybe it's possible to
|
||||
// make the templates more complicated to deal, but in the meantime
|
||||
@ -727,12 +759,16 @@ NS_IMETHODIMP JSStackFrame::GetFormattedStack(nsAString& aStack)
|
||||
|
||||
JS::Rooted<JSString*> formattedStack(cx);
|
||||
if (!JS::StringifySavedFrameStack(cx, stack, &formattedStack)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
JS_ClearPendingException(cx);
|
||||
aStack.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoJSString str;
|
||||
if (!str.init(cx, formattedStack)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
JS_ClearPendingException(cx);
|
||||
aStack.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
aStack = str;
|
||||
@ -787,9 +823,7 @@ NS_IMETHODIMP StackFrame::ToString(nsACString& _retval)
|
||||
funname.AssignLiteral("<TOP_LEVEL>");
|
||||
}
|
||||
|
||||
int32_t lineno;
|
||||
rv = GetLineno(&lineno);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
int32_t lineno = GetLineno();
|
||||
|
||||
static const char format[] = "%s frame :: %s :: %s :: line %d";
|
||||
_retval.AppendPrintf(format, frametype,
|
||||
|
Loading…
Reference in New Issue
Block a user