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);
if (this.mStartDate)
m.mStartDate = this.mStartDate.clone(); m.mStartDate = this.mStartDate.clone();
if (this.mEndDate)
m.mEndDate = this.mEndDate.clone(); m.mEndDate = this.mEndDate.clone();
if (this.mStampDate)
m.mStampDate = this.mStampDate.clone(); 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);
if (this.mStartDate)
m.mStartDate = this.mStartDate.clone(); m.mStartDate = this.mStartDate.clone();
if (this.mEndDate)
m.mEndDate = this.mEndDate.clone(); m.mEndDate = this.mEndDate.clone();
if (this.mStampDate)
m.mStampDate = this.mStampDate.clone(); 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,13 +13,17 @@ 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;
if (this.mCreationDate)
this.mCreationDate.makeImmutable(); this.mCreationDate.makeImmutable();
if (this.mRecurrenceInfo)
this.mRecurrenceInfo.makeImmutable(); this.mRecurrenceInfo.makeImmutable();
if (this.mAlarmTime)
this.mAlarmTime.makeImmutable(); this.mAlarmTime.makeImmutable();
this.mImmutable = true; this.mImmutable = true;
@ -39,9 +43,12 @@ 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();
if (this.mRecurrenceInfo)
m.mRecurrenceInfo = this.mRecurrenceInfo.clone();
if (this.mCreationDate)
m.mCreationDate = this.mCreationDate.clone(); m.mCreationDate = this.mCreationDate.clone();
if (this.mAlarmTime)
m.mAlarmTime = this.mAlarmTime.clone(); m.mAlarmTime = this.mAlarmTime.clone();

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

@ -55,13 +55,17 @@ 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
if (this.mCreationDate)
this.mCreationDate.makeImmutable(); this.mCreationDate.makeImmutable();
if (this.mRecurrenceInfo)
this.mRecurrenceInfo.makeImmutable(); this.mRecurrenceInfo.makeImmutable();
if (this.mAlarmTime)
this.mAlarmTime.makeImmutable(); this.mAlarmTime.makeImmutable();
this.mImmutable = true; this.mImmutable = true;
@ -81,9 +85,12 @@ 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();
if (this.mRecurrenceInfo)
m.mRecurrenceInfo = this.mRecurrenceInfo.clone();
if (this.mCreationDate)
m.mCreationDate = this.mCreationDate.clone(); m.mCreationDate = this.mCreationDate.clone();
if (this.mAlarmTime)
m.mAlarmTime = this.mAlarmTime.clone(); m.mAlarmTime = this.mAlarmTime.clone();
// these need fixing // these need fixing