Method: AutoC::Vector#render_implementation

Defined in:
lib/autoc/vector.rb

#render_implementation(stream) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/autoc/vector.rb', line 72

def render_implementation(stream)
  if element.orderable?
    stream << %{
      static int
      #ifdef __POCC__
        __cdecl
      #endif
      #{ascend}(const void* left, const void* right) {
        return #{element.compare.("(*(#{element.lvalue})left)", "(*(#{element.lvalue})right)")};
      }
      static int
      #ifdef __POCC__
        __cdecl
      #endif
      #{descend}(const void* left, const void* right) {
        return -#{ascend}(left, right);
      }
      #{sort.prototype} {
        qsort(#{storage(:target)}, #{size.('*target')}, sizeof(#{element}), direction > 0 ? #{ascend} : #{descend});
      }
    }
  end
  super
end