Get Python XPCOM bindings building with 1.4. Not part of the build.

This commit is contained in:
mhammond%skippinet.com.au 2003-04-01 13:22:16 +00:00
parent 601bdbff9a
commit 9b18893922
4 changed files with 16 additions and 42 deletions

View File

@ -29,7 +29,7 @@
#include "PyXPCOM_std.h"
#include "nsReadableUtils.h"
#include <nsFileStream.h>
#include <nsIConsoleService.h>
static char *PyTraceback_AsString(PyObject *exc_tb);
@ -38,8 +38,10 @@ static char *PyTraceback_AsString(PyObject *exc_tb);
void LogMessage(const char *prefix, const char *pszMessageText)
{
nsOutputStream console;
console << prefix << pszMessageText;
nsCOMPtr<nsIConsoleService> consoleService = do_GetService(NS_CONSOLESERVICE_CONTRACTID);
NS_ABORT_IF_FALSE(consoleService, "Where is the console service?");
if (consoleService)
consoleService->LogStringMessage(NS_ConvertASCIItoUCS2(pszMessageText).get());
}
void LogMessage(const char *prefix, nsACString &text)

View File

@ -1352,6 +1352,9 @@ PRBool PyXPCOM_InterfaceVariantHelper::FillInVariant(const PythonTypeDescriptor
PRUint32 element_size = GetArrayElementSize(array_type);
int seq_length = PySequence_Length(val);
cb_this_buffer_pointer = seq_length * element_size;
if (cb_this_buffer_pointer==0)
// prevent assertions allocing zero bytes. Can't use NULL.
cb_this_buffer_pointer = 1;
MAKE_VALUE_BUFFER(cb_this_buffer_pointer);
memset(this_buffer_pointer, 0, cb_this_buffer_pointer);
rc = FillSingleArray(this_buffer_pointer, val, seq_length, element_size, array_type&XPT_TDP_TAGMASK);

View File

@ -31,7 +31,9 @@
#include <prthread.h>
#ifdef XP_WIN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include "windows.h"
#endif

View File

@ -28,15 +28,17 @@
// (c) 2000, ActiveState corp.
#include "PyXPCOM_std.h"
#include "nsIFileSpec.h"
#include "nsSpecialSystemDirectory.h"
#include "nsIThread.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIModule.h"
#include "nsIFile.h"
#include "nsILocalFile.h"
#ifdef XP_WIN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include "windows.h"
#endif
@ -125,34 +127,6 @@ done:
// "boot-strap" methods - interfaces we need to get the base
// interface support!
static PyObject *
PyXPCOMMethod_NS_LocateSpecialSystemDirectory(PyObject *self, PyObject *args)
{
int typ;
if (!PyArg_ParseTuple(args, "i", &typ))
return NULL;
nsSpecialSystemDirectory systemDir((nsSpecialSystemDirectory::SystemDirectories)typ);
return PyString_FromString(systemDir.GetNativePathCString());
}
static PyObject *
PyXPCOMMethod_NS_NewFileSpec(PyObject *self, PyObject *args)
{
char *szspec = NULL;
if (!PyArg_ParseTuple(args, "|s", &szspec))
return NULL;
nsIFileSpec *spec = NULL;
nsresult nr;
Py_BEGIN_ALLOW_THREADS;
nr = NS_NewFileSpec(&spec);
if (NS_SUCCEEDED(nr) && spec && szspec)
nr = spec->SetNativePath(szspec);
Py_END_ALLOW_THREADS;
if (NS_FAILED(nr) || spec==nsnull)
return PyXPCOM_BuildPyException(nr);
return Py_nsISupports::PyObjectFromInterface(spec, NS_GET_IID(nsIFileSpec), PR_TRUE);
}
static PyObject *
PyXPCOMMethod_NS_GetGlobalComponentManager(PyObject *self, PyObject *args)
{
@ -434,9 +408,7 @@ extern PyObject *PyXPCOMMethod_IID(PyObject *self, PyObject *args);
static struct PyMethodDef xpcom_methods[]=
{
{"NS_LocateSpecialSystemDirectory", PyXPCOMMethod_NS_LocateSpecialSystemDirectory, 1},
{"NS_GetGlobalComponentManager", PyXPCOMMethod_NS_GetGlobalComponentManager, 1},
{"NS_NewFileSpec", PyXPCOMMethod_NS_NewFileSpec, 1},
{"XPTI_GetInterfaceInfoManager", PyXPCOMMethod_XPTI_GetInterfaceInfoManager, 1},
{"XPTC_InvokeByIndex", PyXPCOMMethod_XPTC_InvokeByIndex, 1},
{"GetGlobalServiceManager", PyXPCOMMethod_GetGlobalServiceManager, 1},
@ -488,7 +460,7 @@ PRBool PyXPCOM_Globals_Ensure()
// not already initialized.
// We need to locate the Mozilla bin directory.
#ifdef XP_WIN
#ifdef XP_WIN
// On Windows this by using "xpcom.dll"
char landmark[MAX_PATH+1];
@ -510,16 +482,11 @@ PRBool PyXPCOM_Globals_Ensure()
#else
// Elsewhere, Mozilla can find it itself (we hope!)
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
#endif // XP_WIN
#endif // XP_WIN
if (NS_FAILED(rv)) {
PyErr_SetString(PyExc_RuntimeError, "The XPCOM subsystem could not be initialized");
return PR_FALSE;
}
// Also set the "special directory"
#ifdef XP_WIN
nsFileSpec spec(landmark);
nsSpecialSystemDirectory::Set(nsSpecialSystemDirectory::OS_CurrentProcessDirectory, &spec);
#endif // XP_WIN
}
// Even if xpcom was already init, we want to flag it as init!
bHaveInitXPCOM = PR_TRUE;