From 4f8759cdf32ab9455d7695cdfe344e2f55faa6ac Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Thu, 10 Jun 2010 22:42:33 -0500 Subject: [PATCH] Update vendored Sqlite3-ruby to 1.3.0 Also, some tweaks to Maruku. --- .../ext/math/mathml_engines/itex2mml.rb | 4 +- .../maruku/ext/math/mathml_engines/none.rb | 10 +- vendor/plugins/sqlite3-ruby/API_CHANGES.rdoc | 48 + vendor/plugins/sqlite3-ruby/CHANGELOG.rdoc | 92 + vendor/plugins/sqlite3-ruby/History.txt | 68 - vendor/plugins/sqlite3-ruby/Manifest.txt | 29 +- vendor/plugins/sqlite3-ruby/README.rdoc | 19 +- vendor/plugins/sqlite3-ruby/README.txt | 56 - vendor/plugins/sqlite3-ruby/Rakefile | 11 +- .../sqlite3-ruby/ext/sqlite3/database.c | 693 +++ .../sqlite3-ruby/ext/sqlite3/database.h | 15 + .../sqlite3-ruby/ext/sqlite3/exception.c | 94 + .../sqlite3-ruby/ext/sqlite3/exception.h | 8 + .../sqlite3-ruby/ext/sqlite3/extconf.rb | 39 + .../sqlite3-ruby/ext/sqlite3/sqlite3.c | 33 + .../sqlite3-ruby/ext/sqlite3/sqlite3_ruby.h | 43 + .../sqlite3-ruby/ext/sqlite3/statement.c | 419 ++ .../sqlite3-ruby/ext/sqlite3/statement.h | 16 + .../sqlite3-ruby/ext/sqlite3_api/MANIFEST | 4 - .../sqlite3-ruby/ext/sqlite3_api/Makefile | 146 - .../sqlite3-ruby/ext/sqlite3_api/extconf.rb | 10 - .../sqlite3-ruby/ext/sqlite3_api/mkmf.log | 71 - .../ext/sqlite3_api/sqlite3_api.i | 362 -- .../ext/sqlite3_api/sqlite3_api_wrap.c | 5018 ----------------- .../ext/sqlite3_api/win32/build.bat | 7 - vendor/plugins/sqlite3-ruby/faq/faq.rb | 145 + vendor/plugins/sqlite3-ruby/faq/faq.yml | 426 ++ vendor/plugins/sqlite3-ruby/lib/sqlite3.rb | 9 + .../sqlite3-ruby/lib/sqlite3/database.rb | 465 +- .../sqlite3-ruby/lib/sqlite3/driver/dl/api.rb | 152 - .../lib/sqlite3/driver/dl/driver.rb | 307 - .../lib/sqlite3/driver/native/driver.rb | 219 - .../sqlite3-ruby/lib/sqlite3/errors.rb | 24 - .../sqlite3-ruby/lib/sqlite3/pragmas.rb | 23 +- .../sqlite3-ruby/lib/sqlite3/resultset.rb | 106 +- .../sqlite3-ruby/lib/sqlite3/statement.rb | 129 +- .../sqlite3-ruby/lib/sqlite3/translator.rb | 7 +- .../sqlite3-ruby/lib/sqlite3/version.rb | 6 +- vendor/plugins/sqlite3-ruby/setup.rb | 4 +- .../plugins/sqlite3-ruby/sqlite3-ruby.gemspec | 141 - vendor/plugins/sqlite3-ruby/test/bm.rb | 140 - .../sqlite3-ruby/test/driver/dl/tc_driver.rb | 292 - vendor/plugins/sqlite3-ruby/test/helper.rb | 66 +- .../plugins/sqlite3-ruby/test/native-vs-dl.rb | 126 - .../sqlite3-ruby/test/test_database.rb | 496 +- .../sqlite3-ruby/test/test_deprecated.rb | 25 + .../sqlite3-ruby/test/test_encoding.rb | 115 + .../plugins/sqlite3-ruby/test/test_errors.rb | 17 - .../sqlite3-ruby/test/test_integration.rb | 73 +- .../test/test_integration_open_close.rb | 2 +- .../test/test_integration_pending.rb | 10 +- .../test/test_integration_resultset.rb | 40 +- .../test/test_integration_statement.rb | 3 +- .../plugins/sqlite3-ruby/test/test_sqlite3.rb | 9 + .../sqlite3-ruby/test/test_statement.rb | 207 + 55 files changed, 3071 insertions(+), 8028 deletions(-) create mode 100644 vendor/plugins/sqlite3-ruby/API_CHANGES.rdoc delete mode 100644 vendor/plugins/sqlite3-ruby/History.txt delete mode 100644 vendor/plugins/sqlite3-ruby/README.txt create mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3/database.c create mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3/database.h create mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3/exception.c create mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3/exception.h create mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3/extconf.rb create mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3/sqlite3.c create mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3/sqlite3_ruby.h create mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3/statement.c create mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3/statement.h delete mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3_api/MANIFEST delete mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3_api/Makefile delete mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3_api/extconf.rb delete mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3_api/mkmf.log delete mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3_api/sqlite3_api.i delete mode 100644 vendor/plugins/sqlite3-ruby/ext/sqlite3_api/sqlite3_api_wrap.c delete mode 100755 vendor/plugins/sqlite3-ruby/ext/sqlite3_api/win32/build.bat create mode 100644 vendor/plugins/sqlite3-ruby/faq/faq.rb create mode 100644 vendor/plugins/sqlite3-ruby/faq/faq.yml delete mode 100644 vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/dl/api.rb delete mode 100644 vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/dl/driver.rb delete mode 100644 vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/native/driver.rb delete mode 100644 vendor/plugins/sqlite3-ruby/sqlite3-ruby.gemspec delete mode 100644 vendor/plugins/sqlite3-ruby/test/bm.rb delete mode 100644 vendor/plugins/sqlite3-ruby/test/driver/dl/tc_driver.rb delete mode 100644 vendor/plugins/sqlite3-ruby/test/native-vs-dl.rb create mode 100644 vendor/plugins/sqlite3-ruby/test/test_deprecated.rb create mode 100644 vendor/plugins/sqlite3-ruby/test/test_encoding.rb delete mode 100644 vendor/plugins/sqlite3-ruby/test/test_errors.rb create mode 100644 vendor/plugins/sqlite3-ruby/test/test_sqlite3.rb create mode 100644 vendor/plugins/sqlite3-ruby/test/test_statement.rb diff --git a/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/itex2mml.rb b/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/itex2mml.rb index 9c45f24d..b17d8e4f 100644 --- a/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/itex2mml.rb +++ b/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/itex2mml.rb @@ -11,9 +11,9 @@ module MaRuKu return nil end begin - require 'itex_stringsupport' - rescue LoadError require 'instiki_stringsupport' + rescue LoadError + require 'itex_stringsupport' end parser = Itex2MML::Parser.new diff --git a/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/none.rb b/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/none.rb index ce25b5c4..bec8283b 100644 --- a/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/none.rb +++ b/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/none.rb @@ -6,13 +6,9 @@ module MaRuKu; module Out; module HTML # or return an empty array on error # return [] # or have a string parsed by REXML: - begin - require 'itex_stringsupport' - rescue LoadError - require 'instiki_stringsupport' - end - tex = tex.escapeHTML - mathml = "#{tex}" + mathml = "#{tex.gsub( /&/, "&" ). + gsub( //, ">" ). + gsub(/'/, "'" ).gsub(/"/, """ )}" return Document.new(mathml).root end diff --git a/vendor/plugins/sqlite3-ruby/API_CHANGES.rdoc b/vendor/plugins/sqlite3-ruby/API_CHANGES.rdoc new file mode 100644 index 00000000..8ca51e67 --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/API_CHANGES.rdoc @@ -0,0 +1,48 @@ += API Changes + +* SQLite3::ResultSet used to query the database for the first row, regardless + of whether the user asked for it or not. I have removed that so that rows + will not be returned until the user asks for them. This is a subtle but + sometimes important change in behavior. + + 83882d2208ed189361617d5ab8532a325aaf729d + +* SQLite3::Database#trace now takes either a block or an object that responds + to "call". The previous implementation passed around a VALUE that was cast + to a void *. This is dangerous because the value could get garbage collected + before the proc was called. If the user wants data passed around with the + block, they should use variables available to the closure or create an + object. + +* SQLite3::Statement#step automatically converts to ruby types, where before + all values were automatically yielded as strings. This will only be a + problem for people who were accessing information about the database that + wasn't previously passed through the pure ruby conversion code. + +* SQLite3::Database#errmsg no longer takes a parameter to return error + messages as UTF-16. Do people even use that? I opt for staying UTF-8 when + possible. See test_integration.rb test_errmsg_utf16 + +* SQLite3::Database#authorize same changes as trace + +* test/test_tc_database.rb was removed because we no longer use the Driver + design pattern. + += Garbage Collection Strategy + +All statements keep pointers back to their respective database connections. +The @connection instance variable on the Statement handle keeps the database +connection alive. Memory allocated for a statement handler will be freed in +two cases: + +* close is called on the statement +* The SQLite3::Database object gets garbage collected + +We can't free the memory for the statement in the garbage collection function +for the statement handler. The reason is because there exists a race +condition. We cannot guarantee the order in which objects will be garbage +collected. So, it is possible that a connection and a statement are up for +garbage collection. If the database connection were to be free'd before the +statement, then boom. Instead we'll be conservative and free unclosed +statements when the connection is terminated. + diff --git a/vendor/plugins/sqlite3-ruby/CHANGELOG.rdoc b/vendor/plugins/sqlite3-ruby/CHANGELOG.rdoc index 49cf1b21..785aa934 100644 --- a/vendor/plugins/sqlite3-ruby/CHANGELOG.rdoc +++ b/vendor/plugins/sqlite3-ruby/CHANGELOG.rdoc @@ -1,3 +1,95 @@ +=== 1.3.0 / 2010-06-06 + +* Enhancements + * Complete rewrite of C-based adapter from SWIG to hand-crafted one [tenderlove] + See API_CHANGES document for details. + This closes: Bug #27300, Bug #27241, Patch #16020 + * Improved UTF, Unicode, M17N, all that handling and proper BLOB handling [tenderlove, nurse] + * Added support for type translations [tenderlove] + + @db.translator.add_translator('sometime') do |type, thing| + 'output' # this will be returned as value for that column + end + +* Experimental + * Added API to access and load extensions. [kashif] + These functions maps directly into SQLite3 own enable_load_extension() + and load_extension() C-API functions. See SQLite3::Database API documentation for details. + This closes: Patches #9178 + +* Bugfixes + * Corrected gem dependencies (runtime and development) + * Fixed threaded tests [Alexey Borzenkov] + * Removed GitHub gemspec + * Fixed "No definition for" warnings from RDoc + * Generate zip and tgz files for releases + * Added Luis Lavena as gem Author (maintainer) + * Prevent mkmf interfere with Mighty Snow Leopard + * Allow extension compilation search for common lib paths [kashif] + (lookup /usr/local, /opt/local and /usr) + * Corrected extension compilation under MSVC [romuloceccon] + * Define load_extension functionality based on availability [tenderlove] + * Deprecation notices for Database#query. Fixes RF #28192 + +=== 1.3.0.beta.2 / 2010-05-15 + +* Enhancements + * Added support for type translations [tenderlove] + + @db.translator.add_translator('sometime') do |type, thing| + 'output' # this will be returned as value for that column + end + +* Bugfixes + * Allow extension compilation search for common lib paths [kashif] + (lookup /usr/local, /opt/local and /usr) + * Corrected extension compilation under MSVC [romuloceccon] + * Define load_extension functionality based on availability [tenderlove] + * Deprecation notices for Database#query. Fixes RF #28192 + +=== 1.3.0.beta.1 / 2010-05-10 + +* Enhancements + * Complete rewrite of C-based adapter from SWIG to hand-crafted one [tenderlove] + See API_CHANGES document for details. + This closes: Bug #27300, Bug #27241, Patch #16020 + * Improved UTF, Unicode, M17N, all that handling and proper BLOB handling [tenderlove, nurse] + +* Experimental + * Added API to access and load extensions. [kashif] + These functions maps directly into SQLite3 own enable_load_extension() + and load_extension() C-API functions. See SQLite3::Database API documentation for details. + This closes: Patches #9178 + +* Bugfixes + * Corrected gem dependencies (runtime and development) + * Fixed threaded tests [Alexey Borzenkov] + * Removed GitHub gemspec + * Fixed "No definition for" warnings from RDoc + * Generate zip and tgz files for releases + * Added Luis Lavena as gem Author (maintainer) + * Prevent mkmf interfere with Mighty Snow Leopard + +=== 1.2.5 / 25 Jul 2009 + +* Check for illegal nil before executing SQL [Erik Veenstra] +* Switch to Hoe for gem task management and packaging. +* Advertise rake-compiler as development dependency. +* Build gem binaries for Windows. +* Improved Ruby 1.9 support compatibility. +* Taint returned values. Patch #20325. +* Database.open and Database.new now take an optional block [Gerrit Kaiser] + + +=== 1.2.4.1 (internal) / 5 Jul 2009 + +* Check for illegal nil before executing SQL [Erik Veenstra] +* Switch to Hoe for gem task management and packaging. +* Advertise rake-compiler as development dependency. +* Build gem binaries for Windows. +* Improved Ruby 1.9 support compatibility. + + === 1.2.4 / 27 Aug 2008 * Package the updated C file for source builds. [Jamis Buck] diff --git a/vendor/plugins/sqlite3-ruby/History.txt b/vendor/plugins/sqlite3-ruby/History.txt deleted file mode 100644 index 21372fb6..00000000 --- a/vendor/plugins/sqlite3-ruby/History.txt +++ /dev/null @@ -1,68 +0,0 @@ -=== 1.2.5 / 25 Jul 2009 - -* Check for illegal nil before executing SQL [Erik Veenstra] -* Switch to Hoe for gem task management and packaging. -* Advertise rake-compiler as development dependency. -* Build gem binaries for Windows. -* Improved Ruby 1.9 support compatibility. -* Taint returned values. Patch #20325. - - -=== 1.2.4.1 (internal) / 5 Jul 2009 - -* Check for illegal nil before executing SQL [Erik Veenstra] -* Switch to Hoe for gem task management and packaging. -* Advertise rake-compiler as development dependency. -* Build gem binaries for Windows. -* Improved Ruby 1.9 support compatibility. - - -=== 1.2.4 / 27 Aug 2008 - -* Package the updated C file for source builds. [Jamis Buck] - - -=== 1.2.3 / 26 Aug 2008 - -* Fix incorrect permissions on database.rb and translator.rb [Various] - -* Avoid using Object#extend for greater speedups [Erik Veenstra] - -* Ruby 1.9 compatibility tweaks for Array#zip [jimmy88@gmail.com] - -* Fix linking against Ruby 1.8.5 [Rob Holland ] - - -=== 1.2.2 / 31 May 2008 - -* Make the table_info method adjust the returned default value for the rows - so that the sqlite3 change in 3.3.8 and greater can be handled - transparently [Jamis Buck ] - -* Ruby 1.9 compatibility tweaks [Roman Le Negrate ] - -* Various performance enhancements [thanks Erik Veenstra] - -* Correct busy_handler documentation [Rob Holland ] - -* Use int_bind64 on Fixnum values larger than a 32bit C int can take. [Rob Holland ] - -* Work around a quirk in SQLite's error reporting by calling sqlite3_reset - to produce a more informative error code upon a failure from - sqlite3_step. [Rob Holland ] - -* Various documentation, test, and style tweaks [Rob Holland ] - -* Be more granular with time/data translation [Rob Holland ] - -* Use Date directly for parsing rather than going via Time [Rob Holland ] - -* Check for the rt library and fdatasync so we link against that when - needed [Rob Holland ] - -* Rename data structures to avoid collision on win32. based on patch - by: Luis Lavena [Rob Holland ] - -* Add test for defaults [Daniel Rodríguez Troitiño] - -* Correctly unquote double-quoted pragma defaults [Łukasz Dargiewicz ] diff --git a/vendor/plugins/sqlite3-ruby/Manifest.txt b/vendor/plugins/sqlite3-ruby/Manifest.txt index 28e2660a..37383f03 100644 --- a/vendor/plugins/sqlite3-ruby/Manifest.txt +++ b/vendor/plugins/sqlite3-ruby/Manifest.txt @@ -1,20 +1,24 @@ +API_CHANGES.rdoc +CHANGELOG.rdoc ChangeLog.cvs -History.txt LICENSE Manifest.txt -README.txt +README.rdoc Rakefile -ext/sqlite3_api/extconf.rb -ext/sqlite3_api/sqlite3_api.i -ext/sqlite3_api/sqlite3_api_wrap.c +ext/sqlite3/database.c +ext/sqlite3/database.h +ext/sqlite3/exception.c +ext/sqlite3/exception.h +ext/sqlite3/extconf.rb +ext/sqlite3/sqlite3.c +ext/sqlite3/sqlite3_ruby.h +ext/sqlite3/statement.c +ext/sqlite3/statement.h faq/faq.rb faq/faq.yml lib/sqlite3.rb lib/sqlite3/constants.rb lib/sqlite3/database.rb -lib/sqlite3/driver/dl/api.rb -lib/sqlite3/driver/dl/driver.rb -lib/sqlite3/driver/native/driver.rb lib/sqlite3/errors.rb lib/sqlite3/pragmas.rb lib/sqlite3/resultset.rb @@ -23,19 +27,18 @@ lib/sqlite3/translator.rb lib/sqlite3/value.rb lib/sqlite3/version.rb setup.rb -tasks/benchmark.rake tasks/faq.rake tasks/gem.rake tasks/native.rake tasks/vendor_sqlite3.rake -test/bm.rb -test/driver/dl/tc_driver.rb test/helper.rb -test/native-vs-dl.rb test/test_database.rb -test/test_errors.rb +test/test_deprecated.rb +test/test_encoding.rb test/test_integration.rb test/test_integration_open_close.rb test/test_integration_pending.rb test/test_integration_resultset.rb test/test_integration_statement.rb +test/test_sqlite3.rb +test/test_statement.rb diff --git a/vendor/plugins/sqlite3-ruby/README.rdoc b/vendor/plugins/sqlite3-ruby/README.rdoc index 5b8eecea..3d54ed53 100644 --- a/vendor/plugins/sqlite3-ruby/README.rdoc +++ b/vendor/plugins/sqlite3-ruby/README.rdoc @@ -1,15 +1,23 @@ = SQLite3/Ruby Interface +* http://github.com/luislavena/sqlite3-ruby +* http://rubyforge.org/projects/sqlite-ruby +* http://sqlite-ruby.rubyforge.org + +== DESCRIPTION + This module allows Ruby programs to interface with the SQLite3 database engine (http://www.sqlite.org). You must have the SQLite engine installed in order to build this module. Note that this module is NOT compatible with SQLite 2.x. - == Compilation and Installation -Simply do the following, after installing SQLite3: +Install SQLite3, enabling option SQLITE_ENABLE_COLUMN_METADATA (see +www.sqlite.org/compile.html for details). + +Then do the following: ruby setup.rb config ruby setup.rb setup @@ -25,11 +33,6 @@ If you have sqlite3 installed in a non-standard location, you can specify the lo gem install sqlite3-ruby -- --with-sqlite3-include=/opt/local/include \ --with-sqlite3-lib=/opt/local/lib -Also, the gem ships with the C source-code pre-built, so (as of version 1.1.1) -you no longer need to have SWIG installed. However, if you have SWIG installed -and you want to generate the C file yourself, you can specify the ---with-swig option. - == Usage For help figuring out the SQLite3/Ruby interface, check out the @@ -41,7 +44,7 @@ FAQ, please send them to jamis@37signals.com The source repository is accessible via git: - git clone git://github.com/jamis/sqlite3-ruby.git + git clone git://github.com/luislavena/sqlite3-ruby.git == Contact Information diff --git a/vendor/plugins/sqlite3-ruby/README.txt b/vendor/plugins/sqlite3-ruby/README.txt deleted file mode 100644 index 897a648d..00000000 --- a/vendor/plugins/sqlite3-ruby/README.txt +++ /dev/null @@ -1,56 +0,0 @@ -= SQLite3/Ruby Interface - -* http://sqlite3-ruby.rubyforge.org -* http://rubyforge.org/projects/sqlite3-ruby -* http://github.com/jamis/sqlite3-ruby - -== DESCRIPTION - -This module allows Ruby programs to interface with the SQLite3 -database engine (http://www.sqlite.org). You must have the -SQLite engine installed in order to build this module. - -Note that this module is NOT compatible with SQLite 2.x. - -== Compilation and Installation - -Simply do the following, after installing SQLite3: - - ruby setup.rb config - ruby setup.rb setup - ruby setup.rb install - -Alternatively, you can download and install the RubyGem package for -SQLite3/Ruby (you must have RubyGems and SQLite3 installed, first): - - gem install sqlite3-ruby - -If you have sqlite3 installed in a non-standard location, you can specify the location of the include and lib files by doing: - - gem install sqlite3-ruby -- --with-sqlite3-include=/opt/local/include \ - --with-sqlite3-lib=/opt/local/lib - -Also, the gem ships with the C source-code pre-built, so (as of version 1.1.1) -you no longer need to have SWIG installed. However, if you have SWIG installed -and you want to generate the C file yourself, you can specify the ---with-swig option. - -== Usage - -For help figuring out the SQLite3/Ruby interface, check out the -FAQ[http://sqlite-ruby.rubyforge.org/sqlite3/faq.html]. It includes examples of -usage. If you have any questions that you feel should be address in the -FAQ, please send them to jamis@37signals.com - -== Source Code - -The source repository is accessible via git: - - git clone git://github.com/jamis/sqlite3-ruby.git - -== Contact Information - -The project page is http://rubyforge.org/projects/sqlite-ruby. There, you can -find links to mailing lists and forums that you can use to discuss this -library. Additionally, there are trackers for submitting bugs and feature -requests. Feel free to use them! diff --git a/vendor/plugins/sqlite3-ruby/Rakefile b/vendor/plugins/sqlite3-ruby/Rakefile index 744f6130..7c5f784c 100644 --- a/vendor/plugins/sqlite3-ruby/Rakefile +++ b/vendor/plugins/sqlite3-ruby/Rakefile @@ -1,5 +1,10 @@ -require 'rubygems' -require 'rake' +# +# NOTE: Keep this file clean. +# Add your customizations inside tasks directory. +# Thank You. +# # load rakefile extensions (tasks) -Dir['tasks/*.rake'].each { |f| import f } +Dir['tasks/*.rake'].sort.each { |f| load f } + +# vim: syntax=ruby diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3/database.c b/vendor/plugins/sqlite3-ruby/ext/sqlite3/database.c new file mode 100644 index 00000000..4382f80d --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/ext/sqlite3/database.c @@ -0,0 +1,693 @@ +#include + +#define REQUIRE_OPEN_DB(_ctxt) \ + if(!_ctxt->db) \ + rb_raise(rb_path2class("SQLite3::Exception"), "cannot use a closed database"); + +VALUE cSqlite3Database; +static VALUE sym_utf16, sym_results_as_hash, sym_type_translation; + +static void deallocate(void * ctx) +{ + sqlite3RubyPtr c = (sqlite3RubyPtr)ctx; + sqlite3 * db = c->db; + sqlite3_stmt * stmt; + + if(db) { + while((stmt = sqlite3_next_stmt(db, NULL)) != NULL) { + sqlite3_finalize(stmt); + } + sqlite3_close(db); + } + xfree(c); +} + +static VALUE allocate(VALUE klass) +{ + sqlite3RubyPtr ctx = xcalloc((size_t)1, sizeof(sqlite3Ruby)); + return Data_Wrap_Struct(klass, NULL, deallocate, ctx); +} + +static char * +utf16_string_value_ptr(VALUE str) +{ + StringValue(str); + rb_str_buf_cat(str, "\x00", 1L); + return RSTRING_PTR(str); +} + +/* call-seq: SQLite3::Database.new(file, options = {}) + * + * Create a new Database object that opens the given file. If utf16 + * is +true+, the filename is interpreted as a UTF-16 encoded string. + * + * By default, the new database will return result rows as arrays + * (#results_as_hash) and has type translation disabled (#type_translation=). + */ +static VALUE initialize(int argc, VALUE *argv, VALUE self) +{ + sqlite3RubyPtr ctx; + VALUE file; + VALUE opts; + VALUE zvfs; + int status; + + Data_Get_Struct(self, sqlite3Ruby, ctx); + + rb_scan_args(argc, argv, "12", &file, &opts, &zvfs); + if(NIL_P(opts)) opts = rb_hash_new(); + +#ifdef HAVE_RUBY_ENCODING_H + if(UTF16_LE_P(file)) { + status = sqlite3_open16(utf16_string_value_ptr(file), &ctx->db); + } else { +#endif + + if(Qtrue == rb_hash_aref(opts, sym_utf16)) { + status = sqlite3_open16(utf16_string_value_ptr(file), &ctx->db); + } else { + +#ifdef HAVE_RUBY_ENCODING_H + if(!UTF8_P(file)) { + file = rb_str_export_to_enc(file, rb_utf8_encoding()); + } +#endif + + status = sqlite3_open_v2( + StringValuePtr(file), + &ctx->db, + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, + NIL_P(zvfs) ? NULL : StringValuePtr(zvfs) + ); + } + +#ifdef HAVE_RUBY_ENCODING_H + } +#endif + + CHECK(ctx->db, status) + + rb_iv_set(self, "@tracefunc", Qnil); + rb_iv_set(self, "@authorizer", Qnil); + rb_iv_set(self, "@encoding", Qnil); + rb_iv_set(self, "@busy_handler", Qnil); + rb_iv_set(self, "@results_as_hash", rb_hash_aref(opts, sym_results_as_hash)); + rb_iv_set(self, "@type_translation", rb_hash_aref(opts, sym_type_translation)); + + if(rb_block_given_p()) { + rb_yield(self); + rb_funcall(self, rb_intern("close"), 0); + } + + return self; +} + +/* call-seq: db.close + * + * Closes this database. + */ +static VALUE sqlite3_rb_close(VALUE self) +{ + sqlite3RubyPtr ctx; + sqlite3 * db; + Data_Get_Struct(self, sqlite3Ruby, ctx); + + db = ctx->db; + CHECK(db, sqlite3_close(ctx->db)); + + ctx->db = NULL; + + return self; +} + +/* call-seq: db.closed? + * + * Returns +true+ if this database instance has been closed (see #close). + */ +static VALUE closed_p(VALUE self) +{ + sqlite3RubyPtr ctx; + Data_Get_Struct(self, sqlite3Ruby, ctx); + + if(!ctx->db) return Qtrue; + + return Qfalse; +} + +/* call-seq: total_changes + * + * Returns the total number of changes made to this database instance + * since it was opened. + */ +static VALUE total_changes(VALUE self) +{ + sqlite3RubyPtr ctx; + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + return INT2NUM((long)sqlite3_total_changes(ctx->db)); +} + +static void tracefunc(void * data, const char *sql) +{ + VALUE self = (VALUE)data; + VALUE thing = rb_iv_get(self, "@tracefunc"); + rb_funcall(thing, rb_intern("call"), 1, rb_str_new2(sql)); +} + +/* call-seq: + * trace { |sql| ... } + * trace(Class.new { def call sql; end }.new) + * + * Installs (or removes) a block that will be invoked for every SQL + * statement executed. The block receives one parameter: the SQL statement + * executed. If the block is +nil+, any existing tracer will be uninstalled. + */ +static VALUE trace(int argc, VALUE *argv, VALUE self) +{ + sqlite3RubyPtr ctx; + VALUE block; + + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + rb_scan_args(argc, argv, "01", &block); + + if(NIL_P(block) && rb_block_given_p()) block = rb_block_proc(); + + rb_iv_set(self, "@tracefunc", block); + + sqlite3_trace(ctx->db, NIL_P(block) ? NULL : tracefunc, (void *)self); + + return self; +} + +static int rb_sqlite3_busy_handler(void * ctx, int count) +{ + VALUE self = (VALUE)(ctx); + VALUE handle = rb_iv_get(self, "@busy_handler"); + VALUE result = rb_funcall(handle, rb_intern("call"), 1, INT2NUM((long)count)); + + if(Qfalse == result) return 0; + + return 1; +} + +/* call-seq: + * busy_handler { |count| ... } + * busy_handler(Class.new { def call count; end }.new) + * + * Register a busy handler with this database instance. When a requested + * resource is busy, this handler will be invoked. If the handler returns + * +false+, the operation will be aborted; otherwise, the resource will + * be requested again. + * + * The handler will be invoked with the name of the resource that was + * busy, and the number of times it has been retried. + * + * See also the mutually exclusive #busy_timeout. + */ +static VALUE busy_handler(int argc, VALUE *argv, VALUE self) +{ + sqlite3RubyPtr ctx; + VALUE block; + int status; + + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + rb_scan_args(argc, argv, "01", &block); + + if(NIL_P(block) && rb_block_given_p()) block = rb_block_proc(); + + rb_iv_set(self, "@busy_handler", block); + + status = sqlite3_busy_handler( + ctx->db, NIL_P(block) ? NULL : rb_sqlite3_busy_handler, (void *)self); + + CHECK(ctx->db, status); + + return self; +} + +/* call-seq: last_insert_row_id + * + * Obtains the unique row ID of the last row to be inserted by this Database + * instance. + */ +static VALUE last_insert_row_id(VALUE self) +{ + sqlite3RubyPtr ctx; + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + return LL2NUM(sqlite3_last_insert_rowid(ctx->db)); +} + +static VALUE sqlite3val2rb(sqlite3_value * val) +{ + switch(sqlite3_value_type(val)) { + case SQLITE_INTEGER: + return LL2NUM(sqlite3_value_int64(val)); + break; + case SQLITE_FLOAT: + return rb_float_new(sqlite3_value_double(val)); + break; + case SQLITE_TEXT: + return rb_tainted_str_new2((const char *)sqlite3_value_text(val)); + break; + case SQLITE_BLOB: + return rb_tainted_str_new2((const char *)sqlite3_value_blob(val)); + break; + case SQLITE_NULL: + return Qnil; + break; + default: + rb_raise(rb_eRuntimeError, "bad type"); /* FIXME */ + } +} + +static void set_sqlite3_func_result(sqlite3_context * ctx, VALUE result) +{ + switch(TYPE(result)) { + case T_NIL: + sqlite3_result_null(ctx); + break; + case T_FIXNUM: + sqlite3_result_int64(ctx, (sqlite3_int64)FIX2LONG(result)); + break; + case T_BIGNUM: +#if SIZEOF_LONG < 8 + if (RBIGNUM_LEN(result) * SIZEOF_BDIGITS <= 8) { + sqlite3_result_int64(ctx, NUM2LL(result)); + break; + } +#endif + case T_FLOAT: + sqlite3_result_double(ctx, NUM2DBL(result)); + break; + case T_STRING: + sqlite3_result_text( + ctx, + (const char *)StringValuePtr(result), + (int)RSTRING_LEN(result), + SQLITE_TRANSIENT + ); + break; + default: + rb_raise(rb_eRuntimeError, "can't return %s", + rb_class2name(CLASS_OF(result))); + } +} + +static void rb_sqlite3_func(sqlite3_context * ctx, int argc, sqlite3_value **argv) +{ + VALUE callable = (VALUE)sqlite3_user_data(ctx); + VALUE * params = NULL; + VALUE result; + int i; + + if (argc > 0) { + params = xcalloc((size_t)argc, sizeof(VALUE *)); + + for(i = 0; i < argc; i++) { + params[i] = sqlite3val2rb(argv[i]); + } + } + + result = rb_funcall2(callable, rb_intern("call"), argc, params); + xfree(params); + + set_sqlite3_func_result(ctx, result); +} + +#ifndef HAVE_RB_PROC_ARITY +int rb_proc_arity(VALUE self) +{ + return (int)NUM2INT(rb_funcall(self, rb_intern("arity"), 0)); +} +#endif + +/* call-seq: define_function(name) { |args,...| } + * + * Define a function named +name+ with +args+. The arity of the block + * will be used as the arity for the function defined. + */ +static VALUE define_function(VALUE self, VALUE name) +{ + sqlite3RubyPtr ctx; + VALUE block; + int status; + + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + block = rb_block_proc(); + + status = sqlite3_create_function( + ctx->db, + StringValuePtr(name), + rb_proc_arity(block), + SQLITE_UTF8, + (void *)block, + rb_sqlite3_func, + NULL, + NULL + ); + + CHECK(ctx->db, status); + + return self; +} + +static int sqlite3_obj_method_arity(VALUE obj, ID id) +{ + VALUE method = rb_funcall(obj, rb_intern("method"), 1, ID2SYM(id)); + VALUE arity = rb_funcall(method, rb_intern("arity"), 0); + + return (int)NUM2INT(arity); +} + +static void rb_sqlite3_step(sqlite3_context * ctx, int argc, sqlite3_value **argv) +{ + VALUE callable = (VALUE)sqlite3_user_data(ctx); + VALUE * params = NULL; + int i; + + if (argc > 0) { + params = xcalloc((size_t)argc, sizeof(VALUE *)); + for(i = 0; i < argc; i++) { + params[i] = sqlite3val2rb(argv[i]); + } + } + rb_funcall2(callable, rb_intern("step"), argc, params); + xfree(params); +} + +static void rb_sqlite3_final(sqlite3_context * ctx) +{ + VALUE callable = (VALUE)sqlite3_user_data(ctx); + VALUE result = rb_funcall(callable, rb_intern("finalize"), 0); + set_sqlite3_func_result(ctx, result); +} + +/* call-seq: define_aggregator(name, aggregator) + * + * Define an aggregate function named +name+ using the object +aggregator+. + * +aggregator+ must respond to +step+ and +finalize+. +step+ will be called + * with row information and +finalize+ must return the return value for the + * aggregator function. + */ +static VALUE define_aggregator(VALUE self, VALUE name, VALUE aggregator) +{ + sqlite3RubyPtr ctx; + int arity, status; + + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + arity = sqlite3_obj_method_arity(aggregator, rb_intern("step")); + + status = sqlite3_create_function( + ctx->db, + StringValuePtr(name), + arity, + SQLITE_UTF8, + (void *)aggregator, + NULL, + rb_sqlite3_step, + rb_sqlite3_final + ); + + rb_iv_set(self, "@agregator", aggregator); + + CHECK(ctx->db, status); + + return self; +} + +/* call-seq: interrupt + * + * Interrupts the currently executing operation, causing it to abort. + */ +static VALUE interrupt(VALUE self) +{ + sqlite3RubyPtr ctx; + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + sqlite3_interrupt(ctx->db); + + return self; +} + +/* call-seq: errmsg + * + * Return a string describing the last error to have occurred with this + * database. + */ +static VALUE errmsg(VALUE self) +{ + sqlite3RubyPtr ctx; + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + return rb_str_new2(sqlite3_errmsg(ctx->db)); +} + +/* call-seq: errcode + * + * Return an integer representing the last error to have occurred with this + * database. + */ +static VALUE errcode_(VALUE self) +{ + sqlite3RubyPtr ctx; + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + return INT2NUM((long)sqlite3_errcode(ctx->db)); +} + +/* call-seq: complete?(sql) + * + * Return +true+ if the string is a valid (ie, parsable) SQL statement, and + * +false+ otherwise. + */ +static VALUE complete_p(VALUE UNUSED(self), VALUE sql) +{ + if(sqlite3_complete(StringValuePtr(sql))) + return Qtrue; + + return Qfalse; +} + +/* call-seq: changes + * + * Returns the number of changes made to this database instance by the last + * operation performed. Note that a "delete from table" without a where + * clause will not affect this value. + */ +static VALUE changes(VALUE self) +{ + sqlite3RubyPtr ctx; + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + return INT2NUM(sqlite3_changes(ctx->db)); +} + +static int rb_sqlite3_auth( + void *ctx, + int _action, + const char * _a, + const char * _b, + const char * _c, + const char * _d) +{ + VALUE self = (VALUE)ctx; + VALUE action = INT2NUM(_action); + VALUE a = _a ? rb_str_new2(_a) : Qnil; + VALUE b = _b ? rb_str_new2(_b) : Qnil; + VALUE c = _c ? rb_str_new2(_c) : Qnil; + VALUE d = _d ? rb_str_new2(_d) : Qnil; + VALUE callback = rb_iv_get(self, "@authorizer"); + VALUE result = rb_funcall(callback, rb_intern("call"), 5, action, a, b, c, d); + + if(T_FIXNUM == TYPE(result)) return (int)NUM2INT(result); + if(Qtrue == result) return SQLITE_OK; + if(Qfalse == result) return SQLITE_DENY; + + return SQLITE_IGNORE; +} + +/* call-seq: set_authorizer = auth + * + * Set the authorizer for this database. +auth+ must respond to +call+, and + * +call+ must take 5 arguments. + * + * Installs (or removes) a block that will be invoked for every access + * to the database. If the block returns 0 (or +true+), the statement + * is allowed to proceed. Returning 1 or false causes an authorization error to + * occur, and returning 2 or nil causes the access to be silently denied. + */ +static VALUE set_authorizer(VALUE self, VALUE authorizer) +{ + sqlite3RubyPtr ctx; + int status; + + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + status = sqlite3_set_authorizer( + ctx->db, NIL_P(authorizer) ? NULL : rb_sqlite3_auth, (void *)self + ); + + CHECK(ctx->db, status); + + rb_iv_set(self, "@authorizer", authorizer); + + return self; +} + +/* call-seq: db.busy_timeout = ms + * + * Indicates that if a request for a resource terminates because that + * resource is busy, SQLite should sleep and retry for up to the indicated + * number of milliseconds. By default, SQLite does not retry + * busy resources. To restore the default behavior, send 0 as the + * +ms+ parameter. + * + * See also the mutually exclusive #busy_handler. + */ +static VALUE set_busy_timeout(VALUE self, VALUE timeout) +{ + sqlite3RubyPtr ctx; + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + CHECK(ctx->db, sqlite3_busy_timeout(ctx->db, (int)NUM2INT(timeout))); + + return self; +} + +/* call-seq: db.load_extension(file) + * + * Loads an SQLite extension library from the named file. Extension + * loading must be enabled using db.enable_load_extension(1) prior + * to calling this API. + */ +static VALUE load_extension(VALUE self, VALUE file) +{ + sqlite3RubyPtr ctx; + int status; + char *errMsg; + VALUE errexp; + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + status = sqlite3_load_extension(ctx->db, RSTRING_PTR(file), 0, &errMsg); + if (status != SQLITE_OK) + { + errexp = rb_exc_new2(rb_eRuntimeError, errMsg); + sqlite3_free(errMsg); + rb_exc_raise(errexp); + } + + return self; +} + +/* call-seq: db.enable_load_extension(onoff) + * + * Enable or disable extension loading. + */ +static VALUE enable_load_extension(VALUE self, VALUE onoff) +{ + sqlite3RubyPtr ctx; + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + CHECK(ctx->db, sqlite3_enable_load_extension(ctx->db, (int)NUM2INT(onoff))); + + return self; +} + +#ifdef HAVE_RUBY_ENCODING_H +static int enc_cb(void * _self, int UNUSED(columns), char **data, char **UNUSED(names)) +{ + VALUE self = (VALUE)_self; + + int index = rb_enc_find_index(data[0]); + rb_encoding * e = rb_enc_from_index(index); + rb_iv_set(self, "@encoding", rb_enc_from_encoding(e)); + + return 0; +} + +/* call-seq: db.encoding + * + * Fetch the encoding set on this database + */ +static VALUE db_encoding(VALUE self) +{ + sqlite3RubyPtr ctx; + VALUE enc; + + Data_Get_Struct(self, sqlite3Ruby, ctx); + REQUIRE_OPEN_DB(ctx); + + enc = rb_iv_get(self, "@encoding"); + + if(NIL_P(enc)) { + sqlite3_exec(ctx->db, "PRAGMA encoding", enc_cb, (void *)self, NULL); + } + + return rb_iv_get(self, "@encoding"); +} +#endif + +void init_sqlite3_database() +{ + ID id_utf16, id_results_as_hash, id_type_translation; +#if 0 + VALUE mSqlite3 = rb_define_module("SQLite3"); +#endif + cSqlite3Database = rb_define_class_under(mSqlite3, "Database", rb_cObject); + + rb_define_alloc_func(cSqlite3Database, allocate); + rb_define_method(cSqlite3Database, "initialize", initialize, -1); + rb_define_method(cSqlite3Database, "close", sqlite3_rb_close, 0); + rb_define_method(cSqlite3Database, "closed?", closed_p, 0); + rb_define_method(cSqlite3Database, "total_changes", total_changes, 0); + rb_define_method(cSqlite3Database, "trace", trace, -1); + rb_define_method(cSqlite3Database, "last_insert_row_id", last_insert_row_id, 0); + rb_define_method(cSqlite3Database, "define_function", define_function, 1); + rb_define_method(cSqlite3Database, "define_aggregator", define_aggregator, 2); + rb_define_method(cSqlite3Database, "interrupt", interrupt, 0); + rb_define_method(cSqlite3Database, "errmsg", errmsg, 0); + rb_define_method(cSqlite3Database, "errcode", errcode_, 0); + rb_define_method(cSqlite3Database, "complete?", complete_p, 1); + rb_define_method(cSqlite3Database, "changes", changes, 0); + rb_define_method(cSqlite3Database, "authorizer=", set_authorizer, 1); + rb_define_method(cSqlite3Database, "busy_handler", busy_handler, -1); + rb_define_method(cSqlite3Database, "busy_timeout=", set_busy_timeout, 1); + +#ifdef HAVE_SQLITE3_LOAD_EXTENSION + rb_define_method(cSqlite3Database, "load_extension", load_extension, 1); +#endif + +#ifdef HAVE_SQLITE3_ENABLE_LOAD_EXTENSION + rb_define_method(cSqlite3Database, "enable_load_extension", enable_load_extension, 1); +#endif + +#ifdef HAVE_RUBY_ENCODING_H + rb_define_method(cSqlite3Database, "encoding", db_encoding, 0); +#endif + + id_utf16 = rb_intern("utf16"); + sym_utf16 = ID2SYM(id_utf16); + id_results_as_hash = rb_intern("results_as_hash"); + sym_results_as_hash = ID2SYM(id_results_as_hash); + id_type_translation = rb_intern("type_translation"); + sym_type_translation = ID2SYM(id_type_translation); +} diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3/database.h b/vendor/plugins/sqlite3-ruby/ext/sqlite3/database.h new file mode 100644 index 00000000..63e5e961 --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/ext/sqlite3/database.h @@ -0,0 +1,15 @@ +#ifndef SQLITE3_DATABASE_RUBY +#define SQLITE3_DATABASE_RUBY + +#include + +struct _sqlite3Ruby { + sqlite3 *db; +}; + +typedef struct _sqlite3Ruby sqlite3Ruby; +typedef sqlite3Ruby * sqlite3RubyPtr; + +void init_sqlite3_database(); + +#endif diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3/exception.c b/vendor/plugins/sqlite3-ruby/ext/sqlite3/exception.c new file mode 100644 index 00000000..36a78e7e --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/ext/sqlite3/exception.c @@ -0,0 +1,94 @@ +#include + +void rb_sqlite3_raise(sqlite3 * db, int status) +{ + VALUE klass = Qnil; + + switch(status) { + case SQLITE_OK: + return; + break; + case SQLITE_ERROR: + klass = rb_path2class("SQLite3::SQLException"); + break; + case SQLITE_INTERNAL: + klass = rb_path2class("SQLite3::InternalException"); + break; + case SQLITE_PERM: + klass = rb_path2class("SQLite3::PermissionException"); + break; + case SQLITE_ABORT: + klass = rb_path2class("SQLite3::AbortException"); + break; + case SQLITE_BUSY: + klass = rb_path2class("SQLite3::BusyException"); + break; + case SQLITE_LOCKED: + klass = rb_path2class("SQLite3::LockedException"); + break; + case SQLITE_NOMEM: + klass = rb_path2class("SQLite3::MemoryException"); + break; + case SQLITE_READONLY: + klass = rb_path2class("SQLite3::ReadOnlyException"); + break; + case SQLITE_INTERRUPT: + klass = rb_path2class("SQLite3::InterruptException"); + break; + case SQLITE_IOERR: + klass = rb_path2class("SQLite3::IOException"); + break; + case SQLITE_CORRUPT: + klass = rb_path2class("SQLite3::CorruptException"); + break; + case SQLITE_NOTFOUND: + klass = rb_path2class("SQLite3::NotFoundException"); + break; + case SQLITE_FULL: + klass = rb_path2class("SQLite3::FullException"); + break; + case SQLITE_CANTOPEN: + klass = rb_path2class("SQLite3::CantOpenException"); + break; + case SQLITE_PROTOCOL: + klass = rb_path2class("SQLite3::ProtocolException"); + break; + case SQLITE_EMPTY: + klass = rb_path2class("SQLite3::EmptyException"); + break; + case SQLITE_SCHEMA: + klass = rb_path2class("SQLite3::SchemaChangedException"); + break; + case SQLITE_TOOBIG: + klass = rb_path2class("SQLite3::TooBigException"); + break; + case SQLITE_CONSTRAINT: + klass = rb_path2class("SQLite3::ConstraintException"); + break; + case SQLITE_MISMATCH: + klass = rb_path2class("SQLite3::MismatchException"); + break; + case SQLITE_MISUSE: + klass = rb_path2class("SQLite3::MisuseException"); + break; + case SQLITE_NOLFS: + klass = rb_path2class("SQLite3::UnsupportedException"); + break; + case SQLITE_AUTH: + klass = rb_path2class("SQLite3::AuthorizationException"); + break; + case SQLITE_FORMAT: + klass = rb_path2class("SQLite3::FormatException"); + break; + case SQLITE_RANGE: + klass = rb_path2class("SQLite3::RangeException"); + break; + case SQLITE_NOTADB: + klass = rb_path2class("SQLite3::NotADatabaseException"); + break; + default: + klass = rb_eRuntimeError; + } + + rb_raise(klass, "%s", sqlite3_errmsg(db)); +} diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3/exception.h b/vendor/plugins/sqlite3-ruby/ext/sqlite3/exception.h new file mode 100644 index 00000000..55b687e3 --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/ext/sqlite3/exception.h @@ -0,0 +1,8 @@ +#ifndef SQLITE3_EXCEPTION_RUBY +#define SQLITE3_EXCEPTION_RUBY + +#define CHECK(_db, _status) rb_sqlite3_raise(_db, _status); + +void rb_sqlite3_raise(sqlite3 * db, int status); + +#endif diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3/extconf.rb b/vendor/plugins/sqlite3-ruby/ext/sqlite3/extconf.rb new file mode 100644 index 00000000..5a8ec34a --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/ext/sqlite3/extconf.rb @@ -0,0 +1,39 @@ +ENV['RC_ARCHS'] = '' if RUBY_PLATFORM =~ /darwin/ + +require 'mkmf' + +# :stopdoc: + +RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC'] + +sqlite = dir_config('sqlite3', ['/usr/local', '/opt/local', '/usr']) + +if RUBY_PLATFORM =~ /mswin/ + $CFLAGS << ' -W3' +else + $CFLAGS << ' -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion' << + ' -Wmissing-noreturn -Winline' +end + +def asplode missing + if RUBY_PLATFORM =~ /mswin/ + abort "#{missing} is missing. Install SQLite3 from " + + "http://www.sqlite.org/ first." + else + abort "#{missing} is missing. Try 'port install sqlite3 +universal' " + + "or 'yum install sqlite3-devel'" + end +end + +asplode('sqlite3.h') unless find_header 'sqlite3.h' +asplode('sqlite3') unless find_library 'sqlite3', 'sqlite3_libversion_number' + +# Functions defined in 1.9 but not 1.8 +have_func('rb_proc_arity') + +# These functions may not be defined +have_func('sqlite3_column_database_name') +have_func('sqlite3_enable_load_extension') +have_func('sqlite3_load_extension') + +create_makefile('sqlite3/sqlite3_native') diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3/sqlite3.c b/vendor/plugins/sqlite3-ruby/ext/sqlite3/sqlite3.c new file mode 100644 index 00000000..a7bbe0b6 --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/ext/sqlite3/sqlite3.c @@ -0,0 +1,33 @@ +#include + +VALUE mSqlite3; +VALUE cSqlite3Blob; + +static VALUE libversion(VALUE UNUSED(klass)) +{ + return INT2NUM(sqlite3_libversion_number()); +} + +void Init_sqlite3_native() +{ + /* + * SQLite3 is a wrapper around the popular database + * sqlite[http://sqlite.org]. + * + * For an example of usage, see SQLite3::Database. + */ + mSqlite3 = rb_define_module("SQLite3"); + + /* A class for differentiating between strings and blobs, when binding them + * into statements. + */ + cSqlite3Blob = rb_define_class_under(mSqlite3, "Blob", rb_cString); + + /* Initialize the sqlite3 library */ + sqlite3_initialize(); + + init_sqlite3_database(); + init_sqlite3_statement(); + + rb_define_singleton_method(mSqlite3, "libversion", libversion, 0); +} diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3/sqlite3_ruby.h b/vendor/plugins/sqlite3-ruby/ext/sqlite3/sqlite3_ruby.h new file mode 100644 index 00000000..5b619ef3 --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/ext/sqlite3/sqlite3_ruby.h @@ -0,0 +1,43 @@ +#ifndef SQLITE3_RUBY +#define SQLITE3_RUBY + +#include + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +#ifndef RBIGNUM_LEN +#define RBIGNUM_LEN(x) RBIGNUM(x)->len +#endif + +#ifdef HAVE_RUBY_ENCODING_H +#include + +#define UTF8_P(_obj) (rb_enc_get_index(_obj) == rb_utf8_encindex()) +#define UTF16_LE_P(_obj) (rb_enc_get_index(_obj) == rb_enc_find_index("UTF-16LE")) +#define SQLITE3_UTF8_STR_NEW2(_obj) \ + (rb_enc_associate_index(rb_str_new2(_obj), rb_utf8_encindex())) + +#else + +#define SQLITE3_UTF8_STR_NEW2(_obj) (rb_str_new2(_obj)) + +#endif + + +#include + +extern VALUE mSqlite3; +extern VALUE cSqlite3Blob; + +#include +#include +#include + +#endif diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3/statement.c b/vendor/plugins/sqlite3-ruby/ext/sqlite3/statement.c new file mode 100644 index 00000000..1b93fd47 --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/ext/sqlite3/statement.c @@ -0,0 +1,419 @@ +#include + +#define REQUIRE_OPEN_STMT(_ctxt) \ + if(!_ctxt->st) \ + rb_raise(rb_path2class("SQLite3::Exception"), "cannot use a closed statement"); + +VALUE cSqlite3Statement; + +static void deallocate(void * ctx) +{ + sqlite3StmtRubyPtr c = (sqlite3StmtRubyPtr)ctx; + xfree(c); +} + +static VALUE allocate(VALUE klass) +{ + sqlite3StmtRubyPtr ctx = xcalloc((size_t)1, sizeof(sqlite3StmtRuby)); + ctx->st = NULL; + ctx->done_p = 0; + + return Data_Wrap_Struct(klass, NULL, deallocate, ctx); +} + +/* call-seq: SQLite3::Statement.new(db, sql) + * + * Create a new statement attached to the given Database instance, and which + * encapsulates the given SQL text. If the text contains more than one + * statement (i.e., separated by semicolons), then the #remainder property + * will be set to the trailing text. + */ +static VALUE initialize(VALUE self, VALUE db, VALUE sql) +{ + sqlite3RubyPtr db_ctx; + sqlite3StmtRubyPtr ctx; + const char *tail = NULL; + int status; + + Data_Get_Struct(db, sqlite3Ruby, db_ctx); + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + + if(!db_ctx->db) + rb_raise(rb_eArgError, "prepare called on a closed database"); + +#ifdef HAVE_RUBY_ENCODING_H + if(!UTF8_P(sql)) { + VALUE encoding = rb_funcall(db, rb_intern("encoding"), 0); + rb_encoding * enc = NIL_P(encoding) ? rb_utf8_encoding() : + rb_to_encoding(encoding); + sql = rb_str_export_to_enc(sql, enc); + } +#endif + + status = sqlite3_prepare_v2( + db_ctx->db, + (const char *)StringValuePtr(sql), + (int)RSTRING_LEN(sql), + &ctx->st, + &tail + ); + + CHECK(db_ctx->db, status); + + rb_iv_set(self, "@connection", db); + rb_iv_set(self, "@remainder", rb_str_new2(tail)); + rb_iv_set(self, "@columns", Qnil); + rb_iv_set(self, "@types", Qnil); + + return self; +} + +/* call-seq: stmt.close + * + * Closes the statement by finalizing the underlying statement + * handle. The statement must not be used after being closed. + */ +static VALUE sqlite3_rb_close(VALUE self) +{ + sqlite3StmtRubyPtr ctx; + sqlite3 * db; + + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + + REQUIRE_OPEN_STMT(ctx); + + db = sqlite3_db_handle(ctx->st); + CHECK(db, sqlite3_finalize(ctx->st)); + + ctx->st = NULL; + + return self; +} + +/* call-seq: stmt.closed? + * + * Returns true if the statement has been closed. + */ +static VALUE closed_p(VALUE self) +{ + sqlite3StmtRubyPtr ctx; + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + + if(!ctx->st) return Qtrue; + + return Qfalse; +} + +static VALUE step(VALUE self) +{ + sqlite3StmtRubyPtr ctx; + sqlite3_stmt *stmt; + int value, length; + VALUE list; +#ifdef HAVE_RUBY_ENCODING_H + rb_encoding * internal_encoding; + int enc_index; +#endif + + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + + REQUIRE_OPEN_STMT(ctx); + + if(ctx->done_p) return Qnil; + +#ifdef HAVE_RUBY_ENCODING_H + { + VALUE db = rb_iv_get(self, "@connection"); + VALUE encoding = rb_funcall(db, rb_intern("encoding"), 0); + enc_index = NIL_P(encoding) ? rb_utf8_encindex() : rb_to_encoding_index(encoding); + internal_encoding = rb_default_internal_encoding(); + } +#endif + + stmt = ctx->st; + + value = sqlite3_step(stmt); + length = sqlite3_column_count(stmt); + list = rb_ary_new2((long)length); + + switch(value) { + case SQLITE_ROW: + { + int i; + for(i = 0; i < length; i++) { + switch(sqlite3_column_type(stmt, i)) { + case SQLITE_INTEGER: + rb_ary_push(list, LL2NUM(sqlite3_column_int64(stmt, i))); + break; + case SQLITE_FLOAT: + rb_ary_push(list, rb_float_new(sqlite3_column_double(stmt, i))); + break; + case SQLITE_TEXT: + { + VALUE str = rb_tainted_str_new( + (const char *)sqlite3_column_text(stmt, i), + (long)sqlite3_column_bytes(stmt, i) + ); +#ifdef HAVE_RUBY_ENCODING_H + rb_enc_associate_index(str, enc_index); + if(internal_encoding) + str = rb_str_export_to_enc(str, internal_encoding); +#endif + rb_ary_push(list, str); + } + break; + case SQLITE_BLOB: + { + VALUE str = rb_tainted_str_new( + (const char *)sqlite3_column_blob(stmt, i), + (long)sqlite3_column_bytes(stmt, i) + ); + rb_ary_push(list, str); + } + break; + case SQLITE_NULL: + rb_ary_push(list, Qnil); + break; + default: + rb_raise(rb_eRuntimeError, "bad type"); + } + } + } + break; + case SQLITE_DONE: + ctx->done_p = 1; + return Qnil; + break; + default: + CHECK(sqlite3_db_handle(ctx->st), value); + } + + return list; +} + +/* call-seq: stmt.bind_param(key, value) + * + * Binds value to the named (or positional) placeholder. If +param+ is a + * Fixnum, it is treated as an index for a positional placeholder. + * Otherwise it is used as the name of the placeholder to bind to. + * + * See also #bind_params. + */ +static VALUE bind_param(VALUE self, VALUE key, VALUE value) +{ + sqlite3StmtRubyPtr ctx; + int status; + int index; + + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + REQUIRE_OPEN_STMT(ctx); + + switch(TYPE(key)) { + case T_SYMBOL: + key = rb_funcall(key, rb_intern("to_s"), 0); + case T_STRING: + if(RSTRING_PTR(key)[0] != ':') key = rb_str_plus(rb_str_new2(":"), key); + index = sqlite3_bind_parameter_index(ctx->st, StringValuePtr(key)); + break; + default: + index = (int)NUM2INT(key); + } + + if(index == 0) + rb_raise(rb_path2class("SQLite3::Exception"), "no such bind parameter"); + + switch(TYPE(value)) { + case T_STRING: + if(CLASS_OF(value) == cSqlite3Blob +#ifdef HAVE_RUBY_ENCODING_H + || rb_enc_get_index(value) == rb_ascii8bit_encindex() +#endif + ) { + status = sqlite3_bind_blob( + ctx->st, + index, + (const char *)StringValuePtr(value), + (int)RSTRING_LEN(value), + SQLITE_TRANSIENT + ); + } else { +#ifdef HAVE_RUBY_ENCODING_H + if(!UTF8_P(value)) { + VALUE db = rb_iv_get(self, "@connection"); + VALUE encoding = rb_funcall(db, rb_intern("encoding"), 0); + rb_encoding * enc = rb_to_encoding(encoding); + value = rb_str_export_to_enc(value, enc); + } +#endif + + status = sqlite3_bind_text( + ctx->st, + index, + (const char *)StringValuePtr(value), + (int)RSTRING_LEN(value), + SQLITE_TRANSIENT + ); + } + break; + case T_BIGNUM: +#if SIZEOF_LONG < 8 + if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) { + status = sqlite3_bind_int64(ctx->st, index, (sqlite3_int64)NUM2LL(value)); + break; + } +#endif + case T_FLOAT: + status = sqlite3_bind_double(ctx->st, index, NUM2DBL(value)); + break; + case T_FIXNUM: + status = sqlite3_bind_int64(ctx->st, index, (sqlite3_int64)FIX2LONG(value)); + break; + case T_NIL: + status = sqlite3_bind_null(ctx->st, index); + break; + default: + rb_raise(rb_eRuntimeError, "can't prepare %s", + rb_class2name(CLASS_OF(value))); + break; + } + + CHECK(sqlite3_db_handle(ctx->st), status); + + return self; +} + +/* call-seq: stmt.reset! + * + * Resets the statement. This is typically done internally, though it might + * occassionally be necessary to manually reset the statement. + */ +static VALUE reset_bang(VALUE self) +{ + sqlite3StmtRubyPtr ctx; + int status; + + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + REQUIRE_OPEN_STMT(ctx); + + status = sqlite3_reset(ctx->st); + CHECK(sqlite3_db_handle(ctx->st), status); + + ctx->done_p = 0; + + return self; +} + +/* call-seq: stmt.done? + * + * returns true if all rows have been returned. + */ +static VALUE done_p(VALUE self) +{ + sqlite3StmtRubyPtr ctx; + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + + if(ctx->done_p) return Qtrue; + return Qfalse; +} + +/* call-seq: stmt.column_count + * + * Returns the number of columns to be returned for this statement + */ +static VALUE column_count(VALUE self) +{ + sqlite3StmtRubyPtr ctx; + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + REQUIRE_OPEN_STMT(ctx); + + return INT2NUM((long)sqlite3_column_count(ctx->st)); +} + +/* call-seq: stmt.column_name(index) + * + * Get the column name at +index+. 0 based. + */ +static VALUE column_name(VALUE self, VALUE index) +{ + sqlite3StmtRubyPtr ctx; + const char * name; + + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + REQUIRE_OPEN_STMT(ctx); + + name = sqlite3_column_name(ctx->st, (int)NUM2INT(index)); + + if(name) return rb_str_new2(name); + return Qnil; +} + +/* call-seq: stmt.column_decltype(index) + * + * Get the column type at +index+. 0 based. + */ +static VALUE column_decltype(VALUE self, VALUE index) +{ + sqlite3StmtRubyPtr ctx; + const char * name; + + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + REQUIRE_OPEN_STMT(ctx); + + name = sqlite3_column_decltype(ctx->st, (int)NUM2INT(index)); + + if(name) return rb_str_new2(name); + return Qnil; +} + +/* call-seq: stmt.bind_parameter_count + * + * Return the number of bind parameters + */ +static VALUE bind_parameter_count(VALUE self) +{ + sqlite3StmtRubyPtr ctx; + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + REQUIRE_OPEN_STMT(ctx); + + return INT2NUM((long)sqlite3_bind_parameter_count(ctx->st)); +} + +#ifdef HAVE_SQLITE3_COLUMN_DATABASE_NAME + +/* call-seq: stmt.database_name(column_index) + * + * Return the database name for the column at +column_index+ + */ +static VALUE database_name(VALUE self, VALUE index) +{ + sqlite3StmtRubyPtr ctx; + Data_Get_Struct(self, sqlite3StmtRuby, ctx); + REQUIRE_OPEN_STMT(ctx); + + return SQLITE3_UTF8_STR_NEW2( + sqlite3_column_database_name(ctx->st, NUM2INT(index))); +} + +#endif + +void init_sqlite3_statement() +{ + cSqlite3Statement = rb_define_class_under(mSqlite3, "Statement", rb_cObject); + + rb_define_alloc_func(cSqlite3Statement, allocate); + rb_define_method(cSqlite3Statement, "initialize", initialize, 2); + rb_define_method(cSqlite3Statement, "close", sqlite3_rb_close, 0); + rb_define_method(cSqlite3Statement, "closed?", closed_p, 0); + rb_define_method(cSqlite3Statement, "bind_param", bind_param, 2); + rb_define_method(cSqlite3Statement, "reset!", reset_bang, 0); + rb_define_method(cSqlite3Statement, "step", step, 0); + rb_define_method(cSqlite3Statement, "done?", done_p, 0); + rb_define_method(cSqlite3Statement, "column_count", column_count, 0); + rb_define_method(cSqlite3Statement, "column_name", column_name, 1); + rb_define_method(cSqlite3Statement, "column_decltype", column_decltype, 1); + rb_define_method(cSqlite3Statement, "bind_parameter_count", bind_parameter_count, 0); + +#ifdef HAVE_SQLITE3_COLUMN_DATABASE_NAME + rb_define_method(cSqlite3Statement, "database_name", database_name, 1); +#endif +} diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3/statement.h b/vendor/plugins/sqlite3-ruby/ext/sqlite3/statement.h new file mode 100644 index 00000000..e7ef1f3a --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/ext/sqlite3/statement.h @@ -0,0 +1,16 @@ +#ifndef SQLITE3_STATEMENT_RUBY +#define SQLITE3_STATEMENT_RUBY + +#include + +struct _sqlite3StmtRuby { + sqlite3_stmt *st; + int done_p; +}; + +typedef struct _sqlite3StmtRuby sqlite3StmtRuby; +typedef sqlite3StmtRuby * sqlite3StmtRubyPtr; + +void init_sqlite3_statement(); + +#endif diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/MANIFEST b/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/MANIFEST deleted file mode 100644 index f335e449..00000000 --- a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/MANIFEST +++ /dev/null @@ -1,4 +0,0 @@ -extconf.rb -post-clean.rb -post-distclean.rb -sqlite3_api.i diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/Makefile b/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/Makefile deleted file mode 100644 index 2071ffd0..00000000 --- a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/Makefile +++ /dev/null @@ -1,146 +0,0 @@ - -SHELL = /bin/sh - -#### Start of system configuration section. #### - -srcdir = . -topdir = /opt/local/lib/ruby/1.8/i686-darwin9.2.2 -hdrdir = $(topdir) -VPATH = $(srcdir):$(topdir):$(hdrdir) -prefix = $(DESTDIR)/opt/local -exec_prefix = $(prefix) -sitedir = $(prefix)/lib/ruby/site_ruby -rubylibdir = $(libdir)/ruby/$(ruby_version) -archdir = $(rubylibdir)/$(arch) -sbindir = $(exec_prefix)/sbin -vendordir = $(prefix)/lib/ruby/vendor_ruby -datadir = $(prefix)/share -includedir = $(prefix)/include -infodir = $(prefix)/info -sysconfdir = $(prefix)/etc -mandir = $(DESTDIR)/opt/local/share/man -libdir = $(exec_prefix)/lib -sharedstatedir = $(prefix)/com -oldincludedir = $(DESTDIR)/usr/include -sitearchdir = $(sitelibdir)/$(sitearch) -vendorarchdir = $(vendorlibdir)/$(vendorarch) -bindir = $(exec_prefix)/bin -localstatedir = $(prefix)/var -vendorlibdir = $(vendordir)/$(ruby_version) -sitelibdir = $(sitedir)/$(ruby_version) -libexecdir = $(exec_prefix)/libexec - -CC = gcc -LIBRUBY = $(LIBRUBY_SO) -LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a -LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME) -LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static - -RUBY_EXTCONF_H = -CFLAGS = -fno-common -O2 -fno-common -pipe -fno-common -INCFLAGS = -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -CPPFLAGS = -DHAVE_SQLITE3_H -I/usr/local/include -I/opt/local/include -CXXFLAGS = $(CFLAGS) -DLDFLAGS = -L. -L/opt/local/lib -LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace -AR = ar -EXEEXT = - -RUBY_INSTALL_NAME = ruby -RUBY_SO_NAME = ruby -arch = i686-darwin9.2.2 -sitearch = i686-darwin9.2.2 -vendorarch = i686-darwin9.2.2 -ruby_version = 1.8 -ruby = /opt/local/bin/ruby -RUBY = $(ruby) -RM = rm -f -MAKEDIRS = mkdir -p -INSTALL = /usr/bin/install -c -INSTALL_PROG = $(INSTALL) -m 0755 -INSTALL_DATA = $(INSTALL) -m 644 -COPY = cp - -#### End of system configuration section. #### - -preload = - -libpath = . $(libdir) /usr/local/lib -LIBPATH = -L"." -L"$(libdir)" -L"/usr/local/lib" -DEFFILE = - -CLEANFILES = mkmf.log -DISTCLEANFILES = - -extout = -extout_prefix = -target_prefix = -LOCAL_LIBS = -LIBS = $(LIBRUBYARG_SHARED) -lsqlite3 -lpthread -ldl -lobjc -SRCS = sqlite3_api_wrap.c -OBJS = sqlite3_api_wrap.o -TARGET = sqlite3_api -DLLIB = $(TARGET).bundle -EXTSTATIC = -STATIC_LIB = - -RUBYCOMMONDIR = $(sitedir)$(target_prefix) -RUBYLIBDIR = $(sitelibdir)$(target_prefix) -RUBYARCHDIR = $(sitearchdir)$(target_prefix) - -TARGET_SO = $(DLLIB) -CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map -CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak - -all: $(DLLIB) -static: $(STATIC_LIB) - -clean: - @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) - -distclean: clean - @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log - @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) - -realclean: distclean -install: install-so install-rb - -install-so: $(RUBYARCHDIR) -install-so: $(RUBYARCHDIR)/$(DLLIB) -$(RUBYARCHDIR)/$(DLLIB): $(DLLIB) - $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR) -install-rb: pre-install-rb install-rb-default -install-rb-default: pre-install-rb-default -pre-install-rb: Makefile -pre-install-rb-default: Makefile -$(RUBYARCHDIR): - $(MAKEDIRS) $@ - -site-install: site-install-so site-install-rb -site-install-so: install-so -site-install-rb: install-rb - -.SUFFIXES: .c .m .cc .cxx .cpp .C .o - -.cc.o: - $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $< - -.cxx.o: - $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $< - -.cpp.o: - $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $< - -.C.o: - $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $< - -.c.o: - $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $< - -$(DLLIB): $(OBJS) - @-$(RM) $@ - $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS) - - - -$(OBJS): ruby.h defines.h diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/extconf.rb b/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/extconf.rb deleted file mode 100644 index 331524bb..00000000 --- a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/extconf.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'mkmf' - -dir_config( "sqlite3" ) - -have_library( "rt", "fdatasync" ) - -if have_header( "sqlite3.h" ) && have_library( "sqlite3", "sqlite3_open" ) then - $CFLAGS << " -fno-strict-aliasing" unless RUBY_PLATFORM =~ /mswin/ - create_makefile( "sqlite3_api" ) -end diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/mkmf.log b/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/mkmf.log deleted file mode 100644 index 0f89d250..00000000 --- a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/mkmf.log +++ /dev/null @@ -1,71 +0,0 @@ -have_library: checking for fdatasync() in -lrt... -------------------- no - -"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lrt -lpthread -ldl -lobjc " -conftest.c: In function ‘t’: -conftest.c:3: error: ‘fdatasync’ undeclared (first use in this function) -conftest.c:3: error: (Each undeclared identifier is reported only once -conftest.c:3: error: for each function it appears in.) -checked program was: -/* begin */ -1: /*top*/ -2: int main() { return 0; } -3: int t() { void ((*volatile p)()); p = (void ((*)()))fdatasync; return 0; } -/* end */ - -"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lrt -lpthread -ldl -lobjc " -ld: library not found for -lrt -collect2: ld returned 1 exit status -checked program was: -/* begin */ -1: /*top*/ -2: int main() { return 0; } -3: int t() { fdatasync(); return 0; } -/* end */ - -"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lrt -lpthread -ldl -lobjc " -ld: library not found for -lrt -collect2: ld returned 1 exit status -checked program was: -/* begin */ -1: int fdatasync(); -2: /*top*/ -3: int main() { return 0; } -4: int t() { fdatasync(); return 0; } -/* end */ - --------------------- - -have_header: checking for sqlite3.h... -------------------- yes - -"gcc -E -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -o conftest.i" -checked program was: -/* begin */ -1: #include -/* end */ - --------------------- - -have_library: checking for sqlite3_open() in -lsqlite3... -------------------- yes - -"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lsqlite3 -lpthread -ldl -lobjc " -conftest.c: In function ‘t’: -conftest.c:3: error: ‘sqlite3_open’ undeclared (first use in this function) -conftest.c:3: error: (Each undeclared identifier is reported only once -conftest.c:3: error: for each function it appears in.) -checked program was: -/* begin */ -1: /*top*/ -2: int main() { return 0; } -3: int t() { void ((*volatile p)()); p = (void ((*)()))sqlite3_open; return 0; } -/* end */ - -"gcc -o conftest -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.2.2 -I. -I/usr/local/include -I/opt/local/include -O2 -fno-common -pipe -fno-common conftest.c -L"." -L"/opt/local/lib" -L"/usr/local/lib" -L. -L/opt/local/lib -lruby-static -lsqlite3 -lpthread -ldl -lobjc " -checked program was: -/* begin */ -1: /*top*/ -2: int main() { return 0; } -3: int t() { sqlite3_open(); return 0; } -/* end */ - --------------------- - diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/sqlite3_api.i b/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/sqlite3_api.i deleted file mode 100644 index 5e103dee..00000000 --- a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/sqlite3_api.i +++ /dev/null @@ -1,362 +0,0 @@ -%module "SQLite3::driver::native::API" -%include "typemaps.i" -%{ -#include -#include "ruby.h" - -#ifndef RSTRING_PTR -#define RSTRING_PTR(s) (RSTRING(s)->ptr) -#endif - -#ifndef RSTRING_LEN -#define RSTRING_LEN(s) (RSTRING(s)->len) -#endif - -#ifndef STR2CSTR -#define STR2CSTR StringValueCStr -#endif - -#define Init_API Init_sqlite3_api - -struct CallbackData { - VALUE proc; - VALUE proc2; - VALUE data; -}; - -typedef struct CallbackData CallbackData; -typedef void RUBY_BLOB; -typedef void RUBY_VALBLOB; - -int Sqlite3_ruby_busy_handler(void* data,int value) { - VALUE result; - CallbackData *cb = (CallbackData*)data; - result = rb_funcall( - cb->proc, rb_intern("call"), 2, cb->data, INT2FIX(value) ); - return FIX2INT(result); -} - -static void mark_CallbackData(void* ptr) { - CallbackData* cb = (CallbackData*)ptr; - if (cb->proc != Qnil) - rb_gc_mark(cb->proc); - if (cb->proc2 != Qnil) - rb_gc_mark(cb->proc2); - if (cb->data != Qnil) - rb_gc_mark(cb->data); -} - -int Sqlite3_ruby_authorizer(void* data,int type, - const char* a,const char* b,const char* c,const char* d) -{ - VALUE result; - CallbackData *cb = (CallbackData*)data; - result = rb_funcall( - cb->proc, rb_intern("call"), 6, cb->data, INT2FIX(type), - ( a ? rb_str_new2(a) : Qnil ), ( b ? rb_str_new2(b) : Qnil ), - ( c ? rb_str_new2(c) : Qnil ), ( d ? rb_str_new2(d) : Qnil ) ); - return FIX2INT(result); -} - -void Sqlite3_ruby_trace(void* data, const char *sql) { - CallbackData *cb = (CallbackData*)data; - rb_funcall( cb->proc, rb_intern("call"), 2, cb->data, - sql ? rb_str_new2(sql) : Qnil ); -} - -void Sqlite3_ruby_function_step(sqlite3_context* ctx,int n, - sqlite3_value** args) -{ - CallbackData *data; - VALUE rb_args; - VALUE *rb_context; - int idx; - - data = (CallbackData*)sqlite3_user_data(ctx); - - if( data->proc2 != Qnil ) { - rb_context = (VALUE*)sqlite3_aggregate_context(ctx,sizeof(VALUE)); - if( *rb_context == 0 ) { - *rb_context = rb_hash_new(); - rb_gc_register_address( rb_context ); - } - } - - rb_args = rb_ary_new2(n+1); - rb_ary_push( rb_args, SWIG_NewPointerObj(ctx,SWIGTYPE_p_sqlite3_context,0) ); - for( idx = 0; idx < n; idx++ ) { - rb_ary_push( rb_args, SWIG_NewPointerObj(args[idx], - SWIGTYPE_p_sqlite3_value,0) ); - } - - rb_apply( data->proc, rb_intern("call"), rb_args ); -} - -void Sqlite3_ruby_function_final(sqlite3_context *ctx) { - VALUE *rb_context; - CallbackData *data; - - rb_context = (VALUE*)sqlite3_aggregate_context(ctx,sizeof(VALUE)); - if( *rb_context == 0 ) { - *rb_context = rb_hash_new(); - rb_gc_register_address( rb_context ); - } - - data = (CallbackData*)sqlite3_user_data(ctx); - - rb_funcall( data->proc2, rb_intern("call"), 1, - SWIG_NewPointerObj(ctx,SWIGTYPE_p_sqlite3_context,0) ); - - rb_gc_unregister_address( rb_context ); -} -%} - -%markfunc CallbackData "mark_CallbackData"; - -struct CallbackData { - VALUE proc; - VALUE proc2; - VALUE data; -}; - -%typemap(in) const void *str { - $1 = (void*)RSTRING_PTR($input); -} - -%typemap(in) (const char *filename, sqlite3**) { - $1 = STR2CSTR($input); - $2 = (sqlite3**)malloc( sizeof( sqlite3* ) ); -} - -%typemap(argout) (const char *filename, sqlite3**) { - VALUE ary; - ary = rb_ary_new2(2); - rb_ary_push( ary, $result ); - rb_ary_push( ary, SWIG_NewPointerObj( *$2, SWIGTYPE_p_sqlite3, 0 ) ); - free( $2 ); - $result = ary; -} - -%typemap(in) (const void *filename, sqlite3**) { - $1 = (void*)RSTRING_PTR($input); - $2 = (sqlite3**)malloc( sizeof( sqlite3* ) ); -} - -%typemap(argout) (const void *filename, sqlite3**) { - VALUE ary; - ary = rb_ary_new2(2); - rb_ary_push( ary, $result ); - rb_ary_push( ary, SWIG_NewPointerObj( *$2, SWIGTYPE_p_sqlite3, 0 ) ); - free( $2 ); - $result = ary; -} - -typedef void RUBY_BLOB; -%typemap(out) const RUBY_BLOB * { - $result = $1 ? - rb_str_new( (char*)$1, sqlite3_column_bytes( arg1, arg2 ) ) : Qnil; -} - -typedef void RUBY_VALBLOB; -%typemap(out) const RUBY_VALBLOB * { - $result = $1 ? rb_str_new( (char*)$1, sqlite3_value_bytes( arg1 ) ) : Qnil; -} - -%typemap(out) const void * { - int i; - if( $1 ) { - for( i = 0; ((char*)$1)[i]; i += 2 ); - $result = rb_str_new( (char*)$1, i ); - } else $result = Qnil; -} - -%typemap(in) (const char * sql,int,sqlite3_stmt**,const char**) (sqlite3_stmt *stmt, char *errmsg) { - $1 = RSTRING_PTR($input); - $2 = RSTRING_LEN($input); - $3 = &stmt2; - $4 = &errmsg2; -} - -%typemap(argout) (const char* sql,int,sqlite3_stmt**,const char**) { - VALUE ary; - ary = rb_ary_new2(3); - rb_ary_push( ary, $result ); - rb_ary_push( ary, SWIG_NewPointerObj( stmt2, SWIGTYPE_p_sqlite3_stmt, 0 ) ); - rb_ary_push( ary, errmsg2 ? rb_str_new2( errmsg2 ) : Qnil ); - $result = ary; -} - -%typemap(in) (const void* sql,int,sqlite3_stmt**,const void**) (sqlite3_stmt *stmt, void *errmsg) { - $1 = RSTRING_PTR($input); - $2 = RSTRING_LEN($input); - $3 = &stmt2; - $4 = &errmsg2; -} - -%typemap(argout) (const void* sql,int,sqlite3_stmt**,const void**) { - VALUE ary; - int i; - - for( i = 0; ((char*)errmsg2)[i]; i += 2 ); - - ary = rb_ary_new2(3); - rb_ary_push( ary, $result ); - rb_ary_push( ary, SWIG_NewPointerObj( stmt2, SWIGTYPE_p_sqlite3_stmt, 0 ) ); - rb_ary_push( ary, errmsg2 ? rb_str_new( (char*)errmsg2, i ) : Qnil ); - $result = ary; -} - -%typemap(in) (const void *blob,int) { - $1 = (void*)RSTRING_PTR($input); - $2 = RSTRING_LEN($input); -} - -%typemap(in) (const void *blob,int,void(*free)(void*)) { - $1 = (void*)RSTRING_PTR($input); - $2 = RSTRING_LEN($input); - $3 = SQLITE_TRANSIENT; -} - -%typemap(in) (const char *text,int) { - $1 = RSTRING_PTR($input); - $2 = RSTRING_LEN($input); -} - -%typemap(in) (const char *text,int,void(*free)(void*)) { - $1 = RSTRING_PTR($input); - $2 = RSTRING_LEN($input); - $3 = SQLITE_TRANSIENT; -} - -%typemap(in) (const void *utf16,int) { - $1 = (void*)RSTRING_PTR($input); - $2 = RSTRING_LEN($input); -} - -%typemap(in) (const void *utf16,int,void(*free)(void*)) { - $1 = (void*)RSTRING_PTR($input); - $2 = RSTRING_LEN($input); - $3 = SQLITE_TRANSIENT; -} - -%typemap(out) sqlite_int64 { - $result = rb_ll2inum( $1 ); -} - -%typemap(out) const char * { - $result = $1 ? rb_str_new2($1) : Qnil; -} - -%typemap(in) sqlite_int64 { - $1 = rb_num2ll( $input ); -} - -%typemap(in) (sqlite3_context*,int data_size) { - SWIG_ConvertPtr($input,(void**)&$1, SWIGTYPE_p_sqlite3_context, 1); - $2 = 4; -} - -%typemap(out) VALUE* { - $result = *(VALUE*)$1; -} - -%constant int Sqlite3_ruby_busy_handler(void*,int); -%constant int Sqlite3_ruby_authorizer(void*,int,const char*,const char*,const char*,const char*); -%constant void Sqlite3_ruby_trace(void*,const char*); -%constant void Sqlite3_ruby_function_step(sqlite3_context* ctx,int n, - sqlite3_value** args); -%constant void Sqlite3_ruby_function_final(sqlite3_context* ctx); - -const char *sqlite3_libversion(void); -int sqlite3_close(sqlite3*); - -sqlite_int64 sqlite3_last_insert_rowid(sqlite3*); - -int sqlite3_changes(sqlite3*); -int sqlite3_total_changes(sqlite3*); -void sqlite3_interrupt(sqlite3*); - -int sqlite3_complete(const char*); -int sqlite3_complete16(const void *str); - -int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); -int sqlite3_busy_timeout(sqlite3*,int); -int sqlite3_set_authorizer(sqlite3*, int(*)(void*,int,const char*,const char*,const char*,const char*), void*); -int sqlite3_trace(sqlite3*, void(*)(void*,const char*), void*); - -int sqlite3_open(const char *filename, sqlite3 **); -int sqlite3_open16(const void *filename, sqlite3 **); - -int sqlite3_errcode(sqlite3*); -const char *sqlite3_errmsg(sqlite3*); -const void *sqlite3_errmsg16(sqlite3*); - -int sqlite3_prepare(sqlite3*,const char* sql,int,sqlite3_stmt**,const char**); -int sqlite3_prepare16(sqlite3*,const void* sql,int,sqlite3_stmt**,const void**); - -int sqlite3_bind_blob(sqlite3_stmt*,int,const void *blob,int,void(*free)(void*)); -int sqlite3_bind_double(sqlite3_stmt*,int,double); -int sqlite3_bind_int(sqlite3_stmt*,int,int); -int sqlite3_bind_int64(sqlite3_stmt*,int,sqlite_int64); -int sqlite3_bind_null(sqlite3_stmt*,int); -int sqlite3_bind_text(sqlite3_stmt*,int,const char*text,int,void(*free)(void*)); -int sqlite3_bind_text16(sqlite3_stmt*,int,const void*utf16,int,void(*free)(void*)); - -int sqlite3_bind_parameter_count(sqlite3_stmt*); -const char *sqlite3_bind_parameter_name(sqlite3_stmt*,int); -int sqlite3_bind_parameter_index(sqlite3_stmt*,const char*); - -int sqlite3_column_count(sqlite3_stmt*); -const char *sqlite3_column_name(sqlite3_stmt*,int); -const void *sqlite3_column_name16(sqlite3_stmt*,int); -const char *sqlite3_column_decltype(sqlite3_stmt*,int); -const void *sqlite3_column_decltype16(sqlite3_stmt*,int); - -int sqlite3_step(sqlite3_stmt*); - -int sqlite3_data_count(sqlite3_stmt*); - -const RUBY_BLOB *sqlite3_column_blob(sqlite3_stmt*,int); -int sqlite3_column_bytes(sqlite3_stmt*,int); -int sqlite3_column_bytes16(sqlite3_stmt*,int); -double sqlite3_column_double(sqlite3_stmt*,int); -double sqlite3_column_int(sqlite3_stmt*,int); -sqlite_int64 sqlite3_column_int64(sqlite3_stmt*,int); -const char *sqlite3_column_text(sqlite3_stmt*,int); -const void *sqlite3_column_text16(sqlite3_stmt*,int); -int sqlite3_column_type(sqlite3_stmt*,int); - -int sqlite3_finalize(sqlite3_stmt*); -int sqlite3_reset(sqlite3_stmt*); - -int sqlite3_create_function(sqlite3*,const char*str,int,int,void*,void(*func)(sqlite3_context*,int,sqlite3_value**),void(*step)(sqlite3_context*,int,sqlite3_value**),void(*final)(sqlite3_context*)); - -int sqlite3_create_function16(sqlite3*,const void*str,int,int,void*,void(*func)(sqlite3_context*,int,sqlite3_value**),void(*step)(sqlite3_context*,int,sqlite3_value**),void(*final)(sqlite3_context*)); - -int sqlite3_aggregate_count(sqlite3_context*); - -const RUBY_VALBLOB *sqlite3_value_blob(sqlite3_value*); -int sqlite3_value_bytes(sqlite3_value*); -int sqlite3_value_bytes16(sqlite3_value*); -double sqlite3_value_double(sqlite3_value*); -int sqlite3_value_int(sqlite3_value*); -sqlite_int64 sqlite3_value_int64(sqlite3_value*); -const char *sqlite3_value_text(sqlite3_value*); -const void *sqlite3_value_text16(sqlite3_value*); -const void *sqlite3_value_text16le(sqlite3_value*); -const void *sqlite3_value_text16be(sqlite3_value*); -int sqlite3_value_type(sqlite3_value*); - -void sqlite3_result_blob(sqlite3_context*,const void *blob,int,void(*free)(void*)); -void sqlite3_result_double(sqlite3_context*,double); -void sqlite3_result_error(sqlite3_context*,const char *text,int); -void sqlite3_result_error16(sqlite3_context*,const void *blob,int); -void sqlite3_result_int(sqlite3_context*,int); -void sqlite3_result_int64(sqlite3_context*,sqlite_int64); -void sqlite3_result_text(sqlite3_context*,const char* text,int,void(*free)(void*)); -void sqlite3_result_text16(sqlite3_context*,const void* utf16,int,void(*free)(void*)); -void sqlite3_result_text16le(sqlite3_context*,const void* utf16,int,void(*free)(void*)); -void sqlite3_result_text16be(sqlite3_context*,const void* utf16,int,void(*free)(void*)); -void sqlite3_result_value(sqlite3_context*,sqlite3_value*); - -VALUE *sqlite3_aggregate_context(sqlite3_context*,int data_size); diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/sqlite3_api_wrap.c b/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/sqlite3_api_wrap.c deleted file mode 100644 index a35f76ed..00000000 --- a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/sqlite3_api_wrap.c +++ /dev/null @@ -1,5018 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.39 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -#define SWIGRUBY - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - - -/* ----------------------------------------------------------------------------- - * swigrun.swg - * - * This file contains generic C API SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "4" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the SWIG runtime code. - In 99.9% of the cases, SWIG just needs to declare them as 'static'. - - But only do this if strictly necessary, ie, if you have problems - with your compiler or suchlike. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 -#define SWIG_CAST_NEW_MEMORY 0x2 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return and integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old versions of SWIG, code such as the following was usually written: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - which is the same really, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - also requires SWIG_ConvertPtr to return new result values, such as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - SWIG errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() -*/ - -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *, int *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store information on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (strcmp(iter->type->name, c) == 0) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (iter->type == from) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - register size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - -#include - -/* Remove global macros defined in Ruby's win32.h */ -#ifdef write -# undef write -#endif -#ifdef read -# undef read -#endif -#ifdef bind -# undef bind -#endif - - -/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ -#ifndef NUM2LL -#define NUM2LL(x) NUM2LONG((x)) -#endif -#ifndef LL2NUM -#define LL2NUM(x) INT2NUM((long) (x)) -#endif -#ifndef ULL2NUM -#define ULL2NUM(x) UINT2NUM((unsigned long) (x)) -#endif - -/* Ruby 1.7 doesn't (yet) define NUM2ULL() */ -#ifndef NUM2ULL -#ifdef HAVE_LONG_LONG -#define NUM2ULL(x) rb_num2ull((x)) -#else -#define NUM2ULL(x) NUM2ULONG(x) -#endif -#endif - -/* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */ -/* Define these for older versions so we can just write code the new way */ -#ifndef RSTRING_LEN -# define RSTRING_LEN(x) RSTRING(x)->len -#endif -#ifndef RSTRING_PTR -# define RSTRING_PTR(x) RSTRING(x)->ptr -#endif -#ifndef RSTRING_END -# define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x)) -#endif -#ifndef RARRAY_LEN -# define RARRAY_LEN(x) RARRAY(x)->len -#endif -#ifndef RARRAY_PTR -# define RARRAY_PTR(x) RARRAY(x)->ptr -#endif -#ifndef RFLOAT_VALUE -# define RFLOAT_VALUE(x) RFLOAT(x)->value -#endif -#ifndef DOUBLE2NUM -# define DOUBLE2NUM(x) rb_float_new(x) -#endif -#ifndef RHASH_TBL -# define RHASH_TBL(x) (RHASH(x)->tbl) -#endif -#ifndef RHASH_ITER_LEV -# define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev) -#endif -#ifndef RHASH_IFNONE -# define RHASH_IFNONE(x) (RHASH(x)->ifnone) -#endif -#ifndef RHASH_SIZE -# define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries) -#endif -#ifndef RHASH_EMPTY_P -# define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0) -#endif -#ifndef RSTRUCT_LEN -# define RSTRUCT_LEN(x) RSTRUCT(x)->len -#endif -#ifndef RSTRUCT_PTR -# define RSTRUCT_PTR(x) RSTRUCT(x)->ptr -#endif - - - -/* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. - * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). - * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() - * and Data_Make_Struct(). - */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif -#else -# define VALUEFUNC(f) (f) -# define VOIDFUNC(f) (f) -#endif - -/* Don't use for expressions have side effect */ -#ifndef RB_STRING_VALUE -#define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s))) -#endif -#ifndef StringValue -#define StringValue(s) RB_STRING_VALUE(s) -#endif -#ifndef StringValuePtr -#define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s)) -#endif -#ifndef StringValueLen -#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s)) -#endif -#ifndef SafeStringValue -#define SafeStringValue(v) do {\ - StringValue(v);\ - rb_check_safe_str(v);\ -} while (0) -#endif - -#ifndef HAVE_RB_DEFINE_ALLOC_FUNC -#define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1) -#define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new") -#endif - -static VALUE _mSWIG = Qnil; - -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - - -/* Define some additional error types */ -#define SWIG_ObjectPreviouslyDeletedError -100 - - -/* Define custom exceptions for errors that do not map to existing Ruby - exceptions. Note this only works for C++ since a global cannot be - initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/ - -SWIGINTERN VALUE -getNullReferenceError(void) { - static int init = 0; - static VALUE rb_eNullReferenceError ; - if (!init) { - init = 1; - rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError); - } - return rb_eNullReferenceError; -} - -SWIGINTERN VALUE -getObjectPreviouslyDeletedError(void) { - static int init = 0; - static VALUE rb_eObjectPreviouslyDeleted ; - if (!init) { - init = 1; - rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError); - } - return rb_eObjectPreviouslyDeleted; -} - - -SWIGINTERN VALUE -SWIG_Ruby_ErrorType(int SWIG_code) { - VALUE type; - switch (SWIG_code) { - case SWIG_MemoryError: - type = rb_eNoMemError; - break; - case SWIG_IOError: - type = rb_eIOError; - break; - case SWIG_RuntimeError: - type = rb_eRuntimeError; - break; - case SWIG_IndexError: - type = rb_eIndexError; - break; - case SWIG_TypeError: - type = rb_eTypeError; - break; - case SWIG_DivisionByZero: - type = rb_eZeroDivError; - break; - case SWIG_OverflowError: - type = rb_eRangeError; - break; - case SWIG_SyntaxError: - type = rb_eSyntaxError; - break; - case SWIG_ValueError: - type = rb_eArgError; - break; - case SWIG_SystemError: - type = rb_eFatal; - break; - case SWIG_AttributeError: - type = rb_eRuntimeError; - break; - case SWIG_NullReferenceError: - type = getNullReferenceError(); - break; - case SWIG_ObjectPreviouslyDeletedError: - type = getObjectPreviouslyDeletedError(); - break; - case SWIG_UnknownError: - type = rb_eRuntimeError; - break; - default: - type = rb_eRuntimeError; - } - return type; -} - - -/* This function is called when a user inputs a wrong argument to - a method. - */ -SWIGINTERN -const char* Ruby_Format_TypeError( const char* msg, - const char* type, - const char* name, - const int argn, - VALUE input ) -{ - char buf[128]; - VALUE str; - VALUE asStr; - if ( msg && *msg ) - { - str = rb_str_new2(msg); - } - else - { - str = rb_str_new(NULL, 0); - } - - str = rb_str_cat2( str, "Expected argument " ); - sprintf( buf, "%d of type ", argn-1 ); - str = rb_str_cat2( str, buf ); - str = rb_str_cat2( str, type ); - str = rb_str_cat2( str, ", but got " ); - str = rb_str_cat2( str, rb_obj_classname(input) ); - str = rb_str_cat2( str, " " ); - asStr = rb_inspect(input); - if ( RSTRING_LEN(asStr) > 30 ) - { - str = rb_str_cat( str, StringValuePtr(asStr), 30 ); - str = rb_str_cat2( str, "..." ); - } - else - { - str = rb_str_append( str, asStr ); - } - - if ( name ) - { - str = rb_str_cat2( str, "\n\tin SWIG method '" ); - str = rb_str_cat2( str, name ); - str = rb_str_cat2( str, "'" ); - } - - return StringValuePtr( str ); -} - -/* This function is called when an overloaded method fails */ -SWIGINTERN -void Ruby_Format_OverloadedError( - const int argc, - const int maxargs, - const char* method, - const char* prototypes - ) -{ - const char* msg = "Wrong # of arguments"; - if ( argc <= maxargs ) msg = "Wrong arguments"; - rb_raise(rb_eArgError,"%s for overloaded method '%s'.\n" - "Possible C/C++ prototypes are:\n%s", - msg, method, prototypes); -} - -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * rubytracking.swg - * - * This file contains support for tracking mappings from - * Ruby objects to C++ objects. This functionality is needed - * to implement mark functions for Ruby's mark and sweep - * garbage collector. - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Ruby 1.8 actually assumes the first case. */ -#if SIZEOF_VOIDP == SIZEOF_LONG -# define SWIG2NUM(v) LONG2NUM((unsigned long)v) -# define NUM2SWIG(x) (unsigned long)NUM2LONG(x) -#elif SIZEOF_VOIDP == SIZEOF_LONG_LONG -# define SWIG2NUM(v) LL2NUM((unsigned long long)v) -# define NUM2SWIG(x) (unsigned long long)NUM2LL(x) -#else -# error sizeof(void*) is not the same as long or long long -#endif - - -/* Global Ruby hash table to store Trackings from C/C++ - structs to Ruby Objects. -*/ -static VALUE swig_ruby_trackings = Qnil; - -/* Global variable that stores a reference to the ruby - hash table delete function. */ -static ID swig_ruby_hash_delete; - -/* Setup a Ruby hash table to store Trackings */ -SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { - /* Create a ruby hash table to store Trackings from C++ - objects to Ruby objects. */ - - /* Try to see if some other .so has already created a - tracking hash table, which we keep hidden in an instance var - in the SWIG module. - This is done to allow multiple DSOs to share the same - tracking table. - */ - ID trackings_id = rb_intern( "@__trackings__" ); - VALUE verbose = rb_gv_get("VERBOSE"); - rb_gv_set("VERBOSE", Qfalse); - swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id ); - rb_gv_set("VERBOSE", verbose); - - /* No, it hasn't. Create one ourselves */ - if ( swig_ruby_trackings == Qnil ) - { - swig_ruby_trackings = rb_hash_new(); - rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings ); - } - - /* Now store a reference to the hash table delete function - so that we only have to look it up once.*/ - swig_ruby_hash_delete = rb_intern("delete"); -} - -/* Get a Ruby number to reference a pointer */ -SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) { - /* We cast the pointer to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the pointer to a Ruby number */ - return SWIG2NUM(ptr); -} - -/* Get a Ruby number to reference an object */ -SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) { - /* We cast the object to an unsigned long - and then store a reference to it using - a Ruby number object. */ - - /* Convert the Object to a Ruby number */ - return SWIG2NUM(object); -} - -/* Get a Ruby object from a previously stored reference */ -SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) { - /* The provided Ruby number object is a reference - to the Ruby object we want.*/ - - /* Convert the Ruby number to a Ruby object */ - return NUM2SWIG(reference); -} - -/* Add a Tracking from a C/C++ struct to a Ruby object */ -SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) { - /* In a Ruby hash table we store the pointer and - the associated Ruby object. The trick here is - that we cannot store the Ruby object directly - if - we do then it cannot be garbage collected. So - instead we typecast it as a unsigned long and - convert it to a Ruby number object.*/ - - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Get a reference to the Ruby object as a Ruby number */ - VALUE value = SWIG_RubyObjectToReference(object); - - /* Store the mapping to the global hash table. */ - rb_hash_aset(swig_ruby_trackings, key, value); -} - -/* Get the Ruby object that owns the specified C/C++ struct */ -SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Now lookup the value stored in the global hash table */ - VALUE value = rb_hash_aref(swig_ruby_trackings, key); - - if (value == Qnil) { - /* No object exists - return nil. */ - return Qnil; - } - else { - /* Convert this value to Ruby object */ - return SWIG_RubyReferenceToObject(value); - } -} - -/* Remove a Tracking from a C/C++ struct to a Ruby object. It - is very important to remove objects once they are destroyed - since the same memory address may be reused later to create - a new object. */ -SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { - /* Get a reference to the pointer as a Ruby number */ - VALUE key = SWIG_RubyPtrToReference(ptr); - - /* Delete the object from the hash table by calling Ruby's - do this we need to call the Hash.delete method.*/ - rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key); -} - -/* This is a helper method that unlinks a Ruby object from its - underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ -SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { - VALUE object = SWIG_RubyInstanceFor(ptr); - - if (object != Qnil) { - DATA_PTR(object) = 0; - } -} - - -#ifdef __cplusplus -} -#endif - -/* ----------------------------------------------------------------------------- - * Ruby API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#endif - -SWIGINTERN VALUE -SWIG_Ruby_AppendOutput(VALUE target, VALUE o) { - if (NIL_P(target)) { - target = o; - } else { - if (TYPE(target) != T_ARRAY) { - VALUE o2 = target; - target = rb_ary_new(); - rb_ary_push(target, o2); - } - rb_ary_push(target, o); - } - return target; -} - -/* For ruby1.8.4 and earlier. */ -#ifndef RUBY_INIT_STACK - RUBY_EXTERN void Init_stack(VALUE* addr); -# define RUBY_INIT_STACK \ - VALUE variable_in_this_stack_frame; \ - Init_stack(&variable_in_this_stack_frame); -#endif - - -#ifdef __cplusplus -} -#endif - - -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * rubyrun.swg - * - * This file contains the runtime support for Ruby modules - * and includes code for managing global variables and pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* For backward compatibility only */ -#define SWIG_POINTER_EXCEPTION 0 - -/* for raw pointers */ -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own) -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags) -#define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own) -#define swig_owntype ruby_owntype - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer) - - -/* Error manipulation */ - -#define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) -#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Ruby-specific SWIG API */ - -#define SWIG_InitRuntime() SWIG_Ruby_InitRuntime() -#define SWIG_define_class(ty) SWIG_Ruby_define_class(ty) -#define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty) -#define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value) -#define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty) - -#include "assert.h" - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - VALUE klass; - VALUE mImpl; - void (*mark)(void *); - void (*destroy)(void *); - int trackObjects; -} swig_class; - - -/* Global pointer used to keep some internal SWIG stuff */ -static VALUE _cSWIG_Pointer = Qnil; -static VALUE swig_runtime_data_type_pointer = Qnil; - -/* Global IDs used to keep some internal SWIG stuff */ -static ID swig_arity_id = 0; -static ID swig_call_id = 0; - -/* - If your swig extension is to be run within an embedded ruby and has - director callbacks, you should set -DRUBY_EMBEDDED during compilation. - This will reset ruby's stack frame on each entry point from the main - program the first time a virtual director function is invoked (in a - non-recursive way). - If this is not done, you run the risk of Ruby trashing the stack. -*/ - -#ifdef RUBY_EMBEDDED - -# define SWIG_INIT_STACK \ - if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \ - ++swig_virtual_calls; -# define SWIG_RELEASE_STACK --swig_virtual_calls; -# define Ruby_DirectorTypeMismatchException(x) \ - rb_raise( rb_eTypeError, x ); return c_result; - - static unsigned int swig_virtual_calls = 0; - -#else /* normal non-embedded extension */ - -# define SWIG_INIT_STACK -# define SWIG_RELEASE_STACK -# define Ruby_DirectorTypeMismatchException(x) \ - throw Swig::DirectorTypeMismatchException( x ); - -#endif /* RUBY_EMBEDDED */ - - -SWIGRUNTIME VALUE -getExceptionClass(void) { - static int init = 0; - static VALUE rubyExceptionClass ; - if (!init) { - init = 1; - rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception")); - } - return rubyExceptionClass; -} - -/* This code checks to see if the Ruby object being raised as part - of an exception inherits from the Ruby class Exception. If so, - the object is simply returned. If not, then a new Ruby exception - object is created and that will be returned to Ruby.*/ -SWIGRUNTIME VALUE -SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) { - VALUE exceptionClass = getExceptionClass(); - if (rb_obj_is_kind_of(obj, exceptionClass)) { - return obj; - } else { - return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj)); - } -} - -/* Initialize Ruby runtime support */ -SWIGRUNTIME void -SWIG_Ruby_InitRuntime(void) -{ - if (_mSWIG == Qnil) { - _mSWIG = rb_define_module("SWIG"); - swig_call_id = rb_intern("call"); - swig_arity_id = rb_intern("arity"); - } -} - -/* Define Ruby class for C type */ -SWIGRUNTIME void -SWIG_Ruby_define_class(swig_type_info *type) -{ - VALUE klass; - char *klass_name = (char *) malloc(4 + strlen(type->name) + 1); - sprintf(klass_name, "TYPE%s", type->name); - if (NIL_P(_cSWIG_Pointer)) { - _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject); - rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new"); - } - klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer); - free((void *) klass_name); -} - -/* Create a new pointer object */ -SWIGRUNTIME VALUE -SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) -{ - int own = flags & SWIG_POINTER_OWN; - int track; - char *klass_name; - swig_class *sklass; - VALUE klass; - VALUE obj; - - if (!ptr) - return Qnil; - - if (type->clientdata) { - sklass = (swig_class *) type->clientdata; - - /* Are we tracking this class and have we already returned this Ruby object? */ - track = sklass->trackObjects; - if (track) { - obj = SWIG_RubyInstanceFor(ptr); - - /* Check the object's type and make sure it has the correct type. - It might not in cases where methods do things like - downcast methods. */ - if (obj != Qnil) { - VALUE value = rb_iv_get(obj, "@__swigtype__"); - char* type_name = RSTRING_PTR(value); - - if (strcmp(type->name, type_name) == 0) { - return obj; - } - } - } - - /* Create a new Ruby object */ - obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), - ( own ? VOIDFUNC(sklass->destroy) : - (track ? VOIDFUNC(SWIG_RubyRemoveTracking) : 0 ) - ), ptr); - - /* If tracking is on for this class then track this object. */ - if (track) { - SWIG_RubyAddTracking(ptr, obj); - } - } else { - klass_name = (char *) malloc(4 + strlen(type->name) + 1); - sprintf(klass_name, "TYPE%s", type->name); - klass = rb_const_get(_mSWIG, rb_intern(klass_name)); - free((void *) klass_name); - obj = Data_Wrap_Struct(klass, 0, 0, ptr); - } - rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - - return obj; -} - -/* Create a new class instance (always owned) */ -SWIGRUNTIME VALUE -SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type) -{ - VALUE obj; - swig_class *sklass = (swig_class *) type->clientdata; - obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0); - rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - return obj; -} - -/* Get type mangle from class name */ -SWIGRUNTIMEINLINE char * -SWIG_Ruby_MangleStr(VALUE obj) -{ - VALUE stype = rb_iv_get(obj, "@__swigtype__"); - return StringValuePtr(stype); -} - -/* Acquire a pointer value */ -typedef void (*ruby_owntype)(void*); - -SWIGRUNTIME ruby_owntype -SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) { - if (obj) { - ruby_owntype oldown = RDATA(obj)->dfree; - RDATA(obj)->dfree = own; - return oldown; - } else { - return 0; - } -} - -/* Convert a pointer value */ -SWIGRUNTIME int -SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own) -{ - char *c; - swig_cast_info *tc; - void *vptr = 0; - - /* Grab the pointer */ - if (NIL_P(obj)) { - *ptr = 0; - return SWIG_OK; - } else { - if (TYPE(obj) != T_DATA) { - return SWIG_ERROR; - } - Data_Get_Struct(obj, void, vptr); - } - - if (own) *own = RDATA(obj)->dfree; - - /* Check to see if the input object is giving up ownership - of the underlying C struct or C++ object. If so then we - need to reset the destructor since the Ruby object no - longer owns the underlying C++ object.*/ - if (flags & SWIG_POINTER_DISOWN) { - /* Is tracking on for this class? */ - int track = 0; - if (ty && ty->clientdata) { - swig_class *sklass = (swig_class *) ty->clientdata; - track = sklass->trackObjects; - } - - if (track) { - /* We are tracking objects for this class. Thus we change the destructor - * to SWIG_RubyRemoveTracking. This allows us to - * remove the mapping from the C++ to Ruby object - * when the Ruby object is garbage collected. If we don't - * do this, then it is possible we will return a reference - * to a Ruby object that no longer exists thereby crashing Ruby. */ - RDATA(obj)->dfree = SWIG_RubyRemoveTracking; - } else { - RDATA(obj)->dfree = 0; - } - } - - /* Do type-checking if type info was provided */ - if (ty) { - if (ty->clientdata) { - if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) { - if (vptr == 0) { - /* The object has already been deleted */ - return SWIG_ObjectPreviouslyDeletedError; - } - *ptr = vptr; - return SWIG_OK; - } - } - if ((c = SWIG_MangleStr(obj)) == NULL) { - return SWIG_ERROR; - } - tc = SWIG_TypeCheck(c, ty); - if (!tc) { - return SWIG_ERROR; - } else { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc, vptr, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } - } else { - *ptr = vptr; - } - - return SWIG_OK; -} - -/* Check convert */ -SWIGRUNTIMEINLINE int -SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty) -{ - char *c = SWIG_MangleStr(obj); - if (!c) return 0; - return SWIG_TypeCheck(c,ty) != 0; -} - -SWIGRUNTIME VALUE -SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { - char result[1024]; - char *r = result; - if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; - *(r++) = '_'; - r = SWIG_PackData(r, ptr, sz); - strcpy(r, type->name); - return rb_str_new2(result); -} - -/* Convert a packed value value */ -SWIGRUNTIME int -SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { - swig_cast_info *tc; - const char *c; - - if (TYPE(obj) != T_STRING) goto type_error; - c = StringValuePtr(obj); - /* Pointer values must start with leading underscore */ - if (*c != '_') goto type_error; - c++; - c = SWIG_UnpackData(c, ptr, sz); - if (ty) { - tc = SWIG_TypeCheck(c, ty); - if (!tc) goto type_error; - } - return SWIG_OK; - - type_error: - return SWIG_ERROR; -} - -SWIGRUNTIME swig_module_info * -SWIG_Ruby_GetModule(void) -{ - VALUE pointer; - swig_module_info *ret = 0; - VALUE verbose = rb_gv_get("VERBOSE"); - - /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */ - rb_gv_set("VERBOSE", Qfalse); - - /* first check if pointer already created */ - pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME); - if (pointer != Qnil) { - Data_Get_Struct(pointer, swig_module_info, ret); - } - - /* reinstate warnings */ - rb_gv_set("VERBOSE", verbose); - return ret; -} - -SWIGRUNTIME void -SWIG_Ruby_SetModule(swig_module_info *pointer) -{ - /* register a new class */ - VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); - /* create and store the structure pointer to a global variable */ - swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); - rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer); -} - -/* This function can be used to check whether a proc or method or similarly - callable function has been passed. Usually used in a %typecheck, like: - - %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) { - $result = SWIG_Ruby_isCallable( $input ); - } - */ -SWIGINTERN -int SWIG_Ruby_isCallable( VALUE proc ) -{ - if ( rb_respond_to( proc, swig_call_id ) == Qtrue ) - return 1; - return 0; -} - -/* This function can be used to check the arity (number of arguments) - a proc or method can take. Usually used in a %typecheck. - Valid arities will be that equal to minimal or those < 0 - which indicate a variable number of parameters at the end. - */ -SWIGINTERN -int SWIG_Ruby_arity( VALUE proc, int minimal ) -{ - if ( rb_respond_to( proc, swig_arity_id ) == Qtrue ) - { - VALUE num = rb_funcall( proc, swig_arity_id, 0 ); - int arity = NUM2INT(num); - if ( arity < 0 && (arity+1) < -minimal ) return 1; - if ( arity == minimal ) return 1; - return 1; - } - return 0; -} - - -#ifdef __cplusplus -} -#endif - - - -#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) - -#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else - - - -/* -------- TYPES TABLE (BEGIN) -------- */ - -#define SWIGTYPE_p_CallbackData swig_types[0] -#define SWIGTYPE_p_char swig_types[1] -#define SWIGTYPE_p_f_p_sqlite3_context__void swig_types[2] -#define SWIGTYPE_p_f_p_sqlite3_context_int_p_p_sqlite3_value__void swig_types[3] -#define SWIGTYPE_p_f_p_void__void swig_types[4] -#define SWIGTYPE_p_f_p_void_int__int swig_types[5] -#define SWIGTYPE_p_f_p_void_int_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__int swig_types[6] -#define SWIGTYPE_p_f_p_void_p_q_const__char__void swig_types[7] -#define SWIGTYPE_p_p_char swig_types[8] -#define SWIGTYPE_p_p_sqlite3 swig_types[9] -#define SWIGTYPE_p_p_sqlite3_stmt swig_types[10] -#define SWIGTYPE_p_p_void swig_types[11] -#define SWIGTYPE_p_sqlite3 swig_types[12] -#define SWIGTYPE_p_sqlite3_context swig_types[13] -#define SWIGTYPE_p_sqlite3_stmt swig_types[14] -#define SWIGTYPE_p_sqlite3_value swig_types[15] -#define SWIGTYPE_p_sqlite_int64 swig_types[16] -#define SWIGTYPE_p_void swig_types[17] -static swig_type_info *swig_types[19]; -static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0}; -#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) -#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) - -/* -------- TYPES TABLE (END) -------- */ - -#define SWIG_init Init_API -#define SWIG_name "SQLite3::Driver::Native::API" - -static VALUE mAPI; - -#define SWIG_RUBY_THREAD_BEGIN_BLOCK -#define SWIG_RUBY_THREAD_END_BLOCK - - -#define SWIGVERSION 0x010339 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) - - -#ifdef __cplusplus -extern "C" { -#endif - -// Ruby 1.9 changed the file name of this header -#ifdef HAVE_RUBY_IO_H -#include "ruby/io.h" -#else -#include "rubyio.h" -#endif - -#ifdef __cplusplus -} -#endif - - -#ifdef __cplusplus -extern "C" { -#endif -#ifdef HAVE_SYS_TIME_H -# include -struct timeval rb_time_timeval(VALUE); -#endif -#ifdef __cplusplus -} -#endif - - -#include -#include "ruby.h" - -#ifndef RSTRING_PTR -#define RSTRING_PTR(s) (RSTRING(s)->ptr) -#endif - -#ifndef RSTRING_LEN -#define RSTRING_LEN(s) (RSTRING(s)->len) -#endif - -#ifndef STR2CSTR -#define STR2CSTR StringValueCStr -#endif - -#define Init_API Init_sqlite3_api - -struct CallbackData { - VALUE proc; - VALUE proc2; - VALUE data; -}; - -typedef struct CallbackData CallbackData; -typedef void RUBY_BLOB; -typedef void RUBY_VALBLOB; - -int Sqlite3_ruby_busy_handler(void* data,int value) { - VALUE result; - CallbackData *cb = (CallbackData*)data; - result = rb_funcall( - cb->proc, rb_intern("call"), 2, cb->data, INT2FIX(value) ); - return FIX2INT(result); -} - -static void mark_CallbackData(void* ptr) { - CallbackData* cb = (CallbackData*)ptr; - if (cb->proc != Qnil) - rb_gc_mark(cb->proc); - if (cb->proc2 != Qnil) - rb_gc_mark(cb->proc2); - if (cb->data != Qnil) - rb_gc_mark(cb->data); -} - -int Sqlite3_ruby_authorizer(void* data,int type, - const char* a,const char* b,const char* c,const char* d) -{ - VALUE result; - CallbackData *cb = (CallbackData*)data; - result = rb_funcall( - cb->proc, rb_intern("call"), 6, cb->data, INT2FIX(type), - ( a ? rb_str_new2(a) : Qnil ), ( b ? rb_str_new2(b) : Qnil ), - ( c ? rb_str_new2(c) : Qnil ), ( d ? rb_str_new2(d) : Qnil ) ); - return FIX2INT(result); -} - -void Sqlite3_ruby_trace(void* data, const char *sql) { - CallbackData *cb = (CallbackData*)data; - rb_funcall( cb->proc, rb_intern("call"), 2, cb->data, - sql ? rb_str_new2(sql) : Qnil ); -} - -void Sqlite3_ruby_function_step(sqlite3_context* ctx,int n, - sqlite3_value** args) -{ - CallbackData *data; - VALUE rb_args; - VALUE *rb_context; - int idx; - - data = (CallbackData*)sqlite3_user_data(ctx); - - if( data->proc2 != Qnil ) { - rb_context = (VALUE*)sqlite3_aggregate_context(ctx,sizeof(VALUE)); - if( *rb_context == 0 ) { - *rb_context = rb_hash_new(); - rb_gc_register_address( rb_context ); - } - } - - rb_args = rb_ary_new2(n+1); - rb_ary_push( rb_args, SWIG_NewPointerObj(ctx,SWIGTYPE_p_sqlite3_context,0) ); - for( idx = 0; idx < n; idx++ ) { - rb_ary_push( rb_args, SWIG_NewPointerObj(args[idx], - SWIGTYPE_p_sqlite3_value,0) ); - } - - rb_apply( data->proc, rb_intern("call"), rb_args ); -} - -void Sqlite3_ruby_function_final(sqlite3_context *ctx) { - VALUE *rb_context; - CallbackData *data; - - rb_context = (VALUE*)sqlite3_aggregate_context(ctx,sizeof(VALUE)); - if( *rb_context == 0 ) { - *rb_context = rb_hash_new(); - rb_gc_register_address( rb_context ); - } - - data = (CallbackData*)sqlite3_user_data(ctx); - - rb_funcall( data->proc2, rb_intern("call"), 1, - SWIG_NewPointerObj(ctx,SWIGTYPE_p_sqlite3_context,0) ); - - rb_gc_unregister_address( rb_context ); -} - - -#include -#if !defined(SWIG_NO_LLONG_MAX) -# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX - 1LL) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) -# endif -#endif - - - #define SWIG_From_long LONG2NUM - - -SWIGINTERNINLINE VALUE -SWIG_From_int (int value) -{ - return SWIG_From_long (value); -} - - -SWIGINTERN swig_type_info* -SWIG_pchar_descriptor(void) -{ - static int init = 0; - static swig_type_info* info = 0; - if (!init) { - info = SWIG_TypeQuery("_p_char"); - init = 1; - } - return info; -} - - -SWIGINTERN int -SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc) -{ - if (TYPE(obj) == T_STRING) { - #if defined(StringValuePtr) - char *cstr = StringValuePtr(obj); - #else - char *cstr = STR2CSTR(obj); - #endif - size_t size = RSTRING_LEN(obj) + 1; - if (cptr) { - if (alloc) { - if (*alloc == SWIG_NEWOBJ) { - *cptr = (char *)memcpy((char *)malloc((size)*sizeof(char)), cstr, sizeof(char)*(size)); - } else { - *cptr = cstr; - *alloc = SWIG_OLDOBJ; - } - } - } - if (psize) *psize = size; - return SWIG_OK; - } else { - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - if (pchar_descriptor) { - void* vptr = 0; - if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { - if (cptr) *cptr = (char *)vptr; - if (psize) *psize = vptr ? (strlen((char*)vptr) + 1) : 0; - if (alloc) *alloc = SWIG_OLDOBJ; - return SWIG_OK; - } - } - } - return SWIG_TypeError; -} - - - - - -SWIGINTERN VALUE -SWIG_ruby_failed(void) -{ - return Qnil; -} - - -/*@SWIG:C:\\Users\\Luis\\Downloads\\swigwin-1.3.39\\Lib\\ruby\\rubyprimtypes.swg,23,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args) -{ - VALUE obj = args[0]; - VALUE type = TYPE(obj); - long *res = (long *)(args[1]); - *res = type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj); - return obj; -} -/*@SWIG@*/ - -SWIGINTERN int -SWIG_AsVal_long (VALUE obj, long* val) -{ - VALUE type = TYPE(obj); - if ((type == T_FIXNUM) || (type == T_BIGNUM)) { - long v; - VALUE a[2]; - a[0] = obj; - a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { - if (val) *val = v; - return SWIG_OK; - } - } - return SWIG_TypeError; -} - - -SWIGINTERN int -SWIG_AsVal_int (VALUE obj, int *val) -{ - long v; - int res = SWIG_AsVal_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v < INT_MIN || v > INT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = (int)(v); - } - } - return res; -} - - -/*@SWIG:C:\\Users\\Luis\\Downloads\\swigwin-1.3.39\\Lib\\ruby\\rubyprimtypes.swg,23,%ruby_aux_method@*/ -SWIGINTERN VALUE SWIG_AUX_NUM2DBL(VALUE *args) -{ - VALUE obj = args[0]; - VALUE type = TYPE(obj); - double *res = (double *)(args[1]); - *res = (type == T_FLOAT ? NUM2DBL(obj) : (type == T_FIXNUM ? (double) FIX2INT(obj) : rb_big2dbl(obj))); - return obj; -} -/*@SWIG@*/ - -SWIGINTERN int -SWIG_AsVal_double (VALUE obj, double *val) -{ - VALUE type = TYPE(obj); - if ((type == T_FLOAT) || (type == T_FIXNUM) || (type == T_BIGNUM)) { - double v; - VALUE a[2]; - a[0] = obj; - a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { - if (val) *val = v; - return SWIG_OK; - } - } - return SWIG_TypeError; -} - - - #define SWIG_From_double rb_float_new - -swig_class SwigClassCallbackData; - -SWIGINTERN VALUE -_wrap_CallbackData_proc_set(int argc, VALUE *argv, VALUE self) { - struct CallbackData *arg1 = (struct CallbackData *) 0 ; - VALUE arg2 = (VALUE) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CallbackData, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "struct CallbackData *","proc", 1, self )); - } - arg1 = (struct CallbackData *)(argp1); - arg2 = argv[0]; - if (arg1) (arg1)->proc = arg2; - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_CallbackData_proc_get(int argc, VALUE *argv, VALUE self) { - struct CallbackData *arg1 = (struct CallbackData *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - VALUE result; - VALUE vresult = Qnil; - - if ((argc < 0) || (argc > 0)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CallbackData, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "struct CallbackData *","proc", 1, self )); - } - arg1 = (struct CallbackData *)(argp1); - result = (VALUE) ((arg1)->proc); - vresult = result; - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_CallbackData_proc2_set(int argc, VALUE *argv, VALUE self) { - struct CallbackData *arg1 = (struct CallbackData *) 0 ; - VALUE arg2 = (VALUE) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CallbackData, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "struct CallbackData *","proc2", 1, self )); - } - arg1 = (struct CallbackData *)(argp1); - arg2 = argv[0]; - if (arg1) (arg1)->proc2 = arg2; - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_CallbackData_proc2_get(int argc, VALUE *argv, VALUE self) { - struct CallbackData *arg1 = (struct CallbackData *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - VALUE result; - VALUE vresult = Qnil; - - if ((argc < 0) || (argc > 0)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CallbackData, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "struct CallbackData *","proc2", 1, self )); - } - arg1 = (struct CallbackData *)(argp1); - result = (VALUE) ((arg1)->proc2); - vresult = result; - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_CallbackData_data_set(int argc, VALUE *argv, VALUE self) { - struct CallbackData *arg1 = (struct CallbackData *) 0 ; - VALUE arg2 = (VALUE) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CallbackData, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "struct CallbackData *","data", 1, self )); - } - arg1 = (struct CallbackData *)(argp1); - arg2 = argv[0]; - if (arg1) (arg1)->data = arg2; - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_CallbackData_data_get(int argc, VALUE *argv, VALUE self) { - struct CallbackData *arg1 = (struct CallbackData *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - VALUE result; - VALUE vresult = Qnil; - - if ((argc < 0) || (argc > 0)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_CallbackData, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "struct CallbackData *","data", 1, self )); - } - arg1 = (struct CallbackData *)(argp1); - result = (VALUE) ((arg1)->data); - vresult = result; - return vresult; -fail: - return Qnil; -} - - -#ifdef HAVE_RB_DEFINE_ALLOC_FUNC -SWIGINTERN VALUE -_wrap_CallbackData_allocate(VALUE self) { -#else - SWIGINTERN VALUE - _wrap_CallbackData_allocate(int argc, VALUE *argv, VALUE self) { -#endif - - - VALUE vresult = SWIG_NewClassInstance(self, SWIGTYPE_p_CallbackData); -#ifndef HAVE_RB_DEFINE_ALLOC_FUNC - rb_obj_call_init(vresult, argc, argv); -#endif - return vresult; - } - - -SWIGINTERN VALUE -_wrap_new_CallbackData(int argc, VALUE *argv, VALUE self) { - struct CallbackData *result = 0 ; - - if ((argc < 0) || (argc > 0)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; - } - result = (struct CallbackData *)calloc(1, sizeof(struct CallbackData)); - DATA_PTR(self) = result; - return self; -fail: - return Qnil; -} - - -SWIGINTERN void -free_CallbackData(struct CallbackData *arg1) { - free((char *) arg1); -} - -SWIGINTERN VALUE -_wrap_sqlite3_libversion(int argc, VALUE *argv, VALUE self) { - char *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 0) || (argc > 0)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail; - } - result = (char *)sqlite3_libversion(); - { - vresult = result ? rb_str_new2(result) : Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_close(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_close", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - result = (int)sqlite3_close(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_last_insert_rowid(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - sqlite_int64 result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_last_insert_rowid", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - result = sqlite3_last_insert_rowid(arg1); - { - vresult = rb_ll2inum( result ); - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_changes(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_changes", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - result = (int)sqlite3_changes(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_total_changes(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_total_changes", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - result = (int)sqlite3_total_changes(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_interrupt(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_interrupt", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - sqlite3_interrupt(arg1); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_complete(int argc, VALUE *argv, VALUE self) { - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","sqlite3_complete", 1, argv[0] )); - } - arg1 = (char *)(buf1); - result = (int)sqlite3_complete((char const *)arg1); - vresult = SWIG_From_int((int)(result)); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return vresult; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_complete16(int argc, VALUE *argv, VALUE self) { - void *arg1 = (void *) 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - { - arg1 = (void*)RSTRING_PTR(argv[0]); - } - result = (int)sqlite3_complete16((void const *)arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_busy_handler(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - int (*arg2)(void *,int) = (int (*)(void *,int)) 0 ; - void *arg3 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res3 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 3) || (argc > 3)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_busy_handler", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(argv[1], (void**)(&arg2), SWIGTYPE_p_f_p_void_int__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), Ruby_Format_TypeError( "", "int (*)(void *,int)","sqlite3_busy_handler", 2, argv[1] )); - } - } - res3 = SWIG_ConvertPtr(argv[2],SWIG_as_voidptrptr(&arg3), 0, 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "void *","sqlite3_busy_handler", 3, argv[2] )); - } - result = (int)sqlite3_busy_handler(arg1,arg2,arg3); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_busy_timeout(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_busy_timeout", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_busy_timeout", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (int)sqlite3_busy_timeout(arg1,arg2); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_set_authorizer(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - int (*arg2)(void *,int,char const *,char const *,char const *,char const *) = (int (*)(void *,int,char const *,char const *,char const *,char const *)) 0 ; - void *arg3 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res3 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 3) || (argc > 3)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_set_authorizer", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(argv[1], (void**)(&arg2), SWIGTYPE_p_f_p_void_int_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), Ruby_Format_TypeError( "", "int (*)(void *,int,char const *,char const *,char const *,char const *)","sqlite3_set_authorizer", 2, argv[1] )); - } - } - res3 = SWIG_ConvertPtr(argv[2],SWIG_as_voidptrptr(&arg3), 0, 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "void *","sqlite3_set_authorizer", 3, argv[2] )); - } - result = (int)sqlite3_set_authorizer(arg1,arg2,arg3); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_trace(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void (*arg2)(void *,char const *) = (void (*)(void *,char const *)) 0 ; - void *arg3 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res3 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 3) || (argc > 3)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_trace", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(argv[1], (void**)(&arg2), SWIGTYPE_p_f_p_void_p_q_const__char__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), Ruby_Format_TypeError( "", "void (*)(void *,char const *)","sqlite3_trace", 2, argv[1] )); - } - } - res3 = SWIG_ConvertPtr(argv[2],SWIG_as_voidptrptr(&arg3), 0, 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), Ruby_Format_TypeError( "", "void *","sqlite3_trace", 3, argv[2] )); - } - result = (int)sqlite3_trace(arg1,arg2,arg3); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_open(int argc, VALUE *argv, VALUE self) { - char *arg1 = (char *) 0 ; - sqlite3 **arg2 = (sqlite3 **) 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - { - arg1 = STR2CSTR(argv[0]); - arg2 = (sqlite3**)malloc( sizeof( sqlite3* ) ); - } - result = (int)sqlite3_open((char const *)arg1,arg2); - vresult = SWIG_From_int((int)(result)); - { - VALUE ary; - ary = rb_ary_new2(2); - rb_ary_push( ary, vresult ); - rb_ary_push( ary, SWIG_NewPointerObj( *arg2, SWIGTYPE_p_sqlite3, 0 ) ); - free( arg2 ); - vresult = ary; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_open16(int argc, VALUE *argv, VALUE self) { - void *arg1 = (void *) 0 ; - sqlite3 **arg2 = (sqlite3 **) 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - { - arg1 = (void*)RSTRING_PTR(argv[0]); - arg2 = (sqlite3**)malloc( sizeof( sqlite3* ) ); - } - result = (int)sqlite3_open16((void const *)arg1,arg2); - vresult = SWIG_From_int((int)(result)); - { - VALUE ary; - ary = rb_ary_new2(2); - rb_ary_push( ary, vresult ); - rb_ary_push( ary, SWIG_NewPointerObj( *arg2, SWIGTYPE_p_sqlite3, 0 ) ); - free( arg2 ); - vresult = ary; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_errcode(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_errcode", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - result = (int)sqlite3_errcode(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_errmsg(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_errmsg", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - result = (char *)sqlite3_errmsg(arg1); - { - vresult = result ? rb_str_new2(result) : Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_errmsg16(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_errmsg16", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - result = (void *)sqlite3_errmsg16(arg1); - { - int i; - if( result ) { - for( i = 0; ((char*)result)[i]; i += 2 ); - vresult = rb_str_new( (char*)result, i ); - } else vresult = Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_prepare(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - sqlite3_stmt **arg4 = (sqlite3_stmt **) 0 ; - char **arg5 = (char **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - sqlite3_stmt *stmt2 ; - char *errmsg2 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_prepare", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - { - arg2 = RSTRING_PTR(argv[1]); - arg3 = RSTRING_LEN(argv[1]); - arg4 = &stmt2; - arg5 = &errmsg2; - } - result = (int)sqlite3_prepare(arg1,(char const *)arg2,arg3,arg4,(char const **)arg5); - vresult = SWIG_From_int((int)(result)); - { - VALUE ary; - ary = rb_ary_new2(3); - rb_ary_push( ary, vresult ); - rb_ary_push( ary, SWIG_NewPointerObj( stmt2, SWIGTYPE_p_sqlite3_stmt, 0 ) ); - rb_ary_push( ary, errmsg2 ? rb_str_new2( errmsg2 ) : Qnil ); - vresult = ary; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_prepare16(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - sqlite3_stmt **arg4 = (sqlite3_stmt **) 0 ; - void **arg5 = (void **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - sqlite3_stmt *stmt2 ; - void *errmsg2 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_prepare16", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - { - arg2 = RSTRING_PTR(argv[1]); - arg3 = RSTRING_LEN(argv[1]); - arg4 = &stmt2; - arg5 = &errmsg2; - } - result = (int)sqlite3_prepare16(arg1,(void const *)arg2,arg3,arg4,(void const **)arg5); - vresult = SWIG_From_int((int)(result)); - { - VALUE ary; - int i; - - for( i = 0; ((char*)errmsg2)[i]; i += 2 ); - - ary = rb_ary_new2(3); - rb_ary_push( ary, vresult ); - rb_ary_push( ary, SWIG_NewPointerObj( stmt2, SWIGTYPE_p_sqlite3_stmt, 0 ) ); - rb_ary_push( ary, errmsg2 ? rb_str_new( (char*)errmsg2, i ) : Qnil ); - vresult = ary; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_blob(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *arg3 = (void *) 0 ; - int arg4 ; - void (*arg5)(void *) = (void (*)(void *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 3) || (argc > 3)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_blob", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_bind_blob", 2, argv[1] )); - } - arg2 = (int)(val2); - { - arg3 = (void*)RSTRING_PTR(argv[2]); - arg4 = RSTRING_LEN(argv[2]); - arg5 = SQLITE_TRANSIENT; - } - result = (int)sqlite3_bind_blob(arg1,arg2,(void const *)arg3,arg4,arg5); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_double(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - double arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - double val3 ; - int ecode3 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 3) || (argc > 3)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_double", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_bind_double", 2, argv[1] )); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_double(argv[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "double","sqlite3_bind_double", 3, argv[2] )); - } - arg3 = (double)(val3); - result = (int)sqlite3_bind_double(arg1,arg2,arg3); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_int(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 3) || (argc > 3)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_int", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_bind_int", 2, argv[1] )); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_int(argv[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "int","sqlite3_bind_int", 3, argv[2] )); - } - arg3 = (int)(val3); - result = (int)sqlite3_bind_int(arg1,arg2,arg3); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_int64(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - sqlite_int64 arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 3) || (argc > 3)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_int64", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_bind_int64", 2, argv[1] )); - } - arg2 = (int)(val2); - { - arg3 = rb_num2ll( argv[2] ); - } - result = (int)sqlite3_bind_int64(arg1,arg2,arg3); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_null(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_null", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_bind_null", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (int)sqlite3_bind_null(arg1,arg2); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_text(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - char *arg3 = (char *) 0 ; - int arg4 ; - void (*arg5)(void *) = (void (*)(void *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 3) || (argc > 3)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_text", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_bind_text", 2, argv[1] )); - } - arg2 = (int)(val2); - { - arg3 = RSTRING_PTR(argv[2]); - arg4 = RSTRING_LEN(argv[2]); - arg5 = SQLITE_TRANSIENT; - } - result = (int)sqlite3_bind_text(arg1,arg2,(char const *)arg3,arg4,arg5); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_text16(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *arg3 = (void *) 0 ; - int arg4 ; - void (*arg5)(void *) = (void (*)(void *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 3) || (argc > 3)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_text16", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_bind_text16", 2, argv[1] )); - } - arg2 = (int)(val2); - { - arg3 = (void*)RSTRING_PTR(argv[2]); - arg4 = RSTRING_LEN(argv[2]); - arg5 = SQLITE_TRANSIENT; - } - result = (int)sqlite3_bind_text16(arg1,arg2,(void const *)arg3,arg4,arg5); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_parameter_count(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_parameter_count", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - result = (int)sqlite3_bind_parameter_count(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_parameter_name(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - char *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_parameter_name", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_bind_parameter_name", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (char *)sqlite3_bind_parameter_name(arg1,arg2); - { - vresult = result ? rb_str_new2(result) : Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_bind_parameter_index(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_bind_parameter_index", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","sqlite3_bind_parameter_index", 2, argv[1] )); - } - arg2 = (char *)(buf2); - result = (int)sqlite3_bind_parameter_index(arg1,(char const *)arg2); - vresult = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return vresult; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_count(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_count", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - result = (int)sqlite3_column_count(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_name(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - char *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_name", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_name", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (char *)sqlite3_column_name(arg1,arg2); - { - vresult = result ? rb_str_new2(result) : Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_name16(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - void *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_name16", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_name16", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (void *)sqlite3_column_name16(arg1,arg2); - { - int i; - if( result ) { - for( i = 0; ((char*)result)[i]; i += 2 ); - vresult = rb_str_new( (char*)result, i ); - } else vresult = Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_decltype(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - char *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_decltype", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_decltype", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (char *)sqlite3_column_decltype(arg1,arg2); - { - vresult = result ? rb_str_new2(result) : Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_decltype16(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - void *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_decltype16", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_decltype16", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (void *)sqlite3_column_decltype16(arg1,arg2); - { - int i; - if( result ) { - for( i = 0; ((char*)result)[i]; i += 2 ); - vresult = rb_str_new( (char*)result, i ); - } else vresult = Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_step(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_step", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - result = (int)sqlite3_step(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_data_count(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_data_count", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - result = (int)sqlite3_data_count(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_blob(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - RUBY_BLOB *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_blob", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_blob", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (RUBY_BLOB *)sqlite3_column_blob(arg1,arg2); - { - vresult = result ? - rb_str_new( (char*)result, sqlite3_column_bytes( arg1, arg2 ) ) : Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_bytes(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_bytes", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_bytes", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (int)sqlite3_column_bytes(arg1,arg2); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_bytes16(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_bytes16", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_bytes16", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (int)sqlite3_column_bytes16(arg1,arg2); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_double(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - double result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_double", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_double", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (double)sqlite3_column_double(arg1,arg2); - vresult = SWIG_From_double((double)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_int(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - double result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_int", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_int", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (double)sqlite3_column_int(arg1,arg2); - vresult = SWIG_From_double((double)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_int64(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - sqlite_int64 result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_int64", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_int64", 2, argv[1] )); - } - arg2 = (int)(val2); - result = sqlite3_column_int64(arg1,arg2); - { - vresult = rb_ll2inum( result ); - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_text(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - char *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_text", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_text", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (char *)sqlite3_column_text(arg1,arg2); - { - vresult = result ? rb_str_new2(result) : Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_text16(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - void *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_text16", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_text16", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (void *)sqlite3_column_text16(arg1,arg2); - { - int i; - if( result ) { - for( i = 0; ((char*)result)[i]; i += 2 ); - vresult = rb_str_new( (char*)result, i ); - } else vresult = Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_column_type(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_column_type", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_column_type", 2, argv[1] )); - } - arg2 = (int)(val2); - result = (int)sqlite3_column_type(arg1,arg2); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_finalize(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_finalize", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - result = (int)sqlite3_finalize(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_reset(int argc, VALUE *argv, VALUE self) { - sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_stmt, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_stmt *","sqlite3_reset", 1, argv[0] )); - } - arg1 = (sqlite3_stmt *)(argp1); - result = (int)sqlite3_reset(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_create_function(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - int arg4 ; - void *arg5 = (void *) 0 ; - void (*arg6)(sqlite3_context *,int,sqlite3_value **) = (void (*)(sqlite3_context *,int,sqlite3_value **)) 0 ; - void (*arg7)(sqlite3_context *,int,sqlite3_value **) = (void (*)(sqlite3_context *,int,sqlite3_value **)) 0 ; - void (*arg8)(sqlite3_context *) = (void (*)(sqlite3_context *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - int res5 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 8) || (argc > 8)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 8)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_create_function", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","sqlite3_create_function", 2, argv[1] )); - } - arg2 = (char *)(buf2); - ecode3 = SWIG_AsVal_int(argv[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "int","sqlite3_create_function", 3, argv[2] )); - } - arg3 = (int)(val3); - ecode4 = SWIG_AsVal_int(argv[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "int","sqlite3_create_function", 4, argv[3] )); - } - arg4 = (int)(val4); - res5 = SWIG_ConvertPtr(argv[4],SWIG_as_voidptrptr(&arg5), 0, 0); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), Ruby_Format_TypeError( "", "void *","sqlite3_create_function", 5, argv[4] )); - } - { - int res = SWIG_ConvertFunctionPtr(argv[5], (void**)(&arg6), SWIGTYPE_p_f_p_sqlite3_context_int_p_p_sqlite3_value__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), Ruby_Format_TypeError( "", "void (*)(sqlite3_context *,int,sqlite3_value **)","sqlite3_create_function", 6, argv[5] )); - } - } - { - int res = SWIG_ConvertFunctionPtr(argv[6], (void**)(&arg7), SWIGTYPE_p_f_p_sqlite3_context_int_p_p_sqlite3_value__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), Ruby_Format_TypeError( "", "void (*)(sqlite3_context *,int,sqlite3_value **)","sqlite3_create_function", 7, argv[6] )); - } - } - { - int res = SWIG_ConvertFunctionPtr(argv[7], (void**)(&arg8), SWIGTYPE_p_f_p_sqlite3_context__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), Ruby_Format_TypeError( "", "void (*)(sqlite3_context *)","sqlite3_create_function", 8, argv[7] )); - } - } - result = (int)sqlite3_create_function(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7,arg8); - vresult = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return vresult; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_create_function16(int argc, VALUE *argv, VALUE self) { - sqlite3 *arg1 = (sqlite3 *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - int arg4 ; - void *arg5 = (void *) 0 ; - void (*arg6)(sqlite3_context *,int,sqlite3_value **) = (void (*)(sqlite3_context *,int,sqlite3_value **)) 0 ; - void (*arg7)(sqlite3_context *,int,sqlite3_value **) = (void (*)(sqlite3_context *,int,sqlite3_value **)) 0 ; - void (*arg8)(sqlite3_context *) = (void (*)(sqlite3_context *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - int res5 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 8) || (argc > 8)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 8)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3 *","sqlite3_create_function16", 1, argv[0] )); - } - arg1 = (sqlite3 *)(argp1); - { - arg2 = (void*)RSTRING_PTR(argv[1]); - } - ecode3 = SWIG_AsVal_int(argv[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "int","sqlite3_create_function16", 3, argv[2] )); - } - arg3 = (int)(val3); - ecode4 = SWIG_AsVal_int(argv[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "int","sqlite3_create_function16", 4, argv[3] )); - } - arg4 = (int)(val4); - res5 = SWIG_ConvertPtr(argv[4],SWIG_as_voidptrptr(&arg5), 0, 0); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), Ruby_Format_TypeError( "", "void *","sqlite3_create_function16", 5, argv[4] )); - } - { - int res = SWIG_ConvertFunctionPtr(argv[5], (void**)(&arg6), SWIGTYPE_p_f_p_sqlite3_context_int_p_p_sqlite3_value__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), Ruby_Format_TypeError( "", "void (*)(sqlite3_context *,int,sqlite3_value **)","sqlite3_create_function16", 6, argv[5] )); - } - } - { - int res = SWIG_ConvertFunctionPtr(argv[6], (void**)(&arg7), SWIGTYPE_p_f_p_sqlite3_context_int_p_p_sqlite3_value__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), Ruby_Format_TypeError( "", "void (*)(sqlite3_context *,int,sqlite3_value **)","sqlite3_create_function16", 7, argv[6] )); - } - } - { - int res = SWIG_ConvertFunctionPtr(argv[7], (void**)(&arg8), SWIGTYPE_p_f_p_sqlite3_context__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), Ruby_Format_TypeError( "", "void (*)(sqlite3_context *)","sqlite3_create_function16", 8, argv[7] )); - } - } - result = (int)sqlite3_create_function16(arg1,(void const *)arg2,arg3,arg4,arg5,arg6,arg7,arg8); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_aggregate_count(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_aggregate_count", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - result = (int)sqlite3_aggregate_count(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_blob(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - RUBY_VALBLOB *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_blob", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (RUBY_VALBLOB *)sqlite3_value_blob(arg1); - { - vresult = result ? rb_str_new( (char*)result, sqlite3_value_bytes( arg1 ) ) : Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_bytes(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_bytes", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (int)sqlite3_value_bytes(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_bytes16(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_bytes16", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (int)sqlite3_value_bytes16(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_double(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - double result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_double", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (double)sqlite3_value_double(arg1); - vresult = SWIG_From_double((double)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_int(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_int", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (int)sqlite3_value_int(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_int64(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - sqlite_int64 result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_int64", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = sqlite3_value_int64(arg1); - { - vresult = rb_ll2inum( result ); - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_text(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - char *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_text", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (char *)sqlite3_value_text(arg1); - { - vresult = result ? rb_str_new2(result) : Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_text16(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_text16", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (void *)sqlite3_value_text16(arg1); - { - int i; - if( result ) { - for( i = 0; ((char*)result)[i]; i += 2 ); - vresult = rb_str_new( (char*)result, i ); - } else vresult = Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_text16le(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_text16le", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (void *)sqlite3_value_text16le(arg1); - { - int i; - if( result ) { - for( i = 0; ((char*)result)[i]; i += 2 ); - vresult = rb_str_new( (char*)result, i ); - } else vresult = Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_text16be(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_text16be", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (void *)sqlite3_value_text16be(arg1); - { - int i; - if( result ) { - for( i = 0; ((char*)result)[i]; i += 2 ); - vresult = rb_str_new( (char*)result, i ); - } else vresult = Qnil; - } - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_value_type(int argc, VALUE *argv, VALUE self) { - sqlite3_value *arg1 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int result; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_value_type", 1, argv[0] )); - } - arg1 = (sqlite3_value *)(argp1); - result = (int)sqlite3_value_type(arg1); - vresult = SWIG_From_int((int)(result)); - return vresult; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_blob(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - void (*arg4)(void *) = (void (*)(void *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_blob", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - { - arg2 = (void*)RSTRING_PTR(argv[1]); - arg3 = RSTRING_LEN(argv[1]); - arg4 = SQLITE_TRANSIENT; - } - sqlite3_result_blob(arg1,(void const *)arg2,arg3,arg4); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_double(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - double arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_double", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - ecode2 = SWIG_AsVal_double(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "double","sqlite3_result_double", 2, argv[1] )); - } - arg2 = (double)(val2); - sqlite3_result_double(arg1,arg2); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_error(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_error", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - { - arg2 = RSTRING_PTR(argv[1]); - arg3 = RSTRING_LEN(argv[1]); - } - sqlite3_result_error(arg1,(char const *)arg2,arg3); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_error16(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_error16", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - { - arg2 = (void*)RSTRING_PTR(argv[1]); - arg3 = RSTRING_LEN(argv[1]); - } - sqlite3_result_error16(arg1,(void const *)arg2,arg3); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_int(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_int", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - ecode2 = SWIG_AsVal_int(argv[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "int","sqlite3_result_int", 2, argv[1] )); - } - arg2 = (int)(val2); - sqlite3_result_int(arg1,arg2); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_int64(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - sqlite_int64 arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_int64", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - { - arg2 = rb_num2ll( argv[1] ); - } - sqlite3_result_int64(arg1,arg2); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_text(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - void (*arg4)(void *) = (void (*)(void *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_text", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - { - arg2 = RSTRING_PTR(argv[1]); - arg3 = RSTRING_LEN(argv[1]); - arg4 = SQLITE_TRANSIENT; - } - sqlite3_result_text(arg1,(char const *)arg2,arg3,arg4); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_text16(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - void (*arg4)(void *) = (void (*)(void *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_text16", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - { - arg2 = (void*)RSTRING_PTR(argv[1]); - arg3 = RSTRING_LEN(argv[1]); - arg4 = SQLITE_TRANSIENT; - } - sqlite3_result_text16(arg1,(void const *)arg2,arg3,arg4); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_text16le(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - void (*arg4)(void *) = (void (*)(void *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_text16le", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - { - arg2 = (void*)RSTRING_PTR(argv[1]); - arg3 = RSTRING_LEN(argv[1]); - arg4 = SQLITE_TRANSIENT; - } - sqlite3_result_text16le(arg1,(void const *)arg2,arg3,arg4); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_text16be(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - void (*arg4)(void *) = (void (*)(void *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_text16be", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - { - arg2 = (void*)RSTRING_PTR(argv[1]); - arg3 = RSTRING_LEN(argv[1]); - arg4 = SQLITE_TRANSIENT; - } - sqlite3_result_text16be(arg1,(void const *)arg2,arg3,arg4); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_result_value(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - sqlite3_value *arg2 = (sqlite3_value *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - - if ((argc < 2) || (argc > 2)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail; - } - res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_sqlite3_context, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "sqlite3_context *","sqlite3_result_value", 1, argv[0] )); - } - arg1 = (sqlite3_context *)(argp1); - res2 = SWIG_ConvertPtr(argv[1], &argp2,SWIGTYPE_p_sqlite3_value, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "sqlite3_value *","sqlite3_result_value", 2, argv[1] )); - } - arg2 = (sqlite3_value *)(argp2); - sqlite3_result_value(arg1,arg2); - return Qnil; -fail: - return Qnil; -} - - -SWIGINTERN VALUE -_wrap_sqlite3_aggregate_context(int argc, VALUE *argv, VALUE self) { - sqlite3_context *arg1 = (sqlite3_context *) 0 ; - int arg2 ; - VALUE *result = 0 ; - VALUE vresult = Qnil; - - if ((argc < 1) || (argc > 1)) { - rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail; - } - { - SWIG_ConvertPtr(argv[0],(void**)&arg1, SWIGTYPE_p_sqlite3_context, 1); - arg2 = 4; - } - result = (VALUE *)sqlite3_aggregate_context(arg1,arg2); - { - vresult = *(VALUE*)result; - } - return vresult; -fail: - return Qnil; -} - - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ - -static swig_type_info _swigt__p_CallbackData = {"_p_CallbackData", "CallbackData *|struct CallbackData *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_sqlite3_context__void = {"_p_f_p_sqlite3_context__void", "void (*)(sqlite3_context *)", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_sqlite3_context_int_p_p_sqlite3_value__void = {"_p_f_p_sqlite3_context_int_p_p_sqlite3_value__void", "void (*)(sqlite3_context *,int,sqlite3_value **)", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_void__void = {"_p_f_p_void__void", "void (*)(void *)", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_void_int__int = {"_p_f_p_void_int__int", "int (*)(void *,int)", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_void_int_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__int = {"_p_f_p_void_int_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__int", "int (*)(void *,int,char const *,char const *,char const *,char const *)", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_void_p_q_const__char__void = {"_p_f_p_void_p_q_const__char__void", "void (*)(void *,char const *)", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_sqlite3 = {"_p_p_sqlite3", "sqlite3 **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_sqlite3_stmt = {"_p_p_sqlite3_stmt", "sqlite3_stmt **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_void = {"_p_p_void", "void **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_sqlite3 = {"_p_sqlite3", "sqlite3 *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_sqlite3_context = {"_p_sqlite3_context", "sqlite3_context *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_sqlite3_stmt = {"_p_sqlite3_stmt", "sqlite3_stmt *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_sqlite3_value = {"_p_sqlite3_value", "sqlite3_value *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_sqlite_int64 = {"_p_sqlite_int64", "sqlite_int64 *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_void = {"_p_void", "RUBY_VALBLOB *|RUBY_BLOB *|void *", 0, 0, (void*)0, 0}; - -static swig_type_info *swig_type_initial[] = { - &_swigt__p_CallbackData, - &_swigt__p_char, - &_swigt__p_f_p_sqlite3_context__void, - &_swigt__p_f_p_sqlite3_context_int_p_p_sqlite3_value__void, - &_swigt__p_f_p_void__void, - &_swigt__p_f_p_void_int__int, - &_swigt__p_f_p_void_int_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__int, - &_swigt__p_f_p_void_p_q_const__char__void, - &_swigt__p_p_char, - &_swigt__p_p_sqlite3, - &_swigt__p_p_sqlite3_stmt, - &_swigt__p_p_void, - &_swigt__p_sqlite3, - &_swigt__p_sqlite3_context, - &_swigt__p_sqlite3_stmt, - &_swigt__p_sqlite3_value, - &_swigt__p_sqlite_int64, - &_swigt__p_void, -}; - -static swig_cast_info _swigc__p_CallbackData[] = { {&_swigt__p_CallbackData, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_sqlite3_context__void[] = { {&_swigt__p_f_p_sqlite3_context__void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_sqlite3_context_int_p_p_sqlite3_value__void[] = { {&_swigt__p_f_p_sqlite3_context_int_p_p_sqlite3_value__void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_void__void[] = { {&_swigt__p_f_p_void__void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_void_int__int[] = { {&_swigt__p_f_p_void_int__int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_void_int_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__int[] = { {&_swigt__p_f_p_void_int_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_void_p_q_const__char__void[] = { {&_swigt__p_f_p_void_p_q_const__char__void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_sqlite3[] = { {&_swigt__p_p_sqlite3, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_sqlite3_stmt[] = { {&_swigt__p_p_sqlite3_stmt, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_void[] = { {&_swigt__p_p_void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_sqlite3[] = { {&_swigt__p_sqlite3, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_sqlite3_context[] = { {&_swigt__p_sqlite3_context, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_sqlite3_stmt[] = { {&_swigt__p_sqlite3_stmt, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_sqlite3_value[] = { {&_swigt__p_sqlite3_value, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_sqlite_int64[] = { {&_swigt__p_sqlite_int64, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}}; - -static swig_cast_info *swig_cast_initial[] = { - _swigc__p_CallbackData, - _swigc__p_char, - _swigc__p_f_p_sqlite3_context__void, - _swigc__p_f_p_sqlite3_context_int_p_p_sqlite3_value__void, - _swigc__p_f_p_void__void, - _swigc__p_f_p_void_int__int, - _swigc__p_f_p_void_int_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__int, - _swigc__p_f_p_void_p_q_const__char__void, - _swigc__p_p_char, - _swigc__p_p_sqlite3, - _swigc__p_p_sqlite3_stmt, - _swigc__p_p_void, - _swigc__p_sqlite3, - _swigc__p_sqlite3_context, - _swigc__p_sqlite3_stmt, - _swigc__p_sqlite3_value, - _swigc__p_sqlite_int64, - _swigc__p_void, -}; - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ - -/* ----------------------------------------------------------------------------- - * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to - * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of - * swig_module, and does all the lookup, filling in the swig_module.types - * array with the correct data and linking the correct swig_cast_info - * structures together. - * - * The generated swig_type_info structures are assigned staticly to an initial - * array. We just loop through that array, and handle each type individually. - * First we lookup if this type has been already loaded, and if so, use the - * loaded structure instead of the generated one. Then we have to fill in the - * cast linked list. The cast data is initially stored in something like a - * two-dimensional array. Each row corresponds to a type (there are the same - * number of rows as there are in the swig_type_initial array). Each entry in - * a column is one of the swig_cast_info structures for that type. - * The cast_initial array is actually an array of arrays, because each row has - * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it - * adding the casts to the list. The one last trick we need to do is making - * sure the type pointer in the swig_cast_info struct is correct. - * - * First off, we lookup the cast->type name to see if it is already loaded. - * There are three cases to handle: - * 1) If the cast->type has already been loaded AND the type we are adding - * casting info to has not been loaded (it is in this module), THEN we - * replace the cast->type pointer with the type pointer that has already - * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the - * cast->type) are loaded, THEN the cast info has already been loaded by - * the previous module so we just ignore it. - * 3) Finally, if cast->type has not already been loaded, then we add that - * swig_cast_info to the linked list (because the cast->type) pointer will - * be correct. - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* c-mode */ -#endif -#endif - -#if 0 -#define SWIGRUNTIME_DEBUG -#endif - - -SWIGRUNTIME void -SWIG_InitializeModule(void *clientdata) { - size_t i; - swig_module_info *module_head, *iter; - int found, init; - - clientdata = clientdata; - - /* check to see if the circular list has been setup, if not, set it up */ - if (swig_module.next==0) { - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - swig_module.next = &swig_module; - init = 1; - } else { - init = 0; - } - - /* Try and load any already created modules */ - module_head = SWIG_GetModule(clientdata); - if (!module_head) { - /* This is the first module loaded for this interpreter */ - /* so set the swig module into the interpreter */ - SWIG_SetModule(clientdata, &swig_module); - module_head = &swig_module; - } else { - /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - found=0; - iter=module_head; - do { - if (iter==&swig_module) { - found=1; - break; - } - iter=iter->next; - } while (iter!= module_head); - - /* if the is found in the list, then all is done and we may leave */ - if (found) return; - /* otherwise we must add out module into the list */ - swig_module.next = module_head->next; - module_head->next = &swig_module; - } - - /* When multiple interpeters are used, a module could have already been initialized in - a different interpreter, but not yet have a pointer in this interpreter. - In this case, we do not want to continue adding types... everything should be - set up already */ - if (init == 0) return; - - /* Now work on filling in swig_module.types */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); -#endif - for (i = 0; i < swig_module.size; ++i) { - swig_type_info *type = 0; - swig_type_info *ret; - swig_cast_info *cast; - -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); -#endif - - /* if there is another module already loaded */ - if (swig_module.next != &swig_module) { - type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); - } - if (type) { - /* Overwrite clientdata field */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found type %s\n", type->name); -#endif - if (swig_module.type_initial[i]->clientdata) { - type->clientdata = swig_module.type_initial[i]->clientdata; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); -#endif - } - } else { - type = swig_module.type_initial[i]; - } - - /* Insert casting types */ - cast = swig_module.cast_initial[i]; - while (cast->type) { - - /* Don't need to add information already in the list */ - ret = 0; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); -#endif - if (swig_module.next != &swig_module) { - ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); -#ifdef SWIGRUNTIME_DEBUG - if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); -#endif - } - if (ret) { - if (type == swig_module.type_initial[i]) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: skip old type %s\n", ret->name); -#endif - cast->type = ret; - ret = 0; - } else { - /* Check for casting already in the list */ - swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); -#ifdef SWIGRUNTIME_DEBUG - if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); -#endif - if (!ocast) ret = 0; - } - } - - if (!ret) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); -#endif - if (type->cast) { - type->cast->prev = cast; - cast->next = type->cast; - } - type->cast = cast; - } - cast++; - } - /* Set entry in modules->types array equal to the type */ - swig_module.types[i] = type; - } - swig_module.types[i] = 0; - -#ifdef SWIGRUNTIME_DEBUG - printf("**** SWIG_InitializeModule: Cast List ******\n"); - for (i = 0; i < swig_module.size; ++i) { - int j = 0; - swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); - while (cast->type) { - printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); - cast++; - ++j; - } - printf("---- Total casts: %d\n",j); - } - printf("**** SWIG_InitializeModule: Cast List ******\n"); -#endif -} - -/* This function will propagate the clientdata field of type to -* any new swig_type_info structures that have been added into the list -* of equivalent types. It is like calling -* SWIG_TypeClientData(type, clientdata) a second time. -*/ -SWIGRUNTIME void -SWIG_PropagateClientData(void) { - size_t i; - swig_cast_info *equiv; - static int init_run = 0; - - if (init_run) return; - init_run = 1; - - for (i = 0; i < swig_module.size; i++) { - if (swig_module.types[i]->clientdata) { - equiv = swig_module.types[i]->cast; - while (equiv) { - if (!equiv->converter) { - if (equiv->type && !equiv->type->clientdata) - SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); - } - equiv = equiv->next; - } - } - } -} - -#ifdef __cplusplus -#if 0 -{ /* c-mode */ -#endif -} -#endif - -/* - -*/ -#ifdef __cplusplus -extern "C" -#endif -SWIGEXPORT void Init_API(void) { - size_t i; - - SWIG_InitRuntime(); - mAPI = rb_define_module("SQLite3"); - mAPI = rb_define_module_under(mAPI, "Driver"); - mAPI = rb_define_module_under(mAPI, "Native"); - mAPI = rb_define_module_under(mAPI, "API"); - - SWIG_InitializeModule(0); - for (i = 0; i < swig_module.size; i++) { - SWIG_define_class(swig_module.types[i]); - } - - SWIG_RubyInitializeTrackings(); - - SwigClassCallbackData.klass = rb_define_class_under(mAPI, "CallbackData", rb_cObject); - SWIG_TypeClientData(SWIGTYPE_p_CallbackData, (void *) &SwigClassCallbackData); - rb_define_alloc_func(SwigClassCallbackData.klass, _wrap_CallbackData_allocate); - rb_define_method(SwigClassCallbackData.klass, "initialize", _wrap_new_CallbackData, -1); - rb_define_method(SwigClassCallbackData.klass, "proc=", _wrap_CallbackData_proc_set, -1); - rb_define_method(SwigClassCallbackData.klass, "proc", _wrap_CallbackData_proc_get, -1); - rb_define_method(SwigClassCallbackData.klass, "proc2=", _wrap_CallbackData_proc2_set, -1); - rb_define_method(SwigClassCallbackData.klass, "proc2", _wrap_CallbackData_proc2_get, -1); - rb_define_method(SwigClassCallbackData.klass, "data=", _wrap_CallbackData_data_set, -1); - rb_define_method(SwigClassCallbackData.klass, "data", _wrap_CallbackData_data_get, -1); - SwigClassCallbackData.mark = (void (*)(void *)) mark_CallbackData; - SwigClassCallbackData.destroy = (void (*)(void *)) free_CallbackData; - SwigClassCallbackData.trackObjects = 0; - rb_define_const(mAPI, "Sqlite3_ruby_busy_handler", SWIG_NewFunctionPtrObj((void *)Sqlite3_ruby_busy_handler, SWIGTYPE_p_f_p_void_int__int)); - rb_define_const(mAPI, "Sqlite3_ruby_authorizer", SWIG_NewFunctionPtrObj((void *)Sqlite3_ruby_authorizer, SWIGTYPE_p_f_p_void_int_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char__int)); - rb_define_const(mAPI, "Sqlite3_ruby_trace", SWIG_NewFunctionPtrObj((void *)Sqlite3_ruby_trace, SWIGTYPE_p_f_p_void_p_q_const__char__void)); - rb_define_const(mAPI, "Sqlite3_ruby_function_step", SWIG_NewFunctionPtrObj((void *)Sqlite3_ruby_function_step, SWIGTYPE_p_f_p_sqlite3_context_int_p_p_sqlite3_value__void)); - rb_define_const(mAPI, "Sqlite3_ruby_function_final", SWIG_NewFunctionPtrObj((void *)Sqlite3_ruby_function_final, SWIGTYPE_p_f_p_sqlite3_context__void)); - rb_define_module_function(mAPI, "sqlite3_libversion", _wrap_sqlite3_libversion, -1); - rb_define_module_function(mAPI, "sqlite3_close", _wrap_sqlite3_close, -1); - rb_define_module_function(mAPI, "sqlite3_last_insert_rowid", _wrap_sqlite3_last_insert_rowid, -1); - rb_define_module_function(mAPI, "sqlite3_changes", _wrap_sqlite3_changes, -1); - rb_define_module_function(mAPI, "sqlite3_total_changes", _wrap_sqlite3_total_changes, -1); - rb_define_module_function(mAPI, "sqlite3_interrupt", _wrap_sqlite3_interrupt, -1); - rb_define_module_function(mAPI, "sqlite3_complete", _wrap_sqlite3_complete, -1); - rb_define_module_function(mAPI, "sqlite3_complete16", _wrap_sqlite3_complete16, -1); - rb_define_module_function(mAPI, "sqlite3_busy_handler", _wrap_sqlite3_busy_handler, -1); - rb_define_module_function(mAPI, "sqlite3_busy_timeout", _wrap_sqlite3_busy_timeout, -1); - rb_define_module_function(mAPI, "sqlite3_set_authorizer", _wrap_sqlite3_set_authorizer, -1); - rb_define_module_function(mAPI, "sqlite3_trace", _wrap_sqlite3_trace, -1); - rb_define_module_function(mAPI, "sqlite3_open", _wrap_sqlite3_open, -1); - rb_define_module_function(mAPI, "sqlite3_open16", _wrap_sqlite3_open16, -1); - rb_define_module_function(mAPI, "sqlite3_errcode", _wrap_sqlite3_errcode, -1); - rb_define_module_function(mAPI, "sqlite3_errmsg", _wrap_sqlite3_errmsg, -1); - rb_define_module_function(mAPI, "sqlite3_errmsg16", _wrap_sqlite3_errmsg16, -1); - rb_define_module_function(mAPI, "sqlite3_prepare", _wrap_sqlite3_prepare, -1); - rb_define_module_function(mAPI, "sqlite3_prepare16", _wrap_sqlite3_prepare16, -1); - rb_define_module_function(mAPI, "sqlite3_bind_blob", _wrap_sqlite3_bind_blob, -1); - rb_define_module_function(mAPI, "sqlite3_bind_double", _wrap_sqlite3_bind_double, -1); - rb_define_module_function(mAPI, "sqlite3_bind_int", _wrap_sqlite3_bind_int, -1); - rb_define_module_function(mAPI, "sqlite3_bind_int64", _wrap_sqlite3_bind_int64, -1); - rb_define_module_function(mAPI, "sqlite3_bind_null", _wrap_sqlite3_bind_null, -1); - rb_define_module_function(mAPI, "sqlite3_bind_text", _wrap_sqlite3_bind_text, -1); - rb_define_module_function(mAPI, "sqlite3_bind_text16", _wrap_sqlite3_bind_text16, -1); - rb_define_module_function(mAPI, "sqlite3_bind_parameter_count", _wrap_sqlite3_bind_parameter_count, -1); - rb_define_module_function(mAPI, "sqlite3_bind_parameter_name", _wrap_sqlite3_bind_parameter_name, -1); - rb_define_module_function(mAPI, "sqlite3_bind_parameter_index", _wrap_sqlite3_bind_parameter_index, -1); - rb_define_module_function(mAPI, "sqlite3_column_count", _wrap_sqlite3_column_count, -1); - rb_define_module_function(mAPI, "sqlite3_column_name", _wrap_sqlite3_column_name, -1); - rb_define_module_function(mAPI, "sqlite3_column_name16", _wrap_sqlite3_column_name16, -1); - rb_define_module_function(mAPI, "sqlite3_column_decltype", _wrap_sqlite3_column_decltype, -1); - rb_define_module_function(mAPI, "sqlite3_column_decltype16", _wrap_sqlite3_column_decltype16, -1); - rb_define_module_function(mAPI, "sqlite3_step", _wrap_sqlite3_step, -1); - rb_define_module_function(mAPI, "sqlite3_data_count", _wrap_sqlite3_data_count, -1); - rb_define_module_function(mAPI, "sqlite3_column_blob", _wrap_sqlite3_column_blob, -1); - rb_define_module_function(mAPI, "sqlite3_column_bytes", _wrap_sqlite3_column_bytes, -1); - rb_define_module_function(mAPI, "sqlite3_column_bytes16", _wrap_sqlite3_column_bytes16, -1); - rb_define_module_function(mAPI, "sqlite3_column_double", _wrap_sqlite3_column_double, -1); - rb_define_module_function(mAPI, "sqlite3_column_int", _wrap_sqlite3_column_int, -1); - rb_define_module_function(mAPI, "sqlite3_column_int64", _wrap_sqlite3_column_int64, -1); - rb_define_module_function(mAPI, "sqlite3_column_text", _wrap_sqlite3_column_text, -1); - rb_define_module_function(mAPI, "sqlite3_column_text16", _wrap_sqlite3_column_text16, -1); - rb_define_module_function(mAPI, "sqlite3_column_type", _wrap_sqlite3_column_type, -1); - rb_define_module_function(mAPI, "sqlite3_finalize", _wrap_sqlite3_finalize, -1); - rb_define_module_function(mAPI, "sqlite3_reset", _wrap_sqlite3_reset, -1); - rb_define_module_function(mAPI, "sqlite3_create_function", _wrap_sqlite3_create_function, -1); - rb_define_module_function(mAPI, "sqlite3_create_function16", _wrap_sqlite3_create_function16, -1); - rb_define_module_function(mAPI, "sqlite3_aggregate_count", _wrap_sqlite3_aggregate_count, -1); - rb_define_module_function(mAPI, "sqlite3_value_blob", _wrap_sqlite3_value_blob, -1); - rb_define_module_function(mAPI, "sqlite3_value_bytes", _wrap_sqlite3_value_bytes, -1); - rb_define_module_function(mAPI, "sqlite3_value_bytes16", _wrap_sqlite3_value_bytes16, -1); - rb_define_module_function(mAPI, "sqlite3_value_double", _wrap_sqlite3_value_double, -1); - rb_define_module_function(mAPI, "sqlite3_value_int", _wrap_sqlite3_value_int, -1); - rb_define_module_function(mAPI, "sqlite3_value_int64", _wrap_sqlite3_value_int64, -1); - rb_define_module_function(mAPI, "sqlite3_value_text", _wrap_sqlite3_value_text, -1); - rb_define_module_function(mAPI, "sqlite3_value_text16", _wrap_sqlite3_value_text16, -1); - rb_define_module_function(mAPI, "sqlite3_value_text16le", _wrap_sqlite3_value_text16le, -1); - rb_define_module_function(mAPI, "sqlite3_value_text16be", _wrap_sqlite3_value_text16be, -1); - rb_define_module_function(mAPI, "sqlite3_value_type", _wrap_sqlite3_value_type, -1); - rb_define_module_function(mAPI, "sqlite3_result_blob", _wrap_sqlite3_result_blob, -1); - rb_define_module_function(mAPI, "sqlite3_result_double", _wrap_sqlite3_result_double, -1); - rb_define_module_function(mAPI, "sqlite3_result_error", _wrap_sqlite3_result_error, -1); - rb_define_module_function(mAPI, "sqlite3_result_error16", _wrap_sqlite3_result_error16, -1); - rb_define_module_function(mAPI, "sqlite3_result_int", _wrap_sqlite3_result_int, -1); - rb_define_module_function(mAPI, "sqlite3_result_int64", _wrap_sqlite3_result_int64, -1); - rb_define_module_function(mAPI, "sqlite3_result_text", _wrap_sqlite3_result_text, -1); - rb_define_module_function(mAPI, "sqlite3_result_text16", _wrap_sqlite3_result_text16, -1); - rb_define_module_function(mAPI, "sqlite3_result_text16le", _wrap_sqlite3_result_text16le, -1); - rb_define_module_function(mAPI, "sqlite3_result_text16be", _wrap_sqlite3_result_text16be, -1); - rb_define_module_function(mAPI, "sqlite3_result_value", _wrap_sqlite3_result_value, -1); - rb_define_module_function(mAPI, "sqlite3_aggregate_context", _wrap_sqlite3_aggregate_context, -1); -} - diff --git a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/win32/build.bat b/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/win32/build.bat deleted file mode 100755 index 550e720f..00000000 --- a/vendor/plugins/sqlite3-ruby/ext/sqlite3_api/win32/build.bat +++ /dev/null @@ -1,7 +0,0 @@ -REM This is not guaranteed to work, ever. It's just a little helper -REM script that I threw together to help me build the win32 version of -REM the library. If someone with more win32-fu than I wants to make -REM something more robust, please feel free! I'd love to include it. -REM -- Jamis Buck - -cl /LD /Ie:\WinSDK\Include /Ic:\ruby\lib\ruby\1.8\i386-mswin32 /Ic:\ruby\sqlite3 /Ic:\ruby\src\ruby-1.8.4_2006-04-14 sqlite3_api_wrap.c /link /LIBPATH:c:\ruby\sqlite3 /LIBPATH:e:\WinSDK\Lib /LIBPATH:c:\ruby\lib sqlite3.lib msvcrt-ruby18.lib diff --git a/vendor/plugins/sqlite3-ruby/faq/faq.rb b/vendor/plugins/sqlite3-ruby/faq/faq.rb new file mode 100644 index 00000000..61d7d01c --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/faq/faq.rb @@ -0,0 +1,145 @@ +require 'yaml' +require 'redcloth' + +def process_faq_list( faqs ) + puts "
    " + faqs.each do |faq| + process_faq_list_item faq + end + puts "
