зеркало из https://github.com/mozilla/pjs.git
fixed for IRIX (doesn't like new-style casts)
This commit is contained in:
Родитель
733321ca8f
Коммит
0c0332fc61
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#if defined(NOT_PRODUCTION_CODE) && defined(USE_EXPERIMENTAL_SMART_POINTERS)
|
#if defined(NOT_PRODUCTION_CODE) && defined(USE_EXPERIMENTAL_SMART_POINTERS)
|
||||||
|
|
||||||
#include <cassert>
|
#include <assert.h>
|
||||||
|
|
||||||
|
|
||||||
/* USER MANUAL
|
/* USER MANUAL
|
||||||
|
@ -156,6 +156,10 @@
|
||||||
/*
|
/*
|
||||||
Set up some #defines to turn off a couple of troublesome C++ features.
|
Set up some #defines to turn off a couple of troublesome C++ features.
|
||||||
Interestingly, none of the compilers barf on template stuff.
|
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)
|
#if defined(__GNUG__) && (__GNUC_MINOR__ <= 90) && !defined(SOLARIS)
|
||||||
|
@ -166,10 +170,26 @@
|
||||||
#define NO_EXPLICIT
|
#define NO_EXPLICIT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(IRIX)
|
||||||
|
#define NO_MEMBER_USING_DECLARATIONS
|
||||||
|
#define NO_EXPLICIT
|
||||||
|
#define NO_NEW_CASTS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef NO_EXPLICIT
|
#ifdef NO_EXPLICIT
|
||||||
#define explicit
|
#define explicit
|
||||||
#endif
|
#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>
|
template <class T>
|
||||||
class derived_safe : public T
|
class derived_safe : public T
|
||||||
|
@ -186,8 +206,8 @@ class derived_safe : public T
|
||||||
using T::AddRef;
|
using T::AddRef;
|
||||||
using T::Release;
|
using T::Release;
|
||||||
#else
|
#else
|
||||||
unsigned long AddRef() { }
|
unsigned long AddRef();
|
||||||
unsigned long Release() { }
|
unsigned long Release();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -339,7 +359,7 @@ class COM_auto_ptr
|
||||||
get() const
|
get() const
|
||||||
// returns a |derived_safe<T>*| to deny clients the use of |AddRef| and |Release|
|
// 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
|
void
|
||||||
|
@ -399,7 +419,7 @@ class func_AddRefs_t
|
||||||
|
|
||||||
operator void**()
|
operator void**()
|
||||||
{
|
{
|
||||||
return reinterpret_cast<void**>(&ptr_);
|
return REINTERPRET_CAST(void**, &ptr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator T**()
|
operator T**()
|
||||||
|
@ -446,7 +466,7 @@ class func_doesnt_AddRef_t
|
||||||
|
|
||||||
operator void**()
|
operator void**()
|
||||||
{
|
{
|
||||||
return reinterpret_cast<void**>(&ptr_);
|
return REINTERPRET_CAST(void**, &ptr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator T**()
|
operator T**()
|
||||||
|
|
|
@ -94,20 +94,20 @@ IFoo::IFoo()
|
||||||
: refcount_(0)
|
: refcount_(0)
|
||||||
{
|
{
|
||||||
++total_constructions_;
|
++total_constructions_;
|
||||||
cout << " new IFoo@" << static_cast<void*>(this) << " [#" << total_constructions_ << "]" << endl;
|
cout << " new IFoo@" << STATIC_CAST(void*, this) << " [#" << total_constructions_ << "]" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
IFoo::~IFoo()
|
IFoo::~IFoo()
|
||||||
{
|
{
|
||||||
++total_destructions_;
|
++total_destructions_;
|
||||||
cout << "IFoo@" << static_cast<void*>(this) << "::~IFoo()" << " [#" << total_destructions_ << "]" << endl;
|
cout << "IFoo@" << STATIC_CAST(void*, this) << "::~IFoo()" << " [#" << total_destructions_ << "]" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long
|
unsigned long
|
||||||
IFoo::AddRef()
|
IFoo::AddRef()
|
||||||
{
|
{
|
||||||
++refcount_;
|
++refcount_;
|
||||||
cout << "IFoo@" << static_cast<void*>(this) << "::AddRef(), refcount --> " << refcount_ << endl;
|
cout << "IFoo@" << STATIC_CAST(void*, this) << "::AddRef(), refcount --> " << refcount_ << endl;
|
||||||
return refcount_;
|
return refcount_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,16 +119,16 @@ IFoo::Release()
|
||||||
cout << ">>";
|
cout << ">>";
|
||||||
|
|
||||||
--refcount_;
|
--refcount_;
|
||||||
cout << "IFoo@" << static_cast<void*>(this) << "::Release(), refcount --> " << refcount_ << endl;
|
cout << "IFoo@" << STATIC_CAST(void*, this) << "::Release(), refcount --> " << refcount_ << endl;
|
||||||
|
|
||||||
if ( !refcount_ )
|
if ( !refcount_ )
|
||||||
{
|
{
|
||||||
cout << " delete IFoo@" << static_cast<void*>(this) << endl;
|
cout << " delete IFoo@" << STATIC_CAST(void*, this) << endl;
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( wrap_message )
|
if ( wrap_message )
|
||||||
cout << "<<IFoo@" << static_cast<void*>(this) << "::Release()" << endl;
|
cout << "<<IFoo@" << STATIC_CAST(void*, this) << "::Release()" << endl;
|
||||||
|
|
||||||
return refcount_;
|
return refcount_;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ CreateIFoo( void** result )
|
||||||
{
|
{
|
||||||
cout << ">>CreateIFoo() --> ";
|
cout << ">>CreateIFoo() --> ";
|
||||||
IFoo* foop = new IFoo;
|
IFoo* foop = new IFoo;
|
||||||
cout << "IFoo@" << static_cast<void*>(foop) << endl;
|
cout << "IFoo@" << STATIC_CAST(void*, foop) << endl;
|
||||||
|
|
||||||
foop->AddRef();
|
foop->AddRef();
|
||||||
*result = foop;
|
*result = foop;
|
||||||
|
@ -180,12 +180,12 @@ class IBar : public IFoo
|
||||||
|
|
||||||
IBar::IBar()
|
IBar::IBar()
|
||||||
{
|
{
|
||||||
cout << " new IBar@" << static_cast<void*>(this) << endl;
|
cout << " new IBar@" << STATIC_CAST(void*, this) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBar::~IBar()
|
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() --> ";
|
cout << ">>CreateIBar() --> ";
|
||||||
IBar* barp = new IBar;
|
IBar* barp = new IBar;
|
||||||
cout << "IBar@" << static_cast<void*>(barp) << endl;
|
cout << "IBar@" << STATIC_CAST(void*, barp) << endl;
|
||||||
|
|
||||||
barp->AddRef();
|
barp->AddRef();
|
||||||
*result = barp;
|
*result = barp;
|
||||||
|
@ -239,10 +239,10 @@ main()
|
||||||
//foop->Release();
|
//foop->Release();
|
||||||
|
|
||||||
cout << endl << "### Test 3: can you |AddRef| if you must?" << endl;
|
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;
|
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;
|
cout << endl << "### Test 5: will a |COM_auto_ptr| |Release| when it goes out of scope?" << endl;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче