Hi,
I had previously proposed to change the prototypes for the
RegisterErrorHandler() and RegisterInfoHandler() methods
as follows:
static SceMiErrorHandler
SceMi::RegisterErrorHandler(
SceMiErrorHandler errorHandler,
void *context);
static SceMiInfoHandler
SceMi::RegisterInfoHandler(
SceMiInfoHandler infoHandler,
void *context);
The difference between these and the current standard is that
the new ones return the previous error/info handler so that
it can be restored later similar to how the UNIX signal()
call works for signal handlers.
However, I have since realized that the above is flawed because
it neglects to take into account that you also need to restore
the original context argument. One way to fix is to use
std::pair:
static std::pair<SceMiErrorHandler, void *>
SceMi::RegisterErrorHandler(
SceMiErrorHandler errorHandler,
void *context);
but this does not port to the C API. Another possibility is
to define a struct:
struct SceMiErrorHandlerContext
{
SceMiErrorHandler Handler;
void *Context;
};
static SceMiErrorHandlerContext
SceMi::RegisterErrorHandler(
SceMiErrorHandler errorHandler,
void *context);
This will work in both C and C++ but people may object to
returning a struct . . . This shouldn't be a problem, though
as the struct is very small: two pointer values, i.e., 8
bytes on a 32-bit architecture or 16 bytes on a 64-bit
architecture.
Per
Received on Thu Jul 22 08:50:36 2004
This archive was generated by hypermail 2.1.8 : Thu Jul 22 2004 - 08:50:39 PDT