mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
auto merge of #2194 : Ms2ger/servo/typeerror-2, r=jdm
This commit is contained in:
commit
0bfbe06f4b
3 changed files with 37 additions and 5 deletions
|
@ -143,7 +143,7 @@ class CGMethodCall(CGThing):
|
||||||
def __init__(self, argsPre, nativeMethodName, static, descriptor, method):
|
def __init__(self, argsPre, nativeMethodName, static, descriptor, method):
|
||||||
CGThing.__init__(self)
|
CGThing.__init__(self)
|
||||||
|
|
||||||
methodName = '"%s.%s"' % (descriptor.interface.identifier.name, method.identifier.name)
|
methodName = '\\"%s.%s\\"' % (descriptor.interface.identifier.name, method.identifier.name)
|
||||||
|
|
||||||
def requiredArgCount(signature):
|
def requiredArgCount(signature):
|
||||||
arguments = signature[1]
|
arguments = signature[1]
|
||||||
|
@ -174,8 +174,8 @@ class CGMethodCall(CGThing):
|
||||||
if requiredArgs > 0:
|
if requiredArgs > 0:
|
||||||
code = (
|
code = (
|
||||||
"if argc < %d {\n"
|
"if argc < %d {\n"
|
||||||
" return 0; //XXXjdm throw exception\n"
|
" throw_type_error(cx, \"Not enough arguments to %s.\");\n"
|
||||||
" //return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, %s);\n"
|
" return 0;\n"
|
||||||
"}" % (requiredArgs, methodName))
|
"}" % (requiredArgs, methodName))
|
||||||
self.cgRoot.prepend(
|
self.cgRoot.prepend(
|
||||||
CGWrapper(CGIndenter(CGGeneric(code)), pre="\n", post="\n"))
|
CGWrapper(CGIndenter(CGGeneric(code)), pre="\n", post="\n"))
|
||||||
|
@ -4327,6 +4327,7 @@ class CGBindingRoot(CGThing):
|
||||||
'dom::bindings::codegen::UnionTypes::*',
|
'dom::bindings::codegen::UnionTypes::*',
|
||||||
'dom::bindings::error::{FailureUnknown, Fallible, Error, ErrorResult}',
|
'dom::bindings::error::{FailureUnknown, Fallible, Error, ErrorResult}',
|
||||||
'dom::bindings::error::{throw_method_failed_with_details}',
|
'dom::bindings::error::{throw_method_failed_with_details}',
|
||||||
|
'dom::bindings::error::throw_type_error',
|
||||||
'script_task::JSPageInfo',
|
'script_task::JSPageInfo',
|
||||||
'dom::bindings::proxyhandler',
|
'dom::bindings::proxyhandler',
|
||||||
'dom::bindings::proxyhandler::{_obj_toString, defineProperty}',
|
'dom::bindings::proxyhandler::{_obj_toString, defineProperty}',
|
||||||
|
|
|
@ -4,9 +4,12 @@
|
||||||
|
|
||||||
use js::jsapi::{JSContext, JSBool};
|
use js::jsapi::{JSContext, JSBool};
|
||||||
use js::jsapi::{JS_IsExceptionPending};
|
use js::jsapi::{JS_IsExceptionPending};
|
||||||
|
use js::jsapi::{JS_ReportErrorNumber, JSErrorFormatString, struct_JSErrorFormatString, JSEXN_TYPEERR};
|
||||||
use js::glue::{ReportError};
|
use js::glue::{ReportError};
|
||||||
|
|
||||||
|
use libc;
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
#[deriving(Show)]
|
#[deriving(Show)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
IndexSize,
|
IndexSize,
|
||||||
|
@ -44,3 +47,31 @@ pub fn throw_not_in_union(cx: *JSContext, names: &'static str) -> JSBool {
|
||||||
});
|
});
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ERROR_FORMAT_STRING_STRING: [libc::c_char, ..4] = [
|
||||||
|
'{' as libc::c_char,
|
||||||
|
'0' as libc::c_char,
|
||||||
|
'}' as libc::c_char,
|
||||||
|
0 as libc::c_char,
|
||||||
|
];
|
||||||
|
|
||||||
|
static ERROR_FORMAT_STRING: JSErrorFormatString = struct_JSErrorFormatString {
|
||||||
|
format: &ERROR_FORMAT_STRING_STRING as *libc::c_char,
|
||||||
|
argCount: 1,
|
||||||
|
exnType: JSEXN_TYPEERR as i16,
|
||||||
|
};
|
||||||
|
|
||||||
|
extern fn get_error_message(_user_ref: *mut libc::c_void,
|
||||||
|
_locale: *libc::c_char,
|
||||||
|
error_number: libc::c_uint) -> *JSErrorFormatString
|
||||||
|
{
|
||||||
|
assert_eq!(error_number, 0);
|
||||||
|
&ERROR_FORMAT_STRING as *JSErrorFormatString
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn throw_type_error(cx: *JSContext, error: &str) {
|
||||||
|
let error = error.to_c_str();
|
||||||
|
error.with_ref(|error| unsafe {
|
||||||
|
JS_ReportErrorNumber(cx, get_error_message, ptr::null(), 0, error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 46a6ae354fadc11a228c78b32e4365f6b6d8006d
|
Subproject commit 92d2979ff9656e6dcc018486bc3a7d1bcc63fd99
|
Loading…
Add table
Add a link
Reference in a new issue