ffi-yajl 0.0.1-universal-java → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +21 -201
  3. data/README.md +105 -10
  4. data/bin/ffi-yajl-bench +11 -11
  5. data/ext/ffi_yajl/ext/dlopen/dlopen.c +40 -0
  6. data/ext/ffi_yajl/ext/dlopen/extconf.rb +16 -0
  7. data/ext/ffi_yajl/ext/dlopen/yajl.sym +18 -0
  8. data/ext/ffi_yajl/ext/encoder/encoder.c +270 -115
  9. data/ext/ffi_yajl/ext/encoder/extconf.rb +71 -14
  10. data/ext/ffi_yajl/ext/parser/extconf.rb +71 -14
  11. data/ext/ffi_yajl/ext/parser/parser.c +85 -44
  12. data/lib/ffi_yajl/benchmark/encode.rb +39 -92
  13. data/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb +23 -23
  14. data/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb +24 -30
  15. data/lib/ffi_yajl/benchmark/encode_profile.rb +15 -19
  16. data/lib/ffi_yajl/benchmark/http.rb +21 -25
  17. data/lib/ffi_yajl/benchmark/parse.rb +77 -117
  18. data/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb +27 -27
  19. data/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb +30 -30
  20. data/lib/ffi_yajl/benchmark/parse_profile.rb +14 -18
  21. data/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb +14 -19
  22. data/lib/ffi_yajl/benchmark/parse_stream.rb +28 -28
  23. data/lib/ffi_yajl/benchmark.rb +26 -6
  24. data/lib/ffi_yajl/encoder.rb +47 -6
  25. data/lib/ffi_yajl/ext.rb +37 -10
  26. data/lib/ffi_yajl/ffi/encoder.rb +150 -63
  27. data/lib/ffi_yajl/ffi/parser.rb +82 -64
  28. data/lib/ffi_yajl/ffi.rb +70 -46
  29. data/lib/ffi_yajl/map_library_name.rb +109 -0
  30. data/lib/ffi_yajl/parser.rb +69 -1
  31. data/lib/ffi_yajl/platform.rb +29 -0
  32. data/lib/ffi_yajl/version.rb +23 -1
  33. data/lib/ffi_yajl.rb +44 -8
  34. metadata +25 -238
  35. data/Rakefile +0 -62
  36. data/ext/libyajl2/extconf.rb +0 -65
  37. data/ext/libyajl2/vendored/.git +0 -1
  38. data/ext/libyajl2/vendored/.gitignore +0 -3
  39. data/ext/libyajl2/vendored/BUILDING +0 -23
  40. data/ext/libyajl2/vendored/BUILDING.win32 +0 -27
  41. data/ext/libyajl2/vendored/CMakeLists.txt +0 -79
  42. data/ext/libyajl2/vendored/COPYING +0 -13
  43. data/ext/libyajl2/vendored/ChangeLog +0 -175
  44. data/ext/libyajl2/vendored/README +0 -74
  45. data/ext/libyajl2/vendored/TODO +0 -9
  46. data/ext/libyajl2/vendored/YAJLDoc.cmake +0 -26
  47. data/ext/libyajl2/vendored/configure +0 -79
  48. data/ext/libyajl2/vendored/example/CMakeLists.txt +0 -23
  49. data/ext/libyajl2/vendored/example/README.md +0 -7
  50. data/ext/libyajl2/vendored/example/parse_config.c +0 -69
  51. data/ext/libyajl2/vendored/example/sample.config +0 -101
  52. data/ext/libyajl2/vendored/perf/CMakeLists.txt +0 -23
  53. data/ext/libyajl2/vendored/perf/documents.c +0 -1418
  54. data/ext/libyajl2/vendored/perf/documents.h +0 -28
  55. data/ext/libyajl2/vendored/perf/perftest.c +0 -134
  56. data/ext/libyajl2/vendored/reformatter/CMakeLists.txt +0 -39
  57. data/ext/libyajl2/vendored/reformatter/json_reformat.c +0 -194
  58. data/ext/libyajl2/vendored/src/CMakeLists.txt +0 -86
  59. data/ext/libyajl2/vendored/src/YAJL.dxy +0 -1258
  60. data/ext/libyajl2/vendored/src/api/yajl_common.h +0 -75
  61. data/ext/libyajl2/vendored/src/api/yajl_gen.h +0 -157
  62. data/ext/libyajl2/vendored/src/api/yajl_parse.h +0 -226
  63. data/ext/libyajl2/vendored/src/api/yajl_tree.h +0 -185
  64. data/ext/libyajl2/vendored/src/api/yajl_version.h.cmake +0 -23
  65. data/ext/libyajl2/vendored/src/yajl +0 -33
  66. data/ext/libyajl2/vendored/src/yajl.c +0 -175
  67. data/ext/libyajl2/vendored/src/yajl.pc.cmake +0 -9
  68. data/ext/libyajl2/vendored/src/yajl_alloc.c +0 -52
  69. data/ext/libyajl2/vendored/src/yajl_alloc.h +0 -34
  70. data/ext/libyajl2/vendored/src/yajl_buf.c +0 -103
  71. data/ext/libyajl2/vendored/src/yajl_buf.h +0 -57
  72. data/ext/libyajl2/vendored/src/yajl_bytestack.h +0 -69
  73. data/ext/libyajl2/vendored/src/yajl_encode.c +0 -220
  74. data/ext/libyajl2/vendored/src/yajl_encode.h +0 -34
  75. data/ext/libyajl2/vendored/src/yajl_gen.c +0 -354
  76. data/ext/libyajl2/vendored/src/yajl_lex.c +0 -763
  77. data/ext/libyajl2/vendored/src/yajl_lex.h +0 -117
  78. data/ext/libyajl2/vendored/src/yajl_parser.c +0 -498
  79. data/ext/libyajl2/vendored/src/yajl_parser.h +0 -78
  80. data/ext/libyajl2/vendored/src/yajl_tree.c +0 -503
  81. data/ext/libyajl2/vendored/src/yajl_version.c +0 -7
  82. data/ext/libyajl2/vendored/test/CMakeLists.txt +0 -23
  83. data/ext/libyajl2/vendored/test/cases/ac_difficult_json_c_test_case_with_comments.json +0 -1
  84. data/ext/libyajl2/vendored/test/cases/ac_difficult_json_c_test_case_with_comments.json.gold +0 -36
  85. data/ext/libyajl2/vendored/test/cases/ac_simple_with_comments.json +0 -11
  86. data/ext/libyajl2/vendored/test/cases/ac_simple_with_comments.json.gold +0 -9
  87. data/ext/libyajl2/vendored/test/cases/ag_false_then_garbage.json +0 -1
  88. data/ext/libyajl2/vendored/test/cases/ag_false_then_garbage.json.gold +0 -2
  89. data/ext/libyajl2/vendored/test/cases/ag_null_then_garbage.json +0 -1
  90. data/ext/libyajl2/vendored/test/cases/ag_null_then_garbage.json.gold +0 -2
  91. data/ext/libyajl2/vendored/test/cases/ag_true_then_garbage.json +0 -1
  92. data/ext/libyajl2/vendored/test/cases/ag_true_then_garbage.json.gold +0 -2
  93. data/ext/libyajl2/vendored/test/cases/am_eof.json +0 -1
  94. data/ext/libyajl2/vendored/test/cases/am_eof.json.gold +0 -4
  95. data/ext/libyajl2/vendored/test/cases/am_integers.json +0 -1
  96. data/ext/libyajl2/vendored/test/cases/am_integers.json.gold +0 -3
  97. data/ext/libyajl2/vendored/test/cases/am_multiple.json +0 -3
  98. data/ext/libyajl2/vendored/test/cases/am_multiple.json.gold +0 -5
  99. data/ext/libyajl2/vendored/test/cases/am_stuff.json +0 -7
  100. data/ext/libyajl2/vendored/test/cases/am_stuff.json.gold +0 -14
  101. data/ext/libyajl2/vendored/test/cases/ap_array_open.json +0 -1
  102. data/ext/libyajl2/vendored/test/cases/ap_array_open.json.gold +0 -2
  103. data/ext/libyajl2/vendored/test/cases/ap_eof_str.json +0 -1
  104. data/ext/libyajl2/vendored/test/cases/ap_eof_str.json.gold +0 -1
  105. data/ext/libyajl2/vendored/test/cases/ap_map_open.json +0 -1
  106. data/ext/libyajl2/vendored/test/cases/ap_map_open.json.gold +0 -2
  107. data/ext/libyajl2/vendored/test/cases/ap_partial_ok.json +0 -1
  108. data/ext/libyajl2/vendored/test/cases/ap_partial_ok.json.gold +0 -4
  109. data/ext/libyajl2/vendored/test/cases/array.json +0 -6
  110. data/ext/libyajl2/vendored/test/cases/array.json.gold +0 -22
  111. data/ext/libyajl2/vendored/test/cases/array_close.json +0 -1
  112. data/ext/libyajl2/vendored/test/cases/array_close.json.gold +0 -2
  113. data/ext/libyajl2/vendored/test/cases/bignums.json +0 -1
  114. data/ext/libyajl2/vendored/test/cases/bignums.json.gold +0 -5
  115. data/ext/libyajl2/vendored/test/cases/bogus_char.json +0 -4
  116. data/ext/libyajl2/vendored/test/cases/bogus_char.json.gold +0 -10
  117. data/ext/libyajl2/vendored/test/cases/codepoints_from_unicode_org.json +0 -1
  118. data/ext/libyajl2/vendored/test/cases/codepoints_from_unicode_org.json.gold +0 -2
  119. data/ext/libyajl2/vendored/test/cases/deep_arrays.json +0 -1
  120. data/ext/libyajl2/vendored/test/cases/deep_arrays.json.gold +0 -2049
  121. data/ext/libyajl2/vendored/test/cases/difficult_json_c_test_case.json +0 -1
  122. data/ext/libyajl2/vendored/test/cases/difficult_json_c_test_case.json.gold +0 -36
  123. data/ext/libyajl2/vendored/test/cases/doubles.json +0 -1
  124. data/ext/libyajl2/vendored/test/cases/doubles.json.gold +0 -7
  125. data/ext/libyajl2/vendored/test/cases/doubles_in_array.json +0 -1
  126. data/ext/libyajl2/vendored/test/cases/doubles_in_array.json.gold +0 -8
  127. data/ext/libyajl2/vendored/test/cases/empty_array.json +0 -1
  128. data/ext/libyajl2/vendored/test/cases/empty_array.json.gold +0 -3
  129. data/ext/libyajl2/vendored/test/cases/empty_string.json +0 -1
  130. data/ext/libyajl2/vendored/test/cases/empty_string.json.gold +0 -2
  131. data/ext/libyajl2/vendored/test/cases/escaped_bulgarian.json +0 -4
  132. data/ext/libyajl2/vendored/test/cases/escaped_bulgarian.json.gold +0 -7
  133. data/ext/libyajl2/vendored/test/cases/escaped_foobar.json +0 -1
  134. data/ext/libyajl2/vendored/test/cases/escaped_foobar.json.gold +0 -2
  135. data/ext/libyajl2/vendored/test/cases/false.json +0 -1
  136. data/ext/libyajl2/vendored/test/cases/false.json.gold +0 -2
  137. data/ext/libyajl2/vendored/test/cases/fg_false_then_garbage.json +0 -1
  138. data/ext/libyajl2/vendored/test/cases/fg_false_then_garbage.json.gold +0 -3
  139. data/ext/libyajl2/vendored/test/cases/fg_issue_7.json +0 -1
  140. data/ext/libyajl2/vendored/test/cases/fg_issue_7.json.gold +0 -3
  141. data/ext/libyajl2/vendored/test/cases/fg_null_then_garbage.json +0 -1
  142. data/ext/libyajl2/vendored/test/cases/fg_null_then_garbage.json.gold +0 -3
  143. data/ext/libyajl2/vendored/test/cases/fg_true_then_garbage.json +0 -1
  144. data/ext/libyajl2/vendored/test/cases/fg_true_then_garbage.json.gold +0 -3
  145. data/ext/libyajl2/vendored/test/cases/four_byte_utf8.json +0 -2
  146. data/ext/libyajl2/vendored/test/cases/four_byte_utf8.json.gold +0 -5
  147. data/ext/libyajl2/vendored/test/cases/high_overflow.json +0 -1
  148. data/ext/libyajl2/vendored/test/cases/high_overflow.json.gold +0 -2
  149. data/ext/libyajl2/vendored/test/cases/integers.json +0 -3
  150. data/ext/libyajl2/vendored/test/cases/integers.json.gold +0 -14
  151. data/ext/libyajl2/vendored/test/cases/invalid_utf8.json +0 -1
  152. data/ext/libyajl2/vendored/test/cases/invalid_utf8.json.gold +0 -3
  153. data/ext/libyajl2/vendored/test/cases/isolated_surrogate_marker.json +0 -1
  154. data/ext/libyajl2/vendored/test/cases/isolated_surrogate_marker.json.gold +0 -2
  155. data/ext/libyajl2/vendored/test/cases/leading_zero_in_number.json +0 -1
  156. data/ext/libyajl2/vendored/test/cases/leading_zero_in_number.json.gold +0 -5
  157. data/ext/libyajl2/vendored/test/cases/lonely_minus_sign.json +0 -7
  158. data/ext/libyajl2/vendored/test/cases/lonely_minus_sign.json.gold +0 -9
  159. data/ext/libyajl2/vendored/test/cases/lonely_number.json +0 -1
  160. data/ext/libyajl2/vendored/test/cases/lonely_number.json.gold +0 -2
  161. data/ext/libyajl2/vendored/test/cases/low_overflow.json +0 -1
  162. data/ext/libyajl2/vendored/test/cases/low_overflow.json.gold +0 -2
  163. data/ext/libyajl2/vendored/test/cases/map_close.json +0 -1
  164. data/ext/libyajl2/vendored/test/cases/map_close.json.gold +0 -2
  165. data/ext/libyajl2/vendored/test/cases/missing_integer_after_decimal_point.json +0 -1
  166. data/ext/libyajl2/vendored/test/cases/missing_integer_after_decimal_point.json.gold +0 -2
  167. data/ext/libyajl2/vendored/test/cases/missing_integer_after_exponent.json +0 -1
  168. data/ext/libyajl2/vendored/test/cases/missing_integer_after_exponent.json.gold +0 -2
  169. data/ext/libyajl2/vendored/test/cases/multiple.json +0 -3
  170. data/ext/libyajl2/vendored/test/cases/multiple.json.gold +0 -4
  171. data/ext/libyajl2/vendored/test/cases/non_utf8_char_in_string.json +0 -1
  172. data/ext/libyajl2/vendored/test/cases/non_utf8_char_in_string.json.gold +0 -8
  173. data/ext/libyajl2/vendored/test/cases/np_partial_bad.json +0 -1
  174. data/ext/libyajl2/vendored/test/cases/np_partial_bad.json.gold +0 -5
  175. data/ext/libyajl2/vendored/test/cases/null.json +0 -1
  176. data/ext/libyajl2/vendored/test/cases/null.json.gold +0 -2
  177. data/ext/libyajl2/vendored/test/cases/nulls_and_bools.json +0 -5
  178. data/ext/libyajl2/vendored/test/cases/nulls_and_bools.json.gold +0 -9
  179. data/ext/libyajl2/vendored/test/cases/simple.json +0 -5
  180. data/ext/libyajl2/vendored/test/cases/simple.json.gold +0 -9
  181. data/ext/libyajl2/vendored/test/cases/simple_with_comments.json +0 -11
  182. data/ext/libyajl2/vendored/test/cases/simple_with_comments.json.gold +0 -5
  183. data/ext/libyajl2/vendored/test/cases/string_invalid_escape.json +0 -1
  184. data/ext/libyajl2/vendored/test/cases/string_invalid_escape.json.gold +0 -3
  185. data/ext/libyajl2/vendored/test/cases/string_invalid_hex_char.json +0 -1
  186. data/ext/libyajl2/vendored/test/cases/string_invalid_hex_char.json.gold +0 -2
  187. data/ext/libyajl2/vendored/test/cases/string_with_escapes.json +0 -3
  188. data/ext/libyajl2/vendored/test/cases/string_with_escapes.json.gold +0 -7
  189. data/ext/libyajl2/vendored/test/cases/string_with_invalid_newline.json +0 -2
  190. data/ext/libyajl2/vendored/test/cases/string_with_invalid_newline.json.gold +0 -2
  191. data/ext/libyajl2/vendored/test/cases/three_byte_utf8.json +0 -1
  192. data/ext/libyajl2/vendored/test/cases/three_byte_utf8.json.gold +0 -7
  193. data/ext/libyajl2/vendored/test/cases/true.json +0 -1
  194. data/ext/libyajl2/vendored/test/cases/true.json.gold +0 -2
  195. data/ext/libyajl2/vendored/test/cases/unescaped_bulgarian.json +0 -1
  196. data/ext/libyajl2/vendored/test/cases/unescaped_bulgarian.json.gold +0 -4
  197. data/ext/libyajl2/vendored/test/cases/zerobyte.json +0 -1
  198. data/ext/libyajl2/vendored/test/cases/zerobyte.json.gold +0 -0
  199. data/ext/libyajl2/vendored/test/run_tests.sh +0 -94
  200. data/ext/libyajl2/vendored/test/yajl_test.c +0 -281
  201. data/ext/libyajl2/vendored/verify/CMakeLists.txt +0 -39
  202. data/ext/libyajl2/vendored/verify/json_verify.c +0 -116
  203. data/lib/ffi_yajl/json_gem.rb +0 -121
  204. data/lib/libyajl.so +0 -0
  205. data/lib/libyajl.so.2 +0 -0
  206. data/lib/libyajl.so.2.0.5 +0 -0
  207. data/lib/libyajl_s.a +0 -0
  208. data/spec/ffi_yajl/encoder_spec.rb +0 -39
  209. data/spec/ffi_yajl/json_gem_spec.rb +0 -355
  210. data/spec/ffi_yajl/parser_spec.rb +0 -78
  211. data/spec/spec_helper.rb +0 -14
