Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.7 KiB

  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. * const.i
  6. *
  7. * Typemaps for constants
  8. * ----------------------------------------------------------------------------- */
  9. %typemap(consttab) int,
  10. unsigned int,
  11. short,
  12. unsigned short,
  13. long,
  14. unsigned long,
  15. unsigned char,
  16. signed char,
  17. bool,
  18. enum SWIGTYPE
  19. "SWIG_LONG_CONSTANT($symname, $value);";
  20. %typemap(consttab) float,
  21. double
  22. "SWIG_DOUBLE_CONSTANT($symname, $value);";
  23. %typemap(consttab) char
  24. "SWIG_CHAR_CONSTANT($symname, $value);";
  25. %typemap(consttab) char *,
  26. const char *,
  27. char [],
  28. const char []
  29. "SWIG_STRING_CONSTANT($symname, $value);";
  30. %typemap(consttab) SWIGTYPE *,
  31. SWIGTYPE &,
  32. SWIGTYPE [] {
  33. /* This actually registers it as a global variable and constant. I don't
  34. * like it, but I can't figure out the zend_constant code... */
  35. zval *z_var;
  36. MAKE_STD_ZVAL(z_var);
  37. SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0);
  38. /* zend_hash_add(&EG(symbol_table), "$1", sizeof("$1"), (void *)&z_var,sizeof(zval *), NULL); */
  39. zend_constant c;
  40. c.value = *z_var;
  41. zval_copy_ctor(&c.value);
  42. size_t len = sizeof("$1") - 1;
  43. c.name = zend_strndup("$1", len);
  44. c.name_len = len+1;
  45. c.flags = CONST_CS | CONST_PERSISTENT;
  46. c.module_number = module_number;
  47. zend_register_constant( &c TSRMLS_CC );
  48. }