Enable overloading ctors for v8.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13810 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
70383a1b61
commit
da6307a19e
2 changed files with 23 additions and 8 deletions
|
|
@ -55,16 +55,30 @@ fail:
|
||||||
return scope.Close(v8::Undefined());
|
return scope.Close(v8::Undefined());
|
||||||
}%}
|
}%}
|
||||||
|
|
||||||
/*
|
%fragment ("JS_mainctordefn", "templates") %{
|
||||||
%fragment ("JS_mainctordefn", "templates")
|
v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
||||||
%{
|
v8::HandleScope scope;
|
||||||
// TODO: implement JS_mainctordefn
|
|
||||||
|
v8::TryCatch tryCatch;
|
||||||
|
// switch all cases by means of series of if-returns.
|
||||||
|
$jsdispatchcases
|
||||||
|
|
||||||
|
// default:
|
||||||
|
if(!tryCatch.HasCaught())
|
||||||
|
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for contruction of $jsmangledname");
|
||||||
|
|
||||||
|
fail:
|
||||||
|
scope.Close(v8::Undefined());
|
||||||
|
}
|
||||||
%}
|
%}
|
||||||
*/
|
|
||||||
|
|
||||||
%fragment ("JS_ctor_dispatch_case", "templates")
|
%fragment ("JS_ctor_dispatch_case", "templates")
|
||||||
%{
|
%{if(args.Length() == $jsargcount) {
|
||||||
// TODO: implement JS_ctor_dispatch_case
|
v8::Handle<v8::Value> self = $jswrapper(args);
|
||||||
|
if(!self->IsUndefined()) {
|
||||||
|
tryCatch.Reset(); return scope.Close(self); /* reset exception and return */
|
||||||
|
}
|
||||||
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%fragment ("JS_destructordefn", "templates")
|
%fragment ("JS_destructordefn", "templates")
|
||||||
|
|
|
||||||
|
|
@ -837,6 +837,7 @@ int JSEmitter::emitCtor(Node *n) {
|
||||||
String *wrap_name = Swig_name_wrapper(Getattr(n, "sym:name"));
|
String *wrap_name = Swig_name_wrapper(Getattr(n, "sym:name"));
|
||||||
Template t_mainctor(getTemplate("JS_mainctordefn"));
|
Template t_mainctor(getTemplate("JS_mainctordefn"));
|
||||||
t_mainctor.replace(T_WRAPPER, wrap_name)
|
t_mainctor.replace(T_WRAPPER, wrap_name)
|
||||||
|
.replace(T_NAME_MANGLED, state.clazz(NAME_MANGLED))
|
||||||
.replace(T_DISPATCH_CASES, state.clazz(CTOR_DISPATCHERS))
|
.replace(T_DISPATCH_CASES, state.clazz(CTOR_DISPATCHERS))
|
||||||
.pretty_print(f_wrappers);
|
.pretty_print(f_wrappers);
|
||||||
state.clazz(CTOR, wrap_name);
|
state.clazz(CTOR, wrap_name);
|
||||||
|
|
@ -1845,7 +1846,7 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar
|
||||||
}
|
}
|
||||||
|
|
||||||
// store number of arguments for argument checks
|
// store number of arguments for argument checks
|
||||||
int num_args = emit_num_arguments(parms) - startIdx;
|
int num_args = emit_num_arguments(parms);
|
||||||
String *argcount = NewString("");
|
String *argcount = NewString("");
|
||||||
Printf(argcount, "%d", num_args);
|
Printf(argcount, "%d", num_args);
|
||||||
Setattr(n, ARGCOUNT, argcount);
|
Setattr(n, ARGCOUNT, argcount);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue