This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with macro that expands to define-simple-class


I've run into a problem with a syntax-rules macro that expands to a
DEFINE-SIMPLE-CLASS statement:

(define-syntax define-simple-database-helper 
  (syntax-rules ()
    ((_ name log-name version (table-name create-statement) ...)
     (define-simple-class name
  (<android.database.sqlite.SQLiteOpenHelper>)
       ((*init* (context :: <Context>))
       (invoke-special <android.database.sqlite.SQLiteOpenHelper> (this) '*init* context log-name #!null version))
       ((onCreate (db :: <android.database.sqlite.SQLiteDatabase>)) ::
  void
  (for-each (lambda (sql)
                (db:execSQL sql))
                              (list create-statement ...)))
       ((onUpgrade (db :: <android.database.sqlite.SQLiteDatabase>) (old-version :: int) (new-version :: int))
  (for-each (lambda (name)
                (db:execSQL (format "drop table if exists ~a" name)))
                              (list table-name ...))
                              (onCreate db))))))

Usage would be like this:

(define-simple-database-helper "games" "database" 1
  ("categories" "create table categories (_id text primary key, name text not null);")
  ("games" "create table games (_id text primary key, name text not null);"))

But loading the definition into svn kawa as of right now and using
(require 'syntax-utils) and EXPAND shows:

(let ((games #!undefined))
 (set games (lambda (*init* onCreate onUpgrade) #!null)))

Is there a way to write this macro (using syntax-rules)?

Thanks for any help!

Peter


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]