Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes | Friends
nsXBLProtoImplField Class Reference

#include <nsXBLProtoImplField.h>

Inheritance diagram for nsXBLProtoImplField:
Inheritance graph
Collaboration diagram for nsXBLProtoImplField:
Collaboration graph

List of all members.

Public Member Functions

 nsXBLProtoImplField (const PRUnichar *aName, const PRUnichar *aReadOnly)
virtual ~nsXBLProtoImplField ()
virtual void Destroy (PRBool aIsCompiled)
void AppendFieldText (const nsAString &aText)
void SetLineNumber (PRUint32 aLineNumber)
virtual nsresult InstallMember (nsIScriptContext *aContext, nsIContent *aBoundElement, void *aScriptObject, void *aTargetClassObject, const nsCString &aClassStr)
virtual nsresult CompileMember (nsIScriptContext *aContext, const nsCString &aClassStr, void *aClassObject)
nsXBLProtoImplMemberGetNext ()
void SetNext (nsXBLProtoImplMember *aNext)

Protected Attributes

PRUint32 mFieldTextLength
PRUint32 mLineNumber
uintN mJSAttributes


struct nsAutoGCRoot

Detailed Description

Definition at line 49 of file nsXBLProtoImplField.h.

Constructor & Destructor Documentation

Definition at line 52 of file nsXBLProtoImplField.cpp.

  : nsXBLProtoImplMember(aName),
  if (aReadOnly) {
    nsAutoString readOnly; readOnly.Assign(*aReadOnly);
    if (readOnly.LowerCaseEqualsLiteral("true"))
      mJSAttributes |= JSPROP_READONLY;

Definition at line 67 of file nsXBLProtoImplField.cpp.

Member Function Documentation

Definition at line 80 of file nsXBLProtoImplField.cpp.

  if (mFieldText) {
    nsDependentString fieldTextStr(mFieldText, mFieldTextLength);
    nsAutoString newFieldText = fieldTextStr + aText;
    PRUnichar* temp = mFieldText;
    mFieldText = ToNewUnicode(newFieldText);
    mFieldTextLength = newFieldText.Length();
  else {
    mFieldText = ToNewUnicode(aText);
    mFieldTextLength = aText.Length();

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXBLProtoImplField::CompileMember ( nsIScriptContext aContext,
const nsCString aClassStr,
void aClassObject 
) [virtual]

Implements nsXBLProtoImplMember.

Definition at line 150 of file nsXBLProtoImplField.cpp.

  return NS_OK;
void nsXBLProtoImplField::Destroy ( PRBool  aIsCompiled) [virtual]

Implements nsXBLProtoImplMember.

Definition at line 75 of file nsXBLProtoImplField.cpp.


Definition at line 106 of file nsXBLProtoImplMember.h.

{ return mNext; };

Here is the caller graph for this function:

nsresult nsXBLProtoImplField::InstallMember ( nsIScriptContext aContext,
nsIContent aBoundElement,
void aScriptObject,
void aTargetClassObject,
const nsCString aClassStr 
) [virtual]

Implements nsXBLProtoImplMember.

Definition at line 97 of file nsXBLProtoImplField.cpp.

  if (mFieldTextLength == 0)
    return NS_OK; // nothing to do.

  JSContext* cx = (JSContext*) aContext->GetNativeContext();
  JSObject * scriptObject = (JSObject *) aScriptObject;
  NS_ASSERTION(scriptObject, "uh-oh, script Object should NOT be null or bad things will happen");
  if (!scriptObject)
    return NS_ERROR_FAILURE;

  nsCAutoString bindingURI(aClassStr);
  PRInt32 hash = bindingURI.RFindChar('#');
  if (hash != kNotFound)
  // compile the literal string 
  jsval result = JSVAL_NULL;
  // EvaluateStringWithValue and JS_DefineUCProperty can both trigger GC, so
  // protect |result| here.
  nsresult rv;
  nsAutoGCRoot root(&result, &rv);
  if (NS_FAILED(rv))
    return rv;
  PRBool undefined;
  // XXX Need a URI here!
  nsCOMPtr<nsIScriptContext> context = aContext;
  rv = context->EvaluateStringWithValue(nsDependentString(mFieldText,
                                        nsnull, bindingURI.get(),
                                        mLineNumber, nsnull,
                                        (void*) &result, &undefined);
  if (NS_FAILED(rv))
    return rv;

  if (!undefined) {
    // Define the evaluated result as a JS property
    nsDependentString name(mName);
    if (!::JS_DefineUCProperty(cx, scriptObject, NS_REINTERPRET_CAST(const jschar*, mName), 
                               name.Length(), result, nsnull, nsnull, mJSAttributes))
      return NS_ERROR_OUT_OF_MEMORY;
  return NS_OK;

Here is the call graph for this function:

Definition at line 57 of file nsXBLProtoImplField.h.

    mLineNumber = aLineNumber;

Here is the caller graph for this function:

void nsXBLProtoImplMember::SetNext ( nsXBLProtoImplMember aNext) [inline, inherited]

Definition at line 107 of file nsXBLProtoImplMember.h.

{ mNext = aNext; };

Here is the caller graph for this function:

Friends And Related Function Documentation

friend struct nsAutoGCRoot [friend, inherited]

Definition at line 119 of file nsXBLProtoImplMember.h.

Member Data Documentation

Definition at line 71 of file nsXBLProtoImplField.h.

Definition at line 72 of file nsXBLProtoImplField.h.

Definition at line 74 of file nsXBLProtoImplField.h.

Definition at line 73 of file nsXBLProtoImplField.h.

PRUnichar* nsXBLProtoImplMember::mName [protected, inherited]

Definition at line 122 of file nsXBLProtoImplMember.h.

Definition at line 121 of file nsXBLProtoImplMember.h.

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