Impl fixes; don't try to clone/makeImmutable null interface members

This commit is contained in:
vladimir%pobox.com 2004-11-18 06:46:07 +00:00
Родитель 8f242803c5
Коммит c9da6321d8
4 изменённых файлов: 63 добавлений и 21 удалений

Просмотреть файл

@ -10,6 +10,7 @@ calEvent.prototype = {
!aIID.equals(Components.interfaces.calIItemBase) && !aIID.equals(Components.interfaces.calIItemBase) &&
!aIID.equals(Components.interfaces.calIEvent)) !aIID.equals(Components.interfaces.calIEvent))
{ {
dump ("calEvent QI failed to " + aIID + "\n");
throw Components.results.NS_ERROR_NO_INTERFACE; throw Components.results.NS_ERROR_NO_INTERFACE;
} }
@ -19,13 +20,26 @@ calEvent.prototype = {
clone: function () { clone: function () {
var m = new calEvent(); var m = new calEvent();
this.cloneItemBaseInto(m); this.cloneItemBaseInto(m);
m.mStartDate = this.mStartDate.clone(); if (this.mStartDate)
m.mEndDate = this.mEndDate.clone(); m.mStartDate = this.mStartDate.clone();
m.mStampDate = this.mStampDate.clone(); if (this.mEndDate)
m.mEndDate = this.mEndDate.clone();
if (this.mStampDate)
m.mStampDate = this.mStampDate.clone();
return m; return m;
}, },
makeImmutable: function () {
if (this.mStartDate)
this.mStartDate.makeImmutable();
if (this.mEndDate)
this.mEndDate.makeImmutable();
if (this.mStampDate)
this.mStampDate.makeImmutable();
this.makeItemBaseImmutable();
},

Просмотреть файл

@ -55,6 +55,7 @@ calEvent.prototype = {
!aIID.equals(Components.interfaces.calIItemBase) && !aIID.equals(Components.interfaces.calIItemBase) &&
!aIID.equals(Components.interfaces.calIEvent)) !aIID.equals(Components.interfaces.calIEvent))
{ {
dump ("calEvent QI failed to " + aIID + "\n");
throw Components.results.NS_ERROR_NO_INTERFACE; throw Components.results.NS_ERROR_NO_INTERFACE;
} }
@ -64,13 +65,26 @@ calEvent.prototype = {
clone: function () { clone: function () {
var m = new calEvent(); var m = new calEvent();
this.cloneItemBaseInto(m); this.cloneItemBaseInto(m);
m.mStartDate = this.mStartDate.clone(); if (this.mStartDate)
m.mEndDate = this.mEndDate.clone(); m.mStartDate = this.mStartDate.clone();
m.mStampDate = this.mStampDate.clone(); if (this.mEndDate)
m.mEndDate = this.mEndDate.clone();
if (this.mStampDate)
m.mStampDate = this.mStampDate.clone();
return m; return m;
}, },
makeImmutable: function () {
if (this.mStartDate)
this.mStartDate.makeImmutable();
if (this.mEndDate)
this.mEndDate.makeImmutable();
if (this.mStampDate)
this.mStampDate.makeImmutable();
this.makeItemBaseImmutable();
},
#define MEMBER_ATTR(varname, initvalue, attrname) \ #define MEMBER_ATTR(varname, initvalue, attrname) \
varname: initvalue, \ varname: initvalue, \
get attrname() { return this.varname; }, \ get attrname() { return this.varname; }, \

Просмотреть файл

@ -13,14 +13,18 @@ calItemBase.prototype = {
mImmutable: false, mImmutable: false,
get isMutable() { return this. mImmutable; }, get isMutable() { return this. mImmutable; },
makeImmutable: function() {
makeItemBaseImmutable: function() {
if (this.mImmutable) if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE; throw Components.results.NS_ERROR_FAILURE;
this.mCreationDate.makeImmutable(); if (this.mCreationDate)
this.mRecurrenceInfo.makeImmutable(); this.mCreationDate.makeImmutable();
this.mAlarmTime.makeImmutable(); if (this.mRecurrenceInfo)
this.mRecurrenceInfo.makeImmutable();
if (this.mAlarmTime)
this.mAlarmTime.makeImmutable();
this.mImmutable = true; this.mImmutable = true;
}, },
@ -39,10 +43,13 @@ calItemBase.prototype = {
m.mMethod = this.mMethod; m.mMethod = this.mMethod;
m.mStatus = this.mStatus; m.mStatus = this.mStatus;
m.mHasAlarm = this.mHasAlarm; m.mHasAlarm = this.mHasAlarm;
m.mRecurrenceInfo = this.mRecurrenceInfo.clone();
m.mCreationDate = this.mCreationDate.clone(); if (this.mRecurrenceInfo)
m.mAlarmTime = this.mAlarmTime.clone(); m.mRecurrenceInfo = this.mRecurrenceInfo.clone();
if (this.mCreationDate)
m.mCreationDate = this.mCreationDate.clone();
if (this.mAlarmTime)
m.mAlarmTime = this.mAlarmTime.clone();
m.mAttachments = this.mAttachments; m.mAttachments = this.mAttachments;

Просмотреть файл

@ -55,14 +55,18 @@ calItemBase.prototype = {
mImmutable: false, mImmutable: false,
get isMutable() { return this. mImmutable; }, get isMutable() { return this. mImmutable; },
makeImmutable: function() {
makeItemBaseImmutable: function() {
if (this.mImmutable) if (this.mImmutable)
throw Components.results.NS_ERROR_FAILURE; throw Components.results.NS_ERROR_FAILURE;
// make all our components immutable // make all our components immutable
this.mCreationDate.makeImmutable(); if (this.mCreationDate)
this.mRecurrenceInfo.makeImmutable(); this.mCreationDate.makeImmutable();
this.mAlarmTime.makeImmutable(); if (this.mRecurrenceInfo)
this.mRecurrenceInfo.makeImmutable();
if (this.mAlarmTime)
this.mAlarmTime.makeImmutable();
this.mImmutable = true; this.mImmutable = true;
}, },
@ -81,10 +85,13 @@ calItemBase.prototype = {
m.mMethod = this.mMethod; m.mMethod = this.mMethod;
m.mStatus = this.mStatus; m.mStatus = this.mStatus;
m.mHasAlarm = this.mHasAlarm; m.mHasAlarm = this.mHasAlarm;
m.mRecurrenceInfo = this.mRecurrenceInfo.clone();
m.mCreationDate = this.mCreationDate.clone(); if (this.mRecurrenceInfo)
m.mAlarmTime = this.mAlarmTime.clone(); m.mRecurrenceInfo = this.mRecurrenceInfo.clone();
if (this.mCreationDate)
m.mCreationDate = this.mCreationDate.clone();
if (this.mAlarmTime)
m.mAlarmTime = this.mAlarmTime.clone();
// these need fixing // these need fixing
m.mAttachments = this.mAttachments; m.mAttachments = this.mAttachments;
@ -96,7 +103,7 @@ calItemBase.prototype = {
#define MEMBER_ATTR(varname, initvalue, attrname) \ #define MEMBER_ATTR(varname, initvalue, attrname) \
varname: initvalue, \ varname: initvalue, \
get attrname() { return this.varname; }, \ get attrname() { return this.varname; }, \
set attrname(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.varname = v; } set attrname(v) { if (this.mImmutable) throw Components.results.NS_ERROR_FAILURE; else this.varname = v; }
MEMBER_ATTR(mGeneration, 0, generation), MEMBER_ATTR(mGeneration, 0, generation),