import source from 1.3.40
[external/swig.git] / Lib / ocaml / ocamldec.swg
1 /* -----------------------------------------------------------------------------
2  * See the LICENSE file for information on copyright, usage and redistribution
3  * of SWIG, and the README file for authors - http://www.swig.org/release.html.
4  *
5  * ocamldec.swg
6  *
7  * Ocaml runtime code -- declarations
8  * ----------------------------------------------------------------------------- */
9
10 #include <stdio.h>
11 #include <string.h>
12 #include <stdlib.h>
13
14 #ifdef __cplusplus
15 #define SWIGEXT extern "C"
16 SWIGEXT {
17 #else
18 #define SWIGEXT 
19 #endif
20 #define value caml_value_t
21 #define CAML_VALUE caml_value_t
22 #include <caml/alloc.h>
23 #include <caml/custom.h>
24 #include <caml/mlvalues.h>
25 #include <caml/memory.h>
26 #include <caml/callback.h>
27 #include <caml/fail.h>
28 #include <caml/misc.h>
29
30 #define caml_array_set swig_caml_array_set
31
32 // Adapted from memory.h and mlvalues.h
33
34 #define SWIG_CAMLlocal1(x) \
35   caml_value_t x = 0; \
36   CAMLxparam1 (x)
37
38 #define SWIG_CAMLlocal2(x, y) \
39   caml_value_t x = 0, y = 0; \
40   CAMLxparam2 (x, y)
41
42 #define SWIG_CAMLlocal3(x, y, z) \
43   caml_value_t x = 0, y = 0, z = 0; \
44   CAMLxparam3 (x, y, z)
45
46 #define SWIG_CAMLlocal4(x, y, z, t) \
47   caml_value_t x = 0, y = 0, z = 0, t = 0; \
48   CAMLxparam4 (x, y, z, t)
49
50 #define SWIG_CAMLlocal5(x, y, z, t, u) \
51   caml_value_t x = 0, y = 0, z = 0, t = 0, u = 0; \
52   CAMLxparam5 (x, y, z, t, u)
53
54 #define SWIG_CAMLlocalN(x, size) \
55   caml_value_t x [(size)] = { 0, /* 0, 0, ... */ }; \
56   CAMLxparamN (x, (size))
57
58 #define SWIG_Field(x, i) (((caml_value_t *)(x)) [i])           /* Also an l-value. */
59 #define SWIG_Store_field(block, offset, val) do{ \
60   mlsize_t caml__temp_offset = (offset); \
61   caml_value_t caml__temp_val = (val); \
62   modify (&SWIG_Field ((block), caml__temp_offset), caml__temp_val); \
63 }while(0)
64
65 #define SWIG_Data_custom_val(v) ((void *) &SWIG_Field((v), 1))
66 #ifdef ARCH_BIG_ENDIAN
67 #define SWIG_Tag_val(val) (((unsigned char *) (val)) [-1])
68                                                  /* Also an l-value. */
69 #define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [sizeof(caml_value_t)-1])
70                                                  /* Also an l-value. */
71 #else
72 #define SWIG_Tag_val(val) (((unsigned char *) (val)) [-sizeof(caml_value_t)])
73                                                  /* Also an l-value. */
74 #define SWIG_Tag_hp(hp) (((unsigned char *) (hp)) [0])
75                                                  /* Also an l-value. */
76 #endif
77
78 #ifdef CAMLreturn0
79 #undef CAMLreturn0
80 #endif
81 #define CAMLreturn0 do{ \
82   caml_local_roots = caml__frame; \
83   return; \
84 }while (0)
85
86 #ifdef CAMLreturn
87 #undef CAMLreturn
88 #endif
89 #define CAMLreturn(result) do{ \
90   caml_value_t caml__temp_result = (result); \
91   caml_local_roots = caml__frame; \
92   return (caml__temp_result); \
93 }while(0)
94
95 #define CAMLreturn_type(result) do{ \
96   caml_local_roots = caml__frame; \
97   return result; \
98 }while(0)
99
100 #ifdef CAMLnoreturn
101 #undef CAMLnoreturn
102 #endif
103 #define CAMLnoreturn ((void) caml__frame)
104
105
106 #ifndef ARCH_ALIGN_INT64
107 #define SWIG_Int64_val(v) (*((int64 *) SWIG_Data_custom_val(v)))
108 #else
109 CAMLextern int64 Int64_val(caml_value_t v);
110 #define SWIG_Int64_val(v) Int64_val(v)
111 #endif
112
113 #define SWIG_NewPointerObj(p,type,flags) caml_val_ptr(p,type)
114 #define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule()
115 #define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer)
116
117 #define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else
118
119     SWIGSTATIC int
120     SWIG_GetPtr(void *source, void **result, swig_type_info *type, swig_type_info *result_type);
121     
122     SWIGSTATIC void *
123     SWIG_MustGetPtr (CAML_VALUE v,  swig_type_info *type);
124     
125     SWIGSTATIC CAML_VALUE _wrap_delete_void( CAML_VALUE );
126     
127     SWIGSTATIC int enum_to_int( char *name, CAML_VALUE v );
128     SWIGSTATIC CAML_VALUE int_to_enum( char *name, int v );
129
130     SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n );
131     SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt );
132     SWIGSTATIC int caml_list_length( CAML_VALUE lst );
133     SWIGSTATIC CAML_VALUE caml_array_new( int n );
134     SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item );
135     SWIGSTATIC CAML_VALUE caml_array_nth( CAML_VALUE arr, int n );
136     SWIGSTATIC int caml_array_length( CAML_VALUE arr );
137
138     SWIGSTATIC CAML_VALUE caml_val_char( char c );
139     SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char c );
140
141     SWIGSTATIC CAML_VALUE caml_val_short( short s );
142     SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short s );
143     
144     SWIGSTATIC CAML_VALUE caml_val_int( int x );
145     SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int x );
146
147     SWIGSTATIC CAML_VALUE caml_val_long( long x );
148     SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long x );
149
150     SWIGSTATIC CAML_VALUE caml_val_float( float f );
151     SWIGSTATIC CAML_VALUE caml_val_double( double d );
152
153     SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor );
154
155     SWIGSTATIC CAML_VALUE caml_val_string( const char *str );
156     SWIGSTATIC CAML_VALUE caml_val_string_len( const char *str, int len );
157
158     SWIGSTATIC long caml_long_val( CAML_VALUE v );
159     SWIGSTATIC double caml_double_val( CAML_VALUE v );
160
161     SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out,
162                                       swig_type_info *descriptor );
163     SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor );
164
165     SWIGSTATIC char *caml_string_val( CAML_VALUE v );
166     SWIGSTATIC int caml_string_len( CAML_VALUE v );
167
168 #ifdef __cplusplus
169 }
170 #endif
171
172 /* mzschemedec.swg ends here */