@@ -1,94 +1,96 @@
1
-
2
- require 'ffi_yajl/ffi'
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2013-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3
22
 
4
23
  module FFI_Yajl
5
24
  module FFI
6
25
  module Parser
7
- attr_accessor :stack, :key_stack, :key, :finished
8
-
9
- #
10
- # stack used to build up our complex object
11
- #
12
- def stack
13
- @stack ||= Array.new
14
- end
15
-
16
- def set_value(val)
17
- case stack.last
18
- when Hash
19
- raise FFI_Yajl::ParseError.new("internal error: missing key in parse") if key.nil?
20
- stack.last[key] = val
21
- when Array
22
- stack.last.push(val)
23
- else
24
- raise FFI_Yajl::ParseError.new("internal error: object not a hash or array")
25
- end
26
- end
27
-
28
- def stack_pop
29
- if stack.length > 1
30
- set_value( stack.pop )
31
- else
32
- @finished = stack.pop
26
+ def set_value(val) # rubocop:disable Naming/AccessorMethodName
27
+ case stack.last
28
+ when Hash
29
+ raise FFI_Yajl::ParseError, "internal error: missing key in parse" if key.nil?
30
+ if @opts[:unique_key_checking] && stack.last.key?(key)
31
+ raise FFI_Yajl::ParseError, "repeated key: #{key}"
33
32
  end
