rubyfb 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/Manifest +0 -1
- data/Rakefile +1 -1
- data/ext/AddUser.c +217 -248
- data/ext/AddUser.h +3 -3
- data/ext/Backup.c +337 -404
- data/ext/Backup.h +3 -3
- data/ext/Blob.c +197 -248
- data/ext/Blob.h +30 -31
- data/ext/Common.c +17 -18
- data/ext/Common.h +10 -10
- data/ext/Connection.c +413 -487
- data/ext/Connection.h +18 -19
- data/ext/DataArea.c +172 -189
- data/ext/DataArea.h +11 -11
- data/ext/Database.c +198 -238
- data/ext/Database.h +16 -17
- data/ext/FireRuby.c +118 -142
- data/ext/FireRuby.h +17 -17
- data/ext/FireRubyException.c +68 -138
- data/ext/FireRubyException.h +14 -21
- data/ext/Generator.c +296 -377
- data/ext/Generator.h +17 -18
- data/ext/RemoveUser.c +91 -102
- data/ext/RemoveUser.h +3 -3
- data/ext/Restore.c +353 -423
- data/ext/Restore.h +3 -3
- data/ext/ResultSet.c +423 -456
- data/ext/ResultSet.h +26 -27
- data/ext/Row.c +505 -568
- data/ext/Row.h +27 -28
- data/ext/ServiceManager.c +143 -164
- data/ext/ServiceManager.h +17 -18
- data/ext/Services.c +58 -67
- data/ext/Services.h +3 -3
- data/ext/Statement.c +388 -449
- data/ext/Statement.h +30 -31
- data/ext/Transaction.c +374 -448
- data/ext/Transaction.h +17 -18
- data/ext/TypeMap.c +654 -774
- data/ext/TypeMap.h +17 -17
- data/ext/rfbint.h +3 -3
- data/lib/active_record/connection_adapters/rubyfb_adapter.rb +1 -1
- data/lib/rubyfb_lib.so +0 -0
- data/lib/src.rb +33 -0
- data/rubyfb.gemspec +3 -3
- data/test/ResultSetTest.rb +13 -0
- data/test/RowTest.rb +16 -0
- metadata +4 -5
- data/test/UnitTest.rb +0 -65
data/ext/FireRuby.c
CHANGED
@@ -49,11 +49,10 @@
|
|
49
49
|
* @param key A string containing the name of the key to be retrieved.
|
50
50
|
*
|
51
51
|
*/
|
52
|
-
VALUE getFireRubySetting(const char *key)
|
53
|
-
|
54
|
-
VALUE settings = rb_gv_get("$FireRubySettings");
|
52
|
+
VALUE getFireRubySetting(const char *key) {
|
53
|
+
VALUE settings = rb_gv_get("$FireRubySettings");
|
55
54
|
|
56
|
-
|
55
|
+
return(rb_hash_aref(settings, toSymbol(key)));
|
57
56
|
}
|
58
57
|
|
59
58
|
|
@@ -65,12 +64,11 @@ VALUE getFireRubySetting(const char *key)
|
|
65
64
|
* @param name A string that will be populated with the class name.
|
66
65
|
*
|
67
66
|
*/
|
68
|
-
void getClassName(VALUE object, char *name)
|
69
|
-
|
70
|
-
|
71
|
-
string = rb_funcall(klass, rb_intern("name"), 0);
|
67
|
+
void getClassName(VALUE object, char *name) {
|
68
|
+
VALUE klass = rb_funcall(object, rb_intern("class"), 0),
|
69
|
+
string = rb_funcall(klass, rb_intern("name"), 0);
|
72
70
|
|
73
|
-
|
71
|
+
strcpy(name, StringValuePtr(string));
|
74
72
|
}
|
75
73
|
|
76
74
|
|
@@ -82,9 +80,8 @@ void getClassName(VALUE object, char *name)
|
|
82
80
|
* @return A Symbol object for the string passed in.
|
83
81
|
*
|
84
82
|
*/
|
85
|
-
VALUE toSymbol(const char *name)
|
86
|
-
|
87
|
-
return(rb_funcall(rb_str_new2(name), rb_intern("intern"), 0));
|
83
|
+
VALUE toSymbol(const char *name) {
|
84
|
+
return(rb_funcall(rb_str_new2(name), rb_intern("intern"), 0));
|
88
85
|
}
|
89
86
|
|
90
87
|
|
@@ -98,103 +95,83 @@ VALUE toSymbol(const char *name)
|
|
98
95
|
* @return A symbol giving the base type for the column.
|
99
96
|
*
|
100
97
|
*/
|
101
|
-
VALUE getColumnType(const XSQLVAR *column)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
type = toSymbol("CHAR");
|
179
|
-
break;
|
180
|
-
|
181
|
-
case SQL_TYPE_TIME:
|
182
|
-
type = toSymbol("TIME");
|
183
|
-
break;
|
184
|
-
|
185
|
-
case SQL_TIMESTAMP:
|
186
|
-
type = toSymbol("TIMESTAMP");
|
187
|
-
break;
|
188
|
-
|
189
|
-
case SQL_VARYING:
|
190
|
-
type = toSymbol("VARCHAR");
|
191
|
-
break;
|
192
|
-
|
193
|
-
default:
|
194
|
-
type = toSymbol("UNKNOWN");
|
195
|
-
}
|
196
|
-
|
197
|
-
return(type);
|
98
|
+
VALUE getColumnType(const XSQLVAR *column) {
|
99
|
+
VALUE type = Qnil;
|
100
|
+
|
101
|
+
switch((column->sqltype & ~1)) {
|
102
|
+
case SQL_BLOB:
|
103
|
+
type = toSymbol("BLOB");
|
104
|
+
break;
|
105
|
+
|
106
|
+
case SQL_TYPE_DATE:
|
107
|
+
type = toSymbol("DATE");
|
108
|
+
break;
|
109
|
+
|
110
|
+
case SQL_DOUBLE:
|
111
|
+
type = toSymbol("DOUBLE");
|
112
|
+
break;
|
113
|
+
|
114
|
+
case SQL_FLOAT:
|
115
|
+
type = toSymbol("FLOAT");
|
116
|
+
break;
|
117
|
+
|
118
|
+
case SQL_INT64:
|
119
|
+
if(column->sqlsubtype != 0) {
|
120
|
+
if(column->sqlsubtype == 1) {
|
121
|
+
type = toSymbol("NUMERIC");
|
122
|
+
} else if(column->sqlsubtype == 2) {
|
123
|
+
type = toSymbol("DECIMAL");
|
124
|
+
}
|
125
|
+
} else {
|
126
|
+
type = toSymbol("BIGINT");
|
127
|
+
}
|
128
|
+
break;
|
129
|
+
|
130
|
+
case SQL_LONG:
|
131
|
+
if(column->sqlsubtype != 0) {
|
132
|
+
if(column->sqlsubtype == 1) {
|
133
|
+
type = toSymbol("NUMERIC");
|
134
|
+
} else if(column->sqlsubtype == 2) {
|
135
|
+
type = toSymbol("DECIMAL");
|
136
|
+
}
|
137
|
+
} else {
|
138
|
+
type = toSymbol("INTEGER");
|
139
|
+
}
|
140
|
+
break;
|
141
|
+
|
142
|
+
case SQL_SHORT:
|
143
|
+
if(column->sqlsubtype != 0) {
|
144
|
+
if(column->sqlsubtype == 1) {
|
145
|
+
type = toSymbol("NUMERIC");
|
146
|
+
} else if(column->sqlsubtype == 2) {
|
147
|
+
type = toSymbol("DECIMAL");
|
148
|
+
}
|
149
|
+
} else {
|
150
|
+
type = toSymbol("SMALLINT");
|
151
|
+
}
|
152
|
+
break;
|
153
|
+
|
154
|
+
case SQL_TEXT:
|
155
|
+
type = toSymbol("CHAR");
|
156
|
+
break;
|
157
|
+
|
158
|
+
case SQL_TYPE_TIME:
|
159
|
+
type = toSymbol("TIME");
|
160
|
+
break;
|
161
|
+
|
162
|
+
case SQL_TIMESTAMP:
|
163
|
+
type = toSymbol("TIMESTAMP");
|
164
|
+
break;
|
165
|
+
|
166
|
+
case SQL_VARYING:
|
167
|
+
type = toSymbol("VARCHAR");
|
168
|
+
break;
|
169
|
+
|
170
|
+
default:
|
171
|
+
type = toSymbol("UNKNOWN");
|
172
|
+
}
|
173
|
+
|
174
|
+
return(type);
|
198
175
|
}
|
199
176
|
|
200
177
|
|
@@ -204,37 +181,36 @@ VALUE getColumnType(const XSQLVAR *column)
|
|
204
181
|
* and then creates the various extension classes within this module.
|
205
182
|
*
|
206
183
|
*/
|
207
|
-
void Init_rubyfb_lib(void)
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
Init_Restore(module);
|
184
|
+
void Init_rubyfb_lib(void) {
|
185
|
+
VALUE module = rb_define_module("Rubyfb"),
|
186
|
+
array = rb_ary_new(),
|
187
|
+
hash = rb_hash_new();
|
188
|
+
|
189
|
+
/* Initialise the configuration and make it available. */
|
190
|
+
rb_ary_push(array, INT2FIX(MAJOR_VERSION_NO));
|
191
|
+
rb_ary_push(array, INT2FIX(MINOR_VERSION_NO));
|
192
|
+
rb_ary_push(array, INT2FIX(BUILD_NO));
|
193
|
+
rb_hash_aset(hash, toSymbol("ALIAS_KEYS"), Qtrue);
|
194
|
+
rb_hash_aset(hash, toSymbol("DATE_AS_DATE"), Qtrue);
|
195
|
+
rb_gv_set("$FireRubyVersion", array);
|
196
|
+
rb_gv_set("$FireRubySettings", hash);
|
197
|
+
|
198
|
+
/* Require needed libraries. */
|
199
|
+
rb_require("date");
|
200
|
+
|
201
|
+
/* Initialise the library classes. */
|
202
|
+
Init_Database(module);
|
203
|
+
Init_Connection(module);
|
204
|
+
Init_Transaction(module);
|
205
|
+
Init_Statement(module);
|
206
|
+
Init_ResultSet(module);
|
207
|
+
Init_Generator(module);
|
208
|
+
Init_FireRubyException(module);
|
209
|
+
Init_Blob(module);
|
210
|
+
Init_Row(module);
|
211
|
+
Init_ServiceManager(module);
|
212
|
+
Init_Backup(module);
|
213
|
+
Init_AddUser(module);
|
214
|
+
Init_RemoveUser(module);
|
215
|
+
Init_Restore(module);
|
240
216
|
}
|
data/ext/FireRuby.h
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
*----------------------------------------------------------------------------*/
|
4
4
|
/**
|
5
5
|
* Copyright � Peter Wood, 2005
|
6
|
-
*
|
6
|
+
*
|
7
7
|
* The contents of this file are subject to the Mozilla Public License Version
|
8
8
|
* 1.1 (the "License"); you may not use this file except in compliance with the
|
9
|
-
* License. You may obtain a copy of the License at
|
9
|
+
* License. You may obtain a copy of the License at
|
10
10
|
*
|
11
11
|
* http://www.mozilla.org/MPL/
|
12
|
-
*
|
12
|
+
*
|
13
13
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
14
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
15
|
* the specificlanguage governing rights and limitations under the License.
|
16
|
-
*
|
16
|
+
*
|
17
17
|
* The Original Code is the FireRuby extension for the Ruby language.
|
18
|
-
*
|
19
|
-
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
20
|
* Reserved.
|
21
21
|
*
|
22
22
|
* @author Peter Wood
|
@@ -25,26 +25,26 @@
|
|
25
25
|
#ifndef FIRERUBY_FIRE_RUBY_H
|
26
26
|
#define FIRERUBY_FIRE_RUBY_H
|
27
27
|
|
28
|
-
|
28
|
+
/* Includes. */
|
29
29
|
#ifndef RUBY_H_INCLUDED
|
30
30
|
#include "ruby.h"
|
31
31
|
#define RUBY_H_INCLUDED
|
32
32
|
#endif
|
33
|
-
|
33
|
+
|
34
34
|
#ifndef IBASE_H_INCLUDED
|
35
35
|
#include "ibase.h"
|
36
36
|
#define IBASE_H_INCLUDED
|
37
37
|
#endif
|
38
|
-
|
39
|
-
|
38
|
+
|
39
|
+
/* Definitions. */
|
40
40
|
#define MAJOR_VERSION_NO 0
|
41
41
|
#define MINOR_VERSION_NO 4
|
42
42
|
#define BUILD_NO 3
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
43
|
+
|
44
|
+
/* Function definitions. */
|
45
|
+
VALUE getFireRubySetting(const char *);
|
46
|
+
void getClassName(VALUE, char *);
|
47
|
+
VALUE toSymbol(const char *);
|
48
|
+
VALUE getColumnType(const XSQLVAR *);
|
49
|
+
|
50
50
|
#endif /* FIRERUBY_FIRE_RUBY_H */
|
data/ext/FireRubyException.c
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
*----------------------------------------------------------------------------*/
|
4
4
|
/**
|
5
5
|
* Copyright � Peter Wood, 2005
|
6
|
-
*
|
6
|
+
*
|
7
7
|
* The contents of this file are subject to the Mozilla Public License Version
|
8
8
|
* 1.1 (the "License"); you may not use this file except in compliance with the
|
9
|
-
* License. You may obtain a copy of the License at
|
9
|
+
* License. You may obtain a copy of the License at
|
10
10
|
*
|
11
11
|
* http://www.mozilla.org/MPL/
|
12
|
-
*
|
12
|
+
*
|
13
13
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
14
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
15
|
* the specificlanguage governing rights and limitations under the License.
|
16
|
-
*
|
16
|
+
*
|
17
17
|
* The Original Code is the FireRuby extension for the Ruby language.
|
18
|
-
*
|
19
|
-
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
20
|
* Reserved.
|
21
21
|
*
|
22
22
|
* @author Peter Wood
|
@@ -28,47 +28,15 @@
|
|
28
28
|
#include "time.h"
|
29
29
|
|
30
30
|
/* Function prototypes. */
|
31
|
-
static VALUE allocateFireRubyException(VALUE);
|
32
31
|
static VALUE initializeFireRubyException(VALUE, VALUE);
|
33
32
|
static VALUE getFireRubyExceptionSQLCode(VALUE);
|
34
33
|
static VALUE getFireRubyExceptionDBCode(VALUE);
|
35
34
|
static VALUE getFireRubyExceptionMessage(VALUE);
|
36
|
-
VALUE decodeError(ISC_STATUS *, const char *, VALUE);
|
37
35
|
|
38
36
|
/* Globals. */
|
39
37
|
VALUE cFireRubyException;
|
40
38
|
|
41
39
|
|
42
|
-
/**
|
43
|
-
* This function integrates with the Ruby language to allow for the allocation
|
44
|
-
* of new FireRubyException objects.
|
45
|
-
*
|
46
|
-
* @param klass A reference to the FireRubyException Class object.
|
47
|
-
*
|
48
|
-
* @return An instance of the FireRubyException class.
|
49
|
-
*
|
50
|
-
*/
|
51
|
-
static VALUE allocateFireRubyException(VALUE klass)
|
52
|
-
{
|
53
|
-
VALUE instance;
|
54
|
-
ExceptionHandle *exception = ALLOC(ExceptionHandle);
|
55
|
-
|
56
|
-
if(exception != NULL)
|
57
|
-
{
|
58
|
-
exception->when = (long)time(NULL);
|
59
|
-
instance = Data_Wrap_Struct(klass, NULL, firerubyExceptionFree,
|
60
|
-
exception);
|
61
|
-
}
|
62
|
-
else
|
63
|
-
{
|
64
|
-
rb_raise(rb_eNoMemError,
|
65
|
-
"Memory allocation failure creating a FireRubyException object.");
|
66
|
-
}
|
67
|
-
|
68
|
-
return(instance);
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
40
|
/**
|
73
41
|
* This function provides the initialize method for the FireRubyException
|
74
42
|
* class.
|
@@ -79,20 +47,18 @@ static VALUE allocateFireRubyException(VALUE klass)
|
|
79
47
|
* @return A reference to the initialized exception object.
|
80
48
|
*
|
81
49
|
*/
|
82
|
-
static VALUE initializeFireRubyException(VALUE self, VALUE message)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
return(self);
|
50
|
+
static VALUE initializeFireRubyException(VALUE self, VALUE message) {
|
51
|
+
/* Check the input type. */
|
52
|
+
if(TYPE(message) != T_STRING) {
|
53
|
+
rb_raise(rb_eException,
|
54
|
+
"Invalid message parameter specified for exception.");
|
55
|
+
}
|
56
|
+
|
57
|
+
rb_iv_set(self, "@message", message);
|
58
|
+
rb_iv_set(self, "@sql_code", 0);
|
59
|
+
rb_iv_set(self, "@db_code", 0);
|
60
|
+
|
61
|
+
return(self);
|
96
62
|
}
|
97
63
|
|
98
64
|
|
@@ -105,9 +71,8 @@ static VALUE initializeFireRubyException(VALUE self, VALUE message)
|
|
105
71
|
* @return A reference to the requested code value.
|
106
72
|
*
|
107
73
|
*/
|
108
|
-
static VALUE getFireRubyExceptionSQLCode(VALUE self)
|
109
|
-
|
110
|
-
return(rb_iv_get(self, "@sql_code"));
|
74
|
+
static VALUE getFireRubyExceptionSQLCode(VALUE self) {
|
75
|
+
return(rb_iv_get(self, "@sql_code"));
|
111
76
|
}
|
112
77
|
|
113
78
|
|
@@ -120,9 +85,8 @@ static VALUE getFireRubyExceptionSQLCode(VALUE self)
|
|
120
85
|
* @return A reference to the requested code value.
|
121
86
|
*
|
122
87
|
*/
|
123
|
-
static VALUE getFireRubyExceptionDBCode(VALUE self)
|
124
|
-
|
125
|
-
return(rb_iv_get(self, "@db_code"));
|
88
|
+
static VALUE getFireRubyExceptionDBCode(VALUE self) {
|
89
|
+
return(rb_iv_get(self, "@db_code"));
|
126
90
|
}
|
127
91
|
|
128
92
|
|
@@ -134,9 +98,8 @@ static VALUE getFireRubyExceptionDBCode(VALUE self)
|
|
134
98
|
* @return A reference to the message for the exception.
|
135
99
|
*
|
136
100
|
*/
|
137
|
-
static VALUE getFireRubyExceptionMessage(VALUE self)
|
138
|
-
|
139
|
-
return(rb_iv_get(self, "@message"));
|
101
|
+
static VALUE getFireRubyExceptionMessage(VALUE self) {
|
102
|
+
return(rb_iv_get(self, "@message"));
|
140
103
|
}
|
141
104
|
|
142
105
|
|
@@ -152,46 +115,41 @@ static VALUE getFireRubyExceptionMessage(VALUE self)
|
|
152
115
|
* @return A reference to the full decode error message string.
|
153
116
|
*
|
154
117
|
*/
|
155
|
-
VALUE decodeException(ISC_STATUS *status, const char *prefix)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
/* Decode the status array. */
|
174
|
-
dbCode = status[1];
|
175
|
-
while(fb_interpret(text, 512, ptr) != 0)
|
176
|
-
{
|
177
|
-
rb_str_concat(message, rb_str_new2(text));
|
178
|
-
rb_str_concat(message, eol);
|
179
|
-
memset(text, 0, 512);
|
180
|
-
}
|
181
|
-
|
182
|
-
isc_sql_interprete(sqlCode, text, 512);
|
183
|
-
if(strlen(text) > 0)
|
184
|
-
{
|
185
|
-
rb_str_concat(message, rb_str_new2(text));
|
186
|
-
}
|
187
|
-
|
188
|
-
sprintf(text, "\nSQL Code = %d\n", sqlCode);
|
118
|
+
VALUE decodeException(const ISC_STATUS *status, const char *prefix) {
|
119
|
+
VALUE message = rb_str_new2(""),
|
120
|
+
eol = rb_str_new2("\n");
|
121
|
+
char text[512];
|
122
|
+
int sqlCode = isc_sqlcode(status),
|
123
|
+
dbCode = 0;
|
124
|
+
const ISC_STATUS **ptr = &status;
|
125
|
+
|
126
|
+
/* Add the prefix message if it exists. */
|
127
|
+
if(prefix != NULL && strlen(prefix) > 0) {
|
128
|
+
rb_str_concat(message, rb_str_new2(prefix));
|
129
|
+
rb_str_concat(message, eol);
|
130
|
+
}
|
131
|
+
|
132
|
+
if(status != NULL) {
|
133
|
+
/* Decode the status array. */
|
134
|
+
dbCode = status[1];
|
135
|
+
while(fb_interpret(text, 512, ptr) != 0) {
|
189
136
|
rb_str_concat(message, rb_str_new2(text));
|
190
|
-
|
137
|
+
rb_str_concat(message, eol);
|
138
|
+
memset(text, 0, 512);
|
139
|
+
}
|
140
|
+
|
141
|
+
isc_sql_interprete(sqlCode, text, 512);
|
142
|
+
if(strlen(text) > 0) {
|
191
143
|
rb_str_concat(message, rb_str_new2(text));
|
192
|
-
|
193
|
-
|
194
|
-
|
144
|
+
}
|
145
|
+
|
146
|
+
sprintf(text, "\nSQL Code = %d\n", sqlCode);
|
147
|
+
rb_str_concat(message, rb_str_new2(text));
|
148
|
+
sprintf(text, "Firebird Code = %d\n", dbCode);
|
149
|
+
rb_str_concat(message, rb_str_new2(text));
|
150
|
+
}
|
151
|
+
|
152
|
+
return(message);
|
195
153
|
}
|
196
154
|
|
197
155
|
|
@@ -204,13 +162,8 @@ VALUE decodeException(ISC_STATUS *status, const char *prefix)
|
|
204
162
|
* @return A reference to a newly created FireRubyException object.
|
205
163
|
*
|
206
164
|
*/
|
207
|
-
VALUE rb_fireruby_exception_new(const char *message)
|
208
|
-
|
209
|
-
VALUE exception = allocateFireRubyException(cFireRubyException);
|
210
|
-
|
211
|
-
initializeFireRubyException(exception, rb_str_new2(message));
|
212
|
-
|
213
|
-
return(exception);
|
165
|
+
VALUE rb_fireruby_exception_new(const char *message) {
|
166
|
+
return rb_funcall(cFireRubyException, rb_intern("new"), 1, rb_str_new2(message));
|
214
167
|
}
|
215
168
|
|
216
169
|
|
@@ -223,29 +176,9 @@ VALUE rb_fireruby_exception_new(const char *message)
|
|
223
176
|
* text generated by the decoding.
|
224
177
|
*
|
225
178
|
*/
|
226
|
-
void rb_fireruby_raise(ISC_STATUS *status, const char *message)
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
rb_raise(cFireRubyException, StringValuePtr(text));
|
231
|
-
}
|
232
|
-
|
233
|
-
|
234
|
-
/**
|
235
|
-
* This function integrates with the Ruby garbage collector to insure that the
|
236
|
-
* resources associated with a FireRubyException object are completely released
|
237
|
-
* when an object of this type is collected.
|
238
|
-
*
|
239
|
-
* @param exception A pointer to the ExceptionHandle structure associated
|
240
|
-
* with a FireRubyException object that is being collected.
|
241
|
-
*
|
242
|
-
*/
|
243
|
-
void firerubyExceptionFree(void *exception)
|
244
|
-
{
|
245
|
-
if(exception != NULL)
|
246
|
-
{
|
247
|
-
free((ExceptionHandle *)exception);
|
248
|
-
}
|
179
|
+
void rb_fireruby_raise(const ISC_STATUS *status, const char *message) {
|
180
|
+
VALUE text = decodeException(status, message);
|
181
|
+
rb_raise(cFireRubyException, "%s", StringValuePtr(text));
|
249
182
|
}
|
250
183
|
|
251
184
|
|
@@ -256,13 +189,10 @@ void firerubyExceptionFree(void *exception)
|
|
256
189
|
* @param module The module to create the class under.
|
257
190
|
*
|
258
191
|
*/
|
259
|
-
void Init_FireRubyException(VALUE module)
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
rb_define_method(cFireRubyException, "sql_code", getFireRubyExceptionSQLCode, 0);
|
266
|
-
rb_define_method(cFireRubyException, "db_code", getFireRubyExceptionDBCode, 0);
|
267
|
-
rb_define_method(cFireRubyException, "message", getFireRubyExceptionMessage, 0);
|
192
|
+
void Init_FireRubyException(VALUE module) {
|
193
|
+
cFireRubyException = rb_define_class_under(module, "FireRubyException", rb_eStandardError);
|
194
|
+
rb_define_method(cFireRubyException, "initialize", initializeFireRubyException, 1);
|
195
|
+
rb_define_method(cFireRubyException, "sql_code", getFireRubyExceptionSQLCode, 0);
|
196
|
+
rb_define_method(cFireRubyException, "db_code", getFireRubyExceptionDBCode, 0);
|
197
|
+
rb_define_method(cFireRubyException, "message", getFireRubyExceptionMessage, 0);
|
268
198
|
}
|