Improve names and comments of code templates for javascript emitters.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13826 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
8b7a9fec25
commit
131a106204
3 changed files with 428 additions and 276 deletions
|
|
@ -1,4 +1,4 @@
|
|||
%fragment("JS_ctordefn", "templates") %{
|
||||
%fragment("js_ctor", "templates") %{
|
||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::Object> self = args.Holder();
|
||||
|
|
@ -11,18 +11,36 @@ v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
|||
goto fail;
|
||||
fail:
|
||||
return scope.Close(v8::Undefined());
|
||||
}%}
|
||||
}
|
||||
%}
|
||||
|
||||
%fragment ("JS_veto_ctor", "templates")
|
||||
%fragment ("js_veto_ctor", "templates")
|
||||
%{
|
||||
v8::Handle<v8::Value> $jsctor(const v8::Arguments& args) {
|
||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
||||
v8::HandleScope scope;
|
||||
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
|
||||
return scope.Close(v8::Undefined());
|
||||
}
|
||||
%}
|
||||
|
||||
%fragment ("JS_mainctordefn", "templates") %{
|
||||
%fragment("js_overloaded_ctor", "templates") %{
|
||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::Object> self = args.Holder();
|
||||
$jslocals
|
||||
$jscode
|
||||
|
||||
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
||||
return scope.Close(self);
|
||||
|
||||
goto fail;
|
||||
fail:
|
||||
return scope.Close(v8::Undefined());
|
||||
}
|
||||
%}
|
||||
|
||||
%fragment ("js_ctor_dispatcher", "templates")
|
||||
%{
|
||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
||||
v8::HandleScope scope;
|
||||
|
||||
|
|
@ -37,8 +55,9 @@ fail:
|
|||
}
|
||||
%}
|
||||
|
||||
%fragment ("JS_ctor_dispatch_case", "templates")
|
||||
%{if(args.Length() == $jsargcount) {
|
||||
%fragment ("js_ctor_dispatch_case", "templates")
|
||||
%{
|
||||
if(args.Length() == $jsargcount) {
|
||||
v8::Handle<v8::Value> self = $jswrapper(args);
|
||||
if(!self->IsUndefined()) {
|
||||
return scope.Close(self);
|
||||
|
|
@ -46,7 +65,7 @@ fail:
|
|||
}
|
||||
%}
|
||||
|
||||
%fragment ("JS_destructordefn", "templates")
|
||||
%fragment ("js_dtor", "templates")
|
||||
%{
|
||||
void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
|
||||
SWIGV8_Proxy* proxy = (SWIGV8_Proxy*) parameter;
|
||||
|
|
@ -59,8 +78,9 @@ void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
|
|||
%}
|
||||
|
||||
|
||||
%fragment("JS_getproperty", "templates") %{
|
||||
v8::Handle<v8::Value> $jsgetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
|
||||
%fragment("js_getter", "templates")
|
||||
%{
|
||||
v8::Handle<v8::Value> $jswrapper(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::Value> jsresult;
|
||||
$jslocals
|
||||
|
|
@ -69,19 +89,23 @@ v8::Handle<v8::Value> $jsgetter(v8::Local<v8::String> property, const v8::Access
|
|||
goto fail;
|
||||
fail:
|
||||
return scope.Close(v8::Undefined());
|
||||
}%}
|
||||
}
|
||||
%}
|
||||
|
||||
%fragment("JS_setproperty", "templates") %{
|
||||
void $jssetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
|
||||
%fragment("js_setter", "templates")
|
||||
%{
|
||||
void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
|
||||
v8::HandleScope scope;
|
||||
$jslocals
|
||||
$jscode
|
||||
goto fail;
|
||||
fail:
|
||||
return;
|
||||
}%}
|
||||
}
|
||||
%}
|
||||
|
||||
%fragment("JS_functionwrapper", "templates") %{
|
||||
%fragment("js_function", "templates")
|
||||
%{
|
||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::Value> jsresult;
|
||||
|
|
@ -94,7 +118,8 @@ fail:
|
|||
}
|
||||
%}
|
||||
|
||||
%fragment("JS_function_dispatcher", "templates") %{
|
||||
%fragment("js_function_dispatcher", "templates")
|
||||
%{
|
||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments &args) {
|
||||
v8::HandleScope scope;
|
||||
v8::Handle<v8::Value> jsresult;
|
||||
|
|
@ -109,7 +134,7 @@ fail:
|
|||
}
|
||||
%}
|
||||
|
||||
%fragment ("JS_functionwrapper_overload", "templates")
|
||||
%fragment ("js_overloaded_function", "templates")
|
||||
%{
|
||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments &args, V8ErrorHandler& SWIGV8_ErrorHandler)
|
||||
{
|
||||
|
|
@ -126,7 +151,7 @@ fail:
|
|||
}
|
||||
%}
|
||||
|
||||
%fragment ("JS_function_dispatch_case", "templates")
|
||||
%fragment ("js_function_dispatch_case", "templates")
|
||||
%{
|
||||
if(args.Length() == $jsargcount) {
|
||||
errorHandler.err.Clear();
|
||||
|
|
@ -137,53 +162,69 @@ fail:
|
|||
}
|
||||
%}
|
||||
|
||||
%fragment ("JS_function_dispatch_case_default", "templates")
|
||||
%{
|
||||
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for function $jsname.");
|
||||
%}
|
||||
|
||||
%fragment("jsv8_declare_class_template", "templates")
|
||||
%{SWIGV8_ClientData $jsmangledname_clientData;
|
||||
%{
|
||||
SWIGV8_ClientData $jsmangledname_clientData;
|
||||
%}
|
||||
|
||||
%fragment("jsv8_define_class_template", "templates")
|
||||
%{v8::Handle<v8::FunctionTemplate> $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
|
||||
%{
|
||||
v8::Handle<v8::FunctionTemplate> $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
|
||||
$jsmangledname_clientData.class_templ = $jsmangledname_class;
|
||||
$jsmangledname_clientData.dtor = $jsdtor;
|
||||
SWIGTYPE$jsmangledtype->clientdata = &$jsmangledname_clientData;%}
|
||||
SWIGTYPE$jsmangledtype->clientdata = &$jsmangledname_clientData;
|
||||
%}
|
||||
|
||||
%fragment("jsv8_inherit", "templates")
|
||||
%{$jsmangledname_class->Inherit($jsbaseclass_class);%}
|
||||
%{
|
||||
$jsmangledname_class->Inherit($jsbaseclass_class);
|
||||
%}
|
||||
|
||||
%fragment("jsv8_create_class_instance", "templates")
|
||||
%{v8::Handle<v8::FunctionTemplate> $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
|
||||
%{
|
||||
v8::Handle<v8::FunctionTemplate> $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
|
||||
$jsmangledname_class_0->SetCallHandler($jsctor);
|
||||
$jsmangledname_class_0->Inherit($jsmangledname_class);
|
||||
$jsmangledname_class_0->SetHiddenPrototype(true);
|
||||
v8::Handle<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction();%}
|
||||
v8::Handle<v8::Object> $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
|
||||
%}
|
||||
|
||||
%fragment("jsv8_register_class", "templates")
|
||||
%{$jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);%}
|
||||
%{
|
||||
$jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);
|
||||
%}
|
||||
|
||||
%fragment("jsv8_create_namespace", "templates")
|
||||
%{v8::Handle<v8::Object> $jsmangledname_obj = v8::Object::New();%}
|
||||
%{
|
||||
v8::Handle<v8::Object> $jsmangledname_obj = v8::Object::New();
|
||||
%}
|
||||
|
||||
%fragment("jsv8_register_member_function", "templates")
|
||||
%{SWIGV8_AddMemberFunction($jsmangledname_class, "$jsname", $jswrapper);%}
|
||||
%{
|
||||
SWIGV8_AddMemberFunction($jsmangledname_class, "$jsname", $jswrapper);
|
||||
%}
|
||||
|
||||
%fragment("jsv8_register_member_variable", "templates")
|
||||
%{SWIGV8_AddMemberVariable($jsmangledname_class, "$jsname", $jsgetter, $jssetter);%}
|
||||
%{
|
||||
SWIGV8_AddMemberVariable($jsmangledname_class, "$jsname", $jsgetter, $jssetter);
|
||||
%}
|
||||
|
||||
%fragment("jsv8_register_static_function", "templates")
|
||||
%{SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper);%}
|
||||
%{
|
||||
SWIGV8_AddStaticFunction($jsparent_obj, "$jsname", $jswrapper);
|
||||
%}
|
||||
|
||||
%fragment("jsv8_register_static_variable", "templates")
|
||||
%{SWIGV8_AddStaticVariable($jsparent_obj, "$jsname", $jsgetter, $jssetter);%}
|
||||
%{
|
||||
SWIGV8_AddStaticVariable($jsparent_obj, "$jsname", $jsgetter, $jssetter);
|
||||
%}
|
||||
|
||||
%fragment("jsv8_register_namespace", "templates")
|
||||
%{$jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);%}
|
||||
%{
|
||||
$jsparent_obj->Set(v8::String::NewSymbol("$jsname"), $jsmangledname_obj);
|
||||
%}
|
||||
|
||||
%fragment("JS_initializer", "templates")
|
||||
%fragment("js_initializer", "templates")
|
||||
%{
|
||||
extern "C" {
|
||||
|
||||
|
|
@ -194,6 +235,7 @@ void $jsname_initialize(v8::Handle<v8::Context> context)
|
|||
v8::HandleScope scope;
|
||||
v8::Local<v8::Object> global_obj = context->Global();
|
||||
|
||||
// a class template for creating proxies of undefined types
|
||||
SWIGV8_SWIGTYPE_Proxy_class_templ = SWIGV8_CreateClassTemplate("SwigProxy");
|
||||
|
||||
/* create objects for namespaces */
|
||||
|
|
@ -219,6 +261,8 @@ void $jsname_initialize(v8::Handle<v8::Context> context)
|
|||
|
||||
/* create and register namespace objects */
|
||||
$jsv8registernspaces
|
||||
|
||||
}
|
||||
|
||||
}%}
|
||||
} // extern "C"
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue