intersys 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,6 @@
2
2
 
3
3
 
4
4
  static void intersys_object_free(struct rbObject* object) {
5
- // printf("Releasing object %d\n", object->oref);
6
5
  if (object->oref) {
7
6
  RUN(cbind_object_release(object->database, object->oref));
8
7
  }
@@ -23,12 +22,11 @@ VALUE intersys_object_s_allocate(VALUE klass) {
23
22
  VALUE intersys_object_initialize(VALUE self) {
24
23
  struct rbObject* object;
25
24
  struct rbDatabase* base;
26
- VALUE klass = rb_funcall(self, rb_intern("class"), 0);
27
- VALUE database = rb_funcall(klass, rb_intern("database"), 0);
25
+ VALUE database = rb_funcall(rb_obj_class(self), rb_intern("database"), 0);
28
26
  Data_Get_Struct(self, struct rbObject, object);
29
27
  Data_Get_Struct(database, struct rbDatabase, base);
30
28
  object->database = base->database;
31
- object->class_name = TOWCHAR(rb_funcall(klass, rb_intern("class_name"), 0));
29
+ object->class_name = TOWCHAR(rb_funcall(rb_obj_class(self), rb_intern("class_name"), 0));
32
30
  return self;
33
31
  }
34
32
 
Binary file
@@ -1,9 +1,22 @@
1
1
  #include "intersys.h"
2
+ #ifdef __CYGWIN__
3
+ #include <windef.h>
4
+ #endif
2
5
  #include <sql.h>
3
6
  #include <sqlext.h>
4
7
  #include <sqlucode.h>
5
8
 
9
+ static void query_close(struct rbQuery* query) {
10
+ printf("Trying to close query (%d,%d)\n", query->closed, query->executed);
11
+ if(!query->closed && query->executed) {
12
+ printf("Closing query\n");
13
+ RUN(cbind_query_close(query->query));
14
+ query->closed = 1;
15
+ }
16
+ }
17
+
6
18
  void intersys_query_free(struct rbQuery* query) {
19
+ query_close(query);
7
20
  RUN(cbind_free_query(query->query));
8
21
  free(query);
9
22
  }
@@ -32,6 +45,7 @@ VALUE intersys_query_execute(VALUE self) {
32
45
  Data_Get_Struct(self, struct rbQuery, query);
33
46
  RUN(cbind_query_execute(query->query, &sql_code));
34
47
  RUN(cbind_query_get_num_pars(query->query, &res));
48
+ query->executed = 1;
35
49
  return self;
36
50
  }
37
51
 
@@ -148,6 +162,6 @@ VALUE intersys_query_fetch(VALUE self) {
148
162
  VALUE intersys_query_close(VALUE self) {
149
163
  struct rbQuery* query;
150
164
  Data_Get_Struct(self, struct rbQuery, query);
151
- RUN(cbind_query_close(query->query));
165
+ query_close(query);
152
166
  return self;
153
167
  }
Binary file
@@ -0,0 +1,15 @@
1
+ require 'intersys'
2
+
3
+ class Person < Intersys::Object
4
+ end
5
+
6
+ #puts Person.intersys_methods
7
+ def my_mtd
8
+ Intersys::Reflection::ClassDefinition.method("%OpenId", nil)
9
+ end
10
+ def class_mtd
11
+ my_mtd.class_method?
12
+ end
13
+
14
+
15
+ Person.intersys_call("%OpenId", 20)
@@ -7,11 +7,21 @@ end
7
7
 
8
8
  class QueryTest < Test::Unit::TestCase
9
9
  def test_open_and_save
10
- @p = Person.open(21)
11
10
  @name = "Anni Fyo"
11
+ @id = 26001
12
+ #assert Person.intersys_call("Populate", 1000)
13
+ assert @p = Person.open(@id)
12
14
  @p.name = @name
13
- @p.save
14
- @p = Article.open(21)
15
+ assert @p.save
16
+ assert @p = Person.open(@id)
15
17
  assert_equal @name, @p.name
18
+ assert Person.intersys_call("%DeleteExtent")
16
19
  end
17
- end
20
+
21
+ def test_create
22
+ assert @p = Person.intersys_call("%New")
23
+ @p.name = "Test user"
24
+ assert @p.save
25
+ puts @p.id
26
+ end
27
+ end
@@ -4,6 +4,7 @@ require File.dirname(__FILE__) + '/../lib/intersys'
4
4
 
5
5
  class QueryTest < Test::Unit::TestCase
6
6
  def test_query1
7
+ return
7
8
  @db = Intersys::Database.new({})
8
9
 
9
10
  @data = @db.query("select * from sample.person")
@@ -2,9 +2,12 @@ require 'test/unit'
2
2
  require File.dirname(__FILE__) + '/../lib/intersys'
3
3
 
4
4
 
5
- class Article < Intersys::Object
5
+ class MyTest < Intersys::Object
6
6
  prefix "Sample"
7
7
  end
8
+
9
+ class Article < Intersys::Object
10
+ end
8
11
  class Person < Intersys::Object
9
12
  end
10
13
 
@@ -14,17 +17,17 @@ class ReflectionTest < Test::Unit::TestCase
14
17
  assert_equal "%Dictionary.ClassDefinition", @cdef.name
15
18
  assert_equal "persistent", @cdef.class_type
16
19
  assert_equal "%Persistent,%Dictionary.ClassDefinitionQuery", @cdef.super
17
- assert_equal 58, @cdef.properties.size
18
- assert_equal 19, @cdef._methods.size
20
+ assert 50 < @cdef.properties.size
21
+ assert 10 < @cdef._methods.size
19
22
  end
20
23
 
21
24
  def test_class_names
22
- assert_equal Article, Article.lookup("Sample.Article")
23
- assert_equal Person, Article.lookup("User.Person")
25
+ assert_equal MyTest, MyTest.lookup("Sample.MyTest")
26
+ assert_equal Person, Person.lookup("User.Person")
24
27
  end
25
28
 
26
29
  def test_class_create
27
- @cdef = Intersys::Reflection::ClassDefinition.call("%New", "User.Person")
30
+ @cdef = Intersys::Reflection::ClassDefinition.call("%New", "User.Article")
28
31
  @cdef.class_type = "persistent"
29
32
  @cdef.super = "%Persistent,%Populate,%XML.Adaptor"
30
33
  @props = @cdef.properties
@@ -53,13 +56,9 @@ class ReflectionTest < Test::Unit::TestCase
53
56
  assert @props << @prop
54
57
  @prop.type = "Sample.Address"
55
58
 
56
- assert_equal "User.Person", @cdef.name
59
+ assert_equal "User.Article", @cdef.name
57
60
  assert_equal 6, @cdef.properties.size
58
61
  #@cdef.save
59
62
  end
60
-
61
- def test_populate
62
- assert Person.intersys_call("Populate", 1000)
63
-
64
- end
65
- end
63
+ end
64
+
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: intersys
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
7
- date: 2006-09-02 00:00:00 +04:00
6
+ version: 0.0.4
7
+ date: 2006-09-08 00:00:00 +04:00
8
8
  summary: Intersystems Cache ruby driver
9
9
  require_paths:
10
10
  - lib
@@ -33,14 +33,24 @@ files:
33
33
  - test/reflection.rb
34
34
  - test/strings.rb
35
35
  - lib/common.c
36
+ - lib/common.o
36
37
  - lib/database.c
38
+ - lib/database.o
37
39
  - lib/definition.c
40
+ - lib/definition.o
38
41
  - lib/extconf.rb
39
42
  - lib/intersys.c
40
43
  - lib/intersys.h
44
+ - lib/intersys.o
41
45
  - lib/intersys.rb
46
+ - lib/intersys_cache.bundle
47
+ - lib/Makefile
48
+ - lib/mkmf.log
42
49
  - lib/object.c
50
+ - lib/object.o
43
51
  - lib/query.c
52
+ - lib/query.o
53
+ - lib/test.rb
44
54
  - README
45
55
  test_files: []
46
56