diff --git a/dom/public/nsIDOMScriptObjectFactory.h b/dom/public/nsIDOMScriptObjectFactory.h index c1c9a5b7cfcd..2d6e78e30615 100644 --- a/dom/public/nsIDOMScriptObjectFactory.h +++ b/dom/public/nsIDOMScriptObjectFactory.h @@ -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} */ \ diff --git a/extensions/python/dom/src/Makefile.in b/extensions/python/dom/src/Makefile.in index 6f47a71625ff..f11c86b52aa7 100644 --- a/extensions/python/dom/src/Makefile.in +++ b/extensions/python/dom/src/Makefile.in @@ -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 diff --git a/extensions/python/dom/src/nsPyContext.cpp b/extensions/python/dom/src/nsPyContext.cpp index 20bd43f5caf7..2bb7df0c36ef 100644 --- a/extensions/python/dom/src/nsPyContext.cpp +++ b/extensions/python/dom/src/nsPyContext.cpp @@ -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); diff --git a/extensions/python/dom/src/nsPyDOMModule.cpp b/extensions/python/dom/src/nsPyDOMModule.cpp index ce5f8c0ddcb6..093298442c87 100644 --- a/extensions/python/dom/src/nsPyDOMModule.cpp +++ b/extensions/python/dom/src/nsPyDOMModule.cpp @@ -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 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 atomService = + do_GetService(NS_ATOMSERVICE_CONTRACTID, &rv); + if (NS_FAILED(rv)) + return PyXPCOM_BuildPyException(rv); + + nsCOMPtr 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 atom(do_GetAtom(nsDependentCString(name))); - if (!atom) return PyXPCOM_BuildPyException(NS_ERROR_UNEXPECTED); - nsresult rv; + nsCOMPtr atomService = + do_GetService(NS_ATOMSERVICE_CONTRACTID, &rv); + if (NS_FAILED(rv)) + return PyXPCOM_BuildPyException(rv); + + nsCOMPtr 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 atom(do_GetAtom(nsDependentCString(name))); - if (!atom) return PyXPCOM_BuildPyException(NS_ERROR_UNEXPECTED); - nsresult rv; + nsCOMPtr atomService = + do_GetService(NS_ATOMSERVICE_CONTRACTID, &rv); + if (NS_FAILED(rv)) + return PyXPCOM_BuildPyException(rv); + + nsCOMPtr 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, diff --git a/extensions/python/xpcom/src/ErrorUtils.cpp b/extensions/python/xpcom/src/ErrorUtils.cpp index 681500b4891f..2a1c948dd138 100644 --- a/extensions/python/xpcom/src/ErrorUtils.cpp +++ b/extensions/python/xpcom/src/ErrorUtils.cpp @@ -46,7 +46,7 @@ // (c) 2000, ActiveState corp. #include "PyXPCOM_std.h" -#include "nsReadableUtils.h" +#include "nsStringAPI.h" #include #include "nspr.h" // PR_fprintf diff --git a/extensions/python/xpcom/src/Makefile.in b/extensions/python/xpcom/src/Makefile.in index a8f7f71c4a9a..ee21549b3a88 100644 --- a/extensions/python/xpcom/src/Makefile.in +++ b/extensions/python/xpcom/src/Makefile.in @@ -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 diff --git a/extensions/python/xpcom/src/PyXPCOM.h b/extensions/python/xpcom/src/PyXPCOM.h index b9c616a69d8c..86397e1d2815 100644 --- a/extensions/python/xpcom/src/PyXPCOM.h +++ b/extensions/python/xpcom/src/PyXPCOM.h @@ -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 +// 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 diff --git a/extensions/python/xpcom/src/VariantUtils.cpp b/extensions/python/xpcom/src/VariantUtils.cpp index 7b7dd3e8f3b8..78ace0fb3323 100644 --- a/extensions/python/xpcom/src/VariantUtils.cpp +++ b/extensions/python/xpcom/src/VariantUtils.cpp @@ -49,10 +49,6 @@ // (c) 2000, ActiveState corp. #include "PyXPCOM_std.h" -#include -#include -#include -#include // ------------------------------------------------------------------------ // 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]; diff --git a/extensions/python/xpcom/src/dllmain.cpp b/extensions/python/xpcom/src/dllmain.cpp index d830aceca01c..b0446b9e19a8 100644 --- a/extensions/python/xpcom/src/dllmain.cpp +++ b/extensions/python/xpcom/src/dllmain.cpp @@ -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(); diff --git a/extensions/python/xpcom/src/loader/Makefile.in b/extensions/python/xpcom/src/loader/Makefile.in index 43a11b5f759a..943b3ca9de0c 100644 --- a/extensions/python/xpcom/src/loader/Makefile.in +++ b/extensions/python/xpcom/src/loader/Makefile.in @@ -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 diff --git a/extensions/python/xpcom/src/module/Makefile.in b/extensions/python/xpcom/src/module/Makefile.in index 9eac29266f53..c561815aec92 100644 --- a/extensions/python/xpcom/src/module/Makefile.in +++ b/extensions/python/xpcom/src/module/Makefile.in @@ -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) diff --git a/extensions/python/xpcom/src/module/_xpcom.cpp b/extensions/python/xpcom/src/module/_xpcom.cpp index 8f792ebacfe7..c2bbe969a209 100644 --- a/extensions/python/xpcom/src/module/_xpcom.cpp +++ b/extensions/python/xpcom/src/module/_xpcom.cpp @@ -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 file; if (NS_FAILED(NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(file)))) { // not already initialized. @@ -503,16 +504,7 @@ static PRBool EnsureXPCOM() nsCOMPtr 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!) diff --git a/widget/public/nsGUIEvent.h b/widget/public/nsGUIEvent.h index a265ee3b6d60..72f8d4b274d2 100644 --- a/widget/public/nsGUIEvent.h +++ b/widget/public/nsGUIEvent.h @@ -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