34
- end
35
33
 
36
- #
37
- # stack to keep track of keys as we create nested hashes
38
- #
39
- def key_stack
40
- @key_stack ||= Array.new
34
+ stack.last[key] = val
35
+ when Array
36
+ stack.last.push(val)
37
+ else
38
+ stack.push(val)
41
39
  end
40
+ end
42
41
 
43
- def key_push
44
- key_stack.push(key)
45
- end
42
+ def stack_pop
43
+ set_value( stack.pop ) if stack.length > 1
44
+ end
46
45
 
47
- def key_pop
48
- @key = key_stack.pop()
49
- end
46
+ def key_push
47
+ key_stack.push(key)
48
+ end
50
49
 
50
+ def key_pop
51
+ @key = key_stack.pop
52
+ end
51
53
 
52
54
  def setup_callbacks
53
55
  @null_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
54
56
  set_value(nil)
55
57
  1
56
58
  end
57
- @boolean_callback = ::FFI::Function.new(:int, [:pointer, :int]) do |ctx, boolval|
59
+ @boolean_callback = ::FFI::Function.new(:int, %i{pointer int}) do |ctx, boolval|
58
60
  set_value(boolval == 1 ? true : false)
59
61
  1
60
62
  end
61
- @integer_callback = ::FFI::Function.new(:int, [:pointer, :long_long]) do |ctx, intval|
63
+ @integer_callback = ::FFI::Function.new(:int, %i{pointer long_long}) do |ctx, intval|
62
64
  set_value(intval)
