/tags/rel-1-3-25/SWIG/Lib/php4/typemaps.i

# · Swig · 234 lines · 199 code · 35 blank · 0 comment · 0 complexity · 60618003ac32993128193b32aef56629 MD5 · raw file

  1. //
  2. // SWIG Typemap library
  3. // Richard Palmer
  4. // Oct 3, 2001
  5. //
  6. // PHP4 implementation
  7. //
  8. //
  9. // This library provides standard typemaps for modifying SWIG's behavior.
  10. // With enough entries in this file, I hope that very few people actually
  11. // ever need to write a typemap.
  12. //
  13. %typemap(in) double *INPUT(double temp)
  14. {
  15. temp = (double) Z_DVAL_PP($input);
  16. $1 = &temp;
  17. }
  18. %typemap(in) float *INPUT(float temp)
  19. {
  20. temp = (float) Z_DVAL_PP($input);
  21. $1 = &temp;
  22. }
  23. %typemap(in) int *INPUT(int temp)
  24. {
  25. temp = (int) Z_LVAL_PP($input);
  26. $1 = &temp;
  27. }
  28. %typemap(in) short *INPUT(short temp)
  29. {
  30. temp = (short) Z_LVAL_PP($input);
  31. $1 = &temp;
  32. }
  33. %typemap(in) long *INPUT(long temp)
  34. {
  35. temp = (long) Z_LVAL_PP($input);
  36. $1 = &temp;
  37. }
  38. %typemap(in) unsigned int *INPUT(unsigned int temp)
  39. {
  40. temp = (unsigned int) Z_LVAL_PP($input);
  41. $1 = &temp;
  42. }
  43. %typemap(in) unsigned short *INPUT(unsigned short temp)
  44. {
  45. temp = (unsigned short) Z_LVAL_PP($input);
  46. $1 = &temp;
  47. }
  48. %typemap(in) unsigned long *INPUT(unsigned long temp)
  49. {
  50. temp = (unsigned long) Z_LVAL_PP($input);
  51. $1 = &temp;
  52. }
  53. %typemap(in) unsigned char *INPUT(unsigned char temp)
  54. {
  55. temp = (unsigned char) Z_LVAL_PP($input);
  56. $1 = &temp;
  57. }
  58. %typemap(in,numinputs=0) int *OUTPUT(int temp),
  59. short *OUTPUT(short temp),
  60. long *OUTPUT(long temp),
  61. unsigned int *OUTPUT(unsigned int temp),
  62. unsigned short *OUTPUT(unsigned short temp),
  63. unsigned long *OUTPUT(unsigned long temp),
  64. unsigned char *OUTPUT(unsigned char temp),
  65. float *OUTPUT(float temp),
  66. double *OUTPUT(double temp)
  67. {
  68. $1 = &temp;
  69. }
  70. %typemap(argout) int *OUTPUT,
  71. short *OUTPUT,
  72. long *OUTPUT,
  73. unsigned int *OUTPUT,
  74. unsigned short *OUTPUT,
  75. unsigned long *OUTPUT,
  76. unsigned char *OUTPUT
  77. {
  78. ZVAL_LONG($result,*($input));
  79. }
  80. %typemap(argout) float *OUTPUT,
  81. double *OUTPUT
  82. {
  83. ZVAL_DOUBLE($result,*($input));
  84. }
  85. %typemap(in) int *INOUT = int *INPUT;
  86. %typemap(in) short *INOUT = short *INPUT;
  87. %typemap(in) long *INOUT = long *INPUT;
  88. %typemap(in) unsigned *INOUT = unsigned *INPUT;
  89. %typemap(in) unsigned short *INOUT = unsigned short *INPUT;
  90. %typemap(in) unsigned long *INOUT = unsigned long *INPUT;
  91. %typemap(in) unsigned char *INOUT = unsigned char *INPUT;
  92. %typemap(in) float *INOUT = float *INPUT;
  93. %typemap(in) double *INOUT = double *INPUT;
  94. %typemap(argout) int *INOUT = int *OUTPUT;
  95. %typemap(argout) short *INOUT = short *OUTPUT;
  96. %typemap(argout) long *INOUT= long *OUTPUT;
  97. %typemap(argout) unsigned short *INOUT= unsigned short *OUTPUT;
  98. %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT;
  99. %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT;
  100. %typemap(argout) float *INOUT = float *OUTPUT;
  101. %typemap(argout) double *INOUT= double *OUTPUT;
  102. // REFERENCE
  103. // Accept Php references as pointers
  104. %typemap(in) double *REFERENCE (double dvalue)
  105. {
  106. if(!ParameterPassedByReference(ht, argvi))
  107. {
  108. zend_error(E_WARNING, "Parameter wasn't passed by reference");
  109. RETURN_NULL();
  110. }
  111. dvalue = (double) (*$input)->value.dval;
  112. $1 = &dvalue;
  113. }
  114. %typemap(in) float *REFERENCE (float dvalue)
  115. {
  116. if(!ParameterPassedByReference(ht, argvi))
  117. {
  118. zend_error(E_WARNING, "Parameter wasn't passed by reference");
  119. RETURN_NULL();
  120. }
  121. dvalue = (float) (*$input)->value.dval;
  122. $1 = &dvalue;
  123. }
  124. %typemap(in) int *REFERENCE (int dvalue)
  125. {
  126. if(!ParameterPassedByReference(ht, argvi))
  127. {
  128. zend_error(E_WARNING, "Parameter wasn't passed by reference");
  129. RETURN_NULL();
  130. }
  131. dvalue = (int) (*$input)->value.lval;
  132. $1 = &dvalue;
  133. }
  134. %typemap(in) short *REFERENCE (short dvalue)
  135. {
  136. if(!ParameterPassedByReference(ht, argvi))
  137. {
  138. zend_error(E_WARNING, "Parameter wasn't passed by reference");
  139. RETURN_NULL();
  140. }
  141. dvalue = (short) (*$input)->value.lval;
  142. $1 = &dvalue;
  143. }
  144. %typemap(in) long *REFERENCE (long dvalue)
  145. {
  146. if(!ParameterPassedByReference(ht, argvi))
  147. {
  148. zend_error(E_WARNING, "Parameter wasn't passed by reference");
  149. RETURN_NULL();
  150. }
  151. dvalue = (long) (*$input)->value.lval;
  152. $1 = &dvalue;
  153. }
  154. %typemap(in) unsigned int *REFERENCE (unsigned int dvalue)
  155. {
  156. if(!ParameterPassedByReference(ht, argvi))
  157. {
  158. zend_error(E_WARNING, "Parameter wasn't passed by reference");
  159. RETURN_NULL();
  160. }
  161. dvalue = (unsigned int) (*$input)->value.lval;
  162. $1 = &dvalue;
  163. }
  164. %typemap(in) unsigned short *REFERENCE (unsigned short dvalue)
  165. {
  166. if(!ParameterPassedByReference(ht, argvi))
  167. {
  168. zend_error(E_WARNING, "Parameter wasn't passed by reference");
  169. RETURN_NULL();
  170. }
  171. dvalue = (unsigned short) $input->value.lval;
  172. $1 = &dvalue;
  173. }
  174. %typemap(in) unsigned long *REFERENCE (unsigned long dvalue)
  175. {
  176. if(!ParameterPassedByReference(ht, argvi))
  177. {
  178. zend_error(E_WARNING, "Parameter wasn't passed by reference");
  179. RETURN_NULL();
  180. }
  181. dvalue = (unsigned long) $input->value.lval;
  182. $1 = &dvalue;
  183. }
  184. %typemap(argout) double *REFERENCE,
  185. float *REFERENCE
  186. {
  187. $1->value.dval = (double)(*$arg);
  188. $1->type = IS_DOUBLE;
  189. }
  190. %typemap(argout) int *REFERENCE,
  191. short *REFERENCE,
  192. long *REFERENCE,
  193. unsigned int *REFERENCE,
  194. unsigned short *REFERENCE,
  195. unsigned long *REFERENCE
  196. {
  197. (*$arg)->value.lval = (long)(*$input);
  198. (*$arg)->type = IS_LONG;
  199. }