From a181d44ee4b78d7e016cf5b9e8fd5591723615bd Mon Sep 17 00:00:00 2001 From: guy Decoux Date: Sat, 28 Feb 2009 20:08:24 +0100 Subject: mmap-0.1.8 --- docs/b.rb | 108 ++++++++++++++++++++ docs/mmap.rb | 320 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 428 insertions(+) create mode 100755 docs/b.rb create mode 100644 docs/mmap.rb (limited to 'docs') diff --git a/docs/b.rb b/docs/b.rb new file mode 100755 index 0000000..2b7adfb --- /dev/null +++ b/docs/b.rb @@ -0,0 +1,108 @@ +#!/usr/bin/ruby + +def yield_or_not(primary) + text = primary.sub(/\{\s*\|([^|]+)\|[^}]*\}/, '') + if text != primary + "def #{text}yield #$1\nend" + else + "def #{text}end" + end +end + +def normalize(text) + norm = text.gsub(/\(\(\|([^|]+)\|\)\)/, '\\1') + norm.gsub(/\(\(\{/, '').gsub!(/\}\)\)/, '') + norm.gsub!(/\(\(<([^|>]+)[^>]*>\)\)/, '\\1') + norm.gsub!(/^\s*:\s/, ' * ') + norm +end + +def intern_def(text, names, fout) + fout.puts "##{normalize(text.join('#'))}" + fout.puts yield_or_not(names[0]) + if names.size > 1 + n = names[0].chomp.sub(/\(.*/, '') + names[1 .. -1].each do |na| + nd = na.chomp.sub(/\(.*/, '') + if nd != n + fout.puts "#same than #{n}" + fout.puts yield_or_not(na) + end + end + end +end + +def output_def(text, names, keywords, fout) + if ! names.empty? + keywords.each do |k| + fout.puts k + intern_def(text, names, fout) + fout.puts "end" if k != "" + end + end +end + +def loop_file(file, fout) + text, keywords, names = [], [""], [] + comment = false + rep, indent, vide = '', -1, nil + IO.foreach(file) do |line| + if /^#\^/ =~ line + comment = ! comment + next + end + if comment + fout.puts "# #{normalize(line)}" + next + end + case line + when /^\s*$/ + vide = true + text.push line + when /^#\^/ + comment = ! comment + when /^##/ + line[0] = ?\s + fout.puts line + when /^#\s*(.+?)\s*$/ + keyword = $1 + output_def(text, names, keywords, fout) + text, names = [], [] + keywords = keyword.split(/\s*##\s*/) + if keywords.size == 1 + fout.puts keywords[0] + keywords = [""] + end + when /^#/ + when /^---/ + name = $' + if vide + output_def(text, names, keywords, fout) + text, names = [], [] + rep, indent, vide = '', -1, false + end + names.push name + else + vide = false + if line.sub!(/^(\s*): /, '* ') + indent += ($1 <=> rep) + rep = $1 + else + line.sub!(/^#{rep}/, '') + end + if indent >= 0 + line = (' ' * indent) + line + else + line.sub!(/\A\s*/, '') + end + text.push line + end + end +end + +File.open("#{ARGV[0]}.rb", "w") do |fout| + loop_file("../#{ARGV[0]}.rd", fout) + Dir['*.rd'].each do |file| + loop_file(file, fout) + end +end diff --git a/docs/mmap.rb b/docs/mmap.rb new file mode 100644 index 0000000..ba00571 --- /dev/null +++ b/docs/mmap.rb @@ -0,0 +1,320 @@ +# The Mmap class implement memory-mapped file objects +# +# === WARNING +# === The variables $' and $` are not available with gsub! and sub! +class Mmap +include Comparable +include Enumerable +class << self + +#disable paging of all pages mapped. flag can be +#Mmap::MCL_CURRENT or Mmap::MCL_FUTURE +# +def lockall(flag) +end + +#create a new Mmap object +# +#* file +# Pathname of the file, if nil is given an anonymous map +# is created Mmanp::MAP_ANON +# +#* mode +# Mode to open the file, it can be "r", "w", "rw", "a" +# +#* protection +# specify the nature of the mapping +# +# * Mmap::MAP_SHARED +# Creates a mapping that's shared with all other processes +# mapping the same areas of the file. +# The default value is Mmap::MAP_SHARED +# +# * Mmap::MAP_PRIVATE +# Creates a private copy-on-write mapping, so changes to the +# contents of the mmap object will be private to this process +# +#* options +# Hash. If one of the options length or offset +# is specified it will not possible to modify the size of +# the mapped file. +# +# * length +# Maps length bytes from the file +# +# * offset +# The mapping begin at offset +# +# * advice +# The type of the access (see #madvise) +# +# +def new(file, mode = "r", protection = Mmap::MAP_SHARED, options = {}) +end + +#reenable paging +# +def unlockall +end +end + +#add count bytes to the file (i.e. pre-extend the file) +# +def extend(count) +end + +#advice can have the value Mmap::MADV_NORMAL, +#Mmap::MADV_RANDOM, Mmap::MADV_SEQUENTIAL, +#Mmap::MADV_WILLNEED, Mmap::MADV_DONTNEED +# +def madvise(advice) +end + +#change the mode, value must be "r", "w" or "rw" +# +def mprotect(mode) +end + +#disable paging +# +def mlock +end + +#flush the file +# +def msync +end +#same than msync +def flush +end + +#reenable paging +# +def munlock +end + +#terminate the association +# +#=== Other methods with the same syntax than for the class String +# +# +def munmap +end + +# +def self == other +end + +# +def self > other +end + +# +def self >= other +end + +# +def self < other +end + +# +def self <= other +end + +# +def self === other +end + +# +def self << other +end + +# +def self =~ other +end + +# +def self[nth] +end + +# +def self[start..last] +end + +# +def self[start, length] +end + +# +def self[nth] = val +end + +# +def self[start..last] = val +end + +# +def self[start, len] = val +end + +# +def self <=> other +end + +# +def <<(other) +end + +# +def casecmp(other) >= 1.7.1 +end + +# +def concat(other) +end + +# +def capitalize! +end + +# +def chop! +end + +# +def chomp!([rs]) +end + +# +def count(o1 [, o2, ...]) +end + +# +def crypt(salt) +end + +# +def delete!(str) +end + +# +def downcase! +end + +# +def each_byte +yield char +end + +# +def each([rs]) +yield line +end + +# +def each_line([rs]) +yield line +end + +# +def empty? +end + +# +def freeze +end + +# +def frozen +end + +# +def gsub!(pattern, replace) +end + +# +def gsub!(pattern) +yield str +end + +# +def include?(other) +end + +# +def index(substr[, pos]) +end + +# +def insert(index, str) >= 1.7.1 +end + +# +def length +end + +# +def reverse! +end + +# +def rindex(substr[, pos]) +end + +# +def scan(pattern) +end + +# +def scan(pattern) +yield str +end + +# +def size +end + +# +def slice +end + +# +def slice! +end + +# +def split([sep[, limit]]) +end + +# +def squeeze!([str]) +end + +# +def strip! +end + +# +def sub!(pattern, replace) +end + +# +def sub!(pattern) +yield str +end + +# +def sum([bits]) +end + +# +def swapcase! +end + +# +def tr!(search, replace) +end + +# +def tr_s!(search, replace) +end -- cgit v1.2.3