summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNishant Gupta <nish.gupta01@gmail.com>2016-08-02 22:12:32 +0530
committerNishant Gupta <nish.gupta01@gmail.com>2016-08-02 22:12:32 +0530
commitefd8d1972c6b6f884d29789e6b48dff7b76ffa8a (patch)
tree520be065630d59b5b572cb1a6426112cc1632183
parent5409a0dc79321fe34bd7195e5d857d625afa8e1f (diff)
downloadswig-efd8d1972c6b6f884d29789e6b48dff7b76ffa8a.tar.gz
Typemaps: std::string
-rw-r--r--Lib/hhvm/hhvm.swg6
-rw-r--r--Lib/hhvm/std_string.i55
2 files changed, 61 insertions, 0 deletions
diff --git a/Lib/hhvm/hhvm.swg b/Lib/hhvm/hhvm.swg
index 89bd17bd6..d15281c2a 100644
--- a/Lib/hhvm/hhvm.swg
+++ b/Lib/hhvm/hhvm.swg
@@ -55,6 +55,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
unsigned short,
long,
long long,
+ unsigned long long,
unsigned long,
unsigned char,
signed char,
@@ -84,6 +85,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
unsigned short,
long,
long long,
+ unsigned long long,
unsigned long,
unsigned char,
signed char,
@@ -122,6 +124,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
unsigned short,
long,
long long,
+ unsigned long long,
unsigned long,
unsigned char,
signed char,
@@ -210,6 +213,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
unsigned short,
long,
long long,
+ unsigned long long,
unsigned long,
unsigned char,
signed char,
@@ -272,6 +276,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
unsigned short,
long,
long long,
+ unsigned long long,
unsigned long,
unsigned char,
signed char,
@@ -366,6 +371,7 @@ bool, const bool &
unsigned short,
long,
long long,
+ unsigned long long,
unsigned long,
unsigned char,
signed char,
diff --git a/Lib/hhvm/std_string.i b/Lib/hhvm/std_string.i
new file mode 100644
index 000000000..8c2b5616f
--- /dev/null
+++ b/Lib/hhvm/std_string.i
@@ -0,0 +1,55 @@
+/* -----------------------------------------------------------------------------
+ * std_string.i
+ *
+ * Typemaps for std::string, std::string& and const std::string&
+ * These are mapped to a HHVM String and are passed around by value.
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include <string>
+%}
+
+namespace std {
+
+%naturalvar string;
+
+class string;
+
+// string
+%typemap(hni_parmtype) string, const string & "const HPHP::String&"
+%typemap(hni_rttype) string, const string & "HPHP::String";
+%typemap(php_type) string, const string & "string";
+%typemap(variant_out) string "toString"
+
+%typemap(in) string %{$1 = $input.toCppString();%}
+%typemap(out) string %{$result = HPHP::String($1);%}
+
+%typemap(in) const string & ($*1_ltype temp)
+%{
+ temp = $input.toCppString();
+ $1 = &temp;
+%}
+%typemap(out) const string & %{$result = HPHP::String(*$1);%}
+%typemap(argout) const string & ""
+
+%typemap(typecheck) string, string&, const string & = char *;
+
+// string &
+%typemap(hni_parmtype) string & "HPHP::VRefParam"
+%typemap(hni_rttype) string & "HPHP::Variant";
+%typemap(php_type) string & "mixed&";
+
+%typemap(in) string & ($*1_ltype temp)
+%{
+ temp = $input.toString().toCppString();
+ $1 = &temp;
+%}
+%typemap(out) string & %{$result = HPHP::Variant(HPHP::String(*$1));%}
+%typemap(argout) string & %{$result.assignIfRef(*$1);%}
+
+%typemap(throws) string, const string& %{
+ throw HPHP::Object(HPHP::SystemLib::AllocRuntimeExceptionObject($1));
+ return;
+%}
+}
+