63
65
  1
64
66
  end
65
- @number_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t ]) do |ctx, stringval, stringlen|
66
- s = stringval.slice(0,stringlen)
67
- s.force_encoding('UTF-8') if defined? Encoding
67
+ @number_callback = ::FFI::Function.new(:int, %i{pointer string size_t}) do |ctx, stringval, stringlen|
68
+ s = stringval.slice(0, stringlen)
69
+ s.force_encoding("UTF-8") if defined? Encoding
68
70
  # XXX: I can't think of a better way to do this right now. need to call to_f if and only if its a float.
69
- v = ( s =~ /\./ ) ? s.to_f : s.to_i
71
+ v = ( s =~ /[\.eE]/ ) ? s.to_f : s.to_i
70
72
  set_value(v)
71
73
  1
72
74
  end
73
- @double_callback = ::FFI::Function.new(:int, [:pointer, :double]) do |ctx, doubleval|
75
+ @double_callback = ::FFI::Function.new(:int, %i{pointer double}) do |ctx, doubleval|
74
76
  set_value(doubleval)
75
77
  1
76
78
  end
77
- @string_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, stringval, stringlen|
78
- s = stringval.slice(0,stringlen)
79
- s.force_encoding('UTF-8') if defined? Encoding
79
+ @string_callback = ::FFI::Function.new(:int, %i{pointer string size_t}) do |ctx, stringval, stringlen|
80
+ s = stringval.slice(0, stringlen)
81
+ s.force_encoding("UTF-8") if defined? Encoding
80
82
  set_value(s)
