Backed out changeset 14ab9b8d15be (bug 983989)

This commit is contained in:
Ed Morley 2014-04-10 15:48:04 +01:00
Родитель 2de6a240e8
Коммит 34e35d1dc3
1 изменённых файлов: 42 добавлений и 43 удалений

Просмотреть файл

@ -106,38 +106,38 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
switch (type.TagPart()) {
case nsXPTType::T_I8 :
d.setInt32(*static_cast<const int8_t*>(s));
d.setInt32(*((int8_t*)s));
return true;
case nsXPTType::T_I16 :
d.setInt32(*static_cast<const int16_t*>(s));
d.setInt32(*((int16_t*)s));
return true;
case nsXPTType::T_I32 :
d.setInt32(*static_cast<const int32_t*>(s));
d.setInt32(*((int32_t*)s));
return true;
case nsXPTType::T_I64 :
d.setNumber(static_cast<double>(*static_cast<const int64_t*>(s)));
d.setNumber(double(*((int64_t*)s)));
return true;
case nsXPTType::T_U8 :
d.setInt32(*static_cast<const uint8_t*>(s));
d.setInt32(*((uint8_t*)s));
return true;
case nsXPTType::T_U16 :
d.setInt32(*static_cast<const uint16_t*>(s));
d.setInt32(*((uint16_t*)s));
return true;
case nsXPTType::T_U32 :
d.setNumber(*static_cast<const uint32_t*>(s));
d.setNumber(*((uint32_t*)s));
return true;
case nsXPTType::T_U64 :
d.setNumber(static_cast<double>(*static_cast<const uint64_t*>(s)));
d.setNumber(double(*((uint64_t*)s)));
return true;
case nsXPTType::T_FLOAT :
d.setNumber(*static_cast<const float*>(s));
d.setNumber(*((float*)s));
return true;
case nsXPTType::T_DOUBLE:
d.setNumber(*static_cast<const double*>(s));
d.setNumber(*((double*)s));
return true;
case nsXPTType::T_BOOL :
{
bool b = *static_cast<const bool*>(s);
bool b = *((bool*)s);
NS_WARN_IF_FALSE(b == 1 || b == 0,
"Passing a malformed bool through XPConnect");
@ -146,35 +146,38 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
}
case nsXPTType::T_CHAR :
{
char p = *static_cast<const char*>(s);
char* p = (char*)s;
if (!p)
return false;
#ifdef STRICT_CHECK_OF_UNICODE
MOZ_ASSERT(! ILLEGAL_CHAR_RANGE(p) , "passing non ASCII data");
#endif // STRICT_CHECK_OF_UNICODE
JSString* str = JS_NewStringCopyN(cx, &p, 1);
if (!str)
JSString* str;
if (!(str = JS_NewStringCopyN(cx, p, 1)))
return false;
d.setString(str);
return true;
}
case nsXPTType::T_WCHAR :
{
jschar p = *static_cast<const jschar*>(s);
JSString* str = JS_NewUCStringCopyN(cx, &p, 1);
if (!str)
jschar* p = (jschar*)s;
if (!p)
return false;
JSString* str;
if (!(str = JS_NewUCStringCopyN(cx, p, 1)))
return false;
d.setString(str);
return true;
}
case nsXPTType::T_JSVAL :
{
d.set(*static_cast<const Value*>(s));
return JS_WrapValue(cx, d);
d.set(*((Value*)s));
if (!JS_WrapValue(cx, d))
return false;
return true;
}
case nsXPTType::T_VOID:
@ -183,17 +186,15 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
case nsXPTType::T_IID:
{
nsID* iid2 = *static_cast<nsID* const *>(s);
nsID* iid2 = *((nsID**)s);
if (!iid2) {
d.setNull();
return true;
}
RootedObject scope(cx, JS::CurrentGlobalOrNull(cx));
JSObject* obj = xpc_NewIDObject(cx, scope, *iid2);
if (!obj)
JSObject* obj;
if (!(obj = xpc_NewIDObject(cx, scope, *iid2)))
return false;
d.setObject(*obj);
return true;
}
@ -203,7 +204,7 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
case nsXPTType::T_DOMSTRING:
{
const nsAString* p = *static_cast<const nsAString* const *>(s);
const nsAString* p = *((const nsAString**)s);
if (!p || p->IsVoid()) {
d.setNull();
return true;
@ -219,7 +220,7 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
case nsXPTType::T_CHAR_STR:
{
const char* p = *static_cast<const char* const *>(s);
char* p = *((char**)s);
if (!p) {
d.setNull();
return true;
@ -227,39 +228,37 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
#ifdef STRICT_CHECK_OF_UNICODE
bool isAscii = true;
for (char* t = p; *t && isAscii; t++) {
char* t;
for (t=p; *t && isAscii ; t++) {
if (ILLEGAL_CHAR_RANGE(*t))
isAscii = false;
}
MOZ_ASSERT(isAscii, "passing non ASCII data");
#endif // STRICT_CHECK_OF_UNICODE
JSString* str = JS_NewStringCopyZ(cx, p);
if (!str)
JSString* str;
if (!(str = JS_NewStringCopyZ(cx, p)))
return false;
d.setString(str);
return true;
}
case nsXPTType::T_WCHAR_STR:
{
const jschar* p = *static_cast<const jschar* const *>(s);
jschar* p = *((jschar**)s);
if (!p) {
d.setNull();
return true;
}
JSString* str = JS_NewUCStringCopyZ(cx, p);
if (!str)
JSString* str;
if (!(str = JS_NewUCStringCopyZ(cx, p)))
return false;
d.setString(str);
return true;
}
case nsXPTType::T_UTF8STRING:
{
const nsACString* utf8String = *static_cast<const nsACString* const *>(s);
const nsACString* utf8String = *((const nsACString**)s);
if (!utf8String || utf8String->IsVoid()) {
d.setNull();
@ -295,7 +294,7 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
// JS_NewUCString takes ownership on success, i.e. a
// successful call will make it the responsiblity of the JS VM
// to free the buffer.
JSString* str = JS_NewUCString(cx, buffer, len);
JSString* str = JS_NewUCString(cx, (jschar*)buffer, len);
if (!str) {
JS_free(cx, buffer);
return false;
@ -306,7 +305,7 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
}
case nsXPTType::T_CSTRING:
{
const nsACString* cString = *static_cast<const nsACString* const *>(s);
const nsACString* cString = *((const nsACString**)s);
if (!cString || cString->IsVoid()) {
d.setNull();
@ -328,7 +327,7 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
case nsXPTType::T_INTERFACE:
case nsXPTType::T_INTERFACE_IS:
{
nsISupports* iface = *static_cast<nsISupports* const *>(s);
nsISupports* iface = *((nsISupports**)s);
if (!iface) {
d.setNull();
return true;
@ -342,7 +341,7 @@ XPCConvert::NativeData2JS(MutableHandleValue d, const void* s,
return XPCVariant::VariantDataToJS(variant,
pErr, d);
}
// else...
xpcObjectHelper helper(iface);
return NativeInterface2JSObject(d, nullptr, helper, iid, nullptr, true, pErr);
}