diff options
author | Oliver Buchtala <oliver.buchtala@googlemail.com> | 2014-05-19 00:21:21 +0200 |
---|---|---|
committer | Oliver Buchtala <oliver.buchtala@googlemail.com> | 2014-05-19 16:04:22 +0200 |
commit | 3f0f58889131baacb23583a7deb35d9394bfc141 (patch) | |
tree | d7c5dbfe9a62ea8e77511ae20632484604ddd6cd /Lib/javascript/v8/javascriptrun.swg | |
parent | d5ea32d7607c1991ae74293472d73740c90e5db8 (diff) | |
download | swig-3f0f58889131baacb23583a7deb35d9394bfc141.tar.gz |
Javascript: support null pointers.
We allow to set pointer types using JS null.
Diffstat (limited to 'Lib/javascript/v8/javascriptrun.swg')
-rw-r--r-- | Lib/javascript/v8/javascriptrun.swg | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 2e0a46717..f200f1520 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -220,7 +220,11 @@ void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void* ptr, swig_type_info int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void** ptr, swig_type_info *info, int flags) { v8::HandleScope scope; - + /* special case: JavaScript null => C NULL pointer */ + if(valRef->IsNull()) { + *ptr=0; + return SWIG_OK; + } if(!valRef->IsObject()) { return SWIG_TypeError; } @@ -228,10 +232,14 @@ int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void** ptr, swig_type_info return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags); } -v8::Handle<v8::Object> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) { +v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) { v8::HandleScope scope; v8::Handle<v8::FunctionTemplate> class_templ; + if (ptr == NULL) { + return scope.Close(v8::Null()); + } + #if (SWIG_V8_VERSION < 0x031900) if(info->clientdata != 0) { class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ; |