Permalink
Browse files

Move extension into its language sub dir and s/amalgalite3/amalgalite/gc

  • Loading branch information...
1 parent af263f5 commit 10d789c6eba91222c46e2fd7d59471a2a6f8ad2c @copiousfreetime committed Mar 13, 2013
View
@@ -12,9 +12,12 @@ This.ruby_gemspec do |spec|
spec.add_development_dependency( 'rspec' , '~> 2.13.0')
spec.add_development_dependency( 'rake' , '~> 10.0.3')
- spec.add_development_dependency( 'rake-compiler', '~> 0.8.1' )
+ spec.add_development_dependency( 'rake-compiler', '~> 0.8.1' )
spec.add_development_dependency( 'rdoc' , '~> 4.0' )
- spec.add_development_dependency( 'zip' , "~> 2.0.2" )
+ spec.add_development_dependency( 'zip' , '~> 2.0.2' )
+
+ spec.extensions.concat This.extension_conf_files
end
load 'tasks/default.rake'
+load 'tasks/extension.rake'
@@ -5,7 +5,7 @@
* vim: shiftwidth=4
:*/
-#include "amalgalite3.h"
+#include "amalgalite.h"
/* Module and Classes */
VALUE mA; /* module Amalgalite */
@@ -266,7 +266,7 @@ VALUE am_sqlite3_compiled_version_number( VALUE self )
*
*/
-void Init_amalgalite3()
+void Init_amalgalite()
{
int rc = 0;
@@ -300,21 +300,21 @@ void Init_amalgalite3()
* Encapsulation of the SQLite C library version
*/
mASV = rb_define_module_under(mAS, "Version");
- rb_define_module_function(mASV, "to_s", am_sqlite3_runtime_version, 0); /* in amalgalite3.c */
+ rb_define_module_function(mASV, "to_s", am_sqlite3_runtime_version, 0); /* in amalgalite.c */
rb_define_module_function(mASV, "runtime_version", am_sqlite3_runtime_version, 0); /* in amalgalite.c */
- rb_define_module_function(mASV, "to_i", am_sqlite3_runtime_version_number, 0); /* in amalgalite3.c */
- rb_define_module_function(mASV, "runtime_version_number", am_sqlite3_runtime_version_number, 0); /* in amalgalite3.c */
- rb_define_module_function(mASV, "compiled_version", am_sqlite3_compiled_version, 0 ); /* in amalgalite3.c */
- rb_define_module_function(mASV, "compiled_version_number", am_sqlite3_compiled_version_number, 0 ); /* in amalgalite3.c */
+ rb_define_module_function(mASV, "to_i", am_sqlite3_runtime_version_number, 0); /* in amalgalite.c */
+ rb_define_module_function(mASV, "runtime_version_number", am_sqlite3_runtime_version_number, 0); /* in amalgalite.c */
+ rb_define_module_function(mASV, "compiled_version", am_sqlite3_compiled_version, 0 ); /* in amalgalite.c */
+ rb_define_module_function(mASV, "compiled_version_number", am_sqlite3_compiled_version_number, 0 ); /* in amalgalite.c */
/*
* Initialize the rest of the module
*/
- Init_amalgalite3_constants( );
- Init_amalgalite3_database( );
- Init_amalgalite3_statement( );
- Init_amalgalite3_blob( );
- Init_amalgalite3_requires_bootstrap( );
+ Init_amalgalite_constants( );
+ Init_amalgalite_database( );
+ Init_amalgalite_statement( );
+ Init_amalgalite_blob( );
+ Init_amalgalite_requires_bootstrap( );
/*
* initialize sqlite itself
@@ -128,11 +128,11 @@ extern VALUE am_sqlite3_blob_length(VALUE self);
/*----------------------------------------------------------------------
* more initialization methods
*----------------------------------------------------------------------*/
-extern void Init_amalgalite3_constants( );
-extern void Init_amalgalite3_database( );
-extern void Init_amalgalite3_statement( );
-extern void Init_amalgalite3_blob( );
-extern void Init_amalgalite3_requires_bootstrap( );
+extern void Init_amalgalite_constants( );
+extern void Init_amalgalite_database( );
+extern void Init_amalgalite_statement( );
+extern void Init_amalgalite_blob( );
+extern void Init_amalgalite_requires_bootstrap( );
/***********************************************************************
@@ -1,4 +1,4 @@
-#include "amalgalite3.h"
+#include "amalgalite.h"
/**
* Copyright (c) 2008 Jeremy Hinegardner
* All rights reserved. See LICENSE and/or COPYING for details.
@@ -219,7 +219,7 @@ VALUE am_sqlite3_blob_alloc(VALUE klass)
* incremental IO on a binary object, then you do not need to use Blob.
*/
-void Init_amalgalite3_blob( )
+void Init_amalgalite_blob( )
{
VALUE ma = rb_define_module("Amalgalite");
@@ -1,12 +1,12 @@
/* Generated by gen_constants.rb -- do not edit */
-#include "amalgalite3.h"
+#include "amalgalite.h"
/**
* Document-class: Amalgalite::SQLite3::Constants
*
* class holding constants in the sqlite extension
*/
-void Init_amalgalite3_constants( )
+void Init_amalgalite_constants( )
{
VALUE ma = rb_define_module("Amalgalite");
@@ -1,4 +1,4 @@
-#include "amalgalite3.h"
+#include "amalgalite.h"
/**
* Copyright (c) 2008 Jeremy Hinegardner
* All rights reserved. See LICENSE and/or COPYING for details.
@@ -1131,7 +1131,7 @@ VALUE am_sqlite3_database_alloc(VALUE klass)
* The ruby extension wrapper around the core sqlite3 database object.
*
*/
-void Init_amalgalite3_database( )
+void Init_amalgalite_database( )
{
VALUE ma = rb_define_module("Amalgalite");
@@ -1146,32 +1146,32 @@ void Init_amalgalite3_database( )
rb_define_singleton_method(cAS_Database, "open", am_sqlite3_database_open, -1);
rb_define_singleton_method(cAS_Database, "open16", am_sqlite3_database_open16, 1);
rb_define_method(cAS_Database, "prepare", am_sqlite3_database_prepare, 1);
- rb_define_method(cAS_Database, "close", am_sqlite3_database_close, 0); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "last_insert_rowid", am_sqlite3_database_last_insert_rowid, 0); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "autocommit?", am_sqlite3_database_is_autocommit, 0); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "register_trace_tap", am_sqlite3_database_register_trace_tap, 1); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "register_profile_tap", am_sqlite3_database_register_profile_tap, 1); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "table_column_metadata", am_sqlite3_database_table_column_metadata, 3); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "row_changes", am_sqlite3_database_row_changes, 0); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "total_changes", am_sqlite3_database_total_changes, 0); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "last_error_code", am_sqlite3_database_last_error_code, 0); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "last_error_message", am_sqlite3_database_last_error_message, 0); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "define_function", am_sqlite3_database_define_function, 2); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "remove_function", am_sqlite3_database_remove_function, 2); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "define_aggregate", am_sqlite3_database_define_aggregate, 3); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "remove_aggregate", am_sqlite3_database_remove_aggregate, 3); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "busy_handler", am_sqlite3_database_busy_handler, 1); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "progress_handler", am_sqlite3_database_progress_handler, 2); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "interrupt!", am_sqlite3_database_interrupt_bang, 0); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "replicate_to", am_sqlite3_database_replicate_to, 1); /* in amalgalite3_database.c */
- rb_define_method(cAS_Database, "execute_batch", am_sqlite3_database_exec, 1); /* in amalgalite3_database.c */
+ rb_define_method(cAS_Database, "close", am_sqlite3_database_close, 0); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "last_insert_rowid", am_sqlite3_database_last_insert_rowid, 0); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "autocommit?", am_sqlite3_database_is_autocommit, 0); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "register_trace_tap", am_sqlite3_database_register_trace_tap, 1); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "register_profile_tap", am_sqlite3_database_register_profile_tap, 1); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "table_column_metadata", am_sqlite3_database_table_column_metadata, 3); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "row_changes", am_sqlite3_database_row_changes, 0); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "total_changes", am_sqlite3_database_total_changes, 0); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "last_error_code", am_sqlite3_database_last_error_code, 0); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "last_error_message", am_sqlite3_database_last_error_message, 0); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "define_function", am_sqlite3_database_define_function, 2); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "remove_function", am_sqlite3_database_remove_function, 2); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "define_aggregate", am_sqlite3_database_define_aggregate, 3); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "remove_aggregate", am_sqlite3_database_remove_aggregate, 3); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "busy_handler", am_sqlite3_database_busy_handler, 1); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "progress_handler", am_sqlite3_database_progress_handler, 2); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "interrupt!", am_sqlite3_database_interrupt_bang, 0); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "replicate_to", am_sqlite3_database_replicate_to, 1); /* in amalgalite_database.c */
+ rb_define_method(cAS_Database, "execute_batch", am_sqlite3_database_exec, 1); /* in amalgalite_database.c */
/*
* Ecapuslate a SQLite3 Database stat
*/
cAS_Database_Stat = rb_define_class_under( cAS_Database, "Stat", rb_cObject );
- rb_define_method(cAS_Database_Stat, "update!", am_sqlite3_database_stat_update_bang, -1); /* in amalgalite3_database.c */
+ rb_define_method(cAS_Database_Stat, "update!", am_sqlite3_database_stat_update_bang, -1); /* in amalgalite_database.c */
}
@@ -5,7 +5,7 @@
* vim: shiftwidth=4
*/
-#include "amalgalite3.h"
+#include "amalgalite.h"
#include <stdio.h>
extern VALUE mA;
VALUE cAR;
@@ -256,7 +256,7 @@ VALUE am_bootstrap_lift_str( VALUE self, VALUE args )
* Bootstrapping module to help _require_ when Amalgalite::Requires is not
* availble in files.
*/
-void Init_amalgalite3_requires_bootstrap()
+void Init_amalgalite_requires_bootstrap()
{
mA = rb_define_module("Amalgalite");
@@ -1,4 +1,4 @@
-#include "amalgalite3.h"
+#include "amalgalite.h"
/**
* Copyright (c) 2008 Jeremy Hinegardner
* All rights reserved. See LICENSE and/or COPYING for details.
@@ -604,7 +604,7 @@ VALUE am_sqlite3_statement_alloc(VALUE klass)
* Amagalite Database extension
*/
-void Init_amalgalite3_statement( )
+void Init_amalgalite_statement( )
{
VALUE ma = rb_define_module("Amalgalite");
@@ -33,4 +33,4 @@
subdir = RUBY_VERSION.sub(/\.\d$/,'')
-create_makefile("amalgalite/#{subdir}/amalgalite3")
+create_makefile("amalgalite/#{subdir}/amalgalite")
@@ -135,17 +135,17 @@
}
-fname = File.expand_path(File.join(File.dirname(__FILE__), "amalgalite3_constants.c"))
+fname = File.expand_path(File.join(File.dirname(__FILE__), "amalgalite_constants.c"))
File.open(fname, "w+") do |f|
f.puts "/* Generated by gen_constants.rb -- do not edit */"
f.puts
- f.puts '#include "amalgalite3.h"'
+ f.puts '#include "amalgalite.h"'
f.puts '/**'
f.puts ' * Document-class: Amalgalite::SQLite3::Constants'
f.puts ' *'
f.puts ' * class holding constants in the sqlite extension'
f.puts ' */'
- f.puts "void Init_amalgalite3_constants( )"
+ f.puts "void Init_amalgalite_constants( )"
f.puts "{"
f.puts
f.puts ' VALUE ma = rb_define_module("Amalgalite");'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -16,10 +16,17 @@ module Amalgalite
class Error < ::StandardError; end
end
-# use a version subdirectory for extensions, initially to support windows, but
-# why make a special case, it doesn't hurt anyone to have an extra subdir
-# someplace
-require "amalgalite/#{RUBY_VERSION.sub(/\.\d$/,'')}/amalgalite3"
+# Load the binary extension, try loading one for the specific version of ruby
+# and if that fails, then fall back to one in the top of the library.
+# this is the method recommended by rake-compiler
+begin
+ # this will be for windows
+ require "amalgalite/#{RUBY_VERSION.sub(/\.\d$/,'')}/amalgalite"
+rescue LoadError
+ # everyone else.
+ require 'amalgalite/amalgalite'
+end
+
require 'amalgalite/aggregate'
require 'amalgalite/blob'

0 comments on commit 10d789c

Please sign in to comment.