mirror of
https://github.com/servo/servo.git
synced 2025-07-25 08:10:21 +01:00
Support custom derives for generated types (#34356)
* script: Derive more Default implementations for dictionaries. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Support arbitrary derives on generated enums. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Support arbitrary derives for generated dictionaries. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Support arbitrary derives for generated unions. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Derive more impls for generated dicts and unions. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Implement FromStr for generated enums. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * crown: Allow returning unrooted values from Default::default. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
3faed9b921
commit
c60e4afbee
10 changed files with 124 additions and 129 deletions
|
@ -18,6 +18,9 @@ class Configuration:
|
|||
glbl = {}
|
||||
exec(compile(open(filename).read(), filename, 'exec'), glbl)
|
||||
config = glbl['DOMInterfaces']
|
||||
self.enumConfig = glbl['Enums']
|
||||
self.dictConfig = glbl['Dictionaries']
|
||||
self.unionConfig = glbl['Unions']
|
||||
|
||||
# Build descriptors for all the interfaces we have in the parse data.
|
||||
# This allows callers to specify a subset of interfaces by filtering
|
||||
|
@ -110,6 +113,9 @@ class Configuration:
|
|||
def getEnums(self, webIDLFile):
|
||||
return [e for e in self.enums if e.filename == webIDLFile]
|
||||
|
||||
def getEnumConfig(self, name):
|
||||
return self.enumConfig.get(name, {})
|
||||
|
||||
def getTypedefs(self, webIDLFile):
|
||||
return [e for e in self.typedefs if e.filename == webIDLFile]
|
||||
|
||||
|
@ -121,9 +127,15 @@ class Configuration:
|
|||
|
||||
return [x for x in items if x.filename == webIDLFile]
|
||||
|
||||
def getUnionConfig(self, name):
|
||||
return self.unionConfig.get(name, {})
|
||||
|
||||
def getDictionaries(self, webIDLFile=""):
|
||||
return self._filterForFile(self.dictionaries, webIDLFile=webIDLFile)
|
||||
|
||||
def getDictConfig(self, name):
|
||||
return self.dictConfig.get(name, {})
|
||||
|
||||
def getCallbacks(self, webIDLFile=""):
|
||||
return self._filterForFile(self.callbacks, webIDLFile=webIDLFile)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue