PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/ocaml/typecheck.i

#
Swig | 176 lines | 146 code | 22 blank | 8 comment | 0 complexity | 8576f850cded9d964dfcc02c6444393c MD5 | raw file
  1/* -----------------------------------------------------------------------------
  2 * typecheck.i
  3 *
  4 * Typechecking rules
  5 * ----------------------------------------------------------------------------- */
  6
  7%typecheck(SWIG_TYPECHECK_INTEGER) char, signed char, const char &, const signed char & {
  8  if( !Is_block($input) ) $1 = 0;
  9  else {
 10      switch( SWIG_Tag_val($input) ) {
 11      case C_char: $1 = 1; break;
 12      default: $1 = 0; break;
 13      }
 14  }
 15}
 16
 17%typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, const unsigned char & {
 18  if( !Is_block($input) ) $1 = 0;
 19  else {
 20      switch( SWIG_Tag_val($input) ) {
 21      case C_uchar: $1 = 1; break;
 22      default: $1 = 0; break;
 23      }
 24  }
 25}
 26
 27%typecheck(SWIG_TYPECHECK_INTEGER) short, signed short, const short &, const signed short &, wchar_t {
 28  if( !Is_block($input) ) $1 = 0;
 29  else {
 30      switch( SWIG_Tag_val($input) ) {
 31      case C_short: $1 = 1; break;
 32      default: $1 = 0; break;
 33      }
 34  }
 35}
 36
 37%typecheck(SWIG_TYPECHECK_INTEGER) unsigned short, const unsigned short & {
 38  if( !Is_block($input) ) $1 = 0;
 39  else {
 40      switch( SWIG_Tag_val($input) ) {
 41      case C_ushort: $1 = 1; break;
 42      default: $1 = 0; break;
 43      }
 44  }
 45}
 46
 47// XXX arty 
 48// Will move enum SWIGTYPE later when I figure out what to do with it...
 49
 50%typecheck(SWIG_TYPECHECK_INTEGER) int, signed int, const int &, const signed int &, enum SWIGTYPE {
 51  if( !Is_block($input) ) $1 = 0;
 52  else {
 53      switch( SWIG_Tag_val($input) ) {
 54      case C_int: $1 = 1; break;
 55      default: $1 = 0; break;
 56      }
 57  }
 58}
 59
 60%typecheck(SWIG_TYPECHECK_INTEGER) unsigned int, const unsigned int & {
 61  if( !Is_block($input) ) $1 = 0;
 62  else {
 63      switch( SWIG_Tag_val($input) ) {
 64      case C_uint: $1 = 1; break;
 65      case C_int32: $1 = 1; break;
 66      default: $1 = 0; break;
 67      }
 68  }
 69}
 70
 71%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 & {
 72  if( !Is_block($input) ) $1 = 0;
 73  else {
 74      switch( SWIG_Tag_val($input) ) {
 75      case C_int64: $1 = 1; break;
 76      default: $1 = 0; break;
 77      }
 78  }
 79}
 80
 81%typecheck(SWIG_TYPECHECK_INTEGER) bool, oc_bool, BOOL, const bool &, const oc_bool &, const BOOL & {
 82  if( !Is_block($input) ) $1 = 0;
 83  else {
 84      switch( SWIG_Tag_val($input) ) {
 85      case C_bool: $1 = 1; break;
 86      default: $1 = 0; break;
 87      }
 88  }
 89}
 90
 91%typecheck(SWIG_TYPECHECK_DOUBLE) float, const float & {
 92  if( !Is_block($input) ) $1 = 0;
 93  else {
 94      switch( SWIG_Tag_val($input) ) {
 95      case C_float: $1 = 1; break;
 96      default: $1 = 0; break;
 97      }
 98  }  
 99}
100
101%typecheck(SWIG_TYPECHECK_DOUBLE) double, const double & {
102  if( !Is_block($input) ) $1 = 0;
103  else {
104      switch( SWIG_Tag_val($input) ) {
105      case C_double: $1 = 1; break;
106      default: $1 = 0; break;
107      }
108  }  
109}
110
111%typecheck(SWIG_TYPECHECK_STRING) char * {
112  if( !Is_block($input) ) $1 = 0;
113  else {
114      switch( SWIG_Tag_val($input) ) {
115      case C_string: $1 = 1; break;
116      case C_ptr: {
117	swig_type_info *typeinfo = 
118	    (swig_type_info *)(long)SWIG_Int64_val(SWIG_Field($input,1));
119	$1 = SWIG_TypeCheck("char *",typeinfo) ||
120	     SWIG_TypeCheck("signed char *",typeinfo) ||
121	     SWIG_TypeCheck("unsigned char *",typeinfo) ||
122	     SWIG_TypeCheck("const char *",typeinfo) ||
123	     SWIG_TypeCheck("const signed char *",typeinfo) ||
124	     SWIG_TypeCheck("const unsigned char *",typeinfo) ||
125	     SWIG_TypeCheck("std::string",typeinfo);
126      } break;
127      default: $1 = 0; break;
128      }
129  }    
130}
131
132%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
133  void *ptr;
134  $1 = !caml_ptr_val_internal($input, &ptr,$descriptor);
135}
136
137#if 0
138
139%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE {
140  void *ptr;
141  $1 = !caml_ptr_val_internal($input, &ptr, $&1_descriptor);
142}
143
144#endif
145
146%typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
147  void *ptr;
148  $1 = !caml_ptr_val_internal($input, &ptr, 0);
149}
150
151/* ------------------------------------------------------------
152 * Exception handling
153 * ------------------------------------------------------------ */
154
155%typemap(throws) int, 
156                  long, 
157                  short, 
158                  unsigned int, 
159                  unsigned long, 
160                  unsigned short {
161  SWIG_exception($1,"Thrown exception from C++ (int)");
162}
163
164%typemap(throws) SWIGTYPE CLASS {
165  $&1_ltype temp = new $1_ltype($1);
166  SWIG_exception((int)temp,"Thrown exception from C++ (object)");
167}
168
169%typemap(throws) SWIGTYPE {
170  (void)$1;
171  SWIG_exception(0,"Thrown exception from C++ (unknown)");
172}
173
174%typemap(throws) char * {
175  SWIG_exception(0,$1);
176}