summaryrefslogtreecommitdiff
path: root/Lib/javascript/v8/javascriptrun.swg
diff options
context:
space:
mode:
authorOliver Buchtala <oliver.buchtala@googlemail.com>2014-05-19 00:21:21 +0200
committerOliver Buchtala <oliver.buchtala@googlemail.com>2014-05-19 16:04:22 +0200
commit3f0f58889131baacb23583a7deb35d9394bfc141 (patch)
treed7c5dbfe9a62ea8e77511ae20632484604ddd6cd /Lib/javascript/v8/javascriptrun.swg
parentd5ea32d7607c1991ae74293472d73740c90e5db8 (diff)
downloadswig-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.swg12
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;