diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-06-01 08:37:48 -0500 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-06-01 08:37:48 -0500 |
commit | 0de09b936e5e37c15b7865157a98ad78b1077659 (patch) | |
tree | dff9058ec210d968aae1031632dede080456db88 /components/script/dom/bindings/codegen/CodegenRust.py | |
parent | 2a8d5952892e050a3d604741dd1007e3bd563315 (diff) | |
parent | b3ac3467494377569997126103005382793d8081 (diff) | |
download | servo-0de09b936e5e37c15b7865157a98ad78b1077659.tar.gz servo-0de09b936e5e37c15b7865157a98ad78b1077659.zip |
Auto merge of #6183 - ecoal95:webglcontextattributes, r=nox
r? @jdm
I couldn't add the `getContextAttributes` method since `CodegenRust`
doesn't know how to return a dictionary value, I'll take a look at it ASAP.
I think the helper functions can return directly the renderer, since they're used just for that, but I wanted to hear your opinions about this.
By the way I'm interested in adding more serious tests for WebGL, and I think the [khronos conformance suit](https://github.com/KhronosGroup/WebGL/tree/master/conformance-suites/1.0.3) should be the best option.
Should I try to integrate it in wpt, or making a `tests/webgl` directory (or similar) inside the servo tree? (Maybe this question should be for @Ms2ger)
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6183)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index d44db4078b4..9f965a9c7e8 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1165,6 +1165,15 @@ def getRetvalDeclarationForType(returnType, descriptorProvider): return CGGeneric("*mut JSObject") if returnType.isSequence(): raise TypeError("We don't support sequence return values") + if returnType.isDictionary(): + nullable = returnType.nullable() + dictName = returnType.inner.name if nullable else returnType.name + result = CGGeneric(dictName) + if typeNeedsRooting(returnType, descriptorProvider): + raise TypeError("We don't support rootable dictionaries return values") + if nullable: + result = CGWrapper(result, pre="Option<", post=">") + return result raise TypeError("Don't know how to declare return value for %s" % returnType) @@ -4517,7 +4526,14 @@ class CGDictionary(CGThing): conversion = self.getMemberConversion(memberInfo) return CGGeneric("%s: %s,\n" % (name, conversion.define())) + def memberInsert(memberInfo): + member, _ = memberInfo + name = self.makeMemberName(member.identifier.name) + insertion = ("set_dictionary_property(cx, obj, \"%s\", &mut self.%s.to_jsval(cx)).unwrap();" % (name, name)) + return CGGeneric("%s\n" % insertion) + memberInits = CGList([memberInit(m) for m in self.memberInfo]) + memberInserts = CGList([memberInsert(m) for m in self.memberInfo]) return string.Template( "impl ${selfName} {\n" @@ -4538,10 +4554,19 @@ class CGDictionary(CGThing): "${initMembers}" " })\n" " }\n" - "}").substitute({ + "}\n" + "\n" + "impl ToJSValConvertible for ${selfName} {\n" + " fn to_jsval(&self, cx: *mut JSContext) -> JSVal {\n" + " let obj = unsafe { JS_NewObject(cx, 0 as *const JSClass, 0 as *const JSObject, 0 as *const JSObject) };\n" + "${insertMembers}" + " ObjectOrNullValue(obj)\n" + " }\n" + "}\n").substitute({ "selfName": self.makeClassName(d), "initParent": CGIndenter(CGGeneric(initParent), indentLevel=12).define(), "initMembers": CGIndenter(memberInits, indentLevel=12).define(), + "insertMembers": CGIndenter(memberInserts, indentLevel=8).define(), }) @staticmethod @@ -4590,6 +4615,7 @@ class CGDictionary(CGThing): return CGGeneric(conversion) + @staticmethod def makeIdName(name): return name + "_id" @@ -4750,6 +4776,7 @@ class CGBindingRoot(CGThing): 'dom::bindings::utils::{Reflectable}', 'dom::bindings::utils::throwing_constructor', 'dom::bindings::utils::get_dictionary_property', + 'dom::bindings::utils::set_dictionary_property', 'dom::bindings::utils::{NativeProperties, NativePropertyHooks}', 'dom::bindings::utils::ConstantVal::{IntVal, UintVal}', 'dom::bindings::utils::NonNullJSNative', |