conditionally factored destructor

This commit is contained in:
scc%netscape.com 1999-05-10 20:48:43 +00:00
Родитель fa3fd7fb39
Коммит 64fea0e7f5
6 изменённых файлов: 74 добавлений и 61 удалений

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

@ -18,6 +18,14 @@
#include "nsCOMPtr.h"
#ifdef NSCAP_FEATURE_FACTOR_DESTRUCTOR
nsCOMPtr_base::~nsCOMPtr_base()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
}
#endif
void
nsCOMPtr_base::assign_with_AddRef( nsISupports* rawPtr )
{
@ -48,7 +56,10 @@ void**
nsCOMPtr_base::begin_assignment()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
mRawPtr = 0;
{
NSCAP_RELEASE(mRawPtr);
mRawPtr = 0;
}
return NSCAP_REINTERPRET_CAST(void**, &mRawPtr);
}

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

@ -116,6 +116,7 @@
#define NSCAP_FEATURE_ALLOW_RAW_POINTERS
#define NSCAP_FEATURE_ALLOW_COMPARISONS
#define NSCAP_FEATURE_FACTOR_DESTRUCTOR
/*
@ -338,11 +339,17 @@ class nsCOMPtr_base
// nothing else to do here
}
#ifdef NSCAP_FEATURE_FACTOR_DESTRUCTOR
~nsCOMPtr_base();
#endif
#if 0
~nsCOMPtr_base()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
}
#endif
NS_EXPORT void assign_with_AddRef( nsISupports* );
NS_EXPORT void assign_with_QueryInterface( nsISupports*, const nsIID&, nsresult* );
@ -363,6 +370,14 @@ class nsCOMPtr : private nsCOMPtr_base
public:
typedef T element_type;
#ifndef NSCAP_FEATURE_FACTOR_DESTRUCTOR
~nsCOMPtr()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
}
#endif
nsCOMPtr()
// : nsCOMPtr_base(0)
{
@ -632,7 +647,7 @@ CallQueryInterface( SourceType* aSource, nsCOMPtr<DestinationType>* aDestination
NS_PRECONDITION(aSource, "null parameter");
NS_PRECONDITION(aDestination, "null parameter");
return aSource->QueryInterface(DestinationType::GetIID(), getter_AddRefs(*aDestination));
return aSource->QueryInterface(DestinationType::GetIID(), NS_STATIC_CAST(void**, getter_AddRefs(*aDestination)));
}

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

@ -18,6 +18,14 @@
#include "nsCOMPtr.h"
#ifdef NSCAP_FEATURE_FACTOR_DESTRUCTOR
nsCOMPtr_base::~nsCOMPtr_base()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
}
#endif
void
nsCOMPtr_base::assign_with_AddRef( nsISupports* rawPtr )
{
@ -48,7 +56,10 @@ void**
nsCOMPtr_base::begin_assignment()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
mRawPtr = 0;
{
NSCAP_RELEASE(mRawPtr);
mRawPtr = 0;
}
return NSCAP_REINTERPRET_CAST(void**, &mRawPtr);
}

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

@ -116,6 +116,7 @@
#define NSCAP_FEATURE_ALLOW_RAW_POINTERS
#define NSCAP_FEATURE_ALLOW_COMPARISONS
#define NSCAP_FEATURE_FACTOR_DESTRUCTOR
/*
@ -338,11 +339,17 @@ class nsCOMPtr_base
// nothing else to do here
}
#ifdef NSCAP_FEATURE_FACTOR_DESTRUCTOR
~nsCOMPtr_base();
#endif
#if 0
~nsCOMPtr_base()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
}
#endif
NS_EXPORT void assign_with_AddRef( nsISupports* );
NS_EXPORT void assign_with_QueryInterface( nsISupports*, const nsIID&, nsresult* );
@ -363,6 +370,14 @@ class nsCOMPtr : private nsCOMPtr_base
public:
typedef T element_type;
#ifndef NSCAP_FEATURE_FACTOR_DESTRUCTOR
~nsCOMPtr()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
}
#endif
nsCOMPtr()
// : nsCOMPtr_base(0)
{
@ -632,7 +647,7 @@ CallQueryInterface( SourceType* aSource, nsCOMPtr<DestinationType>* aDestination
NS_PRECONDITION(aSource, "null parameter");
NS_PRECONDITION(aDestination, "null parameter");
return aSource->QueryInterface(DestinationType::GetIID(), getter_AddRefs(*aDestination));
return aSource->QueryInterface(DestinationType::GetIID(), NS_STATIC_CAST(void**, getter_AddRefs(*aDestination)));
}

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

@ -116,6 +116,7 @@
#define NSCAP_FEATURE_ALLOW_RAW_POINTERS
#define NSCAP_FEATURE_ALLOW_COMPARISONS
#define NSCAP_FEATURE_FACTOR_DESTRUCTOR
/*
@ -338,11 +339,17 @@ class nsCOMPtr_base
// nothing else to do here
}
#ifdef NSCAP_FEATURE_FACTOR_DESTRUCTOR
~nsCOMPtr_base();
#endif
#if 0
~nsCOMPtr_base()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
}
#endif
NS_EXPORT void assign_with_AddRef( nsISupports* );
NS_EXPORT void assign_with_QueryInterface( nsISupports*, const nsIID&, nsresult* );
@ -363,6 +370,14 @@ class nsCOMPtr : private nsCOMPtr_base
public:
typedef T element_type;
#ifndef NSCAP_FEATURE_FACTOR_DESTRUCTOR
~nsCOMPtr()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
}
#endif
nsCOMPtr()
// : nsCOMPtr_base(0)
{
@ -632,7 +647,7 @@ CallQueryInterface( SourceType* aSource, nsCOMPtr<DestinationType>* aDestination
NS_PRECONDITION(aSource, "null parameter");
NS_PRECONDITION(aDestination, "null parameter");
return aSource->QueryInterface(DestinationType::GetIID(), getter_AddRefs(*aDestination));
return aSource->QueryInterface(DestinationType::GetIID(), NS_STATIC_CAST(void**, getter_AddRefs(*aDestination)));
}

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

@ -1,54 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsCOMPtr.h"
void
nsCOMPtr_base::assign_with_AddRef( nsISupports* rawPtr )
{
if ( rawPtr )
NSCAP_ADDREF(rawPtr);
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
mRawPtr = rawPtr;
}
void
nsCOMPtr_base::assign_with_QueryInterface( nsISupports* rawPtr, const nsIID& iid, nsresult* result )
{
nsresult status = NS_OK;
if ( !rawPtr || !NS_SUCCEEDED( status = rawPtr->QueryInterface(iid, NSCAP_REINTERPRET_CAST(void**, &rawPtr)) ) )
rawPtr = 0;
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
mRawPtr = rawPtr;
if ( result )
*result = status;
}
void**
nsCOMPtr_base::begin_assignment()
{
if ( mRawPtr )
NSCAP_RELEASE(mRawPtr);
mRawPtr = 0;
return NSCAP_REINTERPRET_CAST(void**, &mRawPtr);
}