81
83
  1
82
84
  end
83
85
  @start_map_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
84
86
  key_push # for key => { } case, save the key
85
- stack.push(Hash.new)
87
+ stack.push({})
86
88
  1
87
89
  end
88
- @map_key_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, key, keylen|
89
- s = key.slice(0,keylen)
90
- s.force_encoding('UTF-8') if defined? Encoding
91
- self.key = s
90
+ @map_key_callback = ::FFI::Function.new(:int, %i{pointer string size_t}) do |ctx, key, keylen|
91
+ s = key.slice(0, keylen)
92
+ s.force_encoding("UTF-8") if defined? Encoding
93
+ self.key = @opts[:symbolize_keys] ? s.to_sym : s
92
94
  1
93
95
  end
94
96
  @end_map_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
@@ -98,7 +100,7 @@ module FFI_Yajl
98
100
  end
99
101
  @start_array_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
100
102
  key_push # for key => [ ] case, save the key
101
- stack.push(Array.new)
103
+ stack.push([])
102
104
  1
103
105
  end
104
106
  @end_array_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
@@ -108,8 +110,7 @@ module FFI_Yajl
108
110
  end
109
111
  end
110
112
 
111
-
112
- def do_yajl_parse(str, opts = {})
113
+ def do_yajl_parse(str, yajl_opts = {})
113
114
  setup_callbacks
114
115
  callback_ptr = ::FFI::MemoryPointer.new(::FFI_Yajl::YajlCallbacks)
115
116
  callbacks = ::FFI_Yajl::YajlCallbacks.new(callback_ptr)
@@ -125,21 +126,38 @@ module FFI_Yajl
125
126
  callbacks[:yajl_start_array] = @start_array_callback
126
127
  callbacks[:yajl_end_array] = @end_array_callback
127
128
  yajl_handle = ::FFI_Yajl.yajl_alloc(callback_ptr, nil, nil)
128
- if ( stat = ::FFI_Yajl.yajl_parse(yajl_handle, str, str.bytesize) != :yajl_status_ok )
129
+
130
+ # configure the yajl parser
131
+ if yajl_opts[:yajl_allow_comments]
132
+ ::FFI_Yajl.yajl_config(yajl_handle, :yajl_allow_comments, :int, 1)
133
+ end
134
+ if yajl_opts[:yajl_dont_validate_strings]
135
+ ::FFI_Yajl.yajl_config(yajl_handle, :yajl_dont_validate_strings, :int, 1)
136
+ end
137
+ if yajl_opts[:yajl_allow_trailing_garbage]
138
+ ::FFI_Yajl.yajl_config(yajl_handle, :yajl_allow_trailing_garbage, :int, 1)
139
+ end
140
+ if yajl_opts[:yajl_allow_multiple_values]
141
+ ::FFI_Yajl.yajl_config(yajl_handle, :yajl_allow_multiple_values, :int, 1)
142
+ end
143
+ if yajl_opts[:yajl_allow_partial_values]
144
+ ::FFI_Yajl.yajl_config(yajl_handle, :yajl_allow_partial_values, :int, 1)
145
+ end
146
+
147
+ if ::FFI_Yajl.yajl_parse(yajl_handle, str, str.bytesize) != :yajl_status_ok
129
148
  # FIXME: dup the error and call yajl_free_error?
130
149
  error = ::FFI_Yajl.yajl_get_error(yajl_handle, 1, str, str.bytesize)
131
- raise ::FFI_Yajl::ParseError.new(error)
150
+ raise ::FFI_Yajl::ParseError, error
132
151
  end
133
- if ( stat = FFI_Yajl.yajl_complete_parse(yajl_handle) != :yajl_status_ok )
152
+ if ::FFI_Yajl.yajl_complete_parse(yajl_handle) != :yajl_status_ok
134
153
  # FIXME: dup the error and call yajl_free_error?
