1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* drizzle-interface: Interface Wrappers for Drizzle
5
* Copyright (C) 2008 Sun Microsystems, Inc.
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
%include "interface/globals.i"
26
%typemap(in) (const char *query, size_t size) {
28
$1 = STR2CSTR($input);
29
$2 = (size_t)RSTRING($input)->len;
33
%include "interface/libdrizzle/drizzle.i"
34
%include "interface/libdrizzle/con.i"
35
%include "interface/libdrizzle/client.i"
36
%include "interface/libdrizzle/server.i"
37
%include "interface/libdrizzle/query.i"
38
%include "interface/libdrizzle/result.i"
39
%include "interface/libdrizzle/result_client.i"
40
%include "interface/libdrizzle/result_client_buffered.i"
41
%include "interface/libdrizzle/result_client_unbuffered.i"
42
%include "interface/libdrizzle/result_server.i"
43
%include "interface/libdrizzle/column.i"
44
%include "interface/libdrizzle/column_server.i"
48
#define D_exception(code,msg) do { drizzle_raise_exception(code, msg); SWIG_fail; } while(0);
49
#define D_exception_err(code,err) do { drizzle_raise_exception(code, err.message); SWIG_fail; } while(0);
51
#define getExceptionMethod(excptype,eparent) \
53
get ## excptype () { \
54
static int init ## excptype = 0 ; \
55
static VALUE rb_e ## excptype ; \
56
VALUE rb_eparent = drizzle_get_exception (eparent); \
57
if (! init ## excptype ) { \
58
init ## excptype = 1; \
59
rb_e ## excptype = rb_define_class(#excptype , rb_eparent); \
61
return rb_e ## excptype ; \
64
SWIGINTERN VALUE getDrizzleException() {
65
static int initDrizzleException = 0 ;
66
static VALUE rb_eDrizzleException;
67
if (! initDrizzleException ) {
68
initDrizzleException = 1;
69
rb_eDrizzleException = rb_define_class("DrizzleException", rb_eRuntimeError);
71
return rb_eDrizzleException ;
74
VALUE drizzle_get_exception(drizzle_exception excpcode);
76
getExceptionMethod(SubDrizzleException,DrizzleException);
78
void drizzle_raise_exception(drizzle_exception excpcode, const char * msg) {
79
rb_raise(drizzle_get_exception(excpcode),msg);
82
VALUE drizzle_get_exception(drizzle_exception excpcode) {
87
case DrizzleException:
88
exception = getDrizzleException();
91
exception = rb_eRuntimeError;