Skip to content

Commit

Permalink
reduce indentation in CodegenRust.py
Browse files Browse the repository at this point in the history
We're going to wind up tacking on different pieces of code for the
global vs. non-global case once we move the JS_SetReservedSlot call into
create_dom_global.  We might as well separate the indentation changes
into a separate commit.
  • Loading branch information
froydnj committed Oct 27, 2015
1 parent 484c0e4 commit 3d39646
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -2157,27 +2157,29 @@ def CreateBindingJSObject(descriptor, parent=None):
assert!(!obj.is_null());
let obj = RootedObject::new(cx, obj);\
""" % (descriptor.name, parent)
elif descriptor.isGlobal():
create += ("let obj = RootedObject::new(\n"
" cx,\n"
" create_dom_global(\n"
" cx,\n"
" &Class.base as *const js::jsapi::Class as *const JSClass,\n"
" Some(%s))\n"
");\n"
"assert!(!obj.ptr.is_null());\n"
"\n"
"JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT,\n"
" PrivateValue(raw as *const libc::c_void));" % TRACE_HOOK_NAME)
else:
if descriptor.isGlobal():
create += ("let obj = RootedObject::new(\n"
" cx,\n"
" create_dom_global(\n"
" cx,\n"
" &Class.base as *const js::jsapi::Class as *const JSClass,\n"
" Some(%s))\n"
");\n" % TRACE_HOOK_NAME)
else:
create += ("let obj = {\n"
" let _ac = JSAutoCompartment::new(cx, proto.ptr);\n"
" JS_NewObjectWithGivenProto(\n"
" cx, &Class.base as *const js::jsapi::Class as *const JSClass, proto.handle())\n"
"};\n"
"let obj = RootedObject::new(cx, obj);\n")
create += """\
assert!(!obj.ptr.is_null());
JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT,
PrivateValue(raw as *const libc::c_void));"""
create += ("let obj = {\n"
" let _ac = JSAutoCompartment::new(cx, proto.ptr);\n"
" JS_NewObjectWithGivenProto(\n"
" cx, &Class.base as *const js::jsapi::Class as *const JSClass, proto.handle())\n"
"};\n"
"let obj = RootedObject::new(cx, obj);\n"
"assert!(!obj.ptr.is_null());\n"
"\n"
"JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT,\n"
" PrivateValue(raw as *const libc::c_void));")
return create


Expand Down

0 comments on commit 3d39646

Please sign in to comment.