aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTom Schuster <evilpies@gmail.com>2013-11-15 15:41:49 +0100
committerTom Schuster <evilpies@gmail.com>2013-11-15 17:56:11 +0100
commit586dd6aed64c1b6a81cc2d19f9c42f979751fb12 (patch)
treeb8c1a3ed1377ddaffa29bb2311bf6d9604d55701 /src
parente98ddef9bbaf41adb15b158b8a0f21ef252a1a79 (diff)
downloadservo-586dd6aed64c1b6a81cc2d19f9c42f979751fb12.tar.gz
servo-586dd6aed64c1b6a81cc2d19f9c42f979751fb12.zip
Add some more Blob methods/types
Diffstat (limited to 'src')
-rw-r--r--src/components/script/dom/bindings/codegen/Blob.webidl17
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py30
-rw-r--r--src/components/script/dom/bindings/conversions.rs17
-rw-r--r--src/components/script/dom/blob.rs16
4 files changed, 63 insertions, 17 deletions
diff --git a/src/components/script/dom/bindings/codegen/Blob.webidl b/src/components/script/dom/bindings/codegen/Blob.webidl
index afa67719560..9e7bec50c0a 100644
--- a/src/components/script/dom/bindings/codegen/Blob.webidl
+++ b/src/components/script/dom/bindings/codegen/Blob.webidl
@@ -4,12 +4,25 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
- * http://dev.w3.org/2006/webapi/FileAPI/
+ * http://dev.w3.org/2006/webapi/FileAPI/#blob
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
-[Constructor]
+[Constructor/*,
+ Constructor(sequence<(ArrayBuffer or ArrayBufferView or Blob or DOMString)> blobParts, optional BlobPropertyBag option)*/]
interface Blob {
+ readonly attribute unsigned long long size;
+ readonly attribute DOMString type;
+
+ Blob slice([Clamp] optional long long start,
+ [Clamp] optional long long end,
+ optional DOMString contentType);
+ void close();
+};
+
+
+dictionary BlobPropertyBag {
+ DOMString type = "";
};
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index bb87667df83..8cfd491ebdb 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1097,14 +1097,9 @@ for (uint32_t i = 0; i < length; ++i) {
if isMember:
# We have to make a copy, because our jsval may well not
# live as long as our string needs to.
- declType = CGGeneric("nsString")
- return (
- "{\n"
- " FakeDependentString str;\n"
- "%s\n"
- " ${declName} = str;\n"
- "}\n" % CGIndenter(CGGeneric(getConversionCode("str"))).define(),
- declType, None, isOptional, None)
+ declType = CGGeneric("DOMString")
+ return ("%s\n" % getConversionCode("${declName}"),
+ declType, None, isOptional, None)
declType = "DOMString"
initialValue = None
@@ -4833,7 +4828,7 @@ class CGDictionary(CGThing):
else:
inheritance = ""
memberDecls = [" %s: %s," %
- (m[0].identifier.name, self.getMemberType(m))
+ (self.makeMemberName(m[0].identifier.name), self.getMemberType(m))
for m in self.memberInfo]
return (string.Template(
@@ -4876,8 +4871,8 @@ class CGDictionary(CGThing):
return "false"
elif ty in ["i32", "u32", "i16", "u16"]:
return "0"
- elif ty is "nsString":
- return "\"\""
+ elif ty == "DOMString":
+ return '~""'
elif ty.startswith("Option"):
return "None"
else:
@@ -4895,7 +4890,7 @@ class CGDictionary(CGThing):
" ${selfName} {\n" +
((" parent: %s::%s::new(),\n" % (self.makeModuleName(d.parent),
self.makeClassName(d.parent))) if d.parent else "") +
- "\n".join(" %s: %s," % (m[0].identifier.name, defaultValue(self.getMemberType(m))) for m in self.memberInfo) + "\n"
+ "\n".join(" %s: %s," % (self.makeMemberName(m[0].identifier.name), defaultValue(self.getMemberType(m))) for m in self.memberInfo) + "\n"
" }\n"
" }\n"
"\n"
@@ -4965,7 +4960,7 @@ class CGDictionary(CGThing):
holderType, dealWithOptional, initialValue)) = memberInfo
replacements = { "val": "temp",
"valPtr": "&temp",
- "declName": ("self.%s" % member.identifier.name),
+ "declName": ("self.%s" % self.makeMemberName(member.identifier.name)),
# We need a holder name for external interfaces, but
# it's scoped down to the conversion so we can just use
# anything we want.
@@ -5021,7 +5016,7 @@ class CGDictionary(CGThing):
"}")
conversionReplacements["convert"] = CGIndenter(
CGGeneric(conversionReplacements["convert"])).define()
-
+
return CGGeneric(
string.Template(conversion).substitute(conversionReplacements)
)
@@ -5031,6 +5026,13 @@ class CGDictionary(CGThing):
return name + "_id"
@staticmethod
+ def makeMemberName(name):
+ # Can't use Rust keywords as member names.
+ if name == "type":
+ return name + "_"
+ return name
+
+ @staticmethod
def getDictionaryDependencies(dictionary):
deps = set();
if dictionary.parent:
diff --git a/src/components/script/dom/bindings/conversions.rs b/src/components/script/dom/bindings/conversions.rs
index d1143b502c3..22bad8cff16 100644
--- a/src/components/script/dom/bindings/conversions.rs
+++ b/src/components/script/dom/bindings/conversions.rs
@@ -11,6 +11,23 @@ pub trait JSValConvertible {
fn from_jsval(val: JSVal) -> Option<Self>;
}
+
+impl JSValConvertible for i64 {
+ #[fixed_stack_segment]
+ fn to_jsval(&self) -> JSVal {
+ unsafe {
+ RUST_DOUBLE_TO_JSVAL(*self as f64)
+ }
+ }
+
+ #[fixed_stack_segment]
+ fn from_jsval(val: JSVal) -> Option<i64> {
+ unsafe {
+ Some(RUST_JSVAL_TO_DOUBLE(val) as i64)
+ }
+ }
+}
+
impl JSValConvertible for u32 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal {
diff --git a/src/components/script/dom/blob.rs b/src/components/script/dom/blob.rs
index 4b7d37aa7e9..581d9f4535c 100644
--- a/src/components/script/dom/blob.rs
+++ b/src/components/script/dom/blob.rs
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
+use dom::bindings::utils::{DOMString, Reflectable, Reflector, reflect_dom_object};
use dom::bindings::utils::Fallible;
use dom::bindings::codegen::BlobBinding;
use dom::window::Window;
@@ -29,6 +29,20 @@ impl Blob {
pub fn Constructor(window: @mut Window) -> Fallible<@mut Blob> {
Ok(Blob::new(window))
}
+
+ pub fn Size(&self) -> u64 {
+ 0
+ }
+
+ pub fn Type(&self) -> DOMString {
+ ~""
+ }
+
+ pub fn Slice(&self, _start: i64, _end: i64, _contentType: Option<DOMString>) -> @mut Blob {
+ Blob::new(self.window)
+ }
+
+ pub fn Close(&self) {}
}
impl Reflectable for Blob {