swift-db-sqlite3 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.1.2 (2012-07-28)
2
+
3
+ * Fixed compiler warnings on i386.
4
+ * gc guard bind parameters during execute.
5
+ * Fixed segfault due to marking tuples as globals.
6
+
1
7
  == 0.1.1 (2012-07-26)
2
8
 
3
9
  * Type parsing should be case insensitive.
@@ -4,7 +4,31 @@ require 'mkmf'
4
4
 
5
5
  $CFLAGS = '-std=c99 -Os'
6
6
 
7
- find_library('sqlite3', 'main', '/usr/lib /usr/local/lib /opt/lib /opt/local/lib')
8
- find_library('uuid', 'main', '/usr/lib /usr/local/lib /opt/lib /opt/local/lib')
9
- create_makefile('swift_db_sqlite3_ext')
7
+ inc_paths = %w(
8
+ /usr/include
9
+ /usr/local/include
10
+ /opt/local/include
11
+ /sw/include
12
+ )
13
+
14
+ lib_paths = %w(
15
+ /usr/lib
16
+ /usr/local/lib
17
+ /opt/local/lib
18
+ /sw/lib
19
+ )
20
+
21
+ def ensure_library name, lib_paths, hint = nil
22
+ unless find_library(name, 'main', *lib_paths)
23
+ puts $/, '#' * 80, hint, '#' * 80, $/ if hint
24
+ raise "unable to find #{name}"
25
+ end
26
+ end
10
27
 
