Sha256: 5ff23490285e3615a78e4805b2965c6f6733261ab4540a156ec7e331fdfd3175

Contents?: true

Size: 1.52 KB

Versions: 85

Compression:

Stored size: 1.52 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  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

85 entries across 85 versions & 1 rubygems

Version Path
rroonga-14.1.2 misc/grnop2ruby.rb
rroonga-12.1.0 misc/grnop2ruby.rb
rroonga-12.0.8 misc/grnop2ruby.rb
rroonga-12.0.2 misc/grnop2ruby.rb
rroonga-12.0.0 misc/grnop2ruby.rb
rroonga-11.0.6 misc/grnop2ruby.rb
rroonga-11.0.0 misc/grnop2ruby.rb
rroonga-10.0.6 misc/grnop2ruby.rb
rroonga-10.0.2 misc/grnop2ruby.rb
rroonga-10.0.1 misc/grnop2ruby.rb
rroonga-9.0.7-x64-mingw32 misc/grnop2ruby.rb
rroonga-9.0.7-x86-mingw32 misc/grnop2ruby.rb
rroonga-9.0.7 misc/grnop2ruby.rb
rroonga-9.0.3-x64-mingw32 misc/grnop2ruby.rb
rroonga-9.0.3-x86-mingw32 misc/grnop2ruby.rb
rroonga-9.0.3 misc/grnop2ruby.rb
rroonga-9.0.2-x64-mingw32 misc/grnop2ruby.rb
rroonga-9.0.2-x86-mingw32 misc/grnop2ruby.rb
rroonga-9.0.2 misc/grnop2ruby.rb
rroonga-7.1.1-x64-mingw32 misc/grnop2ruby.rb