Changeset 8194 in project


Ignore:
Timestamp:
02/06/08 08:17:41 (12 years ago)
Author:
Kon Lovett
Message:

Save.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/mysql/trunk/mysql.scm

    r8193 r8194  
    8080
    8181(require-for-syntax 'srfi-13)
    82 
    83 (define-for-syntax (c-name->scheme-name str)
    84         (string-downcase (string-translate str "_" "-")) )
    8582
    8683(declare
     
    444441                mysql-field-flags-symbol ) )
    445442
     443;;;
     444
     445(define-for-syntax (c-name->scheme-name str)
     446        (string-downcase (string-translate str "_" "-")) )
     447
     448;;;
     449
    446450;=======================================================================
    447451; Interface to C API
     
    490494      (,(string->symbol (string-append "number->" (symbol->string ?typ))) val))) )
    491495
    492 (define-macro (*define-foreign-enum ?tspec . ?rest)
     496(define-macro ($define-foreign-enum ?tspec . ?rest)
    493497  (let ([1st-item (lambda (x) (if (pair? x) (car x) x))])
    494498    (let-values ([(?flags ?especs)
    495499                  (if (null? ?rest)
    496                       (syntax-error '*define-foreign-enum "missing enumeration specification")
     500                      (syntax-error '$define-foreign-enum "missing enumeration specification")
    497501                      (if (boolean? (car ?rest))
    498502                          (values (list (car ?rest)) (cdr ?rest))
     
    507511;;
    508512
    509 (*define-foreign-enum (mysql-server-option (enum "enum_mysql_set_option"))
     513($define-foreign-enum (mysql-server-option (enum "enum_mysql_set_option"))
    510514        #f      ; No aliases!
    511515        MYSQL_OPTION_MULTI_STATEMENTS_ON
    512516        MYSQL_OPTION_MULTI_STATEMENTS_OFF )
    513517
    514 (*define-foreign-enum (mysql-option (enum "mysql_option"))
     518($define-foreign-enum (mysql-option (enum "mysql_option"))
    515519        #f      ; No aliases!
    516520        MYSQL_OPT_CONNECT_TIMEOUT
     
    535539        MYSQL_REPORT_DATA_TRUNCATION )
    536540
    537 (*define-foreign-enum (mysql-type (enum "enum_field_types"))
     541($define-foreign-enum (mysql-type (enum "enum_field_types"))
    538542        #f      ; No aliases!
    539543        MYSQL_TYPE_DECIMAL
     
    565569        MYSQL_TYPE_GEOMETRY )
    566570
    567 (*define-foreign-enum (mysql-field-flags unsigned-int)
     571($define-foreign-enum (mysql-field-flags unsigned-int)
    568572        #f      ; No aliases!
    569573        NOT_NULL_FLAG                                                                   ; field can't be NULL
     
    583587        TIMESTAMP_FLAG  )                                                       ; field is a timestamp
    584588
    585 (*define-foreign-enum (mysql-client-flags unsigned-int)
     589($define-foreign-enum (mysql-client-flags unsigned-int)
    586590        #f      ; No aliases!
    587591        CLIENT_LONG_PASSWORD                                    ; new more secure passwords
     
    678682; MySQL "my_ulonglong" type.
    679683;
    680 ; We treat "my_ulonglong" in Scheme as the "number" type & as a
    681 ; "double" in the C interface, converting to "my_ulonglong"
    682 ; to/from the MySQL API.
    683 ;
    684 
    685 #>
    686 static double
    687 mysqlaux_mysql_affected_rows (MYSQL *mysql)
    688 {
    689         return ((double) mysql_affected_rows (mysql));
    690 }
    691 
    692 static double
    693 mysqlaux_mysql_insert_id (MYSQL *mysql)
    694 {
    695         return ((double) mysql_insert_id (mysql));
    696 }
    697 
    698 static double
    699 mysqlaux_mysql_num_rows (MYSQL_RES *result)
    700 {
    701         return ((double) mysql_num_rows (result));
    702 }
    703 
    704 static void
    705 mysqlaux_mysql_data_seek (MYSQL_RES *result, double offset)
    706 {
    707         mysql_data_seek (result, (my_ulonglong) offset);
    708 }
    709 <#
    710684
    711685; 24.2.3.1. mysql_affected_rows()
    712686; my_ulonglong mysql_affected_rows(MYSQL *mysql)
    713687(define foreign-mysql-affected-rows
    714         (foreign-lambda my-ulonglong "mysqlaux_mysql_affected_rows" mysql-ptr))
     688        (foreign-lambda* my-ulonglong ((mysql-ptr mysql))
     689         "return (mysql_affected_rows (mysql));"))
    715690
    716691; 24.2.3.34. mysql_insert_id()
    717692; my_ulonglong mysql_insert_id(MYSQL *mysql)
    718693(define foreign-mysql-insert-id
    719         (foreign-lambda my-ulonglong "mysqlaux_mysql_insert_id" mysql-ptr))
     694        (foreign-lambda* my-ulonglong ((mysql-ptr mysql))
     695         "return (mysql_insert_id (mysql));"))
    720696
    721697; 24.2.3.43. mysql_num_rows()
    722698; my_ulonglong mysql_num_rows(MYSQL_RES *result)
    723699(define foreign-mysql-num-rows
    724         (foreign-lambda my-ulonglong "mysqlaux_mysql_num_rows" mysql-res-ptr))
     700        (foreign-lambda* my-ulonglong ((mysql-res-ptr result))
     701         "return (mysql_num_rows (result));"))
    725702
    726703; 24.2.3.7. mysql_data_seek()
    727704; void mysql_data_seek(MYSQL_RES *result, my_ulonglong offset)
    728705(define foreign-mysql-data-seek
    729         (foreign-lambda void "mysqlaux_mysql_data_seek" mysql-res-ptr my-ulonglong))
     706        (foreign-lambda* void ((mysql-res-ptr result) (my-ulonglong offset))
     707         "mysql_data_seek (result, offset);"))
    730708
    731709;-----------------------------------------------------------------------
     
    733711;
    734712
    735 #>
    736 static int
    737 mysqlaux_mysql_options_none (MYSQL *mysql, enum mysql_option opt)
    738 {
    739         return (mysql_options (mysql, opt, NULL));
    740 }
    741 
    742 static int
    743 mysqlaux_mysql_options_string (MYSQL *mysql, enum mysql_option opt, char *value)
    744 {
    745         return (mysql_options (mysql, opt, value));
    746 }
    747 
    748 static int
    749 mysqlaux_mysql_options_ulong (MYSQL *mysql, enum mysql_option opt, unsigned long value)
    750 {
    751         return (mysql_options (mysql, opt, &value));
    752 }
    753 <#
    754 
    755713(define foreign-mysqlaux-options-none
    756         (foreign-lambda int "mysqlaux_mysql_options_none" mysql-ptr mysql-option) )
     714        (foreign-lambda* int ((mysql-ptr mysql) (mysql-option opt))
     715   "return (mysql_options (mysql, opt, NULL));"))
    757716
    758717(define foreign-mysqlaux-options-string
    759         (foreign-lambda int "mysqlaux_mysql_options_string" mysql-ptr mysql-option c-string) )
     718        (foreign-lambda* int ((mysql-ptr mysql) (mysql-option opt) (c-string value))
     719   "return (mysql_options (mysql, opt, value));"))
    760720
    761721(define foreign-mysqlaux-options-ulong
    762         (foreign-lambda int "mysqlaux_mysql_options_ulong" mysql-ptr mysql-option unsigned-long) )
     722        (foreign-lambda* int ((mysql-ptr mysql) (mysql-option opt) (unsigned-long value))
     723   "return (mysql_options (mysql, opt, &value));"))
    763724
    764725;-----------------------------------------------------------------------
     
    18691830;;
    18701831
    1871 (*define-foreign-enum (mysql-timestamp-type (enum "enum_mysql_timestamp_type"))
     1832($define-foreign-enum (mysql-timestamp-type (enum "enum_mysql_timestamp_type"))
    18721833        #f      ; No aliases!
    18731834        MYSQL_TIMESTAMP_NONE
     
    20351996;;
    20361997
    2037 (*define-foreign-enum (mysql-stmt-state (enum "enum_mysql_stmt_state"))
     1998($define-foreign-enum (mysql-stmt-state (enum "enum_mysql_stmt_state"))
    20381999        #f      ; No aliases!
    20392000        MYSQL_STMT_INIT_DONE
     
    20422003        MYSQL_STMT_FETCH_DONE )
    20432004
    2044 (*define-foreign-enum (mysql-stmt-attr-type (enum "enum_stmt_attr_type"))
     2005($define-foreign-enum (mysql-stmt-attr-type (enum "enum_stmt_attr_type"))
    20452006        #f      ; No aliases!
    20462007        STMT_ATTR_UPDATE_MAX_LENGTH
     
    20482009        STMT_ATTR_PREFETCH_ROWS )
    20492010
    2050 (*define-foreign-enum (mysql-status-return-code unsigned-int)
     2011($define-foreign-enum (mysql-status-return-code unsigned-int)
    20512012        #f      ; No aliases!
    20522013        MYSQL_NO_DATA
     
    21032064        (foreign-lambda my-bool "mysql_stmt_attr_get" mysql-stmt-ptr mysql-stmt-attr-type c-pointer))
    21042065
    2105 #>
    2106 static my_bool
    2107 mysqlaux_stmt_attr_set_bool (MYSQL_STMT *stmt, enum enum_stmt_attr_type attr, my_bool value)
    2108 {
    2109         return (mysql_stmt_attr_set (stmt, attr, &value));
    2110 }
    2111 
    2112 static my_bool
    2113 mysqlaux_stmt_attr_set_ulong (MYSQL_STMT *stmt, enum enum_stmt_attr_type attr, unsigned long value)
    2114 {
    2115         return (mysql_stmt_attr_set (stmt, attr, &value));
    2116 }
    2117 <#
    2118 
    21192066(define foreign-mysqlaux-stmt-attr-set-bool
    2120         (foreign-lambda int "mysqlaux_stmt_attr_set_bool"
    2121                                                                                         mysql-stmt-ptr mysql-stmt-attr-type my-bool) )
     2067        (foreign-lambda* my-bool ((mysql-stmt-ptr stmt) (mysql-stmt-attr-type attrr) (my-bool value))
     2068   "return (mysql_stmt_attr_set (stmt, attr, &value));"))
    21222069
    21232070(define foreign-mysqlaux-stmt-attr-set-ulong
    2124         (foreign-lambda int "mysqlaux_stmt_attr_set_ulong"
    2125                                                                                         mysql-stmt-ptr mysql-stmt-attr-type unsigned-long) )
     2071        (foreign-lambda* my-bool ((mysql-stmt-ptr stmt) (mysql-stmt-attr-type attrr) (unsigned-long value))
     2072   "return (mysql_stmt_attr_set (stmt, attr, &value));"))
    21262073
    21272074;my_bool mysql_stmt_reset(MYSQL_STMT * stmt)
     
    21652112        (foreign-lambda mysql-row-offset "mysql_stmt_row_tell" mysql-stmt-ptr))
    21662113
    2167 #>
    2168 static void
    2169 mysqlaux_stmt_data_seek (MYSQL_STMT *stmt, double offset)
    2170 {
    2171         mysql_stmt_data_seek (stmt, (my_ulonglong) offset);
    2172 }
    2173 
    2174 static double
    2175 mysqlaux_stmt_num_rows (MYSQL_STMT *stmt)
    2176 {
    2177         return ((double) mysql_stmt_num_rows (stmt));
    2178 }
    2179 
    2180 static double
    2181 mysqlaux_stmt_affected_rows (MYSQL_STMT *stmt)
    2182 {
    2183         return ((double) mysql_stmt_affected_rows (stmt));
    2184 }
    2185 
    2186 static double
    2187 mysqlaux_stmt_insert_id (MYSQL_STMT *stmt)
    2188 {
    2189         return ((double) mysql_stmt_insert_id (stmt));
    2190 }
    2191 <#
    2192 
    21932114;void mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset)
    21942115(define foreign-mysql-stmt-data-seek
    2195         (foreign-lambda void "mysqlaux_stmt_data_seek" mysql-stmt-ptr my-ulonglong))
     2116        (foreign-lambda* void ((mysql-stmt-ptr stmt) (my-ulonglong offset))
     2117   "mysql_stmt_data_seek (stmt, offset);"))
    21962118
    21972119;my_ulonglong mysql_stmt_num_rows(MYSQL_STMT *stmt)
    21982120(define foreign-mysql-stmt-num-rows
    2199         (foreign-lambda my-ulonglong "mysqlaux_stmt_num_rows" mysql-stmt-ptr))
     2121        (foreign-lambda* my-ulonglong ((mysql-stmt-ptr stmt))
     2122   "return ((double) mysql_stmt_num_rows (stmt));"))
    22002123
    22012124;my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT *stmt)
    22022125(define foreign-mysql-stmt-affected-rows
    2203         (foreign-lambda my-ulonglong "mysqlaux_stmt_affected_rows" mysql-stmt-ptr))
     2126        (foreign-lambda* my-ulonglong ((mysql-stmt-ptr stmt))
     2127   "return ((double) mysql_stmt_affected_rows (stmt));"))
    22042128
    22052129;my_ulonglong mysql_stmt_insert_id(MYSQL_STMT *stmt)
    22062130(define foreign-mysql-stmt-insert-id
    2207         (foreign-lambda my-ulonglong "mysqlaux_stmt_insert_id" mysql-stmt-ptr))
     2131        (foreign-lambda my-ulonglong ((mysql-stmt-ptr stmt))
     2132   "return ((double) mysql_stmt_insert_id (stmt));"))
    22082133
    22092134;unsigned int mysql_stmt_field_count(MYSQL_STMT *stmt)
     
    26432568
    26442569        When MySQL type unspecified attempt to determine from Scheme type:
    2645        
     2570
    26462571                Ex: string => mysql-type-string
    26472572
    26482573        When MySQL type unspecified attempt to determine from database schema type:
    2649        
    2650                 Ex: 
     2574
     2575                Ex:
    26512576
    26522577        When MySQL type specified coerce the Scheme value:
    26532578
    26542579                mysql-null, sql-null, (void) & '() -> MYSQL_TYPE_NULL
    2655        
     2580
    26562581                When types are a straight-forward match, then no coercion:
    2657                
     2582
    26582583                        Ex: mysql-type-string & string
    2659        
     2584
    26602585                When types are not a straight-forward match, then attempt coercion:
    2661                
     2586
    26622587                        Ex: mysql-type-string & number
    26632588
Note: See TracChangeset for help on using the changeset viewer.