135
154
  error = ::FFI_Yajl.yajl_get_error(yajl_handle, 1, str, str.bytesize)
136
- raise ::FFI_Yajl::ParseError.new(error)
155
+ raise ::FFI_Yajl::ParseError, error
137
156
  end
138
- finished
157
+ stack.pop
139
158
  ensure
140
159
  ::FFI_Yajl.yajl_free(yajl_handle) if yajl_handle
141
160
  end
142
161
  end
143
162
  end
144
163
  end
145
-
data/lib/ffi_yajl/ffi.rb CHANGED
@@ -1,19 +1,44 @@
1
- require 'rubygems'
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2013-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ require "rubygems" unless defined?(Gem)
24
+
25
+ require "libyajl2"
26
+ begin
27
+ require "ffi" unless defined?(FFI)
28
+ rescue LoadError
29
+ $stderr.puts "FATAL: to use the ffi extension instead of the compiled C extension, the ffi gem must be installed"
30
+ $stderr.puts " (it is optional, so you must include it in your bundle manually)"
31
+ exit 1
32
+ end
2
33
 
3
- require 'ffi'
34
+ require_relative "map_library_name"
4
35
 
5
36
  module FFI_Yajl
6
37
  extend ::FFI::Library
7
38
 
8
- libname = ::FFI.map_library_name("yajl")
9
- libpath = File.expand_path(File.join(File.dirname(__FILE__), "..", libname))
39
+ extend FFI_Yajl::MapLibraryName
10
40
 
11
- if File.file?(libpath)
12
- # use our vendored version of libyajl2 if we find it installed
13
- ffi_lib libpath
14
- else
15
- ffi_lib 'yajl'
16
- end
41
+ ffi_open_yajl_library
17
42
 
18
43
  class YajlCallbacks < ::FFI::Struct
19
44
  layout :yajl_null, :pointer,
@@ -29,37 +54,37 @@ module FFI_Yajl
29
54
  :yajl_end_array, :pointer
30
55
  end
31
56
 
32
- enum :yajl_status, [
33
- :yajl_status_ok,
34
- :yajl_status_client_canceled,
35
- :yajl_status_insufficient_data,
36
- :yajl_status_error,
37
- ]
38
-
39
- # FFI::Enums are slow, should remove the rest
40
- # enum :yajl_gen_status, [
41
- # :yajl_gen_status_ok,
42
- # :yajl_gen_keys_must_be_strings,
43
- # :yajl_max_depth_exceeded,
44
- # :yajl_gen_in_error_state,
45
- # :yajl_gen_generation_complete,
46
- # :yajl_gen_invalid_number,
47
- # :yajl_gen_no_buf,
48
- # ]
57
+ enum :yajl_status, %i{
58
+ yajl_status_ok
59
+ yajl_status_client_canceled
60
+ yajl_status_insufficient_data
61
+ yajl_status_error
62
+ }
63
+
64
+ # FFI::Enums are slow, should remove the rest
65
+ # enum :yajl_gen_status, [
66
+ # :yajl_gen_status_ok,
67
+ # :yajl_gen_keys_must_be_strings,
68
+ # :yajl_max_depth_exceeded,
69
+ # :yajl_gen_in_error_state,
70
+ # :yajl_gen_generation_complete,
71
+ # :yajl_gen_invalid_number,
72
+ # :yajl_gen_no_buf,
73
+ # ]
49
74
 
50
75
  enum :yajl_option, [
51
76
  :yajl_allow_comments, 0x01,
52
77
  :yajl_dont_validate_strings, 0x02,
53
78
  :yajl_allow_trailing_garbage, 0x04,
54
79
  :yajl_allow_multiple_values, 0x08,
55
- :yajl_allow_partial_values, 0x10,
80
+ :yajl_allow_partial_values, 0x10
56
81
  ]
57
82
 
58
83
  enum :yajl_gen_option, [
59
84
  :yajl_gen_beautify, 0x01,
60
85
  :yajl_gen_indent_string, 0x02,
61
86
  :yajl_gen_print_callback, 0x04,
62
- :yajl_gen_validate_utf8, 0x08,
87
+ :yajl_gen_validate_utf8, 0x08
63
88
  ]
64
89
 
65
90
  typedef :pointer, :yajl_handle
@@ -72,22 +97,22 @@ module FFI_Yajl
72
97
  # const char *yajl_status_to_string (yajl_status code)
73
98
  attach_function :yajl_status_to_string, [ :yajl_status ], :string
74
99
  # yajl_handle yajl_alloc(const yajl_callbacks * callbacks, yajl_alloc_funcs * afs, void * ctx)
75
- attach_function :yajl_alloc, [:pointer, :pointer, :pointer], :yajl_handle
100
+ attach_function :yajl_alloc, %i{pointer pointer pointer}, :yajl_handle
76
101
  # void yajl_free (yajl_handle handle)
77
102
  attach_function :yajl_free, [:yajl_handle], :void
78
103
  # yajl_status yajl_parse (yajl_handle hand, const unsigned char *jsonText, unsigned int jsonTextLength)
79
- attach_function :yajl_parse, [:yajl_handle, :ustring, :uint], :yajl_status
104
+ attach_function :yajl_parse, %i{yajl_handle ustring uint}, :yajl_status
80
105
  # yajl_status yajl_parse_complete (yajl_handle hand)
