intersys 0.0.4 → 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +63 -0
- data/lib/common.c +40 -6
- data/lib/definition.c +92 -14
- data/lib/intersys.c +37 -15
- data/lib/intersys.h +17 -1
- data/lib/intersys.rb +136 -144
- data/lib/object.c +3 -3
- data/lib/query.c +0 -2
- data/lib/test.rb +17 -2
- data/test/object.rb +9 -4
- data/test/query.rb +34 -1
- data/test/strings.rb +8 -0
- metadata +2 -9
- data/lib/common.o +0 -0
- data/lib/database.o +0 -0
- data/lib/definition.o +0 -0
- data/lib/intersys.o +0 -0
- data/lib/intersys_cache.bundle +0 -0
- data/lib/mkmf.log +0 -177
- data/lib/object.o +0 -0
- data/lib/query.o +0 -0
data/README
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
This is driver for post-relational database Cache, created by Intersystems (http://intersystems.com/cache/index.html)
|
2
|
+
|
3
|
+
Author: Max Lapshin <max@maxidoors.ru>
|
4
|
+
Weblog: http://maxidoors.ru
|
5
|
+
Home page of the project: http://rubyforge.org/projects/intersys
|
6
|
+
|
7
|
+
Currently it supports Object access to Cache and preliminary version of SQL.
|
8
|
+
|
9
|
+
To use Cache objects, You must declare proxy class:
|
10
|
+
|
11
|
+
class Person < Intersys::Object
|
12
|
+
end
|
13
|
+
|
14
|
+
By default database connection is established with localhost:1973, user _SYSTEM, password SYS
|
15
|
+
|
16
|
+
Database connection is shared among ALL classes. Currently, it is impossible to establish connection
|
17
|
+
with two databases simultaneously
|
18
|
+
|
19
|
+
If You need some other database settings, You must declare it:
|
20
|
+
|
21
|
+
class Person < Intersys::Object
|
22
|
+
database {:user => "_SYSTEM", :password => "SYS", :namespace => "User", :host => "localhost", :port => "1972"}
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
After initialization You get following methods for Person:
|
27
|
+
|
28
|
+
Person.intersys_call
|
29
|
+
Person.intersys_methods
|
30
|
+
Person.open(id)
|
31
|
+
|
32
|
+
Also, there is very slow
|
33
|
+
|
34
|
+
Person.all_methods
|
35
|
+
|
36
|
+
It loads whole hierarchy of classes and loads all methods from all of them. Method
|
37
|
+
|
38
|
+
Person.intersys_description
|
39
|
+
|
40
|
+
uses this.
|
41
|
+
|
42
|
+
|
43
|
+
You can load proxy interface to Cache object:
|
44
|
+
|
45
|
+
@p = Person.open(id)
|
46
|
+
puts @p.intersys_methods
|
47
|
+
|
48
|
+
puts @p.name
|
49
|
+
puts @p.title
|
50
|
+
|
51
|
+
|
52
|
+
Naming conventions:
|
53
|
+
|
54
|
+
You have no need to declare proxy methods from ruby class to Cache methods.
|
55
|
+
When method_missing is called on instance of Intersys::Object, name of method
|
56
|
+
is camelized.
|
57
|
+
|
58
|
+
Person.delete_extent is transferred to
|
59
|
+
1. Property DeleteExtent
|
60
|
+
2. Method DeleteExtent()
|
61
|
+
3. Method %DeleteExtent()
|
62
|
+
|
63
|
+
Used which of them first is found.
|
data/lib/common.c
CHANGED
@@ -22,11 +22,7 @@ VALUE string_from_wchar(VALUE self) {
|
|
22
22
|
|
23
23
|
int run(int err, char *file, int line) {
|
24
24
|
if (err != 0) {
|
25
|
-
|
26
|
-
INT2FIX(err), rb_str_new2(cbind_get_last_err_msg()), rb_str_new2(file), INT2FIX(line));
|
27
|
-
if(handled == Qnil) {
|
28
|
-
rb_raise(rb_eStandardError, "Intersystems Cache error %d: %s in file %s: %d", err, cbind_get_last_err_msg(), file, line);
|
29
|
-
}
|
25
|
+
rb_raise(rb_eStandardError, "Intersystems Cache error %d: %s in file %s: %d", err, cbind_get_last_err_msg(), file, line);
|
30
26
|
}
|
31
27
|
return err;
|
32
28
|
}
|
@@ -54,4 +50,42 @@ VALUE rb_wcstr_new(const wchar_t *w_str, const char_size_t len) {
|
|
54
50
|
|
55
51
|
VALUE rb_wcstr_new2(const wchar_t *w_str) {
|
56
52
|
return wcstr_new(w_str, w_str ? wcslen(w_str) : -1);
|
57
|
-
}
|
53
|
+
}
|
54
|
+
|
55
|
+
static void intersys_status_mark(struct rbStatus* status) {
|
56
|
+
rb_gc_mark(status->message);
|
57
|
+
}
|
58
|
+
|
59
|
+
VALUE intersys_status_s_allocate(VALUE klass) {
|
60
|
+
struct rbStatus* status = ALLOC(struct rbStatus);
|
61
|
+
bzero(status, sizeof(struct rbStatus));
|
62
|
+
return Data_Wrap_Struct(klass, intersys_status_mark, 0, status);
|
63
|
+
}
|
64
|
+
|
65
|
+
VALUE intersys_status_initialize(VALUE self, VALUE code, VALUE message) {
|
66
|
+
struct rbStatus* status;
|
67
|
+
Data_Get_Struct(self, struct rbStatus, status);
|
68
|
+
status->code = code;
|
69
|
+
status->message = message;
|
70
|
+
rb_call_super(1, &message);
|
71
|
+
return self;
|
72
|
+
}
|
73
|
+
|
74
|
+
VALUE intersys_status_code(VALUE self) {
|
75
|
+
struct rbStatus* status;
|
76
|
+
Data_Get_Struct(self, struct rbStatus, status);
|
77
|
+
return status->code;
|
78
|
+
}
|
79
|
+
|
80
|
+
VALUE intersys_status_message(VALUE self) {
|
81
|
+
struct rbStatus* status;
|
82
|
+
Data_Get_Struct(self, struct rbStatus, status);
|
83
|
+
return status->message;
|
84
|
+
}
|
85
|
+
|
86
|
+
VALUE intersys_status_to_s(VALUE self) {
|
87
|
+
struct rbStatus* status;
|
88
|
+
Data_Get_Struct(self, struct rbStatus, status);
|
89
|
+
return status->message;
|
90
|
+
}
|
91
|
+
|
data/lib/definition.c
CHANGED
@@ -21,24 +21,35 @@ static void intersys_definition_free(struct rbDefinition* definition) {
|
|
21
21
|
|
22
22
|
static void intersys_definition_mark(struct rbDefinition* definition) {
|
23
23
|
rb_gc_mark(definition->class_name);
|
24
|
+
if(definition->object != Qnil) {
|
25
|
+
rb_gc_mark(definition->object);
|
26
|
+
}
|
24
27
|
}
|
25
28
|
|
26
29
|
VALUE intersys_definition_s_allocate(VALUE klass) {
|
27
30
|
struct rbDefinition* definition = ALLOC(struct rbDefinition);
|
28
31
|
bzero(definition, sizeof(struct rbDefinition));
|
32
|
+
definition->object = Qnil;
|
29
33
|
return Data_Wrap_Struct(klass, intersys_definition_mark, intersys_definition_free, definition);
|
30
34
|
}
|
31
35
|
|
32
36
|
VALUE intersys_definition_initialize(VALUE self, VALUE r_database, VALUE class_name, VALUE name) {
|
33
37
|
struct rbDatabase* database;
|
34
38
|
struct rbDefinition* definition;
|
39
|
+
VALUE name_w = Qnil;
|
35
40
|
|
36
41
|
Data_Get_Struct(r_database, struct rbDatabase, database);
|
37
42
|
Data_Get_Struct(self, struct rbDefinition, definition);
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
|
44
|
+
rb_iv_set(self, "@database", r_database);
|
45
|
+
rb_iv_set(self, "@class_name", class_name);
|
41
46
|
definition->class_name = TOWCHAR(class_name);
|
47
|
+
rb_iv_set(self, "@class_name_w", definition->class_name);
|
48
|
+
rb_iv_set(self, "@name", name);
|
49
|
+
name_w = TOWCHAR(name);
|
50
|
+
rb_iv_set(self, "@name_w", name_w);
|
51
|
+
definition->database = database->database;
|
52
|
+
definition->in_name = WCHARSTR(name_w);
|
42
53
|
|
43
54
|
RUN(cbind_alloc_class_def(definition->database, CLASS_NAME(definition), &definition->cl_def));
|
44
55
|
return self;
|
@@ -50,6 +61,27 @@ VALUE intersys_definition_cpp_type(VALUE self) {
|
|
50
61
|
return INT2FIX(definition->cpp_type);
|
51
62
|
}
|
52
63
|
|
64
|
+
VALUE intersys_definition_cpp_name(VALUE self) {
|
65
|
+
struct rbDefinition* definition;
|
66
|
+
Data_Get_Struct(self, struct rbDefinition, definition);
|
67
|
+
switch(definition->cpp_type) {
|
68
|
+
case CBIND_VOID: return ID2SYM(rb_intern("void"));
|
69
|
+
case CBIND_OBJ_ID: return ID2SYM(rb_intern("object"));
|
70
|
+
case CBIND_INT_ID: return ID2SYM(rb_intern("int"));
|
71
|
+
case CBIND_DOUBLE_ID: return ID2SYM(rb_intern("double"));
|
72
|
+
case CBIND_BINARY_ID: return ID2SYM(rb_intern("binary"));
|
73
|
+
case CBIND_STRING_ID: return ID2SYM(rb_intern("string"));
|
74
|
+
case CBIND_STATUS_ID: return ID2SYM(rb_intern("status"));
|
75
|
+
case CBIND_TIME_ID: return ID2SYM(rb_intern("time"));
|
76
|
+
case CBIND_DATE_ID: return ID2SYM(rb_intern("date"));
|
77
|
+
case CBIND_TIMESTAMP_ID: return ID2SYM(rb_intern("timestamp"));
|
78
|
+
case CBIND_BOOL_ID: return ID2SYM(rb_intern("bool"));
|
79
|
+
case CBIND_CURRENCY_ID: return ID2SYM(rb_intern("currency"));
|
80
|
+
case CBIND_DLIST_ID: return ID2SYM(rb_intern("dlist"));
|
81
|
+
}
|
82
|
+
return ID2SYM(rb_intern("unknown"));
|
83
|
+
}
|
84
|
+
|
53
85
|
|
54
86
|
VALUE intersys_definition_cache_type(VALUE self) {
|
55
87
|
struct rbDefinition* definition;
|
@@ -113,14 +145,21 @@ VALUE intersys_property_set(VALUE self, VALUE value) {
|
|
113
145
|
|
114
146
|
|
115
147
|
|
116
|
-
VALUE intersys_method_initialize(VALUE self, VALUE object) {
|
148
|
+
VALUE intersys_method_initialize(VALUE self, VALUE r_database, VALUE class_name, VALUE name, VALUE object) {
|
117
149
|
struct rbDefinition* method;
|
150
|
+
int error;
|
151
|
+
VALUE args[] = {r_database, class_name, name};
|
152
|
+
rb_call_super(3, args);
|
153
|
+
|
118
154
|
|
119
155
|
Data_Get_Struct(self, struct rbDefinition, method);
|
120
156
|
|
121
157
|
method->type = D_METHOD;
|
122
158
|
RUN(cbind_alloc_mtd_def(&method->def));
|
123
|
-
|
159
|
+
error = (cbind_get_mtd_def(method->cl_def, method->in_name, method->def));
|
160
|
+
if(error) {
|
161
|
+
rb_raise(rb_eNoMethodError, "No such method %s in Cache class %s", STR(FROMWCSTR(method->in_name)), STR(rb_iv_get(self, "@class_name")));
|
162
|
+
}
|
124
163
|
RUN(cbind_get_mtd_is_func(method->def, &method->is_func));
|
125
164
|
RUN(cbind_get_mtd_cpp_type(method->def, &method->cpp_type));
|
126
165
|
RUN(cbind_get_mtd_cache_type(method->def, &method->cache_type));
|
@@ -128,11 +167,11 @@ VALUE intersys_method_initialize(VALUE self, VALUE object) {
|
|
128
167
|
RUN(cbind_get_mtd_num_args(method->def, &method->num_args));
|
129
168
|
RUN(cbind_get_mtd_args_info(method->def, &method->args_info));
|
130
169
|
RUN(cbind_get_mtd_name(method->def, &method->name));
|
131
|
-
|
170
|
+
method->object = object;
|
171
|
+
if(rb_obj_is_kind_of(object, cObject)) {
|
132
172
|
struct rbObject* obj;
|
133
173
|
Data_Get_Struct(object, struct rbObject, obj);
|
134
174
|
method->oref = obj->oref;
|
135
|
-
rb_iv_set(self, "@object", object);
|
136
175
|
} else {
|
137
176
|
method->oref = -1;
|
138
177
|
}
|
@@ -187,6 +226,10 @@ static VALUE extract_next_dlist_elem(char *dlist, int* elem_size) {
|
|
187
226
|
bool_t is_uni;
|
188
227
|
VALUE val;
|
189
228
|
|
229
|
+
rb_warn("Unmarshalling strings from dlist is untested. If You see this message, contact developer at max@maxidoors.ru");
|
230
|
+
//FIXME: If unicode string is returned, there are no three bytes padding at the end of string.
|
231
|
+
// We shouldn't use rb_str_new for it, because there must be allocating buffer by hands.
|
232
|
+
// RSTRING(str)->aux.capa must be size+4 (usually it is size+1), because of wcslen requires wide zero at the end (4 bytes)
|
190
233
|
RUN(cbind_dlist_get_str_elem(dlist, &is_uni, &str, &size, elem_size));
|
191
234
|
val = rb_str_new(str, size);
|
192
235
|
if (is_uni) {
|
@@ -197,16 +240,12 @@ static VALUE extract_next_dlist_elem(char *dlist, int* elem_size) {
|
|
197
240
|
rb_raise(cUnMarshallError, "Couldn't unmarshall dlist element");
|
198
241
|
}
|
199
242
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
243
|
VALUE intersys_method_call(VALUE self, VALUE args) {
|
205
244
|
struct rbDefinition* method;
|
206
245
|
int i;
|
207
246
|
Check_Type(args, T_ARRAY);
|
208
247
|
Data_Get_Struct(self, struct rbDefinition, method);
|
209
|
-
if(
|
248
|
+
if(RARRAY(args)->len > method->num_args) {
|
210
249
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", RARRAY(args)->len, method->num_args);
|
211
250
|
}
|
212
251
|
VALUE database = rb_iv_get(self, "@database");
|
@@ -227,9 +266,28 @@ VALUE intersys_method_call(VALUE self, VALUE args) {
|
|
227
266
|
RUN(cbind_set_next_arg_as_res(method->database, method->cpp_type));
|
228
267
|
}
|
229
268
|
RUN(cbind_run_method(method->database, method->oref, CLASS_NAME(method), method->in_name));
|
269
|
+
//TODO: No support for arguments, passed by reference. I don't know, how to implement it.
|
270
|
+
//Perhaps, we must require method replace! from each argument, that is possible to be referenced
|
230
271
|
return intersys_method_extract_retval(self);
|
231
272
|
}
|
232
273
|
|
274
|
+
VALUE intersys_method_each_argument(VALUE self) {
|
275
|
+
struct rbDefinition* method;
|
276
|
+
int i;
|
277
|
+
VALUE database = rb_iv_get(self, "@database");
|
278
|
+
VALUE class_name = rb_iv_get(self, "@class_name");
|
279
|
+
VALUE name = rb_iv_get(self, "@name");
|
280
|
+
Data_Get_Struct(self, struct rbDefinition, method);
|
281
|
+
|
282
|
+
RUN(cbind_reset_args(method->database));
|
283
|
+
RUN(cbind_mtd_rewind_args(method->def));
|
284
|
+
for(i = 0; i < method->num_args; i++) {
|
285
|
+
VALUE arg = rb_funcall(cArgument, rb_intern("new"), 4, database, class_name, name, self);
|
286
|
+
rb_yield(arg);
|
287
|
+
RUN(cbind_mtd_arg_next(method->def));
|
288
|
+
}
|
289
|
+
return self;
|
290
|
+
}
|
233
291
|
|
234
292
|
VALUE intersys_argument_initialize(VALUE self, VALUE r_database, VALUE class_name, VALUE name, VALUE r_method) {
|
235
293
|
struct rbDefinition* argument;
|
@@ -321,7 +379,7 @@ VALUE intersys_method_extract_retval(VALUE self) {
|
|
321
379
|
if(is_null) {
|
322
380
|
return Qnil;
|
323
381
|
}
|
324
|
-
return rb_funcall(rb_cTime, rb_intern("local"), 3, INT2NUM(year), INT2NUM(month), INT2NUM(day))
|
382
|
+
return rb_funcall(rb_cTime, rb_intern("local"), 3, INT2NUM(year), INT2NUM(month), INT2NUM(day));
|
325
383
|
}
|
326
384
|
case CBIND_TIMESTAMP_ID:
|
327
385
|
{
|
@@ -372,7 +430,7 @@ VALUE intersys_method_extract_retval(VALUE self) {
|
|
372
430
|
//TODO: if code is not OK, we should throw exception. No class Status is required
|
373
431
|
RUN(cbind_get_arg_as_status(method->database, method->passed_args, &code, NULL, 0, MULTIBYTE, &size, &is_null));
|
374
432
|
if(!code || is_null) {
|
375
|
-
return
|
433
|
+
return method->object;
|
376
434
|
}
|
377
435
|
buf = rb_str_buf_new(size);
|
378
436
|
RUN(cbind_get_arg_as_status(method->database, method->passed_args, &code, STR(buf), RSTRING(buf)->aux.capa, MULTIBYTE, &size, &is_null));
|
@@ -581,3 +639,23 @@ VALUE intersys_argument_set(VALUE self, VALUE obj) {
|
|
581
639
|
return self;
|
582
640
|
|
583
641
|
}
|
642
|
+
|
643
|
+
VALUE intersys_argument_marshall_dlist(VALUE self, VALUE list) {
|
644
|
+
//struct rbDefinition* argument;
|
645
|
+
//Data_Get_Struct(self, struct rbDefinition, argument);
|
646
|
+
rb_iterate(rb_each, list, intersys_argument_marshall_dlist_elem, Qnil);
|
647
|
+
return self;
|
648
|
+
}
|
649
|
+
|
650
|
+
VALUE intersys_argument_is_by_ref(VALUE self) {
|
651
|
+
struct rbDefinition* argument;
|
652
|
+
Data_Get_Struct(self, struct rbDefinition, argument);
|
653
|
+
return argument->is_by_ref ? Qtrue : Qfalse;
|
654
|
+
}
|
655
|
+
|
656
|
+
|
657
|
+
|
658
|
+
|
659
|
+
|
660
|
+
|
661
|
+
|
data/lib/intersys.c
CHANGED
@@ -1,19 +1,27 @@
|
|
1
1
|
#include "intersys.h"
|
2
2
|
|
3
|
-
VALUE mIntersys, cDatabase, cQuery, cObject, cDefinition, cProperty, cMethod, cArgument
|
4
|
-
VALUE cTime, cMarshallError, cUnMarshallError;
|
3
|
+
VALUE mIntersys, cDatabase, cQuery, cObject, cDefinition, cProperty, cMethod, cArgument;
|
4
|
+
VALUE cTime, cMarshallError, cUnMarshallError, cObjectNotFound, cIntersysException, cStatus;
|
5
5
|
|
6
6
|
void Init_intersys_cache() {
|
7
7
|
rb_define_method(rb_cString, "to_wchar", string_to_wchar, 0);
|
8
8
|
rb_define_method(rb_cString, "from_wchar", string_from_wchar, 0);
|
9
9
|
|
10
|
+
cTime = rb_const_get(rb_cObject, rb_intern("Time"));
|
10
11
|
|
11
12
|
mIntersys = rb_define_module("Intersys");
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
cIntersysException = rb_define_class_under(mIntersys, "IntersysException", rb_eStandardError);
|
14
|
+
cObjectNotFound = rb_define_class_under(mIntersys, "ObjectNotFound", cIntersysException);
|
15
|
+
cMarshallError = rb_define_class_under(mIntersys, "MarshallError", cIntersysException);
|
16
|
+
cUnMarshallError = rb_define_class_under(mIntersys, "UnMarshallError", cIntersysException);
|
17
|
+
|
18
|
+
|
19
|
+
cStatus = rb_define_class_under(mIntersys, "Status", cIntersysException);
|
20
|
+
rb_define_alloc_func(cStatus, intersys_status_s_allocate);
|
21
|
+
rb_define_method(cStatus, "initialize", intersys_status_initialize, 2);
|
22
|
+
rb_define_method(cStatus, "code", intersys_status_code, 0);
|
23
|
+
rb_define_method(cStatus, "message", intersys_status_message, 0);
|
24
|
+
rb_define_method(cStatus, "to_s", intersys_status_to_s, 0);
|
17
25
|
|
18
26
|
|
19
27
|
cDatabase = rb_define_class_under(mIntersys, "Database", rb_cObject);
|
@@ -40,32 +48,46 @@ void Init_intersys_cache() {
|
|
40
48
|
cObject = rb_define_class_under(mIntersys, "Object", rb_cObject);
|
41
49
|
rb_define_alloc_func(cObject, intersys_object_s_allocate);
|
42
50
|
rb_define_method(cObject, "initialize", intersys_object_initialize, 0);
|
43
|
-
rb_define_singleton_method(cObject, "
|
44
|
-
rb_define_singleton_method(cObject, "
|
51
|
+
rb_define_singleton_method(cObject, "create", intersys_object_create, 0);
|
52
|
+
rb_define_singleton_method(cObject, "open", intersys_object_open_by_id, 1);
|
45
53
|
|
46
|
-
cDefinition =
|
54
|
+
cDefinition = rb_define_class_under(mIntersys, "Definition", rb_cObject);
|
47
55
|
rb_define_alloc_func(cDefinition, intersys_definition_s_allocate);
|
48
|
-
rb_define_method(cDefinition, "
|
56
|
+
rb_define_method(cDefinition, "initialize", intersys_definition_initialize, 3);
|
49
57
|
rb_define_method(cDefinition, "cpp_type", intersys_definition_cpp_type, 0);
|
58
|
+
rb_define_method(cDefinition, "cpp_name", intersys_definition_cpp_name, 0);
|
50
59
|
rb_define_method(cDefinition, "cache_type", intersys_definition_cache_type, 0);
|
51
60
|
rb_define_method(cDefinition, "name", intersys_definition_name, 0);
|
52
61
|
rb_define_method(cDefinition, "in_name", intersys_definition_in_name, 0);
|
53
62
|
|
54
|
-
cProperty =
|
63
|
+
cProperty = rb_define_class_under(mIntersys, "Property", cDefinition);
|
55
64
|
rb_define_method(cProperty, "initialize", intersys_property_initialize, 4);
|
56
65
|
rb_define_method(cProperty, "get", intersys_property_get, 0);
|
57
66
|
rb_define_method(cProperty, "set", intersys_property_set, 1);
|
58
67
|
|
59
|
-
cMethod =
|
60
|
-
rb_define_method(cMethod, "
|
68
|
+
cMethod = rb_define_class_under(mIntersys, "Method", cDefinition);
|
69
|
+
rb_define_method(cMethod, "initialize", intersys_method_initialize, 4);
|
61
70
|
rb_define_method(cMethod, "func?", intersys_method_is_func, 0);
|
62
71
|
rb_define_method(cMethod, "class_method?", intersys_method_is_class_method, 0);
|
63
72
|
rb_define_method(cMethod, "num_args", intersys_method_num_args, 0);
|
73
|
+
rb_define_method(cMethod, "each_argument", intersys_method_each_argument, 0);
|
64
74
|
rb_define_method(cMethod, "call!", intersys_method_call, 1);
|
65
75
|
|
66
|
-
cArgument =
|
76
|
+
cArgument = rb_define_class_under(mIntersys, "Argument", cDefinition);
|
67
77
|
rb_define_method(cArgument, "initialize", intersys_argument_initialize, 4);
|
68
78
|
rb_define_method(cArgument, "default", intersys_argument_default_value, 0);
|
69
79
|
rb_define_method(cArgument, "marshall_dlist_element", intersys_argument_marshall_dlist_elem, 1);
|
80
|
+
rb_define_method(cArgument, "marshall_dlist", intersys_argument_marshall_dlist, 1);
|
81
|
+
/*
|
82
|
+
rb_eval_string(
|
83
|
+
"class Argument \n" \
|
84
|
+
"def marshall_dlist(list)\n" \
|
85
|
+
" list.each do |elem|\n" \
|
86
|
+
" marshall_dlist_element(elem)\n" \
|
87
|
+
" end\n" \
|
88
|
+
"end\n" \
|
89
|
+
"end");
|
90
|
+
*/
|
91
|
+
rb_define_method(cArgument, "by_ref?", intersys_argument_is_by_ref, 0);
|
70
92
|
}
|
71
93
|
|
data/lib/intersys.h
CHANGED
@@ -23,6 +23,7 @@ struct rbObject {
|
|
23
23
|
h_database database;
|
24
24
|
int oref;
|
25
25
|
VALUE class_name;
|
26
|
+
bool_t closed;
|
26
27
|
};
|
27
28
|
|
28
29
|
struct rbDefinition {
|
@@ -41,6 +42,7 @@ struct rbDefinition {
|
|
41
42
|
int passed_args;
|
42
43
|
void *args_info;
|
43
44
|
int arg_counter;
|
45
|
+
VALUE object;
|
44
46
|
//Argument definitions
|
45
47
|
bool_t is_by_ref;
|
46
48
|
bool_t is_default;
|
@@ -55,6 +57,11 @@ struct rbDefinition {
|
|
55
57
|
int oref;
|
56
58
|
};
|
57
59
|
|
60
|
+
struct rbStatus {
|
61
|
+
VALUE code;
|
62
|
+
VALUE message;
|
63
|
+
};
|
64
|
+
|
58
65
|
enum { D_PROPERTY, D_METHOD, D_ARGUMENT};
|
59
66
|
|
60
67
|
enum {
|
@@ -74,6 +81,11 @@ VALUE string_from_wchar(VALUE self);
|
|
74
81
|
VALUE rb_wcstr_new(const wchar_t *w_str, const char_size_t len);
|
75
82
|
VALUE rb_wcstr_new2(const wchar_t *w_str);
|
76
83
|
VALUE wcstr_new(const wchar_t *w_str, const char_size_t len);
|
84
|
+
VALUE intersys_status_s_allocate(VALUE klass);
|
85
|
+
VALUE intersys_status_initialize(VALUE self, VALUE code, VALUE message);
|
86
|
+
VALUE intersys_status_code(VALUE self);
|
87
|
+
VALUE intersys_status_message(VALUE self);
|
88
|
+
VALUE intersys_status_to_s(VALUE self);
|
77
89
|
|
78
90
|
/******* Database functions *******/
|
79
91
|
|
@@ -111,19 +123,23 @@ VALUE intersys_object_create(VALUE self);
|
|
111
123
|
VALUE intersys_definition_s_allocate(VALUE klass);
|
112
124
|
VALUE intersys_definition_initialize(VALUE self, VALUE r_database, VALUE class_name, VALUE name);
|
113
125
|
VALUE intersys_definition_cpp_type(VALUE self);
|
126
|
+
VALUE intersys_definition_cpp_name(VALUE self);
|
114
127
|
VALUE intersys_definition_cache_type(VALUE self);
|
115
128
|
VALUE intersys_definition_name(VALUE self);
|
116
129
|
VALUE intersys_definition_in_name(VALUE self);
|
117
130
|
VALUE intersys_property_initialize(VALUE self, VALUE r_database, VALUE class_name, VALUE name, VALUE object);
|
118
131
|
VALUE intersys_property_get(VALUE self);
|
119
132
|
VALUE intersys_property_set(VALUE self, VALUE value);
|
120
|
-
VALUE intersys_method_initialize(VALUE self, VALUE object);
|
133
|
+
VALUE intersys_method_initialize(VALUE self, VALUE r_database, VALUE class_name, VALUE name, VALUE object);
|
121
134
|
VALUE intersys_method_is_func(VALUE self);
|
122
135
|
VALUE intersys_method_is_class_method(VALUE self);
|
123
136
|
VALUE intersys_method_num_args(VALUE self);
|
137
|
+
VALUE intersys_method_each_argument(VALUE self);
|
124
138
|
VALUE intersys_method_call(VALUE self, VALUE args);
|
125
139
|
VALUE intersys_argument_initialize(VALUE self, VALUE r_database, VALUE class_name, VALUE name, VALUE r_method);
|
126
140
|
VALUE intersys_argument_default_value(VALUE self);
|
141
|
+
VALUE intersys_argument_is_by_ref(VALUE self);
|
142
|
+
VALUE intersys_argument_marshall_dlist(VALUE self, VALUE list);
|
127
143
|
VALUE intersys_argument_marshall_dlist_elem(VALUE self, VALUE elem);
|
128
144
|
|
129
145
|
// Private declarations. Not for public use
|
data/lib/intersys.rb
CHANGED
@@ -14,80 +14,99 @@ module Intersys
|
|
14
14
|
rescue
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
class IntersysException < StandardError
|
19
|
-
end
|
20
|
-
|
21
|
-
# Exception, thrown from Object.open method, when no such ID in database
|
22
|
-
class ObjectNotFound < IntersysException
|
23
|
-
end
|
24
|
-
|
25
|
-
# Error of marshalling arguments
|
26
|
-
class MarshallError < IntersysException
|
27
|
-
end
|
17
|
+
require File.dirname(__FILE__) + '/intersys_cache'
|
28
18
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
19
|
+
class Method
|
20
|
+
def description
|
21
|
+
args = []
|
22
|
+
each_argument do |arg|
|
23
|
+
descr = ""
|
24
|
+
descr << "out " if arg.by_ref?
|
25
|
+
descr << "#{arg.cache_type} #{arg.name}"
|
26
|
+
descr << (' = '+arg.default) if arg.default
|
27
|
+
args << descr
|
28
|
+
end
|
29
|
+
"#{cache_type} #{name}("+args.join(', ')+")"
|
30
|
+
end
|
35
31
|
end
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
module Callable
|
34
|
+
# Returns ClassDefinition object for current class
|
35
|
+
def intersys_reflector
|
36
|
+
@reflector ||= Intersys::Reflection::ClassDefinition.open(class_name)
|
37
|
+
end
|
38
|
+
|
39
|
+
# returns list of methods for this class
|
40
|
+
def intersys_methods
|
41
|
+
@methods ||= intersys_reflector._methods
|
44
42
|
end
|
45
|
-
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
# returns list of properties for current class
|
45
|
+
def intersys_properties
|
46
|
+
@properties ||= intersys_reflector.properties
|
47
|
+
end
|
48
|
+
|
49
|
+
#protected
|
50
|
+
# Loads property definition with required name for required object
|
51
|
+
# for internal use only
|
52
|
+
def intersys_property(name)
|
53
|
+
Property.new(database, class_name, name.to_s, self)
|
54
|
+
end
|
51
55
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
@database = database
|
57
|
-
@class_name = class_name
|
58
|
-
@name = name
|
59
|
-
intern_initialize(database, class_name, name)
|
56
|
+
# Loads method definition with required name for required object
|
57
|
+
# for internal use only
|
58
|
+
def intersys_method(name)
|
59
|
+
Method.new(database, class_name, name.to_s, self)
|
60
60
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
# Class representing one object method
|
69
|
-
# for internal use only
|
70
|
-
class Method < Definition
|
71
|
-
def initialize(database, class_name, name, object)
|
72
|
-
super(database, class_name, name.to_s)
|
73
|
-
method_initialize(object)
|
61
|
+
|
62
|
+
public
|
63
|
+
# call class method
|
64
|
+
def intersys_call(method_name, *args)
|
65
|
+
intersys_method(method_name).call!(args)
|
74
66
|
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
67
|
+
alias :call :intersys_call
|
68
|
+
|
69
|
+
def intersys_has_property?(property)
|
70
|
+
self.intersys_reflector.properties.to_a.include?(property)
|
71
|
+
end
|
72
|
+
|
73
|
+
def intersys_has_method?(method)
|
74
|
+
self.intersys_reflector._methods.to_a.include?(method)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Get the specified property
|
78
|
+
def intersys_get(property)
|
79
|
+
intersys_property(property).get
|
80
|
+
end
|
81
|
+
|
82
|
+
# Set the specified property
|
83
|
+
def intersys_set(property, value)
|
84
|
+
intersys_property(property).set(value)
|
85
|
+
end
|
86
|
+
|
87
|
+
def method_missing(method, *args)
|
88
|
+
method_name = method.to_s.camelize
|
89
|
+
if match_data = method_name.match(/intersys_(.*)/)
|
90
|
+
# Protection from errors in this method
|
91
|
+
return super(method, *args)
|
83
92
|
end
|
93
|
+
if match_data = method_name.match(/(\w+)=/)
|
94
|
+
return intersys_set(match_data.captures.first, args.first)
|
95
|
+
end
|
96
|
+
return intersys_get(method_name) if intersys_has_property?(method_name) && args.empty?
|
97
|
+
begin
|
98
|
+
return intersys_call(method_name, *args)
|
99
|
+
rescue NoMethodError => e
|
100
|
+
end
|
101
|
+
begin
|
102
|
+
return intersys_call("%"+method_name, *args)
|
103
|
+
rescue NoMethodError => e
|
104
|
+
end
|
105
|
+
super(method, *args)
|
84
106
|
end
|
107
|
+
|
85
108
|
end
|
86
109
|
|
87
|
-
|
88
|
-
require File.dirname(__FILE__) + '/intersys_cache'
|
89
|
-
|
90
|
-
|
91
110
|
# Basic class for all classes, through which is performed access to Cache classes
|
92
111
|
# For each Cache class must be created ruby class, inherited from Intersys::Object
|
93
112
|
#
|
@@ -133,7 +152,20 @@ module Intersys
|
|
133
152
|
class_names[class_name] = self
|
134
153
|
class_name
|
135
154
|
end
|
136
|
-
|
155
|
+
|
156
|
+
public
|
157
|
+
# Nice function, that generates description of Cache class, looking just as C++ one
|
158
|
+
# Maybe, later, it will be possible even to generate IDL, using this code
|
159
|
+
def intersys_description
|
160
|
+
"class #{class_name} { \n" + intersys_reflector.all_methods.map do |mtd|
|
161
|
+
begin
|
162
|
+
"\t"+intersys_method(mtd).description+";\n"
|
163
|
+
rescue
|
164
|
+
"\tundefined #{mtd}\n"
|
165
|
+
end
|
166
|
+
end.join("") + "};"
|
167
|
+
end
|
168
|
+
|
137
169
|
# Help to work with instance variables of Intersys::Object class
|
138
170
|
# required, because list of registered descendants of Intersys::Object,
|
139
171
|
# database connection etc. should be in one place
|
@@ -158,15 +190,18 @@ module Intersys
|
|
158
190
|
@prefix ||= "User"
|
159
191
|
end
|
160
192
|
|
193
|
+
# Returns Cache class name, if called without parameters, or sets one, if passed
|
161
194
|
def class_name(name = nil)
|
162
195
|
self.class_name = name if name
|
163
196
|
self.class_name = (prefix + "." + to_s) unless @class_name
|
164
197
|
@class_name
|
165
198
|
end
|
166
199
|
|
167
|
-
|
200
|
+
# Returns database, if called without parameters, or sets one, if passed
|
201
|
+
# Once established, it is not possible now to connect to another database
|
202
|
+
def database(db_options = {})
|
168
203
|
common_get_or_set("@database") do
|
169
|
-
|
204
|
+
Intersys::Database.new({:user => "_SYSTEM", :password => "SYS", :namespace => "User"}.merge(db_options))
|
170
205
|
end
|
171
206
|
end
|
172
207
|
|
@@ -186,25 +221,12 @@ module Intersys
|
|
186
221
|
end
|
187
222
|
end
|
188
223
|
|
189
|
-
#
|
190
|
-
def reflector
|
191
|
-
@reflector ||= Intersys::Reflection::ClassDefinition.open(class_name)
|
192
|
-
end
|
193
|
-
|
194
|
-
# returns list of methods for this class
|
195
|
-
def intersys_methods
|
196
|
-
@methods ||= reflector.intersys_get("Methods")
|
197
|
-
end
|
198
|
-
|
199
|
-
# returns list of properties for current class
|
200
|
-
def intersys_properties
|
201
|
-
@properties ||= reflector.properties
|
202
|
-
end
|
203
|
-
|
224
|
+
# :nodoc
|
204
225
|
def inherited(klass)
|
205
226
|
class_names[klass.class_name] = klass
|
206
227
|
end
|
207
228
|
|
229
|
+
# Look into Cache documentation for what is concurrency. I don't know
|
208
230
|
def concurrency
|
209
231
|
1
|
210
232
|
end
|
@@ -214,80 +236,40 @@ module Intersys
|
|
214
236
|
5
|
215
237
|
end
|
216
238
|
|
217
|
-
#
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
# try to load class instance from database for this id
|
223
|
-
# ID can be not integer
|
224
|
-
def open(id)
|
225
|
-
call("%OpenId", id)
|
226
|
-
end
|
227
|
-
|
228
|
-
# Loads property definition with required name for required object
|
229
|
-
# for internal use only
|
230
|
-
def property(name, object)
|
231
|
-
Property.new(database, class_name, name.to_s.to_wchar, object)
|
239
|
+
# Nice method, that deletes all instances of class.
|
240
|
+
# You can just Person.delete_extent, but Person.delete_all looks more like ActiveRecord
|
241
|
+
def delete_all
|
242
|
+
intersys_call("%DeleteExtent")
|
232
243
|
end
|
233
|
-
|
234
|
-
# Loads method definition with required name for required object
|
235
|
-
# for internal use only
|
236
|
-
def method(name, object)
|
237
|
-
Method.new(database, class_name, name.to_s.to_wchar, object)
|
238
|
-
end
|
239
|
-
|
240
|
-
# call class method
|
241
|
-
def call(method_name, *args)
|
242
|
-
method(method_name, nil).call!(args)
|
243
|
-
end
|
244
|
-
alias :intersys_call :call
|
245
|
-
#def self.method_missing(method_name, *args)
|
246
|
-
#end
|
247
244
|
|
248
245
|
end
|
249
246
|
|
250
|
-
#
|
251
|
-
def
|
252
|
-
self.class.
|
253
|
-
end
|
254
|
-
|
255
|
-
# Set the specified property
|
256
|
-
def intersys_set(property, value)
|
257
|
-
self.class.property(property, self).set(value)
|
247
|
+
# You can ask for database from instance
|
248
|
+
def database
|
249
|
+
self.class.database
|
258
250
|
end
|
259
251
|
|
260
|
-
#
|
261
|
-
def
|
262
|
-
self.class.
|
252
|
+
# You can ask from instance it's Cache class name
|
253
|
+
def class_name
|
254
|
+
self.class.class_name
|
263
255
|
end
|
264
256
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
return intersys_call(method_name, *args) if has_method?(method_name)
|
272
|
-
puts "Checking whether %#{method_name} is here: #{self.class.reflector._methods}"
|
273
|
-
return intersys_call("%"+method_name, *args) if has_method?("%"+method_name)
|
274
|
-
super(method, *args)
|
275
|
-
end
|
276
|
-
|
277
|
-
def has_property?(property)
|
278
|
-
self.class.reflector.properties.to_a.include?(property)
|
257
|
+
# Returns id of current object.
|
258
|
+
# You can remove this method and You will get string ID, so leave it here
|
259
|
+
# However, if You ask reflector for id, it will give incorrect answer,
|
260
|
+
# because Cache allows id to be string
|
261
|
+
def id
|
262
|
+
intersys_call("%Id").to_i
|
279
263
|
end
|
280
264
|
|
281
|
-
|
282
|
-
|
265
|
+
# Destroys current object
|
266
|
+
def destroy
|
267
|
+
self.class.intersys_call("%DeleteId", id)
|
283
268
|
end
|
284
269
|
|
285
|
-
|
286
|
-
# Returns id of current object
|
287
|
-
def id
|
288
|
-
intersys_call("%Id").to_i
|
289
|
-
end
|
270
|
+
include Callable
|
290
271
|
end
|
272
|
+
Intersys::Object.extend(Callable)
|
291
273
|
|
292
274
|
# Class representing one query
|
293
275
|
# You shouldn't create it yourself
|
@@ -329,9 +311,9 @@ module Intersys
|
|
329
311
|
def query(query)
|
330
312
|
data = []
|
331
313
|
q = create_query(query).execute.fill(data).close
|
332
|
-
1.upto(data.first.size) do |i|
|
333
|
-
|
334
|
-
end
|
314
|
+
#1.upto(data.first.size) do |i|
|
315
|
+
# puts q.column_name(i)
|
316
|
+
#end
|
335
317
|
data
|
336
318
|
end
|
337
319
|
end
|
@@ -364,6 +346,16 @@ module Intersys
|
|
364
346
|
def properties
|
365
347
|
@properties ||= intersys_get("Properties")
|
366
348
|
end
|
349
|
+
|
350
|
+
def all_methods
|
351
|
+
_methods.to_a + self.super.split(",").map do |klass|
|
352
|
+
klass = klass.strip
|
353
|
+
if match_data = klass.match(/^%([^\.]+)$/)
|
354
|
+
klass = "%Library.#{match_data.captures.first}"
|
355
|
+
end
|
356
|
+
self.class.open(klass).all_methods
|
357
|
+
end.flatten
|
358
|
+
end
|
367
359
|
end
|
368
360
|
|
369
361
|
class PropertyDefinition < Intersys::Object
|
data/lib/object.c
CHANGED
@@ -34,16 +34,17 @@ VALUE intersys_object_open_by_id(VALUE self, VALUE oid) {
|
|
34
34
|
int concurrency = rb_funcall(self, rb_intern("concurrency"), 0);
|
35
35
|
int timeout = rb_funcall(self, rb_intern("timeout"), 0);
|
36
36
|
int error;
|
37
|
+
VALUE id = rb_funcall(oid, rb_intern("to_s"), 0);
|
37
38
|
struct rbObject* object;
|
38
39
|
VALUE r_object = rb_funcall(self, rb_intern("new"), 0);
|
39
40
|
Data_Get_Struct(r_object, struct rbObject, object);
|
40
41
|
|
41
|
-
error = cbind_openid(object->database, CLASS_NAME(object), WCHARSTR(
|
42
|
+
error = cbind_openid(object->database, CLASS_NAME(object), WCHARSTR(TOWCHAR(id)), concurrency, timeout, &object->oref);
|
42
43
|
switch(error) {
|
43
44
|
case 0:
|
44
45
|
return r_object;
|
45
46
|
case -9:
|
46
|
-
rb_raise(cObjectNotFound, "Object with id %s not found",
|
47
|
+
rb_raise(cObjectNotFound, "Object with id %s not found", STR(id));
|
47
48
|
return Qnil;
|
48
49
|
default:
|
49
50
|
RUN(error);
|
@@ -64,4 +65,3 @@ VALUE intersys_object_create(VALUE self) {
|
|
64
65
|
}
|
65
66
|
|
66
67
|
|
67
|
-
|
data/lib/query.c
CHANGED
@@ -7,9 +7,7 @@
|
|
7
7
|
#include <sqlucode.h>
|
8
8
|
|
9
9
|
static void query_close(struct rbQuery* query) {
|
10
|
-
printf("Trying to close query (%d,%d)\n", query->closed, query->executed);
|
11
10
|
if(!query->closed && query->executed) {
|
12
|
-
printf("Closing query\n");
|
13
11
|
RUN(cbind_query_close(query->query));
|
14
12
|
query->closed = 1;
|
15
13
|
}
|
data/lib/test.rb
CHANGED
@@ -5,11 +5,26 @@ end
|
|
5
5
|
|
6
6
|
#puts Person.intersys_methods
|
7
7
|
def my_mtd
|
8
|
-
Intersys::Reflection::ClassDefinition.
|
8
|
+
#Intersys::Reflection::ClassDefinition.intersys_method("%OpenId")
|
9
|
+
Person.intersys_method("%Delete")
|
9
10
|
end
|
10
11
|
def class_mtd
|
11
12
|
my_mtd.class_method?
|
12
13
|
end
|
13
14
|
|
14
15
|
|
15
|
-
Person.intersys_call("%
|
16
|
+
@p = Person.intersys_call("%New")
|
17
|
+
|
18
|
+
require 'profiler'
|
19
|
+
Profiler__::start_profile
|
20
|
+
|
21
|
+
@p.name = "Test user"
|
22
|
+
puts @p.id
|
23
|
+
@p.save
|
24
|
+
puts @p.id
|
25
|
+
@p.destroy
|
26
|
+
|
27
|
+
File.open("desc","w+") {|f| f.write Person.intersys_description }
|
28
|
+
|
29
|
+
Profiler__::stop_profile
|
30
|
+
File.open("profile", "w+") {|f| Profiler__::print_profile(f)}
|
data/test/object.rb
CHANGED
@@ -7,21 +7,26 @@ end
|
|
7
7
|
|
8
8
|
class QueryTest < Test::Unit::TestCase
|
9
9
|
def test_open_and_save
|
10
|
+
Person.database.start
|
10
11
|
@name = "Anni Fyo"
|
11
|
-
@id =
|
12
|
-
#assert Person.
|
12
|
+
@id = 31378
|
13
|
+
#assert Person.populate(1000)
|
13
14
|
assert @p = Person.open(@id)
|
14
15
|
@p.name = @name
|
15
16
|
assert @p.save
|
16
17
|
assert @p = Person.open(@id)
|
17
18
|
assert_equal @name, @p.name
|
18
|
-
assert Person.
|
19
|
+
#assert Person.delete_extent
|
20
|
+
Person.database.rollback
|
19
21
|
end
|
20
22
|
|
21
23
|
def test_create
|
24
|
+
Person.database.start
|
22
25
|
assert @p = Person.intersys_call("%New")
|
23
26
|
@p.name = "Test user"
|
24
27
|
assert @p.save
|
25
|
-
puts @p.id
|
28
|
+
#puts @p.id
|
29
|
+
assert @p.destroy
|
30
|
+
Person.database.rollback
|
26
31
|
end
|
27
32
|
end
|
data/test/query.rb
CHANGED
@@ -1,13 +1,46 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require File.dirname(__FILE__) + '/../lib/intersys'
|
3
3
|
|
4
|
+
class Person < Intersys::Object
|
5
|
+
end
|
6
|
+
|
4
7
|
|
5
8
|
class QueryTest < Test::Unit::TestCase
|
6
9
|
def test_query1
|
7
10
|
return
|
8
11
|
@db = Intersys::Database.new({})
|
9
12
|
|
10
|
-
|
13
|
+
Person.populate(100)
|
14
|
+
@db.start
|
15
|
+
# @data = @db.query("delete from sample.person")
|
16
|
+
@data = @db.query("select Id,name,DOB from sample.person")
|
17
|
+
assert_equal 0, @data.size
|
18
|
+
Person.populate(100)
|
19
|
+
@data = @db.query("select count(Id) from sample.person")
|
20
|
+
assert_equal 100, @data.first.first
|
21
|
+
@data = @db.query("delete from sample.person where %Id > 6")
|
22
|
+
@data = @db.query("select count(Id) from sample.person")
|
23
|
+
assert_equal 6, @data.first.first
|
24
|
+
@data = @db.query("select ID,name from sample.person")
|
25
|
+
@data.each do |row|
|
26
|
+
puts row
|
27
|
+
end
|
11
28
|
assert @data.size > 0
|
29
|
+
@db.rollback
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_select
|
33
|
+
@db = Intersys::Database.new({})
|
34
|
+
assert @db.query("select Id,name,DOB from sample.person")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_alter
|
38
|
+
return
|
39
|
+
@db = Intersys::Database.new({})
|
40
|
+
|
41
|
+
@db.start
|
42
|
+
assert @db.query("alter table sample.person add column DOB1 varchar(255)")
|
43
|
+
assert @db.query("select %Id,name,DOB1 from sample.person")
|
44
|
+
@db.rollback
|
12
45
|
end
|
13
46
|
end
|
data/test/strings.rb
CHANGED
@@ -11,4 +11,12 @@ class StringTest < Test::Unit::TestCase
|
|
11
11
|
def test_to_wchar
|
12
12
|
assert_equal @@wide_string, @@simple_string.to_wchar
|
13
13
|
end
|
14
|
+
|
15
|
+
def test_stress_wide
|
16
|
+
assert_equal @@wide_string, @@wide_string.from_wchar.to_wchar.from_wchar.to_wchar
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_stress
|
20
|
+
assert_equal @@simple_string, @@simple_string.to_wchar.from_wchar.to_wchar.from_wchar
|
21
|
+
end
|
14
22
|
end
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: intersys
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
6
|
+
version: "0.1"
|
7
7
|
date: 2006-09-08 00:00:00 +04:00
|
8
8
|
summary: Intersystems Cache ruby driver
|
9
9
|
require_paths:
|
@@ -33,23 +33,15 @@ files:
|
|
33
33
|
- test/reflection.rb
|
34
34
|
- test/strings.rb
|
35
35
|
- lib/common.c
|
36
|
-
- lib/common.o
|
37
36
|
- lib/database.c
|
38
|
-
- lib/database.o
|
39
37
|
- lib/definition.c
|
40
|
-
- lib/definition.o
|
41
38
|
- lib/extconf.rb
|
42
39
|
- lib/intersys.c
|
43
40
|
- lib/intersys.h
|
44
|
-
- lib/intersys.o
|
45
41
|
- lib/intersys.rb
|
46
|
-
- lib/intersys_cache.bundle
|
47
42
|
- lib/Makefile
|
48
|
-
- lib/mkmf.log
|
49
43
|
- lib/object.c
|
50
|
-
- lib/object.o
|
51
44
|
- lib/query.c
|
52
|
-
- lib/query.o
|
53
45
|
- lib/test.rb
|
54
46
|
- README
|
55
47
|
test_files: []
|
@@ -57,6 +49,7 @@ test_files: []
|
|
57
49
|
rdoc_options:
|
58
50
|
- --main=README
|
59
51
|
- --line-numbers
|
52
|
+
- --webcvs=http://svn.maxidoors.ru/cache-ruby
|
60
53
|
- --charset=utf-8
|
61
54
|
- --promiscuous
|
62
55
|
extra_rdoc_files:
|
data/lib/common.o
DELETED
Binary file
|
data/lib/database.o
DELETED
Binary file
|
data/lib/definition.o
DELETED
Binary file
|
data/lib/intersys.o
DELETED
Binary file
|
data/lib/intersys_cache.bundle
DELETED
Binary file
|
data/lib/mkmf.log
DELETED
@@ -1,177 +0,0 @@
|
|
1
|
-
find_header: checking for c_api.h... -------------------- yes
|
2
|
-
|
3
|
-
"gcc -E -I. -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common conftest.c -o conftest.i"
|
4
|
-
conftest.c:1:19: error: c_api.h: No such file or directory
|
5
|
-
checked program was:
|
6
|
-
/* begin */
|
7
|
-
#include <c_api.h>
|
8
|
-
/* end */
|
9
|
-
|
10
|
-
"gcc -E -I. -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include conftest.c -o conftest.i"
|
11
|
-
checked program was:
|
12
|
-
/* begin */
|
13
|
-
#include <c_api.h>
|
14
|
-
/* end */
|
15
|
-
|
16
|
-
--------------------
|
17
|
-
|
18
|
-
find_library: checking for cbind_alloc_db() in -lcbind... -------------------- no
|
19
|
-
|
20
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
21
|
-
conftest.c: In function ‘t’:
|
22
|
-
conftest.c:4: warning: implicit declaration of function ‘cbind_alloc_db’
|
23
|
-
/usr/bin/ld: can't locate file for: -lcbind
|
24
|
-
collect2: ld returned 1 exit status
|
25
|
-
checked program was:
|
26
|
-
/* begin */
|
27
|
-
|
28
|
-
/*top*/
|
29
|
-
int main() { return 0; }
|
30
|
-
int t() { cbind_alloc_db(); return 0; }
|
31
|
-
/* end */
|
32
|
-
|
33
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
34
|
-
conftest.c: In function ‘t’:
|
35
|
-
conftest.c:5: error: ‘cbind_alloc_db’ undeclared (first use in this function)
|
36
|
-
conftest.c:5: error: (Each undeclared identifier is reported only once
|
37
|
-
conftest.c:5: error: for each function it appears in.)
|
38
|
-
checked program was:
|
39
|
-
/* begin */
|
40
|
-
|
41
|
-
|
42
|
-
/*top*/
|
43
|
-
int main() { return 0; }
|
44
|
-
int t() { void ((*volatile p)()); p = (void ((*)()))cbind_alloc_db; return 0; }
|
45
|
-
/* end */
|
46
|
-
|
47
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
48
|
-
/usr/bin/ld: can't locate file for: -lcbind
|
49
|
-
collect2: ld returned 1 exit status
|
50
|
-
checked program was:
|
51
|
-
/* begin */
|
52
|
-
int cbind_alloc_db();
|
53
|
-
/*top*/
|
54
|
-
int main() { return 0; }
|
55
|
-
int t() { cbind_alloc_db(); return 0; }
|
56
|
-
/* end */
|
57
|
-
|
58
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L"/Applications/Cache/dev/cpp/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
59
|
-
conftest.c: In function ‘t’:
|
60
|
-
conftest.c:4: warning: implicit declaration of function ‘cbind_alloc_db’
|
61
|
-
/usr/bin/ld: can't locate file for: -lcbind
|
62
|
-
collect2: ld returned 1 exit status
|
63
|
-
checked program was:
|
64
|
-
/* begin */
|
65
|
-
|
66
|
-
/*top*/
|
67
|
-
int main() { return 0; }
|
68
|
-
int t() { cbind_alloc_db(); return 0; }
|
69
|
-
/* end */
|
70
|
-
|
71
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L"/Applications/Cache/dev/cpp/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
72
|
-
conftest.c: In function ‘t’:
|
73
|
-
conftest.c:5: error: ‘cbind_alloc_db’ undeclared (first use in this function)
|
74
|
-
conftest.c:5: error: (Each undeclared identifier is reported only once
|
75
|
-
conftest.c:5: error: for each function it appears in.)
|
76
|
-
checked program was:
|
77
|
-
/* begin */
|
78
|
-
|
79
|
-
|
80
|
-
/*top*/
|
81
|
-
int main() { return 0; }
|
82
|
-
int t() { void ((*volatile p)()); p = (void ((*)()))cbind_alloc_db; return 0; }
|
83
|
-
/* end */
|
84
|
-
|
85
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L"/Applications/Cache/dev/cpp/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
86
|
-
/usr/bin/ld: can't locate file for: -lcbind
|
87
|
-
collect2: ld returned 1 exit status
|
88
|
-
checked program was:
|
89
|
-
/* begin */
|
90
|
-
int cbind_alloc_db();
|
91
|
-
/*top*/
|
92
|
-
int main() { return 0; }
|
93
|
-
int t() { cbind_alloc_db(); return 0; }
|
94
|
-
/* end */
|
95
|
-
|
96
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L"/cygdrive/c/Progra~1/Cache/dev/cpp/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
97
|
-
conftest.c: In function ‘t’:
|
98
|
-
conftest.c:4: warning: implicit declaration of function ‘cbind_alloc_db’
|
99
|
-
/usr/bin/ld: warning -L: directory name (/cygdrive/c/Progra~1/Cache/dev/cpp/lib) does not exist
|
100
|
-
/usr/bin/ld: can't locate file for: -lcbind
|
101
|
-
collect2: ld returned 1 exit status
|
102
|
-
checked program was:
|
103
|
-
/* begin */
|
104
|
-
|
105
|
-
/*top*/
|
106
|
-
int main() { return 0; }
|
107
|
-
int t() { cbind_alloc_db(); return 0; }
|
108
|
-
/* end */
|
109
|
-
|
110
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L"/cygdrive/c/Progra~1/Cache/dev/cpp/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
111
|
-
conftest.c: In function ‘t’:
|
112
|
-
conftest.c:5: error: ‘cbind_alloc_db’ undeclared (first use in this function)
|
113
|
-
conftest.c:5: error: (Each undeclared identifier is reported only once
|
114
|
-
conftest.c:5: error: for each function it appears in.)
|
115
|
-
checked program was:
|
116
|
-
/* begin */
|
117
|
-
|
118
|
-
|
119
|
-
/*top*/
|
120
|
-
int main() { return 0; }
|
121
|
-
int t() { void ((*volatile p)()); p = (void ((*)()))cbind_alloc_db; return 0; }
|
122
|
-
/* end */
|
123
|
-
|
124
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L"/cygdrive/c/Progra~1/Cache/dev/cpp/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
125
|
-
/usr/bin/ld: warning -L: directory name (/cygdrive/c/Progra~1/Cache/dev/cpp/lib) does not exist
|
126
|
-
/usr/bin/ld: can't locate file for: -lcbind
|
127
|
-
collect2: ld returned 1 exit status
|
128
|
-
checked program was:
|
129
|
-
/* begin */
|
130
|
-
int cbind_alloc_db();
|
131
|
-
/*top*/
|
132
|
-
int main() { return 0; }
|
133
|
-
int t() { cbind_alloc_db(); return 0; }
|
134
|
-
/* end */
|
135
|
-
|
136
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L"/cygdrive/c/Cachesys/dev/cpp/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
137
|
-
conftest.c: In function ‘t’:
|
138
|
-
conftest.c:4: warning: implicit declaration of function ‘cbind_alloc_db’
|
139
|
-
/usr/bin/ld: warning -L: directory name (/cygdrive/c/Cachesys/dev/cpp/lib) does not exist
|
140
|
-
/usr/bin/ld: can't locate file for: -lcbind
|
141
|
-
collect2: ld returned 1 exit status
|
142
|
-
checked program was:
|
143
|
-
/* begin */
|
144
|
-
|
145
|
-
/*top*/
|
146
|
-
int main() { return 0; }
|
147
|
-
int t() { cbind_alloc_db(); return 0; }
|
148
|
-
/* end */
|
149
|
-
|
150
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L"/cygdrive/c/Cachesys/dev/cpp/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
151
|
-
conftest.c: In function ‘t’:
|
152
|
-
conftest.c:5: error: ‘cbind_alloc_db’ undeclared (first use in this function)
|
153
|
-
conftest.c:5: error: (Each undeclared identifier is reported only once
|
154
|
-
conftest.c:5: error: for each function it appears in.)
|
155
|
-
checked program was:
|
156
|
-
/* begin */
|
157
|
-
|
158
|
-
|
159
|
-
/*top*/
|
160
|
-
int main() { return 0; }
|
161
|
-
int t() { void ((*volatile p)()); p = (void ((*)()))cbind_alloc_db; return 0; }
|
162
|
-
/* end */
|
163
|
-
|
164
|
-
"gcc -g -o conftest -I. -I/Applications/Cache/dev/cpp/include -I/opt/local/lib/ruby/1.8/powerpc-darwin8.4.0 -O -pipe -I/opt/local/include -O -pipe -I/opt/local/include -fno-common -pipe -fno-common -I/Applications/Cache/dev/cpp/include -I/cygdrive/c/Progra~1/Cache/dev/cpp/include -I/cygdrive/c/Cachesys/dev/cpp/include -Wall conftest.c -L"/opt/local/lib" -L"/cygdrive/c/Cachesys/dev/cpp/lib" -L/opt/local/lib -lruby-static -lcbind -lpthread -ldl -lobjc "
|
165
|
-
/usr/bin/ld: warning -L: directory name (/cygdrive/c/Cachesys/dev/cpp/lib) does not exist
|
166
|
-
/usr/bin/ld: can't locate file for: -lcbind
|
167
|
-
collect2: ld returned 1 exit status
|
168
|
-
checked program was:
|
169
|
-
/* begin */
|
170
|
-
int cbind_alloc_db();
|
171
|
-
/*top*/
|
172
|
-
int main() { return 0; }
|
173
|
-
int t() { cbind_alloc_db(); return 0; }
|
174
|
-
/* end */
|
175
|
-
|
176
|
-
--------------------
|
177
|
-
|
data/lib/object.o
DELETED
Binary file
|
data/lib/query.o
DELETED
Binary file
|