globegit-postgresql-plruby 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/Changes +121 -0
  2. data/README.markdown +155 -0
  3. data/Rakefile +48 -0
  4. data/docs/plruby.rb +1931 -0
  5. data/ex_trans.sql +33 -0
  6. data/extconf.rb +267 -0
  7. data/plruby.html +1454 -0
  8. data/plruby.rd +1571 -0
  9. data/postgresql-plruby.gemspec +56 -0
  10. data/src/conversions.h +5 -0
  11. data/src/conversions/basic/conversions.h +25 -0
  12. data/src/conversions/basic/extconf.rb +8 -0
  13. data/src/conversions/basic/plruby_basic.c +357 -0
  14. data/src/conversions/bitstring/bitstring.sql +75 -0
  15. data/src/conversions/bitstring/conversions.h +15 -0
  16. data/src/conversions/bitstring/extconf.rb +8 -0
  17. data/src/conversions/bitstring/plruby_bitstring.c +579 -0
  18. data/src/conversions/convcommon.h +129 -0
  19. data/src/conversions/datetime/conversions.h +13 -0
  20. data/src/conversions/datetime/extconf.rb +8 -0
  21. data/src/conversions/datetime/plruby_datetime.c +269 -0
  22. data/src/conversions/geometry/conversions.h +37 -0
  23. data/src/conversions/geometry/extconf.rb +8 -0
  24. data/src/conversions/geometry/geometry.sql +196 -0
  25. data/src/conversions/geometry/plruby_geometry.c +2494 -0
  26. data/src/conversions/network/conversions.h +21 -0
  27. data/src/conversions/network/extconf.rb +8 -0
  28. data/src/conversions/network/network.sql +63 -0
  29. data/src/conversions/network/plruby_network.c +537 -0
  30. data/src/package.h +20 -0
  31. data/src/plpl.c +1708 -0
  32. data/src/plplan.c +893 -0
  33. data/src/plruby.c +1676 -0
  34. data/src/plruby.h +324 -0
  35. data/src/pltrans.c +388 -0
  36. data/test/conv_bitstring/b.rb +45 -0
  37. data/test/conv_bitstring/runtest +26 -0
  38. data/test/conv_bitstring/test.expected.73 +148 -0
  39. data/test/conv_bitstring/test.expected.74 +148 -0
  40. data/test/conv_bitstring/test.expected.80 +148 -0
  41. data/test/conv_bitstring/test.expected.81 +148 -0
  42. data/test/conv_bitstring/test.expected.82 +148 -0
  43. data/test/conv_bitstring/test.expected.83 +148 -0
  44. data/test/conv_bitstring/test.expected.84 +148 -0
  45. data/test/conv_bitstring/test.out +148 -0
  46. data/test/conv_bitstring/test_mklang.sql +8 -0
  47. data/test/conv_bitstring/test_queries.sql +63 -0
  48. data/test/conv_bitstring/test_queries.sql.in +63 -0
  49. data/test/conv_geometry/b.rb +45 -0
  50. data/test/conv_geometry/runtest +26 -0
  51. data/test/conv_geometry/test.expected.73 +265 -0
  52. data/test/conv_geometry/test.expected.74 +265 -0
  53. data/test/conv_geometry/test.expected.80 +265 -0
  54. data/test/conv_geometry/test.expected.81 +265 -0
  55. data/test/conv_geometry/test.expected.82 +265 -0
  56. data/test/conv_geometry/test.expected.83 +265 -0
  57. data/test/conv_geometry/test.expected.84 +265 -0
  58. data/test/conv_geometry/test.out +265 -0
  59. data/test/conv_geometry/test_mklang.sql +8 -0
  60. data/test/conv_geometry/test_queries.sql +194 -0
  61. data/test/conv_geometry/test_queries.sql.in +194 -0
  62. data/test/conv_network/b.rb +45 -0
  63. data/test/conv_network/runtest +26 -0
  64. data/test/conv_network/test.expected.73 +213 -0
  65. data/test/conv_network/test.expected.74 +237 -0
  66. data/test/conv_network/test.expected.80 +237 -0
  67. data/test/conv_network/test.expected.81 +237 -0
  68. data/test/conv_network/test.expected.82 +237 -0
  69. data/test/conv_network/test.expected.83 +237 -0
  70. data/test/conv_network/test.expected.84 +237 -0
  71. data/test/conv_network/test.out +237 -0
  72. data/test/conv_network/test_mklang.sql +8 -0
  73. data/test/conv_network/test_queries.sql +60 -0
  74. data/test/conv_network/test_queries.sql.in +60 -0
  75. data/test/plp/b.rb +34 -0
  76. data/test/plp/runtest +29 -0
  77. data/test/plp/test.expected.73 +472 -0
  78. data/test/plp/test.expected.74 +472 -0
  79. data/test/plp/test.expected.75 +472 -0
  80. data/test/plp/test.expected.80 +472 -0
  81. data/test/plp/test.expected.81 +472 -0
  82. data/test/plp/test.expected.82 +472 -0
  83. data/test/plp/test.expected.83 +472 -0
  84. data/test/plp/test.expected.84 +472 -0
  85. data/test/plp/test.out +472 -0
  86. data/test/plp/test_mklang.sql +8 -0
  87. data/test/plp/test_queries.sql +273 -0
  88. data/test/plp/test_setup.sql +931 -0
  89. data/test/plp/test_setup.sql.in +931 -0
  90. data/test/plt/b.rb +34 -0
  91. data/test/plt/runtest +29 -0
  92. data/test/plt/test.expected.73 +178 -0
  93. data/test/plt/test.expected.74 +178 -0
  94. data/test/plt/test.expected.75 +178 -0
  95. data/test/plt/test.expected.80 +178 -0
  96. data/test/plt/test.expected.81 +178 -0
  97. data/test/plt/test.expected.82 +178 -0
  98. data/test/plt/test.expected.83 +164 -0
  99. data/test/plt/test.expected.84 +168 -0
  100. data/test/plt/test.out +168 -0
  101. data/test/plt/test_mklang.sql +8 -0
  102. data/test/plt/test_queries.sql +72 -0
  103. data/test/plt/test_setup.sql +252 -0
  104. data/test/plt/test_setup.sql.in +252 -0
  105. data/test/range/b.rb +45 -0
  106. data/test/range/runtest +26 -0
  107. data/test/range/test.expected.73 +396 -0
  108. data/test/range/test.expected.73.in +396 -0
  109. data/test/range/test.expected.74 +396 -0
  110. data/test/range/test.expected.74.in +396 -0
  111. data/test/range/test.expected.75 +396 -0
  112. data/test/range/test.expected.75.in +396 -0
  113. data/test/range/test.expected.80 +396 -0
  114. data/test/range/test.expected.81 +397 -0
  115. data/test/range/test.expected.82 +397 -0
  116. data/test/range/test.expected.83 +397 -0
  117. data/test/range/test.expected.84 +399 -0
  118. data/test/range/test.out +399 -0
  119. data/test/range/test_mklang.sql +8 -0
  120. data/test/range/test_queries.sql +249 -0
  121. data/test/range/test_queries.sql.in +249 -0
  122. metadata +207 -0
