fixed for IRIX (doesn't like new-style casts)

This commit is contained in:
scc%netscape.com 1998-11-14 00:35:48 +00:00
Родитель f0e94f9767
Коммит 6e4a1432aa
2 изменённых файлов: 38 добавлений и 18 удалений

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

@ -35,7 +35,7 @@
#if defined(NOT_PRODUCTION_CODE) && defined(USE_EXPERIMENTAL_SMART_POINTERS)
#include <cassert>
#include <assert.h>
/* USER MANUAL
@ -156,6 +156,10 @@
/*
Set up some #defines to turn off a couple of troublesome C++ features.
Interestingly, none of the compilers barf on template stuff.
Ideally, we would want declarations like these in a configuration file
that that everybody would get. Deciding exactly how to do that should
be part of the process of moving from experimental to production.
*/
#if defined(__GNUG__) && (__GNUC_MINOR__ <= 90) && !defined(SOLARIS)
@ -166,10 +170,26 @@
#define NO_EXPLICIT
#endif
#if defined(IRIX)
#define NO_MEMBER_USING_DECLARATIONS
#define NO_EXPLICIT
#define NO_NEW_CASTS
#endif
#ifdef NO_EXPLICIT
#define explicit
#endif
#ifndef NO_NEW_CASTS
#define STATIC_CAST(T,x) static_cast<T>(x)
#define REINTERPRET_CAST(T,x) reinterpret_cast<T>(x)
#else
#define STATIC_CAST(T,x) ((T)(x))
#define REINTERPRET_CAST(T,x) ((T)(x))
#endif
template <class T>
class derived_safe : public T
@ -186,8 +206,8 @@ class derived_safe : public T
using T::AddRef;
using T::Release;
#else
unsigned long AddRef() { }
unsigned long Release() { }
unsigned long AddRef();
unsigned long Release();
#endif
};
@ -339,7 +359,7 @@ class COM_auto_ptr
get() const
// returns a |derived_safe<T>*| to deny clients the use of |AddRef| and |Release|
{
return reinterpret_cast<derived_safe<T>*>(ptr_);
return REINTERPRET_CAST(derived_safe<T>*, ptr_);
}
void
@ -399,7 +419,7 @@ class func_AddRefs_t
operator void**()
{
return reinterpret_cast<void**>(&ptr_);
return REINTERPRET_CAST(void**, &ptr_);
}
operator T**()
@ -446,7 +466,7 @@ class func_doesnt_AddRef_t
operator void**()
{
return reinterpret_cast<void**>(&ptr_);
return REINTERPRET_CAST(void**, &ptr_);
}
operator T**()

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

@ -94,20 +94,20 @@ IFoo::IFoo()
: refcount_(0)
{
++total_constructions_;
cout << " new IFoo@" << static_cast<void*>(this) << " [#" << total_constructions_ << "]" << endl;
cout << " new IFoo@" << STATIC_CAST(void*, this) << " [#" << total_constructions_ << "]" << endl;
}
IFoo::~IFoo()
{
++total_destructions_;
cout << "IFoo@" << static_cast<void*>(this) << "::~IFoo()" << " [#" << total_destructions_ << "]" << endl;
cout << "IFoo@" << STATIC_CAST(void*, this) << "::~IFoo()" << " [#" << total_destructions_ << "]" << endl;
}
unsigned long
IFoo::AddRef()
{
++refcount_;
cout << "IFoo@" << static_cast<void*>(this) << "::AddRef(), refcount --> " << refcount_ << endl;
cout << "IFoo@" << STATIC_CAST(void*, this) << "::AddRef(), refcount --> " << refcount_ << endl;
return refcount_;
}
@ -119,16 +119,16 @@ IFoo::Release()
cout << ">>";
--refcount_;
cout << "IFoo@" << static_cast<void*>(this) << "::Release(), refcount --> " << refcount_ << endl;
cout << "IFoo@" << STATIC_CAST(void*, this) << "::Release(), refcount --> " << refcount_ << endl;
if ( !refcount_ )
{
cout << " delete IFoo@" << static_cast<void*>(this) << endl;
cout << " delete IFoo@" << STATIC_CAST(void*, this) << endl;
delete this;
}
if ( wrap_message )
cout << "<<IFoo@" << static_cast<void*>(this) << "::Release()" << endl;
cout << "<<IFoo@" << STATIC_CAST(void*, this) << "::Release()" << endl;
return refcount_;
}
@ -139,7 +139,7 @@ CreateIFoo( void** result )
{
cout << ">>CreateIFoo() --> ";
IFoo* foop = new IFoo;
cout << "IFoo@" << static_cast<void*>(foop) << endl;
cout << "IFoo@" << STATIC_CAST(void*, foop) << endl;
foop->AddRef();
*result = foop;
@ -180,12 +180,12 @@ class IBar : public IFoo
IBar::IBar()
{
cout << " new IBar@" << static_cast<void*>(this) << endl;
cout << " new IBar@" << STATIC_CAST(void*, this) << endl;
}
IBar::~IBar()
{
cout << "IBar@" << static_cast<void*>(this) << "::~IBar()" << endl;
cout << "IBar@" << STATIC_CAST(void*, this) << "::~IBar()" << endl;
}
@ -196,7 +196,7 @@ CreateIBar( void** result )
{
cout << ">>CreateIBar() --> ";
IBar* barp = new IBar;
cout << "IBar@" << static_cast<void*>(barp) << endl;
cout << "IBar@" << STATIC_CAST(void*, barp) << endl;
barp->AddRef();
*result = barp;
@ -239,10 +239,10 @@ main()
//foop->Release();
cout << endl << "### Test 3: can you |AddRef| if you must?" << endl;
static_cast<IFoo*>(foop)->AddRef();
STATIC_CAST(IFoo*, foop)->AddRef();
cout << endl << "### Test 4: can you |Release| if you must?" << endl;
static_cast<IFoo*>(foop)->Release();
STATIC_CAST(IFoo*, foop)->Release();
cout << endl << "### Test 5: will a |COM_auto_ptr| |Release| when it goes out of scope?" << endl;
}