类 Object
常量
- 注释
- C_ESC
- C_ESC_PAT
- DEFS
- INTERN_DEFS
- NAME_TO_INT_DEFS
公共实例方法
c_str(str) 点击切换源代码
# File socket/mkconstants.rb, line 32 def c_str(str) '"' + str.gsub(C_ESC_PAT) {|s| C_ESC[s]} + '"' end
def_intern(func_name, pat, prefix_optional=nil) 点击切换源代码
# File socket/mkconstants.rb, line 246 def def_intern(func_name, pat, prefix_optional=nil) prefix_pat = nil if prefix_optional if Regexp === prefix_optional prefix_pat = prefix_optional else prefix_pat = /\A#{Regexp.escape prefix_optional}/ end end hash_var = "#{func_name}_hash" vardef = "static st_table *#{hash_var};" gen_hash = gen_int_to_name_hash(hash_var, pat, prefix_pat) decl = gen_int_to_name_decl(func_name, hash_var) func = gen_int_to_name_func(func_name, hash_var) INTERN_DEFS << [vardef, gen_hash, decl, func] end
def_name_to_int(funcname, pat, prefix_optional, guard=nil) 点击切换源代码
# File socket/mkconstants.rb, line 203 def def_name_to_int(funcname, pat, prefix_optional, guard=nil) decl = gen_name_to_int_decl(funcname, pat, prefix_optional, guard) func = gen_name_to_int_func(funcname, pat, prefix_optional, guard) NAME_TO_INT_DEFS << [decl, func] end
each_const() { |guard, name, default_value| ... } 点击切换源代码
# File socket/mkconstants.rb, line 61 def each_const DEFS.each {|name, default_value| guard = nil if /\A(AF_INET6|PF_INET6|IPV6_.*)\z/ =~ name # IPv6 is not supported although AF_INET6 is defined on mingw guard = "defined(INET6)" end yield guard, name, default_value } end
each_name(pat) { |name| ... } 点击切换源代码
# File socket/mkconstants.rb, line 72 def each_name(pat) DEFS.each {|name, default_value| next if pat !~ name yield name } end
each_names_with_len(pat, prefix_optional=nil) { |h, len| ... } 点击切换源代码
# File socket/mkconstants.rb, line 129 def each_names_with_len(pat, prefix_optional=nil) h = {} DEFS.each {|name, default_value| next if pat !~ name (h[name.length] ||= []) << [name, name] } if prefix_optional if Regexp === prefix_optional prefix_pat = prefix_optional else prefix_pat = /\A#{Regexp.escape prefix_optional}/ end DEFS.each {|const, default_value| next if pat !~ const next if prefix_pat !~ const name = $' (h[name.length] ||= []) << [name, const] } end hh = {} h.each {|len, pairs| pairs.each {|name, const| raise "name crash: #{name}" if hh[name] hh[name] = true } } h.keys.sort.each {|len| yield h[len], len } end
reverse_each_name(pat) { |name| ... } 点击切换源代码
# File socket/mkconstants.rb, line 122 def reverse_each_name(pat) DEFS.reverse_each {|name, default_value| next if pat !~ name yield name } end
reverse_each_name_with_prefix_optional(pat, prefix_pat) { |n, n| ... } 点击切换源代码
# File socket/mkconstants.rb, line 209 def reverse_each_name_with_prefix_optional(pat, prefix_pat) reverse_each_name(pat) {|n| yield n, n } if prefix_pat reverse_each_name(pat) {|n| next if prefix_pat !~ n yield n, $' } end end