Bug 397929 - Windows macro names kill kittens, maim babies, and introduce naming conflicts. Add an XPIDL annotation allowing the C++ method name for a method in an interface to either not be the method name, capitalized, or to not be [GS]et plus the attribute name, capitalized. This patch makes window.postMessage happy as PostMessageMoz; other APIs will need followup checkins. r=bsmedberg, a=schrep

This commit is contained in:
jwalden@mit.edu 2008-02-07 12:53:19 -08:00
Родитель 84079ff4e0
Коммит 4751b5362a
4 изменённых файлов: 22 добавлений и 24 удалений

Просмотреть файл

@ -44,13 +44,6 @@ interface nsIControllers;
interface nsIDOMLocation;
interface nsIVariant;
%{C++
/* I hate you, Windows. */
#ifdef PostMessage
#undef PostMessage
#endif
%}
[scriptable, uuid(86f7b733-aff9-469a-9e8c-2996f7db2720)]
interface nsIDOMWindowInternal : nsIDOMWindow2
{
@ -221,5 +214,5 @@ interface nsIDOMWindowInternal : nsIDOMWindow2
*
* See the WHATWG HTML5 specification, section 6.4, for more details.
*/
void postMessage(in DOMString message);
[binaryname(PostMessageMoz)] void postMessage(in DOMString message);
};

Просмотреть файл

@ -5046,15 +5046,10 @@ nsGlobalWindow::CallerInnerWindow()
return static_cast<nsGlobalWindow*>(win.get());
}
/* I hate you, Windows. */
#ifdef PostMessage
#undef PostMessage
#endif
NS_IMETHODIMP
nsGlobalWindow::PostMessage(const nsAString& aMessage)
nsGlobalWindow::PostMessageMoz(const nsAString& aMessage)
{
FORWARD_TO_INNER_CREATE(PostMessage, (aMessage));
FORWARD_TO_INNER_CREATE(PostMessageMoz, (aMessage));
//
// Window.postMessage is an intentional subversion of the same-origin policy.

Просмотреть файл

@ -98,11 +98,6 @@
#include "nsPIDOMEventTarget.h"
#include "nsIArray.h"
/* I hate you, Windows. */
#ifdef PostMessage
#undef PostMessage
#endif
#define DEFAULT_HOME_PAGE "www.mozilla.org"
#define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"

Просмотреть файл

@ -733,6 +733,7 @@ write_type(IDL_tree type_tree, gboolean is_out, FILE *outfile)
#define ATTR_IDENT(tree) (IDL_IDENT(IDL_LIST(IDL_ATTR_DCL(tree).simple_declarations).data))
#define ATTR_TYPE_DECL(tree) (IDL_ATTR_DCL(tree).param_type_spec)
#define ATTR_TYPE(tree) (IDL_NODE_TYPE(ATTR_TYPE_DECL(tree)))
#define ATTR_DECLS(tree) (IDL_LIST(IDL_ATTR_DCL(tree).simple_declarations).data)
/*
* AS_DECL writes 'NS_IMETHOD foo(string bar, long sil)'
@ -744,15 +745,24 @@ write_attr_accessor(IDL_tree attr_tree, FILE * outfile,
gboolean getter, int mode, const char *className)
{
char *attrname = ATTR_IDENT(attr_tree).str;
const char *binaryname;
if (mode == AS_DECL) {
fputs("NS_IMETHOD ", outfile);
} else if (mode == AS_IMPL) {
fprintf(outfile, "NS_IMETHODIMP %s::", className);
}
fprintf(outfile, "%cet%c%s(",
getter ? 'G' : 'S',
toupper(*attrname), attrname + 1);
fprintf(outfile, "%cet",
getter ? 'G' : 'S');
binaryname = IDL_tree_property_get(ATTR_DECLS(attr_tree), "binaryname");
if (binaryname) {
fprintf(outfile, "%s(",
binaryname);
} else {
fprintf(outfile, "%c%s(",
toupper(*attrname),
attrname + 1);
}
if (mode == AS_DECL || mode == AS_IMPL) {
/* Setters for string, wstring, nsid, domstring, utf8string,
* cstring and astring get const.
@ -1009,6 +1019,7 @@ write_method_signature(IDL_tree method_tree, FILE *outfile, int mode,
gboolean op_notxpcom =
(IDL_tree_property_get(op->ident, "notxpcom") != NULL);
const char *name;
const char *binaryname;
IDL_tree iter;
if (mode == AS_DECL) {
@ -1035,7 +1046,11 @@ write_method_signature(IDL_tree method_tree, FILE *outfile, int mode,
}
name = IDL_IDENT(op->ident).str;
if (mode == AS_IMPL) {
fprintf(outfile, "%s::%c%s(", className, toupper(*name), name + 1);
fprintf(outfile, "%s::", className);
}
binaryname = IDL_tree_property_get(op->ident, "binaryname");
if (binaryname) {
fprintf(outfile, "%s(", binaryname);
} else {
fprintf(outfile, "%c%s(", toupper(*name), name + 1);
}