Add a file that we kinda need to actually build
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 26 Jan 2012 17:00:40 +0100
changeset 85147 62e78467654014cce6d4e71913d6199483f0f864
parent 85146 abb107b76e18051399a612ce143d2647cddac1a7
child 85148 fdee219a75502a61e28f8d2990ec4d91385e4dbd
push id49
push userbzbarsky@mozilla.com
push dateThu, 26 Jan 2012 16:00:48 +0000
milestone12.0a1
Add a file that we kinda need to actually build
dom/bindings/ConfigurationParser.py
dom/bindings/Makefile.in
new file mode 100644
--- /dev/null
+++ b/dom/bindings/ConfigurationParser.py
@@ -0,0 +1,48 @@
+# 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/.
+
+# Classes for handling our configuration data
+
+class DOMClassImplementation():
+    def __init__(self, domClass, implConf):
+        self.domClass = domClass
+        self.nativeClass = implConf['nativeClass']
+        self.workers = implConf.get('workers', False)
+        if self.workers:
+            self.name = domClass.name + '_workers'
+        else:
+            self.name = domClass.name
+        self.nativeIsISupports = not self.workers
+
+class DOMClass():
+    def __init__(self, classConf, interface):
+        self.name = classConf['name']
+        self.implementations = [DOMClassImplementation(self, implConf) for implConf in classConf['implementations']]
+
+        # Build the interface chain.
+        self.interfaceChain = [self.name]
+        parent = interface.parent
+        while parent:
+            self.interfaceChain.insert(0, parent.identifier.name)
+            parent = parent.parent
+
+class Configuration:
+    def __init__(self, filename, parseData):
+        self.configFile = {}
+        execfile(filename, self.configFile)
+
+        # We need dom_classes.
+        if 'dom_classes' not in self.configFile:
+            raise UserError(filename + ": `dom_classes` was not defined.")
+
+        # Build data structures for classes where we have parse data. We've
+        # already filtered the parse data so that this does what we want.
+        self.dom_classes = dict()
+        for classConf in self.configFile['dom_classes']:
+            name = classConf['name']
+            if name not in parseData:
+                continue
+            self.dom_classes[name] = DOMClass(classConf, parseData[name])
+
+
--- a/dom/bindings/Makefile.in
+++ b/dom/bindings/Makefile.in
@@ -32,16 +32,17 @@ EXPORTS_$(bindingsIncludePath) = \
   Utils.h \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 $(BINDING_CPP_FILES): %Binding.cpp: BindingGen.py \
                       Bindings.conf \
                       PrototypeList.h \
+                      ConfigurationParser.py \
                       $(WEBIDL_BASE)/%.webidl
 	$(PYTHON) $(topsrcdir)/config/pythonpath.py -I$(topsrcdir)/other-licenses/ply -I$(srcdir)/parser \
 		$(srcdir)/BindingGen.py $(srcdir)/Bindings.conf $*Binding $(WEBIDL_BASE)/$*.webidl
 
 # The global phase generates PrototypeList.h, which is used in the per-file
 # bindings phase. We need to re-run the global phase whenever any of the
 # webIDL files change in order to keep PrototypeList.h up to date. But if
 # the list itself doesn't change, we don't need to rebuild all of the
@@ -63,16 +64,17 @@ export:: .GlobalPhaseIndicator
 	$(INSTALL) $(IFLAGS1) PrototypeList.h $(DIST)/include/$(bindingsIncludePath)
 
 GLOBAL_PHASE_TARGETS = \
   PrototypeList.h \
   ParserResults.pkl \
   .GlobalPhaseIndicator \
   $(NULL)
 .GlobalPhaseIndicator: GlobalGen.py \
+                       ConfigurationParser.py \
                        $(addprefix $(WEBIDL_BASE)/, $(WEBIDL_FILES))
 	$(PYTHON_PATH) -I$(topsrcdir)/other-licenses/ply -I$(srcdir)/parser \
     $(srcdir)/GlobalGen.py $(srcdir)/Bindings.conf $(WEBIDL_BASE) $(WEBIDL_FILES)
 	touch .GlobalPhaseIndicator
 
 GARBAGE += \
   $(GLOBAL_PHASE_TARGETS) \
   $(BINDING_HEADER_FILES) \