intersys 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/Makefile +2 -2
- data/lib/common.c +11 -10
- data/lib/database.c +1 -1
- data/lib/definition.c +7 -6
- data/lib/extconf.rb +14 -8
- data/lib/intersys.h +7 -0
- data/lib/object.c +1 -1
- data/lib/poppack.h +0 -0
- data/lib/pshpack1.h +0 -0
- metadata +3 -1
data/lib/Makefile
CHANGED
@@ -75,8 +75,8 @@ extout_prefix =
|
|
75
75
|
target_prefix =
|
76
76
|
LOCAL_LIBS =
|
77
77
|
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lobjc
|
78
|
-
SRCS = common.c database.c definition.c intersys.c object.c query.c
|
79
|
-
OBJS = common.o database.o definition.o intersys.o object.o query.o
|
78
|
+
SRCS = common.c database.c definition.c global.c intersys.c object.c query.c
|
79
|
+
OBJS = common.o database.o definition.o global.o intersys.o object.o query.o
|
80
80
|
TARGET = intersys_cache
|
81
81
|
DLLIB = $(TARGET).bundle
|
82
82
|
STATIC_LIB =
|
data/lib/common.c
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
#include "intersys.h"
|
2
2
|
|
3
3
|
VALUE string_to_wchar(VALUE self) {
|
4
|
-
|
4
|
+
VALUE result;
|
5
5
|
int size;
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
result = rb_str_buf_new((LEN(self)+1)*sizeof(wchar_t));
|
7
|
+
RUN(cbind_utf8_to_uni(STR(self), (byte_size_t)LEN(self), WCHARSTR(result), (char_size_t)sizeof(wchar_t)*LEN(self), &size));
|
8
|
+
WCHARSTR(result)[size] = 0;
|
9
|
+
return result;
|
9
10
|
}
|
10
11
|
|
11
12
|
VALUE string_from_wchar(VALUE self) {
|
12
|
-
|
13
|
-
bzero(chars, sizeof(chars));
|
13
|
+
VALUE result;
|
14
14
|
int size;
|
15
15
|
if(LEN(self) == 0 || !STR(self)) {
|
16
16
|
return rb_str_new2("");
|
17
17
|
}
|
18
|
-
|
19
|
-
|
18
|
+
result = rb_str_buf_new(LEN(self));
|
19
|
+
RUN(cbind_uni_to_utf8(WCHARSTR(self), wcslen(WCHARSTR(self)), STR(result), LEN(result), &size));
|
20
|
+
return result;
|
20
21
|
}
|
21
22
|
|
22
23
|
|
@@ -37,7 +38,7 @@ VALUE wcstr_new(const wchar_t *w_str, const char_size_t len) {
|
|
37
38
|
capa = (int)(len + 1)*sizeof(wchar_t);
|
38
39
|
|
39
40
|
result = rb_str_buf_new(capa);
|
40
|
-
|
41
|
+
memset(STR(result) + size, 0, capa-size);
|
41
42
|
rb_str_buf_cat(result, (char *)w_str, size);
|
42
43
|
|
43
44
|
rb_str_freeze(result);
|
@@ -58,7 +59,7 @@ static void intersys_status_mark(struct rbStatus* status) {
|
|
58
59
|
|
59
60
|
VALUE intersys_status_s_allocate(VALUE klass) {
|
60
61
|
struct rbStatus* status = ALLOC(struct rbStatus);
|
61
|
-
|
62
|
+
memset(status, 0, sizeof(struct rbStatus));
|
62
63
|
return Data_Wrap_Struct(klass, intersys_status_mark, 0, status);
|
63
64
|
}
|
64
65
|
|
data/lib/database.c
CHANGED
@@ -15,7 +15,7 @@ void intersys_base_free(struct rbDatabase* base) {
|
|
15
15
|
|
16
16
|
VALUE intersys_base_s_allocate(VALUE klass) {
|
17
17
|
struct rbDatabase* intersys_base = ALLOC(struct rbDatabase);
|
18
|
-
|
18
|
+
memset(intersys_base, 0, sizeof(struct rbDatabase));
|
19
19
|
return Data_Wrap_Struct(klass, 0, intersys_base_free, intersys_base);
|
20
20
|
}
|
21
21
|
|
data/lib/definition.c
CHANGED
@@ -28,7 +28,7 @@ static void intersys_definition_mark(struct rbDefinition* definition) {
|
|
28
28
|
|
29
29
|
VALUE intersys_definition_s_allocate(VALUE klass) {
|
30
30
|
struct rbDefinition* definition = ALLOC(struct rbDefinition);
|
31
|
-
|
31
|
+
memset(definition, 0, sizeof(struct rbDefinition));
|
32
32
|
definition->object = Qnil;
|
33
33
|
return Data_Wrap_Struct(klass, intersys_definition_mark, intersys_definition_free, definition);
|
34
34
|
}
|
@@ -243,14 +243,15 @@ static VALUE extract_next_dlist_elem(char *dlist, int* elem_size) {
|
|
243
243
|
VALUE intersys_method_call(VALUE self, VALUE args) {
|
244
244
|
struct rbDefinition* method;
|
245
245
|
int i;
|
246
|
+
VALUE database = rb_iv_get(self, "@database");
|
247
|
+
VALUE class_name = rb_iv_get(self, "@class_name");
|
248
|
+
VALUE name = rb_iv_get(self, "@name");
|
249
|
+
|
246
250
|
Check_Type(args, T_ARRAY);
|
247
251
|
Data_Get_Struct(self, struct rbDefinition, method);
|
248
252
|
if(RARRAY(args)->len > method->num_args) {
|
249
253
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", RARRAY(args)->len, method->num_args);
|
250
254
|
}
|
251
|
-
VALUE database = rb_iv_get(self, "@database");
|
252
|
-
VALUE class_name = rb_iv_get(self, "@class_name");
|
253
|
-
VALUE name = rb_iv_get(self, "@name");
|
254
255
|
|
255
256
|
RUN(cbind_reset_args(method->database));
|
256
257
|
RUN(cbind_mtd_rewind_args(method->def));
|
@@ -447,7 +448,7 @@ VALUE intersys_method_extract_retval(VALUE self) {
|
|
447
448
|
//It is important to add wchar_t to end, because for wcslen we need more than 1 terminating zero.
|
448
449
|
//I don't know exactly, how works wcslen, but I add 4 (sizeof wchar_t) terminating zeroes
|
449
450
|
result = rb_str_buf_new(size + sizeof(wchar_t));
|
450
|
-
|
451
|
+
memset(STR(result) + size, 0, sizeof(wchar_t));
|
451
452
|
RUN(cbind_get_arg_as_str(method->database, method->passed_args, STR(result), size, CPP_UNICODE, &size, &is_null));
|
452
453
|
LEN(result) = size;
|
453
454
|
return FROMWCHAR(result);
|
@@ -495,8 +496,8 @@ VALUE intersys_method_extract_retval(VALUE self) {
|
|
495
496
|
|
496
497
|
VALUE intersys_argument_marshall_dlist_elem(VALUE self, VALUE elem) {
|
497
498
|
struct rbDefinition* argument;
|
498
|
-
Data_Get_Struct(self, struct rbDefinition, argument);
|
499
499
|
int elem_size;
|
500
|
+
Data_Get_Struct(self, struct rbDefinition, argument);
|
500
501
|
|
501
502
|
switch(TYPE(elem)) {
|
502
503
|
case T_NIL: {
|
data/lib/extconf.rb
CHANGED
@@ -18,7 +18,8 @@ MACOS = RUBY_PLATFORM.match(/darwin/)
|
|
18
18
|
@cache_placements = ["/home/max/cache", "/Applications/Cache", "/cygdrive/c/Progra~1/Cache", "/cygdrive/c/Cachesys", "C:/Cachesys"]
|
19
19
|
|
20
20
|
def locations(suffix)
|
21
|
-
|
21
|
+
# .map{|place| place.split("/").join(WIN32 ? "\\" : "/")}
|
22
|
+
@cache_placements.map {|place| place + suffix }
|
22
23
|
end
|
23
24
|
|
24
25
|
def include_locations
|
@@ -35,23 +36,27 @@ def include_flags
|
|
35
36
|
end
|
36
37
|
|
37
38
|
if WIN32
|
38
|
-
$CFLAGS << ' -I"C:\\Program Files\\Microsoft
|
39
|
-
$CFLAGS << ' -I"C:\\Program Files\\Microsoft
|
40
|
-
$
|
41
|
-
$LDFLAGS << ' -libpath:"C
|
42
|
-
$LDFLAGS << ' -libpath:"C
|
39
|
+
$CFLAGS << ' -I"C:\\Program Files\\Microsoft Platform SDK\\Include\\crt" '
|
40
|
+
$CFLAGS << ' -I"C:\\Program Files\\Microsoft Platform SDK\\Include" '
|
41
|
+
$CFLAGS << ' -I"C:\\Program Files\\Microsoft Visual Studio 8\\VC\\include" -D_WIN32 '
|
42
|
+
$LDFLAGS << ' /link -libpath:"C:/CacheSys/dev/cpp/lib" '
|
43
|
+
$LDFLAGS << ' -libpath:"C:/Program Files/Microsoft Visual Studio 8/VC/lib" '
|
44
|
+
$LDFLAGS << ' -libpath:"C:/Program Files/Microsoft Platform SDK/Lib" '
|
43
45
|
end
|
44
46
|
|
45
47
|
|
46
48
|
def link_flags
|
47
|
-
" "+(library_locations.map { |place| "-L"+place} + ["-Wall"]).join(" ")
|
49
|
+
" "+(library_locations.map { |place| WIN32 ? "-libpath:\"#{place}\"" : ("-L"+place)} + ["-Wall"]).join(" ")
|
48
50
|
end
|
49
51
|
|
50
52
|
$CFLAGS << include_flags
|
51
53
|
$LDFLAGS << link_flags
|
52
54
|
|
53
55
|
have_header "c_api.h"
|
54
|
-
have_header "sql.h"
|
56
|
+
unless have_header "sql.h"
|
57
|
+
$CFLAGS << ' -Isql_include '
|
58
|
+
have_header "sql.h"
|
59
|
+
end
|
55
60
|
have_header "sqlext.h"
|
56
61
|
|
57
62
|
unless MACOS
|
@@ -61,3 +66,4 @@ end
|
|
61
66
|
|
62
67
|
create_makefile 'intersys_cache'
|
63
68
|
|
69
|
+
|
data/lib/intersys.h
CHANGED
@@ -7,6 +7,13 @@
|
|
7
7
|
#include <time.h>
|
8
8
|
#include <c_api.h>
|
9
9
|
|
10
|
+
#ifdef _WIN32
|
11
|
+
#ifndef _WCHAR_T_DEFINED
|
12
|
+
typedef unsigned short wchar_t;
|
13
|
+
#define _WCHAR_T_DEFINED
|
14
|
+
#endif
|
15
|
+
#endif /* WIN32 */
|
16
|
+
|
10
17
|
struct rbDatabase {
|
11
18
|
h_connection connection;
|
12
19
|
h_database database;
|
data/lib/object.c
CHANGED
@@ -15,7 +15,7 @@ static void intersys_object_mark(struct rbObject* object) {
|
|
15
15
|
|
16
16
|
VALUE intersys_object_s_allocate(VALUE klass) {
|
17
17
|
struct rbObject* object = ALLOC(struct rbObject);
|
18
|
-
|
18
|
+
memset(object, 0, sizeof(struct rbObject));
|
19
19
|
return Data_Wrap_Struct(klass, intersys_object_mark, intersys_object_free, object);
|
20
20
|
}
|
21
21
|
|
data/lib/poppack.h
ADDED
File without changes
|
data/lib/pshpack1.h
ADDED
File without changes
|
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:
|
6
|
+
version: 0.2.1
|
7
7
|
date: 2006-09-16 00:00:00 +04:00
|
8
8
|
summary: Intersystems Cache ruby driver
|
9
9
|
require_paths:
|
@@ -47,6 +47,8 @@ files:
|
|
47
47
|
- lib/Makefile
|
48
48
|
- lib/object.c
|
49
49
|
- lib/object.rb
|
50
|
+
- lib/poppack.h
|
51
|
+
- lib/pshpack1.h
|
50
52
|
- lib/query.c
|
51
53
|
- lib/reflection.rb
|
52
54
|
- lib/sql_include
|