├── Gemfile ├── lib ├── gdal-ruby │ └── version.rb └── gdal.rb ├── Makefile ├── .travis.yml ├── .gitignore ├── spec └── gdal_spec.rb ├── CHANGELOG.md ├── ext └── gdal-ruby │ ├── gdalconst │ ├── extconf.rb │ └── gdalconst.c │ ├── ogr │ └── extconf.rb │ ├── osr │ └── extconf.rb │ ├── gdal │ └── extconf.rb │ ├── ruby-2.2-patch.rb │ └── LICENSE ├── Rakefile ├── gdal.gemspec ├── LICENSE └── README.md /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /lib/gdal-ruby/version.rb: -------------------------------------------------------------------------------- 1 | module Gdal 2 | module Ruby 3 | VERSION = "2.0.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/gdal.rb: -------------------------------------------------------------------------------- 1 | require 'gdal-ruby/version' 2 | require 'gdal-ruby/gdal' 3 | require 'gdal-ruby/ogr' 4 | require 'gdal-ruby/osr' 5 | require 'gdal-ruby/gdalconst' 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: build 2 | 3 | build: 4 | bundle exec rake 5 | 6 | test: 7 | rm -rf tmp && bundle exec rake 8 | 9 | clean: 10 | rm -rf tmp 11 | 12 | .PHONY: build clean test 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 1.9.2 4 | - 1.9.3 5 | - 2.1.5 6 | - 2.2.1 7 | before_install: 8 | - sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable -y 9 | - sudo apt-get update 10 | - sudo apt-get install libgdal-dev 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | *.so 5 | *.bundle 6 | .config 7 | .yardoc 8 | Gemfile.lock 9 | InstalledFiles 10 | _yardoc 11 | coverage 12 | doc/ 13 | lib/bundler/man 14 | pkg 15 | rdoc 16 | spec/reports 17 | test/tmp 18 | test/version_tmp 19 | tmp 20 | -------------------------------------------------------------------------------- /spec/gdal_spec.rb: -------------------------------------------------------------------------------- 1 | require 'gdal-ruby/ogr' 2 | 3 | describe "Gdal" do 4 | it "converts WKT to GeoJSON" do 5 | valid_wkt = 'POINT (30 10)' 6 | valid_json = '{ "type": "Point", "coordinates": [ 30.0, 10.0 ] }' 7 | 8 | Gdal::Ogr.create_geometry_from_wkt(valid_wkt).export_to_json.should eq(valid_json) 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v1.0.0 2 | * Regenerated bindings using GDAL 1.10.1 sources and SWIG 3.0.5 3 | * Patch for ruby 2.2.1 (Thanks @aleksejleonov and @johnjohndoe) (Issue #5) 4 | * Fix symbol conflicts when requiring both `gdal-ruby/gdal` and `gdal-ruby/ogr` with `get_driver_by_name` and other functions (Issue #2) 5 | * Since the symbol conflicts are now fixed, `gdal`, `ogr`, `osr` and `gdalconst` are now `require`'d be default (Issue #2) 6 | 7 | ## v0.0.7 8 | * Fix for building on ruby versions where `$CXXFLAGS` isn't defined 9 | -------------------------------------------------------------------------------- /ext/gdal-ruby/gdalconst/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | 3 | # see https://github.com/zhm/gdal-ruby/issues/5 4 | require_relative '../ruby-2.2-patch' 5 | 6 | raise 'gdal-config not found.' if `which gdal-config`.empty? 7 | 8 | dir_config 'gdal', 9 | `gdal-config --cflags`.split(' ')[0].gsub(/-I/, ''), 10 | `gdal-config --libs`.split(' ')[0].gsub(/-L/, '') 11 | 12 | have_library 'gdal' or raise 'libgdal not found' 13 | 14 | pkg_config 'gdal' 15 | 16 | $libs = append_library $libs, 'gdal' 17 | 18 | # earlier versions of ruby do not define $CXXFLAGS 19 | $CXXFLAGS = CONFIG["CXXFLAGS"] unless defined?($CXXFLAGS) 20 | 21 | $CFLAGS << ' -Wno-format-security' 22 | $CXXFLAGS << ' -Wno-format-security' 23 | 24 | create_makefile('gdal-ruby/gdalconst') 25 | -------------------------------------------------------------------------------- /ext/gdal-ruby/ogr/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | 3 | # see https://github.com/zhm/gdal-ruby/issues/5 4 | require_relative '../ruby-2.2-patch' 5 | 6 | raise 'gdal-config not found.' if `which gdal-config`.empty? 7 | 8 | dir_config 'gdal', 9 | `gdal-config --cflags`.split(' ')[0].gsub(/-I/, ''), 10 | `gdal-config --libs`.split(' ')[0].gsub(/-L/, '') 11 | 12 | have_library 'gdal' or raise 'libgdal not found' 13 | 14 | pkg_config 'gdal' 15 | 16 | $libs = append_library $libs, 'gdal' 17 | 18 | # earlier versions of ruby do not define $CXXFLAGS 19 | $CXXFLAGS = CONFIG["CXXFLAGS"] unless defined?($CXXFLAGS) 20 | 21 | $CFLAGS << ' -Wno-format-security' 22 | $CXXFLAGS << ' -Wno-format-security' 23 | 24 | if !(`gdal-config --version`.strip =~ /^1/) 25 | $CFLAGS << ' -Wno-reserved-user-defined-literal -std=c++11' 26 | $CXXFLAGS << ' -Wno-reserved-user-defined-literal -std=c++11' 27 | end 28 | 29 | create_makefile('gdal-ruby/ogr') 30 | -------------------------------------------------------------------------------- /ext/gdal-ruby/osr/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | 3 | # see https://github.com/zhm/gdal-ruby/issues/5 4 | require_relative '../ruby-2.2-patch' 5 | 6 | raise 'gdal-config not found.' if `which gdal-config`.empty? 7 | 8 | dir_config 'gdal', 9 | `gdal-config --cflags`.split(' ')[0].gsub(/-I/, ''), 10 | `gdal-config --libs`.split(' ')[0].gsub(/-L/, '') 11 | 12 | have_library 'gdal' or raise 'libgdal not found' 13 | 14 | pkg_config 'gdal' 15 | 16 | $libs = append_library $libs, 'gdal' 17 | 18 | # earlier versions of ruby do not define $CXXFLAGS 19 | $CXXFLAGS = CONFIG["CXXFLAGS"] unless defined?($CXXFLAGS) 20 | 21 | $CFLAGS << ' -Wno-format-security' 22 | $CXXFLAGS << ' -Wno-format-security' 23 | 24 | if !(`gdal-config --version`.strip =~ /^1/) 25 | $CFLAGS << ' -Wno-reserved-user-defined-literal -std=c++11' 26 | $CXXFLAGS << ' -Wno-reserved-user-defined-literal -std=c++11' 27 | end 28 | 29 | create_makefile('gdal-ruby/osr') 30 | -------------------------------------------------------------------------------- /ext/gdal-ruby/gdal/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | 3 | # see https://github.com/zhm/gdal-ruby/issues/5 4 | require_relative '../ruby-2.2-patch' 5 | 6 | raise 'gdal-config not found.' if `which gdal-config`.empty? 7 | 8 | dir_config 'gdal', 9 | `gdal-config --cflags`.split(' ')[0].gsub(/-I/, ''), 10 | `gdal-config --libs`.split(' ')[0].gsub(/-L/, '') 11 | 12 | have_library 'gdal' or raise 'libgdal not found' 13 | 14 | pkg_config 'gdal' 15 | 16 | $libs = append_library $libs, 'gdal' 17 | 18 | # earlier versions of ruby do not define $CXXFLAGS 19 | $CXXFLAGS = CONFIG["CXXFLAGS"] unless defined?($CXXFLAGS) 20 | 21 | $CFLAGS << ' -Wno-format-security' 22 | $CXXFLAGS << ' -Wno-format-security' 23 | 24 | if !(`gdal-config --version`.strip =~ /^1/) 25 | $CFLAGS << ' -Wno-reserved-user-defined-literal -std=c++11' 26 | $CXXFLAGS << ' -Wno-reserved-user-defined-literal -std=c++11' 27 | end 28 | 29 | create_makefile 'gdal-ruby/gdal' 30 | 31 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | require 'rubygems' 3 | require 'bundler' 4 | require 'bundler/gem_tasks' 5 | require 'rake/testtask' 6 | require 'rake' 7 | require 'rake/extensiontask' 8 | require 'rspec/core' 9 | require 'rspec/core/rake_task' 10 | 11 | Bundler.setup 12 | 13 | Rake::ExtensionTask.new('gdal-ruby/gdal') do |ext| 14 | ext.name = 'gdal' 15 | ext.lib_dir = "lib/gdal-ruby" 16 | end 17 | 18 | Rake::ExtensionTask.new('gdal-ruby/ogr') do |ext| 19 | ext.name = 'ogr' 20 | ext.lib_dir = "lib/gdal-ruby" 21 | end 22 | 23 | Rake::ExtensionTask.new('gdal-ruby/osr') do |ext| 24 | ext.name = 'osr' 25 | ext.lib_dir = "lib/gdal-ruby" 26 | end 27 | 28 | Rake::ExtensionTask.new('gdal-ruby/gdalconst') do |ext| 29 | ext.name = 'gdalconst' 30 | ext.lib_dir = "lib/gdal-ruby" 31 | end 32 | 33 | RSpec::Core::RakeTask.new(:spec) do |spec| 34 | Rake::Task['compile'].invoke 35 | spec.pattern = FileList['spec/**/*_spec.rb'] 36 | end 37 | 38 | task :default => :spec 39 | -------------------------------------------------------------------------------- /gdal.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | require File.expand_path('../lib/gdal-ruby/version', __FILE__) 3 | 4 | Gem::Specification.new do |gem| 5 | gem.authors = ["Zac McCormick"] 6 | gem.email = ["zac.mccormick@gmail.com"] 7 | gem.description = %q{GDAL/OGR bindings for ruby} 8 | gem.summary = %q{GDAL/OGR bindings for ruby. Currently contains native extensions for GDAL 1.9.1} 9 | gem.homepage = "https://github.com/zhm/gdal-ruby" 10 | 11 | gem.files = `git ls-files`.split($\) 12 | gem.extensions = ['ext/gdal-ruby/gdal/extconf.rb', 'ext/gdal-ruby/gdalconst/extconf.rb', 13 | 'ext/gdal-ruby/ogr/extconf.rb', 'ext/gdal-ruby/osr/extconf.rb'] 14 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 15 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 16 | gem.name = "gdal" 17 | gem.require_paths = ["lib"] 18 | gem.version = Gdal::Ruby::VERSION 19 | 20 | gem.add_development_dependency 'rake', ['>= 0'] 21 | gem.add_development_dependency 'rake-compiler', ['>= 0'] 22 | gem.add_development_dependency 'rspec', ['>= 0'] 23 | end 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Zac McCormick 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following 12 | disclaimer in the documentation and/or other materials provided 13 | with the distribution. 14 | * Neither the name of the author nor the names of other 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /ext/gdal-ruby/ruby-2.2-patch.rb: -------------------------------------------------------------------------------- 1 | # This is monkeypatch for Ruby 2.2.0+ 2 | # Method pkg_config is broken on Ubuntu 12.04, so I replace it to method from Ruby 2.1.5 3 | 4 | if RUBY_VERSION >= '2.2.0' 5 | 6 | module MakeMakefile 7 | def pkg_config(pkg, option=nil) 8 | if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig) 9 | # iff package specific config command is given 10 | elsif ($PKGCONFIG ||= 11 | (pkgconfig = with_config("pkg-config", ("pkg-config" unless CROSS_COMPILING))) && 12 | find_executable0(pkgconfig) && pkgconfig) and 13 | system("#{$PKGCONFIG} --exists #{pkg}") 14 | # default to pkg-config command 15 | pkgconfig = $PKGCONFIG 16 | get = proc {|opt| 17 | opt = IO.popen("#{$PKGCONFIG} --#{opt} #{pkg}", err:[:child, :out], &:read) 18 | opt.strip if $?.success? 19 | } 20 | elsif find_executable0(pkgconfig = "#{pkg}-config") 21 | # default to package specific config command, as a last resort. 22 | else 23 | pkgconfig = nil 24 | end 25 | if pkgconfig 26 | get ||= proc {|opt| 27 | opt = IO.popen("#{pkgconfig} --#{opt}", err:[:child, :out], &:read) 28 | opt.strip if $?.success? 29 | } 30 | end 31 | orig_ldflags = $LDFLAGS 32 | if get and option 33 | get[option] 34 | elsif get and try_ldflags(ldflags = get['libs']) 35 | if incflags = get['cflags-only-I'] 36 | $INCFLAGS << " " << incflags 37 | cflags = get['cflags-only-other'] 38 | else 39 | cflags = get['cflags'] 40 | end 41 | libs = get['libs-only-l'] || '' 42 | ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ") 43 | $CFLAGS += " " << cflags 44 | $CXXFLAGS += " " << cflags 45 | $LDFLAGS = [orig_ldflags, ldflags].join(' ') 46 | $libs += " " << libs 47 | Logging::message "package configuration for %s\n", pkg 48 | Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n", 49 | cflags, ldflags, libs 50 | [cflags, ldflags, libs] 51 | else 52 | Logging::message "package configuration for %s is not found\n", pkg 53 | nil 54 | end 55 | end 56 | end 57 | 58 | end 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gdal-ruby [![Build Status](https://secure.travis-ci.org/zhm/gdal-ruby.png)](http://travis-ci.org/zhm/gdal-ruby) 2 | 3 | Native bindings for GDAL/OGR for ruby. The GDAL repository contains ruby bindings 4 | in the `swig/ruby` directory, but they aren't compiled or installed with default 5 | installations of GDAL. In addition to not typically being installed, the GDAL build 6 | system places the files in a global ruby directory which can cause some problems since 7 | it's not the way other ruby libraries are typically installed. This gem simply turns 8 | the ruby bindings from the GDAL repo into a gem which can be easily managed like all 9 | of the other dependencies in your application. This simplifies the process of being 10 | able to switch between versions of ruby and use bundler to manage the extension. Also 11 | this gem enables you to install GDAL from the standard package managers that don't 12 | include the ruby bindings. 13 | 14 | ## Installation 15 | 16 | You will first need to install GDAL. There are several ways to install it, but the 17 | easiest way is using a package manager. 18 | 19 | OS X: 20 | 21 | brew install gdal 22 | 23 | Ubuntu: 24 | 25 | sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable 26 | sudo apt-get update 27 | sudo apt-get install libgdal-dev 28 | 29 | Add this line to your application's Gemfile: 30 | 31 | gem 'gdal' 32 | 33 | And then execute: 34 | 35 | $ bundle 36 | 37 | Or install it yourself as: 38 | 39 | $ gem install gdal 40 | 41 | Installing on Mac using The Framework way GDAL : 42 | 43 | - Download and install GDAL Complete dmg from [kyngchaos](http://www.kyngchaos.com/software/frameworks). 44 | 45 | - Export path ` export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH ` in your bash or zsh profile 46 | 47 | - Verify the installation ` gdal-config --version ` 48 | 49 | - Install the gem using: 50 | 51 | ` $ gem install gdal -- --with-gdal-lib=/Library/Frameworks/GDAL.framework/unix/lib --with-gdal-includes=/Library/Frameworks/GDAL.framework/Versions/Current/Headers/ ` 52 | 53 | 54 | ## Usage 55 | 56 | To test it out: 57 | 58 | $ ruby -e "require 'gdal-ruby/ogr'; puts Gdal::Ogr.create_geometry_from_wkt('POINT (30 10)').export_to_json" 59 | 60 | The best documentation for right now is the [autotest](http://trac.osgeo.org/gdal/browser/trunk/autotest/ruby/ogr) code in the GDAL source tree. You can see various 61 | patterns for accessing files and using the OGR API from the autotest sources. 62 | 63 | ## License 64 | 65 | This gem is BSD. The .c and .cpp files in the ext/gdal-ruby directory are from GDAL. For more info, 66 | See `ext/gdal-ruby/LICENSE` or visit [gdal.org](http://www.gdal.org/). 67 | -------------------------------------------------------------------------------- /ext/gdal-ruby/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | GDAL/OGR Licensing 3 | ================== 4 | 5 | This file attempts to include all licenses that apply within the GDAL/OGR 6 | source tree, in particular any that are supposed to be exposed to the end user 7 | for credit requirements for instance. The contents of this file can be 8 | displayed from GDAL commandline utilities using the --license commandline 9 | switch. 10 | 11 | 12 | GDAL/OGR General 13 | ---------------- 14 | 15 | In general GDAL/OGR is licensed under an MIT/X style license with the 16 | following terms: 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a 19 | copy of this software and associated documentation files (the "Software"), 20 | to deal in the Software without restriction, including without limitation 21 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 22 | and/or sell copies of the Software, and to permit persons to whom the 23 | Software is furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included 26 | in all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 29 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 31 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 33 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 34 | DEALINGS IN THE SOFTWARE. 35 | 36 | 37 | gdal/frmts/gtiff/tif_float.c 38 | ---------------------------- 39 | 40 | Copyright (c) 2002, Industrial Light & Magic, a division of Lucas 41 | Digital Ltd. LLC 42 | 43 | All rights reserved. 44 | 45 | Redistribution and use in source and binary forms, with or without 46 | modification, are permitted provided that the following conditions are 47 | met: 48 | * Redistributions of source code must retain the above copyright 49 | notice, this list of conditions and the following disclaimer. 50 | * Redistributions in binary form must reproduce the above 51 | copyright notice, this list of conditions and the following disclaimer 52 | in the documentation and/or other materials provided with the 53 | distribution. 54 | * Neither the name of Industrial Light & Magic nor the names of 55 | its contributors may be used to endorse or promote products derived 56 | from this software without specific prior written permission. 57 | 58 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 59 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 60 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 61 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 62 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 63 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 64 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 65 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 66 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 67 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 68 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 69 | 70 | 71 | gdal/frmts/hdf4/hdf-eos/* 72 | ------------------------ 73 | 74 | Copyright (C) 1996 Hughes and Applied Research Corporation 75 | 76 | Permission to use, modify, and distribute this software and its documentation 77 | for any purpose without fee is hereby granted, provided that the above 78 | copyright notice appear in all copies and that both that copyright notice and 79 | this permission notice appear in supporting documentation. 80 | 81 | 82 | gdal/frmts/pcraster/libcsf 83 | -------------------------- 84 | 85 | Copyright (c) 1997-2003, Utrecht University 86 | All rights reserved. 87 | 88 | Redistribution and use in source and binary forms, with or without 89 | modification, are permitted provided that the following conditions 90 | are met: 91 | 92 | * Redistributions of source code must retain the above copyright 93 | notice, this list of conditions and the following disclaimer. 94 | 95 | * Redistributions in binary form must reproduce the above 96 | copyright notice, this list of conditions and the following 97 | disclaimer in the documentation and/or other materials provided 98 | with the distribution. 99 | 100 | * Neither the name of Utrecht University nor the names of its contributors 101 | may be used to endorse or promote products derived from this software 102 | without specific prior written permission. 103 | 104 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 105 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 106 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 107 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 108 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 109 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 110 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 111 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 112 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 113 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 114 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 115 | 116 | gdal/frmts/grib/degrib/* 117 | ------------------------ 118 | 119 | The degrib and g2clib source code are modified versions of code produced 120 | by NOAA NWS and are in the public domain subject to the following 121 | restrictions: 122 | 123 | http://www.weather.gov/im/softa.htm 124 | 125 | DISCLAIMER The United States Government makes no warranty, expressed or 126 | implied, as to the usefulness of the software and documentation for any 127 | purpose. The U.S. Government, its instrumentalities, officers, employees, 128 | and agents assumes no responsibility (1) for the use of the software and 129 | documentation listed below, or (2) to provide technical support to users. 130 | 131 | http://www.weather.gov/disclaimer.php 132 | 133 | The information on government servers are in the public domain, unless 134 | specifically annotated otherwise, and may be used freely by the public so 135 | long as you do not 1) claim it is your own (e.g. by claiming copyright for 136 | NWS information -- see below), 2) use it in a manner that implies an 137 | endorsement or affiliation with NOAA/NWS, or 3) modify it in content and 138 | then present it as official government material. You also cannot present 139 | information of your own in a way that makes it appear to be official 140 | government information.. 141 | 142 | The user assumes the entire risk related to its use of this data. NWS is 143 | providing this data "as is," and NWS disclaims any and all warranties, 144 | whether express or implied, including (without limitation) any implied 145 | warranties of merchantability or fitness for a particular purpose. In no 146 | event will NWS be liable to you or to any third party for any direct, 147 | indirect, incidental, consequential, special or exemplary damages or lost 148 | profit resulting from any use or misuse of this data. 149 | 150 | As required by 17 U.S.C. 403, third parties producing copyrighted works 151 | consisting predominantly of the material appearing in NWS Web pages must 152 | provide notice with such work(s) identifying the NWS material incorporated 153 | and stating that such material is not subject to copyright protection. 154 | 155 | port/cpl_minizip* 156 | ----------------- 157 | 158 | This is version 2005-Feb-10 of the Info-ZIP copyright and license. 159 | The definitive version of this document should be available at 160 | ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely. 161 | 162 | 163 | Copyright (c) 1990-2005 Info-ZIP. All rights reserved. 164 | 165 | For the purposes of this copyright and license, "Info-ZIP" is defined as 166 | the following set of individuals: 167 | 168 | Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, 169 | Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth, 170 | Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, 171 | David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko, 172 | Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, 173 | Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda, 174 | Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren, 175 | Rich Wales, Mike White 176 | 177 | This software is provided "as is," without warranty of any kind, express 178 | or implied. In no event shall Info-ZIP or its contributors be held liable 179 | for any direct, indirect, incidental, special or consequential damages 180 | arising out of the use of or inability to use this software. 181 | 182 | Permission is granted to anyone to use this software for any purpose, 183 | including commercial applications, and to alter it and redistribute it 184 | freely, subject to the following restrictions: 185 | 186 | 1. Redistributions of source code must retain the above copyright notice, 187 | definition, disclaimer, and this list of conditions. 188 | 189 | 2. Redistributions in binary form (compiled executables) must reproduce 190 | the above copyright notice, definition, disclaimer, and this list of 191 | conditions in documentation and/or other materials provided with the 192 | distribution. The sole exception to this condition is redistribution 193 | of a standard UnZipSFX binary (including SFXWiz) as part of a 194 | self-extracting archive; that is permitted without inclusion of this 195 | license, as long as the normal SFX banner has not been removed from 196 | the binary or disabled. 197 | 198 | 3. Altered versions--including, but not limited to, ports to new operating 199 | systems, existing ports with new graphical interfaces, and dynamic, 200 | shared, or static library versions--must be plainly marked as such 201 | and must not be misrepresented as being the original source. Such 202 | altered versions also must not be misrepresented as being Info-ZIP 203 | releases--including, but not limited to, labeling of the altered 204 | versions with the names "Info-ZIP" (or any variation thereof, including, 205 | but not limited to, different capitalizations), "Pocket UnZip," "WiZ" 206 | or "MacZip" without the explicit permission of Info-ZIP. Such altered 207 | versions are further prohibited from misrepresentative use of the 208 | Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). 209 | 210 | 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," 211 | "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its 212 | own source and binary releases. 213 | 214 | 215 | gdal/ogr/ogrsf_frmts/dxf/intronurbs.cpp 216 | --------------------------------------- 217 | 218 | This code is derived from the code associated with the book "An Introduction 219 | to NURBS" by David F. Rogers. More information on the book and the code is 220 | available at: 221 | 222 | http://www.nar-associates.com/nurbs/ 223 | 224 | 225 | Copyright (c) 2009, David F. Rogers 226 | All rights reserved. 227 | 228 | Redistribution and use in source and binary forms, with or without 229 | modification, are permitted provided that the following conditions are met: 230 | 231 | * Redistributions of source code must retain the above copyright notice, 232 | this list of conditions and the following disclaimer. 233 | * Redistributions in binary form must reproduce the above copyright notice, 234 | this list of conditions and the following disclaimer in the documentation 235 | and/or other materials provided with the distribution. 236 | * Neither the name of the David F. Rogers nor the names of its contributors 237 | may be used to endorse or promote products derived from this software 238 | without specific prior written permission. 239 | 240 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 241 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 242 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 243 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 244 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 245 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 246 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 247 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 248 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 249 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 250 | POSSIBILITY OF SUCH DAMAGE. 251 | 252 | 253 | 254 | -------------------------------------------------------------------------------- /ext/gdal-ruby/gdalconst/gdalconst.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * This file was automatically generated by SWIG (http://www.swig.org). 3 | * Version 3.0.5 4 | * 5 | * This file is not intended to be easily readable and contains a number of 6 | * coding conventions designed to improve portability and efficiency. Do not make 7 | * changes to this file unless you know what you are doing--modify the SWIG 8 | * interface file instead. 9 | * ----------------------------------------------------------------------------- */ 10 | 11 | #include "cpl_port.h" 12 | 13 | #define SWIGRUBY 14 | 15 | /* ----------------------------------------------------------------------------- 16 | * This section contains generic SWIG labels for method/variable 17 | * declarations/attributes, and other compiler dependent labels. 18 | * ----------------------------------------------------------------------------- */ 19 | 20 | /* template workaround for compilers that cannot correctly implement the C++ standard */ 21 | #ifndef SWIGTEMPLATEDISAMBIGUATOR 22 | # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) 23 | # define SWIGTEMPLATEDISAMBIGUATOR template 24 | # elif defined(__HP_aCC) 25 | /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ 26 | /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ 27 | # define SWIGTEMPLATEDISAMBIGUATOR template 28 | # else 29 | # define SWIGTEMPLATEDISAMBIGUATOR 30 | # endif 31 | #endif 32 | 33 | /* inline attribute */ 34 | #ifndef SWIGINLINE 35 | # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) 36 | # define SWIGINLINE inline 37 | # else 38 | # define SWIGINLINE 39 | # endif 40 | #endif 41 | 42 | /* attribute recognised by some compilers to avoid 'unused' warnings */ 43 | #ifndef SWIGUNUSED 44 | # if defined(__GNUC__) 45 | # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 46 | # define SWIGUNUSED __attribute__ ((__unused__)) 47 | # else 48 | # define SWIGUNUSED 49 | # endif 50 | # elif defined(__ICC) 51 | # define SWIGUNUSED __attribute__ ((__unused__)) 52 | # else 53 | # define SWIGUNUSED 54 | # endif 55 | #endif 56 | 57 | #ifndef SWIG_MSC_UNSUPPRESS_4505 58 | # if defined(_MSC_VER) 59 | # pragma warning(disable : 4505) /* unreferenced local function has been removed */ 60 | # endif 61 | #endif 62 | 63 | #ifndef SWIGUNUSEDPARM 64 | # ifdef __cplusplus 65 | # define SWIGUNUSEDPARM(p) 66 | # else 67 | # define SWIGUNUSEDPARM(p) p SWIGUNUSED 68 | # endif 69 | #endif 70 | 71 | /* internal SWIG method */ 72 | #ifndef SWIGINTERN 73 | # define SWIGINTERN static SWIGUNUSED 74 | #endif 75 | 76 | /* internal inline SWIG method */ 77 | #ifndef SWIGINTERNINLINE 78 | # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE 79 | #endif 80 | 81 | /* exporting methods */ 82 | #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 83 | # ifndef GCC_HASCLASSVISIBILITY 84 | # define GCC_HASCLASSVISIBILITY 85 | # endif 86 | #endif 87 | 88 | #ifndef SWIGEXPORT 89 | # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 90 | # if defined(STATIC_LINKED) 91 | # define SWIGEXPORT 92 | # else 93 | # define SWIGEXPORT __declspec(dllexport) 94 | # endif 95 | # else 96 | # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) 97 | # define SWIGEXPORT __attribute__ ((visibility("default"))) 98 | # else 99 | # define SWIGEXPORT 100 | # endif 101 | # endif 102 | #endif 103 | 104 | /* calling conventions for Windows */ 105 | #ifndef SWIGSTDCALL 106 | # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 107 | # define SWIGSTDCALL __stdcall 108 | # else 109 | # define SWIGSTDCALL 110 | # endif 111 | #endif 112 | 113 | /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ 114 | #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) 115 | # define _CRT_SECURE_NO_DEPRECATE 116 | #endif 117 | 118 | /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ 119 | #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) 120 | # define _SCL_SECURE_NO_DEPRECATE 121 | #endif 122 | 123 | 124 | /* ----------------------------------------------------------------------------- 125 | * This section contains generic SWIG labels for method/variable 126 | * declarations/attributes, and other compiler dependent labels. 127 | * ----------------------------------------------------------------------------- */ 128 | 129 | /* template workaround for compilers that cannot correctly implement the C++ standard */ 130 | #ifndef SWIGTEMPLATEDISAMBIGUATOR 131 | # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) 132 | # define SWIGTEMPLATEDISAMBIGUATOR template 133 | # elif defined(__HP_aCC) 134 | /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ 135 | /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ 136 | # define SWIGTEMPLATEDISAMBIGUATOR template 137 | # else 138 | # define SWIGTEMPLATEDISAMBIGUATOR 139 | # endif 140 | #endif 141 | 142 | /* inline attribute */ 143 | #ifndef SWIGINLINE 144 | # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) 145 | # define SWIGINLINE inline 146 | # else 147 | # define SWIGINLINE 148 | # endif 149 | #endif 150 | 151 | /* attribute recognised by some compilers to avoid 'unused' warnings */ 152 | #ifndef SWIGUNUSED 153 | # if defined(__GNUC__) 154 | # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 155 | # define SWIGUNUSED __attribute__ ((__unused__)) 156 | # else 157 | # define SWIGUNUSED 158 | # endif 159 | # elif defined(__ICC) 160 | # define SWIGUNUSED __attribute__ ((__unused__)) 161 | # else 162 | # define SWIGUNUSED 163 | # endif 164 | #endif 165 | 166 | #ifndef SWIG_MSC_UNSUPPRESS_4505 167 | # if defined(_MSC_VER) 168 | # pragma warning(disable : 4505) /* unreferenced local function has been removed */ 169 | # endif 170 | #endif 171 | 172 | #ifndef SWIGUNUSEDPARM 173 | # ifdef __cplusplus 174 | # define SWIGUNUSEDPARM(p) 175 | # else 176 | # define SWIGUNUSEDPARM(p) p SWIGUNUSED 177 | # endif 178 | #endif 179 | 180 | /* internal SWIG method */ 181 | #ifndef SWIGINTERN 182 | # define SWIGINTERN static SWIGUNUSED 183 | #endif 184 | 185 | /* internal inline SWIG method */ 186 | #ifndef SWIGINTERNINLINE 187 | # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE 188 | #endif 189 | 190 | /* exporting methods */ 191 | #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 192 | # ifndef GCC_HASCLASSVISIBILITY 193 | # define GCC_HASCLASSVISIBILITY 194 | # endif 195 | #endif 196 | 197 | #ifndef SWIGEXPORT 198 | # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 199 | # if defined(STATIC_LINKED) 200 | # define SWIGEXPORT 201 | # else 202 | # define SWIGEXPORT __declspec(dllexport) 203 | # endif 204 | # else 205 | # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) 206 | # define SWIGEXPORT __attribute__ ((visibility("default"))) 207 | # else 208 | # define SWIGEXPORT 209 | # endif 210 | # endif 211 | #endif 212 | 213 | /* calling conventions for Windows */ 214 | #ifndef SWIGSTDCALL 215 | # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 216 | # define SWIGSTDCALL __stdcall 217 | # else 218 | # define SWIGSTDCALL 219 | # endif 220 | #endif 221 | 222 | /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ 223 | #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) 224 | # define _CRT_SECURE_NO_DEPRECATE 225 | #endif 226 | 227 | /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ 228 | #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) 229 | # define _SCL_SECURE_NO_DEPRECATE 230 | #endif 231 | 232 | 233 | /* ----------------------------------------------------------------------------- 234 | * swigrun.swg 235 | * 236 | * This file contains generic C API SWIG runtime support for pointer 237 | * type checking. 238 | * ----------------------------------------------------------------------------- */ 239 | 240 | /* This should only be incremented when either the layout of swig_type_info changes, 241 | or for whatever reason, the runtime changes incompatibly */ 242 | #define SWIG_RUNTIME_VERSION "4" 243 | 244 | /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ 245 | #ifdef SWIG_TYPE_TABLE 246 | # define SWIG_QUOTE_STRING(x) #x 247 | # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) 248 | # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) 249 | #else 250 | # define SWIG_TYPE_TABLE_NAME 251 | #endif 252 | 253 | /* 254 | You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for 255 | creating a static or dynamic library from the SWIG runtime code. 256 | In 99.9% of the cases, SWIG just needs to declare them as 'static'. 257 | 258 | But only do this if strictly necessary, ie, if you have problems 259 | with your compiler or suchlike. 260 | */ 261 | 262 | #ifndef SWIGRUNTIME 263 | # define SWIGRUNTIME SWIGINTERN 264 | #endif 265 | 266 | #ifndef SWIGRUNTIMEINLINE 267 | # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE 268 | #endif 269 | 270 | /* Generic buffer size */ 271 | #ifndef SWIG_BUFFER_SIZE 272 | # define SWIG_BUFFER_SIZE 1024 273 | #endif 274 | 275 | /* Flags for pointer conversions */ 276 | #define SWIG_POINTER_DISOWN 0x1 277 | #define SWIG_CAST_NEW_MEMORY 0x2 278 | 279 | /* Flags for new pointer objects */ 280 | #define SWIG_POINTER_OWN 0x1 281 | 282 | 283 | /* 284 | Flags/methods for returning states. 285 | 286 | The SWIG conversion methods, as ConvertPtr, return an integer 287 | that tells if the conversion was successful or not. And if not, 288 | an error code can be returned (see swigerrors.swg for the codes). 289 | 290 | Use the following macros/flags to set or process the returning 291 | states. 292 | 293 | In old versions of SWIG, code such as the following was usually written: 294 | 295 | if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { 296 | // success code 297 | } else { 298 | //fail code 299 | } 300 | 301 | Now you can be more explicit: 302 | 303 | int res = SWIG_ConvertPtr(obj,vptr,ty.flags); 304 | if (SWIG_IsOK(res)) { 305 | // success code 306 | } else { 307 | // fail code 308 | } 309 | 310 | which is the same really, but now you can also do 311 | 312 | Type *ptr; 313 | int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); 314 | if (SWIG_IsOK(res)) { 315 | // success code 316 | if (SWIG_IsNewObj(res) { 317 | ... 318 | delete *ptr; 319 | } else { 320 | ... 321 | } 322 | } else { 323 | // fail code 324 | } 325 | 326 | I.e., now SWIG_ConvertPtr can return new objects and you can 327 | identify the case and take care of the deallocation. Of course that 328 | also requires SWIG_ConvertPtr to return new result values, such as 329 | 330 | int SWIG_ConvertPtr(obj, ptr,...) { 331 | if () { 332 | if () { 333 | *ptr = ; 334 | return SWIG_NEWOBJ; 335 | } else { 336 | *ptr = ; 337 | return SWIG_OLDOBJ; 338 | } 339 | } else { 340 | return SWIG_BADOBJ; 341 | } 342 | } 343 | 344 | Of course, returning the plain '0(success)/-1(fail)' still works, but you can be 345 | more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the 346 | SWIG errors code. 347 | 348 | Finally, if the SWIG_CASTRANK_MODE is enabled, the result code 349 | allows to return the 'cast rank', for example, if you have this 350 | 351 | int food(double) 352 | int fooi(int); 353 | 354 | and you call 355 | 356 | food(1) // cast rank '1' (1 -> 1.0) 357 | fooi(1) // cast rank '0' 358 | 359 | just use the SWIG_AddCast()/SWIG_CheckState() 360 | */ 361 | 362 | #define SWIG_OK (0) 363 | #define SWIG_ERROR (-1) 364 | #define SWIG_IsOK(r) (r >= 0) 365 | #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) 366 | 367 | /* The CastRankLimit says how many bits are used for the cast rank */ 368 | #define SWIG_CASTRANKLIMIT (1 << 8) 369 | /* The NewMask denotes the object was created (using new/malloc) */ 370 | #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) 371 | /* The TmpMask is for in/out typemaps that use temporal objects */ 372 | #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) 373 | /* Simple returning values */ 374 | #define SWIG_BADOBJ (SWIG_ERROR) 375 | #define SWIG_OLDOBJ (SWIG_OK) 376 | #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) 377 | #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) 378 | /* Check, add and del mask methods */ 379 | #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) 380 | #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) 381 | #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) 382 | #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) 383 | #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) 384 | #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) 385 | 386 | /* Cast-Rank Mode */ 387 | #if defined(SWIG_CASTRANK_MODE) 388 | # ifndef SWIG_TypeRank 389 | # define SWIG_TypeRank unsigned long 390 | # endif 391 | # ifndef SWIG_MAXCASTRANK /* Default cast allowed */ 392 | # define SWIG_MAXCASTRANK (2) 393 | # endif 394 | # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) 395 | # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) 396 | SWIGINTERNINLINE int SWIG_AddCast(int r) { 397 | return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; 398 | } 399 | SWIGINTERNINLINE int SWIG_CheckState(int r) { 400 | return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 401 | } 402 | #else /* no cast-rank mode */ 403 | # define SWIG_AddCast(r) (r) 404 | # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) 405 | #endif 406 | 407 | 408 | #include 409 | 410 | #ifdef __cplusplus 411 | extern "C" { 412 | #endif 413 | 414 | typedef void *(*swig_converter_func)(void *, int *); 415 | typedef struct swig_type_info *(*swig_dycast_func)(void **); 416 | 417 | /* Structure to store information on one type */ 418 | typedef struct swig_type_info { 419 | const char *name; /* mangled name of this type */ 420 | const char *str; /* human readable name of this type */ 421 | swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ 422 | struct swig_cast_info *cast; /* linked list of types that can cast into this type */ 423 | void *clientdata; /* language specific type data */ 424 | int owndata; /* flag if the structure owns the clientdata */ 425 | } swig_type_info; 426 | 427 | /* Structure to store a type and conversion function used for casting */ 428 | typedef struct swig_cast_info { 429 | swig_type_info *type; /* pointer to type that is equivalent to this type */ 430 | swig_converter_func converter; /* function to cast the void pointers */ 431 | struct swig_cast_info *next; /* pointer to next cast in linked list */ 432 | struct swig_cast_info *prev; /* pointer to the previous cast */ 433 | } swig_cast_info; 434 | 435 | /* Structure used to store module information 436 | * Each module generates one structure like this, and the runtime collects 437 | * all of these structures and stores them in a circularly linked list.*/ 438 | typedef struct swig_module_info { 439 | swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ 440 | size_t size; /* Number of types in this module */ 441 | struct swig_module_info *next; /* Pointer to next element in circularly linked list */ 442 | swig_type_info **type_initial; /* Array of initially generated type structures */ 443 | swig_cast_info **cast_initial; /* Array of initially generated casting structures */ 444 | void *clientdata; /* Language specific module data */ 445 | } swig_module_info; 446 | 447 | /* 448 | Compare two type names skipping the space characters, therefore 449 | "char*" == "char *" and "Class" == "Class", etc. 450 | 451 | Return 0 when the two name types are equivalent, as in 452 | strncmp, but skipping ' '. 453 | */ 454 | SWIGRUNTIME int 455 | SWIG_TypeNameComp(const char *f1, const char *l1, 456 | const char *f2, const char *l2) { 457 | for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { 458 | while ((*f1 == ' ') && (f1 != l1)) ++f1; 459 | while ((*f2 == ' ') && (f2 != l2)) ++f2; 460 | if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; 461 | } 462 | return (int)((l1 - f1) - (l2 - f2)); 463 | } 464 | 465 | /* 466 | Check type equivalence in a name list like ||... 467 | Return 0 if equal, -1 if nb < tb, 1 if nb > tb 468 | */ 469 | SWIGRUNTIME int 470 | SWIG_TypeCmp(const char *nb, const char *tb) { 471 | int equiv = 1; 472 | const char* te = tb + strlen(tb); 473 | const char* ne = nb; 474 | while (equiv != 0 && *ne) { 475 | for (nb = ne; *ne; ++ne) { 476 | if (*ne == '|') break; 477 | } 478 | equiv = SWIG_TypeNameComp(nb, ne, tb, te); 479 | if (*ne) ++ne; 480 | } 481 | return equiv; 482 | } 483 | 484 | /* 485 | Check type equivalence in a name list like ||... 486 | Return 0 if not equal, 1 if equal 487 | */ 488 | SWIGRUNTIME int 489 | SWIG_TypeEquiv(const char *nb, const char *tb) { 490 | return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; 491 | } 492 | 493 | /* 494 | Check the typename 495 | */ 496 | SWIGRUNTIME swig_cast_info * 497 | SWIG_TypeCheck(const char *c, swig_type_info *ty) { 498 | if (ty) { 499 | swig_cast_info *iter = ty->cast; 500 | while (iter) { 501 | if (strcmp(iter->type->name, c) == 0) { 502 | if (iter == ty->cast) 503 | return iter; 504 | /* Move iter to the top of the linked list */ 505 | iter->prev->next = iter->next; 506 | if (iter->next) 507 | iter->next->prev = iter->prev; 508 | iter->next = ty->cast; 509 | iter->prev = 0; 510 | if (ty->cast) ty->cast->prev = iter; 511 | ty->cast = iter; 512 | return iter; 513 | } 514 | iter = iter->next; 515 | } 516 | } 517 | return 0; 518 | } 519 | 520 | /* 521 | Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison 522 | */ 523 | SWIGRUNTIME swig_cast_info * 524 | SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { 525 | if (ty) { 526 | swig_cast_info *iter = ty->cast; 527 | while (iter) { 528 | if (iter->type == from) { 529 | if (iter == ty->cast) 530 | return iter; 531 | /* Move iter to the top of the linked list */ 532 | iter->prev->next = iter->next; 533 | if (iter->next) 534 | iter->next->prev = iter->prev; 535 | iter->next = ty->cast; 536 | iter->prev = 0; 537 | if (ty->cast) ty->cast->prev = iter; 538 | ty->cast = iter; 539 | return iter; 540 | } 541 | iter = iter->next; 542 | } 543 | } 544 | return 0; 545 | } 546 | 547 | /* 548 | Cast a pointer up an inheritance hierarchy 549 | */ 550 | SWIGRUNTIMEINLINE void * 551 | SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { 552 | return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); 553 | } 554 | 555 | /* 556 | Dynamic pointer casting. Down an inheritance hierarchy 557 | */ 558 | SWIGRUNTIME swig_type_info * 559 | SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { 560 | swig_type_info *lastty = ty; 561 | if (!ty || !ty->dcast) return ty; 562 | while (ty && (ty->dcast)) { 563 | ty = (*ty->dcast)(ptr); 564 | if (ty) lastty = ty; 565 | } 566 | return lastty; 567 | } 568 | 569 | /* 570 | Return the name associated with this type 571 | */ 572 | SWIGRUNTIMEINLINE const char * 573 | SWIG_TypeName(const swig_type_info *ty) { 574 | return ty->name; 575 | } 576 | 577 | /* 578 | Return the pretty name associated with this type, 579 | that is an unmangled type name in a form presentable to the user. 580 | */ 581 | SWIGRUNTIME const char * 582 | SWIG_TypePrettyName(const swig_type_info *type) { 583 | /* The "str" field contains the equivalent pretty names of the 584 | type, separated by vertical-bar characters. We choose 585 | to print the last name, as it is often (?) the most 586 | specific. */ 587 | if (!type) return NULL; 588 | if (type->str != NULL) { 589 | const char *last_name = type->str; 590 | const char *s; 591 | for (s = type->str; *s; s++) 592 | if (*s == '|') last_name = s+1; 593 | return last_name; 594 | } 595 | else 596 | return type->name; 597 | } 598 | 599 | /* 600 | Set the clientdata field for a type 601 | */ 602 | SWIGRUNTIME void 603 | SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { 604 | swig_cast_info *cast = ti->cast; 605 | /* if (ti->clientdata == clientdata) return; */ 606 | ti->clientdata = clientdata; 607 | 608 | while (cast) { 609 | if (!cast->converter) { 610 | swig_type_info *tc = cast->type; 611 | if (!tc->clientdata) { 612 | SWIG_TypeClientData(tc, clientdata); 613 | } 614 | } 615 | cast = cast->next; 616 | } 617 | } 618 | SWIGRUNTIME void 619 | SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { 620 | SWIG_TypeClientData(ti, clientdata); 621 | ti->owndata = 1; 622 | } 623 | 624 | /* 625 | Search for a swig_type_info structure only by mangled name 626 | Search is a O(log #types) 627 | 628 | We start searching at module start, and finish searching when start == end. 629 | Note: if start == end at the beginning of the function, we go all the way around 630 | the circular list. 631 | */ 632 | SWIGRUNTIME swig_type_info * 633 | SWIG_MangledTypeQueryModule(swig_module_info *start, 634 | swig_module_info *end, 635 | const char *name) { 636 | swig_module_info *iter = start; 637 | do { 638 | if (iter->size) { 639 | size_t l = 0; 640 | size_t r = iter->size - 1; 641 | do { 642 | /* since l+r >= 0, we can (>> 1) instead (/ 2) */ 643 | size_t i = (l + r) >> 1; 644 | const char *iname = iter->types[i]->name; 645 | if (iname) { 646 | int compare = strcmp(name, iname); 647 | if (compare == 0) { 648 | return iter->types[i]; 649 | } else if (compare < 0) { 650 | if (i) { 651 | r = i - 1; 652 | } else { 653 | break; 654 | } 655 | } else if (compare > 0) { 656 | l = i + 1; 657 | } 658 | } else { 659 | break; /* should never happen */ 660 | } 661 | } while (l <= r); 662 | } 663 | iter = iter->next; 664 | } while (iter != end); 665 | return 0; 666 | } 667 | 668 | /* 669 | Search for a swig_type_info structure for either a mangled name or a human readable name. 670 | It first searches the mangled names of the types, which is a O(log #types) 671 | If a type is not found it then searches the human readable names, which is O(#types). 672 | 673 | We start searching at module start, and finish searching when start == end. 674 | Note: if start == end at the beginning of the function, we go all the way around 675 | the circular list. 676 | */ 677 | SWIGRUNTIME swig_type_info * 678 | SWIG_TypeQueryModule(swig_module_info *start, 679 | swig_module_info *end, 680 | const char *name) { 681 | /* STEP 1: Search the name field using binary search */ 682 | swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); 683 | if (ret) { 684 | return ret; 685 | } else { 686 | /* STEP 2: If the type hasn't been found, do a complete search 687 | of the str field (the human readable name) */ 688 | swig_module_info *iter = start; 689 | do { 690 | size_t i = 0; 691 | for (; i < iter->size; ++i) { 692 | if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) 693 | return iter->types[i]; 694 | } 695 | iter = iter->next; 696 | } while (iter != end); 697 | } 698 | 699 | /* neither found a match */ 700 | return 0; 701 | } 702 | 703 | /* 704 | Pack binary data into a string 705 | */ 706 | SWIGRUNTIME char * 707 | SWIG_PackData(char *c, void *ptr, size_t sz) { 708 | static const char hex[17] = "0123456789abcdef"; 709 | const unsigned char *u = (unsigned char *) ptr; 710 | const unsigned char *eu = u + sz; 711 | for (; u != eu; ++u) { 712 | unsigned char uu = *u; 713 | *(c++) = hex[(uu & 0xf0) >> 4]; 714 | *(c++) = hex[uu & 0xf]; 715 | } 716 | return c; 717 | } 718 | 719 | /* 720 | Unpack binary data from a string 721 | */ 722 | SWIGRUNTIME const char * 723 | SWIG_UnpackData(const char *c, void *ptr, size_t sz) { 724 | unsigned char *u = (unsigned char *) ptr; 725 | const unsigned char *eu = u + sz; 726 | for (; u != eu; ++u) { 727 | char d = *(c++); 728 | unsigned char uu; 729 | if ((d >= '0') && (d <= '9')) 730 | uu = ((d - '0') << 4); 731 | else if ((d >= 'a') && (d <= 'f')) 732 | uu = ((d - ('a'-10)) << 4); 733 | else 734 | return (char *) 0; 735 | d = *(c++); 736 | if ((d >= '0') && (d <= '9')) 737 | uu |= (d - '0'); 738 | else if ((d >= 'a') && (d <= 'f')) 739 | uu |= (d - ('a'-10)); 740 | else 741 | return (char *) 0; 742 | *u = uu; 743 | } 744 | return c; 745 | } 746 | 747 | /* 748 | Pack 'void *' into a string buffer. 749 | */ 750 | SWIGRUNTIME char * 751 | SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { 752 | char *r = buff; 753 | if ((2*sizeof(void *) + 2) > bsz) return 0; 754 | *(r++) = '_'; 755 | r = SWIG_PackData(r,&ptr,sizeof(void *)); 756 | if (strlen(name) + 1 > (bsz - (r - buff))) return 0; 757 | strcpy(r,name); 758 | return buff; 759 | } 760 | 761 | SWIGRUNTIME const char * 762 | SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { 763 | if (*c != '_') { 764 | if (strcmp(c,"NULL") == 0) { 765 | *ptr = (void *) 0; 766 | return name; 767 | } else { 768 | return 0; 769 | } 770 | } 771 | return SWIG_UnpackData(++c,ptr,sizeof(void *)); 772 | } 773 | 774 | SWIGRUNTIME char * 775 | SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { 776 | char *r = buff; 777 | size_t lname = (name ? strlen(name) : 0); 778 | if ((2*sz + 2 + lname) > bsz) return 0; 779 | *(r++) = '_'; 780 | r = SWIG_PackData(r,ptr,sz); 781 | if (lname) { 782 | strncpy(r,name,lname+1); 783 | } else { 784 | *r = 0; 785 | } 786 | return buff; 787 | } 788 | 789 | SWIGRUNTIME const char * 790 | SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { 791 | if (*c != '_') { 792 | if (strcmp(c,"NULL") == 0) { 793 | memset(ptr,0,sz); 794 | return name; 795 | } else { 796 | return 0; 797 | } 798 | } 799 | return SWIG_UnpackData(++c,ptr,sz); 800 | } 801 | 802 | #ifdef __cplusplus 803 | } 804 | #endif 805 | 806 | /* Errors in SWIG */ 807 | #define SWIG_UnknownError -1 808 | #define SWIG_IOError -2 809 | #define SWIG_RuntimeError -3 810 | #define SWIG_IndexError -4 811 | #define SWIG_TypeError -5 812 | #define SWIG_DivisionByZero -6 813 | #define SWIG_OverflowError -7 814 | #define SWIG_SyntaxError -8 815 | #define SWIG_ValueError -9 816 | #define SWIG_SystemError -10 817 | #define SWIG_AttributeError -11 818 | #define SWIG_MemoryError -12 819 | #define SWIG_NullReferenceError -13 820 | 821 | 822 | 823 | #include 824 | 825 | /* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which 826 | * breaks using rb_intern as an lvalue, as SWIG does. We work around this 827 | * issue for now by disabling this. 828 | * https://sourceforge.net/tracker/?func=detail&aid=2859614&group_id=1645&atid=101645 829 | */ 830 | #ifdef rb_intern 831 | # undef rb_intern 832 | #endif 833 | 834 | /* Remove global macros defined in Ruby's win32.h */ 835 | #ifdef write 836 | # undef write 837 | #endif 838 | #ifdef read 839 | # undef read 840 | #endif 841 | #ifdef bind 842 | # undef bind 843 | #endif 844 | #ifdef close 845 | # undef close 846 | #endif 847 | #ifdef connect 848 | # undef connect 849 | #endif 850 | 851 | 852 | /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ 853 | #ifndef NUM2LL 854 | #define NUM2LL(x) NUM2LONG((x)) 855 | #endif 856 | #ifndef LL2NUM 857 | #define LL2NUM(x) INT2NUM((long) (x)) 858 | #endif 859 | #ifndef ULL2NUM 860 | #define ULL2NUM(x) UINT2NUM((unsigned long) (x)) 861 | #endif 862 | 863 | /* Ruby 1.7 doesn't (yet) define NUM2ULL() */ 864 | #ifndef NUM2ULL 865 | #ifdef HAVE_LONG_LONG 866 | #define NUM2ULL(x) rb_num2ull((x)) 867 | #else 868 | #define NUM2ULL(x) NUM2ULONG(x) 869 | #endif 870 | #endif 871 | 872 | /* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */ 873 | /* Define these for older versions so we can just write code the new way */ 874 | #ifndef RSTRING_LEN 875 | # define RSTRING_LEN(x) RSTRING(x)->len 876 | #endif 877 | #ifndef RSTRING_PTR 878 | # define RSTRING_PTR(x) RSTRING(x)->ptr 879 | #endif 880 | #ifndef RSTRING_END 881 | # define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x)) 882 | #endif 883 | #ifndef RARRAY_LEN 884 | # define RARRAY_LEN(x) RARRAY(x)->len 885 | #endif 886 | #ifndef RARRAY_PTR 887 | # define RARRAY_PTR(x) RARRAY(x)->ptr 888 | #endif 889 | #ifndef RFLOAT_VALUE 890 | # define RFLOAT_VALUE(x) RFLOAT(x)->value 891 | #endif 892 | #ifndef DOUBLE2NUM 893 | # define DOUBLE2NUM(x) rb_float_new(x) 894 | #endif 895 | #ifndef RHASH_TBL 896 | # define RHASH_TBL(x) (RHASH(x)->tbl) 897 | #endif 898 | #ifndef RHASH_ITER_LEV 899 | # define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev) 900 | #endif 901 | #ifndef RHASH_IFNONE 902 | # define RHASH_IFNONE(x) (RHASH(x)->ifnone) 903 | #endif 904 | #ifndef RHASH_SIZE 905 | # define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries) 906 | #endif 907 | #ifndef RHASH_EMPTY_P 908 | # define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0) 909 | #endif 910 | #ifndef RSTRUCT_LEN 911 | # define RSTRUCT_LEN(x) RSTRUCT(x)->len 912 | #endif 913 | #ifndef RSTRUCT_PTR 914 | # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr 915 | #endif 916 | 917 | 918 | 919 | /* 920 | * Need to be very careful about how these macros are defined, especially 921 | * when compiling C++ code or C code with an ANSI C compiler. 922 | * 923 | * VALUEFUNC(f) is a macro used to typecast a C function that implements 924 | * a Ruby method so that it can be passed as an argument to API functions 925 | * like rb_define_method() and rb_define_singleton_method(). 926 | * 927 | * VOIDFUNC(f) is a macro used to typecast a C function that implements 928 | * either the "mark" or "free" stuff for a Ruby Data object, so that it 929 | * can be passed as an argument to API functions like Data_Wrap_Struct() 930 | * and Data_Make_Struct(). 931 | */ 932 | 933 | #ifdef __cplusplus 934 | # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ 935 | # define PROTECTFUNC(f) ((VALUE (*)()) f) 936 | # define VALUEFUNC(f) ((VALUE (*)()) f) 937 | # define VOIDFUNC(f) ((void (*)()) f) 938 | # else 939 | # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ 940 | # define PROTECTFUNC(f) ((VALUE (*)()) f) 941 | # define VALUEFUNC(f) ((VALUE (*)()) f) 942 | # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) 943 | # else /* These definitions should work for Ruby 1.7+ */ 944 | # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) 945 | # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) 946 | # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) 947 | # endif 948 | # endif 949 | #else 950 | # define VALUEFUNC(f) (f) 951 | # define VOIDFUNC(f) (f) 952 | #endif 953 | 954 | /* Don't use for expressions have side effect */ 955 | #ifndef RB_STRING_VALUE 956 | #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s))) 957 | #endif 958 | #ifndef StringValue 959 | #define StringValue(s) RB_STRING_VALUE(s) 960 | #endif 961 | #ifndef StringValuePtr 962 | #define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s)) 963 | #endif 964 | #ifndef StringValueLen 965 | #define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s)) 966 | #endif 967 | #ifndef SafeStringValue 968 | #define SafeStringValue(v) do {\ 969 | StringValue(v);\ 970 | rb_check_safe_str(v);\ 971 | } while (0) 972 | #endif 973 | 974 | #ifndef HAVE_RB_DEFINE_ALLOC_FUNC 975 | #define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) 976 | #define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") 977 | #endif 978 | 979 | static VALUE _mSWIG = Qnil; 980 | 981 | /* ----------------------------------------------------------------------------- 982 | * error manipulation 983 | * ----------------------------------------------------------------------------- */ 984 | 985 | 986 | /* Define some additional error types */ 987 | #define SWIG_ObjectPreviouslyDeletedError -100 988 | 989 | 990 | /* Define custom exceptions for errors that do not map to existing Ruby 991 | exceptions. Note this only works for C++ since a global cannot be 992 | initialized by a function in C. For C, fallback to rb_eRuntimeError.*/ 993 | 994 | SWIGINTERN VALUE 995 | getNullReferenceError(void) { 996 | static int init = 0; 997 | static VALUE rb_eNullReferenceError ; 998 | if (!init) { 999 | init = 1; 1000 | rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError); 1001 | } 1002 | return rb_eNullReferenceError; 1003 | } 1004 | 1005 | SWIGINTERN VALUE 1006 | getObjectPreviouslyDeletedError(void) { 1007 | static int init = 0; 1008 | static VALUE rb_eObjectPreviouslyDeleted ; 1009 | if (!init) { 1010 | init = 1; 1011 | rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError); 1012 | } 1013 | return rb_eObjectPreviouslyDeleted; 1014 | } 1015 | 1016 | 1017 | SWIGINTERN VALUE 1018 | SWIG_Ruby_ErrorType(int SWIG_code) { 1019 | VALUE type; 1020 | switch (SWIG_code) { 1021 | case SWIG_MemoryError: 1022 | type = rb_eNoMemError; 1023 | break; 1024 | case SWIG_IOError: 1025 | type = rb_eIOError; 1026 | break; 1027 | case SWIG_RuntimeError: 1028 | type = rb_eRuntimeError; 1029 | break; 1030 | case SWIG_IndexError: 1031 | type = rb_eIndexError; 1032 | break; 1033 | case SWIG_TypeError: 1034 | type = rb_eTypeError; 1035 | break; 1036 | case SWIG_DivisionByZero: 1037 | type = rb_eZeroDivError; 1038 | break; 1039 | case SWIG_OverflowError: 1040 | type = rb_eRangeError; 1041 | break; 1042 | case SWIG_SyntaxError: 1043 | type = rb_eSyntaxError; 1044 | break; 1045 | case SWIG_ValueError: 1046 | type = rb_eArgError; 1047 | break; 1048 | case SWIG_SystemError: 1049 | type = rb_eFatal; 1050 | break; 1051 | case SWIG_AttributeError: 1052 | type = rb_eRuntimeError; 1053 | break; 1054 | case SWIG_NullReferenceError: 1055 | type = getNullReferenceError(); 1056 | break; 1057 | case SWIG_ObjectPreviouslyDeletedError: 1058 | type = getObjectPreviouslyDeletedError(); 1059 | break; 1060 | case SWIG_UnknownError: 1061 | type = rb_eRuntimeError; 1062 | break; 1063 | default: 1064 | type = rb_eRuntimeError; 1065 | } 1066 | return type; 1067 | } 1068 | 1069 | 1070 | /* This function is called when a user inputs a wrong argument to 1071 | a method. 1072 | */ 1073 | SWIGINTERN 1074 | const char* Ruby_Format_TypeError( const char* msg, 1075 | const char* type, 1076 | const char* name, 1077 | const int argn, 1078 | VALUE input ) 1079 | { 1080 | char buf[128]; 1081 | VALUE str; 1082 | VALUE asStr; 1083 | if ( msg && *msg ) 1084 | { 1085 | str = rb_str_new2(msg); 1086 | } 1087 | else 1088 | { 1089 | str = rb_str_new(NULL, 0); 1090 | } 1091 | 1092 | str = rb_str_cat2( str, "Expected argument " ); 1093 | sprintf( buf, "%d of type ", argn-1 ); 1094 | str = rb_str_cat2( str, buf ); 1095 | str = rb_str_cat2( str, type ); 1096 | str = rb_str_cat2( str, ", but got " ); 1097 | str = rb_str_cat2( str, rb_obj_classname(input) ); 1098 | str = rb_str_cat2( str, " " ); 1099 | asStr = rb_inspect(input); 1100 | if ( RSTRING_LEN(asStr) > 30 ) 1101 | { 1102 | str = rb_str_cat( str, StringValuePtr(asStr), 30 ); 1103 | str = rb_str_cat2( str, "..." ); 1104 | } 1105 | else 1106 | { 1107 | str = rb_str_append( str, asStr ); 1108 | } 1109 | 1110 | if ( name ) 1111 | { 1112 | str = rb_str_cat2( str, "\n\tin SWIG method '" ); 1113 | str = rb_str_cat2( str, name ); 1114 | str = rb_str_cat2( str, "'" ); 1115 | } 1116 | 1117 | return StringValuePtr( str ); 1118 | } 1119 | 1120 | /* This function is called when an overloaded method fails */ 1121 | SWIGINTERN 1122 | void Ruby_Format_OverloadedError( 1123 | const int argc, 1124 | const int maxargs, 1125 | const char* method, 1126 | const char* prototypes 1127 | ) 1128 | { 1129 | const char* msg = "Wrong # of arguments"; 1130 | if ( argc <= maxargs ) msg = "Wrong arguments"; 1131 | rb_raise(rb_eArgError,"%s for overloaded method '%s'.\n" 1132 | "Possible C/C++ prototypes are:\n%s", 1133 | msg, method, prototypes); 1134 | } 1135 | 1136 | /* ----------------------------------------------------------------------------- 1137 | * rubytracking.swg 1138 | * 1139 | * This file contains support for tracking mappings from 1140 | * Ruby objects to C++ objects. This functionality is needed 1141 | * to implement mark functions for Ruby's mark and sweep 1142 | * garbage collector. 1143 | * ----------------------------------------------------------------------------- */ 1144 | 1145 | #ifdef __cplusplus 1146 | extern "C" { 1147 | #endif 1148 | 1149 | /* Ruby 1.8 actually assumes the first case. */ 1150 | #if SIZEOF_VOIDP == SIZEOF_LONG 1151 | # define SWIG2NUM(v) LONG2NUM((unsigned long)v) 1152 | # define NUM2SWIG(x) (unsigned long)NUM2LONG(x) 1153 | #elif SIZEOF_VOIDP == SIZEOF_LONG_LONG 1154 | # define SWIG2NUM(v) LL2NUM((unsigned long long)v) 1155 | # define NUM2SWIG(x) (unsigned long long)NUM2LL(x) 1156 | #else 1157 | # error sizeof(void*) is not the same as long or long long 1158 | #endif 1159 | 1160 | 1161 | /* Global Ruby hash table to store Trackings from C/C++ 1162 | structs to Ruby Objects. 1163 | */ 1164 | static VALUE swig_ruby_trackings = Qnil; 1165 | 1166 | /* Global variable that stores a reference to the ruby 1167 | hash table delete function. */ 1168 | static ID swig_ruby_hash_delete; 1169 | 1170 | /* Setup a Ruby hash table to store Trackings */ 1171 | SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { 1172 | /* Create a ruby hash table to store Trackings from C++ 1173 | objects to Ruby objects. */ 1174 | 1175 | /* Try to see if some other .so has already created a 1176 | tracking hash table, which we keep hidden in an instance var 1177 | in the SWIG module. 1178 | This is done to allow multiple DSOs to share the same 1179 | tracking table. 1180 | */ 1181 | ID trackings_id = rb_intern( "@__trackings__" ); 1182 | VALUE verbose = rb_gv_get("VERBOSE"); 1183 | rb_gv_set("VERBOSE", Qfalse); 1184 | swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); 1185 | rb_gv_set("VERBOSE", verbose); 1186 | 1187 | /* No, it hasn't. Create one ourselves */ 1188 | if ( swig_ruby_trackings == Qnil ) 1189 | { 1190 | swig_ruby_trackings = rb_hash_new(); 1191 | rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); 1192 | } 1193 | 1194 | /* Now store a reference to the hash table delete function 1195 | so that we only have to look it up once.*/ 1196 | swig_ruby_hash_delete = rb_intern("delete"); 1197 | } 1198 | 1199 | /* Get a Ruby number to reference a pointer */ 1200 | SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { 1201 | /* We cast the pointer to an unsigned long 1202 | and then store a reference to it using 1203 | a Ruby number object. */ 1204 | 1205 | /* Convert the pointer to a Ruby number */ 1206 | return SWIG2NUM(ptr); 1207 | } 1208 | 1209 | /* Get a Ruby number to reference an object */ 1210 | SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { 1211 | /* We cast the object to an unsigned long 1212 | and then store a reference to it using 1213 | a Ruby number object. */ 1214 | 1215 | /* Convert the Object to a Ruby number */ 1216 | return SWIG2NUM(object); 1217 | } 1218 | 1219 | /* Get a Ruby object from a previously stored reference */ 1220 | SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { 1221 | /* The provided Ruby number object is a reference 1222 | to the Ruby object we want.*/ 1223 | 1224 | /* Convert the Ruby number to a Ruby object */ 1225 | return NUM2SWIG(reference); 1226 | } 1227 | 1228 | /* Add a Tracking from a C/C++ struct to a Ruby object */ 1229 | SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { 1230 | /* In a Ruby hash table we store the pointer and 1231 | the associated Ruby object. The trick here is 1232 | that we cannot store the Ruby object directly - if 1233 | we do then it cannot be garbage collected. So 1234 | instead we typecast it as a unsigned long and 1235 | convert it to a Ruby number object.*/ 1236 | 1237 | /* Get a reference to the pointer as a Ruby number */ 1238 | VALUE key = SWIG_RubyPtrToReference(ptr); 1239 | 1240 | /* Get a reference to the Ruby object as a Ruby number */ 1241 | VALUE value = SWIG_RubyObjectToReference(object); 1242 | 1243 | /* Store the mapping to the global hash table. */ 1244 | rb_hash_aset(swig_ruby_trackings, key, value); 1245 | } 1246 | 1247 | /* Get the Ruby object that owns the specified C/C++ struct */ 1248 | SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { 1249 | /* Get a reference to the pointer as a Ruby number */ 1250 | VALUE key = SWIG_RubyPtrToReference(ptr); 1251 | 1252 | /* Now lookup the value stored in the global hash table */ 1253 | VALUE value = rb_hash_aref(swig_ruby_trackings, key); 1254 | 1255 | if (value == Qnil) { 1256 | /* No object exists - return nil. */ 1257 | return Qnil; 1258 | } 1259 | else { 1260 | /* Convert this value to Ruby object */ 1261 | return SWIG_RubyReferenceToObject(value); 1262 | } 1263 | } 1264 | 1265 | /* Remove a Tracking from a C/C++ struct to a Ruby object. It 1266 | is very important to remove objects once they are destroyed 1267 | since the same memory address may be reused later to create 1268 | a new object. */ 1269 | SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { 1270 | /* Get a reference to the pointer as a Ruby number */ 1271 | VALUE key = SWIG_RubyPtrToReference(ptr); 1272 | 1273 | /* Delete the object from the hash table by calling Ruby's 1274 | do this we need to call the Hash.delete method.*/ 1275 | rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); 1276 | } 1277 | 1278 | /* This is a helper method that unlinks a Ruby object from its 1279 | underlying C++ object. This is needed if the lifetime of the 1280 | Ruby object is longer than the C++ object */ 1281 | SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { 1282 | VALUE object = SWIG_RubyInstanceFor(ptr); 1283 | 1284 | if (object != Qnil) { 1285 | DATA_PTR(object) = 0; 1286 | } 1287 | } 1288 | 1289 | 1290 | #ifdef __cplusplus 1291 | } 1292 | #endif 1293 | 1294 | /* ----------------------------------------------------------------------------- 1295 | * Ruby API portion that goes into the runtime 1296 | * ----------------------------------------------------------------------------- */ 1297 | 1298 | #ifdef __cplusplus 1299 | extern "C" { 1300 | #endif 1301 | 1302 | SWIGINTERN VALUE 1303 | SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { 1304 | if (NIL_P(target)) { 1305 | target = o; 1306 | } else { 1307 | if (TYPE(target) != T_ARRAY) { 1308 | VALUE o2 = target; 1309 | target = rb_ary_new(); 1310 | rb_ary_push(target, o2); 1311 | } 1312 | rb_ary_push(target, o); 1313 | } 1314 | return target; 1315 | } 1316 | 1317 | /* For ruby1.8.4 and earlier. */ 1318 | #ifndef RUBY_INIT_STACK 1319 | RUBY_EXTERN void Init_stack(VALUE* addr); 1320 | # define RUBY_INIT_STACK \ 1321 | VALUE variable_in_this_stack_frame; \ 1322 | Init_stack(&variable_in_this_stack_frame); 1323 | #endif 1324 | 1325 | 1326 | #ifdef __cplusplus 1327 | } 1328 | #endif 1329 | 1330 | 1331 | /* ----------------------------------------------------------------------------- 1332 | * rubyrun.swg 1333 | * 1334 | * This file contains the runtime support for Ruby modules 1335 | * and includes code for managing global variables and pointer 1336 | * type checking. 1337 | * ----------------------------------------------------------------------------- */ 1338 | 1339 | /* For backward compatibility only */ 1340 | #define SWIG_POINTER_EXCEPTION 0 1341 | 1342 | /* for raw pointers */ 1343 | #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0) 1344 | #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) 1345 | #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) 1346 | #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) 1347 | #define swig_owntype ruby_owntype 1348 | 1349 | /* for raw packed data */ 1350 | #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) 1351 | #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) 1352 | 1353 | /* for class or struct pointers */ 1354 | #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) 1355 | #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) 1356 | 1357 | /* for C or C++ function pointers */ 1358 | #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) 1359 | #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) 1360 | 1361 | /* for C++ member pointers, ie, member methods */ 1362 | #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty) 1363 | #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) 1364 | 1365 | 1366 | /* Runtime API */ 1367 | 1368 | #define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule(clientdata) 1369 | #define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) 1370 | 1371 | 1372 | /* Error manipulation */ 1373 | 1374 | #define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) 1375 | #define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), "%s", msg) 1376 | #define SWIG_fail goto fail 1377 | 1378 | 1379 | /* Ruby-specific SWIG API */ 1380 | 1381 | #define SWIG_InitRuntime() SWIG_Ruby_InitRuntime() 1382 | #define SWIG_define_class(ty) SWIG_Ruby_define_class(ty) 1383 | #define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty) 1384 | #define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value) 1385 | #define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty) 1386 | 1387 | #include "assert.h" 1388 | 1389 | /* ----------------------------------------------------------------------------- 1390 | * pointers/data manipulation 1391 | * ----------------------------------------------------------------------------- */ 1392 | 1393 | #ifdef __cplusplus 1394 | extern "C" { 1395 | #endif 1396 | 1397 | typedef struct { 1398 | VALUE klass; 1399 | VALUE mImpl; 1400 | void (*mark)(void *); 1401 | void (*destroy)(void *); 1402 | int trackObjects; 1403 | } swig_class; 1404 | 1405 | 1406 | /* Global pointer used to keep some internal SWIG stuff */ 1407 | static VALUE _cSWIG_Pointer = Qnil; 1408 | static VALUE swig_runtime_data_type_pointer = Qnil; 1409 | 1410 | /* Global IDs used to keep some internal SWIG stuff */ 1411 | static ID swig_arity_id = 0; 1412 | static ID swig_call_id = 0; 1413 | 1414 | /* 1415 | If your swig extension is to be run within an embedded ruby and has 1416 | director callbacks, you should set -DRUBY_EMBEDDED during compilation. 1417 | This will reset ruby's stack frame on each entry point from the main 1418 | program the first time a virtual director function is invoked (in a 1419 | non-recursive way). 1420 | If this is not done, you run the risk of Ruby trashing the stack. 1421 | */ 1422 | 1423 | #ifdef RUBY_EMBEDDED 1424 | 1425 | # define SWIG_INIT_STACK \ 1426 | if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \ 1427 | ++swig_virtual_calls; 1428 | # define SWIG_RELEASE_STACK --swig_virtual_calls; 1429 | # define Ruby_DirectorTypeMismatchException(x) \ 1430 | rb_raise( rb_eTypeError, "%s", x ); return c_result; 1431 | 1432 | static unsigned int swig_virtual_calls = 0; 1433 | 1434 | #else /* normal non-embedded extension */ 1435 | 1436 | # define SWIG_INIT_STACK 1437 | # define SWIG_RELEASE_STACK 1438 | # define Ruby_DirectorTypeMismatchException(x) \ 1439 | throw Swig::DirectorTypeMismatchException( x ); 1440 | 1441 | #endif /* RUBY_EMBEDDED */ 1442 | 1443 | 1444 | SWIGRUNTIME VALUE 1445 | getExceptionClass(void) { 1446 | static int init = 0; 1447 | static VALUE rubyExceptionClass ; 1448 | if (!init) { 1449 | init = 1; 1450 | rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception")); 1451 | } 1452 | return rubyExceptionClass; 1453 | } 1454 | 1455 | /* This code checks to see if the Ruby object being raised as part 1456 | of an exception inherits from the Ruby class Exception. If so, 1457 | the object is simply returned. If not, then a new Ruby exception 1458 | object is created and that will be returned to Ruby.*/ 1459 | SWIGRUNTIME VALUE 1460 | SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) { 1461 | VALUE exceptionClass = getExceptionClass(); 1462 | if (rb_obj_is_kind_of(obj, exceptionClass)) { 1463 | return obj; 1464 | } else { 1465 | return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)); 1466 | } 1467 | } 1468 | 1469 | /* Initialize Ruby runtime support */ 1470 | SWIGRUNTIME void 1471 | SWIG_Ruby_InitRuntime(void) 1472 | { 1473 | if (_mSWIG == Qnil) { 1474 | _mSWIG = rb_define_module("SWIG"); 1475 | swig_call_id = rb_intern("call"); 1476 | swig_arity_id = rb_intern("arity"); 1477 | } 1478 | } 1479 | 1480 | /* Define Ruby class for C type */ 1481 | SWIGRUNTIME void 1482 | SWIG_Ruby_define_class(swig_type_info *type) 1483 | { 1484 | char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); 1485 | sprintf(klass_name, "TYPE%s", type->name); 1486 | if (NIL_P(_cSWIG_Pointer)) { 1487 | _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); 1488 | rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); 1489 | } 1490 | rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); 1491 | free((void *) klass_name); 1492 | } 1493 | 1494 | /* Create a new pointer object */ 1495 | SWIGRUNTIME VALUE 1496 | SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) 1497 | { 1498 | int own = flags & SWIG_POINTER_OWN; 1499 | int track; 1500 | char *klass_name; 1501 | swig_class *sklass; 1502 | VALUE klass; 1503 | VALUE obj; 1504 | 1505 | if (!ptr) 1506 | return Qnil; 1507 | 1508 | if (type->clientdata) { 1509 | sklass = (swig_class *) type->clientdata; 1510 | 1511 | /* Are we tracking this class and have we already returned this Ruby object? */ 1512 | track = sklass->trackObjects; 1513 | if (track) { 1514 | obj = SWIG_RubyInstanceFor(ptr); 1515 | 1516 | /* Check the object's type and make sure it has the correct type. 1517 | It might not in cases where methods do things like 1518 | downcast methods. */ 1519 | if (obj != Qnil) { 1520 | VALUE value = rb_iv_get(obj, "@__swigtype__"); 1521 | const char* type_name = RSTRING_PTR(value); 1522 | 1523 | if (strcmp(type->name, type_name) == 0) { 1524 | return obj; 1525 | } 1526 | } 1527 | } 1528 | 1529 | /* Create a new Ruby object */ 1530 | obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), 1531 | ( own ? VOIDFUNC(sklass->destroy) : 1532 | (track ? VOIDFUNC(SWIG_RubyRemoveTracking) : 0 ) 1533 | ), ptr); 1534 | 1535 | /* If tracking is on for this class then track this object. */ 1536 | if (track) { 1537 | SWIG_RubyAddTracking(ptr, obj); 1538 | } 1539 | } else { 1540 | klass_name = (char *) malloc(4 + strlen(type->name) + 1); 1541 | sprintf(klass_name, "TYPE%s", type->name); 1542 | klass = rb_const_get(_mSWIG, rb_intern(klass_name)); 1543 | free((void *) klass_name); 1544 | obj = Data_Wrap_Struct(klass, 0, 0, ptr); 1545 | } 1546 | rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); 1547 | 1548 | return obj; 1549 | } 1550 | 1551 | /* Create a new class instance (always owned) */ 1552 | SWIGRUNTIME VALUE 1553 | SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type) 1554 | { 1555 | VALUE obj; 1556 | swig_class *sklass = (swig_class *) type->clientdata; 1557 | obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0); 1558 | rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); 1559 | return obj; 1560 | } 1561 | 1562 | /* Get type mangle from class name */ 1563 | SWIGRUNTIMEINLINE char * 1564 | SWIG_Ruby_MangleStr(VALUE obj) 1565 | { 1566 | VALUE stype = rb_iv_get(obj, "@__swigtype__"); 1567 | return StringValuePtr(stype); 1568 | } 1569 | 1570 | /* Acquire a pointer value */ 1571 | typedef void (*ruby_owntype)(void*); 1572 | 1573 | SWIGRUNTIME ruby_owntype 1574 | SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { 1575 | if (obj) { 1576 | ruby_owntype oldown = RDATA(obj)->dfree; 1577 | RDATA(obj)->dfree = own; 1578 | return oldown; 1579 | } else { 1580 | return 0; 1581 | } 1582 | } 1583 | 1584 | /* Convert a pointer value */ 1585 | SWIGRUNTIME int 1586 | SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) 1587 | { 1588 | char *c; 1589 | swig_cast_info *tc; 1590 | void *vptr = 0; 1591 | 1592 | /* Grab the pointer */ 1593 | if (NIL_P(obj)) { 1594 | *ptr = 0; 1595 | return SWIG_OK; 1596 | } else { 1597 | if (TYPE(obj) != T_DATA) { 1598 | return SWIG_ERROR; 1599 | } 1600 | Data_Get_Struct(obj, void, vptr); 1601 | } 1602 | 1603 | if (own) *own = RDATA(obj)->dfree; 1604 | 1605 | /* Check to see if the input object is giving up ownership 1606 | of the underlying C struct or C++ object. If so then we 1607 | need to reset the destructor since the Ruby object no 1608 | longer owns the underlying C++ object.*/ 1609 | if (flags & SWIG_POINTER_DISOWN) { 1610 | /* Is tracking on for this class? */ 1611 | int track = 0; 1612 | if (ty && ty->clientdata) { 1613 | swig_class *sklass = (swig_class *) ty->clientdata; 1614 | track = sklass->trackObjects; 1615 | } 1616 | 1617 | if (track) { 1618 | /* We are tracking objects for this class. Thus we change the destructor 1619 | * to SWIG_RubyRemoveTracking. This allows us to 1620 | * remove the mapping from the C++ to Ruby object 1621 | * when the Ruby object is garbage collected. If we don't 1622 | * do this, then it is possible we will return a reference 1623 | * to a Ruby object that no longer exists thereby crashing Ruby. */ 1624 | RDATA(obj)->dfree = SWIG_RubyRemoveTracking; 1625 | } else { 1626 | RDATA(obj)->dfree = 0; 1627 | } 1628 | } 1629 | 1630 | /* Do type-checking if type info was provided */ 1631 | if (ty) { 1632 | if (ty->clientdata) { 1633 | if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { 1634 | if (vptr == 0) { 1635 | /* The object has already been deleted */ 1636 | return SWIG_ObjectPreviouslyDeletedError; 1637 | } 1638 | *ptr = vptr; 1639 | return SWIG_OK; 1640 | } 1641 | } 1642 | if ((c = SWIG_MangleStr(obj)) == NULL) { 1643 | return SWIG_ERROR; 1644 | } 1645 | tc = SWIG_TypeCheck(c, ty); 1646 | if (!tc) { 1647 | return SWIG_ERROR; 1648 | } else { 1649 | int newmemory = 0; 1650 | *ptr = SWIG_TypeCast(tc, vptr, &newmemory); 1651 | assert(!newmemory); /* newmemory handling not yet implemented */ 1652 | } 1653 | } else { 1654 | *ptr = vptr; 1655 | } 1656 | 1657 | return SWIG_OK; 1658 | } 1659 | 1660 | /* Check convert */ 1661 | SWIGRUNTIMEINLINE int 1662 | SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty) 1663 | { 1664 | char *c = SWIG_MangleStr(obj); 1665 | if (!c) return 0; 1666 | return SWIG_TypeCheck(c,ty) != 0; 1667 | } 1668 | 1669 | SWIGRUNTIME VALUE 1670 | SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { 1671 | char result[1024]; 1672 | char *r = result; 1673 | if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; 1674 | *(r++) = '_'; 1675 | r = SWIG_PackData(r, ptr, sz); 1676 | strcpy(r, type->name); 1677 | return rb_str_new2(result); 1678 | } 1679 | 1680 | /* Convert a packed value value */ 1681 | SWIGRUNTIME int 1682 | SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { 1683 | swig_cast_info *tc; 1684 | const char *c; 1685 | 1686 | if (TYPE(obj) != T_STRING) goto type_error; 1687 | c = StringValuePtr(obj); 1688 | /* Pointer values must start with leading underscore */ 1689 | if (*c != '_') goto type_error; 1690 | c++; 1691 | c = SWIG_UnpackData(c, ptr, sz); 1692 | if (ty) { 1693 | tc = SWIG_TypeCheck(c, ty); 1694 | if (!tc) goto type_error; 1695 | } 1696 | return SWIG_OK; 1697 | 1698 | type_error: 1699 | return SWIG_ERROR; 1700 | } 1701 | 1702 | SWIGRUNTIME swig_module_info * 1703 | SWIG_Ruby_GetModule(void *SWIGUNUSEDPARM(clientdata)) 1704 | { 1705 | VALUE pointer; 1706 | swig_module_info *ret = 0; 1707 | VALUE verbose = rb_gv_get("VERBOSE"); 1708 | 1709 | /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */ 1710 | rb_gv_set("VERBOSE", Qfalse); 1711 | 1712 | /* first check if pointer already created */ 1713 | pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); 1714 | if (pointer != Qnil) { 1715 | Data_Get_Struct(pointer, swig_module_info, ret); 1716 | } 1717 | 1718 | /* reinstate warnings */ 1719 | rb_gv_set("VERBOSE", verbose); 1720 | return ret; 1721 | } 1722 | 1723 | SWIGRUNTIME void 1724 | SWIG_Ruby_SetModule(swig_module_info *pointer) 1725 | { 1726 | /* register a new class */ 1727 | VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); 1728 | /* create and store the structure pointer to a global variable */ 1729 | swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); 1730 | rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer); 1731 | } 1732 | 1733 | /* This function can be used to check whether a proc or method or similarly 1734 | callable function has been passed. Usually used in a %typecheck, like: 1735 | 1736 | %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) { 1737 | $result = SWIG_Ruby_isCallable( $input ); 1738 | } 1739 | */ 1740 | SWIGINTERN 1741 | int SWIG_Ruby_isCallable( VALUE proc ) 1742 | { 1743 | if ( rb_respond_to( proc, swig_call_id ) ) 1744 | return 1; 1745 | return 0; 1746 | } 1747 | 1748 | /* This function can be used to check the arity (number of arguments) 1749 | a proc or method can take. Usually used in a %typecheck. 1750 | Valid arities will be that equal to minimal or those < 0 1751 | which indicate a variable number of parameters at the end. 1752 | */ 1753 | SWIGINTERN 1754 | int SWIG_Ruby_arity( VALUE proc, int minimal ) 1755 | { 1756 | if ( rb_respond_to( proc, swig_arity_id ) ) 1757 | { 1758 | VALUE num = rb_funcall( proc, swig_arity_id, 0 ); 1759 | int arity = NUM2INT(num); 1760 | if ( arity < 0 && (arity+1) < -minimal ) return 1; 1761 | if ( arity == minimal ) return 1; 1762 | return 1; 1763 | } 1764 | return 0; 1765 | } 1766 | 1767 | 1768 | #ifdef __cplusplus 1769 | } 1770 | #endif 1771 | 1772 | 1773 | 1774 | #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) 1775 | 1776 | #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else 1777 | 1778 | 1779 | 1780 | /* -------- TYPES TABLE (BEGIN) -------- */ 1781 | 1782 | #define SWIGTYPE_p_char swig_types[0] 1783 | static swig_type_info *swig_types[2]; 1784 | static swig_module_info swig_module = {swig_types, 1, 0, 0, 0, 0}; 1785 | #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) 1786 | #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) 1787 | 1788 | /* -------- TYPES TABLE (END) -------- */ 1789 | 1790 | #define SWIG_init Init_gdalconst 1791 | #define SWIG_name "Gdal::Gdalconst" 1792 | 1793 | static VALUE mGdalconst; 1794 | 1795 | #define SWIG_RUBY_THREAD_BEGIN_BLOCK 1796 | #define SWIG_RUBY_THREAD_END_BLOCK 1797 | 1798 | 1799 | #define SWIGVERSION 0x030005 1800 | #define SWIG_VERSION SWIGVERSION 1801 | 1802 | 1803 | #define SWIG_as_voidptr(a) (void *)((const void *)(a)) 1804 | #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) 1805 | 1806 | 1807 | #include "gdal.h" 1808 | #include "gdalwarper.h" 1809 | #include "cpl_string.h" 1810 | #include "cpl_minixml.h" 1811 | 1812 | 1813 | #include 1814 | #if !defined(SWIG_NO_LLONG_MAX) 1815 | # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) 1816 | # define LLONG_MAX __LONG_LONG_MAX__ 1817 | # define LLONG_MIN (-LLONG_MAX - 1LL) 1818 | # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) 1819 | # endif 1820 | #endif 1821 | 1822 | 1823 | #define SWIG_From_long LONG2NUM 1824 | 1825 | 1826 | SWIGINTERNINLINE VALUE 1827 | SWIG_From_int (int value) 1828 | { 1829 | return SWIG_From_long (value); 1830 | } 1831 | 1832 | 1833 | SWIGINTERN swig_type_info* 1834 | SWIG_pchar_descriptor(void) 1835 | { 1836 | static int init = 0; 1837 | static swig_type_info* info = 0; 1838 | if (!init) { 1839 | info = SWIG_TypeQuery("_p_char"); 1840 | init = 1; 1841 | } 1842 | return info; 1843 | } 1844 | 1845 | 1846 | SWIGINTERNINLINE VALUE 1847 | SWIG_FromCharPtrAndSize(const char* carray, size_t size) 1848 | { 1849 | if (carray) { 1850 | if (size > LONG_MAX) { 1851 | swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); 1852 | return pchar_descriptor ? 1853 | SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : Qnil; 1854 | } else { 1855 | return rb_str_new(carray, (long)(size)); 1856 | } 1857 | } else { 1858 | return Qnil; 1859 | } 1860 | } 1861 | 1862 | 1863 | SWIGINTERNINLINE VALUE 1864 | SWIG_FromCharPtr(const char *cptr) 1865 | { 1866 | return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); 1867 | } 1868 | 1869 | 1870 | /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ 1871 | 1872 | static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; 1873 | 1874 | static swig_type_info *swig_type_initial[] = { 1875 | &_swigt__p_char, 1876 | }; 1877 | 1878 | static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; 1879 | 1880 | static swig_cast_info *swig_cast_initial[] = { 1881 | _swigc__p_char, 1882 | }; 1883 | 1884 | 1885 | /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ 1886 | 1887 | /* ----------------------------------------------------------------------------- 1888 | * Type initialization: 1889 | * This problem is tough by the requirement that no dynamic 1890 | * memory is used. Also, since swig_type_info structures store pointers to 1891 | * swig_cast_info structures and swig_cast_info structures store pointers back 1892 | * to swig_type_info structures, we need some lookup code at initialization. 1893 | * The idea is that swig generates all the structures that are needed. 1894 | * The runtime then collects these partially filled structures. 1895 | * The SWIG_InitializeModule function takes these initial arrays out of 1896 | * swig_module, and does all the lookup, filling in the swig_module.types 1897 | * array with the correct data and linking the correct swig_cast_info 1898 | * structures together. 1899 | * 1900 | * The generated swig_type_info structures are assigned statically to an initial 1901 | * array. We just loop through that array, and handle each type individually. 1902 | * First we lookup if this type has been already loaded, and if so, use the 1903 | * loaded structure instead of the generated one. Then we have to fill in the 1904 | * cast linked list. The cast data is initially stored in something like a 1905 | * two-dimensional array. Each row corresponds to a type (there are the same 1906 | * number of rows as there are in the swig_type_initial array). Each entry in 1907 | * a column is one of the swig_cast_info structures for that type. 1908 | * The cast_initial array is actually an array of arrays, because each row has 1909 | * a variable number of columns. So to actually build the cast linked list, 1910 | * we find the array of casts associated with the type, and loop through it 1911 | * adding the casts to the list. The one last trick we need to do is making 1912 | * sure the type pointer in the swig_cast_info struct is correct. 1913 | * 1914 | * First off, we lookup the cast->type name to see if it is already loaded. 1915 | * There are three cases to handle: 1916 | * 1) If the cast->type has already been loaded AND the type we are adding 1917 | * casting info to has not been loaded (it is in this module), THEN we 1918 | * replace the cast->type pointer with the type pointer that has already 1919 | * been loaded. 1920 | * 2) If BOTH types (the one we are adding casting info to, and the 1921 | * cast->type) are loaded, THEN the cast info has already been loaded by 1922 | * the previous module so we just ignore it. 1923 | * 3) Finally, if cast->type has not already been loaded, then we add that 1924 | * swig_cast_info to the linked list (because the cast->type) pointer will 1925 | * be correct. 1926 | * ----------------------------------------------------------------------------- */ 1927 | 1928 | #ifdef __cplusplus 1929 | extern "C" { 1930 | #if 0 1931 | } /* c-mode */ 1932 | #endif 1933 | #endif 1934 | 1935 | #if 0 1936 | #define SWIGRUNTIME_DEBUG 1937 | #endif 1938 | 1939 | 1940 | SWIGRUNTIME void 1941 | SWIG_InitializeModule(void *clientdata) { 1942 | size_t i; 1943 | swig_module_info *module_head, *iter; 1944 | int init; 1945 | 1946 | /* check to see if the circular list has been setup, if not, set it up */ 1947 | if (swig_module.next==0) { 1948 | /* Initialize the swig_module */ 1949 | swig_module.type_initial = swig_type_initial; 1950 | swig_module.cast_initial = swig_cast_initial; 1951 | swig_module.next = &swig_module; 1952 | init = 1; 1953 | } else { 1954 | init = 0; 1955 | } 1956 | 1957 | /* Try and load any already created modules */ 1958 | module_head = SWIG_GetModule(clientdata); 1959 | if (!module_head) { 1960 | /* This is the first module loaded for this interpreter */ 1961 | /* so set the swig module into the interpreter */ 1962 | SWIG_SetModule(clientdata, &swig_module); 1963 | } else { 1964 | /* the interpreter has loaded a SWIG module, but has it loaded this one? */ 1965 | iter=module_head; 1966 | do { 1967 | if (iter==&swig_module) { 1968 | /* Our module is already in the list, so there's nothing more to do. */ 1969 | return; 1970 | } 1971 | iter=iter->next; 1972 | } while (iter!= module_head); 1973 | 1974 | /* otherwise we must add our module into the list */ 1975 | swig_module.next = module_head->next; 1976 | module_head->next = &swig_module; 1977 | } 1978 | 1979 | /* When multiple interpreters are used, a module could have already been initialized in 1980 | a different interpreter, but not yet have a pointer in this interpreter. 1981 | In this case, we do not want to continue adding types... everything should be 1982 | set up already */ 1983 | if (init == 0) return; 1984 | 1985 | /* Now work on filling in swig_module.types */ 1986 | #ifdef SWIGRUNTIME_DEBUG 1987 | printf("SWIG_InitializeModule: size %d\n", swig_module.size); 1988 | #endif 1989 | for (i = 0; i < swig_module.size; ++i) { 1990 | swig_type_info *type = 0; 1991 | swig_type_info *ret; 1992 | swig_cast_info *cast; 1993 | 1994 | #ifdef SWIGRUNTIME_DEBUG 1995 | printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); 1996 | #endif 1997 | 1998 | /* if there is another module already loaded */ 1999 | if (swig_module.next != &swig_module) { 2000 | type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); 2001 | } 2002 | if (type) { 2003 | /* Overwrite clientdata field */ 2004 | #ifdef SWIGRUNTIME_DEBUG 2005 | printf("SWIG_InitializeModule: found type %s\n", type->name); 2006 | #endif 2007 | if (swig_module.type_initial[i]->clientdata) { 2008 | type->clientdata = swig_module.type_initial[i]->clientdata; 2009 | #ifdef SWIGRUNTIME_DEBUG 2010 | printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); 2011 | #endif 2012 | } 2013 | } else { 2014 | type = swig_module.type_initial[i]; 2015 | } 2016 | 2017 | /* Insert casting types */ 2018 | cast = swig_module.cast_initial[i]; 2019 | while (cast->type) { 2020 | 2021 | /* Don't need to add information already in the list */ 2022 | ret = 0; 2023 | #ifdef SWIGRUNTIME_DEBUG 2024 | printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); 2025 | #endif 2026 | if (swig_module.next != &swig_module) { 2027 | ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); 2028 | #ifdef SWIGRUNTIME_DEBUG 2029 | if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); 2030 | #endif 2031 | } 2032 | if (ret) { 2033 | if (type == swig_module.type_initial[i]) { 2034 | #ifdef SWIGRUNTIME_DEBUG 2035 | printf("SWIG_InitializeModule: skip old type %s\n", ret->name); 2036 | #endif 2037 | cast->type = ret; 2038 | ret = 0; 2039 | } else { 2040 | /* Check for casting already in the list */ 2041 | swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); 2042 | #ifdef SWIGRUNTIME_DEBUG 2043 | if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); 2044 | #endif 2045 | if (!ocast) ret = 0; 2046 | } 2047 | } 2048 | 2049 | if (!ret) { 2050 | #ifdef SWIGRUNTIME_DEBUG 2051 | printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); 2052 | #endif 2053 | if (type->cast) { 2054 | type->cast->prev = cast; 2055 | cast->next = type->cast; 2056 | } 2057 | type->cast = cast; 2058 | } 2059 | cast++; 2060 | } 2061 | /* Set entry in modules->types array equal to the type */ 2062 | swig_module.types[i] = type; 2063 | } 2064 | swig_module.types[i] = 0; 2065 | 2066 | #ifdef SWIGRUNTIME_DEBUG 2067 | printf("**** SWIG_InitializeModule: Cast List ******\n"); 2068 | for (i = 0; i < swig_module.size; ++i) { 2069 | int j = 0; 2070 | swig_cast_info *cast = swig_module.cast_initial[i]; 2071 | printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); 2072 | while (cast->type) { 2073 | printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); 2074 | cast++; 2075 | ++j; 2076 | } 2077 | printf("---- Total casts: %d\n",j); 2078 | } 2079 | printf("**** SWIG_InitializeModule: Cast List ******\n"); 2080 | #endif 2081 | } 2082 | 2083 | /* This function will propagate the clientdata field of type to 2084 | * any new swig_type_info structures that have been added into the list 2085 | * of equivalent types. It is like calling 2086 | * SWIG_TypeClientData(type, clientdata) a second time. 2087 | */ 2088 | SWIGRUNTIME void 2089 | SWIG_PropagateClientData(void) { 2090 | size_t i; 2091 | swig_cast_info *equiv; 2092 | static int init_run = 0; 2093 | 2094 | if (init_run) return; 2095 | init_run = 1; 2096 | 2097 | for (i = 0; i < swig_module.size; i++) { 2098 | if (swig_module.types[i]->clientdata) { 2099 | equiv = swig_module.types[i]->cast; 2100 | while (equiv) { 2101 | if (!equiv->converter) { 2102 | if (equiv->type && !equiv->type->clientdata) 2103 | SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); 2104 | } 2105 | equiv = equiv->next; 2106 | } 2107 | } 2108 | } 2109 | } 2110 | 2111 | #ifdef __cplusplus 2112 | #if 0 2113 | { /* c-mode */ 2114 | #endif 2115 | } 2116 | #endif 2117 | 2118 | /* 2119 | 2120 | */ 2121 | #ifdef __cplusplus 2122 | extern "C" 2123 | #endif 2124 | SWIGEXPORT void Init_gdalconst(void) { 2125 | size_t i; 2126 | 2127 | SWIG_InitRuntime(); 2128 | mGdalconst = rb_define_module("Gdal"); 2129 | mGdalconst = rb_define_module_under(mGdalconst, "Gdalconst"); 2130 | 2131 | SWIG_InitializeModule(0); 2132 | for (i = 0; i < swig_module.size; i++) { 2133 | SWIG_define_class(swig_module.types[i]); 2134 | } 2135 | 2136 | SWIG_RubyInitializeTrackings(); 2137 | rb_define_const(mGdalconst, "GDT_UNKNOWN", SWIG_From_int((int)(GDT_Unknown))); 2138 | rb_define_const(mGdalconst, "GDT_BYTE", SWIG_From_int((int)(GDT_Byte))); 2139 | rb_define_const(mGdalconst, "GDT_UINT16", SWIG_From_int((int)(GDT_UInt16))); 2140 | rb_define_const(mGdalconst, "GDT_INT16", SWIG_From_int((int)(GDT_Int16))); 2141 | rb_define_const(mGdalconst, "GDT_UINT32", SWIG_From_int((int)(GDT_UInt32))); 2142 | rb_define_const(mGdalconst, "GDT_INT32", SWIG_From_int((int)(GDT_Int32))); 2143 | rb_define_const(mGdalconst, "GDT_FLOAT32", SWIG_From_int((int)(GDT_Float32))); 2144 | rb_define_const(mGdalconst, "GDT_FLOAT64", SWIG_From_int((int)(GDT_Float64))); 2145 | rb_define_const(mGdalconst, "GDT_CINT16", SWIG_From_int((int)(GDT_CInt16))); 2146 | rb_define_const(mGdalconst, "GDT_CINT32", SWIG_From_int((int)(GDT_CInt32))); 2147 | rb_define_const(mGdalconst, "GDT_CFLOAT32", SWIG_From_int((int)(GDT_CFloat32))); 2148 | rb_define_const(mGdalconst, "GDT_CFLOAT64", SWIG_From_int((int)(GDT_CFloat64))); 2149 | rb_define_const(mGdalconst, "GDT_TYPECOUNT", SWIG_From_int((int)(GDT_TypeCount))); 2150 | rb_define_const(mGdalconst, "GA_READONLY", SWIG_From_int((int)(GA_ReadOnly))); 2151 | rb_define_const(mGdalconst, "GA_UPDATE", SWIG_From_int((int)(GA_Update))); 2152 | rb_define_const(mGdalconst, "GF_READ", SWIG_From_int((int)(GF_Read))); 2153 | rb_define_const(mGdalconst, "GF_WRITE", SWIG_From_int((int)(GF_Write))); 2154 | rb_define_const(mGdalconst, "GCI_UNDEFINED", SWIG_From_int((int)(GCI_Undefined))); 2155 | rb_define_const(mGdalconst, "GCI_GRAYINDEX", SWIG_From_int((int)(GCI_GrayIndex))); 2156 | rb_define_const(mGdalconst, "GCI_PALETTEINDEX", SWIG_From_int((int)(GCI_PaletteIndex))); 2157 | rb_define_const(mGdalconst, "GCI_REDBAND", SWIG_From_int((int)(GCI_RedBand))); 2158 | rb_define_const(mGdalconst, "GCI_GREENBAND", SWIG_From_int((int)(GCI_GreenBand))); 2159 | rb_define_const(mGdalconst, "GCI_BLUEBAND", SWIG_From_int((int)(GCI_BlueBand))); 2160 | rb_define_const(mGdalconst, "GCI_ALPHABAND", SWIG_From_int((int)(GCI_AlphaBand))); 2161 | rb_define_const(mGdalconst, "GCI_HUEBAND", SWIG_From_int((int)(GCI_HueBand))); 2162 | rb_define_const(mGdalconst, "GCI_SATURATIONBAND", SWIG_From_int((int)(GCI_SaturationBand))); 2163 | rb_define_const(mGdalconst, "GCI_LIGHTNESSBAND", SWIG_From_int((int)(GCI_LightnessBand))); 2164 | rb_define_const(mGdalconst, "GCI_CYANBAND", SWIG_From_int((int)(GCI_CyanBand))); 2165 | rb_define_const(mGdalconst, "GCI_MAGENTABAND", SWIG_From_int((int)(GCI_MagentaBand))); 2166 | rb_define_const(mGdalconst, "GCI_YELLOWBAND", SWIG_From_int((int)(GCI_YellowBand))); 2167 | rb_define_const(mGdalconst, "GCI_BLACKBAND", SWIG_From_int((int)(GCI_BlackBand))); 2168 | rb_define_const(mGdalconst, "GCI_YCBCR_YBAND", SWIG_From_int((int)(GCI_YCbCr_YBand))); 2169 | rb_define_const(mGdalconst, "GCI_YCBCR_CRBAND", SWIG_From_int((int)(GCI_YCbCr_CrBand))); 2170 | rb_define_const(mGdalconst, "GCI_YCBCR_CBBAND", SWIG_From_int((int)(GCI_YCbCr_CbBand))); 2171 | rb_define_const(mGdalconst, "GRA_NEARESTNEIGHBOUR", SWIG_From_int((int)(GRA_NearestNeighbour))); 2172 | rb_define_const(mGdalconst, "GRA_BILINEAR", SWIG_From_int((int)(GRA_Bilinear))); 2173 | rb_define_const(mGdalconst, "GRA_CUBIC", SWIG_From_int((int)(GRA_Cubic))); 2174 | rb_define_const(mGdalconst, "GRA_CUBICSPLINE", SWIG_From_int((int)(GRA_CubicSpline))); 2175 | rb_define_const(mGdalconst, "GRA_LANCZOS", SWIG_From_int((int)(GRA_Lanczos))); 2176 | rb_define_const(mGdalconst, "GRA_AVERAGE", SWIG_From_int((int)(GRA_Average))); 2177 | rb_define_const(mGdalconst, "GRA_MODE", SWIG_From_int((int)(GRA_Mode))); 2178 | rb_define_const(mGdalconst, "GPI_GRAY", SWIG_From_int((int)(GPI_Gray))); 2179 | rb_define_const(mGdalconst, "GPI_RGB", SWIG_From_int((int)(GPI_RGB))); 2180 | rb_define_const(mGdalconst, "GPI_CMYK", SWIG_From_int((int)(GPI_CMYK))); 2181 | rb_define_const(mGdalconst, "GPI_HLS", SWIG_From_int((int)(GPI_HLS))); 2182 | rb_define_const(mGdalconst, "CXT_ELEMENT", SWIG_From_int((int)(CXT_Element))); 2183 | rb_define_const(mGdalconst, "CXT_TEXT", SWIG_From_int((int)(CXT_Text))); 2184 | rb_define_const(mGdalconst, "CXT_ATTRIBUTE", SWIG_From_int((int)(CXT_Attribute))); 2185 | rb_define_const(mGdalconst, "CXT_COMMENT", SWIG_From_int((int)(CXT_Comment))); 2186 | rb_define_const(mGdalconst, "CXT_LITERAL", SWIG_From_int((int)(CXT_Literal))); 2187 | rb_define_const(mGdalconst, "CE_NONE", SWIG_From_int((int)(CE_None))); 2188 | rb_define_const(mGdalconst, "CE_DEBUG", SWIG_From_int((int)(CE_Debug))); 2189 | rb_define_const(mGdalconst, "CE_WARNING", SWIG_From_int((int)(CE_Warning))); 2190 | rb_define_const(mGdalconst, "CE_FAILURE", SWIG_From_int((int)(CE_Failure))); 2191 | rb_define_const(mGdalconst, "CE_FATAL", SWIG_From_int((int)(CE_Fatal))); 2192 | rb_define_const(mGdalconst, "CPLE_NONE", SWIG_From_int((int)(CPLE_None))); 2193 | rb_define_const(mGdalconst, "CPLE_APPDEFINED", SWIG_From_int((int)(CPLE_AppDefined))); 2194 | rb_define_const(mGdalconst, "CPLE_OUTOFMEMORY", SWIG_From_int((int)(CPLE_OutOfMemory))); 2195 | rb_define_const(mGdalconst, "CPLE_FILEIO", SWIG_From_int((int)(CPLE_FileIO))); 2196 | rb_define_const(mGdalconst, "CPLE_OPENFAILED", SWIG_From_int((int)(CPLE_OpenFailed))); 2197 | rb_define_const(mGdalconst, "CPLE_ILLEGALARG", SWIG_From_int((int)(CPLE_IllegalArg))); 2198 | rb_define_const(mGdalconst, "CPLE_NOTSUPPORTED", SWIG_From_int((int)(CPLE_NotSupported))); 2199 | rb_define_const(mGdalconst, "CPLE_ASSERTIONFAILED", SWIG_From_int((int)(CPLE_AssertionFailed))); 2200 | rb_define_const(mGdalconst, "CPLE_NOWRITEACCESS", SWIG_From_int((int)(CPLE_NoWriteAccess))); 2201 | rb_define_const(mGdalconst, "CPLE_USERINTERRUPT", SWIG_From_int((int)(CPLE_UserInterrupt))); 2202 | rb_define_const(mGdalconst, "DMD_LONGNAME", SWIG_FromCharPtr(GDAL_DMD_LONGNAME)); 2203 | rb_define_const(mGdalconst, "DMD_HELPTOPIC", SWIG_FromCharPtr(GDAL_DMD_HELPTOPIC)); 2204 | rb_define_const(mGdalconst, "DMD_MIMETYPE", SWIG_FromCharPtr(GDAL_DMD_MIMETYPE)); 2205 | rb_define_const(mGdalconst, "DMD_EXTENSION", SWIG_FromCharPtr(GDAL_DMD_EXTENSION)); 2206 | rb_define_const(mGdalconst, "DMD_CREATIONOPTIONLIST", SWIG_FromCharPtr(GDAL_DMD_CREATIONOPTIONLIST)); 2207 | rb_define_const(mGdalconst, "DMD_CREATIONDATATYPES", SWIG_FromCharPtr(GDAL_DMD_CREATIONDATATYPES)); 2208 | rb_define_const(mGdalconst, "DMD_SUBDATASETS", SWIG_FromCharPtr(GDAL_DMD_SUBDATASETS)); 2209 | rb_define_const(mGdalconst, "DCAP_CREATE", SWIG_FromCharPtr(GDAL_DCAP_CREATE)); 2210 | rb_define_const(mGdalconst, "DCAP_CREATECOPY", SWIG_FromCharPtr(GDAL_DCAP_CREATECOPY)); 2211 | rb_define_const(mGdalconst, "DCAP_VIRTUALIO", SWIG_FromCharPtr(GDAL_DCAP_VIRTUALIO)); 2212 | rb_define_const(mGdalconst, "CPLES_BACKSLASHQUOTABLE", SWIG_From_int((int)(CPLES_BackslashQuotable))); 2213 | rb_define_const(mGdalconst, "CPLES_XML", SWIG_From_int((int)(CPLES_XML))); 2214 | rb_define_const(mGdalconst, "CPLES_URL", SWIG_From_int((int)(CPLES_URL))); 2215 | rb_define_const(mGdalconst, "CPLES_SQL", SWIG_From_int((int)(CPLES_SQL))); 2216 | rb_define_const(mGdalconst, "CPLES_CSV", SWIG_From_int((int)(CPLES_CSV))); 2217 | rb_define_const(mGdalconst, "GFT_INTEGER", SWIG_From_int((int)(GFT_Integer))); 2218 | rb_define_const(mGdalconst, "GFT_REAL", SWIG_From_int((int)(GFT_Real))); 2219 | rb_define_const(mGdalconst, "GFT_STRING", SWIG_From_int((int)(GFT_String))); 2220 | rb_define_const(mGdalconst, "GFU_GENERIC", SWIG_From_int((int)(GFU_Generic))); 2221 | rb_define_const(mGdalconst, "GFU_PIXELCOUNT", SWIG_From_int((int)(GFU_PixelCount))); 2222 | rb_define_const(mGdalconst, "GFU_NAME", SWIG_From_int((int)(GFU_Name))); 2223 | rb_define_const(mGdalconst, "GFU_MIN", SWIG_From_int((int)(GFU_Min))); 2224 | rb_define_const(mGdalconst, "GFU_MAX", SWIG_From_int((int)(GFU_Max))); 2225 | rb_define_const(mGdalconst, "GFU_MINMAX", SWIG_From_int((int)(GFU_MinMax))); 2226 | rb_define_const(mGdalconst, "GFU_RED", SWIG_From_int((int)(GFU_Red))); 2227 | rb_define_const(mGdalconst, "GFU_GREEN", SWIG_From_int((int)(GFU_Green))); 2228 | rb_define_const(mGdalconst, "GFU_BLUE", SWIG_From_int((int)(GFU_Blue))); 2229 | rb_define_const(mGdalconst, "GFU_ALPHA", SWIG_From_int((int)(GFU_Alpha))); 2230 | rb_define_const(mGdalconst, "GFU_REDMIN", SWIG_From_int((int)(GFU_RedMin))); 2231 | rb_define_const(mGdalconst, "GFU_GREENMIN", SWIG_From_int((int)(GFU_GreenMin))); 2232 | rb_define_const(mGdalconst, "GFU_BLUEMIN", SWIG_From_int((int)(GFU_BlueMin))); 2233 | rb_define_const(mGdalconst, "GFU_ALPHAMIN", SWIG_From_int((int)(GFU_AlphaMin))); 2234 | rb_define_const(mGdalconst, "GFU_REDMAX", SWIG_From_int((int)(GFU_RedMax))); 2235 | rb_define_const(mGdalconst, "GFU_GREENMAX", SWIG_From_int((int)(GFU_GreenMax))); 2236 | rb_define_const(mGdalconst, "GFU_BLUEMAX", SWIG_From_int((int)(GFU_BlueMax))); 2237 | rb_define_const(mGdalconst, "GFU_ALPHAMAX", SWIG_From_int((int)(GFU_AlphaMax))); 2238 | rb_define_const(mGdalconst, "GFU_MAXCOUNT", SWIG_From_int((int)(GFU_MaxCount))); 2239 | rb_define_const(mGdalconst, "GMF_ALL_VALID", SWIG_From_int((int)(0x01))); 2240 | rb_define_const(mGdalconst, "GMF_PER_DATASET", SWIG_From_int((int)(0x02))); 2241 | rb_define_const(mGdalconst, "GMF_ALPHA", SWIG_From_int((int)(0x04))); 2242 | rb_define_const(mGdalconst, "GMF_NODATA", SWIG_From_int((int)(0x08))); 2243 | rb_define_const(mGdalconst, "GARIO_PENDING", SWIG_From_int((int)(GARIO_PENDING))); 2244 | rb_define_const(mGdalconst, "GARIO_UPDATE", SWIG_From_int((int)(GARIO_UPDATE))); 2245 | rb_define_const(mGdalconst, "GARIO_ERROR", SWIG_From_int((int)(GARIO_ERROR))); 2246 | rb_define_const(mGdalconst, "GARIO_COMPLETE", SWIG_From_int((int)(GARIO_COMPLETE))); 2247 | } 2248 | 2249 | --------------------------------------------------------------------------------