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.

44 lines
1.0 KiB

  1. %include <std/std_except.i>
  2. %include <rubystdcommon.swg>
  3. %include <rubystdautodoc.swg>
  4. /*
  5. Generate the traits for a 'primitive' type, such as 'double',
  6. for which the SWIG_AsVal and SWIG_From methods are already defined.
  7. */
  8. %define %traits_ptypen(Type...)
  9. %fragment(SWIG_Traits_frag(Type),"header",
  10. fragment=SWIG_AsVal_frag(Type),
  11. fragment=SWIG_From_frag(Type),
  12. fragment="StdTraits") {
  13. namespace swig {
  14. template <> struct traits<Type > {
  15. typedef value_category category;
  16. static const char* type_name() { return #Type; }
  17. };
  18. template <> struct traits_asval<Type > {
  19. typedef Type value_type;
  20. static int asval(VALUE obj, value_type *val) {
  21. return SWIG_AsVal(Type)(obj, val);
  22. }
  23. };
  24. template <> struct traits_from<Type > {
  25. typedef Type value_type;
  26. static VALUE from(const value_type& val) {
  27. return SWIG_From(Type)(val);
  28. }
  29. };
  30. }
  31. }
  32. %enddef
  33. %include <std/std_common.i>
  34. //
  35. // Generates the traits for all the known primitive
  36. // C++ types (int, double, ...)
  37. //
  38. %apply_cpptypes(%traits_ptypen);