diff options
Diffstat (limited to 'devtools/swigwin-1.3.34/Lib/ocaml')
26 files changed, 3191 insertions, 0 deletions
diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/carray.i b/devtools/swigwin-1.3.34/Lib/ocaml/carray.i new file mode 100644 index 0000000..bbf1ddd --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/carray.i @@ -0,0 +1,136 @@ +%insert(mli) %{ +type _value = c_obj +%} + +%insert(ml) %{ +type _value = c_obj +%} + +%define %array_tmap_out(type,what,out_f) +%typemap(type) what [ANY] { + int i; + /* $*1_type */ + $result = caml_array_new($1_dim0); + for( i = 0; i < $1_dim0; i++ ) { + caml_array_set($result,i,out_f($1[i])); + } +} +%enddef + +%define %array_tmap_in(type,what,in_f) +%typemap(type) what [ANY] { + int i; + /* $*1_type */ + $1 = ($*1_type *)malloc( $1_size ); + for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { + $1[i] = in_f(caml_array_nth($input,i)); + } +} + +%typemap(free) what [ANY] { + free( (void *)$1 ); +} +%enddef + +%define %make_simple_array_typemap(type,out_f,in_f) +%array_tmap_out(out,type,out_f); +%array_tmap_out(varout,type,out_f); +%array_tmap_out(directorin,type,out_f); + +%array_tmap_in(in,type,in_f); +%array_tmap_in(varin,type,in_f); +%array_tmap_in(directorout,type,in_f); +%enddef + +%make_simple_array_typemap(bool,caml_val_bool,caml_long_val); +%make_simple_array_typemap(short,caml_val_short,caml_long_val); +%make_simple_array_typemap(unsigned short,caml_val_ushort,caml_long_val); +%make_simple_array_typemap(int,caml_val_int,caml_long_val); +%make_simple_array_typemap(unsigned int,caml_val_uint,caml_long_val); +%make_simple_array_typemap(long,caml_val_long,caml_long_val); +%make_simple_array_typemap(unsigned long,caml_val_ulong,caml_long_val); +%make_simple_array_typemap(size_t,caml_val_int,caml_long_val); +%make_simple_array_typemap(float,caml_val_float,caml_double_val); +%make_simple_array_typemap(double,caml_val_double,caml_double_val); + +#ifdef __cplusplus +%typemap(in) SWIGTYPE [] { + int i; + + /* $*1_type */ + $1 = new $*1_type [$1_dim0]; + for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { + $1[i] = *(($*1_ltype *) + caml_ptr_val(caml_array_nth($input,i), + $*1_descriptor)) ; + } +} +#else +%typemap(in) SWIGTYPE [] { + int i; + + /* $*1_type */ + $1 = ($*1_type *)malloc( $1_size ); + for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { + $1[i] = *(($*1_ltype) + caml_ptr_val(caml_array_nth($input), + $*1_descriptor)); + } +} +#endif + +%typemap(out) SWIGTYPE [] { + int i; + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + $result = caml_array_new($1_dim0); + + for( i = 0; i < $1_dim0; i++ ) { + if( fromval ) { + caml_array_set + ($result, + i, + callback(*fromval,caml_val_ptr((void *)&$1[i],$*1_descriptor))); + } else { + caml_array_set + ($result, + i, + caml_val_ptr ((void *)&$1[i],$&1_descriptor)); + } + } +} + +%typemap(in) enum SWIGTYPE [] { + int i; + + /* $*1_type */ + $1 = ($*1_type *)malloc( $1_size ); + for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { + $1[i] = ($type) + caml_long_val_full(caml_array_nth($input), + "$type_marker"); + } +} + +%typemap(out) enum SWIGTYPE [] { + int i; + $result = caml_array_new($1_dim0); + + for( i = 0; i < $1_dim0; i++ ) { + caml_array_set + ($result, + i, + callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"), + *caml_named_value("$type_marker"), + Val_int($1[i]))); + } +} + +#ifdef __cplusplus +%typemap(freearg) SWIGTYPE [ANY] { + delete [] $1; +} +#else +%typemap(freearg) SWIGTYPE [ANY] { + free( (void *)$1 ); +} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/class.swg b/devtools/swigwin-1.3.34/Lib/ocaml/class.swg new file mode 100644 index 0000000..0ee304c --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/class.swg @@ -0,0 +1,66 @@ +(*Stream:class_ctors*) +let create_$classname_from_ptr raw_ptr = + C_obj +begin + let h = Hashtbl.create 20 in + List.iter (fun (nm,fn) -> Hashtbl.replace h nm fn) + [ "nop", (fun args -> C_void) ; + $classbody + "&", (fun args -> raw_ptr) ; + ":parents", + (fun args -> + C_list + (let out = ref [] in + Hashtbl.iter (fun x y -> out := (x,y) :: !out) h ; + (List.map + (fun (x,y) -> + C_string (String.sub x 2 ((String.length x) - 2))) + (List.filter + (fun (x,y) -> + ((String.length x) > 2) + && x.[0] == ':' && x.[1] == ':') !out)))) ; + ":classof", (fun args -> C_string "$realname") ; + ":methods", (fun args -> + C_list (let out = ref [] in + Hashtbl.iter (fun x y -> out := (C_string x) :: !out) h ; !out)) + ] ; + let rec invoke_inner raw_ptr mth arg = + begin + try + let application = Hashtbl.find h mth in + application + (match arg with + C_list l -> (C_list (raw_ptr :: l)) + | C_void -> (C_list [ raw_ptr ]) + | v -> (C_list [ raw_ptr ; v ])) + with Not_found -> + (* Try parent classes *) + begin + let parent_classes = [ + $baselist + ] in + let rec try_parent plist raw_ptr = + match plist with + p :: tl -> + begin + try + (invoke (p raw_ptr)) mth arg + with (BadMethodName (p,m,s)) -> + try_parent tl raw_ptr + end + | [] -> + raise (BadMethodName (raw_ptr,mth,"$realname")) + in try_parent parent_classes raw_ptr + end + end in + (fun mth arg -> invoke_inner raw_ptr mth arg) +end + +let _ = Callback.register + "create_$normalized_from_ptr" + create_$classname_from_ptr + + +(*Stream:mli*) +val create_$classname_from_ptr : c_obj -> c_obj + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/cstring.i b/devtools/swigwin-1.3.34/Lib/ocaml/cstring.i new file mode 100644 index 0000000..e562582 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/cstring.i @@ -0,0 +1,271 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * cstring.i + * + * This file provides typemaps and macros for dealing with various forms + * of C character string handling. The primary use of this module + * is in returning character data that has been allocated or changed in + * some way. + * ----------------------------------------------------------------------------- */ + +/* %cstring_input_binary(TYPEMAP, SIZE) + * + * Macro makes a function accept binary string data along with + * a size. + */ + +%define %cstring_input_binary(TYPEMAP, SIZE) +%apply (char *STRING, int LENGTH) { (TYPEMAP, SIZE) }; +%enddef + +/* + * %cstring_bounded_output(TYPEMAP, MAX) + * + * This macro is used to return a NULL-terminated output string of + * some maximum length. For example: + * + * %cstring_bounded_output(char *outx, 512); + * void foo(char *outx) { + * sprintf(outx,"blah blah\n"); + * } + * + */ + +%define %cstring_bounded_output(TYPEMAP,MAX) +%typemap(ignore) TYPEMAP(char temp[MAX+1]) { + $1 = ($1_ltype) temp; +} +%typemap(argout) TYPEMAP { + $1[MAX] = 0; + $result = caml_list_append($result,caml_val_string(str)); +} +%enddef + +/* + * %cstring_chunk_output(TYPEMAP, SIZE) + * + * This macro is used to return a chunk of binary string data. + * Embedded NULLs are okay. For example: + * + * %cstring_chunk_output(char *outx, 512); + * void foo(char *outx) { + * memmove(outx, somedata, 512); + * } + * + */ + +%define %cstring_chunk_output(TYPEMAP,SIZE) +%typemap(ignore) TYPEMAP(char temp[SIZE]) { + $1 = ($1_ltype) temp; +} +%typemap(argout) TYPEMAP { + $result = caml_list_append($result,caml_val_string_len($1,SIZE)); +} +%enddef + +/* + * %cstring_bounded_mutable(TYPEMAP, SIZE) + * + * This macro is used to wrap a string that's going to mutate. + * + * %cstring_bounded_mutable(char *in, 512); + * void foo(in *x) { + * while (*x) { + * *x = toupper(*x); + * x++; + * } + * } + * + */ + + +%define %cstring_bounded_mutable(TYPEMAP,MAX) +%typemap(in) TYPEMAP(char temp[MAX+1]) { + char *t = (char *)caml_ptr_val($input); + strncpy(temp,t,MAX); + $1 = ($1_ltype) temp; +} +%typemap(argout) TYPEMAP { + $result = caml_list_append($result,caml_val_string_len($1,MAX)); +} +%enddef + +/* + * %cstring_mutable(TYPEMAP [, expansion]) + * + * This macro is used to wrap a string that will mutate in place. + * It may change size up to a user-defined expansion. + * + * %cstring_mutable(char *in); + * void foo(in *x) { + * while (*x) { + * *x = toupper(*x); + * x++; + * } + * } + * + */ + +%define %cstring_mutable(TYPEMAP,...) +%typemap(in) TYPEMAP { + char *t = String_val($input); + int n = string_length($input); + $1 = ($1_ltype) t; +#if #__VA_ARGS__ == "" +#ifdef __cplusplus + $1 = ($1_ltype) new char[n+1]; +#else + $1 = ($1_ltype) malloc(n+1); +#endif +#else +#ifdef __cplusplus + $1 = ($1_ltype) new char[n+1+__VA_ARGS__]; +#else + $1 = ($1_ltype) malloc(n+1+__VA_ARGS__); +#endif +#endif + memmove($1,t,n); + $1[n] = 0; +} + +%typemap(argout) TYPEMAP { + $result = caml_list_append($result,caml_val_string($1)); +#ifdef __cplusplus + delete[] $1; +#else + free($1); +#endif +} +%enddef + +/* + * %cstring_output_maxsize(TYPEMAP, SIZE) + * + * This macro returns data in a string of some user-defined size. + * + * %cstring_output_maxsize(char *outx, int max) { + * void foo(char *outx, int max) { + * sprintf(outx,"blah blah\n"); + * } + */ + +%define %cstring_output_maxsize(TYPEMAP, SIZE) +%typemap(in) (TYPEMAP, SIZE) { + $2 = caml_val_long($input); +#ifdef __cplusplus + $1 = ($1_ltype) new char[$2+1]; +#else + $1 = ($1_ltype) malloc($2+1); +#endif +} +%typemap(argout) (TYPEMAP,SIZE) { + $result = caml_list_append($result,caml_val_string($1)); +#ifdef __cplusplus + delete [] $1; +#else + free($1); +#endif +} +%enddef + +/* + * %cstring_output_withsize(TYPEMAP, SIZE) + * + * This macro is used to return character data along with a size + * parameter. + * + * %cstring_output_maxsize(char *outx, int *max) { + * void foo(char *outx, int *max) { + * sprintf(outx,"blah blah\n"); + * *max = strlen(outx); + * } + */ + +%define %cstring_output_withsize(TYPEMAP, SIZE) +%typemap(in) (TYPEMAP, SIZE) { + int n = caml_val_long($input); +#ifdef __cplusplus + $1 = ($1_ltype) new char[n+1]; + $2 = ($2_ltype) new $*1_ltype; +#else + $1 = ($1_ltype) malloc(n+1); + $2 = ($2_ltype) malloc(sizeof($*1_ltype)); +#endif + *$2 = n; +} +%typemap(argout) (TYPEMAP,SIZE) { + $result = caml_list_append($result,caml_val_string_len($1,$2)); +#ifdef __cplusplus + delete [] $1; + delete $2; +#else + free($1); + free($2); +#endif +} +%enddef + +/* + * %cstring_output_allocate(TYPEMAP, RELEASE) + * + * This macro is used to return character data that was + * allocated with new or malloc. + * + * %cstring_output_allocated(char **outx, free($1)); + * void foo(char **outx) { + * *outx = (char *) malloc(512); + * sprintf(outx,"blah blah\n"); + * } + */ + +%define %cstring_output_allocate(TYPEMAP, RELEASE) +%typemap(ignore) TYPEMAP($*1_ltype temp = 0) { + $1 = &temp; +} + +%typemap(argout) TYPEMAP { + if (*$1) { + $result = caml_list_append($result,caml_val_string($1)); + RELEASE; + } else { + $result = caml_list_append($result,caml_val_ptr($1)); + } +} +%enddef + +/* + * %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) + * + * This macro is used to return character data that was + * allocated with new or malloc. + * + * %cstring_output_allocated(char **outx, int *sz, free($1)); + * void foo(char **outx, int *sz) { + * *outx = (char *) malloc(512); + * sprintf(outx,"blah blah\n"); + * *sz = strlen(outx); + * } + */ + +%define %cstring_output_allocate_size(TYPEMAP, SIZE, RELEASE) +%typemap(ignore) (TYPEMAP, SIZE) ($*1_ltype temp = 0, $*2_ltype tempn) { + $1 = &temp; + $2 = &tempn; +} + +%typemap(argout)(TYPEMAP,SIZE) { + if (*$1) { + $result = caml_list_append($result,caml_val_string_len($1,$2)); + RELEASE; + } else + $result = caml_list_append($result,caml_val_ptr($1)); +} +%enddef + + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/director.swg b/devtools/swigwin-1.3.34/Lib/ocaml/director.swg new file mode 100644 index 0000000..8733316 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/director.swg @@ -0,0 +1,103 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * director.swg + * + * This file contains support for director classes that proxy + * method calls from C++ to Ocaml extensions. + * + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus + +#include <string> + +namespace Swig { + /* base class for director exceptions */ + class DirectorException { + protected: + std::string swig_msg; + public: + DirectorException(const char* msg="") { + } + const char *getMessage() const { + return swig_msg.c_str(); + } + virtual ~DirectorException() {} + }; + + /* type mismatch in the return value from a python method call */ + class DirectorTypeMismatchException : public Swig::DirectorException { + public: + DirectorTypeMismatchException(const char* msg="") { + } + }; + + /* any python exception that occurs during a director method call */ + class DirectorMethodException : public Swig::DirectorException {}; + + /* attempt to call a pure virtual method via a director method */ + class DirectorPureVirtualException : public Swig::DirectorException { + public: + DirectorPureVirtualException(const char* msg="") { + } + + static void raise(const char *msg) { + throw DirectorPureVirtualException(msg); + } + }; + + /* simple thread abstraction for pthreads on win32 */ +#ifdef __THREAD__ +#define __PTHREAD__ +#if defined(_WIN32) || defined(__WIN32__) +#define pthread_mutex_lock EnterCriticalSection +#define pthread_mutex_unlock LeaveCriticalSection +#define pthread_mutex_t CRITICAL_SECTION +#define MUTEX_INIT(var) CRITICAL_SECTION var +#else +#include <pthread.h> +#define MUTEX_INIT(var) pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER +#endif +#endif + + /* director base class */ + class Director { + private: + /* pointer to the wrapped ocaml object */ + CAML_VALUE swig_self; + /* flag indicating whether the object is owned by ocaml or c++ */ + mutable bool swig_disown_flag; + + public: + /* wrap a ocaml object, optionally taking ownership */ + Director(CAML_VALUE self) : swig_self(self), swig_disown_flag(false) { + register_global_root(&swig_self); + } + + /* discard our reference at destruction */ + virtual ~Director() { + remove_global_root(&swig_self); + swig_disown(); + // Disown is safe here because we're just divorcing a reference that + // points to us. + } + + /* return a pointer to the wrapped ocaml object */ + CAML_VALUE swig_get_self() const { + return swig_self; + } + + /* acquire ownership of the wrapped ocaml object (the sense of "disown" + * is from ocaml) */ + void swig_disown() const { + if (!swig_disown_flag) { + swig_disown_flag=true; + callback(*caml_named_value("caml_obj_disown"),swig_self); + } + } + }; +} + +#endif /* __cplusplus */ diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/extra-install.list b/devtools/swigwin-1.3.34/Lib/ocaml/extra-install.list new file mode 100644 index 0000000..a63c7fc --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/extra-install.list @@ -0,0 +1,5 @@ +# see top-level Makefile.in +# libswigocaml is not needed anymore. +swigp4.ml +swig.mli +swig.ml diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/libswigocaml.h b/devtools/swigwin-1.3.34/Lib/ocaml/libswigocaml.h new file mode 100644 index 0000000..e752540 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/libswigocaml.h @@ -0,0 +1,20 @@ +/* Ocaml runtime support */ + +#ifdef __cplusplus +extern "C" { +#endif + + typedef int oc_bool; + extern void *nullptr; + + extern oc_bool isnull( void *v ); + + extern void *get_char_ptr( char *str ); + extern void *make_ptr_array( int size ); + extern void *get_ptr( void *arrayptr, int elt ); + extern void set_ptr( void *arrayptr, int elt, void *elt_v ); + extern void *offset_ptr( void *ptr, int n ); + +#ifdef __cplusplus +}; +#endif diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.i b/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.i new file mode 100644 index 0000000..a46e239 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.i @@ -0,0 +1,61 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * ocaml.i + * + * SWIG Configuration File for Ocaml + * ----------------------------------------------------------------------------- */ + +%runtime %{ +#define SWIGSTATIC static +%} + +/* Insert common stuff */ +%insert(runtime) "swigrun.swg" + +/* Include headers */ +%insert(runtime) "ocamldec.swg" + +/* Type registration */ +%insert(init) "swiginit.swg" +%insert(init) "typeregister.swg" + +%insert(mlitail) %{ + val swig_val : c_enum_type -> c_obj -> Swig.c_obj +%} + +%insert(mltail) %{ + let rec swig_val t v = + match v with + C_enum e -> enum_to_int t v + | C_list l -> Swig.C_list (List.map (swig_val t) l) + | C_array a -> Swig.C_array (Array.map (swig_val t) a) + | _ -> Obj.magic v +%} + +/*#ifndef SWIG_NOINCLUDE*/ +%insert(runtime) "ocaml.swg" +/*#endif*/ + +%insert(classtemplate) "class.swg" + +/* Definitions */ +#define SWIG_malloc(size) swig_malloc(size, FUNC_NAME) +#define SWIG_free(mem) free(mem) + +/* Read in standard typemaps. */ +%include <swig.swg> +%include <typemaps.i> +%include <typecheck.i> +%include <exception.i> +%include <preamble.swg> + +/* ocaml keywords */ +/* There's no need to use this, because of my rewriting machinery. C++ + * words never collide with ocaml keywords */ + +/* still we include the file, but the warning says that the offending + name will be properly renamed. Just to let the user to know about + it. */ +%include <ocamlkw.swg> diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.swg b/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.swg new file mode 100644 index 0000000..5f8f929 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/ocaml.swg @@ -0,0 +1,602 @@ +/* -*-c-*- */ + +/* SWIG pointer structure */ + +#include <string.h> +#include <assert.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define C_bool 0 +#define C_char 1 +#define C_uchar 2 +#define C_short 3 +#define C_ushort 4 +#define C_int 5 +#define C_uint 6 +#define C_int32 7 +#define C_int64 8 +#define C_float 9 +#define C_double 10 +#define C_ptr 11 +#define C_array 12 +#define C_list 13 +#define C_obj 14 +#define C_string 15 +#define C_enum 16 +#define C_director_core 17 + + +/* Cast a pointer if possible; returns 1 if successful */ + + SWIGSTATIC int + SWIG_Cast (void *source, swig_type_info *source_type, + void **ptr, swig_type_info *dest_type) + { + if( !source ) { // Special case for NULL. This is a popular question + // for other modules on the list, so I want an easy way out... + *ptr = 0; + return 0; + } + +#ifdef TYPE_CAST_VERBOSE + fprintf( stderr, "Trying to cast %s to %s\n", + source_type ? source_type->str : "<none>", + dest_type ? dest_type->str : "<none>" ); +#endif + if (dest_type != source_type) { + /* We have a type mismatch. Will have to look through our type + mapping table to figure out whether or not we can accept this + datatype. + -- + Ignore typechecks for void *. Allow any conversion. */ + if( !dest_type || !source_type || + !strcmp(dest_type->name,"_p_void") || + !strcmp(source_type->name,"_p_void") ) { + *ptr = source; + return 0; + } else { + swig_cast_info *tc = + SWIG_TypeCheckStruct(source_type, dest_type ); +#ifdef TYPE_CAST_VERBOSE + fprintf( stderr, "Typecheck -> %s\n", + tc ? tc->str : "<none>" ); +#endif + if( tc ) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc, source, &newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + return 0; + } else + return -1; + } + } else { + *ptr = source; + return 0; + } + } + +/* Return 0 if successful. */ + SWIGSTATIC int + SWIG_GetPtr(void *inptr, void **outptr, + swig_type_info *intype, swig_type_info *outtype) { + if (intype) { + return SWIG_Cast(inptr, intype, + outptr, outtype) == -1; + } else { + *outptr = inptr; + return 0; + } + } + + SWIGSTATIC void caml_print_list( CAML_VALUE v ); + + SWIGSTATIC void caml_print_val( CAML_VALUE v ) { + switch( SWIG_Tag_val(v) ) { + case C_bool: + if( Bool_val(SWIG_Field(v,0)) ) fprintf( stderr, "true " ); + else fprintf( stderr, "false " ); + break; + case C_char: + case C_uchar: + fprintf( stderr, "'%c' (\\%03d) ", + (Int_val(SWIG_Field(v,0)) >= ' ' && + Int_val(SWIG_Field(v,0)) < 127) ? Int_val(SWIG_Field(v,0)) : '.', + Int_val(SWIG_Field(v,0)) ); + break; + case C_short: + case C_ushort: + case C_int: + fprintf( stderr, "%d ", (int)caml_long_val(v) ); + break; + + case C_uint: + case C_int32: + fprintf( stderr, "%ud ", (unsigned int)caml_long_val(v) ); + break; + case C_int64: + fprintf( stderr, "%ld ", caml_long_val(v) ); + break; + case C_float: + case C_double: + fprintf( stderr, "%f ", caml_double_val(v) ); + break; + + case C_ptr: + { + void *vout = 0; + swig_type_info *ty = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1)); + caml_ptr_val_internal(v,&vout,0); + fprintf( stderr, "PTR(%p,%s) ", + vout, + ty ? ty->name : "(null)" ); + } + break; + case C_array: + { + unsigned int i; + for( i = 0; i < Wosize_val( SWIG_Field(v,0) ); i++ ) + caml_print_val( SWIG_Field(SWIG_Field(v,0),i) ); + } + break; + case C_list: + caml_print_list( SWIG_Field(v,0) ); + break; + case C_obj: + fprintf( stderr, "OBJ(%p) ", (void *)SWIG_Field(v,0) ); + break; + case C_string: + { + void *cout; + caml_ptr_val_internal(v,&cout,0); + fprintf( stderr, "'%s' ", (char *)cout ); + } + break; + } + } + + SWIGSTATIC void caml_print_list( CAML_VALUE v ) { + CAMLparam1(v); + while( v && Is_block(v) ) { + fprintf( stderr, "[ " ); + caml_print_val( SWIG_Field(v,0) ); + fprintf( stderr, "]\n" ); + v = SWIG_Field(v,1); + } + CAMLreturn0; + } + + SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) { + CAMLparam1(lst); + int i = 0; + while( i < n && lst && Is_block(lst) ) { + i++; lst = SWIG_Field(lst,1); + } + if( lst == Val_unit ) CAMLreturn(Val_unit); + else CAMLreturn(SWIG_Field(lst,0)); + } + + SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) { + CAMLparam2(lst,elt); + SWIG_CAMLlocal3(v,vt,lh); + lh = Val_unit; + v = Val_unit; + + /* Appending C_void should have no effect */ + if( !Is_block(elt) ) return lst; + + while( lst && Is_block(lst) ) { + if( v && v != Val_unit ) { + vt = alloc_tuple(2); + SWIG_Store_field(v,1,vt); + v = vt; + } else { + v = lh = alloc_tuple(2); + } + SWIG_Store_field(v,0,SWIG_Field(lst,0)); + lst = SWIG_Field(lst,1); + } + + if( v && Is_block(v) ) { + vt = alloc_tuple(2); + SWIG_Store_field(v,1,vt); + v = vt; + } else { + v = lh = alloc_tuple(2); + } + SWIG_Store_field(v,0,elt); + SWIG_Store_field(v,1,Val_unit); + + CAMLreturn(lh); + } + + SWIGSTATIC int caml_list_length( CAML_VALUE lst ) { + CAMLparam1(lst); + int i = 0; + while( lst && Is_block(lst) ) { i++; lst = SWIG_Field(lst,1); } + CAMLreturn(i); + } + + SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ) { + CAMLparam2(arr,item); + SWIG_Store_field(SWIG_Field(arr,0),n,item); + CAMLreturn0; + } + + SWIGSTATIC value caml_array_nth( CAML_VALUE arr, int n ) { + CAMLparam1(arr); + if( SWIG_Tag_val(arr) == C_array ) + CAMLreturn(SWIG_Field(SWIG_Field(arr,0),n)); + else if( SWIG_Tag_val(arr) == C_list ) + CAMLreturn(caml_list_nth(arr,0)); + else + failwith("Need array or list"); + } + + SWIGSTATIC int caml_array_len( CAML_VALUE arr ) { + CAMLparam1(arr); + if( SWIG_Tag_val(arr) == C_array ) + CAMLreturn(Wosize_val(SWIG_Field(arr,0))); + else if( SWIG_Tag_val(arr) == C_list ) + CAMLreturn(caml_list_length(arr)); + else + failwith("Need array or list"); + } + + SWIGSTATIC CAML_VALUE caml_swig_alloc(int x,int y) { + return caml_alloc(x,y); + } + + SWIGSTATIC value caml_array_new( int n ) { + CAMLparam0(); + SWIG_CAMLlocal1(vv); + vv = caml_swig_alloc(1,C_array); + SWIG_Store_field(vv,0,alloc_tuple(n)); + CAMLreturn(vv); + } + + SWIGSTATIC CAML_VALUE caml_val_bool( int b ) { + CAMLparam0(); + SWIG_CAMLlocal1(bv); + bv = caml_swig_alloc(1,C_bool); + SWIG_Store_field(bv,0,Val_bool(b)); + CAMLreturn(bv); + } + + SWIGSTATIC CAML_VALUE caml_val_char( char c ) { + CAMLparam0(); + SWIG_CAMLlocal1(cv); + cv = caml_swig_alloc(1,C_char); + SWIG_Store_field(cv,0,Val_int(c)); + CAMLreturn(cv); + } + + SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char uc ) { + CAMLparam0(); + SWIG_CAMLlocal1(ucv); + ucv = caml_swig_alloc(1,C_uchar); + SWIG_Store_field(ucv,0,Val_int(uc)); + CAMLreturn(ucv); + } + + SWIGSTATIC CAML_VALUE caml_val_short( short s ) { + CAMLparam0(); + SWIG_CAMLlocal1(sv); + sv = caml_swig_alloc(1,C_short); + SWIG_Store_field(sv,0,Val_int(s)); + CAMLreturn(sv); + } + + SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short us ) { + CAMLparam0(); + SWIG_CAMLlocal1(usv); + usv = caml_swig_alloc(1,C_ushort); + SWIG_Store_field(usv,0,Val_int(us)); + CAMLreturn(usv); + } + + SWIGSTATIC CAML_VALUE caml_val_int( int i ) { + CAMLparam0(); + SWIG_CAMLlocal1(iv); + iv = caml_swig_alloc(1,C_int); + SWIG_Store_field(iv,0,Val_int(i)); + CAMLreturn(iv); + } + + SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int ui ) { + CAMLparam0(); + SWIG_CAMLlocal1(uiv); + uiv = caml_swig_alloc(1,C_int); + SWIG_Store_field(uiv,0,Val_int(ui)); + CAMLreturn(uiv); + } + + SWIGSTATIC CAML_VALUE caml_val_long( long l ) { + CAMLparam0(); + SWIG_CAMLlocal1(lv); + lv = caml_swig_alloc(1,C_int64); + SWIG_Store_field(lv,0,copy_int64(l)); + CAMLreturn(lv); + } + + SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long ul ) { + CAMLparam0(); + SWIG_CAMLlocal1(ulv); + ulv = caml_swig_alloc(1,C_int64); + SWIG_Store_field(ulv,0,copy_int64(ul)); + CAMLreturn(ulv); + } + + SWIGSTATIC CAML_VALUE caml_val_float( float f ) { + CAMLparam0(); + SWIG_CAMLlocal1(fv); + fv = caml_swig_alloc(1,C_float); + SWIG_Store_field(fv,0,copy_double((double)f)); + CAMLreturn(fv); + } + + SWIGSTATIC CAML_VALUE caml_val_double( double d ) { + CAMLparam0(); + SWIG_CAMLlocal1(fv); + fv = caml_swig_alloc(1,C_double); + SWIG_Store_field(fv,0,copy_double(d)); + CAMLreturn(fv); + } + + SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *info ) { + CAMLparam0(); + SWIG_CAMLlocal1(vv); + vv = caml_swig_alloc(2,C_ptr); + SWIG_Store_field(vv,0,copy_int64((long)p)); + SWIG_Store_field(vv,1,copy_int64((long)info)); + CAMLreturn(vv); + } + + SWIGSTATIC CAML_VALUE caml_val_string( const char *p ) { + CAMLparam0(); + SWIG_CAMLlocal1(vv); + if( !p ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); + vv = caml_swig_alloc(1,C_string); + SWIG_Store_field(vv,0,copy_string(p)); + CAMLreturn(vv); + } + + SWIGSTATIC CAML_VALUE caml_val_string_len( const char *p, int len ) { + CAMLparam0(); + SWIG_CAMLlocal1(vv); + if( !p || len < 0 ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); + vv = caml_swig_alloc(1,C_string); + SWIG_Store_field(vv,0,alloc_string(len)); + memcpy(String_val(SWIG_Field(vv,0)),p,len); + CAMLreturn(vv); + } + + #define caml_val_obj(v, name) caml_val_obj_helper(v, SWIG_TypeQuery((name)), name) + SWIGSTATIC CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) { + CAMLparam0(); + CAMLreturn(callback2(*caml_named_value("caml_create_object_fn"), + caml_val_ptr(v,type), + copy_string(name))); + } + + SWIGSTATIC long caml_long_val_full( CAML_VALUE v, char *name ) { + CAMLparam1(v); + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_bool: + case C_char: + case C_uchar: + case C_short: + case C_ushort: + case C_int: + CAMLreturn(Int_val(SWIG_Field(v,0))); + case C_uint: + case C_int32: + CAMLreturn(Int32_val(SWIG_Field(v,0))); + case C_int64: + CAMLreturn((long)SWIG_Int64_val(SWIG_Field(v,0))); + case C_float: + case C_double: + CAMLreturn((long)Double_val(SWIG_Field(v,0))); + case C_string: + CAMLreturn((long)String_val(SWIG_Field(v,0))); + case C_ptr: + CAMLreturn((long)SWIG_Int64_val(SWIG_Field(SWIG_Field(v,0),0))); + case C_enum: { + SWIG_CAMLlocal1(ret); + CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int"); + if( !name ) failwith( "Not an enum conversion" ); + ret = callback2(*enum_to_int,*caml_named_value(name),v); + CAMLreturn(caml_long_val(ret)); + } + default: + failwith("No conversion to int"); + } + } + + SWIGSTATIC long caml_long_val( CAML_VALUE v ) { + return caml_long_val_full(v,0); + } + + SWIGSTATIC double caml_double_val( CAML_VALUE v ) { + CAMLparam1(v); + if( !Is_block(v) ) return 0.0; + switch( SWIG_Tag_val(v) ) { + case C_bool: + case C_char: + case C_uchar: + case C_short: + case C_ushort: + case C_int: + CAMLreturn_type(Int_val(SWIG_Field(v,0))); + case C_uint: + case C_int32: + CAMLreturn_type(Int32_val(SWIG_Field(v,0))); + case C_int64: + CAMLreturn_type(SWIG_Int64_val(SWIG_Field(v,0))); + case C_float: + case C_double: + CAMLreturn_type(Double_val(SWIG_Field(v,0))); + default: + fprintf( stderr, "Unknown block tag %d\n", SWIG_Tag_val(v) ); + failwith("No conversion to double"); + } + } + + SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, + swig_type_info *descriptor ) { + CAMLparam1(v); + void *outptr = NULL; + swig_type_info *outdescr = NULL; + + if( v == Val_unit ) { + *out = 0; + CAMLreturn(0); + } + if( !Is_block(v) ) return -1; + switch( SWIG_Tag_val(v) ) { + case C_int: + if( !caml_long_val( v ) ) { + *out = 0; + CAMLreturn(0); + } else { + *out = 0; + CAMLreturn(1); + } + break; + case C_obj: + CAMLreturn + (caml_ptr_val_internal + (callback(*caml_named_value("caml_obj_ptr"),v), + out,descriptor)); + case C_string: + outptr = (void *)String_val(SWIG_Field(v,0)); + break; + case C_ptr: + outptr = (void *)(long)SWIG_Int64_val(SWIG_Field(v,0)); + outdescr = (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field(v,1)); + break; + default: + *out = 0; + CAMLreturn(1); + break; + } + + CAMLreturn(SWIG_GetPtr(outptr,out,outdescr,descriptor)); + } + + SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) { + CAMLparam0(); +#ifdef TYPE_CAST_VERBOSE + caml_print_val( v ); +#endif + void *out = NULL; + if( !caml_ptr_val_internal( v, &out, descriptor ) ) + CAMLreturn_type(out); + else + failwith( "No appropriate conversion found." ); + } + + SWIGSTATIC char *caml_string_val( CAML_VALUE v ) { + return (char *)caml_ptr_val( v, 0 ); + } + + SWIGSTATIC int caml_string_len( CAML_VALUE v ) { + switch( SWIG_Tag_val(v) ) { + case C_string: + return string_length(SWIG_Field(v,0)); + default: + return strlen((char *)caml_ptr_val(v,0)); + } + } + + SWIGSTATIC int caml_bool_check( CAML_VALUE v ) { + CAMLparam1(v); + + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_bool: + case C_ptr: + case C_string: + CAMLreturn(1); + default: + CAMLreturn(0); + } + } + + SWIGSTATIC int caml_int_check( CAML_VALUE v ) { + CAMLparam1(v); + + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_char: + case C_uchar: + case C_short: + case C_ushort: + case C_int: + case C_uint: + case C_int32: + case C_int64: + CAMLreturn(1); + + default: + CAMLreturn(0); + } + } + + SWIGSTATIC int caml_float_check( CAML_VALUE v ) { + CAMLparam1(v); + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_float: + case C_double: + CAMLreturn(1); + + default: + CAMLreturn(0); + } + } + + SWIGSTATIC int caml_ptr_check( CAML_VALUE v ) { + CAMLparam1(v); + if( !Is_block(v) ) return 0; + + switch( SWIG_Tag_val(v) ) { + case C_string: + case C_ptr: + case C_int64: + CAMLreturn(1); + + default: + CAMLreturn(0); + } + } + + static swig_module_info *SWIG_Ocaml_GetModule() { + CAML_VALUE pointer; + + pointer = callback(*caml_named_value("swig_find_type_info"), caml_val_int(0)); + if (Is_block(pointer) && SWIG_Tag_val(pointer) == C_ptr) { + return (swig_module_info *)(void *)(long)SWIG_Int64_val(SWIG_Field(pointer,0)); + } + return 0; + } + + static void SWIG_Ocaml_SetModule(swig_module_info *pointer) { + CAML_VALUE mod_pointer; + + mod_pointer = caml_val_ptr(pointer, NULL); + callback(*caml_named_value("swig_set_type_info"), mod_pointer); + } + +#ifdef __cplusplus +} +#endif +#undef value + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/ocamldec.swg b/devtools/swigwin-1.3.34/Lib/ocaml/ocamldec.swg new file mode 100644 index 0000000..3b5290f --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/ocamldec.swg @@ -0,0 +1,172 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * ocamldec.swg + * + * Ocaml runtime code -- declarations + * ----------------------------------------------------------------------------- */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#ifdef __cplusplus +#define SWIGEXT extern "C" +SWIGEXT { +#else +#define SWIGEXT +#endif +#define value caml_value_t +#define CAML_VALUE caml_value_t +#include <caml/alloc.h> +#include <caml/custom.h> +#include <caml/mlvalues.h> +#include <caml/memory.h> +#include <caml/callback.h> +#include <caml/fail.h> +#include <caml/misc.h> + +#define caml_array_set swig_caml_array_set + +// Adapted from memory.h and mlvalues.h + +#define SWIG_CAMLlocal1(x) \ + caml_value_t x = 0; \ + CAMLxparam1 (x) + +#define SWIG_CAMLlocal2(x, y) \ + caml_value_t x = 0, y = 0; \ + CAMLxparam2 (x, y) + +#define SWIG_CAMLlocal3(x, y, z) \ + caml_value_t x = 0, y = 0, z = 0; \ + CAMLxparam3 (x, y, z) + +#define SWIG_CAMLlocal4(x, y, z, t) \ + caml_value_t x = 0, y = 0, z = 0, t = 0; \ + CAMLxparam4 (x, y, z, t) + +#define SWIG_CAMLlocal5(x, y, z, t, u) \ + caml_value_t x = 0, y = 0, z = 0, t = 0, u = 0; \ + CAMLxparam5 (x, y, z, t, u) + +#define SWIG_CAMLlocalN(x, size) \ + caml_value_t x [(size)] = { 0, /* 0, 0, ... */ }; \ + CAMLxparamN (x, (size)) + +#define SWIG_Field(x, i) (((caml_value_t *)(x)) [i]) /* Also an l-value. */ +#define SWIG_Store_field(block, offset, val) do{ \ + mlsize_t caml__temp_offset = (offset); \ + caml_value_t caml__temp_val = (val); \ + modify (&SWIG_Field ((block), caml__temp_offset), caml__temp_val); \ +}while(0) + +#define SWIG_Data_custom_val(v) ((void *) &SWIG_Field((v), 1)) +#ifdef ARCH_BIG_ENDIAN +#define SWIG_Tag_val(val) (((unsigned char *) (val)) [-1]) + /* Also an l-value. */ +#define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [sizeof(caml_value_t)-1]) + /* Also an l-value. */ +#else +#define SWIG_Tag_val(val) (((unsigned char *) (val)) [-sizeof(caml_value_t)]) + /* Also an l-value. */ +#define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [0]) + /* Also an l-value. */ +#endif + +#ifdef CAMLreturn0 +#undef CAMLreturn0 +#endif +#define CAMLreturn0 do{ \ + caml_local_roots = caml__frame; \ + return; \ +}while (0) + +#ifdef CAMLreturn +#undef CAMLreturn +#endif +#define CAMLreturn(result) do{ \ + caml_value_t caml__temp_result = (result); \ + caml_local_roots = caml__frame; \ + return (caml__temp_result); \ +}while(0) + +#define CAMLreturn_type(result) do{ \ + caml_local_roots = caml__frame; \ + return result; \ +}while(0) + +#ifdef CAMLnoreturn +#undef CAMLnoreturn +#endif +#define CAMLnoreturn ((void) caml__frame) + + +#ifndef ARCH_ALIGN_INT64 +#define SWIG_Int64_val(v) (*((int64 *) SWIG_Data_custom_val(v))) +#else +CAMLextern int64 Int64_val(caml_value_t v); +#define SWIG_Int64_val(v) Int64_val(v) +#endif + +#define SWIG_NewPointerObj(p,type,flags) caml_val_ptr(p,type) +#define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer) + +#define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else + + SWIGSTATIC int + SWIG_GetPtr(void *source, void **result, swig_type_info *type, swig_type_info *result_type); + + SWIGSTATIC void * + SWIG_MustGetPtr (CAML_VALUE v, swig_type_info *type); + + SWIGSTATIC CAML_VALUE _wrap_delete_void( CAML_VALUE ); + + SWIGSTATIC int enum_to_int( char *name, CAML_VALUE v ); + SWIGSTATIC CAML_VALUE int_to_enum( char *name, int v ); + + SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ); + SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ); + SWIGSTATIC int caml_list_length( CAML_VALUE lst ); + SWIGSTATIC CAML_VALUE caml_array_new( int n ); + SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ); + SWIGSTATIC CAML_VALUE caml_array_nth( CAML_VALUE arr, int n ); + SWIGSTATIC int caml_array_length( CAML_VALUE arr ); + + SWIGSTATIC CAML_VALUE caml_val_char( char c ); + SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char c ); + + SWIGSTATIC CAML_VALUE caml_val_short( short s ); + SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short s ); + + SWIGSTATIC CAML_VALUE caml_val_int( int x ); + SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int x ); + + SWIGSTATIC CAML_VALUE caml_val_long( long x ); + SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long x ); + + SWIGSTATIC CAML_VALUE caml_val_float( float f ); + SWIGSTATIC CAML_VALUE caml_val_double( double d ); + + SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor ); + + SWIGSTATIC CAML_VALUE caml_val_string( const char *str ); + SWIGSTATIC CAML_VALUE caml_val_string_len( const char *str, int len ); + + SWIGSTATIC long caml_long_val( CAML_VALUE v ); + SWIGSTATIC double caml_double_val( CAML_VALUE v ); + + SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, + swig_type_info *descriptor ); + SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ); + + SWIGSTATIC char *caml_string_val( CAML_VALUE v ); + SWIGSTATIC int caml_string_len( CAML_VALUE v ); + +#ifdef __cplusplus +} +#endif + +/* mzschemedec.swg ends here */ diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/ocamlkw.swg b/devtools/swigwin-1.3.34/Lib/ocaml/ocamlkw.swg new file mode 100644 index 0000000..ba06f23 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/ocamlkw.swg @@ -0,0 +1,64 @@ +#ifndef OCAML_OCAMLKW_SWG_ +#define OCAML_OCAMLKW_SWG_ + +/* Warnings for Ocaml keywords */ +#define OCAMLKW(x) %namewarn("314:" #x " is a ocaml keyword and it will properly renamed") #x + +/* + from + http://caml.inria.fr/ocaml/htmlman/manual044.html +*/ + + +OCAMLKW(and); +OCAMLKW(as); +OCAMLKW(assert); +OCAMLKW(begin); +OCAMLKW(class); +OCAMLKW(constraint); +OCAMLKW(do); +OCAMLKW(done); +OCAMLKW(downto); +OCAMLKW(else); +OCAMLKW(end); +OCAMLKW(exception); +OCAMLKW(external); +OCAMLKW(false); +OCAMLKW(for); +OCAMLKW(fun); +OCAMLKW(function); +OCAMLKW(functor); +OCAMLKW(if); +OCAMLKW(in); +OCAMLKW(include); +OCAMLKW(inherit); +OCAMLKW(initializer); +OCAMLKW(lazy); +OCAMLKW(let); +OCAMLKW(match); +OCAMLKW(method); +OCAMLKW(module); +OCAMLKW(mutable); +OCAMLKW(new); +OCAMLKW(object); +OCAMLKW(of); +OCAMLKW(open); +OCAMLKW(or); +OCAMLKW(private); +OCAMLKW(rec); +OCAMLKW(sig); +OCAMLKW(struct); +OCAMLKW(then); +OCAMLKW(to); +OCAMLKW(true); +OCAMLKW(try); +OCAMLKW(type); +OCAMLKW(val); +OCAMLKW(virtual); +OCAMLKW(when); +OCAMLKW(while); +OCAMLKW(with); + +#undef OCAMLKW + +#endif //OCAML_OCAMLKW_SWG_ diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/preamble.swg b/devtools/swigwin-1.3.34/Lib/ocaml/preamble.swg new file mode 100644 index 0000000..39374ce --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/preamble.swg @@ -0,0 +1,17 @@ +%insert(mli) %{ +exception BadArgs of string +exception BadMethodName of c_obj * string * string +exception NotObject of c_obj +exception NotEnumType of c_obj +exception LabelNotFromThisEnum of c_obj +exception InvalidDirectorCall of c_obj +%} + +%insert(ml) %{ +exception BadArgs of string +exception BadMethodName of c_obj * string * string +exception NotObject of c_obj +exception NotEnumType of c_obj +exception LabelNotFromThisEnum of c_obj +exception InvalidDirectorCall of c_obj +%}
\ No newline at end of file diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_common.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_common.i new file mode 100644 index 0000000..b2dff61 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_common.i @@ -0,0 +1,22 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_common.i + * + * SWIG typemaps for STL - common utilities + * ----------------------------------------------------------------------------- */ + +%include <std/std_except.i> + +%apply size_t { std::size_t }; + +%{ +#include <string> + CAML_VALUE SwigString_FromString(const std::string& s) { + return caml_val_string((char *)s.c_str()); + } + std::string SwigString_AsString(CAML_VALUE o) { + return std::string((char *)caml_ptr_val(o,0)); + } +%} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_complex.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_complex.i new file mode 100644 index 0000000..5192261 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_complex.i @@ -0,0 +1,65 @@ +// -*- C++ -*- +#ifndef SWIG_STD_COMPLEX_I_ +#define SWIG_STD_COMPLEX_I_ + +#ifdef SWIG + +%{ +#include <complex> +%} + +namespace std +{ + template <class T> class complex; + + %define specialize_std_complex(T) + + %typemap(in) complex<T> { + if (PyComplex_Check($input)) { + $1 = std::complex<T>(PyComplex_RealAsDouble($input), + PyComplex_ImagAsDouble($input)); + } else if (PyFloat_Check($input)) { + $1 = std::complex<T>(PyFloat_AsDouble($input), 0); + } else if (PyInt_Check($input)) { + $1 = std::complex<T>(PyInt_AsLong($input), 0); + } + else { + PyErr_SetString(PyExc_TypeError,"Expected a complex"); + SWIG_fail; + } + } + + %typemap(in) const complex<T>& (std::complex<T> temp) { + if (PyComplex_Check($input)) { + temp = std::complex<T>(PyComplex_RealAsDouble($input), + PyComplex_ImagAsDouble($input)); + $1 = &temp; + } else if (PyFloat_Check($input)) { + temp = std::complex<T>(PyFloat_AsDouble($input), 0); + $1 = &temp; + } else if (PyInt_Check($input)) { + temp = std::complex<T>(PyInt_AsLong($input), 0); + $1 = &temp; + } else { + PyErr_SetString(PyExc_TypeError,"Expected a complex"); + SWIG_fail; + } + } + + %typemap(out) complex<T> { + $result = PyComplex_FromDoubles($1.real(), $1.imag()); + } + + %typemap(out) const complex<T> & { + $result = PyComplex_FromDoubles($1->real(), $1->imag()); + } + + %enddef + + specialize_std_complex(double); + specialize_std_complex(float); +} + +#endif // SWIG + +#endif //SWIG_STD_COMPLEX_I_ diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_deque.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_deque.i new file mode 100644 index 0000000..44815eb --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_deque.i @@ -0,0 +1,31 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_deque.i + * + * Default std_deque wrapper + * ----------------------------------------------------------------------------- */ + +%module std_deque + +%rename(__getitem__) std::deque::getitem; +%rename(__setitem__) std::deque::setitem; +%rename(__delitem__) std::deque::delitem; +%rename(__getslice__) std::deque::getslice; +%rename(__setslice__) std::deque::setslice; +%rename(__delslice__) std::deque::delslice; + +%extend std::deque { + int __len__() { + return (int) self->size(); + } + int __nonzero__() { + return ! self->empty(); + } + void append(const T &x) { + self->push_back(x); + } +}; + +%include <_std_deque.i> diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_list.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_list.i new file mode 100644 index 0000000..0aea907 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_list.i @@ -0,0 +1,222 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_list.i + * + * SWIG typemaps for std::list types + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +%module std_list +%{ +#include <list> +#include <stdexcept> +%} + + +namespace std{ + template<class T> class list + { + public: + + typedef T &reference; + typedef const T& const_reference; + typedef T &iterator; + typedef const T& const_iterator; + + list(); + list(unsigned int size, const T& value = T()); + list(const list<T> &); + + ~list(); + void assign(unsigned int n, const T& value); + void swap(list<T> &x); + + const_reference front(); + const_reference back(); + const_iterator begin(); + const_iterator end(); + + void resize(unsigned int n, T c = T()); + bool empty() const; + + void push_front(const T& x); + void push_back(const T& x); + + + void pop_front(); + void pop_back(); + void clear(); + unsigned int size() const; + unsigned int max_size() const; + void resize(unsigned int n, const T& value); + + void remove(const T& value); + void unique(); + void reverse(); + void sort(); + + + + %extend + { + const_reference __getitem__(int i) throw (std::out_of_range) + { + std::list<T>::iterator first = self->begin(); + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + { + for (int k=0;k<i;k++) + { + first++; + } + return *first; + } + else throw std::out_of_range("list index out of range"); + } + void __setitem__(int i, const T& x) throw (std::out_of_range) + { + std::list<T>::iterator first = self->begin(); + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + { + for (int k=0;k<i;k++) + { + first++; + } + *first = x; + } + else throw std::out_of_range("list index out of range"); + } + void __delitem__(int i) throw (std::out_of_range) + { + std::list<T>::iterator first = self->begin(); + int size = int(self->size()); + if (i<0) i += size; + if (i>=0 && i<size) + { + for (int k=0;k<i;k++) + { + first++; + } + self->erase(first); + } + else throw std::out_of_range("list index out of range"); + } + std::list<T> __getslice__(int i,int j) + { + std::list<T>::iterator first = self->begin(); + std::list<T>::iterator end = self->end(); + + int size = int(self->size()); + if (i<0) i += size; + if (j<0) j += size; + if (i<0) i = 0; + if (j>size) j = size; + if (i>=j) i=j; + if (i>=0 && i<size && j>=0) + { + for (int k=0;k<i;k++) + { + first++; + } + for (int m=0;m<j;m++) + { + end++; + } + std::list<T> tmp(j-i); + if (j>i) std::copy(first,end,tmp.begin()); + return tmp; + } + else throw std::out_of_range("list index out of range"); + } + void __delslice__(int i,int j) + { + std::list<T>::iterator first = self->begin(); + std::list<T>::iterator end = self->end(); + + int size = int(self->size()); + if (i<0) i += size; + if (j<0) j += size; + if (i<0) i = 0; + if (j>size) j = size; + + for (int k=0;k<i;k++) + { + first++; + } + for (int m=0;m<=j;m++) + { + end++; + } + self->erase(first,end); + } + void __setslice__(int i,int j, const std::list<T>& v) + { + std::list<T>::iterator first = self->begin(); + std::list<T>::iterator end = self->end(); + + int size = int(self->size()); + if (i<0) i += size; + if (j<0) j += size; + if (i<0) i = 0; + if (j>size) j = size; + + for (int k=0;k<i;k++) + { + first++; + } + for (int m=0;m<=j;m++) + { + end++; + } + if (int(v.size()) == j-i) + { + std::copy(v.begin(),v.end(),first); + } + else { + self->erase(first,end); + if (i+1 <= int(self->size())) + { + first = self->begin(); + for (int k=0;k<i;k++) + { + first++; + } + self->insert(first,v.begin(),v.end()); + } + else self->insert(self->end(),v.begin(),v.end()); + } + + } + unsigned int __len__() + { + return self->size(); + } + bool __nonzero__() + { + return !(self->empty()); + } + void append(const T& x) + { + self->push_back(x); + } + void pop() + { + self->pop_back(); + } + + }; + + }; +} + + + + + + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_map.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_map.i new file mode 100644 index 0000000..f174f28 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_map.i @@ -0,0 +1,173 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_map.i + * + * SWIG typemaps for std::map + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::map +// ------------------------------------------------------------------------ + +%{ +#include <map> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + template<class K, class T> class map { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + + + // specializations for built-ins + + %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) + + template<class T> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T& get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, const T& x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) + template<class K> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(const K& key, T x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, + T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) + template<> class map<K,T> { + // add typemaps here + public: + map(); + map(const map<K,T> &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + T get(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); + } + void set(K key, T x) { + (*self)[key] = x; + } + void del(K key) throw (std::out_of_range) { + std::map<K,T >::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(K key) { + std::map<K,T >::iterator i = self->find(key); + return i != self->end(); + } + } + }; + %enddef + + // add specializations here +} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_pair.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_pair.i new file mode 100644 index 0000000..dc0604d --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_pair.i @@ -0,0 +1,37 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_pair.i + * + * SWIG typemaps for std::pair + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <exception.i> + +// ------------------------------------------------------------------------ +// std::pair +// ------------------------------------------------------------------------ + +%{ +#include <utility> +%} + +namespace std { + + template<class T, class U> struct pair { + + pair(); + pair(T first, U second); + pair(const pair& p); + + template <class U1, class U2> pair(const pair<U1, U2> &p); + + T first; + U second; + }; + + // add specializations here + +} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_string.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_string.i new file mode 100644 index 0000000..7add3a0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_string.i @@ -0,0 +1,179 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_string.i + * + * SWIG typemaps for std::string + * ----------------------------------------------------------------------------- */ + +// ------------------------------------------------------------------------ +// 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> +#include <vector> + using std::string; + using std::vector; +%} + +%include <std_vector.i> + +%naturalvar std::string; +%naturalvar std::wstring; + +namespace std { + template <class charT> class basic_string { + public: + typedef charT *pointer; + typedef charT &reference; + typedef const charT &const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + basic_string(); + basic_string( charT *str ); + size_t size(); + charT operator []( int pos ) const; + charT *c_str() const; + basic_string<charT> &operator = ( const basic_string &ws ); + basic_string<charT> &operator = ( const charT *str ); + basic_string<charT> &append( const basic_string<charT> &other ); + basic_string<charT> &append( const charT *str ); + void push_back( charT c ); + void clear(); + void reserve( size_type t ); + void resize( size_type n, charT c = charT() ); + int compare( const basic_string<charT> &other ) const; + int compare( const charT *str ) const; + basic_string<charT> &insert( size_type pos, + const basic_string<charT> &str ); + size_type find( const basic_string<charT> &other, int pos = 0 ) const; + size_type find( charT c, int pos = 0 ) const; + %extend { + bool operator == ( const basic_string<charT> &other ) const { + return self->compare( other ) == 0; + } + bool operator != ( const basic_string<charT> &other ) const { + return self->compare( other ) != 0; + } + bool operator < ( const basic_string<charT> &other ) const { + return self->compare( other ) == -1; + } + bool operator > ( const basic_string<charT> &other ) const { + return self->compare( other ) == 1; + } + bool operator <= ( const basic_string<charT> &other ) const { + return self->compare( other ) != 1; + } + bool operator >= ( const basic_string<charT> &other ) const { + return self->compare( other ) != -1; + } + } + }; + + %template(string) basic_string<char>; + %template(wstring) basic_string<wchar_t>; + typedef basic_string<char> string; + typedef basic_string<wchar_t> wstring; + + /* Overloading check */ + %typemap(in) string { + if (caml_ptr_check($input)) + $1.assign((char *)caml_ptr_val($input,0), + caml_string_len($input)); + else + SWIG_exception(SWIG_TypeError, "string expected"); + } + + %typemap(in) const string & (std::string temp) { + if (caml_ptr_check($input)) { + temp.assign((char *)caml_ptr_val($input,0), + caml_string_len($input)); + $1 = &temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) string & (std::string temp) { + if (caml_ptr_check($input)) { + temp.assign((char *)caml_ptr_val($input,0), + caml_string_len($input)); + $1 = &temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(in) string * (std::string *temp) { + if (caml_ptr_check($input)) { + temp = new std::string((char *)caml_ptr_val($input,0), + caml_string_len($input)); + $1 = temp; + } else { + SWIG_exception(SWIG_TypeError, "string expected"); + } + } + + %typemap(free) string * (std::string *temp) { + delete temp; + } + + %typemap(argout) string & { + caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), + (*$1).size())); + } + + %typemap(directorout) string { + $result.assign((char *)caml_ptr_val($input,0), + caml_string_len($input)); + } + + %typemap(out) string { + $result = caml_val_string_len($1.c_str(),$1.size()); + } + + %typemap(out) string * { + $result = caml_val_string_len((*$1).c_str(),(*$1).size()); + } +} + +#ifdef ENABLE_CHARPTR_ARRAY +char **c_charptr_array( const std::vector <string > &str_v ); + +%{ + SWIGEXT char **c_charptr_array( const std::vector <string > &str_v ) { + char **out = new char *[str_v.size() + 1]; + out[str_v.size()] = 0; + for( int i = 0; i < str_v.size(); i++ ) { + out[i] = (char *)str_v[i].c_str(); + } + return out; + } +%} +#endif + +#ifdef ENABLE_STRING_VECTOR +%template (StringVector) std::vector<string >; + +%insert(ml) %{ + (* Some STL convenience items *) + + let string_array_to_vector sa = + let nv = _new_StringVector C_void in + array_to_vector nv (fun x -> C_string x) sa ; nv + + let c_string_array ar = + _c_charptr_array (string_array_to_vector ar) +%} + +%insert(mli) %{ + val c_string_array: string array -> c_obj +%} +#endif diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/std_vector.i b/devtools/swigwin-1.3.34/Lib/ocaml/std_vector.i new file mode 100644 index 0000000..91c3355 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/std_vector.i @@ -0,0 +1,92 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * std_vector.i + * + * SWIG typemaps for std::vector types + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> + +// ------------------------------------------------------------------------ +// std::vector +// +// The aim of all that follows would be to integrate std::vector with +// Python as much as possible, namely, to allow the user to pass and +// be returned Python tuples or lists. +// const declarations are used to guess the intent of the function being +// exported; therefore, the following rationale is applied: +// +// -- f(std::vector<T>), f(const std::vector<T>&), f(const std::vector<T>*): +// the parameter being read-only, either a Python sequence or a +// previously wrapped std::vector<T> can be passed. +// -- f(std::vector<T>&), f(std::vector<T>*): +// the parameter must be modified; therefore, only a wrapped std::vector +// can be passed. +// -- std::vector<T> f(): +// the vector is returned by copy; therefore, a Python sequence of T:s +// is returned which is most easily used in other Python functions +// -- std::vector<T>& f(), std::vector<T>* f(), const std::vector<T>& f(), +// const std::vector<T>* f(): +// the vector is returned by reference; therefore, a wrapped std::vector +// is returned +// ------------------------------------------------------------------------ + +%{ +#include <vector> +#include <algorithm> +#include <stdexcept> +%} + +// exported class + +namespace std { + template <class T> class vector { + public: + vector(unsigned int size = 0); + vector(unsigned int size, const T& value); + vector(const vector<T>&); + unsigned int size() const; + bool empty() const; + void clear(); + void push_back(const T& x); + T operator [] ( int f ); + vector <T> &operator = ( vector <T> &other ); + %extend { + void set( int i, const T &x ) { + self->resize(i+1); + (*self)[i] = x; + } + }; + %extend { + T *to_array() { + T *array = new T[self->size() + 1]; + for( int i = 0; i < self->size(); i++ ) + array[i] = (*self)[i]; + return array; + } + }; + }; +}; + +%insert(ml) %{ + + let array_to_vector v argcons array = + for i = 0 to (Array.length array) - 1 do + (invoke v) "set" (C_list [ C_int i ; (argcons array.(i)) ]) + done ; + v + + let vector_to_array v argcons array = + for i = 0; to (get_int ((invoke v) "size" C_void)) - 1 do + array.(i) <- argcons ((invoke v) "[]" (C_int i)) + done ; + v + +%} + +%insert(mli) %{ + val array_to_vector : c_obj -> ('a -> c_obj) -> 'a array -> c_obj + val vector_to_array : c_obj -> (c_obj -> 'a) -> 'a array -> c_obj +%} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/stl.i b/devtools/swigwin-1.3.34/Lib/ocaml/stl.i new file mode 100644 index 0000000..66b72e0 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/stl.i @@ -0,0 +1,15 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * stl.i + * + * Initial STL definition. extended as needed in each language + * ----------------------------------------------------------------------------- */ + +%include <std_common.i> +%include <std_string.i> +%include <std_vector.i> +%include <std_map.i> +%include <std_pair.i> + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/swig.ml b/devtools/swigwin-1.3.34/Lib/ocaml/swig.ml new file mode 100644 index 0000000..5dc2de7 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/swig.ml @@ -0,0 +1,159 @@ +(* -*- tuareg -*- *) +open Int32 +open Int64 + +type enum = [ `Int of int ] + +type 'a c_obj_t = + C_void + | C_bool of bool + | C_char of char + | C_uchar of char + | C_short of int + | C_ushort of int + | C_int of int + | C_uint of int32 + | C_int32 of int32 + | C_int64 of int64 + | C_float of float + | C_double of float + | C_ptr of int64 * int64 + | C_array of 'a c_obj_t array + | C_list of 'a c_obj_t list + | C_obj of (string -> 'a c_obj_t -> 'a c_obj_t) + | C_string of string + | C_enum of 'a + | C_director_core of 'a c_obj_t * 'a c_obj_t option ref + +type c_obj = enum c_obj_t + +exception BadArgs of string +exception BadMethodName of string * string +exception NotObject of c_obj +exception NotEnumType of c_obj +exception LabelNotFromThisEnum of c_obj +exception InvalidDirectorCall of c_obj +exception NoSuchClass of string +let rec invoke obj = + match obj with + C_obj o -> o + | C_director_core (o,r) -> invoke o + | _ -> raise (NotObject (Obj.magic obj)) +let _ = Callback.register "swig_runmethod" invoke + +let fnhelper arg = + match arg with C_list l -> l | C_void -> [] | _ -> [ arg ] + +let rec get_int x = + match x with + C_bool b -> if b then 1 else 0 + | C_char c + | C_uchar c -> (int_of_char c) + | C_short s + | C_ushort s + | C_int s -> s + | C_uint u + | C_int32 u -> (Int32.to_int u) + | C_int64 u -> (Int64.to_int u) + | C_float f -> (int_of_float f) + | C_double d -> (int_of_float d) + | C_ptr (p,q) -> (Int64.to_int p) + | C_obj o -> (try (get_int (o "int" C_void)) + with _ -> (get_int (o "&" C_void))) + | _ -> raise (Failure "Can't convert to int") + +let rec get_float x = + match x with + C_char c + | C_uchar c -> (float_of_int (int_of_char c)) + | C_short s -> (float_of_int s) + | C_ushort s -> (float_of_int s) + | C_int s -> (float_of_int s) + | C_uint u + | C_int32 u -> (float_of_int (Int32.to_int u)) + | C_int64 u -> (float_of_int (Int64.to_int u)) + | C_float f -> f + | C_double d -> d + | C_obj o -> (try (get_float (o "float" C_void)) + with _ -> (get_float (o "double" C_void))) + | _ -> raise (Failure "Can't convert to float") + +let rec get_char x = + (char_of_int (get_int x)) + +let rec get_string x = + match x with + C_string str -> str + | _ -> raise (Failure "Can't convert to string") + +let rec get_bool x = + match x with + C_bool b -> b + | _ -> + (try if get_int x != 0 then true else false + with _ -> raise (Failure "Can't convert to bool")) + +let disown_object obj = + match obj with + C_director_core (o,r) -> r := None + | _ -> raise (Failure "Not a director core object") +let _ = Callback.register "caml_obj_disown" disown_object +let addr_of obj = + match obj with + C_obj _ -> (invoke obj) "&" C_void + | C_director_core (self,r) -> (invoke self) "&" C_void + | C_ptr _ -> obj + | _ -> raise (Failure "Not a pointer.") +let _ = Callback.register "caml_obj_ptr" addr_of + +let make_float f = C_float f +let make_double f = C_double f +let make_string s = C_string s +let make_bool b = C_bool b +let make_char c = C_char c +let make_char_i c = C_char (char_of_int c) +let make_uchar c = C_uchar c +let make_uchar_i c = C_uchar (char_of_int c) +let make_short i = C_short i +let make_ushort i = C_ushort i +let make_int i = C_int i +let make_uint i = C_uint (Int32.of_int i) +let make_int32 i = C_int32 (Int32.of_int i) +let make_int64 i = C_int64 (Int64.of_int i) + +let new_derived_object cfun x_class args = + begin + let get_object ob = + match !ob with + None -> + raise (NotObject C_void) + | Some o -> o in + let ob_ref = ref None in + let class_fun class_f ob_r = + (fun meth args -> class_f (get_object ob_r) meth args) in + let new_class = class_fun x_class ob_ref in + let dircore = C_director_core (C_obj new_class,ob_ref) in + let obj = + cfun (match args with + C_list argl -> (C_list ((dircore :: argl))) + | C_void -> (C_list [ dircore ]) + | a -> (C_list [ dircore ; a ])) in + ob_ref := Some obj ; + obj + end + +let swig_current_type_info = ref C_void +let find_type_info obj = !swig_current_type_info +let _ = Callback.register "swig_find_type_info" find_type_info +let set_type_info obj = + match obj with + C_ptr _ -> swig_current_type_info := obj ; + obj + | _ -> raise (Failure "Internal error: passed non pointer to set_type_info") +let _ = Callback.register "swig_set_type_info" set_type_info + +let class_master_list = Hashtbl.create 20 +let register_class_byname nm co = + Hashtbl.replace class_master_list nm (Obj.magic co) +let create_class nm arg = + try (Obj.magic (Hashtbl.find class_master_list nm)) arg with _ -> raise (NoSuchClass nm) diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/swig.mli b/devtools/swigwin-1.3.34/Lib/ocaml/swig.mli new file mode 100644 index 0000000..3207b9e --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/swig.mli @@ -0,0 +1,61 @@ +(* -*- tuareg -*- *) + +type enum = [ `Int of int ] + +type 'a c_obj_t = + C_void + | C_bool of bool + | C_char of char + | C_uchar of char + | C_short of int + | C_ushort of int + | C_int of int + | C_uint of int32 + | C_int32 of int32 + | C_int64 of int64 + | C_float of float + | C_double of float + | C_ptr of int64 * int64 + | C_array of 'a c_obj_t array + | C_list of 'a c_obj_t list + | C_obj of (string -> 'a c_obj_t -> 'a c_obj_t) + | C_string of string + | C_enum of 'a + | C_director_core of 'a c_obj_t * 'a c_obj_t option ref + +type c_obj = enum c_obj_t + +exception InvalidDirectorCall of c_obj +exception NoSuchClass of string + +val invoke : ('a c_obj_t) -> (string -> 'a c_obj_t -> 'a c_obj_t) +val fnhelper : 'a c_obj_t -> 'a c_obj_t list + +val get_int : 'a c_obj_t -> int +val get_float : 'a c_obj_t -> float +val get_string : 'a c_obj_t -> string +val get_char : 'a c_obj_t -> char +val get_bool : 'a c_obj_t -> bool + +val make_float : float -> 'a c_obj_t +val make_double : float -> 'a c_obj_t +val make_string : string -> 'a c_obj_t +val make_bool : bool -> 'a c_obj_t +val make_char : char -> 'a c_obj_t +val make_char_i : int -> 'a c_obj_t +val make_uchar : char -> 'a c_obj_t +val make_uchar_i : int -> 'a c_obj_t +val make_short : int -> 'a c_obj_t +val make_ushort : int -> 'a c_obj_t +val make_int : int -> 'a c_obj_t +val make_uint : int -> 'a c_obj_t +val make_int32 : int -> 'a c_obj_t +val make_int64 : int -> 'a c_obj_t + +val new_derived_object: + ('a c_obj_t -> 'a c_obj_t) -> + ('a c_obj_t -> string -> 'a c_obj_t -> 'a c_obj_t) -> + 'a c_obj_t -> 'a c_obj_t + +val register_class_byname : string -> ('a c_obj_t -> 'a c_obj_t) -> unit +val create_class : string -> 'a c_obj_t -> 'a c_obj_t diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/swigp4.ml.in b/devtools/swigwin-1.3.34/Lib/ocaml/swigp4.ml.in new file mode 100644 index 0000000..0387c0a --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/swigp4.ml.in @@ -0,0 +1,118 @@ +open Pcaml ;; + +let lap x y = x :: y +let c_ify e @OCAMLLOC@ = + match e with + <:expr< $int:_$ >> -> <:expr< (C_int $e$) >> + | <:expr< $str:_$ >> -> <:expr< (C_string $e$) >> + | <:expr< $chr:_$ >> -> <:expr< (C_char $e$) >> + | <:expr< $flo:_$ >> -> <:expr< (C_double $e$) >> + | <:expr< True >> -> <:expr< (C_bool $e$) >> + | <:expr< False >> -> <:expr< (C_bool $e$) >> + | _ -> <:expr< $e$ >> +let mk_list args @OCAMLLOC@ f = + let rec mk_list_inner args @OCAMLLOC@ f = + match args with + [] -> <:expr< [] >> + | x :: xs -> + (let @OCAMLLOC@ = MLast.loc_of_expr x in + <:expr< [ ($f x @OCAMLLOC@$) ] @ ($mk_list_inner xs @OCAMLLOC@ f$) >>) in + match args with + [] -> <:expr< (Obj.magic C_void) >> + | [ a ] -> <:expr< (Obj.magic $f a @OCAMLLOC@$) >> + | _ -> <:expr< (Obj.magic (C_list ($mk_list_inner args @OCAMLLOC@ f$))) >> + +EXTEND + expr: + [ [ e1 = expr ; "'" ; "[" ; e2 = expr ; "]" -> + <:expr< (invoke $e1$) "[]" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke $e1$) $str:l$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke $e1$) $str:u$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke $e1$) $s$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "." ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke $e1$) "()" ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:l$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:u$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< (invoke ((invoke $e1$) "->" C_void)) $s$ ($mk_list args @OCAMLLOC@ c_ify$) >> + | e1 = expr ; "'" ; "++" -> + <:expr< (invoke $e1$) "++" C_void >> + | e1 = expr ; "'" ; "--" -> + <:expr< (invoke $e1$) "--" C_void >> + | e1 = expr ; "'" ; "-" ; e2 = expr -> + <:expr< (invoke $e1$) "-" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "+" ; e2 = expr -> <:expr< (invoke $e1$) "+" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "*" ; e2 = expr -> <:expr< (invoke $e1$) "*" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | "'" ; "&" ; e1 = expr -> + <:expr< (invoke $e1$) "&" C_void >> + | "'" ; "!" ; e1 = expr -> + <:expr< (invoke $e1$) "!" C_void >> + | "'" ; "~" ; e1 = expr -> + <:expr< (invoke $e1$) "~" C_void >> + | e1 = expr ; "'" ; "/" ; e2 = expr -> + <:expr< (invoke $e1$) "/" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "%" ; e2 = expr -> + <:expr< (invoke $e1$) "%" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "lsl" ; e2 = expr -> + <:expr< (invoke $e1$) ("<" ^ "<") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "lsr" ; e2 = expr -> + <:expr< (invoke $e1$) (">" ^ ">") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "<" ; e2 = expr -> + <:expr< (invoke $e1$) "<" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "<=" ; e2 = expr -> + <:expr< (invoke $e1$) "<=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; ">" ; e2 = expr -> + <:expr< (invoke $e1$) ">" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; ">=" ; e2 = expr -> + <:expr< (invoke $e1$) ">=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "==" ; e2 = expr -> + <:expr< (invoke $e1$) "==" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "!=" ; e2 = expr -> + <:expr< (invoke $e1$) "!=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "&" ; e2 = expr -> + <:expr< (invoke $e1$) "&" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "^" ; e2 = expr -> + <:expr< (invoke $e1$) "^" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "|" ; e2 = expr -> + <:expr< (invoke $e1$) "|" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "&&" ; e2 = expr -> + <:expr< (invoke $e1$) "&&" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "||" ; e2 = expr -> + <:expr< (invoke $e1$) "||" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "=" ; e2 = expr -> + <:expr< (invoke $e1$) "=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "+=" ; e2 = expr -> + <:expr< (invoke $e1$) "+=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "-=" ; e2 = expr -> + <:expr< (invoke $e1$) "-=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "*=" ; e2 = expr -> + <:expr< (invoke $e1$) "*=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "/=" ; e2 = expr -> + <:expr< (invoke $e1$) "/=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "%=" ; e2 = expr -> + <:expr< (invoke $e1$) "%=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "lsl" ; "=" ; e2 = expr -> + <:expr< (invoke $e1$) ("<" ^ "<=") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "lsr" ; "=" ; e2 = expr -> + <:expr< (invoke $e1$) (">" ^ ">=") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "&=" ; e2 = expr -> + <:expr< (invoke $e1$) "&=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "^=" ; e2 = expr -> + <:expr< (invoke $e1$) "^=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | e1 = expr ; "'" ; "|=" ; e2 = expr -> + <:expr< (invoke $e1$) "|=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >> + | "'" ; e = expr -> c_ify e @OCAMLLOC@ + | c = expr ; "as" ; id = LIDENT -> <:expr< $lid:"get_" ^ id$ $c$ >> + | c = expr ; "to" ; id = LIDENT -> <:expr< $uid:"C_" ^ id$ $c$ >> + | "`" ; "`" ; l = LIDENT -> <:expr< C_enum `$lid:l$ >> + | "`" ; "`" ; u = UIDENT -> <:expr< C_enum `$uid:u$ >> + | f = expr ; "'" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> + <:expr< $f$ ($mk_list args @OCAMLLOC@ c_ify$) >> + ] ] ; +END ;; + diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/typecheck.i b/devtools/swigwin-1.3.34/Lib/ocaml/typecheck.i new file mode 100644 index 0000000..51e6606 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/typecheck.i @@ -0,0 +1,179 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typecheck.i + * + * Typechecking rules + * ----------------------------------------------------------------------------- */ + +%typecheck(SWIG_TYPECHECK_INTEGER) char, signed char, const char &, const signed char & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_char: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, const unsigned char & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_uchar: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) short, signed short, const short &, const signed short &, wchar_t { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_short: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) unsigned short, const unsigned short & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_ushort: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +// XXX arty +// Will move enum SWIGTYPE later when I figure out what to do with it... + +%typecheck(SWIG_TYPECHECK_INTEGER) int, signed int, const int &, const signed int &, enum SWIGTYPE { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_int: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) unsigned int, const unsigned int & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_uint: $1 = 1; break; + case C_int32: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) long, signed long, unsigned long, long long, signed long long, unsigned long long, const long &, const signed long &, const unsigned long &, const long long &, const signed long long &, const unsigned long long & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_int64: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_INTEGER) bool, oc_bool, BOOL, const bool &, const oc_bool &, const BOOL & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_bool: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_DOUBLE) float, const float & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_float: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_DOUBLE) double, const double & { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_double: $1 = 1; break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_STRING) char * { + if( !Is_block($input) ) $1 = 0; + else { + switch( SWIG_Tag_val($input) ) { + case C_string: $1 = 1; break; + case C_ptr: { + swig_type_info *typeinfo = + (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field($input,1)); + $1 = SWIG_TypeCheck("char *",typeinfo) || + SWIG_TypeCheck("signed char *",typeinfo) || + SWIG_TypeCheck("unsigned char *",typeinfo) || + SWIG_TypeCheck("const char *",typeinfo) || + SWIG_TypeCheck("const signed char *",typeinfo) || + SWIG_TypeCheck("const unsigned char *",typeinfo) || + SWIG_TypeCheck("std::string",typeinfo); + } break; + default: $1 = 0; break; + } + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + void *ptr; + $1 = !caml_ptr_val_internal($input, &ptr,$descriptor); +} + +#if 0 + +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { + void *ptr; + $1 = !caml_ptr_val_internal($input, &ptr, $&1_descriptor); +} + +#endif + +%typecheck(SWIG_TYPECHECK_VOIDPTR) void * { + void *ptr; + $1 = !caml_ptr_val_internal($input, &ptr, 0); +} + +/* ------------------------------------------------------------ + * Exception handling + * ------------------------------------------------------------ */ + +%typemap(throws) int, + long, + short, + unsigned int, + unsigned long, + unsigned short { + SWIG_exception($1,"Thrown exception from C++ (int)"); +} + +%typemap(throws) SWIGTYPE CLASS { + $&1_ltype temp = new $1_ltype($1); + SWIG_exception((int)temp,"Thrown exception from C++ (object)"); +} + +%typemap(throws) SWIGTYPE { + (void)$1; + SWIG_exception(0,"Thrown exception from C++ (unknown)"); +} + +%typemap(throws) char * { + SWIG_exception(0,$1); +} diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/typemaps.i b/devtools/swigwin-1.3.34/Lib/ocaml/typemaps.i new file mode 100644 index 0000000..b082d06 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/typemaps.i @@ -0,0 +1,319 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * typemaps.i + * + * The Ocaml module handles all types uniformly via typemaps. Here + * are the definitions. + * ----------------------------------------------------------------------------- */ + +/* Pointers */ + +%typemap(in) void "" + +%typemap(out) void "$result = Val_int(0);" + +%typemap(in) void * { + $1 = caml_ptr_val($input,$descriptor); +} + +%typemap(varin) void * { + $1 = ($ltype)caml_ptr_val($input,$descriptor); +} + +%typemap(out) void * { + $result = caml_val_ptr($1,$descriptor); +} + +%typemap(varout) void * { + $result = caml_val_ptr($1,$descriptor); +} + +#ifdef __cplusplus + +%typemap(in) SWIGTYPE & { + /* %typemap(in) SWIGTYPE & */ + $1 = ($ltype) caml_ptr_val($input,$1_descriptor); +} + +%typemap(varin) SWIGTYPE & { + /* %typemap(varin) SWIGTYPE & */ + $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); +} + +%typemap(out) SWIGTYPE & { + /* %typemap(out) SWIGTYPE & */ + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); + } else { + $result = caml_val_ptr ((void *) &$1,$1_descriptor); + } +} + +#if 0 +%typemap(argout) SWIGTYPE & { + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + swig_result = + caml_list_append(swig_result, + callback(*fromval,caml_val_ptr((void *) $1, + $1_descriptor))); + } else { + swig_result = + caml_list_append(swig_result, + caml_val_ptr ((void *) $1,$1_descriptor)); + } +} +#endif + +%typemap(argout) const SWIGTYPE & { } + +%typemap(in) SWIGTYPE { + $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; +} + +%typemap(out) SWIGTYPE { + /* %typemap(out) SWIGTYPE */ + $&1_ltype temp = new $ltype(($1_ltype &) $1); + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); + } else { + $result = caml_val_ptr ((void *)temp,$&1_descriptor); + } +} + +#else + +%typemap(in) SWIGTYPE { + $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; +} + +%typemap(out) SWIGTYPE { + /* %typemap(out) SWIGTYPE */ + void *temp = calloc(1,sizeof($ltype)); + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + memmove( temp, &$1, sizeof( $1_type ) ); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); + } else { + $result = caml_val_ptr ((void *)temp,$&1_descriptor); + } +} + +%apply SWIGTYPE { const SWIGTYPE & }; + +#endif + +/* The SIMPLE_MAP macro below defines the whole set of typemaps needed + for simple types. */ + +%define SIMPLE_MAP(C_NAME, C_TO_MZ, MZ_TO_C) +/* In */ +%typemap(in) C_NAME { + $1 = MZ_TO_C($input); +} +%typemap(varin) C_NAME { + $1 = MZ_TO_C($input); +} +%typemap(in) C_NAME & ($*1_ltype temp) { + temp = ($*1_ltype) MZ_TO_C($input); + $1 = &temp; +} +%typemap(varin) C_NAME & { + $1 = MZ_TO_C($input); +} +%typemap(directorout) C_NAME { + $1 = MZ_TO_C($input); +} +%typemap(in) C_NAME *INPUT ($*1_ltype temp) { + temp = ($*1_ltype) MZ_TO_C($input); + $1 = &temp; +} +%typemap(in,numinputs=0) C_NAME *OUTPUT ($*1_ltype temp) { + $1 = &temp; +} +/* Out */ +%typemap(out) C_NAME { + $result = C_TO_MZ($1); +} +%typemap(varout) C_NAME { + $result = C_TO_MZ($1); +} +%typemap(varout) C_NAME & { + /* %typemap(varout) C_NAME & (generic) */ + $result = C_TO_MZ($1); +} +%typemap(argout) C_NAME *OUTPUT { + swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); +} +%typemap(out) C_NAME & { + /* %typemap(out) C_NAME & (generic) */ + $result = C_TO_MZ(*$1); +} +%typemap(argout) C_NAME & { + swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); +} +%typemap(directorin) C_NAME { + args = caml_list_append(args,C_TO_MZ($1_name)); +} +%enddef + +SIMPLE_MAP(bool, caml_val_bool, caml_long_val); +SIMPLE_MAP(oc_bool, caml_val_bool, caml_long_val); +SIMPLE_MAP(char, caml_val_char, caml_long_val); +SIMPLE_MAP(signed char, caml_val_char, caml_long_val); +SIMPLE_MAP(unsigned char, caml_val_uchar, caml_long_val); +SIMPLE_MAP(int, caml_val_int, caml_long_val); +SIMPLE_MAP(short, caml_val_short, caml_long_val); +SIMPLE_MAP(wchar_t, caml_val_short, caml_long_val); +SIMPLE_MAP(long, caml_val_long, caml_long_val); +SIMPLE_MAP(ptrdiff_t, caml_val_int, caml_long_val); +SIMPLE_MAP(unsigned int, caml_val_uint, caml_long_val); +SIMPLE_MAP(unsigned short, caml_val_ushort, caml_long_val); +SIMPLE_MAP(unsigned long, caml_val_ulong, caml_long_val); +SIMPLE_MAP(size_t, caml_val_int, caml_long_val); +SIMPLE_MAP(float, caml_val_float, caml_double_val); +SIMPLE_MAP(double, caml_val_double, caml_double_val); +SIMPLE_MAP(long long,caml_val_ulong,caml_long_val); +SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); + +/* Void */ + +%typemap(out) void "$result = Val_unit;"; + +/* Pass through value */ + +%typemap (in) value,caml::value,CAML_VALUE "$1=$input;"; +%typemap (out) value,caml::value,CAML_VALUE "$result=$1;"; + +/* Arrays */ + +%typemap(in) ArrayCarrier * { + $1 = ($ltype)caml_ptr_val($input,$1_descriptor); +} + +%typemap(out) ArrayCarrier * { + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); + } else { + $result = caml_val_ptr ((void *)$1,$1_descriptor); + } +} + +#if 0 +%include <carray.i> +#endif + +/* Handle char arrays as strings */ + +%define %char_ptr_in(how) +%typemap(how) char *, signed char *, unsigned char * { + /* %typemap(how) char * ... */ + $1 = ($ltype)caml_string_val($input); +} +/* Again work around the empty array bound bug */ +%typemap(how) char [ANY], signed char [ANY], unsigned char [ANY] { + /* %typemap(how) char [ANY] ... */ + char *temp = caml_string_val($input); + strcpy((char *)$1,temp); + /* strncpy would be better but we might not have an array size */ +} +%enddef + +%char_ptr_in(in); +%char_ptr_in(varin); +%char_ptr_in(directorout); + +%define %char_ptr_out(how) +%typemap(how) + char *, signed char *, unsigned char *, + const char *, const signed char *, const unsigned char * { + $result = caml_val_string((char *)$1); +} +/* I'd like to use the length here but can't because it might be empty */ +%typemap(how) + char [ANY], signed char [ANY], unsigned char [ANY], + const char [ANY], const signed char [ANY], const unsigned char [ANY] { + $result = caml_val_string((char *)$1); +} +%enddef + +%char_ptr_out(out); +%char_ptr_out(varout); +%char_ptr_out(directorin); + +%define %swigtype_ptr_in(how) +%typemap(how) SWIGTYPE * { + /* %typemap(how) SWIGTYPE * */ + $1 = ($ltype)caml_ptr_val($input,$1_descriptor); +} +%typemap(how) SWIGTYPE (CLASS::*) { + /* %typemap(how) SWIGTYPE (CLASS::*) */ + void *v = caml_ptr_val($input,$1_descriptor); + memcpy(& $1, &v, sizeof(v)); +} +%enddef + +%define %swigtype_ptr_out(how) +%typemap(out) SWIGTYPE * { + /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ + CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + if( fromval ) { + $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); + } else { + $result = caml_val_ptr ((void *)$1,$1_descriptor); + } +} +%typemap(how) SWIGTYPE (CLASS::*) { + /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ + void *v; + memcpy(&v,& $1, sizeof(void *)); + $result = caml_val_ptr (v,$1_descriptor); +} +%enddef + +%swigtype_ptr_in(in); +%swigtype_ptr_in(varin); +%swigtype_ptr_in(directorout); +%swigtype_ptr_out(out); +%swigtype_ptr_out(varout); +%swigtype_ptr_out(directorin); + +%define %swigtype_array_fail(how,msg) +%typemap(how) SWIGTYPE [] { + failwith(msg); +} +%enddef + +%swigtype_array_fail(in,"Array arguments for arbitrary types need a typemap"); +%swigtype_array_fail(varin,"Assignment to global arrays for arbitrary types need a typemap"); +%swigtype_array_fail(out,"Array arguments for arbitrary types need a typemap"); +%swigtype_array_fail(varout,"Array variables need a typemap"); +%swigtype_array_fail(directorin,"Array results with arbitrary types need a typemap"); +%swigtype_array_fail(directorout,"Array arguments with arbitrary types need a typemap"); + +/* C++ References */ + +/* Enums */ +%define %swig_enum_in(how) +%typemap(how) enum SWIGTYPE { + $1 = ($type)caml_long_val_full($input,"$type_marker"); +} +%enddef + +%define %swig_enum_out(how) +%typemap(how) enum SWIGTYPE { + $result = callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),*caml_named_value("$type_marker"),Val_int((int)$1)); +} +%enddef + +%swig_enum_in(in) +%swig_enum_in(varin) +%swig_enum_in(directorout) +%swig_enum_out(out) +%swig_enum_out(varout) +%swig_enum_out(directorin) diff --git a/devtools/swigwin-1.3.34/Lib/ocaml/typeregister.swg b/devtools/swigwin-1.3.34/Lib/ocaml/typeregister.swg new file mode 100644 index 0000000..c3ba904 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/ocaml/typeregister.swg @@ -0,0 +1,2 @@ +SWIGEXT void SWIG_init() { + SWIG_InitializeModule(0); |