summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNishant Gupta <nish.gupta01@gmail.com>2016-07-23 18:53:51 +0530
committerNishant Gupta <nish.gupta01@gmail.com>2016-07-23 18:53:51 +0530
commit62fa36305162d7cf897562b13fbd9d0af7955a82 (patch)
tree00802e541c2355145890af61c18cbdeba9553ef4
parenta6e80618d66c74a9fdfce5c138d3a67647c066a7 (diff)
downloadswig-62fa36305162d7cf897562b13fbd9d0af7955a82.tar.gz
example: sync
-rw-r--r--Examples/hhvm/check.list1
-rw-r--r--Examples/hhvm/sync/Makefile20
-rw-r--r--Examples/hhvm/sync/config.cmake2
-rw-r--r--Examples/hhvm/sync/example.cxx13
-rw-r--r--Examples/hhvm/sync/example.h9
-rw-r--r--Examples/hhvm/sync/example.i7
-rw-r--r--Examples/hhvm/sync/runme.php14
-rw-r--r--Lib/hhvm/hhvm.swg5
8 files changed, 69 insertions, 2 deletions
diff --git a/Examples/hhvm/check.list b/Examples/hhvm/check.list
index 50a7838c8..fb3e7eda6 100644
--- a/Examples/hhvm/check.list
+++ b/Examples/hhvm/check.list
@@ -6,3 +6,4 @@ class
value
reference
enum
+sync
diff --git a/Examples/hhvm/sync/Makefile b/Examples/hhvm/sync/Makefile
new file mode 100644
index 000000000..89779ecd5
--- /dev/null
+++ b/Examples/hhvm/sync/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIGEXE = $(TOP)/../swig
+SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' hhvm_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
+ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ hhvm_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' hhvm_clean
diff --git a/Examples/hhvm/sync/config.cmake b/Examples/hhvm/sync/config.cmake
new file mode 100644
index 000000000..7d75ae957
--- /dev/null
+++ b/Examples/hhvm/sync/config.cmake
@@ -0,0 +1,2 @@
+HHVM_EXTENSION(example ../ext_example.cpp ../example.cxx)
+HHVM_SYSTEMLIB(example ../ext_example.php)
diff --git a/Examples/hhvm/sync/example.cxx b/Examples/hhvm/sync/example.cxx
new file mode 100644
index 000000000..66582ab29
--- /dev/null
+++ b/Examples/hhvm/sync/example.cxx
@@ -0,0 +1,13 @@
+#include "example.h"
+#include <stdio.h>
+
+int x = 42;
+char *s = (char *)"Test";
+
+void Sync::printer(void) {
+
+ printf("The value of global s is %s\n", ::s);
+ printf("The value of global x is %d\n", ::x);
+ printf("The value of class s is %s\n", s);
+ printf("The value of class x is %d\n", x);
+}
diff --git a/Examples/hhvm/sync/example.h b/Examples/hhvm/sync/example.h
new file mode 100644
index 000000000..d67ec21dc
--- /dev/null
+++ b/Examples/hhvm/sync/example.h
@@ -0,0 +1,9 @@
+extern char *s;
+extern int x;
+
+class Sync {
+ public:
+ int x;
+ char *s;
+ void printer(void);
+};
diff --git a/Examples/hhvm/sync/example.i b/Examples/hhvm/sync/example.i
new file mode 100644
index 000000000..17ff87cf3
--- /dev/null
+++ b/Examples/hhvm/sync/example.i
@@ -0,0 +1,7 @@
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "example.h"
diff --git a/Examples/hhvm/sync/runme.php b/Examples/hhvm/sync/runme.php
new file mode 100644
index 000000000..900e14a61
--- /dev/null
+++ b/Examples/hhvm/sync/runme.php
@@ -0,0 +1,14 @@
+<?
+
+// Load module and PHP classes.
+
+echo "Got new object\n";
+echo "Got string ". s_get() . " and value " . x_get() . "\n";
+
+$s = new Sync();
+echo "Got new object\n";
+
+$s->printer();
+
+?>
+
diff --git a/Lib/hhvm/hhvm.swg b/Lib/hhvm/hhvm.swg
index 0ad3726ea..72caa0231 100644
--- a/Lib/hhvm/hhvm.swg
+++ b/Lib/hhvm/hhvm.swg
@@ -132,8 +132,9 @@
}
%typemap(in) char *,
- char [ANY]
-%{$1 = $input.c_str();%}
+ char [ANY],
+ char []
+%{$1 = (char *)$input.c_str();%}
%typemap(in) SWIGTYPE *,
SWIGTYPE [],