81
106
  attach_function :yajl_complete_parse, [:yajl_handle], :yajl_status
82
107
  # unsigned char *yajl_get_error (yajl_handle hand, int verbose, const unsigned char *jsonText, unsigned int jsonTextLength)
83
- attach_function :yajl_get_error, [:yajl_handle, :int, :ustring, :int], :ustring
108
+ attach_function :yajl_get_error, %i{yajl_handle int ustring int}, :ustring
84
109
  # void yajl_free_error (yajl_handle hand, unsigned char *str)
85
- attach_function :yajl_free_error, [:yajl_handle, :ustring], :void
110
+ attach_function :yajl_free_error, %i{yajl_handle ustring}, :void
86
111
 
87
112
  #
88
- attach_function :yajl_config, [:yajl_handle, :yajl_option, :int], :int
113
+ attach_function :yajl_config, %i{yajl_handle yajl_option varargs}, :int
89
114
 
90
- attach_function :yajl_gen_config, [:yajl_gen, :yajl_gen_option, :varargs], :int
115
+ attach_function :yajl_gen_config, %i{yajl_gen yajl_gen_option varargs}, :int
91
116
 
92
117
  # yajl_gen yajl_gen_alloc (const yajl_alloc_funcs *allocFuncs)
93
118
  attach_function :yajl_gen_alloc, [:pointer], :yajl_gen
@@ -96,34 +121,33 @@ module FFI_Yajl
96
121
  # void yajl_gen_free (yajl_gen handle)
97
122
  attach_function :yajl_gen_free, [:yajl_gen], :void
98
123
 
99
- attach_function :yajl_gen_integer, [:yajl_gen, :long_long], :int
100
- attach_function :yajl_gen_double, [:yajl_gen, :double], :int
101
- attach_function :yajl_gen_number, [:yajl_gen, :ustring, :int], :int
102
- attach_function :yajl_gen_string, [:yajl_gen, :ustring, :int], :int
124
+ attach_function :yajl_gen_integer, %i{yajl_gen long_long}, :int
125
+ attach_function :yajl_gen_double, %i{yajl_gen double}, :int
126
+ attach_function :yajl_gen_number, %i{yajl_gen ustring int}, :int
127
+ attach_function :yajl_gen_string, %i{yajl_gen ustring int}, :int
103
128
  attach_function :yajl_gen_null, [:yajl_gen], :int
104
- attach_function :yajl_gen_bool, [:yajl_gen, :int], :int
129
+ attach_function :yajl_gen_bool, %i{yajl_gen int}, :int
105
130
  attach_function :yajl_gen_map_open, [:yajl_gen], :int
106
131
  attach_function :yajl_gen_map_close, [:yajl_gen], :int
107
132
  attach_function :yajl_gen_array_open, [:yajl_gen], :int
108
133
  attach_function :yajl_gen_array_close, [:yajl_gen], :int
109
134
  # yajl_gen_status yajl_gen_get_buf (yajl_gen hand, const unsigned char **buf, unsigned int *len)
110
- attach_function :yajl_gen_get_buf, [:yajl_gen, :pointer ,:pointer], :int
135
+ attach_function :yajl_gen_get_buf, %i{yajl_gen pointer pointer}, :int
111
136
  # void yajl_gen_clear (yajl_gen hand)
112
137
  attach_function :yajl_gen_clear, [:yajl_gen], :void
113
-
114
138
  end
115
139
 
116
- require 'ffi_yajl/encoder'
117
- require 'ffi_yajl/parser'
140
+ require_relative "encoder"
141
+ require_relative "parser"
118
142
 
119
143
  module FFI_Yajl
120
144
  class Parser
121
- require 'ffi_yajl/ffi/parser'
145
+ require_relative "ffi/parser"
122
146
  include FFI_Yajl::FFI::Parser
123
147
  end
124
148
 
125
149
  class Encoder
126
- require 'ffi_yajl/ffi/encoder'
150
+ require_relative "ffi/encoder"
127
151
  include FFI_Yajl::FFI::Encoder
128
152
  end
129
153
  end
