2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsXBLProtoImplProperty.h"
|
|
|
|
#include "nsUnicharUtils.h"
|
2013-02-26 11:04:13 -08:00
|
|
|
#include "nsContentUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsReadableUtils.h"
|
|
|
|
#include "nsIScriptContext.h"
|
2013-01-16 18:50:25 -08:00
|
|
|
#include "nsJSUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIScriptGlobalObject.h"
|
2011-11-03 13:39:08 -07:00
|
|
|
#include "nsXBLPrototypeBinding.h"
|
|
|
|
#include "nsXBLSerialize.h"
|
2013-02-08 06:24:22 -08:00
|
|
|
#include "xpcpublic.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-26 11:04:13 -08:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLProtoImplProperty::nsXBLProtoImplProperty(const PRUnichar* aName,
|
|
|
|
const PRUnichar* aGetter,
|
|
|
|
const PRUnichar* aSetter,
|
2012-12-17 12:22:38 -08:00
|
|
|
const PRUnichar* aReadOnly,
|
|
|
|
uint32_t aLineNumber) :
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLProtoImplMember(aName),
|
2012-07-30 07:20:58 -07:00
|
|
|
mGetterText(nullptr),
|
|
|
|
mSetterText(nullptr),
|
2007-03-22 10:30:00 -07:00
|
|
|
mJSAttributes(JSPROP_ENUMERATE)
|
|
|
|
#ifdef DEBUG
|
2011-10-17 07:59:28 -07:00
|
|
|
, mIsCompiled(false)
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsXBLProtoImplProperty);
|
|
|
|
|
|
|
|
if (aReadOnly) {
|
|
|
|
nsAutoString readOnly; readOnly.Assign(*aReadOnly);
|
|
|
|
if (readOnly.LowerCaseEqualsLiteral("true"))
|
|
|
|
mJSAttributes |= JSPROP_READONLY;
|
|
|
|
}
|
|
|
|
|
2012-12-17 12:22:38 -08:00
|
|
|
if (aGetter) {
|
2007-03-22 10:30:00 -07:00
|
|
|
AppendGetterText(nsDependentString(aGetter));
|
2012-12-17 12:22:38 -08:00
|
|
|
SetGetterLineNumber(aLineNumber);
|
|
|
|
}
|
|
|
|
if (aSetter) {
|
2007-03-22 10:30:00 -07:00
|
|
|
AppendSetterText(nsDependentString(aSetter));
|
2012-12-17 12:22:38 -08:00
|
|
|
SetSetterLineNumber(aLineNumber);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-11-03 13:39:08 -07:00
|
|
|
nsXBLProtoImplProperty::nsXBLProtoImplProperty(const PRUnichar* aName,
|
|
|
|
const bool aIsReadOnly)
|
|
|
|
: nsXBLProtoImplMember(aName),
|
2012-07-30 07:20:58 -07:00
|
|
|
mGetterText(nullptr),
|
|
|
|
mSetterText(nullptr),
|
2011-11-03 13:39:08 -07:00
|
|
|
mJSAttributes(JSPROP_ENUMERATE)
|
|
|
|
#ifdef DEBUG
|
|
|
|
, mIsCompiled(false)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(nsXBLProtoImplProperty);
|
|
|
|
|
|
|
|
if (aIsReadOnly)
|
|
|
|
mJSAttributes |= JSPROP_READONLY;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLProtoImplProperty::~nsXBLProtoImplProperty()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(nsXBLProtoImplProperty);
|
|
|
|
|
2008-02-12 08:02:41 -08:00
|
|
|
if (!(mJSAttributes & JSPROP_GETTER)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
delete mGetterText;
|
|
|
|
}
|
|
|
|
|
2008-02-12 08:02:41 -08:00
|
|
|
if (!(mJSAttributes & JSPROP_SETTER)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
delete mSetterText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsXBLProtoImplProperty::AppendGetterText(const nsAString& aText)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(!mIsCompiled,
|
|
|
|
"Must not be compiled when accessing getter text");
|
|
|
|
if (!mGetterText) {
|
|
|
|
mGetterText = new nsXBLTextWithLineNumber();
|
|
|
|
if (!mGetterText)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mGetterText->AppendText(aText);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsXBLProtoImplProperty::AppendSetterText(const nsAString& aText)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(!mIsCompiled,
|
|
|
|
"Must not be compiled when accessing setter text");
|
|
|
|
if (!mSetterText) {
|
|
|
|
mSetterText = new nsXBLTextWithLineNumber();
|
|
|
|
if (!mSetterText)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mSetterText->AppendText(aText);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
nsXBLProtoImplProperty::SetGetterLineNumber(uint32_t aLineNumber)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(!mIsCompiled,
|
|
|
|
"Must not be compiled when accessing getter text");
|
|
|
|
if (!mGetterText) {
|
|
|
|
mGetterText = new nsXBLTextWithLineNumber();
|
|
|
|
if (!mGetterText)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mGetterText->SetLineNumber(aLineNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
nsXBLProtoImplProperty::SetSetterLineNumber(uint32_t aLineNumber)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(!mIsCompiled,
|
|
|
|
"Must not be compiled when accessing setter text");
|
|
|
|
if (!mSetterText) {
|
|
|
|
mSetterText = new nsXBLTextWithLineNumber();
|
|
|
|
if (!mSetterText)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mSetterText->SetLineNumber(aLineNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* gPropertyArgs[] = { "val" };
|
|
|
|
|
|
|
|
nsresult
|
2013-02-08 06:24:21 -08:00
|
|
|
nsXBLProtoImplProperty::InstallMember(JSContext *aCx,
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::Handle<JSObject*> aTargetClassObject)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(mIsCompiled,
|
|
|
|
"Should not be installing an uncompiled property");
|
2013-02-08 06:24:21 -08:00
|
|
|
MOZ_ASSERT(js::IsObjectInContextCompartment(aTargetClassObject, aCx));
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::Rooted<JSObject*> globalObject(aCx, JS_GetGlobalForObject(aCx, aTargetClassObject));
|
|
|
|
JS::Rooted<JSObject*> scopeObject(aCx, xpc::GetXBLScope(aCx, globalObject));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// now we want to reevaluate our property using aContext and the script object for this window...
|
2013-02-08 06:24:20 -08:00
|
|
|
if (mJSGetterObject || mJSSetterObject) {
|
2013-02-08 06:24:22 -08:00
|
|
|
// First, enter the compartment of the scope object and clone the functions.
|
|
|
|
JSAutoCompartment ac(aCx, scopeObject);
|
2013-04-05 06:21:02 -07:00
|
|
|
|
|
|
|
JS::Rooted<JSObject*> getter(aCx, nullptr);
|
|
|
|
if (mJSGetterObject) {
|
2013-02-08 06:24:22 -08:00
|
|
|
if (!(getter = ::JS_CloneFunctionObject(aCx, mJSGetterObject, scopeObject)))
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2013-04-05 06:21:02 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::Rooted<JSObject*> setter(aCx, nullptr);
|
|
|
|
if (mJSSetterObject) {
|
2013-02-08 06:24:22 -08:00
|
|
|
if (!(setter = ::JS_CloneFunctionObject(aCx, mJSSetterObject, scopeObject)))
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2013-04-05 06:21:02 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-08 06:24:22 -08:00
|
|
|
// Now, enter the content compartment, wrap the getter/setter, and define
|
|
|
|
// them on the class object.
|
|
|
|
JSAutoCompartment ac2(aCx, aTargetClassObject);
|
2007-03-22 10:30:00 -07:00
|
|
|
nsDependentString name(mName);
|
2013-04-05 06:21:02 -07:00
|
|
|
if (!JS_WrapObject(aCx, getter.address()) ||
|
|
|
|
!JS_WrapObject(aCx, setter.address()) ||
|
2013-02-08 06:24:22 -08:00
|
|
|
!::JS_DefineUCProperty(aCx, aTargetClassObject,
|
2012-05-05 02:00:06 -07:00
|
|
|
static_cast<const jschar*>(mName),
|
2009-03-10 16:21:40 -07:00
|
|
|
name.Length(), JSVAL_VOID,
|
2013-04-05 06:21:02 -07:00
|
|
|
JS_DATA_TO_FUNC_PTR(JSPropertyOp, getter.get()),
|
|
|
|
JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, setter.get()),
|
2013-02-13 10:16:19 -08:00
|
|
|
mJSAttributes))
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-05 06:21:02 -07:00
|
|
|
nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
nsXBLProtoImplProperty::CompileMember(nsIScriptContext* aContext, const nsCString& aClassStr,
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::Handle<JSObject*> aClassObject)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(!mIsCompiled,
|
|
|
|
"Trying to compile an already-compiled property");
|
|
|
|
NS_PRECONDITION(aClassObject,
|
|
|
|
"Must have class object to compile");
|
|
|
|
|
|
|
|
if (!mName)
|
|
|
|
return NS_ERROR_FAILURE; // Without a valid name, we can't install the member.
|
|
|
|
|
|
|
|
// We have a property.
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2012-09-01 19:35:17 -07:00
|
|
|
nsAutoCString functionUri;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mGetterText || mSetterText) {
|
|
|
|
functionUri = aClassStr;
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t hash = functionUri.RFindChar('#');
|
2007-03-22 10:30:00 -07:00
|
|
|
if (hash != kNotFound) {
|
|
|
|
functionUri.Truncate(hash);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool deletedGetter = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mGetterText && mGetterText->GetText()) {
|
|
|
|
nsDependentString getter(mGetterText->GetText());
|
|
|
|
if (!getter.IsEmpty()) {
|
2013-02-26 11:04:13 -08:00
|
|
|
AutoPushJSContext cx(aContext->GetNativeContext());
|
2013-01-16 18:50:25 -08:00
|
|
|
JSAutoRequest ar(cx);
|
|
|
|
JSAutoCompartment ac(cx, aClassObject);
|
|
|
|
JS::CompileOptions options(cx);
|
|
|
|
options.setFileAndLine(functionUri.get(), mGetterText->GetLineNumber())
|
|
|
|
.setVersion(JSVERSION_LATEST)
|
|
|
|
.setUserBit(true); // Flag us as XBL
|
|
|
|
nsCString name = NS_LITERAL_CSTRING("get_") + NS_ConvertUTF16toUTF8(mName);
|
2013-03-06 08:41:43 -08:00
|
|
|
JS::RootedObject rootedNull(cx, nullptr); // See bug 781070.
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::RootedObject getterObject(cx);
|
2013-01-16 18:50:25 -08:00
|
|
|
rv = nsJSUtils::CompileFunction(cx, rootedNull, options, name, 0, nullptr,
|
2013-04-05 06:21:02 -07:00
|
|
|
getter, getterObject.address());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Make sure we free mGetterText here before setting mJSGetterObject, since
|
|
|
|
// that'll overwrite mGetterText
|
|
|
|
delete mGetterText;
|
2011-10-17 07:59:28 -07:00
|
|
|
deletedGetter = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
mJSGetterObject = getterObject;
|
|
|
|
|
|
|
|
if (mJSGetterObject && NS_SUCCEEDED(rv)) {
|
|
|
|
mJSAttributes |= JSPROP_GETTER | JSPROP_SHARED;
|
|
|
|
}
|
|
|
|
if (NS_FAILED(rv)) {
|
2012-07-30 07:20:58 -07:00
|
|
|
mJSGetterObject = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
mJSAttributes &= ~JSPROP_GETTER;
|
|
|
|
/*chaining to return failure*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // if getter is not empty
|
|
|
|
|
|
|
|
if (!deletedGetter) { // Empty getter
|
|
|
|
delete mGetterText;
|
2012-07-30 07:20:58 -07:00
|
|
|
mJSGetterObject = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// We failed to compile our getter. So either we've set it to null, or
|
|
|
|
// it's still set to the text object. In either case, it's safe to return
|
|
|
|
// the error here, since then we'll be cleaned up as uncompiled and that
|
|
|
|
// will be ok. Going on and compiling the setter and _then_ returning an
|
|
|
|
// error, on the other hand, will try to clean up a compiled setter as
|
|
|
|
// uncompiled and crash.
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool deletedSetter = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mSetterText && mSetterText->GetText()) {
|
|
|
|
nsDependentString setter(mSetterText->GetText());
|
|
|
|
if (!setter.IsEmpty()) {
|
2013-02-26 11:04:13 -08:00
|
|
|
AutoPushJSContext cx(aContext->GetNativeContext());
|
2013-01-16 18:50:25 -08:00
|
|
|
JSAutoRequest ar(cx);
|
|
|
|
JSAutoCompartment ac(cx, aClassObject);
|
|
|
|
JS::CompileOptions options(cx);
|
|
|
|
options.setFileAndLine(functionUri.get(), mSetterText->GetLineNumber())
|
|
|
|
.setVersion(JSVERSION_LATEST)
|
|
|
|
.setUserBit(true); // Flag us as XBL
|
|
|
|
nsCString name = NS_LITERAL_CSTRING("set_") + NS_ConvertUTF16toUTF8(mName);
|
2013-03-06 08:41:43 -08:00
|
|
|
JS::RootedObject rootedNull(cx, nullptr); // See bug 781070.
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::RootedObject setterObject(cx);
|
2013-01-16 18:50:25 -08:00
|
|
|
rv = nsJSUtils::CompileFunction(cx, rootedNull, options, name, 1,
|
2013-04-05 06:21:02 -07:00
|
|
|
gPropertyArgs, setter, setterObject.address());
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Make sure we free mSetterText here before setting mJSGetterObject, since
|
|
|
|
// that'll overwrite mSetterText
|
|
|
|
delete mSetterText;
|
2011-10-17 07:59:28 -07:00
|
|
|
deletedSetter = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
mJSSetterObject = setterObject;
|
|
|
|
|
|
|
|
if (mJSSetterObject && NS_SUCCEEDED(rv)) {
|
|
|
|
mJSAttributes |= JSPROP_SETTER | JSPROP_SHARED;
|
|
|
|
}
|
|
|
|
if (NS_FAILED(rv)) {
|
2012-07-30 07:20:58 -07:00
|
|
|
mJSSetterObject = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
mJSAttributes &= ~JSPROP_SETTER;
|
|
|
|
/*chaining to return failure*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // if setter wasn't empty....
|
|
|
|
|
|
|
|
if (!deletedSetter) { // Empty setter
|
|
|
|
delete mSetterText;
|
2012-07-30 07:20:58 -07:00
|
|
|
mJSSetterObject = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
mIsCompiled = NS_SUCCEEDED(rv);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2007-05-24 07:10:02 -07:00
|
|
|
|
|
|
|
void
|
2007-10-29 06:45:07 -07:00
|
|
|
nsXBLProtoImplProperty::Trace(TraceCallback aCallback, void *aClosure) const
|
2007-05-24 07:10:02 -07:00
|
|
|
{
|
2008-02-12 08:02:41 -08:00
|
|
|
if (mJSAttributes & JSPROP_GETTER) {
|
2012-05-03 12:28:10 -07:00
|
|
|
aCallback(mJSGetterObject, "mJSGetterObject", aClosure);
|
2007-05-24 07:10:02 -07:00
|
|
|
}
|
|
|
|
|
2008-02-12 08:02:41 -08:00
|
|
|
if (mJSAttributes & JSPROP_SETTER) {
|
2012-05-03 12:28:10 -07:00
|
|
|
aCallback(mJSSetterObject, "mJSSetterObject", aClosure);
|
2007-05-24 07:10:02 -07:00
|
|
|
}
|
|
|
|
}
|
2011-11-03 13:39:08 -07:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXBLProtoImplProperty::Read(nsIScriptContext* aContext,
|
|
|
|
nsIObjectInputStream* aStream,
|
|
|
|
XBLBindingSerializeDetails aType)
|
|
|
|
{
|
2013-04-05 06:21:02 -07:00
|
|
|
JSContext *cx = aContext->GetNativeContext();
|
|
|
|
|
2011-11-03 13:39:08 -07:00
|
|
|
if (aType == XBLBinding_Serialize_GetterProperty ||
|
|
|
|
aType == XBLBinding_Serialize_GetterSetterProperty) {
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::Rooted<JSObject*> getterObject(cx);
|
2013-04-05 06:21:03 -07:00
|
|
|
nsresult rv = XBL_DeserializeFunction(aContext, aStream, &getterObject);
|
2011-11-03 13:39:08 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-11-15 23:50:18 -08:00
|
|
|
mJSGetterObject = getterObject;
|
2011-11-03 13:39:08 -07:00
|
|
|
mJSAttributes |= JSPROP_GETTER | JSPROP_SHARED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aType == XBLBinding_Serialize_SetterProperty ||
|
|
|
|
aType == XBLBinding_Serialize_GetterSetterProperty) {
|
2013-04-05 06:21:02 -07:00
|
|
|
JS::Rooted<JSObject*> setterObject(cx);
|
2013-04-05 06:21:03 -07:00
|
|
|
nsresult rv = XBL_DeserializeFunction(aContext, aStream, &setterObject);
|
2011-11-03 13:39:08 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-11-15 23:50:18 -08:00
|
|
|
mJSSetterObject = setterObject;
|
2011-11-03 13:39:08 -07:00
|
|
|
mJSAttributes |= JSPROP_SETTER | JSPROP_SHARED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
mIsCompiled = true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsXBLProtoImplProperty::Write(nsIScriptContext* aContext,
|
|
|
|
nsIObjectOutputStream* aStream)
|
|
|
|
{
|
|
|
|
XBLBindingSerializeDetails type;
|
|
|
|
|
|
|
|
if (mJSAttributes & JSPROP_GETTER) {
|
|
|
|
type = mJSAttributes & JSPROP_SETTER ?
|
|
|
|
XBLBinding_Serialize_GetterSetterProperty :
|
|
|
|
XBLBinding_Serialize_GetterProperty;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
type = XBLBinding_Serialize_SetterProperty;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mJSAttributes & JSPROP_READONLY) {
|
|
|
|
type |= XBLBinding_Serialize_ReadOnly;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = aStream->Write8(type);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = aStream->WriteWStringZ(mName);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (mJSAttributes & JSPROP_GETTER) {
|
2011-11-03 13:39:08 -07:00
|
|
|
rv = XBL_SerializeFunction(aContext, aStream, mJSGetterObject);
|
2011-11-03 13:39:08 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mJSAttributes & JSPROP_SETTER) {
|
2011-11-03 13:39:08 -07:00
|
|
|
rv = XBL_SerializeFunction(aContext, aStream, mJSSetterObject);
|
2011-11-03 13:39:08 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|