Sha256: 97800d65fce8ea7853a874918116420d46a68d60eeadf0527b4a6237958cd184

Contents?: true

Size: 1.51 KB

Versions: 107

Compression:

Stored size: 1.51 KB

Contents

# -*- coding: utf-8 -*-
#
# Copyright (C) 2009  Yuto Hayamizu <y.hayamizu@gmail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#
# This script expects "groonga.h" as a first argument, extracts the
# 'grn_operator', and write 'rb_define_const's of 'grn_operator' to
# standard outout.
#
# Usage:
#   ruby grnop2ruby.rb /path/to/groonga.h
#

replace_dictionary = {
  "VAR" => "VARIABLE",
  "EXPR" => "EXPRESSION",
  "NOP" => "NO_OPERATION",
  "REF" => "REFERENCE",
  "OBJ" => "OBJECT",
  "INCR" => "INCREMENT",
  "DECR" => "DECREMENT",
  "MOD" => "MODULO",
  "LCP" => "LONGEST_COMMON_PREFIX",
}

ARGF.each_line do |line|
  case line
  when /\A\s+(GRN_OP_\w+)/
    operator = $1
    rb_operator = operator.gsub(/\AGRN_OP_/, "").split("_").map{ |word|
      replace_dictionary[word] || word
    }.join("_")
    puts "    rb_define_const(rb_mGrnOperation, \"%s\",
                    UINT2NUM(%s));" % [rb_operator, operator]
  end
end

Version data entries

107 entries across 107 versions & 2 rubygems

Version Path
rroonga-4.0.3-x86-mingw32 misc/grnop2ruby.rb
rroonga-4.0.3-x64-mingw32 misc/grnop2ruby.rb
rroonga-4.0.3 misc/grnop2ruby.rb
rroonga-4.0.2-x64-mingw32 misc/grnop2ruby.rb
rroonga-4.0.2-x86-mingw32 misc/grnop2ruby.rb
rroonga-4.0.2 misc/grnop2ruby.rb
rroonga-4.0.1-x86-mingw32 misc/grnop2ruby.rb
rroonga-4.0.1-x64-mingw32 misc/grnop2ruby.rb
rroonga-4.0.1 misc/grnop2ruby.rb
rroonga-4.0.0-x64-mingw32 misc/grnop2ruby.rb
rroonga-4.0.0-x86-mingw32 misc/grnop2ruby.rb
rroonga-4.0.0 misc/grnop2ruby.rb
rroonga-3.1.2-x64-mingw32 misc/grnop2ruby.rb
rroonga-3.1.2-x86-mingw32 misc/grnop2ruby.rb
rroonga-3.1.2 misc/grnop2ruby.rb
rroonga-3.1.1-x64-mingw32 misc/grnop2ruby.rb
rroonga-3.1.1-x86-mingw32 misc/grnop2ruby.rb
rroonga-3.1.1 misc/grnop2ruby.rb
rroonga-3.1.0-x64-mingw32 misc/grnop2ruby.rb
rroonga-3.1.0-x86-mingw32 misc/grnop2ruby.rb