This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Problem with macro that expands to define-simple-class
- From: <craven at gmx dot net>
- To: kawa mailing list <kawa at sourceware dot org>
- Date: Wed, 05 Sep 2012 10:40:21 +0200
- Subject: 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