Add CHISupportsOwner, a simple Objective-C class that just holds a reference to an XPCOM object (via an nsISupports*).

This commit is contained in:
smfr%smfr.org 2005-10-12 00:32:53 +00:00
parent da2729380f
commit cbf43f3ea9
3 changed files with 184 additions and 0 deletions

View File

@ -1047,6 +1047,48 @@
settings = {
};
};
0F0F5E3908FC65FB00B4EBCD = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.cpp.objcpp;
name = CHISupportsOwner.mm;
path = src/extensions/CHISupportsOwner.mm;
refType = 2;
sourceTree = SOURCE_ROOT;
};
0F0F5E3A08FC65FB00B4EBCD = {
fileRef = 0F0F5E3908FC65FB00B4EBCD;
isa = PBXBuildFile;
settings = {
};
};
0F0F5E3B08FC65FB00B4EBCD = {
fileRef = 0F0F5E3908FC65FB00B4EBCD;
isa = PBXBuildFile;
settings = {
};
};
0F0F5E3C08FC660300B4EBCD = {
fileEncoding = 30;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
name = CHISupportsOwner.h;
path = src/extensions/CHISupportsOwner.h;
refType = 2;
sourceTree = SOURCE_ROOT;
};
0F0F5E3D08FC660300B4EBCD = {
fileRef = 0F0F5E3C08FC660300B4EBCD;
isa = PBXBuildFile;
settings = {
};
};
0F0F5E3E08FC660300B4EBCD = {
fileRef = 0F0F5E3C08FC660300B4EBCD;
isa = PBXBuildFile;
settings = {
};
};
0F13A30D07D7F3930034B176 = {
fileEncoding = 30;
isa = PBXFileReference;
@ -3500,6 +3542,7 @@
0FC4B33E08941B4F009C5F41,
0F222C6108C6102B00B34F14,
0F08FB1508D37DA90022DD45,
0F0F5E3D08FC660300B4EBCD,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@ -4648,6 +4691,7 @@
0FE7712B08C7C42F00AFB850,
0FDEEA3B08CBD04200754D9B,
0F08FB1808D37DB30022DD45,
0F0F5E3A08FC65FB00B4EBCD,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@ -7385,6 +7429,7 @@
0FC4B33F08941B4F009C5F41,
0F222C6208C6102B00B34F14,
0F08FB1608D37DA90022DD45,
0F0F5E3E08FC660300B4EBCD,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@ -8540,6 +8585,7 @@
0FE7712C08C7C42F00AFB850,
0FDEEA3C08CBD04200754D9B,
0F08FB1908D37DB30022DD45,
0F0F5E3B08FC65FB00B4EBCD,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@ -16240,6 +16286,7 @@
children = (
3489ADC90753B717005ADF6C,
F541495E02711B0001A80166,
0F0F5E3C08FC660300B4EBCD,
F583E3C203B8228F01A80166,
F541495A02711A8301A80166,
F5FDF166031AF47301DE816D,
@ -16274,6 +16321,7 @@
children = (
3489ADCA0753B717005ADF6C,
F541495F02711B0001A80166,
0F0F5E3908FC65FB00B4EBCD,
F583E3BF03B8228701A80166,
F541495B02711A8301A80166,
F5FDF167031AF47301DE816D,

View File

@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <smfr@smfr.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import <Foundation/Foundation.h>
//
// CHISupportsOwner is a simple Obj-C class whose only task is to
// keep an add-reffed pointer to an XPCOM object. This allows you to
// put XPCOM objects into Cocoa containers, and have them retained.
//
@interface CHISupportsOwner : NSObject
{
@private
nsISupports* mISupports; // AddReffed (that's the point of this class)
}
- (id)initWithValue:(nsISupports*)inValue;
- (void)setValue:(nsISupports*)inValue;
- (nsISupports*)value; // return value not addreffed
@end

View File

@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Fraser <smfr@smfr.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#import "nsISupportsUtils.h"
#import "CHISupportsOwner.h"
@implementation CHISupportsOwner
- (id)initWithValue:(nsISupports*)inValue
{
if ((self = [super init]))
{
mISupports = inValue;
NS_IF_ADDREF(mISupports);
}
return self;
}
- (void)dealloc
{
NS_IF_RELEASE(mISupports);
[super dealloc];
}
- (void)setValue:(nsISupports*)inValue
{
if (mISupports != inValue)
{
NS_IF_RELEASE(mISupports);
mISupports = inValue;
NS_IF_ADDREF(mISupports);
}
}
- (nsISupports*)value
{
return mISupports;
}
@end