summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2008-05-30 13:29:24 -0600
committerJamis Buck <jamis@37signals.com>2008-05-30 13:29:24 -0600
commit9be2cc70eb12164021c8239552f3a81fdb367da5 (patch)
tree58c6a8c3902f3b06ba7fd68aee0ddd4f6a09f445
parent2914f06f7eb8a24b6067bde3a2eec9d41f13e014 (diff)
downloadthird_party-sqlite3-ruby-9be2cc70eb12164021c8239552f3a81fdb367da5.tar.gz
third_party-sqlite3-ruby-9be2cc70eb12164021c8239552f3a81fdb367da5.tar.xz
third_party-sqlite3-ruby-9be2cc70eb12164021c8239552f3a81fdb367da5.zip
Update the sqlite3-api wrapper implementation.
This updates the swig-generated C file, so that people can build sqlite3-ruby without needing swig around. Also, the makefile is built on-demand by extconf.rb so we don't need it in the repo.
-rw-r--r--ext/sqlite3_api/.gitignore5
-rw-r--r--ext/sqlite3_api/Makefile146
-rw-r--r--ext/sqlite3_api/sqlite3_api_wrap.c230
3 files changed, 120 insertions, 261 deletions
diff --git a/ext/sqlite3_api/.gitignore b/ext/sqlite3_api/.gitignore
new file mode 100644
index 0000000..8dfacf6
--- /dev/null
+++ b/ext/sqlite3_api/.gitignore
@@ -0,0 +1,5 @@
+mkmf.log
+*.o
+*.bundle
+*.so
+Makefile
diff --git a/ext/sqlite3_api/Makefile b/ext/sqlite3_api/Makefile
deleted file mode 100644
index 13a7167..0000000
--- a/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-darwin8.10.1
-hdrdir = $(topdir)
-VPATH = $(srcdir):$(topdir):$(hdrdir)
-prefix = $(DESTDIR)/opt/local
-exec_prefix = $(DESTDIR)/opt/local
-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 = $(DESTDIR)/opt/local/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-darwin8.10.1 -I.
-CPPFLAGS = -DHAVE_SQLITE3_H -I/usr/local/include -I/opt/local/include
-CXXFLAGS = $(CFLAGS)
-DLDFLAGS = -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-darwin8.10.1
-sitearch = i686-darwin8.10.1
-vendorarch = i686-darwin8.10.1
-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"$(libdir)" -L"/usr/local/lib"
-DEFFILE =
-
-CLEANFILES =
-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) $(DLDFLAGS) $(LIBPATH) -o $@ $(OBJS) $(LOCAL_LIBS) $(LIBS)
-
-
-
-$(OBJS): ruby.h defines.h
diff --git a/ext/sqlite3_api/sqlite3_api_wrap.c b/ext/sqlite3_api/sqlite3_api_wrap.c
index ae78b77..039ef05 100644
--- a/ext/sqlite3_api/sqlite3_api_wrap.c
+++ b/ext/sqlite3_api/sqlite3_api_wrap.c
@@ -617,121 +617,121 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
}
#endif
-/***********************************************************************
- * 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.
- ************************************************************************/
-
-/* Global Ruby hash table to store Trackings from C/C++
- structs to Ruby Objects. */
-static VALUE swig_ruby_trackings;
-
-/* Setup a Ruby hash table to store Trackings */
-static void SWIG_RubyInitializeTrackings() {
- /* Create a ruby hash table to store Trackings from C++
- objects to Ruby objects. Also make sure to tell
- the garabage collector about the hash table. */
- swig_ruby_trackings = rb_hash_new();
- rb_gc_register_address(&swig_ruby_trackings);
-}
-
-/* Get a Ruby number to reference a pointer */
-static 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 */
- unsigned long value = (unsigned long) ptr;
- return LONG2NUM(value);
-}
-
-/* Get a Ruby number to reference an object */
-static 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 */
- unsigned long value = (unsigned long) object;
- return LONG2NUM(value);
-}
-
-/* Get a Ruby object from a previously stored reference */
-static VALUE SWIG_RubyReferenceToObject(VALUE reference) {
- /* The provided Ruby number object is a reference
- to the Ruby object we want.*/
-
- /* First convert the Ruby number to a C number */
- unsigned long value = NUM2LONG(reference);
- return (VALUE) value;
-}
-
-/* Add a Tracking from a C/C++ struct to a Ruby object */
-static 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 */
-static 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 */
-static void SWIG_RubyRemoveTracking(void* ptr) {
- /* Get a reference to the pointer as a Ruby number */
- VALUE key = SWIG_RubyPtrToReference(ptr);
+/***********************************************************************
+ * 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.
+ ************************************************************************/
+
+/* Global Ruby hash table to store Trackings from C/C++
+ structs to Ruby Objects. */
+static VALUE swig_ruby_trackings;
+
+/* Setup a Ruby hash table to store Trackings */
+static void SWIG_RubyInitializeTrackings() {
+ /* Create a ruby hash table to store Trackings from C++
+ objects to Ruby objects. Also make sure to tell
+ the garabage collector about the hash table. */
+ swig_ruby_trackings = rb_hash_new();
+ rb_gc_register_address(&swig_ruby_trackings);
+}
+
+/* Get a Ruby number to reference a pointer */
+static 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 */
+ unsigned long value = (unsigned long) ptr;
+ return LONG2NUM(value);
+}
+
+/* Get a Ruby number to reference an object */
+static 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 */
+ unsigned long value = (unsigned long) object;
+ return LONG2NUM(value);
+}
+
+/* Get a Ruby object from a previously stored reference */
+static VALUE SWIG_RubyReferenceToObject(VALUE reference) {
+ /* The provided Ruby number object is a reference
+ to the Ruby object we want.*/
+
+ /* First convert the Ruby number to a C number */
+ unsigned long value = NUM2LONG(reference);
+ return (VALUE) value;
+}
+
+/* Add a Tracking from a C/C++ struct to a Ruby object */
+static 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 */
+static 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 */
+static void SWIG_RubyRemoveTracking(void* ptr) {
+ /* Get a reference to the pointer as a Ruby number */
+ VALUE key = SWIG_RubyPtrToReference(ptr);
/* Define delete method - in C++ this could be marked as
static but unfortunately not in C. */
- VALUE delete_function = rb_intern("delete");
+ VALUE delete_function = rb_intern("delete");
/* 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, delete_function, 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 */
-static void SWIG_RubyUnlinkObjects(void* ptr) {
- VALUE object = SWIG_RubyInstanceFor(ptr);
-
- if (object != Qnil) {
- DATA_PTR(object) = 0;
- }
-}
+}
+
+/* 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 */
+static void SWIG_RubyUnlinkObjects(void* ptr) {
+ VALUE object = SWIG_RubyInstanceFor(ptr);
+
+ if (object != Qnil) {
+ DATA_PTR(object) = 0;
+ }
+}
/* Common SWIG API */
#define SWIG_ConvertPtr(obj, pp, type, flags) \
@@ -1073,8 +1073,8 @@ struct CallbackData {
};
typedef struct CallbackData CallbackData;
-typedef void BLOB;
-typedef void VALBLOB;
+typedef void RUBY_BLOB;
+typedef void RUBY_VALBLOB;
int Sqlite3_ruby_busy_handler(void* data,int value) {
VALUE result;
@@ -2035,14 +2035,14 @@ static VALUE
_wrap_sqlite3_column_blob(int argc, VALUE *argv, VALUE self) {
sqlite3_stmt *arg1 = (sqlite3_stmt *) 0 ;
int arg2 ;
- BLOB *result;
+ RUBY_BLOB *result;
VALUE vresult = Qnil;
if ((argc < 2) || (argc > 2))
rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc);
SWIG_ConvertPtr(argv[0], (void **) &arg1, SWIGTYPE_p_sqlite3_stmt, 0);
arg2 = NUM2INT(argv[1]);
- result = (BLOB *)sqlite3_column_blob(arg1,arg2);
+ result = (RUBY_BLOB *)sqlite3_column_blob(arg1,arg2);
{
vresult = result ?
@@ -2319,13 +2319,13 @@ _wrap_sqlite3_aggregate_count(int argc, VALUE *argv, VALUE self) {
static VALUE
_wrap_sqlite3_value_blob(int argc, VALUE *argv, VALUE self) {
sqlite3_value *arg1 = (sqlite3_value *) 0 ;
- VALBLOB *result;
+ RUBY_VALBLOB *result;
VALUE vresult = Qnil;
if ((argc < 1) || (argc > 1))
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc);
SWIG_ConvertPtr(argv[0], (void **) &arg1, SWIGTYPE_p_sqlite3_value, 0);
- result = (VALBLOB *)sqlite3_value_blob(arg1);
+ result = (RUBY_VALBLOB *)sqlite3_value_blob(arg1);
{
vresult = result ? rb_str_new( (char*)result, sqlite3_value_bytes( arg1 ) ) : Qnil;
@@ -2763,7 +2763,7 @@ static swig_type_info _swigt__p_sqlite3_stmt = {"_p_sqlite3_stmt", "sqlite3_stmt
static swig_type_info _swigt__p_sqlite3_value = {"_p_sqlite3_value", "sqlite3_value *", 0, 0, 0};
static swig_type_info _swigt__p_sqlite_int64 = {"_p_sqlite_int64", "sqlite_int64 *", 0, 0, 0};
static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "unsigned long *|VALUE *", 0, 0, 0};
-static swig_type_info _swigt__p_void = {"_p_void", "void *|VALBLOB *", 0, 0, 0};
+static swig_type_info _swigt__p_void = {"_p_void", "void *|RUBY_VALBLOB *", 0, 0, 0};
static swig_type_info *swig_type_initial[] = {
&_swigt__p_CallbackData,