mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 742893 - Part a: Make xpc_qsValueTo{Uint,Int}64 public; r=bholley
This commit is contained in:
parent
9989b037f1
commit
7164d44025
@ -1324,13 +1324,13 @@ def getArgumentConversionTemplate(type, descriptor):
|
||||
elif tag is IDLType.Tags.int64:
|
||||
# XXXbz this may not match what WebIDL says to do in terms of reducing
|
||||
# mod 2^64. Should we check?
|
||||
replacements["jstype"] = "PRInt64"
|
||||
replacements["converter"] = "xpc_qsValueToInt64"
|
||||
replacements["jstype"] = "int64_t"
|
||||
replacements["converter"] = "xpc::ValueToInt64"
|
||||
elif tag is IDLType.Tags.uint64:
|
||||
# XXXbz this may not match what WebIDL says to do in terms of reducing
|
||||
# mod 2^64. Should we check?
|
||||
replacements["jstype"] = "PRUint64"
|
||||
replacements["converter"] = "xpc_qsValueToUint64"
|
||||
replacements["jstype"] = "uint64_t"
|
||||
replacements["converter"] = "xpc::ValueToUint64"
|
||||
elif tag in [IDLType.Tags.float, IDLType.Tags.double]:
|
||||
replacements["jstype"] = "double"
|
||||
replacements["converter"] = "JS::ToNumber"
|
||||
|
@ -653,50 +653,6 @@ xpc_qsVariantToJsval(XPCLazyCallContext &ccx,
|
||||
nsIVariant *p,
|
||||
jsval *rval);
|
||||
|
||||
/**
|
||||
* Convert a jsval to PRInt64. Return true on success.
|
||||
*/
|
||||
inline JSBool
|
||||
xpc_qsValueToInt64(JSContext *cx,
|
||||
jsval v,
|
||||
PRInt64 *result)
|
||||
{
|
||||
if (JSVAL_IS_INT(v)) {
|
||||
int32_t intval;
|
||||
if (!JS_ValueToECMAInt32(cx, v, &intval))
|
||||
return false;
|
||||
*result = static_cast<PRInt64>(intval);
|
||||
} else {
|
||||
double doubleval;
|
||||
if (!JS_ValueToNumber(cx, v, &doubleval))
|
||||
return false;
|
||||
*result = static_cast<PRInt64>(doubleval);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a jsval to PRUint64. Return true on success.
|
||||
*/
|
||||
inline JSBool
|
||||
xpc_qsValueToUint64(JSContext *cx,
|
||||
jsval v,
|
||||
PRUint64 *result)
|
||||
{
|
||||
if (JSVAL_IS_INT(v)) {
|
||||
uint32_t intval;
|
||||
if (!JS_ValueToECMAUint32(cx, v, &intval))
|
||||
return false;
|
||||
*result = static_cast<PRUint64>(intval);
|
||||
} else {
|
||||
double doubleval;
|
||||
if (!JS_ValueToNumber(cx, v, &doubleval))
|
||||
return false;
|
||||
*result = static_cast<PRUint64>(doubleval);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
xpc_qsAssertContextOK(JSContext *cx);
|
||||
|
@ -127,13 +127,13 @@ argumentUnboxingTemplates = {
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'long long':
|
||||
" PRInt64 ${name};\n"
|
||||
" if (!xpc_qsValueToInt64(cx, ${argVal}, &${name}))\n"
|
||||
" int64_t ${name};\n"
|
||||
" if (!xpc::ValueToInt64(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'unsigned long long':
|
||||
" PRUint64 ${name};\n"
|
||||
" if (!xpc_qsValueToUint64(cx, ${argVal}, &${name}))\n"
|
||||
" uint64_t ${name};\n"
|
||||
" if (!xpc::ValueToUint64(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'float':
|
||||
|
@ -456,13 +456,13 @@ argumentUnboxingTemplates = {
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'long long':
|
||||
" PRInt64 ${name};\n"
|
||||
" if (!xpc_qsValueToInt64(cx, ${argVal}, &${name}))\n"
|
||||
" int64_t ${name};\n"
|
||||
" if (!xpc::ValueToInt64(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'unsigned long long':
|
||||
" PRUint64 ${name};\n"
|
||||
" if (!xpc_qsValueToUint64(cx, ${argVal}, &${name}))\n"
|
||||
" uint64_t ${name};\n"
|
||||
" if (!xpc::ValueToUint64(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'float':
|
||||
|
@ -260,6 +260,46 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
|
||||
nsIMemoryMultiReporterCallback *cb,
|
||||
nsISupports *closure);
|
||||
|
||||
/**
|
||||
* Convert a jsval to PRInt64. Return true on success.
|
||||
*/
|
||||
inline bool
|
||||
ValueToInt64(JSContext *cx, JS::Value v, int64_t *result)
|
||||
{
|
||||
if (JSVAL_IS_INT(v)) {
|
||||
int32_t intval;
|
||||
if (!JS_ValueToECMAInt32(cx, v, &intval))
|
||||
return false;
|
||||
*result = static_cast<int64_t>(intval);
|
||||
} else {
|
||||
double doubleval;
|
||||
if (!JS_ValueToNumber(cx, v, &doubleval))
|
||||
return false;
|
||||
*result = static_cast<int64_t>(doubleval);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a jsval to uint64_t. Return true on success.
|
||||
*/
|
||||
inline bool
|
||||
ValueToUint64(JSContext *cx, JS::Value v, uint64_t *result)
|
||||
{
|
||||
if (JSVAL_IS_INT(v)) {
|
||||
uint32_t intval;
|
||||
if (!JS_ValueToECMAUint32(cx, v, &intval))
|
||||
return false;
|
||||
*result = static_cast<uint64_t>(intval);
|
||||
} else {
|
||||
double doubleval;
|
||||
if (!JS_ValueToNumber(cx, v, &doubleval))
|
||||
return false;
|
||||
*result = static_cast<uint64_t>(doubleval);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace xpc
|
||||
|
||||
namespace mozilla {
|
||||
|
Loading…
Reference in New Issue
Block a user