From 4edad4b6bf13b0336dab9600487187d1e76012f8 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 27 Nov 2012 15:32:05 -0500 Subject: [PATCH] Bug 767933 part 2. Implement codegen for 'unrestricted float' and 'unrestricted double', as aliases for float and double for now. r=khuey --- dom/bindings/Codegen.py | 7 +++-- dom/bindings/test/TestBindingHeader.h | 37 +++++++++++++++++++++++++ dom/bindings/test/TestCodeGen.webidl | 34 +++++++++++++++++++++++ dom/bindings/test/TestExampleGen.webidl | 34 +++++++++++++++++++++++ 4 files changed, 110 insertions(+), 2 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index a98f68e83a77..2a879e889eaf 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -1813,7 +1813,9 @@ builtinNames = { IDLType.Tags.uint16: 'uint16_t', IDLType.Tags.uint32: 'uint32_t', IDLType.Tags.uint64: 'uint64_t', + IDLType.Tags.unrestricted_float: 'float', IDLType.Tags.float: 'float', + IDLType.Tags.unrestricted_double: 'double', IDLType.Tags.double: 'double' } @@ -3291,8 +3293,9 @@ if (!%(resultStr)s) { IDLType.Tags.uint16, IDLType.Tags.int32]: return (setValue("INT_TO_JSVAL(int32_t(%s))" % result), True) - elif tag in [IDLType.Tags.int64, IDLType.Tags.uint64, IDLType.Tags.float, - IDLType.Tags.double]: + elif tag in [IDLType.Tags.int64, IDLType.Tags.uint64, + IDLType.Tags.unrestricted_float, IDLType.Tags.float, + IDLType.Tags.unrestricted_double, IDLType.Tags.double]: # XXXbz will cast to double do the "even significand" thing that webidl # calls for for 64-bit ints? Do we care? return (setValue("JS_NumberValue(double(%s))" % result), True) diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h index 9191a6176631..0a68810477de 100644 --- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -211,6 +211,43 @@ public: void PassOptionalUnsignedLongLong(const Optional&); void PassOptionalUnsignedLongLongWithDefault(uint64_t); + float WritableFloat() const; + void SetWritableFloat(float); + float WritableUnrestrictedFloat() const; + void SetWritableUnrestrictedFloat(float); + Nullable GetWritableNullableFloat() const; + void SetWritableNullableFloat(Nullable); + Nullable GetWritableNullableUnrestrictedFloat() const; + void SetWritableNullableUnrestrictedFloat(Nullable); + double WritableDouble() const; + void SetWritableDouble(double); + double WritableUnrestrictedDouble() const; + void SetWritableUnrestrictedDouble(double); + Nullable GetWritableNullableDouble() const; + void SetWritableNullableDouble(Nullable); + Nullable GetWritableNullableUnrestrictedDouble() const; + void SetWritableNullableUnrestrictedDouble(Nullable); + void PassFloat(float, float, Nullable, Nullable, + double, double, Nullable, Nullable, + const Sequence&, const Sequence&, + const Sequence >&, + const Sequence >&, + const Sequence&, const Sequence&, + const Sequence >&, + const Sequence >&); + void PassLenientFloat(float, float, Nullable, Nullable, + double, double, Nullable, Nullable, + const Sequence&, const Sequence&, + const Sequence >&, + const Sequence >&, + const Sequence&, const Sequence&, + const Sequence >&, + const Sequence >&); + float LenientFloatAttr() const; + void SetLenientFloatAttr(float); + double LenientDoubleAttr() const; + void SetLenientDoubleAttr(double); + // Interface types already_AddRefed ReceiveSelf(); already_AddRefed ReceiveNullableSelf(); diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index 7d9703b84852..8130791f84e2 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -150,6 +150,40 @@ interface TestInterface { void passOptionalUnsignedLongLong(optional unsigned long long arg); void passOptionalUnsignedLongLongWithDefault(optional unsigned long long arg = 17); + attribute float writableFloat; + attribute unrestricted float writableUnrestrictedFloat; + attribute float? writableNullableFloat; + attribute unrestricted float? writableNullableUnrestrictedFloat; + attribute double writableDouble; + attribute unrestricted double writableUnrestrictedDouble; + attribute double? writableNullableDouble; + attribute unrestricted double? writableNullableUnrestrictedDouble; + void passFloat(float arg1, unrestricted float arg2, + float? arg3, unrestricted float? arg4, + double arg5, unrestricted double arg6, + double? arg7, unrestricted double? arg8, + sequence arg9, sequence arg10, + sequence arg11, sequence arg12, + sequence arg13, sequence arg14, + sequence arg15, sequence arg16); + [LenientFloat] + void passLenientFloat(float arg1, unrestricted float arg2, + float? arg3, unrestricted float? arg4, + double arg5, unrestricted double arg6, + double? arg7, unrestricted double? arg8, + sequence arg9, + sequence arg10, + sequence arg11, + sequence arg12, + sequence arg13, + sequence arg14, + sequence arg15, + sequence arg16); + [LenientFloat] + attribute float lenientFloatAttr; + [LenientFloat] + attribute double lenientDoubleAttr; + // Castable interface types // XXXbz add tests for throwing versions of all the castable interface stuff TestInterface receiveSelf(); diff --git a/dom/bindings/test/TestExampleGen.webidl b/dom/bindings/test/TestExampleGen.webidl index 34eace8c64ee..7edab7a28cd0 100644 --- a/dom/bindings/test/TestExampleGen.webidl +++ b/dom/bindings/test/TestExampleGen.webidl @@ -71,6 +71,40 @@ interface TestExampleInterface { void passOptionalUnsignedLongLong(optional unsigned long long arg); void passOptionalUnsignedLongLongWithDefault(optional unsigned long long arg = 17); + attribute float writableFloat; + attribute unrestricted float writableUnrestrictedFloat; + attribute float? writableNullableFloat; + attribute unrestricted float? writableNullableUnrestrictedFloat; + attribute double writableDouble; + attribute unrestricted double writableUnrestrictedDouble; + attribute double? writableNullableDouble; + attribute unrestricted double? writableNullableUnrestrictedDouble; + void passFloat(float arg1, unrestricted float arg2, + float? arg3, unrestricted float? arg4, + double arg5, unrestricted double arg6, + double? arg7, unrestricted double? arg8, + sequence arg9, sequence arg10, + sequence arg11, sequence arg12, + sequence arg13, sequence arg14, + sequence arg15, sequence arg16); + [LenientFloat] + void passLenientFloat(float arg1, unrestricted float arg2, + float? arg3, unrestricted float? arg4, + double arg5, unrestricted double arg6, + double? arg7, unrestricted double? arg8, + sequence arg9, + sequence arg10, + sequence arg11, + sequence arg12, + sequence arg13, + sequence arg14, + sequence arg15, + sequence arg16); + [LenientFloat] + attribute float lenientFloatAttr; + [LenientFloat] + attribute double lenientDoubleAttr; + // Castable interface types // XXXbz add tests for throwing versions of all the castable interface stuff TestInterface receiveSelf();