Use snake case for arguments and locals in CGWrapMethod.

This commit is contained in:
Ms2ger 2015-01-30 16:08:19 +01:00
parent 648b4991b9
commit 1056ea320b

View file

@ -1795,14 +1795,14 @@ class CGAbstractMethod(CGThing):
assert(False) # Override me! assert(False) # Override me!
def CreateBindingJSObject(descriptor, parent=None): def CreateBindingJSObject(descriptor, parent=None):
create = "let mut raw: JS<%s> = JS::from_raw(&*aObject);\n" % descriptor.concreteType create = "let mut raw: JS<%s> = JS::from_raw(&*object);\n" % descriptor.concreteType
if descriptor.proxy: if descriptor.proxy:
assert not descriptor.isGlobal() assert not descriptor.isGlobal()
create += """ create += """
let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as uint]; let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as uint];
let mut private = PrivateValue(squirrel_away_unique(aObject) as *const libc::c_void); let mut private = PrivateValue(squirrel_away_unique(object) as *const libc::c_void);
let obj = with_compartment(aCx, proto, || { let obj = with_compartment(cx, proto, || {
NewProxyObject(aCx, handler, NewProxyObject(cx, handler,
&private, &private,
proto, %s, proto, %s,
ptr::null_mut(), ptr::null_mut()) ptr::null_mut(), ptr::null_mut())
@ -1811,16 +1811,16 @@ assert!(!obj.is_null());\
""" % (descriptor.name, parent) """ % (descriptor.name, parent)
else: else:
if descriptor.isGlobal(): if descriptor.isGlobal():
create += "let obj = create_dom_global(aCx, &Class.base as *const js::Class as *const JSClass);\n" create += "let obj = create_dom_global(cx, &Class.base as *const js::Class as *const JSClass);\n"
else: else:
create += ("let obj = with_compartment(aCx, proto, || {\n" create += ("let obj = with_compartment(cx, proto, || {\n"
" JS_NewObject(aCx, &Class.base as *const js::Class as *const JSClass, &*proto, &*%s)\n" " JS_NewObject(cx, &Class.base as *const js::Class as *const JSClass, &*proto, &*%s)\n"
"});\n" % parent) "});\n" % parent)
create += """\ create += """\
assert!(!obj.is_null()); assert!(!obj.is_null());
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32, JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
PrivateValue(squirrel_away_unique(aObject) as *const libc::c_void));""" PrivateValue(squirrel_away_unique(object) as *const libc::c_void));"""
return create return create
class CGWrapMethod(CGAbstractMethod): class CGWrapMethod(CGAbstractMethod):
@ -1831,22 +1831,22 @@ class CGWrapMethod(CGAbstractMethod):
def __init__(self, descriptor): def __init__(self, descriptor):
assert not descriptor.interface.isCallback() assert not descriptor.interface.isCallback()
if not descriptor.isGlobal(): if not descriptor.isGlobal():
args = [Argument('*mut JSContext', 'aCx'), Argument('GlobalRef', 'aScope'), args = [Argument('*mut JSContext', 'cx'), Argument('GlobalRef', 'scope'),
Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)] Argument("Box<%s>" % descriptor.concreteType, 'object', mutable=True)]
else: else:
args = [Argument('*mut JSContext', 'aCx'), args = [Argument('*mut JSContext', 'cx'),
Argument("Box<%s>" % descriptor.concreteType, 'aObject', mutable=True)] Argument("Box<%s>" % descriptor.concreteType, 'object', mutable=True)]
retval = 'Temporary<%s>' % descriptor.concreteType retval = 'Temporary<%s>' % descriptor.concreteType
CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, pub=True) CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, pub=True)
def definition_body(self): def definition_body(self):
if not self.descriptor.isGlobal(): if not self.descriptor.isGlobal():
return CGGeneric("""\ return CGGeneric("""\
let scope = aScope.reflector().get_jsobject(); let scope = scope.reflector().get_jsobject();
assert!(!scope.is_null()); assert!(!scope.is_null());
assert!(((*JS_GetClass(scope)).flags & JSCLASS_IS_GLOBAL) != 0); assert!(((*JS_GetClass(scope)).flags & JSCLASS_IS_GLOBAL) != 0);
let proto = with_compartment(aCx, scope, || GetProtoObject(aCx, scope, scope)); let proto = with_compartment(cx, scope, || GetProtoObject(cx, scope, scope));
assert!(!proto.is_null()); assert!(!proto.is_null());
%s %s
@ -1857,13 +1857,13 @@ Temporary::new(raw)""" % CreateBindingJSObject(self.descriptor, "scope"))
else: else:
return CGGeneric("""\ return CGGeneric("""\
%s %s
with_compartment(aCx, obj, || { with_compartment(cx, obj, || {
let proto = GetProtoObject(aCx, obj, obj); let proto = GetProtoObject(cx, obj, obj);
JS_SetPrototype(aCx, obj, proto); JS_SetPrototype(cx, obj, proto);
raw.reflector().set_jsobject(obj); raw.reflector().set_jsobject(obj);
RegisterBindings::Register(aCx, obj); RegisterBindings::Register(cx, obj);
}); });
Temporary::new(raw)""" % CreateBindingJSObject(self.descriptor)) Temporary::new(raw)""" % CreateBindingJSObject(self.descriptor))