зеркало из https://github.com/mozilla/gecko-dev.git
Switch from nsIScriptErrorLogger approach - having the Console Service support multiple factory interfaces for different kinds of console methods - to having a separate script error class. Per discussion with jband.
Add a few #ifndef __nsidefineforthisfile__ guards to .h files.
This commit is contained in:
Родитель
69ca3f19d4
Коммит
c34165e864
|
@ -47,7 +47,6 @@ XPIDLSRCS = \
|
|||
nsIConsoleMessage.idl \
|
||||
nsIConsoleListener.idl \
|
||||
nsIScriptError.idl \
|
||||
nsIScriptErrorLogger.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -38,10 +38,8 @@ XPIDLSRCS = \
|
|||
.\nsIConsoleMessage.idl \
|
||||
.\nsIConsoleListener.idl \
|
||||
.\nsIScriptError.idl \
|
||||
.\nsIScriptErrorLogger.idl \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LINCS = \
|
||||
$(NULL)
|
||||
|
||||
|
@ -50,7 +48,6 @@ LLIBS = \
|
|||
$(DIST)\lib\xpcom.lib \
|
||||
$(NULL)
|
||||
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\nsConsoleMessage.obj \
|
||||
.\$(OBJDIR)\nsConsoleService.obj \
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef __nsconsolemessage_h__
|
||||
#define __nsconsolemessage_h__
|
||||
|
||||
#include "nsIConsoleMessage.h"
|
||||
#include "nsString.h"
|
||||
|
||||
|
@ -38,3 +41,5 @@ public:
|
|||
private:
|
||||
nsAutoString mMessage;
|
||||
};
|
||||
|
||||
#endif /* __nsconsolemessage_h__ */
|
||||
|
|
|
@ -28,13 +28,8 @@
|
|||
|
||||
#include "nsConsoleService.h"
|
||||
#include "nsConsoleMessage.h"
|
||||
#include "nsScriptError.h"
|
||||
|
||||
// NS_IMPL_THREADSAFE_ISUPPORTS(nsConsoleService, NS_GET_IID(nsIConsoleService));
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsConsoleService,
|
||||
nsIConsoleService,
|
||||
nsIScriptErrorLogger);
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS(nsConsoleService, NS_GET_IID(nsIConsoleService));
|
||||
|
||||
nsConsoleService::nsConsoleService()
|
||||
{
|
||||
|
@ -194,20 +189,3 @@ nsConsoleService::UnregisterListener(nsIConsoleListener *listener) {
|
|||
mListeners->RemoveElement(listener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIScriptErrorLogger methods
|
||||
NS_IMETHODIMP
|
||||
nsConsoleService::LogScriptError(const PRUnichar *message,
|
||||
const PRUnichar *sourceName,
|
||||
const PRUnichar *sourceLine,
|
||||
PRUint32 lineNumber,
|
||||
PRUint32 columnNumber,
|
||||
PRUint32 flags,
|
||||
const char *category)
|
||||
{
|
||||
// LogMessage adds a ref to this, and eventual release does delete.
|
||||
nsScriptError *err = new nsScriptError(message, sourceName, sourceLine,
|
||||
lineNumber, columnNumber,
|
||||
flags, category);
|
||||
return this->LogMessage(err);
|
||||
}
|
||||
|
|
|
@ -24,13 +24,16 @@
|
|||
* 'lil description of this file.
|
||||
*/
|
||||
|
||||
#ifndef __nsconsoleservice_h__
|
||||
#define __nsconsoleservice_h__
|
||||
|
||||
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptErrorLogger.h"
|
||||
|
||||
class nsConsoleService : public nsIConsoleService, nsIScriptErrorLogger
|
||||
class nsConsoleService : public nsIConsoleService
|
||||
{
|
||||
public:
|
||||
nsConsoleService();
|
||||
|
@ -38,7 +41,6 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONSOLESERVICE
|
||||
NS_DECL_NSISCRIPTERRORLOGGER
|
||||
|
||||
private:
|
||||
// Circular buffer of saved messages
|
||||
|
@ -56,3 +58,5 @@ private:
|
|||
// Listeners to notify whenever a new message is logged.
|
||||
nsCOMPtr<nsSupportsArray> mListeners;
|
||||
};
|
||||
|
||||
#endif /* __nsconsoleservice_h__ */
|
||||
|
|
|
@ -23,8 +23,10 @@
|
|||
#include "nsIGenericFactory.h"
|
||||
|
||||
#include "nsConsoleService.h"
|
||||
#include "nsScriptError.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsConsoleService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptError)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
|
@ -32,6 +34,11 @@ static nsModuleComponentInfo components[] =
|
|||
nsConsoleServiceConstructor,
|
||||
nsnull, // RegisterConsoleService
|
||||
nsnull, // UnregisterConsoleService
|
||||
},
|
||||
{ "Script Error", NS_SCRIPTERROR_CID, NS_SCRIPTERROR_PROGID,
|
||||
nsScriptErrorConstructor,
|
||||
nsnull,
|
||||
nsnull,
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -51,3 +58,6 @@ static nsModuleComponentInfo components[] =
|
|||
NS_IMPL_NSGETMODULE("nsConsoleServiceModule", components)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -51,24 +51,19 @@ interface nsIScriptError : nsIConsoleMessage
|
|||
readonly attribute PRUint32 flags;
|
||||
|
||||
readonly attribute string category;
|
||||
|
||||
void init(in wstring message,
|
||||
in wstring sourceName,
|
||||
in wstring sourcLine,
|
||||
in PRUint32 lineNumber,
|
||||
in PRUint32 columnNumber,
|
||||
in PRUint32 flags,
|
||||
in string category);
|
||||
};
|
||||
|
||||
// jband asks: save more info for debuggy stuff in console?
|
||||
// e.g. title of window, maybe weak reference to originating window?
|
||||
// maybe just way to get from url to loaded document.
|
||||
|
||||
|
||||
|
||||
// struct JSErrorReport {
|
||||
// const char *filename; /* source file name, URL, etc., or null */
|
||||
// uintN lineno; /* source line number */
|
||||
// const char *linebuf; /* offending source line without final \n */
|
||||
// const char *tokenptr; /* pointer to error token in linebuf */
|
||||
// const jschar *uclinebuf; /* unicode (original) line buffer */
|
||||
// const jschar *uctokenptr; /* unicode (original) token pointer */
|
||||
// uintN flags; /* error/warning, etc. */
|
||||
// uintN errorNumber; /* the error number, e.g. see js.msg */
|
||||
// const jschar *ucmessage; /* the (default) error message */
|
||||
// const jschar **messageArgs; /* arguments for the error message */
|
||||
// };
|
||||
%{ C++
|
||||
#define NS_SCRIPTERROR_CID \
|
||||
{ 0xe38e53b9, 0x5bb0, 0x456a, { 0xb5, 0x53, 0x57, 0x93, 0x70, 0xcb, 0x15, 0x67 }}
|
||||
|
||||
#define NS_SCRIPTERROR_PROGID "scripterror"
|
||||
%}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
/*
|
||||
* Interface (for nsConsoleService to expose) for logging script errors;
|
||||
* logs an nsIScriptError to the console service.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(5eb93360-1dd2-11b2-9986-d1c3d4821e3f)]
|
||||
interface nsIScriptErrorLogger : nsISupports
|
||||
{
|
||||
void logScriptError(in wstring message,
|
||||
in wstring sourceName,
|
||||
in wstring sourceLine,
|
||||
in PRUint32 lineNumber,
|
||||
in PRUint32 columnNumber,
|
||||
in PRUint32 flags,
|
||||
in string category);
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
|
@ -77,11 +77,22 @@ nsScriptError::GetCategory(char **result) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptError::Init(const PRUnichar *message,
|
||||
const PRUnichar *sourceName,
|
||||
const PRUnichar *sourceLine,
|
||||
PRUint32 lineNumber,
|
||||
PRUint32 columnNumber,
|
||||
PRUint32 flags,
|
||||
const char *category)
|
||||
{
|
||||
mMessage.SetString(message);
|
||||
mSourceName.SetString(sourceName);
|
||||
mLineNumber = lineNumber;
|
||||
mSourceLine.SetString(sourceLine);
|
||||
mColumnNumber = columnNumber;
|
||||
mFlags = flags;
|
||||
mCategory.SetString(category);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef __nsscripterror_h__
|
||||
#define __nsscripterror_h__
|
||||
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsString.h"
|
||||
|
||||
|
@ -31,23 +34,6 @@ public:
|
|||
|
||||
// TODO - do something reasonable on getting null from these babies.
|
||||
|
||||
nsScriptError(const PRUnichar *message,
|
||||
const PRUnichar *sourceName, // or URL
|
||||
const PRUnichar *sourceLine,
|
||||
PRUint32 lineNumber,
|
||||
PRUint32 columnNumber,
|
||||
PRUint32 flags,
|
||||
const char *category)
|
||||
{
|
||||
mMessage.SetString(message);
|
||||
mSourceName.SetString(sourceName);
|
||||
mLineNumber = lineNumber;
|
||||
mSourceLine.SetString(sourceLine);
|
||||
mColumnNumber = columnNumber;
|
||||
mFlags = flags;
|
||||
mCategory.SetString(category);
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONSOLEMESSAGE
|
||||
NS_DECL_NSISCRIPTERROR
|
||||
|
@ -62,4 +48,4 @@ private:
|
|||
nsCAutoString mCategory;
|
||||
};
|
||||
|
||||
|
||||
#endif /* __nsscripterror_h__ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче