PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/php/const.i

#
Swig | 53 lines | 38 code | 6 blank | 9 comment | 0 complexity | 267970412650ef03160950ada9f0402e MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * const.i
  3. *
  4. * Typemaps for constants
  5. * ----------------------------------------------------------------------------- */
  6. %typemap(consttab) int,
  7. unsigned int,
  8. short,
  9. unsigned short,
  10. long,
  11. unsigned long,
  12. unsigned char,
  13. signed char,
  14. bool,
  15. enum SWIGTYPE
  16. "SWIG_LONG_CONSTANT($symname, $value);";
  17. %typemap(consttab) float,
  18. double
  19. "SWIG_DOUBLE_CONSTANT($symname, $value);";
  20. %typemap(consttab) char
  21. "SWIG_CHAR_CONSTANT($symname, $value);";
  22. %typemap(consttab) char *,
  23. const char *,
  24. char [],
  25. const char []
  26. "SWIG_STRING_CONSTANT($symname, $value);";
  27. %typemap(consttab) SWIGTYPE *,
  28. SWIGTYPE &,
  29. SWIGTYPE [] {
  30. /* This actually registers it as a global variable and constant. I don't
  31. * like it, but I can't figure out the zend_constant code... */
  32. zval *z_var;
  33. MAKE_STD_ZVAL(z_var);
  34. SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0);
  35. /* zend_hash_add(&EG(symbol_table), "$1", sizeof("$1"), (void *)&z_var,sizeof(zval *), NULL); */
  36. zend_constant c;
  37. c.value = *z_var;
  38. zval_copy_ctor(&c.value);
  39. size_t len = sizeof("$1") - 1;
  40. c.name = zend_strndup("$1", len);
  41. c.name_len = len+1;
  42. c.flags = CONST_CS | CONST_PERSISTENT;
  43. c.module_number = module_number;
  44. zend_register_constant( &c TSRMLS_CC );
  45. }
  46. /* Handled as a global variable. */
  47. %typemap(consttab) SWIGTYPE (CLASS::*) "";