From 426652868084fe94c4a8aa37507f029842b36430 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Mon, 30 Jun 2014 16:02:04 -0700 Subject: [PATCH] Bug 1031051: Part 18 - Kill the old XPIDL-based event generator. r=smaug --- content/base/src/WebSocket.cpp | 1 - content/base/src/nsDocument.cpp | 1 - content/media/MediaRecorder.cpp | 1 - .../recognition/SpeechRecognition.cpp | 1 - .../xml/document/src/nsXMLPrettyPrinter.cpp | 1 - dom/base/nsGlobalWindow.cpp | 2 - dom/cellbroadcast/src/CellBroadcast.cpp | 1 - dom/devicestorage/nsDeviceStorage.cpp | 1 - dom/events/EventDispatcher.cpp | 1 - dom/gamepad/GamepadService.cpp | 1 - dom/icc/src/IccManager.cpp | 1 - dom/mobileconnection/src/MobileConnection.cpp | 1 - dom/src/storage/DOMStorage.cpp | 1 - dom/system/nsDeviceSensors.cpp | 1 - dom/voicemail/Voicemail.cpp | 1 - js/xpconnect/src/Makefile.in | 53 +- js/xpconnect/src/event_impl_gen.conf.in | 34 - js/xpconnect/src/event_impl_gen.py | 740 ------------------ js/xpconnect/src/moz.build | 3 - security/manager/ssl/src/nsNSSComponent.cpp | 1 - 20 files changed, 1 insertion(+), 846 deletions(-) delete mode 100644 js/xpconnect/src/event_impl_gen.conf.in delete mode 100755 js/xpconnect/src/event_impl_gen.py diff --git a/content/base/src/WebSocket.cpp b/content/base/src/WebSocket.cpp index 2101493984fb..f1f4c3c2629c 100644 --- a/content/base/src/WebSocket.cpp +++ b/content/base/src/WebSocket.cpp @@ -42,7 +42,6 @@ #include "nsWrapperCacheInlines.h" #include "nsIObserverService.h" #include "nsIWebSocketChannel.h" -#include "GeneratedEvents.h" namespace mozilla { namespace dom { diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index fc112866df05..007a0d3e089a 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -181,7 +181,6 @@ #include "nsXULAppAPI.h" #include "mozilla/dom/Touch.h" #include "mozilla/dom/TouchEvent.h" -#include "GeneratedEvents.h" #include "mozilla/Preferences.h" diff --git a/content/media/MediaRecorder.cpp b/content/media/MediaRecorder.cpp index 0cd4bfde55a5..85d8c3889389 100644 --- a/content/media/MediaRecorder.cpp +++ b/content/media/MediaRecorder.cpp @@ -5,7 +5,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "MediaRecorder.h" -#include "GeneratedEvents.h" #include "MediaEncoder.h" #include "mozilla/DOMEventTargetHelper.h" #include "nsError.h" diff --git a/content/media/webspeech/recognition/SpeechRecognition.cpp b/content/media/webspeech/recognition/SpeechRecognition.cpp index 414f69932b7d..ba65471eb698 100644 --- a/content/media/webspeech/recognition/SpeechRecognition.cpp +++ b/content/media/webspeech/recognition/SpeechRecognition.cpp @@ -17,7 +17,6 @@ #include "AudioSegment.h" #include "endpointer.h" -#include "GeneratedEvents.h" #include "mozilla/dom/SpeechRecognitionEvent.h" #include "nsIObserverService.h" #include "nsServiceManagerUtils.h" diff --git a/content/xml/document/src/nsXMLPrettyPrinter.cpp b/content/xml/document/src/nsXMLPrettyPrinter.cpp index aacb26e404a9..682a2d00c80f 100644 --- a/content/xml/document/src/nsXMLPrettyPrinter.cpp +++ b/content/xml/document/src/nsXMLPrettyPrinter.cpp @@ -24,7 +24,6 @@ #include "nsIDocument.h" #include "nsVariant.h" #include "nsIDOMCustomEvent.h" -#include "GeneratedEvents.h" using namespace mozilla; using namespace mozilla::dom; diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 53b01d088826..868dce3b88b5 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -176,8 +176,6 @@ #include "nsFrameLoader.h" #include "nsISupportsPrimitives.h" #include "nsXPCOMCID.h" -#include "GeneratedEvents.h" -#include "GeneratedEventClasses.h" #include "mozIThirdPartyUtil.h" #ifdef MOZ_LOGGING // so we can get logging even in release builds diff --git a/dom/cellbroadcast/src/CellBroadcast.cpp b/dom/cellbroadcast/src/CellBroadcast.cpp index 670ef0e54446..4afa19656a1a 100644 --- a/dom/cellbroadcast/src/CellBroadcast.cpp +++ b/dom/cellbroadcast/src/CellBroadcast.cpp @@ -8,7 +8,6 @@ #include "mozilla/dom/MozCellBroadcastEvent.h" #include "nsIDOMMozCellBroadcastMessage.h" #include "nsServiceManagerUtils.h" -#include "GeneratedEvents.h" #define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1" diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index 5edd454df4be..77a2508003fd 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -50,7 +50,6 @@ #include "DeviceStorageRequestChild.h" #include "nsCRT.h" #include "nsIObserverService.h" -#include "GeneratedEvents.h" #include "nsIMIMEService.h" #include "nsCExternalHandlerService.h" #include "nsIPermissionManager.h" diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp index 5160fc456509..d3087bb9ab6b 100644 --- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -13,7 +13,6 @@ #include "nsINode.h" #include "nsPIDOMWindow.h" #include "GeckoProfiler.h" -#include "GeneratedEvents.h" #include "mozilla/ContentEvents.h" #include "mozilla/dom/CloseEvent.h" #include "mozilla/dom/DeviceOrientationEvent.h" diff --git a/dom/gamepad/GamepadService.cpp b/dom/gamepad/GamepadService.cpp index bb32cd06be2c..236c9b641bf7 100644 --- a/dom/gamepad/GamepadService.cpp +++ b/dom/gamepad/GamepadService.cpp @@ -12,7 +12,6 @@ #include "nsAutoPtr.h" #include "nsIDOMEvent.h" #include "nsIDOMDocument.h" -#include "GeneratedEvents.h" #include "nsIDOMWindow.h" #include "nsIObserver.h" #include "nsIObserverService.h" diff --git a/dom/icc/src/IccManager.cpp b/dom/icc/src/IccManager.cpp index 618c46ddab83..dcc35c563395 100644 --- a/dom/icc/src/IccManager.cpp +++ b/dom/icc/src/IccManager.cpp @@ -4,7 +4,6 @@ #include "IccManager.h" #include "mozilla/dom/MozIccManagerBinding.h" -#include "GeneratedEvents.h" #include "Icc.h" #include "IccListener.h" #include "mozilla/dom/IccChangeEvent.h" diff --git a/dom/mobileconnection/src/MobileConnection.cpp b/dom/mobileconnection/src/MobileConnection.cpp index 316a051164f7..85f9a73a8701 100644 --- a/dom/mobileconnection/src/MobileConnection.cpp +++ b/dom/mobileconnection/src/MobileConnection.cpp @@ -4,7 +4,6 @@ #include "MobileConnection.h" -#include "GeneratedEvents.h" #include "mozilla/dom/CFStateChangeEvent.h" #include "mozilla/dom/DataErrorEvent.h" #include "mozilla/dom/MozClirModeEvent.h" diff --git a/dom/src/storage/DOMStorage.cpp b/dom/src/storage/DOMStorage.cpp index 886685be5fcc..2c468e844e0e 100644 --- a/dom/src/storage/DOMStorage.cpp +++ b/dom/src/storage/DOMStorage.cpp @@ -17,7 +17,6 @@ #include "nsDOMClassInfoID.h" #include "mozilla/Services.h" #include "mozilla/Preferences.h" -#include "GeneratedEvents.h" #include "nsThreadUtils.h" #include "nsContentUtils.h" #include "nsServiceManagerUtils.h" diff --git a/dom/system/nsDeviceSensors.cpp b/dom/system/nsDeviceSensors.cpp index b928df4032fa..41f545595220 100644 --- a/dom/system/nsDeviceSensors.cpp +++ b/dom/system/nsDeviceSensors.cpp @@ -14,7 +14,6 @@ #include "nsIDOMDocument.h" #include "nsIServiceManager.h" #include "nsIServiceManager.h" -#include "GeneratedEvents.h" #include "mozilla/Preferences.h" #include "mozilla/Attributes.h" #include "mozilla/Services.h" diff --git a/dom/voicemail/Voicemail.cpp b/dom/voicemail/Voicemail.cpp index be72b446401b..7ac893929b8a 100644 --- a/dom/voicemail/Voicemail.cpp +++ b/dom/voicemail/Voicemail.cpp @@ -14,7 +14,6 @@ #include "mozilla/Services.h" #include "nsDOMClassInfo.h" #include "nsServiceManagerUtils.h" -#include "GeneratedEvents.h" #define NS_RILCONTENTHELPER_CONTRACTID "@mozilla.org/ril/content-helper;1" const char* kPrefRilNumRadioInterfaces = "ril.numRadioInterfaces"; diff --git a/js/xpconnect/src/Makefile.in b/js/xpconnect/src/Makefile.in index 8db3bd5650bf..259c46acb16f 100644 --- a/js/xpconnect/src/Makefile.in +++ b/js/xpconnect/src/Makefile.in @@ -3,15 +3,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -EXTRA_MDDEPEND_FILES = dom_qsgen.pp event_impl_gen.pp - -INSTALL_TARGETS += extra_export_files -extra_export_files_FILES := \ - GeneratedEventClasses.h \ - GeneratedEvents.h \ - $(NULL) -extra_export_files_DEST = $(DIST)/include -extra_export_files_TARGET := export +EXTRA_MDDEPEND_FILES = dom_qsgen.pp include $(topsrcdir)/config/rules.mk @@ -32,52 +24,9 @@ dom_quickstubs.cpp: $(srcdir)/dom_quickstubs.qsconf \ $(ENABLE_TRACEABLE_FLAGS) \ $(srcdir)/dom_quickstubs.qsconf -event_impl_gen.conf : $(srcdir)/event_impl_gen.conf.in - $(call py_action,preprocessor,$(DEFINES) $(ACDEFINES) $^ -o event_impl_gen.conf) - -GeneratedEvents.h: event_impl_gen.conf \ - $(srcdir)/event_impl_gen.py \ - $(LIBXUL_DIST)/sdk/bin/header.py \ - $(LIBXUL_DIST)/sdk/bin/xpidl.py - $(PYTHON) $(topsrcdir)/config/pythonpath.py \ - $(PLY_INCLUDE) \ - -I$(LIBXUL_DIST)/sdk/bin \ - $(srcdir)/event_impl_gen.py \ - -I $(DEPTH)/dist/idl \ - --header-output GeneratedEvents.h \ - event_impl_gen.conf - -GeneratedEventClasses.h: GeneratedEvents.cpp - -GeneratedEvents.cpp: GeneratedEvents.h \ - event_impl_gen.conf \ - $(srcdir)/event_impl_gen.py \ - $(LIBXUL_DIST)/sdk/bin/header.py \ - $(LIBXUL_DIST)/sdk/bin/xpidl.py - $(PYTHON) $(topsrcdir)/config/pythonpath.py \ - $(PLY_INCLUDE) \ - -I$(LIBXUL_DIST)/sdk/bin \ - $(srcdir)/event_impl_gen.py \ - -I $(DEPTH)/dist/idl \ - --class-declarations GeneratedEventClasses.h \ - --stub-output GeneratedEvents.cpp \ - --makedepend-output $(MDDEPDIR)/event_impl_gen.pp \ - event_impl_gen.conf - -GeneratedEvents-webidl: event_impl_gen.conf - $(PYTHON) $(topsrcdir)/config/pythonpath.py \ - $(PLY_INCLUDE) \ - -I$(LIBXUL_DIST)/sdk/bin \ - $(srcdir)/event_impl_gen.py \ - -I $(DEPTH)/dist/idl \ - --webidltarget=$(top_srcdir)/dom/webidl \ - event_impl_gen.conf - GARBAGE += \ - event_impl_gen.conf \ xpidl_debug \ $(MDDEPDIR)/dom_qsgen.pp \ $(MDDEPDIR)/dombindingsgen.pp \ - $(MDDEPDIR)/event_impl_gen.pp \ $(wildcard $(topsrcdir)/other-licenses/ply/ply/*.pyc) \ $(NULL) diff --git a/js/xpconnect/src/event_impl_gen.conf.in b/js/xpconnect/src/event_impl_gen.conf.in deleted file mode 100644 index 12c1073ad4f5..000000000000 --- a/js/xpconnect/src/event_impl_gen.conf.in +++ /dev/null @@ -1,34 +0,0 @@ -""" -*- Mode: Python -*- - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - - The name of the event which real interface should have nsIDOM-prefix, - and should be in nsIDOM.idl file and which should have - Init dictionary for the event constructor. """ - -simple_events = [ - ] - -""" include file names """ -special_includes = [ - 'nsContentUtils.h', - 'nsIDOMApplicationRegistry.h', - 'nsIDOMFile.h' - ] - -""" name of the type to not include using #include "typename.h" """ -exclude_automatic_type_include = [ - 'nsISupports', - 'mozIDOMApplication', - 'nsIDOMBlob' - ] - -""" Map xpidl interface names to implementation classes. The third column is the canonical interface. """ -xpidl_to_native = [ - ['nsIDOMDocument', 'nsIDocument', 'nsIDocument'], - ['nsIDOMElement', 'mozilla::dom::Element', 'mozilla::dom::Element'], - ['nsIDOMCSSStyleSheet', 'mozilla::CSSStyleSheet', 'nsIStyleSheet'], - ['nsIDOMWindow', 'nsGlobalWindow', 'nsIDOMEventTarget'] - ] - diff --git a/js/xpconnect/src/event_impl_gen.py b/js/xpconnect/src/event_impl_gen.py deleted file mode 100755 index d8176dd2ae88..000000000000 --- a/js/xpconnect/src/event_impl_gen.py +++ /dev/null @@ -1,740 +0,0 @@ -#!/usr/bin/env python -# header.py - Generate C++ header files from IDL. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -import sys, os, xpidl, makeutils - -def strip_end(text, suffix): - if not text.endswith(suffix): - return text - return text[:-len(suffix)] - -def findIDL(includePath, interfaceFileName): - for d in includePath: - # Not os.path.join: we need a forward slash even on Windows because - # this filename ends up in makedepend output. - path = d + '/' + interfaceFileName - if os.path.exists(path): - return path - raise BaseException("No IDL file found for interface %s " - "in include path %r" - % (interfaceFileName, includePath)) - -eventFileNameToIdl = {}; - -def loadIDL(parser, includePath, filename): - global eventFileNameToIdl - if filename in eventFileNameToIdl: - return eventFileNameToIdl[filename] - - idlFile = findIDL(includePath, filename) - if not idlFile in makeutils.dependencies: - makeutils.dependencies.append(idlFile) - idl = p.parse(open(idlFile).read(), idlFile) - idl.resolve(includePath, p) - eventFileNameToIdl[filename] = idl - return idl - -def loadEventIDL(parser, includePath, eventname): - eventidl = ("nsIDOM%s.idl" % eventname) - return loadIDL(parser, includePath, eventidl) - -class Configuration: - def __init__(self, filename): - config = {} - execfile(filename, config) - self.simple_events = config.get('simple_events', []) - self.special_includes = config.get('special_includes', []) - self.exclude_automatic_type_include = config.get('exclude_automatic_type_include', []) - self.xpidl_to_native = config.get('xpidl_to_native', []) - -def readConfigFile(filename): - return Configuration(filename) - -def firstCap(str): - return str[0].upper() + str[1:] - -def getBaseName(iface): - return ("%s" % iface.base[6:]) - -def print_header_file(fd, conf): - fd.write("#ifndef _gen_mozilla_idl_generated_events_h_\n" - "#define _gen_mozilla_idl_generated_events_h_\n\n") - fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n") - fd.write("#include \"nscore.h\"\n") - fd.write("class nsIDOMEvent;\n") - fd.write("class nsPresContext;\n") - fd.write("namespace mozilla {\n"); - fd.write("class WidgetEvent;\n") - fd.write("namespace dom {\n"); - fd.write("class EventTarget;\n") - fd.write("}\n"); - fd.write("}\n\n"); - for e in conf.simple_events: - fd.write("nsresult\n") - fd.write("NS_NewDOM%s(nsIDOMEvent** aInstance, " % e) - fd.write("mozilla::dom::EventTarget* aOwner, ") - fd.write("nsPresContext* aPresContext, mozilla::WidgetEvent* aEvent);\n") - - fd.write("\n#endif\n") - -def print_classes_file(fd, conf): - fd.write("#ifndef _gen_mozilla_idl_generated_event_declarations_h_\n") - fd.write("#define _gen_mozilla_idl_generated_event_declarations_h_\n\n") - - fd.write("#include \"mozilla/dom/Event.h\"\n"); - includes = [] - for s in conf.special_includes: - if not s in includes: - includes.append(strip_end(s, ".h")) - - for e in conf.simple_events: - if not e in includes: - includes.append(("nsIDOM%s" % e)) - - attrnames = [] - for e in conf.simple_events: - idl = loadEventIDL(p, options.incdirs, e) - collect_names_and_non_primitive_attribute_types(idl, attrnames, includes) - - for c in includes: - if not c in conf.exclude_automatic_type_include: - fd.write("#include \"%s.h\"\n" % c) - - for e in conf.simple_events: - fd.write('#include "mozilla/dom/%sBinding.h"\n' % e); - - fd.write("namespace mozilla {\n") - fd.write("namespace dom {\n") - for e in conf.simple_events: - idl = loadEventIDL(p, options.incdirs, e) - for pr in idl.productions: - if pr.kind == 'interface': - print_class_declaration(e, pr, fd, conf) - fd.write("} // namespace dom\n") - fd.write("} // namespace mozilla\n\n") - fd.write("#endif\n"); - -def print_class_declaration(eventname, iface, fd, conf): - classname = ("%s" % eventname) - basename = getBaseName(iface) - attributes = [] - ccattributes = [] - for member in iface.members: - if isinstance(member, xpidl.Attribute): - attributes.append(member) - if (member.realtype.nativeType('in').endswith('*')): - ccattributes.append(member); - - baseinterfaces = [] - baseiface = iface.idl.getName(iface.base, iface.location) - while baseiface.name != "nsIDOMEvent": - baseinterfaces.append(baseiface) - baseiface = baseiface.idl.getName(baseiface.base, baseiface.location) - baseinterfaces.reverse() - - allattributes = [] - for baseiface in baseinterfaces: - for member in baseiface.members: - if isinstance(member, xpidl.Attribute): - allattributes.append(member) - allattributes.extend(attributes); - - fd.write("\nclass %s MOZ_FINAL : public %s, public %s\n" % (classname, basename, iface.name)) - fd.write("{\n") - fd.write("public:\n") - fd.write(" %s(mozilla::dom::EventTarget* aOwner, " % classname) - fd.write("nsPresContext* aPresContext = nullptr, mozilla::WidgetEvent* aEvent = nullptr);\n"); - fd.write(" virtual ~%s();\n\n" % classname) - fd.write(" NS_DECL_ISUPPORTS_INHERITED\n") - fd.write(" NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(%s, %s)\n" % (classname, basename)) - fd.write(" NS_FORWARD_TO_EVENT\n") - - for baseiface in baseinterfaces: - baseimpl = ("%s" % baseiface.name[6:]) - fd.write(" NS_FORWARD_%s(%s::)\n" % (baseiface.name.upper(), baseimpl)) - - fd.write(" NS_DECL_%s\n" % iface.name.upper()) - - hasVariant = False - for a in allattributes: - if a.type == "nsIVariant": - hasVariant = True - break; - fd.write(" static already_AddRefed<%s> Constructor(const GlobalObject& aGlobal, " % eventname) - fd.write("const nsAString& aType, ") - fd.write("const %sInit& aParam, " % eventname) - fd.write("ErrorResult& aRv);\n\n") - - fd.write(" virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE\n") - fd.write(" {\n") - fd.write(" return mozilla::dom::%sBinding::Wrap(aCx, this);\n" % eventname) - fd.write(" }\n\n") - - for a in attributes: - """xpidl methods take care of string member variables!""" - firstCapName = firstCap(a.name) - cleanNativeType = a.realtype.nativeType('in').strip('* ') - if a.realtype.nativeType('in').count("nsAString"): - continue - elif a.realtype.nativeType('in').count("nsIVariant"): - fd.write(" void Get%s(JSContext* aCx, JS::MutableHandle aRetval, ErrorResult& aRv);\n\n" % firstCapName); - elif a.realtype.nativeType('in').endswith('*'): - fd.write(" already_AddRefed<%s> Get%s()\n" % (xpidl_to_native(cleanNativeType, conf), firstCapName)) - fd.write(" {\n"); - fd.write(" nsCOMPtr<%s> %s = do_QueryInterface(m%s);\n" % (xpidl_to_canonical(cleanNativeType, conf), a.name, firstCapName)) - fd.write(" return %s.forget().downcast<%s>();\n" % (a.name, xpidl_to_native(cleanNativeType, conf))) - fd.write(" }\n\n"); - else: - fd.write(" %s %s()\n" % (cleanNativeType, firstCapName)) - fd.write(" {\n"); - fd.write(" return m%s;\n" % firstCapName) - fd.write(" }\n\n"); - - fd.write(" void ") - fd.write("Init%s(" % eventname) - if hasVariant: - fd.write("JSContext* aCx, ") - fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable") - for a in allattributes: - writeNativeAttributeParams(fd, a, conf) - fd.write(", ErrorResult& aRv);\n\n") - - fd.write("protected:\n") - for a in attributes: - fd.write(" %s\n" % attributeVariableTypeAndName(a)) - fd.write("};\n") - -def collect_names_and_non_primitive_attribute_types(idl, attrnames, forwards): - for p in idl.productions: - if p.kind == 'interface' or p.kind == 'dictionary': - interfaces = [] - base = p.base - baseiface = p - while base is not None: - baseiface = baseiface.idl.getName(baseiface.base, baseiface.location) - interfaces.append(baseiface) - base = baseiface.base - - interfaces.reverse() - interfaces.append(p) - - for iface in interfaces: - collect_names_and_non_primitive_attribute_types_from_interface(iface, attrnames, forwards) - -def collect_names_and_non_primitive_attribute_types_from_interface(iface, attrnames, forwards): - for member in iface.members: - if isinstance(member, xpidl.Attribute): - if not member.name in attrnames: - attrnames.append(member.name) - if member.realtype.nativeType('in').endswith('*'): - t = member.realtype.nativeType('in').strip('* ') - if not t in forwards: - forwards.append(t) - -def print_cpp(idl, fd, conf, eventname): - for p in idl.productions: - if p.kind == 'interface': - write_cpp(eventname, p, fd, conf) - -def print_cpp_file(fd, conf): - fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n") - fd.write('#include "GeneratedEventClasses.h"\n') - fd.write('#include "xpcprivate.h"\n'); - fd.write('#include "mozilla/dom/Event.h"\n'); - fd.write('#include "mozilla/dom/EventTarget.h"\n'); - - for e in conf.simple_events: - idl = loadEventIDL(p, options.incdirs, e) - print_cpp(idl, fd, conf, e) - -def init_value(attribute): - realtype = attribute.realtype.nativeType('in') - realtype = realtype.strip(' ') - if realtype.endswith('*'): - return "nullptr" - if realtype == "bool": - return "false" - if realtype.count("nsAString"): - return "" - if realtype.count("nsACString"): - return "" - if realtype.count("JS::Value"): - raise BaseException("JS::Value not supported in simple events!") - return "0" - -def attributeVariableTypeAndName(a): - if a.realtype.nativeType('in').endswith('*'): - l = ["nsCOMPtr<%s> m%s;" % (a.realtype.nativeType('in').strip('* '), - firstCap(a.name))] - elif a.realtype.nativeType('in').count("nsAString"): - l = ["nsString m%s;" % firstCap(a.name)] - elif a.realtype.nativeType('in').count("nsACString"): - l = ["nsCString m%s;" % firstCap(a.name)] - else: - l = ["%sm%s;" % (a.realtype.nativeType('in'), - firstCap(a.name))] - return ", ".join(l) - -def writeAttributeGetter(fd, classname, a): - fd.write("NS_IMETHODIMP\n") - fd.write("%s::Get%s(" % (classname, firstCap(a.name))) - if a.realtype.nativeType('in').endswith('*'): - fd.write("%s** a%s" % (a.realtype.nativeType('in').strip('* '), firstCap(a.name))) - elif a.realtype.nativeType('in').count("nsAString"): - fd.write("nsAString& a%s" % firstCap(a.name)) - elif a.realtype.nativeType('in').count("nsACString"): - fd.write("nsACString& a%s" % firstCap(a.name)) - else: - fd.write("%s*a%s" % (a.realtype.nativeType('in'), firstCap(a.name))) - fd.write(")\n"); - fd.write("{\n"); - if a.realtype.nativeType('in').endswith('*'): - fd.write(" NS_IF_ADDREF(*a%s = m%s);\n" % (firstCap(a.name), firstCap(a.name))) - elif a.realtype.nativeType('in').count("nsAString"): - fd.write(" a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name))) - elif a.realtype.nativeType('in').count("nsACString"): - fd.write(" a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name))) - else: - fd.write(" *a%s = %s();\n" % (firstCap(a.name), firstCap(a.name))) - fd.write(" return NS_OK;\n"); - fd.write("}\n\n"); - if a.realtype.nativeType('in').count("nsIVariant"): - fd.write("void\n") - fd.write("%s::Get%s(JSContext* aCx, JS::MutableHandle aRetval, ErrorResult& aRv)\n" % (classname, firstCap(a.name))) - fd.write("{\n") - fd.write(" nsresult rv = NS_ERROR_UNEXPECTED;\n") - fd.write(" if (!m%s) {\n" % firstCap(a.name)) - fd.write(" aRetval.setNull();\n") - fd.write(" } else if (!XPCVariant::VariantDataToJS(m%s, &rv, aRetval)) {\n" % (firstCap(a.name))) - fd.write(" aRv.Throw(NS_ERROR_FAILURE);\n") - fd.write(" }\n") - fd.write("}\n\n") - -def writeAttributeParams(fd, a): - if a.realtype.nativeType('in').endswith('*'): - fd.write(", %s* a%s" % (a.realtype.nativeType('in').strip('* '), firstCap(a.name))) - elif a.realtype.nativeType('in').count("nsAString"): - fd.write(", const nsAString& a%s" % firstCap(a.name)) - elif a.realtype.nativeType('in').count("nsACString"): - fd.write(", const nsACString& a%s" % firstCap(a.name)) - else: - fd.write(", %s a%s" % (a.realtype.nativeType('in'), firstCap(a.name))) - -def writeNativeAttributeParams(fd, a, conf): - if a.type == "nsIVariant": - fd.write(", JS::Value a%s" % firstCap(a.name)); - elif a.realtype.nativeType('in').endswith('*'): - fd.write(", %s* a%s" % (xpidl_to_native(a.realtype.nativeType('in').strip('* '), conf), firstCap(a.name))) - elif a.realtype.nativeType('in').count("nsAString"): - fd.write(", const nsAString& a%s" % firstCap(a.name)) - elif a.realtype.nativeType('in').count("nsACString"): - fd.write(", const nsACString& a%s" % firstCap(a.name)) - else: - fd.write(", %s a%s" % (a.realtype.nativeType('in'), firstCap(a.name))) - -def write_cpp(eventname, iface, fd, conf): - classname = ("%s" % eventname) - basename = getBaseName(iface) - attributes = [] - ccattributes = [] - for member in iface.members: - if isinstance(member, xpidl.Attribute): - attributes.append(member) - if (member.realtype.nativeType('in').endswith('*')): - ccattributes.append(member); - - baseinterfaces = [] - baseiface = iface.idl.getName(iface.base, iface.location) - while baseiface.name != "nsIDOMEvent": - baseinterfaces.append(baseiface) - baseiface = baseiface.idl.getName(baseiface.base, baseiface.location) - baseinterfaces.reverse() - - baseattributes = [] - for baseiface in baseinterfaces: - for member in baseiface.members: - if isinstance(member, xpidl.Attribute): - baseattributes.append(member) - - allattributes = [] - allattributes.extend(baseattributes); - allattributes.extend(attributes); - - fd.write("namespace mozilla {\n") - fd.write("namespace dom {\n\n") - - fd.write("%s::%s(mozilla::dom::EventTarget* aOwner, " % (classname, classname)) - fd.write("nsPresContext* aPresContext, mozilla::WidgetEvent* aEvent)\n"); - fd.write(": %s(aOwner, aPresContext, aEvent)" % basename) - for a in attributes: - fd.write(",\n m%s(%s)" % (firstCap(a.name), init_value(a))) - fd.write("\n{\n") - fd.write("}\n\n") - - fd.write("%s::~%s() {}\n\n" % (classname, classname)) - - fd.write("NS_IMPL_CYCLE_COLLECTION_CLASS(%s)\n" % (classname)) - fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(%s, %s)\n" % (classname, basename)) - for c in ccattributes: - fd.write(" NS_IMPL_CYCLE_COLLECTION_UNLINK(m%s)\n" % firstCap(c.name)) - fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_END\n\n"); - fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(%s, %s)\n" % (classname, basename)) - for c in ccattributes: - fd.write(" NS_IMPL_CYCLE_COLLECTION_TRAVERSE(m%s)\n" % firstCap(c.name)) - fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END\n\n"); - - fd.write("NS_IMPL_ADDREF_INHERITED(%s, %s)\n" % (classname, basename)) - fd.write("NS_IMPL_RELEASE_INHERITED(%s, %s)\n\n" % (classname, basename)) - - fd.write("NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(%s)\n" % classname) - fd.write(" NS_INTERFACE_MAP_ENTRY(nsIDOM%s)\n" % eventname) - fd.write("NS_INTERFACE_MAP_END_INHERITING(%s)\n\n" % basename) - - hasVariant = False - for a in allattributes: - if a.type == "nsIVariant": - hasVariant = True - break; - - fd.write("already_AddRefed<%s>\n" % eventname) - fd.write("%s::Constructor(const GlobalObject& aGlobal, " % eventname) - fd.write("const nsAString& aType, ") - fd.write("const %sInit& aParam, " % eventname) - fd.write("ErrorResult& aRv)\n") - fd.write("{\n") - fd.write(" nsCOMPtr t = do_QueryInterface(aGlobal.GetAsSupports());\n") - fd.write(" nsRefPtr<%s> e = new %s(t, nullptr, nullptr);\n" % (eventname, eventname)) - fd.write(" bool trusted = e->Init(t);\n") - fd.write(" e->Init%s(" % eventname) - if hasVariant: - fd.write("aGlobal.Context(), "); - fd.write("aType, aParam.mBubbles, aParam.mCancelable") - for a in allattributes: - fd.write(", aParam.m%s" % firstCap(a.name)) - fd.write(", aRv);\n") - fd.write(" e->SetTrusted(trusted);\n") - fd.write(" return e.forget();\n") - fd.write("}\n\n") - - fd.write("NS_IMETHODIMP\n") - fd.write("%s::Init%s(" % (classname, eventname)) - fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable") - for a in allattributes: - writeAttributeParams(fd, a) - fd.write(")\n{\n") - fd.write(" nsresult rv = %s::Init%s(aType, aCanBubble, aCancelable" % (basename, ("%s" % iface.base[6:]))) - for a in baseattributes: - fd.write(", a%s" % firstCap(a.name)) - fd.write(");\n"); - fd.write(" NS_ENSURE_SUCCESS(rv, rv);\n") - for a in attributes: - if a.realtype.nativeType("in").count("nsAString"): - fd.write(" if (!m%s.Assign(a%s, fallible_t())) {\n" % (firstCap(a.name), firstCap(a.name))) - fd.write(" return NS_ERROR_OUT_OF_MEMORY;\n") - fd.write(" }\n") - else: - fd.write(" m%s = a%s;\n" % (firstCap(a.name), firstCap(a.name))) - fd.write(" return NS_OK;\n") - fd.write("}\n\n") - - fd.write("void\n") - fd.write("%s::Init%s(" % (classname, eventname)) - if hasVariant: - fd.write("JSContext* aCx, ") - fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable") - for a in allattributes: - writeNativeAttributeParams(fd, a, conf) - fd.write(", ErrorResult& aRv") - fd.write(")\n") - fd.write("{\n"); - for a in allattributes: - if a.type == "nsIVariant": - fd.write(" nsCOMPtr %s = dont_AddRef(XPCVariant::newVariant(aCx, a%s));\n" % (a.name, firstCap(a.name))) - fd.write(" if (!%s) {\n" % a.name) - fd.write(" aRv.Throw(NS_ERROR_FAILURE);\n") - fd.write(" return;\n") - fd.write(" }\n") - elif a.realtype.nativeType('in').endswith('*'): - xpidl_t = a.realtype.nativeType('in').strip('* ') - native_t = xpidl_to_native(xpidl_t, conf) - if xpidl_t != native_t: - fd.write(" nsCOMPtr<%s> %s = do_QueryInterface(static_cast<%s*>(a%s));\n" % (xpidl_t, a.name, xpidl_to_canonical(xpidl_t, conf), firstCap(a.name))) - fd.write(" aRv = Init%s(" % classname); - fd.write("aType, aCanBubble, aCancelable") - for a in allattributes: - if a.realtype.nativeType('in').endswith('*'): - xpidl_t = a.realtype.nativeType('in').strip('* ') - native_t = xpidl_to_native(xpidl_t, conf) - if xpidl_t != native_t or a.type == "nsIVariant": - fd.write(", %s" % a.name) - continue - fd.write(", a%s" % firstCap(a.name)) - fd.write(");\n}\n\n"); - - for a in attributes: - writeAttributeGetter(fd, classname, a) - - fd.write("} // namespace dom\n") - fd.write("} // namespace mozilla\n\n") - - fd.write("nsresult\n") - fd.write("NS_NewDOM%s(nsIDOMEvent** aInstance, " % eventname) - fd.write("mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext = nullptr, mozilla::WidgetEvent* aEvent = nullptr)\n") - fd.write("{\n") - fd.write(" mozilla::dom::%s* it = new mozilla::dom::%s(aOwner, aPresContext, aEvent);\n" % (classname, classname)) - fd.write(" NS_ADDREF(it);\n") - fd.write(" *aInstance = static_cast(it);\n") - fd.write(" return NS_OK;\n"); - fd.write("}\n\n") - -def toWebIDLType(attribute, inType=False, onlyInterface=False): - if attribute.type == "nsIVariant": - return "any"; - if attribute.type == "nsISupports": - return "%s%s" % (attribute.type, "" if onlyInterface else "?") - if attribute.type.count("nsIDOM"): - return "%s%s" % (attribute.type[6:], "" if onlyInterface else "?") - if attribute.type.count("nsI"): - return "%s%s" % (attribute.type[3:], "" if onlyInterface else "?") - if attribute.realtype.nativeType('in').endswith('*') or attribute.realtype.nativeType('in').count("nsAString"): - return "%s%s" % (attribute.type, "" if onlyInterface else "?") - return attribute.type - -def write_webidl(eventname, iface, fd, conf, idl): - basename = ("%s" % iface.base[6:]) - attributes = [] - ccattributes = [] - consts = [] - hasInit = False - initMethod = "init%s" % eventname; - for member in iface.members: - if isinstance(member, xpidl.Attribute): - attributes.append(member) - if (member.realtype.nativeType('in').endswith('*')): - ccattributes.append(member); - elif isinstance(member, xpidl.Method) and member.name == initMethod: - if not member.noscript and not member.notxpcom: - hasInit = True - elif isinstance(member, xpidl.ConstMember): - consts.append(member); - else: - raise BaseException("Unsupported idl member %s::%s" % (eventname, member.name)) - - baseinterfaces = [] - baseiface = iface.idl.getName(iface.base, iface.location) - while baseiface.name != "nsIDOMEvent": - baseinterfaces.append(baseiface) - baseiface = baseiface.idl.getName(baseiface.base, baseiface.location) - baseinterfaces.reverse() - - allattributes = [] - for baseiface in baseinterfaces: - for member in baseiface.members: - if isinstance(member, xpidl.Attribute): - allattributes.append(member) - allattributes.extend(attributes) - - fd.write( -"""/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. - */ -""") - - neededInterfaces = [] - for a in attributes: - if a.realtype.nativeType('in').endswith('*'): - nativeType = a.realtype.nativeType('in').strip('* ') - mappingForWebIDL = False - for xp in conf.xpidl_to_native: - if xp[0] == nativeType: - mappingForWebIDL = True - break; - if not mappingForWebIDL: - webidlType = toWebIDLType(a, False, True) - if (not webidlType in neededInterfaces and webidlType != "any"): - neededInterfaces.append(webidlType); - - for i in neededInterfaces: - fd.write("interface %s;\n" % i) - - fd.write("\n"); - fd.write("[Constructor(DOMString type, optional %sInit eventInitDict), HeaderFile=\"GeneratedEventClasses.h\"]\n" % eventname); - fd.write("interface %s : %s\n" % (eventname, basename)) - fd.write("{\n") - - for c in consts: - fd.write(" const %s %s = %s;\n" % (c.type, c.name, c.getValue())) - if len(consts): - fd.write("\n") - - for a in attributes: - if a.realtype.nativeType('in').count("nsIVariant"): - fd.write(" [Throws]\n") - fd.write(" readonly attribute %s %s;\n" % (toWebIDLType(a), a.name)) - elif a.realtype.nativeType('in').endswith('*') or a.realtype.nativeType('in').count("nsAString"): - fd.write(" readonly attribute %s %s;\n" % (toWebIDLType(a), a.name)) - else: - fd.write(" readonly attribute %s %s;\n" % (a.type, a.name)) - if hasInit: - fd.write("\n [Throws]\n") - m = " void %s(" % initMethod - fd.write(m) - indent = "".join(" " for i in range(len(m))) - indent = ",\n%s" % indent - fd.write("DOMString type") - fd.write(indent); - fd.write("boolean canBubble") - fd.write(indent); - fd.write("boolean cancelable") - for a in baseattributes + attributes: - fd.write(indent); - fd.write("%s %s" % (toWebIDLType(a, True), a.name)) - fd.write(");\n"); - fd.write("};\n\n") - - dname = "%sInit" % eventname - for p in idl.productions: - if p.kind == "dictionary" and p.name == dname: - fd.write("dictionary %s : %sInit\n" % (dname, basename)) - fd.write("{\n") - # We want to keep the same ordering what interface has. - for ifaceattribute in attributes: - for member in p.members: - if member.name == ifaceattribute.name: - a = member - if a.realtype.nativeType('in').endswith('*'): - fd.write(" %s %s = null;\n" % (toWebIDLType(a, True), a.name)) - elif a.realtype.nativeType('in').count("nsAString"): - if a.defvalue is None: - if a.nullable: - fd.write(" %s? %s = null;\n" % (a.type, a.name)) - else: - fd.write(" %s %s = \"\";\n" % (a.type, a.name)) - else: - if a.nullable: - fd.write(" %s? %s = \"%s\";\n" % (a.type, a.name, a.defvalue)) - else: - fd.write(" %s %s = \"%s\";\n" % (a.type, a.name, a.defvalue)) - else: - if a.defvalue is None: - if a.type == "boolean": - fd.write(" %s %s = false;\n" % (a.type, a.name)) - else: - fd.write(" %s %s = 0;\n" % (a.type, a.name)) - # Infinity is not supported by all the types, but - # WebIDL parser will then complain about the wrong values. - elif a.defvalue == "Infinity": - fd.write(" unrestricted %s %s = Infinity;\n" % (a.type, a.name)) - elif a.defvalue == "-Infinity": - fd.write(" unrestricted %s %s = -Infinity;\n" % (a.type, a.name)) - else: - fd.write(" %s %s = %s;\n" % (a.type, a.name, a.defvalue)) - continue - fd.write("};\n") - return - - # There is no dictionary defined in the .idl file. Generate one based on - # the interface. - fd.write("dictionary %s : %sInit\n" % (dname, basename)) - fd.write("{\n") - for a in attributes: - if a.realtype.nativeType('in').endswith('*'): - fd.write(" %s %s = null;\n" % (toWebIDLType(a, True), a.name)) - elif a.realtype.nativeType('in').count("nsAString"): - fd.write(" %s? %s = \"\";\n" % (a.type, a.name)) - elif a.type == "boolean": - fd.write(" %s %s = false;\n" % (a.type, a.name)) - else: - fd.write(" %s %s = 0;\n" % (a.type, a.name)) - fd.write("};\n") - -def print_webidl_file(idl, fd, conf, eventname): - for p in idl.productions: - if p.kind == 'interface': - write_webidl(eventname, p, fd, conf, idl) - -def xpidl_to_native(xpidl, conf): - for x in conf.xpidl_to_native: - if x[0] == xpidl: - return x[1] - return xpidl - -def xpidl_to_canonical(xpidl, conf): - for x in conf.xpidl_to_native: - if x[0] == xpidl: - return x[2] - return xpidl - -def native_to_xpidl(native, conf): - for x in conf.xpidl_to_native: - if x[1] == native: - return x[0] - return native - -def print_webidl_files(webidlDir, conf): - for e in conf.simple_events: - idl = loadEventIDL(p, options.incdirs, e) - webidl = "%s/%s.webidl" % (webidlDir, e) - if not os.path.exists(webidl): - fd = open(webidl, 'w') - print_webidl_file(idl, fd, conf, e) - fd.close(); - -if __name__ == '__main__': - from optparse import OptionParser - o = OptionParser(usage="usage: %prog [options] configfile") - o.add_option('-I', action='append', dest='incdirs', default=['.'], - help="Directory to search for imported files") - o.add_option('-o', "--stub-output", - type='string', dest='stub_output', default=None, - help="Quick stub C++ source output file", metavar="FILE") - o.add_option('--header-output', type='string', default=None, - help="Quick stub header output file", metavar="FILE") - o.add_option('--makedepend-output', type='string', default=None, - help="gnumake dependencies output file", metavar="FILE") - o.add_option('--cachedir', dest='cachedir', default=None, - help="Directory in which to cache lex/parse tables.") - o.add_option('--class-declarations', type='string', default=None, - help="Class declarations", metavar="FILE") - o.add_option('--webidltarget', dest='webidltarget', default=None, - help="Directory in which to store generated WebIDL files.") - (options, filenames) = o.parse_args() - if len(filenames) != 1: - o.error("Exactly one config filename is needed.") - filename = filenames[0] - - if options.cachedir is not None: - if not os.path.isdir(options.cachedir): - os.mkdir(options.cachedir) - sys.path.append(options.cachedir) - - # Instantiate the parser. - p = xpidl.IDLParser(outputdir=options.cachedir) - - conf = readConfigFile(filename) - - if options.header_output is not None: - outfd = open(options.header_output, 'w') - print_header_file(outfd, conf) - outfd.close() - if options.class_declarations is not None: - outfd = open(options.class_declarations, 'w') - print_classes_file(outfd, conf) - outfd.close() - if options.stub_output is not None: - makeutils.targets.append(options.stub_output) - outfd = open(options.stub_output, 'w') - print_cpp_file(outfd, conf) - outfd.close() - if options.makedepend_output is not None: - makeutils.writeMakeDependOutput(options.makedepend_output) - - if options.webidltarget is not None: - print_webidl_files(options.webidltarget, conf) - diff --git a/js/xpconnect/src/moz.build b/js/xpconnect/src/moz.build index 0827beec26f0..a9a5d8ed14d5 100644 --- a/js/xpconnect/src/moz.build +++ b/js/xpconnect/src/moz.build @@ -55,7 +55,6 @@ SOURCES += [ GENERATED_SOURCES += [ 'dom_quickstubs.cpp', - 'GeneratedEvents.cpp', ] FAIL_ON_WARNINGS = True @@ -70,8 +69,6 @@ FINAL_LIBRARY = 'gklayout' GENERATED_FILES = [ 'dom_quickstubs.h', - 'GeneratedEventClasses.h', - 'GeneratedEvents.h', ] DEFINES['JS_THREADSAFE'] = True diff --git a/security/manager/ssl/src/nsNSSComponent.cpp b/security/manager/ssl/src/nsNSSComponent.cpp index f9ecf9fe95fc..375392795412 100644 --- a/security/manager/ssl/src/nsNSSComponent.cpp +++ b/security/manager/ssl/src/nsNSSComponent.cpp @@ -47,7 +47,6 @@ #include "nsITokenPasswordDialogs.h" #include "nsServiceManagerUtils.h" #include "nsNSSShutDown.h" -#include "GeneratedEvents.h" #include "SharedSSLState.h" #include "NSSErrorsService.h"