Skip to content

Commit 19bf4b3

Browse files
committed
Merge branch 'string-matching'
Conflicts: .gitignore Rakefile tests/test_json_encoding.rb
2 parents 3f97501 + 6dc725a commit 19bf4b3

18 files changed

+505
-321
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
coverage
33
pkg
44
.nfs.*
5+
.idea
6+
java/Json.iml

Rakefile

Lines changed: 126 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@ MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
2323
PKG_NAME = 'json'
2424
PKG_TITLE = 'JSON Implementation for Ruby'
2525
PKG_VERSION = File.read('VERSION').chomp
26-
PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile|\.nfs\./).exclude(/\.(so|bundle|o|class|#{CONFIG['DLEXT']})$/)
26+
PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile|\.nfs\.|\.iml\Z/).exclude(/\.(so|bundle|o|class|#{CONFIG['DLEXT']})$/)
2727

2828
EXT_ROOT_DIR = 'ext/json/ext'
2929
EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser"
3030
EXT_PARSER_DL = "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}"
31+
RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
3132
EXT_PARSER_SRC = "#{EXT_PARSER_DIR}/parser.c"
3233
PKG_FILES << EXT_PARSER_SRC
3334
EXT_GENERATOR_DIR = "#{EXT_ROOT_DIR}/generator"
3435
EXT_GENERATOR_DL = "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}"
3536
EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
3637

3738
JAVA_DIR = "java/src/json/ext"
39+
JAVA_RAGEL_PATH = "#{JAVA_DIR}/Parser.rl"
3840
JAVA_PARSER_SRC = "#{JAVA_DIR}/Parser.java"
3941
JAVA_SOURCES = FileList["#{JAVA_DIR}/*.java"]
4042
JAVA_CLASSES = []
@@ -43,7 +45,6 @@ JRUBY_GENERATOR_JAR = File.expand_path("lib/json/ext/generator.jar")
4345

4446
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
4547
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
46-
RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
4748

4849
def myruby(*args, &block)
4950
@myruby ||= File.join(CONFIG['bindir'], CONFIG['ruby_install_name'])
@@ -81,110 +82,6 @@ else
8182
task :install => :install_ext
8283
end
8384

84-
desc "Compiling extension"
85-
task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
86-
87-
file EXT_PARSER_DL => EXT_PARSER_SRC do
88-
cd EXT_PARSER_DIR do
89-
myruby 'extconf.rb'
90-
sh MAKE
91-
end
92-
cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
93-
end
94-
95-
file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
96-
cd EXT_GENERATOR_DIR do
97-
myruby 'extconf.rb'
98-
sh MAKE
99-
end
100-
cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
101-
end
102-
103-
desc "Generate parser with ragel"
104-
task :ragel => EXT_PARSER_SRC
105-
106-
desc "Delete the ragel generated C source"
107-
task :ragel_clean do
108-
rm_rf EXT_PARSER_SRC
109-
end
110-
111-
file EXT_PARSER_SRC => RAGEL_PATH do
112-
cd EXT_PARSER_DIR do
113-
if RAGEL_CODEGEN == 'ragel'
114-
sh "ragel parser.rl -G2 -o parser.c"
115-
else
116-
sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2"
117-
end
118-
end
119-
end
120-
121-
desc "Generate diagrams of ragel parser (ps)"
122-
task :ragel_dot_ps do
123-
root = 'diagrams'
124-
specs = []
125-
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
126-
for s in specs
127-
if RAGEL_DOTGEN == 'ragel'
128-
sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tps -o#{root}/#{s}.ps"
129-
else
130-
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tps -o#{root}/#{s}.ps"
131-
end
132-
end
133-
end
134-
135-
desc "Generate diagrams of ragel parser (png)"
136-
task :ragel_dot_png do
137-
root = 'diagrams'
138-
specs = []
139-
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
140-
for s in specs
141-
if RAGEL_DOTGEN == 'ragel'
142-
sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tpng -o#{root}/#{s}.png"
143-
else
144-
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tpng -o#{root}/#{s}.png"
145-
end
146-
end
147-
end
148-
149-
desc "Generate diagrams of ragel parser"
150-
task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
151-
152-
desc "Testing library (pure ruby)"
153-
task :test_pure => :clean do
154-
ENV['JSON'] = 'pure'
155-
ENV['RUBYOPT'] = "-Ilib #{ENV['RUBYOPT']}"
156-
myruby '-S', 'testrb', *Dir['tests/*.rb']
157-
end
158-
159-
desc "Testing library (extension)"
160-
task :test_ext => :compile_ext do
161-
ENV['JSON'] = 'ext'
162-
ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
163-
myruby '-S', 'testrb', *Dir['./tests/*.rb']
164-
end
165-
166-
desc "Benchmarking parser"
167-
task :benchmark_parser do
168-
ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
169-
myruby 'benchmarks/parser_benchmark.rb'
170-
myruby 'benchmarks/parser2_benchmark.rb'
171-
end
172-
173-
desc "Benchmarking generator"
174-
task :benchmark_generator do
175-
ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
176-
myruby 'benchmarks/generator_benchmark.rb'
177-
myruby 'benchmarks/generator2_benchmark.rb'
178-
end
179-
180-
desc "Benchmarking library"
181-
task :benchmark => [ :benchmark_parser, :benchmark_generator ]
182-
183-
desc "Create RDOC documentation"
184-
task :doc => [ :version, EXT_PARSER_SRC ] do
185-
sh "sdoc -o doc -t '#{PKG_TITLE}' -m README README lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
186-
end
187-
18885
if defined?(Gem) and defined?(Rake::GemPackageTask)
18986
spec_pure = Gem::Specification.new do |s|
19087
s.name = 'json_pure'
@@ -204,7 +101,7 @@ if defined?(Gem) and defined?(Rake::GemPackageTask)
204101
s.extra_rdoc_files << 'README'
205102
s.rdoc_options <<
206103
'--title' << 'JSON implemention for ruby' << '--main' << 'README'
207-
s.test_files.concat Dir['tests/*.rb']
104+
s.test_files.concat Dir['./tests/test_*.rb']
208105

209106
s.author = "Florian Frank"
210107
s.email = "flori@ping.de"
@@ -241,7 +138,7 @@ if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::Extension
241138
s.extra_rdoc_files << 'README'
242139
s.rdoc_options <<
243140
'--title' << 'JSON implemention for Ruby' << '--main' << 'README'
244-
s.test_files.concat Dir['tests/*.rb']
141+
s.test_files.concat Dir['./tests/test_*.rb']
245142

246143
s.author = "Florian Frank"
247144
s.email = "flori@ping.de"
@@ -290,8 +187,19 @@ EOT
290187
end
291188
end
292189

190+
desc "Testing library (pure ruby)"
191+
task :test_pure => :clean do
192+
ENV['JSON'] = 'pure'
193+
ENV['RUBYOPT'] = "-Ilib #{ENV['RUBYOPT']}"
194+
myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
195+
end
196+
197+
desc "Testing library (pure ruby and extension)"
198+
task :test => [ :test_pure, :test_ext ]
199+
200+
293201
if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
294-
file JAVA_PARSER_SRC => RAGEL_PATH do
202+
file JAVA_PARSER_SRC => JAVA_RAGEL_PATH do
295203
cd JAVA_DIR do
296204
if RAGEL_CODEGEN == 'ragel'
297205
sh "ragel Parser.rl -J -o Parser.java"
@@ -301,6 +209,14 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
301209
end
302210
end
303211

212+
desc "Generate parser for java with ragel"
213+
task :ragel => JAVA_PARSER_SRC
214+
215+
desc "Delete the ragel generated Java source"
216+
task :ragel_clean do
217+
rm_rf JAVA_PARSER_SRC
218+
end
219+
304220
JRUBY_JAR = File.join(Config::CONFIG["libdir"], "jruby.jar")
305221
if File.exist?(JRUBY_JAR)
306222
JAVA_SOURCES.each do |src|
@@ -315,16 +231,8 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
315231
warn "WARNING: Cannot find jruby in path => Cannot build jruby extension!"
316232
end
317233

318-
desc "Generate parser for java with ragel"
319-
task :ragel_java => JAVA_PARSER_SRC
320-
321-
desc "Delete the ragel generated Java source"
322-
task :ragel_clean_java do
323-
rm_rf JAVA_PARSER_SRC
324-
end
325-
326234
desc "Compiling jruby extension"
327-
task :compile_jruby => JAVA_CLASSES
235+
task :compile_ext => JAVA_CLASSES
328236

329237
desc "Package the jruby gem"
330238
task :jruby_gem => :create_jar do
@@ -334,12 +242,12 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
334242
end
335243

336244
desc "Testing library (jruby)"
337-
task :test_jruby => :create_jar do
245+
task :test_ext => :create_jar do
338246
ENV['JSON'] = 'ext'
339-
myruby '-S', 'testrb', '-Ilib', *Dir['tests/*.rb']
247+
myruby '-S', 'testrb', '-Ilib', *Dir['./tests/test_*.rb']
340248
end
341249

342-
file JRUBY_PARSER_JAR => :compile_jruby do
250+
file JRUBY_PARSER_JAR => :compile_ext do
343251
cd 'java/src' do
344252
parser_classes = FileList[
345253
"json/ext/ByteListTranscoder*.class",
@@ -357,7 +265,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
357265
desc "Create parser jar"
358266
task :create_parser_jar => JRUBY_PARSER_JAR
359267

360-
file JRUBY_GENERATOR_JAR => :compile_jruby do
268+
file JRUBY_GENERATOR_JAR => :compile_ext do
361269
cd 'java/src' do
362270
generator_classes = FileList[
363271
"json/ext/ByteListTranscoder*.class",
@@ -380,12 +288,103 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
380288

381289
desc "Build all gems and archives for a new release of the jruby extension."
382290
task :release => [ :clean, :version, :jruby_gem ]
383-
384-
desc "Testing library (jruby extension)"
385-
task :test => :test_jruby
386291
else
387-
desc "Testing library (pure ruby and extension)"
388-
task :test => [ :test_pure, :test_ext ]
292+
desc "Compiling extension"
293+
task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
294+
295+
file EXT_PARSER_DL => EXT_PARSER_SRC do
296+
cd EXT_PARSER_DIR do
297+
myruby 'extconf.rb'
298+
sh MAKE
299+
end
300+
cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
301+
end
302+
303+
file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
304+
cd EXT_GENERATOR_DIR do
305+
myruby 'extconf.rb'
306+
sh MAKE
307+
end
308+
cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
309+
end
310+
311+
desc "Testing library (extension)"
312+
task :test_ext => :compile_ext do
313+
ENV['JSON'] = 'ext'
314+
ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
315+
myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
316+
end
317+
318+
desc "Benchmarking parser"
319+
task :benchmark_parser do
320+
ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
321+
myruby 'benchmarks/parser_benchmark.rb'
322+
myruby 'benchmarks/parser2_benchmark.rb'
323+
end
324+
325+
desc "Benchmarking generator"
326+
task :benchmark_generator do
327+
ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
328+
myruby 'benchmarks/generator_benchmark.rb'
329+
myruby 'benchmarks/generator2_benchmark.rb'
330+
end
331+
332+
desc "Benchmarking library"
333+
task :benchmark => [ :benchmark_parser, :benchmark_generator ]
334+
335+
desc "Create RDOC documentation"
336+
task :doc => [ :version, EXT_PARSER_SRC ] do
337+
sh "sdoc -o doc -t '#{PKG_TITLE}' -m README README lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
338+
end
339+
340+
desc "Generate parser with ragel"
341+
task :ragel => EXT_PARSER_SRC
342+
343+
desc "Delete the ragel generated C source"
344+
task :ragel_clean do
345+
rm_rf EXT_PARSER_SRC
346+
end
347+
348+
file EXT_PARSER_SRC => RAGEL_PATH do
349+
cd EXT_PARSER_DIR do
350+
if RAGEL_CODEGEN == 'ragel'
351+
sh "ragel parser.rl -G2 -o parser.c"
352+
else
353+
sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2"
354+
end
355+
end
356+
end
357+
358+
desc "Generate diagrams of ragel parser (ps)"
359+
task :ragel_dot_ps do
360+
root = 'diagrams'
361+
specs = []
362+
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
363+
for s in specs
364+
if RAGEL_DOTGEN == 'ragel'
365+
sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tps -o#{root}/#{s}.ps"
366+
else
367+
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tps -o#{root}/#{s}.ps"
368+
end
369+
end
370+
end
371+
372+
desc "Generate diagrams of ragel parser (png)"
373+
task :ragel_dot_png do
374+
root = 'diagrams'
375+
specs = []
376+
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
377+
for s in specs
378+
if RAGEL_DOTGEN == 'ragel'
379+
sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tpng -o#{root}/#{s}.png"
380+
else
381+
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tpng -o#{root}/#{s}.png"
382+
end
383+
end
384+
end
385+
386+
desc "Generate diagrams of ragel parser"
387+
task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
389388

390389
desc "Build all gems and archives for a new release of json and json_pure."
391390
task :release => [ :clean, :version, :cross, :native, :gem, ] do

ext/json/ext/parser/extconf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
end
1313

1414
have_header("re.h")
15+
have_header("ruby/st.h")
1516
create_makefile 'json/ext/parser'

0 commit comments

Comments
 (0)