mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
[Bug 348426] Python extensions fail to build with libxul
r=benjamin@smedbergs.us, sr=jst
This commit is contained in:
parent
ec17457d23
commit
43a8cdaf19
@ -40,7 +40,7 @@
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID \
|
||||
{ /* {38EC7717-6CBE-44a8-B2BB-53F2BA998B31} */ \
|
||||
|
@ -1,4 +1,4 @@
|
||||
# todo - add license.
|
||||
# todo - add standard Mozilla license.
|
||||
|
||||
# The Python DOM ScriptLanguage implementation.
|
||||
|
||||
@ -15,18 +15,18 @@ IS_COMPONENT = 1
|
||||
REQUIRES = pyxpcom xpcom string xpcom_obsolete dom \
|
||||
widget js gfx gklayout content layout necko xpconnect $(NULL)
|
||||
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
LOCAL_INCLUDES = $(MOZ_PYTHON_INCLUDES)
|
||||
EXTRA_LIBS += $(MOZ_PYTHON_LIBS) $(MOZ_JS_LIBS)
|
||||
|
||||
ifeq ($(OS_ARCH), WINNT)
|
||||
EXTRA_LIBS += $(DIST)/lib/pyxpcom.lib
|
||||
else
|
||||
EXTRA_LIBS += -lpyxpcom
|
||||
endif
|
||||
# We always need the Python and pyxpcom includes and libs.
|
||||
LOCAL_INCLUDES = $(MOZ_PYTHON_INCLUDES)
|
||||
EXTRA_LIBS += $(MOZ_PYTHON_LIBS) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)pyxpcom.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
# In the shorter term we need JS too.
|
||||
EXTRA_LIBS += $(MOZ_JS_LIBS)
|
||||
|
||||
CPPSRCS = \
|
||||
nsPyArgArray.cpp \
|
||||
@ -39,9 +39,13 @@ CPPSRCS = \
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
CXXFLAGS += -DPYTHON_SO=\"libpython$(MOZ_PYTHON_VER_DOTTED).so\"
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
clobber::
|
||||
rm -f *.ilk
|
||||
|
@ -42,8 +42,9 @@
|
||||
#include "nsIArray.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "prtime.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringAPI.h"
|
||||
#include "nsGUIEvent.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsDOMScriptObjectHolder.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
@ -139,7 +140,7 @@ nsresult nsPythonContext::HandlePythonError()
|
||||
return NS_OK;
|
||||
|
||||
nsScriptErrorEvent errorevent(PR_TRUE, NS_LOAD_ERROR);
|
||||
nsAutoString strFilename;
|
||||
nsString strFilename;
|
||||
|
||||
PyObject *exc, *typ, *tb;
|
||||
PyErr_Fetch(&exc, &typ, &tb);
|
||||
@ -161,7 +162,7 @@ nsresult nsPythonContext::HandlePythonError()
|
||||
if (code) {
|
||||
PyObject *filename = PyObject_GetAttrString(code, "co_filename");
|
||||
if (filename && PyString_Check(filename)) {
|
||||
CopyUTF8toUTF16(PyString_AsString(filename), strFilename);
|
||||
CopyUTF8toUTF16(nsCString(PyString_AsString(filename)), strFilename);
|
||||
errorevent.fileName = strFilename.get();
|
||||
}
|
||||
Py_XDECREF(filename);
|
||||
|
@ -310,10 +310,18 @@ static PyObject *PyAddScriptEventListener(PyObject *self, PyObject *args)
|
||||
receiver->GetListenerManager(PR_TRUE, getter_AddRefs(manager));
|
||||
if (!manager) return PyXPCOM_BuildPyException(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIAtom> atom(do_GetAtom(nsDependentCString(name)));
|
||||
if (!atom) return PyXPCOM_BuildPyException(NS_ERROR_UNEXPECTED);
|
||||
|
||||
// avoid do_GetAtom - its not part of the XPCOM glue.
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAtomService> atomService =
|
||||
do_GetService(NS_ATOMSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return PyXPCOM_BuildPyException(rv);
|
||||
|
||||
nsCOMPtr<nsIAtom> atom;
|
||||
rv = atomService->GetAtomUTF8(name, getter_AddRefs(atom));
|
||||
if (NS_FAILED(rv))
|
||||
return PyXPCOM_BuildPyException(rv);
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
rv = manager->AddScriptEventListener(target, atom, body, lang, defer,
|
||||
untrusted);
|
||||
@ -373,10 +381,17 @@ static PyObject *PyRegisterScriptEventListener(PyObject *self, PyObject *args)
|
||||
receiver->GetListenerManager(PR_TRUE, getter_AddRefs(manager));
|
||||
if (!manager) return PyXPCOM_BuildPyException(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIAtom> atom(do_GetAtom(nsDependentCString(name)));
|
||||
if (!atom) return PyXPCOM_BuildPyException(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAtomService> atomService =
|
||||
do_GetService(NS_ATOMSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return PyXPCOM_BuildPyException(rv);
|
||||
|
||||
nsCOMPtr<nsIAtom> atom;
|
||||
rv = atomService->GetAtomUTF8(name, getter_AddRefs(atom));
|
||||
if (NS_FAILED(rv))
|
||||
return PyXPCOM_BuildPyException(rv);
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
rv = manager->RegisterScriptEventListener(scriptContext, obScope,
|
||||
target, atom);
|
||||
@ -437,10 +452,17 @@ static PyObject *PyCompileScriptEventListener(PyObject *self, PyObject *args)
|
||||
receiver->GetListenerManager(PR_TRUE, getter_AddRefs(manager));
|
||||
if (!manager) return PyXPCOM_BuildPyException(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsCOMPtr<nsIAtom> atom(do_GetAtom(nsDependentCString(name)));
|
||||
if (!atom) return PyXPCOM_BuildPyException(NS_ERROR_UNEXPECTED);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIAtomService> atomService =
|
||||
do_GetService(NS_ATOMSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return PyXPCOM_BuildPyException(rv);
|
||||
|
||||
nsCOMPtr<nsIAtom> atom;
|
||||
rv = atomService->GetAtomUTF8(name, getter_AddRefs(atom));
|
||||
if (NS_FAILED(rv))
|
||||
return PyXPCOM_BuildPyException(rv);
|
||||
|
||||
PRBool didCompile;
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
rv = manager->CompileScriptEventListener(scriptContext, obScope,
|
||||
|
@ -46,7 +46,7 @@
|
||||
// (c) 2000, ActiveState corp.
|
||||
|
||||
#include "PyXPCOM_std.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsStringAPI.h"
|
||||
#include <nsIConsoleService.h>
|
||||
#include "nspr.h" // PR_fprintf
|
||||
|
||||
|
@ -48,9 +48,7 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = pyxpcom
|
||||
LIBRARY_NAME = pyxpcom
|
||||
#MODULE_NAME =
|
||||
REQUIRES = xpcom string $(NULL)
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
@ -83,10 +81,14 @@ CPPSRCS= \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += -DPYTHON_SO=\"libpython$(MOZ_PYTHON_VER_DOTTED).so\"
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
clobber::
|
||||
rm -f *.ilk *.pdb *.exp *.lib *.pyd
|
||||
|
@ -59,8 +59,9 @@
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIVariant.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "xptcall.h"
|
||||
#include "xpt_xdr.h"
|
||||
@ -77,6 +78,8 @@
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
// PYXPCOM_EXPORT means 'exported from the pyxpcom core lib' - which changes
|
||||
// spelling depending on whether pyxpcom is being built or just referenced.
|
||||
#ifdef BUILD_PYXPCOM
|
||||
/* We are building the main dll */
|
||||
# define PYXPCOM_EXPORT NS_EXPORT
|
||||
|
@ -49,10 +49,6 @@
|
||||
// (c) 2000, ActiveState corp.
|
||||
|
||||
#include "PyXPCOM_std.h"
|
||||
#include <nsIInterfaceInfoManager.h>
|
||||
#include <nsAString.h>
|
||||
#include <nsString.h>
|
||||
#include <nsReadableUtils.h>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// nsString utilities
|
||||
@ -116,16 +112,15 @@ PyObject_FromNSString( const nsACString &s, PRBool bAssumeUTF8 /*= PR_FALSE */)
|
||||
Py_INCREF(Py_None);
|
||||
} else {
|
||||
if (bAssumeUTF8) {
|
||||
const nsPromiseFlatCString& temp = PromiseFlatCString(s);
|
||||
const nsCString temp(s);
|
||||
ret = PyUnicode_DecodeUTF8(temp.get(), temp.Length(), NULL);
|
||||
} else {
|
||||
ret = PyString_FromStringAndSize(NULL, s.Length());
|
||||
if (!ret)
|
||||
return NULL;
|
||||
// Need "CopyAsciiTo"!?
|
||||
nsACString::const_iterator fromBegin, fromEnd;
|
||||
char* dest = PyString_AS_STRING(ret);
|
||||
copy_string(s.BeginReading(fromBegin), s.EndReading(fromEnd), dest);
|
||||
PL_strncpy(dest, s.BeginReading(), s.Length());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -139,7 +134,7 @@ PyObject_FromNSString( const nsAString &s )
|
||||
ret = Py_None;
|
||||
Py_INCREF(Py_None);
|
||||
} else {
|
||||
const nsPromiseFlatString& temp = PromiseFlatString(s);
|
||||
const nsString temp(s);
|
||||
ret = PyUnicode_FromPRUnichar(temp.get(), temp.Length());
|
||||
}
|
||||
return ret;
|
||||
@ -988,13 +983,13 @@ PyXPCOM_InterfaceVariantHelper::~PyXPCOM_InterfaceVariantHelper()
|
||||
}
|
||||
}
|
||||
if (ns_v.IsValDOMString() && ns_v.val.p) {
|
||||
delete (const nsAString *)ns_v.val.p;
|
||||
delete (const nsString *)ns_v.val.p;
|
||||
}
|
||||
if (ns_v.IsValCString() && ns_v.val.p) {
|
||||
delete (const nsACString *)ns_v.val.p;
|
||||
delete (const nsCString *)ns_v.val.p;
|
||||
}
|
||||
if (ns_v.IsValUTF8String() && ns_v.val.p) {
|
||||
delete (const nsACString *)ns_v.val.p;
|
||||
delete (const nsCString *)ns_v.val.p;
|
||||
}
|
||||
if (ns_v.IsValArray()) {
|
||||
nsXPTCVariant &ns_v = m_var_array[i];
|
||||
|
@ -47,6 +47,7 @@
|
||||
|
||||
#include "PyXPCOM_std.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsITimelineService.h"
|
||||
|
||||
@ -131,7 +132,9 @@ void AddStandardPaths()
|
||||
Py_XDECREF(newStr);
|
||||
// And now try and get Python to process this directory as a "site dir"
|
||||
// - ie, look for .pth files, etc
|
||||
nsCAutoString cmdBuf(NS_LITERAL_CSTRING("import site;site.addsitedir(r'") + pathCBuf + NS_LITERAL_CSTRING("')\n"));
|
||||
nsCAutoString cmdBuf(NS_LITERAL_CSTRING("import site;site.addsitedir(r'"));
|
||||
cmdBuf.Append(pathCBuf);
|
||||
cmdBuf.Append(NS_LITERAL_CSTRING("')\n"));
|
||||
if (0 != PyRun_SimpleString((char *)cmdBuf.get())) {
|
||||
PyXPCOM_LogError("The directory '%s' could not be added as a site directory", pathCBuf.get());
|
||||
PyErr_Clear();
|
||||
|
@ -47,7 +47,6 @@ include $(DEPTH)/config/autoconf.mk
|
||||
LIBRARY_NAME = pyloader
|
||||
IS_COMPONENT = 1
|
||||
REQUIRES = pyxpcom xpcom string xpcom_obsolete $(NULL)
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
@ -68,8 +67,11 @@ CPPSRCS = \
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
|
||||
|
||||
clobber::
|
||||
rm -f *.ilk
|
||||
|
@ -47,7 +47,6 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = _xpcom$(MOZ_PYTHON_DEBUG_SUFFIX)
|
||||
REQUIRES = pyxpcom xpcom string $(NULL)
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
FORCE_USE_PIC = 1
|
||||
|
||||
@ -71,9 +70,14 @@ include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
# Don't use the EXTRA_DSO_LDOPTS from rules.mk, it breaks the python module
|
||||
EXTRA_DSO_LDOPTS = -bundle $(MOZ_COMPONENT_LIBS)
|
||||
EXTRA_DSO_LDOPTS = -bundle $(MOZ_COMPONENT_LIBS) \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(NULL)
|
||||
|
||||
else
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(NULL)
|
||||
endif
|
||||
IMPORT_LIBRARY := $(SHARED_LIBRARY:.pyd=.lib)
|
||||
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsTraceRefcntImpl.h"
|
||||
@ -475,10 +476,10 @@ static PRBool EnsureXPCOM()
|
||||
{
|
||||
static PRBool bHaveInitXPCOM = PR_FALSE;
|
||||
if (!bHaveInitXPCOM) {
|
||||
// xpcom appears to assert if already initialized
|
||||
// Is there an official way to determine this?
|
||||
// Been through lots of iterations - but getting the
|
||||
// app directories appears to work.
|
||||
// xpcom appears to assert if already initialized, but there
|
||||
// is no official way to determine this! Sadly though,
|
||||
// apparently this problem is not real ;) See bug 38671.
|
||||
// For now, getting the app directories appears to work.
|
||||
nsCOMPtr<nsIFile> file;
|
||||
if (NS_FAILED(NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(file)))) {
|
||||
// not already initialized.
|
||||
@ -503,16 +504,7 @@ static PRBool EnsureXPCOM()
|
||||
|
||||
nsCOMPtr<nsILocalFile> ns_bin_dir;
|
||||
NS_ConvertASCIItoUTF16 strLandmark(landmark);
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
// In an interesting chicken-and-egg problem, we
|
||||
// throw assertions in creating the nsILocalFile
|
||||
// we need to pass to InitXPCOM!
|
||||
nsTraceRefcntImpl::SetActivityIsLegal(PR_TRUE);
|
||||
#endif
|
||||
NS_NewLocalFile(strLandmark, PR_FALSE, getter_AddRefs(ns_bin_dir));
|
||||
#ifdef NS_BUILD_REFCNT_LOGGING
|
||||
nsTraceRefcntImpl::SetActivityIsLegal(PR_FALSE);
|
||||
#endif
|
||||
nsresult rv = NS_InitXPCOM2(nsnull, ns_bin_dir, nsnull);
|
||||
#else
|
||||
// Elsewhere, Mozilla can find it itself (we hope!)
|
||||
|
@ -43,8 +43,7 @@
|
||||
#include "nsPoint.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsEvent.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
// nsIDOMEvent contains a long enum which includes a member called ERROR,
|
||||
// which conflicts with something that Windows defines somewhere.
|
||||
@ -63,6 +62,7 @@ class nsIAccessible;
|
||||
class nsIContent;
|
||||
class nsIURI;
|
||||
class nsIDOMEvent;
|
||||
class nsHashKey;
|
||||
|
||||
/**
|
||||
* Event Struct Types
|
||||
|
Loading…
Reference in New Issue
Block a user