Update v8 specification.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13758 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Oliver Buchtala 2012-09-08 00:51:29 +00:00
commit e8dd979d16

View file

@ -66,16 +66,15 @@ There are different types of function wrappers:
v8::Handle<v8::Value> wrap_${NAME_MANGLED}(const v8::Arguments &args) { v8::Handle<v8::Value> wrap_${NAME_MANGLED}(const v8::Arguments &args) {
v8::HandleScope scope; v8::HandleScope scope;
v8::Handle<v8::Value> ret; v8::Handle<v8::Value> ret;
${LOCALS} ${LOCALS}
${MARSHAL_INPUT} ${CODE}
${ACTION}
${MARSHAL_OUTPUT}
return scope.Close(ret); return scope.Close(ret);
} }
~~~~ ~~~~
- `LOCALS`: declarations for input and output arguments
- `CODE` contains input marshalling, the action, and output marshalling
### Constructors ### Constructors
~~~~ ~~~~
@ -83,16 +82,14 @@ v8::Handle<v8::Value> ${NAME_MANGLED}_new(const v8::Arguments& args) {
v8::HandleScope scope; v8::HandleScope scope;
v8::Handle<v8::Object> self = args.Holder(); v8::Handle<v8::Object> self = args.Holder();
${LOCALS} ${LOCALS}
${MARSHAL_INPUT} ${CODE}
${ACTION}
self->SetInternalField(0, v8::External::New(ptr)); self->SetInternalField(0, v8::External::New(ptr));
return self; return self;
} }
~~~~ ~~~~
- `LOCALS`: declaration and marshalling for input arguments - `LOCALS`: declarations for input arguments
- `MARSHAL_INPUT`: code is generated by applying input typemaps - `CODE` contains input marshalling, and the action
- `ACTION`: the C/C++ ctor to be executed
### Destructors ### Destructors
@ -105,28 +102,26 @@ v8::Handle<v8::Value> ${NAME_MANGLED}_get(v8::Local<v8::String> property, const
v8::HandleScope scope; v8::HandleScope scope;
v8::Handle<v8::Object> ret; v8::Handle<v8::Object> ret;
${LOCALS} ${LOCALS}
${ACTION} ${CODE}
${MARSHAL_OUTPUT}
return scope.Close(ret); return scope.Close(ret);
} }
~~~~ ~~~~
- `NAME_MANGLED`: the qualified mangled name of the variable, E.g., `foo::x -> foo_x`, `A.x -> A_x` - `NAME_MANGLED`: the qualified mangled name of the variable, E.g., `foo::x -> foo_x`, `A.x -> A_x`
- `LOCALS`: declare C return variable - `LOCALS`: declarations for output arguments
- `MARSHAL_OUTPUT`: code is generated by applying output typemaps - `CODE` contains the action, and output marshalling
### Setters ### Setters
~~~~ ~~~~
void ${NAME_MANGLED}_set(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { void ${NAME_MANGLED}_set(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
${LOCALS} ${LOCALS}
${MARSHAL_INPUT} ${CODE}
${ACTION}
} }
~~~~ ~~~~
- `NAME_MANGLED`: the qualified mangled name of the variable, E.g., `foo::x -> foo_x`, `A.x -> A_x` - `NAME_MANGLED`: the qualified mangled name of the variable, E.g., `foo::x -> foo_x`, `A.x -> A_x`
- `LOCALS`: declarations for input arguments - `LOCALS`: declarations for input arguments
- `MARSHAL_INPUT`: code is generated by applying input typemaps - `CODE` contains input marshalling, and the action
### Functions ### Functions
@ -135,14 +130,15 @@ v8::Handle<v8::Value> ${NAME_MANGLED}(const Arguments &args) {
v8::HandleScope scope; v8::HandleScope scope;
v8::Handle<v8::Object> ret; v8::Handle<v8::Object> ret;
${LOCALS} ${LOCALS}
${MARSHAL_INPUT} ${CODE}
${ACTION}
${MARSHAL_OUTPUT}
return scope.Close(ret); return scope.Close(ret);
} }
~~~~ ~~~~
- if the function does not have a return value, return v8::Undefined - `NAME_MANGLED`: the qualified mangled name of the variable, E.g., `foo::x -> foo_x`, `A.x -> A_x`
- `LOCALS`: declarations for input arguments
- `CODE` contains input marshalling, the action, and output marshalling
### Overloading ### Overloading
@ -169,7 +165,9 @@ void ${MODULE}_Initialize(v8::Handle<v8::Context> context)
${PART_INHERITANCE} ${PART_INHERITANCE}
${PART_REGISTER} ${PART_REGISTER_CLASSES}
${PART_REGISTER_NS}
} }
~~~~ ~~~~
@ -217,7 +215,7 @@ ${CONTEXT}->SetAccessor(v8::String::NewSymbol("${NAME_UNQUALIFIED}"), ${GETTER},
#### Global Function #### Global Function
~~~~ ~~~~
${CONTEXT}->Set(v8::String::NewSymbol("${NAME_UNQUALIFIED}"), v8::FunctionTemplate::New(wrap_${NAME_QUALIFIED})->GetFunction()); SWIGV8_AddGlobalFunction(${CONTEXT}, "${NAME_UNQUALIFIED}", wrap_${NAME_QUALIFIED});
~~~~ ~~~~
- `CONTEXT`: either global, or the according namespace template - `CONTEXT`: either global, or the according namespace template