From c63fb1198ffa308dd4e4770b66742b8a6b7e7d88 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Thu, 19 Jul 2012 18:53:30 +0900 Subject: [PATCH] Bug 771401 - Change PRTime in IDL to signed long long. r=bholley sr=bsmedberg --- .../tests/components/js/xpctest_attributes.js | 10 ++++++++-- .../components/native/xpctest_attributes.cpp | 18 ++++++++++++++++++ .../tests/components/native/xpctest_private.h | 2 ++ js/xpconnect/tests/idl/xpctest_attributes.idl | 6 ++++-- js/xpconnect/tests/unit/test_attributes.js | 4 ++++ xpcom/base/nsrootidl.idl | 2 +- 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/js/xpconnect/tests/components/js/xpctest_attributes.js b/js/xpconnect/tests/components/js/xpctest_attributes.js index b7d3fe959a6..204d4f1b151 100644 --- a/js/xpconnect/tests/components/js/xpctest_attributes.js +++ b/js/xpconnect/tests/components/js/xpctest_attributes.js @@ -17,7 +17,10 @@ TestObjectReadWrite.prototype = { shortProperty: 32767, longProperty: 2147483647, floatProperty: 5.5, - charProperty: "X" + charProperty: "X", + // timeProperty is PRTime and signed type. + // So it has to allow negative value. + timeProperty: -1 }; @@ -35,7 +38,10 @@ TestObjectReadOnly.prototype = { shortReadOnly: 32767, longReadOnly: 2147483647, floatReadOnly: 5.5, - charReadOnly: "X" + charReadOnly: "X", + // timeProperty is PRTime and signed type. + // So it has to allow negative value. + timeReadOnly: -1 }; diff --git a/js/xpconnect/tests/components/native/xpctest_attributes.cpp b/js/xpconnect/tests/components/native/xpctest_attributes.cpp index 49ec55371d5..9aa09504dbb 100644 --- a/js/xpconnect/tests/components/native/xpctest_attributes.cpp +++ b/js/xpconnect/tests/components/native/xpctest_attributes.cpp @@ -14,6 +14,9 @@ xpcTestObjectReadOnly :: xpcTestObjectReadOnly() { longProperty = 2147483647; floatProperty = 5.5f; charProperty = 'X'; + // timeProperty is PRTime and signed type. + // So it has to allow negative value. + timeProperty = -1; } NS_IMETHODIMP xpcTestObjectReadOnly :: GetStrReadOnly(char * *aStrReadOnly){ @@ -46,6 +49,10 @@ NS_IMETHODIMP xpcTestObjectReadOnly :: GetCharReadOnly(char *aCharReadOnly){ *aCharReadOnly = charProperty; return NS_OK; } +NS_IMETHODIMP xpcTestObjectReadOnly :: GetTimeReadOnly(PRTime *aTimeReadOnly){ + *aTimeReadOnly = timeProperty; + return NS_OK; +} NS_IMPL_ISUPPORTS1(xpcTestObjectReadWrite, nsIXPCTestObjectReadWrite) @@ -57,6 +64,9 @@ xpcTestObjectReadWrite :: xpcTestObjectReadWrite() { longProperty = 2147483647; floatProperty = 5.5f; charProperty = 'X'; + // timeProperty is PRTime and signed type. + // So it has to allow negative value. + timeProperty = -1; } xpcTestObjectReadWrite :: ~xpcTestObjectReadWrite() @@ -119,3 +129,11 @@ NS_IMETHODIMP xpcTestObjectReadWrite :: SetCharProperty(char aCharProperty) { charProperty = aCharProperty; return NS_OK; } +NS_IMETHODIMP xpcTestObjectReadWrite :: GetTimeProperty(PRTime *aTimeProperty) { + *aTimeProperty = timeProperty; + return NS_OK; +} +NS_IMETHODIMP xpcTestObjectReadWrite :: SetTimeProperty(PRTime aTimeProperty) { + timeProperty = aTimeProperty; + return NS_OK; +} diff --git a/js/xpconnect/tests/components/native/xpctest_private.h b/js/xpconnect/tests/components/native/xpctest_private.h index ae62afd205b..65a153c821f 100644 --- a/js/xpconnect/tests/components/native/xpctest_private.h +++ b/js/xpconnect/tests/components/native/xpctest_private.h @@ -29,6 +29,7 @@ class xpcTestObjectReadOnly MOZ_FINAL : public nsIXPCTestObjectReadOnly { PRInt32 longProperty; float floatProperty; char charProperty; + PRTime timeProperty; }; class xpcTestObjectReadWrite MOZ_FINAL : public nsIXPCTestObjectReadWrite { @@ -46,6 +47,7 @@ class xpcTestObjectReadWrite MOZ_FINAL : public nsIXPCTestObjectReadWrite { float floatProperty; char charProperty; char *stringProperty; + PRTime timeProperty; }; class nsXPCTestParams MOZ_FINAL : public nsIXPCTestParams diff --git a/js/xpconnect/tests/idl/xpctest_attributes.idl b/js/xpconnect/tests/idl/xpctest_attributes.idl index b9fe4cc046f..cbecaa08e39 100644 --- a/js/xpconnect/tests/idl/xpctest_attributes.idl +++ b/js/xpconnect/tests/idl/xpctest_attributes.idl @@ -10,7 +10,7 @@ * */ -[scriptable, uuid(29e950a0-0134-44bc-b947-5e0ee95c8f7e)] +[scriptable, uuid(42fbd9f6-b12d-47ef-b7a1-02d73c11fe53)] interface nsIXPCTestObjectReadOnly : nsISupports { readonly attribute string strReadOnly; readonly attribute boolean boolReadOnly; @@ -18,9 +18,10 @@ interface nsIXPCTestObjectReadOnly : nsISupports { readonly attribute long longReadOnly; readonly attribute float floatReadOnly; readonly attribute char charReadOnly; + readonly attribute PRTime timeReadOnly; }; -[scriptable, uuid(492609a7-2582-436b-b0ef-92e29bb9e143)] +[scriptable, uuid(f07529b0-a479-4954-aba5-ab3142c6b1cb)] interface nsIXPCTestObjectReadWrite : nsISupports { attribute string stringProperty; attribute boolean booleanProperty; @@ -28,4 +29,5 @@ interface nsIXPCTestObjectReadWrite : nsISupports { attribute long longProperty; attribute float floatProperty; attribute char charProperty; + attribute PRTime timeProperty; }; diff --git a/js/xpconnect/tests/unit/test_attributes.js b/js/xpconnect/tests/unit/test_attributes.js index b3c0bb0c0bd..c033728b7bd 100644 --- a/js/xpconnect/tests/unit/test_attributes.js +++ b/js/xpconnect/tests/unit/test_attributes.js @@ -30,6 +30,7 @@ function test_component_readwrite(contractid) { do_check_eq(2147483647, o.longProperty); do_check_true(5.25 < o.floatProperty && 5.75 > o.floatProperty); do_check_eq("X", o.charProperty); + do_check_eq(-1, o.timeProperty); // Write new values. o.stringProperty = "another string"; @@ -38,6 +39,7 @@ function test_component_readwrite(contractid) { o.longProperty = 1234567890; o.floatProperty = 10.2; o.charProperty = "Z"; + o.timeProperty = 1; // Test the new values. do_check_eq("another string", o.stringProperty); @@ -46,6 +48,7 @@ function test_component_readwrite(contractid) { do_check_eq(1234567890, o.longProperty); do_check_true(10.15 < o.floatProperty && 10.25 > o.floatProperty); do_check_eq("Z", o.charProperty); + do_check_eq(1, o.timeProperty); // Assign values that differ from the expected type to verify conversion. @@ -74,4 +77,5 @@ function test_component_readonly(contractid) { do_check_eq(2147483647, o.longReadOnly); do_check_true(5.25 < o.floatReadOnly && 5.75 > o.floatReadOnly); do_check_eq("X", o.charReadOnly); + do_check_eq(-1, o.timeReadOnly); } diff --git a/xpcom/base/nsrootidl.idl b/xpcom/base/nsrootidl.idl index c53a40c4868..3d0be32d5f6 100644 --- a/xpcom/base/nsrootidl.idl +++ b/xpcom/base/nsrootidl.idl @@ -30,7 +30,7 @@ typedef unsigned short PRUint16 ; typedef unsigned short PRUnichar; typedef unsigned long PRUint32 ; typedef unsigned long long PRUint64 ; -typedef unsigned long long PRTime ; +typedef long long PRTime ; typedef short PRInt16 ; typedef long PRInt32 ; typedef long long PRInt64 ;