Gentoo Archives: gentoo-commits

From: "Diego Petteno (flameeyes)" <flameeyes@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-ruby/hpricot/files: hpricot-0.8.2-jruby.patch
Date: Mon, 01 Feb 2010 16:39:26
Message-Id: E1NbzJ6-0004sr-6p@stork.gentoo.org
1 flameeyes 10/02/01 16:39:24
2
3 Added: hpricot-0.8.2-jruby.patch
4 Log:
5 Add a patch to fix a big bug on JRuby.
6 (Portage version: 2.2_rc62/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 dev-ruby/hpricot/files/hpricot-0.8.2-jruby.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-ruby/hpricot/files/hpricot-0.8.2-jruby.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-ruby/hpricot/files/hpricot-0.8.2-jruby.patch?rev=1.1&content-type=text/plain
13
14 Index: hpricot-0.8.2-jruby.patch
15 ===================================================================
16 From 26708b9e80110c14a9d9fe7f974fc544f86b702a Mon Sep 17 00:00:00 2001
17 From: Ola Bini <ola.bini@×××××.com>
18 Date: Mon, 1 Feb 2010 16:46:02 +0100
19 Subject: [PATCH] Fix bug #11 - sort out some bad casts on JRuby
20
21 ---
22 ext/hpricot_scan/HpricotScanService.java | 33 +++++++++++++++++++----------
23 ext/hpricot_scan/hpricot_scan.java.rl | 33 +++++++++++++++++++----------
24 2 files changed, 42 insertions(+), 24 deletions(-)
25
26 diff --git a/ext/hpricot_scan/HpricotScanService.java b/ext/hpricot_scan/HpricotScanService.java
27 index d921309..c5fe796 100644
28 --- a/ext/hpricot_scan/HpricotScanService.java
29 +++ b/ext/hpricot_scan/HpricotScanService.java
30 @@ -139,62 +139,62 @@ public class HpricotScanService implements BasicLibraryService {
31
32 // H_ATTR(target)
33 public static IRubyObject hpricot_ele_set_target(IRubyObject self, IRubyObject x) {
34 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("target"), x);
35 + H_ELE_GET_asHash(self, H_ELE_ATTR).fastASet(self.getRuntime().newSymbol("target"), x);
36 return self;
37 }
38
39 public static IRubyObject hpricot_ele_get_target(IRubyObject self) {
40 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("target"));
41 + return H_ELE_GET_asHash(self, H_ELE_ATTR).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("target"));
42 }
43
44 // H_ATTR(encoding)
45 public static IRubyObject hpricot_ele_set_encoding(IRubyObject self, IRubyObject x) {
46 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("encoding"), x);
47 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("encoding"), x);
48 return self;
49 }
50
51 public static IRubyObject hpricot_ele_get_encoding(IRubyObject self) {
52 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("encoding"));
53 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("encoding"));
54 }
55
56 // H_ATTR(version)
57 public static IRubyObject hpricot_ele_set_version(IRubyObject self, IRubyObject x) {
58 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("version"), x);
59 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("version"), x);
60 return self;
61 }
62
63 public static IRubyObject hpricot_ele_get_version(IRubyObject self) {
64 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("version"));
65 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("version"));
66 }
67
68 // H_ATTR(standalone)
69 public static IRubyObject hpricot_ele_set_standalone(IRubyObject self, IRubyObject x) {
70 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("standalone"), x);
71 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("standalone"), x);
72 return self;
73 }
74
75 public static IRubyObject hpricot_ele_get_standalone(IRubyObject self) {
76 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("standalone"));
77 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("standalone"));
78 }
79
80 // H_ATTR(system_id)
81 public static IRubyObject hpricot_ele_set_system_id(IRubyObject self, IRubyObject x) {
82 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("system_id"), x);
83 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("system_id"), x);
84 return self;
85 }
86
87 public static IRubyObject hpricot_ele_get_system_id(IRubyObject self) {
88 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("system_id"));
89 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("system_id"));
90 }
91
92 // H_ATTR(public_id)
93 public static IRubyObject hpricot_ele_set_public_id(IRubyObject self, IRubyObject x) {
94 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("public_id"), x);
95 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("public_id"), x);
96 return self;
97 }
98
99 public static IRubyObject hpricot_ele_get_public_id(IRubyObject self) {
100 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("public_id"));
101 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("public_id"));
102 }
103
104 public static class Scanner {
105 @@ -1903,6 +1903,15 @@ case 5:
106 return ((IRubyObject[])recv.dataGetStruct())[n];
107 }
108
109 + public static RubyHash H_ELE_GET_asHash(IRubyObject recv, int n) {
110 + IRubyObject obj = ((IRubyObject[])recv.dataGetStruct())[n];
111 + if(obj.isNil()) {
112 + obj = RubyHash.newHash(recv.getRuntime());
113 + ((IRubyObject[])recv.dataGetStruct())[n] = obj;
114 + }
115 + return (RubyHash)obj;
116 + }
117 +
118 public static IRubyObject H_ELE_SET(IRubyObject recv, int n, IRubyObject value) {
119 ((IRubyObject[])recv.dataGetStruct())[n] = value;
120 return value;
121 diff --git a/ext/hpricot_scan/hpricot_scan.java.rl b/ext/hpricot_scan/hpricot_scan.java.rl
122 index d1fb04b..1821761 100644
123 --- a/ext/hpricot_scan/hpricot_scan.java.rl
124 +++ b/ext/hpricot_scan/hpricot_scan.java.rl
125 @@ -137,62 +137,62 @@ public class HpricotScanService implements BasicLibraryService {
126
127 // H_ATTR(target)
128 public static IRubyObject hpricot_ele_set_target(IRubyObject self, IRubyObject x) {
129 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("target"), x);
130 + H_ELE_GET_asHash(self, H_ELE_ATTR).fastASet(self.getRuntime().newSymbol("target"), x);
131 return self;
132 }
133
134 public static IRubyObject hpricot_ele_get_target(IRubyObject self) {
135 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("target"));
136 + return H_ELE_GET_asHash(self, H_ELE_ATTR).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("target"));
137 }
138
139 // H_ATTR(encoding)
140 public static IRubyObject hpricot_ele_set_encoding(IRubyObject self, IRubyObject x) {
141 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("encoding"), x);
142 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("encoding"), x);
143 return self;
144 }
145
146 public static IRubyObject hpricot_ele_get_encoding(IRubyObject self) {
147 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("encoding"));
148 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("encoding"));
149 }
150
151 // H_ATTR(version)
152 public static IRubyObject hpricot_ele_set_version(IRubyObject self, IRubyObject x) {
153 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("version"), x);
154 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("version"), x);
155 return self;
156 }
157
158 public static IRubyObject hpricot_ele_get_version(IRubyObject self) {
159 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("version"));
160 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("version"));
161 }
162
163 // H_ATTR(standalone)
164 public static IRubyObject hpricot_ele_set_standalone(IRubyObject self, IRubyObject x) {
165 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("standalone"), x);
166 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("standalone"), x);
167 return self;
168 }
169
170 public static IRubyObject hpricot_ele_get_standalone(IRubyObject self) {
171 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("standalone"));
172 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("standalone"));
173 }
174
175 // H_ATTR(system_id)
176 public static IRubyObject hpricot_ele_set_system_id(IRubyObject self, IRubyObject x) {
177 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("system_id"), x);
178 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("system_id"), x);
179 return self;
180 }
181
182 public static IRubyObject hpricot_ele_get_system_id(IRubyObject self) {
183 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("system_id"));
184 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("system_id"));
185 }
186
187 // H_ATTR(public_id)
188 public static IRubyObject hpricot_ele_set_public_id(IRubyObject self, IRubyObject x) {
189 - ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("public_id"), x);
190 + ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).fastASet(self.getRuntime().newSymbol("public_id"), x);
191 return self;
192 }
193
194 public static IRubyObject hpricot_ele_get_public_id(IRubyObject self) {
195 - return ((RubyHash)H_ELE_GET(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("public_id"));
196 + return ((RubyHash)H_ELE_GET_asHash(self, H_ELE_ATTR)).op_aref(self.getRuntime().getCurrentContext(), self.getRuntime().newSymbol("public_id"));
197 }
198
199 public static class Scanner {
200 @@ -965,6 +965,15 @@ public class HpricotScanService implements BasicLibraryService {
201 return ((IRubyObject[])recv.dataGetStruct())[n];
202 }
203
204 + public static RubyHash H_ELE_GET_asHash(IRubyObject recv, int n) {
205 + IRubyObject obj = ((IRubyObject[])recv.dataGetStruct())[n];
206 + if(obj.isNil()) {
207 + obj = RubyHash.newHash(recv.getRuntime());
208 + ((IRubyObject[])recv.dataGetStruct())[n] = obj;
209 + }
210 + return (RubyHash)obj;
211 + }
212 +
213 public static IRubyObject H_ELE_SET(IRubyObject recv, int n, IRubyObject value) {
214 ((IRubyObject[])recv.dataGetStruct())[n] = value;
215 return value;
216 --
217 1.6.6.1