Get pyxpcom building and working again, at least on Windows. file test

fails, but we can live with that for now.  Not part of the build.


git-svn-id: svn://10.0.0.236/trunk@134454 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mhammond%skippinet.com.au
2002-11-26 11:39:07 +00:00
parent 6d8229ae4a
commit f4be74069c
8 changed files with 83 additions and 110 deletions

View File

@@ -28,6 +28,7 @@
// (c) 2000, ActiveState corp.
#include "PyXPCOM_std.h"
#include "nsReadableUtils.h"
#include <nsFileStream.h>
static char *PyTraceback_AsString(PyObject *exc_tb);
@@ -37,10 +38,17 @@ static char *PyTraceback_AsString(PyObject *exc_tb);
void LogMessage(const char *prefix, const char *pszMessageText)
{
nsOutputConsoleStream console;
nsOutputStream console;
console << prefix << pszMessageText;
}
void LogMessage(const char *prefix, nsACString &text)
{
char *c = ToNewCString(text);
LogMessage(prefix, c);
nsCRT::free(c);
}
// A helper for the various logging routines.
static void VLogF(const char *prefix, const char *fmt, va_list argptr)
{
@@ -61,36 +69,35 @@ void PyXPCOM_LogError(const char *fmt, ...)
PyErr_Fetch( &exc_typ, &exc_val, &exc_tb);
if (exc_typ) {
PyErr_NormalizeException( &exc_typ, &exc_val, &exc_tb);
char *string1 = nsnull;
nsOutputStringStream streamout(string1);
nsCAutoString streamout;
if (exc_tb) {
const char *szTraceback = PyTraceback_AsString(exc_tb);
if (szTraceback == NULL)
streamout << "Can't get the traceback info!";
streamout += "Can't get the traceback info!";
else {
streamout << "Traceback (most recent call last):\n";
streamout << szTraceback;
streamout += "Traceback (most recent call last):\n";
streamout += szTraceback;
PyMem_Free((void *)szTraceback);
}
}
PyObject *temp = PyObject_Str(exc_typ);
if (temp) {
streamout << PyString_AsString(temp);
streamout += PyString_AsString(temp);
Py_DECREF(temp);
} else
streamout << "Can't convert exception to a string!";
streamout << ": ";
streamout += "Can't convert exception to a string!";
streamout += ": ";
if (exc_val != NULL) {
temp = PyObject_Str(exc_val);
if (temp) {
streamout << PyString_AsString(temp);
streamout += PyString_AsString(temp);
Py_DECREF(temp);
} else
streamout << "Can't convert exception value to a string!";
streamout += "Can't convert exception value to a string!";
}
streamout << "\n";
LogMessage("PyXPCOM Exception:", string1);
streamout += "\n";
LogMessage("PyXPCOM Exception:", streamout);
}
PyErr_Restore(exc_typ, exc_val, exc_tb);
}

View File

@@ -19,7 +19,7 @@
// pyloader
//
// Not part of the main Python _xpcom package, but a seperate, thin DLL.
// Not part of the main Python _xpcom package, but a separate, thin DLL.
//
// The main loader and registrar for Python. A thin DLL that is designed to live in
// the xpcom "components" directory. Simply locates and loads the standard
@@ -37,6 +37,8 @@
#include "stdlib.h"
#include "stdarg.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include <nsFileStream.h> // For console logging.
#ifdef HAVE_LONG_LONG
@@ -48,7 +50,6 @@
static char *PyTraceback_AsString(PyObject *exc_tb);
#ifdef XP_WIN
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
@@ -172,8 +173,14 @@ extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager *servMgr,
void LogMessage(const char *prefix, const char *pszMessageText)
{
nsOutputConsoleStream console;
console << prefix << pszMessageText;
fprintf(stderr, "%s", pszMessageText);
}
void LogMessage(const char *prefix, nsACString &text)
{
char *c = ToNewCString(text);
LogMessage(prefix, c);
nsCRT::free(c);
}
// A helper for the various logging routines.
@@ -195,36 +202,35 @@ static void LogError(const char *fmt, ...)
PyObject *exc_typ = NULL, *exc_val = NULL, *exc_tb = NULL;
PyErr_Fetch( &exc_typ, &exc_val, &exc_tb);
if (exc_typ) {
char *string1 = nsnull;
nsOutputStringStream streamout(string1);
nsCAutoString streamout;
if (exc_tb) {
const char *szTraceback = PyTraceback_AsString(exc_tb);
if (szTraceback == NULL)
streamout << "Can't get the traceback info!";
streamout += "Can't get the traceback info!";
else {
streamout << "Traceback (most recent call last):\n";
streamout << szTraceback;
streamout += "Traceback (most recent call last):\n";
streamout += szTraceback;
PyMem_Free((void *)szTraceback);
}
}
PyObject *temp = PyObject_Str(exc_typ);
if (temp) {
streamout << PyString_AsString(temp);
streamout += PyString_AsString(temp);
Py_DECREF(temp);
} else
streamout << "Can convert exception to a string!";
streamout << ": ";
streamout += "Can convert exception to a string!";
streamout += ": ";
if (exc_val != NULL) {
temp = PyObject_Str(exc_val);
if (temp) {
streamout << PyString_AsString(temp);
streamout += PyString_AsString(temp);
Py_DECREF(temp);
} else
streamout << "Can convert exception value to a string!";
streamout += "Can convert exception value to a string!";
}
streamout << "\n";
LogMessage("PyXPCOM Exception:", string1);
streamout += "\n";
LogMessage("PyXPCOM Exception:", streamout);
}
PyErr_Restore(exc_typ, exc_val, exc_tb);
}