diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-06-12 22:48:37 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-06-12 22:48:37 -0700 |
commit | 7a1f2b7c9de07c25046be344ff438048e707a3e3 (patch) | |
tree | 73dbd9f77dd40da0276aa04169c85196d5933a46 /lib | |
parent | b6de464bacfc3aac73d84468a074d2860df8c94f (diff) | |
download | ffi-yajl-7a1f2b7c9de07c25046be344ff438048e707a3e3.tar.gz |
fixing state context in the c extension
just pass self through the context and then access state and ruby
objects through the instance variables.
question? what if the self object is moved by the garbage collector?
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ffi_yajl/ffi/parser.rb | 15 | ||||
-rw-r--r-- | lib/ffi_yajl/parser.rb | 16 |
2 files changed, 16 insertions, 15 deletions
diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb index 6674952..2e21627 100644 --- a/lib/ffi_yajl/ffi/parser.rb +++ b/lib/ffi_yajl/ffi/parser.rb @@ -4,14 +4,6 @@ require 'ffi_yajl/ffi' module FFI_Yajl module FFI module Parser - attr_accessor :stack, :key_stack, :key, :finished - - # - # stack used to build up our complex object - # - def stack - @stack ||= Array.new - end def set_value(val) case stack.last @@ -33,13 +25,6 @@ module FFI_Yajl end end - # - # stack to keep track of keys as we create nested hashes - # - def key_stack - @key_stack ||= Array.new - end - def key_push key_stack.push(key) end diff --git a/lib/ffi_yajl/parser.rb b/lib/ffi_yajl/parser.rb index ca47ed9..6465106 100644 --- a/lib/ffi_yajl/parser.rb +++ b/lib/ffi_yajl/parser.rb @@ -2,8 +2,24 @@ module FFI_Yajl class ParseError < StandardError; end class Parser + attr_accessor :stack, :key_stack, :key, :finished + attr_accessor :opts + # + # stack used to build up our complex object + # + def stack + @stack ||= Array.new + end + + # + # stack to keep track of keys as we create nested hashes + # + def key_stack + @key_stack ||= Array.new + end + def self.parse(obj, *args) new(*args).parse(obj) end |