[Ocaml] Apply patch #3151788 from Joel Reymont. Brings Ocaml support a up to date (ver 3.11 and 3.12), including std::string.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12460 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-02-14 07:22:06 +00:00
commit 1fab53b204
9 changed files with 240 additions and 245 deletions

View file

@ -1,4 +1,8 @@
/* File : example.i */
%module example
%{
extern "C" void factor(int &x, int &y);
%}
extern "C" void factor(int &x, int &y);

View file

@ -46,3 +46,5 @@ void draw_depth_map( volume *v, int div_x, int div_y ) {
}
double volume::depth( double x, double y ) { return 0.0; }
volume::~volume() { }

View file

@ -9,7 +9,8 @@ public:
class volume {
public:
virtual double depth( double x, double y );
virtual double depth( double x, double y );
virtual ~volume();
};
extern void draw_shape_coverage( shape *s, int div_x, int div_y );

View file

@ -1,3 +1,9 @@
--- New ---
It's not possible to access std::(w)string at the moment as it breaks other string examples.
--- Old ---
This example shows how to use both std::string and std::wstring in Ocaml,
and also demonstrates that one might use this to make a locale-obedient
Ocaml program.

View file

@ -1,14 +1,18 @@
/* -*- mode: c++ -*- */
/* File : example.h -- Tests all string typemaps */
#include <sys/time.h>
#include <time.h>
void takes_std_string( std::string in ) {
cout << "takes_std_string( \"" << in << "\" );" << endl;
}
std::string gives_std_string() {
time_t t;
return std::string( asctime( localtime( &t ) ) );
struct timeval tv;
gettimeofday(&tv, NULL);
return std::string( asctime( localtime( &tv.tv_sec ) ) );
}
void takes_char_ptr( char *p ) {
@ -24,10 +28,10 @@ void takes_and_gives_std_string( std::string &inout ) {
inout.insert( inout.end(), ']' );
}
void takes_and_gives_char_ptr( char *&ptr ) {
char *pout = strchr( ptr, '.' );
if( pout ) ptr = pout + 1;
else ptr = "foo";
void takes_and_gives_char_ptr( char *&inout ) {
char *pout = strchr( inout, '.' );
if( pout ) inout = pout + 1;
else inout = "foo";
}
/*