" +end + +def process_faq_list_item( faq ) + question = faq.keys.first + answer = faq.values.first + + print "
  • " + + question_text = RedCloth.new(question).to_html.gsub( %r{},"" ) + if answer.is_a?( Array ) + puts question_text + process_faq_list answer + else + print "#{question_text}" + end + + puts "
  • " +end + +def process_faq_descriptions( faqs, path=nil ) + faqs.each do |faq| + process_faq_description faq, path + end +end + +def process_faq_description( faq, path ) + question = faq.keys.first + path = ( path ? path + " " : "" ) + question + answer = faq.values.first + + if answer.is_a?( Array ) + process_faq_descriptions( answer, path ) + else + title = RedCloth.new( path ).to_html.gsub( %r{}, "" ) + answer = RedCloth.new( answer || "" ) + + puts "" + puts "
    #{title}
    " + puts "
    #{add_api_links(answer.to_html)}
    " + end +end + +API_OBJECTS = [ "Database", "Statement", "ResultSet", + "ParsedStatement", "Pragmas", "Translator" ].inject( "(" ) { |acc,name| + acc << "|" if acc.length > 1 + acc << name + acc + } + ")" + +def add_api_links( text ) + text.gsub( /#{API_OBJECTS}(#(\w+))?/ ) do + disp_obj = obj = $1 + + case obj + when "Pragmas"; disp_obj = "Database" + end + + method = $3 + s = "#{disp_obj}" + s << "##{method}" if method + s << "" + s + end +end + +faqs = YAML.load( File.read( "faq.yml" ) ) + +puts <<-EOF + + + SQLite3/Ruby FAQ + + + +

    SQLite/Ruby FAQ

    +
    +EOF + +process_faq_list( faqs ) +puts "
    " +process_faq_descriptions( faqs ) + +puts "" diff --git a/vendor/plugins/sqlite3-ruby/faq/faq.yml b/vendor/plugins/sqlite3-ruby/faq/faq.yml new file mode 100644 index 00000000..f4bb4c1b --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/faq/faq.yml @@ -0,0 +1,426 @@ +--- +- "How do I do a database query?": + - "I just want an array of the rows...": >- + + Use the Database#execute method. If you don't give it a block, it will + return an array of all the rows: + + +
    +        require 'sqlite3'
    +
    +        db = SQLite3::Database.new( "test.db" )
    +        rows = db.execute( "select * from test" )
    +      
    + + - "I'd like to use a block to iterate through the rows...": >- + + Use the Database#execute method. If you give it a block, each row of the + result will be yielded to the block: + + +
    +        require 'sqlite3'
    +
    +        db = SQLite3::Database.new( "test.db" )
    +        db.execute( "select * from test" ) do |row|
    +          ...
    +        end
    +      
    + + - "I need to get the column names as well as the rows...": >- + + Use the Database#execute2 method. This works just like Database#execute; + if you don't give it a block, it returns an array of rows; otherwise, it + will yield each row to the block. _However_, the first row returned is + always an array of the column names from the query: + + +
    +        require 'sqlite3'
    +
    +        db = SQLite3::Database.new( "test.db" )
    +        columns, *rows = db.execute2( "select * from test" )
    +
    +        # or use a block:
    +
    +        columns = nil
    +        db.execute2( "select * from test" ) do |row|
    +          if columns.nil?
    +            columns = row
    +          else
    +            # process row
    +          end
    +        end
    +      
    + + - "I just want the first row of the result set...": >- + + Easy. Just call Database#get_first_row: + + +
    +        row = db.get_first_row( "select * from table" )
    +      
    + + + This also supports bind variables, just like Database#execute + and friends. + + - "I just want the first value of the first row of the result set...": >- + + Also easy. Just call Database#get_first_value: + + +
    +        count = db.get_first_value( "select count(*) from table" )
    +      
    + + + This also supports bind variables, just like Database#execute + and friends. + +- "How do I prepare a statement for repeated execution?": >- + If the same statement is going to be executed repeatedly, you can speed + things up a bit by _preparing_ the statement. You do this via the + Database#prepare method. It returns a Statement object, and you can + then invoke #execute on that to get the ResultSet: + + +
    +      stmt = db.prepare( "select * from person" )
    +
    +      1000.times do
    +        stmt.execute do |result|
    +          ...
    +        end
    +      end
    +
    +      stmt.close
    +
    +      # or, use a block
    +
    +      db.prepare( "select * from person" ) do |stmt|
    +        1000.times do
    +          stmt.execute do |result|
    +            ...
    +          end
    +        end
    +      end
    +    
    + + + This is made more useful by the ability to bind variables to placeholders + via the Statement#bind_param and Statement#bind_params methods. (See the + next FAQ for details.) + +- "How do I use placeholders in an SQL statement?": >- + Placeholders in an SQL statement take any of the following formats: + + + * @?@ + + * @?_nnn_@ + + * @:_word_@ + + + Where _n_ is an integer, and _word_ is an alpha-numeric identifier (or + number). When the placeholder is associated with a number, that number + identifies the index of the bind variable to replace it with. When it + is an identifier, it identifies the name of the correponding bind + variable. (In the instance of the first format--a single question + mark--the placeholder is assigned a number one greater than the last + index used, or 1 if it is the first.) + + + For example, here is a query using these placeholder formats: + + +
    +      select *
    +        from table
    +       where ( c = ?2 or c = ? )
    +         and d = :name
    +         and e = :1
    +    
    + + + This defines 5 different placeholders: 1, 2, 3, and "name". + + + You replace these placeholders by _binding_ them to values. This can be + accomplished in a variety of ways. + + + The Database#execute, and Database#execute2 methods all accept additional + arguments following the SQL statement. These arguments are assumed to be + bind parameters, and they are bound (positionally) to their corresponding + placeholders: + + +
    +      db.execute( "select * from table where a = ? and b = ?",
    +                  "hello",
    +                  "world" )
    +    
    + + + The above would replace the first question mark with 'hello' and the + second with 'world'. If the placeholders have an explicit index given, they + will be replaced with the bind parameter at that index (1-based). + + + If a Hash is given as a bind parameter, then its key/value pairs are bound + to the placeholders. This is how you bind by name: + + +
    +      db.execute( "select * from table where a = :name and b = :value",
    +                  "name" => "bob",
    +                  "value" => "priceless" )
    +    
    + + + You can also bind explicitly using the Statement object itself. Just pass + additional parameters to the Statement#execute statement: + + +
    +      db.prepare( "select * from table where a = :name and b = ?" ) do |stmt|
    +        stmt.execute "value", "name" => "bob"
    +      end
    +    
    + + + Or do a Database#prepare to get the Statement, and then use either + Statement#bind_param or Statement#bind_params: + + +
    +      stmt = db.prepare( "select * from table where a = :name and b = ?" )
    +
    +      stmt.bind_param( "name", "bob" )
    +      stmt.bind_param( 1, "value" )
    +
    +      # or
    +
    +      stmt.bind_params( "value", "name" => "bob" )
    +    
    + +- "How do I discover metadata about a query?": >- + + If you ever want to know the names or types of the columns in a result + set, you can do it in several ways. + + + The first way is to ask the row object itself. Each row will have a + property "fields" that returns an array of the column names. The row + will also have a property "types" that returns an array of the column + types: + + +
    +      rows = db.execute( "select * from table" )
    +      p rows[0].fields
    +      p rows[0].types
    +    
    + + + Obviously, this approach requires you to execute a statement that actually + returns data. If you don't know if the statement will return any rows, but + you still need the metadata, you can use Database#query and ask the + ResultSet object itself: + + +
    +      db.query( "select * from table" ) do |result|
    +        p result.columns
    +        p result.types
    +        ...
    +      end
    +    
    + + + Lastly, you can use Database#prepare and ask the Statement object what + the metadata are: + + +
    +      stmt = db.prepare( "select * from table" )
    +      p stmt.columns
    +      p stmt.types
    +    
    + +- "I'd like the rows to be indexible by column name.": >- + By default, each row from a query is returned as an Array of values. This + means that you can only obtain values by their index. Sometimes, however, + you would like to obtain values by their column name. + + + The first way to do this is to set the Database property "results_as_hash" + to true. If you do this, then all rows will be returned as Hash objects, + with the column names as the keys. (In this case, the "fields" property + is unavailable on the row, although the "types" property remains.) + + +
    +      db.results_as_hash = true
    +      db.execute( "select * from table" ) do |row|
    +        p row['column1']
    +        p row['column2']
    +      end
    +    
    + + + The other way is to use Ara Howard's + "ArrayFields":http://rubyforge.org/projects/arrayfields + module. Just require "arrayfields", and all of your rows will be indexable + by column name, even though they are still arrays! + + +
    +      require 'arrayfields'
    +
    +      ...
    +      db.execute( "select * from table" ) do |row|
    +        p row[0] == row['column1']
    +        p row[1] == row['column2']
    +      end
    +    
    + +- "I'd like the values from a query to be the correct types, instead of String.": >- + You can turn on "type translation" by setting Database#type_translation to + true: + + +
    +      db.type_translation = true
    +      db.execute( "select * from table" ) do |row|
    +        p row
    +      end
    +    
    + + + By doing this, each return value for each row will be translated to its + correct type, based on its declared column type. + + + You can even declare your own translation routines, if (for example) you are + using an SQL type that is not handled by default: + + +
    +      # assume "objects" table has the following schema:
    +      #   create table objects (
    +      #     name varchar2(20),
    +      #     thing object
    +      #   )
    +
    +      db.type_translation = true
    +      db.translator.add_translator( "object" ) do |type, value|
    +        db.decode( value )
    +      end
    +
    +      h = { :one=>:two, "three"=>"four", 5=>6 }
    +      dump = db.encode( h )
    +
    +      db.execute( "insert into objects values ( ?, ? )", "bob", dump )
    +
    +      obj = db.get_first_value( "select thing from objects where name='bob'" )
    +      p obj == h
    +    
    + +- "How do insert binary data into the database?": >- + Use blobs. Blobs are new features of SQLite3. You have to use bind + variables to make it work: + + +
    +      db.execute( "insert into foo ( ?, ? )",
    +        SQLite3::Blob.new( "\0\1\2\3\4\5" ),
    +        SQLite3::Blob.new( "a\0b\0c\0d ) )
    +    
    + + + The blob values must be indicated explicitly by binding each parameter to + a value of type SQLite3::Blob. + +- "How do I do a DDL (insert, update, delete) statement?": >- + You can actually do inserts, updates, and deletes in exactly the same way + as selects, but in general the Database#execute method will be most + convenient: + + +
    +      db.execute( "insert into table values ( ?, ? )", *bind_vars )
    +    
    + +- "How do I execute multiple statements in a single string?": >- + The standard query methods (Database#execute, Database#execute2, + Database#query, and Statement#execute) will only execute the first + statement in the string that is given to them. Thus, if you have a + string with multiple SQL statements, each separated by a string, + you can't use those methods to execute them all at once. + + + Instead, use Database#execute_batch: + + +
    +      sql = <
    +
    +
    +    Unlike the other query methods, Database#execute_batch accepts no
    +    block. It will also only ever return +nil+. Thus, it is really only
    +    suitable for batch processing of DDL statements.
    +
    +- "How do I begin/end a transaction?":
    +    Use Database#transaction to start a transaction. If you give it a block,
    +    the block will be automatically committed at the end of the block,
    +    unless an exception was raised, in which case the transaction will be
    +    rolled back. (Never explicitly call Database#commit or Database#rollback
    +    inside of a transaction block--you'll get errors when the block
    +    terminates!)
    +
    +
    +    
    +      database.transaction do |db|
    +        db.execute( "insert into table values ( 'a', 'b', 'c' )" )
    +        ...
    +      end
    +    
    + + + Alternatively, if you don't give a block to Database#transaction, the + transaction remains open until you explicitly call Database#commit or + Database#rollback. + + +
    +      db.transaction
    +      db.execute( "insert into table values ( 'a', 'b', 'c' )" )
    +      db.commit
    +    
    + + + Note that SQLite does not allow nested transactions, so you'll get errors + if you try to open a new transaction while one is already active. Use + Database#transaction_active? to determine whether a transaction is + active or not. + +#- "How do I discover metadata about a table/index?": +# +#- "How do I do tweak database settings?": diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3.rb index d2d0ea10..b17ce52d 100644 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3.rb +++ b/vendor/plugins/sqlite3-ruby/lib/sqlite3.rb @@ -1 +1,10 @@ +# support multiple ruby version (fat binaries under windows) +begin + RUBY_VERSION =~ /(\d+.\d+)/ + require "sqlite3/#{$1}/sqlite3_native" +rescue LoadError + require 'sqlite3/sqlite3_native' +end + require 'sqlite3/database' +require 'sqlite3/version' diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/database.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/database.rb index e2ba69c1..4d3522fa 100644 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/database.rb +++ b/vendor/plugins/sqlite3-ruby/lib/sqlite3/database.rb @@ -35,7 +35,7 @@ module SQLite3 class Database include Pragmas - class < e - @driver.result_error( func, - "#{e.message} (#{e.class})", -1 ) - end + def create_function name, arity, text_rep=Constants::TextRep::ANY, &block + define_function(name) do |*args| + fp = FunctionProxy.new + block.call(fp, *args) + fp.result end - - result = @driver.create_function( @handle, name, arity, text_rep, nil, - callback, nil, nil ) - Error.check( result, self ) - self end @@ -410,47 +357,40 @@ module SQLite3 # aggregate functions. def create_aggregate( name, arity, step=nil, finalize=nil, text_rep=Constants::TextRep::ANY, &block ) - # begin - if block - proxy = AggregateDefinitionProxy.new - proxy.instance_eval(&block) - step ||= proxy.step_callback - finalize ||= proxy.finalize_callback - end - step_callback = proc do |func,*args| - ctx = @driver.aggregate_context( func ) - unless ctx[:__error] - begin - step.call( FunctionProxy.new( @driver, func, ctx ), - *args.map{|v| Value.new(self,v)} ) - rescue Exception => e - ctx[:__error] = e - end + factory = Class.new do + def self.step( &block ) + define_method(:step, &block) + end + + def self.finalize( &block ) + define_method(:finalize, &block) end end - finalize_callback = proc do |func| - ctx = @driver.aggregate_context( func ) - unless ctx[:__error] - begin - finalize.call( FunctionProxy.new( @driver, func, ctx ) ) - rescue Exception => e - @driver.result_error( func, - "#{e.message} (#{e.class})", -1 ) - end - else - e = ctx[:__error] - @driver.result_error( func, - "#{e.message} (#{e.class})", -1 ) + if block_given? + factory.instance_eval(&block) + else + factory.class_eval do + define_method(:step, step) + define_method(:finalize, finalize) end end - result = @driver.create_function( @handle, name, arity, text_rep, nil, - nil, step_callback, finalize_callback ) - Error.check( result, self ) + proxy = factory.new + proxy.extend(Module.new { + attr_accessor :ctx - self + def step( *args ) + super(@ctx, *args) + end + + def finalize + super(@ctx) + end + }) + proxy.ctx = FunctionProxy.new + define_aggregator(name, proxy) end # This is another approach to creating an aggregate function (see @@ -500,47 +440,22 @@ module SQLite3 # db.create_aggregate_handler( LengthsAggregateHandler ) # puts db.get_first_value( "select lengths(name) from A" ) def create_aggregate_handler( handler ) - arity = -1 - text_rep = Constants::TextRep::ANY + proxy = Class.new do + def initialize handler + @handler = handler + @fp = FunctionProxy.new + end - arity = handler.arity if handler.respond_to?(:arity) - text_rep = handler.text_rep if handler.respond_to?(:text_rep) - name = handler.name + def step( *args ) + @handler.step(@fp, *args) + end - step = proc do |func,*args| - ctx = @driver.aggregate_context( func ) - unless ctx[ :__error ] - ctx[ :handler ] ||= handler.new - begin - ctx[ :handler ].step( FunctionProxy.new( @driver, func, ctx ), - *args.map{|v| Value.new(self,v)} ) - rescue Exception, StandardError => e - ctx[ :__error ] = e - end + def finalize + @handler.finalize @fp + @fp.result end end - - finalize = proc do |func| - ctx = @driver.aggregate_context( func ) - unless ctx[ :__error ] - ctx[ :handler ] ||= handler.new - begin - ctx[ :handler ].finalize( FunctionProxy.new( @driver, func, ctx ) ) - rescue Exception => e - ctx[ :__error ] = e - end - end - - if ctx[ :__error ] - e = ctx[ :__error ] - @driver.sqlite3_result_error( func, "#{e.message} (#{e.class})", -1 ) - end - end - - result = @driver.create_function( @handle, name, arity, text_rep, nil, - nil, step, finalize ) - Error.check( result, self ) - + define_aggregator(handler.name, proxy.new(handler.new)) self end @@ -604,33 +519,6 @@ module SQLite3 @transaction_active end - # Loads the corresponding driver, or if it is nil, attempts to locate a - # suitable driver. - def load_driver( driver ) - case driver - when Class - # do nothing--use what was given - when Symbol, String - require "sqlite3/driver/#{driver.to_s.downcase}/driver" - driver = SQLite3::Driver.const_get( driver )::Driver - else - [ "Native", "DL" ].each do |d| - begin - require "sqlite3/driver/#{d.downcase}/driver" - driver = SQLite3::Driver.const_get( d )::Driver - break - rescue SyntaxError - raise - rescue ScriptError, Exception, NameError - end - end - raise "no driver for sqlite3 found" unless driver - end - - @driver = driver.new - end - private :load_driver - # A helper class for dealing with custom functions (see #create_function, # #create_aggregate, and #create_aggregate_handler). It encapsulates the # opaque function object that represents the current invocation. It also @@ -640,26 +528,15 @@ module SQLite3 # This class will almost _always_ be instantiated indirectly, by working # with the create methods mentioned above. class FunctionProxy + attr_accessor :result # Create a new FunctionProxy that encapsulates the given +func+ object. # If context is non-nil, the functions context will be set to that. If # it is non-nil, it must quack like a Hash. If it is nil, then none of # the context functions will be available. - def initialize( driver, func, context=nil ) - @driver = driver - @func = func - @context = context - end - - # Calls #set_result to set the result of this function. - def result=( result ) - set_result( result ) - end - - # Set the result of the function to the given value. The function will - # then return this value. - def set_result( result, utf16=false ) - @driver.result_text( @func, result, utf16 ) + def initialize + @result = nil + @context = {} end # Set the result of the function to the given error message. @@ -672,50 +549,20 @@ module SQLite3 # that the aggregate has processed so far. This will include the current # row, and so will always return at least 1. def count - ensure_aggregate! @driver.aggregate_count( @func ) end # Returns the value with the given key from the context. This is only # available to aggregate functions. def []( key ) - ensure_aggregate! @context[ key ] end # Sets the value with the given key in the context. This is only # available to aggregate functions. def []=( key, value ) - ensure_aggregate! @context[ key ] = value end - - # A function for performing a sanity check, to ensure that the function - # being invoked is an aggregate function. This is implied by the - # existence of the context variable. - def ensure_aggregate! - unless @context - raise MisuseException, "function is not an aggregate" - end - end - private :ensure_aggregate! - end - - # A proxy used for defining the callbacks to an aggregate function. - class AggregateDefinitionProxy # :nodoc: - attr_reader :step_callback, :finalize_callback - - def step( &block ) - @step_callback = block - end - - def finalize( &block ) - @finalize_callback = block - end - end - end - end - diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/dl/api.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/dl/api.rb deleted file mode 100644 index 60a2c3d1..00000000 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/dl/api.rb +++ /dev/null @@ -1,152 +0,0 @@ -require 'dl/import' - -module SQLite3 ; module Driver; module DL; - - module API - extend ::DL::Importable - - library_name = case RUBY_PLATFORM.downcase - when /darwin/ - "libsqlite3.dylib" - when /linux/, /freebsd|netbsd|openbsd|dragonfly/, /solaris/ - "libsqlite3.so" - when /mswin|mingw/ - "sqlite3.dll" - else - abort <<-EOF -== * UNSUPPORTED PLATFORM ====================================================== -The platform '#{RUBY_PLATFORM}' is unsupported. Please help the author by -editing the following file to allow your sqlite3 library to be found, and -submitting a patch to jamis_buck@byu.edu. Thanks! - -#{__FILE__} -=========================================================================== * == - EOF - end - - if defined? SQLITE3_LIB_PATH - library_name = File.join( SQLITE3_LIB_PATH, library_name ) - end - - dlload library_name - - typealias "db", "void*" - typealias "stmt", "void*" - typealias "value", "void*" - typealias "context", "void*" - - # until Ruby/DL supports 64-bit ints, we'll just treat them as 32-bit ints - typealias "int64", "unsigned long" - - extern "const char *sqlite3_libversion()" - - extern "int sqlite3_open(const char*,db*)" - extern "int sqlite3_open16(const void*,db*)" - extern "int sqlite3_close(db)" - extern "const char* sqlite3_errmsg(db)" - extern "void* sqlite3_errmsg16(db)" - extern "int sqlite3_errcode(db)" - - extern "int sqlite3_prepare(db,const char*,int,stmt*,const char**)" - extern "int sqlite3_prepare16(db,const void*,int,stmt*,const void**)" - extern "int sqlite3_finalize(stmt)" - extern "int sqlite3_reset(stmt)" - extern "int sqlite3_step(stmt)" - - extern "int64 sqlite3_last_insert_rowid(db)" - extern "int sqlite3_changes(db)" - extern "int sqlite3_total_changes(db)" - extern "void sqlite3_interrupt(db)" - extern "ibool sqlite3_complete(const char*)" - extern "ibool sqlite3_complete16(const void*)" - - extern "int sqlite3_busy_handler(db,void*,void*)" - extern "int sqlite3_busy_timeout(db,int)" - - extern "int sqlite3_set_authorizer(db,void*,void*)" - extern "void* sqlite3_trace(db,void*,void*)" - - extern "int sqlite3_bind_blob(stmt,int,const void*,int,void*)" - extern "int sqlite3_bind_double(stmt,int,double)" - extern "int sqlite3_bind_int(stmt,int,int)" - extern "int sqlite3_bind_int64(stmt,int,int64)" - extern "int sqlite3_bind_null(stmt,int)" - extern "int sqlite3_bind_text(stmt,int,const char*,int,void*)" - extern "int sqlite3_bind_text16(stmt,int,const void*,int,void*)" - #extern "int sqlite3_bind_value(stmt,int,value)" - - extern "int sqlite3_bind_parameter_count(stmt)" - extern "const char* sqlite3_bind_parameter_name(stmt,int)" - extern "int sqlite3_bind_parameter_index(stmt,const char*)" - - extern "int sqlite3_column_count(stmt)" - extern "int sqlite3_data_count(stmt)" - - extern "const void *sqlite3_column_blob(stmt,int)" - extern "int sqlite3_column_bytes(stmt,int)" - extern "int sqlite3_column_bytes16(stmt,int)" - extern "const char *sqlite3_column_decltype(stmt,int)" - extern "void *sqlite3_column_decltype16(stmt,int)" - extern "double sqlite3_column_double(stmt,int)" - extern "int sqlite3_column_int(stmt,int)" - extern "int64 sqlite3_column_int64(stmt,int)" - extern "const char *sqlite3_column_name(stmt,int)" - extern "const void *sqlite3_column_name16(stmt,int)" - extern "const char *sqlite3_column_text(stmt,int)" - extern "const void *sqlite3_column_text16(stmt,int)" - extern "int sqlite3_column_type(stmt,int)" - - extern "int sqlite3_create_function(db,const char*,int,int,void*,void*,void*,void*)" - extern "int sqlite3_create_function16(db,const void*,int,int,void*,void*,void*,void*)" - extern "int sqlite3_aggregate_count(context)" - - extern "const void *sqlite3_value_blob(value)" - extern "int sqlite3_value_bytes(value)" - extern "int sqlite3_value_bytes16(value)" - extern "double sqlite3_value_double(value)" - extern "int sqlite3_value_int(value)" - extern "int64 sqlite3_value_int64(value)" - extern "const char* sqlite3_value_text(value)" - extern "const void* sqlite3_value_text16(value)" - extern "const void* sqlite3_value_text16le(value)" - extern "const void* sqlite3_value_text16be(value)" - extern "int sqlite3_value_type(value)" - - extern "void *sqlite3_aggregate_context(context,int)" - extern "void *sqlite3_user_data(context)" - extern "void *sqlite3_get_auxdata(context,int)" - extern "void sqlite3_set_auxdata(context,int,void*,void*)" - - extern "void sqlite3_result_blob(context,const void*,int,void*)" - extern "void sqlite3_result_double(context,double)" - extern "void sqlite3_result_error(context,const char*,int)" - extern "void sqlite3_result_error16(context,const void*,int)" - extern "void sqlite3_result_int(context,int)" - extern "void sqlite3_result_int64(context,int64)" - extern "void sqlite3_result_null(context)" - extern "void sqlite3_result_text(context,const char*,int,void*)" - extern "void sqlite3_result_text16(context,const void*,int,void*)" - extern "void sqlite3_result_text16le(context,const void*,int,void*)" - extern "void sqlite3_result_text16be(context,const void*,int,void*)" - extern "void sqlite3_result_value(context,value)" - - extern "int sqlite3_create_collation(db,const char*,int,void*,void*)" - extern "int sqlite3_create_collation16(db,const char*,int,void*,void*)" - extern "int sqlite3_collation_needed(db,void*,void*)" - extern "int sqlite3_collation_needed16(db,void*,void*)" - - # ==== CRYPTO (NOT IN PUBLIC RELEASE) ==== - if defined?( CRYPTO_API ) && CRYPTO_API - extern "int sqlite3_key(db,void*,int)" - extern "int sqlite3_rekey(db,void*,int)" - end - - # ==== EXPERIMENTAL ==== - if defined?( EXPERIMENTAL_API ) && EXPERIMENTAL_API - extern "int sqlite3_progress_handler(db,int,void*,void*)" - extern "int sqlite3_commit_hook(db,void*,void*)" - end - - end - -end ; end ; end diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/dl/driver.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/dl/driver.rb deleted file mode 100644 index f53c1897..00000000 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/dl/driver.rb +++ /dev/null @@ -1,307 +0,0 @@ -require 'sqlite3/driver/dl/api' - -warn "The DL driver for sqlite3-ruby is deprecated and will be removed" -warn "in a future release. Please update your installation to use the" -warn "Native driver." - -module Kernel - # Allows arbitrary objects to be passed as a pointer to functions. - # (Probably not very GC safe, but by encapsulating it like this we - # can change the implementation later.) - def to_ptr - ptr = DL.malloc(DL.sizeof("L")) - ptr.set_object self - ptr - end -end - -class DL::PtrData - # The inverse of the Kernel#to_ptr operation. - def to_object - n = to_s(4).unpack("L").first - return nil if n < 1 - ObjectSpace._id2ref(n) rescue self.to_s - end - - def set_object(obj) - self[0] = [obj.object_id].pack("L") - end -end - -module SQLite3 ; module Driver ; module DL - - class Driver - STATIC = ::DL::PtrData.new(0) - TRANSIENT = ::DL::PtrData.new(-1) - - def open( filename, utf16=false ) - handle = ::DL::PtrData.new(0) - result = API.send( ( utf16 ? :sqlite3_open16 : :sqlite3_open ), - filename+"\0", handle.ref ) - [ result, handle ] - end - - def errmsg( db, utf16=false ) - if utf16 - msg = API.sqlite3_errmsg16( db ) - msg.free = nil - msg.to_s(utf16_length(msg)) - else - API.sqlite3_errmsg( db ) - end - end - - def prepare( db, sql, utf16=false ) - handle = ::DL::PtrData.new(0) - remainder = ::DL::PtrData.new(0) - - result = API.send( ( utf16 ? :sqlite3_prepare16 : :sqlite3_prepare ), - db, sql+"\0", sql.length, handle.ref, remainder.ref ) - - args = utf16 ? [ utf16_length(remainder) ] : [] - remainder = remainder.to_s( *args ) - - [ result, handle, remainder ] - end - - def complete?( sql, utf16=false ) - API.send( utf16 ? :sqlite3_complete16 : :sqlite3_complete, sql+"\0" ) - end - - def value_blob( value ) - blob = API.sqlite3_value_blob( value ) - blob.free = nil - blob.to_s( API.sqlite3_value_bytes( value ) ) - end - - def value_text( value, utf16=false ) - method = case utf16 - when nil, false then :sqlite3_value_text - when :le then :sqlite3_value_text16le - when :be then :sqlite3_value_text16be - else :sqlite3_value_text16 - end - - result = API.send( method, value ) - if utf16 - result.free = nil - size = API.sqlite3_value_bytes( value ) - result = result.to_s( size ) - end - - result - end - - def column_blob( stmt, column ) - blob = API.sqlite3_column_blob( stmt, column ) - blob.free = nil - blob.to_s( API.sqlite3_column_bytes( stmt, column ) ) - end - - def result_text( func, text, utf16=false ) - method = case utf16 - when false, nil then :sqlite3_result_text - when :le then :sqlite3_result_text16le - when :be then :sqlite3_result_text16be - else :sqlite3_result_text16 - end - - s = text.to_s - API.send( method, func, s, s.length, TRANSIENT ) - end - - def busy_handler( db, data=nil, &block ) - @busy_handler = block - - unless @busy_handler_callback - @busy_handler_callback = ::DL.callback( "IPI" ) do |cookie, timeout| - @busy_handler.call( cookie, timeout ) || 0 - end - end - - API.sqlite3_busy_handler( db, block&&@busy_handler_callback, data ) - end - - def set_authorizer( db, data=nil, &block ) - @authorizer_handler = block - - unless @authorizer_handler_callback - @authorizer_handler_callback = ::DL.callback( "IPIPPPP" - ) do |cookie,mode,a,b,c,d| - @authorizer_handler.call( cookie, mode, - a&&a.to_s, b&&b.to_s, c&&c.to_s, d&&d.to_s ) || 0 - end - end - - API.sqlite3_set_authorizer( db, block&&@authorizer_handler_callback, - data ) - end - - def trace( db, data=nil, &block ) - @trace_handler = block - - unless @trace_handler_callback - @trace_handler_callback = ::DL.callback( "IPS" ) do |cookie,sql| - @trace_handler.call( cookie ? cookie.to_object : nil, sql ) || 0 - end - end - - API.sqlite3_trace( db, block&&@trace_handler_callback, data ) - end - - def create_function( db, name, args, text, cookie, - func, step, final ) - # begin - if @func_handler_callback.nil? && func - @func_handler_callback = ::DL.callback( "0PIP" ) do |context,nargs,args| - args = args.to_s(nargs*4).unpack("L*").map {|i| ::DL::PtrData.new(i)} - data = API.sqlite3_user_data( context ).to_object - data[:func].call( context, *args ) - end - end - - if @step_handler_callback.nil? && step - @step_handler_callback = ::DL.callback( "0PIP" ) do |context,nargs,args| - args = args.to_s(nargs*4).unpack("L*").map {|i| ::DL::PtrData.new(i)} - data = API.sqlite3_user_data( context ).to_object - data[:step].call( context, *args ) - end - end - - if @final_handler_callback.nil? && final - @final_handler_callback = ::DL.callback( "0P" ) do |context| - data = API.sqlite3_user_data( context ).to_object - data[:final].call( context ) - end - end - - data = { :cookie => cookie, - :name => name, - :func => func, - :step => step, - :final => final } - - API.sqlite3_create_function( db, name, args, text, data, - ( func ? @func_handler_callback : nil ), - ( step ? @step_handler_callback : nil ), - ( final ? @final_handler_callback : nil ) ) - end - - def aggregate_context( context ) - ptr = API.sqlite3_aggregate_context( context, 4 ) - ptr.free = nil - obj = ( ptr ? ptr.to_object : nil ) - if obj.nil? - obj = Hash.new - ptr.set_object obj - end - obj - end - - def bind_blob( stmt, index, value ) - s = value.to_s - API.sqlite3_bind_blob( stmt, index, s, s.length, TRANSIENT ) - end - - def bind_text( stmt, index, value, utf16=false ) - s = value.to_s - method = ( utf16 ? :sqlite3_bind_text16 : :sqlite3_bind_text ) - API.send( method, stmt, index, s, s.length, TRANSIENT ) - end - - def column_text( stmt, column ) - result = API.sqlite3_column_text( stmt, column ) - result ? result.to_s : nil - end - - def column_name( stmt, column ) - result = API.sqlite3_column_name( stmt, column ) - result ? result.to_s : nil - end - - def column_decltype( stmt, column ) - result = API.sqlite3_column_decltype( stmt, column ) - result ? result.to_s : nil - end - - def self.api_delegate( name ) - define_method( name ) { |*args| API.send( "sqlite3_#{name}", *args ) } - end - - api_delegate :aggregate_count - api_delegate :bind_double - api_delegate :bind_int - api_delegate :bind_int64 - api_delegate :bind_null - api_delegate :bind_parameter_index - api_delegate :bind_parameter_name - api_delegate :busy_timeout - api_delegate :changes - api_delegate :close - api_delegate :column_bytes - api_delegate :column_bytes16 - api_delegate :column_count - api_delegate :column_double - api_delegate :column_int - api_delegate :column_int64 - api_delegate :column_type - api_delegate :data_count - api_delegate :errcode - api_delegate :finalize - api_delegate :interrupt - api_delegate :last_insert_rowid - api_delegate :libversion - api_delegate :reset - api_delegate :result_error - api_delegate :step - api_delegate :total_changes - api_delegate :value_bytes - api_delegate :value_bytes16 - api_delegate :value_double - api_delegate :value_int - api_delegate :value_int64 - api_delegate :value_type - - # ==== EXPERIMENTAL ==== - if defined?( EXPERIMENTAL_API ) && EXPERIMENTAL_API - def progress_handler( db, n, data=nil, &block ) - @progress_handler = block - - unless @progress_handler_callback - @progress_handler_callback = ::DL.callback( "IP" ) do |cookie| - @progress_handler.call( cookie ) - end - end - - API.sqlite3_progress_handler( db, n, block&&@progress_handler_callback, - data ) - end - - def commit_hook( db, data=nil, &block ) - @commit_hook_handler = block - - unless @commit_hook_handler_callback - @commit_hook_handler_callback = ::DL.callback( "IP" ) do |cookie| - @commit_hook_handler.call( cookie ) - end - end - - API.sqlite3_commit_hook( db, block&&@commit_hook_handler_callback, - data ) - end - end - - private - - def utf16_length(ptr) - len = 0 - loop do - break if ptr[len,1] == "\0" - len += 2 - end - len - end - - end - -end ; end ; end diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/native/driver.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/native/driver.rb deleted file mode 100644 index 1cf0f826..00000000 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/driver/native/driver.rb +++ /dev/null @@ -1,219 +0,0 @@ -# support multiple ruby version (fat binaries under windows) -begin - require 'sqlite3_api' -rescue LoadError - if RUBY_PLATFORM =~ /mingw|mswin/ then - RUBY_VERSION =~ /(\d+.\d+)/ - require "#{$1}/sqlite3_api" - end -end - -module SQLite3 ; module Driver ; module Native - - class Driver - - def initialize - @callback_data = Hash.new - @authorizer = Hash.new - @busy_handler = Hash.new - @trace = Hash.new - end - - def complete?( sql, utf16=false ) - API.send( utf16 ? :sqlite3_complete16 : :sqlite3_complete, sql ) != 0 - end - - def busy_handler( db, data=nil, &block ) - if block - cb = API::CallbackData.new - cb.proc = block - cb.data = data - result = API.sqlite3_busy_handler( db, API::Sqlite3_ruby_busy_handler, cb ) - # Reference the Callback object so that - # it is not deleted by the GC - @busy_handler[db] = cb - else - # Unreference the callback *after* having removed it - # from sqlite - result = API.sqlite3_busy_handler( db, nil, nil ) - @busy_handler.delete(db) - end - - result - end - - def set_authorizer( db, data=nil, &block ) - if block - cb = API::CallbackData.new - cb.proc = block - cb.data = data - result = API.sqlite3_set_authorizer( db, API::Sqlite3_ruby_authorizer, cb ) - @authorizer[db] = cb # see comments in busy_handler - else - result = API.sqlite3_set_authorizer( db, nil, nil ) - @authorizer.delete(db) # see comments in busy_handler - end - - result - end - - def trace( db, data=nil, &block ) - if block - cb = API::CallbackData.new - cb.proc = block - cb.data = data - result = API.sqlite3_trace( db, API::Sqlite3_ruby_trace, cb ) - @trace[db] = cb # see comments in busy_handler - else - result = API.sqlite3_trace( db, nil, nil ) - @trace.delete(db) # see comments in busy_handler - end - - result - end - - def open( filename, utf16=false ) - API.send( utf16 ? :sqlite3_open16 : :sqlite3_open, filename ) - end - - def errmsg( db, utf16=false ) - API.send( utf16 ? :sqlite3_errmsg16 : :sqlite3_errmsg, db ) - end - - def prepare( db, sql, utf16=false ) - API.send( ( utf16 ? :sqlite3_prepare16 : :sqlite3_prepare ), - db, sql ) - end - - def bind_text( stmt, index, value, utf16=false ) - API.send( ( utf16 ? :sqlite3_bind_text16 : :sqlite3_bind_text ), - stmt, index, value.to_s ) - end - - def column_name( stmt, index, utf16=false ) - API.send( ( utf16 ? :sqlite3_column_name16 : :sqlite3_column_name ), - stmt, index ) - end - - def column_decltype( stmt, index, utf16=false ) - API.send( - ( utf16 ? :sqlite3_column_decltype16 : :sqlite3_column_decltype ), - stmt, index ) - end - - def column_text( stmt, index, utf16=false ) - API.send( ( utf16 ? :sqlite3_column_text16 : :sqlite3_column_text ), - stmt, index ) - end - - def create_function( db, name, args, text, cookie, func, step, final ) - if func || ( step && final ) - cb = API::CallbackData.new - cb.proc = cb.proc2 = nil - cb.data = cookie - end - - if func - cb.proc = func - - func = API::Sqlite3_ruby_function_step - step = final = nil - elsif step && final - cb.proc = step - cb.proc2 = final - - func = nil - step = API::Sqlite3_ruby_function_step - final = API::Sqlite3_ruby_function_final - end - - result = API.sqlite3_create_function( db, name, args, text, cb, func, step, final ) - - # see comments in busy_handler - if cb - @callback_data[ name ] = cb - else - @callback_data.delete( name ) - end - - return result - end - - def value_text( value, utf16=false ) - method = case utf16 - when nil, false then :sqlite3_value_text - when :le then :sqlite3_value_text16le - when :be then :sqlite3_value_text16be - else :sqlite3_value_text16 - end - - API.send( method, value ) - end - - def result_text( context, result, utf16=false ) - method = case utf16 - when nil, false then :sqlite3_result_text - when :le then :sqlite3_result_text16le - when :be then :sqlite3_result_text16be - else :sqlite3_result_text16 - end - - API.send( method, context, result.to_s ) - end - - def result_error( context, value, utf16=false ) - API.send( ( utf16 ? :sqlite3_result_error16 : :sqlite3_result_error ), - context, value ) - end - - def self.api_delegate( name ) - eval "def #{name} (*args) API.sqlite3_#{name}( *args ) ; end" - end - - api_delegate :libversion - api_delegate :close - api_delegate :last_insert_rowid - api_delegate :changes - api_delegate :total_changes - api_delegate :interrupt - api_delegate :busy_timeout - api_delegate :errcode - api_delegate :bind_blob - api_delegate :bind_double - api_delegate :bind_int - api_delegate :bind_int64 - api_delegate :bind_null - api_delegate :bind_parameter_count - api_delegate :bind_parameter_name - api_delegate :bind_parameter_index - api_delegate :column_count - api_delegate :step - api_delegate :data_count - api_delegate :column_blob - api_delegate :column_bytes - api_delegate :column_bytes16 - api_delegate :column_double - api_delegate :column_int - api_delegate :column_int64 - api_delegate :column_type - api_delegate :finalize - api_delegate :reset - api_delegate :aggregate_count - api_delegate :value_blob - api_delegate :value_bytes - api_delegate :value_bytes16 - api_delegate :value_double - api_delegate :value_int - api_delegate :value_int64 - api_delegate :value_type - api_delegate :result_blob - api_delegate :result_double - api_delegate :result_int - api_delegate :result_int64 - api_delegate :result_null - api_delegate :result_value - api_delegate :aggregate_context - - end - -end ; end ; end diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/errors.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/errors.rb index b2014453..3936a594 100644 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/errors.rb +++ b/vendor/plugins/sqlite3-ruby/lib/sqlite3/errors.rb @@ -1,7 +1,6 @@ require 'sqlite3/constants' module SQLite3 - class Exception < ::StandardError @code = 0 @@ -42,27 +41,4 @@ module SQLite3 class FormatException < Exception; end class RangeException < Exception; end class NotADatabaseException < Exception; end - - EXCEPTIONS = [ - nil, - SQLException, InternalException, PermissionException, - AbortException, BusyException, LockedException, MemoryException, - ReadOnlyException, InterruptException, IOException, CorruptException, - NotFoundException, FullException, CantOpenException, ProtocolException, - EmptyException, SchemaChangedException, TooBigException, - ConstraintException, MismatchException, MisuseException, - UnsupportedException, AuthorizationException, FormatException, - RangeException, NotADatabaseException - ].each_with_index { |e,i| e.instance_variable_set( :@code, i ) if e } - - module Error - def check( result, db=nil, msg=nil ) - unless result == Constants::ErrorCode::OK - msg = ( msg ? msg + ": " : "" ) + db.errmsg if db - raise(( EXCEPTIONS[result] || SQLite3::Exception ), msg) - end - end - module_function :check - end - end diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/pragmas.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/pragmas.rb index 52bda1a1..2e319387 100644 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/pragmas.rb +++ b/vendor/plugins/sqlite3-ruby/lib/sqlite3/pragmas.rb @@ -213,16 +213,24 @@ module SQLite3 get_query_pragma "index_list", table, &block end - def table_info( table, &block ) # :yields: row - columns, *rows = execute2("PRAGMA table_info(#{table})") + ### + # Returns information about +table+. Yields each row of table information + # if a block is provided. + def table_info table + stmt = prepare "PRAGMA table_info(#{table})" + columns = stmt.columns - needs_tweak_default = version_compare(driver.libversion, "3.3.7") > 0 + needs_tweak_default = + version_compare(SQLite3.libversion.to_s, "3.3.7") > 0 result = [] unless block_given? - rows.each do |row| - new_row = {} - columns.each_with_index do |name, index| - new_row[name] = row[index] + stmt.each do |row| + new_row = Hash[*columns.zip(row).flatten] + + # FIXME: This should be removed but is required for older versions + # of rails + if(Object.const_defined?(:ActiveRecord)) + new_row['notnull'] = new_row['notnull'].to_s end tweak_default(new_row) if needs_tweak_default @@ -233,6 +241,7 @@ module SQLite3 result << new_row end end + stmt.close result end diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/resultset.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/resultset.rb index 66c671c2..bc331b08 100644 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/resultset.rb +++ b/vendor/plugins/sqlite3-ruby/lib/sqlite3/resultset.rb @@ -31,46 +31,22 @@ module SQLite3 # Create a new ResultSet attached to the given database, using the # given sql text. - def initialize( db, stmt ) - @db = db - @driver = @db.driver + def initialize db, stmt + @db = db @stmt = stmt - commence end - # A convenience method for compiling the virtual machine and stepping - # to the first row of the result set. - def commence - result = @driver.step( @stmt.handle ) - if result == Constants::ErrorCode::ERROR - @driver.reset( @stmt.handle ) - end - check result - @first_row = true - end - private :commence - - def check( result ) - @eof = ( result == Constants::ErrorCode::DONE ) - found = ( result == Constants::ErrorCode::ROW ) - Error.check( result, @db ) unless @eof || found - end - private :check - # Reset the cursor, so that a result set which has reached end-of-file # can be rewound and reiterated. def reset( *bind_params ) - @stmt.must_be_open! - @stmt.reset!(false) - @driver.reset( @stmt.handle ) + @stmt.reset! @stmt.bind_params( *bind_params ) @eof = false - commence end # Query whether the cursor has reached the end of the result set or not. def eof? - @eof + @stmt.done? end # Obtain the next row from the cursor. If there are no more rows to be @@ -87,69 +63,39 @@ module SQLite3 # For hashes, the column names are the keys of the hash, and the column # types are accessible via the +types+ property. def next - return nil if @eof + row = @stmt.step + return nil if @stmt.done? - @stmt.must_be_open! - - unless @first_row - result = @driver.step( @stmt.handle ) - check result + if @db.type_translation + row = @stmt.types.zip(row).map do |type, value| + @db.translator.translate( type, value ) + end end - @first_row = false - - unless @eof - row = [] - @driver.data_count( @stmt.handle ).times do |column| - type = @driver.column_type( @stmt.handle, column ) - - if type == Constants::ColumnType::TEXT - row << @driver.column_text( @stmt.handle, column ) - elsif type == Constants::ColumnType::NULL - row << nil - elsif type == Constants::ColumnType::BLOB - row << @driver.column_blob( @stmt.handle, column ) - else - row << @driver.column_text( @stmt.handle, column ) - end - end - - if @db.type_translation - row = @stmt.types.zip( row ).map do |type, value| - @db.translator.translate( type, value ) - end - end - - if @db.results_as_hash - new_row = HashWithTypes[ *( @stmt.columns.zip( row ).to_a.flatten ) ] - row.each_with_index { |value,idx| - value.taint - new_row[idx] = value - } - row = new_row + if @db.results_as_hash + new_row = HashWithTypes[*@stmt.columns.zip(row).flatten] + row.each_with_index { |value,idx| + new_row[idx] = value + } + row = new_row + else + if row.respond_to?(:fields) + row = ArrayWithTypes.new(row) else - if row.respond_to?(:fields) - row = ArrayWithTypes.new(row) - else - row = ArrayWithTypesAndFields.new(row) - end - row.fields = @stmt.columns - row.each { |column| column.taint } + row = ArrayWithTypesAndFields.new(row) end - - row.types = @stmt.types - - return row + row.fields = @stmt.columns end - nil + row.types = @stmt.types + row end # Required by the Enumerable mixin. Provides an internal iterator over the # rows of the result set. - def each - while row=self.next - yield row + def each( &block ) + while node = self.next + yield node end end diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/statement.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/statement.rb index fd9a3060..ade99ef4 100644 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/statement.rb +++ b/vendor/plugins/sqlite3-ruby/lib/sqlite3/statement.rb @@ -8,51 +8,17 @@ class String end module SQLite3 - - # A class for differentiating between strings and blobs, when binding them - # into statements. - class Blob < String; end - # A statement represents a prepared-but-unexecuted SQL query. It will rarely # (if ever) be instantiated directly by a client, and is most often obtained # via the Database#prepare method. class Statement + include Enumerable # This is any text that followed the first valid SQL statement in the text # with which the statement was initialized. If there was no trailing text, # this will be the empty string. attr_reader :remainder - # The underlying opaque handle used to access the SQLite @driver. - attr_reader :handle - - # Create a new statement attached to the given Database instance, and which - # encapsulates the given SQL text. If the text contains more than one - # statement (i.e., separated by semicolons), then the #remainder property - # will be set to the trailing text. - def initialize( db, sql, utf16=false ) - raise ArgumentError, "nil argument passed as sql text" unless sql - @db = db - @driver = @db.driver - @closed = false - @results = @columns = nil - result, @handle, @remainder = @driver.prepare( @db.handle, sql ) - Error.check( result, @db ) - end - - # Closes the statement by finalizing the underlying statement - # handle. The statement must not be used after being closed. - def close - must_be_open! - @closed = true - @driver.finalize( @handle ) - end - - # Returns true if the underlying statement has been closed. - def closed? - @closed - end - # Binds the given variables to the corresponding placeholders in the SQL # text. # @@ -78,42 +44,6 @@ module SQLite3 end end - # Binds value to the named (or positional) placeholder. If +param+ is a - # Fixnum, it is treated as an index for a positional placeholder. - # Otherwise it is used as the name of the placeholder to bind to. - # - # See also #bind_params. - def bind_param( param, value ) - must_be_open! - reset! if active? - if Fixnum === param - case value - when Bignum then - @driver.bind_int64( @handle, param, value ) - when Integer then - if value >= (2 ** 31) - @driver.bind_int64( @handle, param, value ) - else - @driver.bind_int( @handle, param, value ) - end - when Numeric then - @driver.bind_double( @handle, param, value.to_f ) - when Blob then - @driver.bind_blob( @handle, param, value ) - when nil then - @driver.bind_null( @handle, param ) - else - @driver.bind_text( @handle, param, value ) - end - else - param = param.to_s - param = ":#{param}" unless param[0] == ?: - index = @driver.bind_parameter_index( @handle, param ) - raise Exception, "no such bind parameter '#{param}'" if index == 0 - bind_param index, value - end - end - # Execute the statement. This creates a new ResultSet object for the # statement's virtual machine. If a block was given, the new ResultSet will # be yielded to it; otherwise, the ResultSet will be returned. @@ -129,17 +59,13 @@ module SQLite3 # # See also #bind_params, #execute!. def execute( *bind_vars ) - must_be_open! - reset! if active? + reset! if active? || done? bind_params(*bind_vars) unless bind_vars.empty? - @results = ResultSet.new( @db, self ) + @results = ResultSet.new(@connection, self) - if block_given? - yield @results - else - return @results - end + yield @results if block_given? + @results end # Execute the statement. If no block was given, this returns an array of @@ -156,30 +82,15 @@ module SQLite3 # end # # See also #bind_params, #execute. - def execute!( *bind_vars ) - result = execute( *bind_vars ) - rows = [] unless block_given? - while row = result.next - if block_given? - yield row - else - rows << row - end - end - rows - end - - # Resets the statement. This is typically done internally, though it might - # occassionally be necessary to manually reset the statement. - def reset!(clear_result=true) - @driver.reset(@handle) - @results = nil if clear_result + def execute!( *bind_vars, &block ) + execute(*bind_vars) + block_given? ? each(&block) : to_a end # Returns true if the statement is currently active, meaning it has an # open result set. def active? - not @results.nil? + !done? end # Return an array of the column names for this statement. Note that this @@ -190,11 +101,20 @@ module SQLite3 return @columns end + def each + loop do + val = step + break self if done? + yield val + end + end + # Return an array of the data types for each column in this statement. Note # that this may execute the statement in order to obtain the metadata; this # makes it a (potentially) expensive operation. def types - get_metadata unless defined?(@types) + must_be_open! + get_metadata unless @types @types end @@ -202,15 +122,12 @@ module SQLite3 # that this will actually execute the SQL, which means it can be a # (potentially) expensive operation. def get_metadata - must_be_open! - @columns = [] @types = [] - column_count = @driver.column_count( @handle ) column_count.times do |column| - @columns << @driver.column_name( @handle, column ) - @types << @driver.column_decltype( @handle, column ) + @columns << column_name(column) + @types << column_decltype(column) end @columns.freeze @@ -221,11 +138,9 @@ module SQLite3 # Performs a sanity check to ensure that the statement is not # closed. If it is, an exception is raised. def must_be_open! # :nodoc: - if @closed + if closed? raise SQLite3::Exception, "cannot use a closed statement" end end - end - end diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/translator.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/translator.rb index 1635e982..cae36941 100644 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/translator.rb +++ b/vendor/plugins/sqlite3-ruby/lib/sqlite3/translator.rb @@ -44,7 +44,12 @@ module SQLite3 # and are always passed straight through regardless of the type parameter. def translate( type, value ) unless value.nil? - @translators[ type_name( type ) ].call( type, value ) + # FIXME: this is a hack to support Sequel + if type && %w{ datetime timestamp }.include?(type.downcase) + @translators[ type_name( type ) ].call( type, value.to_s ) + else + @translators[ type_name( type ) ].call( type, value ) + end end end diff --git a/vendor/plugins/sqlite3-ruby/lib/sqlite3/version.rb b/vendor/plugins/sqlite3-ruby/lib/sqlite3/version.rb index b162acde..71575622 100644 --- a/vendor/plugins/sqlite3-ruby/lib/sqlite3/version.rb +++ b/vendor/plugins/sqlite3-ruby/lib/sqlite3/version.rb @@ -3,14 +3,14 @@ module SQLite3 module Version MAJOR = 1 - MINOR = 2 - TINY = 5 + MINOR = 3 + TINY = 0 BUILD = nil STRING = [ MAJOR, MINOR, TINY, BUILD ].compact.join( "." ) #:beta-tag: - VERSION = '1.2.5' + VERSION = '1.3.0' end end diff --git a/vendor/plugins/sqlite3-ruby/setup.rb b/vendor/plugins/sqlite3-ruby/setup.rb index 5f22fc1f..82b45091 100644 --- a/vendor/plugins/sqlite3-ruby/setup.rb +++ b/vendor/plugins/sqlite3-ruby/setup.rb @@ -481,7 +481,7 @@ module FileOperations end def extdir?(dir) - File.exist?(dir + '/MANIFEST') + File.exist?(dir + '/MANIFEST') or File.exist?("#{dir}/extconf.rb") end def all_files_in(dirname) @@ -1149,7 +1149,7 @@ class Installer def install_dir_ext(rel) return unless extdir?(curr_srcdir()) install_files ruby_extentions('.'), - "#{config('so-dir')}/#{File.dirname(rel)}", + "#{config('so-dir')}/#{rel}", 0555 end diff --git a/vendor/plugins/sqlite3-ruby/sqlite3-ruby.gemspec b/vendor/plugins/sqlite3-ruby/sqlite3-ruby.gemspec deleted file mode 100644 index c8495011..00000000 --- a/vendor/plugins/sqlite3-ruby/sqlite3-ruby.gemspec +++ /dev/null @@ -1,141 +0,0 @@ ---- !ruby/object:Gem::Specification -name: sqlite3-ruby -version: !ruby/object:Gem::Version - version: 1.2.5 -platform: ruby -authors: -- Jamis Buck -autorequire: -bindir: bin -cert_chain: [] - -date: 2009-07-25 00:00:00 -03:00 -default_executable: -dependencies: -- !ruby/object:Gem::Dependency - name: mocha - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: rake-compiler - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ~> - - !ruby/object:Gem::Version - version: 0.5.0 - version: -- !ruby/object:Gem::Dependency - name: hoe - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 2.3.2 - version: -description: |- - This module allows Ruby programs to interface with the SQLite3 - database engine (http://www.sqlite.org). You must have the - SQLite engine installed in order to build this module. - - Note that this module is NOT compatible with SQLite 2.x. -email: -- jamis@37signals.com -executables: [] - -extensions: -- ext/sqlite3_api/extconf.rb -extra_rdoc_files: -- History.txt -- Manifest.txt -- README.txt -files: -- ChangeLog.cvs -- History.txt -- LICENSE -- Manifest.txt -- README.txt -- Rakefile -- ext/sqlite3_api/extconf.rb -- ext/sqlite3_api/sqlite3_api.i -- ext/sqlite3_api/sqlite3_api_wrap.c -- faq/faq.rb -- faq/faq.yml -- lib/sqlite3.rb -- lib/sqlite3/constants.rb -- lib/sqlite3/database.rb -- lib/sqlite3/driver/dl/api.rb -- lib/sqlite3/driver/dl/driver.rb -- lib/sqlite3/driver/native/driver.rb -- lib/sqlite3/errors.rb -- lib/sqlite3/pragmas.rb -- lib/sqlite3/resultset.rb -- lib/sqlite3/statement.rb -- lib/sqlite3/translator.rb -- lib/sqlite3/value.rb -- lib/sqlite3/version.rb -- setup.rb -- tasks/benchmark.rake -- tasks/faq.rake -- tasks/gem.rake -- tasks/native.rake -- tasks/vendor_sqlite3.rake -- test/bm.rb -- test/driver/dl/tc_driver.rb -- test/helper.rb -- test/native-vs-dl.rb -- test/test_database.rb -- test/test_errors.rb -- test/test_integration.rb -- test/test_integration_open_close.rb -- test/test_integration_pending.rb -- test/test_integration_resultset.rb -- test/test_integration_statement.rb -has_rdoc: true -homepage: http://sqlite3-ruby.rubyforge.org -licenses: [] - -post_install_message: -rdoc_options: -- --main -- README.txt -- --main=README.txt -require_paths: -- lib -- ext -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">" - - !ruby/object:Gem::Version - version: 1.8.5 - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -requirements: [] - -rubyforge_project: sqlite-ruby -rubygems_version: 1.3.5 -signing_key: -specification_version: 3 -summary: This module allows Ruby programs to interface with the SQLite3 database engine (http://www.sqlite.org) -test_files: -- test/test_database.rb -- test/test_errors.rb -- test/test_integration.rb -- test/test_integration_open_close.rb -- test/test_integration_pending.rb -- test/test_integration_resultset.rb -- test/test_integration_statement.rb diff --git a/vendor/plugins/sqlite3-ruby/test/bm.rb b/vendor/plugins/sqlite3-ruby/test/bm.rb deleted file mode 100644 index aacb4a12..00000000 --- a/vendor/plugins/sqlite3-ruby/test/bm.rb +++ /dev/null @@ -1,140 +0,0 @@ -require 'benchmark' - -N = 1000 - -$VERBOSE=nil - -puts "file require" -Benchmark.bm( 7 ) do |x| - x.report('sqlite') do - N.times do - $".delete_if { |i| i =~ /sqlite/ } - require 'sqlite' - end - end - x.report('sqlite3') do - N.times do - $".delete_if { |i| i =~ /sqlite3/ } - require 'sqlite3' - end - end -end - -puts -puts "database creation..." -Benchmark.bm( 7 ) do |x| - x.report('sqlite') do - N.times do - File.delete "test.db" rescue nil - SQLite::Database.open( "test.db" ).close - end - end - x.report('sqlite3') do - N.times do - File.delete "test.db" rescue nil - SQLite3::Database.open( "test.db" ).close - end - end -end -File.delete "test.db" rescue nil - -SQLite::Database.open( "test.db" ).close -SQLite3::Database.open( "test3.db" ).close - -puts -puts "database open..." -Benchmark.bm( 7 ) do |x| - x.report('sqlite') do - N.times do - SQLite::Database.open( "test.db" ).close - end - end - x.report('sqlite3') do - N.times do - SQLite3::Database.open( "test3.db" ).close - end - end -end -File.delete "test.db" rescue nil -File.delete "test3.db" rescue nil - -db = SQLite::Database.open( "test.db" ) -db3 = SQLite3::Database.open( "test3.db" ) - -db.execute "create table foo (a,b)" -db3.execute "create table foo (a,b)" - -puts -puts "insertions" -Benchmark.bm( 7 ) do |x| - x.report('sqlite') do - db.transaction do - N.times do |i| - db.execute "insert into foo values (#{i}, #{i+1})" - end - end - end - x.report('sqlite3') do - db3.transaction do - N.times do |i| - db3.execute "insert into foo values (#{i}, #{i+1})" - end - end - end -end - -puts -puts "insertions using prepared statement" -Benchmark.bm( 7 ) do |x| - x.report('sqlite') do - db.transaction do - stmt = db.prepare "insert into foo values (?,?)" - N.times { |i| stmt.execute i, i+1 } - end - end - x.report('sqlite3') do - db3.transaction do - db3.prepare( "insert into foo values (?,?)" ) do |stmt| - N.times { |i| stmt.execute i, i+1 } - end - end - end -end - -db.close -db3.close -File.delete "test.db" rescue nil -File.delete "test3.db" rescue nil - -db = SQLite::Database.open( "test.db" ) -db3 = SQLite3::Database.open( "test3.db" ) - -db.execute "create table foo (a,b)" -db.execute "insert into foo values (1,2)" -db.execute "insert into foo values (3,4)" -db.execute "insert into foo values (5,6)" - -db3.execute "create table foo (a,b)" -db3.execute "insert into foo values (1,2)" -db3.execute "insert into foo values (3,4)" -db3.execute "insert into foo values (5,6)" - -puts -puts "queries" -Benchmark.bm( 7 ) do |x| - x.report('sqlite') do - N.times do - db.execute "select * from foo" - end - end - x.report('sqlite3') do - N.times do - db3.execute "select * from foo" - end - end -end - -db.close -db3.close -File.delete "test.db" rescue nil -File.delete "test3.db" rescue nil diff --git a/vendor/plugins/sqlite3-ruby/test/driver/dl/tc_driver.rb b/vendor/plugins/sqlite3-ruby/test/driver/dl/tc_driver.rb deleted file mode 100644 index b2cb2df4..00000000 --- a/vendor/plugins/sqlite3-ruby/test/driver/dl/tc_driver.rb +++ /dev/null @@ -1,292 +0,0 @@ -if (ENV["SQLITE3_DRIVERS"] || "Native").split(/,/).include?("DL") - $:.unshift "../../../lib" - - require 'sqlite3/constants' - require 'sqlite3/driver/dl/driver' - require 'test/unit' - - class TC_DL_Driver < Test::Unit::TestCase - - def utf16ify( str ) - chars = str.split(//) - chars.zip(["\0"] * chars.length).flatten.join - end - - def setup - @driver = SQLite3::Driver::DL::Driver.new - @dbname = "test.db" - @db = nil - end - - def teardown - @driver.close( @db ) rescue nil - File.delete @dbname rescue nil - end - - def test_open - result, @db = @driver.open( @dbname ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - assert File.exist?( @dbname ) - end - - def test_open_utf16 - name = utf16ify( @dbname ) - result, @db = @driver.open( name, true ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - assert File.exist?( @dbname ) - end - - def test_errmsg - result, @db = @driver.open( @dbname ) - msg = @driver.errmsg( @db ) - assert_equal msg, "not an error" - end - - def test_errmsg16 - result, @db = @driver.open( @dbname ) - msg = @driver.errmsg( @db, true ) - assert_equal msg, utf16ify( "not an error" ) - end - - def test_prepare - result, @db = @driver.open( @dbname ) - sql = "create table foo ( a, b )" - result, handle, remainder = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - assert_equal "", remainder - @driver.finalize( handle ) - end - - def test_prepare_error - result, @db = @driver.open( @dbname ) - sql = "create tble foo ( a, b )" - result, handle, remainder = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::ERROR, result - end - - def test_prepare_remainder - result, @db = @driver.open( @dbname ) - sql = "create table foo ( a, b ); select * from foo" - result, handle, remainder = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - assert_equal " select * from foo", remainder - @driver.finalize( handle ) - end - - def test_prepare16 - result, @db = @driver.open( @dbname ) - sql = utf16ify( "create table foo ( a, b )" ) - result, handle, remainder = @driver.prepare( @db, sql, true ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - assert_equal "", remainder - @driver.finalize( handle ) - end - - def test_prepare16_remainder - result, @db = @driver.open( @dbname ) - sql = utf16ify( "create table foo ( a, b ); select * from foo" ) - result, handle, remainder = @driver.prepare( @db, sql, true ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - assert_equal utf16ify( " select * from foo" ), remainder - @driver.finalize( handle ) - end - - def test_complete - assert @driver.complete?( "select * from foo;" ) - end - - def test_complete_fail - assert !@driver.complete?( "select * from foo" ) - end - - def test_complete16 - assert @driver.complete?( utf16ify("select * from foo;"), true ) - end - - def create_foo - result, @db = @driver.open( @dbname ) - sql = "create table foo ( a, b )" - result, handle, = @driver.prepare( @db, sql ) - @driver.step( handle ) - @driver.finalize( handle ) - end - - def populate_foo - create_foo - sql = "insert into foo values ( 100, 200 )" - result, handle, = @driver.prepare( @db, sql ) - @driver.step( handle ) - @driver.finalize( handle ) - end - - def test_step - populate_foo - sql = "select * from foo" - result, handle, = @driver.prepare( @db, sql ) - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::ROW, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::DONE, result - @driver.finalize( handle ) - end - - def test_step_fail - populate_foo - sql = "select * from" - result, handle, = @driver.prepare( @db, sql ) - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::MISUSE, result - @driver.finalize( handle ) - end - - def test_bind_blob - create_foo - sql = "insert into foo (b) values (?)" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.bind_blob( handle, 1, "a\0b\1c\2d\0e" ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::DONE, result - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - sql = "select b from foo" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::ROW, result - assert_equal "a\0b\1c\2d\0e", @driver.column_blob( handle, 0 ) - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - end - - def test_bind_double - create_foo - sql = "insert into foo (b) values (?)" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.bind_double( handle, 1, 3.14 ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::DONE, result - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - sql = "select b from foo" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::ROW, result - assert_equal 3.14, @driver.column_double( handle, 0 ) - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - end - - def test_bind_int - create_foo - sql = "insert into foo (b) values (?)" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.bind_int( handle, 1, 14 ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::DONE, result - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - sql = "select b from foo" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::ROW, result - assert_equal 14, @driver.column_int( handle, 0 ) - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - end - - def test_bind_null - create_foo - sql = "insert into foo (b) values (?)" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.bind_null( handle, 1 ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::DONE, result - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - sql = "select b from foo" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::ROW, result - assert_equal SQLite3::Constants::ColumnType::NULL, - @driver.column_type( handle, 0 ) - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - end - - def test_bind_text - create_foo - sql = "insert into foo (b) values (?)" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.bind_text( handle, 1, "hello, world" ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::DONE, result - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - sql = "select b from foo" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::ROW, result - assert_equal "hello, world", @driver.column_text( handle, 0 ) - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - end - - def test_bind_text16 - create_foo - sql = "insert into foo (b) values (?)" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.bind_text( handle, 1, utf16ify("hello, world"), true ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::DONE, result - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - sql = "select b from foo" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.step( handle ) - assert_equal SQLite3::Constants::ErrorCode::ROW, result - assert_equal "hello, world", @driver.column_text( handle, 0 ) - result = @driver.finalize( handle ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - end - - def test_bind_parameter_index - create_foo - sql = "insert into foo (b) values (:hello)" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - result = @driver.bind_parameter_index( handle, ":hello" ) - assert_equal 1, result - result = @driver.bind_parameter_index( handle, ":foo" ) - assert_equal 0, result - @driver.finalize( handle ) - end - - def test_bind_parameter_name - create_foo - sql = "insert into foo (a,b) values (?,:foo)" - result, handle, = @driver.prepare( @db, sql ) - assert_equal SQLite3::Constants::ErrorCode::OK, result - assert_nil nil, @driver.bind_parameter_name(handle,1) - assert_equal ":foo", @driver.bind_parameter_name(handle,2) - @driver.finalize( handle ) - end - - end -end \ No newline at end of file diff --git a/vendor/plugins/sqlite3-ruby/test/helper.rb b/vendor/plugins/sqlite3-ruby/test/helper.rb index 6d5aa90e..a61859e6 100644 --- a/vendor/plugins/sqlite3-ruby/test/helper.rb +++ b/vendor/plugins/sqlite3-ruby/test/helper.rb @@ -1,67 +1,3 @@ -# add lib folder to the path -$:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) - require 'sqlite3' - -require 'rubygems' require 'test/unit' - -# define mocks to be used -require 'mocha' - -class Driver < Mocha::Mock - def initialize - super - stubs( :open ).returns([0, 'cookie']) - stubs( :close ).returns(0) - stubs( :complete? ).returns(0) - stubs( :errmsg ).returns('') - stubs( :errcode ).returns(0) - stubs( :trace ).returns(nil) - stubs( :set_authorizer ).returns(0) - stubs( :prepare ).returns([0, 'stmt', 'remainder']) - stubs( :finalize ).returns(0) - stubs( :changes ).returns(14) - stubs( :total_changes ).returns(28) - stubs( :interrupt ).returns(0) - end -end - -class MockResultSet < Mocha::Mock - def initialize - super - stubs( :each ).yields(['foo']) - stubs( :columns ).returns(['name']) - end -end - -class Statement < Mocha::Mock - attr_reader :handle - attr_reader :sql - attr_reader :last_result - - def initialize( handle, sql ) - super() - @handle = handle - @sql = sql - stubs( :close ).returns(0) - stubs( :remainder ).returns('') - stubs( :execute ).returns(MockResultSet.new) - end -end - -# UTF conversion extensions -class String - def to_utf16(terminate=false) - self.split(//).map { |c| c[0] }.pack("v*") + - (terminate ? "\0\0" : "") - end - - def from_utf16 - result = "" - length.times do |i| - result << self[i,1] if i % 2 == 0 && self[i] != 0 - end - result - end -end +require 'iconv' diff --git a/vendor/plugins/sqlite3-ruby/test/native-vs-dl.rb b/vendor/plugins/sqlite3-ruby/test/native-vs-dl.rb deleted file mode 100644 index 45e7e28b..00000000 --- a/vendor/plugins/sqlite3-ruby/test/native-vs-dl.rb +++ /dev/null @@ -1,126 +0,0 @@ -$:.unshift "../lib", "../ext/sqlite3_api" - -require 'sqlite3' - -require 'benchmark' - -N = 1000 - -$VERBOSE=nil - -puts "database creation..." -Benchmark.bm( 7 ) do |x| - x.report('dl') do - N.times do - File.delete "test.db" rescue nil - SQLite3::Database.open( "test.db", :driver => "DL" ).close - end - end - x.report('native') do - N.times do - File.delete "test.db" rescue nil - SQLite3::Database.open( "test.db", :driver => "Native" ).close - end - end -end -File.delete "test.db" rescue nil - -SQLite3::Database.open( "test.db" ).close - -puts -puts "database open..." -Benchmark.bm( 7 ) do |x| - x.report('dl') do - N.times do - SQLite3::Database.open( "test.db", :driver => "DL" ).close - end - end - x.report('native') do - N.times do - SQLite3::Database.open( "test.db", :driver => "Native" ).close - end - end -end -File.delete "test.db" rescue nil - -dl = SQLite3::Database.open( "test-dl.db", :driver => "DL" ) -native = SQLite3::Database.open( "test-native.db", :driver => "Native" ) - -dl.execute "create table foo (a,b)" -native.execute "create table foo (a,b)" - -puts -puts "insertions" -Benchmark.bm( 7 ) do |x| - x.report('dl') do - dl.transaction do - N.times do |i| - dl.execute "insert into foo values (#{i}, #{i+1})" - end - end - end - x.report('native') do - native.transaction do - N.times do |i| - native.execute "insert into foo values (#{i}, #{i+1})" - end - end - end -end - -puts -puts "insertions using prepared statement" -Benchmark.bm( 7 ) do |x| - x.report('dl') do - dl.transaction do - dl.prepare "insert into foo values (?,?)" do |stmt| - N.times { |i| stmt.execute i, i+1 } - end - end - end - x.report('native') do - native.transaction do - native.prepare( "insert into foo values (?,?)" ) do |stmt| - N.times { |i| stmt.execute i, i+1 } - end - end - end -end - -dl.close -native.close -File.delete "test-dl.db" rescue nil -File.delete "test-native.db" rescue nil - -dl = SQLite3::Database.open( "test-dl.db", :driver => "DL" ) -native = SQLite3::Database.open( "test-native.db", :driver => "Native" ) - -dl.execute "create table foo (a,b)" -dl.execute "insert into foo values (1,2)" -dl.execute "insert into foo values (3,4)" -dl.execute "insert into foo values (5,6)" - -native.execute "create table foo (a,b)" -native.execute "insert into foo values (1,2)" -native.execute "insert into foo values (3,4)" -native.execute "insert into foo values (5,6)" - -puts -puts "queries" -Benchmark.bm( 7 ) do |x| - x.report('dl') do - N.times do - dl.execute "select * from foo" - end - end - x.report('native') do - N.times do - native.execute "select * from foo" - end - end -end - -dl.close -native.close -File.delete "test-dl.db" rescue nil -File.delete "test-native.db" rescue nil diff --git a/vendor/plugins/sqlite3-ruby/test/test_database.rb b/vendor/plugins/sqlite3-ruby/test/test_database.rb index ca4d8e35..9c319a77 100644 --- a/vendor/plugins/sqlite3-ruby/test/test_database.rb +++ b/vendor/plugins/sqlite3-ruby/test/test_database.rb @@ -1,217 +1,291 @@ -require File.join(File.dirname(__FILE__), 'helper') +require 'helper' +require 'iconv' -class TC_Database_Init < Test::Unit::TestCase - def test_new - # any_instance fails here... - driver = Driver.new - driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie']) - Driver.stubs(:new).returns(driver) - db = SQLite3::Database.new( 'foo.db', :driver => Driver ) - assert !db.closed? - assert !db.results_as_hash - assert !db.type_translation - end - - def test_new_with_block - driver = Driver.new - driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie']) - Driver.stubs(:new).returns(driver) - returned_db = SQLite3::Database.new( "foo.db", :driver => Driver ) do |db| - assert !db.closed? - assert !db.results_as_hash - assert !db.type_translation +module SQLite3 + class TestDatabase < Test::Unit::TestCase + def setup + @db = SQLite3::Database.new(':memory:') end - assert returned_db.closed? - end - def test_open - driver = Driver.new - driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie']) - Driver.stubs(:new).returns(driver) - db = SQLite3::Database.open( "foo.db", :driver => Driver ) - assert !db.closed? - assert !db.results_as_hash - assert !db.type_translation - end - - def test_open_with_block - driver = Driver.new - driver.expects(:open).once.with('foo.db', false).returns([0, 'cookie']) - Driver.stubs(:new).returns(driver) - returned_db = SQLite3::Database.open( "foo.db", :driver => Driver ) do |db| - assert !db.closed? - assert !db.results_as_hash - assert !db.type_translation + def test_changes + @db.execute("CREATE TABLE items (id integer PRIMARY KEY AUTOINCREMENT, number integer)") + assert_equal 0, @db.changes + @db.execute("INSERT INTO items (number) VALUES (10)") + assert_equal 1, @db.changes + @db.execute_batch( + "UPDATE items SET number = (number + :nn) WHERE (number = :n)", + {"nn" => 20, "n" => 10}) + assert_equal 1, @db.changes + assert_equal [[30]], @db.execute("select number from items") + end + + def test_new + db = SQLite3::Database.new(':memory:') + assert db + end + + def test_new_yields_self + thing = nil + SQLite3::Database.new(':memory:') do |db| + thing = db + end + assert_instance_of(SQLite3::Database, thing) + end + + def test_new_with_options + db = SQLite3::Database.new(Iconv.conv('UTF-16LE', 'UTF-8', ':memory:'), + :utf16 => true) + assert db + end + + def test_close + db = SQLite3::Database.new(':memory:') + db.close + assert db.closed? + end + + def test_block_closes_self + thing = nil + SQLite3::Database.new(':memory:') do |db| + thing = db + assert !thing.closed? + end + assert thing.closed? + end + + def test_prepare + db = SQLite3::Database.new(':memory:') + stmt = db.prepare('select "hello world"') + assert_instance_of(SQLite3::Statement, stmt) + end + + def test_total_changes + db = SQLite3::Database.new(':memory:') + db.execute("create table foo ( a integer primary key, b text )") + db.execute("insert into foo (b) values ('hello')") + assert_equal 1, db.total_changes + end + + def test_execute_returns_list_of_hash + db = SQLite3::Database.new(':memory:', :results_as_hash => true) + db.execute("create table foo ( a integer primary key, b text )") + db.execute("insert into foo (b) values ('hello')") + rows = db.execute("select * from foo") + assert_equal [{0=>1, "a"=>1, "b"=>"hello", 1=>"hello"}], rows + end + + def test_execute_yields_hash + db = SQLite3::Database.new(':memory:', :results_as_hash => true) + db.execute("create table foo ( a integer primary key, b text )") + db.execute("insert into foo (b) values ('hello')") + db.execute("select * from foo") do |row| + assert_equal({0=>1, "a"=>1, "b"=>"hello", 1=>"hello"}, row) + end + end + + def test_table_info + db = SQLite3::Database.new(':memory:', :results_as_hash => true) + db.execute("create table foo ( a integer primary key, b text )") + info = [{ + "name" => "a", + "pk" => 1, + "notnull" => 0, + "type" => "integer", + "dflt_value" => nil, + "cid" => 0 + }, + { + "name" => "b", + "pk" => 0, + "notnull" => 0, + "type" => "text", + "dflt_value" => nil, + "cid" => 1 + }] + assert_equal info, db.table_info('foo') + end + + def test_total_changes_closed + db = SQLite3::Database.new(':memory:') + db.close + assert_raise(SQLite3::Exception) do + db.total_changes + end + end + + def test_trace_requires_opendb + @db.close + assert_raise(SQLite3::Exception) do + @db.trace { |x| } + end + end + + def test_trace_with_block + result = nil + @db.trace { |sql| result = sql } + @db.execute "select 'foo'" + assert_equal "select 'foo'", result + end + + def test_trace_with_object + obj = Class.new { + attr_accessor :result + def call sql; @result = sql end + }.new + + @db.trace(obj) + @db.execute "select 'foo'" + assert_equal "select 'foo'", obj.result + end + + def test_trace_takes_nil + @db.trace(nil) + @db.execute "select 'foo'" + end + + def test_last_insert_row_id_closed + @db.close + assert_raise(SQLite3::Exception) do + @db.last_insert_row_id + end + end + + def test_define_function + called_with = nil + @db.define_function("hello") do |value| + called_with = value + end + @db.execute("select hello(10)") + assert_equal 10, called_with + end + + def test_call_func_arg_type + called_with = nil + @db.define_function("hello") do |b, c, d| + called_with = [b, c, d] + nil + end + @db.execute("select hello(2.2, 'foo', NULL)") + assert_equal [2.2, 'foo', nil], called_with + end + + def test_define_varargs + called_with = nil + @db.define_function("hello") do |*args| + called_with = args + nil + end + @db.execute("select hello(2.2, 'foo', NULL)") + assert_equal [2.2, 'foo', nil], called_with + end + + def test_function_return + @db.define_function("hello") { |a| 10 } + assert_equal [10], @db.execute("select hello('world')").first + end + + def test_function_return_types + [10, 2.2, nil, "foo"].each do |thing| + @db.define_function("hello") { |a| thing } + assert_equal [thing], @db.execute("select hello('world')").first + end + end + + def test_define_function_closed + @db.close + assert_raise(SQLite3::Exception) do + @db.define_function('foo') { } + end + end + + def test_inerrupt_closed + @db.close + assert_raise(SQLite3::Exception) do + @db.interrupt + end + end + + def test_define_aggregate + @db.execute "create table foo ( a integer primary key, b text )" + @db.execute "insert into foo ( b ) values ( 'foo' )" + @db.execute "insert into foo ( b ) values ( 'bar' )" + @db.execute "insert into foo ( b ) values ( 'baz' )" + + acc = Class.new { + attr_reader :sum + alias :finalize :sum + def initialize + @sum = 0 + end + + def step a + @sum += a + end + }.new + + @db.define_aggregator("accumulate", acc) + value = @db.get_first_value( "select accumulate(a) from foo" ) + assert_equal 6, value + end + + def test_authorizer_ok + @db.authorizer = Class.new { + def call action, a, b, c, d; true end + }.new + @db.prepare("select 'fooooo'") + + @db.authorizer = Class.new { + def call action, a, b, c, d; 0 end + }.new + @db.prepare("select 'fooooo'") + end + + def test_authorizer_ignore + @db.authorizer = Class.new { + def call action, a, b, c, d; nil end + }.new + stmt = @db.prepare("select 'fooooo'") + assert_equal nil, stmt.step + end + + def test_authorizer_fail + @db.authorizer = Class.new { + def call action, a, b, c, d; false end + }.new + assert_raises(SQLite3::AuthorizationException) do + @db.prepare("select 'fooooo'") + end + end + + def test_remove_auth + @db.authorizer = Class.new { + def call action, a, b, c, d; false end + }.new + assert_raises(SQLite3::AuthorizationException) do + @db.prepare("select 'fooooo'") + end + + @db.authorizer = nil + @db.prepare("select 'fooooo'") + end + + def test_close_with_open_statements + stmt = @db.prepare("select 'foo'") + assert_raises(SQLite3::BusyException) do + @db.close + end + end + + def test_execute_with_empty_bind_params + assert_equal [['foo']], @db.execute("select 'foo'", []) + end + + def test_query_with_named_bind_params + assert_equal [['foo']], @db.query("select :n", {'n' => 'foo'}).to_a + end + + def test_execute_with_named_bind_params + assert_equal [['foo']], @db.execute("select :n", {'n' => 'foo'}) end - assert returned_db.closed? - end - - def test_with_type_translation - db = SQLite3::Database.open( "foo.db", :driver => Driver, - :type_translation => true ) - assert db.type_translation - end - - def test_with_results_as_hash - db = SQLite3::Database.open( "foo.db", :driver => Driver, - :results_as_hash => true ) - assert db.results_as_hash - end - - def test_with_type_translation_and_results_as_hash - db = SQLite3::Database.open( "foo.db", :driver => Driver, - :results_as_hash => true, - :type_translation => true ) - assert db.results_as_hash - assert db.type_translation - end -end - -class TC_Database < Test::Unit::TestCase - def setup - @db = SQLite3::Database.open( "foo.db", - :driver => Driver, :statement_factory => Statement ) - end - - def test_quote - assert_equal "''one''two''three''", SQLite3::Database.quote( - "'one'two'three'" ) - end - - def test_complete - Driver.any_instance.expects(:complete?) - @db.complete? "foo" - end - - def test_errmsg - Driver.any_instance.expects(:errmsg) - @db.errmsg - end - - def test_errcode - Driver.any_instance.expects(:errcode) - @db.errcode - end - - def test_translator - translator = @db.translator - assert_instance_of SQLite3::Translator, translator - end - - def test_close - Driver.any_instance.expects(:close).returns(0) - @db.close - assert @db.closed? - Driver.any_instance.expects(:close).never - @db.close - end - - def test_trace - Driver.any_instance.expects(:trace).with('cookie', 15) - @db.trace( 15 ) { "foo" } - # assert_equal 1, driver.mock_blocks[:trace].length - end - - def test_authorizer - Driver.any_instance.expects(:set_authorizer).with('cookie', 15).returns(0) - @db.authorizer( 15 ) { "foo" } - # assert_equal 1, driver.mock_blocks[:set_authorizer].length - end - - def test_prepare_no_block - Statement.any_instance.expects(:close).never - assert_nothing_raised { @db.prepare( "foo" ) } - end - - def test_prepare_with_block - called = false - # any_instance fails here... - statement = Statement.new('cookie', 'foo') - statement.expects(:close).once - Statement.stubs(:new).returns(statement) - @db.prepare( "foo" ) { |stmt| called = true } - assert called - end - - def test_execute_no_block - # any_instance fails here... - statement = Statement.new('cookie', 'foo') - statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new) - Statement.stubs(:new).returns(statement) - MockResultSet.any_instance.stubs(:inject).returns([['foo']]) - result = @db.execute( "foo", "bar", "baz" ) - assert_equal [["foo"]], result - end - - def test_execute_with_block - called = false - # any_instance fails here... - statement = Statement.new('cookie', 'foo') - statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new) - Statement.stubs(:new).returns(statement) - @db.execute( "foo", "bar", "baz" ) do |row| - called = true - assert_equal ["foo"], row - end - - assert called - end - - def test_execute2_no_block - # any_instance fails here... - statement = Statement.new('cookie', 'foo') - statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new) - Statement.stubs(:new).returns(statement) - MockResultSet.any_instance.stubs(:inject).returns([['name'], ['foo']]) - result = @db.execute2( "foo", "bar", "baz" ) - assert_equal [["name"],["foo"]], result - end - - def test_execute2_with_block - called = false - parts = [ ["name"],["foo"] ] - # any_instance fails here... - statement = Statement.new('cookie', 'foo') - statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new) - Statement.stubs(:new).returns(statement) - @db.execute2( "foo", "bar", "baz" ) do |row| - called = true - assert_equal parts.shift, row - end - - assert called - end - - def test_execute_batch - # any_instance fails here... - statement = Statement.new('cookie', 'foo') - statement.expects(:execute).with('bar', 'baz').returns(MockResultSet.new) - Statement.stubs(:new).returns(statement) - @db.execute_batch( "foo", "bar", "baz" ) - end - - def test_get_first_row - result = @db.get_first_row( "foo", "bar", "baz" ) - assert_equal ["foo"], result - end - - def test_get_first_value - result = @db.get_first_value( "foo", "bar", "baz" ) - assert_equal "foo", result - end - - def test_changes - Driver.any_instance.expects(:changes).returns(14) - assert_equal 14, @db.changes - end - - def test_total_changes - Driver.any_instance.expects(:total_changes).returns(28) - assert_equal 28, @db.total_changes - end - - def test_interrupt - Driver.any_instance.expects(:interrupt) - @db.interrupt end end diff --git a/vendor/plugins/sqlite3-ruby/test/test_deprecated.rb b/vendor/plugins/sqlite3-ruby/test/test_deprecated.rb new file mode 100644 index 00000000..eecef630 --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/test/test_deprecated.rb @@ -0,0 +1,25 @@ +require 'helper' + +module SQLite3 + class TestDeprecated < Test::Unit::TestCase + def setup + @db = SQLite3::Database.new(':memory:') + end + + def test_query_with_many_bind_params + assert_equal [[nil, 1]], @db.query("select ?, ?", nil, 1).to_a + end + + def test_query_with_nil_bind_params + assert_equal [['foo']], @db.query("select 'foo'", nil).to_a + end + + def test_execute_with_many_bind_params + assert_equal [[nil, 1]], @db.execute("select ?, ?", nil, 1) + end + + def test_execute_with_nil_bind_params + assert_equal [['foo']], @db.execute("select 'foo'", nil) + end + end +end diff --git a/vendor/plugins/sqlite3-ruby/test/test_encoding.rb b/vendor/plugins/sqlite3-ruby/test/test_encoding.rb new file mode 100644 index 00000000..9e28438c --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/test/test_encoding.rb @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- + +require 'helper' + +module SQLite3 + class TestEncoding < Test::Unit::TestCase + def setup + @db = SQLite3::Database.new(':memory:') + @create = "create table ex(id int, data string)" + @insert = "insert into ex(id, data) values (?, ?)" + @db.execute(@create); + end + + def test_default_internal_is_honored + before_enc = Encoding.default_internal + + str = "壁に耳あり、障子に目あり" + stmt = @db.prepare('insert into ex(data) values (?)') + stmt.bind_param 1, str + stmt.step + + Encoding.default_internal = 'EUC-JP' + string = @db.execute('select data from ex').first.first + + assert_equal Encoding.default_internal, string.encoding + assert_equal str.encode('EUC-JP'), string + assert_equal str, string.encode(str.encoding) + ensure + Encoding.default_internal = before_enc + end + + def test_blob_is_binary + str = "猫舌" + @db.execute('create table foo(data text)') + stmt = @db.prepare('insert into foo(data) values (?)') + stmt.bind_param(1, SQLite3::Blob.new(str)) + stmt.step + + string = @db.execute('select data from foo').first.first + assert_equal Encoding.find('ASCII-8BIT'), string.encoding + assert_equal str, string.force_encoding('UTF-8') + end + + def test_blob_is_ascii8bit + str = "猫舌" + @db.execute('create table foo(data text)') + stmt = @db.prepare('insert into foo(data) values (?)') + stmt.bind_param(1, str.dup.force_encoding("ASCII-8BIT")) + stmt.step + + string = @db.execute('select data from foo').first.first + assert_equal Encoding.find('ASCII-8BIT'), string.encoding + assert_equal str, string.force_encoding('UTF-8') + end + + def test_blob_with_eucjp + str = "猫舌".encode("EUC-JP") + @db.execute('create table foo(data text)') + stmt = @db.prepare('insert into foo(data) values (?)') + stmt.bind_param(1, SQLite3::Blob.new(str)) + stmt.step + + string = @db.execute('select data from foo').first.first + assert_equal Encoding.find('ASCII-8BIT'), string.encoding + assert_equal str, string.force_encoding('EUC-JP') + end + + def test_db_with_eucjp + db = SQLite3::Database.new(':memory:'.encode('EUC-JP')) + assert_equal(Encoding.find('UTF-8'), db.encoding) + end + + def test_db_with_utf16 + db = SQLite3::Database.new(':memory:'.encode('UTF-16LE')) + assert_equal(Encoding.find('UTF-16LE'), db.encoding) + end + + def test_statement_eucjp + str = "猫舌" + @db.execute("insert into ex(data) values ('#{str}')".encode('EUC-JP')) + row = @db.execute("select data from ex") + assert_equal @db.encoding, row.first.first.encoding + assert_equal str, row.first.first + end + + def test_statement_utf8 + str = "猫舌" + @db.execute("insert into ex(data) values ('#{str}')") + row = @db.execute("select data from ex") + assert_equal @db.encoding, row.first.first.encoding + assert_equal str, row.first.first + end + + def test_encoding + assert_equal Encoding.find("UTF-8"), @db.encoding + end + + def test_utf_8 + str = "猫舌" + @db.execute(@insert, 10, str) + row = @db.execute("select data from ex") + assert_equal @db.encoding, row.first.first.encoding + assert_equal str, row.first.first + end + + def test_euc_jp + str = "猫舌".encode('EUC-JP') + @db.execute(@insert, 10, str) + row = @db.execute("select data from ex") + assert_equal @db.encoding, row.first.first.encoding + assert_equal str.encode('UTF-8'), row.first.first + end + + end if RUBY_VERSION >= '1.9.1' +end diff --git a/vendor/plugins/sqlite3-ruby/test/test_errors.rb b/vendor/plugins/sqlite3-ruby/test/test_errors.rb deleted file mode 100644 index 132fbc90..00000000 --- a/vendor/plugins/sqlite3-ruby/test/test_errors.rb +++ /dev/null @@ -1,17 +0,0 @@ -require File.join(File.dirname(__FILE__), 'helper') - -class TC_Errors < Test::Unit::TestCase - (1..26).each do |code| - define_method( "test_error_code_%02d" % code ) do - db = stub('database', :errmsg => 'message') - begin - SQLite3::Error.check( code, db ) - rescue SQLite3::Exception => e - assert_instance_of SQLite3::EXCEPTIONS[code], e - assert_equal code, e.code - assert_equal code, e.class.code - assert_equal "message", e.message - end - end - end -end diff --git a/vendor/plugins/sqlite3-ruby/test/test_integration.rb b/vendor/plugins/sqlite3-ruby/test/test_integration.rb index 314a7118..2721c8dd 100644 --- a/vendor/plugins/sqlite3-ruby/test/test_integration.rb +++ b/vendor/plugins/sqlite3-ruby/test/test_integration.rb @@ -1,8 +1,8 @@ -require File.join(File.dirname(__FILE__), 'helper') +require 'helper' class TC_Database_Integration < Test::Unit::TestCase def setup - @db = SQLite3::Database.new( "test.db" ) + @db = SQLite3::Database.new(":memory:") @db.transaction do @db.execute "create table foo ( a integer primary key, b text )" @db.execute "insert into foo ( b ) values ( 'foo' )" @@ -13,7 +13,6 @@ class TC_Database_Integration < Test::Unit::TestCase def teardown @db.close - File.delete( "test.db" ) end def test_table_info_with_type_translation_active @@ -25,9 +24,9 @@ class TC_Database_Integration < Test::Unit::TestCase @db.transaction do @db.execute "create table defaults_test ( a string default NULL, b string default 'Hello' )" data = @db.table_info( "defaults_test" ) - assert_equal({"name" => "a", "type" => "string", "dflt_value" => nil, "notnull" => "0", "cid" => "0", "pk" => "0"}, + assert_equal({"name" => "a", "type" => "string", "dflt_value" => nil, "notnull" => 0, "cid" => 0, "pk" => 0}, data[0]) - assert_equal({"name" => "b", "type" => "string", "dflt_value" => "Hello", "notnull" => "0", "cid" => "1", "pk" => "0"}, + assert_equal({"name" => "b", "type" => "string", "dflt_value" => "Hello", "notnull" => 0, "cid" => 1, "pk" => 0}, data[1]) end end @@ -36,9 +35,9 @@ class TC_Database_Integration < Test::Unit::TestCase @db.transaction do @db.execute "create table no_defaults_test ( a integer default 1, b integer )" data = @db.table_info( "no_defaults_test" ) - assert_equal({"name" => "a", "type" => "integer", "dflt_value" => "1", "notnull" => "0", "cid" => "0", "pk" => "0"}, + assert_equal({"name" => "a", "type" => "integer", "dflt_value" => "1", "notnull" => 0, "cid" => 0, "pk" => 0}, data[0]) - assert_equal({"name" => "b", "type" => "integer", "dflt_value" => nil, "notnull" => "0", "cid" => "1", "pk" => "0"}, + assert_equal({"name" => "b", "type" => "integer", "dflt_value" => nil, "notnull" => 0, "cid" => 1, "pk" => 0}, data[1]) end end @@ -50,21 +49,25 @@ class TC_Database_Integration < Test::Unit::TestCase assert @db.complete?( "select * from foo;" ) end - def test_complete_fail_utf16 - assert !@db.complete?( "select * from foo".to_utf16(false), true ) - end + # FIXME: do people really need UTF16 sql statements? + #def test_complete_fail_utf16 + # assert !@db.complete?( "select * from foo".to_utf16(false), true ) + #end - def test_complete_success_utf16 - assert @db.complete?( "select * from foo;".to_utf16(true), true ) - end + # FIXME: do people really need UTF16 sql statements? + #def test_complete_success_utf16 + # assert @db.complete?( "select * from foo;".to_utf16(true), true ) + #end def test_errmsg assert_equal "not an error", @db.errmsg end - def test_errmsg_utf16 - assert_equal "not an error".to_utf16, @db.errmsg(true) - end + # FIXME: do people really need UTF16 error messages? + #def test_errmsg_utf16 + # msg = Iconv.conv('UTF-16', 'UTF-8', 'not an error') + # assert_equal msg, @db.errmsg(true) + #end def test_errcode assert_equal 0, @db.errcode @@ -72,26 +75,26 @@ class TC_Database_Integration < Test::Unit::TestCase def test_trace result = nil - @db.trace( "data" ) { |data,sql| result = [ data, sql ]; 0 } + @db.trace { |sql| result = sql } @db.execute "select * from foo" - assert_equal ["data","select * from foo"], result + assert_equal "select * from foo", result end def test_authorizer_okay - @db.authorizer( "data" ) { |data,type,a,b,c,d| 0 } + @db.authorizer { |type,a,b,c,d| 0 } rows = @db.execute "select * from foo" assert_equal 3, rows.length end def test_authorizer_error - @db.authorizer( "data" ) { |data,type,a,b,c,d| 1 } + @db.authorizer { |type,a,b,c,d| 1 } assert_raise( SQLite3::AuthorizationException ) do @db.execute "select * from foo" end end def test_authorizer_silent - @db.authorizer( "data" ) { |data,type,a,b,c,d| 2 } + @db.authorizer { |type,a,b,c,d| 2 } rows = @db.execute "select * from foo" assert rows.empty? end @@ -184,7 +187,7 @@ class TC_Database_Integration < Test::Unit::TestCase def test_execute2_no_block_no_bind_no_match columns, *rows = @db.execute2( "select * from foo where a > 100" ) assert rows.empty? - assert [ "a", "b" ], columns + assert_equal [ "a", "b" ], columns end def test_execute2_with_block_no_bind_no_match @@ -199,13 +202,13 @@ class TC_Database_Integration < Test::Unit::TestCase def test_execute2_no_block_with_bind_no_match columns, *rows = @db.execute2( "select * from foo where a > ?", 100 ) assert rows.empty? - assert [ "a", "b" ], columns + assert_equal [ "a", "b" ], columns end def test_execute2_with_block_with_bind_no_match called = 0 @db.execute2( "select * from foo where a > ?", 100 ) do |row| - assert [ "a", "b" ], row unless called == 0 + assert_equal [ "a", "b" ], row unless called == 0 called += 1 end assert_equal 1, called @@ -214,13 +217,13 @@ class TC_Database_Integration < Test::Unit::TestCase def test_execute2_no_block_no_bind_with_match columns, *rows = @db.execute2( "select * from foo where a = 1" ) assert_equal 1, rows.length - assert [ "a", "b" ], columns + assert_equal [ "a", "b" ], columns end def test_execute2_with_block_no_bind_with_match called = 0 @db.execute2( "select * from foo where a = 1" ) do |row| - assert [ "a", "b" ], row unless called == 0 + assert_equal [ 1, "foo" ], row unless called == 0 called += 1 end assert_equal 2, called @@ -229,7 +232,7 @@ class TC_Database_Integration < Test::Unit::TestCase def test_execute2_no_block_with_bind_with_match columns, *rows = @db.execute2( "select * from foo where a = ?", 1 ) assert_equal 1, rows.length - assert [ "a", "b" ], columns + assert_equal [ "a", "b" ], columns end def test_execute2_with_block_with_bind_with_match @@ -265,7 +268,7 @@ class TC_Database_Integration < Test::Unit::TestCase insert into bar values ( 'seven', 8, ? ); SQL rows = @db.execute( "select * from bar" ).map { |a,b,c| c } - assert_equal %w{1 1 1}, rows + assert_equal [1, 1, 1], rows end def test_query_no_block_no_bind_no_match @@ -339,7 +342,7 @@ class TC_Database_Integration < Test::Unit::TestCase def test_get_first_row_no_bind_with_match result = @db.get_first_row( "select * from foo where a=1" ) - assert_equal [ "1", "foo" ], result + assert_equal [ 1, "foo" ], result end def test_get_first_row_with_bind_no_match @@ -349,7 +352,7 @@ class TC_Database_Integration < Test::Unit::TestCase def test_get_first_row_with_bind_with_match result = @db.get_first_row( "select * from foo where a=?", 1 ) - assert_equal [ "1", "foo" ], result + assert_equal [ 1, "foo" ], result end def test_get_first_value_no_bind_no_match @@ -458,7 +461,7 @@ class TC_Database_Integration < Test::Unit::TestCase func.result = x end - assert_raise( SQLite3::SQLException ) do + assert_raise( SQLite3::InterruptException ) do @db.execute "select abort(a) from foo" end end @@ -483,7 +486,7 @@ class TC_Database_Integration < Test::Unit::TestCase @db.create_aggregate( "accumulate", 1, step, final ) value = @db.get_first_value( "select accumulate(a) from foo" ) - assert_equal "6", value + assert_equal 6, value end def test_create_aggregate_with_block @@ -497,7 +500,7 @@ class TC_Database_Integration < Test::Unit::TestCase end value = @db.get_first_value( "select accumulate(a) from foo" ) - assert_equal "6", value + assert_equal 6, value end def test_create_aggregate_with_no_data @@ -512,7 +515,7 @@ class TC_Database_Integration < Test::Unit::TestCase value = @db.get_first_value( "select accumulate(a) from foo where a = 100" ) - assert_equal "0", value + assert_equal 0, value end def test_create_aggregate_handler @@ -531,7 +534,7 @@ class TC_Database_Integration < Test::Unit::TestCase @db.create_aggregate_handler( handler ) value = @db.get_first_value( "select multiply(a) from foo" ) - assert_equal "6", value + assert_equal 6, value end def test_bind_array_parameter diff --git a/vendor/plugins/sqlite3-ruby/test/test_integration_open_close.rb b/vendor/plugins/sqlite3-ruby/test/test_integration_open_close.rb index 14185229..357dcc26 100644 --- a/vendor/plugins/sqlite3-ruby/test/test_integration_open_close.rb +++ b/vendor/plugins/sqlite3-ruby/test/test_integration_open_close.rb @@ -1,4 +1,4 @@ -require File.join(File.dirname(__FILE__), 'helper') +require 'helper' class TC_OpenClose < Test::Unit::TestCase def test_create_close diff --git a/vendor/plugins/sqlite3-ruby/test/test_integration_pending.rb b/vendor/plugins/sqlite3-ruby/test/test_integration_pending.rb index 06357ea4..cb4bea68 100644 --- a/vendor/plugins/sqlite3-ruby/test/test_integration_pending.rb +++ b/vendor/plugins/sqlite3-ruby/test/test_integration_pending.rb @@ -1,11 +1,11 @@ -require File.join(File.dirname(__FILE__), 'helper') +require 'helper' require 'thread' require 'benchmark' class TC_Integration_Pending < Test::Unit::TestCase def setup - @db = SQLite3::Database.new( "test.db" ) + @db = SQLite3::Database.new("test.db") @db.transaction do @db.execute "create table foo ( a integer primary key, b text )" @db.execute "insert into foo ( b ) values ( 'foo' )" @@ -65,8 +65,9 @@ class TC_Integration_Pending < Test::Unit::TestCase db2.close if db2 end end + sleep 1 - @db.busy_handler do |data, count| + @db.busy_handler do |count| handler_call_count += 1 false end @@ -97,6 +98,7 @@ class TC_Integration_Pending < Test::Unit::TestCase end end + sleep 1 time = Benchmark.measure do assert_raise( SQLite3::BusyException ) do @db.execute "insert into foo (b) values ( 'from 2' )" @@ -108,4 +110,4 @@ class TC_Integration_Pending < Test::Unit::TestCase assert time.real*1000 >= 1000 end -end \ No newline at end of file +end diff --git a/vendor/plugins/sqlite3-ruby/test/test_integration_resultset.rb b/vendor/plugins/sqlite3-ruby/test/test_integration_resultset.rb index aee998b4..5274fc90 100644 --- a/vendor/plugins/sqlite3-ruby/test/test_integration_resultset.rb +++ b/vendor/plugins/sqlite3-ruby/test/test_integration_resultset.rb @@ -1,8 +1,8 @@ -require File.join(File.dirname(__FILE__), 'helper') +require 'helper' class TC_ResultSet < Test::Unit::TestCase def setup - @db = SQLite3::Database.new( "test.db" ) + @db = SQLite3::Database.new(":memory:") @db.transaction do @db.execute "create table foo ( a integer primary key, b text )" @db.execute "insert into foo ( b ) values ( 'foo' )" @@ -16,7 +16,6 @@ class TC_ResultSet < Test::Unit::TestCase def teardown @stmt.close @db.close - File.delete( "test.db" ) end def test_reset_unused @@ -56,7 +55,7 @@ class TC_ResultSet < Test::Unit::TestCase def test_next_no_type_translation_no_hash @result.reset( 1 ) - assert_equal [ "1", "foo" ], @result.next + assert_equal [ 1, "foo" ], @result.next end def test_next_type_translation @@ -68,10 +67,22 @@ class TC_ResultSet < Test::Unit::TestCase def test_next_type_translation_with_untyped_column @db.type_translation = true @db.query( "select count(*) from foo" ) do |result| - assert_equal ["3"], result.next + assert_equal [3], result.next end end + def test_type_translation_execute + @db.type_translation = true + @db.execute "create table bar ( a integer, b america )" + @db.execute "insert into bar (a, b) values (NULL, '1974-07-25 14:39:00')" + + @db.translator.add_translator('america') do |type, thing| + 'america' + end + + assert_equal [[nil, 'america']], @db.execute("select * from bar") + end + def test_type_translation_with_null_column @db.type_translation = true @db.execute "create table bar ( a integer, b time, c string )" @@ -98,10 +109,23 @@ class TC_ResultSet < Test::Unit::TestCase end end + def test_real_translation + @db.type_translation = true + @db.execute('create table foo_real(a real)') + @db.execute('insert into foo_real values (42)' ) + @db.query('select a, sum(a), typeof(a), typeof(sum(a)) from foo_real') do |result| + result = result.next + assert result[0].is_a?(Float) + assert result[1].is_a?(Float) + assert result[2].is_a?(String) + assert result[3].is_a?(String) + end + end + def test_next_results_as_hash @db.results_as_hash = true @result.reset( 1 ) - assert_equal( { "a" => "1", "b" => "foo", 0 => "1", 1 => "foo" }, + assert_equal( { "a" => 1, "b" => "foo", 0 => 1, 1 => "foo" }, @result.next ) end @@ -110,7 +134,7 @@ class TC_ResultSet < Test::Unit::TestCase @result.reset( 1 ) row = @result.next row.each do |_, v| - assert_equal true, v.tainted? + assert(v.tainted?) if String === v end end @@ -118,7 +142,7 @@ class TC_ResultSet < Test::Unit::TestCase @result.reset( 1 ) row = @result.next row.each do |v| - assert_equal true, v.tainted? + assert(v.tainted?) if String === v end end diff --git a/vendor/plugins/sqlite3-ruby/test/test_integration_statement.rb b/vendor/plugins/sqlite3-ruby/test/test_integration_statement.rb index 926d510f..9f7cde54 100644 --- a/vendor/plugins/sqlite3-ruby/test/test_integration_statement.rb +++ b/vendor/plugins/sqlite3-ruby/test/test_integration_statement.rb @@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), 'helper') class TC_Statement < Test::Unit::TestCase def setup - @db = SQLite3::Database.new( "test.db" ) + @db = SQLite3::Database.new(":memory:") @db.transaction do @db.execute "create table foo ( a integer primary key, b text )" @db.execute "insert into foo ( b ) values ( 'foo' )" @@ -15,7 +15,6 @@ class TC_Statement < Test::Unit::TestCase def teardown @stmt.close @db.close - File.delete( "test.db" ) end def test_remainder_empty diff --git a/vendor/plugins/sqlite3-ruby/test/test_sqlite3.rb b/vendor/plugins/sqlite3-ruby/test/test_sqlite3.rb new file mode 100644 index 00000000..d28ef64a --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/test/test_sqlite3.rb @@ -0,0 +1,9 @@ +require 'helper' + +module SQLite3 + class TestSQLite3 < Test::Unit::TestCase + def test_libversion + assert_not_nil SQLite3.libversion + end + end +end diff --git a/vendor/plugins/sqlite3-ruby/test/test_statement.rb b/vendor/plugins/sqlite3-ruby/test/test_statement.rb new file mode 100644 index 00000000..fa1f3ffa --- /dev/null +++ b/vendor/plugins/sqlite3-ruby/test/test_statement.rb @@ -0,0 +1,207 @@ +require 'helper' + +module SQLite3 + class TestStatement < Test::Unit::TestCase + def setup + @db = SQLite3::Database.new(':memory:') + @stmt = SQLite3::Statement.new(@db, "select 'foo'") + end + + ### + # This method may not exist depending on how sqlite3 was compiled + def test_database_name + @db.execute('create table foo(text BLOB)') + @db.execute('insert into foo(text) values (?)',SQLite3::Blob.new('hello')) + stmt = @db.prepare('select text from foo') + if stmt.respond_to?(:database_name) + assert_equal 'main', stmt.database_name(0) + end + end + + def test_prepare_blob + @db.execute('create table foo(text BLOB)') + stmt = @db.prepare('insert into foo(text) values (?)') + stmt.bind_param(1, SQLite3::Blob.new('hello')) + stmt.step + stmt.close + end + + def test_select_blob + @db.execute('create table foo(text BLOB)') + @db.execute('insert into foo(text) values (?)',SQLite3::Blob.new('hello')) + assert_equal 'hello', @db.execute('select * from foo').first.first + end + + def test_new + assert @stmt + end + + def test_new_closed_handle + @db = SQLite3::Database.new(':memory:') + @db.close + assert_raises(ArgumentError) do + SQLite3::Statement.new(@db, 'select "foo"') + end + end + + def test_new_with_remainder + stmt = SQLite3::Statement.new(@db, "select 'foo';bar") + assert_equal 'bar', stmt.remainder + end + + def test_empty_remainder + assert_equal '', @stmt.remainder + end + + def test_close + @stmt.close + assert @stmt.closed? + end + + def test_double_close + @stmt.close + assert_raises(SQLite3::Exception) do + @stmt.close + end + end + + def test_bind_param_string + stmt = SQLite3::Statement.new(@db, "select ?") + stmt.bind_param(1, "hello") + result = nil + stmt.each { |x| result = x } + assert_equal ['hello'], result + end + + def test_bind_param_int + stmt = SQLite3::Statement.new(@db, "select ?") + stmt.bind_param(1, 10) + result = nil + stmt.each { |x| result = x } + assert_equal [10], result + end + + def test_bind_nil + stmt = SQLite3::Statement.new(@db, "select ?") + stmt.bind_param(1, nil) + result = nil + stmt.each { |x| result = x } + assert_equal [nil], result + end + + def test_bind_blobs + end + + def test_bind_64 + stmt = SQLite3::Statement.new(@db, "select ?") + stmt.bind_param(1, 2 ** 31) + result = nil + stmt.each { |x| result = x } + assert_equal [2 ** 31], result + end + + def test_bind_double + stmt = SQLite3::Statement.new(@db, "select ?") + stmt.bind_param(1, 2.2) + result = nil + stmt.each { |x| result = x } + assert_equal [2.2], result + end + + def test_named_bind + stmt = SQLite3::Statement.new(@db, "select :foo") + stmt.bind_param(':foo', 'hello') + result = nil + stmt.each { |x| result = x } + assert_equal ['hello'], result + end + + def test_named_bind_no_colon + stmt = SQLite3::Statement.new(@db, "select :foo") + stmt.bind_param('foo', 'hello') + result = nil + stmt.each { |x| result = x } + assert_equal ['hello'], result + end + + def test_named_bind_symbol + stmt = SQLite3::Statement.new(@db, "select :foo") + stmt.bind_param(:foo, 'hello') + result = nil + stmt.each { |x| result = x } + assert_equal ['hello'], result + end + + def test_named_bind_not_found + stmt = SQLite3::Statement.new(@db, "select :foo") + assert_raises(SQLite3::Exception) do + stmt.bind_param('bar', 'hello') + end + end + + def test_each + r = nil + @stmt.each do |row| + r = row + end + assert_equal(['foo'], r) + end + + def test_reset! + r = [] + @stmt.each { |row| r << row } + @stmt.reset! + @stmt.each { |row| r << row } + assert_equal [['foo'], ['foo']], r + end + + def test_step + r = @stmt.step + assert_equal ['foo'], r + end + + def test_tainted + r = @stmt.step + assert r.first.tainted? + end + + def test_step_twice + assert_not_nil @stmt.step + assert !@stmt.done? + assert_nil @stmt.step + assert @stmt.done? + + @stmt.reset! + assert !@stmt.done? + end + + def test_step_never_moves_past_done + 10.times { @stmt.step } + @stmt.done? + end + + def test_column_count + assert_equal 1, @stmt.column_count + end + + def test_column_name + assert_equal "'foo'", @stmt.column_name(0) + assert_equal nil, @stmt.column_name(10) + end + + def test_bind_parameter_count + stmt = SQLite3::Statement.new(@db, "select ?, ?, ?") + assert_equal 3, stmt.bind_parameter_count + end + + def test_execute_with_varargs + stmt = @db.prepare('select ?, ?') + assert_equal [[nil, nil]], stmt.execute(nil, nil).to_a + end + + def test_execute_with_hash + stmt = @db.prepare('select :n, :h') + assert_equal [[10, nil]], stmt.execute('n' => 10, 'h' => nil).to_a + end + end +end