28
+ find_header('sqlite3.h', *inc_paths) or raise 'unable to locate sqlite3 headers'
29
+ find_header('uuid/uuid.h', *inc_paths) or raise 'unable to locate uuid headers'
30
+
31
+ ensure_library 'sqlite3', lib_paths, 'please install sqlite3 development libraries'
32
+ ensure_library 'uuid', lib_paths, 'please install uuid development libraries'
33
+
34
+ create_makefile('swift_db_sqlite3_ext')
@@ -38,14 +38,14 @@ Result* db_sqlite3_result_handle(VALUE self) {
38
38
 
39
39
  void db_sqlite3_result_mark(Result *r) {
40
40
  if (r) {
41
- if (!NIL_P(r->statement))
42
- rb_gc_mark_maybe(r->statement);
43
- if (!NIL_P(r->fields))
44
- rb_gc_mark_maybe(r->fields);
45
- if (!NIL_P(r->types))
46
- rb_gc_mark_maybe(r->types);
47
- if (!NIL_P(r->rows))
48
- rb_gc_mark_maybe(r->rows);
41
+ if (r->rows)
42
+ rb_gc_mark(r->rows);
43
+ if (r->statement)
44
+ rb_gc_mark(r->statement);
45
+ if (r->fields)
46
+ rb_gc_mark(r->fields);
47
+ if (r->types)
48
+ rb_gc_mark(r->types);
49
49
  }
50
50
  }
51
51
 
@@ -101,7 +101,7 @@ VALUE db_sqlite3_result_consume(VALUE self) {
101
101
  };
102
102
 
103
103
  int lazy_types = 0;
104
- size_t ntypes = sizeof(types) / sizeof(Type);
104
+ size_t ntypes = sizeof(types) / sizeof(Type);
105
105
 
106
106
  rb_ary_clear(r->fields);
107
107
  rb_ary_clear(r->types);
@@ -181,9 +181,9 @@ VALUE db_sqlite3_result_each(VALUE self) {
181
181
  int n, f;
182
182
  Result *r = db_sqlite3_result_handle(self);
183
183
 
184
- if (!r->rows) return Qnil;
184
+ if (!r->rows)
185
+ return Qnil;
185
186
 
186
- rb_gc_register_address(&r->rows);
187
187
  for (n = 0; n < RARRAY_LEN(r->rows); n++) {
188
188
  VALUE tuple = rb_hash_new();
189
189
  VALUE row = rb_ary_entry(r->rows, n);
@@ -191,7 +191,8 @@ VALUE db_sqlite3_result_each(VALUE self) {
191
191
  rb_hash_aset(tuple, rb_ary_entry(r->fields, f), rb_ary_entry(row, f));
192
192
  rb_yield(tuple);
193
193
  }
194
- rb_gc_unregister_address(&r->rows);
194
+
195
+ return Qtrue;
195
196
  }
196
197
 
197
198
  VALUE db_sqlite3_result_selected_rows(VALUE self) {
@@ -33,8 +33,8 @@ Statement* db_sqlite3_statement_handle_safe(VALUE self) {
33
33
  }
34
34
 
35
35
  void db_sqlite3_statement_mark(Statement *s) {
36
- if (s && !NIL_P(s->adapter))
37
- rb_gc_mark_maybe(s->adapter);
36
+ if (s && s->adapter)
37
+ rb_gc_mark(s->adapter);
38
38
  }
39
39
 
40
40
  VALUE db_sqlite3_statement_deallocate(Statement *s) {
@@ -80,8 +80,9 @@ VALUE db_sqlite3_statement_execute(int argc, VALUE *argv, VALUE self) {
80
80
  rb_scan_args(argc, argv, "00*", &bind);
81
81
  expect = sqlite3_bind_parameter_count(s->s);
82
82
  if (expect != RARRAY_LEN(bind))
83
- rb_raise(eSwiftArgumentError, "expected %d bind values got %d", expect, RARRAY_LEN(bind));
83
+ rb_raise(eSwiftArgumentError, "expected %d bind values got %d", expect, (int)RARRAY_LEN(bind));
84
84
 
85
+ rb_gc_register_address(&bind);
85
86
  for (n = 0; n < expect; n++) {
86
87
  VALUE value = rb_ary_entry(bind, n);
87
88
  if (NIL_P(value))
@@ -95,6 +96,7 @@ VALUE db_sqlite3_statement_execute(int argc, VALUE *argv, VALUE self) {
95
96
  result = db_sqlite3_result_allocate(cDSR);
96
97
  db_sqlite3_result_initialize(result, self);
97
98
  db_sqlite3_result_consume(result);
99
+ rb_gc_unregister_address(&bind);
98
100
  return result;
99
101
  }
100
102
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swift-db-sqlite3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-26 00:00:00.000000000 Z
12
+ date: 2012-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -35,25 +35,25 @@ extensions:
35
35
  - ext/swift/db/sqlite3/extconf.rb
36
36
  extra_rdoc_files: []
37
37
  files:
38
- - ext/swift/db/sqlite3/statement.c
39
- - ext/swift/db/sqlite3/result.c
40
- - ext/swift/db/sqlite3/datetime.c
41
- - ext/swift/db/sqlite3/typecast.c
38
+ - ext/swift/db/sqlite3/adapter.c
42
39
  - ext/swift/db/sqlite3/common.c
40
+ - ext/swift/db/sqlite3/datetime.c
43
41
  - ext/swift/db/sqlite3/main.c
44
- - ext/swift/db/sqlite3/adapter.c
42
+ - ext/swift/db/sqlite3/result.c
43
+ - ext/swift/db/sqlite3/statement.c
44
+ - ext/swift/db/sqlite3/typecast.c
45
45
  - ext/swift/db/sqlite3/adapter.h
46
- - ext/swift/db/sqlite3/statement.h
47
- - ext/swift/db/sqlite3/typecast.h
48
46
  - ext/swift/db/sqlite3/common.h
49
- - ext/swift/db/sqlite3/result.h
50
47
  - ext/swift/db/sqlite3/datetime.h
48
+ - ext/swift/db/sqlite3/result.h
49
+ - ext/swift/db/sqlite3/statement.h
50
+ - ext/swift/db/sqlite3/typecast.h
51
51
  - ext/swift/db/sqlite3/extconf.rb
52
- - test/test_encoding.rb
53
52
  - test/helper.rb
54
53
  - test/test_adapter.rb
55
- - lib/swift/db/sqlite3.rb
54
+ - test/test_encoding.rb
56
55
  - lib/swift-db-sqlite3.rb
56
+ - lib/swift/db/sqlite3.rb
57
57
  - README.md
58
58
  - CHANGELOG
59
59
  homepage: http://github.com/deepfryed/swift-db-sqlite3
@@ -82,4 +82,3 @@ signing_key:
82
82
  specification_version: 3
83
83
  summary: Swift sqlite3 adapter
84
84
  test_files: []
85
- has_rdoc: