ox 1.2.14 → 1.2.15

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ox might be problematic. Click here for more details.

data/ext/ox/cache8.c CHANGED
@@ -16,7 +16,7 @@
16
16
  struct _Cache8 {
17
17
  union {
18
18
  struct _Cache8 *slots[SLOT_CNT];
19
- uint64_t values[SLOT_CNT];
19
+ unsigned long values[SLOT_CNT];
20
20
  };
21
21
  };
22
22
 
@@ -56,8 +56,8 @@ cache8_delete(Cache8 cache, int depth) {
56
56
  free(cache);
57
57
  }
58
58
 
59
- uint64_t
60
- ox_cache8_get(Cache8 cache, VALUE key, uint64_t **slot) {
59
+ slot_t
60
+ ox_cache8_get(Cache8 cache, VALUE key, slot_t **slot) {
61
61
  Cache8 *cp;
62
62
  int i;
63
63
  VALUE k;
data/ext/ox/cache8.h CHANGED
@@ -33,12 +33,13 @@
33
33
 
34
34
  #include "ruby.h"
35
35
 
36
- typedef struct _Cache8 *Cache8;
36
+ typedef struct _Cache8 *Cache8;
37
+ typedef unsigned long slot_t;
37
38
 
38
39
  extern void ox_cache8_new(Cache8 *cache);
39
40
  extern void ox_cache8_delete(Cache8 cache);
40
41
 
41
- extern uint64_t ox_cache8_get(Cache8 cache, VALUE key, uint64_t **slot);
42
+ extern slot_t ox_cache8_get(Cache8 cache, VALUE key, slot_t **slot);
42
43
 
43
44
  extern void ox_cache8_print(Cache8 cache);
44
45
 
data/ext/ox/cache8_test.c CHANGED
@@ -31,37 +31,37 @@
31
31
  #include <stdio.h>
32
32
  #include "cache8.h"
33
33
 
34
- static uint64_t data[] = {
35
- 0x000000A0A0A0A0A0ULL,
36
- 0x0000000000ABCDEFULL,
37
- 0x0123456789ABCDEFULL,
38
- 0x0000000000000001ULL,
39
- 0x0000000000000002ULL,
40
- 0x0000000000000003ULL,
41
- 0x0000000000000004ULL,
34
+ static slot_t data[] = {
35
+ 0x000000A0A0A0A0A0UL,
36
+ 0x0000000000ABCDEFUL,
37
+ 0x0123456789ABCDEFUL,
38
+ 0x0000000000000001UL,
39
+ 0x0000000000000002UL,
40
+ 0x0000000000000003UL,
41
+ 0x0000000000000004UL,
42
42
  0
43
43
  };
44
44
 
45
45
  void
46
46
  ox_cache8_test() {
47
47
  Cache8 c;
48
- uint64_t v;
49
- uint64_t *d;
50
- uint64_t cnt = 1;
51
- uint64_t *slot = 0;
48
+ slot_t v;
49
+ slot_t *d;
50
+ slot_t cnt = 1;
51
+ slot_t *slot = 0;
52
52
 
53
53
  ox_cache8_new(&c);
54
54
  for (d = data; 0 != *d; d++) {
55
55
  v = ox_cache8_get(c, *d, &slot);
56
56
  if (0 == v) {
57
57
  if (0 == slot) {
58
- printf("*** failed to get a slot for 0x%016llx\n", *d);
58
+ printf("*** failed to get a slot for 0x%016lx\n", *d);
59
59
  } else {
60
- printf("*** adding 0x%016llx to cache with value %llu\n", *d, cnt);
60
+ printf("*** adding 0x%016lx to cache with value %lu\n", *d, cnt);
61
61
  *slot = cnt++;
62
62
  }
63
63
  } else {
64
- printf("*** get on 0x%016llx returned %llu\n", *d, v);
64
+ printf("*** get on 0x%016lx returned %lu\n", *d, v);
65
65
  }
66
66
  //ox_cache8_print(c);
67
67
  }
data/ext/ox/dump.c CHANGED
@@ -44,6 +44,8 @@
44
44
  #include "cache8.h"
45
45
  #include "ox.h"
46
46
 
47
+ typedef unsigned long ulong;
48
+
47
49
  typedef struct _Str {
48
50
  const char *str;
49
51
  size_t len;
@@ -192,7 +194,7 @@ fill_attr(Out out, char name, const char *value, size_t len) {
192
194
  }
193
195
 
194
196
  inline static const char*
195
- ulong2str(uint64_t num, char *end) {
197
+ ulong2str(ulong num, char *end) {
196
198
  char *b;
197
199
 
198
200
  *end-- = '\0';
@@ -206,8 +208,8 @@ ulong2str(uint64_t num, char *end) {
206
208
 
207
209
  static int
208
210
  check_circular(Out out, VALUE obj, Element e) {
209
- uint64_t *slot;
210
- uint64_t id;
211
+ ulong *slot;
212
+ ulong id;
211
213
  int result;
212
214
 
213
215
  if (0 == (id = ox_cache8_get(out->circ_cache, obj, &slot))) {
@@ -541,7 +543,7 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
541
543
  } else {
542
544
  char buf64[4096];
543
545
  char *b64 = buf64;
544
- uint64_t size = b64_size(cnt);
546
+ ulong size = b64_size(cnt);
545
547
 
546
548
  e.type = String64Code;
547
549
  if (sizeof(buf64) < size) {
@@ -574,7 +576,7 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
574
576
  } else {
575
577
  char buf64[4096];
576
578
  char *b64 = buf64;
577
- uint64_t size = b64_size(cnt);
579
+ ulong size = b64_size(cnt);
578
580
 
579
581
  e.type = Symbol64Code;
580
582
  if (sizeof(buf64) < size) {
@@ -617,6 +619,11 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
617
619
  }
618
620
  case T_STRUCT:
619
621
  {
622
+ #ifdef NO_RSTRUCT
623
+ e.type = NilClassCode;
624
+ e.closed = 1;
625
+ out->w_start(out, &e);
626
+ #else
620
627
  VALUE clas;
621
628
 
622
629
  if (0 != out->circ_cache && check_circular(out, obj, &e)) {
@@ -651,6 +658,7 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
651
658
  }
652
659
  out->w_end(out, &e);
653
660
  }
661
+ #endif
654
662
  break;
655
663
  }
656
664
  case T_OBJECT:
@@ -688,9 +696,12 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
688
696
  out->depth = od;
689
697
  out->w_end(out, &e);
690
698
  }
699
+ #else
700
+ #ifdef JRUBY
701
+ VALUE vars = rb_funcall2(obj, rb_intern("instance_variables"), 0, 0);
691
702
  #else
692
703
  VALUE vars = rb_obj_instance_variables(obj);
693
-
704
+ #endif
694
705
  e.type = ObjectCode;
695
706
  cnt = (int)RARRAY_LEN(vars);
696
707
  e.closed = (0 >= cnt);
@@ -734,7 +745,7 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
734
745
  } else {
735
746
  char buf64[4096];
736
747
  char *b64 = buf64;
737
- uint64_t size = b64_size(cnt);
748
+ ulong size = b64_size(cnt);
738
749
 
739
750
  if (sizeof(buf64) < size) {
740
751
  if (0 == (b64 = (char*)malloc(size + 1))) {
data/ext/ox/obj_load.c CHANGED
@@ -132,6 +132,7 @@ classname2obj(const char *name, PInfo pi) {
132
132
  }
133
133
  }
134
134
 
135
+ #ifndef NO_RSTRUCT
135
136
  inline static VALUE
136
137
  structname2obj(const char *name) {
137
138
  VALUE ost;
@@ -154,6 +155,7 @@ structname2obj(const char *name) {
154
155
  return rb_struct_new(ost);
155
156
  #endif
156
157
  }
158
+ #endif
157
159
 
158
160
  // 2010-07-09T10:47:45.895826162+09:00
159
161
  inline static VALUE
@@ -222,6 +224,7 @@ get_obj_from_attrs(Attr a, PInfo pi) {
222
224
  return Qundef;
223
225
  }
224
226
 
227
+ #ifndef NO_RSTRUCT
225
228
  static VALUE
226
229
  get_struct_from_attrs(Attr a) {
227
230
  for (; 0 != a->name; a++) {
@@ -231,6 +234,7 @@ get_struct_from_attrs(Attr a) {
231
234
  }
232
235
  return Qundef;
233
236
  }
237
+ #endif
234
238
 
235
239
  static VALUE
236
240
  get_class_from_attrs(Attr a, PInfo pi) {
@@ -613,10 +617,14 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
613
617
  }
614
618
  break;
615
619
  case StructCode:
620
+ #ifdef NO_RSTRUCT
621
+ raise_error("Ruby structs not supported with this verion of Ruby", pi->str, pi->s);
622
+ #else
616
623
  h->obj = get_struct_from_attrs(attrs);
617
624
  if (0 != pi->circ_array) {
618
625
  circ_array_set(pi->circ_array, h->obj, get_id_from_attrs(pi, attrs));
619
626
  }
627
+ #endif
620
628
  break;
621
629
  case ClassCode:
622
630
  h->obj = get_class_from_attrs(attrs, pi);
@@ -674,13 +682,20 @@ end_element(PInfo pi, const char *ename) {
674
682
  }
675
683
  break;
676
684
  case StructCode:
685
+ #ifdef NO_RSTRUCT
686
+ raise_error("Ruby structs not supported with this verion of Ruby", pi->str, pi->s);
687
+ #else
677
688
  rb_struct_aset(pi->h->obj, h->var, h->obj);
689
+ #endif
678
690
  break;
679
691
  case HashCode:
680
692
  h->type = KeyCode;
681
693
  pi->h++;
682
694
  break;
683
695
  case RangeCode:
696
+ #ifdef NO_RSTRUCT
697
+ raise_error("Ruby structs not supported with this verion of Ruby", pi->str, pi->s);
698
+ #else
684
699
  if (beg_id == h->var) {
685
700
  RSTRUCT_PTR(pi->h->obj)[0] = h->obj;
686
701
  } else if (end_id == h->var) {
@@ -690,6 +705,7 @@ end_element(PInfo pi, const char *ename) {
690
705
  } else {
691
706
  raise_error("Invalid range attribute", pi->str, pi->s);
692
707
  }
708
+ #endif
693
709
  break;
694
710
  case KeyCode:
695
711
  rb_hash_aset((pi->h - 1)->obj, pi->h->obj, h->obj);
data/ext/ox/ox.h CHANGED
@@ -45,6 +45,13 @@ extern "C" {
45
45
  #endif
46
46
  #include "cache.h"
47
47
 
48
+ #ifdef JRUBY
49
+ #define NO_RSTRUCT 1
50
+ #endif
51
+ #ifdef RBX_Qnil
52
+ #define NO_RSTRUCT 1
53
+ #endif
54
+
48
55
  #define raise_error(msg, xml, current) _raise_error(msg, xml, current, __FILE__, __LINE__)
49
56
 
50
57
  #define MAX_TEXT_LEN 4096
data/lib/ox/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '1.2.14'
4
+ VERSION = '1.2.15'
5
5
  end
data/test/bug3.rb CHANGED
@@ -3,21 +3,19 @@
3
3
  $: << '../lib'
4
4
  $: << '../ext'
5
5
 
6
- if __FILE__ == $0
7
- if (i = ARGV.index('-I'))
8
- x,path = ARGV.slice!(i, 2)
9
- $: << path
10
- end
11
- end
12
-
13
6
  require 'ox'
14
7
 
15
- def dump(cnt = 100000)
16
- cnt.times do |i|
17
- xml = Ox.dump([:inc, 1])
18
- #puts xml
19
-
8
+ def name_it()
9
+ begin
10
+ "x".foo
11
+ rescue Exception => e
12
+ #puts e.message
13
+ xml = Ox.dump(e, effort: :tolerant)
14
+ puts xml
15
+ o = Ox.load(xml, mode: :object)
16
+ puts o.message
17
+ puts Ox.dump(e)
20
18
  end
21
19
  end
22
20
 
23
- dump()
21
+ name_it()
metadata CHANGED
@@ -1,24 +1,28 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ox
3
- version: !ruby/object:Gem::Version
4
- version: 1.2.14
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 1.2.15
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Peter Ohler
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-02 00:00:00.000000000Z
12
+
13
+ date: 2011-09-06 00:00:00 +09:00
14
+ default_executable:
13
15
  dependencies: []
16
+
14
17
  description: A fast XML parser and object serializer that uses only standard C lib.
15
18
  email: peter@ohler.com
16
19
  executables: []
17
- extensions:
20
+
21
+ extensions:
18
22
  - ext/ox/extconf.rb
19
- extra_rdoc_files:
23
+ extra_rdoc_files:
20
24
  - README.rdoc
21
- files:
25
+ files:
22
26
  - lib/ox/bag.rb
23
27
  - lib/ox/cdata.rb
24
28
  - lib/ox/comment.rb
@@ -43,7 +47,6 @@ files:
43
47
  - ext/ox/obj_load.c
44
48
  - ext/ox/ox.c
45
49
  - ext/ox/parse.c
46
- - test/big.rb
47
50
  - test/bug1.rb
48
51
  - test/bug2.rb
49
52
  - test/bug3.rb
@@ -76,31 +79,35 @@ files:
76
79
  - test/Sample.graffle
77
80
  - LICENSE
78
81
  - README.rdoc
82
+ has_rdoc: true
79
83
  homepage: https://github.com/ohler55/ox
80
84
  licenses: []
85
+
81
86
  post_install_message:
82
- rdoc_options:
87
+ rdoc_options:
83
88
  - --main
84
89
  - README.rdoc
85
- require_paths:
90
+ require_paths:
86
91
  - lib
87
92
  - ext
88
- required_ruby_version: !ruby/object:Gem::Requirement
93
+ required_ruby_version: !ruby/object:Gem::Requirement
89
94
  none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
100
  none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '0'
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: "0"
100
105
  requirements: []
106
+
101
107
  rubyforge_project: ox
102
- rubygems_version: 1.8.6
108
+ rubygems_version: 1.6.2
103
109
  signing_key:
104
110
  specification_version: 3
105
111
  summary: A fast XML parser and object serializer.
106
112
  test_files: []
113
+
data/test/big.rb DELETED
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby -wW1
2
-
3
- $: << '../lib'
4
- $: << '../ext'
5
-
6
- if __FILE__ == $0
7
- while (i = ARGV.index('-I'))
8
- x,path = ARGV.slice!(i, 2)
9
- $: << path
10
- end
11
- end
12
-
13
- require 'ox'
14
-
15
- def dump(cnt = 10000)
16
- h = { }
17
- cnt.times do |i|
18
- h[i] = [i * 2, "this is #{i}"]
19
- end
20
- xml = Ox.dump(h)
21
- puts "size: #{xml.size}"
22
- end
23
-
24
- dump(200000)