Bug 767933 part 2. Implement codegen for 'unrestricted float' and 'unrestricted double', as aliases for float and double for now. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 27 Nov 2012 15:32:05 -0500
changeset 114271 c426c6ea5ff73c5ba6e4566cebf22340cb197386
parent 114270 8375549bb321502e2cc963dcda89c516203452b7
child 114272 935af8796e8fa12184300805d7ad49a720caaff1
push id23913
push useremorley@mozilla.com
push dateWed, 28 Nov 2012 17:11:31 +0000
treeherdermozilla-central@17c267a881cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs767933
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/bindings/test/TestBindingHeader.h
dom/bindings/test/TestCodeGen.webidl
dom/bindings/test/TestExampleGen.webidl
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -1808,17 +1808,19 @@ builtinNames = {
     IDLType.Tags.int8: 'int8_t',
     IDLType.Tags.int16: 'int16_t',
     IDLType.Tags.int32: 'int32_t',
     IDLType.Tags.int64: 'int64_t',
     IDLType.Tags.uint8: 'uint8_t',
     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'
 }
 
 numericTags = [
     IDLType.Tags.int8, IDLType.Tags.uint8,
     IDLType.Tags.int16, IDLType.Tags.uint16,
     IDLType.Tags.int32, IDLType.Tags.uint32,
     IDLType.Tags.int64, IDLType.Tags.uint64,
@@ -3286,18 +3288,19 @@ if (!%(resultStr)s) {
                 "}\n" + recTemplate, recInfal)
     
     tag = type.tag()
     
     if tag in [IDLType.Tags.int8, IDLType.Tags.uint8, IDLType.Tags.int16,
                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)
 
     elif tag == IDLType.Tags.uint32:
         return (setValue("UINT_TO_JSVAL(%s)" % result), True)
 
     elif tag == IDLType.Tags.bool:
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -206,16 +206,53 @@ public:
   uint64_t ReadonlyUnsignedLongLong();
   uint64_t WritableUnsignedLongLong();
   void SetWritableUnsignedLongLong(uint64_t);
   void PassUnsignedLongLong(uint64_t);
   uint64_t ReceiveUnsignedLongLong();
   void PassOptionalUnsignedLongLong(const Optional<uint64_t>&);
   void PassOptionalUnsignedLongLongWithDefault(uint64_t);
 
+  float WritableFloat() const;
+  void SetWritableFloat(float);
+  float WritableUnrestrictedFloat() const;
+  void SetWritableUnrestrictedFloat(float);
+  Nullable<float> GetWritableNullableFloat() const;
+  void SetWritableNullableFloat(Nullable<float>);
+  Nullable<float> GetWritableNullableUnrestrictedFloat() const;
+  void SetWritableNullableUnrestrictedFloat(Nullable<float>);
+  double WritableDouble() const;
+  void SetWritableDouble(double);
+  double WritableUnrestrictedDouble() const;
+  void SetWritableUnrestrictedDouble(double);
+  Nullable<double> GetWritableNullableDouble() const;
+  void SetWritableNullableDouble(Nullable<double>);
+  Nullable<double> GetWritableNullableUnrestrictedDouble() const;
+  void SetWritableNullableUnrestrictedDouble(Nullable<double>);
+  void PassFloat(float, float, Nullable<float>, Nullable<float>,
+                 double, double, Nullable<double>, Nullable<double>,
+                 const Sequence<float>&, const Sequence<float>&,
+                 const Sequence<Nullable<float> >&,
+                 const Sequence<Nullable<float> >&,
+                 const Sequence<double>&, const Sequence<double>&,
+                 const Sequence<Nullable<double> >&,
+                 const Sequence<Nullable<double> >&);
+  void PassLenientFloat(float, float, Nullable<float>, Nullable<float>,
+                        double, double, Nullable<double>, Nullable<double>,
+                        const Sequence<float>&, const Sequence<float>&,
+                        const Sequence<Nullable<float> >&,
+                        const Sequence<Nullable<float> >&,
+                        const Sequence<double>&, const Sequence<double>&,
+                        const Sequence<Nullable<double> >&,
+                        const Sequence<Nullable<double> >&);
+  float LenientFloatAttr() const;
+  void SetLenientFloatAttr(float);
+  double LenientDoubleAttr() const;
+  void SetLenientDoubleAttr(double);
+
   // Interface types
   already_AddRefed<TestInterface> ReceiveSelf();
   already_AddRefed<TestInterface> ReceiveNullableSelf();
   TestInterface* ReceiveWeakSelf();
   TestInterface* ReceiveWeakNullableSelf();
   void PassSelf(TestInterface&);
   void PassSelf2(NonNull<TestInterface>&);
   void PassNullableSelf(TestInterface*);
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -145,16 +145,50 @@ interface TestInterface {
 
   readonly attribute unsigned long long readonlyUnsignedLongLong;
   attribute unsigned long long  writableUnsignedLongLong;
   void passUnsignedLongLong(unsigned long long arg);
   unsigned long long receiveUnsignedLongLong();
   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<float> arg9, sequence<unrestricted float> arg10,
+                 sequence<float?> arg11, sequence<unrestricted float?> arg12,
+                 sequence<double> arg13, sequence<unrestricted double> arg14,
+                 sequence<double?> arg15, sequence<unrestricted double?> 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<float> arg9,
+                        sequence<unrestricted float> arg10,
+                        sequence<float?> arg11,
+                        sequence<unrestricted float?> arg12,
+                        sequence<double> arg13,
+                        sequence<unrestricted double> arg14,
+                        sequence<double?> arg15,
+                        sequence<unrestricted double?> 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();
   TestInterface? receiveNullableSelf();
   TestInterface receiveWeakSelf();
   TestInterface? receiveWeakNullableSelf();
   // A verstion to test for casting to TestInterface&
   void passSelf(TestInterface arg);
--- a/dom/bindings/test/TestExampleGen.webidl
+++ b/dom/bindings/test/TestExampleGen.webidl
@@ -66,16 +66,50 @@ interface TestExampleInterface {
 
   readonly attribute unsigned long long readonlyUnsignedLongLong;
   attribute unsigned long long  writableUnsignedLongLong;
   void passUnsignedLongLong(unsigned long long arg);
   unsigned long long receiveUnsignedLongLong();
   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<float> arg9, sequence<unrestricted float> arg10,
+                 sequence<float?> arg11, sequence<unrestricted float?> arg12,
+                 sequence<double> arg13, sequence<unrestricted double> arg14,
+                 sequence<double?> arg15, sequence<unrestricted double?> 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<float> arg9,
+                        sequence<unrestricted float> arg10,
+                        sequence<float?> arg11,
+                        sequence<unrestricted float?> arg12,
+                        sequence<double> arg13,
+                        sequence<unrestricted double> arg14,
+                        sequence<double?> arg15,
+                        sequence<unrestricted double?> 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();
   TestInterface? receiveNullableSelf();
   TestInterface receiveWeakSelf();
   TestInterface? receiveWeakNullableSelf();
   // A verstion to test for casting to TestInterface&
   void passSelf(TestInterface arg);