update swig on windows
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
SRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
PROGFILE = runme.ml
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run
|
||||
|
||||
build: static toplevel
|
||||
|
||||
static:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
ocaml_core
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
ocaml_static_cpp
|
||||
|
||||
dynamic:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
ocaml_dynamic_cpp
|
||||
|
||||
toplevel: static
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
ocaml_static_cpp_toplevel
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean
|
||||
@@ -0,0 +1,41 @@
|
||||
/* -*- 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() {
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
return std::string( asctime( localtime( &tv.tv_sec ) ) );
|
||||
}
|
||||
|
||||
void takes_char_ptr( char *p ) {
|
||||
cout << "takes_char_ptr( \"" << p << "\" );" << endl;
|
||||
}
|
||||
|
||||
const char *gives_const_char_ptr() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
void takes_and_gives_std_string( std::string &inout ) {
|
||||
inout.insert( inout.begin(), '[' );
|
||||
inout.insert( inout.end(), ']' );
|
||||
}
|
||||
|
||||
void takes_and_gives_const_char_ptr( const char *&inout ) {
|
||||
const char *pout = strchr( inout, '.' );
|
||||
if( pout ) inout = pout + 1;
|
||||
else inout = "foo";
|
||||
}
|
||||
|
||||
/*
|
||||
* Local-Variables:
|
||||
* c-indentation-style: "stroustrup"
|
||||
* End:
|
||||
*/
|
||||
@@ -0,0 +1,15 @@
|
||||
%module example
|
||||
%{
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_string.i"
|
||||
%include example.h
|
||||
@@ -0,0 +1,17 @@
|
||||
(* This example is meant to reach every case in cstring.i *)
|
||||
|
||||
open Swig
|
||||
open Example
|
||||
|
||||
let _ = _takes_std_string (C_string "foo")
|
||||
let _ = print_endline
|
||||
("_gives_std_string <<" ^ (get_string (_gives_std_string C_void)) ^ " >>")
|
||||
let _ = _takes_char_ptr (C_string "bar")
|
||||
let _ = print_endline
|
||||
("_gives_const_char_ptr << " ^ (get_string (_gives_const_char_ptr C_void)) ^ " >>")
|
||||
let _ = print_endline
|
||||
("_takes_and_gives_std_string << " ^
|
||||
(get_string (_takes_and_gives_std_string (C_string "foo"))) ^ " >>")
|
||||
let _ = print_endline
|
||||
("_takes_and_gives_const_char_ptr << " ^
|
||||
(get_string (_takes_and_gives_const_char_ptr (C_string "bar.bar"))) ^ " >>")
|
||||
Reference in New Issue
Block a user