mirror of
https://github.com/servo/servo.git
synced 2025-06-13 19:04:30 +00:00
Introduce static makeNativeName methods to share code with the upcoming static members.
This commit is contained in:
parent
927ae39817
commit
92f9fe59e5
1 changed files with 27 additions and 12 deletions
|
@ -2396,12 +2396,17 @@ class CGSpecializedMethod(CGAbstractExternMethod):
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, name, 'JSBool', args)
|
CGAbstractExternMethod.__init__(self, descriptor, name, 'JSBool', args)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
name = self.method.identifier.name
|
nativeName = CGSpecializedMethod.makeNativeName(self.descriptor,
|
||||||
return CGWrapper(CGMethodCall([], MakeNativeName(name), self.method.isStatic(),
|
self.method)
|
||||||
|
return CGWrapper(CGMethodCall([], nativeName, self.method.isStatic(),
|
||||||
self.descriptor, self.method),
|
self.descriptor, self.method),
|
||||||
pre="let this = JS::from_raw(this);\n"
|
pre="let this = JS::from_raw(this);\n"
|
||||||
"let mut this = this.root();\n")
|
"let mut this = this.root();\n")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def makeNativeName(descriptor, method):
|
||||||
|
return MakeNativeName(method.identifier.name)
|
||||||
|
|
||||||
class CGGenericGetter(CGAbstractBindingMethod):
|
class CGGenericGetter(CGAbstractBindingMethod):
|
||||||
"""
|
"""
|
||||||
A class for generating the C++ code for an IDL attribute getter.
|
A class for generating the C++ code for an IDL attribute getter.
|
||||||
|
@ -2441,18 +2446,25 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
|
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
name = self.attr.identifier.name
|
nativeName = CGSpecializedGetter.makeNativeName(self.descriptor,
|
||||||
nativeName = MakeNativeName(name)
|
self.attr)
|
||||||
infallible = ('infallible' in
|
|
||||||
self.descriptor.getExtendedAttributes(self.attr,
|
|
||||||
getter=True))
|
|
||||||
if self.attr.type.nullable() or not infallible:
|
|
||||||
nativeName = "Get" + nativeName
|
|
||||||
return CGWrapper(CGGetterCall([], self.attr.type, nativeName,
|
return CGWrapper(CGGetterCall([], self.attr.type, nativeName,
|
||||||
self.descriptor, self.attr),
|
self.descriptor, self.attr),
|
||||||
pre="let this = JS::from_raw(this);\n"
|
pre="let this = JS::from_raw(this);\n"
|
||||||
"let mut this = this.root();\n")
|
"let mut this = this.root();\n")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def makeNativeName(descriptor, attr):
|
||||||
|
nativeName = MakeNativeName(attr.identifier.name)
|
||||||
|
infallible = ('infallible' in
|
||||||
|
descriptor.getExtendedAttributes(attr, getter=True))
|
||||||
|
if attr.type.nullable() or not infallible:
|
||||||
|
return "Get" + nativeName
|
||||||
|
|
||||||
|
return nativeName
|
||||||
|
|
||||||
|
|
||||||
class CGGenericSetter(CGAbstractBindingMethod):
|
class CGGenericSetter(CGAbstractBindingMethod):
|
||||||
"""
|
"""
|
||||||
A class for generating the Rust code for an IDL attribute setter.
|
A class for generating the Rust code for an IDL attribute setter.
|
||||||
|
@ -2497,13 +2509,16 @@ class CGSpecializedSetter(CGAbstractExternMethod):
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
|
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
name = self.attr.identifier.name
|
nativeName = CGSpecializedSetter.makeNativeName(self.descriptor,
|
||||||
return CGWrapper(CGSetterCall([], self.attr.type,
|
self.attr)
|
||||||
"Set" + MakeNativeName(name),
|
return CGWrapper(CGSetterCall([], self.attr.type, nativeName,
|
||||||
self.descriptor, self.attr),
|
self.descriptor, self.attr),
|
||||||
pre="let this = JS::from_raw(this);\n"
|
pre="let this = JS::from_raw(this);\n"
|
||||||
"let mut this = this.root();\n")
|
"let mut this = this.root();\n")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def makeNativeName(descriptor, attr):
|
||||||
|
return "Set" + MakeNativeName(attr.identifier.name)
|
||||||
|
|
||||||
class CGMemberJITInfo(CGThing):
|
class CGMemberJITInfo(CGThing):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue