mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1517674 - Rename JS_NewDateObject and JS_ObjectIsDate to JS:: versions of the same, and move their declarations to js/public/Date.h and their implementations to js/src/jsdate.cpp. r=arai
--HG-- extra : rebase_source : 581fa2b7831ab09c33801f8e9a52a78566973ff4
This commit is contained in:
parent
a128f0c35c
commit
7883beee5b
@ -5190,7 +5190,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||
name = getUnionMemberName(memberType)
|
||||
dateObject = CGGeneric("%s.SetTo%s(cx, ${val});\n"
|
||||
"done = true;\n" % (unionArgumentObj, name))
|
||||
dateObject = CGIfWrapper(dateObject, "JS_ObjectIsDate(cx, argObj)")
|
||||
dateObject = CGIfWrapper(dateObject, "JS::ObjectIsDate(cx, argObj)")
|
||||
names.append(name)
|
||||
else:
|
||||
dateObject = None
|
||||
@ -6207,7 +6207,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||
JS::Rooted<JSObject*> possibleDateObject(cx, &$${val}.toObject());
|
||||
{ // scope for isDate
|
||||
bool isDate;
|
||||
if (!JS_ObjectIsDate(cx, possibleDateObject, &isDate)) {
|
||||
if (!JS::ObjectIsDate(cx, possibleDateObject, &isDate)) {
|
||||
$*{exceptionCode}
|
||||
}
|
||||
if (!isDate) {
|
||||
|
@ -29,11 +29,15 @@
|
||||
* of accessor methods to the various aspects of the represented date.
|
||||
*/
|
||||
|
||||
#include "mozilla/FloatingPoint.h"
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/FloatingPoint.h" // mozilla::{IsFinite,IsNaN}, mozilla::UnspecifiedNaN
|
||||
#include "mozilla/MathAlgorithms.h" // mozilla::Abs
|
||||
|
||||
#include "js/Conversions.h"
|
||||
#include "js/Value.h"
|
||||
#include "js/Conversions.h" // JS::ToInteger
|
||||
#include "js/RootingAPI.h" // JS::Handle
|
||||
#include "js/Value.h" // JS::CanonicalizeNaN, JS::DoubleValue, JS::Value
|
||||
|
||||
struct JSContext;
|
||||
class JSObject;
|
||||
|
||||
namespace JS {
|
||||
|
||||
@ -110,7 +114,7 @@ inline ClippedTime TimeClip(double time) {
|
||||
// Produce a double Value from the given time. Because times may be NaN,
|
||||
// prefer using this to manual canonicalization.
|
||||
inline Value TimeValue(ClippedTime time) {
|
||||
return DoubleValue(JS::CanonicalizeNaN(time.toDouble()));
|
||||
return DoubleValue(CanonicalizeNaN(time.toDouble()));
|
||||
}
|
||||
|
||||
// Create a new Date object whose [[DateValue]] internal slot contains the
|
||||
@ -118,6 +122,31 @@ inline Value TimeValue(ClippedTime time) {
|
||||
// another representation.)
|
||||
extern JS_PUBLIC_API JSObject* NewDateObject(JSContext* cx, ClippedTime time);
|
||||
|
||||
/**
|
||||
* Create a new Date object for a year/month/day-of-month/hour/minute/second.
|
||||
*
|
||||
* The created date is initialized with the time value
|
||||
*
|
||||
* TimeClip(UTC(MakeDate(MakeDay(year, mon, mday),
|
||||
* MakeTime(hour, min, sec, 0.0))))
|
||||
*
|
||||
* where each function/operation is as specified in ECMAScript.
|
||||
*/
|
||||
extern JS_PUBLIC_API JSObject* NewDateObject(JSContext* cx, int year, int mon,
|
||||
int mday, int hour, int min,
|
||||
int sec);
|
||||
|
||||
/**
|
||||
* On success, returns true, setting |*isDate| to true if |obj| is a Date
|
||||
* object or a wrapper around one, or to false if not. Returns false on
|
||||
* failure.
|
||||
*
|
||||
* This method returns true with |*isDate == false| when passed an ES6 proxy
|
||||
* whose target is a Date, or when passed a revoked proxy.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool ObjectIsDate(JSContext* cx, Handle<JSObject*> obj,
|
||||
bool* isDate);
|
||||
|
||||
// Year is a year, month is 0-11, day is 1-based. The return value is a number
|
||||
// of milliseconds since the epoch.
|
||||
//
|
||||
|
@ -387,7 +387,7 @@ const WHITELIST_FUNCTIONS: &'static [&'static str] = &[
|
||||
"JS_NewUint8Array",
|
||||
"JS_NewUint8ClampedArray",
|
||||
"js::ObjectClassName",
|
||||
"JS_ObjectIsDate",
|
||||
"JS::ObjectIsDate",
|
||||
"JS_ParseJSON",
|
||||
"JS_ReadBytes",
|
||||
"JS_ReadStructuredClone",
|
||||
|
@ -16,6 +16,7 @@ typedef uint32_t HashNumber;
|
||||
#include "js/CompilationAndEvaluation.h"
|
||||
#include "js/CompileOptions.h"
|
||||
#include "js/Conversions.h"
|
||||
#include "js/Date.h"
|
||||
#include "js/Initialization.h"
|
||||
#include "js/MemoryMetrics.h"
|
||||
#include "js/SourceText.h"
|
||||
|
@ -4970,37 +4970,6 @@ JS_PUBLIC_API JS::WarningReporter JS::SetWarningReporter(
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
* Dates.
|
||||
*/
|
||||
JS_PUBLIC_API JSObject* JS_NewDateObject(JSContext* cx, int year, int mon,
|
||||
int mday, int hour, int min, int sec) {
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
return NewDateObject(cx, year, mon, mday, hour, min, sec);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS::NewDateObject(JSContext* cx, JS::ClippedTime time) {
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
return NewDateObjectMsec(cx, time);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS_ObjectIsDate(JSContext* cx, HandleObject obj,
|
||||
bool* isDate) {
|
||||
cx->check(obj);
|
||||
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*isDate = cls == ESClass::Date;
|
||||
return true;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
* Regular Expressions.
|
||||
*/
|
||||
|
@ -3399,25 +3399,6 @@ extern JS_PUBLIC_API bool SetForEach(JSContext* cx, HandleObject obj,
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
/*
|
||||
* Dates.
|
||||
*/
|
||||
|
||||
extern JS_PUBLIC_API JSObject* JS_NewDateObject(JSContext* cx, int year,
|
||||
int mon, int mday, int hour,
|
||||
int min, int sec);
|
||||
|
||||
/**
|
||||
* On success, returns true, setting |*isDate| to true if |obj| is a Date
|
||||
* object or a wrapper around one, or to false if not. Returns false on
|
||||
* failure.
|
||||
*
|
||||
* This method returns true with |*isDate == false| when passed an ES6 proxy
|
||||
* whose target is a Date, or when passed a revoked proxy.
|
||||
*/
|
||||
extern JS_PUBLIC_API bool JS_ObjectIsDate(JSContext* cx, JS::HandleObject obj,
|
||||
bool* isDate);
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/*
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "jsnum.h"
|
||||
#include "jstypes.h"
|
||||
#include "jsutil.h"
|
||||
@ -3357,6 +3358,12 @@ JSObject* js::NewDateObjectMsec(JSContext* cx, ClippedTime t,
|
||||
return obj;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS::NewDateObject(JSContext* cx, ClippedTime time) {
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
return NewDateObjectMsec(cx, time);
|
||||
}
|
||||
|
||||
JS_FRIEND_API JSObject* js::NewDateObject(JSContext* cx, int year, int mon,
|
||||
int mday, int hour, int min,
|
||||
int sec) {
|
||||
@ -3387,6 +3394,27 @@ JS_FRIEND_API bool js::DateIsValid(JSContext* cx, HandleObject obj,
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API JSObject* JS::NewDateObject(JSContext* cx, int year, int mon,
|
||||
int mday, int hour, int min,
|
||||
int sec) {
|
||||
AssertHeapIsIdle();
|
||||
CHECK_THREAD(cx);
|
||||
return js::NewDateObject(cx, year, mon, mday, hour, min, sec);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API bool JS::ObjectIsDate(JSContext* cx, Handle<JSObject*> obj,
|
||||
bool* isDate) {
|
||||
cx->check(obj);
|
||||
|
||||
ESClass cls;
|
||||
if (!GetBuiltinClass(cx, obj, &cls)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*isDate = cls == ESClass::Date;
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_FRIEND_API bool js::DateGetMsecSinceEpoch(JSContext* cx, HandleObject obj,
|
||||
double* msecsSinceEpoch) {
|
||||
ESClass cls;
|
||||
|
Loading…
Reference in New Issue
Block a user