Permalink
Browse files

Moved reflect.* stuff into classic.go where it belongs.

Small documentation improvements.
  • Loading branch information...
1 parent 86da961 commit b7647455f6e8e18b82a2991846a51e53f7a3da64 @phf committed Dec 13, 2009
Showing with 24 additions and 24 deletions.
  1. +24 −3 classic.go
  2. +0 −21 connection.go
View
@@ -4,18 +4,39 @@
package sqlite3
+// We use the "classic" stuff without channels to implement
+// the nicer, more Go-like channel-based stuff. Officially
+// the "classic" API is optional, but we really need it. :-D
+
import (
"db";
"os";
"reflect";
)
+// stolen from fmt package, special-cases interface values
+func getField(v *reflect.StructValue, i int) reflect.Value {
+ val := v.Field(i);
+ if i, ok := val.(*reflect.InterfaceValue); ok {
+ if inter := i.Interface(); inter != nil {
+ return reflect.NewValue(inter)
+ }
+ }
+ return val;
+}
+
+func struct2array(s *reflect.StructValue) (r []interface{}) {
+ l := s.NumField();
+ r = make([]interface{}, l);
+ for i := 0; i < l; i++ {
+ r[i] = getField(s, i)
+ }
+ return;
+}
+
// Execute precompiled statement with given parameters
// (if any). The statement stays valid even if we fail
// to execute with given parameters.
-//
-// TODO: Figure out parameter stuff, right now all are
-// TEXT parameters. :-/
func (self *Connection) ExecuteClassic(statement db.Statement, parameters ...) (rset db.ClassicResultSet, error os.Error) {
s, ok := statement.(*Statement);
if !ok {
View
@@ -7,7 +7,6 @@ package sqlite3
import (
"db";
"os";
- "reflect";
)
// SQLite connections
@@ -54,26 +53,6 @@ func (self *Connection) Prepare(query string) (statement db.Statement, error os.
return;
}
-// stolen from fmt package, special-cases interface values
-func getField(v *reflect.StructValue, i int) reflect.Value {
- val := v.Field(i);
- if i, ok := val.(*reflect.InterfaceValue); ok {
- if inter := i.Interface(); inter != nil {
- return reflect.NewValue(inter)
- }
- }
- return val;
-}
-
-func struct2array(s *reflect.StructValue) (r []interface{}) {
- l := s.NumField();
- r = make([]interface{}, l);
- for i := 0; i < l; i++ {
- r[i] = getField(s, i)
- }
- return;
-}
-
func (self *Connection) Execute(statement db.Statement, parameters ...) (rs db.ResultSet, error os.Error) {

0 comments on commit b764745

Please sign in to comment.