@@ -0,0 +1,109 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2013-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ require "libyajl2"
24
+
25
+ # Mixin for use in finding the right yajl library on the system. The 'caller'
26
+ # needs to also mixin either the FFI module or the DLopen module. Those are
27
+ # deliberately not mixed in to avoid loading the dlopen module in the ffi
28
+ # codepath (which fails on jruby which does not have that C extension).
29
+
30
+ module FFI_Yajl
31
+ module MapLibraryName
32
+ private
33
+
34
+ # Stub for tests to override the host_os
35
+ #
36
+ # @api private
37
+ # @return [Array<String>] lower case ruby host_os string
38
+ def host_os
39
+ RbConfig::CONFIG["host_os"].downcase
40
+ end
41
+
42
+ # Array of yajl library names on the platform. Some platforms like Windows
43
+ # and Mac may have different names/extensions.
44
+ #
45
+ # @api private
46
+ # @return [Array<String>] Array of yajl library names for platform
47
+ def library_names
48
+ case host_os
49
+ when /mingw|mswin/
50
+ [ "libyajl.so", "yajl.dll" ]
51
+ when /cygwin/
52
+ [ "libyajl.so", "cygyajl.dll" ]
53
+ when /darwin/
54
+ [ "libyajl.bundle", "libyajl.dylib" ]
55
+ else
56
+ [ "libyajl.so" ]
57
+ end
58
+ end
59
+
60
+ # Array of yajl library names prepended with the libyajl2 path to use to
61
+ # load those directly and bypass the system libyajl by default. Since
62
+ # these are full paths, this API checks to ensure that the file exists on
63
+ # the filesystem. May return an empty array.
64
+ #
65
+ # @api private
66
+ # @return [Array<String>] Array of full paths to libyajl2 gem libraries
67
+ def expanded_library_names
68
+ library_names.map do |libname|
69
+ pathname = File.expand_path(File.join(Libyajl2.opt_path, libname))
70
+ pathname if File.file?(pathname)
71
+ end.compact
72
+ end
73
+
74
+ # Iterate across the expanded library names in the libyajl2-gem and then
75
+ # attempt to load the system libraries. Uses the native dlopen extension
76
+ # that ships in this gem.
77
+ #
78
+ # @api private
79
+ def dlopen_yajl_library
80
+ found = false
81
+ ( expanded_library_names + library_names ).each do |libname|
82
+
83
+ dlopen(libname)
84
+ found = true
85
+ break
86
+ rescue ArgumentError
87
+
88
+ end
89
+ raise "cannot find yajl library for platform" unless found
90
+ end
91
+
92
+ # Iterate across the expanded library names in the libyajl2-gem and attempt
93
+ # to load them. If they are missing just use `ffi_lib 'yajl'` to accept
94
+ # the FFI default algorithm to find the library.
95
+ #
96
+ # @api private
97
+ def ffi_open_yajl_library
98
+ found = false
99
+ expanded_library_names.each do |libname|
100
+
101
+ ffi_lib libname
102
+ found = true
103
+ rescue LoadError
104
+
105
+ end
106
+ ffi_lib "yajl" unless found
107
+ end
108
+ end
109
+ end
@@ -1,21 +1,89 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2013-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
22
 
2
23
  module FFI_Yajl
3
24
  class ParseError < StandardError; end
25
+
4
26
  class Parser
27
+ attr_writer :stack, :key_stack
28
+ attr_accessor :key, :finished
29
+
5
30
  attr_accessor :opts
6
31
 
32
+ #
33
+ # stack used to build up our complex object
34
+ #
35
+ def stack
36
+ @stack ||= []
37
+ end
38
+
39
+ #
40
+ # stack to keep track of keys as we create nested hashes
41
+ #
42
+ def key_stack
43
+ @key_stack ||= []
44
+ end
45
+
7
46
  def self.parse(obj, *args)
8
47
  new(*args).parse(obj)
9
48
  end
10
49
 
11
50
  def initialize(opts = {})
12
- @opts = opts
51
+ @opts = opts ? opts.dup : {}
52
+ # JSON gem uses 'symbolize_names' and ruby-yajl supports this as well
53
+ @opts[:symbolize_keys] = true if @opts[:symbolize_names]
13
54
  end
14
55
 
15
56
  def parse(str)
57
+ raise FFI_Yajl::ParseError, "input must be a string or IO" unless str.is_a?(String) || str.respond_to?(:read)
58
+
16
59
  # initialization that we can do in pure ruby
17
60
  yajl_opts = {}
18
61
 
62
+ if @opts[:check_utf8] == false && @opts[:dont_validate_strings] == false
63
+ raise ArgumentError, "options check_utf8 and dont_validate_strings are both false which conflict"
64
+ end
65
+ if @opts[:check_utf8] == true && @opts[:dont_validate_strings] == true
66
+ raise ArgumentError, "options check_utf8 and dont_validate_strings are both true which conflict"
67
+ end
68
+
69
+ yajl_opts[:yajl_allow_comments] = true
70
+
71
+ if @opts.key?(:allow_comments)
72
+ yajl_opts[:yajl_allow_comments] = @opts[:allow_comments]
73
+ end
74
+
75
+ yajl_opts[:yajl_dont_validate_strings] = (@opts[:check_utf8] == false || @opts[:dont_validate_strings])
76
+ yajl_opts[:yajl_allow_trailing_garbage] = @opts[:allow_trailing_garbage]
77
+ yajl_opts[:yajl_allow_multiple_values] = @opts[:allow_multiple_values]
78
+ yajl_opts[:yajl_allow_partial_values] = @opts[:allow_partial_values]
79
+
80
+ yajl_opts[:unique_key_checking] = @opts[:unique_key_checking]
81
+
82
+ # XXX: bug-compat with ruby-yajl
83
+ return nil if str == ""
84
+
85
+ str = str.read if str.respond_to?(:read)
86
+
19
87
  # call either the ext or ffi hook
20
88
  do_yajl_parse(str, yajl_opts)
21
89
  end
@@ -0,0 +1,29 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright (c) 2013-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ module FFI_Yajl
24
+ module Platform
25
+ def windows?
26
+ !!(RUBY_PLATFORM =~ /mswin|mingw|cygwin|windows/)
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,25 @@
1
+ # Copyright (c) 2015 Lamont Granquist
2
+ # Copyright:: Copyright (c) 2013-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
1
23
  module FFI_Yajl
2
- VERSION = "0.0.1"
24
+ VERSION = "3.0.1".freeze
3
25
  end