Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more
BasicObject
# File socket/mkconstants.rb, line 31
def c_str(str)
'"' + str.gsub(C_ESC_PAT) {|s| C_ESC[s]} + '"'
end
# File socket/mkconstants.rb, line 238
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
# File socket/mkconstants.rb, line 195
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
# File socket/mkconstants.rb, line 57
def each_const
DEFS.each {|name, default_value|
if name =~ /\AINADDR_/
make_value = "UINT2NUM"
else
make_value = "INT2NUM"
end
guard = nil
if /\A(AF_INET6|PF_INET6|IPV6_.*)\z/ =~ name
# IPv6 is not supported although AF_INET6 is defined on bcc32/mingw
guard = "defined(INET6)"
end
yield guard, make_value, name, default_value
}
end
# File socket/mkconstants.rb, line 73
def each_name(pat)
DEFS.each {|name, default_value|
next if pat !~ name
yield name
}
end
# File socket/mkconstants.rb, line 122
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
# File socket/mkconstants.rb, line 115
def reverse_each_name(pat)
DEFS.reverse_each {|name, default_value|
next if pat !~ name
yield name
}
end
# File socket/mkconstants.rb, line 201
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
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.