summaryrefslogtreecommitdiff
path: root/lib/ffi_yajl/ffi/parser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ffi_yajl/ffi/parser.rb')
-rw-r--r--lib/ffi_yajl/ffi/parser.rb11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb
index 77d2389..d0d152a 100644
--- a/lib/ffi_yajl/ffi/parser.rb
+++ b/lib/ffi_yajl/ffi/parser.rb
@@ -23,7 +23,6 @@
module FFI_Yajl
module FFI
module Parser
-
def set_value(val)
case stack.last
when Hash
@@ -50,10 +49,9 @@ module FFI_Yajl
end
def key_pop
- @key = key_stack.pop()
+ @key = key_stack.pop
end
-
def setup_callbacks
@null_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
set_value(nil)
@@ -68,7 +66,7 @@ module FFI_Yajl
1
end
@number_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t ]) do |ctx, stringval, stringlen|
- s = stringval.slice(0,stringlen)
+ s = stringval.slice(0, stringlen)
s.force_encoding('UTF-8') if defined? Encoding
# 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.
v = ( s =~ /[\.eE]/ ) ? s.to_f : s.to_i
@@ -80,7 +78,7 @@ module FFI_Yajl
1
end
@string_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, stringval, stringlen|
- s = stringval.slice(0,stringlen)
+ s = stringval.slice(0, stringlen)
s.force_encoding('UTF-8') if defined? Encoding
set_value(s)
1
@@ -91,7 +89,7 @@ module FFI_Yajl
1
end
@map_key_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, key, keylen|
- s = key.slice(0,keylen)
+ s = key.slice(0, keylen)
s.force_encoding('UTF-8') if defined? Encoding
self.key = @opts[:symbolize_keys] ? s.to_sym : s
1
@@ -113,7 +111,6 @@ module FFI_Yajl
end
end
-
def do_yajl_parse(str, yajl_opts = {})
setup_callbacks
callback_ptr = ::FFI::MemoryPointer.new(::FFI_Yajl::YajlCallbacks)