@@ -0,0 +1,129 @@
1
+ #include "package.h"
2
+
3
+ #include <postgres.h>
4
+ #include <catalog/pg_type.h>
5
+ #include <utils/builtins.h>
6
+ #include <lib/stringinfo.h>
7
+ #include "package.h"
8
+ #include <ruby.h>
9
+ #include "package.h"
10
+
11
+ #define CPY_FREE(p0_, p1_, size_) do { \
12
+ void *p2_ = (void *)p1_; \
13
+ memcpy((p0_), (p2_), (size_)); \
14
+ pfree(p2_); \
15
+ } while (0)
16
+
17
+ #if PG_PL_VERSION >= 74
18
+
19
+ #define PL_MDUMP(name_,func_) \
20
+ static VALUE \
21
+ name_(int argc, VALUE *argv, VALUE obj) \
22
+ { \
23
+ void *mac; \
24
+ char *res; \
25
+ VALUE result; \
26
+ \
27
+ Data_Get_Struct(obj, void, mac); \
28
+ res = (char *)PLRUBY_DFC1(func_, mac); \
29
+ result = rb_tainted_str_new(VARDATA(res), VARSIZE(res)); \
30
+ pfree(res); \
31
+ return result; \
32
+ }
33
+
34
+ #define PL_MLOAD(name_,func_,type_) \
35
+ static VALUE \
36
+ name_(VALUE obj, VALUE a) \
37
+ { \
38
+ StringInfoData si; \
39
+ type_ *mac0, *mac1; \
40
+ \
41
+ if (TYPE(a) != T_STRING || !RSTRING_LEN(a)) { \
42
+ rb_raise(rb_eArgError, "expected a String object"); \
43
+ } \
44
+ initStringInfo(&si); \
45
+ appendBinaryStringInfo(&si, RSTRING_PTR(a), RSTRING_LEN(a)); \
46
+ mac1 = (type_ *)PLRUBY_DFC1(func_, &si); \
47
+ pfree(si.data); \
48
+ Data_Get_Struct(obj, type_, mac0); \
49
+ CPY_FREE(mac0, mac1, sizeof(type_)); \
50
+ return obj; \
51
+ }
52
+
53
+ #define PL_MLOADVAR(name_,func_,type_,size_) \
54
+ static VALUE \
55
+ name_(VALUE obj, VALUE a) \
56
+ { \
57
+ StringInfoData si; \
58
+ type_ *mac0, *mac1; \
59
+ int szl; \
60
+ \
61
+ if (TYPE(a) != T_STRING || !RSTRING_LEN(a)) { \
62
+ rb_raise(rb_eArgError, "expected a String object"); \
63
+ } \
64
+ initStringInfo(&si); \
65
+ appendBinaryStringInfo(&si, RSTRING_PTR(a), RSTRING_LEN(a)); \
66
+ mac1 = (type_ *)PLRUBY_DFC1(func_, &si); \
67
+ pfree(si.data); \
68
+ Data_Get_Struct(obj, type_, mac0); \
69
+ free(mac0); \
70
+ szl = size_(mac1); \
71
+ mac0 = (type_ *)ALLOC_N(char, szl); \
72
+ CPY_FREE(mac0, mac1, szl); \
73
+ RDATA(obj)->data = mac0; \
74
+ return obj; \
75
+ }
76
+
77
+ #ifndef RUBY_CAN_USE_MARSHAL_LOAD
78
+ extern VALUE plruby_s_load _((VALUE, VALUE));
79
+ #endif
80
+
81
+ #else
82
+
83
+ #define PL_MDUMP(name_,func_)
84
+ #define PL_MLOAD(name_,func_,type_)
85
+ #define PL_MLOADVAR(name_,func_,type_,size_)
86
+
87
+ #endif
88
+
89
+ extern VALUE plruby_to_s _((VALUE));
90
+ extern VALUE plruby_s_new _((int, VALUE *, VALUE));
91
+ extern VALUE plruby_define_void_class _((char *, char *));
92
+ #ifndef HAVE_RB_INITIALIZE_COPY
93
+ extern VALUE plruby_clone _((VALUE));
94
+ #endif
95
+ extern Oid plruby_datum_oid _((VALUE, int *));
96
+ extern VALUE plruby_datum_set _((VALUE, Datum));
97
+ extern VALUE plruby_datum_get _((VALUE, Oid *));
98
+
99
+ #ifndef StringValuePtr
100
+ #define StringValuePtr(x) STR2CSTR(x)
101
+ #endif
102
+
103
+ #ifndef RSTRING_PTR
104
+ # define RSTRING_PTR(x_) RSTRING(x_)->ptr
105
+ # define RSTRING_LEN(x_) RSTRING(x_)->len
106
+ #endif
107
+
108
+ #ifndef RARRAY_PTR
109
+ # define RARRAY_PTR(x_) RARRAY(x_)->ptr
110
+ # define RARRAY_LEN(x_) RARRAY(x_)->len
111
+ #endif
112
+
113
+ #ifndef RHASH_TBL
114
+ #define RHASH_TBL(x_) (RHASH(x_)->tbl)
115
+ #endif
116
+
117
+ #ifndef RFLOAT_VALUE
118
+ #define RFLOAT_VALUE(x_) (RFLOAT(x_)->value)
119
+ #endif
120
+
121
+ extern Datum plruby_dfc0 _((PGFunction));
122
+ extern Datum plruby_dfc1 _((PGFunction, Datum));
123
+ extern Datum plruby_dfc2 _((PGFunction, Datum, Datum));
124
+ extern Datum plruby_dfc3 _((PGFunction, Datum, Datum, Datum));
125
+
126
+ #define PLRUBY_DFC0(a_) plruby_dfc0(a_)
127
+ #define PLRUBY_DFC1(a_,b_) plruby_dfc1(a_,PointerGetDatum(b_))
128
+ #define PLRUBY_DFC2(a_,b_,c_) plruby_dfc2(a_,PointerGetDatum(b_),PointerGetDatum(c_))
129
+ #define PLRUBY_DFC3(a_,b_,c_,d_) plruby_dfc3(a_,PointerGetDatum(b_),PointerGetDatum(c_),PointerGetDatum(d_))
@@ -0,0 +1,13 @@
1
+ {
2
+ VALUE tmp;
3
+
4
+ #if RUBY_CAN_USE_AUTOLOAD
5
+ rb_funcall(rb_mKernel, rb_intern("autoload"), 2, rb_str_new2("Tinterval"),
6
+ rb_str_new2("plruby/plruby_datetime"));
7
+ tmp = INT2NUM(rb_intern("Tinterval"));
8
+ rb_hash_aset(plruby_conversions, INT2NUM(TINTERVALOID), tmp);
9
+ #else
10
+ tmp = plruby_define_void_class("Tinterval", "plruby/plruby_datetime");
11
+ rb_hash_aset(plruby_classes, INT2NUM(TINTERVALOID), tmp);
12
+ #endif
13
+ }
@@ -0,0 +1,8 @@
1
+ require 'mkmf'
2
+
3
+ if CONFIG["LIBRUBYARG"] == "$(LIBRUBYARG_SHARED)" &&
4
+ !enable_config("plruby-shared")
5
+ $LIBRUBYARG = ""
6
+ end
7
+ have_library('ruby18', 'ruby_init')
8
+ create_makefile('plruby/plruby_datetime')
@@ -0,0 +1,269 @@
1
+ #include "convcommon.h"
2
+
3
+ #include <utils/date.h>
4
+ #include <utils/nabstime.h>
5
+
6
+ static VALUE pl_cTinter, pl_mMarshal;
7
+
8
+ static char *
9
+ pl_dequote(char *src)
10
+ {
11
+ char *origin;
12
+
13
+ while (*src && *src != '"') ++src;
14
+ if (*src != '"') {
15
+ rb_raise(rb_eArgError, "Invalid Tinterval");
16
+ }
17
+ ++src;
18
+ origin = src;
19
+ while (*src && *src != '"') ++src;
20
+ if (*src != '"') {
21
+ rb_raise(rb_eArgError, "Invalid Tinterval");
22
+ }
23
+ *src = 0;
24
+ return origin;
25
+ }
26
+
27
+ struct pl_tint {
28
+ VALUE low, high;
29
+ };
30
+
31
+ static void
32
+ pl_tint_mark(struct pl_tint *tint)
33
+ {
34
+ rb_gc_mark(tint->low);
35
+ rb_gc_mark(tint->high);
36
+ }
37
+
38
+ static VALUE
39
+ pl_tint_s_alloc(VALUE obj)
40
+ {
41
+ struct pl_tint *tint;
42
+ return Data_Make_Struct(obj, struct pl_tint, pl_tint_mark, free, tint);
43
+ }
44
+
45
+ static VALUE
46
+ pl_tint_s_from_string(VALUE obj, VALUE str)
47
+ {
48
+ char *first, *second, *tmp;
49
+ VALUE d0, d1;
50
+ struct pl_tint *tint;
51
+ VALUE res;
52
+
53
+ tmp = StringValuePtr(str);
54
+ first = pl_dequote(tmp);
55
+ second = pl_dequote(first + strlen(first) + 1);
56
+ d0 = rb_dbl2big(DatumGetTimestamp(PLRUBY_DFC1(date_timestamp,
57
+ PLRUBY_DFC1(date_in, first))));
58
+ d1 = rb_dbl2big(DatumGetTimestamp(PLRUBY_DFC1(date_timestamp,
59
+ PLRUBY_DFC1(date_in, second))));
60
+ res = Data_Make_Struct(obj, struct pl_tint, pl_tint_mark, free, tint);
61
+ tint->low = rb_funcall(rb_cTime, rb_intern("at"), 1, d0);
62
+ tint->high = rb_funcall(rb_cTime, rb_intern("at"), 1, d1);
63
+ if (OBJ_TAINTED(str)) OBJ_TAINT(res);
64
+ return res;
65
+ }
66
+
67
+ static VALUE
68
+ pl_tint_s_datum(VALUE obj, VALUE a)
69
+ {
70
+ TimeIntervalData *interval;
71
+ Oid typoid;
72
+ VALUE tmp, res;
73
+
74
+ interval = (TimeIntervalData *)plruby_datum_get(a, &typoid);
75
+ if (typoid != TINTERVALOID) {
76
+ rb_raise(rb_eArgError, "invalid argument");
77
+ }
78
+ res = rb_ary_new2(2);
79
+ tmp = rb_dbl2big(DatumGetTimestamp(PLRUBY_DFC1(abstime_timestamp,
80
+ interval->data[0])));
81
+ tmp = rb_funcall(rb_cTime, rb_intern("at"), 1, tmp);
82
+ OBJ_TAINT(tmp);
83
+ rb_ary_push(res, tmp);
84
+ tmp = rb_dbl2big(DatumGetTimestamp(PLRUBY_DFC1(abstime_timestamp,
85
+ interval->data[1])));
86
+ tmp = rb_funcall(rb_cTime, rb_intern("at"), 1, tmp);
87
+ OBJ_TAINT(tmp);
88
+ rb_ary_push(res, tmp);
89
+ OBJ_TAINT(res);
90
+ return res;
91
+ }
92
+
93
+ #if PG_PL_VERSION >= 74
94
+
95
+ static VALUE
96
+ pl_tint_mdump(int argc, VALUE *argv, VALUE obj)
97
+ {
98
+ struct pl_tint *tint;
99
+ VALUE ary;
100
+
101
+ Data_Get_Struct(obj, struct pl_tint, tint);
102
+ ary = rb_ary_new2(2);
103
+ rb_ary_push(ary, tint->low);
104
+ rb_ary_push(ary, tint->high);
105
+ return rb_funcall(pl_mMarshal, rb_intern("dump"), 1, ary);
106
+ }
107
+
108
+ static VALUE
109
+ pl_tint_mload(VALUE obj, VALUE a)
110
+ {
111
+ struct pl_tint *tint;
112
+
113
+ if (TYPE(a) != T_STRING || !RSTRING_LEN(a)) {
114
+ rb_raise(rb_eArgError, "expected a String object");
115
+ }
116
+ a = rb_funcall(pl_mMarshal, rb_intern("load"), 1, a);
117
+ if (TYPE(a) != T_ARRAY || RARRAY_LEN(a) != 2) {
118
+ rb_raise(rb_eArgError, "expected an Array with 2 elements");
119
+ }
120
+ if (!rb_obj_is_kind_of(RARRAY_PTR(a)[0], rb_cTime) ||
121
+ !rb_obj_is_kind_of(RARRAY_PTR(a)[1], rb_cTime)) {
122
+ rb_raise(rb_eArgError, "need 2 Times objects");
123
+ }
124
+ Data_Get_Struct(obj, struct pl_tint, tint);
125
+ tint->low = RARRAY_PTR(a)[0];
126
+ tint->high = RARRAY_PTR(a)[1];
127
+ return obj;
128
+ }
129
+
130
+ #endif
131
+
132
+ static VALUE
133
+ pl_tint_init(VALUE obj, VALUE a, VALUE b)
134
+ {
135
+ struct pl_tint *tint;
136
+
137
+ if (!rb_obj_is_kind_of(a, rb_cTime) || !rb_obj_is_kind_of(b, rb_cTime)) {
138
+ rb_raise(rb_eArgError, "need 2 Times objects");
139
+ }
140
+ Data_Get_Struct(obj, struct pl_tint, tint);
141
+ tint->low = a;
142
+ tint->high = b;
143
+ if (OBJ_TAINTED(a) || OBJ_TAINTED(b)) OBJ_TAINT(obj);
144
+ return obj;
145
+ }
146
+
147
+ static VALUE
148
+ pl_tint_low(VALUE obj)
149
+ {
150
+ struct pl_tint *tint;
151
+ VALUE res;
152
+
153
+ Data_Get_Struct(obj, struct pl_tint, tint);
154
+ res = rb_obj_dup(tint->low);
155
+ if (OBJ_TAINTED(obj)) OBJ_TAINT(res);
156
+ return res;
157
+ }
158
+
159
+ static VALUE
160
+ pl_tint_lowset(VALUE obj, VALUE a)
161
+ {
162
+ struct pl_tint *tint;
163
+
164
+ Data_Get_Struct(obj, struct pl_tint, tint);
165
+ if (!rb_obj_is_kind_of(a, rb_cTime)) {
166
+ rb_raise(rb_eArgError, "need a Time object");
167
+ }
168
+ tint->low = a;
169
+ if (OBJ_TAINTED(a)) OBJ_TAINT(obj);
170
+ return a;
171
+ }
172
+
173
+ static VALUE
174
+ pl_tint_high(VALUE obj)
175
+ {
176
+ struct pl_tint *tint;
177
+ VALUE res;
178
+
179
+ Data_Get_Struct(obj, struct pl_tint, tint);
180
+ res = rb_obj_dup(tint->high);
181
+ if (OBJ_TAINTED(obj)) OBJ_TAINT(res);
182
+ return res;
183
+ }
184
+
185
+ static VALUE
186
+ pl_tint_highset(VALUE obj, VALUE a)
187
+ {
188
+ struct pl_tint *tint;
189
+
190
+ Data_Get_Struct(obj, struct pl_tint, tint);
191
+ if (!rb_obj_is_kind_of(a, rb_cTime)) {
192
+ rb_raise(rb_eArgError, "need a Time object");
193
+ }
194
+ tint->high = a;
195
+ if (OBJ_TAINTED(a)) OBJ_TAINT(obj);
196
+ return a;
197
+ }
198
+
199
+ #define tinterval_str "[\"%s\" \"%s\"]"
200
+
201
+ static VALUE
202
+ pl_tint_to_s(VALUE obj)
203
+ {
204
+ char *tmp, *t0, *t1;
205
+ VALUE v0, v1;
206
+ struct pl_tint *tint;
207
+
208
+ Data_Get_Struct(obj, struct pl_tint, tint);
209
+ v0 = plruby_to_s(tint->low);
210
+ t0 = StringValuePtr(v0);
211
+ v1 = plruby_to_s(tint->high);
212
+ t1 = StringValuePtr(v1);
213
+ tmp = ALLOCA_N(char, strlen(tinterval_str) + strlen(t0) + strlen(t1) + 1);
214
+ sprintf(tmp, tinterval_str, t0, t1);
215
+ if (OBJ_TAINTED(obj)) {
216
+ return rb_tainted_str_new2(tmp);
217
+ }
218
+ return rb_str_new2(tmp);
219
+ }
220
+
221
+ static VALUE
222
+ pl_tint_init_copy(VALUE copy, VALUE orig)
223
+ {
224
+ struct pl_tint *t0, *t1;
225
+
226
+ if (copy == orig) return copy;
227
+ if (TYPE(orig) != T_DATA ||
228
+ RDATA(orig)->dmark != (RUBY_DATA_FUNC)pl_tint_mark) {
229
+ rb_raise(rb_eTypeError, "wrong argument type to clone");
230
+ }
231
+ Data_Get_Struct(orig, struct pl_tint, t0);
232
+ Data_Get_Struct(copy, struct pl_tint, t1);
233
+ t1->low = rb_obj_dup(t0->low);
234
+ t1->high = rb_obj_dup(t0->high);
235
+ return copy;
236
+ }
237
+
238
+ void Init_plruby_datetime()
239
+ {
240
+ pl_mMarshal = rb_const_get(rb_cObject, rb_intern("Marshal"));
241
+ pl_cTinter = rb_define_class("Tinterval", rb_cObject);
242
+ rb_undef_method(CLASS_OF(pl_cTinter), "method_missing");
243
+ #if HAVE_RB_DEFINE_ALLOC_FUNC
244
+ rb_define_alloc_func(pl_cTinter, pl_tint_s_alloc);
245
+ #else
246
+ rb_define_singleton_method(pl_cTinter, "allocate", pl_tint_s_alloc, 0);
247
+ #endif
248
+ rb_define_singleton_method(pl_cTinter, "new", plruby_s_new, -1);
249
+ rb_define_singleton_method(pl_cTinter, "from_string", pl_tint_s_from_string, 1);
250
+ rb_define_singleton_method(pl_cTinter, "from_datum", pl_tint_s_datum, 1);
251
+ rb_define_method(pl_cTinter, "initialize", pl_tint_init, 2);
252
+ #ifndef HAVE_RB_INITIALIZE_COPY
253
+ rb_define_method(pl_cTinter, "clone", plruby_clone, 0);
254
+ #endif
255
+ rb_define_method(pl_cTinter, "initialize_copy", pl_tint_init_copy, 1);
256
+ #if PG_PL_VERSION >= 74
257
+ rb_define_method(pl_cTinter, "marshal_load", pl_tint_mload, 1);
258
+ rb_define_method(pl_cTinter, "marshal_dump", pl_tint_mdump, -1);
259
+ #ifndef RUBY_CAN_USE_MARSHAL_LOAD
260
+ rb_define_singleton_method(pl_cTinter, "_load", plruby_s_load, 1);
261
+ rb_define_alias(pl_cTinter, "_dump", "marshal_dump");
262
+ #endif
263
+ #endif
264
+ rb_define_method(pl_cTinter, "low", pl_tint_low, 0);
265
+ rb_define_method(pl_cTinter, "low=", pl_tint_lowset, 1);
266
+ rb_define_method(pl_cTinter, "high", pl_tint_high, 0);
267
+ rb_define_method(pl_cTinter, "high=", pl_tint_highset, 1);
268
+ rb_define_method(pl_cTinter, "to_s", pl_tint_to_s, 0);
269
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ #if RUBY_CAN_USE_AUTOLOAD
3
+ rb_funcall(rb_mKernel, rb_intern("autoload"), 2, rb_str_new2("Point"),
4
+ rb_str_new2("plruby/plruby_geometry"));
5
+ rb_funcall(rb_mKernel, rb_intern("autoload"), 2, rb_str_new2("Segment"),
6
+ rb_str_new2("plruby/plruby_geometry"));
7
+ rb_funcall(rb_mKernel, rb_intern("autoload"), 2, rb_str_new2("Box"),
8
+ rb_str_new2("plruby/plruby_geometry"));
9
+ rb_funcall(rb_mKernel, rb_intern("autoload"), 2, rb_str_new2("Path"),
10
+ rb_str_new2("plruby/plruby_geometry"));
11
+ rb_funcall(rb_mKernel, rb_intern("autoload"), 2, rb_str_new2("Polygon"),
12
+ rb_str_new2("plruby/plruby_geometry"));
13
+ rb_funcall(rb_mKernel, rb_intern("autoload"), 2, rb_str_new2("Circle"),
14
+ rb_str_new2("plruby/plruby_geometry"));
15
+ rb_hash_aset(plruby_conversions, INT2NUM(POINTOID), INT2NUM(rb_intern("Point")));
16
+ rb_hash_aset(plruby_conversions, INT2NUM(LSEGOID), INT2NUM(rb_intern("Segment")));
17
+ rb_hash_aset(plruby_conversions, INT2NUM(BOXOID), INT2NUM(rb_intern("Box")));
18
+ rb_hash_aset(plruby_conversions, INT2NUM(PATHOID), INT2NUM(rb_intern("Path")));
19
+ rb_hash_aset(plruby_conversions, INT2NUM(POLYGONOID), INT2NUM(rb_intern("Polygon")));
20
+ rb_hash_aset(plruby_conversions, INT2NUM(CIRCLEOID), INT2NUM(rb_intern("Circle")));
21
+ #else
22
+ VALUE tmp;
23
+
24
+ tmp = plruby_define_void_class("Point", "plruby/plruby_geometry");
25
+ rb_hash_aset(plruby_classes, INT2NUM(POINTOID), tmp);
26
+ tmp = plruby_define_void_class("Segment", "plruby/plruby_geometry");
27
+ rb_hash_aset(plruby_classes, INT2NUM(LSEGOID), tmp);
28
+ tmp = plruby_define_void_class("Box", "plruby/plruby_geometry");
29
+ rb_hash_aset(plruby_classes, INT2NUM(BOXOID), tmp);
30
+ tmp = plruby_define_void_class("Path", "plruby/plruby_geometry");
31
+ rb_hash_aset(plruby_classes, INT2NUM(PATHOID), tmp);
32
+ tmp = plruby_define_void_class("Polygon", "plruby/plruby_geometry");
33
+ rb_hash_aset(plruby_classes, INT2NUM(POLYGONOID), tmp);
34
+ tmp = plruby_define_void_class("Circle", "plruby/plruby_geometry");
35
+ rb_hash_aset(plruby_classes, INT2NUM(CIRCLEOID), tmp);
36
+ #endif
37
+ }