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.

59 lines
1.2 KiB

  1. %define CONVERT_BOOL_IN(lvar,t,invar)
  2. convert_to_boolean_ex(invar);
  3. lvar = (t) Z_LVAL_PP(invar);
  4. %enddef
  5. %define CONVERT_INT_IN(lvar,t,invar)
  6. convert_to_long_ex(invar);
  7. lvar = (t) Z_LVAL_PP(invar);
  8. %enddef
  9. %define CONVERT_INT_OUT(lvar,invar)
  10. lvar = (t) Z_LVAL_PP(invar);
  11. %enddef
  12. %define CONVERT_FLOAT_IN(lvar,t,invar)
  13. convert_to_double_ex(invar);
  14. lvar = (t) Z_DVAL_PP(invar);
  15. %enddef
  16. %define CONVERT_CHAR_IN(lvar,t,invar)
  17. convert_to_string_ex(invar);
  18. lvar = (t) *Z_STRVAL_PP(invar);
  19. %enddef
  20. %define CONVERT_STRING_IN(lvar,t,invar)
  21. convert_to_string_ex(invar);
  22. lvar = (t) Z_STRVAL_PP(invar);
  23. %enddef
  24. %define %pass_by_val( TYPE, CONVERT_IN )
  25. %typemap(in) TYPE
  26. %{
  27. CONVERT_IN($1,$1_ltype,$input);
  28. %}
  29. %enddef
  30. %fragment("t_output_helper","header") %{
  31. void
  32. t_output_helper( zval **target, zval *o) {
  33. if ( (*target)->type == IS_ARRAY ) {
  34. /* it's already an array, just append */
  35. add_next_index_zval( *target, o );
  36. return;
  37. }
  38. if ( (*target)->type == IS_NULL ) {
  39. REPLACE_ZVAL_VALUE(target,o,1);
  40. return;
  41. }
  42. zval *tmp;
  43. ALLOC_INIT_ZVAL(tmp);
  44. *tmp = **target;
  45. zval_copy_ctor(tmp);
  46. array_init(*target);
  47. add_next_index_zval( *target, tmp);
  48. add_next_index_zval( *target, o);
  49. }
  50. %}