The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5fcae5eb66
commit
12a43edc2d
1508 changed files with 125983 additions and 44037 deletions
55
Lib/ocaml/std_string.i
Normal file
55
Lib/ocaml/std_string.i
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// -*- C++ -*-
|
||||
// SWIG typemaps for std::string
|
||||
// Art Yerkes
|
||||
// Modified from: Luigi Ballabio
|
||||
// Apr 8, 2002
|
||||
//
|
||||
// Ocaml implementation
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::string is typemapped by value
|
||||
// This can prevent exporting methods which return a string
|
||||
// in order for the user to modify it.
|
||||
// However, I think I'll wait until someone asks for it...
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%include exception.i
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
class string;
|
||||
|
||||
/* Overloading check */
|
||||
|
||||
%typemap(typecheck) string = char *;
|
||||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
%typemap(in) string {
|
||||
if (caml_ptr_check($input))
|
||||
$1 = std::string((char *)caml_ptr_val($input,0));
|
||||
else
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
}
|
||||
|
||||
%typemap(in) const string & (std::string temp) {
|
||||
if (caml_ptr_check($input)) {
|
||||
temp = std::string((char *)caml_ptr_val($input,0));
|
||||
$1 = &temp;
|
||||
} else {
|
||||
SWIG_exception(SWIG_TypeError, "string expected");
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(out) string {
|
||||
$result = caml_val_ptr((char *)$1.c_str(),0);
|
||||
}
|
||||
|
||||
%typemap(out) const string & {
|
||||
$result = caml_val_ptr((char *)$1->c_str(),0);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue