зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset f223b115ad37 (bug 891107)
This commit is contained in:
Родитель
da7b7e3756
Коммит
ed7fa27091
|
@ -1337,14 +1337,6 @@ ArgumentTypeMismatch(JSContext* cx, const char* arg, const char* func,
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
CannotConstructError(JSContext* cx, const char* type)
|
||||
{
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
|
||||
CTYPESMSG_CANNOT_CONSTRUCT, type);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
DuplicateFieldError(JSContext* cx, Handle<JSFlatString*> name)
|
||||
{
|
||||
|
@ -4201,7 +4193,8 @@ ConstructAbstract(JSContext* cx,
|
|||
Value* vp)
|
||||
{
|
||||
// Calling an abstract base class constructor is disallowed.
|
||||
return CannotConstructError(cx, "abstract type");
|
||||
JS_ReportError(cx, "cannot construct from abstract type");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -4226,7 +4219,8 @@ CType::ConstructData(JSContext* cx,
|
|||
// * __proto__ === t.prototype
|
||||
switch (GetTypeCode(obj)) {
|
||||
case TYPE_void_t:
|
||||
return CannotConstructError(cx, "void_t");
|
||||
JS_ReportError(cx, "cannot construct from void_t");
|
||||
return false;
|
||||
case TYPE_function:
|
||||
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr,
|
||||
CTYPESMSG_FUNCTION_CONSTRUCT);
|
||||
|
|
|
@ -62,6 +62,3 @@ MSG_DEF(CTYPESMSG_ARG_TYPE_ERROR,3, JSEXN_TYPEERR, "the type of argument {0} {1}
|
|||
MSG_DEF(CTYPESMSG_FUNCTION_CONSTRUCT,0, JSEXN_TYPEERR, "cannot construct from FunctionType; use FunctionType.ptr instead")
|
||||
MSG_DEF(CTYPESMSG_RET_TYPE_ERROR,2, JSEXN_TYPEERR, "return type {0} (got {1})")
|
||||
MSG_DEF(CTYPESMSG_VARG_TYPE_ERROR,2, JSEXN_TYPEERR, "variadic argument {0} must be a CData object (got {1})")
|
||||
|
||||
/* ctype */
|
||||
MSG_DEF(CTYPESMSG_CANNOT_CONSTRUCT,1, JSEXN_TYPEERR, "cannot construct from {0}")
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
load(libdir + 'asserts.js');
|
||||
|
||||
function test() {
|
||||
assertTypeErrorMessage(() => { ctypes.void_t(); },
|
||||
"cannot construct from void_t");
|
||||
assertTypeErrorMessage(() => { ctypes.CType(); },
|
||||
"cannot construct from abstract type");
|
||||
}
|
||||
|
||||
if (typeof ctypes === "object")
|
||||
test();
|
|
@ -228,16 +228,16 @@ function run_test()
|
|||
function run_abstract_class_tests()
|
||||
{
|
||||
// Test that ctypes.CType is an abstract constructor that throws.
|
||||
do_check_throws(function() { ctypes.CType(); }, TypeError);
|
||||
do_check_throws(function() { new ctypes.CType() }, TypeError);
|
||||
do_check_throws(function() { ctypes.CType(); }, Error);
|
||||
do_check_throws(function() { new ctypes.CType() }, Error);
|
||||
|
||||
// Test that classes and prototypes are set up correctly.
|
||||
do_check_class(ctypes.CType, "Function");
|
||||
do_check_class(ctypes.CType.prototype, "CType");
|
||||
|
||||
do_check_true(ctypes.CType.hasOwnProperty("prototype"));
|
||||
do_check_throws(function() { ctypes.CType.prototype(); }, TypeError);
|
||||
do_check_throws(function() { new ctypes.CType.prototype() }, TypeError);
|
||||
do_check_throws(function() { ctypes.CType.prototype(); }, Error);
|
||||
do_check_throws(function() { new ctypes.CType.prototype() }, Error);
|
||||
|
||||
do_check_true(ctypes.CType.prototype.hasOwnProperty("constructor"));
|
||||
do_check_true(ctypes.CType.prototype.constructor === ctypes.CType);
|
||||
|
@ -266,8 +266,8 @@ function run_abstract_class_tests()
|
|||
do_check_eq(typeof ctypes.CType.prototype.toSource(), 'string');
|
||||
|
||||
// Test that ctypes.CData is an abstract constructor that throws.
|
||||
do_check_throws(function() { ctypes.CData(); }, TypeError);
|
||||
do_check_throws(function() { new ctypes.CData() }, TypeError);
|
||||
do_check_throws(function() { ctypes.CData(); }, Error);
|
||||
do_check_throws(function() { new ctypes.CData() }, Error);
|
||||
|
||||
// Test that classes and prototypes are set up correctly.
|
||||
do_check_class(ctypes.CData, "Function");
|
||||
|
|
Загрузка…
Ссылка в новой задаче