summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-socket/src/gen.rb
blob: ba2f53a4adc1dda16a8765cc71cd7f73445c7b99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env ruby

Dir.chdir(File.dirname($0))

f = File.open("const.cstub", "w")

IO.readlines("const.def").each { |name|
  name.sub(/^#.*/, "")
  name.strip!
  next if name.empty?

  f.write <<CODE
#if defined(#{name})#{name.start_with?('IPPROTO_') ? ' || defined(_WINSOCKAPI_)' : ''}
  define_const(#{name});
#endif
CODE
}