Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes
XPCJSStackFrame Class Reference
Inheritance diagram for XPCJSStackFrame:
Inheritance graph
[legend]
Collaboration diagram for XPCJSStackFrame:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 XPCJSStackFrame ()
virtual ~XPCJSStackFrame ()
JSBool IsJSFrame () const
string toString ()

Static Public Member Functions

NS_DECL_ISUPPORTS static
NS_DECL_NSISTACKFRAME nsresult 
CreateStack (JSContext *cx, JSStackFrame *fp, XPCJSStackFrame **stack)
static nsresult CreateStackFrameLocation (PRUint32 aLanguage, const char *aFilename, const char *aFunctionName, PRInt32 aLineNumber, nsIStackFrame *aCaller, XPCJSStackFrame **stack)

Public Attributes

readonly attribute PRUint32 language
readonly attribute string languageName
readonly attribute string filename
readonly attribute string name
readonly attribute PRInt32 lineNumber
readonly attribute string sourceLine
readonly attribute nsIStackFrame caller

Private Attributes

nsIStackFramemCaller
char * mFilename
char * mFunname
PRInt32 mLineno
PRUint32 mLanguage

Detailed Description

Definition at line 45 of file xpcstack.cpp.


Constructor & Destructor Documentation

Definition at line 111 of file xpcstack.cpp.

Here is the caller graph for this function:

Definition at line 120 of file xpcstack.cpp.

{
    if(mFilename)
        nsMemory::Free(mFilename);
    if(mFunname)
        nsMemory::Free(mFunname);
    NS_IF_RELEASE(mCaller);
}

Member Function Documentation

nsresult XPCJSStackFrame::CreateStack ( JSContext cx,
JSStackFrame fp,
XPCJSStackFrame **  stack 
) [static]

Definition at line 132 of file xpcstack.cpp.

{
    XPCJSStackFrame* self = new XPCJSStackFrame();
    JSBool failed = JS_FALSE;
    if(self)
    {
        NS_ADDREF(self);

        if(fp->down)
        {
            if(NS_FAILED(CreateStack(cx, fp->down,
                         (XPCJSStackFrame**) &self->mCaller)))
                failed = JS_TRUE;
        }

        if(!failed)
        {
            if (JS_IsNativeFrame(cx, fp))
                self->mLanguage = nsIProgrammingLanguage::CPLUSPLUS;
            else
                self->mLanguage = nsIProgrammingLanguage::JAVASCRIPT;
            if(self->IsJSFrame())
            {
                JSScript* script = JS_GetFrameScript(cx, fp);
                jsbytecode* pc = JS_GetFramePC(cx, fp);
                if(script && pc)
                {
                    const char* filename = JS_GetScriptFilename(cx, script);
                    if(filename)
                    {
                        self->mFilename = (char*)
                                nsMemory::Clone(filename,
                                        sizeof(char)*(strlen(filename)+1));
                    }

                    self->mLineno = (PRInt32) JS_PCToLineNumber(cx, script, pc);


                    JSFunction* fun = JS_GetFrameFunction(cx, fp);
                    if(fun)
                    {
                        const char* funname = JS_GetFunctionName(fun);
                        if(funname)
                        {
                        self->mFunname = (char*)
                                nsMemory::Clone(funname,
                                        sizeof(char)*(strlen(funname)+1));
                        }
                    }
                }
                else
                {
                    self->mLanguage = nsIProgrammingLanguage::CPLUSPLUS;
                }
            }
        }
        if(failed)
            NS_RELEASE(self);
    }

    *stack = self;
    return self ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

nsresult XPCJSStackFrame::CreateStackFrameLocation ( PRUint32  aLanguage,
const char *  aFilename,
const char *  aFunctionName,
PRInt32  aLineNumber,
nsIStackFrame aCaller,
XPCJSStackFrame **  stack 
) [static]

Definition at line 199 of file xpcstack.cpp.

{
    JSBool failed = JS_FALSE;
    XPCJSStackFrame* self = new XPCJSStackFrame();
    if(self)
        NS_ADDREF(self);
    else
        failed = JS_TRUE;

    if(!failed)
    {
        self->mLanguage = aLanguage;
        self->mLineno = aLineNumber;
    }

    if(!failed && aFilename)
    {
        self->mFilename = (char*)
                nsMemory::Clone(aFilename,
                        sizeof(char)*(strlen(aFilename)+1));
        if(!self->mFilename)
            failed = JS_TRUE;
    }

    if(!failed && aFunctionName)
    {
        self->mFunname = (char*)
                nsMemory::Clone(aFunctionName,
                        sizeof(char)*(strlen(aFunctionName)+1));
        if(!self->mFunname)
            failed = JS_TRUE;
    }

    if(!failed && aCaller)
    {
        NS_ADDREF(aCaller);
        self->mCaller = aCaller;
    }

    if(failed && self)
    {
        NS_RELEASE(self);   // sets self to nsnull
    }

    *stack = self;
    return self ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

JSBool XPCJSStackFrame::IsJSFrame ( ) const [inline]

Definition at line 65 of file xpcstack.cpp.


Member Data Documentation

Definition at line 61 of file nsIException.idl.

Definition at line 56 of file nsIException.idl.

Definition at line 54 of file nsIException.idl.

Definition at line 55 of file nsIException.idl.

Definition at line 59 of file nsIException.idl.

Definition at line 69 of file xpcstack.cpp.

char* XPCJSStackFrame::mFilename [private]

Definition at line 71 of file xpcstack.cpp.

char* XPCJSStackFrame::mFunname [private]

Definition at line 72 of file xpcstack.cpp.

Definition at line 74 of file xpcstack.cpp.

Definition at line 73 of file xpcstack.cpp.

readonly attribute string nsIStackFrame::name [inherited]

Definition at line 57 of file nsIException.idl.

Definition at line 60 of file nsIException.idl.


The documentation for this class was generated from the following file: